diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index a8dce3cd0b..d68a0b4b9d 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -19,7 +19,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Balancing { - public static class BalancingChangesManager + public static class BalancingChangesManager { internal static List UniversalBalancingChanges = null; internal static List NPCSpecificBalancingChanges = null; diff --git a/Buffs/Alcohol/AlcoholPoisoning.cs b/Buffs/Alcohol/AlcoholPoisoning.cs index 68b049c383..59e6e2dcc3 100644 --- a/Buffs/Alcohol/AlcoholPoisoning.cs +++ b/Buffs/Alcohol/AlcoholPoisoning.cs @@ -9,11 +9,11 @@ namespace CalamityMod.Buffs.Alcohol { DisplayName.SetDefault("Alcohol Poisoning"); Description.SetDefault("You drank too much and you are now dying"); - Main.debuff[Type] = true; - Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; - canBeCleared = false; - } + Main.debuff[Type] = true; + Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + canBeCleared = false; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/CalamityGlobalBuff.cs b/Buffs/CalamityGlobalBuff.cs index f6cbc5d37a..13b236904d 100644 --- a/Buffs/CalamityGlobalBuff.cs +++ b/Buffs/CalamityGlobalBuff.cs @@ -6,31 +6,31 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs { - public class CalamityGlobalBuff : GlobalBuff + public class CalamityGlobalBuff : GlobalBuff { public override void Update(int type, Player player, ref int buffIndex) { - if (type == BuffID.Endurance) - { - player.endurance -= 0.05f; - } - else if (type == BuffID.MagicPower) - { - player.magicDamage -= 0.1f; - } - else if (type == BuffID.Panic) - { - player.moveSpeed -= 0.5f; - } - else if (type == BuffID.SugarRush) - { - player.moveSpeed -= 0.1f; - } - else if (type == BuffID.Swiftness) - { - player.moveSpeed -= 0.1f; - } - else if (type == BuffID.Shine) + if (type == BuffID.Endurance) + { + player.endurance -= 0.05f; + } + else if (type == BuffID.MagicPower) + { + player.magicDamage -= 0.1f; + } + else if (type == BuffID.Panic) + { + player.moveSpeed -= 0.5f; + } + else if (type == BuffID.SugarRush) + { + player.moveSpeed -= 0.1f; + } + else if (type == BuffID.Swiftness) + { + player.moveSpeed -= 0.1f; + } + else if (type == BuffID.Shine) { player.Calamity().shine = true; } @@ -57,22 +57,22 @@ namespace CalamityMod.Buffs public override void Update(int type, NPC npc, ref int buffIndex) { - if (type == BuffID.Webbed) - { - if (npc.Calamity().webbed < npc.buffTime[buffIndex]) - npc.Calamity().webbed = npc.buffTime[buffIndex]; - if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().webbed; - npc.DelBuff(buffIndex); - buffIndex--; - } + if (type == BuffID.Webbed) + { + if (npc.Calamity().webbed < npc.buffTime[buffIndex]) + npc.Calamity().webbed = npc.buffTime[buffIndex]; + if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().webbed; + npc.DelBuff(buffIndex); + buffIndex--; + } else if (type == BuffID.Slow) { if (npc.Calamity().slowed < npc.buffTime[buffIndex]) npc.Calamity().slowed = npc.buffTime[buffIndex]; - if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().slowed; - npc.DelBuff(buffIndex); + if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().slowed; + npc.DelBuff(buffIndex); buffIndex--; } if (type == BuffID.Electrified) @@ -88,28 +88,28 @@ namespace CalamityMod.Buffs { Player player = Main.player[Main.myPlayer]; - // Vanilla buffs + // Vanilla buffs switch (type) { - case BuffID.Endurance: - tip = "5% reduced damage"; - break; + case BuffID.Endurance: + tip = "5% reduced damage"; + break; - case BuffID.MagicPower: - tip = "10% increased magic damage"; - break; + case BuffID.MagicPower: + tip = "10% increased magic damage"; + break; - case BuffID.Archery: - tip = "20% increased arrow speed and 1.05x arrow damage"; - break; + case BuffID.Archery: + tip = "20% increased arrow speed and 1.05x arrow damage"; + break; - case BuffID.Swiftness: - tip = "15% increased movement speed"; - break; + case BuffID.Swiftness: + tip = "15% increased movement speed"; + break; - case BuffID.SugarRush: - tip = "10% increased movement speed and 20% increased mining speed"; - break; + case BuffID.SugarRush: + tip = "10% increased movement speed and 20% increased mining speed"; + break; case BuffID.NebulaUpDmg1: tip = "7.5% increased damage"; @@ -123,19 +123,19 @@ namespace CalamityMod.Buffs tip = "22.5% increased damage"; break; - case BuffID.BeetleMight1: - tip = "Melee damage increased by 10%"; - break; + case BuffID.BeetleMight1: + tip = "Melee damage increased by 10%"; + break; - case BuffID.BeetleMight2: - tip = "Melee damage increased by 20%"; - break; + case BuffID.BeetleMight2: + tip = "Melee damage increased by 20%"; + break; - case BuffID.BeetleMight3: - tip = "Melee damage increased by 30%"; - break; + case BuffID.BeetleMight3: + tip = "Melee damage increased by 30%"; + break; - case BuffID.BeetleEndurance1: + case BuffID.BeetleEndurance1: tip = "Damage taken reduced by 10%"; break; @@ -170,7 +170,7 @@ namespace CalamityMod.Buffs break; case BuffID.CursedInferno: - tip += ". All damage taken increased by 20%"; + tip += ". All damage taken increased by 20%"; break; case BuffID.Warmth: diff --git a/Buffs/DamageOverTime/AbyssalFlames.cs b/Buffs/DamageOverTime/AbyssalFlames.cs index 02e8e90062..8cd81ba6cb 100644 --- a/Buffs/DamageOverTime/AbyssalFlames.cs +++ b/Buffs/DamageOverTime/AbyssalFlames.cs @@ -23,10 +23,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().aFlames < npc.buffTime[buffIndex]) - npc.Calamity().aFlames = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().aFlames < npc.buffTime[buffIndex]) + npc.Calamity().aFlames = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/AstralInfectionDebuff.cs b/Buffs/DamageOverTime/AstralInfectionDebuff.cs index 6b9eb18f95..51e67816d5 100644 --- a/Buffs/DamageOverTime/AstralInfectionDebuff.cs +++ b/Buffs/DamageOverTime/AstralInfectionDebuff.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().astralInfection < npc.buffTime[buffIndex]) - npc.Calamity().astralInfection = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().astralInfection < npc.buffTime[buffIndex]) + npc.Calamity().astralInfection = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/BanishingFire.cs b/Buffs/DamageOverTime/BanishingFire.cs index 50750405fe..1e182ef7b7 100644 --- a/Buffs/DamageOverTime/BanishingFire.cs +++ b/Buffs/DamageOverTime/BanishingFire.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().banishingFire < npc.buffTime[buffIndex]) - npc.Calamity().banishingFire = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().banishingFire < npc.buffTime[buffIndex]) + npc.Calamity().banishingFire = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/BrimstoneFlames.cs b/Buffs/DamageOverTime/BrimstoneFlames.cs index f25b100141..d14a428d97 100644 --- a/Buffs/DamageOverTime/BrimstoneFlames.cs +++ b/Buffs/DamageOverTime/BrimstoneFlames.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().bFlames < npc.buffTime[buffIndex]) - npc.Calamity().bFlames = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().bFlames < npc.buffTime[buffIndex]) + npc.Calamity().bFlames = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/BurningBlood.cs b/Buffs/DamageOverTime/BurningBlood.cs index 17aa0a8437..6db18910e3 100644 --- a/Buffs/DamageOverTime/BurningBlood.cs +++ b/Buffs/DamageOverTime/BurningBlood.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().bBlood < npc.buffTime[buffIndex]) - npc.Calamity().bBlood = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().bBlood < npc.buffTime[buffIndex]) + npc.Calamity().bBlood = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/CrushDepth.cs b/Buffs/DamageOverTime/CrushDepth.cs index 0b63b68f55..120f031ca3 100644 --- a/Buffs/DamageOverTime/CrushDepth.cs +++ b/Buffs/DamageOverTime/CrushDepth.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().cDepth < npc.buffTime[buffIndex]) - npc.Calamity().cDepth = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().cDepth < npc.buffTime[buffIndex]) + npc.Calamity().cDepth = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/DemonFlames.cs b/Buffs/DamageOverTime/DemonFlames.cs index 2a370bbc21..1ccf79aa9e 100644 --- a/Buffs/DamageOverTime/DemonFlames.cs +++ b/Buffs/DamageOverTime/DemonFlames.cs @@ -17,10 +17,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().dFlames < npc.buffTime[buffIndex]) - npc.Calamity().dFlames = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().dFlames < npc.buffTime[buffIndex]) + npc.Calamity().dFlames = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/GodSlayerInferno.cs b/Buffs/DamageOverTime/GodSlayerInferno.cs index 76b7335b36..89c97ee4ef 100644 --- a/Buffs/DamageOverTime/GodSlayerInferno.cs +++ b/Buffs/DamageOverTime/GodSlayerInferno.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().gsInferno < npc.buffTime[buffIndex]) - npc.Calamity().gsInferno = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().gsInferno < npc.buffTime[buffIndex]) + npc.Calamity().gsInferno = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/HolyFlames.cs b/Buffs/DamageOverTime/HolyFlames.cs index 9c08d139f3..0774575b57 100644 --- a/Buffs/DamageOverTime/HolyFlames.cs +++ b/Buffs/DamageOverTime/HolyFlames.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().hFlames < npc.buffTime[buffIndex]) - npc.Calamity().hFlames = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().hFlames < npc.buffTime[buffIndex]) + npc.Calamity().hFlames = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/Nightwither.cs b/Buffs/DamageOverTime/Nightwither.cs index 931cc9b8de..d7563521f5 100644 --- a/Buffs/DamageOverTime/Nightwither.cs +++ b/Buffs/DamageOverTime/Nightwither.cs @@ -17,10 +17,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().nightwither < npc.buffTime[buffIndex]) - npc.Calamity().nightwither = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().nightwither < npc.buffTime[buffIndex]) + npc.Calamity().nightwither = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/DamageOverTime/Plague.cs b/Buffs/DamageOverTime/Plague.cs index 4090a54712..dd95c370bc 100644 --- a/Buffs/DamageOverTime/Plague.cs +++ b/Buffs/DamageOverTime/Plague.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().pFlames < npc.buffTime[buffIndex]) - npc.Calamity().pFlames = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().pFlames < npc.buffTime[buffIndex]) + npc.Calamity().pFlames = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/ShellfishEating.cs b/Buffs/DamageOverTime/ShellfishEating.cs index 47540279c0..e3a16ae5c7 100644 --- a/Buffs/DamageOverTime/ShellfishEating.cs +++ b/Buffs/DamageOverTime/ShellfishEating.cs @@ -16,10 +16,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().shellfishVore < npc.buffTime[buffIndex]) - npc.Calamity().shellfishVore = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().shellfishVore < npc.buffTime[buffIndex]) + npc.Calamity().shellfishVore = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/SnapClamDebuff.cs b/Buffs/DamageOverTime/SnapClamDebuff.cs index 34ac6157ec..c7049a673a 100644 --- a/Buffs/DamageOverTime/SnapClamDebuff.cs +++ b/Buffs/DamageOverTime/SnapClamDebuff.cs @@ -16,10 +16,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().clamDebuff < npc.buffTime[buffIndex]) - npc.Calamity().clamDebuff = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().clamDebuff < npc.buffTime[buffIndex]) + npc.Calamity().clamDebuff = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/SulphuricPoisoning.cs b/Buffs/DamageOverTime/SulphuricPoisoning.cs index 174a3054d3..3ce4eab8ad 100644 --- a/Buffs/DamageOverTime/SulphuricPoisoning.cs +++ b/Buffs/DamageOverTime/SulphuricPoisoning.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().sulphurPoison < npc.buffTime[buffIndex]) - npc.Calamity().sulphurPoison = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().sulphurPoison < npc.buffTime[buffIndex]) + npc.Calamity().sulphurPoison = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/DamageOverTime/Vaporfied.cs b/Buffs/DamageOverTime/Vaporfied.cs index a2398cbde3..29e3cbfc39 100644 --- a/Buffs/DamageOverTime/Vaporfied.cs +++ b/Buffs/DamageOverTime/Vaporfied.cs @@ -18,13 +18,13 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().vaporfied < npc.buffTime[buffIndex]) - npc.Calamity().vaporfied = npc.buffTime[buffIndex]; - if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().vaporfied; - npc.DelBuff(buffIndex); - buffIndex--; - } + if (npc.Calamity().vaporfied < npc.buffTime[buffIndex]) + npc.Calamity().vaporfied = npc.buffTime[buffIndex]; + if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().vaporfied; + npc.DelBuff(buffIndex); + buffIndex--; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Mounts/AndromedaSmallBuff.cs b/Buffs/Mounts/AndromedaSmallBuff.cs index a33dd40e35..72856d744f 100644 --- a/Buffs/Mounts/AndromedaSmallBuff.cs +++ b/Buffs/Mounts/AndromedaSmallBuff.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.Mounts { - public class AndromedaSmallBuff : ModBuff + public class AndromedaSmallBuff : ModBuff { public override void SetDefaults() { diff --git a/Buffs/Mounts/DoGCartBuff.cs b/Buffs/Mounts/DoGCartBuff.cs index 4f0b762736..9e2b5390c1 100644 --- a/Buffs/Mounts/DoGCartBuff.cs +++ b/Buffs/Mounts/DoGCartBuff.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.Mounts { - public class DoGCartBuff : ModBuff + public class DoGCartBuff : ModBuff { public override void SetDefaults() { diff --git a/Buffs/Pets/PineappleBuff.cs b/Buffs/Pets/PineappleBuff.cs index acdbb282ec..f7df037f00 100644 --- a/Buffs/Pets/PineappleBuff.cs +++ b/Buffs/Pets/PineappleBuff.cs @@ -5,25 +5,25 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.Pets { - public class PineappleBuff : ModBuff - { - public override void SetDefaults() - { - DisplayName.SetDefault("Pineapple"); - Description.SetDefault("It smells like pizza..."); - Main.buffNoTimeDisplay[Type] = true; - Main.vanityPet[Type] = true; - } + public class PineappleBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Pineapple"); + Description.SetDefault("It smells like pizza..."); + Main.buffNoTimeDisplay[Type] = true; + Main.vanityPet[Type] = true; + } - public override void Update(Player player, ref int buffIndex) - { - player.buffTime[buffIndex] = 18000; - player.Calamity().pineapplePet = true; - bool PetProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; - if (PetProjectileNotSpawned && player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); - } - } - } + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + player.Calamity().pineapplePet = true; + bool PetProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + if (PetProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); + } + } + } } diff --git a/Buffs/Pets/PlaguebringerBabBuff.cs b/Buffs/Pets/PlaguebringerBabBuff.cs index 0aca49804d..682d65ff6d 100644 --- a/Buffs/Pets/PlaguebringerBabBuff.cs +++ b/Buffs/Pets/PlaguebringerBabBuff.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Buffs.Pets if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) { int bee = Projectile.NewProjectile(player.position.X + (float)(player.width / 2), player.position.Y + (float)(player.height / 2), 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); - Main.projectile[bee].frame = 2; + Main.projectile[bee].frame = 2; } } } diff --git a/Buffs/Pets/ReaverOrbBuff.cs b/Buffs/Pets/ReaverOrbBuff.cs index 98fb1ba970..b6c243e9aa 100644 --- a/Buffs/Pets/ReaverOrbBuff.cs +++ b/Buffs/Pets/ReaverOrbBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Pets Description.SetDefault("The reaver orb will light your way"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Pets/RotomBuff.cs b/Buffs/Pets/RotomBuff.cs index fe3f71b6cb..df0ad77cd7 100644 --- a/Buffs/Pets/RotomBuff.cs +++ b/Buffs/Pets/RotomBuff.cs @@ -5,25 +5,25 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.Pets { - public class RotomBuff : ModBuff - { - public override void SetDefaults() - { - DisplayName.SetDefault("Electric Troublemaker"); - Description.SetDefault("Lightning never strikes the same place twice"); - Main.buffNoTimeDisplay[Type] = true; - Main.vanityPet[Type] = true; - } + public class RotomBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Electric Troublemaker"); + Description.SetDefault("Lightning never strikes the same place twice"); + Main.buffNoTimeDisplay[Type] = true; + Main.vanityPet[Type] = true; + } - public override void Update(Player player, ref int buffIndex) - { - player.buffTime[buffIndex] = 18000; - player.Calamity().rotomPet = true; - bool PetProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; - if (PetProjectileNotSpawned && player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); - } - } - } + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + player.Calamity().rotomPet = true; + bool PetProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + if (PetProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); + } + } + } } diff --git a/Buffs/Placeables/YellowDamageCandle.cs b/Buffs/Placeables/YellowDamageCandle.cs index 64a99338f2..0b7dd4348a 100644 --- a/Buffs/Placeables/YellowDamageCandle.cs +++ b/Buffs/Placeables/YellowDamageCandle.cs @@ -24,10 +24,10 @@ namespace CalamityMod.Buffs.Placeables public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().yellowCandle < npc.buffTime[buffIndex]) - npc.Calamity().yellowCandle = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().yellowCandle < npc.buffTime[buffIndex]) + npc.Calamity().yellowCandle = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/Potions/PenumbraBuff.cs b/Buffs/Potions/PenumbraBuff.cs index 371d848858..b1127349a0 100644 --- a/Buffs/Potions/PenumbraBuff.cs +++ b/Buffs/Potions/PenumbraBuff.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Buffs.Potions DisplayName.SetDefault("Penumbra"); Description.SetDefault("Stealth regenerates 15% faster while moving\n" + "At night, stealth additionally regenerates 15% faster while standing still\n" + - "Both boosts increase to 20% during a solar eclipse"); + "Both boosts increase to 20% during a solar eclipse"); Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; diff --git a/Buffs/Potions/ShadowBuff.cs b/Buffs/Potions/ShadowBuff.cs index 34e1da15ef..3184e8210b 100644 --- a/Buffs/Potions/ShadowBuff.cs +++ b/Buffs/Potions/ShadowBuff.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Buffs.Potions public override void Update(Player player, ref int buffIndex) { - player.invis = true; + player.invis = true; player.Calamity().shadow = true; } } diff --git a/Buffs/Potions/Soaring.cs b/Buffs/Potions/Soaring.cs index c881cf16a9..c302c0ced4 100644 --- a/Buffs/Potions/Soaring.cs +++ b/Buffs/Potions/Soaring.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Buffs.Potions { DisplayName.SetDefault("Soaring"); Description.SetDefault("Increased wing flight time and speed\n" + - "True melee hits restore wing flight time"); + "True melee hits restore wing flight time"); Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; diff --git a/Buffs/Potions/TeslaBuff.cs b/Buffs/Potions/TeslaBuff.cs index a4d3d6bd93..d72c8f05f3 100644 --- a/Buffs/Potions/TeslaBuff.cs +++ b/Buffs/Potions/TeslaBuff.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.Potions { - public class TeslaBuff : ModBuff + public class TeslaBuff : ModBuff { public override void SetDefaults() { diff --git a/Buffs/StatBuffs/AbyssalMadness.cs b/Buffs/StatBuffs/AbyssalMadness.cs index 3e71d5819e..6f7ff9d49b 100644 --- a/Buffs/StatBuffs/AbyssalMadness.cs +++ b/Buffs/StatBuffs/AbyssalMadness.cs @@ -16,9 +16,9 @@ namespace CalamityMod.Buffs.StatBuffs canBeCleared = false; } - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().omegaBlueHentai = true; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().omegaBlueHentai = true; + } + } } diff --git a/Buffs/StatBuffs/AdrenalineMode.cs b/Buffs/StatBuffs/AdrenalineMode.cs index 78752bc5f9..515eb75b3b 100644 --- a/Buffs/StatBuffs/AdrenalineMode.cs +++ b/Buffs/StatBuffs/AdrenalineMode.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.StatBuffs { - public class AdrenalineMode : ModBuff + public class AdrenalineMode : ModBuff { public override void SetDefaults() { @@ -16,7 +16,7 @@ namespace CalamityMod.Buffs.StatBuffs canBeCleared = false; } - public override void Update(Player player, ref int buffIndex) + public override void Update(Player player, ref int buffIndex) { player.Calamity().adrenalineModeActive = true; } diff --git a/Buffs/StatBuffs/Afflicted.cs b/Buffs/StatBuffs/Afflicted.cs index 2a6b9ec8c0..84a37d60fa 100644 --- a/Buffs/StatBuffs/Afflicted.cs +++ b/Buffs/StatBuffs/Afflicted.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; + Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/AvertorBonus.cs b/Buffs/StatBuffs/AvertorBonus.cs index 81b1f5f6d2..ebbb822c26 100644 --- a/Buffs/StatBuffs/AvertorBonus.cs +++ b/Buffs/StatBuffs/AvertorBonus.cs @@ -15,9 +15,9 @@ namespace CalamityMod.Buffs.StatBuffs longerExpertDebuff = false; } - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().avertorBonus = true; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().avertorBonus = true; + } + } } diff --git a/Buffs/StatBuffs/BloodflareBloodFrenzy.cs b/Buffs/StatBuffs/BloodflareBloodFrenzy.cs index a8d4390850..bf46dc7499 100644 --- a/Buffs/StatBuffs/BloodflareBloodFrenzy.cs +++ b/Buffs/StatBuffs/BloodflareBloodFrenzy.cs @@ -16,9 +16,9 @@ namespace CalamityMod.Buffs.StatBuffs canBeCleared = false; } - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().bloodflareFrenzy = true; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().bloodflareFrenzy = true; + } + } } diff --git a/Buffs/StatBuffs/BloodyBoost.cs b/Buffs/StatBuffs/BloodyBoost.cs index 3f2d09b79c..7b996b8a7e 100644 --- a/Buffs/StatBuffs/BloodyBoost.cs +++ b/Buffs/StatBuffs/BloodyBoost.cs @@ -9,16 +9,16 @@ namespace CalamityMod.Buffs.StatBuffs { DisplayName.SetDefault("Bloody Boost"); Description.SetDefault("Increased offensive and defensive stats\n" + - "Healing potions grant more health"); + "Healing potions grant more health"); Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; longerExpertDebuff = false; } - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().bloodPactBoost = true; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().bloodPactBoost = true; + } + } } diff --git a/Buffs/StatBuffs/BossZen.cs b/Buffs/StatBuffs/BossZen.cs index 65d46ea30c..8745f40d5b 100644 --- a/Buffs/StatBuffs/BossZen.cs +++ b/Buffs/StatBuffs/BossZen.cs @@ -10,23 +10,23 @@ namespace CalamityMod.Buffs.StatBuffs DisplayName.SetDefault("Boss Effects"); Description.SetDefault("This tooltip is edited in the function below"); Main.debuff[Type] = true; - Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; - canBeCleared = false; - } + Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + canBeCleared = false; + } public override void Update(Player player, ref int buffIndex) { player.Calamity().bossZen = true; } - public override void ModifyBuffTip(ref string tip, ref int rare) - { - tip = "The nearby boss is:\n" + - "Greatly reducing enemy spawn rates\n" + - "Disabling teleportation effects\n" + - "Increasing Nurse healing cost by 400%\n" + - "Disabling Target and Super Dummy hitboxes"; - } - } + public override void ModifyBuffTip(ref string tip, ref int rare) + { + tip = "The nearby boss is:\n" + + "Greatly reducing enemy spawn rates\n" + + "Disabling teleportation effects\n" + + "Increasing Nurse healing cost by 400%\n" + + "Disabling Target and Super Dummy hitboxes"; + } + } } diff --git a/Buffs/StatBuffs/BrimflameFrenzyBuff.cs b/Buffs/StatBuffs/BrimflameFrenzyBuff.cs index 3cff4e9497..2e4f3fca94 100644 --- a/Buffs/StatBuffs/BrimflameFrenzyBuff.cs +++ b/Buffs/StatBuffs/BrimflameFrenzyBuff.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.StatBuffs { - public class BrimflameFrenzyBuff : ModBuff + public class BrimflameFrenzyBuff : ModBuff { public override void SetDefaults() { diff --git a/Buffs/StatBuffs/ElysianGuard.cs b/Buffs/StatBuffs/ElysianGuard.cs index b10c1883bd..d6dc282b36 100644 --- a/Buffs/StatBuffs/ElysianGuard.cs +++ b/Buffs/StatBuffs/ElysianGuard.cs @@ -12,9 +12,9 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; - longerExpertDebuff = false; + Main.buffNoTimeDisplay[Type] = true; + longerExpertDebuff = false; canBeCleared = false; } - } + } } diff --git a/Buffs/StatBuffs/HallowedRuneAtkBuff.cs b/Buffs/StatBuffs/HallowedRuneAtkBuff.cs index cda8a37727..876a2b24ff 100644 --- a/Buffs/StatBuffs/HallowedRuneAtkBuff.cs +++ b/Buffs/StatBuffs/HallowedRuneAtkBuff.cs @@ -12,14 +12,14 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; + Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().hallowedPower = true; - player.minionDamage += 0.1f; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().hallowedPower = true; + player.minionDamage += 0.1f; + } + } } diff --git a/Buffs/StatBuffs/HallowedRuneDefBuff.cs b/Buffs/StatBuffs/HallowedRuneDefBuff.cs index 4856abe2bf..fd4b8c8436 100644 --- a/Buffs/StatBuffs/HallowedRuneDefBuff.cs +++ b/Buffs/StatBuffs/HallowedRuneDefBuff.cs @@ -12,14 +12,14 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; + Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } public override void Update(Player player, ref int buffIndex) { - player.statDefense += 8; - player.endurance += 0.04f; - } + player.statDefense += 8; + player.endurance += 0.04f; + } } } diff --git a/Buffs/StatBuffs/HallowedRuneRegenBuff.cs b/Buffs/StatBuffs/HallowedRuneRegenBuff.cs index c85e46f920..d69e28bc8a 100644 --- a/Buffs/StatBuffs/HallowedRuneRegenBuff.cs +++ b/Buffs/StatBuffs/HallowedRuneRegenBuff.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; + Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/KamiBuff.cs b/Buffs/StatBuffs/KamiBuff.cs index c13e4f3af0..444b09cd92 100644 --- a/Buffs/StatBuffs/KamiBuff.cs +++ b/Buffs/StatBuffs/KamiBuff.cs @@ -20,8 +20,8 @@ namespace CalamityMod.Buffs.StatBuffs public override void Update(Player player, ref int buffIndex) { player.Calamity().kamiBoost = true; - if (player.buffTime[buffIndex] == 1) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YanmeiKnifeExpire"), player.Center); + if (player.buffTime[buffIndex] == 1) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YanmeiKnifeExpire"), player.Center); } } } diff --git a/Buffs/StatBuffs/Molten.cs b/Buffs/StatBuffs/Molten.cs index d175eb5847..35f8accd59 100644 --- a/Buffs/StatBuffs/Molten.cs +++ b/Buffs/StatBuffs/Molten.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.StatBuffs { - public class Molten : ModBuff + public class Molten : ModBuff { public override void SetDefaults() { diff --git a/Buffs/StatBuffs/PhantomicArmourBuff.cs b/Buffs/StatBuffs/PhantomicArmourBuff.cs index 4b44ef4120..85327fb561 100644 --- a/Buffs/StatBuffs/PhantomicArmourBuff.cs +++ b/Buffs/StatBuffs/PhantomicArmourBuff.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.StatBuffs { - class PhantomicArmourBuff : ModBuff + class PhantomicArmourBuff : ModBuff { public override void SetDefaults() { @@ -13,7 +13,7 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; + Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/PhantomicEmpowermentBuff.cs b/Buffs/StatBuffs/PhantomicEmpowermentBuff.cs index 49b82c8ebb..fe78a8f2af 100644 --- a/Buffs/StatBuffs/PhantomicEmpowermentBuff.cs +++ b/Buffs/StatBuffs/PhantomicEmpowermentBuff.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.StatBuffs { - class PhantomicEmpowermentBuff : ModBuff + class PhantomicEmpowermentBuff : ModBuff { public override void SetDefaults() { @@ -12,7 +12,7 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; + Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/PhantomicRestorationBuff.cs b/Buffs/StatBuffs/PhantomicRestorationBuff.cs index b9c7a65f5a..ace3972774 100644 --- a/Buffs/StatBuffs/PhantomicRestorationBuff.cs +++ b/Buffs/StatBuffs/PhantomicRestorationBuff.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; + Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/PolarisBuff.cs b/Buffs/StatBuffs/PolarisBuff.cs index 4654acdc1b..79ec4f9a15 100644 --- a/Buffs/StatBuffs/PolarisBuff.cs +++ b/Buffs/StatBuffs/PolarisBuff.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; + Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/ProfanedCrystalBuff.cs b/Buffs/StatBuffs/ProfanedCrystalBuff.cs index 9a3cf2b919..66222340ed 100644 --- a/Buffs/StatBuffs/ProfanedCrystalBuff.cs +++ b/Buffs/StatBuffs/ProfanedCrystalBuff.cs @@ -27,34 +27,34 @@ namespace CalamityMod.Buffs.StatBuffs public override void ModifyBuffTip(ref string tip, ref int rare) { Player player = Main.player[Main.myPlayer]; - if (player.Calamity().profanedCrystalBuffs) - { - if (player.Calamity().endoCooper) - { - tip = "An ascended ice construct is suppressing your true potential.."; - } - else if (player.Calamity().magicHat) - { - tip = "A magical hat overwhelms your senses, squandering your true potential.."; - } - else - { - bool offense = (Main.dayTime && !player.wet) || player.lavaWet; - bool enrage = player.statLife <= (int)(player.statLifeMax2 * 0.5); - tip = "You are an emissary of the profaned goddess now!\n" + - (offense ? "The " + (Main.dayTime ? "light of the sun" : "heat of the lava") + " empowers your offensive capabilities" : - "The " + (player.wet ? (player.honeyWet ? "honey cools" : "water douses") : "darkness of night cools") + " your flames, empowering your defensive capabilities") + - (enrage ? "\nYour weakened life force fuels your desperate attacks" : ""); - } - } - else if (CalamityWorld.downedSCal && CalamityWorld.downedExoMechs) - { - tip = "Your profaned soul is constrained by your insufficient summoning powers"; - } - else - { - tip = !CalamityWorld.downedExoMechs ? "The soul within this crystal has been defiled by overwhelming energy waves from dangerous mechanations" : "The profaned soul within has been defiled by the powerful magic of a supreme witch"; - } - } + if (player.Calamity().profanedCrystalBuffs) + { + if (player.Calamity().endoCooper) + { + tip = "An ascended ice construct is suppressing your true potential.."; + } + else if (player.Calamity().magicHat) + { + tip = "A magical hat overwhelms your senses, squandering your true potential.."; + } + else + { + bool offense = (Main.dayTime && !player.wet) || player.lavaWet; + bool enrage = player.statLife <= (int)(player.statLifeMax2 * 0.5); + tip = "You are an emissary of the profaned goddess now!\n" + + (offense ? "The " + (Main.dayTime ? "light of the sun" : "heat of the lava") + " empowers your offensive capabilities" : + "The " + (player.wet ? (player.honeyWet ? "honey cools" : "water douses") : "darkness of night cools") + " your flames, empowering your defensive capabilities") + + (enrage ? "\nYour weakened life force fuels your desperate attacks" : ""); + } + } + else if (CalamityWorld.downedSCal && CalamityWorld.downedExoMechs) + { + tip = "Your profaned soul is constrained by your insufficient summoning powers"; + } + else + { + tip = !CalamityWorld.downedExoMechs ? "The soul within this crystal has been defiled by overwhelming energy waves from dangerous mechanations" : "The profaned soul within has been defiled by the powerful magic of a supreme witch"; + } + } } } diff --git a/Buffs/StatBuffs/RageMode.cs b/Buffs/StatBuffs/RageMode.cs index 1d691878c7..c60767bfe3 100644 --- a/Buffs/StatBuffs/RageMode.cs +++ b/Buffs/StatBuffs/RageMode.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Buffs.StatBuffs // Otherwise, Rage Mode ends instantly. else { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AbilitySounds/RageEnd"), player.position); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AbilitySounds/RageEnd"), player.position); player.DelBuff(buffIndex--); // TML documentation requires you to decrement buffIndex if deleting the buff during Update. mp.rageModeActive = false; mp.rage = 0f; diff --git a/Buffs/StatBuffs/SpiritGeneratorAtkBuff.cs b/Buffs/StatBuffs/SpiritGeneratorAtkBuff.cs index 50a4402d21..360862743a 100644 --- a/Buffs/StatBuffs/SpiritGeneratorAtkBuff.cs +++ b/Buffs/StatBuffs/SpiritGeneratorAtkBuff.cs @@ -12,13 +12,13 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; + Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } - public override void Update(Player player, ref int buffIndex) - { - player.minionDamage += 0.1f; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.minionDamage += 0.1f; + } + } } diff --git a/Buffs/StatBuffs/SpiritGeneratorDefBuff.cs b/Buffs/StatBuffs/SpiritGeneratorDefBuff.cs index d4136d4bc4..4e2ad33344 100644 --- a/Buffs/StatBuffs/SpiritGeneratorDefBuff.cs +++ b/Buffs/StatBuffs/SpiritGeneratorDefBuff.cs @@ -12,14 +12,14 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; + Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } public override void Update(Player player, ref int buffIndex) { - player.statDefense += 6; - player.endurance += 0.03f; - } + player.statDefense += 6; + player.endurance += 0.03f; + } } } diff --git a/Buffs/StatBuffs/SpiritGeneratorRegenBuff.cs b/Buffs/StatBuffs/SpiritGeneratorRegenBuff.cs index 738fca831e..9ce3a3038c 100644 --- a/Buffs/StatBuffs/SpiritGeneratorRegenBuff.cs +++ b/Buffs/StatBuffs/SpiritGeneratorRegenBuff.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; + Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/TarragonCloak.cs b/Buffs/StatBuffs/TarragonCloak.cs index 7dceada438..0fd7e3448a 100644 --- a/Buffs/StatBuffs/TarragonCloak.cs +++ b/Buffs/StatBuffs/TarragonCloak.cs @@ -16,9 +16,9 @@ namespace CalamityMod.Buffs.StatBuffs canBeCleared = false; } - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().tarragonCloak = true; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().tarragonCloak = true; + } + } } diff --git a/Buffs/StatBuffs/TarragonImmunity.cs b/Buffs/StatBuffs/TarragonImmunity.cs index 2d6cd18ce4..4552ffc727 100644 --- a/Buffs/StatBuffs/TarragonImmunity.cs +++ b/Buffs/StatBuffs/TarragonImmunity.cs @@ -16,9 +16,9 @@ namespace CalamityMod.Buffs.StatBuffs canBeCleared = false; } - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().tarragonImmunity = true; - } - } + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().tarragonImmunity = true; + } + } } diff --git a/Buffs/StatDebuffs/ArmorCrunch.cs b/Buffs/StatDebuffs/ArmorCrunch.cs index 1e5461009b..7aecebe2a2 100644 --- a/Buffs/StatDebuffs/ArmorCrunch.cs +++ b/Buffs/StatDebuffs/ArmorCrunch.cs @@ -20,10 +20,10 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().aCrunch < npc.buffTime[buffIndex]) - npc.Calamity().aCrunch = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().aCrunch < npc.buffTime[buffIndex]) + npc.Calamity().aCrunch = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/StatDebuffs/Enraged.cs b/Buffs/StatDebuffs/Enraged.cs index db53b710b4..4a55ec7231 100644 --- a/Buffs/StatDebuffs/Enraged.cs +++ b/Buffs/StatDebuffs/Enraged.cs @@ -23,10 +23,10 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().enraged < npc.buffTime[buffIndex]) - npc.Calamity().enraged = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().enraged < npc.buffTime[buffIndex]) + npc.Calamity().enraged = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/StatDebuffs/Eutrophication.cs b/Buffs/StatDebuffs/Eutrophication.cs index 6041669534..53510221a4 100644 --- a/Buffs/StatDebuffs/Eutrophication.cs +++ b/Buffs/StatDebuffs/Eutrophication.cs @@ -18,12 +18,12 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().eutrophication < npc.buffTime[buffIndex]) - npc.Calamity().eutrophication = npc.buffTime[buffIndex]; - if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().eutrophication; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().eutrophication < npc.buffTime[buffIndex]) + npc.Calamity().eutrophication = npc.buffTime[buffIndex]; + if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().eutrophication; + npc.DelBuff(buffIndex); + buffIndex--; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/StatDebuffs/ExoFreeze.cs b/Buffs/StatDebuffs/ExoFreeze.cs index a28b0b02c7..5b490f26e9 100644 --- a/Buffs/StatDebuffs/ExoFreeze.cs +++ b/Buffs/StatDebuffs/ExoFreeze.cs @@ -18,12 +18,12 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().eFreeze < npc.buffTime[buffIndex]) - npc.Calamity().eFreeze = npc.buffTime[buffIndex]; - if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().eFreeze; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().eFreeze < npc.buffTime[buffIndex]) + npc.Calamity().eFreeze = npc.buffTime[buffIndex]; + if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().eFreeze; + npc.DelBuff(buffIndex); + buffIndex--; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/StatDebuffs/GlacialState.cs b/Buffs/StatDebuffs/GlacialState.cs index da0a4b58e4..1cb543f523 100644 --- a/Buffs/StatDebuffs/GlacialState.cs +++ b/Buffs/StatDebuffs/GlacialState.cs @@ -23,12 +23,12 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().gState < npc.buffTime[buffIndex]) - npc.Calamity().gState = npc.buffTime[buffIndex]; - if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().gState; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().gState < npc.buffTime[buffIndex]) + npc.Calamity().gState = npc.buffTime[buffIndex]; + if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().gState; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/StatDebuffs/Irradiated.cs b/Buffs/StatDebuffs/Irradiated.cs index 1a2df34e2b..458b9887c5 100644 --- a/Buffs/StatDebuffs/Irradiated.cs +++ b/Buffs/StatDebuffs/Irradiated.cs @@ -23,10 +23,10 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().irradiated < npc.buffTime[buffIndex]) - npc.Calamity().irradiated = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().irradiated < npc.buffTime[buffIndex]) + npc.Calamity().irradiated = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/StatDebuffs/KamiDebuff.cs b/Buffs/StatDebuffs/KamiDebuff.cs index 66203d38ce..e29040ef6d 100644 --- a/Buffs/StatDebuffs/KamiDebuff.cs +++ b/Buffs/StatDebuffs/KamiDebuff.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.StatDebuffs { - public class KamiDebuff : ModBuff + public class KamiDebuff : ModBuff { public const float MultiplicativeDamageReduction = 0.8f; // Hard-cap for npc speed when afflicted with this debuff. Does not affect certain NPCs and does not affect any bosses (Basically only works on boss minions). @@ -22,12 +22,12 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().kamiFlu < npc.buffTime[buffIndex]) - npc.Calamity().kamiFlu = npc.buffTime[buffIndex]; - if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().kamiFlu; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().kamiFlu < npc.buffTime[buffIndex]) + npc.Calamity().kamiFlu = npc.buffTime[buffIndex]; + if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().kamiFlu; + npc.DelBuff(buffIndex); + buffIndex--; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/StatDebuffs/MarkedforDeath.cs b/Buffs/StatDebuffs/MarkedforDeath.cs index 6f56f672ff..0f7ec2f986 100644 --- a/Buffs/StatDebuffs/MarkedforDeath.cs +++ b/Buffs/StatDebuffs/MarkedforDeath.cs @@ -19,10 +19,10 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().marked < npc.buffTime[buffIndex]) - npc.Calamity().marked = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().marked < npc.buffTime[buffIndex]) + npc.Calamity().marked = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/StatDebuffs/PearlAura.cs b/Buffs/StatDebuffs/PearlAura.cs index 176563792e..328aed6b5a 100644 --- a/Buffs/StatDebuffs/PearlAura.cs +++ b/Buffs/StatDebuffs/PearlAura.cs @@ -16,10 +16,10 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().pearlAura < npc.buffTime[buffIndex]) - npc.Calamity().pearlAura = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().pearlAura < npc.buffTime[buffIndex]) + npc.Calamity().pearlAura = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/StatDebuffs/TemporalSadness.cs b/Buffs/StatDebuffs/TemporalSadness.cs index a98e113444..196883779e 100644 --- a/Buffs/StatDebuffs/TemporalSadness.cs +++ b/Buffs/StatDebuffs/TemporalSadness.cs @@ -18,12 +18,12 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().tSad < npc.buffTime[buffIndex]) - npc.Calamity().tSad = npc.buffTime[buffIndex]; - if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().tSad; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().tSad < npc.buffTime[buffIndex]) + npc.Calamity().tSad = npc.buffTime[buffIndex]; + if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().tSad; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/StatDebuffs/TeslaFreeze.cs b/Buffs/StatDebuffs/TeslaFreeze.cs index 633211b0b5..31e64000da 100644 --- a/Buffs/StatDebuffs/TeslaFreeze.cs +++ b/Buffs/StatDebuffs/TeslaFreeze.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.StatDebuffs { - public class TeslaFreeze : ModBuff + public class TeslaFreeze : ModBuff { public override void SetDefaults() { @@ -18,12 +18,12 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().tesla < npc.buffTime[buffIndex]) - npc.Calamity().tesla = npc.buffTime[buffIndex]; - if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().tesla; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().tesla < npc.buffTime[buffIndex]) + npc.Calamity().tesla = npc.buffTime[buffIndex]; + if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().tesla; + npc.DelBuff(buffIndex); + buffIndex--; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/StatDebuffs/TimeSlow.cs b/Buffs/StatDebuffs/TimeSlow.cs index fad83a3d71..cf072806ce 100644 --- a/Buffs/StatDebuffs/TimeSlow.cs +++ b/Buffs/StatDebuffs/TimeSlow.cs @@ -19,12 +19,12 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().timeSlow < npc.buffTime[buffIndex]) - npc.Calamity().timeSlow = npc.buffTime[buffIndex]; - if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().timeSlow; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().timeSlow < npc.buffTime[buffIndex]) + npc.Calamity().timeSlow = npc.buffTime[buffIndex]; + if ((CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().timeSlow; + npc.DelBuff(buffIndex); + buffIndex--; } /*public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/StatDebuffs/WarCleave.cs b/Buffs/StatDebuffs/WarCleave.cs index 4ff463e10d..eb7edfe3ad 100644 --- a/Buffs/StatDebuffs/WarCleave.cs +++ b/Buffs/StatDebuffs/WarCleave.cs @@ -19,10 +19,10 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().wCleave < npc.buffTime[buffIndex]) - npc.Calamity().wCleave = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().wCleave < npc.buffTime[buffIndex]) + npc.Calamity().wCleave = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/StatDebuffs/WhisperingDeath.cs b/Buffs/StatDebuffs/WhisperingDeath.cs index e43c112f7c..d21f0ca879 100644 --- a/Buffs/StatDebuffs/WhisperingDeath.cs +++ b/Buffs/StatDebuffs/WhisperingDeath.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().wDeath < npc.buffTime[buffIndex]) - npc.Calamity().wDeath = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().wDeath < npc.buffTime[buffIndex]) + npc.Calamity().wDeath = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } } } diff --git a/Buffs/StatDebuffs/WitherDebuff.cs b/Buffs/StatDebuffs/WitherDebuff.cs index b07d94d843..cbdbb4d2f9 100644 --- a/Buffs/StatDebuffs/WitherDebuff.cs +++ b/Buffs/StatDebuffs/WitherDebuff.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Buffs.StatDebuffs { DisplayName.SetDefault("Wither"); Description.SetDefault("Withered...\n" + - "Defense reduced by 20"); // Literally Ichor but patron. Also not to be confused with Withered Armor/Weapons + "Defense reduced by 20"); // Literally Ichor but patron. Also not to be confused with Withered Armor/Weapons Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; @@ -20,10 +20,10 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().wither < npc.buffTime[buffIndex]) - npc.Calamity().wither = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + if (npc.Calamity().wither < npc.buffTime[buffIndex]) + npc.Calamity().wither = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/Summon/AerospecSummonSetBuff.cs b/Buffs/Summon/AerospecSummonSetBuff.cs index a95ef8e8f7..bd5f2e7bee 100644 --- a/Buffs/Summon/AerospecSummonSetBuff.cs +++ b/Buffs/Summon/AerospecSummonSetBuff.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The valkyrie will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; + //Main.persistentBuff[Type] = true; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/Summon/ApexSharkBuff.cs b/Buffs/Summon/ApexSharkBuff.cs index 918c599947..36849c6d50 100644 --- a/Buffs/Summon/ApexSharkBuff.cs +++ b/Buffs/Summon/ApexSharkBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Ancient yet so dangerous"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/AquaticStar.cs b/Buffs/Summon/AquaticStar.cs index 4c90da5b18..496cbf47ff 100644 --- a/Buffs/Summon/AquaticStar.cs +++ b/Buffs/Summon/AquaticStar.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The aquatic star will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/AstrageldonBuff.cs b/Buffs/Summon/AstrageldonBuff.cs index 41ffe09314..c977a131ec 100644 --- a/Buffs/Summon/AstrageldonBuff.cs +++ b/Buffs/Summon/AstrageldonBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The mini astrageldon slime will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/AstralProbeBuff.cs b/Buffs/Summon/AstralProbeBuff.cs index ec79cf665c..dac48fe7dd 100644 --- a/Buffs/Summon/AstralProbeBuff.cs +++ b/Buffs/Summon/AstralProbeBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The astral probe will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/AtaxiaSummonSetBuff.cs b/Buffs/Summon/AtaxiaSummonSetBuff.cs index 99db5f664d..350fdeefba 100644 --- a/Buffs/Summon/AtaxiaSummonSetBuff.cs +++ b/Buffs/Summon/AtaxiaSummonSetBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The hydrothermic vent will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/BelladonnaSpiritBuff.cs b/Buffs/Summon/BelladonnaSpiritBuff.cs index d19200e5cc..78993e6f52 100644 --- a/Buffs/Summon/BelladonnaSpiritBuff.cs +++ b/Buffs/Summon/BelladonnaSpiritBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A cute forest spirit is following you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/BlackHawkBuff.cs b/Buffs/Summon/BlackHawkBuff.cs index 2e864b05c6..78ff092d3b 100644 --- a/Buffs/Summon/BlackHawkBuff.cs +++ b/Buffs/Summon/BlackHawkBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The fighter jet will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/BloodClot.cs b/Buffs/Summon/BloodClot.cs index c531351efb..bf8e60993b 100644 --- a/Buffs/Summon/BloodClot.cs +++ b/Buffs/Summon/BloodClot.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The blood clot will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/BloodDragonsBuff.cs b/Buffs/Summon/BloodDragonsBuff.cs index ee0cc8c5ab..e1c0f63a90 100644 --- a/Buffs/Summon/BloodDragonsBuff.cs +++ b/Buffs/Summon/BloodDragonsBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Big happy family"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/BrimstoneWaifu.cs b/Buffs/Summon/BrimstoneWaifu.cs index 6c2abd436d..d96e8335f4 100644 --- a/Buffs/Summon/BrimstoneWaifu.cs +++ b/Buffs/Summon/BrimstoneWaifu.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The brimstone elemental will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/BrittleStar.cs b/Buffs/Summon/BrittleStar.cs index 9c6b0ca3e1..23436ec672 100644 --- a/Buffs/Summon/BrittleStar.cs +++ b/Buffs/Summon/BrittleStar.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The brittle star will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/Calamari.cs b/Buffs/Summon/Calamari.cs index 12878cdac7..0d90a14826 100644 --- a/Buffs/Summon/Calamari.cs +++ b/Buffs/Summon/Calamari.cs @@ -12,8 +12,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The squid will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/CalamitasEyes.cs b/Buffs/Summon/CalamitasEyes.cs index a33ee47b09..5d5906b0cf 100644 --- a/Buffs/Summon/CalamitasEyes.cs +++ b/Buffs/Summon/CalamitasEyes.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Calamitas and her brothers will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/CausticStaffBuff.cs b/Buffs/Summon/CausticStaffBuff.cs index 1ae34f974f..370f0feb26 100644 --- a/Buffs/Summon/CausticStaffBuff.cs +++ b/Buffs/Summon/CausticStaffBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A mini jungle dragon is following you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/CinderBlossomBuff.cs b/Buffs/Summon/CinderBlossomBuff.cs index a4bd4bce5e..e9549d9147 100644 --- a/Buffs/Summon/CinderBlossomBuff.cs +++ b/Buffs/Summon/CinderBlossomBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A hot, searing flower is floating uncomfortably close to you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/CloudyWaifu.cs b/Buffs/Summon/CloudyWaifu.cs index 9dc93e5a53..7e739bd29e 100644 --- a/Buffs/Summon/CloudyWaifu.cs +++ b/Buffs/Summon/CloudyWaifu.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The cloud elemental will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/ColdDivinityBuff.cs b/Buffs/Summon/ColdDivinityBuff.cs index 9a12a2a952..e3e279d58b 100644 --- a/Buffs/Summon/ColdDivinityBuff.cs +++ b/Buffs/Summon/ColdDivinityBuff.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.Summon { - public class ColdDivinityBuff : ModBuff + public class ColdDivinityBuff : ModBuff { public override void SetDefaults() { @@ -12,8 +12,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The magic of the ancient ice castle will aid you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/Corroslime.cs b/Buffs/Summon/Corroslime.cs index 2e382b45a2..5f80a91696 100644 --- a/Buffs/Summon/Corroslime.cs +++ b/Buffs/Summon/Corroslime.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The corroslime will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/CorvidHarbringerBuff.cs b/Buffs/Summon/CorvidHarbringerBuff.cs index ffaaf1234d..84ae1f4c6e 100644 --- a/Buffs/Summon/CorvidHarbringerBuff.cs +++ b/Buffs/Summon/CorvidHarbringerBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The powerful raven will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/CosmicEnergy.cs b/Buffs/Summon/CosmicEnergy.cs index 9cb70f24f5..363167631a 100644 --- a/Buffs/Summon/CosmicEnergy.cs +++ b/Buffs/Summon/CosmicEnergy.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The cosmic energy will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/CosmicViperEngineBuff.cs b/Buffs/Summon/CosmicViperEngineBuff.cs index 83f8987f42..a61500b0cf 100644 --- a/Buffs/Summon/CosmicViperEngineBuff.cs +++ b/Buffs/Summon/CosmicViperEngineBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The cosmic gunship will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/CosmilampBuff.cs b/Buffs/Summon/CosmilampBuff.cs index 77464bc8cd..ac57e51f9b 100644 --- a/Buffs/Summon/CosmilampBuff.cs +++ b/Buffs/Summon/CosmilampBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The cosmilamp will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/Crimslime.cs b/Buffs/Summon/Crimslime.cs index 7fd7a035a3..4f89aa5702 100644 --- a/Buffs/Summon/Crimslime.cs +++ b/Buffs/Summon/Crimslime.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The crimslime will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/DaedalusSummonSetBuff.cs b/Buffs/Summon/DaedalusSummonSetBuff.cs index a6affebc01..0d15f66d40 100644 --- a/Buffs/Summon/DaedalusSummonSetBuff.cs +++ b/Buffs/Summon/DaedalusSummonSetBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The daedalus crystal will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/DankCreeperBuff.cs b/Buffs/Summon/DankCreeperBuff.cs index 9dc3c0a443..b46d4c6f1b 100644 --- a/Buffs/Summon/DankCreeperBuff.cs +++ b/Buffs/Summon/DankCreeperBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The dank creeper will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/DazzlingStabberBuff.cs b/Buffs/Summon/DazzlingStabberBuff.cs index bb6118fe65..e6fd71bff4 100644 --- a/Buffs/Summon/DazzlingStabberBuff.cs +++ b/Buffs/Summon/DazzlingStabberBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("En garde"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/DemonshadeSetDevilBuff.cs b/Buffs/Summon/DemonshadeSetDevilBuff.cs index 51514b57e2..24efeacef1 100644 --- a/Buffs/Summon/DemonshadeSetDevilBuff.cs +++ b/Buffs/Summon/DemonshadeSetDevilBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The red devil will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/DormantBrimseekerBuff.cs b/Buffs/Summon/DormantBrimseekerBuff.cs index 10fd57279a..00e572c307 100644 --- a/Buffs/Summon/DormantBrimseekerBuff.cs +++ b/Buffs/Summon/DormantBrimseekerBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Does it want something from you?"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/ElementalAxeBuff.cs b/Buffs/Summon/ElementalAxeBuff.cs index b3336ea651..56e668a49c 100644 --- a/Buffs/Summon/ElementalAxeBuff.cs +++ b/Buffs/Summon/ElementalAxeBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The elemental axe will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/EndoCooperBuff.cs b/Buffs/Summon/EndoCooperBuff.cs index 5681b1117a..980a6fe36a 100644 --- a/Buffs/Summon/EndoCooperBuff.cs +++ b/Buffs/Summon/EndoCooperBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The ascened Cooper will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/EndoHydraBuff.cs b/Buffs/Summon/EndoHydraBuff.cs index 22c942ca01..587195156d 100644 --- a/Buffs/Summon/EndoHydraBuff.cs +++ b/Buffs/Summon/EndoHydraBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The endo hydra will protect you... for some reason"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/EyeOfNightBuff.cs b/Buffs/Summon/EyeOfNightBuff.cs index db3f86b42b..f820b55ad0 100644 --- a/Buffs/Summon/EyeOfNightBuff.cs +++ b/Buffs/Summon/EyeOfNightBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("It eerily watches"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/FleshOfInfidelityBuff.cs b/Buffs/Summon/FleshOfInfidelityBuff.cs index fea7a77d87..2d55ee5230 100644 --- a/Buffs/Summon/FleshOfInfidelityBuff.cs +++ b/Buffs/Summon/FleshOfInfidelityBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Why is it following you?"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/FrostBlossomBuff.cs b/Buffs/Summon/FrostBlossomBuff.cs index ea3b506cb3..b32c24d843 100644 --- a/Buffs/Summon/FrostBlossomBuff.cs +++ b/Buffs/Summon/FrostBlossomBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A cold, prickly flower is floating uncomfortably close to you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/FuelCellBundleBuff.cs b/Buffs/Summon/FuelCellBundleBuff.cs index ee2d51fb4d..98f65a67d4 100644 --- a/Buffs/Summon/FuelCellBundleBuff.cs +++ b/Buffs/Summon/FuelCellBundleBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A small plague bee is following you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/FungalClumpBuff.cs b/Buffs/Summon/FungalClumpBuff.cs index d863ceb510..d924b87111 100644 --- a/Buffs/Summon/FungalClumpBuff.cs +++ b/Buffs/Summon/FungalClumpBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The fungal clump will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/GammaHeadBuff.cs b/Buffs/Summon/GammaHeadBuff.cs index 750afdbaf6..18ce2b5b88 100644 --- a/Buffs/Summon/GammaHeadBuff.cs +++ b/Buffs/Summon/GammaHeadBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("..."); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/GastricBelcherBuff.cs b/Buffs/Summon/GastricBelcherBuff.cs index fea1b0801f..44a310395c 100644 --- a/Buffs/Summon/GastricBelcherBuff.cs +++ b/Buffs/Summon/GastricBelcherBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The aquatic aberration will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/GladiatorSwords.cs b/Buffs/Summon/GladiatorSwords.cs index d0dcb8e1c2..8737258f8b 100644 --- a/Buffs/Summon/GladiatorSwords.cs +++ b/Buffs/Summon/GladiatorSwords.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The gladiator swords will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/HauntedDishesBuff.cs b/Buffs/Summon/HauntedDishesBuff.cs index 8a7989a18c..fb4d76beae 100644 --- a/Buffs/Summon/HauntedDishesBuff.cs +++ b/Buffs/Summon/HauntedDishesBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The haunted dishes will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/HermitCrab.cs b/Buffs/Summon/HermitCrab.cs index d3a71c9d60..747f206bce 100644 --- a/Buffs/Summon/HermitCrab.cs +++ b/Buffs/Summon/HermitCrab.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The hermit crab will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/Herring.cs b/Buffs/Summon/Herring.cs index fb7ddb02d8..1419a878cf 100644 --- a/Buffs/Summon/Herring.cs +++ b/Buffs/Summon/Herring.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The herring will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/HotE.cs b/Buffs/Summon/HotE.cs index db7f0f970b..5d245e95c3 100644 --- a/Buffs/Summon/HotE.cs +++ b/Buffs/Summon/HotE.cs @@ -11,8 +11,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("All elementals will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/HowlTrio.cs b/Buffs/Summon/HowlTrio.cs index 2feb16d8e2..be1c1bf911 100644 --- a/Buffs/Summon/HowlTrio.cs +++ b/Buffs/Summon/HowlTrio.cs @@ -13,15 +13,15 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Howl protects you, Calcifer lights your way, Turnip-Head stalks you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { CalamityPlayer modPlayer = player.Calamity(); - int howl = ModContent.ProjectileType(); - int calcifer = ModContent.ProjectileType(); - int turnip = ModContent.ProjectileType(); + int howl = ModContent.ProjectileType(); + int calcifer = ModContent.ProjectileType(); + int turnip = ModContent.ProjectileType(); if (player.ownedProjectileCounts[howl] > 0 || player.ownedProjectileCounts[calcifer] > 0 || player.ownedProjectileCounts[turnip] > 0) { modPlayer.howlTrio = true; diff --git a/Buffs/Summon/IceClasperBuff.cs b/Buffs/Summon/IceClasperBuff.cs index b57c7fabe0..d24013c214 100644 --- a/Buffs/Summon/IceClasperBuff.cs +++ b/Buffs/Summon/IceClasperBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The ice clasper will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/IgneousExaltationBuff.cs b/Buffs/Summon/IgneousExaltationBuff.cs index 9294ea8b97..f813278cca 100644 --- a/Buffs/Summon/IgneousExaltationBuff.cs +++ b/Buffs/Summon/IgneousExaltationBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A blade is orbiting you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/MagicHatBuff.cs b/Buffs/Summon/MagicHatBuff.cs index dcae1e8800..7fc47d1781 100644 --- a/Buffs/Summon/MagicHatBuff.cs +++ b/Buffs/Summon/MagicHatBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The hat carries your soul, bound by a contract"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/Mechworm.cs b/Buffs/Summon/Mechworm.cs index 622fabdbb6..e988eef205 100644 --- a/Buffs/Summon/Mechworm.cs +++ b/Buffs/Summon/Mechworm.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The mechworm will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/MidnightSunBuff.cs b/Buffs/Summon/MidnightSunBuff.cs index 57512cc571..09ed5b4817 100644 --- a/Buffs/Summon/MidnightSunBuff.cs +++ b/Buffs/Summon/MidnightSunBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A strange UFO is observing you, and it's making you very uncomfortable"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/MountedScannerBuff.cs b/Buffs/Summon/MountedScannerBuff.cs index e04d349368..beed63ef08 100644 --- a/Buffs/Summon/MountedScannerBuff.cs +++ b/Buffs/Summon/MountedScannerBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Powerful machinery surrounds you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/MutatedTruffleBuff.cs b/Buffs/Summon/MutatedTruffleBuff.cs index 52abdb72cc..1e39a968db 100644 --- a/Buffs/Summon/MutatedTruffleBuff.cs +++ b/Buffs/Summon/MutatedTruffleBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The young duke will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/PerditionBuff.cs b/Buffs/Summon/PerditionBuff.cs index 1773a82e3e..8e3093b182 100644 --- a/Buffs/Summon/PerditionBuff.cs +++ b/Buffs/Summon/PerditionBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("How unfortunate"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/Phantom.cs b/Buffs/Summon/Phantom.cs index 7fb60bc693..67e796f3c9 100644 --- a/Buffs/Summon/Phantom.cs +++ b/Buffs/Summon/Phantom.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The phantom will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/PlaguePrincessBuff.cs b/Buffs/Summon/PlaguePrincessBuff.cs index ef4ec31272..f51ade2569 100644 --- a/Buffs/Summon/PlaguePrincessBuff.cs +++ b/Buffs/Summon/PlaguePrincessBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("It’s a shame you can’t hug her"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/PlaguebringerSummonBuff.cs b/Buffs/Summon/PlaguebringerSummonBuff.cs index 14407a9d54..476fd7c502 100644 --- a/Buffs/Summon/PlaguebringerSummonBuff.cs +++ b/Buffs/Summon/PlaguebringerSummonBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The plaguebringer will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/PlantationBuff.cs b/Buffs/Summon/PlantationBuff.cs index 5922ae7e0e..9f007ec5f9 100644 --- a/Buffs/Summon/PlantationBuff.cs +++ b/Buffs/Summon/PlantationBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The miniature plantera will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/PoleWarperBuff.cs b/Buffs/Summon/PoleWarperBuff.cs index 4c66ae794e..ec0c17c7d2 100644 --- a/Buffs/Summon/PoleWarperBuff.cs +++ b/Buffs/Summon/PoleWarperBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Sentient magnets are attracted to you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/ProfanedBabs.cs b/Buffs/Summon/ProfanedBabs.cs index dbf7f73f2a..403e5b11aa 100644 --- a/Buffs/Summon/ProfanedBabs.cs +++ b/Buffs/Summon/ProfanedBabs.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.Summon { - public class ProfanedBabs : ModBuff //Buff name is reference to how I refer to the guardians as my babs ~Amber + public class ProfanedBabs : ModBuff //Buff name is reference to how I refer to the guardians as my babs ~Amber { public override void SetDefaults() { @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The healer will heal your wounds!"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { @@ -33,20 +33,20 @@ namespace CalamityMod.Buffs.Summon public override void ModifyBuffTip(ref string tip, ref int rare) { Player player = Main.player[Main.myPlayer]; - bool offense = player.Calamity().gOffense; - bool defense = player.Calamity().gDefense; - if (player.Calamity().profanedCrystal && (!player.Calamity().profanedCrystalBuffs && !CalamityWorld.downedSCal)) - { - tip = "The Profaned Babs will accompany you!"; - } - else if (offense && defense) - { - tip = "The Profaned Babs will fight for and defend you!"; - } - else if (offense || defense) - { - tip = "The " + (offense ? "Offensive" : "Defensive") + " Duo will " + (offense ? "fight for and heal you!" : "protect and heal you!"); - } - } + bool offense = player.Calamity().gOffense; + bool defense = player.Calamity().gDefense; + if (player.Calamity().profanedCrystal && (!player.Calamity().profanedCrystalBuffs && !CalamityWorld.downedSCal)) + { + tip = "The Profaned Babs will accompany you!"; + } + else if (offense && defense) + { + tip = "The Profaned Babs will fight for and defend you!"; + } + else if (offense || defense) + { + tip = "The " + (offense ? "Offensive" : "Defensive") + " Duo will " + (offense ? "fight for and heal you!" : "protect and heal you!"); + } + } } } diff --git a/Buffs/Summon/RadiantResolutionBuff.cs b/Buffs/Summon/RadiantResolutionBuff.cs index 72cec1f0ea..17522338eb 100644 --- a/Buffs/Summon/RadiantResolutionBuff.cs +++ b/Buffs/Summon/RadiantResolutionBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A radiant aura protects you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/ResurrectionButterflyBuff.cs b/Buffs/Summon/ResurrectionButterflyBuff.cs index 60a5811e93..c0ea1d68ad 100644 --- a/Buffs/Summon/ResurrectionButterflyBuff.cs +++ b/Buffs/Summon/ResurrectionButterflyBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Sleep beneath the Cherry Blossoms, Red-White Butterfly"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/RustyDroneBuff.cs b/Buffs/Summon/RustyDroneBuff.cs index 31b44129c3..fb32c86e9e 100644 --- a/Buffs/Summon/RustyDroneBuff.cs +++ b/Buffs/Summon/RustyDroneBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A pitifully fragile drone is observing you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/SageSpiritBuff.cs b/Buffs/Summon/SageSpiritBuff.cs index 45034d0575..68d211a2f5 100644 --- a/Buffs/Summon/SageSpiritBuff.cs +++ b/Buffs/Summon/SageSpiritBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("It's uncomfortably close"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/Sandnado.cs b/Buffs/Summon/Sandnado.cs index f29e060c85..ae18616a31 100644 --- a/Buffs/Summon/Sandnado.cs +++ b/Buffs/Summon/Sandnado.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The sandnado will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/SandyHealingWaifu.cs b/Buffs/Summon/SandyHealingWaifu.cs index 6f33129535..6c3f232602 100644 --- a/Buffs/Summon/SandyHealingWaifu.cs +++ b/Buffs/Summon/SandyHealingWaifu.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The sand elemental will heal you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/SandyWaifu.cs b/Buffs/Summon/SandyWaifu.cs index b3c5b379be..f67eb2b2be 100644 --- a/Buffs/Summon/SandyWaifu.cs +++ b/Buffs/Summon/SandyWaifu.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The sand elemental will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/ScabRipperBuff.cs b/Buffs/Summon/ScabRipperBuff.cs index da31bcba76..45dd9e96b0 100644 --- a/Buffs/Summon/ScabRipperBuff.cs +++ b/Buffs/Summon/ScabRipperBuff.cs @@ -12,8 +12,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The baby blood crawler will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/SepulcherMinionBuff.cs b/Buffs/Summon/SepulcherMinionBuff.cs index 34910472ba..ed1a18e8ac 100644 --- a/Buffs/Summon/SepulcherMinionBuff.cs +++ b/Buffs/Summon/SepulcherMinionBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("It is not benevolent"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/ShellfishBuff.cs b/Buffs/Summon/ShellfishBuff.cs index b3657f45b5..a70b954563 100644 --- a/Buffs/Summon/ShellfishBuff.cs +++ b/Buffs/Summon/ShellfishBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The shellfish will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/SilvaSummonSetBuff.cs b/Buffs/Summon/SilvaSummonSetBuff.cs index 73bae9adc7..50e63dcd63 100644 --- a/Buffs/Summon/SilvaSummonSetBuff.cs +++ b/Buffs/Summon/SilvaSummonSetBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The crystal will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/SiriusBuff.cs b/Buffs/Summon/SiriusBuff.cs index 9bc62aafd9..556d02204e 100644 --- a/Buffs/Summon/SiriusBuff.cs +++ b/Buffs/Summon/SiriusBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A bit too bright, but it helps you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/SnakeEyesBuff.cs b/Buffs/Summon/SnakeEyesBuff.cs index 15fbc0c159..a27dfc6047 100644 --- a/Buffs/Summon/SnakeEyesBuff.cs +++ b/Buffs/Summon/SnakeEyesBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Always watching..."); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/SolarSpirit.cs b/Buffs/Summon/SolarSpirit.cs index c6cb35c54a..63b94c2477 100644 --- a/Buffs/Summon/SolarSpirit.cs +++ b/Buffs/Summon/SolarSpirit.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The solar spirit will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/SolarSpiritGod.cs b/Buffs/Summon/SolarSpiritGod.cs index a2629c246d..d6cd9098de 100644 --- a/Buffs/Summon/SolarSpiritGod.cs +++ b/Buffs/Summon/SolarSpiritGod.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The solar god spirit will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/SoulSeekerBuff.cs b/Buffs/Summon/SoulSeekerBuff.cs index e552084a4b..68d7ff322d 100644 --- a/Buffs/Summon/SoulSeekerBuff.cs +++ b/Buffs/Summon/SoulSeekerBuff.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("It definitely wants something from you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - } + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/StaffOfNecrosteocytesBuff.cs b/Buffs/Summon/StaffOfNecrosteocytesBuff.cs index 06d352fa34..67da8ca383 100644 --- a/Buffs/Summon/StaffOfNecrosteocytesBuff.cs +++ b/Buffs/Summon/StaffOfNecrosteocytesBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A skeleton is observing you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/StarSwallowerBuff.cs b/Buffs/Summon/StarSwallowerBuff.cs index 264233b4ff..2bfc20882e 100644 --- a/Buffs/Summon/StarSwallowerBuff.cs +++ b/Buffs/Summon/StarSwallowerBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Mmmm myes"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/StatigelSummonSetBuff.cs b/Buffs/Summon/StatigelSummonSetBuff.cs index 27d8e1deb3..adb050f6b2 100644 --- a/Buffs/Summon/StatigelSummonSetBuff.cs +++ b/Buffs/Summon/StatigelSummonSetBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The slime god will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/StormjawBuff.cs b/Buffs/Summon/StormjawBuff.cs index 29f00f42ce..dc2db86111 100644 --- a/Buffs/Summon/StormjawBuff.cs +++ b/Buffs/Summon/StormjawBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The baby stormlion will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/TundraFlameBlossomsBuff.cs b/Buffs/Summon/TundraFlameBlossomsBuff.cs index 1207c5bca1..8dde3986a9 100644 --- a/Buffs/Summon/TundraFlameBlossomsBuff.cs +++ b/Buffs/Summon/TundraFlameBlossomsBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("A perfect unison of balance and beauty"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/VictideSummonSetBuff.cs b/Buffs/Summon/VictideSummonSetBuff.cs index 024eb09ff2..708484f760 100644 --- a/Buffs/Summon/VictideSummonSetBuff.cs +++ b/Buffs/Summon/VictideSummonSetBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The urchin will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/VileFeederBuff.cs b/Buffs/Summon/VileFeederBuff.cs index 43a80f081c..9b11e86a47 100644 --- a/Buffs/Summon/VileFeederBuff.cs +++ b/Buffs/Summon/VileFeederBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The baby eater of souls will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/VoidConcentrationBuff.cs b/Buffs/Summon/VoidConcentrationBuff.cs index a7d50be895..e1bf0ed474 100644 --- a/Buffs/Summon/VoidConcentrationBuff.cs +++ b/Buffs/Summon/VoidConcentrationBuff.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Buffs.Summon CalamityPlayer mp = player.Calamity(); int count = player.ownedProjectileCounts[ModContent.ProjectileType()]; player.minionDamage += 0.05f; //5% - mp.voidConcentrationAura = true; + mp.voidConcentrationAura = true; if (!mp.voidAuraDamage && count == 0) { player.DelBuff(buffIndex); diff --git a/Buffs/Summon/WaterWaifu.cs b/Buffs/Summon/WaterWaifu.cs index 22bdf54fd6..380fd4c672 100644 --- a/Buffs/Summon/WaterWaifu.cs +++ b/Buffs/Summon/WaterWaifu.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("Anahita will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/WulfrumDroidBuff.cs b/Buffs/Summon/WulfrumDroidBuff.cs index a91a54c48d..89352151c3 100644 --- a/Buffs/Summon/WulfrumDroidBuff.cs +++ b/Buffs/Summon/WulfrumDroidBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The wulfrum droid will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/Buffs/Summon/YharonKindleBuff.cs b/Buffs/Summon/YharonKindleBuff.cs index e7bdc44486..d885cf3bde 100644 --- a/Buffs/Summon/YharonKindleBuff.cs +++ b/Buffs/Summon/YharonKindleBuff.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Buffs.Summon Description.SetDefault("The fiery draconid will protect you"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } + //Main.persistentBuff[Type] = true; + } public override void Update(Player player, ref int buffIndex) { diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index b10734f90d..81c24bf49f 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -80,7 +80,7 @@ using Terraria.ModLoader.IO; namespace CalamityMod.CalPlayer { - public partial class CalamityPlayer : ModPlayer + public partial class CalamityPlayer : ModPlayer { #region Variables @@ -108,19 +108,19 @@ namespace CalamityMod.CalPlayer public double contactDamageReduction = 0D; public double projectileDamageReduction = 0D; public bool brimlashBusterBoost = false; - public int evilSmasherBoost = 0; - public int hellbornBoost = 0; + public int evilSmasherBoost = 0; + public int hellbornBoost = 0; public float animusBoost = 1f; - public int searedPanCounter = 0; - public int searedPanTimer = 0; + public int searedPanCounter = 0; + public int searedPanTimer = 0; public int potionTimer = 0; - public bool cirrusDress = false; + public bool cirrusDress = false; public bool blockAllDashes = false; public bool resetHeightandWidth = false; public bool noLifeRegen = false; public int itemTypeLastReforged = 0; public int reforgeTierSafety = 0; - public bool finalTierAccessoryReforge = false; + public bool finalTierAccessoryReforge = false; public float rangedAmmoCost = 1f; public bool heldGaelsLastFrame = false; public bool disableVoodooSpawns = false; @@ -162,12 +162,12 @@ namespace CalamityMod.CalPlayer // Total time is calculated on demand by adding the current stopwatch time to the previous session total. // This allows time to be tracked accurately through multiple save and quits. internal TimeSpan previousSessionTotal; - internal int lastSplitType = -1; + internal int lastSplitType = -1; internal TimeSpan lastSplit; - #endregion + #endregion - #region Tile Entity Trackers - public int CurrentlyViewedFactoryID = -1; + #region Tile Entity Trackers + public int CurrentlyViewedFactoryID = -1; public int CurrentlyViewedChargerID = -1; public int CurrentlyViewedHologramID = -1; public string CurrentlyViewedHologramText; @@ -354,11 +354,11 @@ namespace CalamityMod.CalPlayer public AndromedaPlayerState andromedaState; public int andromedaCripple; public const float UnicornSpeedNerfPower = 0.8f; - public const float MechanicalCartSpeedNerfPower = 0.7f; - #endregion + public const float MechanicalCartSpeedNerfPower = 0.7f; + #endregion - #region Pet - public bool thirdSage = false; + #region Pet + public bool thirdSage = false; public bool thirdSageH = true; public bool perfmini = false; public bool akato = false; @@ -386,7 +386,7 @@ namespace CalamityMod.CalPlayer public bool hiveMindPet = false; public bool bendyPet = false; public bool littleLightPet = false; - public bool pineapplePet = false; + public bool pineapplePet = false; #endregion #region Rage @@ -489,9 +489,9 @@ namespace CalamityMod.CalPlayer public bool evasionScarf = false; public bool badgeOfBravery = false; public bool badgeOfBraveryRare = false; - public float warBannerBonus = 0f; - private const float maxWarBannerBonus = 0.2f; - private const float maxWarBannerDistance = 480f; + public float warBannerBonus = 0f; + private const float maxWarBannerBonus = 0.2f; + private const float maxWarBannerDistance = 480f; public bool cryogenSoul = false; public bool yInsignia = false; public bool eGauntlet = false; @@ -517,7 +517,7 @@ namespace CalamityMod.CalPlayer public bool seaShell = false; public bool absorber = false; public bool aAmpoule = false; - public bool sponge = false; + public bool sponge = false; public bool rOoze = false; public bool pAmulet = false; public bool fBarrier = false; @@ -549,7 +549,7 @@ namespace CalamityMod.CalPlayer public bool alchFlask = false; public bool reducedPlagueDmg = false; public bool abaddon = false; - public bool aeroStone = false; + public bool aeroStone = false; public bool community = false; public bool shatteredCommunity = false; public bool fleshTotem = false; @@ -563,9 +563,9 @@ namespace CalamityMod.CalPlayer public bool celestialJewel = false; public bool astralArcanum = false; public bool harpyRing = false; - public bool angelTreads = false; + public bool angelTreads = false; public bool harpyWingBoost = false; //harpy wings + harpy ring - public bool fleshKnuckles = false; + public bool fleshKnuckles = false; public bool ironBoots = false; public bool depthCharm = false; public bool anechoicPlating = false; @@ -648,15 +648,15 @@ namespace CalamityMod.CalPlayer public int icicleCooldown = 0; public bool rustyMedal = false; public bool noStupidNaturalARSpawns = false; - public bool roverDrive = false; - public int roverDriveTimer = 0; - public int roverFrameCounter = 0; - public int roverFrame = 0; + public bool roverDrive = false; + public int roverDriveTimer = 0; + public int roverFrameCounter = 0; + public int roverFrame = 0; public int voidFrameCounter = 0; public int voidFrame = 0; public bool rottenDogTooth = false; - public bool angelicAlliance = false; - public int angelicActivate = -1; + public bool angelicAlliance = false; + public int angelicActivate = -1; public bool BloomStoneRegen = false; public bool ChaosStone = false; public bool CryoStone = false; @@ -687,8 +687,8 @@ namespace CalamityMod.CalPlayer public int tarraMageHealCooldown = 0; public int tarraCrits = 0; public bool tarraRanged = false; - public int tarraRangedCooldown = 0; - public bool tarraThrowing = false; + public int tarraRangedCooldown = 0; + public bool tarraThrowing = false; public bool tarragonImmunity = false; public int tarraThrowingCrits = 0; public bool tarraSummon = false; @@ -706,7 +706,7 @@ namespace CalamityMod.CalPlayer public bool godSlayerDamage = false; public bool godSlayerRanged = false; public bool godSlayerThrowing = false; - public bool godSlayerDashHotKeyPressed = false; + public bool godSlayerDashHotKeyPressed = false; public bool ataxiaBolt = false; public bool ataxiaFire = false; public bool ataxiaVolley = false; @@ -760,8 +760,8 @@ namespace CalamityMod.CalPlayer public int prismaticLasers = 0; public bool silvaSet = false; public bool silvaMage = false; - public int silvaMageCooldown = 0; - public bool silvaSummon = false; + public int silvaMageCooldown = 0; + public bool silvaSummon = false; public bool hasSilvaEffect = false; public static int silvaReviveDuration = 480; public int silvaCountdown = silvaReviveDuration; @@ -789,20 +789,20 @@ namespace CalamityMod.CalPlayer private float adamantiteSetDefenseBoostInterpolant; public int AdamantiteSetDefenseBoost - { + { get => (int)(MathHelper.Clamp(adamantiteSetDefenseBoostInterpolant, 0f, 1f) * AdamantiteArmorSetChange.DefenseBoostMax); - set - { + set + { // Clamp the boost within a respected bound. adamantiteSetDefenseBoostInterpolant = MathHelper.Clamp(value / (float)AdamantiteArmorSetChange.DefenseBoostMax, 0f, 1f); } - } + } private GemTechArmorState gemTechState; public GemTechArmorState GemTechState - { - get - { + { + get + { if (gemTechState is null || gemTechState.HasInvalidOwner) gemTechState = new GemTechArmorState(player.whoAmI); return gemTechState; @@ -845,8 +845,8 @@ namespace CalamityMod.CalPlayer public bool cragsLava = false; public bool vaporfied = false; public bool waterLeechBleeding = false; - public bool banishingFire = false; - public bool wither = false; + public bool banishingFire = false; + public bool wither = false; public bool ManaBurn = false; #endregion @@ -936,11 +936,11 @@ namespace CalamityMod.CalPlayer public bool bloodfinBoost = false; public int bloodfinTimer = 30; public bool hallowedRegen = false; - public bool hallowedPower = false; + public bool hallowedPower = false; public bool kamiBoost = false; - public bool avertorBonus = false; - public bool divineBless = false; - #endregion + public bool avertorBonus = false; + public bool divineBless = false; + #endregion #region Minion public bool wDroid = false; @@ -1009,7 +1009,7 @@ namespace CalamityMod.CalPlayer public bool coldDivinity = false; public bool voidAura = false; public bool voidAuraDamage = false; - public bool voidConcentrationAura = false; + public bool voidConcentrationAura = false; public bool youngDuke = false; public bool virili = false; public bool frostBlossom = false; @@ -1245,7 +1245,7 @@ namespace CalamityMod.CalPlayer boost.AddWithCondition("bossHPBar", drawBossHPBar); boost.AddWithCondition("drawSmallText", shouldDrawSmallText); boost.AddWithCondition("fullHPRespawn", healToFull); - boost.AddWithCondition("finalTierAccessoryReforge", finalTierAccessoryReforge); + boost.AddWithCondition("finalTierAccessoryReforge", finalTierAccessoryReforge); boost.AddWithCondition("newMerchantInventory", newMerchantInventory); boost.AddWithCondition("newPainterInventory", newPainterInventory); @@ -1473,9 +1473,9 @@ namespace CalamityMod.CalPlayer (bOrange ? 25 : 0) + (eBerry ? 25 : 0) + (dFruit ? 25 : 0); - if (fleshKnuckles) - player.statLifeMax2 += 45; - if (ZoneAbyss && abyssalAmulet) + if (fleshKnuckles) + player.statLifeMax2 += 45; + if (ZoneAbyss && abyssalAmulet) player.statLifeMax2 += player.statLifeMax2 / 5 / 20 * (lumenousAmulet ? 25 : 10); if (coreOfTheBloodGod) player.statLifeMax2 += player.statLifeMax2 / 5 / 20 * 10; @@ -1538,10 +1538,10 @@ namespace CalamityMod.CalPlayer throwingCrit = 0; throwingAmmoCost = 1f; accStealthGenBoost = 0f; - rogueUseSpeedFactor = 0f; + rogueUseSpeedFactor = 0f; trueMeleeDamage = 0D; - warBannerBonus = 0f; + warBannerBonus = 0f; dashMod = 0; externalAbyssLight = 0; @@ -1574,7 +1574,7 @@ namespace CalamityMod.CalPlayer hiveMindPet = false; bendyPet = false; littleLightPet = false; - pineapplePet = false; + pineapplePet = false; onyxExcavator = false; angryDog = false; @@ -1648,7 +1648,7 @@ namespace CalamityMod.CalPlayer shadowSpeed = false; dsSetBonus = false; wearingRogueArmor = false; - cirrusDress = false; + cirrusDress = false; blockAllDashes = false; blazingCursorDamage = false; @@ -1681,7 +1681,7 @@ namespace CalamityMod.CalPlayer seaShell = false; absorber = false; aAmpoule = false; - sponge = false; + sponge = false; rOoze = false; pAmulet = false; fBarrier = false; @@ -1706,7 +1706,7 @@ namespace CalamityMod.CalPlayer alchFlask = false; reducedPlagueDmg = false; abaddon = false; - aeroStone = false; + aeroStone = false; community = false; shatteredCommunity = false; stressPills = false; @@ -1720,9 +1720,9 @@ namespace CalamityMod.CalPlayer celestialJewel = false; astralArcanum = false; harpyRing = false; - angelTreads = false; + angelTreads = false; harpyWingBoost = false; //harpy wings + harpy ring - fleshKnuckles = false; + fleshKnuckles = false; darkSunRing = false; calamityRing = false; voidOfExtinction = false; @@ -1744,7 +1744,7 @@ namespace CalamityMod.CalPlayer hallowedRune = false; phantomicArtifact = false; hallowedRegen = false; - hallowedPower = false; + hallowedPower = false; kamiBoost = false; IBoots = false; elysianFire = false; @@ -1768,9 +1768,9 @@ namespace CalamityMod.CalPlayer corrosiveSpine = false; rustyMedal = false; noStupidNaturalARSpawns = false; - roverDrive = false; + roverDrive = false; rottenDogTooth = false; - angelicAlliance = false; + angelicAlliance = false; BloomStoneRegen = false; ChaosStone = false; CryoStone = false; @@ -1869,9 +1869,9 @@ namespace CalamityMod.CalPlayer abyssalMirror = false; eclipseMirror = false; featherCrown = false; - featherCrownDraw = false; + featherCrownDraw = false; moonCrown = false; - moonCrownDraw = false; + moonCrownDraw = false; dragonScales = false; gloveOfPrecision = false; gloveOfRecklessness = false; @@ -1922,8 +1922,8 @@ namespace CalamityMod.CalPlayer cragsLava = false; vaporfied = false; waterLeechBleeding = false; - banishingFire = false; - wither = false; + banishingFire = false; + wither = false; ManaBurn = false; revivify = false; @@ -1980,8 +1980,8 @@ namespace CalamityMod.CalPlayer polarisBoostTwo = false; polarisBoostThree = false; bloodfinBoost = false; - bloodPactBoost = false; - divineBless = false; + bloodPactBoost = false; + divineBless = false; killSpikyBalls = false; @@ -2091,7 +2091,7 @@ namespace CalamityMod.CalPlayer coldDivinity = false; voidAura = false; voidAuraDamage = false; - voidConcentrationAura = false; + voidConcentrationAura = false; radiantResolution = false; virili = false; frostBlossom = false; @@ -2222,7 +2222,7 @@ namespace CalamityMod.CalPlayer } #region Debuffs - totalDefenseDamage = 0; + totalDefenseDamage = 0; defenseDamageRecoveryFrames = 0; totalDefenseDamageRecoveryFrames = DefenseDamageBaseRecoveryTime; defenseDamageDelayFrames = 0; @@ -2249,10 +2249,10 @@ namespace CalamityMod.CalPlayer gSabatonFall = 0; gSabatonCooldown = 0; astralStarRainCooldown = 0; - silvaMageCooldown = 0; - bloodflareMageCooldown = 0; - tarraRangedCooldown = 0; - tarraMageHealCooldown = 0; + silvaMageCooldown = 0; + bloodflareMageCooldown = 0; + tarraRangedCooldown = 0; + tarraMageHealCooldown = 0; bossRushImmunityFrameCurseTimer = 0; aBulwarkRareMeleeBoostTimer = 0; acidRoundMultiplier = 1D; @@ -2267,16 +2267,16 @@ namespace CalamityMod.CalPlayer theBeeCooldown = 0; killSpikyBalls = false; rogueCrownCooldown = 0; - icicleCooldown = 0; - statisTimer = 0; - hallowedRuneCooldown = 0; - sulphurBubbleCooldown = 0; - ladHearts = 0; - prismaticLasers = 0; - roverDriveTimer = 0; - angelicActivate = -1; - resetHeightandWidth = false; - noLifeRegen = false; + icicleCooldown = 0; + statisTimer = 0; + hallowedRuneCooldown = 0; + sulphurBubbleCooldown = 0; + ladHearts = 0; + prismaticLasers = 0; + roverDriveTimer = 0; + angelicActivate = -1; + resetHeightandWidth = false; + noLifeRegen = false; alcoholPoisoning = false; shadowflame = false; wDeath = false; @@ -2312,8 +2312,8 @@ namespace CalamityMod.CalPlayer cragsLava = false; vaporfied = false; waterLeechBleeding = false; - banishingFire = false; - wither = false; + banishingFire = false; + wither = false; #endregion #region Rogue @@ -2327,7 +2327,7 @@ namespace CalamityMod.CalPlayer throwingVelocity = 1f; throwingCrit = 0; throwingAmmoCost = 1f; - rogueUseSpeedFactor = 0f; + rogueUseSpeedFactor = 0f; #endregion #region UI @@ -2341,7 +2341,7 @@ namespace CalamityMod.CalPlayer #region Buffs sRegen = false; hallowedRegen = false; - hallowedPower = false; + hallowedPower = false; onyxExcavator = false; angryDog = false; fab = false; @@ -2438,11 +2438,11 @@ namespace CalamityMod.CalPlayer revivify = false; healCounter = 300; danceOfLightCharge = 0; - bloodPactBoost = false; - rangedAmmoCost = 1f; - avertorBonus = false; - divineBless = false; - #endregion + bloodPactBoost = false; + rangedAmmoCost = 1f; + avertorBonus = false; + divineBless = false; + #endregion #region Armorbonuses flamethrowerBoost = false; @@ -2452,7 +2452,7 @@ namespace CalamityMod.CalPlayer godSlayerDamage = false; godSlayerRanged = false; godSlayerThrowing = false; - godSlayerDashHotKeyPressed = false; + godSlayerDashHotKeyPressed = false; auricBoost = false; silvaSet = false; silvaMage = false; @@ -2564,11 +2564,11 @@ namespace CalamityMod.CalPlayer KameiBladeUseDelay = 0; lastProjectileHit = null; brimlashBusterBoost = false; - evilSmasherBoost = 0; - hellbornBoost = 0; + evilSmasherBoost = 0; + hellbornBoost = 0; animusBoost = 1f; - searedPanCounter = 0; - searedPanTimer = 0; + searedPanCounter = 0; + searedPanTimer = 0; potionTimer = 0; bloodflareCoreLostDefense = 0; persecutedEnchantSummonTimer = 0; @@ -2580,13 +2580,13 @@ namespace CalamityMod.CalPlayer Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); } - if (player.respawnTimer > 300) - { - if (CalamityWorld.armageddon && !areThereAnyDamnBosses) - player.respawnTimer -= 5; - else if (Main.expertMode) // 600 normal 900 expert - player.respawnTimer--; - } + if (player.respawnTimer > 300) + { + if (CalamityWorld.armageddon && !areThereAnyDamnBosses) + player.respawnTimer -= 5; + else if (Main.expertMode) // 600 normal 900 expert + player.respawnTimer--; + } } #endregion @@ -2601,7 +2601,7 @@ namespace CalamityMod.CalPlayer Dictionary skies = EffectsField.GetValue(SkyManager.Instance) as Dictionary; bool updateRequired = false; foreach (string skyName in skies.Keys) - { + { if (skies[skyName].IsActive() && skyName != "CalamityMod:BossRush") { skies[skyName].Opacity = 0f; @@ -2667,10 +2667,10 @@ namespace CalamityMod.CalPlayer bool useSBrimstone = NPC.AnyNPCs(ModContent.NPCType()) || SCalSky.OverridingIntensity > 0f; player.ManageSpecialBiomeVisuals("CalamityMod:SupremeCalamitas", useSBrimstone); - bool useWyrmWater = NPC.AnyNPCs(ModContent.NPCType()); - player.ManageSpecialBiomeVisuals("CalamityMod:AdultEidolonWyrm", useWyrmWater); + bool useWyrmWater = NPC.AnyNPCs(ModContent.NPCType()); + player.ManageSpecialBiomeVisuals("CalamityMod:AdultEidolonWyrm", useWyrmWater); - bool inAstral = ZoneAstral; + bool inAstral = ZoneAstral; player.ManageSpecialBiomeVisuals("CalamityMod:Astral", inAstral); CryogenSky.UpdateDrawEligibility(); @@ -2896,38 +2896,38 @@ namespace CalamityMod.CalPlayer } if (CalamityMod.AngelicAllianceHotKey.JustPressed && angelicAlliance && Main.myPlayer == player.whoAmI && !divineBless && !player.HasCooldown(Cooldowns.DivineBless.ID)) { - int seconds = CalamityUtils.SecondsToFrames(15f); - player.AddBuff(ModContent.BuffType(), seconds, false); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AbilitySounds/AngelicAllianceActivation"), player.Center); + int seconds = CalamityUtils.SecondsToFrames(15f); + player.AddBuff(ModContent.BuffType(), seconds, false); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AbilitySounds/AngelicAllianceActivation"), player.Center); - // Spawn an archangel for every minion you have - float angelAmt = 0f; - for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) - { - Projectile proj = Main.projectile[projIndex]; - if (proj.minionSlots <= 0f || !proj.IsSummon()) - continue; - if (proj.active && proj.owner == player.whoAmI) - { - angelAmt += 1f; - } - } - for (int projIndex = 0; projIndex < angelAmt; projIndex++) - { - Projectile proj = Main.projectile[projIndex]; - float start = 360f / angelAmt; - Projectile.NewProjectile(new Vector2((int)(player.Center.X + (Math.Sin(projIndex * start) * 300)), (int)(player.Center.Y + (Math.Cos(projIndex * start) * 300))), Vector2.Zero, ModContent.ProjectileType(), proj.damage / 4, proj.knockBack / 4f, player.whoAmI, Main.rand.Next(120), projIndex * start); - player.statLife += 2; - player.HealEffect(2); - } + // Spawn an archangel for every minion you have + float angelAmt = 0f; + for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) + { + Projectile proj = Main.projectile[projIndex]; + if (proj.minionSlots <= 0f || !proj.IsSummon()) + continue; + if (proj.active && proj.owner == player.whoAmI) + { + angelAmt += 1f; + } + } + for (int projIndex = 0; projIndex < angelAmt; projIndex++) + { + Projectile proj = Main.projectile[projIndex]; + float start = 360f / angelAmt; + Projectile.NewProjectile(new Vector2((int)(player.Center.X + (Math.Sin(projIndex * start) * 300)), (int)(player.Center.Y + (Math.Cos(projIndex * start) * 300))), Vector2.Zero, ModContent.ProjectileType(), proj.damage / 4, proj.knockBack / 4f, player.whoAmI, Main.rand.Next(120), projIndex * start); + player.statLife += 2; + player.HealEffect(2); + } } if (CalamityMod.SandCloakHotkey.JustPressed && sandCloak && Main.myPlayer == player.whoAmI && rogueStealth >= rogueStealthMax * 0.25f && - wearingRogueArmor && rogueStealthMax > 0 && !player.HasCooldown(Cooldowns.SandCloak.ID)) + wearingRogueArmor && rogueStealthMax > 0 && !player.HasCooldown(Cooldowns.SandCloak.ID)) { player.AddCooldown(Cooldowns.SandCloak.ID, CalamityUtils.SecondsToFrames(30)); - rogueStealth -= rogueStealthMax * 0.25f; - Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 7, 8, player.whoAmI); - Main.PlaySound(SoundID.Item, player.position, 45); + rogueStealth -= rogueStealthMax * 0.25f; + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 7, 8, player.whoAmI); + Main.PlaySound(SoundID.Item, player.position, 45); } if (CalamityMod.SpectralVeilHotKey.JustPressed && spectralVeil && Main.myPlayer == player.whoAmI && rogueStealth >= rogueStealthMax * 0.25f && wearingRogueArmor && rogueStealthMax > 0) @@ -3031,7 +3031,7 @@ namespace CalamityMod.CalPlayer { if (player.whoAmI == Main.myPlayer) { - player.AddBuff(ModContent.BuffType(), 602, false); + player.AddBuff(ModContent.BuffType(), 602, false); } } if (bloodflareRanged && !player.HasCooldown(BloodflareRangedSet.ID)) @@ -3071,12 +3071,12 @@ namespace CalamityMod.CalPlayer float randomSpeed2 = (float)Main.rand.Next(1, 7); offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; int soul = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f) + randomSpeed, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, ai1); - if (soul.WithinBounds(Main.maxProjectiles)) - Main.projectile[soul].Calamity().forceTypeless = true; - int soul2 = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f) + randomSpeed2, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, ai1); - if (soul2.WithinBounds(Main.maxProjectiles)) - Main.projectile[soul2].Calamity().forceTypeless = true; - } + if (soul.WithinBounds(Main.maxProjectiles)) + Main.projectile[soul].Calamity().forceTypeless = true; + int soul2 = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f) + randomSpeed2, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, ai1); + if (soul2.WithinBounds(Main.maxProjectiles)) + Main.projectile[soul2].Calamity().forceTypeless = true; + } } } if (omegaBlueSet && !player.HasCooldown(OmegaBlue.ID)) @@ -3163,9 +3163,9 @@ namespace CalamityMod.CalPlayer if (player.whoAmI == Main.myPlayer) { int mark = Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, ModContent.ProjectileType(), damage, kBack, player.whoAmI); - if (mark.WithinBounds(Main.maxProjectiles)) - Main.projectile[mark].Calamity().forceTypeless = true; - } + if (mark.WithinBounds(Main.maxProjectiles)) + Main.projectile[mark].Calamity().forceTypeless = true; + } } } if (prismaticSet && !player.HasCooldown(PrismaticLaser.ID) && prismaticLasers <= 0) @@ -3198,9 +3198,9 @@ namespace CalamityMod.CalPlayer } } - // Trigger for pressing the God Slayer dash key - if (CalamityMod.GodSlayerDashHotKey.JustPressed && (player.controlUp || player.controlDown || player.controlLeft || player.controlRight) && !player.pulley && player.grappling[0] == -1 && !player.tongued && !player.mount.Active && !player.HasCooldown(GodSlayerDash.ID) && player.dashDelay == 0) - godSlayerDashHotKeyPressed = true; + // Trigger for pressing the God Slayer dash key + if (CalamityMod.GodSlayerDashHotKey.JustPressed && (player.controlUp || player.controlDown || player.controlLeft || player.controlRight) && !player.pulley && player.grappling[0] == -1 && !player.tongued && !player.mount.Active && !player.HasCooldown(GodSlayerDash.ID) && player.dashDelay == 0) + godSlayerDashHotKeyPressed = true; // Trigger for pressing the Rage hotkey. if (CalamityMod.RageHotKey.JustPressed) @@ -3236,9 +3236,9 @@ namespace CalamityMod.CalPlayer int projectileIndex = Projectile.NewProjectile(player.Center + initialVelocity * 3f, initialVelocity, ModContent.ProjectileType(), damage, 2f, player.whoAmI); Main.projectile[projectileIndex].tileCollide = false; Main.projectile[projectileIndex].localAI[1] = (Main.projectile[projectileIndex].velocity.Y < 0f).ToInt(); - if (projectileIndex.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectileIndex].Calamity().forceTypeless = true; - } + if (projectileIndex.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectileIndex].Calamity().forceTypeless = true; + } // Remove all rage when the special attack is used, and apply the cooldown. rage = 0f; @@ -3251,8 +3251,8 @@ namespace CalamityMod.CalPlayer // Rage duration isn't calculated here because the buff keeps itself alive automatically as long as the player has Rage left. player.AddBuff(ModContent.BuffType(), 2); - // Play Rage Activation sound - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AbilitySounds/RageActivate"), player.position); + // Play Rage Activation sound + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AbilitySounds/RageActivate"), player.position); // TODO -- improve Rage activation visuals for (int num502 = 0; num502 < 64; num502++) @@ -3282,8 +3282,8 @@ namespace CalamityMod.CalPlayer { player.AddBuff(ModContent.BuffType(), AdrenalineDuration); - // Play Adrenaline Activation sound - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AbilitySounds/AdrenalineActivate"), player.position); + // Play Adrenaline Activation sound + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AbilitySounds/AdrenalineActivate"), player.position); // TODO -- improve Adrenaline activation visuals for (int num502 = 0; num502 < 64; num502++) @@ -3671,59 +3671,59 @@ namespace CalamityMod.CalPlayer profanedCrystalForce = true; } - // Whichever is lowest in your vanity slots should take priority + // Whichever is lowest in your vanity slots should take priority if (item.type == ModContent.ItemType()) { - featherCrownDraw = false; - moonCrownDraw = false; + featherCrownDraw = false; + moonCrownDraw = false; abyssDivingGear = true; } if (item.type == ModContent.ItemType()) { - abyssDivingGear = false; - moonCrownDraw = false; + abyssDivingGear = false; + moonCrownDraw = false; featherCrownDraw = true; } if (item.type == ModContent.ItemType()) { - abyssDivingGear = false; - featherCrownDraw = false; + abyssDivingGear = false; + featherCrownDraw = false; moonCrownDraw = true; } - // Summon anime girl if it's in vanity slot as the pet is purely vanity - // It's possible for other "pet" items like Fungal Clump or HotE to summon a passive version of their "pets" with some tweaks though + // Summon anime girl if it's in vanity slot as the pet is purely vanity + // It's possible for other "pet" items like Fungal Clump or HotE to summon a passive version of their "pets" with some tweaks though if (item.type == ModContent.ItemType()) { - spiritOriginVanity = true; - if (player.whoAmI == Main.myPlayer) - { - if (player.FindBuffIndex(ModContent.BuffType()) == -1) - player.AddBuff(ModContent.BuffType(), 18000, true); - } + spiritOriginVanity = true; + if (player.whoAmI == Main.myPlayer) + { + if (player.FindBuffIndex(ModContent.BuffType()) == -1) + player.AddBuff(ModContent.BuffType(), 18000, true); + } } if (item.type == ModContent.ItemType()) { - howlsHeartVanity = 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, -Vector2.UnitY, ModContent.ProjectileType(), (int)(HowlsHeart.HowlDamage * player.MinionDamage()), 1f, player.whoAmI, 0f, 1f); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - Projectile.NewProjectile(player.Center, -Vector2.UnitY, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - Projectile.NewProjectile(player.Center, -Vector2.UnitY, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); - } - } + howlsHeartVanity = 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, -Vector2.UnitY, ModContent.ProjectileType(), (int)(HowlsHeart.HowlDamage * player.MinionDamage()), 1f, player.whoAmI, 0f, 1f); + } + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + { + Projectile.NewProjectile(player.Center, -Vector2.UnitY, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); + } + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + { + Projectile.NewProjectile(player.Center, -Vector2.UnitY, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); + } + } } } } @@ -3748,15 +3748,15 @@ namespace CalamityMod.CalPlayer CalamityConfig.Instance.BossHealthBarExtraInfo = shouldDrawSmallText; - // Increase tile placement speed to speed up early game a bit and make building more fun - player.tileSpeed += 0.5f; + // Increase tile placement speed to speed up early game a bit and make building more fun + player.tileSpeed += 0.5f; - // Increase wall placement speed to speed up early game a bit and make building more fun - player.wallSpeed += 0.5f; + // Increase wall placement speed to speed up early game a bit and make building more fun + player.wallSpeed += 0.5f; - // Takes the % move speed boost and reduces it to a quarter to get the actual speed increase - // 400% move speed boost = 80% run speed boost, so an 8 run speed would become 14.4 with a 400% move speed stat - float accRunSpeedMin = player.accRunSpeed * 0.5f; + // Takes the % move speed boost and reduces it to a quarter to get the actual speed increase + // 400% move speed boost = 80% run speed boost, so an 8 run speed would become 14.4 with a 400% move speed stat + float accRunSpeedMin = player.accRunSpeed * 0.5f; player.accRunSpeed += player.accRunSpeed * moveSpeedStat * 0.002f; if (player.accRunSpeed < accRunSpeedMin) @@ -3786,51 +3786,51 @@ namespace CalamityMod.CalPlayer } if (badgeOfBraveryRare) { - int closestNPC = -1; - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC nPC = Main.npc[i]; - if (nPC.active && !nPC.friendly && (nPC.damage > 0 || nPC.boss) && !nPC.dontTakeDamage) - { - closestNPC = i; - break; - } - } - float distance = -1f; - for (int j = 0; j < Main.maxNPCs; j++) - { - NPC nPC = Main.npc[j]; - if (nPC.active && !nPC.friendly && (nPC.damage > 0 || nPC.boss) && !nPC.dontTakeDamage) - { - float distance2 = Math.Abs(nPC.position.X + (float)(nPC.width / 2) - (player.position.X + (float)(player.width / 2))) + Math.Abs(nPC.position.Y + (float)(nPC.height / 2) - (player.position.Y + (float)(player.height / 2))); - if (distance == -1f || distance2 < distance) - { - distance = distance2; - closestNPC = j; - } - } - } + int closestNPC = -1; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC nPC = Main.npc[i]; + if (nPC.active && !nPC.friendly && (nPC.damage > 0 || nPC.boss) && !nPC.dontTakeDamage) + { + closestNPC = i; + break; + } + } + float distance = -1f; + for (int j = 0; j < Main.maxNPCs; j++) + { + NPC nPC = Main.npc[j]; + if (nPC.active && !nPC.friendly && (nPC.damage > 0 || nPC.boss) && !nPC.dontTakeDamage) + { + float distance2 = Math.Abs(nPC.position.X + (float)(nPC.width / 2) - (player.position.X + (float)(player.width / 2))) + Math.Abs(nPC.position.Y + (float)(nPC.height / 2) - (player.position.Y + (float)(player.height / 2))); + if (distance == -1f || distance2 < distance) + { + distance = distance2; + closestNPC = j; + } + } + } - if (closestNPC != -1) - { - NPC actualClosestNPC = Main.npc[closestNPC]; + if (closestNPC != -1) + { + NPC actualClosestNPC = Main.npc[closestNPC]; - float generousHitboxWidth = Math.Max(actualClosestNPC.Hitbox.Width / 2f, actualClosestNPC.Hitbox.Height / 2f); - float hitboxEdgeDist = actualClosestNPC.Distance(player.Center) - generousHitboxWidth; + float generousHitboxWidth = Math.Max(actualClosestNPC.Hitbox.Width / 2f, actualClosestNPC.Hitbox.Height / 2f); + float hitboxEdgeDist = actualClosestNPC.Distance(player.Center) - generousHitboxWidth; - if (hitboxEdgeDist < 0) - hitboxEdgeDist = 0; + if (hitboxEdgeDist < 0) + hitboxEdgeDist = 0; - if (hitboxEdgeDist < maxWarBannerDistance) - { - warBannerBonus = MathHelper.Lerp(0f, maxWarBannerBonus, 1f - (hitboxEdgeDist / maxWarBannerDistance)); + if (hitboxEdgeDist < maxWarBannerDistance) + { + warBannerBonus = MathHelper.Lerp(0f, maxWarBannerBonus, 1f - (hitboxEdgeDist / maxWarBannerDistance)); - if (warBannerBonus > maxWarBannerBonus) - warBannerBonus = maxWarBannerBonus; - } + if (warBannerBonus > maxWarBannerBonus) + warBannerBonus = maxWarBannerBonus; + } - meleeSpeedMult += warBannerBonus; - } + meleeSpeedMult += warBannerBonus; + } } if (eGauntlet) { @@ -3876,10 +3876,10 @@ namespace CalamityMod.CalPlayer else meleeSpeedMult += 0.05f; } - if (player.beetleOffense && player.beetleOrbs > 0) - { - meleeSpeedMult -= 0.1f * player.beetleOrbs; - } + if (player.beetleOffense && player.beetleOrbs > 0) + { + meleeSpeedMult -= 0.1f * player.beetleOrbs; + } if (CalamityConfig.Instance.Proficiency) { meleeSpeedMult += GetMeleeSpeedBonus(); @@ -4103,68 +4103,68 @@ namespace CalamityMod.CalPlayer public override void PostUpdateRunSpeeds() { - #region SpeedBoosts - if (!player.mount.Active) - { - float runAccMult = 1f + - (shadowSpeed ? 0.5f : 0f) + - (stressPills ? 0.05f : 0f) + - ((abyssalDivingSuit && player.IsUnderwater()) ? 0.05f : 0f) + - (sirenWaterBuff ? 0.15f : 0f) + - ((frostFlare && player.statLife < (int)(player.statLifeMax2 * 0.25)) ? 0.15f : 0f) + - (dragonScales ? 0.1f : 0f) + - (kamiBoost ? KamiBuff.RunAccelerationBoost : 0f) + + #region SpeedBoosts + if (!player.mount.Active) + { + float runAccMult = 1f + + (shadowSpeed ? 0.5f : 0f) + + (stressPills ? 0.05f : 0f) + + ((abyssalDivingSuit && player.IsUnderwater()) ? 0.05f : 0f) + + (sirenWaterBuff ? 0.15f : 0f) + + ((frostFlare && player.statLife < (int)(player.statLifeMax2 * 0.25)) ? 0.15f : 0f) + + (dragonScales ? 0.1f : 0f) + + (kamiBoost ? KamiBuff.RunAccelerationBoost : 0f) + (CobaltSet ? CobaltArmorSetChange.SpeedBoostSetBonusPercentage * 0.01f : 0f) + (silvaSet ? 0.05f : 0f) + - (blueCandle ? 0.05f : 0f) + - (planarSpeedBoost > 0 ? (0.01f * planarSpeedBoost) : 0f) + - ((deepDiver && player.IsUnderwater()) ? 0.15f : 0f) + - (rogueStealthMax > 0f ? (rogueStealth >= rogueStealthMax ? rogueStealth * 0.05f : rogueStealth * 0.025f) : 0f); + (blueCandle ? 0.05f : 0f) + + (planarSpeedBoost > 0 ? (0.01f * planarSpeedBoost) : 0f) + + ((deepDiver && player.IsUnderwater()) ? 0.15f : 0f) + + (rogueStealthMax > 0f ? (rogueStealth >= rogueStealthMax ? rogueStealth * 0.05f : rogueStealth * 0.025f) : 0f); - float runSpeedMult = 1f + - (shadowSpeed ? 0.5f : 0f) + - (stressPills ? 0.05f : 0f) + - ((abyssalDivingSuit && player.IsUnderwater()) ? 0.05f : 0f) + - (sirenWaterBuff ? 0.15f : 0f) + - ((frostFlare && player.statLife < (int)(player.statLifeMax2 * 0.25)) ? 0.15f : 0f) + - (dragonScales ? 0.1f : 0f) + - (kamiBoost ? KamiBuff.RunSpeedBoost : 0f) + + float runSpeedMult = 1f + + (shadowSpeed ? 0.5f : 0f) + + (stressPills ? 0.05f : 0f) + + ((abyssalDivingSuit && player.IsUnderwater()) ? 0.05f : 0f) + + (sirenWaterBuff ? 0.15f : 0f) + + ((frostFlare && player.statLife < (int)(player.statLifeMax2 * 0.25)) ? 0.15f : 0f) + + (dragonScales ? 0.1f : 0f) + + (kamiBoost ? KamiBuff.RunSpeedBoost : 0f) + (CobaltSet ? CobaltArmorSetChange.SpeedBoostSetBonusPercentage * 0.01f : 0f) + (silvaSet ? 0.05f : 0f) + - (planarSpeedBoost > 0 ? (0.01f * planarSpeedBoost) : 0f) + - ((deepDiver && player.IsUnderwater()) ? 0.15f : 0f) + - (rogueStealthMax > 0f ? (rogueStealth >= rogueStealthMax ? rogueStealth * 0.05f : rogueStealth * 0.025f) : 0f); + (planarSpeedBoost > 0 ? (0.01f * planarSpeedBoost) : 0f) + + ((deepDiver && player.IsUnderwater()) ? 0.15f : 0f) + + (rogueStealthMax > 0f ? (rogueStealth >= rogueStealthMax ? rogueStealth * 0.05f : rogueStealth * 0.025f) : 0f); - if (abyssalDivingSuit && !player.IsUnderwater()) - { - float multiplier = 0.4f + abyssalDivingSuitPlateHits * 0.2f; - runAccMult *= multiplier; - runSpeedMult *= multiplier; - } - if (fabledTortoise) - { - float multiplier = shellBoost ? 0.8f : 0.5f; - runAccMult *= multiplier; - runSpeedMult *= multiplier; - } - if (ursaSergeant) - { - runAccMult *= 0.85f; - runSpeedMult *= 0.85f; - } - if (elysianGuard) - { - runAccMult *= 0.5f; - runSpeedMult *= 0.5f; - } - if ((player.slippy || player.slippy2) && player.iceSkate) - { - runAccMult *= 0.6f; - } + if (abyssalDivingSuit && !player.IsUnderwater()) + { + float multiplier = 0.4f + abyssalDivingSuitPlateHits * 0.2f; + runAccMult *= multiplier; + runSpeedMult *= multiplier; + } + if (fabledTortoise) + { + float multiplier = shellBoost ? 0.8f : 0.5f; + runAccMult *= multiplier; + runSpeedMult *= multiplier; + } + if (ursaSergeant) + { + runAccMult *= 0.85f; + runSpeedMult *= 0.85f; + } + if (elysianGuard) + { + runAccMult *= 0.5f; + runSpeedMult *= 0.5f; + } + if ((player.slippy || player.slippy2) && player.iceSkate) + { + runAccMult *= 0.6f; + } - player.runAcceleration *= runAccMult; - player.maxRunSpeed *= runSpeedMult; - } + player.runAcceleration *= runAccMult; + player.maxRunSpeed *= runSpeedMult; + } #endregion #region DashEffects @@ -4203,16 +4203,16 @@ namespace CalamityMod.CalPlayer } bool playerDashing = player.pulley || (player.grappling[0] == -1 && !player.tongued); - if (playerDashing && dashMod == 9 && player.dashDelay < 0) - { - GodSlayerDodge(); - return true; - } + if (playerDashing && dashMod == 9 && player.dashDelay < 0) + { + GodSlayerDodge(); + return true; + } // Neither scarf can be used if either is on cooldown // TODO -- Why do the two scarves not use the same cooldown? They're both called "Scarf Cooldown". if (playerDashing && dashMod == 1 && player.dashDelay < 0 && dodgeScarf && !(player.HasCooldown(Cooldowns.CounterScarf.ID) || player.HasCooldown(Cooldowns.EvasionScarf.ID))) { - CounterScarfDodge(); + CounterScarfDodge(); return true; } @@ -4258,29 +4258,29 @@ namespace CalamityMod.CalPlayer NetMessage.SendData(MessageID.Dodge, -1, -1, null, player.whoAmI, 1f, 0f, 0f, 0, 0, 0); } - private void GodSlayerDodge() - { + private void GodSlayerDodge() + { player.GiveIFrames(player.longInvince ? 100 : 60, true); - Main.PlaySound(SoundID.Item, (int)player.position.X, (int)player.position.Y, 67); + Main.PlaySound(SoundID.Item, (int)player.position.X, (int)player.position.Y, 67); - for (int j = 0; j < 30; j++) - { - int num = Dust.NewDust(player.position, player.width, player.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num]; - dust.position.X += Main.rand.Next(-20, 21); - dust.position.Y += Main.rand.Next(-20, 21); - dust.velocity *= 0.4f; - dust.scale *= 1f + Main.rand.Next(40) * 0.01f; - dust.shader = GameShaders.Armor.GetSecondaryShader(player.cWaist, player); - if (Main.rand.NextBool(2)) - { - dust.scale *= 1f + Main.rand.Next(40) * 0.01f; - dust.noGravity = true; - } - } + for (int j = 0; j < 30; j++) + { + int num = Dust.NewDust(player.position, player.width, player.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[num]; + dust.position.X += Main.rand.Next(-20, 21); + dust.position.Y += Main.rand.Next(-20, 21); + dust.velocity *= 0.4f; + dust.scale *= 1f + Main.rand.Next(40) * 0.01f; + dust.shader = GameShaders.Armor.GetSecondaryShader(player.cWaist, player); + if (Main.rand.NextBool(2)) + { + dust.scale *= 1f + Main.rand.Next(40) * 0.01f; + dust.noGravity = true; + } + } - NetMessage.SendData(MessageID.Dodge, -1, -1, null, player.whoAmI, 1f, 0f, 0f, 0, 0, 0); - } + NetMessage.SendData(MessageID.Dodge, -1, -1, null, player.whoAmI, 1f, 0f, 0f, 0, 0, 0); + } private void CounterScarfDodge() { @@ -4334,9 +4334,9 @@ namespace CalamityMod.CalPlayer int lumenyl = Projectile.NewProjectile(player.Center.X, player.Center.Y, Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f), ModContent.ProjectileType(), (int)(55 * player.RogueDamage()), 0, player.whoAmI); Main.projectile[lumenyl].rotation = Main.rand.NextFloat(0, 360); Main.projectile[lumenyl].frame = Main.rand.Next(0, 4); - if (lumenyl.WithinBounds(Main.maxProjectiles)) - Main.projectile[lumenyl].Calamity().forceTypeless = true; - } + if (lumenyl.WithinBounds(Main.maxProjectiles)) + Main.projectile[lumenyl].Calamity().forceTypeless = true; + } // TODO -- Calamity dodges should probably not send a vanilla dodge packet considering that causes Tabi dust if (player.whoAmI == Main.myPlayer) @@ -4360,11 +4360,11 @@ namespace CalamityMod.CalPlayer Main.PlaySound(SoundID.Item68, player.Center); int eclipse = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(2750 * player.RogueDamage()), 0, player.whoAmI); - if (eclipse.WithinBounds(Main.maxProjectiles)) - Main.projectile[eclipse].Calamity().forceTypeless = true; + if (eclipse.WithinBounds(Main.maxProjectiles)) + Main.projectile[eclipse].Calamity().forceTypeless = true; - // TODO -- Calamity dodges should probably not send a vanilla dodge packet considering that causes Tabi dust - if (player.whoAmI == Main.myPlayer) + // TODO -- Calamity dodges should probably not send a vanilla dodge packet considering that causes Tabi dust + if (player.whoAmI == Main.myPlayer) { NetMessage.SendData(MessageID.Dodge, -1, -1, null, player.whoAmI, 1f, 0f, 0f, 0, 0, 0); } @@ -4465,38 +4465,38 @@ namespace CalamityMod.CalPlayer if (nCore && !player.HasCooldown(Cooldowns.NebulousCore.ID)) { - Main.PlaySound(SoundID.Item, (int)player.position.X, (int)player.position.Y, 67); + Main.PlaySound(SoundID.Item, (int)player.position.X, (int)player.position.Y, 67); - for (int j = 0; j < 50; j++) - { - int num = Dust.NewDust(player.position, player.width, player.height, 173, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num]; - dust.position.X += Main.rand.Next(-20, 21); - dust.position.Y += Main.rand.Next(-20, 21); - dust.velocity *= 0.9f; - dust.scale *= 1f + Main.rand.Next(40) * 0.01f; - dust.shader = GameShaders.Armor.GetSecondaryShader(player.cWaist, player); - if (Main.rand.NextBool(2)) - dust.scale *= 1f + Main.rand.Next(40) * 0.01f; - } + for (int j = 0; j < 50; j++) + { + int num = Dust.NewDust(player.position, player.width, player.height, 173, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[num]; + dust.position.X += Main.rand.Next(-20, 21); + dust.position.Y += Main.rand.Next(-20, 21); + dust.velocity *= 0.9f; + dust.scale *= 1f + Main.rand.Next(40) * 0.01f; + dust.shader = GameShaders.Armor.GetSecondaryShader(player.cWaist, player); + if (Main.rand.NextBool(2)) + dust.scale *= 1f + Main.rand.Next(40) * 0.01f; + } - player.statLife += 100; - player.HealEffect(100); + player.statLife += 100; + player.HealEffect(100); - if (player.statLife > player.statLifeMax2) - player.statLife = player.statLifeMax2; + if (player.statLife > player.statLifeMax2) + player.statLife = player.statLifeMax2; player.AddCooldown(Cooldowns.NebulousCore.ID, CalamityUtils.SecondsToFrames(90)); - return false; - } + return false; + } - if (dashMod == 9 && player.dashDelay < 0) - { - if (player.statLife < 1) - player.statLife = 1; + if (dashMod == 9 && player.dashDelay < 0) + { + if (player.statLife < 1) + player.statLife = 1; - return false; - } + return false; + } if (silvaSet && silvaCountdown > 0) { @@ -4742,10 +4742,10 @@ namespace CalamityMod.CalPlayer public override void ModifyWeaponDamage(Item item, ref float add, ref float mult, ref float flat) { if (item.type == ModContent.ItemType()) - mult += GaelsGreatsword.BaseDamage / (float)GaelsGreatsword.BaseDamage - 1f; + mult += GaelsGreatsword.BaseDamage / (float)GaelsGreatsword.BaseDamage - 1f; if (flamethrowerBoost && item.ranged && (item.useAmmo == AmmoID.Gel || CalamityLists.flamethrowerList.Contains(item.type))) - mult += hoverboardBoost ? 0.35f : 0.25f; + mult += hoverboardBoost ? 0.35f : 0.25f; if (item.ranged) acidRoundMultiplier = item.useTime / 20D; @@ -4996,12 +4996,12 @@ namespace CalamityMod.CalPlayer int defenseAdd = (int)(target.defense * 0.5); damage += defenseAdd; } - if (item.melee && badgeOfBravery) - { - int penetratableDefense = Math.Max(target.defense - player.armorPenetration, 0); - int penetratedDefense = Math.Min(penetratableDefense, 5); - damage += (int)(0.5f * penetratedDefense); - } + if (item.melee && badgeOfBravery) + { + int penetratableDefense = Math.Max(target.defense - player.armorPenetration, 0); + int penetratedDefense = Math.Min(penetratableDefense, 5); + damage += (int)(0.5f * penetratedDefense); + } #endregion if (draedonsHeart) @@ -5065,8 +5065,8 @@ namespace CalamityMod.CalPlayer if (isTrueMelee) { - // Add more true melee damage to the true melee projectile that scales with melee speed - // This is done because melee speed does nothing to melee weapons that are purely projectiles + // Add more true melee damage to the true melee projectile that scales with melee speed + // This is done because melee speed does nothing to melee weapons that are purely projectiles damageMult += trueMeleeDamage + ((1f - player.meleeSpeed) * (100f / player.meleeSpeed) / 100f * 0.25f); } @@ -5076,12 +5076,12 @@ namespace CalamityMod.CalPlayer damageMult += 0.05; } - if (enraged) + if (enraged) damageMult += 1.25; // Calamity buffs Inferno Fork by 33%. - // However, because the weapon is coded like spaghetti, you have to multiply the explosion's damage too. - if (proj.type == ProjectileID.InfernoFriendlyBlast) + // However, because the weapon is coded like spaghetti, you have to multiply the explosion's damage too. + if (proj.type == ProjectileID.InfernoFriendlyBlast) damageMult += 0.33; if (brimflameFrenzy && brimflameSet) @@ -5104,10 +5104,10 @@ namespace CalamityMod.CalPlayer damageMult += 0.1; } - // Adjust damage based on the damage multiplier + // Adjust damage based on the damage multiplier damage = (int)(damage * damageMult); - // Old Die damage multiplier, rolls again and takes the higher roll if it's a rogue projectile or the player is wearing rogue armor + // Old Die damage multiplier, rolls again and takes the higher roll if it's a rogue projectile or the player is wearing rogue armor if (oldDie) { float diceMult = Main.rand.NextFloat(0.9215f, 1.1205f); @@ -5158,16 +5158,16 @@ namespace CalamityMod.CalPlayer int penetrateAmt = 0; if (proj.Calamity().stealthStrike && proj.Calamity().rogue) { - // Nanotech is a total of 20 as it has all three bools + // Nanotech is a total of 20 as it has all three bools if (nanotech) penetrateAmt += 10; if (filthyGlove || bloodyGlove) penetrateAmt += 10; } - if (proj.melee && badgeOfBravery) - { - penetrateAmt += 5; - } + if (proj.melee && badgeOfBravery) + { + penetrateAmt += 5; + } int penetratableDefense = Math.Max(target.defense - player.armorPenetration, 0); //if find how much defense we can penetrate int penetratedDefense = Math.Min(penetratableDefense, penetrateAmt); //if we have more penetrate than enemy defense, use enemy defense damage += (int)(0.5f * penetratedDefense); @@ -5349,79 +5349,79 @@ namespace CalamityMod.CalPlayer damage = bossRushDamage; } - // Enemies deal less contact damage while sick, due to being weakened. - if (npc.poisoned) - { - int damageReductionFromPoison = (int)(damage * (npc.Calamity().irradiated > 0 ? 0.075 : 0.05)); - if (npc.Calamity().VulnerableToSickness.HasValue) - { - if (npc.Calamity().VulnerableToSickness.Value) - damageReductionFromPoison *= 2; - else - damageReductionFromPoison /= 2; - } + // Enemies deal less contact damage while sick, due to being weakened. + if (npc.poisoned) + { + int damageReductionFromPoison = (int)(damage * (npc.Calamity().irradiated > 0 ? 0.075 : 0.05)); + if (npc.Calamity().VulnerableToSickness.HasValue) + { + if (npc.Calamity().VulnerableToSickness.Value) + damageReductionFromPoison *= 2; + else + damageReductionFromPoison /= 2; + } - damage -= damageReductionFromPoison; - } + damage -= damageReductionFromPoison; + } - if (npc.venom) - { - int damageReductionFromVenom = (int)(damage * (npc.Calamity().irradiated > 0 ? 0.075 : 0.05)); - if (npc.Calamity().VulnerableToSickness.HasValue) - { - if (npc.Calamity().VulnerableToSickness.Value) - damageReductionFromVenom *= 2; - else - damageReductionFromVenom /= 2; - } + if (npc.venom) + { + int damageReductionFromVenom = (int)(damage * (npc.Calamity().irradiated > 0 ? 0.075 : 0.05)); + if (npc.Calamity().VulnerableToSickness.HasValue) + { + if (npc.Calamity().VulnerableToSickness.Value) + damageReductionFromVenom *= 2; + else + damageReductionFromVenom /= 2; + } - damage -= damageReductionFromVenom; - } + damage -= damageReductionFromVenom; + } - if (npc.Calamity().astralInfection > 0) - { - int damageReductionFromAstralInfection = (int)(damage * (npc.Calamity().irradiated > 0 ? 0.075 : 0.05)); - if (npc.Calamity().VulnerableToSickness.HasValue) - { - if (npc.Calamity().VulnerableToSickness.Value) - damageReductionFromAstralInfection *= 2; - else - damageReductionFromAstralInfection /= 2; - } + if (npc.Calamity().astralInfection > 0) + { + int damageReductionFromAstralInfection = (int)(damage * (npc.Calamity().irradiated > 0 ? 0.075 : 0.05)); + if (npc.Calamity().VulnerableToSickness.HasValue) + { + if (npc.Calamity().VulnerableToSickness.Value) + damageReductionFromAstralInfection *= 2; + else + damageReductionFromAstralInfection /= 2; + } - damage -= damageReductionFromAstralInfection; - } + damage -= damageReductionFromAstralInfection; + } - if (npc.Calamity().pFlames > 0) - { - int damageReductionFromPlague = (int)(damage * (npc.Calamity().irradiated > 0 ? 0.075 : 0.05)); - if (npc.Calamity().VulnerableToSickness.HasValue) - { - if (npc.Calamity().VulnerableToSickness.Value) - damageReductionFromPlague *= 2; - else - damageReductionFromPlague /= 2; - } + if (npc.Calamity().pFlames > 0) + { + int damageReductionFromPlague = (int)(damage * (npc.Calamity().irradiated > 0 ? 0.075 : 0.05)); + if (npc.Calamity().VulnerableToSickness.HasValue) + { + if (npc.Calamity().VulnerableToSickness.Value) + damageReductionFromPlague *= 2; + else + damageReductionFromPlague /= 2; + } - damage -= damageReductionFromPlague; - } + damage -= damageReductionFromPlague; + } - if (npc.Calamity().wDeath > 0) - { - int damageReductionFromWhisperingDeath = (int)(damage * (npc.Calamity().irradiated > 0 ? 0.15 : 0.1)); - if (npc.Calamity().VulnerableToSickness.HasValue) - { - if (npc.Calamity().VulnerableToSickness.Value) - damageReductionFromWhisperingDeath *= 2; - else - damageReductionFromWhisperingDeath /= 2; - } + if (npc.Calamity().wDeath > 0) + { + int damageReductionFromWhisperingDeath = (int)(damage * (npc.Calamity().irradiated > 0 ? 0.15 : 0.1)); + if (npc.Calamity().VulnerableToSickness.HasValue) + { + if (npc.Calamity().VulnerableToSickness.Value) + damageReductionFromWhisperingDeath *= 2; + else + damageReductionFromWhisperingDeath /= 2; + } - damage -= damageReductionFromWhisperingDeath; - } + damage -= damageReductionFromWhisperingDeath; + } - // Check if the player has iframes for the sake of avoiding defense damage. - bool hasIFrames = false; + // Check if the player has iframes for the sake of avoiding defense damage. + bool hasIFrames = false; for (int i = 0; i < player.hurtCooldowns.Length; i++) if (player.hurtCooldowns[i] > 0) hasIFrames = true; @@ -5436,7 +5436,7 @@ namespace CalamityMod.CalPlayer CalamityMod.bossVelocityDamageScaleValues.TryGetValue(npc.type, out float velocityScalar); if (((npc.type == NPCID.EyeofCthulhu || npc.type == NPCID.Spazmatism) && npc.ai[0] >= 2f) || (npc.type == NPCID.Plantera && npc.life / (float)npc.lifeMax <= 0.5f) || - (npc.type == ModContent.NPCType() && npc.life / (float)npc.lifeMax < 0.6f)) + (npc.type == ModContent.NPCType() && npc.life / (float)npc.lifeMax < 0.6f)) velocityScalar = CalamityMod.bitingEnemeyVelocityScale; if (npc.velocity == Vector2.Zero) @@ -5470,12 +5470,12 @@ namespace CalamityMod.CalPlayer if (fleshTotem && !player.HasCooldown(Cooldowns.FleshTotem.ID)) { - player.AddCooldown(Cooldowns.FleshTotem.ID, CalamityUtils.SecondsToFrames(20), true, coreOfTheBloodGod ? "bloodgod" : "default"); - contactDamageReduction += 0.5; + player.AddCooldown(Cooldowns.FleshTotem.ID, CalamityUtils.SecondsToFrames(20), true, coreOfTheBloodGod ? "bloodgod" : "default"); + contactDamageReduction += 0.5; } if (tarragonCloak && tarraMelee && !player.HasCooldown(Cooldowns.TarragonCloak.ID)) - contactDamageReduction += 0.5; + contactDamageReduction += 0.5; if (bloodflareMelee && bloodflareFrenzy && !player.HasCooldown(BloodflareFrenzy.ID)) contactDamageReduction += 0.5; @@ -5485,7 +5485,7 @@ namespace CalamityMod.CalPlayer if (npc.Calamity().relicOfResilienceWeakness > 0) { - contactDamageReduction += Items.Weapons.Typeless.RelicOfResilience.WeaknessDR; + contactDamageReduction += Items.Weapons.Typeless.RelicOfResilience.WeaknessDR; npc.Calamity().relicOfResilienceWeakness = 0; } @@ -5529,14 +5529,14 @@ namespace CalamityMod.CalPlayer if (CalamityWorld.revenge) { - if (adrenaline == adrenalineMax && !adrenalineModeActive) - { - double adrenalineDRBoost = 0D + - (adrenalineBoostOne ? 0.05 : 0D) + - (adrenalineBoostTwo ? 0.05 : 0D) + - (adrenalineBoostThree ? 0.05 : 0D); - contactDamageReduction += 0.5 + adrenalineDRBoost; - } + if (adrenaline == adrenalineMax && !adrenalineModeActive) + { + double adrenalineDRBoost = 0D + + (adrenalineBoostOne ? 0.05 : 0D) + + (adrenalineBoostTwo ? 0.05 : 0D) + + (adrenalineBoostThree ? 0.05 : 0D); + contactDamageReduction += 0.5 + adrenalineDRBoost; + } } if (player.mount.Active && (player.mount.Type == ModContent.MountType() || player.mount.Type == ModContent.MountType()) && Math.Abs(player.velocity.X) > player.mount.RunSpeed / 2f) @@ -5566,14 +5566,14 @@ namespace CalamityMod.CalPlayer // Contact damage reduction is reduced by DR Damage, which itself is proportional to defense damage if (totalDefenseDamage > 0 && defenseStat > 0) { - double drDamageRatio = CurrentDefenseDamage / (double)defenseStat; - if (drDamageRatio > 1D) - drDamageRatio = 1D; + double drDamageRatio = CurrentDefenseDamage / (double)defenseStat; + if (drDamageRatio > 1D) + drDamageRatio = 1D; contactDamageReduction *= 1D - drDamageRatio; if (contactDamageReduction < 0D) contactDamageReduction = 0D; - } + } // Scale with base damage reduction if (DRStat > 0) @@ -5608,37 +5608,37 @@ namespace CalamityMod.CalPlayer #region Modify Hit By Proj public override void ModifyHitByProjectile(Projectile proj, ref int damage, ref bool crit) { - if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => proj.type != x) && proj.active && !proj.friendly && proj.hostile && damage > 0) - { - // Reflects count as dodges. They share the timer and can be disabled by Armageddon right click. + if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => proj.type != x) && proj.active && !proj.friendly && proj.hostile && damage > 0) + { + // Reflects count as dodges. They share the timer and can be disabled by Armageddon right click. if (!disableAllDodges && !player.HasCooldown(GlobalDodge.ID)) - { - // The Evolution + { + // The Evolution if (projRefRare) - { - proj.hostile = false; - proj.friendly = true; - proj.velocity *= -2f; - proj.extraUpdates += 1; - proj.penetrate = 1; + { + proj.hostile = false; + proj.friendly = true; + proj.velocity *= -2f; + proj.extraUpdates += 1; + proj.penetrate = 1; player.GiveIFrames(20, false); damage = 0; - projRefRareLifeRegenCounter = 300; - projTypeJustHitBy = proj.type; + projRefRareLifeRegenCounter = 300; + projTypeJustHitBy = proj.type; player.AddCooldown(GlobalDodge.ID, EvolutionReflectCooldown); return; - } - } - } + } + } + } if (phantomicArtifact && player.ownedProjectileCounts[ModContent.ProjectileType()] != 0) { Projectile pro = Main.projectile.AsEnumerable().Where(projectile => projectile.friendly && projectile.owner == player.whoAmI && projectile.type == ModContent.ProjectileType()).First(); phantomicBulwarkCooldown = 1800; // 30 second cooldown pro.Kill(); - projectileDamageReduction += 0.2; + projectileDamageReduction += 0.2; } if (auralisAuroraCounter >= 300) @@ -5776,12 +5776,12 @@ namespace CalamityMod.CalPlayer proj.type == ProjectileID.BulletSnowman || proj.type == ProjectileID.BulletDeadeye || proj.type == ProjectileID.SniperBullet || proj.type == ProjectileID.VortexLaser) projectileDamageReduction += 0.5; } - if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => proj.type != x) && proj.active && !proj.friendly && proj.hostile && damage > 0) - { + if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => proj.type != x) && proj.active && !proj.friendly && proj.hostile && damage > 0) + { // Daedalus Reflect counts as a reflect but doesn't actually stop you from taking damage if (daedalusReflect && !disableAllDodges && !projRefRare && !player.HasCooldown(GlobalDodge.ID)) - projectileDamageReduction += 0.5; - } + projectileDamageReduction += 0.5; + } if (beeResist) @@ -5818,14 +5818,14 @@ namespace CalamityMod.CalPlayer if (CalamityWorld.revenge) { - if (adrenaline == adrenalineMax && !adrenalineModeActive) - { - double adrenalineDRBoost = 0D + - (adrenalineBoostOne ? 0.05 : 0D) + - (adrenalineBoostTwo ? 0.05 : 0D) + - (adrenalineBoostThree ? 0.05 : 0D); - projectileDamageReduction += 0.5 + adrenalineDRBoost; - } + if (adrenaline == adrenalineMax && !adrenalineModeActive) + { + double adrenalineDRBoost = 0D + + (adrenalineBoostOne ? 0.05 : 0D) + + (adrenalineBoostTwo ? 0.05 : 0D) + + (adrenalineBoostThree ? 0.05 : 0D); + projectileDamageReduction += 0.5 + adrenalineDRBoost; + } } if (player.mount.Active && (player.mount.Type == ModContent.MountType() || player.mount.Type == ModContent.MountType()) && Math.Abs(player.velocity.X) > player.mount.RunSpeed / 2f) @@ -5855,15 +5855,15 @@ namespace CalamityMod.CalPlayer // Projectile damage reduction is reduced by DR Damage, which itself is proportional to defense damage if (totalDefenseDamage > 0 && defenseStat > 0) { - double drDamageRatio = CurrentDefenseDamage / (double)defenseStat; - if (drDamageRatio > 1D) - drDamageRatio = 1D; + double drDamageRatio = CurrentDefenseDamage / (double)defenseStat; + if (drDamageRatio > 1D) + drDamageRatio = 1D; - projectileDamageReduction *= 1D - drDamageRatio; + projectileDamageReduction *= 1D - drDamageRatio; - if (projectileDamageReduction < 0D) - projectileDamageReduction = 0D; - } + if (projectileDamageReduction < 0D) + projectileDamageReduction = 0D; + } // Scale with base damage reduction if (DRStat > 0) @@ -6398,39 +6398,39 @@ namespace CalamityMod.CalPlayer } } } - #endregion + #endregion - #region On Hit - public override void OnHitByNPC(NPC npc, int damage, bool crit) - { - if (sulfurSet) - npc.AddBuff(BuffID.Poisoned, 120); + #region On Hit + public override void OnHitByNPC(NPC npc, int damage, bool crit) + { + if (sulfurSet) + npc.AddBuff(BuffID.Poisoned, 120); - if (npc.type == NPCID.ShadowFlameApparition || (npc.type == NPCID.ChaosBall && (Main.hardMode || areThereAnyDamnBosses))) - { - player.AddBuff(ModContent.BuffType(), 180); - } - else if (npc.type == NPCID.Spazmatism && npc.ai[0] != 1f && npc.ai[0] != 2f && npc.ai[0] != 0f) - { - player.AddBuff(BuffID.Bleeding, 300); - } - else if (npc.type == NPCID.Plantera && npc.life < npc.lifeMax / 2) - { - player.AddBuff(BuffID.Poisoned, 300); - } - else if (npc.type == NPCID.PlanterasTentacle) - { - player.AddBuff(BuffID.Poisoned, 180); - } - else if (npc.type == NPCID.AncientDoom) - { - player.AddBuff(ModContent.BuffType(), 120); - } - else if (npc.type == NPCID.AncientLight) - { - player.AddBuff(ModContent.BuffType(), 180); - } - } + if (npc.type == NPCID.ShadowFlameApparition || (npc.type == NPCID.ChaosBall && (Main.hardMode || areThereAnyDamnBosses))) + { + player.AddBuff(ModContent.BuffType(), 180); + } + else if (npc.type == NPCID.Spazmatism && npc.ai[0] != 1f && npc.ai[0] != 2f && npc.ai[0] != 0f) + { + player.AddBuff(BuffID.Bleeding, 300); + } + else if (npc.type == NPCID.Plantera && npc.life < npc.lifeMax / 2) + { + player.AddBuff(BuffID.Poisoned, 300); + } + else if (npc.type == NPCID.PlanterasTentacle) + { + player.AddBuff(BuffID.Poisoned, 180); + } + else if (npc.type == NPCID.AncientDoom) + { + player.AddBuff(ModContent.BuffType(), 120); + } + else if (npc.type == NPCID.AncientLight) + { + player.AddBuff(ModContent.BuffType(), 180); + } + } public override void OnHitByProjectile(Projectile proj, int damage, bool crit) { @@ -6508,32 +6508,32 @@ namespace CalamityMod.CalPlayer } } - // As these reflects do not cancel damage, they need to be in OnHit rather than ModifyHit - if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => proj.type != x) && proj.active && !proj.friendly && proj.hostile && damage > 0) - { - // The Transformer can reflect bullets + // As these reflects do not cancel damage, they need to be in OnHit rather than ModifyHit + if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => proj.type != x) && proj.active && !proj.friendly && proj.hostile && damage > 0) + { + // The Transformer can reflect bullets if (aSparkRare) - { - if (proj.type == ProjectileID.BulletSnowman || proj.type == ProjectileID.BulletDeadeye || proj.type == ProjectileID.SniperBullet || proj.type == ProjectileID.VortexLaser) - { - proj.hostile = false; - proj.friendly = true; - proj.velocity *= -1f; - proj.damage = (int)(proj.damage * 8 * player.AverageDamage()); + { + if (proj.type == ProjectileID.BulletSnowman || proj.type == ProjectileID.BulletDeadeye || proj.type == ProjectileID.SniperBullet || proj.type == ProjectileID.VortexLaser) + { + proj.hostile = false; + proj.friendly = true; + proj.velocity *= -1f; + proj.damage = (int)(proj.damage * 8 * player.AverageDamage()); proj.penetrate = 1; player.GiveIFrames(20, false); - } - } + } + } - // Reflects count as dodges. They share the timer and can be disabled by global dodge disabling effects. + // Reflects count as dodges. They share the timer and can be disabled by global dodge disabling effects. if (!disableAllDodges && !player.HasCooldown(GlobalDodge.ID)) - { - if (daedalusReflect && !projRefRare) - { - proj.hostile = false; - proj.friendly = true; - proj.velocity *= -1f; - proj.penetrate = 1; + { + if (daedalusReflect && !projRefRare) + { + proj.hostile = false; + proj.friendly = true; + proj.velocity *= -1f; + proj.penetrate = 1; player.GiveIFrames(20, false); damage /= 2; @@ -6541,8 +6541,8 @@ namespace CalamityMod.CalPlayer player.AddCooldown(GlobalDodge.ID, DaedalusReflectCooldown); // No return because the projectile hit isn't canceled -- it only does half damage. } - } - } + } + } } #endregion @@ -6623,9 +6623,9 @@ namespace CalamityMod.CalPlayer int knifeCol = Main.rand.Next(0, 2); int knife = Projectile.NewProjectile(player.Center, velocity, ModContent.ProjectileType(), knifeDamage, 0f, player.whoAmI, knifeCol, 0); - if (knife.WithinBounds(Main.maxProjectiles)) - Main.projectile[knife].Calamity().forceTypeless = true; - } + if (knife.WithinBounds(Main.maxProjectiles)) + Main.projectile[knife].Calamity().forceTypeless = true; + } } } } @@ -6641,9 +6641,9 @@ namespace CalamityMod.CalPlayer Vector2 startingPosition = Main.MouseWorld - Vector2.UnitY.RotatedByRandom(0.4f) * 1250f; Vector2 directionToMouse = (startingPosition - Main.MouseWorld).SafeNormalize(Vector2.UnitY).RotatedByRandom(0.1f); int drop = Projectile.NewProjectileDirect(startingPosition, directionToMouse * 12f, ModContent.ProjectileType(), (int)(damage * 0.3), 0f, player.whoAmI).penetrate = 2; - if (drop.WithinBounds(Main.maxProjectiles)) - Main.projectile[drop].Calamity().forceTypeless = true; - } + if (drop.WithinBounds(Main.maxProjectiles)) + Main.projectile[drop].Calamity().forceTypeless = true; + } } } } @@ -6734,11 +6734,11 @@ namespace CalamityMod.CalPlayer bool falling = player.gravDir == -1 ? player.velocity.Y < 0.05f : player.velocity.Y > 0.05f; if (player.controlJump && falling) { - if (!player.mount.Active) - { - player.velocity.Y *= 0.9f; - player.wingFrame = 3; - } + if (!player.mount.Active) + { + player.velocity.Y *= 0.9f; + player.wingFrame = 3; + } player.noFallDmg = true; player.fallStart = (int)(player.position.Y / 16f); } @@ -6769,17 +6769,17 @@ namespace CalamityMod.CalPlayer if (weakPetrification) WeakPetrification(); - // Disable vanilla dashes during god slayer dash - if (godSlayerDashHotKeyPressed) - { - // Set the player to have no registered vanilla dashes. - player.dash = 0; + // Disable vanilla dashes during god slayer dash + if (godSlayerDashHotKeyPressed) + { + // Set the player to have no registered vanilla dashes. + player.dash = 0; - // Prevent the possibility of Shield of Cthulhu invulnerability exploits. - player.eocHit = -1; - if (player.eocDash != 0) - player.eocDash = 0; - } + // Prevent the possibility of Shield of Cthulhu invulnerability exploits. + player.eocHit = -1; + if (player.eocDash != 0) + player.eocDash = 0; + } if (lol || (silvaCountdown > 0 && hasSilvaEffect && silvaSet) || (dashMod == 9 && player.dashDelay < 0)) { @@ -6832,13 +6832,13 @@ namespace CalamityMod.CalPlayer #region Pre Hurt public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { - #region Ignore Incoming Hits - // If any dodges are active which could dodge this hit, the hurting event is canceled (and the dodge is used). - if (HandleDodges()) - return false; + #region Ignore Incoming Hits + // If any dodges are active which could dodge this hit, the hurting event is canceled (and the dodge is used). + if (HandleDodges()) + return false; - // Lul makes the player completely invincible. - if (lol) + // Lul makes the player completely invincible. + if (lol) return false; // Unless holding Coldheart Icicle, the Purified Jam makes you completely invincible. @@ -6994,26 +6994,26 @@ namespace CalamityMod.CalPlayer CalamityNetcode.NewNPC_ClientSide(spawnPosition, ModContent.NPCType(), player); } - if (revivify) - { - int healAmt = (int)(damage / 15D); - player.statLife += healAmt; - player.HealEffect(healAmt); - } + if (revivify) + { + int healAmt = (int)(damage / 15D); + player.statLife += healAmt; + player.HealEffect(healAmt); + } - if (daedalusAbsorb && Main.rand.NextBool(10)) - { - int healAmt = (int)(damage / 2D); - player.statLife += healAmt; - player.HealEffect(healAmt); - } + if (daedalusAbsorb && Main.rand.NextBool(10)) + { + int healAmt = (int)(damage / 2D); + player.statLife += healAmt; + player.HealEffect(healAmt); + } - if (absorber) - { - int healAmt = (int)(damage / (sponge ? 16D : 20D)); - player.statLife += healAmt; - player.HealEffect(healAmt); - } + if (absorber) + { + int healAmt = (int)(damage / (sponge ? 16D : 20D)); + player.statLife += healAmt; + player.HealEffect(healAmt); + } if (witheringDamageDone > 0) { @@ -7037,10 +7037,10 @@ namespace CalamityMod.CalPlayer } } - if (evilSmasherBoost > 0) - evilSmasherBoost -= 1; + if (evilSmasherBoost > 0) + evilSmasherBoost -= 1; - hellbornBoost = 0; + hellbornBoost = 0; if (amidiasBlessing) { @@ -7150,8 +7150,8 @@ namespace CalamityMod.CalPlayer if (npcDist < freezeDist) { float duration = Main.rand.Next(10 + (int)damage / 4, 20 + (int)damage / 3); - if (duration > 120) - duration = 120; + if (duration > 120) + duration = 120; npc.AddBuff(ModContent.BuffType(), (int)duration, false); } @@ -7200,7 +7200,7 @@ namespace CalamityMod.CalPlayer polarisBoostTwo = false; polarisBoostThree = false; if (player.FindBuffIndex(ModContent.BuffType()) > -1) - player.ClearBuff(ModContent.BuffType()); + player.ClearBuff(ModContent.BuffType()); } } @@ -7410,13 +7410,13 @@ namespace CalamityMod.CalPlayer if (player.whoAmI == Main.myPlayer && !player.HasCooldown(Cooldowns.InkBomb.ID)) { player.AddCooldown(Cooldowns.InkBomb.ID, CalamityUtils.SecondsToFrames(20)); - rogueStealth += 0.5f; + rogueStealth += 0.5f; for (int i = 0; i < 5; i++) { - Main.PlaySound(SoundID.Item, (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y, 61); + Main.PlaySound(SoundID.Item, (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y, 61); int ink = Projectile.NewProjectile(player.Center.X, player.Center.Y, Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-0f, -4f), ModContent.ProjectileType(), 0, 0, player.whoAmI); if (ink.WithinBounds(Main.maxProjectiles)) - Main.projectile[ink].Calamity().forceTypeless = true; + Main.projectile[ink].Calamity().forceTypeless = true; } } } @@ -7678,7 +7678,7 @@ namespace CalamityMod.CalPlayer #region Dash Stuff public void ModDashMovement() { - if (dashMod == 4 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // Asgardian Aegis + if (dashMod == 4 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // Asgardian Aegis { Rectangle rectangle = new Rectangle((int)((double)player.position.X + (double)player.velocity.X * 0.5 - 4.0), (int)((double)player.position.Y + (double)player.velocity.Y * 0.5 - 4.0), player.width + 8, player.height + 8); for (int i = 0; i < Main.maxNPCs; i++) @@ -7687,41 +7687,41 @@ namespace CalamityMod.CalPlayer if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.Calamity().dashImmunityTime[player.whoAmI] <= 0) { Rectangle rect = npc.getRect(); - if (rectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) - { - float num = 300f * player.AverageDamage(); - float num2 = 15f; - bool crit = false; - if (player.kbGlove) - { - num2 *= 2f; - } - if (player.kbBuff) - { - num2 *= 1.5f; - } - if (Main.rand.Next(100) < player.meleeCrit) - { - crit = true; - } - int direction = player.direction; - if (player.velocity.X < 0f) - { - direction = -1; - } - if (player.velocity.X > 0f) - { - direction = 1; - } - player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); - Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(135 * player.AverageDamage()), 20f, Main.myPlayer, 0f, 0f); - Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(90 * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); - if (npc.Calamity().dashImmunityTime[player.whoAmI] < 6) - npc.Calamity().dashImmunityTime[player.whoAmI] = 6; - npc.AddBuff(ModContent.BuffType(), 300); + if (rectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) + { + float num = 300f * player.AverageDamage(); + float num2 = 15f; + bool crit = false; + if (player.kbGlove) + { + num2 *= 2f; + } + if (player.kbBuff) + { + num2 *= 1.5f; + } + if (Main.rand.Next(100) < player.meleeCrit) + { + crit = true; + } + int direction = player.direction; + if (player.velocity.X < 0f) + { + direction = -1; + } + if (player.velocity.X > 0f) + { + direction = 1; + } + player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(135 * player.AverageDamage()), 20f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(90 * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); + if (npc.Calamity().dashImmunityTime[player.whoAmI] < 6) + npc.Calamity().dashImmunityTime[player.whoAmI] = 6; + npc.AddBuff(ModContent.BuffType(), 300); player.GiveIFrames(AsgardianAegis.ShieldSlamIFrames, false); - } + } } } } @@ -7734,37 +7734,37 @@ namespace CalamityMod.CalPlayer if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.Calamity().dashImmunityTime[player.whoAmI] <= 0) { Rectangle rect = npc.getRect(); - if (rectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) - { - float num = 250f * player.AverageDamage(); - float num2 = 12f; - bool crit = false; - if (player.kbGlove) - { - num2 *= 2f; - } - if (player.kbBuff) - { - num2 *= 1.5f; - } - if (Main.rand.Next(100) < player.meleeCrit) - { - crit = true; - } - int direction = player.direction; - if (player.velocity.X < 0f) - { - direction = -1; - } - if (player.velocity.X > 0f) - { - direction = 1; - } - player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); - Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(120 * player.AverageDamage()), 15f, Main.myPlayer, 0f, 0f); - Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(80 * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); - if (npc.Calamity().dashImmunityTime[player.whoAmI] < 6) - npc.Calamity().dashImmunityTime[player.whoAmI] = 6; + if (rectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) + { + float num = 250f * player.AverageDamage(); + float num2 = 12f; + bool crit = false; + if (player.kbGlove) + { + num2 *= 2f; + } + if (player.kbBuff) + { + num2 *= 1.5f; + } + if (Main.rand.Next(100) < player.meleeCrit) + { + crit = true; + } + int direction = player.direction; + if (player.velocity.X < 0f) + { + direction = -1; + } + if (player.velocity.X > 0f) + { + direction = 1; + } + player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(120 * player.AverageDamage()), 15f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(80 * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); + if (npc.Calamity().dashImmunityTime[player.whoAmI] < 6) + npc.Calamity().dashImmunityTime[player.whoAmI] = 6; player.GiveIFrames(ElysianAegis.ShieldSlamIFrames, false); } @@ -7780,88 +7780,88 @@ namespace CalamityMod.CalPlayer if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.Calamity().dashImmunityTime[player.whoAmI] <= 0) { Rectangle rect = npc.getRect(); - if (rectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) - { - float num = 100f * player.AverageDamage(); - float num2 = 9f; - bool crit = false; - if (player.kbGlove) - { - num2 *= 2f; - } - if (player.kbBuff) - { - num2 *= 1.5f; - } - if (Main.rand.Next(100) < player.meleeCrit) - { - crit = true; - } - int direction = player.direction; - if (player.velocity.X < 0f) - { - direction = -1; - } - if (player.velocity.X > 0f) - { - direction = 1; - } - player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); - Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(60 * player.AverageDamage()), 15f, Main.myPlayer, 0f, 0f); - if (npc.Calamity().dashImmunityTime[player.whoAmI] < 6) - npc.Calamity().dashImmunityTime[player.whoAmI] = 6; + if (rectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) + { + float num = 100f * player.AverageDamage(); + float num2 = 9f; + bool crit = false; + if (player.kbGlove) + { + num2 *= 2f; + } + if (player.kbBuff) + { + num2 *= 1.5f; + } + if (Main.rand.Next(100) < player.meleeCrit) + { + crit = true; + } + int direction = player.direction; + if (player.velocity.X < 0f) + { + direction = -1; + } + if (player.velocity.X > 0f) + { + direction = 1; + } + player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(60 * player.AverageDamage()), 15f, Main.myPlayer, 0f, 0f); + if (npc.Calamity().dashImmunityTime[player.whoAmI] < 6) + npc.Calamity().dashImmunityTime[player.whoAmI] = 6; player.GiveIFrames(AsgardsValor.ShieldSlamIFrames, false); } } } } - if (dashMod == 6 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // Ornate Shield - { - Rectangle rectangle = new Rectangle((int)((double)player.position.X + (double)player.velocity.X * 0.5 - 4.0), (int)((double)player.position.Y + (double)player.velocity.Y * 0.5 - 4.0), player.width + 8, player.height + 8); - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.Calamity().dashImmunityTime[player.whoAmI] <= 0) - { - Rectangle rect = npc.getRect(); - if (rectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) - { - float num = 50f * player.AverageDamage(); - float num2 = 3f; - bool crit = false; - if (player.kbGlove) - { - num2 *= 2f; - } - if (player.kbBuff) - { - num2 *= 1.5f; - } - if (Main.rand.Next(100) < player.meleeCrit) - { - crit = true; - } - int direction = player.direction; - if (player.velocity.X < 0f) - { - direction = -1; - } - if (player.velocity.X > 0f) - { - direction = 1; - } - player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); - if (npc.Calamity().dashImmunityTime[player.whoAmI] < 6) - npc.Calamity().dashImmunityTime[player.whoAmI] = 6; - npc.AddBuff(BuffID.Frostburn, 300); + if (dashMod == 6 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // Ornate Shield + { + Rectangle rectangle = new Rectangle((int)((double)player.position.X + (double)player.velocity.X * 0.5 - 4.0), (int)((double)player.position.Y + (double)player.velocity.Y * 0.5 - 4.0), player.width + 8, player.height + 8); + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.Calamity().dashImmunityTime[player.whoAmI] <= 0) + { + Rectangle rect = npc.getRect(); + if (rectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) + { + float num = 50f * player.AverageDamage(); + float num2 = 3f; + bool crit = false; + if (player.kbGlove) + { + num2 *= 2f; + } + if (player.kbBuff) + { + num2 *= 1.5f; + } + if (Main.rand.Next(100) < player.meleeCrit) + { + crit = true; + } + int direction = player.direction; + if (player.velocity.X < 0f) + { + direction = -1; + } + if (player.velocity.X > 0f) + { + direction = 1; + } + player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); + if (npc.Calamity().dashImmunityTime[player.whoAmI] < 6) + npc.Calamity().dashImmunityTime[player.whoAmI] = 6; + npc.AddBuff(BuffID.Frostburn, 300); player.GiveIFrames(OrnateShield.ShieldSlamIFrames, false); } - } - } - } - if (dashMod == 8 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // Plaguebringer Armor + } + } + } + if (dashMod == 8 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // Plaguebringer Armor { 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.maxNPCs; i++) @@ -7886,7 +7886,7 @@ namespace CalamityMod.CalPlayer } player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); if (npc.Calamity().dashImmunityTime[player.whoAmI] < 6) - npc.Calamity().dashImmunityTime[player.whoAmI] = 6; + npc.Calamity().dashImmunityTime[player.whoAmI] = 6; npc.AddBuff(ModContent.BuffType(), 300); player.GiveIFrames(PlaguebringerVisor.PlagueDashIFrames, false); @@ -7894,67 +7894,67 @@ namespace CalamityMod.CalPlayer } } } - if (dashMod == 9 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // God Slayer Armor - { - Rectangle rectangle = new Rectangle((int)((double)player.position.X + (double)player.velocity.X * 0.5 - 4.0), (int)((double)player.position.Y + (double)player.velocity.Y * 0.5 - 4.0), player.width + 8, player.height + 8); - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.Calamity().dashImmunityTime[player.whoAmI] <= 0) - { - Rectangle rect = npc.getRect(); - if (rectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) - { - Main.PlaySound(SoundID.Item, (int)player.position.X, (int)player.position.Y, 67); + if (dashMod == 9 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // God Slayer Armor + { + Rectangle rectangle = new Rectangle((int)((double)player.position.X + (double)player.velocity.X * 0.5 - 4.0), (int)((double)player.position.Y + (double)player.velocity.Y * 0.5 - 4.0), player.width + 8, player.height + 8); + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.Calamity().dashImmunityTime[player.whoAmI] <= 0) + { + Rectangle rect = npc.getRect(); + if (rectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) + { + Main.PlaySound(SoundID.Item, (int)player.position.X, (int)player.position.Y, 67); - for (int j = 0; j < 30; j++) - { - int dust = Dust.NewDust(player.position, player.width, player.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Dust dust2 = Main.dust[dust]; - dust2.position.X += Main.rand.Next(-20, 21); - dust2.position.Y += Main.rand.Next(-20, 21); - dust2.velocity *= 0.9f; - dust2.scale *= 1f + Main.rand.Next(40) * 0.01f; - dust2.shader = GameShaders.Armor.GetSecondaryShader(player.cWaist, player); - if (Main.rand.NextBool(2)) - dust2.scale *= 1f + Main.rand.Next(40) * 0.01f; - } + for (int j = 0; j < 30; j++) + { + int dust = Dust.NewDust(player.position, player.width, player.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Dust dust2 = Main.dust[dust]; + dust2.position.X += Main.rand.Next(-20, 21); + dust2.position.Y += Main.rand.Next(-20, 21); + dust2.velocity *= 0.9f; + dust2.scale *= 1f + Main.rand.Next(40) * 0.01f; + dust2.shader = GameShaders.Armor.GetSecondaryShader(player.cWaist, player); + if (Main.rand.NextBool(2)) + dust2.scale *= 1f + Main.rand.Next(40) * 0.01f; + } - float num = 3000f * player.AverageDamage(); - float num2 = 15f; - bool crit = false; - if (player.kbGlove) - { - num2 *= 2f; - } - if (player.kbBuff) - { - num2 *= 1.5f; - } - if (Main.rand.Next(100) < player.meleeCrit) - { - crit = true; - } - int direction = player.direction; - if (player.velocity.X < 0f) - { - direction = -1; - } - if (player.velocity.X > 0f) - { - direction = 1; - } - player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); - if (npc.Calamity().dashImmunityTime[player.whoAmI] < 6) - npc.Calamity().dashImmunityTime[player.whoAmI] = 6; - npc.AddBuff(ModContent.BuffType(), 300); + float num = 3000f * player.AverageDamage(); + float num2 = 15f; + bool crit = false; + if (player.kbGlove) + { + num2 *= 2f; + } + if (player.kbBuff) + { + num2 *= 1.5f; + } + if (Main.rand.Next(100) < player.meleeCrit) + { + crit = true; + } + int direction = player.direction; + if (player.velocity.X < 0f) + { + direction = -1; + } + if (player.velocity.X > 0f) + { + direction = 1; + } + player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); + if (npc.Calamity().dashImmunityTime[player.whoAmI] < 6) + npc.Calamity().dashImmunityTime[player.whoAmI] = 6; + npc.AddBuff(ModContent.BuffType(), 300); player.GiveIFrames(GodSlayerChestplate.DashIFrames, false); } - } - } - } - if (player.dashDelay > 0) + } + } + } + if (player.dashDelay > 0) { return; } @@ -8046,23 +8046,23 @@ namespace CalamityMod.CalPlayer } num7 = 18f; } - else if (dashMod == 6) // Ornate Shield - { - for (int m = 0; m < 24; m++) - { - int num14 = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 4f), player.width, player.height - 8, 67, 0f, 0f, 100, default, 1f); - Main.dust[num14].velocity *= 0.1f; - Main.dust[num14].scale *= 1f + (float)Main.rand.Next(20) * 0.01f; - Main.dust[num14].shader = GameShaders.Armor.GetSecondaryShader(player.ArmorSetDye(), player); - Main.dust[num14].noGravity = true; - if (Main.rand.NextBool(2)) - { - Main.dust[num14].fadeIn = 0.5f; - } - } - num7 = 12.5f; - } - else if (dashMod == 7) // Statis' Belt of Curses + else if (dashMod == 6) // Ornate Shield + { + for (int m = 0; m < 24; m++) + { + int num14 = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 4f), player.width, player.height - 8, 67, 0f, 0f, 100, default, 1f); + Main.dust[num14].velocity *= 0.1f; + Main.dust[num14].scale *= 1f + (float)Main.rand.Next(20) * 0.01f; + Main.dust[num14].shader = GameShaders.Armor.GetSecondaryShader(player.ArmorSetDye(), player); + Main.dust[num14].noGravity = true; + if (Main.rand.NextBool(2)) + { + Main.dust[num14].fadeIn = 0.5f; + } + } + num7 = 12.5f; + } + else if (dashMod == 7) // Statis' Belt of Curses { statisTimer++; for (int k = 0; k < 2; k++) @@ -8108,92 +8108,92 @@ namespace CalamityMod.CalPlayer } num7 = 12.5f; } - else if (dashMod == 9) // God Slayer Armor - { - player.maxFallSpeed = 50f; - for (int m = 0; m < 24; m++) - { - int num14 = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 4f), player.width, player.height - 8, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2.75f); - Main.dust[num14].velocity *= 0.1f; - Main.dust[num14].scale *= 1f + (float)Main.rand.Next(20) * 0.01f; - Main.dust[num14].shader = GameShaders.Armor.GetSecondaryShader(player.ArmorSetDye(), player); - Main.dust[num14].noGravity = true; - if (Main.rand.NextBool(2)) - { - Main.dust[num14].fadeIn = 0.5f; - } - } - num7 = 40f; // 46 frames before hitting this gate value - num10 = 0.8f; - } - if (dashMod > 0) + else if (dashMod == 9) // God Slayer Armor + { + player.maxFallSpeed = 50f; + for (int m = 0; m < 24; m++) + { + int num14 = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 4f), player.width, player.height - 8, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2.75f); + Main.dust[num14].velocity *= 0.1f; + Main.dust[num14].scale *= 1f + (float)Main.rand.Next(20) * 0.01f; + Main.dust[num14].shader = GameShaders.Armor.GetSecondaryShader(player.ArmorSetDye(), player); + Main.dust[num14].noGravity = true; + if (Main.rand.NextBool(2)) + { + Main.dust[num14].fadeIn = 0.5f; + } + } + num7 = 40f; // 46 frames before hitting this gate value + num10 = 0.8f; + } + if (dashMod > 0) { player.vortexStealthActive = false; - if (dashMod == 9) - { - if (player.velocity.Length() > num7) - { - player.velocity *= num8; - return; - } - if (player.velocity.Length() > num9) - { - player.velocity *= num10; - return; - } - } - else - { - if (player.velocity.X > num7 || player.velocity.X < -num7) - { - player.velocity.X *= num8; - return; - } - if (player.velocity.X > num9 || player.velocity.X < -num9) - { - player.velocity.X *= num10; - return; - } - } + if (dashMod == 9) + { + if (player.velocity.Length() > num7) + { + player.velocity *= num8; + return; + } + if (player.velocity.Length() > num9) + { + player.velocity *= num10; + return; + } + } + else + { + if (player.velocity.X > num7 || player.velocity.X < -num7) + { + player.velocity.X *= num8; + return; + } + if (player.velocity.X > num9 || player.velocity.X < -num9) + { + player.velocity.X *= num10; + return; + } + } player.dashDelay = delay; - // Cooldown for God Slayer Armor dash - if (dashMod == 9) - { + // Cooldown for God Slayer Armor dash + if (dashMod == 9) + { player.AddCooldown(GodSlayerDash.ID, CalamityUtils.SecondsToFrames(35)); - godSlayerDashHotKeyPressed = false; - } + godSlayerDashHotKeyPressed = false; + } - if (dashMod == 9) - { - if (player.velocity.Length() < 0f) - { - player.velocity.Normalize(); - player.velocity *= -num9; - return; - } - if (player.velocity.Length() > 0f) - { - player.velocity.Normalize(); - player.velocity *= num9; - return; - } - } - else - { - if (player.velocity.X < 0f) - { - player.velocity.X = -num9; - return; - } - if (player.velocity.X > 0f) - { - player.velocity.X = num9; - return; - } - } + if (dashMod == 9) + { + if (player.velocity.Length() < 0f) + { + player.velocity.Normalize(); + player.velocity *= -num9; + return; + } + if (player.velocity.Length() > 0f) + { + player.velocity.Normalize(); + player.velocity *= num9; + return; + } + } + else + { + if (player.velocity.X < 0f) + { + player.velocity.X = -num9; + return; + } + if (player.velocity.X > 0f) + { + player.velocity.X = num9; + return; + } + } } } else if (dashMod > 0 && !player.mount.Active) @@ -8286,25 +8286,25 @@ namespace CalamityMod.CalPlayer } } } - else if (dashMod == 6) // Ornate Shield - { - if (DoADash(16.9f)) - { - for (int d = 0; d < 60; d++) - { - int idx = Dust.NewDust(player.position, player.width, player.height, 67, 0f, 0f, 100, default, 1.25f); - Dust dust = Main.dust[idx]; - dust.position.X += Main.rand.NextFloat(-5f, 5f); - dust.position.Y += Main.rand.NextFloat(-5f, 5f); - dust.velocity *= 0.2f; - dust.scale *= Main.rand.NextFloat(1f, 1.2f); - dust.shader = GameShaders.Armor.GetSecondaryShader(player.ArmorSetDye(), player); - dust.noGravity = true; - dust.fadeIn = 0.5f; - } - } - } - else if (dashMod == 7) // Statis' Belt of Curses + else if (dashMod == 6) // Ornate Shield + { + if (DoADash(16.9f)) + { + for (int d = 0; d < 60; d++) + { + int idx = Dust.NewDust(player.position, player.width, player.height, 67, 0f, 0f, 100, default, 1.25f); + Dust dust = Main.dust[idx]; + dust.position.X += Main.rand.NextFloat(-5f, 5f); + dust.position.Y += Main.rand.NextFloat(-5f, 5f); + dust.velocity *= 0.2f; + dust.scale *= Main.rand.NextFloat(1f, 1.2f); + dust.shader = GameShaders.Armor.GetSecondaryShader(player.ArmorSetDye(), player); + dust.noGravity = true; + dust.fadeIn = 0.5f; + } + } + } + else if (dashMod == 7) // Statis' Belt of Curses { if (DoADash(25.4f)) { @@ -8338,32 +8338,32 @@ namespace CalamityMod.CalPlayer } } } - else if (dashMod == 9) // God Slayer Armor - { - if (DoADash(80f)) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); + else if (dashMod == 9) // God Slayer Armor + { + if (DoADash(80f)) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); - for (int d = 0; d < 60; d++) - { - int idx = Dust.NewDust(player.position, player.width, player.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Dust dust = Main.dust[idx]; - dust.position.X += Main.rand.NextFloat(-5f, 5f); - dust.position.Y += Main.rand.NextFloat(-5f, 5f); - dust.velocity *= 0.2f; - dust.scale *= Main.rand.NextFloat(1f, 1.2f); - dust.shader = GameShaders.Armor.GetSecondaryShader(player.ArmorSetDye(), player); - dust.noGravity = true; - dust.fadeIn = 0.5f; - } - } - } - } + for (int d = 0; d < 60; d++) + { + int idx = Dust.NewDust(player.position, player.width, player.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Dust dust = Main.dust[idx]; + dust.position.X += Main.rand.NextFloat(-5f, 5f); + dust.position.Y += Main.rand.NextFloat(-5f, 5f); + dust.velocity *= 0.2f; + dust.scale *= Main.rand.NextFloat(1f, 1.2f); + dust.shader = GameShaders.Armor.GetSecondaryShader(player.ArmorSetDye(), player); + dust.noGravity = true; + dust.fadeIn = 0.5f; + } + } + } + } } private bool DoADash(float dashDistance) { - bool godSlayerDash = dashMod == 9; + bool godSlayerDash = dashMod == 9; bool justDashed = false; int direction = 0; @@ -8372,186 +8372,186 @@ namespace CalamityMod.CalPlayer if (dashTimeMod < 0) dashTimeMod++; - if (godSlayerDash) - { - if (player.controlUp && player.controlLeft) - { - if (dashTimeMod < 0) - { - direction = -4; - justDashed = true; - dashTimeMod = 0; - } - else - dashTimeMod = -15; - } - else if (player.controlUp && player.controlRight) - { - if (dashTimeMod > 0) - { - direction = 4; - justDashed = true; - dashTimeMod = 0; - } - else - dashTimeMod = 15; - } - else if (player.controlDown && player.controlLeft) - { - if (dashTimeMod < 0) - { - direction = -3; - justDashed = true; - dashTimeMod = 0; - player.maxFallSpeed = 50f; - } - else - dashTimeMod = -15; - } - else if (player.controlDown && player.controlRight) - { - if (dashTimeMod > 0) - { - direction = 3; - justDashed = true; - dashTimeMod = 0; - player.maxFallSpeed = 50f; - } - else - dashTimeMod = 15; - } - else if (player.controlUp) - { - if (dashTimeMod < 0) - { - direction = -2; - justDashed = true; - dashTimeMod = 0; - } - else - dashTimeMod = -15; - } - else if (player.controlDown) - { - if (dashTimeMod > 0) - { - direction = 2; - justDashed = true; - dashTimeMod = 0; - player.maxFallSpeed = 50f; - } - else - dashTimeMod = 15; - } - else if (player.controlLeft) - { - if (dashTimeMod < 0) - { - direction = -1; - justDashed = true; - dashTimeMod = 0; - } - else - dashTimeMod = -15; - } - else if (player.controlRight) - { - if (dashTimeMod > 0) - { - direction = 1; - justDashed = true; - dashTimeMod = 0; - } - else - dashTimeMod = 15; - } - } - else - { - if (player.controlRight && player.releaseRight) - { - if (dashTimeMod > 0) - { - direction = 1; - justDashed = true; - dashTimeMod = 0; - } - else - dashTimeMod = 15; - } - else if (player.controlLeft && player.releaseLeft) - { - if (dashTimeMod < 0) - { - direction = -1; - justDashed = true; - dashTimeMod = 0; - } - else - dashTimeMod = -15; - } - } + if (godSlayerDash) + { + if (player.controlUp && player.controlLeft) + { + if (dashTimeMod < 0) + { + direction = -4; + justDashed = true; + dashTimeMod = 0; + } + else + dashTimeMod = -15; + } + else if (player.controlUp && player.controlRight) + { + if (dashTimeMod > 0) + { + direction = 4; + justDashed = true; + dashTimeMod = 0; + } + else + dashTimeMod = 15; + } + else if (player.controlDown && player.controlLeft) + { + if (dashTimeMod < 0) + { + direction = -3; + justDashed = true; + dashTimeMod = 0; + player.maxFallSpeed = 50f; + } + else + dashTimeMod = -15; + } + else if (player.controlDown && player.controlRight) + { + if (dashTimeMod > 0) + { + direction = 3; + justDashed = true; + dashTimeMod = 0; + player.maxFallSpeed = 50f; + } + else + dashTimeMod = 15; + } + else if (player.controlUp) + { + if (dashTimeMod < 0) + { + direction = -2; + justDashed = true; + dashTimeMod = 0; + } + else + dashTimeMod = -15; + } + else if (player.controlDown) + { + if (dashTimeMod > 0) + { + direction = 2; + justDashed = true; + dashTimeMod = 0; + player.maxFallSpeed = 50f; + } + else + dashTimeMod = 15; + } + else if (player.controlLeft) + { + if (dashTimeMod < 0) + { + direction = -1; + justDashed = true; + dashTimeMod = 0; + } + else + dashTimeMod = -15; + } + else if (player.controlRight) + { + if (dashTimeMod > 0) + { + direction = 1; + justDashed = true; + dashTimeMod = 0; + } + else + dashTimeMod = 15; + } + } + else + { + if (player.controlRight && player.releaseRight) + { + if (dashTimeMod > 0) + { + direction = 1; + justDashed = true; + dashTimeMod = 0; + } + else + dashTimeMod = 15; + } + else if (player.controlLeft && player.releaseLeft) + { + if (dashTimeMod < 0) + { + direction = -1; + justDashed = true; + dashTimeMod = 0; + } + else + dashTimeMod = -15; + } + } if (justDashed) { - int totalDirections = 8; - float radians = MathHelper.TwoPi / totalDirections; - Vector2 spinningPoint = new Vector2(0f, -dashDistance); - Vector2[] possibleVelocities = new Vector2[totalDirections]; - for (int k = 0; k < totalDirections; k++) - possibleVelocities[k] = spinningPoint.RotatedBy(radians * k); + int totalDirections = 8; + float radians = MathHelper.TwoPi / totalDirections; + Vector2 spinningPoint = new Vector2(0f, -dashDistance); + Vector2[] possibleVelocities = new Vector2[totalDirections]; + for (int k = 0; k < totalDirections; k++) + possibleVelocities[k] = spinningPoint.RotatedBy(radians * k); - switch (direction) - { - // Up Left - case -4: - player.velocity = possibleVelocities[7]; - break; + switch (direction) + { + // Up Left + case -4: + player.velocity = possibleVelocities[7]; + break; - // Down Left - case -3: - player.velocity = possibleVelocities[5]; - break; + // Down Left + case -3: + player.velocity = possibleVelocities[5]; + break; - // Up - case -2: - player.velocity = possibleVelocities[0]; - break; + // Up + case -2: + player.velocity = possibleVelocities[0]; + break; - // Left - case -1: - player.velocity = godSlayerDash ? possibleVelocities[6] : new Vector2(possibleVelocities[6].X, player.velocity.Y); - break; + // Left + case -1: + player.velocity = godSlayerDash ? possibleVelocities[6] : new Vector2(possibleVelocities[6].X, player.velocity.Y); + break; - // Nothing - case 0: - break; + // Nothing + case 0: + break; - // Right - case 1: - player.velocity = godSlayerDash ? possibleVelocities[2] : new Vector2(possibleVelocities[2].X, player.velocity.Y); - break; + // Right + case 1: + player.velocity = godSlayerDash ? possibleVelocities[2] : new Vector2(possibleVelocities[2].X, player.velocity.Y); + break; - // Down - case 2: - player.velocity = possibleVelocities[4]; - break; + // Down + case 2: + player.velocity = possibleVelocities[4]; + break; - // Down Right - case 3: - player.velocity = possibleVelocities[3]; - break; + // Down Right + case 3: + player.velocity = possibleVelocities[3]; + break; - // Up Right - case 4: - player.velocity = possibleVelocities[1]; - break; - } + // Up Right + case 4: + player.velocity = possibleVelocities[1]; + break; + } - Point point5 = (player.Center + new Vector2(MathHelper.Clamp(direction, -1f, 1f) * player.width / 2 + 2, player.gravDir * -player.height / 2f + player.gravDir * 2f)).ToTileCoordinates(); - Point point6 = (player.Center + new Vector2(MathHelper.Clamp(direction, -1f, 1f) * player.width / 2 + 2, 0f)).ToTileCoordinates(); - if (WorldGen.SolidOrSlopedTile(point5.X, point5.Y) || WorldGen.SolidOrSlopedTile(point6.X, point6.Y)) - player.velocity.X /= 2f; + Point point5 = (player.Center + new Vector2(MathHelper.Clamp(direction, -1f, 1f) * player.width / 2 + 2, player.gravDir * -player.height / 2f + player.gravDir * 2f)).ToTileCoordinates(); + Point point6 = (player.Center + new Vector2(MathHelper.Clamp(direction, -1f, 1f) * player.width / 2 + 2, 0f)).ToTileCoordinates(); + if (WorldGen.SolidOrSlopedTile(point5.X, point5.Y) || WorldGen.SolidOrSlopedTile(point6.X, point6.Y)) + player.velocity.X /= 2f; player.dashDelay = -1; } @@ -8627,14 +8627,14 @@ namespace CalamityMod.CalPlayer Main.dust[num7].velocity.Y *= 0.2f; Main.dust[num7].shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } - else if (dashMod == 9) - { - int num7 = Dust.NewDust(new Vector2(player.position.X - 4f, player.position.Y + (float)player.height + (float)num3), player.width + 8, 4, (int)CalamityDusts.PurpleCosmilite, -player.velocity.X * 0.5f, player.velocity.Y * 0.5f, 50, default, 3f); - Main.dust[num7].velocity.X *= 0.2f; - Main.dust[num7].velocity.Y *= 0.2f; - Main.dust[num7].shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); - } - } + else if (dashMod == 9) + { + int num7 = Dust.NewDust(new Vector2(player.position.X - 4f, player.position.Y + (float)player.height + (float)num3), player.width + 8, 4, (int)CalamityDusts.PurpleCosmilite, -player.velocity.X * 0.5f, player.velocity.Y * 0.5f, 50, default, 3f); + Main.dust[num7].velocity.X *= 0.2f; + Main.dust[num7].velocity.Y *= 0.2f; + Main.dust[num7].shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); + } + } } else if (player.controlRight && player.velocity.X < player.accRunSpeed && player.dashDelay >= 0) { @@ -8701,14 +8701,14 @@ namespace CalamityMod.CalPlayer Main.dust[num12].velocity.Y *= 0.2f; Main.dust[num12].shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } - else if (dashMod == 9) - { - int num12 = Dust.NewDust(new Vector2(player.position.X - 4f, player.position.Y + (float)player.height + (float)num8), player.width + 8, 4, (int)CalamityDusts.PurpleCosmilite, -player.velocity.X * 0.5f, player.velocity.Y * 0.5f, 50, default, 3f); - Main.dust[num12].velocity.X *= 0.2f; - Main.dust[num12].velocity.Y *= 0.2f; - Main.dust[num12].shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); - } - } + else if (dashMod == 9) + { + int num12 = Dust.NewDust(new Vector2(player.position.X - 4f, player.position.Y + (float)player.height + (float)num8), player.width + 8, 4, (int)CalamityDusts.PurpleCosmilite, -player.velocity.X * 0.5f, player.velocity.Y * 0.5f, 50, default, 3f); + Main.dust[num12].velocity.X *= 0.2f; + Main.dust[num12].velocity.Y *= 0.2f; + Main.dust[num12].shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); + } + } } if (player.mount.Active && player.mount.Type == ModContent.MountType() && Math.Abs(player.velocity.X) > player.mount.DashSpeed - player.mount.RunSpeed / 2f) @@ -8784,7 +8784,7 @@ namespace CalamityMod.CalPlayer { player.ApplyDamageToNPC(nPC, (int)Damage, Knockback, direction, false); } - nPC.Calamity().dashImmunityTime[player.whoAmI] = NPCImmuneTime; + nPC.Calamity().dashImmunityTime[player.whoAmI] = NPCImmuneTime; player.GiveIFrames(PlayerImmuneTime, false); num++; break; @@ -9103,11 +9103,11 @@ namespace CalamityMod.CalPlayer stealthAcceleration = 1f; // Reset acceleration when you attack float lossReductionRatio = flatStealthLossReduction / (rogueStealthMax * 100f); - float remainingStealth = rogueStealthMax * lossReductionRatio; - float stealthToLose = rogueStealthMax - remainingStealth; - // You cannot lose less than one stealth point. - if (stealthToLose < 0.01f) - stealthToLose = 0.01f; + float remainingStealth = rogueStealthMax * lossReductionRatio; + float stealthToLose = rogueStealthMax - remainingStealth; + // You cannot lose less than one stealth point. + if (stealthToLose < 0.01f) + stealthToLose = 0.01f; if (stealthStrikeHalfCost) { rogueStealth -= 0.5f * stealthToLose; @@ -9115,12 +9115,12 @@ namespace CalamityMod.CalPlayer rogueStealth = 0f; } else if (stealthStrike75Cost) - { + { rogueStealth -= 0.75f * stealthToLose; if (rogueStealth <= 0f) rogueStealth = 0f; } - else + else rogueStealth = remainingStealth; } #endregion diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 6d9e07bae3..9ead663ca7 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -42,7 +42,7 @@ using Terraria.ModLoader; namespace CalamityMod.CalPlayer { - public partial class CalamityPlayer : ModPlayer + public partial class CalamityPlayer : ModPlayer { #region Profaned Moonlight Colors public static readonly List MoonlightDyeDayColors = new List() diff --git a/CalPlayer/CalamityPlayerFishing.cs b/CalPlayer/CalamityPlayerFishing.cs index f340f29857..e052eae396 100644 --- a/CalPlayer/CalamityPlayerFishing.cs +++ b/CalPlayer/CalamityPlayerFishing.cs @@ -21,568 +21,568 @@ using Terraria.ModLoader; namespace CalamityMod.CalPlayer { - public partial class CalamityPlayer : ModPlayer + public partial class CalamityPlayer : ModPlayer { #region Catch Fish public override void CatchFish(Item fishingRod, Item bait, int power, int liquidType, int poolSize, int worldLayer, int questFish, ref int caughtType, ref bool junk) { - bool water = liquidType == 0; - bool lava = liquidType == 1; - bool honey = liquidType == 2; + bool water = liquidType == 0; + bool lava = liquidType == 1; + bool honey = liquidType == 2; - Point point = player.Center.ToTileCoordinates(); - bool canSulphurFish = false; - if (CalamityWorld.abyssSide) - { - if (point.X < 380) - canSulphurFish = true; - } - else - { - if (point.X > Main.maxTilesX - 380) - canSulphurFish = true; - } + Point point = player.Center.ToTileCoordinates(); + bool canSulphurFish = false; + if (CalamityWorld.abyssSide) + { + if (point.X < 380) + canSulphurFish = true; + } + else + { + if (point.X > Main.maxTilesX - 380) + canSulphurFish = true; + } - if (ZoneAbyss || ZoneSulphur) - canSulphurFish = true; + if (ZoneAbyss || ZoneSulphur) + canSulphurFish = true; - // Old Duke spawn - if (canSulphurFish && bait.type == ModContent.ItemType() && water && !BossRushEvent.BossRushActive) - { - CalamityGlobalNPC.OldDukeSpawn(player.whoAmI, ModContent.NPCType(), bait.type); - } + // Old Duke spawn + if (canSulphurFish && bait.type == ModContent.ItemType() && water && !BossRushEvent.BossRushActive) + { + CalamityGlobalNPC.OldDukeSpawn(player.whoAmI, ModContent.NPCType(), bait.type); + } - // Quest Fish - if (ZoneSunkenSea && questFish == ModContent.ItemType() && Main.rand.NextBool(10)) - { - caughtType = ModContent.ItemType(); - return; - } - if (ZoneSunkenSea && questFish == ModContent.ItemType() && Main.rand.NextBool(10)) - { - caughtType = ModContent.ItemType(); - return; - } - if (ZoneSunkenSea && questFish == ModContent.ItemType() && Main.rand.NextBool(10)) - { - caughtType = ModContent.ItemType(); - return; - } - if (ZoneCalamity && questFish == ModContent.ItemType() && Main.rand.NextBool(10)) - { - caughtType = ModContent.ItemType(); - return; - } - if (ZoneCalamity && questFish == ModContent.ItemType() && Main.rand.NextBool(10)) - { - caughtType = ModContent.ItemType(); - return; - } + // Quest Fish + if (ZoneSunkenSea && questFish == ModContent.ItemType() && Main.rand.NextBool(10)) + { + caughtType = ModContent.ItemType(); + return; + } + if (ZoneSunkenSea && questFish == ModContent.ItemType() && Main.rand.NextBool(10)) + { + caughtType = ModContent.ItemType(); + return; + } + if (ZoneSunkenSea && questFish == ModContent.ItemType() && Main.rand.NextBool(10)) + { + caughtType = ModContent.ItemType(); + return; + } + if (ZoneCalamity && questFish == ModContent.ItemType() && Main.rand.NextBool(10)) + { + caughtType = ModContent.ItemType(); + return; + } + if (ZoneCalamity && questFish == ModContent.ItemType() && Main.rand.NextBool(10)) + { + caughtType = ModContent.ItemType(); + return; + } - if (alluringBait) - { - int chanceForPotionFish = 1000 / power; + if (alluringBait) + { + int chanceForPotionFish = 1000 / power; - if (chanceForPotionFish < 3) - chanceForPotionFish = 3; + if (chanceForPotionFish < 3) + chanceForPotionFish = 3; - if (Main.rand.NextBool(chanceForPotionFish)) - { - List fishList = new List(); + if (Main.rand.NextBool(chanceForPotionFish)) + { + List fishList = new List(); - if (lava) - { - fishList.AddWithCondition(ItemID.FlarefinKoi, !ZoneCalamity); - fishList.AddWithCondition(ItemID.Obsidifish, !ZoneCalamity); - fishList.AddWithCondition(ModContent.ItemType(), ZoneCalamity); - fishList.AddWithCondition(ModContent.ItemType(), ZoneCalamity); - fishList.AddWithCondition(ModContent.ItemType(), ZoneCalamity); - } - else if (water) - { - if (player.ZoneDirtLayerHeight || player.ZoneRockLayerHeight) - { - fishList.Add(ItemID.ArmoredCavefish); - fishList.Add(ItemID.Stinkfish); - fishList.Add(ItemID.SpecularFish); - fishList.AddWithCondition(ItemID.ChaosFish, player.ZoneHoly); - fishList.AddWithCondition(ItemID.VariegatedLardfish, player.ZoneJungle); - } - if (player.ZoneOverworldHeight || player.ZoneSkyHeight) - { - fishList.AddWithCondition(ItemID.DoubleCod, player.ZoneJungle); - } - fishList.AddWithCondition(ItemID.FrostMinnow, player.ZoneSnow); - fishList.AddWithCondition(ItemID.Ebonkoi, player.ZoneCorrupt); - fishList.AddWithCondition(ItemID.CrimsonTigerfish, player.ZoneCrimson); - fishList.AddWithCondition(ItemID.Hemopiranha, player.ZoneCrimson); - fishList.AddWithCondition(ItemID.PrincessFish, player.ZoneHoly); - fishList.AddWithCondition(ItemID.Prismite, player.ZoneHoly); - fishList.AddWithCondition(ItemID.Damselfish, player.ZoneSkyHeight); - fishList.AddWithCondition(ModContent.ItemType(), ZoneAstral); - fishList.AddWithCondition(ModContent.ItemType(), ZoneSunkenSea); - fishList.AddWithCondition(ModContent.ItemType(), ZoneSunkenSea); - fishList.AddWithCondition(ModContent.ItemType(), ZoneSunkenSea); - } + if (lava) + { + fishList.AddWithCondition(ItemID.FlarefinKoi, !ZoneCalamity); + fishList.AddWithCondition(ItemID.Obsidifish, !ZoneCalamity); + fishList.AddWithCondition(ModContent.ItemType(), ZoneCalamity); + fishList.AddWithCondition(ModContent.ItemType(), ZoneCalamity); + fishList.AddWithCondition(ModContent.ItemType(), ZoneCalamity); + } + else if (water) + { + if (player.ZoneDirtLayerHeight || player.ZoneRockLayerHeight) + { + fishList.Add(ItemID.ArmoredCavefish); + fishList.Add(ItemID.Stinkfish); + fishList.Add(ItemID.SpecularFish); + fishList.AddWithCondition(ItemID.ChaosFish, player.ZoneHoly); + fishList.AddWithCondition(ItemID.VariegatedLardfish, player.ZoneJungle); + } + if (player.ZoneOverworldHeight || player.ZoneSkyHeight) + { + fishList.AddWithCondition(ItemID.DoubleCod, player.ZoneJungle); + } + fishList.AddWithCondition(ItemID.FrostMinnow, player.ZoneSnow); + fishList.AddWithCondition(ItemID.Ebonkoi, player.ZoneCorrupt); + fishList.AddWithCondition(ItemID.CrimsonTigerfish, player.ZoneCrimson); + fishList.AddWithCondition(ItemID.Hemopiranha, player.ZoneCrimson); + fishList.AddWithCondition(ItemID.PrincessFish, player.ZoneHoly); + fishList.AddWithCondition(ItemID.Prismite, player.ZoneHoly); + fishList.AddWithCondition(ItemID.Damselfish, player.ZoneSkyHeight); + fishList.AddWithCondition(ModContent.ItemType(), ZoneAstral); + fishList.AddWithCondition(ModContent.ItemType(), ZoneSunkenSea); + fishList.AddWithCondition(ModContent.ItemType(), ZoneSunkenSea); + fishList.AddWithCondition(ModContent.ItemType(), ZoneSunkenSea); + } - if (fishList.Any()) - { - int fishAmt = fishList.Count; - int caughtFish = fishList[Main.rand.Next(fishAmt)]; - caughtType = caughtFish; - return; - } - } - } + if (fishList.Any()) + { + int fishAmt = fishList.Count; + int caughtFish = fishList[Main.rand.Next(fishAmt)]; + caughtType = caughtFish; + return; + } + } + } - if (enchantedPearl || fishingStation) - { - int chanceForCrates = (enchantedPearl ? 10 : 0) + - (fishingStation ? 10 : 0); + if (enchantedPearl || fishingStation) + { + int chanceForCrates = (enchantedPearl ? 10 : 0) + + (fishingStation ? 10 : 0); - int poolSizeAmt = poolSize / 10; - if (poolSizeAmt > 100) - poolSizeAmt = 100; + int poolSizeAmt = poolSize / 10; + if (poolSizeAmt > 100) + poolSizeAmt = 100; - int fishingPowerDivisor = power + poolSizeAmt; + int fishingPowerDivisor = power + poolSizeAmt; - int chanceForIronCrate = 1000 / fishingPowerDivisor; - int chanceForBiomeCrate = 2000 / fishingPowerDivisor; - int chanceForGoldCrate = 3000 / fishingPowerDivisor; - int chanceForRareItems = 4000 / fishingPowerDivisor; + int chanceForIronCrate = 1000 / fishingPowerDivisor; + int chanceForBiomeCrate = 2000 / fishingPowerDivisor; + int chanceForGoldCrate = 3000 / fishingPowerDivisor; + int chanceForRareItems = 4000 / fishingPowerDivisor; - if (chanceForIronCrate < 3) - chanceForIronCrate = 3; + if (chanceForIronCrate < 3) + chanceForIronCrate = 3; - if (chanceForBiomeCrate < 4) - chanceForBiomeCrate = 4; + if (chanceForBiomeCrate < 4) + chanceForBiomeCrate = 4; - if (chanceForGoldCrate < 5) - chanceForGoldCrate = 5; + if (chanceForGoldCrate < 5) + chanceForGoldCrate = 5; - if (chanceForRareItems < 6) - chanceForRareItems = 6; + if (chanceForRareItems < 6) + chanceForRareItems = 6; - if (lava) - { - if (Main.rand.Next(100) < chanceForCrates) - { - if (Main.rand.NextBool(chanceForBiomeCrate)) - { - if (ZoneCalamity) - caughtType = ModContent.ItemType(); - } - } - } + if (lava) + { + if (Main.rand.Next(100) < chanceForCrates) + { + if (Main.rand.NextBool(chanceForBiomeCrate)) + { + if (ZoneCalamity) + caughtType = ModContent.ItemType(); + } + } + } - if (water) - { - if (Main.rand.Next(100) < chanceForCrates) - { - if (Main.rand.NextBool(chanceForRareItems) && enchantedPearl && fishingStation && player.cratePotion) - { - List rareItemList = new List(); + if (water) + { + if (Main.rand.Next(100) < chanceForCrates) + { + if (Main.rand.NextBool(chanceForRareItems) && enchantedPearl && fishingStation && player.cratePotion) + { + List rareItemList = new List(); - if (canSulphurFish) - { - switch (Main.rand.Next(2)) - { - case 0: - rareItemList.Add(ModContent.ItemType()); - break; - case 1: - rareItemList.Add(ModContent.ItemType()); - break; - } - } - if (ZoneAstral) - { - switch (Main.rand.Next(3)) - { - case 0: - rareItemList.Add(ModContent.ItemType()); - break; - case 1: - rareItemList.Add(ModContent.ItemType()); - break; - case 2: - rareItemList.Add(ModContent.ItemType()); - break; - } - } - if (ZoneSunkenSea) - { - switch (Main.rand.Next(2)) - { - case 0: - rareItemList.Add(ModContent.ItemType()); - break; - case 1: - rareItemList.Add(ModContent.ItemType()); - break; - } - } - if (player.ZoneSnow && player.ZoneRockLayerHeight && (player.ZoneCorrupt || player.ZoneCrimson || player.ZoneHoly)) - { - rareItemList.Add(ItemID.ScalyTruffle); - } - rareItemList.AddWithCondition(ItemID.Toxikarp, player.ZoneCorrupt); - rareItemList.AddWithCondition(ItemID.Bladetongue, player.ZoneCrimson); - rareItemList.AddWithCondition(ItemID.CrystalSerpent, player.ZoneHoly); + if (canSulphurFish) + { + switch (Main.rand.Next(2)) + { + case 0: + rareItemList.Add(ModContent.ItemType()); + break; + case 1: + rareItemList.Add(ModContent.ItemType()); + break; + } + } + if (ZoneAstral) + { + switch (Main.rand.Next(3)) + { + case 0: + rareItemList.Add(ModContent.ItemType()); + break; + case 1: + rareItemList.Add(ModContent.ItemType()); + break; + case 2: + rareItemList.Add(ModContent.ItemType()); + break; + } + } + if (ZoneSunkenSea) + { + switch (Main.rand.Next(2)) + { + case 0: + rareItemList.Add(ModContent.ItemType()); + break; + case 1: + rareItemList.Add(ModContent.ItemType()); + break; + } + } + if (player.ZoneSnow && player.ZoneRockLayerHeight && (player.ZoneCorrupt || player.ZoneCrimson || player.ZoneHoly)) + { + rareItemList.Add(ItemID.ScalyTruffle); + } + rareItemList.AddWithCondition(ItemID.Toxikarp, player.ZoneCorrupt); + rareItemList.AddWithCondition(ItemID.Bladetongue, player.ZoneCrimson); + rareItemList.AddWithCondition(ItemID.CrystalSerpent, player.ZoneHoly); - if (rareItemList.Any()) - { - int rareItemAmt = rareItemList.Count; - int caughtRareItem = rareItemList[Main.rand.Next(rareItemAmt)]; - caughtType = caughtRareItem; - } - } - else if (Main.rand.NextBool(chanceForGoldCrate)) - { - caughtType = ItemID.GoldenCrate; - } - else if (Main.rand.NextBool(chanceForBiomeCrate)) - { - List biomeCrateList = new List(); + if (rareItemList.Any()) + { + int rareItemAmt = rareItemList.Count; + int caughtRareItem = rareItemList[Main.rand.Next(rareItemAmt)]; + caughtType = caughtRareItem; + } + } + else if (Main.rand.NextBool(chanceForGoldCrate)) + { + caughtType = ItemID.GoldenCrate; + } + else if (Main.rand.NextBool(chanceForBiomeCrate)) + { + List biomeCrateList = new List(); - biomeCrateList.AddWithCondition(ModContent.ItemType(), ZoneAstral); - biomeCrateList.AddWithCondition(ModContent.ItemType(), ZoneSunkenSea); - biomeCrateList.AddWithCondition(ModContent.ItemType(), canSulphurFish); - biomeCrateList.AddWithCondition(ItemID.CorruptFishingCrate, player.ZoneCorrupt); - biomeCrateList.AddWithCondition(ItemID.CrimsonFishingCrate, player.ZoneCrimson); - biomeCrateList.AddWithCondition(ItemID.HallowedFishingCrate, player.ZoneHoly); - biomeCrateList.AddWithCondition(ItemID.DungeonFishingCrate, player.ZoneDungeon); - biomeCrateList.AddWithCondition(ItemID.JungleFishingCrate, player.ZoneJungle); - biomeCrateList.AddWithCondition(ItemID.FloatingIslandFishingCrate, player.ZoneSkyHeight); + biomeCrateList.AddWithCondition(ModContent.ItemType(), ZoneAstral); + biomeCrateList.AddWithCondition(ModContent.ItemType(), ZoneSunkenSea); + biomeCrateList.AddWithCondition(ModContent.ItemType(), canSulphurFish); + biomeCrateList.AddWithCondition(ItemID.CorruptFishingCrate, player.ZoneCorrupt); + biomeCrateList.AddWithCondition(ItemID.CrimsonFishingCrate, player.ZoneCrimson); + biomeCrateList.AddWithCondition(ItemID.HallowedFishingCrate, player.ZoneHoly); + biomeCrateList.AddWithCondition(ItemID.DungeonFishingCrate, player.ZoneDungeon); + biomeCrateList.AddWithCondition(ItemID.JungleFishingCrate, player.ZoneJungle); + biomeCrateList.AddWithCondition(ItemID.FloatingIslandFishingCrate, player.ZoneSkyHeight); - if (biomeCrateList.Any()) - { - int biomeCrateAmt = biomeCrateList.Count; - int caughtBiomeCrate = biomeCrateList[Main.rand.Next(biomeCrateAmt)]; - caughtType = caughtBiomeCrate; - } - } - else if (Main.rand.NextBool(chanceForIronCrate)) - { - caughtType = ItemID.IronCrate; - } - else - { - caughtType = ItemID.WoodenCrate; - } - return; - } - } - } + if (biomeCrateList.Any()) + { + int biomeCrateAmt = biomeCrateList.Count; + int caughtBiomeCrate = biomeCrateList[Main.rand.Next(biomeCrateAmt)]; + caughtType = caughtBiomeCrate; + } + } + else if (Main.rand.NextBool(chanceForIronCrate)) + { + caughtType = ItemID.IronCrate; + } + else + { + caughtType = ItemID.WoodenCrate; + } + return; + } + } + } - if (water) - { - if (caughtType == ItemID.WoodenCrate || caughtType == ItemID.IronCrate || caughtType == ItemID.GoldenCrate || caughtType == ItemID.FrogLeg || caughtType == ItemID.BalloonPufferfish || caughtType == ItemID.ZephyrFish) - { - return; - } - if ((player.ZoneCrimson || player.ZoneCorrupt) && player.ZoneRockLayerHeight && Main.hardMode) - { - if (Main.rand.NextBool(25)) - { - caughtType = ModContent.ItemType(); - } - } + if (water) + { + if (caughtType == ItemID.WoodenCrate || caughtType == ItemID.IronCrate || caughtType == ItemID.GoldenCrate || caughtType == ItemID.FrogLeg || caughtType == ItemID.BalloonPufferfish || caughtType == ItemID.ZephyrFish) + { + return; + } + if ((player.ZoneCrimson || player.ZoneCorrupt) && player.ZoneRockLayerHeight && Main.hardMode) + { + if (Main.rand.NextBool(25)) + { + caughtType = ModContent.ItemType(); + } + } - if (player.ZoneHoly && player.ZoneRockLayerHeight && Main.hardMode) - { - if (Main.rand.NextBool(25)) - { - caughtType = ModContent.ItemType(); - } - } + if (player.ZoneHoly && player.ZoneRockLayerHeight && Main.hardMode) + { + if (Main.rand.NextBool(25)) + { + caughtType = ModContent.ItemType(); + } + } - if (player.ZoneSkyHeight && Main.hardMode) - { - if (Main.rand.NextBool(25)) - { - caughtType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); - } - } + if (player.ZoneSkyHeight && Main.hardMode) + { + if (Main.rand.NextBool(25)) + { + caughtType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); + } + } - if (player.ZoneOverworldHeight && !Main.dayTime) - { - if (Main.rand.NextBool(10)) - { - caughtType = ModContent.ItemType(); - } - } + if (player.ZoneOverworldHeight && !Main.dayTime) + { + if (Main.rand.NextBool(10)) + { + caughtType = ModContent.ItemType(); + } + } - if (player.ZoneOverworldHeight && Main.dayTime) - { - if (Main.rand.NextBool(25)) - { - caughtType = ModContent.ItemType(); - } - } + if (player.ZoneOverworldHeight && Main.dayTime) + { + if (Main.rand.NextBool(25)) + { + caughtType = ModContent.ItemType(); + } + } - if (player.ZoneRockLayerHeight) - { - if (Main.rand.NextBool(25)) - { - caughtType = ModContent.ItemType(); - } - } + if (player.ZoneRockLayerHeight) + { + if (Main.rand.NextBool(25)) + { + caughtType = ModContent.ItemType(); + } + } - if (player.ZoneSnow) - { - if (Main.rand.NextBool(25) && Main.hardMode) - { - caughtType = ModContent.ItemType(); - } - } + if (player.ZoneSnow) + { + if (Main.rand.NextBool(25) && Main.hardMode) + { + caughtType = ModContent.ItemType(); + } + } - if (player.ZoneDirtLayerHeight) - { - if (Main.rand.NextBool(Main.hardMode ? 100 : 40)) - { - caughtType = ModContent.ItemType(); - } - } + if (player.ZoneDirtLayerHeight) + { + if (Main.rand.NextBool(Main.hardMode ? 100 : 40)) + { + caughtType = ModContent.ItemType(); + } + } - if (ZoneAstral) // Astral Infection, fishing in water - { - int astralFish = Main.rand.Next(100); - if (astralFish >= 85) // 15% - { - caughtType = ModContent.ItemType(); - } - else if (astralFish <= 84 && astralFish >= 70) // 15% - { - caughtType = ModContent.ItemType(); - } - else if (astralFish <= 69 && astralFish >= 55) // 15% - { - caughtType = ModContent.ItemType(); - } - else if (player.cratePotion && astralFish <= 18 && astralFish >= 9) // 10% - { - caughtType = ModContent.ItemType(); - } - else if (!player.cratePotion && astralFish <= 13 && astralFish >= 9) // 5% - { - caughtType = ModContent.ItemType(); - } - else if (astralFish <= 8 && astralFish >= 6) // 3% - { - caughtType = ModContent.ItemType(); - } - else if (astralFish <= 5 && astralFish >= 3) // 3% - { - caughtType = ModContent.ItemType(); - } - else if (astralFish <= 2 && astralFish >= 0) // 3% - { - caughtType = ModContent.ItemType(); - } - else // 36% w/o crate pot, 31% w/ crate pot - { - caughtType = ModContent.ItemType(); - return; - } - } + if (ZoneAstral) // Astral Infection, fishing in water + { + int astralFish = Main.rand.Next(100); + if (astralFish >= 85) // 15% + { + caughtType = ModContent.ItemType(); + } + else if (astralFish <= 84 && astralFish >= 70) // 15% + { + caughtType = ModContent.ItemType(); + } + else if (astralFish <= 69 && astralFish >= 55) // 15% + { + caughtType = ModContent.ItemType(); + } + else if (player.cratePotion && astralFish <= 18 && astralFish >= 9) // 10% + { + caughtType = ModContent.ItemType(); + } + else if (!player.cratePotion && astralFish <= 13 && astralFish >= 9) // 5% + { + caughtType = ModContent.ItemType(); + } + else if (astralFish <= 8 && astralFish >= 6) // 3% + { + caughtType = ModContent.ItemType(); + } + else if (astralFish <= 5 && astralFish >= 3) // 3% + { + caughtType = ModContent.ItemType(); + } + else if (astralFish <= 2 && astralFish >= 0) // 3% + { + caughtType = ModContent.ItemType(); + } + else // 36% w/o crate pot, 31% w/ crate pot + { + caughtType = ModContent.ItemType(); + return; + } + } - if (ZoneSunkenSea) // Sunken Sea, fishing in water - { - int sunkenFish = Main.rand.Next(100); - if (sunkenFish >= 85 && Main.hardMode) // 15% - { - caughtType = ModContent.ItemType(); - } - else if (sunkenFish <= 84 && sunkenFish >= 70) // 15% - { - caughtType = ModContent.ItemType(); - } - else if (sunkenFish <= 69 && sunkenFish >= 55) // 15% - { - caughtType = ModContent.ItemType(); - } - else if (player.cratePotion && sunkenFish <= 18 && sunkenFish >= 9) // 10% - { - caughtType = ModContent.ItemType(); - } - else if (!player.cratePotion && sunkenFish <= 13 && sunkenFish >= 9) // 5% - { - caughtType = ModContent.ItemType(); - } - else if (sunkenFish <= 31 && sunkenFish >= 29) // 3% - { - caughtType = ModContent.ItemType(); - } - else if (sunkenFish <= 8 && sunkenFish >= 6 && Main.hardMode) // 3% - { - caughtType = ModContent.ItemType(); - } - else if (sunkenFish <= 5 && sunkenFish >= 3) // 3% - { - caughtType = ModContent.ItemType(); - } - else if (sunkenFish <= 2 && sunkenFish >= 0 && CalamityWorld.downedDesertScourge) // 3% - { - caughtType = ModContent.ItemType(); - } - else // 38% w/o crate pot, 33% w/ crate pot + 18% if prehardmode - { - caughtType = ModContent.ItemType(); - return; - } - } + if (ZoneSunkenSea) // Sunken Sea, fishing in water + { + int sunkenFish = Main.rand.Next(100); + if (sunkenFish >= 85 && Main.hardMode) // 15% + { + caughtType = ModContent.ItemType(); + } + else if (sunkenFish <= 84 && sunkenFish >= 70) // 15% + { + caughtType = ModContent.ItemType(); + } + else if (sunkenFish <= 69 && sunkenFish >= 55) // 15% + { + caughtType = ModContent.ItemType(); + } + else if (player.cratePotion && sunkenFish <= 18 && sunkenFish >= 9) // 10% + { + caughtType = ModContent.ItemType(); + } + else if (!player.cratePotion && sunkenFish <= 13 && sunkenFish >= 9) // 5% + { + caughtType = ModContent.ItemType(); + } + else if (sunkenFish <= 31 && sunkenFish >= 29) // 3% + { + caughtType = ModContent.ItemType(); + } + else if (sunkenFish <= 8 && sunkenFish >= 6 && Main.hardMode) // 3% + { + caughtType = ModContent.ItemType(); + } + else if (sunkenFish <= 5 && sunkenFish >= 3) // 3% + { + caughtType = ModContent.ItemType(); + } + else if (sunkenFish <= 2 && sunkenFish >= 0 && CalamityWorld.downedDesertScourge) // 3% + { + caughtType = ModContent.ItemType(); + } + else // 38% w/o crate pot, 33% w/ crate pot + 18% if prehardmode + { + caughtType = ModContent.ItemType(); + return; + } + } - if (player.FindBuffIndex(BuffID.Gills) > -1 && CalamityWorld.downedCalamitas && Main.rand.NextBool(25)) - { - caughtType = ModContent.ItemType(); - } + if (player.FindBuffIndex(BuffID.Gills) > -1 && CalamityWorld.downedCalamitas && Main.rand.NextBool(25)) + { + caughtType = ModContent.ItemType(); + } - if (junk) - { - if (canSulphurFish) - { - caughtType = ModContent.ItemType(); - } - return; - } + if (junk) + { + if (canSulphurFish) + { + caughtType = ModContent.ItemType(); + } + return; + } - /*if (canSulphurFish && (bait.type == ItemID.GoldWorm || bait.type == ItemID.GoldGrasshopper || bait.type == ItemID.GoldButterfly) && power > 150) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - CalamityGlobalNPC.OldDukeSpawn(player.whoAmI, ModContent.NPCType()); - } - else - { - NetMessage.SendData(61, -1, -1, null, player.whoAmI, (float)ModContent.NPCType(), 0f, 0f, 0, 0, 0); - } - switch (Main.rand.Next(4)) - { - case 0: caughtType = ModContent.ItemType(); break; //movement acc - case 1: caughtType = ModContent.ItemType(); break; //regen acc - case 2: caughtType = ModContent.ItemType(); break; //defense acc - case 3: caughtType = ModContent.ItemType(); break; //light pet - } - return; - }*/ + /*if (canSulphurFish && (bait.type == ItemID.GoldWorm || bait.type == ItemID.GoldGrasshopper || bait.type == ItemID.GoldButterfly) && power > 150) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + CalamityGlobalNPC.OldDukeSpawn(player.whoAmI, ModContent.NPCType()); + } + else + { + NetMessage.SendData(61, -1, -1, null, player.whoAmI, (float)ModContent.NPCType(), 0f, 0f, 0, 0, 0); + } + switch (Main.rand.Next(4)) + { + case 0: caughtType = ModContent.ItemType(); break; //movement acc + case 1: caughtType = ModContent.ItemType(); break; //regen acc + case 2: caughtType = ModContent.ItemType(); break; //defense acc + case 3: caughtType = ModContent.ItemType(); break; //light pet + } + return; + }*/ - if (canSulphurFish) - { - if (Main.rand.NextBool(15)) - { - caughtType = ModContent.ItemType(); - } - if (Main.rand.NextFloat() < 0.08f) - { - caughtType = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ItemType(), - ModContent.ItemType() - }); - } - if (player.cratePotion && Main.rand.NextBool(5)) // 20% - { - caughtType = ModContent.ItemType(); - } - else if (!player.cratePotion && Main.rand.NextBool(10)) // 10% - { - caughtType = ModContent.ItemType(); - } - } + if (canSulphurFish) + { + if (Main.rand.NextBool(15)) + { + caughtType = ModContent.ItemType(); + } + if (Main.rand.NextFloat() < 0.08f) + { + caughtType = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ItemType(), + ModContent.ItemType() + }); + } + if (player.cratePotion && Main.rand.NextBool(5)) // 20% + { + caughtType = ModContent.ItemType(); + } + else if (!player.cratePotion && Main.rand.NextBool(10)) // 10% + { + caughtType = ModContent.ItemType(); + } + } - if (player.ZoneOverworldHeight && Main.bloodMoon) - { - if (Main.rand.NextBool(25)) - { - caughtType = ModContent.ItemType(); - } - } - } + if (player.ZoneOverworldHeight && Main.bloodMoon) + { + if (Main.rand.NextBool(25)) + { + caughtType = ModContent.ItemType(); + } + } + } - if (lava) - { - if (ZoneCalamity) // Brimstone Crags, fishing in lava - { - int cragFish = Main.rand.Next(100); - if (cragFish >= 85) // 15% - { - caughtType = ModContent.ItemType(); - } - else if (cragFish <= 84 && cragFish >= 70) // 15% - { - caughtType = ModContent.ItemType(); - } - else if (cragFish <= 69 && cragFish >= 55) // 15% - { - caughtType = ModContent.ItemType(); - } - else if (cragFish <= 54 && cragFish >= 41 && Main.hardMode) // 14% - { - caughtType = ModContent.ItemType(); - } - else if (player.cratePotion && cragFish <= 30 && cragFish >= 21) // 10% - { - caughtType = ModContent.ItemType(); - } - else if (!player.cratePotion && cragFish <= 25 && cragFish >= 21) // 5% - { - caughtType = ModContent.ItemType(); - } - else if (cragFish <= 20 && cragFish >= 11 && CalamityWorld.downedProvidence) // 10% - { - caughtType = ModContent.ItemType(); - } - else if (cragFish <= 10 && cragFish >= (Main.hardMode ? 8 : 6)) // 5% (3% hardmode) - { - caughtType = ModContent.ItemType(); - } - else if (cragFish <= 2 && cragFish >= 0) // 3% - { - caughtType = ModContent.ItemType(); - } - else // 32% w/o crate pot, 27% w/ crate pot, add 10% pre-Prov, add another 12% prehardmode - { - caughtType = ModContent.ItemType(); - } - } - } - } + if (lava) + { + if (ZoneCalamity) // Brimstone Crags, fishing in lava + { + int cragFish = Main.rand.Next(100); + if (cragFish >= 85) // 15% + { + caughtType = ModContent.ItemType(); + } + else if (cragFish <= 84 && cragFish >= 70) // 15% + { + caughtType = ModContent.ItemType(); + } + else if (cragFish <= 69 && cragFish >= 55) // 15% + { + caughtType = ModContent.ItemType(); + } + else if (cragFish <= 54 && cragFish >= 41 && Main.hardMode) // 14% + { + caughtType = ModContent.ItemType(); + } + else if (player.cratePotion && cragFish <= 30 && cragFish >= 21) // 10% + { + caughtType = ModContent.ItemType(); + } + else if (!player.cratePotion && cragFish <= 25 && cragFish >= 21) // 5% + { + caughtType = ModContent.ItemType(); + } + else if (cragFish <= 20 && cragFish >= 11 && CalamityWorld.downedProvidence) // 10% + { + caughtType = ModContent.ItemType(); + } + else if (cragFish <= 10 && cragFish >= (Main.hardMode ? 8 : 6)) // 5% (3% hardmode) + { + caughtType = ModContent.ItemType(); + } + else if (cragFish <= 2 && cragFish >= 0) // 3% + { + caughtType = ModContent.ItemType(); + } + else // 32% w/o crate pot, 27% w/ crate pot, add 10% pre-Prov, add another 12% prehardmode + { + caughtType = ModContent.ItemType(); + } + } + } + } #endregion #region Get Fishing Level public override void GetFishingLevel(Item fishingRod, Item bait, ref int fishingLevel) { - if ((ZoneAstral || ZoneAbyss || ZoneSulphur) && bait.type == ModContent.ItemType()) - fishingLevel = (int)(fishingLevel * 1.1f); - if (player.ZoneSnow && fishingRod.type == ModContent.ItemType()) - fishingLevel = (int)(fishingLevel * 1.1f); - if (player.ZoneSkyHeight && fishingRod.type == ModContent.ItemType()) - fishingLevel = (int)(fishingLevel * 1.1f); + if ((ZoneAstral || ZoneAbyss || ZoneSulphur) && bait.type == ModContent.ItemType()) + fishingLevel = (int)(fishingLevel * 1.1f); + if (player.ZoneSnow && fishingRod.type == ModContent.ItemType()) + fishingLevel = (int)(fishingLevel * 1.1f); + if (player.ZoneSkyHeight && fishingRod.type == ModContent.ItemType()) + fishingLevel = (int)(fishingLevel * 1.1f); - if (bait.type == ModContent.ItemType()) - { - Point point = player.Center.ToTileCoordinates(); - bool canSulphurFish = false; - if (CalamityWorld.abyssSide) - { - if (point.X < 380) - canSulphurFish = true; - } - else - { - if (point.X > Main.maxTilesX - 380) - canSulphurFish = true; - } + if (bait.type == ModContent.ItemType()) + { + Point point = player.Center.ToTileCoordinates(); + bool canSulphurFish = false; + if (CalamityWorld.abyssSide) + { + if (point.X < 380) + canSulphurFish = true; + } + else + { + if (point.X > Main.maxTilesX - 380) + canSulphurFish = true; + } - if (ZoneAbyss || ZoneSulphur) - canSulphurFish = true; + if (ZoneAbyss || ZoneSulphur) + canSulphurFish = true; - Item item = player.ActiveItem(); - if (!canSulphurFish || item.fishingPole <= 0 || item.holdStyle != 1) - fishingLevel = -1; - } - } + Item item = player.ActiveItem(); + if (!canSulphurFish || item.fishingPole <= 0 || item.holdStyle != 1) + fishingLevel = -1; + } + } #endregion } } diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 887ff2c7f6..89ad121928 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -10,68 +10,68 @@ using Terraria.ModLoader; namespace CalamityMod.CalPlayer { - public partial class CalamityPlayer : ModPlayer + public partial class CalamityPlayer : ModPlayer { #region Update Bad Life Regen public override void UpdateBadLifeRegen() { - if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) - noLifeRegen = true; + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + noLifeRegen = true; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - double lifeRegenMult = death ? 1.5 : 1D; - if (reaverDefense) - lifeRegenMult *= 0.8; - int lifeRegenLost = 0; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + double lifeRegenMult = death ? 1.5 : 1D; + if (reaverDefense) + lifeRegenMult *= 0.8; + int lifeRegenLost = 0; // Initial Debuffs - // Get fucked, Nebula Armor - player.nebulaLevelLife = 0; + // Get fucked, Nebula Armor + player.nebulaLevelLife = 0; - // Vanilla - if (death) - { - if (player.poisoned) - lifeRegenLost += 4; + // Vanilla + if (death) + { + if (player.poisoned) + lifeRegenLost += 4; - if (player.onFire) - lifeRegenLost += 8; + if (player.onFire) + lifeRegenLost += 8; - if (player.tongued) - lifeRegenLost += 100; + if (player.tongued) + lifeRegenLost += 100; - if (player.venom) - lifeRegenLost += 12; + if (player.venom) + lifeRegenLost += 12; - if (player.onFrostBurn) - lifeRegenLost += 12; + if (player.onFrostBurn) + lifeRegenLost += 12; - if (player.onFire2) - lifeRegenLost += 12; + if (player.onFire2) + lifeRegenLost += 12; - if (player.burned) - lifeRegenLost += 60; + if (player.burned) + lifeRegenLost += 60; - if (player.suffocating) - lifeRegenLost += 40; + if (player.suffocating) + lifeRegenLost += 40; - if (player.electrified) - { - lifeRegenLost += 8; - if (player.controlLeft || player.controlRight) - lifeRegenLost += 32; - } - } + if (player.electrified) + { + lifeRegenLost += 8; + if (player.controlLeft || player.controlRight) + lifeRegenLost += 32; + } + } - // Calamity + // Calamity if (shadowflame) { if (player.lifeRegen > 0) player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += 30; + lifeRegenLost += 30; } if (wDeath) @@ -88,17 +88,17 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += 16; + lifeRegenLost += 16; } - if (weakBrimstoneFlames) - { - if (player.lifeRegen > 0) - player.lifeRegen = 0; + if (weakBrimstoneFlames) + { + if (player.lifeRegen > 0) + player.lifeRegen = 0; - player.lifeRegenTime = 0; - lifeRegenLost += 7; - } + player.lifeRegenTime = 0; + lifeRegenLost += 7; + } if (bFlames) { @@ -106,7 +106,7 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += abaddon ? 8 : 16; + lifeRegenLost += abaddon ? 8 : 16; } if (nightwither) @@ -115,8 +115,8 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += 16; - } + lifeRegenLost += 16; + } if (vaporfied) { @@ -124,16 +124,16 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += 8; - } + lifeRegenLost += 8; + } - if (cragsLava) - { + if (cragsLava) + { if (player.lifeRegen > 0) player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += 30; + lifeRegenLost += 30; } if (gsInferno) @@ -142,7 +142,7 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += profanedCrystalBuffs ? 35 : 30; + lifeRegenLost += profanedCrystalBuffs ? 35 : 30; } if (astralInfection) @@ -151,7 +151,7 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += 20; + lifeRegenLost += 20; } if (ZoneSulphur && player.IsUnderwater() && !decayEffigy && !player.lavaWet && !player.honeyWet) @@ -163,27 +163,27 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - int waterDivisor = 250; - int minimumRegenLost = 8; - if (sulfurSet && sulphurskin) - { - waterDivisor = 500; - minimumRegenLost = 1; - } - else if (sulfurSet) - { - waterDivisor = 400; - minimumRegenLost = 3; - } - else if (sulphurskin) - { - waterDivisor = 350; - minimumRegenLost = 2; - } - int sulphurWater = pissWaterBoost / waterDivisor; + int waterDivisor = 250; + int minimumRegenLost = 8; + if (sulfurSet && sulphurskin) + { + waterDivisor = 500; + minimumRegenLost = 1; + } + else if (sulfurSet) + { + waterDivisor = 400; + minimumRegenLost = 3; + } + else if (sulphurskin) + { + waterDivisor = 350; + minimumRegenLost = 2; + } + int sulphurWater = pissWaterBoost / waterDivisor; if (sulphurWater < minimumRegenLost) sulphurWater = minimumRegenLost; - lifeRegenLost += sulphurWater; + lifeRegenLost += sulphurWater; } else pissWaterBoost = 0; @@ -194,15 +194,15 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += 6; - if (sulfurSet) - { - lifeRegenLost -= 2; - } - if (sulphurskin) - { - lifeRegenLost -= 2; - } + lifeRegenLost += 6; + if (sulfurSet) + { + lifeRegenLost -= 2; + } + if (sulphurskin) + { + lifeRegenLost -= 2; + } } if (hFlames) @@ -211,7 +211,7 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += 16; + lifeRegenLost += 16; } if (banishingFire) @@ -220,29 +220,29 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += 60; - } + lifeRegenLost += 60; + } - if (waterLeechBleeding) - { - if (player.lifeRegen > 0) - player.lifeRegen = 0; - - player.lifeRegenTime = 0; - lifeRegenLost += 6; - if (CalamityWorld.downedAquaticScourge) - lifeRegenLost += 6; - if (CalamityWorld.downedPolterghast) - lifeRegenLost += 12; - } - - if (pFlames) + if (waterLeechBleeding) { if (player.lifeRegen > 0) player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += reducedPlagueDmg ? 10 : 20; + lifeRegenLost += 6; + if (CalamityWorld.downedAquaticScourge) + lifeRegenLost += 6; + if (CalamityWorld.downedPolterghast) + lifeRegenLost += 12; + } + + if (pFlames) + { + if (player.lifeRegen > 0) + player.lifeRegen = 0; + + player.lifeRegenTime = 0; + lifeRegenLost += reducedPlagueDmg ? 10 : 20; } if (bBlood) @@ -251,7 +251,7 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += 8; + lifeRegenLost += 8; } if (vHex) @@ -260,19 +260,19 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += 16; + lifeRegenLost += 16; } - if (dragonFire) - { - if (player.lifeRegen > 0) - player.lifeRegen = 0; + if (dragonFire) + { + if (player.lifeRegen > 0) + player.lifeRegen = 0; - player.lifeRegenTime = 0; - lifeRegenLost += 18; - } + player.lifeRegenTime = 0; + lifeRegenLost += 18; + } - if (cDepth) + if (cDepth) { if (player.statDefense > 0) { @@ -287,129 +287,129 @@ namespace CalamityMod.CalPlayer player.lifeRegen = 0; player.lifeRegenTime = 0; - lifeRegenLost += calcDepthDamage; + lifeRegenLost += calcDepthDamage; } } - if (vodka) - { - alcoholPoisonLevel++; - lifeRegenLost += 1; - } - if (redWine) - { - alcoholPoisonLevel++; - lifeRegenLost += 1; - if (baguette) - lifeRegenLost += 3; - } - if (grapeBeer) - { - alcoholPoisonLevel++; - } - if (moonshine) - { - alcoholPoisonLevel++; - lifeRegenLost += 1; - } - if (rum) - { - alcoholPoisonLevel++; - } - if (fabsolVodka) - { - alcoholPoisonLevel++; - } - if (fireball) - { - alcoholPoisonLevel++; - lifeRegenLost += 1; - } - if (whiskey) - { - alcoholPoisonLevel++; - } - if (everclear) - { - alcoholPoisonLevel += 2; - lifeRegenLost += 10; - } - if (bloodyMary) - { - alcoholPoisonLevel++; - lifeRegenLost += 2; - } - if (tequila) - { - alcoholPoisonLevel++; - lifeRegenLost += 1; - } - if (tequilaSunrise) - { - alcoholPoisonLevel++; - lifeRegenLost += 1; - } - if (screwdriver) - { - alcoholPoisonLevel++; - lifeRegenLost += 1; - } - if (caribbeanRum) - { - alcoholPoisonLevel++; - } - if (cinnamonRoll) - { - alcoholPoisonLevel++; - } - if (margarita) - { - alcoholPoisonLevel++; - lifeRegenLost += 1; - } - if (starBeamRye) - { - alcoholPoisonLevel++; - lifeRegenLost += 1; - } - if (moscowMule) - { - alcoholPoisonLevel++; - lifeRegenLost += 2; - } - if (whiteWine) - { - alcoholPoisonLevel++; - lifeRegenLost += 1; - } - if (evergreenGin) - { - alcoholPoisonLevel++; - lifeRegenLost += 1; - } + if (vodka) + { + alcoholPoisonLevel++; + lifeRegenLost += 1; + } + if (redWine) + { + alcoholPoisonLevel++; + lifeRegenLost += 1; + if (baguette) + lifeRegenLost += 3; + } + if (grapeBeer) + { + alcoholPoisonLevel++; + } + if (moonshine) + { + alcoholPoisonLevel++; + lifeRegenLost += 1; + } + if (rum) + { + alcoholPoisonLevel++; + } + if (fabsolVodka) + { + alcoholPoisonLevel++; + } + if (fireball) + { + alcoholPoisonLevel++; + lifeRegenLost += 1; + } + if (whiskey) + { + alcoholPoisonLevel++; + } + if (everclear) + { + alcoholPoisonLevel += 2; + lifeRegenLost += 10; + } + if (bloodyMary) + { + alcoholPoisonLevel++; + lifeRegenLost += 2; + } + if (tequila) + { + alcoholPoisonLevel++; + lifeRegenLost += 1; + } + if (tequilaSunrise) + { + alcoholPoisonLevel++; + lifeRegenLost += 1; + } + if (screwdriver) + { + alcoholPoisonLevel++; + lifeRegenLost += 1; + } + if (caribbeanRum) + { + alcoholPoisonLevel++; + } + if (cinnamonRoll) + { + alcoholPoisonLevel++; + } + if (margarita) + { + alcoholPoisonLevel++; + lifeRegenLost += 1; + } + if (starBeamRye) + { + alcoholPoisonLevel++; + lifeRegenLost += 1; + } + if (moscowMule) + { + alcoholPoisonLevel++; + lifeRegenLost += 2; + } + if (whiteWine) + { + alcoholPoisonLevel++; + lifeRegenLost += 1; + } + if (evergreenGin) + { + alcoholPoisonLevel++; + lifeRegenLost += 1; + } - if (cirrusDress) - alcoholPoisonLevel = 0; + if (cirrusDress) + alcoholPoisonLevel = 0; - if (alcoholPoisonLevel > 3) - { - player.nebulaLevelLife = 0; + if (alcoholPoisonLevel > 3) + { + player.nebulaLevelLife = 0; - if (player.whoAmI == Main.myPlayer) - player.AddBuff(ModContent.BuffType(), 2, false); + if (player.whoAmI == Main.myPlayer) + player.AddBuff(ModContent.BuffType(), 2, false); - if (player.lifeRegen > 0) - player.lifeRegen = 0; + if (player.lifeRegen > 0) + player.lifeRegen = 0; - player.lifeRegenTime = 0; - lifeRegenLost += 3 * alcoholPoisonLevel; - } + player.lifeRegenTime = 0; + lifeRegenLost += 3 * alcoholPoisonLevel; + } - if (manaOverloader) - { - if (player.statMana > (int)(player.statManaMax2 * 0.5)) - lifeRegenLost += 3; - } + if (manaOverloader) + { + if (player.statMana > (int)(player.statManaMax2 * 0.5)) + lifeRegenLost += 3; + } if (brimflameFrenzy) { player.manaRegen = 0; @@ -418,76 +418,76 @@ namespace CalamityMod.CalPlayer if (player.lifeRegen > 0) player.lifeRegen = 0; lifeRegenLost += 42; //the meaning of death - } + } - if (witheredDebuff) - { - witheredWeaponHoldTime += witheringWeaponEnchant.ToDirectionInt(); - if (witheredWeaponHoldTime < 0) - { - witheredWeaponHoldTime = 0; - } - else - { - lifeRegenLost += (int)(5D * Math.Pow(1.5D, witheredWeaponHoldTime / 87D)); - if (player.lifeRegen > 0) - player.lifeRegen = 0; - } - } - else - witheredWeaponHoldTime = 0; - - if (ManaBurn) - { - int debuffIndex = player.FindBuffIndex(ModContent.BuffType()); - float debuffIntensity = debuffIndex == -1 ? 0f : player.buffTime[debuffIndex] / (float)Player.manaSickTimeMax; - - lifeRegenLost += (int)(Math.Sqrt(debuffIntensity) * Math.Pow(6D, debuffIntensity + 1f)); - if (player.lifeRegen > 0) - player.lifeRegen = 0; - } - - player.lifeRegen -= (int)(lifeRegenLost * lifeRegenMult); - - // Buffs - - if (divineBless) - { - if (player.whoAmI == Main.myPlayer && player.miscCounter % 15 == 0) // Flat 4 health per second + if (witheredDebuff) + { + witheredWeaponHoldTime += witheringWeaponEnchant.ToDirectionInt(); + if (witheredWeaponHoldTime < 0) { - if (!noLifeRegen) - player.statLife += 1; + witheredWeaponHoldTime = 0; + } + else + { + lifeRegenLost += (int)(5D * Math.Pow(1.5D, witheredWeaponHoldTime / 87D)); + if (player.lifeRegen > 0) + player.lifeRegen = 0; + } + } + else + witheredWeaponHoldTime = 0; + + if (ManaBurn) + { + int debuffIndex = player.FindBuffIndex(ModContent.BuffType()); + float debuffIntensity = debuffIndex == -1 ? 0f : player.buffTime[debuffIndex] / (float)Player.manaSickTimeMax; + + lifeRegenLost += (int)(Math.Sqrt(debuffIntensity) * Math.Pow(6D, debuffIntensity + 1f)); + if (player.lifeRegen > 0) + player.lifeRegen = 0; + } + + player.lifeRegen -= (int)(lifeRegenLost * lifeRegenMult); + + // Buffs + + if (divineBless) + { + if (player.whoAmI == Main.myPlayer && player.miscCounter % 15 == 0) // Flat 4 health per second + { + if (!noLifeRegen) + player.statLife += 1; } } - if (bloodfinBoost) - { - if (player.lifeRegen < 0) - { - if (player.lifeRegenTime < 1800) - player.lifeRegenTime = 1800; + if (bloodfinBoost) + { + if (player.lifeRegen < 0) + { + if (player.lifeRegenTime < 1800) + player.lifeRegenTime = 1800; - player.lifeRegen += 10; - } - else - { - player.lifeRegen += 5; - player.lifeRegenTime += 10; - } + player.lifeRegen += 10; + } + else + { + player.lifeRegen += 5; + player.lifeRegenTime += 10; + } if (bloodfinTimer > 0) - bloodfinTimer--; + bloodfinTimer--; - if (player.whoAmI == Main.myPlayer && bloodfinTimer <= 0) + if (player.whoAmI == Main.myPlayer && bloodfinTimer <= 0) { bloodfinTimer = 30; - if (player.statLife < (int)(player.statLifeMax2 * 0.75) && !noLifeRegen) - player.statLife += 1; + if (player.statLife < (int)(player.statLifeMax2 * 0.75) && !noLifeRegen) + player.statLife += 1; } } - if (celestialJewel || astralArcanum) + if (celestialJewel || astralArcanum) { bool lesserEffect = false; for (int l = 0; l < Player.MaxBuffs; l++) @@ -496,7 +496,7 @@ namespace CalamityMod.CalPlayer lesserEffect = CalamityLists.alcoholList.Contains(hasBuff); } - int defenseBoost = astralArcanum ? 15 : 11; + int defenseBoost = astralArcanum ? 15 : 11; if (lesserEffect) { player.lifeRegen += astralArcanum ? 2 : 1; @@ -542,9 +542,9 @@ namespace CalamityMod.CalPlayer } } - // Last Debuffs + // Last Debuffs - if (noLifeRegen) + if (noLifeRegen) { if (player.lifeRegen > 0) player.lifeRegen = 0; @@ -555,9 +555,9 @@ namespace CalamityMod.CalPlayer player.lifeRegenCount = 0; } - if (hInferno) + if (hInferno) { - player.nebulaLevelLife = 0; + player.nebulaLevelLife = 0; hInfernoBoost++; @@ -567,28 +567,28 @@ namespace CalamityMod.CalPlayer player.lifeRegenTime = 0; player.lifeRegen -= (int)(hInfernoBoost * lifeRegenMult); - if (player.lifeRegen < -200) + if (player.lifeRegen < -200) player.lifeRegen = -200; } else hInfernoBoost = 0; - if (ZoneAbyss) - { - if (!player.IsUnderwater()) - { - if (player.statLife > 100) - { - player.nebulaLevelLife = 0; + if (ZoneAbyss) + { + if (!player.IsUnderwater()) + { + if (player.statLife > 100) + { + player.nebulaLevelLife = 0; - if (player.lifeRegen > 0) - player.lifeRegen = 0; + if (player.lifeRegen > 0) + player.lifeRegen = 0; - player.lifeRegenTime = 0; - player.lifeRegen -= (int)(160D * lifeRegenMult); - } - } - } + player.lifeRegenTime = 0; + player.lifeRegen -= (int)(160D * lifeRegenMult); + } + } + } if (weakPetrification) { @@ -607,170 +607,170 @@ namespace CalamityMod.CalPlayer #region Update Life Regen public override void UpdateLifeRegen() { - if (rum) - player.lifeRegen += 2; + if (rum) + player.lifeRegen += 2; - if (caribbeanRum) - player.lifeRegen += 2; + if (caribbeanRum) + player.lifeRegen += 2; - if (aChicken) - player.lifeRegen += 1; + if (aChicken) + player.lifeRegen += 1; - if (cadence) - player.lifeRegen += 5; + if (cadence) + player.lifeRegen += 5; - if (mushy) - player.lifeRegen += 1; + if (mushy) + player.lifeRegen += 1; - if (permafrostsConcoction) - { - if (player.statLife < actualMaxLife / 2) - player.lifeRegen++; - if (player.statLife < actualMaxLife / 4) - player.lifeRegen++; - if (player.statLife < actualMaxLife / 10) - player.lifeRegen += 2; + if (permafrostsConcoction) + { + if (player.statLife < actualMaxLife / 2) + player.lifeRegen++; + if (player.statLife < actualMaxLife / 4) + player.lifeRegen++; + if (player.statLife < actualMaxLife / 10) + player.lifeRegen += 2; - if (player.poisoned || player.onFire || bFlames) - player.lifeRegen += 4; - } + if (player.poisoned || player.onFire || bFlames) + player.lifeRegen += 4; + } - if (tRegen) - player.lifeRegen += 3; + if (tRegen) + player.lifeRegen += 3; - if (sRegen) - player.lifeRegen += 2; + if (sRegen) + player.lifeRegen += 2; if (hallowedRegen) player.lifeRegen += 3; if (affliction || afflicted) - player.lifeRegen += 1; + player.lifeRegen += 1; - if (absorber) - { - if (player.StandingStill() && player.itemAnimation == 0) - player.lifeRegen += 4; - } + if (absorber) + { + if (player.StandingStill() && player.itemAnimation == 0) + player.lifeRegen += 4; + } - if (aAmpoule) - { - player.lifeRegen += 4; - } - else if (rOoze) - { - if (!Main.dayTime) - player.lifeRegen += 4; - } + if (aAmpoule) + { + player.lifeRegen += 4; + } + else if (rOoze) + { + if (!Main.dayTime) + player.lifeRegen += 4; + } - if (ursaSergeant) - { - if (player.statLife <= (int)(actualMaxLife * 0.15)) - { - player.lifeRegen += 3; - player.lifeRegenTime += 3; - } - else if (player.statLife <= (int)(actualMaxLife * 0.25)) - { - player.lifeRegen += 2; - player.lifeRegenTime += 2; - } - else if (player.statLife <= (int)(actualMaxLife * 0.5)) - { - player.lifeRegen += 1; - player.lifeRegenTime += 1; - } - } + if (ursaSergeant) + { + if (player.statLife <= (int)(actualMaxLife * 0.15)) + { + player.lifeRegen += 3; + player.lifeRegenTime += 3; + } + else if (player.statLife <= (int)(actualMaxLife * 0.25)) + { + player.lifeRegen += 2; + player.lifeRegenTime += 2; + } + else if (player.statLife <= (int)(actualMaxLife * 0.5)) + { + player.lifeRegen += 1; + player.lifeRegenTime += 1; + } + } - if (polarisBoost) - { - player.lifeRegen += 1; - player.lifeRegenTime += 1; - } + if (polarisBoost) + { + player.lifeRegen += 1; + player.lifeRegenTime += 1; + } - if (projRefRareLifeRegenCounter > 0) - { - player.lifeRegenTime += 2; - player.lifeRegen += 2; - } + if (projRefRareLifeRegenCounter > 0) + { + player.lifeRegenTime += 2; + player.lifeRegen += 2; + } - if (darkSunRing) - { - if (Main.eclipse || Main.dayTime) - player.lifeRegen += 3; - } + if (darkSunRing) + { + if (Main.eclipse || Main.dayTime) + player.lifeRegen += 3; + } - if (phantomicHeartRegen <= 720 && phantomicHeartRegen >= 600) - { - player.lifeRegen += 2; - if (Main.rand.NextBool(2)) - { - int regen = Dust.NewDust(player.position, player.width, player.height, 5, 0f, 0f, 200, new Color(99, 54, 84), 2f); - Main.dust[regen].noGravity = true; - Main.dust[regen].fadeIn = 1.3f; - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); - Main.dust[regen].velocity = velocity; - velocity.Normalize(); - velocity *= 34f; - Main.dust[regen].position = player.Center - velocity; - } - } + if (phantomicHeartRegen <= 720 && phantomicHeartRegen >= 600) + { + player.lifeRegen += 2; + if (Main.rand.NextBool(2)) + { + int regen = Dust.NewDust(player.position, player.width, player.height, 5, 0f, 0f, 200, new Color(99, 54, 84), 2f); + Main.dust[regen].noGravity = true; + Main.dust[regen].fadeIn = 1.3f; + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); + Main.dust[regen].velocity = velocity; + velocity.Normalize(); + velocity *= 34f; + Main.dust[regen].position = player.Center - velocity; + } + } - if (community) - { - float floatTypeBoost = 0.05f + - (NPC.downedSlimeKing ? 0.01f : 0f) + - (NPC.downedBoss1 ? 0.01f : 0f) + - (NPC.downedBoss2 ? 0.01f : 0f) + - (NPC.downedQueenBee ? 0.01f : 0f) + - (NPC.downedBoss3 ? 0.01f : 0f) + // 0.1 - (Main.hardMode ? 0.01f : 0f) + - (NPC.downedMechBossAny ? 0.01f : 0f) + - (NPC.downedPlantBoss ? 0.01f : 0f) + - (NPC.downedGolemBoss ? 0.01f : 0f) + - (NPC.downedFishron ? 0.01f : 0f) + // 0.15 - (NPC.downedAncientCultist ? 0.01f : 0f) + - (NPC.downedMoonlord ? 0.01f : 0f) + - (CalamityWorld.downedProvidence ? 0.01f : 0f) + - (CalamityWorld.downedDoG ? 0.01f : 0f) + - (CalamityWorld.downedYharon ? 0.01f : 0f); // 0.2 - int integerTypeBoost = (int)(floatTypeBoost * 50f); - int regenBoost = 1 + (integerTypeBoost / 5); - bool lesserEffect = false; - for (int l = 0; l < Player.MaxBuffs; l++) - { - int hasBuff = player.buffType[l]; - bool shouldAffect = CalamityLists.alcoholList.Contains(hasBuff); - if (shouldAffect) - lesserEffect = true; - } - if (player.lifeRegen < 0) - player.lifeRegen += lesserEffect ? 1 : regenBoost; - } + if (community) + { + float floatTypeBoost = 0.05f + + (NPC.downedSlimeKing ? 0.01f : 0f) + + (NPC.downedBoss1 ? 0.01f : 0f) + + (NPC.downedBoss2 ? 0.01f : 0f) + + (NPC.downedQueenBee ? 0.01f : 0f) + + (NPC.downedBoss3 ? 0.01f : 0f) + // 0.1 + (Main.hardMode ? 0.01f : 0f) + + (NPC.downedMechBossAny ? 0.01f : 0f) + + (NPC.downedPlantBoss ? 0.01f : 0f) + + (NPC.downedGolemBoss ? 0.01f : 0f) + + (NPC.downedFishron ? 0.01f : 0f) + // 0.15 + (NPC.downedAncientCultist ? 0.01f : 0f) + + (NPC.downedMoonlord ? 0.01f : 0f) + + (CalamityWorld.downedProvidence ? 0.01f : 0f) + + (CalamityWorld.downedDoG ? 0.01f : 0f) + + (CalamityWorld.downedYharon ? 0.01f : 0f); // 0.2 + int integerTypeBoost = (int)(floatTypeBoost * 50f); + int regenBoost = 1 + (integerTypeBoost / 5); + bool lesserEffect = false; + for (int l = 0; l < Player.MaxBuffs; l++) + { + int hasBuff = player.buffType[l]; + bool shouldAffect = CalamityLists.alcoholList.Contains(hasBuff); + if (shouldAffect) + lesserEffect = true; + } + if (player.lifeRegen < 0) + player.lifeRegen += lesserEffect ? 1 : regenBoost; + } - if (regenator) - { - player.lifeRegenTime += 6; - player.lifeRegen += 12; - } + if (regenator) + { + player.lifeRegenTime += 6; + player.lifeRegen += 12; + } if (handWarmer && eskimoSet) { player.lifeRegen += 2; } - if (bloodPactBoost) + if (bloodPactBoost) { player.lifeRegen += 2; } - if (avertorBonus) + if (avertorBonus) { player.lifeRegen += 4; } - if (bloodflareSummon) - { - if (player.statLife <= (int)(actualMaxLife * 0.5)) - player.lifeRegen += 2; - } + if (bloodflareSummon) + { + if (player.statLife <= (int)(actualMaxLife * 0.5)) + player.lifeRegen += 2; + } if (fearmongerSet && fearmongerRegenFrames > 0) { @@ -779,214 +779,214 @@ namespace CalamityMod.CalPlayer if (player.lifeRegenTime < 1800) player.lifeRegenTime = 1800; - player.lifeRegenTime += 4; + player.lifeRegenTime += 4; } - if (pinkCandle && !noLifeRegen) - { - // Every frame, add up 1/60th of the healing value (0.4% max HP per second) - pinkCandleHealFraction += player.statLifeMax2 * 0.004 / 60; + if (pinkCandle && !noLifeRegen) + { + // Every frame, add up 1/60th of the healing value (0.4% max HP per second) + pinkCandleHealFraction += player.statLifeMax2 * 0.004 / 60; - if (pinkCandleHealFraction >= 1D) - { - pinkCandleHealFraction = 0D; + if (pinkCandleHealFraction >= 1D) + { + pinkCandleHealFraction = 0D; - if (player.statLife < player.statLifeMax2) - player.statLife++; - } - } - else - pinkCandleHealFraction = 0D; + if (player.statLife < player.statLifeMax2) + player.statLife++; + } + } + else + pinkCandleHealFraction = 0D; - if (reaverRegen && reaverRegenCooldown >= 60) - { - reaverRegenCooldown = 0; + if (reaverRegen && reaverRegenCooldown >= 60) + { + reaverRegenCooldown = 0; - if (player.statLife != player.statLifeMax2 && !noLifeRegen) - player.statLife += 1; - } + if (player.statLife != player.statLifeMax2 && !noLifeRegen) + player.statLife += 1; + } - if (BloomStoneRegen) - { - float dayTimeCompletion = !Main.dayTime ? 1f : (float)(Main.time / Main.dayLength); - float regenBenefitFactor = MathHelper.SmoothStep(0.25f, 1f, Utils.InverseLerp(0f, 0.24f, dayTimeCompletion, true) * Utils.InverseLerp(1f, 0.76f, dayTimeCompletion, true)); + if (BloomStoneRegen) + { + float dayTimeCompletion = !Main.dayTime ? 1f : (float)(Main.time / Main.dayLength); + float regenBenefitFactor = MathHelper.SmoothStep(0.25f, 1f, Utils.InverseLerp(0f, 0.24f, dayTimeCompletion, true) * Utils.InverseLerp(1f, 0.76f, dayTimeCompletion, true)); - player.lifeRegen += (int)MathHelper.Lerp(2f, 6f, regenBenefitFactor); - player.lifeRegenTime += (int)MathHelper.Lerp(1f, 3f, regenBenefitFactor); - } + player.lifeRegen += (int)MathHelper.Lerp(2f, 6f, regenBenefitFactor); + player.lifeRegenTime += (int)MathHelper.Lerp(1f, 3f, regenBenefitFactor); + } - // Standing still healing bonuses (all exclusive with vanilla Shiny Stone) - if (!player.shinyStone) - { - int lifeRegenTimeMaxBoost = areThereAnyDamnBosses ? 450 : 1800; - int lifeRegenMaxBoost = areThereAnyDamnBosses ? 1 : 4; - float lifeRegenLifeRegenTimeMaxBoost = areThereAnyDamnBosses ? 8f : 30f; + // Standing still healing bonuses (all exclusive with vanilla Shiny Stone) + if (!player.shinyStone) + { + int lifeRegenTimeMaxBoost = areThereAnyDamnBosses ? 450 : 1800; + int lifeRegenMaxBoost = areThereAnyDamnBosses ? 1 : 4; + float lifeRegenLifeRegenTimeMaxBoost = areThereAnyDamnBosses ? 8f : 30f; - if (player.StandingStill() && player.itemAnimation == 0) - { - bool boostedRegen = false; - bool noSunlight = false; - if (shadeRegen) - { - boostedRegen = true; - if (player.lifeRegen > 0 && player.statLife < actualMaxLife) - { - if (Main.rand.Next(30000) < player.lifeRegenTime || Main.rand.NextBool(30)) - { - int regen = Dust.NewDust(player.position, player.width, player.height, 173, 0f, 0f, 200, default, 1f); - Main.dust[regen].noGravity = true; - Main.dust[regen].fadeIn = 1.3f; - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); - Main.dust[regen].velocity = velocity; - velocity.Normalize(); - velocity *= 34f; - Main.dust[regen].position = player.Center - velocity; - } - } - } - else if (cFreeze) - { - boostedRegen = true; - if (player.lifeRegen > 0 && player.statLife < actualMaxLife) - { - if (Main.rand.Next(30000) < player.lifeRegenTime || Main.rand.NextBool(30)) - { - int regen = Dust.NewDust(player.position, player.width, player.height, 67, 0f, 0f, 200, new Color(150, Main.DiscoG, 255), 0.75f); - Main.dust[regen].noGravity = true; - Main.dust[regen].fadeIn = 1.3f; - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); - Main.dust[regen].velocity = velocity; - velocity.Normalize(); - velocity *= 34f; - Main.dust[regen].position = player.Center - velocity; - } - } - } - else if (draedonsHeart) - { - boostedRegen = true; - if (player.lifeRegen > 0 && player.statLife < actualMaxLife) - { - if (Main.rand.Next(30000) < player.lifeRegenTime || Main.rand.NextBool(2)) - { - int regen = Dust.NewDust(player.position, player.width, player.height, 107, 0f, 0f, 200, default, 1f); - Main.dust[regen].noGravity = true; - Main.dust[regen].fadeIn = 1.3f; - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); - Main.dust[regen].velocity = velocity; - velocity.Normalize(); - velocity *= 34f; - Main.dust[regen].position = player.Center - velocity; - } - } - } - else if (photosynthesis) - { - boostedRegen = true; - if (!Main.dayTime) - noSunlight = true; - if (player.lifeRegen > 0 && player.statLife < actualMaxLife) - { - if (Main.rand.Next(30000) < player.lifeRegenTime || Main.rand.NextBool(2)) - { - int regen = Dust.NewDust(player.position, player.width, player.height, 244, 0f, 0f, 200, default, 1f); - Main.dust[regen].noGravity = true; - Main.dust[regen].fadeIn = 1.3f; - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); - Main.dust[regen].velocity = velocity; - velocity.Normalize(); - velocity *= 34f; - Main.dust[regen].position = player.Center - velocity; - } - } - } - if (boostedRegen) - { - int lifeRegenTimeMaxBoost2 = !noSunlight ? lifeRegenTimeMaxBoost : (lifeRegenTimeMaxBoost / 5); - int lifeRegenMaxBoost2 = !noSunlight ? lifeRegenMaxBoost : (lifeRegenMaxBoost / 5); - float lifeRegenLifeRegenTimeMaxBoost2 = !noSunlight ? lifeRegenLifeRegenTimeMaxBoost : (lifeRegenLifeRegenTimeMaxBoost / 5); + if (player.StandingStill() && player.itemAnimation == 0) + { + bool boostedRegen = false; + bool noSunlight = false; + if (shadeRegen) + { + boostedRegen = true; + if (player.lifeRegen > 0 && player.statLife < actualMaxLife) + { + if (Main.rand.Next(30000) < player.lifeRegenTime || Main.rand.NextBool(30)) + { + int regen = Dust.NewDust(player.position, player.width, player.height, 173, 0f, 0f, 200, default, 1f); + Main.dust[regen].noGravity = true; + Main.dust[regen].fadeIn = 1.3f; + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); + Main.dust[regen].velocity = velocity; + velocity.Normalize(); + velocity *= 34f; + Main.dust[regen].position = player.Center - velocity; + } + } + } + else if (cFreeze) + { + boostedRegen = true; + if (player.lifeRegen > 0 && player.statLife < actualMaxLife) + { + if (Main.rand.Next(30000) < player.lifeRegenTime || Main.rand.NextBool(30)) + { + int regen = Dust.NewDust(player.position, player.width, player.height, 67, 0f, 0f, 200, new Color(150, Main.DiscoG, 255), 0.75f); + Main.dust[regen].noGravity = true; + Main.dust[regen].fadeIn = 1.3f; + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); + Main.dust[regen].velocity = velocity; + velocity.Normalize(); + velocity *= 34f; + Main.dust[regen].position = player.Center - velocity; + } + } + } + else if (draedonsHeart) + { + boostedRegen = true; + if (player.lifeRegen > 0 && player.statLife < actualMaxLife) + { + if (Main.rand.Next(30000) < player.lifeRegenTime || Main.rand.NextBool(2)) + { + int regen = Dust.NewDust(player.position, player.width, player.height, 107, 0f, 0f, 200, default, 1f); + Main.dust[regen].noGravity = true; + Main.dust[regen].fadeIn = 1.3f; + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); + Main.dust[regen].velocity = velocity; + velocity.Normalize(); + velocity *= 34f; + Main.dust[regen].position = player.Center - velocity; + } + } + } + else if (photosynthesis) + { + boostedRegen = true; + if (!Main.dayTime) + noSunlight = true; + if (player.lifeRegen > 0 && player.statLife < actualMaxLife) + { + if (Main.rand.Next(30000) < player.lifeRegenTime || Main.rand.NextBool(2)) + { + int regen = Dust.NewDust(player.position, player.width, player.height, 244, 0f, 0f, 200, default, 1f); + Main.dust[regen].noGravity = true; + Main.dust[regen].fadeIn = 1.3f; + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); + Main.dust[regen].velocity = velocity; + velocity.Normalize(); + velocity *= 34f; + Main.dust[regen].position = player.Center - velocity; + } + } + } + if (boostedRegen) + { + int lifeRegenTimeMaxBoost2 = !noSunlight ? lifeRegenTimeMaxBoost : (lifeRegenTimeMaxBoost / 5); + int lifeRegenMaxBoost2 = !noSunlight ? lifeRegenMaxBoost : (lifeRegenMaxBoost / 5); + float lifeRegenLifeRegenTimeMaxBoost2 = !noSunlight ? lifeRegenLifeRegenTimeMaxBoost : (lifeRegenLifeRegenTimeMaxBoost / 5); - if (player.lifeRegenTime > 90 && player.lifeRegenTime < lifeRegenTimeMaxBoost2) - player.lifeRegenTime = lifeRegenTimeMaxBoost2; + if (player.lifeRegenTime > 90 && player.lifeRegenTime < lifeRegenTimeMaxBoost2) + player.lifeRegenTime = lifeRegenTimeMaxBoost2; - player.lifeRegenTime += lifeRegenMaxBoost2; - player.lifeRegen += lifeRegenMaxBoost2; + player.lifeRegenTime += lifeRegenMaxBoost2; + player.lifeRegen += lifeRegenMaxBoost2; - float num3 = player.lifeRegenTime * 2.5f; // lifeRegenTime max is 3600 - num3 /= 300f; - if (num3 > 0f) - { - if (num3 > lifeRegenLifeRegenTimeMaxBoost2) - num3 = lifeRegenLifeRegenTimeMaxBoost2; + float num3 = player.lifeRegenTime * 2.5f; // lifeRegenTime max is 3600 + num3 /= 300f; + if (num3 > 0f) + { + if (num3 > lifeRegenLifeRegenTimeMaxBoost2) + num3 = lifeRegenLifeRegenTimeMaxBoost2; - player.lifeRegen += (int)num3; - } - if (player.lifeRegen > 0 && player.statLife < actualMaxLife) - { - player.lifeRegenCount++; - } - } - } - } + player.lifeRegen += (int)num3; + } + if (player.lifeRegen > 0 && player.statLife < actualMaxLife) + { + player.lifeRegenCount++; + } + } + } + } - // The Camper regen boost activates while moving so it can stack with Shiny Stone like effects - if (camper && player.statLife < actualMaxLife && !player.StandingStill()) - { - float camperRegenMult = areThereAnyDamnBosses ? 1.25f : 2f; - int camperRegenCount = areThereAnyDamnBosses ? 1 : 4; - player.lifeRegen = (int)(player.lifeRegen * camperRegenMult); - player.lifeRegenCount += camperRegenCount; - if (Main.rand.Next(30000) < player.lifeRegenTime || Main.rand.NextBool(2)) - { - int regen = Dust.NewDust(player.position, player.width, player.height, 12, 0f, 0f, 200, Color.OrangeRed, 1f); - Main.dust[regen].noGravity = true; - Main.dust[regen].fadeIn = 1.3f; - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); - Main.dust[regen].velocity = velocity; - velocity.Normalize(); - velocity *= 34f; - Main.dust[regen].position = player.Center - velocity; - } - } + // The Camper regen boost activates while moving so it can stack with Shiny Stone like effects + if (camper && player.statLife < actualMaxLife && !player.StandingStill()) + { + float camperRegenMult = areThereAnyDamnBosses ? 1.25f : 2f; + int camperRegenCount = areThereAnyDamnBosses ? 1 : 4; + player.lifeRegen = (int)(player.lifeRegen * camperRegenMult); + player.lifeRegenCount += camperRegenCount; + if (Main.rand.Next(30000) < player.lifeRegenTime || Main.rand.NextBool(2)) + { + int regen = Dust.NewDust(player.position, player.width, player.height, 12, 0f, 0f, 200, Color.OrangeRed, 1f); + Main.dust[regen].noGravity = true; + Main.dust[regen].fadeIn = 1.3f; + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); + Main.dust[regen].velocity = velocity; + velocity.Normalize(); + velocity *= 34f; + Main.dust[regen].position = player.Center - velocity; + } + } - if (player.statLife < actualMaxLife) - { - bool noLifeRegenCap = (player.shinyStone || draedonsHeart || cFreeze || shadeRegen || photosynthesis || camper) && - player.StandingStill() && player.itemAnimation == 0; + if (player.statLife < actualMaxLife) + { + bool noLifeRegenCap = (player.shinyStone || draedonsHeart || cFreeze || shadeRegen || photosynthesis || camper) && + player.StandingStill() && player.itemAnimation == 0; - if (!noLifeRegenCap) - { - // Max HP = 400 - // 350 HP = 1 - 0.875 * 10 = 1.25 = 1 - // 100 HP = 1 - 0.25 * 10 = 7.5 = 7 - // 200 HP = 1 - 0.5 * 10 = 5 - int lifeRegenScale = (int)((1f - (player.statLife / actualMaxLife)) * 10f); // 9 to 0 (1% HP to 100%) - if (player.lifeRegen > lifeRegenScale) - { - float lifeRegenScalar = 1f + (player.statLife / actualMaxLife); // 1 to 2 (1% HP to 100%) - int defLifeRegen = (int)(player.lifeRegen / lifeRegenScalar); - player.lifeRegen = defLifeRegen; - } - } - } + if (!noLifeRegenCap) + { + // Max HP = 400 + // 350 HP = 1 - 0.875 * 10 = 1.25 = 1 + // 100 HP = 1 - 0.25 * 10 = 7.5 = 7 + // 200 HP = 1 - 0.5 * 10 = 5 + int lifeRegenScale = (int)((1f - (player.statLife / actualMaxLife)) * 10f); // 9 to 0 (1% HP to 100%) + if (player.lifeRegen > lifeRegenScale) + { + float lifeRegenScalar = 1f + (player.statLife / actualMaxLife); // 1 to 2 (1% HP to 100%) + int defLifeRegen = (int)(player.lifeRegen / lifeRegenScalar); + player.lifeRegen = defLifeRegen; + } + } + } - if (BossRushEvent.BossRushActive) - { - if (CalamityConfig.Instance.BossRushHealthCurse) - { - if (player.lifeRegen > 0) - player.lifeRegen = 0; + if (BossRushEvent.BossRushActive) + { + if (CalamityConfig.Instance.BossRushHealthCurse) + { + if (player.lifeRegen > 0) + player.lifeRegen = 0; - player.lifeRegenTime = 0; + player.lifeRegenTime = 0; - if (player.lifeRegenCount > 0) - player.lifeRegenCount = 0; - } - } + if (player.lifeRegenCount > 0) + player.lifeRegenCount = 0; + } + } - // For the stat meter - lifeRegenStat = player.lifeRegen; - } + // For the stat meter + lifeRegenStat = player.lifeRegen; + } #endregion } } diff --git a/CalamityConfig.cs b/CalamityConfig.cs index f817919280..4f36a12ce2 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -8,373 +8,373 @@ using Terraria.ModLoader.Config; namespace CalamityMod { - [Label("Config")] - [BackgroundColor(49, 32, 36, 216)] - public class CalamityConfig : ModConfig - { - public static CalamityConfig Instance; - public override ConfigScope Mode => ConfigScope.ClientSide; + [Label("Config")] + [BackgroundColor(49, 32, 36, 216)] + public class CalamityConfig : ModConfig + { + public static CalamityConfig Instance; + public override ConfigScope Mode => ConfigScope.ClientSide; - // Clamps values that would cause ugly problems if loaded directly without sanitization. - [OnDeserialized] - internal void ClampValues(StreamingContext context) - { - BossHealthBoost = Utils.Clamp(BossHealthBoost, MinBossHealthBoost, MaxBossHealthBoost); - MeterShake = Utils.Clamp(MeterShake, MinMeterShake, MaxMeterShake); - } + // Clamps values that would cause ugly problems if loaded directly without sanitization. + [OnDeserialized] + internal void ClampValues(StreamingContext context) + { + BossHealthBoost = Utils.Clamp(BossHealthBoost, MinBossHealthBoost, MaxBossHealthBoost); + MeterShake = Utils.Clamp(MeterShake, MinMeterShake, MaxMeterShake); + } - [Header("Graphics Changes")] + [Header("Graphics Changes")] - [Label("$Mods.CalamityMod.Afterimages")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Enables rendering afterimages for Calamity NPCs, projectiles, etc.\nDisable to improve performance.")] - public bool Afterimages { get; set; } + [Label("$Mods.CalamityMod.Afterimages")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Enables rendering afterimages for Calamity NPCs, projectiles, etc.\nDisable to improve performance.")] + public bool Afterimages { get; set; } - [Label("$Mods.CalamityMod.MaxParticles")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0, 1000)] - [DefaultValue(500)] - [Tooltip("Sets the maximum of particle effects that can exist at once.\nParticles are separate from dust and gores.\nTurn down to improve performance.")] - public int ParticleLimit { get; set; } + [Label("$Mods.CalamityMod.MaxParticles")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0, 1000)] + [DefaultValue(500)] + [Tooltip("Sets the maximum of particle effects that can exist at once.\nParticles are separate from dust and gores.\nTurn down to improve performance.")] + public int ParticleLimit { get; set; } - [Label("$Mods.CalamityMod.ScreenshakeOff")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(false)] - [Tooltip("Disables all screen-shaking effects.")] - public bool DisableScreenShakes { get; set; } + [Label("$Mods.CalamityMod.ScreenshakeOff")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + [Tooltip("Disables all screen-shaking effects.")] + public bool DisableScreenShakes { get; set; } - [Label("$Mods.CalamityMod.StealthInvisibility")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Enables players gradually turning invisible as their Rogue Stealth increases.\nThis effect is visually similar to Shroomite armor's stealth.")] - public bool StealthInvisbility { get; set; } + [Label("$Mods.CalamityMod.StealthInvisibility")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Enables players gradually turning invisible as their Rogue Stealth increases.\nThis effect is visually similar to Shroomite armor's stealth.")] + public bool StealthInvisbility { get; set; } - [Label("$Mods.CalamityMod.ShopAlert")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Adds an icon that appears over Town NPCs when they have new items in their shops.")] - public bool ShopNewAlert { get; set; } + [Label("$Mods.CalamityMod.ShopAlert")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Adds an icon that appears over Town NPCs when they have new items in their shops.")] + public bool ShopNewAlert { get; set; } - [Header("UI Changes")] + [Header("UI Changes")] - [Label("$Mods.CalamityMod.BossHealthBar")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Enables Calamity's boss health bar in the bottom right corner of the screen.")] - public bool BossHealthBar { get; set; } + [Label("$Mods.CalamityMod.BossHealthBar")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Enables Calamity's boss health bar in the bottom right corner of the screen.")] + public bool BossHealthBar { get; set; } - [Label("$Mods.CalamityMod.BossHealthBarExtra")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Adds extra info to the Calamity boss health bar.\nThis displays either the boss's exact health or number of remaining parts or segments.")] - public bool BossHealthBarExtraInfo { get; set; } + [Label("$Mods.CalamityMod.BossHealthBarExtra")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Adds extra info to the Calamity boss health bar.\nThis displays either the boss's exact health or number of remaining parts or segments.")] + public bool BossHealthBarExtraInfo { get; set; } - [Label("$Mods.CalamityMod.DebuffDisplay")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Adds an array of debuff icons above all bosses and minibosses.")] - public bool DebuffDisplay { get; set; } + [Label("$Mods.CalamityMod.DebuffDisplay")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Adds an array of debuff icons above all bosses and minibosses.")] + public bool DebuffDisplay { get; set; } - [Label("$Mods.CalamityMod.CooldownDisplay")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0f,2f)] - [DefaultValue(2f)] - [Increment(1f)] - [DrawTicks] - [Tooltip("Displays all the important cooldowns on your UI under your buffs and debuffs. Set this to 1 to have it display in a more compact way, and to 0 to entirely disable the UI")] - public float CooldownDisplay { get; set; } + [Label("$Mods.CalamityMod.CooldownDisplay")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0f,2f)] + [DefaultValue(2f)] + [Increment(1f)] + [DrawTicks] + [Tooltip("Displays all the important cooldowns on your UI under your buffs and debuffs. Set this to 1 to have it display in a more compact way, and to 0 to entirely disable the UI")] + public float CooldownDisplay { get; set; } - [Label("$Mods.CalamityMod.VanillaCooldownDisplay")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Adds custom cooldown displays for Chaos State and Potion Sickness.\nThis doesn't remove them from your buff list, but can help with visibility nontheless")] - public bool VanillaCooldownDisplay { get; set; } + [Label("$Mods.CalamityMod.VanillaCooldownDisplay")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Adds custom cooldown displays for Chaos State and Potion Sickness.\nThis doesn't remove them from your buff list, but can help with visibility nontheless")] + public bool VanillaCooldownDisplay { get; set; } - [BackgroundColor(192, 54, 64, 192)] - [Label("$Mods.CalamityMod.MeterLock")] - [DefaultValue(true)] - [Tooltip("Prevents clicking on the Stealth, Charge, Rage, and Adrenaline Meters.\nThis stops them from being dragged around with the mouse.")] - public bool MeterPosLock { get; set; } + [BackgroundColor(192, 54, 64, 192)] + [Label("$Mods.CalamityMod.MeterLock")] + [DefaultValue(true)] + [Tooltip("Prevents clicking on the Stealth, Charge, Rage, and Adrenaline Meters.\nThis stops them from being dragged around with the mouse.")] + public bool MeterPosLock { get; set; } - [Label("$Mods.CalamityMod.StealthMeter")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Enables the Stealth Meter UI, which shows the player's current stealth level.\nThe Stealth Meter is always hidden if not wearing Rogue armor.")] - public bool StealthBar { get; set; } + [Label("$Mods.CalamityMod.StealthMeter")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Enables the Stealth Meter UI, which shows the player's current stealth level.\nThe Stealth Meter is always hidden if not wearing Rogue armor.")] + public bool StealthBar { get; set; } - [Label("$Mods.CalamityMod.StealthMeterX")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0f, 3840f)] - [DefaultValue(820f)] - [Tooltip("The X position of the Stealth Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] - public float StealthMeterPosX { get; set; } + [Label("$Mods.CalamityMod.StealthMeterX")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0f, 3840f)] + [DefaultValue(820f)] + [Tooltip("The X position of the Stealth Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + public float StealthMeterPosX { get; set; } - [Label("$Mods.CalamityMod.StealthMeterY")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0f, 2160f)] - [DefaultValue(43f)] - [Tooltip("The Y position of the Stealth Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] - public float StealthMeterPosY { get; set; } + [Label("$Mods.CalamityMod.StealthMeterY")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0f, 2160f)] + [DefaultValue(43f)] + [Tooltip("The Y position of the Stealth Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + public float StealthMeterPosY { get; set; } - [Label("$Mods.CalamityMod.ChargeMeter")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Enables the Charge Meter UI, which shows the charge level of the player's currently held Arsenal item.\nThe Charge Meter is always hidden if not holding a chargable arsenal item.")] - public bool ChargeMeter { get; set; } + [Label("$Mods.CalamityMod.ChargeMeter")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Enables the Charge Meter UI, which shows the charge level of the player's currently held Arsenal item.\nThe Charge Meter is always hidden if not holding a chargable arsenal item.")] + public bool ChargeMeter { get; set; } - [Label("$Mods.CalamityMod.ChargeMeterX")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0f, 3840f)] - [DefaultValue(950f)] - [Tooltip("The X position of the Charge Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] - public float ChargeMeterPosX { get; set; } + [Label("$Mods.CalamityMod.ChargeMeterX")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0f, 3840f)] + [DefaultValue(950f)] + [Tooltip("The X position of the Charge Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + public float ChargeMeterPosX { get; set; } - [Label("$Mods.CalamityMod.ChargeMeterY")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0f, 2160f)] - [DefaultValue(43f)] - [Tooltip("The Y position of the Charge Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] - public float ChargeMeterPosY { get; set; } + [Label("$Mods.CalamityMod.ChargeMeterY")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0f, 2160f)] + [DefaultValue(43f)] + [Tooltip("The Y position of the Charge Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + public float ChargeMeterPosY { get; set; } - [Label("$Mods.CalamityMod.SpeedrunTimer")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(false)] - [Tooltip("Enables a Speedrun Timer.")] - public bool SpeedrunTimer { get; set; } + [Label("$Mods.CalamityMod.SpeedrunTimer")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + [Tooltip("Enables a Speedrun Timer.")] + public bool SpeedrunTimer { get; set; } - [Label("$Mods.CalamityMod.SpeedrunTimerX")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(-800f, 800f)] - [DefaultValue(68f)] - [Tooltip("The X position of the Speedrun Timer.")] - public float SpeedrunTimerPosX { get; set; } + [Label("$Mods.CalamityMod.SpeedrunTimerX")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(-800f, 800f)] + [DefaultValue(68f)] + [Tooltip("The X position of the Speedrun Timer.")] + public float SpeedrunTimerPosX { get; set; } - [Label("$Mods.CalamityMod.SpeedrunTimerY")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(16f, 1000f)] - [DefaultValue(16f)] - [Tooltip("The Y position of the Speedrun Timer.")] - public float SpeedrunTimerPosY { get; set; } + [Label("$Mods.CalamityMod.SpeedrunTimerY")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(16f, 1000f)] + [DefaultValue(16f)] + [Tooltip("The Y position of the Speedrun Timer.")] + public float SpeedrunTimerPosY { get; set; } - [Header("General Gameplay Changes")] + [Header("General Gameplay Changes")] - [Label("$Mods.CalamityMod.EarlyHMRework")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Demon Altars no longer spawn ores and crimson/corruption blocks when broken.\n" + - "Wall of Flesh spawns Cobalt and Palladium ore on first kill.\n" + - "The first mech boss you fight has 20% less HP and damage and spawns Mythril and Orichalcum ore on first kill.\n" + - "The second mech boss you fight has 10% less HP and damage and spawns Adamantite and Titanium ore on first kill.\n" + - "The third mech boss spawns Hallowed Ore on first kill")] - public bool EarlyHardmodeProgressionRework { get; set; } + [Label("$Mods.CalamityMod.EarlyHMRework")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Demon Altars no longer spawn ores and crimson/corruption blocks when broken.\n" + + "Wall of Flesh spawns Cobalt and Palladium ore on first kill.\n" + + "The first mech boss you fight has 20% less HP and damage and spawns Mythril and Orichalcum ore on first kill.\n" + + "The second mech boss you fight has 10% less HP and damage and spawns Adamantite and Titanium ore on first kill.\n" + + "The third mech boss spawns Hallowed Ore on first kill")] + public bool EarlyHardmodeProgressionRework { get; set; } - [Label("$Mods.CalamityMod.Proficiency")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Enables the Proficiency system which allows the player to gain slight stat bonuses by persistently using one damage class.\nDisabling the system does not remove levels players already have, but disables their stat bonuses and prevents experience gain.")] - public bool Proficiency { get; set; } + [Label("$Mods.CalamityMod.Proficiency")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Enables the Proficiency system which allows the player to gain slight stat bonuses by persistently using one damage class.\nDisabling the system does not remove levels players already have, but disables their stat bonuses and prevents experience gain.")] + public bool Proficiency { get; set; } - [Label("$Mods.CalamityMod.BossZen")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("While a boss is alive, all players near a boss receive the Boss Effects buff, which drastically reduces enemy spawn rates.")] - public bool BossZen { get; set; } + [Label("$Mods.CalamityMod.BossZen")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("While a boss is alive, all players near a boss receive the Boss Effects buff, which drastically reduces enemy spawn rates.")] + public bool BossZen { get; set; } - [Label("$Mods.CalamityMod.NPCNightSpawn")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(false)] - [Tooltip("Allows you to determine if town NPCs (including the Old Man) can spawn at night.")] - public bool CanTownNPCsSpawnAtNight { get; set; } + [Label("$Mods.CalamityMod.NPCNightSpawn")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + [Tooltip("Allows you to determine if town NPCs (including the Old Man) can spawn at night.")] + public bool CanTownNPCsSpawnAtNight { get; set; } - private const int MinTownNPCSpawnMultiplier = 1; - private const int MaxTownNPCSpawnMultiplier = 10; + private const int MinTownNPCSpawnMultiplier = 1; + private const int MaxTownNPCSpawnMultiplier = 10; - [Label("$Mods.CalamityMod.NPCExtraSpawn")] - [BackgroundColor(192, 54, 64, 192)] - [Range(MinTownNPCSpawnMultiplier, MaxTownNPCSpawnMultiplier)] - [Increment(1)] - [DrawTicks] - [DefaultValue(MinTownNPCSpawnMultiplier)] - [Tooltip("Makes town NPCs spawn more quickly, the higher this value is.")] - public int TownNPCSpawnRateMultiplier { get; set; } + [Label("$Mods.CalamityMod.NPCExtraSpawn")] + [BackgroundColor(192, 54, 64, 192)] + [Range(MinTownNPCSpawnMultiplier, MaxTownNPCSpawnMultiplier)] + [Increment(1)] + [DrawTicks] + [DefaultValue(MinTownNPCSpawnMultiplier)] + [Tooltip("Makes town NPCs spawn more quickly, the higher this value is.")] + public int TownNPCSpawnRateMultiplier { get; set; } - private const float MinBossHealthBoost = 0f; - private const float MaxBossHealthBoost = 900f; + private const float MinBossHealthBoost = 0f; + private const float MaxBossHealthBoost = 900f; - [Label("$Mods.CalamityMod.BossHPBoost")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(MinBossHealthBoost, MaxBossHealthBoost)] - [Increment(50f)] - [DrawTicks] - [DefaultValue(MinBossHealthBoost)] - [Tooltip("Globally boosts the health of all bosses.\nDoes not affect bosses that are already spawned.")] - public float BossHealthBoost { get; set; } + [Label("$Mods.CalamityMod.BossHPBoost")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(MinBossHealthBoost, MaxBossHealthBoost)] + [Increment(50f)] + [DrawTicks] + [DefaultValue(MinBossHealthBoost)] + [Tooltip("Globally boosts the health of all bosses.\nDoes not affect bosses that are already spawned.")] + public float BossHealthBoost { get; set; } - [Header("Expert Mode Changes")] + [Header("Expert Mode Changes")] - [Label("$Mods.CalamityMod.ExpertDebuffReduction")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("Disables Expert Mode doubling the duration of all debuffs inflicted on the player.\nCalamity is balanced with the assumption that this setting is enabled.")] - public bool NerfExpertDebuffs { get; set; } + [Label("$Mods.CalamityMod.ExpertDebuffReduction")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Disables Expert Mode doubling the duration of all debuffs inflicted on the player.\nCalamity is balanced with the assumption that this setting is enabled.")] + public bool NerfExpertDebuffs { get; set; } - [Label("$Mods.CalamityMod.ChillWaterRework")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - [Tooltip("When enabled, water in the Snow and Ice biomes will rapidly drain the player's breath instead of inflicting Chilled.")] - public bool ReworkChilledWater { get; set; } + [Label("$Mods.CalamityMod.ChillWaterRework")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("When enabled, water in the Snow and Ice biomes will rapidly drain the player's breath instead of inflicting Chilled.")] + public bool ReworkChilledWater { get; set; } - [Label("$Mods.CalamityMod.ExpertSafeTowns")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(false)] - [Tooltip("Counteracts Expert Mode allowing enemies to spawn near towns by vastly decreasing spawn rates.\nThis can have unintended side effects such as making critters difficult to find.")] - public bool DisableExpertTownSpawns { get; set; } + [Label("$Mods.CalamityMod.ExpertSafeTowns")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + [Tooltip("Counteracts Expert Mode allowing enemies to spawn near towns by vastly decreasing spawn rates.\nThis can have unintended side effects such as making critters difficult to find.")] + public bool DisableExpertTownSpawns { get; set; } - [Header("Revengeance Mode Changes")] + [Header("Revengeance Mode Changes")] - private const float MinMeterShake = 0f; - private const float MaxMeterShake = 4f; + private const float MinMeterShake = 0f; + private const float MaxMeterShake = 4f; - [Label("$Mods.CalamityMod.RipperBarShake")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(MinMeterShake, MaxMeterShake)] - [Increment(1f)] - [DrawTicks] - [DefaultValue(2f)] - [Tooltip("How much the Rage and Adrenaline Meters shake while in use.\nSet to zero to disable the shaking entirely.")] - public float MeterShake { get; set; } + [Label("$Mods.CalamityMod.RipperBarShake")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(MinMeterShake, MaxMeterShake)] + [Increment(1f)] + [DrawTicks] + [DefaultValue(2f)] + [Tooltip("How much the Rage and Adrenaline Meters shake while in use.\nSet to zero to disable the shaking entirely.")] + public float MeterShake { get; set; } - [Label("$Mods.CalamityMod.RageX")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0f, 3840f)] - [DefaultValue(RipperUI.DefaultRagePosX)] - [Tooltip("The X position of the Rage Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] - public float RageMeterPosX { get; set; } + [Label("$Mods.CalamityMod.RageX")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0f, 3840f)] + [DefaultValue(RipperUI.DefaultRagePosX)] + [Tooltip("The X position of the Rage Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + public float RageMeterPosX { get; set; } - [Label("$Mods.CalamityMod.RageY")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0f, 2160f)] - [DefaultValue(RipperUI.DefaultRagePosY)] - [Tooltip("The Y position of the Rage Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] - public float RageMeterPosY { get; set; } + [Label("$Mods.CalamityMod.RageY")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0f, 2160f)] + [DefaultValue(RipperUI.DefaultRagePosY)] + [Tooltip("The Y position of the Rage Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + public float RageMeterPosY { get; set; } - [Label("$Mods.CalamityMod.AdrenalineX")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0f, 3840f)] - [DefaultValue(RipperUI.DefaultAdrenPosX)] - [Tooltip("The X position of the Adrenaline Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] - public float AdrenalineMeterPosX { get; set; } + [Label("$Mods.CalamityMod.AdrenalineX")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0f, 3840f)] + [DefaultValue(RipperUI.DefaultAdrenPosX)] + [Tooltip("The X position of the Adrenaline Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + public float AdrenalineMeterPosX { get; set; } - [Label("$Mods.CalamityMod.AdrenalineY")] - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0f, 2160f)] - [DefaultValue(RipperUI.DefaultAdrenPosY)] - [Tooltip("The Y position of the Adrenaline Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] - public float AdrenalineMeterPosY { get; set; } + [Label("$Mods.CalamityMod.AdrenalineY")] + [BackgroundColor(192, 54, 64, 192)] + [SliderColor(224, 165, 56, 128)] + [Range(0f, 2160f)] + [DefaultValue(RipperUI.DefaultAdrenPosY)] + [Tooltip("The Y position of the Adrenaline Meter.\nThe meter can be dragged with the mouse if Lock Meter Positions is disabled.")] + public float AdrenalineMeterPosY { get; set; } - [Header("Boss Rush Curses")] + [Header("Boss Rush Curses")] - [Label("$Mods.CalamityMod.BRCurseAccessory")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(false)] - [Tooltip("Limits the player to five accessories during the Boss Rush.")] - public bool BossRushAccessoryCurse { get; set; } + [Label("$Mods.CalamityMod.BRCurseAccessory")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + [Tooltip("Limits the player to five accessories during the Boss Rush.")] + public bool BossRushAccessoryCurse { get; set; } - [Label("$Mods.CalamityMod.BRCurseHealth")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(false)] - [Tooltip("Disables all health regeneration during the Boss Rush.")] - public bool BossRushHealthCurse { get; set; } + [Label("$Mods.CalamityMod.BRCurseHealth")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + [Tooltip("Disables all health regeneration during the Boss Rush.")] + public bool BossRushHealthCurse { get; set; } - [Label("$Mods.CalamityMod.BRCurseDash")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(false)] - [Tooltip("Disables all dashes during the Boss Rush.")] - public bool BossRushDashCurse { get; set; } + [Label("$Mods.CalamityMod.BRCurseDash")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + [Tooltip("Disables all dashes during the Boss Rush.")] + public bool BossRushDashCurse { get; set; } - [Label("$Mods.CalamityMod.BRCurseImmunity")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(false)] - [Tooltip("During the Boss Rush, being hit twice within three seconds will cause instant death.\nThis effect ignores revives.")] - public bool BossRushImmunityFrameCurse { get; set; } + [Label("$Mods.CalamityMod.BRCurseImmunity")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + [Tooltip("During the Boss Rush, being hit twice within three seconds will cause instant death.\nThis effect ignores revives.")] + public bool BossRushImmunityFrameCurse { get; set; } - public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref string message) => true; + public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref string message) => true; - public static void LoadConfigLabels(Mod instance) - { - string[][] _configLabels = new[] - { - new [] { "Afterimages", ItemID.SteampunkGoggles.ToString(), "Afterimages" }, - new [] { "MaxParticles", ItemID.FragmentStardust.ToString(), "Maximum particles" }, - new [] { "ScreenshakeOff", instance.ItemType("WavePounder").ToString(), "Disable Screenshakes" }, - new [] { "StealthInvisibility", instance.ItemType("StealthHairDye").ToString(), "Stealth Invisibility" }, - new [] { "ShopAlert", ItemID.GoldChest.ToString(), "New Shop Inventory Alert" }, - - new [] { "BossHealthBar", instance.ItemType("BloodOrange").ToString(), "Boss Health Bars" }, - new [] { "BossHealthBarExtra", instance.ItemType("EncryptedSchematicPlanetoid").ToString(), "Boss Health Bar Extra Info" }, - new [] { "DebuffDisplay", ItemID.FlaskofIchor.ToString(), "Boss and Miniboss Debuff Display" }, - new [] { "CooldownDisplay", instance.ItemType("NebulousCore").ToString(), "Cooldown Display" }, - new [] { "VanillaCooldownDisplay", ItemID.HealingPotion.ToString(), "Vanilla Cooldowns Display" }, - new [] { "MeterLock", ItemID.GemLockTopaz.ToString(), "Lock Meter Positions" }, - - new [] { "StealthMeter", instance.ItemType("EclipseMirror").ToString(), "Stealth Meter" }, - new [] { "StealthMeterX", ItemID.LaserRuler.ToString(), "Stealth Meter X Position" }, - new [] { "StealthMeterY", ItemID.LaserRuler.ToString(), "Stealth Meter Y Position" }, - - new [] { "ChargeMeter", instance.ItemType("PowerCell").ToString(), "Charge Meter" }, - new [] { "ChargeMeterX", ItemID.LaserRuler.ToString(), "Charge Meter X Position" }, - new [] { "ChargeMeterY", ItemID.LaserRuler.ToString(), "Charge Meter Y Position" }, - - new [] { "SpeedrunTimer", ItemID.Stopwatch.ToString(), "Speedrun Timer" }, - new [] { "SpeedrunTimerX", ItemID.LaserRuler.ToString(), "Speedrun Timer X Position" }, - new [] { "SpeedrunTimerY", ItemID.LaserRuler.ToString(), "Speedrun Timer Y Position" }, - - new [] { "EarlyHMRework", ItemID.Pwnhammer.ToString(), "Early Hardmode Progression Rework" }, - new [] { "Proficiency", instance.ItemType("MagicLevelMeter").ToString(), "Proficiency" }, - new [] { "BossZen", instance.ItemType("ZenPotion").ToString(), "Boss Zen" }, - new [] { "NPCNightSpawn", ItemID.ClothierVoodooDoll.ToString(), "Let Town NPCs spawn at night" }, - new [] { "NPCExtraSpawn", ItemID.GuideVoodooDoll.ToString(), "Town NPC Spawn Rate Multiplier" }, - new [] { "BossHPBoost", ItemID.LifeCrystal.ToString(), "Boss Health Percentage Boost" }, - - new [] { "ExpertDebuffReduction", ItemID.AnkhCharm.ToString(), "Reduce Expert Debuff Durations" }, - new [] { "ChillWaterRework", ItemID.ArcticDivingGear.ToString(), "Rework Chilled Water" }, - new [] { "ExpertSafeTowns", ItemID.Sunflower.ToString(), "Disable Expert Enemy Spawns in Towns" }, - new [] { "RipperBarShake", instance.ItemType("Revenge").ToString(), "Rage and Adrenaline Meter Shake" }, - new [] { "RageX", ItemID.LaserRuler.ToString(), "Rage Meter X Position" }, - new [] { "RageY", ItemID.LaserRuler.ToString(), "Rage Meter Y Position" }, - new [] { "AdrenalineX", ItemID.LaserRuler.ToString(), "Adrenaline Meter X Position" }, - new [] { "AdrenalineY", ItemID.LaserRuler.ToString(), "Adrenaline Meter Y Position" }, - - new [] { "BRCurseAccessory", ItemID.Shackle.ToString(), "Accessory Curse" }, - new [] { "BRCurseHealth", ItemID.Shackle.ToString(), "Health Curse" }, - new [] { "BRCurseDash", ItemID.Shackle.ToString(), "Dash Curse" }, - new [] { "BRCurseImmunity", ItemID.Shackle.ToString(), "Immunity Frame Curse" } - }; - - foreach (string[] label in _configLabels) + public static void LoadConfigLabels(Mod instance) + { + string[][] _configLabels = new[] { - ModTranslation text = instance.CreateTranslation(label[0]); - text.SetDefault($"[i:" + label[1] + "] "+ label[2]); - instance.AddTranslation(text); - } - } - } + new [] { "Afterimages", ItemID.SteampunkGoggles.ToString(), "Afterimages" }, + new [] { "MaxParticles", ItemID.FragmentStardust.ToString(), "Maximum particles" }, + new [] { "ScreenshakeOff", instance.ItemType("WavePounder").ToString(), "Disable Screenshakes" }, + new [] { "StealthInvisibility", instance.ItemType("StealthHairDye").ToString(), "Stealth Invisibility" }, + new [] { "ShopAlert", ItemID.GoldChest.ToString(), "New Shop Inventory Alert" }, + + new [] { "BossHealthBar", instance.ItemType("BloodOrange").ToString(), "Boss Health Bars" }, + new [] { "BossHealthBarExtra", instance.ItemType("EncryptedSchematicPlanetoid").ToString(), "Boss Health Bar Extra Info" }, + new [] { "DebuffDisplay", ItemID.FlaskofIchor.ToString(), "Boss and Miniboss Debuff Display" }, + new [] { "CooldownDisplay", instance.ItemType("NebulousCore").ToString(), "Cooldown Display" }, + new [] { "VanillaCooldownDisplay", ItemID.HealingPotion.ToString(), "Vanilla Cooldowns Display" }, + new [] { "MeterLock", ItemID.GemLockTopaz.ToString(), "Lock Meter Positions" }, + + new [] { "StealthMeter", instance.ItemType("EclipseMirror").ToString(), "Stealth Meter" }, + new [] { "StealthMeterX", ItemID.LaserRuler.ToString(), "Stealth Meter X Position" }, + new [] { "StealthMeterY", ItemID.LaserRuler.ToString(), "Stealth Meter Y Position" }, + + new [] { "ChargeMeter", instance.ItemType("PowerCell").ToString(), "Charge Meter" }, + new [] { "ChargeMeterX", ItemID.LaserRuler.ToString(), "Charge Meter X Position" }, + new [] { "ChargeMeterY", ItemID.LaserRuler.ToString(), "Charge Meter Y Position" }, + + new [] { "SpeedrunTimer", ItemID.Stopwatch.ToString(), "Speedrun Timer" }, + new [] { "SpeedrunTimerX", ItemID.LaserRuler.ToString(), "Speedrun Timer X Position" }, + new [] { "SpeedrunTimerY", ItemID.LaserRuler.ToString(), "Speedrun Timer Y Position" }, + + new [] { "EarlyHMRework", ItemID.Pwnhammer.ToString(), "Early Hardmode Progression Rework" }, + new [] { "Proficiency", instance.ItemType("MagicLevelMeter").ToString(), "Proficiency" }, + new [] { "BossZen", instance.ItemType("ZenPotion").ToString(), "Boss Zen" }, + new [] { "NPCNightSpawn", ItemID.ClothierVoodooDoll.ToString(), "Let Town NPCs spawn at night" }, + new [] { "NPCExtraSpawn", ItemID.GuideVoodooDoll.ToString(), "Town NPC Spawn Rate Multiplier" }, + new [] { "BossHPBoost", ItemID.LifeCrystal.ToString(), "Boss Health Percentage Boost" }, + + new [] { "ExpertDebuffReduction", ItemID.AnkhCharm.ToString(), "Reduce Expert Debuff Durations" }, + new [] { "ChillWaterRework", ItemID.ArcticDivingGear.ToString(), "Rework Chilled Water" }, + new [] { "ExpertSafeTowns", ItemID.Sunflower.ToString(), "Disable Expert Enemy Spawns in Towns" }, + new [] { "RipperBarShake", instance.ItemType("Revenge").ToString(), "Rage and Adrenaline Meter Shake" }, + new [] { "RageX", ItemID.LaserRuler.ToString(), "Rage Meter X Position" }, + new [] { "RageY", ItemID.LaserRuler.ToString(), "Rage Meter Y Position" }, + new [] { "AdrenalineX", ItemID.LaserRuler.ToString(), "Adrenaline Meter X Position" }, + new [] { "AdrenalineY", ItemID.LaserRuler.ToString(), "Adrenaline Meter Y Position" }, + + new [] { "BRCurseAccessory", ItemID.Shackle.ToString(), "Accessory Curse" }, + new [] { "BRCurseHealth", ItemID.Shackle.ToString(), "Health Curse" }, + new [] { "BRCurseDash", ItemID.Shackle.ToString(), "Dash Curse" }, + new [] { "BRCurseImmunity", ItemID.Shackle.ToString(), "Immunity Frame Curse" } + }; + + foreach (string[] label in _configLabels) + { + ModTranslation text = instance.CreateTranslation(label[0]); + text.SetDefault($"[i:" + label[1] + "] "+ label[2]); + instance.AddTranslation(text); + } + } + } } \ No newline at end of file diff --git a/CalamityLists.cs b/CalamityLists.cs index f03a9aa062..11e409e09d 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -75,7 +75,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { - public class CalamityLists + public class CalamityLists { public static IList donatorList; public static List projectileDestroyExceptionList; diff --git a/CalamityMod.cs b/CalamityMod.cs index f7e5507248..651049393d 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -74,7 +74,7 @@ using Terraria.UI; namespace CalamityMod { - public class CalamityMod : Mod + public class CalamityMod : Mod { // CONSIDER -- I have been advised by Jopo that Mods should never contain static variables // TODO -- 1.4 fixes the crit reforge price calculation bug, so GetWeaponCrit everywhere can go. diff --git a/Cooldowns/ChaosState.cs b/Cooldowns/ChaosState.cs index ba7573a6b2..52778ebc5b 100644 --- a/Cooldowns/ChaosState.cs +++ b/Cooldowns/ChaosState.cs @@ -3,50 +3,50 @@ using Terraria.Audio; namespace CalamityMod.Cooldowns { - public class ChaosState : CooldownHandler - { - public static new string ID => "ChaosState"; + public class ChaosState : CooldownHandler + { + public static new string ID => "ChaosState"; - public override bool ShouldDisplay => CalamityConfig.Instance.VanillaCooldownDisplay && instance.player.chaosState; - public override string DisplayName => "Teleportation Cooldown"; - public override string Texture => "CalamityMod/Cooldowns/ChaosState" + skinTexture; - public override Color OutlineColor => outlineColor; - public override Color CooldownStartColor => Color.Lerp(cooldownColorStart, cooldownColorEnd, 1 - instance.Completion); - public override Color CooldownEndColor => Color.Lerp(cooldownColorStart, cooldownColorEnd, 1 - instance.Completion); + public override bool ShouldDisplay => CalamityConfig.Instance.VanillaCooldownDisplay && instance.player.chaosState; + public override string DisplayName => "Teleportation Cooldown"; + public override string Texture => "CalamityMod/Cooldowns/ChaosState" + skinTexture; + public override Color OutlineColor => outlineColor; + public override Color CooldownStartColor => Color.Lerp(cooldownColorStart, cooldownColorEnd, 1 - instance.Completion); + public override Color CooldownEndColor => Color.Lerp(cooldownColorStart, cooldownColorEnd, 1 - instance.Completion); public override LegacySoundStyle EndSound => instance.player.Calamity().mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/Custom/AbilitySounds/ChaosStateOver"); - //It's the same cooldown with different skins each time, basically. - public string skinTexture; - public Color outlineColor; - public Color cooldownColorStart; - public Color cooldownColorEnd; + //It's the same cooldown with different skins each time, basically. + public string skinTexture; + public Color outlineColor; + public Color cooldownColorStart; + public Color cooldownColorEnd; - public ChaosState() : this("") { } - public ChaosState(string skin) - { - switch (skin) - { - case "spectralveil": - skinTexture = "Veil"; - outlineColor = new Color(138, 120, 222); - cooldownColorStart = new Color(46, 46, 134); - cooldownColorEnd = new Color(81, 90, 156); - break; + public ChaosState() : this("") { } + public ChaosState(string skin) + { + switch (skin) + { + case "spectralveil": + skinTexture = "Veil"; + outlineColor = new Color(138, 120, 222); + cooldownColorStart = new Color(46, 46, 134); + cooldownColorEnd = new Color(81, 90, 156); + break; - case "normalityrelocator": - skinTexture = "NR"; - outlineColor = new Color(129, 239, 246); - cooldownColorStart = new Color(134, 143, 151); - cooldownColorEnd = new Color(129, 239, 246); - break; + case "normalityrelocator": + skinTexture = "NR"; + outlineColor = new Color(129, 239, 246); + cooldownColorStart = new Color(134, 143, 151); + cooldownColorEnd = new Color(129, 239, 246); + break; - default: - skinTexture = ""; - outlineColor = new Color(246, 116, 181); - cooldownColorStart = new Color(223, 58, 140); - cooldownColorEnd = new Color(255, 179, 218); - break; - } - } - } + default: + skinTexture = ""; + outlineColor = new Color(246, 116, 181); + cooldownColorStart = new Color(223, 58, 140); + cooldownColorEnd = new Color(255, 179, 218); + break; + } + } + } } \ No newline at end of file diff --git a/Cooldowns/Cooldown.cs b/Cooldowns/Cooldown.cs index 3528e971bc..f5d43fca4d 100644 --- a/Cooldowns/Cooldown.cs +++ b/Cooldowns/Cooldown.cs @@ -1,35 +1,35 @@ namespace CalamityMod.Cooldowns { - // This base version of Cooldown is never directly used. It is necessary due to C# language constraints. - // All actual cooldowns are the below type, Cooldown. - public class Cooldown - { - // Do not ever change this value. It is set when a cooldown is registered. - internal readonly ushort netID; + // This base version of Cooldown is never directly used. It is necessary due to C# language constraints. + // All actual cooldowns are the below type, Cooldown. + public class Cooldown + { + // Do not ever change this value. It is set when a cooldown is registered. + internal readonly ushort netID; - /// - /// Unique string ID of the cooldown. You can set this to whatever you want.
- /// It is recommended that this ID be defined statically in your CooldownHandler implementation. - ///
- public readonly string ID = ""; + /// + /// Unique string ID of the cooldown. You can set this to whatever you want.
+ /// It is recommended that this ID be defined statically in your CooldownHandler implementation. + ///
+ public readonly string ID = ""; - internal Cooldown(string id, ushort nid) - { - ID = id; - netID = nid; - } - } - - // Cooldowns are nothing other than identifiers. They serve as a minimal identification interface that is netcode compatible. - // Everything else is handled by one of the following two types: - // - CooldownInstance (if a player has a cooldown, this is what they have) - // - CooldownHandler (every CooldownInstance has one: it handles the behavior of that cooldown instance) - // - // Individual "types" of cooldowns from a content sense are registered with a Handler. - // Every cooldown MUST define a Handler to be registered and functional. - // The differences between all the cooldowns are implemented as various subclasses of CooldownHandler. - public class Cooldown : Cooldown where T : CooldownHandler - { - internal Cooldown(string id, ushort nid) : base(id, nid) {} - } + internal Cooldown(string id, ushort nid) + { + ID = id; + netID = nid; + } + } + + // Cooldowns are nothing other than identifiers. They serve as a minimal identification interface that is netcode compatible. + // Everything else is handled by one of the following two types: + // - CooldownInstance (if a player has a cooldown, this is what they have) + // - CooldownHandler (every CooldownInstance has one: it handles the behavior of that cooldown instance) + // + // Individual "types" of cooldowns from a content sense are registered with a Handler. + // Every cooldown MUST define a Handler to be registered and functional. + // The differences between all the cooldowns are implemented as various subclasses of CooldownHandler. + public class Cooldown : Cooldown where T : CooldownHandler + { + internal Cooldown(string id, ushort nid) : base(id, nid) {} + } } diff --git a/Cooldowns/CooldownHandler.cs b/Cooldowns/CooldownHandler.cs index 879bb69b1c..6ec8208161 100644 --- a/Cooldowns/CooldownHandler.cs +++ b/Cooldowns/CooldownHandler.cs @@ -8,175 +8,175 @@ using Terraria.ModLoader; namespace CalamityMod.Cooldowns { - public class CooldownHandler - { - public static string ID => null; - public CooldownInstance instance; + public class CooldownHandler + { + public static string ID => null; + public CooldownInstance instance; - #region Gameplay Behavior - /// - /// This method runs once every frame while the cooldown instance is active. - /// - public virtual void Tick() { } + #region Gameplay Behavior + /// + /// This method runs once every frame while the cooldown instance is active. + /// + public virtual void Tick() { } - /// - /// This method runs when the cooldown instance ends naturally.
- /// It is not called if the cooldown instance is deleted because the player died. - ///
- public virtual void OnCompleted() { } + /// + /// This method runs when the cooldown instance ends naturally.
+ /// It is not called if the cooldown instance is deleted because the player died. + ///
+ public virtual void OnCompleted() { } - /// - /// Determines whether the cooldown instance can currently tick down.
- /// For example, this is useful for cooldowns that don't tick down if there are any bosses alive.
- /// You can also use it so that cooldowns which persist through death do not tick down while the player is dead. - ///
- public virtual bool CanTickDown => true; + /// + /// Determines whether the cooldown instance can currently tick down.
+ /// For example, this is useful for cooldowns that don't tick down if there are any bosses alive.
+ /// You can also use it so that cooldowns which persist through death do not tick down while the player is dead. + ///
+ public virtual bool CanTickDown => true; - /// - /// Set this to true to make this cooldown remain even when the player dies.
- /// All cooldowns with PersistsThroughDeath set to false disappear immediately when the player dies. - ///
- public virtual bool PersistsThroughDeath => false; + /// + /// Set this to true to make this cooldown remain even when the player dies.
+ /// All cooldowns with PersistsThroughDeath set to false disappear immediately when the player dies. + ///
+ public virtual bool PersistsThroughDeath => false; - /// - /// Set this to true to make this cooldown persist through saves and loads.
- /// All cooldowns with SavedWithPlayer set to true are serialized into the modded player file. - ///
- public virtual bool SavedWithPlayer => true; + /// + /// Set this to true to make this cooldown persist through saves and loads.
+ /// All cooldowns with SavedWithPlayer set to true are serialized into the modded player file. + ///
+ public virtual bool SavedWithPlayer => true; - /// - /// When the cooldown instance ends, this sound is played. Leave at null for no sound. - /// - public virtual LegacySoundStyle EndSound => null; - #endregion + /// + /// When the cooldown instance ends, this sound is played. Leave at null for no sound. + /// + public virtual LegacySoundStyle EndSound => null; + #endregion - #region Display & Rendering - /// - /// The name of the cooldown instance, appears when the player hovers over the indicator - /// - public virtual string DisplayName => ""; + #region Display & Rendering + /// + /// The name of the cooldown instance, appears when the player hovers over the indicator + /// + public virtual string DisplayName => ""; - /// - /// Whether or not this cooldown instance should appear in the cooldown rack UI. - /// - public virtual bool ShouldDisplay => true; + /// + /// Whether or not this cooldown instance should appear in the cooldown rack UI. + /// + public virtual bool ShouldDisplay => true; - /// - /// The texture of the cooldown indicator.
- /// These must be 20x20 pixels when at 2x2 scale. - ///
- public virtual string Texture => ""; - /// - /// This texture is overlaid atop the cooldown when the cooldown rack is rendering in compact mode. - /// - public virtual string OverlayTexture => $"{Texture}Overlay"; - /// - /// This outline texture is rendered around the base icon texture. - /// - public virtual string OutlineTexture => $"{Texture}Outline"; + /// + /// The texture of the cooldown indicator.
+ /// These must be 20x20 pixels when at 2x2 scale. + ///
+ public virtual string Texture => ""; + /// + /// This texture is overlaid atop the cooldown when the cooldown rack is rendering in compact mode. + /// + public virtual string OverlayTexture => $"{Texture}Overlay"; + /// + /// This outline texture is rendered around the base icon texture. + /// + public virtual string OutlineTexture => $"{Texture}Outline"; - internal static string DefaultChargeBarTexture = "CalamityMod/Cooldowns/BarBase"; - /// - /// The texture of this cooldown's "charge bar", or the circle rendered by shaders.
- /// By default, this is only used when the cooldown rack is rendering in expanded mode .
- /// Leave it as the default to have the charge bar be displayed as a shader-rendered circle.
- /// These must be 44x44 pixels when at 2x2 scale. - ///
- public virtual string ChargeBarTexture => DefaultChargeBarTexture; - /// - /// The background texture of this cooldown's "charge bar", or the circle rendered by shaders.
- /// By default, this is only used when the cooldown rack is rendering in expanded mode.
- /// Leave it as the default to have nothing render underneath the charge bar itself.
- /// These must be 44x44 pixels when at 2x2 scale. - ///
- public virtual string ChargeBarBackTexture => DefaultChargeBarTexture; + internal static string DefaultChargeBarTexture = "CalamityMod/Cooldowns/BarBase"; + /// + /// The texture of this cooldown's "charge bar", or the circle rendered by shaders.
+ /// By default, this is only used when the cooldown rack is rendering in expanded mode .
+ /// Leave it as the default to have the charge bar be displayed as a shader-rendered circle.
+ /// These must be 44x44 pixels when at 2x2 scale. + ///
+ public virtual string ChargeBarTexture => DefaultChargeBarTexture; + /// + /// The background texture of this cooldown's "charge bar", or the circle rendered by shaders.
+ /// By default, this is only used when the cooldown rack is rendering in expanded mode.
+ /// Leave it as the default to have nothing render underneath the charge bar itself.
+ /// These must be 44x44 pixels when at 2x2 scale. + ///
+ public virtual string ChargeBarBackTexture => DefaultChargeBarTexture; - /// - /// The color used for the icon outline when rendering in expanded mode.
- /// In compact mode, this color is used for the overlay that goes above the icon. - ///
- public virtual Color OutlineColor => Color.White; - /// - /// The color used for the start of the circular cooldown timer rendered by shaders.
- /// This color is only used when drawing in expanded mode and is ignored if a charge bar texture is provided. - ///
- public virtual Color CooldownStartColor => Color.Gray; - /// - /// The color used for the end of the circular cooldown timer rendered by shaders.
- /// This color is only used when drawing in expanded mode and is ignored if a charge bar texture is provided. - ///
- public virtual Color CooldownEndColor => Color.White; + /// + /// The color used for the icon outline when rendering in expanded mode.
+ /// In compact mode, this color is used for the overlay that goes above the icon. + ///
+ public virtual Color OutlineColor => Color.White; + /// + /// The color used for the start of the circular cooldown timer rendered by shaders.
+ /// This color is only used when drawing in expanded mode and is ignored if a charge bar texture is provided. + ///
+ public virtual Color CooldownStartColor => Color.Gray; + /// + /// The color used for the end of the circular cooldown timer rendered by shaders.
+ /// This color is only used when drawing in expanded mode and is ignored if a charge bar texture is provided. + ///
+ public virtual Color CooldownEndColor => Color.White; - /// - /// This method is called to render the cooldown when the cooldown rack is in expanded mode. - /// - public virtual void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) - { - Texture2D sprite = ModContent.GetTexture(Texture); - Texture2D outline = ModContent.GetTexture(OutlineTexture); - Texture2D barBase = ModContent.GetTexture(ChargeBarTexture); + /// + /// This method is called to render the cooldown when the cooldown rack is in expanded mode. + /// + public virtual void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + Texture2D sprite = ModContent.GetTexture(Texture); + Texture2D outline = ModContent.GetTexture(OutlineTexture); + Texture2D barBase = ModContent.GetTexture(ChargeBarTexture); - //Draw the ring - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); - ApplyBarShaders(opacity); + //Draw the ring + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); + ApplyBarShaders(opacity); - spriteBatch.Draw(barBase, position, null, Color.White * opacity, 0, barBase.Size() * 0.5f, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(barBase, position, null, Color.White * opacity, 0, barBase.Size() * 0.5f, scale, SpriteEffects.None, 0f); - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, Main.UIScaleMatrix); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, Main.UIScaleMatrix); - //Draw the outline - spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); + //Draw the outline + spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); - //Draw the icon - spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); - } + //Draw the icon + spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + } - /// - /// This method is called to render the cooldown when the cooldown rack is in compact mode. - /// - public virtual void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) - { - Texture2D sprite = ModContent.GetTexture(Texture); - Texture2D outline = ModContent.GetTexture(OutlineTexture); - Texture2D overlay = ModContent.GetTexture(OverlayTexture); - Color outlineColor = OutlineColor; + /// + /// This method is called to render the cooldown when the cooldown rack is in compact mode. + /// + public virtual void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + Texture2D sprite = ModContent.GetTexture(Texture); + Texture2D outline = ModContent.GetTexture(OutlineTexture); + Texture2D overlay = ModContent.GetTexture(OverlayTexture); + Color outlineColor = OutlineColor; - //Draw the outline - spriteBatch.Draw(outline, position, null, outlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); + //Draw the outline + spriteBatch.Draw(outline, position, null, outlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); - //Draw the icon - spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + //Draw the icon + spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); - //Draw the small overlay - int lostHeight = (int)Math.Ceiling(overlay.Height * (1 - instance.Completion)); - Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight); - spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, outlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); - } + //Draw the small overlay + int lostHeight = (int)Math.Ceiling(overlay.Height * (1 - instance.Completion)); + Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight); + spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, outlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + } - /// - /// Renders the circular cooldown timer with a radial shader.
- /// If the charge bar texture is defined, it is used. Otherwise it renders a flat ring which slides from the start color to the end color. - ///
- public virtual void ApplyBarShaders(float opacity) - { - if (ChargeBarTexture == DefaultChargeBarTexture) - { - GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity); - GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(1 - instance.Completion); - GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownStartColor); - GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownEndColor); - GameShaders.Misc["CalamityMod:CircularBarShader"].Apply(); - } - else - { - GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].SetShaderTexture(ModContent.GetTexture(ChargeBarBackTexture)); - GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].UseOpacity(opacity); - GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].UseSaturation(1 - instance.Completion); - GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].Apply(); - } - } - #endregion - } + /// + /// Renders the circular cooldown timer with a radial shader.
+ /// If the charge bar texture is defined, it is used. Otherwise it renders a flat ring which slides from the start color to the end color. + ///
+ public virtual void ApplyBarShaders(float opacity) + { + if (ChargeBarTexture == DefaultChargeBarTexture) + { + GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(1 - instance.Completion); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownStartColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownEndColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].Apply(); + } + else + { + GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].SetShaderTexture(ModContent.GetTexture(ChargeBarBackTexture)); + GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].UseOpacity(opacity); + GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].UseSaturation(1 - instance.Completion); + GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].Apply(); + } + } + #endregion + } } diff --git a/Cooldowns/CooldownInstance.cs b/Cooldowns/CooldownInstance.cs index 2368197e78..213f104be2 100644 --- a/Cooldowns/CooldownInstance.cs +++ b/Cooldowns/CooldownInstance.cs @@ -5,141 +5,141 @@ using Terraria.ModLoader.IO; namespace CalamityMod.Cooldowns { - public class CooldownInstance - { - private const string NetIDSaveKey = "netID"; - private const string DurationSaveKey = "duration"; - private const string TimeLeftSaveKey = "timeLeft"; + public class CooldownInstance + { + private const string NetIDSaveKey = "netID"; + private const string DurationSaveKey = "duration"; + private const string TimeLeftSaveKey = "timeLeft"; - public CooldownInstance(Player p, Cooldown cd, int dur) - { - netID = cd.netID; - player = p; - duration = dur; - timeLeft = dur; - handler = null; - AssignHandler(cd); - } + public CooldownInstance(Player p, Cooldown cd, int dur) + { + netID = cd.netID; + player = p; + duration = dur; + timeLeft = dur; + handler = null; + AssignHandler(cd); + } - public CooldownInstance(Player p, Cooldown cd, int dur, params object[] args) - { - netID = cd.netID; - player = p; - duration = dur; - timeLeft = dur; - handler = null; - AssignHandler(cd, args); - } + public CooldownInstance(Player p, Cooldown cd, int dur, params object[] args) + { + netID = cd.netID; + player = p; + duration = dur; + timeLeft = dur; + handler = null; + AssignHandler(cd, args); + } - internal CooldownInstance(Player p, string id, TagCompound tag) - { - netID = (ushort)tag.GetAsInt(NetIDSaveKey); - // Correct for netID mismatch if for some reason this occurs. - // The string ID of the cooldown overrides whatever the netID may have been saved as. - Cooldown cd = CooldownRegistry.Get(id); - ushort registeredNetID = cd.netID; - if (netID != registeredNetID) - { - // Log when this occurs, even though it should be harmless. - CalamityMod.Instance.Logger.Warn($"Cooldown \"{id}\" loaded from NBT with discrepant netID {netID}. This cooldown was registered with netID {registeredNetID}"); - netID = registeredNetID; - } - player = p; - duration = tag.GetAsInt(DurationSaveKey); - timeLeft = tag.GetAsInt(TimeLeftSaveKey); - AssignHandler(cd); - } + internal CooldownInstance(Player p, string id, TagCompound tag) + { + netID = (ushort)tag.GetAsInt(NetIDSaveKey); + // Correct for netID mismatch if for some reason this occurs. + // The string ID of the cooldown overrides whatever the netID may have been saved as. + Cooldown cd = CooldownRegistry.Get(id); + ushort registeredNetID = cd.netID; + if (netID != registeredNetID) + { + // Log when this occurs, even though it should be harmless. + CalamityMod.Instance.Logger.Warn($"Cooldown \"{id}\" loaded from NBT with discrepant netID {netID}. This cooldown was registered with netID {registeredNetID}"); + netID = registeredNetID; + } + player = p; + duration = tag.GetAsInt(DurationSaveKey); + timeLeft = tag.GetAsInt(TimeLeftSaveKey); + AssignHandler(cd); + } - /// - /// Creates a cooldown instance from serialized binary data, used in netcode. - /// - /// Reader of the binary stream. - internal CooldownInstance(BinaryReader reader) - { - netID = reader.ReadUInt16(); - byte playerIDByte = reader.ReadByte(); - player = Main.player[playerIDByte]; - duration = reader.ReadInt32(); - timeLeft = reader.ReadInt32(); + /// + /// Creates a cooldown instance from serialized binary data, used in netcode. + /// + /// Reader of the binary stream. + internal CooldownInstance(BinaryReader reader) + { + netID = reader.ReadUInt16(); + byte playerIDByte = reader.ReadByte(); + player = Main.player[playerIDByte]; + duration = reader.ReadInt32(); + timeLeft = reader.ReadInt32(); - string id = CooldownRegistry.registry[netID].ID; - AssignHandler(CooldownRegistry.Get(id)); - } + string id = CooldownRegistry.registry[netID].ID; + AssignHandler(CooldownRegistry.Get(id)); + } - // These two functions make the blind reflection assumption that every Cooldown passed to them will actually be - // Cooldown - // (which they all will be, of course, because nobody instantiates Cooldown) + // These two functions make the blind reflection assumption that every Cooldown passed to them will actually be + // Cooldown + // (which they all will be, of course, because nobody instantiates Cooldown) - internal void AssignHandler(Cooldown cd) - { - Type handlerT = cd.GetType().GenericTypeArguments[0]; - handler = Activator.CreateInstance(handlerT) as CooldownHandler; - handler.instance = this; - } + internal void AssignHandler(Cooldown cd) + { + Type handlerT = cd.GetType().GenericTypeArguments[0]; + handler = Activator.CreateInstance(handlerT) as CooldownHandler; + handler.instance = this; + } - internal void AssignHandler(Cooldown cd, params object[] args) - { - Type handlerT = cd.GetType().GenericTypeArguments[0]; - handler = Activator.CreateInstance(handlerT, args) as CooldownHandler; - handler.instance = this; - } + internal void AssignHandler(Cooldown cd, params object[] args) + { + Type handlerT = cd.GetType().GenericTypeArguments[0]; + handler = Activator.CreateInstance(handlerT, args) as CooldownHandler; + handler.instance = this; + } - /// - /// The netID of the cooldown represented by this cooldown instance.
- /// This is used to look up gameplay behavior and rendering behavior as the cooldown instance is used in the game engine. - ///
- internal ushort netID; - - /// - /// The player that the cooldown is applying to - /// - public Player player; + /// + /// The netID of the cooldown represented by this cooldown instance.
+ /// This is used to look up gameplay behavior and rendering behavior as the cooldown instance is used in the game engine. + ///
+ internal ushort netID; + + /// + /// The player that the cooldown is applying to + /// + public Player player; - /// - /// The total, original duration of the cooldown. This value is in frames, 60 per second. - /// - public int duration; + /// + /// The total, original duration of the cooldown. This value is in frames, 60 per second. + /// + public int duration; - /// - /// The remaining duration of the cooldown. This value is in frames, 60 per second. - /// - public int timeLeft; + /// + /// The remaining duration of the cooldown. This value is in frames, 60 per second. + /// + public int timeLeft; - /// - /// A ratio of how "completed" an instance of a cooldown is. - /// - public float Completion => duration != 0 ? timeLeft / (float)duration : 0; + /// + /// A ratio of how "completed" an instance of a cooldown is. + /// + public float Completion => duration != 0 ? timeLeft / (float)duration : 0; - /// - /// The handler which implements the behavior of this cooldown instance. - /// - public CooldownHandler handler; + /// + /// The handler which implements the behavior of this cooldown instance. + /// + public CooldownHandler handler; - /// - /// Serializes this cooldown instance into a TagCompound for saving with the world. - /// - /// An NBT TagCompound which contains the essential variables of this cooldown instance. - internal TagCompound Save() - { - return new TagCompound - { - { NetIDSaveKey, (int)netID }, - { DurationSaveKey, duration }, - { TimeLeftSaveKey, timeLeft } - }; - } + /// + /// Serializes this cooldown instance into a TagCompound for saving with the world. + /// + /// An NBT TagCompound which contains the essential variables of this cooldown instance. + internal TagCompound Save() + { + return new TagCompound + { + { NetIDSaveKey, (int)netID }, + { DurationSaveKey, duration }, + { TimeLeftSaveKey, timeLeft } + }; + } - /// - /// Serializes this cooldown instance into binary data for netcode. - /// - /// Writer for an unspecified binary stream. - internal void Write(BinaryWriter writer) - { - writer.Write(netID); - byte playerIDByte = (byte)player.whoAmI; - writer.Write(playerIDByte); - writer.Write(duration); - writer.Write(timeLeft); - } - } + /// + /// Serializes this cooldown instance into binary data for netcode. + /// + /// Writer for an unspecified binary stream. + internal void Write(BinaryWriter writer) + { + writer.Write(netID); + byte playerIDByte = (byte)player.whoAmI; + writer.Write(playerIDByte); + writer.Write(duration); + writer.Write(timeLeft); + } + } } diff --git a/Cooldowns/CooldownRegistry.cs b/Cooldowns/CooldownRegistry.cs index 438ae38cbd..42ad47e6b4 100644 --- a/Cooldowns/CooldownRegistry.cs +++ b/Cooldowns/CooldownRegistry.cs @@ -5,127 +5,127 @@ using Terraria.ModLoader; namespace CalamityMod.Cooldowns { - public class CooldownRegistry - { - // Indexed by ushort netID. Contains every registered cooldown. - // Cooldowns are given netIDs when they are registered. - // Cooldowns are useless until they are registered. - public static Cooldown[] registry; - private const ushort defaultSize = 256; - private static ushort nextCDNetID = 0; + public class CooldownRegistry + { + // Indexed by ushort netID. Contains every registered cooldown. + // Cooldowns are given netIDs when they are registered. + // Cooldowns are useless until they are registered. + public static Cooldown[] registry; + private const ushort defaultSize = 256; + private static ushort nextCDNetID = 0; - private static Dictionary nameToNetID = null; + private static Dictionary nameToNetID = null; - public static void Load() - { - registry = new Cooldown[defaultSize]; - nameToNetID = new Dictionary(defaultSize); - - // TODO -- CooldownHandlers should be ILoadable in 1.4 - RegisterModCooldowns(CalamityMod.Instance); - - #region Unused manual registration left here as backup - // Vanilla cooldowns represented by the interface - //var potionSickness = Register(PotionSickness.ID); - //var chaosState = Register(ChaosState.ID); - //var globalDodge = Register(GlobalDodge.ID); - - // Calamity cooldowns - //var aquaticHeartIceShield = Register(AquaticHeartIceShield.ID); - //var bloodflareFrenzy = Register(BloodflareFrenzy.ID); - //var bloodflareRanged = Register(BloodflareRangedSet.ID); - //var brimflameFrenzy = Register(BrimflameFrenzy.ID); - //var counterScarf = Register(CounterScarf.ID); - //var divineBless = Register(DivineBless.ID); - //var divingPlatesBreaking = Register(DivingPlatesBreaking.ID); - //var divingPlatesBroken = Register(DivingPlatesBroken.ID); - //var draconicElixir = Register(DraconicElixir.ID); - //var evasionScarf = Register(EvasionScarf.ID); - //var fleshTotem = Register(FleshTotem.ID); - //var godSlayerDash = Register(GodSlayerDash.ID); - //var inkBomb = Register(InkBomb.ID); - //var lionHeartShield = Register(LionHeartShield.ID); - //var nebulousCore = Register(NebulousCore.ID); - //var omegaBlue = Register(OmegaBlue.ID); - //var permafrostConcoction = Register(PermafrostConcoction.ID); - //var plagueBlackout = Register(PlagueBlackout.ID); - //var prismaticLaser = Register(PrismaticLaser.ID); - //var profanedSoulArtifact = Register(ProfanedSoulArtifact.ID); - //var relicOfResilience = Register(RelicOfResilience.ID); - //var rogueBooster = Register(RogueBooster.ID); - //var sandCloak = Register(SandCloak.ID); - //var silvaRevive = Register(SilvaRevive.ID); - //var tarragonCloak = Register(TarragonCloak.ID); - //var tarragonImmunity = Register(TarragonImmunity.ID); - //var universeSplitter = Register(UniverseSplitter.ID); - #endregion - } - - public static void RegisterModCooldowns(Mod mod) + public static void Load() { - Type baseHandlerType = typeof(CooldownHandler); - foreach (Type type in mod.Code.GetTypes()) - { - if (type.IsSubclassOf(baseHandlerType) && !type.IsAbstract && type != baseHandlerType) - { - //Get the static property ID of the handler - string handlerID = (string)type.GetProperty("ID").GetValue(null); + registry = new Cooldown[defaultSize]; + nameToNetID = new Dictionary(defaultSize); - //If for whatever reason the ID is not set, create an ID from the mod and handler name - if (handlerID == null) - handlerID = mod.Name + "_" + type.Name; + // TODO -- CooldownHandlers should be ILoadable in 1.4 + RegisterModCooldowns(CalamityMod.Instance); - //Use reflection to call the method. You can't use the type as the generic type argument of register here - MethodInfo methodInfo = typeof(CooldownRegistry).GetMethod("Register", BindingFlags.Public | BindingFlags.Static); - Type[] genericArguments = new Type[] { type }; + #region Unused manual registration left here as backup + // Vanilla cooldowns represented by the interface + //var potionSickness = Register(PotionSickness.ID); + //var chaosState = Register(ChaosState.ID); + //var globalDodge = Register(GlobalDodge.ID); - MethodInfo genericRegister = methodInfo.MakeGenericMethod(genericArguments); - genericRegister.Invoke(null, new object[] { handlerID }); - } - } - } + // Calamity cooldowns + //var aquaticHeartIceShield = Register(AquaticHeartIceShield.ID); + //var bloodflareFrenzy = Register(BloodflareFrenzy.ID); + //var bloodflareRanged = Register(BloodflareRangedSet.ID); + //var brimflameFrenzy = Register(BrimflameFrenzy.ID); + //var counterScarf = Register(CounterScarf.ID); + //var divineBless = Register(DivineBless.ID); + //var divingPlatesBreaking = Register(DivingPlatesBreaking.ID); + //var divingPlatesBroken = Register(DivingPlatesBroken.ID); + //var draconicElixir = Register(DraconicElixir.ID); + //var evasionScarf = Register(EvasionScarf.ID); + //var fleshTotem = Register(FleshTotem.ID); + //var godSlayerDash = Register(GodSlayerDash.ID); + //var inkBomb = Register(InkBomb.ID); + //var lionHeartShield = Register(LionHeartShield.ID); + //var nebulousCore = Register(NebulousCore.ID); + //var omegaBlue = Register(OmegaBlue.ID); + //var permafrostConcoction = Register(PermafrostConcoction.ID); + //var plagueBlackout = Register(PlagueBlackout.ID); + //var prismaticLaser = Register(PrismaticLaser.ID); + //var profanedSoulArtifact = Register(ProfanedSoulArtifact.ID); + //var relicOfResilience = Register(RelicOfResilience.ID); + //var rogueBooster = Register(RogueBooster.ID); + //var sandCloak = Register(SandCloak.ID); + //var silvaRevive = Register(SilvaRevive.ID); + //var tarragonCloak = Register(TarragonCloak.ID); + //var tarragonImmunity = Register(TarragonImmunity.ID); + //var universeSplitter = Register(UniverseSplitter.ID); + #endregion + } - public static void Unload() - { - registry = null; - nameToNetID?.Clear(); - nameToNetID = null; - } + public static void RegisterModCooldowns(Mod mod) + { + Type baseHandlerType = typeof(CooldownHandler); + foreach (Type type in mod.Code.GetTypes()) + { + if (type.IsSubclassOf(baseHandlerType) && !type.IsAbstract && type != baseHandlerType) + { + //Get the static property ID of the handler + string handlerID = (string)type.GetProperty("ID").GetValue(null); - public static Cooldown Get(string id) - { - bool hasValue = nameToNetID.TryGetValue(id, out ushort netID); - return hasValue ? registry[netID] : null; - } + //If for whatever reason the ID is not set, create an ID from the mod and handler name + if (handlerID == null) + handlerID = mod.Name + "_" + type.Name; - /// - /// Registers a CooldownHandler for use in netcode, assigning it a Cooldown and thus a netID. Cooldowns are useless until this has been done. - /// - /// The registered Cooldown. - public static Cooldown Register(string id) where HandlerT : CooldownHandler - { - int currentMaxID = registry.Length; + //Use reflection to call the method. You can't use the type as the generic type argument of register here + MethodInfo methodInfo = typeof(CooldownRegistry).GetMethod("Register", BindingFlags.Public | BindingFlags.Static); + Type[] genericArguments = new Type[] { type }; - // This case only happens when you cap out at 65,536 cooldown registrations (which should never occur). - // It just stops you from registering more cooldowns. - if (nextCDNetID == currentMaxID) - return null; + MethodInfo genericRegister = methodInfo.MakeGenericMethod(genericArguments); + genericRegister.Invoke(null, new object[] { handlerID }); + } + } + } - Cooldown cd = new Cooldown(id, nextCDNetID); - nameToNetID[cd.ID] = cd.netID; - registry[cd.netID] = cd; - ++nextCDNetID; + public static void Unload() + { + registry = null; + nameToNetID?.Clear(); + nameToNetID = null; + } - // If the end of the array is reached, double its size. - if (nextCDNetID == currentMaxID && currentMaxID < ushort.MaxValue) - { - Cooldown[] largerArray = new Cooldown[currentMaxID * 2]; - for (int i = 0; i < currentMaxID; ++i) - largerArray[i] = registry[i]; + public static Cooldown Get(string id) + { + bool hasValue = nameToNetID.TryGetValue(id, out ushort netID); + return hasValue ? registry[netID] : null; + } - registry = largerArray; - } - return cd; - } - } + /// + /// Registers a CooldownHandler for use in netcode, assigning it a Cooldown and thus a netID. Cooldowns are useless until this has been done. + /// + /// The registered Cooldown. + public static Cooldown Register(string id) where HandlerT : CooldownHandler + { + int currentMaxID = registry.Length; + + // This case only happens when you cap out at 65,536 cooldown registrations (which should never occur). + // It just stops you from registering more cooldowns. + if (nextCDNetID == currentMaxID) + return null; + + Cooldown cd = new Cooldown(id, nextCDNetID); + nameToNetID[cd.ID] = cd.netID; + registry[cd.netID] = cd; + ++nextCDNetID; + + // If the end of the array is reached, double its size. + if (nextCDNetID == currentMaxID && currentMaxID < ushort.MaxValue) + { + Cooldown[] largerArray = new Cooldown[currentMaxID * 2]; + for (int i = 0; i < currentMaxID; ++i) + largerArray[i] = registry[i]; + + registry = largerArray; + } + return cd; + } + } } diff --git a/Cooldowns/NebulousCore.cs b/Cooldowns/NebulousCore.cs index 1316ea4df6..be4be151ab 100644 --- a/Cooldowns/NebulousCore.cs +++ b/Cooldowns/NebulousCore.cs @@ -2,7 +2,7 @@ namespace CalamityMod.Cooldowns { - public class NebulousCore : CooldownHandler + public class NebulousCore : CooldownHandler { public static new string ID => "NebulousCore"; public override bool ShouldDisplay => true; diff --git a/Cooldowns/PermafrostConcoction.cs b/Cooldowns/PermafrostConcoction.cs index 911bbc0d57..e96c337e97 100644 --- a/Cooldowns/PermafrostConcoction.cs +++ b/Cooldowns/PermafrostConcoction.cs @@ -2,7 +2,7 @@ namespace CalamityMod.Cooldowns { - public class PermafrostConcoction : CooldownHandler + public class PermafrostConcoction : CooldownHandler { public static new string ID => "PermafrostConcoction"; public override bool ShouldDisplay => true; diff --git a/Cooldowns/RelicOfResilience.cs b/Cooldowns/RelicOfResilience.cs index d562a7b7f8..dbcd412105 100644 --- a/Cooldowns/RelicOfResilience.cs +++ b/Cooldowns/RelicOfResilience.cs @@ -2,7 +2,7 @@ namespace CalamityMod.Cooldowns { - public class RelicOfResilience : CooldownHandler + public class RelicOfResilience : CooldownHandler { public static new string ID => "RelicOfResilience"; public override bool ShouldDisplay => true; diff --git a/CustomRecipes/ArsenalTierGatedRecipe.cs b/CustomRecipes/ArsenalTierGatedRecipe.cs index daae8f3b9a..56f5c42233 100644 --- a/CustomRecipes/ArsenalTierGatedRecipe.cs +++ b/CustomRecipes/ArsenalTierGatedRecipe.cs @@ -8,7 +8,7 @@ namespace CalamityMod.CustomRecipes public int Tier; public bool AllowedInOldWorlds; public ArsenalTierGatedRecipe(Mod mod, int tier, bool allowedInOldWorlds = false) : base(mod) - { + { Tier = tier; AllowedInOldWorlds = allowedInOldWorlds; } diff --git a/DataStructures/Attunement.cs b/DataStructures/Attunement.cs index c477ff3e40..d094db976e 100644 --- a/DataStructures/Attunement.cs +++ b/DataStructures/Attunement.cs @@ -7,7 +7,7 @@ using CalamityMod.Items.Weapons.Melee; namespace CalamityMod.DataStructures { - public enum AttunementID : byte + public enum AttunementID : byte { Default, Hot, Cold, Tropical, Evil, //Broken biome blade TrueDefault, TrueHot, TrueCold, TrueTropical, TrueEvil, Holy, Astral, Marine, //Biome blade diff --git a/DataStructures/DeadMinionProperties.cs b/DataStructures/DeadMinionProperties.cs index 0db7acabbd..c6758a11f5 100644 --- a/DataStructures/DeadMinionProperties.cs +++ b/DataStructures/DeadMinionProperties.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.DataStructures { - public class DeadMinionProperties + public class DeadMinionProperties { public int Type; public int OriginalDamage; diff --git a/Dusts/CeaselessDust.cs b/Dusts/CeaselessDust.cs index c569eee0f8..8c6c28a062 100644 --- a/Dusts/CeaselessDust.cs +++ b/Dusts/CeaselessDust.cs @@ -11,25 +11,25 @@ namespace CalamityMod.Dusts dust.noGravity = true; } - public override bool Update(Dust dust) - { - float scale = dust.scale; - Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), scale * 0.4f, scale * 0.1f, scale); + public override bool Update(Dust dust) + { + float scale = dust.scale; + Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), scale * 0.4f, scale * 0.1f, scale); - dust.position += dust.velocity; - dust.velocity *= 0.95f; - dust.scale -= 0.05f; + dust.position += dust.velocity; + dust.velocity *= 0.95f; + dust.scale -= 0.05f; - if (dust.scale <= 0.05f) - dust.active = false; + if (dust.scale <= 0.05f) + dust.active = false; - return false; - } + return false; + } - public override Color? GetAlpha(Dust dust, Color lightColor) - { - int newColor = (int)(250f * dust.scale); - return new Color(newColor, newColor, newColor, 0); - } - } + public override Color? GetAlpha(Dust dust, Color lightColor) + { + int newColor = (int)(250f * dust.scale); + return new Color(newColor, newColor, newColor, 0); + } + } } diff --git a/Dusts/FinalFlame.cs b/Dusts/FinalFlame.cs index efeceeea56..7616ac40c8 100644 --- a/Dusts/FinalFlame.cs +++ b/Dusts/FinalFlame.cs @@ -12,18 +12,18 @@ namespace CalamityMod.Dusts dust.velocity *= 0.5f; dust.noGravity = true; dust.noLight = true; - dust.alpha = 50; + dust.alpha = 50; } public override bool Update(Dust dust) { dust.position += dust.velocity; dust.scale *= 0.94f; - dust.velocity *= 0.90f; + dust.velocity *= 0.90f; Lighting.AddLight(dust.position, 0.255f, 0.185f, 0.094f); if (dust.scale < 0.4f) { - dust.active = false; + dust.active = false; } return false; } diff --git a/Dusts/RosePiece.cs b/Dusts/RosePiece.cs index d612058d41..701f12d271 100644 --- a/Dusts/RosePiece.cs +++ b/Dusts/RosePiece.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Dusts { - public class RosePiece : ModDust + public class RosePiece : ModDust { public override void OnSpawn(Dust dust) { diff --git a/Effects/BasicTint.fx b/Effects/BasicTint.fx index 895532ce3b..003bcfc900 100644 --- a/Effects/BasicTint.fx +++ b/Effects/BasicTint.fx @@ -17,12 +17,12 @@ float2 uImageSize1; float4 Recolor(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 { - + float4 color = tex2D(uImage0, coords); float originalAlpha = color.a; color.rbg = lerp(color.rbg, uColor, uOpacity); return color * originalAlpha; - + } technique Technique1 diff --git a/Enums/ClassType.cs b/Enums/ClassType.cs index a2d67b6a38..f7c2bc2d61 100644 --- a/Enums/ClassType.cs +++ b/Enums/ClassType.cs @@ -1,11 +1,11 @@ namespace CalamityMod { - public enum ClassType - { - Melee = 0, - Ranged = 1, - Magic = 2, - Summon = 3, - Rogue = 4 - } + public enum ClassType + { + Melee = 0, + Ranged = 1, + Magic = 2, + Summon = 3, + Rogue = 4 + } } \ No newline at end of file diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 71b3bce53e..be29873dcb 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -38,7 +38,7 @@ using Terraria.ModLoader; namespace CalamityMod.Events { - public class BossRushEvent + public class BossRushEvent { public enum TimeChangeContext { @@ -336,11 +336,11 @@ namespace CalamityMod.Events BossIDsAfterDeath = null; BossDeathEffects = null; } - #endregion + #endregion - #region Properties + #region Properties public static int CurrentTier - { + { get { if (BossRushStage > Bosses.FindIndex(boss => boss.EntityID == NPCID.CultistBoss)) @@ -349,7 +349,7 @@ namespace CalamityMod.Events return 2; return 1; } - } + } public static int MusicToPlay { @@ -374,10 +374,10 @@ namespace CalamityMod.Events return 0; } } - #endregion Properties + #endregion Properties - #region Updates - internal static void MiscUpdateEffects() + #region Updates + internal static void MiscUpdateEffects() { if (!BossRushActive) return; @@ -460,7 +460,7 @@ namespace CalamityMod.Events // Change dimness. if (BossRushStage >= 0 && BossRushStage < Bosses.Count) - { + { WhiteDimness = MathHelper.Lerp(WhiteDimness, Bosses[BossRushStage].DimnessFactor, 0.1f); if (MathHelper.Distance(WhiteDimness, Bosses[BossRushStage].DimnessFactor) < 0.004f) WhiteDimness = Bosses[BossRushStage].DimnessFactor; @@ -485,7 +485,7 @@ namespace CalamityMod.Events } internal static void EndEffects() - { + { for (int doom = 0; doom < Main.maxNPCs; doom++) { NPC n = Main.npc[doom]; diff --git a/Events/BossRushScreenShader.cs b/Events/BossRushScreenShader.cs index 81dd38ac1d..59cdcda7be 100644 --- a/Events/BossRushScreenShader.cs +++ b/Events/BossRushScreenShader.cs @@ -14,9 +14,9 @@ namespace CalamityMod.Events base.Apply(); } - public override void Update(GameTime gameTime) - { + public override void Update(GameTime gameTime) + { UseColor(Color.Lerp(BossRushSky.GeneralColor, Color.Black, BossRushEvent.WhiteDimness)); } - } + } } diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index b057294cde..5e400d45bc 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -641,16 +641,16 @@ namespace CalamityMod.ILEditing /// Change the following code sequence in Wiring.HitWireSingle /// num8 = (int) Utils.SelectRandom(Main.rand, new short[2] /// { - /// 355, - /// 358 + /// 355, + /// 358 /// }); /// /// to /// /// var arr = new short[2] /// { - /// 355, - /// 358 + /// 355, + /// 358 /// }); /// arr = arr.ToList().Add(id).ToArray(); /// num8 = Utils.SelectRandom(Main.rand, arr); diff --git a/ILEditing/VanillaBugfixingILChanges.cs b/ILEditing/VanillaBugfixingILChanges.cs index be01253f8b..483327f35b 100644 --- a/ILEditing/VanillaBugfixingILChanges.cs +++ b/ILEditing/VanillaBugfixingILChanges.cs @@ -140,7 +140,7 @@ namespace CalamityMod.ILEditing #region Fix Projectile Update Priority Problems - // This IL edit is commented out because it seems to be causing issues, sometimes creating errors preventing Terraria from updating + // This IL edit is commented out because it seems to be causing issues, sometimes creating errors preventing Terraria from updating // CONTEXT FOR FIX: The way projectile updating works is via looping, starting from 0 and ending at 999. For most cases this works sufficiently. // However, in contexts where two projectile's update logic are dependent on each-other in some way (such as mechworm segment movement) it is possible // that one projectile will update unexpectedly before the other, creating gaps. By making the update logic ordered based on a priority system, this can be diff --git a/Items/Accessories/AbyssalAmulet.cs b/Items/Accessories/AbyssalAmulet.cs index 90c3a62cff..bde7e75d05 100644 --- a/Items/Accessories/AbyssalAmulet.cs +++ b/Items/Accessories/AbyssalAmulet.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Abyssal Amulet"); Tooltip.SetDefault("Attacks inflict the Crush Depth debuff\n" + - "Grants immunity to the Crush Depth debuff\n" + + "Grants immunity to the Crush Depth debuff\n" + "While in the abyss you gain 10% increased max life"); } @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.abyssalAmulet = true; - player.buffImmune[ModContent.BuffType()] = true; - } + player.buffImmune[ModContent.BuffType()] = true; + } } } diff --git a/Items/Accessories/AbyssalDivingGear.cs b/Items/Accessories/AbyssalDivingGear.cs index 31c89921ec..aa67f4edd9 100644 --- a/Items/Accessories/AbyssalDivingGear.cs +++ b/Items/Accessories/AbyssalDivingGear.cs @@ -6,70 +6,70 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - //[AutoloadEquip(EquipType.Face)] - public class AbyssalDivingGear : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Abyssal Diving Gear"); - Tooltip.SetDefault("Reduces the damage caused by the pressure of the abyss while out of breath\n" + - "Removes the bleed effect caused by the abyss\n" + - "Grants the ability to swim and greatly extends underwater breathing\n" + - "Provides light underwater and extra mobility on ice\n" + - "Provides a moderate amount of light in the abyss\n" + - "Greatly reduces breath loss in the abyss"); - } + //[AutoloadEquip(EquipType.Face)] + public class AbyssalDivingGear : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Abyssal Diving Gear"); + Tooltip.SetDefault("Reduces the damage caused by the pressure of the abyss while out of breath\n" + + "Removes the bleed effect caused by the abyss\n" + + "Grants the ability to swim and greatly extends underwater breathing\n" + + "Provides light underwater and extra mobility on ice\n" + + "Provides a moderate amount of light in the abyss\n" + + "Greatly reduces breath loss in the abyss"); + } - public override void SetDefaults() - { - item.width = 26; - item.height = 26; - item.value = CalamityGlobalItem.Rarity7BuyPrice; - item.rare = ItemRarityID.Lime; - item.accessory = true; - } + public override void SetDefaults() + { + item.width = 26; + item.height = 26; + item.value = CalamityGlobalItem.Rarity7BuyPrice; + item.rare = ItemRarityID.Lime; + item.accessory = true; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.depthCharm = true; - modPlayer.jellyfishNecklace = true; - if (!hideVisual) - modPlayer.abyssDivingGear = true; //this bool is just used for drawing - player.arcticDivingGear = true; - player.accFlipper = true; - player.accDivingHelm = true; - player.iceSkate = true; - if (player.wet) - { - Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, 0.2f, 0.8f, 0.9f); - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.depthCharm = true; + modPlayer.jellyfishNecklace = true; + if (!hideVisual) + modPlayer.abyssDivingGear = true; //this bool is just used for drawing + player.arcticDivingGear = true; + player.accFlipper = true; + player.accDivingHelm = true; + player.iceSkate = true; + if (player.wet) + { + Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, 0.2f, 0.8f, 0.9f); + } + } - public override void UpdateVanity(Player player, EquipType type) - { - player.Calamity().abyssDivingGear = true; //this bool is just used for drawing - } + public override void UpdateVanity(Player player, EquipType type) + { + player.Calamity().abyssDivingGear = true; //this bool is just used for drawing + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.ArcticDivingGear); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.ArcticDivingGear); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } - public class AbyssDivingGearHair : EquipTexture - { - public override void DrawHair(ref bool drawHair, ref bool drawAltHair) - { - drawHair = false; - drawAltHair = false; - } - } + public class AbyssDivingGearHair : EquipTexture + { + public override void DrawHair(ref bool drawHair, ref bool drawAltHair) + { + drawHair = false; + drawAltHair = false; + } + } } diff --git a/Items/Accessories/AeroStone.cs b/Items/Accessories/AeroStone.cs index bfb762b1a6..9de993da85 100644 --- a/Items/Accessories/AeroStone.cs +++ b/Items/Accessories/AeroStone.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class AeroStone : ModItem + public class AeroStone : ModItem { public override void SetStaticDefaults() { @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.Calamity().aeroStone = true; + player.Calamity().aeroStone = true; player.moveSpeed += 0.1f; player.jumpSpeedBoost += 0.5f; } diff --git a/Items/Accessories/Affliction.cs b/Items/Accessories/Affliction.cs index c5f9de1106..ea13bc890e 100644 --- a/Items/Accessories/Affliction.cs +++ b/Items/Accessories/Affliction.cs @@ -27,12 +27,12 @@ namespace CalamityMod.Items.Accessories item.rare = ItemRarityID.Purple; } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Accessories/Affliction")); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Accessories/Affliction")); + } - public override void UpdateAccessory(Player player, bool hideVisual) + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.affliction = true; diff --git a/Items/Accessories/AlluringBait.cs b/Items/Accessories/AlluringBait.cs index b0d2e4bdb2..a4f8e254bf 100644 --- a/Items/Accessories/AlluringBait.cs +++ b/Items/Accessories/AlluringBait.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories Tooltip.SetDefault("30 increased fishing power during the day\n" + "45 increased fishing power during the night\n" + "60 increased fishing power during a solar eclipse\n" + - "Greatly increases chance of catching potion ingredient fish"); + "Greatly increases chance of catching potion ingredient fish"); } public override void SetDefaults() @@ -26,14 +26,14 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.Calamity().alluringBait = true; + player.Calamity().alluringBait = true; if (Main.eclipse) - player.fishingSkill += 60; + player.fishingSkill += 60; else if (!Main.dayTime) - player.fishingSkill += 45; + player.fishingSkill += 45; else - player.fishingSkill += 30; + player.fishingSkill += 30; } } } diff --git a/Items/Accessories/AmalgamatedBrain.cs b/Items/Accessories/AmalgamatedBrain.cs index 09dae3e4f5..ee4125e504 100644 --- a/Items/Accessories/AmalgamatedBrain.cs +++ b/Items/Accessories/AmalgamatedBrain.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class AmalgamatedBrain : ModItem + public class AmalgamatedBrain : ModItem { public override void SetStaticDefaults() { @@ -35,13 +35,13 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(60 * player.AverageDamage()), 2f, player.whoAmI); - if (rain.whoAmI.WithinBounds(Main.maxProjectiles)) - { - rain.Calamity().forceTypeless = true; - rain.tileCollide = false; - rain.penetrate = 1; - } + Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(60 * player.AverageDamage()), 2f, player.whoAmI); + if (rain.whoAmI.WithinBounds(Main.maxProjectiles)) + { + rain.Calamity().forceTypeless = true; + rain.tileCollide = false; + rain.penetrate = 1; + } } } } diff --git a/Items/Accessories/AmbrosialAmpoule.cs b/Items/Accessories/AmbrosialAmpoule.cs index 5402d4ad0d..e2e97b94a7 100644 --- a/Items/Accessories/AmbrosialAmpoule.cs +++ b/Items/Accessories/AmbrosialAmpoule.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class AmbrosialAmpoule : ModItem + public class AmbrosialAmpoule : ModItem { public override void SetStaticDefaults() { @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.aAmpoule = true; - modPlayer.rOoze = true; + modPlayer.rOoze = true; } public override void AddRecipes() diff --git a/Items/Accessories/AngelTreads.cs b/Items/Accessories/AngelTreads.cs index c72636c4af..a722496499 100644 --- a/Items/Accessories/AngelTreads.cs +++ b/Items/Accessories/AngelTreads.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - [AutoloadEquip(EquipType.Shoes)] + [AutoloadEquip(EquipType.Shoes)] public class AngelTreads : ModItem { public override void SetStaticDefaults() diff --git a/Items/Accessories/AngelicAlliance.cs b/Items/Accessories/AngelicAlliance.cs index 40d80fe731..45e638f57e 100644 --- a/Items/Accessories/AngelicAlliance.cs +++ b/Items/Accessories/AngelicAlliance.cs @@ -8,72 +8,72 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - //Developer item, dedicatee: Nincity - public class AngelicAlliance : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Angelic Alliance"); - Tooltip.SetDefault("Call upon the force of heaven to empower your attacks and minions\n" + - "Courage, Enlightenment, Bliss. United in Judgement\n" + - "+2 max minions, 15% increased summon damage, and 8% increased damage to all other classes\n" + - "Life regeneration is boosted while jumping\n" + - "This line is modified in the code below. If you can read this, someone probably did something wrong (It was Ben)\n" + - "While under the effects of Divine Bless, for every minion you have, an archangel shall be summoned to aid you in combat\n" + - "Each spawned angel will instantly heal you for two health\n" + - "All minion attacks inflict Banishing Fire and you are granted a flat health boost of four health per second\n" + - "This effect has a cooldown of 1 minute"); - } + //Developer item, dedicatee: Nincity + public class AngelicAlliance : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Angelic Alliance"); + Tooltip.SetDefault("Call upon the force of heaven to empower your attacks and minions\n" + + "Courage, Enlightenment, Bliss. United in Judgement\n" + + "+2 max minions, 15% increased summon damage, and 8% increased damage to all other classes\n" + + "Life regeneration is boosted while jumping\n" + + "This line is modified in the code below. If you can read this, someone probably did something wrong (It was Ben)\n" + + "While under the effects of Divine Bless, for every minion you have, an archangel shall be summoned to aid you in combat\n" + + "Each spawned angel will instantly heal you for two health\n" + + "All minion attacks inflict Banishing Fire and you are granted a flat health boost of four health per second\n" + + "This effect has a cooldown of 1 minute"); + } - public override void SetDefaults() - { - item.width = 56; - item.height = 92; - item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; - item.accessory = true; - item.rare = 10; - item.Calamity().customRarity = CalamityRarity.HotPink; - item.Calamity().devItem = true; - } + public override void SetDefaults() + { + item.width = 56; + item.height = 92; + item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; + item.accessory = true; + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.HotPink; + item.Calamity().devItem = true; + } - public override void ModifyTooltips(List list) - { - string hotkey = CalamityMod.AngelicAllianceHotKey.TooltipHotkeyString(); - foreach (TooltipLine line2 in list) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip4") - { - line2.text = "Press " + hotkey + " to grace yourself in divinity for 15 seconds"; - } - } - } + public override void ModifyTooltips(List list) + { + string hotkey = CalamityMod.AngelicAllianceHotKey.TooltipHotkeyString(); + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip4") + { + line2.text = "Press " + hotkey + " to grace yourself in divinity for 15 seconds"; + } + } + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.angelicAlliance = true; - player.allDamage += 0.08f; - player.minionDamage += 0.07f; //7% + 8% = 15% - player.maxMinions += 2; - if (player.controlJump) - player.lifeRegen += 4; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.angelicAlliance = true; + player.allDamage += 0.08f; + player.minionDamage += 0.07f; //7% + 8% = 15% + player.maxMinions += 2; + if (player.controlJump) + player.lifeRegen += 4; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddRecipeGroup("AnyHallowedHelmet"); - //recipe.AddRecipeGroup("AnyHallowedPlatemail"); - //recipe.AddRecipeGroup("AnyHallowedGreaves"); - recipe.AddIngredient(ItemID.HallowedPlateMail); - recipe.AddIngredient(ItemID.HallowedGreaves); - recipe.AddIngredient(ItemID.PaladinsShield); - recipe.AddIngredient(ItemID.TrueExcalibur); - recipe.AddIngredient(ItemID.CrossNecklace); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddRecipeGroup("AnyHallowedHelmet"); + //recipe.AddRecipeGroup("AnyHallowedPlatemail"); + //recipe.AddRecipeGroup("AnyHallowedGreaves"); + recipe.AddIngredient(ItemID.HallowedPlateMail); + recipe.AddIngredient(ItemID.HallowedGreaves); + recipe.AddIngredient(ItemID.PaladinsShield); + recipe.AddIngredient(ItemID.TrueExcalibur); + recipe.AddIngredient(ItemID.CrossNecklace); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Accessories/AsgardianAegis.cs b/Items/Accessories/AsgardianAegis.cs index bdfe16a370..185dd6287c 100644 --- a/Items/Accessories/AsgardianAegis.cs +++ b/Items/Accessories/AsgardianAegis.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.dashMod = 4; - player.dash = 0; + player.dash = 0; modPlayer.elysianAegis = true; modPlayer.abaddon = true; player.noKnockback = true; diff --git a/Items/Accessories/AsgardsValor.cs b/Items/Accessories/AsgardsValor.cs index 50fbc170b1..a3792f98bc 100644 --- a/Items/Accessories/AsgardsValor.cs +++ b/Items/Accessories/AsgardsValor.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.dashMod = 2; - player.dash = 0; + player.dash = 0; player.noKnockback = true; player.fireWalk = true; modPlayer.abaddon = true; diff --git a/Items/Accessories/AstralArcanum.cs b/Items/Accessories/AstralArcanum.cs index e36b2a8b47..a124c1f7b6 100644 --- a/Items/Accessories/AstralArcanum.cs +++ b/Items/Accessories/AstralArcanum.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - item.defense = 12; + item.defense = 12; item.width = 26; item.height = 26; item.accessory = true; @@ -54,8 +54,8 @@ namespace CalamityMod.Items.Accessories ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddIngredient(ItemID.LunarBar, 5); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddIngredient(ItemID.LunarBar, 5); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Accessories/BadgeofBravery.cs b/Items/Accessories/BadgeofBravery.cs index fbf8912eac..5cb341ecf8 100644 --- a/Items/Accessories/BadgeofBravery.cs +++ b/Items/Accessories/BadgeofBravery.cs @@ -12,15 +12,15 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Badge of Bravery"); Tooltip.SetDefault("15% increased melee speed\n" + - "Increases melee damage and melee crit by 5%\n" + - "+5 armor penetration"); + "Increases melee damage and melee crit by 5%\n" + + "+5 armor penetration"); } public override void SetDefaults() { item.width = 30; item.height = 30; - item.rare = ItemRarityID.Purple; + item.rare = ItemRarityID.Purple; item.value = CalamityGlobalItem.Rarity12BuyPrice; item.accessory = true; item.Calamity().customRarity = CalamityRarity.Turquoise; diff --git a/Items/Accessories/BlazingCore.cs b/Items/Accessories/BlazingCore.cs index 42be0393cc..368c952fe7 100644 --- a/Items/Accessories/BlazingCore.cs +++ b/Items/Accessories/BlazingCore.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class BlazingCore : ModItem + public class BlazingCore : ModItem { public override void SetStaticDefaults() { @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Accessories "Being hit creates a miniature sun that lingers, dealing damage to nearby enemies\n" + "The sun will slowly drag enemies into it\n" + "Only one sun can be active at once\n" + - "Provides a moderate amount of light in the Abyss"); + "Provides a moderate amount of light in the Abyss"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(5, 6)); } diff --git a/Items/Accessories/BloodPact.cs b/Items/Accessories/BloodPact.cs index 6669b36f23..e3c61680d1 100644 --- a/Items/Accessories/BloodPact.cs +++ b/Items/Accessories/BloodPact.cs @@ -12,8 +12,8 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("Blood Pact"); Tooltip.SetDefault("Doubles your max HP\n" + "Allows you to be critically hit 25% of the time\n" + - "After a critical hit, you gain various buffs for ten seconds\n" + - "Any healing potions consumed during this time period heal 50% more health"); + "After a critical hit, you gain various buffs for ten seconds\n" + + "Any healing potions consumed during this time period heal 50% more health"); } public override void SetDefaults() diff --git a/Items/Accessories/BloodflareCore.cs b/Items/Accessories/BloodflareCore.cs index 86468a4b32..732d7b3109 100644 --- a/Items/Accessories/BloodflareCore.cs +++ b/Items/Accessories/BloodflareCore.cs @@ -5,28 +5,28 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class BloodflareCore : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bloodflare Core"); - Tooltip.SetDefault("You lose up to half your defense after taking damage\n" + "Lost defense regenerates over time\n" + "You gain 1 health for every 1 defense gained as it regenerates"); - } + public class BloodflareCore : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bloodflare Core"); + Tooltip.SetDefault("You lose up to half your defense after taking damage\n" + "Lost defense regenerates over time\n" + "You gain 1 health for every 1 defense gained as it regenerates"); + } - public override void SetDefaults() - { - item.width = 26; - item.height = 26; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.accessory = true; - } + public override void SetDefaults() + { + item.width = 26; + item.height = 26; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.accessory = true; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.bloodflareCore = true; - } - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.bloodflareCore = true; + } + } } diff --git a/Items/Accessories/BloodstainedGlove.cs b/Items/Accessories/BloodstainedGlove.cs index e54fe25de1..19669d1b8e 100644 --- a/Items/Accessories/BloodstainedGlove.cs +++ b/Items/Accessories/BloodstainedGlove.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] + [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] public class BloodstainedGlove : ModItem { public override void SetStaticDefaults() diff --git a/Items/Accessories/BlunderBooster.cs b/Items/Accessories/BlunderBooster.cs index d421471fdc..0ed514b024 100644 --- a/Items/Accessories/BlunderBooster.cs +++ b/Items/Accessories/BlunderBooster.cs @@ -6,13 +6,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class BlunderBooster : ModItem + public class BlunderBooster : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Blunder Booster"); Tooltip.SetDefault("12% increased rogue damage and 15% increased rogue projectile velocity\n" + - "Stealth generates 10% faster\n" + + "Stealth generates 10% faster\n" + "Summons a red lightning aura to surround the player and electrify nearby enemies\n" + "TOOLTIP LINE HERE" + "This effect has a 1 second cooldown before it can be used again"); @@ -22,8 +22,8 @@ namespace CalamityMod.Items.Accessories { item.width = 30; item.height = 38; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; item.accessory = true; } @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.Calamity().hasJetpack = true; + player.Calamity().hasJetpack = true; player.Calamity().throwingDamage += 0.12f; player.Calamity().throwingVelocity += 0.15f; player.Calamity().blunderBooster = true; diff --git a/Items/Accessories/Calamity.cs b/Items/Accessories/Calamity.cs index 8e589d9a9c..6305ba1e80 100644 --- a/Items/Accessories/Calamity.cs +++ b/Items/Accessories/Calamity.cs @@ -5,40 +5,40 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class Calamity : ModItem - { - public const float MaxNPCSpeed = 5f; + public class Calamity : ModItem + { + public const float MaxNPCSpeed = 5f; - // This is ONLY the direct DPS of having the cursor over the enemy, not the damage from the flames debuff. - // The debuff is VulnerabilityHex, check that file for its DPS. - public const int BaseDamage = 266; - public const int HitsPerSecond = 12; + // This is ONLY the direct DPS of having the cursor over the enemy, not the damage from the flames debuff. + // The debuff is VulnerabilityHex, check that file for its DPS. + public const int BaseDamage = 266; + public const int HitsPerSecond = 12; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Calamity"); - Tooltip.SetDefault("Lights your cursor ablaze with the Witch's flames, summoning a burning sigil around it\n" + - "Enemies touching the sigil take immense damage and are inflicted with Vulnerability Hex\n" + - "Equip in a vanity slot to change the cursor without dealing damage"); - Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 6)); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Calamity"); + Tooltip.SetDefault("Lights your cursor ablaze with the Witch's flames, summoning a burning sigil around it\n" + + "Enemies touching the sigil take immense damage and are inflicted with Vulnerability Hex\n" + + "Equip in a vanity slot to change the cursor without dealing damage"); + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 6)); + } - public override void SetDefaults() - { - item.width = 44; - item.height = 108; - item.Calamity().customRarity = CalamityRarity.Violet; - item.rare = ItemRarityID.Purple; - item.value = CalamityGlobalItem.RarityVioletBuyPrice; - item.accessory = true; - } + public override void SetDefaults() + { + item.width = 44; + item.height = 108; + item.Calamity().customRarity = CalamityRarity.Violet; + item.rare = ItemRarityID.Purple; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.accessory = true; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.Calamity().blazingCursorDamage = true; - player.Calamity().blazingCursorVisuals = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.Calamity().blazingCursorDamage = true; + player.Calamity().blazingCursorVisuals = true; + } - public override void UpdateEquip(Player player) => player.Calamity().blazingCursorVisuals = true; - } + public override void UpdateEquip(Player player) => player.Calamity().blazingCursorVisuals = true; + } } diff --git a/Items/Accessories/CalamityRing.cs b/Items/Accessories/CalamityRing.cs index 4f9c6fedc4..92ea1ec3c8 100644 --- a/Items/Accessories/CalamityRing.cs +++ b/Items/Accessories/CalamityRing.cs @@ -6,14 +6,14 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class CalamityRing : ModItem + public class CalamityRing : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Void of Calamity"); Tooltip.SetDefault("Cursed? Reduces damage reduction by 10%\n" + - "15% increase to all damage\n" + - "Brimstone fire rains down while invincibility is active"); + "15% increase to all damage\n" + + "Brimstone fire rains down while invincibility is active"); } public override void SetDefaults() @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Accessories { if (player.miscCounter % 10 == 0) { - CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(30 * player.AverageDamage()), 5f, player.whoAmI); + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(30 * player.AverageDamage()), 5f, player.whoAmI); } } } diff --git a/Items/Accessories/CelestialJewel.cs b/Items/Accessories/CelestialJewel.cs index f6ac5bd195..89c639d0ee 100644 --- a/Items/Accessories/CelestialJewel.cs +++ b/Items/Accessories/CelestialJewel.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - item.defense = 8; + item.defense = 8; item.width = 26; item.height = 26; item.value = CalamityGlobalItem.Rarity7BuyPrice; @@ -50,8 +50,8 @@ namespace CalamityMod.Items.Accessories { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.TeleportationPotion, 3); - recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ItemID.TeleportationPotion, 3); + recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); diff --git a/Items/Accessories/ChaosAmulet.cs b/Items/Accessories/ChaosAmulet.cs index 8014af2327..8d9204d1db 100644 --- a/Items/Accessories/ChaosAmulet.cs +++ b/Items/Accessories/ChaosAmulet.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class ChaosAmulet : ModItem + public class ChaosAmulet : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/CheatTestThing.cs b/Items/Accessories/CheatTestThing.cs index 550d545241..9195ed98cf 100644 --- a/Items/Accessories/CheatTestThing.cs +++ b/Items/Accessories/CheatTestThing.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class CheatTestThing : ModItem + public class CheatTestThing : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/CoinofDeceit.cs b/Items/Accessories/CoinofDeceit.cs index 634ba85c28..05092e6c76 100644 --- a/Items/Accessories/CoinofDeceit.cs +++ b/Items/Accessories/CoinofDeceit.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Coin of Deceit"); Tooltip.SetDefault("Stealth strikes only expend 75% of your max stealth\n" + - "6% increased rogue crit chance"); + "6% increased rogue crit chance"); } public override void SetDefaults() @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Accessories ModRecipe recipe = new ModRecipe(mod); recipe.AddRecipeGroup("AnyGoldBar", 4); recipe.AddRecipeGroup("AnyCopperBar", 8); - // So you make fake coins out of wood, nobody will judge you + // So you make fake coins out of wood, nobody will judge you recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddTile(TileID.Anvils); recipe.SetResult(this); diff --git a/Items/Accessories/CorrosiveSpine.cs b/Items/Accessories/CorrosiveSpine.cs index 081316f503..e1c7028937 100644 --- a/Items/Accessories/CorrosiveSpine.cs +++ b/Items/Accessories/CorrosiveSpine.cs @@ -28,24 +28,24 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.moveSpeed += 0.1f; + player.moveSpeed += 0.1f; player.Calamity().corrosiveSpine = true; if (player.immune) { if (Main.rand.NextBool(15)) { - int cloudCount = Main.rand.Next(2,5); + int cloudCount = Main.rand.Next(2,5); for (int i = 0; i < cloudCount; i++) { - int type = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType() - }); - float speed = Main.rand.NextFloat(3f, 11f); - Projectile.NewProjectile(player.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * speed, - type, (int)(100 * player.RogueDamage()), 0f, player.whoAmI); + int type = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() + }); + float speed = Main.rand.NextFloat(3f, 11f); + Projectile.NewProjectile(player.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * speed, + type, (int)(100 * player.RogueDamage()), 0f, player.whoAmI); } } } diff --git a/Items/Accessories/CounterScarf.cs b/Items/Accessories/CounterScarf.cs index f37523f578..ef829ab20e 100644 --- a/Items/Accessories/CounterScarf.cs +++ b/Items/Accessories/CounterScarf.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - [AutoloadEquip(EquipType.Neck)] + [AutoloadEquip(EquipType.Neck)] public class CounterScarf : ModItem { public override void SetStaticDefaults() @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Accessories item.value = CalamityGlobalItem.Rarity3BuyPrice; item.rare = ItemRarityID.Orange; item.accessory = true; - } + } public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().dodgeScarf; @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.dodgeScarf = true; modPlayer.dashMod = 1; - player.dash = 0; + player.dash = 0; } } } diff --git a/Items/Accessories/CrownJewel.cs b/Items/Accessories/CrownJewel.cs index 2a95860269..91a9b34d42 100644 --- a/Items/Accessories/CrownJewel.cs +++ b/Items/Accessories/CrownJewel.cs @@ -16,13 +16,13 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - item.defense = 5; + item.defense = 5; item.width = 26; item.height = 26; item.value = CalamityGlobalItem.Rarity1BuyPrice; item.rare = ItemRarityID.Blue; item.accessory = true; - } + } public override void UpdateAccessory(Player player, bool hideVisual) { diff --git a/Items/Accessories/DaedalusEmblem.cs b/Items/Accessories/DaedalusEmblem.cs index 7a1d1aa768..51743c227a 100644 --- a/Items/Accessories/DaedalusEmblem.cs +++ b/Items/Accessories/DaedalusEmblem.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.Calamity().rangedAmmoCost *= 0.8f; + player.Calamity().rangedAmmoCost *= 0.8f; player.lifeRegen += 2; player.statDefense += 5; player.rangedDamage += 0.1f; diff --git a/Items/Accessories/DeepDiver.cs b/Items/Accessories/DeepDiver.cs index 8def81b9b3..c8c36ea047 100644 --- a/Items/Accessories/DeepDiver.cs +++ b/Items/Accessories/DeepDiver.cs @@ -18,11 +18,11 @@ namespace CalamityMod.Items.Accessories { item.width = 24; item.height = 28; - item.value = CalamityGlobalItem.Rarity5BuyPrice; - item.rare = ItemRarityID.Pink; - item.defense = 8; + item.value = CalamityGlobalItem.Rarity5BuyPrice; + item.rare = ItemRarityID.Pink; + item.defense = 8; item.accessory = true; - } + } public override void UpdateAccessory(Player player, bool hideVisual) { @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.deepDiver = true; modPlayer.dashMod = 5; - player.dash = 0; + player.dash = 0; } } } diff --git a/Items/Accessories/DeificAmulet.cs b/Items/Accessories/DeificAmulet.cs index 9126ce4a87..86df2c6a93 100644 --- a/Items/Accessories/DeificAmulet.cs +++ b/Items/Accessories/DeificAmulet.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Deific Amulet"); - Tooltip.SetDefault("Causes stars to fall and grants increased immune time when damaged\n" + + Tooltip.SetDefault("Causes stars to fall and grants increased immune time when damaged\n" + "Provides life regeneration and reduces the cooldown of healing potions\n"); } @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.dAmulet = true; - player.longInvince = true; + player.longInvince = true; player.lifeRegen += 1; } diff --git a/Items/Accessories/DraedonsHeart.cs b/Items/Accessories/DraedonsHeart.cs index c8fdcbffa5..59c7b08ea8 100644 --- a/Items/Accessories/DraedonsHeart.cs +++ b/Items/Accessories/DraedonsHeart.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Items.Accessories item.width = 52; item.height = 68; item.accessory = true; - item.rare = ItemRarityID.Red; - item.value = CalamityGlobalItem.RarityVioletBuyPrice; - item.Calamity().customRarity = CalamityRarity.Violet; - } + item.rare = ItemRarityID.Red; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.Calamity().customRarity = CalamityRarity.Violet; + } public override void UpdateAccessory(Player player, bool hideVisual) { diff --git a/Items/Accessories/DragonScales.cs b/Items/Accessories/DragonScales.cs index c5c588e212..57e19c6aa8 100644 --- a/Items/Accessories/DragonScales.cs +++ b/Items/Accessories/DragonScales.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Dragon Scales"); Tooltip.SetDefault("Only a living dragon holds true treasure\n" + - "Rogue projectiles create slow fireballs as they travel\n" + + "Rogue projectiles create slow fireballs as they travel\n" + "Stealth strikes create infernados on death\n" + "+10% max run speed and acceleration"); } diff --git a/Items/Accessories/DukeScales.cs b/Items/Accessories/DukeScales.cs index e1aebb7ce8..40978c7556 100644 --- a/Items/Accessories/DukeScales.cs +++ b/Items/Accessories/DukeScales.cs @@ -10,9 +10,9 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Old Duke's Scales"); 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 sulphuric poisoning"); + "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 sulphuric poisoning"); } public override void SetDefaults() diff --git a/Items/Accessories/DynamoStemCells.cs b/Items/Accessories/DynamoStemCells.cs index 929eeb6837..dc5b9aa110 100644 --- a/Items/Accessories/DynamoStemCells.cs +++ b/Items/Accessories/DynamoStemCells.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class DynamoStemCells : ModItem + public class DynamoStemCells : ModItem { public override void SetStaticDefaults() { @@ -19,14 +19,14 @@ Ranged weapons have a chance to fire mini swarmers"); { item.width = 20; item.height = 20; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.accessory = true; + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.accessory = true; } public override void UpdateAccessory(Player player, bool hideVisual) { - player.Calamity().dynamoStemCells = true; + player.Calamity().dynamoStemCells = true; player.moveSpeed += 0.1f; } } diff --git a/Items/Accessories/EldritchSoulArtifact.cs b/Items/Accessories/EldritchSoulArtifact.cs index 23e67b95ab..08601970d2 100644 --- a/Items/Accessories/EldritchSoulArtifact.cs +++ b/Items/Accessories/EldritchSoulArtifact.cs @@ -21,10 +21,10 @@ namespace CalamityMod.Items.Accessories { item.width = 64; item.height = 58; - item.accessory = true; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - } + item.accessory = true; + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + } public override void UpdateAccessory(Player player, bool hideVisual) { @@ -35,10 +35,10 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 25); - recipe.AddIngredient(ModContent.ItemType(), 25); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.DemonAltar); + recipe.AddIngredient(ModContent.ItemType(), 25); + recipe.AddIngredient(ModContent.ItemType(), 25); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.DemonAltar); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Accessories/ElectriciansGlove.cs b/Items/Accessories/ElectriciansGlove.cs index b68cf1b647..4690be0a54 100644 --- a/Items/Accessories/ElectriciansGlove.cs +++ b/Items/Accessories/ElectriciansGlove.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] + [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] public class ElectriciansGlove : ModItem { public override void SetStaticDefaults() diff --git a/Items/Accessories/ElementalGauntlet.cs b/Items/Accessories/ElementalGauntlet.cs index 8daed76fe4..2e54a7fdd1 100644 --- a/Items/Accessories/ElementalGauntlet.cs +++ b/Items/Accessories/ElementalGauntlet.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] + [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] public class ElementalGauntlet : ModItem { public override void SetStaticDefaults() diff --git a/Items/Accessories/ElysianAegis.cs b/Items/Accessories/ElysianAegis.cs index d8993a2715..8bd97f1607 100644 --- a/Items/Accessories/ElysianAegis.cs +++ b/Items/Accessories/ElysianAegis.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.dashMod = 3; - player.dash = 0; + player.dash = 0; modPlayer.elysianAegis = true; player.buffImmune[BuffID.OnFire] = true; player.buffImmune[ModContent.BuffType()] = true; diff --git a/Items/Accessories/EnchantedPearl.cs b/Items/Accessories/EnchantedPearl.cs index 010955760e..a114742f19 100644 --- a/Items/Accessories/EnchantedPearl.cs +++ b/Items/Accessories/EnchantedPearl.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Enchanted Pearl"); Tooltip.SetDefault("Increases fishing skill\n" + - "Increases chance to catch crates"); + "Increases chance to catch crates"); } public override void SetDefaults() @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.fishingSkill += 10; - player.Calamity().enchantedPearl = true; + player.Calamity().enchantedPearl = true; } public override void AddRecipes() diff --git a/Items/Accessories/EtherealExtorter.cs b/Items/Accessories/EtherealExtorter.cs index bc208d5ea0..e1243779c6 100644 --- a/Items/Accessories/EtherealExtorter.cs +++ b/Items/Accessories/EtherealExtorter.cs @@ -28,8 +28,8 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.etherealExtorter = true; modPlayer.throwingDamage += 0.1f; - player.lifeRegen -= 1; - modPlayer.rogueStealthMax += 0.1f; + player.lifeRegen -= 1; + modPlayer.rogueStealthMax += 0.1f; } } } diff --git a/Items/Accessories/EvasionScarf.cs b/Items/Accessories/EvasionScarf.cs index b45a457a03..1d556fb558 100644 --- a/Items/Accessories/EvasionScarf.cs +++ b/Items/Accessories/EvasionScarf.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - [AutoloadEquip(EquipType.Neck)] + [AutoloadEquip(EquipType.Neck)] public class EvasionScarf : ModItem { public override void SetStaticDefaults() @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Accessories modPlayer.dodgeScarf = true; modPlayer.evasionScarf = true; modPlayer.dashMod = 1; - player.dash = 0; + player.dash = 0; } public override void AddRecipes() diff --git a/Items/Accessories/FabledTortoiseShell.cs b/Items/Accessories/FabledTortoiseShell.cs index 6674fce722..a10c66138a 100644 --- a/Items/Accessories/FabledTortoiseShell.cs +++ b/Items/Accessories/FabledTortoiseShell.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class FabledTortoiseShell : ModItem + public class FabledTortoiseShell : ModItem { public override void SetStaticDefaults() { @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories Tooltip.SetDefault("35% decreased movement speed\n" + "Enemies take damage when they hit you\n" + "You move faster and lose 18 defense for 3 seconds if you take damage\n" + - "Temporary immunity to lava"); + "Temporary immunity to lava"); } public override void SetDefaults() @@ -24,18 +24,18 @@ namespace CalamityMod.Items.Accessories item.value = CalamityGlobalItem.Rarity5BuyPrice; item.rare = ItemRarityID.Pink; item.accessory = true; - } + } - public override void UpdateAccessory(Player player, bool hideVisual) + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.fabledTortoise = true; - player.lavaMax += 240; - float moveSpeedDecrease = modPlayer.shellBoost ? 0.15f : 0.35f; + player.lavaMax += 240; + float moveSpeedDecrease = modPlayer.shellBoost ? 0.15f : 0.35f; player.moveSpeed -= moveSpeedDecrease; player.thorns += 0.25f; - if (modPlayer.shellBoost) - player.statDefense -= 18; + if (modPlayer.shellBoost) + player.statDefense -= 18; } } } diff --git a/Items/Accessories/FeatherCrown.cs b/Items/Accessories/FeatherCrown.cs index d6272e0293..0c222672dd 100644 --- a/Items/Accessories/FeatherCrown.cs +++ b/Items/Accessories/FeatherCrown.cs @@ -29,14 +29,14 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.throwingVelocity += 0.15f; modPlayer.featherCrown = true; - if (!hideVisual) - modPlayer.featherCrownDraw = true; //this bool is just used for drawing + if (!hideVisual) + modPlayer.featherCrownDraw = true; //this bool is just used for drawing } - public override void UpdateVanity(Player player, EquipType type) - { - player.Calamity().featherCrownDraw = true; //this bool is just used for drawing - } + public override void UpdateVanity(Player player, EquipType type) + { + player.Calamity().featherCrownDraw = true; //this bool is just used for drawing + } public override void AddRecipes() { @@ -57,12 +57,12 @@ namespace CalamityMod.Items.Accessories } } - public class FeatherCrownHair : EquipTexture - { - public override void DrawHair(ref bool drawHair, ref bool drawAltHair) - { - drawHair = false; - drawAltHair = false; - } - } + public class FeatherCrownHair : EquipTexture + { + public override void DrawHair(ref bool drawHair, ref bool drawAltHair) + { + drawHair = false; + drawAltHair = false; + } + } } diff --git a/Items/Accessories/FilthyGlove.cs b/Items/Accessories/FilthyGlove.cs index 07192a2d32..6ee3cc3f42 100644 --- a/Items/Accessories/FilthyGlove.cs +++ b/Items/Accessories/FilthyGlove.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] + [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] public class FilthyGlove : ModItem { public override void SetStaticDefaults() diff --git a/Items/Accessories/FrigidBulwark.cs b/Items/Accessories/FrigidBulwark.cs index 26c56ff690..f397b16504 100644 --- a/Items/Accessories/FrigidBulwark.cs +++ b/Items/Accessories/FrigidBulwark.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class FrigidBulwark : ModItem + public class FrigidBulwark : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/FrostBarrier.cs b/Items/Accessories/FrostBarrier.cs index 8d20f50112..0a0d992ff6 100644 --- a/Items/Accessories/FrostBarrier.cs +++ b/Items/Accessories/FrostBarrier.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class FrostBarrier : ModItem + public class FrostBarrier : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/FrostFlare.cs b/Items/Accessories/FrostFlare.cs index e832d209c5..74903952fa 100644 --- a/Items/Accessories/FrostFlare.cs +++ b/Items/Accessories/FrostFlare.cs @@ -6,7 +6,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class FrostFlare : ModItem + public class FrostFlare : ModItem { public override void SetStaticDefaults() { @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Accessories "Immunity to frostburn, chilled and frozen\n" + "Being above 75% life grants 10% increased damage\n" + "Being below 25% life grants 20 defense and 15% increased max movement speed and acceleration\n" + - "Grants resistance against cold attacks"); + "Grants resistance against cold attacks"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(5, 4)); } diff --git a/Items/Accessories/FungalClump.cs b/Items/Accessories/FungalClump.cs index eb9d60b32a..cb0e0d006f 100644 --- a/Items/Accessories/FungalClump.cs +++ b/Items/Accessories/FungalClump.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Accessories { public class FungalClump : ModItem { - public const int FungalClumpDamage = 10; + public const int FungalClumpDamage = 10; public override void SetStaticDefaults() { diff --git a/Items/Accessories/GiantPearl.cs b/Items/Accessories/GiantPearl.cs index 2dec3aacbb..d0b30097dc 100644 --- a/Items/Accessories/GiantPearl.cs +++ b/Items/Accessories/GiantPearl.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories Tooltip.SetDefault("You have a light aura around you\n" + "Enemies within the aura are slowed down\n" + "Does not work while a boss is alive\n" + - "Provides a small amount of light in the abyss"); + "Provides a small amount of light in the abyss"); } public override void SetDefaults() diff --git a/Items/Accessories/GiantShell.cs b/Items/Accessories/GiantShell.cs index 3fac14cbdd..5b8e841a06 100644 --- a/Items/Accessories/GiantShell.cs +++ b/Items/Accessories/GiantShell.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.endurance += 0.05f; + player.endurance += 0.05f; player.moveSpeed -= 0.15f; CalamityPlayer modPlayer = player.Calamity(); modPlayer.gShell = true; diff --git a/Items/Accessories/GiantTortoiseShell.cs b/Items/Accessories/GiantTortoiseShell.cs index 6ef4c55329..6ffae9ab7b 100644 --- a/Items/Accessories/GiantTortoiseShell.cs +++ b/Items/Accessories/GiantTortoiseShell.cs @@ -4,7 +4,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class GiantTortoiseShell : ModItem + public class GiantTortoiseShell : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/GladiatorsLocket.cs b/Items/Accessories/GladiatorsLocket.cs index b49d0cf936..2eb3b03ee5 100644 --- a/Items/Accessories/GladiatorsLocket.cs +++ b/Items/Accessories/GladiatorsLocket.cs @@ -43,8 +43,8 @@ namespace CalamityMod.Items.Accessories if (player.FindBuffIndex(ModContent.BuffType()) == -1) player.AddBuff(ModContent.BuffType(), 3600, true); - int damage = 30; - int swordDmg = (int)(damage * player.AverageDamage()); + int damage = 30; + int swordDmg = (int)(damage * player.AverageDamage()); if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), swordDmg, 2f, Main.myPlayer); diff --git a/Items/Accessories/GloveOfRecklessness.cs b/Items/Accessories/GloveOfRecklessness.cs index d216a7e10f..3a04b9c91d 100644 --- a/Items/Accessories/GloveOfRecklessness.cs +++ b/Items/Accessories/GloveOfRecklessness.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] + [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] public class GloveOfRecklessness : ModItem { public override void SetStaticDefaults() diff --git a/Items/Accessories/GloveofPrecision.cs b/Items/Accessories/GloveofPrecision.cs index 645384acc2..c0d92f0ea3 100644 --- a/Items/Accessories/GloveofPrecision.cs +++ b/Items/Accessories/GloveofPrecision.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] + [AutoloadEquip(new EquipType[] { EquipType.HandsOn, EquipType.HandsOff } )] public class GloveOfPrecision : ModItem { public override void SetStaticDefaults() diff --git a/Items/Accessories/GrandGelatin.cs b/Items/Accessories/GrandGelatin.cs index d403f06f91..447016d7e8 100644 --- a/Items/Accessories/GrandGelatin.cs +++ b/Items/Accessories/GrandGelatin.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class GrandGelatin : ModItem + public class GrandGelatin : ModItem { public override void SetStaticDefaults() { @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Accessories { player.moveSpeed += 0.1f; player.jumpSpeedBoost += 0.5f; - player.statLifeMax2 += 20; + player.statLifeMax2 += 20; player.statManaMax2 += 20; if (Math.Abs(player.velocity.X) < 0.05f && Math.Abs(player.velocity.Y) < 0.05f && player.itemAnimation == 0) { diff --git a/Items/Accessories/GravistarSabaton.cs b/Items/Accessories/GravistarSabaton.cs index c366339a2f..2e82d343b6 100644 --- a/Items/Accessories/GravistarSabaton.cs +++ b/Items/Accessories/GravistarSabaton.cs @@ -4,7 +4,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class GravistarSabaton : ModItem + public class GravistarSabaton : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/HallowedRune.cs b/Items/Accessories/HallowedRune.cs index 04be50fda8..426faff59c 100644 --- a/Items/Accessories/HallowedRune.cs +++ b/Items/Accessories/HallowedRune.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class HallowedRune : ModItem + public class HallowedRune : ModItem { public override void SetStaticDefaults() { @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Accessories recipe.AddIngredient(ItemID.SoulofFright, 5); recipe.AddIngredient(ItemID.SoulofMight, 5); recipe.AddIngredient(ItemID.SoulofSight, 5); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Accessories/HeartoftheElements.cs b/Items/Accessories/HeartoftheElements.cs index 8c46fffdf3..9ad08374cd 100644 --- a/Items/Accessories/HeartoftheElements.cs +++ b/Items/Accessories/HeartoftheElements.cs @@ -10,7 +10,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Accessories { - public class HeartoftheElements : ModItem + public class HeartoftheElements : ModItem { public override void SetStaticDefaults() { @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Accessories item.Calamity().customRarity = CalamityRarity.Rainbow; } - public override bool CanEquipAccessory(Player player, int slot) + public override bool CanEquipAccessory(Player player, int slot) { CalamityPlayer modPlayer = player.Calamity(); if (modPlayer.brimstoneWaifu || modPlayer.sandWaifu || modPlayer.sandBoobWaifu || modPlayer.cloudWaifu || modPlayer.sirenWaifu) @@ -40,59 +40,59 @@ namespace CalamityMod.Items.Accessories return true; } - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (player != null && !player.dead) - Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, Main.DiscoR / 255f, Main.DiscoG / 255f, Main.DiscoB / 255f); + public override void UpdateAccessory(Player player, bool hideVisual) + { + if (player != null && !player.dead) + Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, Main.DiscoR / 255f, Main.DiscoG / 255f, Main.DiscoB / 255f); - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.allWaifus = true; - modPlayer.elementalHeart = true; + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.allWaifus = true; + modPlayer.elementalHeart = true; - int brimmy = ProjectileType(); - int siren = ProjectileType(); - int healer = ProjectileType(); - int sandy = ProjectileType(); - int cloudy = ProjectileType(); + int brimmy = ProjectileType(); + int siren = ProjectileType(); + int healer = ProjectileType(); + int sandy = ProjectileType(); + int cloudy = ProjectileType(); - Vector2 velocity = new Vector2(0f, -1f); - int elementalDmg = (int)(90 * player.MinionDamage()); - float kBack = 2f + player.minionKB; + Vector2 velocity = new Vector2(0f, -1f); + int elementalDmg = (int)(90 * player.MinionDamage()); + float kBack = 2f + player.minionKB; - 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 != null && player.whoAmI == Main.myPlayer && !player.dead) - { - 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); - } - if (player.ownedProjectileCounts[siren] < 1) - { - Projectile.NewProjectile(player.Center, velocity, siren, elementalDmg, kBack, player.whoAmI); - } - if (player.ownedProjectileCounts[healer] < 1) - { - Projectile.NewProjectile(player.Center, velocity, healer, elementalDmg, kBack, player.whoAmI); - } - if (player.ownedProjectileCounts[sandy] < 1) - { - Projectile.NewProjectile(player.Center, velocity, sandy, elementalDmg, kBack, player.whoAmI); - } - if (player.ownedProjectileCounts[cloudy] < 1) - { - Projectile.NewProjectile(player.Center, velocity, cloudy, elementalDmg, kBack, player.whoAmI); - } - } - } + 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 != null && player.whoAmI == Main.myPlayer && !player.dead) + { + 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); + } + if (player.ownedProjectileCounts[siren] < 1) + { + Projectile.NewProjectile(player.Center, velocity, siren, elementalDmg, kBack, player.whoAmI); + } + if (player.ownedProjectileCounts[healer] < 1) + { + Projectile.NewProjectile(player.Center, velocity, healer, elementalDmg, kBack, player.whoAmI); + } + if (player.ownedProjectileCounts[sandy] < 1) + { + Projectile.NewProjectile(player.Center, velocity, sandy, elementalDmg, kBack, player.whoAmI); + } + if (player.ownedProjectileCounts[cloudy] < 1) + { + Projectile.NewProjectile(player.Center, velocity, cloudy, elementalDmg, kBack, player.whoAmI); + } + } + } public override void AddRecipes() { diff --git a/Items/Accessories/HideofAstrumDeus.cs b/Items/Accessories/HideofAstrumDeus.cs index 1ef11caead..be616e7d9c 100644 --- a/Items/Accessories/HideofAstrumDeus.cs +++ b/Items/Accessories/HideofAstrumDeus.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Hide of Astrum Deus"); Tooltip.SetDefault("Taking damage, or inflicting a true melee strike, drops an immense amount of astral stars from the sky\n" + - "Taking damage boosts true melee damage by 50%\n" + + "Taking damage boosts true melee damage by 50%\n" + "Boost duration is based on the amount of damage you took, the higher the damage the longer the boost\n" + "Provides immunity to the astral infection, cursed inferno, on fire, and frostburn debuffs\n" + "Enemies take damage when they hit you and are inflicted with the astral infection debuff"); @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Accessories item.value = CalamityGlobalItem.Rarity9BuyPrice; item.rare = ItemRarityID.Cyan; item.accessory = true; - } + } public override void UpdateAccessory(Player player, bool hideVisual) { diff --git a/Items/Accessories/HowlsHeart.cs b/Items/Accessories/HowlsHeart.cs index c3ab8ff3fd..95fa711276 100644 --- a/Items/Accessories/HowlsHeart.cs +++ b/Items/Accessories/HowlsHeart.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Howl's Heart"); Tooltip.SetDefault("Summons Howl to fight for you, Calcifer to light your way, and Turnip-Head to follow you around\n" + - "Placing this accessory in vanity slots will summon the trio without the combat or exploration utilities"); + "Placing this accessory in vanity slots will summon the trio without the combat or exploration utilities"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(5, 4)); } diff --git a/Items/Accessories/JellyChargedBattery.cs b/Items/Accessories/JellyChargedBattery.cs index 1dfaa7385d..2677a92e2d 100644 --- a/Items/Accessories/JellyChargedBattery.cs +++ b/Items/Accessories/JellyChargedBattery.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Jelly-Charged Battery"); Tooltip.SetDefault("+1 max minions and 7% minion damage\n" + - "Minion attacks spawn orbs of energy and inflict Electrified"); + "Minion attacks spawn orbs of energy and inflict Electrified"); } public override void SetDefaults() @@ -25,8 +25,8 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.Calamity().voltaicJelly = true; - player.Calamity().jellyChargedBattery = true; + player.Calamity().voltaicJelly = true; + player.Calamity().jellyChargedBattery = true; player.minionDamage += 0.07f; } diff --git a/Items/Accessories/LeviathanAmbergris.cs b/Items/Accessories/LeviathanAmbergris.cs index ea9ba64621..dd6117f8de 100644 --- a/Items/Accessories/LeviathanAmbergris.cs +++ b/Items/Accessories/LeviathanAmbergris.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - item.defense = 20; + item.defense = 20; item.width = 20; item.height = 22; item.value = CalamityGlobalItem.Rarity7BuyPrice; diff --git a/Items/Accessories/LivingDew.cs b/Items/Accessories/LivingDew.cs index 0fecf798ac..20202f13f4 100644 --- a/Items/Accessories/LivingDew.cs +++ b/Items/Accessories/LivingDew.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Living Dew"); Tooltip.SetDefault("5% increased damage reduction, +5 defense, and increased life regen while in the Jungle\n" + - "Immunity to Poison"); + "Immunity to Poison"); } public override void SetDefaults() diff --git a/Items/Accessories/LumenousAmulet.cs b/Items/Accessories/LumenousAmulet.cs index f0ab937a29..874b75e27e 100644 --- a/Items/Accessories/LumenousAmulet.cs +++ b/Items/Accessories/LumenousAmulet.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Lumenous Amulet"); Tooltip.SetDefault("Attacks inflict the Crush Depth debuff\n" + - "Grants immunity to the Crush Depth debuff\n" + + "Grants immunity to the Crush Depth debuff\n" + "While in the abyss you gain 25% increased max life\n" + "Provides a moderate amount of light in the abyss"); } @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.abyssalAmulet = true; modPlayer.lumenousAmulet = true; - player.buffImmune[ModContent.BuffType()] = true; - } + player.buffImmune[ModContent.BuffType()] = true; + } public override void AddRecipes() { diff --git a/Items/Accessories/LureofEnthrallment.cs b/Items/Accessories/LureofEnthrallment.cs index cb7e167e3b..123282bf43 100644 --- a/Items/Accessories/LureofEnthrallment.cs +++ b/Items/Accessories/LureofEnthrallment.cs @@ -7,7 +7,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class LureofEnthrallment : ModItem + public class LureofEnthrallment : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/ManaOverloader.cs b/Items/Accessories/ManaOverloader.cs index fc9f72b6b2..3129c04444 100644 --- a/Items/Accessories/ManaOverloader.cs +++ b/Items/Accessories/ManaOverloader.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.Accessories 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" + "Grants spectre healing, the amount healed scales with your mana\n" + - "The healing only works while holding a magic weapon\n" + - "The more mana you have, the more you heal"); + "The healing only works while holding a magic weapon\n" + + "The more mana you have, the more you heal"); } public override void SetDefaults() diff --git a/Items/Accessories/MoonstoneCrown.cs b/Items/Accessories/MoonstoneCrown.cs index 8e7d6fb042..7fbe73fb44 100644 --- a/Items/Accessories/MoonstoneCrown.cs +++ b/Items/Accessories/MoonstoneCrown.cs @@ -33,14 +33,14 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.throwingVelocity += 0.15f; modPlayer.moonCrown = true; - if (!hideVisual) - modPlayer.moonCrownDraw = true; //this bool is just used for drawing + if (!hideVisual) + modPlayer.moonCrownDraw = true; //this bool is just used for drawing } - public override void UpdateVanity(Player player, EquipType type) - { - player.Calamity().moonCrownDraw = true; //this bool is just used for drawing - } + public override void UpdateVanity(Player player, EquipType type) + { + player.Calamity().moonCrownDraw = true; //this bool is just used for drawing + } public override void AddRecipes() { @@ -54,12 +54,12 @@ namespace CalamityMod.Items.Accessories } } - public class MoonstoneCrownHair : EquipTexture - { - public override void DrawHair(ref bool drawHair, ref bool drawAltHair) - { - drawHair = false; - drawAltHair = false; - } - } + public class MoonstoneCrownHair : EquipTexture + { + public override void DrawHair(ref bool drawHair, ref bool drawAltHair) + { + drawHair = false; + drawAltHair = false; + } + } } diff --git a/Items/Accessories/NebulousCore.cs b/Items/Accessories/NebulousCore.cs index c6b4234759..14bed7426c 100644 --- a/Items/Accessories/NebulousCore.cs +++ b/Items/Accessories/NebulousCore.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Accessories Tooltip.SetDefault("10% increased damage\n" + "Summons floating nebula stars to protect you\n" + "You will survive an attack that would have killed you and be healed 100 HP\n" + - "This effect has a 90 second cooldown"); + "This effect has a 90 second cooldown"); } public override void SetDefaults() diff --git a/Items/Accessories/NecklaceofVexation.cs b/Items/Accessories/NecklaceofVexation.cs index ea438c686f..dea5f3e123 100644 --- a/Items/Accessories/NecklaceofVexation.cs +++ b/Items/Accessories/NecklaceofVexation.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("Necklace of Vexation"); Tooltip.SetDefault("Revenge\n" + "20% increased damage when under 50% life\n" + - "All attacks inflict Cursed Inferno and Venom while wearing Reaver armor"); + "All attacks inflict Cursed Inferno and Venom while wearing Reaver armor"); } public override void SetDefaults() diff --git a/Items/Accessories/NuclearRod.cs b/Items/Accessories/NuclearRod.cs index bb54a5075d..18efe78905 100644 --- a/Items/Accessories/NuclearRod.cs +++ b/Items/Accessories/NuclearRod.cs @@ -4,7 +4,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class NuclearRod : ModItem + public class NuclearRod : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/OrnateShield.cs b/Items/Accessories/OrnateShield.cs index eb1480708b..d27af32c5f 100644 --- a/Items/Accessories/OrnateShield.cs +++ b/Items/Accessories/OrnateShield.cs @@ -6,8 +6,8 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - [AutoloadEquip(EquipType.Shield)] - public class OrnateShield : ModItem + [AutoloadEquip(EquipType.Shield)] + public class OrnateShield : ModItem { public const int ShieldSlamIFrames = 4; @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Ornate Shield"); Tooltip.SetDefault("Boosted damage reduction and health while wearing the Daedalus armor\n" + - "Grants a frost dash"); + "Grants a frost dash"); } public override void SetDefaults() @@ -38,9 +38,9 @@ namespace CalamityMod.Items.Accessories player.endurance += 0.08f; player.statLifeMax2 += 20; } - player.Calamity().dashMod = 6; - player.dash = 0; - } + player.Calamity().dashMod = 6; + player.dash = 0; + } public override void AddRecipes() { diff --git a/Items/Accessories/PermafrostsConcoction.cs b/Items/Accessories/PermafrostsConcoction.cs index 310568acc0..4b01ac1478 100644 --- a/Items/Accessories/PermafrostsConcoction.cs +++ b/Items/Accessories/PermafrostsConcoction.cs @@ -4,7 +4,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class PermafrostsConcoction : ModItem + public class PermafrostsConcoction : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/PlagueHive.cs b/Items/Accessories/PlagueHive.cs index 89c15df13d..7f3cad08b3 100644 --- a/Items/Accessories/PlagueHive.cs +++ b/Items/Accessories/PlagueHive.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class PlagueHive : ModItem + public class PlagueHive : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/PlaguedFuelPack.cs b/Items/Accessories/PlaguedFuelPack.cs index 8a6d2d0bc4..d15586ba3f 100644 --- a/Items/Accessories/PlaguedFuelPack.cs +++ b/Items/Accessories/PlaguedFuelPack.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class PlaguedFuelPack : ModItem + public class PlaguedFuelPack : ModItem { public override void SetStaticDefaults() { @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.Calamity().hasJetpack = true; + player.Calamity().hasJetpack = true; player.Calamity().throwingDamage += 0.05f; player.Calamity().throwingVelocity += 0.15f; player.Calamity().plaguedFuelPack = true; diff --git a/Items/Accessories/RaidersTalisman.cs b/Items/Accessories/RaidersTalisman.cs index a92fa5dcb2..b6cc47d190 100644 --- a/Items/Accessories/RaidersTalisman.cs +++ b/Items/Accessories/RaidersTalisman.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("Raider's Talisman"); Tooltip.SetDefault("Whenever you crit an enemy with a rogue weapon your rogue damage increases\n" + "This effect can stack up to 150 times\n" + - "Max rogue damage boost is 15%\n" + + "Max rogue damage boost is 15%\n" + "This line is modified below"); } diff --git a/Items/Accessories/RampartofDeities.cs b/Items/Accessories/RampartofDeities.cs index 032e61c883..51d2de898a 100644 --- a/Items/Accessories/RampartofDeities.cs +++ b/Items/Accessories/RampartofDeities.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - [AutoloadEquip(EquipType.Shield)] + [AutoloadEquip(EquipType.Shield)] public class RampartofDeities : ModItem { public override void SetStaticDefaults() @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Accessories modPlayer.dAmulet = true; modPlayer.rampartOfDeities = true; modPlayer.fBulwark = true; - player.longInvince = true; + player.longInvince = true; player.lifeRegen += 1; } diff --git a/Items/Accessories/RangedLevelMeter.cs b/Items/Accessories/RangedLevelMeter.cs index 2f77a86eb4..b68fdde67f 100644 --- a/Items/Accessories/RangedLevelMeter.cs +++ b/Items/Accessories/RangedLevelMeter.cs @@ -46,8 +46,8 @@ namespace CalamityMod.Items.Accessories break; case 4: damageGain = 2; - moveSpeed = 1; - critGain = 1; + moveSpeed = 1; + critGain = 1; break; case 5: damageGain = 2; diff --git a/Items/Accessories/ReaperToothNecklace.cs b/Items/Accessories/ReaperToothNecklace.cs index b9da7450c5..61dea31ac2 100644 --- a/Items/Accessories/ReaperToothNecklace.cs +++ b/Items/Accessories/ReaperToothNecklace.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class ReaperToothNecklace : ModItem + public class ReaperToothNecklace : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/Regenator.cs b/Items/Accessories/Regenator.cs index 94575886e8..677eab3a26 100644 --- a/Items/Accessories/Regenator.cs +++ b/Items/Accessories/Regenator.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Accessories item.rare = ItemRarityID.Lime; item.defense = 10; item.accessory = true; - } + } public override void UpdateAccessory(Player player, bool hideVisual) { diff --git a/Items/Accessories/RogueEmblem.cs b/Items/Accessories/RogueEmblem.cs index 599afdf469..6790e86014 100644 --- a/Items/Accessories/RogueEmblem.cs +++ b/Items/Accessories/RogueEmblem.cs @@ -4,7 +4,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class RogueEmblem : ModItem + public class RogueEmblem : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/RogueLevelMeter.cs b/Items/Accessories/RogueLevelMeter.cs index 824d973d79..7777dec2a6 100644 --- a/Items/Accessories/RogueLevelMeter.cs +++ b/Items/Accessories/RogueLevelMeter.cs @@ -46,8 +46,8 @@ namespace CalamityMod.Items.Accessories break; case 4: damageGain = 2; - velocityGain = 1; - critGain = 1; + velocityGain = 1; + critGain = 1; break; case 5: damageGain = 2; diff --git a/Items/Accessories/RottenBrain.cs b/Items/Accessories/RottenBrain.cs index 6dc1307c31..37ef1cf4d7 100644 --- a/Items/Accessories/RottenBrain.cs +++ b/Items/Accessories/RottenBrain.cs @@ -6,7 +6,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class RottenBrain : ModItem + public class RottenBrain : ModItem { public override void SetStaticDefaults() { @@ -31,13 +31,13 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(18 * player.AverageDamage()), 2f, player.whoAmI); - if (rain.whoAmI.WithinBounds(Main.maxProjectiles)) - { - rain.Calamity().forceTypeless = true; - rain.tileCollide = false; - rain.penetrate = 1; - } + Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(18 * player.AverageDamage()), 2f, player.whoAmI); + if (rain.whoAmI.WithinBounds(Main.maxProjectiles)) + { + rain.Calamity().forceTypeless = true; + rain.tileCollide = false; + rain.penetrate = 1; + } } } } diff --git a/Items/Accessories/RottenDogtooth.cs b/Items/Accessories/RottenDogtooth.cs index 2e84e0fda5..b495dbb489 100644 --- a/Items/Accessories/RottenDogtooth.cs +++ b/Items/Accessories/RottenDogtooth.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class RottenDogtooth : ModItem + public class RottenDogtooth : ModItem { internal const int ArmorCrunchDebuffTime = 180; internal const float StealthStrikeDamageMultiplier = 0.1f; @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Accessories } public override void UpdateAccessory(Player player, bool hideVisual) - { + { player.Calamity().rottenDogTooth = true; player.Calamity().flatStealthLossReduction++; } diff --git a/Items/Accessories/RoverDrive.cs b/Items/Accessories/RoverDrive.cs index 1f3389d12f..2d6c51ec5e 100644 --- a/Items/Accessories/RoverDrive.cs +++ b/Items/Accessories/RoverDrive.cs @@ -11,8 +11,8 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Rover Drive"); Tooltip.SetDefault("Activates a protective shield that grants 15 defense for 10 seconds\n" + - //Actually 10.1 seconds at full power with a dissipation across 0.1666 seconds but whatever - "The shield then dissipates and recharges for 20 seconds before being reactivated"); + //Actually 10.1 seconds at full power with a dissipation across 0.1666 seconds but whatever + "The shield then dissipates and recharges for 20 seconds before being reactivated"); } public override void SetDefaults() diff --git a/Items/Accessories/SamuraiBadge.cs b/Items/Accessories/SamuraiBadge.cs index 55718c4bd7..f8adb024e8 100644 --- a/Items/Accessories/SamuraiBadge.cs +++ b/Items/Accessories/SamuraiBadge.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Warbanner of the Sun"); Tooltip.SetDefault("Increases melee damage, true melee damage and melee speed the closer you are to enemies\n" + - "Max boost is 20% increased melee damage, true melee damage and melee speed"); + "Max boost is 20% increased melee damage, true melee damage and melee speed"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 5)); } @@ -21,10 +21,10 @@ namespace CalamityMod.Items.Accessories { item.width = 32; item.height = 78; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.accessory = true; - } + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.accessory = true; + } public override void UpdateAccessory(Player player, bool hideVisual) { diff --git a/Items/Accessories/SandCloak.cs b/Items/Accessories/SandCloak.cs index 11141aef3a..8e268b3be1 100644 --- a/Items/Accessories/SandCloak.cs +++ b/Items/Accessories/SandCloak.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class SandCloak : ModItem + public class SandCloak : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/SandSharkToothNecklace.cs b/Items/Accessories/SandSharkToothNecklace.cs index c75050eadb..336a3a17c9 100644 --- a/Items/Accessories/SandSharkToothNecklace.cs +++ b/Items/Accessories/SandSharkToothNecklace.cs @@ -24,16 +24,16 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.allDamage += 0.06f; - player.armorPenetration += 10; + player.allDamage += 0.06f; + player.armorPenetration += 10; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.SharkToothNecklace); - recipe.AddIngredient(ItemID.AvengerEmblem); - recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.AvengerEmblem); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.TinkerersWorkbench); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Accessories/ShatteredCommunity.cs b/Items/Accessories/ShatteredCommunity.cs index b74693c010..083af91fd9 100644 --- a/Items/Accessories/ShatteredCommunity.cs +++ b/Items/Accessories/ShatteredCommunity.cs @@ -11,213 +11,213 @@ using Terraria.ModLoader.IO; namespace CalamityMod.Items.Accessories { - public class ShatteredCommunity : ModItem - { - // The percentage of a full Rage bar that is gained every second with the Shattered Community equipped. - public const float RagePerSecond = 0.02f; - private static readonly Color rarityColorOne = new Color(128, 62, 128); - private static readonly Color rarityColorTwo = new Color(245, 105, 245); + public class ShatteredCommunity : ModItem + { + // The percentage of a full Rage bar that is gained every second with the Shattered Community equipped. + public const float RagePerSecond = 0.02f; + private static readonly Color rarityColorOne = new Color(128, 62, 128); + private static readonly Color rarityColorTwo = new Color(245, 105, 245); - // Base level cost is 400,000 damage dealt while Rage is active. - // Each successive level costs (400,000 * level) MORE damage, so the total required goes up quadratically. - // Total required to reach level 60 is 732,000,000 damage dealt. - // This is within one order of magnitude of the integer limit, so relevant values are stored as longs. - private const long BaseLevelCost = 400000L; - private static long LevelCost(int level) => BaseLevelCost * level; - private static long CumulativeLevelCost(int level) => (BaseLevelCost / 2L) * level * (level + 1); - private const int MaxLevel = 25; // was 60. - private const float RageDamagePerLevel = 0.01f; // x1.35 --> x1.60 (used to be x1.95, jesus) + // Base level cost is 400,000 damage dealt while Rage is active. + // Each successive level costs (400,000 * level) MORE damage, so the total required goes up quadratically. + // Total required to reach level 60 is 732,000,000 damage dealt. + // This is within one order of magnitude of the integer limit, so relevant values are stored as longs. + private const long BaseLevelCost = 400000L; + private static long LevelCost(int level) => BaseLevelCost * level; + private static long CumulativeLevelCost(int level) => (BaseLevelCost / 2L) * level * (level + 1); + private const int MaxLevel = 25; // was 60. + private const float RageDamagePerLevel = 0.01f; // x1.35 --> x1.60 (used to be x1.95, jesus) - internal int level = 0; - internal long totalRageDamage = 0L; + internal int level = 0; + internal long totalRageDamage = 0L; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shattered Community"); - Tooltip.SetDefault("Ruined by unknowable hatred, it still contains (most of) the power of The Community...\n" + - "You generate rage over time and rage does not fade away out of combat\n" + - "Taking damage gives rage, this effect is not hindered by your defensive stats\n" + - "While Rage Mode is active, taking damage gives only half as much rage\n" + - "Deal damage with Rage Mode to further empower your wrath\n"); - Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(7, 5)); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shattered Community"); + Tooltip.SetDefault("Ruined by unknowable hatred, it still contains (most of) the power of The Community...\n" + + "You generate rage over time and rage does not fade away out of combat\n" + + "Taking damage gives rage, this effect is not hindered by your defensive stats\n" + + "While Rage Mode is active, taking damage gives only half as much rage\n" + + "Deal damage with Rage Mode to further empower your wrath\n"); + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(7, 5)); + } - public override void SetDefaults() - { - item.width = 20; - item.height = 20; - item.accessory = true; - item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; - item.rare = ItemRarityID.Red; - item.Calamity().customRarity = CalamityRarity.HotPink; - item.Calamity().devItem = true; - } + public override void SetDefaults() + { + item.width = 20; + item.height = 20; + item.accessory = true; + item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.HotPink; + item.Calamity().devItem = true; + } - // Not overriding these Clones makes tooltips fail to function correctly due to HoverItem spaghetti. - public override ModItem Clone() - { - var clone = (ShatteredCommunity)base.Clone(); - clone.level = level; - clone.totalRageDamage = totalRageDamage; - return clone; - } - public override ModItem Clone(Item item) - { - var clone = (ShatteredCommunity)base.Clone(); - clone.level = level; - clone.totalRageDamage = totalRageDamage; - return clone; - } + // Not overriding these Clones makes tooltips fail to function correctly due to HoverItem spaghetti. + public override ModItem Clone() + { + var clone = (ShatteredCommunity)base.Clone(); + clone.level = level; + clone.totalRageDamage = totalRageDamage; + return clone; + } + public override ModItem Clone(Item item) + { + var clone = (ShatteredCommunity)base.Clone(); + clone.level = level; + clone.totalRageDamage = totalRageDamage; + return clone; + } - internal static Color GetRarityColor() => CalamityUtils.ColorSwap(rarityColorOne, rarityColorTwo, 3f); + internal static Color GetRarityColor() => CalamityUtils.ColorSwap(rarityColorOne, rarityColorTwo, 3f); - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.shatteredCommunity = true; + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.shatteredCommunity = true; - // Shattered Community gives (mostly) the same boosts as normal Community - // It does not give melee speed or minion knockback, but always gives life regen (instead of only conditionally) - player.allDamage += 0.1f; - modPlayer.AllCritBoost(5); - player.statDefense += 10; - player.endurance += 0.05f; - player.lifeRegen += 2; - player.moveSpeed += 0.1f; + // Shattered Community gives (mostly) the same boosts as normal Community + // It does not give melee speed or minion knockback, but always gives life regen (instead of only conditionally) + player.allDamage += 0.1f; + modPlayer.AllCritBoost(5); + player.statDefense += 10; + player.endurance += 0.05f; + player.lifeRegen += 2; + player.moveSpeed += 0.1f; - // Shattered Community provides a stacking +1% Rage Mode damage per level. - modPlayer.RageDamageBoost += level * RageDamagePerLevel; - } + // Shattered Community provides a stacking +1% Rage Mode damage per level. + modPlayer.RageDamageBoost += level * RageDamagePerLevel; + } - // Community and Shattered Community are mutually exclusive - public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().community; - public override bool CanUseItem(Player player) => false; + // Community and Shattered Community are mutually exclusive + public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().community; + public override bool CanUseItem(Player player) => false; - // Produces purple light while in the world. - public override void PostUpdate() - { - float brightness = Main.essScale; - Lighting.AddLight(item.Center, 0.92f * brightness, 0.42f * brightness, 0.92f * brightness); - } + // Produces purple light while in the world. + public override void PostUpdate() + { + float brightness = Main.essScale; + Lighting.AddLight(item.Center, 0.92f * brightness, 0.42f * brightness, 0.92f * brightness); + } - internal static void AccumulateRageDamage(Player player, CalamityPlayer mp, long damage) - { - if (!mp.shatteredCommunity) - return; - // Static context, so the item ID has to be retrieved from TML. - int thisItemID = ModContent.ItemType(); - ShatteredCommunity sc = null; + internal static void AccumulateRageDamage(Player player, CalamityPlayer mp, long damage) + { + if (!mp.shatteredCommunity) + return; + // Static context, so the item ID has to be retrieved from TML. + int thisItemID = ModContent.ItemType(); + ShatteredCommunity sc = null; - // First, find the Shattered Community in the player's inventory. - // slots 3, 4, 5, 6, 7, 8, 9 are valid non-vanity accessories - for (int i = 3; i <= 9; ++i) - { - Item acc = player.armor[i]; - if (acc.type == thisItemID) - sc = acc.modItem as ShatteredCommunity; - } + // First, find the Shattered Community in the player's inventory. + // slots 3, 4, 5, 6, 7, 8, 9 are valid non-vanity accessories + for (int i = 3; i <= 9; ++i) + { + Item acc = player.armor[i]; + if (acc.type == thisItemID) + sc = acc.modItem as ShatteredCommunity; + } - // Safety check in case for some reason the equipped Shattered Community isn't found. - if (sc is null) - return; + // Safety check in case for some reason the equipped Shattered Community isn't found. + if (sc is null) + return; - // Actually accumulate the damage. - sc.totalRageDamage += damage; + // Actually accumulate the damage. + sc.totalRageDamage += damage; - // Level up if applicable. - if (sc.level < MaxLevel && sc.totalRageDamage > CumulativeLevelCost(sc.level + 1)) - { - ++sc.level; - sc.LevelUpEffects(player); - } - } + // Level up if applicable. + if (sc.level < MaxLevel && sc.totalRageDamage > CumulativeLevelCost(sc.level + 1)) + { + ++sc.level; + sc.LevelUpEffects(player); + } + } - private void LevelUpEffects(Player player) - { - // Spawn the purple laser beam from failing the Dungeon Defenders event. - int projID = ProjectileID.DD2ElderWins; - Vector2 offset = new Vector2(0f, 800f); // The effect is extremely tall, so start it very low down - Projectile fx = Projectile.NewProjectileDirect(player.Center + offset, Vector2.Zero, projID, 0, 0f, player.whoAmI); - fx.friendly = false; - fx.hostile = false; - // On the 108th update, crystal debris is spawned, so we avoid that. - fx.timeLeft = 107; - fx.MaxUpdates = 2; // Make the animation play at double speed. + private void LevelUpEffects(Player player) + { + // Spawn the purple laser beam from failing the Dungeon Defenders event. + int projID = ProjectileID.DD2ElderWins; + Vector2 offset = new Vector2(0f, 800f); // The effect is extremely tall, so start it very low down + Projectile fx = Projectile.NewProjectileDirect(player.Center + offset, Vector2.Zero, projID, 0, 0f, player.whoAmI); + fx.friendly = false; + fx.hostile = false; + // On the 108th update, crystal debris is spawned, so we avoid that. + fx.timeLeft = 107; + fx.MaxUpdates = 2; // Make the animation play at double speed. - // Play a weird dimensional lightning sound simultaneously. - var extraSound = SoundID.DD2_EtherianPortalDryadTouch.WithVolume(1.4f); - Main.PlaySound(extraSound, player.Center); + // Play a weird dimensional lightning sound simultaneously. + var extraSound = SoundID.DD2_EtherianPortalDryadTouch.WithVolume(1.4f); + Main.PlaySound(extraSound, player.Center); - // Display a level up text notification. - Rectangle textArea = new Rectangle((int)player.Center.X, (int)player.Center.Y, 1, 1); - Color textColor = new Color(236, 209, 236); - CombatText.NewText(textArea, textColor, "The Community cracks...", false, false); - } + // Display a level up text notification. + Rectangle textArea = new Rectangle((int)player.Center.X, (int)player.Center.Y, 1, 1); + Color textColor = new Color(236, 209, 236); + CombatText.NewText(textArea, textColor, "The Community cracks...", false, false); + } - public override void ModifyTooltips(List tooltips) - { - // Stat tooltips are added dynamically. - StringBuilder sb = new StringBuilder(256); + public override void ModifyTooltips(List tooltips) + { + // Stat tooltips are added dynamically. + StringBuilder sb = new StringBuilder(256); - // Line 6: Current level - sb.Append("Current level: "); - sb.Append(level); - sb.Append(" (+"); - sb.Append(level); - sb.Append("% Rage Mode damage)"); - tooltips.Add(new TooltipLine(mod, "Tooltip6", sb.ToString())); - sb.Clear(); + // Line 6: Current level + sb.Append("Current level: "); + sb.Append(level); + sb.Append(" (+"); + sb.Append(level); + sb.Append("% Rage Mode damage)"); + tooltips.Add(new TooltipLine(mod, "Tooltip6", sb.ToString())); + sb.Clear(); - if (level < MaxLevel) - { - long progressToNextLevel = totalRageDamage - CumulativeLevelCost(level); - long totalToNextLevel = LevelCost(level + 1); - double ratio = (double)progressToNextLevel / totalToNextLevel; - string percent = (100D * ratio).ToString("0.00"); + if (level < MaxLevel) + { + long progressToNextLevel = totalRageDamage - CumulativeLevelCost(level); + long totalToNextLevel = LevelCost(level + 1); + double ratio = (double)progressToNextLevel / totalToNextLevel; + string percent = (100D * ratio).ToString("0.00"); - // Line 7: Progress to next level - sb.Append("Progress to next level: "); - sb.Append(percent); - sb.Append('%'); - tooltips.Add(new TooltipLine(mod, "Tooltip7", sb.ToString())); - sb.Clear(); - } + // Line 7: Progress to next level + sb.Append("Progress to next level: "); + sb.Append(percent); + sb.Append('%'); + tooltips.Add(new TooltipLine(mod, "Tooltip7", sb.ToString())); + sb.Clear(); + } - // Line 8: Total damage dealt - sb.Append("Total Rage Mode damage: "); - sb.Append(totalRageDamage); - tooltips.Add(new TooltipLine(mod, "Tooltip8", sb.ToString())); - } + // Line 8: Total damage dealt + sb.Append("Total Rage Mode damage: "); + sb.Append(totalRageDamage); + tooltips.Add(new TooltipLine(mod, "Tooltip8", sb.ToString())); + } - public override TagCompound Save() - { - TagCompound tag = new TagCompound - { - { "level", level }, - { "totalDamage", totalRageDamage } - }; - return tag; - } + public override TagCompound Save() + { + TagCompound tag = new TagCompound + { + { "level", level }, + { "totalDamage", totalRageDamage } + }; + return tag; + } - public override void Load(TagCompound tag) - { - level = tag.GetInt("level"); - // Shattered Community's level cap was reduced from 60 to 25, so cap out ones that were made higher previously. - if (level > MaxLevel) - level = MaxLevel; - totalRageDamage = tag.GetLong("totalDamage"); - } + public override void Load(TagCompound tag) + { + level = tag.GetInt("level"); + // Shattered Community's level cap was reduced from 60 to 25, so cap out ones that were made higher previously. + if (level > MaxLevel) + level = MaxLevel; + totalRageDamage = tag.GetLong("totalDamage"); + } - public override void NetSend(BinaryWriter writer) - { - writer.Write(level); - writer.Write(totalRageDamage); - } + public override void NetSend(BinaryWriter writer) + { + writer.Write(level); + writer.Write(totalRageDamage); + } - public override void NetRecieve(BinaryReader reader) - { - level = reader.ReadInt32(); - totalRageDamage = reader.ReadInt64(); - } - } + public override void NetRecieve(BinaryReader reader) + { + level = reader.ReadInt32(); + totalRageDamage = reader.ReadInt64(); + } + } } diff --git a/Items/Accessories/ShieldoftheOcean.cs b/Items/Accessories/ShieldoftheOcean.cs index 8435061285..d10f6e01ba 100644 --- a/Items/Accessories/ShieldoftheOcean.cs +++ b/Items/Accessories/ShieldoftheOcean.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Shield of the Ocean"); Tooltip.SetDefault("Increased defense by 5 when submerged in liquid\n" + - "Increases movement speed and life regen while wearing the Victide armor"); + "Increases movement speed and life regen while wearing the Victide armor"); } public override void SetDefaults() diff --git a/Items/Accessories/SigilofCalamitas.cs b/Items/Accessories/SigilofCalamitas.cs index da6cedf164..7f0f0c5006 100644 --- a/Items/Accessories/SigilofCalamitas.cs +++ b/Items/Accessories/SigilofCalamitas.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("Sigil of Calamitas"); Tooltip.SetDefault("15% increased magic damage and 10% decreased mana usage\n" + "+100 max mana\n" + - "Increases pickup range for mana stars"); + "Increases pickup range for mana stars"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 8)); } @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.manaMagnet = true; + player.manaMagnet = true; player.statManaMax2 += 100; player.magicDamage += 0.15f; player.manaCost *= 0.9f; @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.CelestialEmblem); + recipe.AddIngredient(ItemID.CelestialEmblem); recipe.AddRecipeGroup("AnyEvilWater", 10); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType(), 5); diff --git a/Items/Accessories/SpectralVeil.cs b/Items/Accessories/SpectralVeil.cs index 42c353f0bd..fd515daa67 100644 --- a/Items/Accessories/SpectralVeil.cs +++ b/Items/Accessories/SpectralVeil.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class SpectralVeil : ModItem + public class SpectralVeil : ModItem { public const float TeleportRange = 845f; public override void SetStaticDefaults() @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Accessories Tooltip.SetDefault("The inside of the cloak is full of teeth...\n" + "TOOLTIP LINE HERE\n" + "If you dodge something while invulnerable, you instantly gain full stealth\n" + - "Teleportation is disabled while Chaos State is active\n" + + "Teleportation is disabled while Chaos State is active\n" + "Stealth generates 20% faster while moving"); } @@ -22,10 +22,10 @@ namespace CalamityMod.Items.Accessories { item.width = 30; item.height = 38; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.accessory = true; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.accessory = true; } public override void ModifyTooltips(List list) diff --git a/Items/Accessories/Sponge.cs b/Items/Accessories/Sponge.cs index 037c8beedf..70def6adf2 100644 --- a/Items/Accessories/Sponge.cs +++ b/Items/Accessories/Sponge.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class Sponge : ModItem + public class Sponge : ModItem { public override string Texture => (DateTime.Now.Month == 4 && DateTime.Now.Day == 1) ? "CalamityMod/Items/Accessories/SpongeReal" : "CalamityMod/Items/Accessories/Sponge"; diff --git a/Items/Accessories/StarTaintedGenerator.cs b/Items/Accessories/StarTaintedGenerator.cs index 776d6a590e..4e2d55e9cf 100644 --- a/Items/Accessories/StarTaintedGenerator.cs +++ b/Items/Accessories/StarTaintedGenerator.cs @@ -11,8 +11,8 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Star-Tainted Generator"); Tooltip.SetDefault("+2 max minions, does not stack with downgrades\n" + - "7% increased minion damage\n" + - "Minion attacks spawn astral explosions and inflict several debuffs"); + "7% increased minion damage\n" + + "Minion attacks spawn astral explosions and inflict several debuffs"); } public override void SetDefaults() @@ -26,9 +26,9 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.Calamity().voltaicJelly = true; - player.Calamity().starbusterCore = true; - player.Calamity().starTaintedGenerator = true; + player.Calamity().voltaicJelly = true; + player.Calamity().starbusterCore = true; + player.Calamity().starTaintedGenerator = true; player.minionDamage += 0.07f; } diff --git a/Items/Accessories/StarbusterCore.cs b/Items/Accessories/StarbusterCore.cs index 21c5430194..f5868364ec 100644 --- a/Items/Accessories/StarbusterCore.cs +++ b/Items/Accessories/StarbusterCore.cs @@ -4,7 +4,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class StarbusterCore : ModItem + public class StarbusterCore : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/StatMeter.cs b/Items/Accessories/StatMeter.cs index 6e9a0085de..d197dfdaa5 100644 --- a/Items/Accessories/StatMeter.cs +++ b/Items/Accessories/StatMeter.cs @@ -8,147 +8,147 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class StatMeter : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Stat Meter"); - Tooltip.SetDefault("Displays almost all player stats"); - } + public class StatMeter : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Stat Meter"); + Tooltip.SetDefault("Displays almost all player stats"); + } - public override void SetDefaults() - { - item.width = 26; - item.height = 26; - item.value = Item.buyPrice(0, 6, 0, 0); - item.rare = ItemRarityID.Blue; - } + public override void SetDefaults() + { + item.width = 26; + item.height = 26; + item.value = Item.buyPrice(0, 6, 0, 0); + item.rare = ItemRarityID.Blue; + } - public override void ModifyTooltips(List list) - { - Player player = Main.player[Main.myPlayer]; - if (player is null) - return; - CalamityPlayer modPlayer = player.Calamity(); + public override void ModifyTooltips(List list) + { + Player player = Main.player[Main.myPlayer]; + if (player is null) + return; + CalamityPlayer modPlayer = player.Calamity(); - Item heldItem = null; - if (player.selectedItem >= 0 && player.selectedItem < Main.maxInventory) - heldItem = player.ActiveItem(); + Item heldItem = null; + if (player.selectedItem >= 0 && player.selectedItem < Main.maxInventory) + heldItem = player.ActiveItem(); - // Replace the vanilla tooltip with a full stat readout - foreach (TooltipLine l in list) - { - if (l.mod == "Terraria" && l.Name == "Tooltip0") - l.text = CreateStatMeterTooltip(player, modPlayer, heldItem); - } + // Replace the vanilla tooltip with a full stat readout + foreach (TooltipLine l in list) + { + if (l.mod == "Terraria" && l.Name == "Tooltip0") + l.text = CreateStatMeterTooltip(player, modPlayer, heldItem); + } - // To save screen space, favorited tooltips do not exist for the Stat Meter - list.RemoveAll(l => l.mod == "Terraria" && (l.Name == "Favorite" || l.Name == "FavoriteDesc")); - } + // To save screen space, favorited tooltips do not exist for the Stat Meter + list.RemoveAll(l => l.mod == "Terraria" && (l.Name == "Favorite" || l.Name == "FavoriteDesc")); + } - private string CreateStatMeterTooltip(Player player, CalamityPlayer modPlayer, Item heldItem) - { - // Un-cancel out defense damage for display in the stat meter. (why cancel it out in the first place then?) - int defense = modPlayer.defenseStat - modPlayer.CurrentDefenseDamage; - int DR = modPlayer.DRStat; - int meleeSpeed = modPlayer.meleeSpeedStat; - int manaCost = modPlayer.manaCostStat; - int rogueVelocity = modPlayer.rogueVelocityStat; - int minionSlots = modPlayer.minionSlotStat; - int ammoConsumption = modPlayer.ammoReductionRanged; - int rogueConsumption = modPlayer.ammoReductionRogue; - int rogueStealth = modPlayer.stealthStat; - // Format the stealth regen statistics to be accurate to 2 decimal places. - string standingRegen = modPlayer.standingRegenStat.ToString("n2"); - string movingRegen = modPlayer.movingRegenStat.ToString("n2"); - int lifeRegen = modPlayer.lifeRegenStat; - int manaRegen = modPlayer.manaRegenStat; - int armorPenetration = modPlayer.armorPenetrationStat; - string wingFlightTime = modPlayer.wingFlightTimeStat.ToString("n2"); - string jumpSpeed = modPlayer.jumpSpeedStat.ToString("n2"); - int moveSpeed = modPlayer.moveSpeedStat; - int lightLevel = modPlayer.abyssLightLevelStat; - int breathLoss = modPlayer.abyssBreathLossStat; - int breathLossRate = modPlayer.abyssBreathLossRateStat; - int lifeLostAtZeroBreath = modPlayer.abyssLifeLostAtZeroBreathStat; - int defenseLoss = modPlayer.abyssDefenseLossStat; + private string CreateStatMeterTooltip(Player player, CalamityPlayer modPlayer, Item heldItem) + { + // Un-cancel out defense damage for display in the stat meter. (why cancel it out in the first place then?) + int defense = modPlayer.defenseStat - modPlayer.CurrentDefenseDamage; + int DR = modPlayer.DRStat; + int meleeSpeed = modPlayer.meleeSpeedStat; + int manaCost = modPlayer.manaCostStat; + int rogueVelocity = modPlayer.rogueVelocityStat; + int minionSlots = modPlayer.minionSlotStat; + int ammoConsumption = modPlayer.ammoReductionRanged; + int rogueConsumption = modPlayer.ammoReductionRogue; + int rogueStealth = modPlayer.stealthStat; + // Format the stealth regen statistics to be accurate to 2 decimal places. + string standingRegen = modPlayer.standingRegenStat.ToString("n2"); + string movingRegen = modPlayer.movingRegenStat.ToString("n2"); + int lifeRegen = modPlayer.lifeRegenStat; + int manaRegen = modPlayer.manaRegenStat; + int armorPenetration = modPlayer.armorPenetrationStat; + string wingFlightTime = modPlayer.wingFlightTimeStat.ToString("n2"); + string jumpSpeed = modPlayer.jumpSpeedStat.ToString("n2"); + int moveSpeed = modPlayer.moveSpeedStat; + int lightLevel = modPlayer.abyssLightLevelStat; + int breathLoss = modPlayer.abyssBreathLossStat; + int breathLossRate = modPlayer.abyssBreathLossRateStat; + int lifeLostAtZeroBreath = modPlayer.abyssLifeLostAtZeroBreathStat; + int defenseLoss = modPlayer.abyssDefenseLossStat; - // The notice about held item mattering is always displayed first. - StringBuilder sb = new StringBuilder("Displays almost all player stats\nOffensive stats displayed vary with held item\n\n", 1024); + // The notice about held item mattering is always displayed first. + StringBuilder sb = new StringBuilder("Displays almost all player stats\nOffensive stats displayed vary with held item\n\n", 1024); - // Only append rippers stats in Rev+, if rippers are enabled. - if (CalamityWorld.revenge) - { - sb.Append("Rage Damage Boost: ").Append(modPlayer.rageDamageStat).Append("%\n"); - sb.Append("Adrenaline Damage Boost: ").Append(modPlayer.adrenalineDamageStat) - .Append("% | Adrenaline DR Boost: ").Append(modPlayer.adrenalineDRStat) - .Append("%\n\n"); - } + // Only append rippers stats in Rev+, if rippers are enabled. + if (CalamityWorld.revenge) + { + sb.Append("Rage Damage Boost: ").Append(modPlayer.rageDamageStat).Append("%\n"); + sb.Append("Adrenaline Damage Boost: ").Append(modPlayer.adrenalineDamageStat) + .Append("% | Adrenaline DR Boost: ").Append(modPlayer.adrenalineDRStat) + .Append("%\n\n"); + } - // Append item stats only if the held item isn't null, and base it off of the item's damage type. - if (heldItem != null && !heldItem.IsAir) - { - if (heldItem.melee) - { - sb.Append("Melee Damage: ").Append(modPlayer.damageStats[0]) - .Append("% | True Melee Damage: ").Append(modPlayer.damageStats[5]) - .Append("% | Melee Crit Chance: ").Append(modPlayer.critStats[0]) - .Append("%\nMelee Speed Boost: ").Append(meleeSpeed).Append("%\n\n"); - } - else if (heldItem.ranged) - { - sb.Append("Ranged Damage: ").Append(modPlayer.damageStats[1]) - .Append("% | Ranged Crit Chance: ").Append(modPlayer.critStats[1]) - .Append("%\nAmmo Consumption Chance: ").Append(ammoConsumption).Append("%\n\n"); - } - else if (heldItem.magic) - { - sb.Append("Magic Damage: ").Append(modPlayer.damageStats[2]) - .Append("% | Magic Crit Chance: ").Append(modPlayer.critStats[2]) - .Append("%\nMana Usage: ").Append(manaCost) - .Append("% | Mana Regen: ").Append(manaRegen).Append("\n\n"); - } - else if (heldItem.summon) - { - sb.Append("Minion Damage: ").Append(modPlayer.damageStats[3]) - .Append("% | Minion Slots: ").Append(minionSlots).Append("\n\n"); - } - else if (heldItem.Calamity()?.rogue ?? false) - { - sb.Append("Rogue Damage: ").Append(modPlayer.damageStats[4]) - .Append("% | Rogue Crit Chance: ").Append(modPlayer.critStats[3]) - .Append("%\nRogue Velocity Boost: ").Append(rogueVelocity) - .Append("% | Rogue Weapon Consumption Chance: ").Append(rogueConsumption) - .Append("%\nMax Stealth: ").Append(rogueStealth) - .Append(" | Standing Regen: ").Append(standingRegen).Append(" / sec") - .Append(" | Moving Regen: ").Append(movingRegen).Append(" / sec") - .Append("\n\n"); - } - } + // Append item stats only if the held item isn't null, and base it off of the item's damage type. + if (heldItem != null && !heldItem.IsAir) + { + if (heldItem.melee) + { + sb.Append("Melee Damage: ").Append(modPlayer.damageStats[0]) + .Append("% | True Melee Damage: ").Append(modPlayer.damageStats[5]) + .Append("% | Melee Crit Chance: ").Append(modPlayer.critStats[0]) + .Append("%\nMelee Speed Boost: ").Append(meleeSpeed).Append("%\n\n"); + } + else if (heldItem.ranged) + { + sb.Append("Ranged Damage: ").Append(modPlayer.damageStats[1]) + .Append("% | Ranged Crit Chance: ").Append(modPlayer.critStats[1]) + .Append("%\nAmmo Consumption Chance: ").Append(ammoConsumption).Append("%\n\n"); + } + else if (heldItem.magic) + { + sb.Append("Magic Damage: ").Append(modPlayer.damageStats[2]) + .Append("% | Magic Crit Chance: ").Append(modPlayer.critStats[2]) + .Append("%\nMana Usage: ").Append(manaCost) + .Append("% | Mana Regen: ").Append(manaRegen).Append("\n\n"); + } + else if (heldItem.summon) + { + sb.Append("Minion Damage: ").Append(modPlayer.damageStats[3]) + .Append("% | Minion Slots: ").Append(minionSlots).Append("\n\n"); + } + else if (heldItem.Calamity()?.rogue ?? false) + { + sb.Append("Rogue Damage: ").Append(modPlayer.damageStats[4]) + .Append("% | Rogue Crit Chance: ").Append(modPlayer.critStats[3]) + .Append("%\nRogue Velocity Boost: ").Append(rogueVelocity) + .Append("% | Rogue Weapon Consumption Chance: ").Append(rogueConsumption) + .Append("%\nMax Stealth: ").Append(rogueStealth) + .Append(" | Standing Regen: ").Append(standingRegen).Append(" / sec") + .Append(" | Moving Regen: ").Append(movingRegen).Append(" / sec") + .Append("\n\n"); + } + } - // Generic stats always render. - sb.Append("Defense: ").Append(defense); - sb.Append(" | DR: ").Append(DR).Append("%"); - sb.Append(" | Life Regen: ").Append(lifeRegen).Append("\n"); - sb.Append("Armor Penetration: ").Append(armorPenetration); - sb.Append(" | Wing Flight Time: ").Append(wingFlightTime).Append(" seconds\n"); - sb.Append("Jump Speed Boost: ").Append(jumpSpeed).Append("%"); - sb.Append(" | Movement Speed Boost: ").Append(moveSpeed).Append("%\n\n"); - sb.Append("Abyss Light Strength: ").Append(lightLevel).Append("\n\n"); + // Generic stats always render. + sb.Append("Defense: ").Append(defense); + sb.Append(" | DR: ").Append(DR).Append("%"); + sb.Append(" | Life Regen: ").Append(lifeRegen).Append("\n"); + sb.Append("Armor Penetration: ").Append(armorPenetration); + sb.Append(" | Wing Flight Time: ").Append(wingFlightTime).Append(" seconds\n"); + sb.Append("Jump Speed Boost: ").Append(jumpSpeed).Append("%"); + sb.Append(" | Movement Speed Boost: ").Append(moveSpeed).Append("%\n\n"); + sb.Append("Abyss Light Strength: ").Append(lightLevel).Append("\n\n"); - // Abyss stats only render if the player is in the Abyss. - if (modPlayer.ZoneAbyss) - { - sb.Append("Other Abyss Stats:").Append("\n"); - sb.Append("Breath Lost Per Tick: ").Append(breathLoss); - sb.Append(" | Breath Loss Rate: ").Append(breathLossRate).Append("\n"); - sb.Append("Life Lost Per Tick at Zero Breath: ").Append(lifeLostAtZeroBreath).Append("\n"); - sb.Append("Defense Lost: ").Append(defenseLoss); - } - else - sb.Append("Other Abyss stats are only displayed while in the Abyss"); + // Abyss stats only render if the player is in the Abyss. + if (modPlayer.ZoneAbyss) + { + sb.Append("Other Abyss Stats:").Append("\n"); + sb.Append("Breath Lost Per Tick: ").Append(breathLoss); + sb.Append(" | Breath Loss Rate: ").Append(breathLossRate).Append("\n"); + sb.Append("Life Lost Per Tick at Zero Breath: ").Append(lifeLostAtZeroBreath).Append("\n"); + sb.Append("Defense Lost: ").Append(defenseLoss); + } + else + sb.Append("Other Abyss stats are only displayed while in the Abyss"); - return sb.ToString(); - } - } + return sb.ToString(); + } + } } diff --git a/Items/Accessories/StatisBeltOfCurses.cs b/Items/Accessories/StatisBeltOfCurses.cs index 8d3e560698..bcb72f5712 100644 --- a/Items/Accessories/StatisBeltOfCurses.cs +++ b/Items/Accessories/StatisBeltOfCurses.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Accessories player.noFallDmg = true; player.blackBelt = true; modPlayer.dashMod = 7; - player.dash = 0; + player.dash = 0; player.spikedBoots = 2; } diff --git a/Items/Accessories/StatisCurse.cs b/Items/Accessories/StatisCurse.cs index 9bab5dab80..609d92068a 100644 --- a/Items/Accessories/StatisCurse.cs +++ b/Items/Accessories/StatisCurse.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Statis' Curse"); Tooltip.SetDefault("Increases max minions by 3, does not stack with downgrades\n" + - "10% increased minion damage\n" + + "10% increased minion damage\n" + "Increased minion knockback\n" + "Minions inflict holy flames and shadowflames on hit"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(8, 4)); diff --git a/Items/Accessories/StatisNinjaBelt.cs b/Items/Accessories/StatisNinjaBelt.cs index c40afaa442..b9de99d3c9 100644 --- a/Items/Accessories/StatisNinjaBelt.cs +++ b/Items/Accessories/StatisNinjaBelt.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Accessories player.extraFall += 35; player.blackBelt = true; player.dash = 1; - player.Calamity().dashMod = 0; + player.Calamity().dashMod = 0; player.spikedBoots = 2; } diff --git a/Items/Accessories/SupremeBaitTackleBoxFishingStation.cs b/Items/Accessories/SupremeBaitTackleBoxFishingStation.cs index fba553d4e2..9836b71b4f 100644 --- a/Items/Accessories/SupremeBaitTackleBoxFishingStation.cs +++ b/Items/Accessories/SupremeBaitTackleBoxFishingStation.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories Tooltip.SetDefault("The ultimate fishing accessory\n" + "Increases fishing skill by 80\n" + "Fishing line will never break and decreases chance of bait consumption\n" + - "Increases chance to catch crates\n" + + "Increases chance to catch crates\n" + "Sonar potion effect"); } @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Accessories player.fishingSkill += 80; player.accFishingLine = true; player.accTackleBox = true; - player.Calamity().fishingStation = true; + player.Calamity().fishingStation = true; player.sonarPotion = true; } diff --git a/Items/Accessories/TheAbsorber.cs b/Items/Accessories/TheAbsorber.cs index 829cbec3ef..22935e4147 100644 --- a/Items/Accessories/TheAbsorber.cs +++ b/Items/Accessories/TheAbsorber.cs @@ -32,10 +32,10 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } - public override void UpdateAccessory(Player player, bool hideVisual) + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - // Removed Giant Shell speed boost from The Absorber + // Removed Giant Shell speed boost from The Absorber // modPlayer.gShell = true; modPlayer.fCarapace = true; modPlayer.seaShell = true; diff --git a/Items/Accessories/TheAmalgam.cs b/Items/Accessories/TheAmalgam.cs index 8da5f0a3dc..05185a3554 100644 --- a/Items/Accessories/TheAmalgam.cs +++ b/Items/Accessories/TheAmalgam.cs @@ -10,65 +10,65 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Accessories { - public class TheAmalgam : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Amalgam"); - Tooltip.SetDefault("Extends the duration of potion buffs by 100% and potion buffs remain active even after you die\n" + - "15% increased damage\n" + - "Shade rains down when you are hit\n" + - "Nearby enemies receive a variety of debuffs when you are hit"); - Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(9, 6)); - } + public class TheAmalgam : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("The Amalgam"); + Tooltip.SetDefault("Extends the duration of potion buffs by 100% and potion buffs remain active even after you die\n" + + "15% increased damage\n" + + "Shade rains down when you are hit\n" + + "Nearby enemies receive a variety of debuffs when you are hit"); + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(9, 6)); + } - public override void SetDefaults() - { - item.width = 34; - item.height = 34; - item.accessory = true; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.rare = ItemRarityID.Purple; - } + public override void SetDefaults() + { + item.width = 34; + item.height = 34; + item.accessory = true; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.rare = ItemRarityID.Purple; + } - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.amalgam = true; - player.allDamage += 0.15f; + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.amalgam = true; + player.allDamage += 0.15f; - if (player.immune) - { - if (player.miscCounter % 6 == 0) - { - if (player.whoAmI == Main.myPlayer) - { - Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileType(), (int)(300 * player.AverageDamage()), 2f, player.whoAmI); - if (rain.whoAmI.WithinBounds(Main.maxProjectiles)) - { - rain.Calamity().forceTypeless = true; - rain.tileCollide = false; - rain.penetrate = 1; - } - } - } - } - } + if (player.immune) + { + if (player.miscCounter % 6 == 0) + { + if (player.whoAmI == Main.myPlayer) + { + Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileType(), (int)(300 * player.AverageDamage()), 2f, player.whoAmI); + if (rain.whoAmI.WithinBounds(Main.maxProjectiles)) + { + rain.Calamity().forceTypeless = true; + rain.tileCollide = false; + rain.penetrate = 1; + } + } + } + } + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemType()); - recipe.AddIngredient(ItemType(), 5); - recipe.AddIngredient(ItemType(), 10); - recipe.AddIngredient(ItemType(), 15); - recipe.AddIngredient(ItemType(), 15); - recipe.AddIngredient(ItemType(), 5); - recipe.AddIngredient(ItemType(), 4); - recipe.AddTile(TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType(), 5); + recipe.AddIngredient(ItemType(), 10); + recipe.AddIngredient(ItemType(), 15); + recipe.AddIngredient(ItemType(), 15); + recipe.AddIngredient(ItemType(), 5); + recipe.AddIngredient(ItemType(), 4); + recipe.AddTile(TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Accessories/TheBee.cs b/Items/Accessories/TheBee.cs index 6b5ff2be5b..5c7fa10acc 100644 --- a/Items/Accessories/TheBee.cs +++ b/Items/Accessories/TheBee.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("The Bee"); Tooltip.SetDefault("When at full HP, your damage is increased based on your damage reduction\n" + "Damage taken at full HP is halved\n" + - "This has a 10 second cooldown"); + "This has a 10 second cooldown"); } public override void SetDefaults() @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Accessories item.value = CalamityGlobalItem.Rarity3BuyPrice; item.rare = ItemRarityID.Orange; item.accessory = true; - } + } public override void UpdateAccessory(Player player, bool hideVisual) { diff --git a/Items/Accessories/TheCamper.cs b/Items/Accessories/TheCamper.cs index efc090da96..c3d8d3d808 100644 --- a/Items/Accessories/TheCamper.cs +++ b/Items/Accessories/TheCamper.cs @@ -7,8 +7,8 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - //Dedicated to Dzicozan - [AutoloadEquip(EquipType.Back)] + //Dedicated to Dzicozan + [AutoloadEquip(EquipType.Back)] public class TheCamper : ModItem { int auraCounter = 0; @@ -17,11 +17,11 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("The Camper"); Tooltip.SetDefault("In rest may we find victory.\n" + - "You deal 90% less damage unless stationary\n" + + "You deal 90% less damage unless stationary\n" + "Standing still grants buff(s) dependent on what weapon you're holding\n" + "Standing still provides a damaging aura around you\n" + "While moving, you regenerate health as if standing still\n" + - "Provides a small amount of light in the Abyss"); + "Provides a small amount of light in the Abyss"); } public override void SetDefaults() diff --git a/Items/Accessories/TheCommunity.cs b/Items/Accessories/TheCommunity.cs index 45dc614994..fb91a85183 100644 --- a/Items/Accessories/TheCommunity.cs +++ b/Items/Accessories/TheCommunity.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Accessories item.rare = ItemRarityID.Lime; item.accessory = true; item.Calamity().customRarity = CalamityRarity.Rainbow; - } + } public override void UpdateAccessory(Player player, bool hideVisual) { @@ -37,5 +37,5 @@ namespace CalamityMod.Items.Accessories // Community and Shattered Community are mutually exclusive public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().shatteredCommunity; - } + } } diff --git a/Items/Accessories/TheEvolution.cs b/Items/Accessories/TheEvolution.cs index dd0af649bf..794c26d991 100644 --- a/Items/Accessories/TheEvolution.cs +++ b/Items/Accessories/TheEvolution.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Items.Accessories { item.width = 58; item.height = 44; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.rare = ItemRarityID.Purple; - item.accessory = true; - } + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.rare = ItemRarityID.Purple; + item.accessory = true; + } public override void UpdateAccessory(Player player, bool hideVisual) { diff --git a/Items/Accessories/TheTransformer.cs b/Items/Accessories/TheTransformer.cs index ad88d82c11..8167fa2ac1 100644 --- a/Items/Accessories/TheTransformer.cs +++ b/Items/Accessories/TheTransformer.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Accessories item.value = CalamityGlobalItem.Rarity4BuyPrice; item.rare = ItemRarityID.LightRed; item.accessory = true; - } + } public override void UpdateAccessory(Player player, bool hideVisual) { diff --git a/Items/Accessories/ToxicHeart.cs b/Items/Accessories/ToxicHeart.cs index 8d2cf784c9..4c8c39dae6 100644 --- a/Items/Accessories/ToxicHeart.cs +++ b/Items/Accessories/ToxicHeart.cs @@ -8,7 +8,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class ToxicHeart : ModItem + public class ToxicHeart : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/Vanity/Popo.cs b/Items/Accessories/Vanity/Popo.cs index 09adc3b90e..71c6927386 100644 --- a/Items/Accessories/Vanity/Popo.cs +++ b/Items/Accessories/Vanity/Popo.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Vanity { - public class Popo : ModItem + public class Popo : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/VitalJelly.cs b/Items/Accessories/VitalJelly.cs index 371fe120f5..5853ae1dca 100644 --- a/Items/Accessories/VitalJelly.cs +++ b/Items/Accessories/VitalJelly.cs @@ -4,7 +4,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class VitalJelly : ModItem + public class VitalJelly : ModItem { public override void SetStaticDefaults() { @@ -16,9 +16,9 @@ namespace CalamityMod.Items.Accessories { item.width = 20; item.height = 24; - item.value = CalamityGlobalItem.Rarity1BuyPrice; - item.rare = ItemRarityID.Blue; - item.accessory = true; + item.value = CalamityGlobalItem.Rarity1BuyPrice; + item.rare = ItemRarityID.Blue; + item.accessory = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/VoidofExtinction.cs b/Items/Accessories/VoidofExtinction.cs index 0846c4c804..cdadc86858 100644 --- a/Items/Accessories/VoidofExtinction.cs +++ b/Items/Accessories/VoidofExtinction.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class VoidofExtinction : ModItem + public class VoidofExtinction : ModItem { public const int FireProjectiles = 2; public const float FireAngleSpread = 120; @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.calamityRing = true; - modPlayer.voidOfExtinction = true; + modPlayer.voidOfExtinction = true; player.lavaRose = true; player.lavaMax += 240; player.allDamage += 0.15f; @@ -66,12 +66,12 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - Projectile fire = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(30 * player.AverageDamage()), 5f, player.whoAmI); - if (fire.whoAmI.WithinBounds(Main.maxProjectiles)) - { - fire.usesLocalNPCImmunity = true; - fire.localNPCHitCooldown = 60; - } + Projectile fire = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(30 * player.AverageDamage()), 5f, player.whoAmI); + if (fire.whoAmI.WithinBounds(Main.maxProjectiles)) + { + fire.usesLocalNPCImmunity = true; + fire.localNPCHitCooldown = 60; + } } } } diff --git a/Items/Accessories/VoltaicJelly.cs b/Items/Accessories/VoltaicJelly.cs index ce6bfcc74d..4aa12fd87e 100644 --- a/Items/Accessories/VoltaicJelly.cs +++ b/Items/Accessories/VoltaicJelly.cs @@ -4,13 +4,13 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class VoltaicJelly : ModItem + public class VoltaicJelly : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Voltaic Jelly"); Tooltip.SetDefault("+1 max minions\n" + - "Minion attacks inflict Electrified"); + "Minion attacks inflict Electrified"); } public override void SetDefaults() @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.Calamity().voltaicJelly = true; + player.Calamity().voltaicJelly = true; } } } diff --git a/Items/Accessories/Wings/AureateWings.cs b/Items/Accessories/Wings/AureateWings.cs index 2e5e9abd74..0b2f652353 100644 --- a/Items/Accessories/Wings/AureateWings.cs +++ b/Items/Accessories/Wings/AureateWings.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Accessories.Wings { if ((player.armor[0].type == ModContent.ItemType() || player.armor[0].type == ModContent.ItemType() || player.armor[0].type == ModContent.ItemType()) && player.armor[1].type == ModContent.ItemType() && - player.armor[2].type == ModContent.ItemType()) + player.armor[2].type == ModContent.ItemType()) { player.moveSpeed += 0.1f; } diff --git a/Items/Accessories/Wings/CelestialTracers.cs b/Items/Accessories/Wings/CelestialTracers.cs index f83c2d46c0..4761f031ab 100644 --- a/Items/Accessories/Wings/CelestialTracers.cs +++ b/Items/Accessories/Wings/CelestialTracers.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Wings { - [AutoloadEquip(EquipType.Wings)] + [AutoloadEquip(EquipType.Wings)] public class CelestialTracers : ModItem { public override void SetStaticDefaults() diff --git a/Items/Accessories/Wings/ElysianTracers.cs b/Items/Accessories/Wings/ElysianTracers.cs index 139d7df8a2..6d926205e3 100644 --- a/Items/Accessories/Wings/ElysianTracers.cs +++ b/Items/Accessories/Wings/ElysianTracers.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Wings { - [AutoloadEquip(EquipType.Wings)] + [AutoloadEquip(EquipType.Wings)] public class ElysianTracers : ModItem { public override void SetStaticDefaults() diff --git a/Items/Accessories/Wings/ElysianWings.cs b/Items/Accessories/Wings/ElysianWings.cs index 1777a285f6..36655e7bb8 100644 --- a/Items/Accessories/Wings/ElysianWings.cs +++ b/Items/Accessories/Wings/ElysianWings.cs @@ -5,18 +5,18 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Wings { - [AutoloadEquip(EquipType.Wings)] + [AutoloadEquip(EquipType.Wings)] public class ElysianWings : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Elysian Wings"); Tooltip.SetDefault("Blessed by the Profaned Flame\n" + - "Horizontal speed: 9.75\n" + + "Horizontal speed: 9.75\n" + "Acceleration multiplier: 2.7\n" + "Great vertical speed\n" + "Flight time: 240\n" + - "Temporary immunity to lava and 10% increased movement speed"); + "Temporary immunity to lava and 10% increased movement speed"); } public override void SetDefaults() @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Accessories.Wings item.width = 36; item.height = 32; item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; + item.rare = ItemRarityID.Purple; item.Calamity().customRarity = CalamityRarity.Turquoise; item.accessory = true; } diff --git a/Items/Accessories/Wings/InfinityBoots.cs b/Items/Accessories/Wings/InfinityBoots.cs index 6391eee244..5bc92c9d91 100644 --- a/Items/Accessories/Wings/InfinityBoots.cs +++ b/Items/Accessories/Wings/InfinityBoots.cs @@ -8,14 +8,14 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Wings { - [AutoloadEquip(EquipType.Wings, EquipType.Shoes)] + [AutoloadEquip(EquipType.Wings, EquipType.Shoes)] public class InfinityBoots : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Seraph Tracers"); Tooltip.SetDefault("Ludicrous speed!\n" + - "Counts as wings\n" + + "Counts as wings\n" + "Horizontal speed: 9.00\n" + "Acceleration multiplier: 2.5\n" + "Good vertical speed\n" + diff --git a/Items/Accessories/Wings/SkylineWings.cs b/Items/Accessories/Wings/SkylineWings.cs index 88360e382e..0ccb14f11a 100644 --- a/Items/Accessories/Wings/SkylineWings.cs +++ b/Items/Accessories/Wings/SkylineWings.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Accessories.Wings "Acceleration multiplier: 1.0\n" + "Average vertical speed\n" + "Flight time: 80\n" + - "10% increased jump speed while wearing the Aerospec armor"); + "10% increased jump speed while wearing the Aerospec armor"); } public override void SetDefaults() @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Accessories.Wings player.armor[0].type == ModContent.ItemType()) && player.armor[1].type == ModContent.ItemType() && player.armor[2].type == ModContent.ItemType()) { - player.jumpSpeedBoost += 0.5f; + player.jumpSpeedBoost += 0.5f; } player.wingTimeMax = 80; player.noFallDmg = true; diff --git a/Items/Accessories/Wings/SoulofCryogen.cs b/Items/Accessories/Wings/SoulofCryogen.cs index 57ec276613..d7683f56cf 100644 --- a/Items/Accessories/Wings/SoulofCryogen.cs +++ b/Items/Accessories/Wings/SoulofCryogen.cs @@ -7,7 +7,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories.Wings { - [AutoloadEquip(EquipType.Wings)] + [AutoloadEquip(EquipType.Wings)] public class SoulofCryogen : ModItem { public override void SetStaticDefaults() @@ -62,19 +62,19 @@ namespace CalamityMod.Items.Accessories.Wings player.allDamage += 0.07f; player.wingTimeMax = 120; player.noFallDmg = true; - if (modPlayer.icicleCooldown <= 0) - { - if (player.controlJump && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !player.mount.Active && !player.mount.Cart) - { - int p = Projectile.NewProjectile(player.Center.X, player.Center.Y, player.velocity.X * 0f, 2f, ModContent.ProjectileType(), (int)(25 * player.AverageDamage()), 3f, player.whoAmI, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[p].Calamity().forceTypeless = true; - Main.projectile[p].frame = Main.rand.Next(5); - } - modPlayer.icicleCooldown = 10; - } - } + if (modPlayer.icicleCooldown <= 0) + { + if (player.controlJump && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !player.mount.Active && !player.mount.Cart) + { + int p = Projectile.NewProjectile(player.Center.X, player.Center.Y, player.velocity.X * 0f, 2f, ModContent.ProjectileType(), (int)(25 * player.AverageDamage()), 3f, player.whoAmI, 1f); + if (p.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[p].Calamity().forceTypeless = true; + Main.projectile[p].frame = Main.rand.Next(5); + } + modPlayer.icicleCooldown = 10; + } + } } } } diff --git a/Items/Accessories/Wings/TarragonWings.cs b/Items/Accessories/Wings/TarragonWings.cs index b12d8bbaa7..91f9fec7dc 100644 --- a/Items/Accessories/Wings/TarragonWings.cs +++ b/Items/Accessories/Wings/TarragonWings.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Wings { - [AutoloadEquip(EquipType.Wings)] + [AutoloadEquip(EquipType.Wings)] public class TarragonWings : ModItem { public override void SetStaticDefaults() @@ -27,9 +27,9 @@ namespace CalamityMod.Items.Accessories.Wings { item.width = 22; item.height = 20; - item.rare = ItemRarityID.Purple; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.Calamity().customRarity = CalamityRarity.Turquoise; + item.rare = ItemRarityID.Purple; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.Calamity().customRarity = CalamityRarity.Turquoise; item.accessory = true; } diff --git a/Items/Accessories/WulfrumBattery.cs b/Items/Accessories/WulfrumBattery.cs index 64e0ab82a0..d8313e4a25 100644 --- a/Items/Accessories/WulfrumBattery.cs +++ b/Items/Accessories/WulfrumBattery.cs @@ -4,7 +4,7 @@ using Terraria.ID; namespace CalamityMod.Items.Accessories { - public class WulfrumBattery : ModItem + public class WulfrumBattery : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Accessories/YharimsGift.cs b/Items/Accessories/YharimsGift.cs index 1a6dbce491..7633ad650c 100644 --- a/Items/Accessories/YharimsGift.cs +++ b/Items/Accessories/YharimsGift.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - item.defense = 30; + item.defense = 30; item.width = 20; item.height = 22; item.accessory = true; @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.moveSpeed += 0.15f; + player.moveSpeed += 0.15f; player.allDamage += 0.15f; if (!player.StandingStill()) { @@ -53,11 +53,11 @@ namespace CalamityMod.Items.Accessories } if (player.immune) { - if (player.miscCounter % 8 == 0) - { + if (player.miscCounter % 8 == 0) + { if (player.whoAmI == Main.myPlayer) { - CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(375 * player.AverageDamage()), 9f, player.whoAmI); + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(375 * player.AverageDamage()), 9f, player.whoAmI); } } } diff --git a/Items/Accessories/YharimsInsignia.cs b/Items/Accessories/YharimsInsignia.cs index 216a2a4a71..8dabba636b 100644 --- a/Items/Accessories/YharimsInsignia.cs +++ b/Items/Accessories/YharimsInsignia.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class YharimsInsignia : ModItem + public class YharimsInsignia : ModItem { public override void SetStaticDefaults() { @@ -23,8 +23,8 @@ namespace CalamityMod.Items.Accessories { item.width = 22; item.height = 38; - item.rare = ItemRarityID.Purple; - item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.value = CalamityGlobalItem.Rarity12BuyPrice; item.accessory = true; item.Calamity().customRarity = CalamityRarity.Turquoise; } @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Accessories recipe.AddIngredient(ItemID.WarriorEmblem); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Ammo/AstralSolution.cs b/Items/Ammo/AstralSolution.cs index 14d90056a7..33e4e9eb3a 100644 --- a/Items/Ammo/AstralSolution.cs +++ b/Items/Ammo/AstralSolution.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Ammo { DisplayName.SetDefault("Astral Solution"); Tooltip.SetDefault("Used by the Clentaminator\n" + - "Spreads the Astral Infection"); + "Spreads the Astral Infection"); } public override void SetDefaults() diff --git a/Items/Ammo/BloodfireArrow.cs b/Items/Ammo/BloodfireArrow.cs index 83ac8acb8f..cbb76dbae1 100644 --- a/Items/Ammo/BloodfireArrow.cs +++ b/Items/Ammo/BloodfireArrow.cs @@ -24,9 +24,9 @@ namespace CalamityMod.Items.Ammo item.consumable = true; item.knockBack = 3.5f; item.value = Item.sellPrice(copper: 24); - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.shoot = ModContent.ProjectileType(); + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; item.ammo = AmmoID.Arrow; } diff --git a/Items/Ammo/BloodfireBullet.cs b/Items/Ammo/BloodfireBullet.cs index b565ccc313..b5cf71331d 100644 --- a/Items/Ammo/BloodfireBullet.cs +++ b/Items/Ammo/BloodfireBullet.cs @@ -6,38 +6,38 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Ammo { - public class BloodfireBullet : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bloodfire Bullet"); - Tooltip.SetDefault("Accelerates your life regeneration on hit\n" + "Deals bonus damage based on your current life regeneration"); - } + public class BloodfireBullet : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bloodfire Bullet"); + Tooltip.SetDefault("Accelerates your life regeneration on hit\n" + "Deals bonus damage based on your current life regeneration"); + } - public override void SetDefaults() - { - item.damage = 26; - item.ranged = true; - item.width = 14; - item.height = 30; - item.maxStack = 999; - item.consumable = true; - item.knockBack = 4.5f; - item.value = Item.sellPrice(copper: 24); - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 4.8f; - item.ammo = ItemID.MusketBall; - } + public override void SetDefaults() + { + item.damage = 26; + item.ranged = true; + item.width = 14; + item.height = 30; + item.maxStack = 999; + item.consumable = true; + item.knockBack = 4.5f; + item.value = Item.sellPrice(copper: 24); + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 4.8f; + item.ammo = ItemID.MusketBall; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this, 333); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this, 333); + recipe.AddRecipe(); + } + } } diff --git a/Items/Ammo/ElysianArrow.cs b/Items/Ammo/ElysianArrow.cs index 15d0673ea7..b25114767b 100644 --- a/Items/Ammo/ElysianArrow.cs +++ b/Items/Ammo/ElysianArrow.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Ammo item.knockBack = 3f; item.value = Item.sellPrice(copper: 24); item.rare = ItemRarityID.Purple; - item.shoot = ModContent.ProjectileType(); + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; item.ammo = AmmoID.Arrow; } diff --git a/Items/Ammo/VeriumBullet.cs b/Items/Ammo/VeriumBullet.cs index 57265e0282..f9b2d277dd 100644 --- a/Items/Ammo/VeriumBullet.cs +++ b/Items/Ammo/VeriumBullet.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Ammo { DisplayName.SetDefault("Verium Bullet"); Tooltip.SetDefault("There is no escape!\n" + - "Homes in after striking an enemy"); + "Homes in after striking an enemy"); } public override void SetDefaults() diff --git a/Items/AntiCystOintment.cs b/Items/AntiCystOintment.cs index 82c90024f5..1f07375ec6 100644 --- a/Items/AntiCystOintment.cs +++ b/Items/AntiCystOintment.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Items public override void UpdateInventory(Player player) { - if (item.favorited) - player.Calamity().disablePerfCystSpawns = true; + if (item.favorited) + player.Calamity().disablePerfCystSpawns = true; } public override void AddRecipes() diff --git a/Items/AntiTumorOintment.cs b/Items/AntiTumorOintment.cs index d0a76378da..6a7fcaba2e 100644 --- a/Items/AntiTumorOintment.cs +++ b/Items/AntiTumorOintment.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Items public override void UpdateInventory(Player player) { - if (item.favorited) - player.Calamity().disableHiveCystSpawns = true; + if (item.favorited) + player.Calamity().disableHiveCystSpawns = true; } public override void AddRecipes() diff --git a/Items/Armor/AerospecHelm.cs b/Items/Armor/AerospecHelm.cs index 24031bf422..52ee8df54d 100644 --- a/Items/Armor/AerospecHelm.cs +++ b/Items/Armor/AerospecHelm.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { player.setBonus = "5% increased movement speed and melee critical strike chance\n" + - "Enemies are more likely to target you\n" + + "Enemies are more likely to target you\n" + "Taking over 25 damage in one hit will cause a spread of homing feathers to fall\n" + "Allows you to fall more quickly and disables fall damage"; CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Armor/AerospecHelmet.cs b/Items/Armor/AerospecHelmet.cs index 7732140259..09d8d83294 100644 --- a/Items/Armor/AerospecHelmet.cs +++ b/Items/Armor/AerospecHelmet.cs @@ -58,10 +58,10 @@ namespace CalamityMod.Items.Armor } } player.minionDamage += 0.11f; - player.maxMinions++; - } + player.maxMinions++; + } - public override void UpdateEquip(Player player) + public override void UpdateEquip(Player player) { player.moveSpeed += 0.05f; player.minionDamage += 0.05f; diff --git a/Items/Armor/AstralBreastplate.cs b/Items/Armor/AstralBreastplate.cs index 0d100aada4..3faabca2f3 100644 --- a/Items/Armor/AstralBreastplate.cs +++ b/Items/Armor/AstralBreastplate.cs @@ -35,8 +35,8 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ItemID.MeteoriteBar, 9); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddIngredient(ItemID.MeteoriteBar, 9); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/AstralHelm.cs b/Items/Armor/AstralHelm.cs index 36a47d4b32..3e74e26a5e 100644 --- a/Items/Armor/AstralHelm.cs +++ b/Items/Armor/AstralHelm.cs @@ -44,8 +44,8 @@ namespace CalamityMod.Items.Armor modPlayer.astralStarRain = true; player.moveSpeed += 0.05f; player.allDamage += 0.35f; - player.maxMinions += 3; - modPlayer.AllCritBoost(25); + player.maxMinions += 3; + modPlayer.AllCritBoost(25); player.Calamity().wearingRogueArmor = true; } @@ -58,8 +58,8 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ItemID.MeteoriteBar, 6); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddIngredient(ItemID.MeteoriteBar, 6); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/AstralLeggings.cs b/Items/Armor/AstralLeggings.cs index a6e466880c..227431768f 100644 --- a/Items/Armor/AstralLeggings.cs +++ b/Items/Armor/AstralLeggings.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ItemID.MeteoriteBar, 8); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddIngredient(ItemID.MeteoriteBar, 8); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/AtaxiaArmor.cs b/Items/Armor/AtaxiaArmor.cs index db59cf8eef..ecede12582 100644 --- a/Items/Armor/AtaxiaArmor.cs +++ b/Items/Armor/AtaxiaArmor.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ItemID.HellstoneBar, 8); - recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.HellstoneBar, 8); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/AtaxiaHeadgear.cs b/Items/Armor/AtaxiaHeadgear.cs index 65022dc5b0..540b0a7e00 100644 --- a/Items/Armor/AtaxiaHeadgear.cs +++ b/Items/Armor/AtaxiaHeadgear.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class AtaxiaHeadgear : ModItem { public override void SetStaticDefaults() @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Armor public override void ArmorSetShadows(Player player) { player.armorEffectDrawOutlines = true; - player.Calamity().hydrothermalSmoke = true; + player.Calamity().hydrothermalSmoke = true; } public override void UpdateArmorSet(Player player) @@ -61,9 +61,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 7); - recipe.AddIngredient(ItemID.HellstoneBar, 4); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.HellstoneBar, 4); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/AtaxiaHelm.cs b/Items/Armor/AtaxiaHelm.cs index b03230481f..8b9b902d4e 100644 --- a/Items/Armor/AtaxiaHelm.cs +++ b/Items/Armor/AtaxiaHelm.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class AtaxiaHelm : ModItem { public override void SetStaticDefaults() @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Armor public override void ArmorSetShadows(Player player) { player.armorEffectDrawOutlines = true; - player.Calamity().hydrothermalSmoke = true; + player.Calamity().hydrothermalSmoke = true; } public override void UpdateArmorSet(Player player) @@ -67,9 +67,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 7); - recipe.AddIngredient(ItemID.HellstoneBar, 4); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.HellstoneBar, 4); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/AtaxiaHelmet.cs b/Items/Armor/AtaxiaHelmet.cs index 900a652c6f..b661e812e8 100644 --- a/Items/Armor/AtaxiaHelmet.cs +++ b/Items/Armor/AtaxiaHelmet.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class AtaxiaHelmet : ModItem { public override void SetStaticDefaults() @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Armor public override void ArmorSetShadows(Player player) { player.armorEffectDrawOutlines = true; - player.Calamity().hydrothermalSmoke = true; + player.Calamity().hydrothermalSmoke = true; } public override void UpdateArmorSet(Player player) @@ -59,10 +59,10 @@ namespace CalamityMod.Items.Armor } } player.minionDamage += 0.4f; - player.maxMinions += 2; - } + player.maxMinions += 2; + } - public override void UpdateEquip(Player player) + public override void UpdateEquip(Player player) { player.minionDamage += 0.05f; player.minionKB += 1.5f; @@ -74,9 +74,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 7); - recipe.AddIngredient(ItemID.HellstoneBar, 4); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.HellstoneBar, 4); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/AtaxiaHood.cs b/Items/Armor/AtaxiaHood.cs index 572b27adce..584d210e0d 100644 --- a/Items/Armor/AtaxiaHood.cs +++ b/Items/Armor/AtaxiaHood.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class AtaxiaHood : ModItem { public override void SetStaticDefaults() @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Armor public override void ArmorSetShadows(Player player) { player.armorEffectDrawOutlines = true; - player.Calamity().hydrothermalSmoke = true; + player.Calamity().hydrothermalSmoke = true; } public override void UpdateArmorSet(Player player) @@ -69,9 +69,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 7); - recipe.AddIngredient(ItemID.HellstoneBar, 4); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.HellstoneBar, 4); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/AtaxiaMask.cs b/Items/Armor/AtaxiaMask.cs index 76872b1318..68eec6f1fc 100644 --- a/Items/Armor/AtaxiaMask.cs +++ b/Items/Armor/AtaxiaMask.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class AtaxiaMask : ModItem { public override void SetStaticDefaults() @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Armor public override void ArmorSetShadows(Player player) { player.armorEffectDrawOutlines = true; - player.Calamity().hydrothermalSmoke = true; + player.Calamity().hydrothermalSmoke = true; } public override void UpdateArmorSet(Player player) @@ -62,9 +62,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 7); - recipe.AddIngredient(ItemID.HellstoneBar, 4); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.HellstoneBar, 4); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/AtaxiaSubligar.cs b/Items/Armor/AtaxiaSubligar.cs index 65566a9654..e306dc7655 100644 --- a/Items/Armor/AtaxiaSubligar.cs +++ b/Items/Armor/AtaxiaSubligar.cs @@ -26,17 +26,17 @@ namespace CalamityMod.Items.Armor public override void UpdateEquip(Player player) { - player.Calamity().AllCritBoost(5); - player.moveSpeed += 0.1f; + player.Calamity().AllCritBoost(5); + player.moveSpeed += 0.1f; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ItemID.HellstoneBar, 5); - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.HellstoneBar, 5); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/AuricTeslaBodyArmor.cs b/Items/Armor/AuricTeslaBodyArmor.cs index e7722fa170..54c7f3df62 100644 --- a/Items/Armor/AuricTeslaBodyArmor.cs +++ b/Items/Armor/AuricTeslaBodyArmor.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Body)] + [AutoloadEquip(EquipType.Body)] public class AuricTeslaBodyArmor : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/AuricTeslaHelm.cs b/Items/Armor/AuricTeslaHelm.cs index 908df2efb5..e42b960496 100644 --- a/Items/Armor/AuricTeslaHelm.cs +++ b/Items/Armor/AuricTeslaHelm.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class AuricTeslaHelm : ModItem { public override void SetStaticDefaults() @@ -60,9 +60,9 @@ namespace CalamityMod.Items.Armor player.lifeRegen += 10; } - if (modPlayer.godSlayerDashHotKeyPressed) - modPlayer.dashMod = 9; - } + if (modPlayer.godSlayerDashHotKeyPressed) + modPlayer.dashMod = 9; + } public override void UpdateEquip(Player player) { diff --git a/Items/Armor/AuricTeslaHoodedFacemask.cs b/Items/Armor/AuricTeslaHoodedFacemask.cs index a050a7ef89..35a2a704be 100644 --- a/Items/Armor/AuricTeslaHoodedFacemask.cs +++ b/Items/Armor/AuricTeslaHoodedFacemask.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class AuricTeslaHoodedFacemask : ModItem { public override void SetStaticDefaults() @@ -58,9 +58,9 @@ namespace CalamityMod.Items.Armor player.lifeRegen += 10; } - if (modPlayer.godSlayerDashHotKeyPressed) - modPlayer.dashMod = 9; - } + if (modPlayer.godSlayerDashHotKeyPressed) + modPlayer.dashMod = 9; + } public override void UpdateEquip(Player player) { diff --git a/Items/Armor/AuricTeslaSpaceHelmet.cs b/Items/Armor/AuricTeslaSpaceHelmet.cs index 4ee504f086..5077a530e9 100644 --- a/Items/Armor/AuricTeslaSpaceHelmet.cs +++ b/Items/Armor/AuricTeslaSpaceHelmet.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class AuricTeslaSpaceHelmet : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/BloodflareBodyArmor.cs b/Items/Armor/BloodflareBodyArmor.cs index 231f65334a..f3ec7e1f44 100644 --- a/Items/Armor/BloodflareBodyArmor.cs +++ b/Items/Armor/BloodflareBodyArmor.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Armor ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 16); recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/BloodflareCuisses.cs b/Items/Armor/BloodflareCuisses.cs index df9f39173c..72677e0e3b 100644 --- a/Items/Armor/BloodflareCuisses.cs +++ b/Items/Armor/BloodflareCuisses.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Armor ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 13); recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/BloodflareHelm.cs b/Items/Armor/BloodflareHelm.cs index f9fdb92211..6f82f98d05 100644 --- a/Items/Armor/BloodflareHelm.cs +++ b/Items/Armor/BloodflareHelm.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class BloodflareHelm : ModItem { public override void SetStaticDefaults() @@ -43,9 +43,9 @@ namespace CalamityMod.Items.Armor modPlayer.rogueStealthMax += 1.2f; modPlayer.wearingRogueArmor = true; player.setBonus = "Greatly increases life regen\n" + - "Enemies below 50% life drop a heart when struck\n" + - "This effect has a 5 second cooldown\n" + - "Enemies killed during a Blood Moon have a much higher chance to drop Blood Orbs\n" + + "Enemies below 50% life drop a heart when struck\n" + + "This effect has a 5 second cooldown\n" + + "Enemies killed during a Blood Moon have a much higher chance to drop Blood Orbs\n" + "Being over 80% life boosts your defense by 30 and rogue crit by 5%\n" + "Being below 80% life boosts your rogue damage by 10%\n" + "Rogue critical strikes have a 50% chance to heal you\n" + @@ -70,7 +70,7 @@ namespace CalamityMod.Items.Armor ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 11); recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/BloodflareHelmet.cs b/Items/Armor/BloodflareHelmet.cs index 8ca180271f..8fa565290c 100644 --- a/Items/Armor/BloodflareHelmet.cs +++ b/Items/Armor/BloodflareHelmet.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class BloodflareHelmet : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/BloodflareHornedHelm.cs b/Items/Armor/BloodflareHornedHelm.cs index 01d5bcfdca..2311931140 100644 --- a/Items/Armor/BloodflareHornedHelm.cs +++ b/Items/Armor/BloodflareHornedHelm.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class BloodflareHornedHelm : ModItem { public override void SetStaticDefaults() @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Armor string hotkey = CalamityMod.TarraHotKey.TooltipHotkeyString(); player.setBonus = "Greatly increases life regen\n" + "Enemies below 50% life drop a heart when struck\n" + - "This effect has a 5 second cooldown\n" + + "This effect has a 5 second cooldown\n" + "Enemies killed during a Blood Moon have a much higher chance to drop Blood Orbs\n" + "Press " + hotkey + " to unleash the lost souls of polterghast to destroy your enemies\n" + "This effect has a 30 second cooldown\n" + @@ -64,7 +64,7 @@ namespace CalamityMod.Items.Armor ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 11); recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/BloodflareHornedMask.cs b/Items/Armor/BloodflareHornedMask.cs index e8b879eeb7..82bd7c1593 100644 --- a/Items/Armor/BloodflareHornedMask.cs +++ b/Items/Armor/BloodflareHornedMask.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class BloodflareHornedMask : ModItem { public override void SetStaticDefaults() @@ -41,9 +41,9 @@ namespace CalamityMod.Items.Armor modPlayer.bloodflareSet = true; modPlayer.bloodflareMage = true; player.setBonus = "Greatly increases life regen\n" + - "Enemies below 50% life drop a heart when struck\n" + - "This effect has a 5 second cooldown\n" + - "Enemies killed during a Blood Moon have a much higher chance to drop Blood Orbs\n" + + "Enemies below 50% life drop a heart when struck\n" + + "This effect has a 5 second cooldown\n" + + "Enemies killed during a Blood Moon have a much higher chance to drop Blood Orbs\n" + "Magic weapons fire ghostly bolts every 1.67 seconds\n" + "Magic critical strikes cause flame explosions every 2 seconds"; player.crimsonRegen = true; @@ -64,7 +64,7 @@ namespace CalamityMod.Items.Armor ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 11); recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/BloodflareMask.cs b/Items/Armor/BloodflareMask.cs index 8b71a68f7e..320785ee32 100644 --- a/Items/Armor/BloodflareMask.cs +++ b/Items/Armor/BloodflareMask.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class BloodflareMask : ModItem { public override void SetStaticDefaults() @@ -42,9 +42,9 @@ namespace CalamityMod.Items.Armor modPlayer.bloodflareMelee = true; player.setBonus = "Greatly increases life regen\n" + "Enemies are more likely to target you\n" + - "Enemies below 50% life drop a heart when struck\n" + - "This effect has a 5 second cooldown\n" + - "Enemies killed during a Blood Moon have a much higher chance to drop Blood Orbs\n" + + "Enemies below 50% life drop a heart when struck\n" + + "This effect has a 5 second cooldown\n" + + "Enemies killed during a Blood Moon have a much higher chance to drop Blood Orbs\n" + "True melee strikes will heal you\n" + "After striking an enemy 15 times with true melee you will enter a blood frenzy for 5 seconds\n" + "During this you will gain 25% increased melee damage, critical strike chance, and contact damage is halved\n" + @@ -66,7 +66,7 @@ namespace CalamityMod.Items.Armor ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 11); recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/CirrusDress.cs b/Items/Armor/CirrusDress.cs index 47e8793640..f1762655af 100644 --- a/Items/Armor/CirrusDress.cs +++ b/Items/Armor/CirrusDress.cs @@ -3,50 +3,50 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Body)] + [AutoloadEquip(EquipType.Body)] public class CirrusDress : ModItem { - /* How to obtain - * 1 - Have alcohol poisoning - * 2 - Visit the Stylist while Cirrus is alive in the world - * 3 - Open her shop to find the dress - */ + /* How to obtain + * 1 - Have alcohol poisoning + * 2 - Visit the Stylist while Cirrus is alive in the world + * 3 - Open her shop to find the dress + */ public override void SetStaticDefaults() { DisplayName.SetDefault("Cirrus' Dress"); Tooltip.SetDefault("Here, this should help you drink as much alcohol as you want!\n" + "5% increased magic damage and critical strike chance\n" + - "You feel thick..."); + "You feel thick..."); } public override void SetDefaults() { item.width = 18; item.height = 18; - item.value = CalamityGlobalItem.Rarity16BuyPrice; - item.Calamity().customRarity = CalamityRarity.HotPink; - item.Calamity().devItem = true; + item.value = CalamityGlobalItem.Rarity16BuyPrice; + item.Calamity().customRarity = CalamityRarity.HotPink; + item.Calamity().devItem = true; item.defense = 8; } public override void UpdateEquip(Player player) { - player.Calamity().cirrusDress = true; + player.Calamity().cirrusDress = true; player.magicDamage += 0.05f; player.magicCrit += 5; } - public override void SetMatch(bool male, ref int equipSlot, ref bool robes) - { - robes = true; - // The equipSlot is added in CalamityMod.cs --> Load hook - equipSlot = mod.GetEquipSlot("CirrusDress_Legs", EquipType.Legs); - } + public override void SetMatch(bool male, ref int equipSlot, ref bool robes) + { + robes = true; + // The equipSlot is added in CalamityMod.cs --> Load hook + equipSlot = mod.GetEquipSlot("CirrusDress_Legs", EquipType.Legs); + } - public override void DrawHands(ref bool drawHands, ref bool drawArms) - { - drawHands = true; - } + public override void DrawHands(ref bool drawHands, ref bool drawArms) + { + drawHands = true; + } } } diff --git a/Items/Armor/DaedalusBreastplate.cs b/Items/Armor/DaedalusBreastplate.cs index c7131d0a81..d8dae05f5e 100644 --- a/Items/Armor/DaedalusBreastplate.cs +++ b/Items/Armor/DaedalusBreastplate.cs @@ -33,9 +33,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ItemID.CrystalShard, 6); - recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.CrystalShard, 6); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/DaedalusHat.cs b/Items/Armor/DaedalusHat.cs index fa7df4c6cd..476fd8a114 100644 --- a/Items/Armor/DaedalusHat.cs +++ b/Items/Armor/DaedalusHat.cs @@ -58,9 +58,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ItemID.CrystalShard, 3); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.CrystalShard, 3); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/DaedalusHeadgear.cs b/Items/Armor/DaedalusHeadgear.cs index 61edef9fdc..8d1c39af69 100644 --- a/Items/Armor/DaedalusHeadgear.cs +++ b/Items/Armor/DaedalusHeadgear.cs @@ -55,10 +55,10 @@ namespace CalamityMod.Items.Armor } } player.minionDamage += 0.2f; - player.maxMinions += 2; - } + player.maxMinions += 2; + } - public override void UpdateEquip(Player player) + public override void UpdateEquip(Player player) { player.minionDamage += 0.05f; } @@ -67,9 +67,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ItemID.CrystalShard, 3); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.CrystalShard, 3); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/DaedalusHelmet.cs b/Items/Armor/DaedalusHelmet.cs index d206e65f9d..3517936501 100644 --- a/Items/Armor/DaedalusHelmet.cs +++ b/Items/Armor/DaedalusHelmet.cs @@ -56,9 +56,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ItemID.CrystalShard, 3); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.CrystalShard, 3); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/DaedalusLeggings.cs b/Items/Armor/DaedalusLeggings.cs index 3ea12d0015..e46236dac6 100644 --- a/Items/Armor/DaedalusLeggings.cs +++ b/Items/Armor/DaedalusLeggings.cs @@ -34,9 +34,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ItemID.CrystalShard, 4); - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.CrystalShard, 4); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/DaedalusVisor.cs b/Items/Armor/DaedalusVisor.cs index f26fc84c9a..4be0ac6992 100644 --- a/Items/Armor/DaedalusVisor.cs +++ b/Items/Armor/DaedalusVisor.cs @@ -63,9 +63,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ItemID.CrystalShard, 3); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.CrystalShard, 3); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/DemonshadeHelm.cs b/Items/Armor/DemonshadeHelm.cs index caad3db42c..9258371299 100644 --- a/Items/Armor/DemonshadeHelm.cs +++ b/Items/Armor/DemonshadeHelm.cs @@ -10,7 +10,7 @@ using static CalamityMod.CalPlayer.CalamityPlayer; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class DemonshadeHelm : ModItem, IExtendedHat { public override void SetStaticDefaults() diff --git a/Items/Armor/DesertProwlerHat.cs b/Items/Armor/DesertProwlerHat.cs index 35d09369a4..e355e4ad06 100644 --- a/Items/Armor/DesertProwlerHat.cs +++ b/Items/Armor/DesertProwlerHat.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class DesertProwlerHat : ModItem { public override void SetStaticDefaults() @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { player.setBonus = "Ranged attacks deal an extra 1 flat damage\n" + - "Ranged crits can rarely whip up a sandstorm"; + "Ranged crits can rarely whip up a sandstorm"; CalamityPlayer modPlayer = player.Calamity(); modPlayer.desertProwler = true; } @@ -47,8 +47,8 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddIngredient(ItemID.Silk, 8); - recipe.AddTile(TileID.Loom); + recipe.AddIngredient(ItemID.Silk, 8); + recipe.AddTile(TileID.Loom); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/DesertProwlerPants.cs b/Items/Armor/DesertProwlerPants.cs index 983d3ff276..2ef9ef8c6b 100644 --- a/Items/Armor/DesertProwlerPants.cs +++ b/Items/Armor/DesertProwlerPants.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.Silk, 5); - recipe.AddTile(TileID.Loom); + recipe.AddIngredient(ItemID.Silk, 5); + recipe.AddTile(TileID.Loom); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/DesertProwlerShirt.cs b/Items/Armor/DesertProwlerShirt.cs index 04c011f3da..7b341ee37c 100644 --- a/Items/Armor/DesertProwlerShirt.cs +++ b/Items/Armor/DesertProwlerShirt.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Body)] + [AutoloadEquip(EquipType.Body)] public class DesertProwlerShirt : ModItem { public override void SetStaticDefaults() @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddIngredient(ItemID.Silk, 10); - recipe.AddTile(TileID.Loom); + recipe.AddIngredient(ItemID.Silk, 10); + recipe.AddTile(TileID.Loom); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/FathomSwarmerBoots.cs b/Items/Armor/FathomSwarmerBoots.cs index 528835e72a..9d87b0f939 100644 --- a/Items/Armor/FathomSwarmerBoots.cs +++ b/Items/Armor/FathomSwarmerBoots.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Fathom Swarmer Greaves"); Tooltip.SetDefault("4% increased minion damage\n" + - "Grants the ability to swim\n" + + "Grants the ability to swim\n" + "Movement speed increased by 40% while submerged in liquid"); } @@ -33,15 +33,15 @@ namespace CalamityMod.Items.Armor { player.moveSpeed += 0.4f; } - player.ignoreWater = true; + player.ignoreWater = true; if (player.wingTime <= 0) //ignore flippers while the player can fly - player.accFlipper = true; + player.accFlipper = true; } - public override void UpdateVanity(Player player, EquipType type) - { - player.Calamity().fathomSwarmerTail = true; - } + public override void UpdateVanity(Player player, EquipType type) + { + player.Calamity().fathomSwarmerTail = true; + } public override void AddRecipes() { diff --git a/Items/Armor/FathomSwarmerBreastplate.cs b/Items/Armor/FathomSwarmerBreastplate.cs index 1a4777a29a..3d2a3215f2 100644 --- a/Items/Armor/FathomSwarmerBreastplate.cs +++ b/Items/Armor/FathomSwarmerBreastplate.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Fathom Swarmer Breastplate"); Tooltip.SetDefault("6% increased damage reduction\n" + - "6% increased minion damage\n" + + "6% increased minion damage\n" + "Boosted defense and regen increased while submerged in liquid\n" + - "Reduces defense loss within the Abyss"); + "Reduces defense loss within the Abyss"); } public override void SetDefaults() @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Armor player.statDefense += 10; player.lifeRegen += 5; } - player.Calamity().fathomSwarmerBreastplate = true; + player.Calamity().fathomSwarmerBreastplate = true; } public override void AddRecipes() diff --git a/Items/Armor/FathomSwarmerVisage.cs b/Items/Armor/FathomSwarmerVisage.cs index a705ebff7c..dec553deec 100644 --- a/Items/Armor/FathomSwarmerVisage.cs +++ b/Items/Armor/FathomSwarmerVisage.cs @@ -7,14 +7,14 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class FathomSwarmerVisage : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Fathom Swarmer Visage"); Tooltip.SetDefault("5% increased minion damage\n" + - "Provides breathing and light underwater"); + "Provides breathing and light underwater"); } public override void SetDefaults() @@ -52,15 +52,15 @@ namespace CalamityMod.Items.Armor { CalamityPlayer modPlayer = player.Calamity(); player.minionDamage += 0.05f; - if (player.breath <= player.breathMax + 2 && !modPlayer.ZoneAbyss) - { - player.breath = player.breathMax + 3; - } - modPlayer.fathomSwarmerVisage = true; - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) - { - Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, 0.3f, 0.9f, 1.35f); - } + if (player.breath <= player.breathMax + 2 && !modPlayer.ZoneAbyss) + { + player.breath = player.breathMax + 3; + } + modPlayer.fathomSwarmerVisage = true; + if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) + { + Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, 0.3f, 0.9f, 1.35f); + } } diff --git a/Items/Armor/FearmongerGreathelm.cs b/Items/Armor/FearmongerGreathelm.cs index 11ea5b1d62..68e378ec16 100644 --- a/Items/Armor/FearmongerGreathelm.cs +++ b/Items/Armor/FearmongerGreathelm.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class FearmongerGreathelm : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/GemTechBodyArmor.cs b/Items/Armor/GemTechBodyArmor.cs index 71e51f6f1f..d9cede57e5 100644 --- a/Items/Armor/GemTechBodyArmor.cs +++ b/Items/Armor/GemTechBodyArmor.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Body)] + [AutoloadEquip(EquipType.Body)] public class GemTechBodyArmor : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/GemTechHeadgear.cs b/Items/Armor/GemTechHeadgear.cs index e3d5a5b937..20f4d2d339 100644 --- a/Items/Armor/GemTechHeadgear.cs +++ b/Items/Armor/GemTechHeadgear.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class GemTechHeadgear : ModItem { public const int GemBreakDamageLowerBound = 100; diff --git a/Items/Armor/GodSlayerHelm.cs b/Items/Armor/GodSlayerHelm.cs index 59bf7108ee..7c5d1e0ab1 100644 --- a/Items/Armor/GodSlayerHelm.cs +++ b/Items/Armor/GodSlayerHelm.cs @@ -53,10 +53,10 @@ namespace CalamityMod.Items.Armor player.aggro += 1000; if (modPlayer.godSlayerDashHotKeyPressed) - { + { modPlayer.dashMod = 9; - player.dash = 0; - } + player.dash = 0; + } } public override void UpdateEquip(Player player) diff --git a/Items/Armor/GodSlayerHelmet.cs b/Items/Armor/GodSlayerHelmet.cs index 9200d507da..a78e2f9632 100644 --- a/Items/Armor/GodSlayerHelmet.cs +++ b/Items/Armor/GodSlayerHelmet.cs @@ -48,10 +48,10 @@ namespace CalamityMod.Items.Armor "You fire a god killer shrapnel round while firing ranged weapons every 2.5 seconds"; if (modPlayer.godSlayerDashHotKeyPressed) - { + { modPlayer.dashMod = 9; - player.dash = 0; - } + player.dash = 0; + } } public override void UpdateEquip(Player player) diff --git a/Items/Armor/GodSlayerMask.cs b/Items/Armor/GodSlayerMask.cs index 3f6b7d852f..f8e0c32428 100644 --- a/Items/Armor/GodSlayerMask.cs +++ b/Items/Armor/GodSlayerMask.cs @@ -55,10 +55,10 @@ namespace CalamityMod.Items.Armor "The higher your rogue stealth the higher your rogue damage, crit, and movement speed"; if (modPlayer.godSlayerDashHotKeyPressed) - { + { modPlayer.dashMod = 9; - player.dash = 0; - } + player.dash = 0; + } } public override void UpdateEquip(Player player) diff --git a/Items/Armor/OmegaBlueChestplate.cs b/Items/Armor/OmegaBlueChestplate.cs index 8b3e5f59a8..7f8918d493 100644 --- a/Items/Armor/OmegaBlueChestplate.cs +++ b/Items/Armor/OmegaBlueChestplate.cs @@ -34,7 +34,7 @@ No positive life regen"); player.allDamage += 0.12f; modPlayer.AllCritBoost(8); modPlayer.omegaBlueChestplate = true; - modPlayer.noLifeRegen = true; + modPlayer.noLifeRegen = true; } public override void AddRecipes() diff --git a/Items/Armor/OmegaBlueHelmet.cs b/Items/Armor/OmegaBlueHelmet.cs index ee4c763a13..5c0cf2cdd7 100644 --- a/Items/Armor/OmegaBlueHelmet.cs +++ b/Items/Armor/OmegaBlueHelmet.cs @@ -9,7 +9,7 @@ using CalamityMod.Cooldowns; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class OmegaBlueHelmet : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/PlagueReaperMask.cs b/Items/Armor/PlagueReaperMask.cs index 9af9745ddc..23eac14dd1 100644 --- a/Items/Armor/PlagueReaperMask.cs +++ b/Items/Armor/PlagueReaperMask.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class PlagueReaperMask : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/PlagueReaperStriders.cs b/Items/Armor/PlagueReaperStriders.cs index 9a885999f9..8291358694 100644 --- a/Items/Armor/PlagueReaperStriders.cs +++ b/Items/Armor/PlagueReaperStriders.cs @@ -35,8 +35,8 @@ namespace CalamityMod.Items.Armor ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.NecroGreaves); recipe.AddIngredient(ModContent.ItemType(), 21); - recipe.AddIngredient(ItemID.Nanites, 17); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.Nanites, 17); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/PlagueReaperVest.cs b/Items/Armor/PlagueReaperVest.cs index 06849d1378..20584b6a1e 100644 --- a/Items/Armor/PlagueReaperVest.cs +++ b/Items/Armor/PlagueReaperVest.cs @@ -36,8 +36,8 @@ namespace CalamityMod.Items.Armor ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.NecroBreastplate); //I will instead change the position of the necro armor get trolled recipe.AddIngredient(ModContent.ItemType(), 29); //I like prime numbers =) - recipe.AddIngredient(ItemID.Nanites, 19); //Change this to 30 and 20 and I will hunt you down - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.Nanites, 19); //Change this to 30 and 20 and I will hunt you down + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/PlaguebringerVisor.cs b/Items/Armor/PlaguebringerVisor.cs index d71d843f10..ccb41bec14 100644 --- a/Items/Armor/PlaguebringerVisor.cs +++ b/Items/Armor/PlaguebringerVisor.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Armor player.Calamity().plaguebringerPatronSet = true; player.Calamity().dashMod = 8; - player.dash = 0; + player.dash = 0; player.maxMinions += 3; if (player.whoAmI == Main.myPlayer) { diff --git a/Items/Armor/PrismaticGreaves.cs b/Items/Armor/PrismaticGreaves.cs index 8b9ddf6e89..54bdc0ec59 100644 --- a/Items/Armor/PrismaticGreaves.cs +++ b/Items/Armor/PrismaticGreaves.cs @@ -6,48 +6,48 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Legs)] - public class PrismaticGreaves : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Prismatic Greaves"); - Tooltip.SetDefault("10% increased magic damage and 12% increased magic crit\n" + - "20% decreased non-magic damage\n" + - "10% increased flight time and 2% increased jump speed"); - } + [AutoloadEquip(EquipType.Legs)] + public class PrismaticGreaves : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Prismatic Greaves"); + Tooltip.SetDefault("10% increased magic damage and 12% increased magic crit\n" + + "20% decreased non-magic damage\n" + + "10% increased flight time and 2% increased jump speed"); + } - public override void SetDefaults() - { - item.width = 18; - item.height = 18; - item.defense = 21; + public override void SetDefaults() + { + item.width = 18; + item.height = 18; + item.defense = 21; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.Calamity().donorItem = true; - } + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.Calamity().donorItem = true; + } - public override void UpdateEquip(Player player) - { - player.Calamity().prismaticGreaves = true; - player.magicDamage += 0.1f; - player.magicCrit += 12; - player.jumpSpeedBoost += 0.1f; - player.allDamage -= 0.2f; - player.magicDamage += 0.2f; - } + public override void UpdateEquip(Player player) + { + player.Calamity().prismaticGreaves = true; + player.magicDamage += 0.1f; + player.magicCrit += 12; + player.jumpSpeedBoost += 0.1f; + player.allDamage -= 0.2f; + player.magicDamage += 0.2f; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddIngredient(ItemID.Nanites, 300); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 6); + recipe.AddIngredient(ItemID.Nanites, 300); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Armor/PrismaticHelmet.cs b/Items/Armor/PrismaticHelmet.cs index 79380ab3cb..c8ccf3336b 100644 --- a/Items/Armor/PrismaticHelmet.cs +++ b/Items/Armor/PrismaticHelmet.cs @@ -6,72 +6,72 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] - public class PrismaticHelmet : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Prismatic Helmet"); - Tooltip.SetDefault("18% increased magic damage and 12% increased magic crit\n" + - "20% decreased non-magic damage\n" + - "Enemies with less than 500 max health deal no contact damage\n" + - "This does not occur while a boss is alive"); - } + [AutoloadEquip(EquipType.Head)] + public class PrismaticHelmet : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Prismatic Helmet"); + Tooltip.SetDefault("18% increased magic damage and 12% increased magic crit\n" + + "20% decreased non-magic damage\n" + + "Enemies with less than 500 max health deal no contact damage\n" + + "This does not occur while a boss is alive"); + } - public override void SetDefaults() - { - item.width = 18; - item.height = 18; - item.defense = 18; //71 + public override void SetDefaults() + { + item.width = 18; + item.height = 18; + item.defense = 18; //71 - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.Calamity().donorItem = true; - } + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.Calamity().donorItem = true; + } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) + { + return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + } - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadowSubtle = true; - player.armorEffectDrawOutlines = true; - } + public override void ArmorSetShadows(Player player) + { + player.armorEffectDrawShadowSubtle = true; + player.armorEffectDrawOutlines = true; + } - public override void UpdateArmorSet(Player player) - { - player.Calamity().prismaticSet = true; - player.statManaMax2 += 40; - player.manaCost *= 0.85f; - player.manaRegenBonus += 8; - string hotkey = CalamityMod.TarraHotKey.TooltipHotkeyString(); - player.setBonus = "+40 max mana and 15% reduced mana cost\n" + - "Increased mana regeneration rate\n" + - "Press " + hotkey + " to unleash a barrage of death lasers at the cursor for the next 5 seconds\n" + - "This has a 30 second cooldown"; - } + public override void UpdateArmorSet(Player player) + { + player.Calamity().prismaticSet = true; + player.statManaMax2 += 40; + player.manaCost *= 0.85f; + player.manaRegenBonus += 8; + string hotkey = CalamityMod.TarraHotKey.TooltipHotkeyString(); + player.setBonus = "+40 max mana and 15% reduced mana cost\n" + + "Increased mana regeneration rate\n" + + "Press " + hotkey + " to unleash a barrage of death lasers at the cursor for the next 5 seconds\n" + + "This has a 30 second cooldown"; + } - public override void UpdateEquip(Player player) - { - player.Calamity().prismaticHelmet = true; - player.allDamage -= 0.2f; - player.magicDamage += 0.2f; - player.magicDamage += 0.18f; - player.magicCrit += 12; - } + public override void UpdateEquip(Player player) + { + player.Calamity().prismaticHelmet = true; + player.allDamage -= 0.2f; + player.magicDamage += 0.2f; + player.magicDamage += 0.18f; + player.magicCrit += 12; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddIngredient(ItemID.Nanites, 300); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ItemID.Nanites, 300); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Armor/PrismaticRegalia.cs b/Items/Armor/PrismaticRegalia.cs index 0ef0bf9a4e..524936a095 100644 --- a/Items/Armor/PrismaticRegalia.cs +++ b/Items/Armor/PrismaticRegalia.cs @@ -6,50 +6,50 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Body)] - public class PrismaticRegalia : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Prismatic Regalia"); - Tooltip.SetDefault("12% increased magic damage and 15% increased magic crit\n" + - "20% decreased non-magic damage\n" + - "+20 max life and +40 max mana\n" + - "Magic attacks occasionally fire a pair of homing rockets"); - } + [AutoloadEquip(EquipType.Body)] + public class PrismaticRegalia : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Prismatic Regalia"); + Tooltip.SetDefault("12% increased magic damage and 15% increased magic crit\n" + + "20% decreased non-magic damage\n" + + "+20 max life and +40 max mana\n" + + "Magic attacks occasionally fire a pair of homing rockets"); + } - public override void SetDefaults() - { - item.width = 18; - item.height = 18; - item.defense = 33; + public override void SetDefaults() + { + item.width = 18; + item.height = 18; + item.defense = 33; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.Calamity().donorItem = true; - } + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.Calamity().donorItem = true; + } - public override void UpdateEquip(Player player) - { - player.Calamity().prismaticRegalia = true; - player.statLifeMax2 += 20; - player.statManaMax2 += 40; - player.magicDamage += 0.12f; - player.magicCrit += 15; - player.allDamage -= 0.2f; - player.magicDamage += 0.2f; - } + public override void UpdateEquip(Player player) + { + player.Calamity().prismaticRegalia = true; + player.statLifeMax2 += 20; + player.statManaMax2 += 40; + player.magicDamage += 0.12f; + player.magicCrit += 15; + player.allDamage -= 0.2f; + player.magicDamage += 0.2f; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ItemID.Nanites, 300); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ItemID.Nanites, 300); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Armor/ReaverCuisses.cs b/Items/Armor/ReaverCuisses.cs index 62efcdd14c..eaf3866f9b 100644 --- a/Items/Armor/ReaverCuisses.cs +++ b/Items/Armor/ReaverCuisses.cs @@ -34,9 +34,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ItemID.JungleSpores, 8); - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.JungleSpores, 8); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/ReaverHeadgear.cs b/Items/Armor/ReaverHeadgear.cs index 0b64080092..8b933007f7 100644 --- a/Items/Armor/ReaverHeadgear.cs +++ b/Items/Armor/ReaverHeadgear.cs @@ -9,10 +9,10 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class ReaverHeadgear : ModItem { - //Exploration and Mining Helm + //Exploration and Mining Helm public override void SetStaticDefaults() { DisplayName.SetDefault("Reaver Headgear"); @@ -43,9 +43,9 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { player.setBonus = "Causes nearby treasure to sparkle\n" + - "Increased item grab range and block placement range\n" + - "Mining tiles restores breath while underwater\n" + - "Summons a reaver orb to light up the area around you\n" + + "Increased item grab range and block placement range\n" + + "Mining tiles restores breath while underwater\n" + + "Summons a reaver orb to light up the area around you\n" + "Reduces enemy aggression, even in the abyss\n" + "Provides a small amount of light in the abyss"; CalamityPlayer modPlayer = player.Calamity(); @@ -65,57 +65,57 @@ namespace CalamityMod.Items.Armor Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); } } - if (player.miscCounter % 10 == 0) - { - int searchDist = 17; - int x = (int)player.Center.X / 16; - int y = (int)player.Center.Y / 16; - for (int i = x - searchDist; i <= x + searchDist; ++i) - { - for (int j = y - searchDist; j <= y + searchDist; ++j) - { - if (Main.rand.NextBool(4) && (new Vector2((float)(x - i), (float)(y - j)).Length() < (float)searchDist && i > 0 && (i < Main.maxTilesX - 1 && j > 0) && (j < Main.maxTilesY - 1 && Main.tile[i, j] != null && Main.tile[i, j].active()))) - { - bool shouldSparkle = false; - //Check for the money piles - if (Main.tile[i, j].type == TileID.SmallPiles && Main.tile[i, j].frameY == 18) - { - if (Main.tile[i, j].frameX >= 576 && Main.tile[i, j].frameX <= 882) - shouldSparkle = true; - } - else if (Main.tile[i, j].type == TileID.LargePiles && Main.tile[i, j].frameX >= 864 && Main.tile[i, j].frameX <= 1170) - shouldSparkle = true; + if (player.miscCounter % 10 == 0) + { + int searchDist = 17; + int x = (int)player.Center.X / 16; + int y = (int)player.Center.Y / 16; + for (int i = x - searchDist; i <= x + searchDist; ++i) + { + for (int j = y - searchDist; j <= y + searchDist; ++j) + { + if (Main.rand.NextBool(4) && (new Vector2((float)(x - i), (float)(y - j)).Length() < (float)searchDist && i > 0 && (i < Main.maxTilesX - 1 && j > 0) && (j < Main.maxTilesY - 1 && Main.tile[i, j] != null && Main.tile[i, j].active()))) + { + bool shouldSparkle = false; + //Check for the money piles + if (Main.tile[i, j].type == TileID.SmallPiles && Main.tile[i, j].frameY == 18) + { + if (Main.tile[i, j].frameX >= 576 && Main.tile[i, j].frameX <= 882) + shouldSparkle = true; + } + else if (Main.tile[i, j].type == TileID.LargePiles && Main.tile[i, j].frameX >= 864 && Main.tile[i, j].frameX <= 1170) + shouldSparkle = true; - if (shouldSparkle || Main.tileSpelunker[Main.tile[i, j].type] || Main.tileAlch[Main.tile[i, j].type] && Main.tile[i, j].type != TileID.ImmatureHerbs) - { - int sparkle = Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, 204, 0f, 0f, 150, new Color(), 0.3f); - Dust dust = Main.dust[sparkle]; - dust.fadeIn = 0.75f; - dust.velocity = dust.velocity * 0.1f; - dust.noLight = true; - } - } - } - } - } + if (shouldSparkle || Main.tileSpelunker[Main.tile[i, j].type] || Main.tileAlch[Main.tile[i, j].type] && Main.tile[i, j].type != TileID.ImmatureHerbs) + { + int sparkle = Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, 204, 0f, 0f, 150, new Color(), 0.3f); + Dust dust = Main.dust[sparkle]; + dust.fadeIn = 0.75f; + dust.velocity = dust.velocity * 0.1f; + dust.noLight = true; + } + } + } + } + } } public override void UpdateEquip(Player player) { player.ignoreWater = true; - player.pickSpeed -= 0.1f; + player.pickSpeed -= 0.1f; player.tileSpeed += 0.2f; player.wallSpeed += 0.2f; - player.lavaMax += 420; + player.lavaMax += 420; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddIngredient(ItemID.JungleSpores, 4); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.JungleSpores, 4); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/ReaverHelm.cs b/Items/Armor/ReaverHelm.cs index abb613e544..977646eaa4 100644 --- a/Items/Armor/ReaverHelm.cs +++ b/Items/Armor/ReaverHelm.cs @@ -9,13 +9,13 @@ namespace CalamityMod.Items.Armor [AutoloadEquip(EquipType.Head)] public class ReaverHelm : ModItem { - //Defense and DR Helm + //Defense and DR Helm public override void SetStaticDefaults() { DisplayName.SetDefault("Reaver Helm"); Tooltip.SetDefault("15% increased damage reduction but 30% decreased damage\n" + - "+50 max life\n" + - "Passively regenerates one health point every second"); + "+50 max life\n" + + "Passively regenerates one health point every second"); } public override void SetDefaults() @@ -43,25 +43,25 @@ namespace CalamityMod.Items.Armor CalamityPlayer modPlayer = player.Calamity(); player.thorns += 0.33f; player.moveSpeed -= 0.2f; - player.statDefense += 10; - player.lifeRegen += 3; + player.statDefense += 10; + player.lifeRegen += 3; player.aggro += 600; modPlayer.reaverDefense = true; modPlayer.wearingRogueArmor = true; player.setBonus = "+10 defense and +3 life regen\n" + - "Enemies are more likely to target you\n" + - "Reduces the life regen lost from damage over time debuffs by 20%\n" + - "All attacks have a small chance to steal life and speed up the rate of life regen\n" + - "20% decreased movement speed and flight time\n" + - "Enemy damage is reflected and summons a thorn spike\n" + - "Reaver Rage has a 25% chance to activate when you are damaged"; - //Reaver Rage provides 30% damage to offset the helm "bonus", 5 def, and 5% melee speed. + "Enemies are more likely to target you\n" + + "Reduces the life regen lost from damage over time debuffs by 20%\n" + + "All attacks have a small chance to steal life and speed up the rate of life regen\n" + + "20% decreased movement speed and flight time\n" + + "Enemy damage is reflected and summons a thorn spike\n" + + "Reaver Rage has a 25% chance to activate when you are damaged"; + //Reaver Rage provides 30% damage to offset the helm "bonus", 5 def, and 5% melee speed. } public override void UpdateEquip(Player player) { - player.allDamage -= 0.3f; - player.endurance += 0.15f; + player.allDamage -= 0.3f; + player.endurance += 0.15f; player.Calamity().reaverRegen = true; player.statLifeMax2 += 50; } @@ -70,9 +70,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddIngredient(ItemID.JungleSpores, 4); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.JungleSpores, 4); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/ReaverScaleMail.cs b/Items/Armor/ReaverScaleMail.cs index 53aec1fb00..93247c4be5 100644 --- a/Items/Armor/ReaverScaleMail.cs +++ b/Items/Armor/ReaverScaleMail.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ItemID.JungleSpores, 12); - recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.JungleSpores, 12); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/ReaverVisage.cs b/Items/Armor/ReaverVisage.cs index fb10631774..67e29fd5be 100644 --- a/Items/Armor/ReaverVisage.cs +++ b/Items/Armor/ReaverVisage.cs @@ -6,10 +6,10 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class ReaverVisage : ModItem { - //Jump/Flight Boosts and Movement Speed Helm + //Jump/Flight Boosts and Movement Speed Helm public override void SetStaticDefaults() { DisplayName.SetDefault("Reaver Visage"); @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Armor item.defense = 13; //46 } - public override bool IsArmorSet(Item head, Item body, Item legs) + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); } @@ -43,12 +43,12 @@ namespace CalamityMod.Items.Armor modPlayer.wearingRogueArmor = true; player.setBonus = "Grants immunity to fall damage and allows constant jumping\n" + "10% increased flight time and horizontal wing speed\n" + - "Hooks fly out and retract 10% faster\n" + - "Reduces the cooldown of dashes"; + "Hooks fly out and retract 10% faster\n" + + "Reduces the cooldown of dashes"; player.noFallDmg = true; player.autoJump = true; - if (player.miscCounter % 3 == 2 && player.dashDelay > 0) - player.dashDelay--; + if (player.miscCounter % 3 == 2 && player.dashDelay > 0) + player.dashDelay--; } public override void UpdateEquip(Player player) @@ -61,9 +61,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddIngredient(ItemID.JungleSpores, 4); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.JungleSpores, 4); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/SilvaLeggings.cs b/Items/Armor/SilvaLeggings.cs index df4d79512f..14479fc1db 100644 --- a/Items/Armor/SilvaLeggings.cs +++ b/Items/Armor/SilvaLeggings.cs @@ -23,9 +23,9 @@ namespace CalamityMod.Items.Armor item.height = 18; item.value = Item.buyPrice(0, 54, 0, 0); item.defense = 39; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + } public override void UpdateEquip(Player player) { diff --git a/Items/Armor/SnowRuffianChestplate.cs b/Items/Armor/SnowRuffianChestplate.cs index 1de589f072..b08954ed54 100644 --- a/Items/Armor/SnowRuffianChestplate.cs +++ b/Items/Armor/SnowRuffianChestplate.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Body)] + [AutoloadEquip(EquipType.Body)] public class SnowRuffianChestplate : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/SnowRuffianGreaves.cs b/Items/Armor/SnowRuffianGreaves.cs index b3729850f3..c826282d57 100644 --- a/Items/Armor/SnowRuffianGreaves.cs +++ b/Items/Armor/SnowRuffianGreaves.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Legs)] + [AutoloadEquip(EquipType.Legs)] public class SnowRuffianGreaves : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/SnowRuffianMask.cs b/Items/Armor/SnowRuffianMask.cs index 57365cdb6f..aa2b58c5a6 100644 --- a/Items/Armor/SnowRuffianMask.cs +++ b/Items/Armor/SnowRuffianMask.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class SnowRuffianMask : ModItem { private bool shouldBoost = false; diff --git a/Items/Armor/StatigelArmor.cs b/Items/Armor/StatigelArmor.cs index 688660f033..ccc4414e4f 100644 --- a/Items/Armor/StatigelArmor.cs +++ b/Items/Armor/StatigelArmor.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Armor public override void UpdateEquip(Player player) { - player.Calamity().AllCritBoost(5); + player.Calamity().AllCritBoost(5); } public override void AddRecipes() diff --git a/Items/Armor/StatigelCap.cs b/Items/Armor/StatigelCap.cs index fb5894c4eb..3ce2c05c7c 100644 --- a/Items/Armor/StatigelCap.cs +++ b/Items/Armor/StatigelCap.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class StatigelCap : ModItem { public override void SetStaticDefaults() @@ -35,12 +35,12 @@ namespace CalamityMod.Items.Armor { player.setBonus = "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + "Grants an extra jump and increased jump height\n" + - "12% increased jump speed"; + "12% increased jump speed"; CalamityPlayer modPlayer = player.Calamity(); modPlayer.statigelSet = true; - modPlayer.statigelJump = true; - Player.jumpHeight += 5; - player.jumpSpeedBoost += 0.6f; + modPlayer.statigelJump = true; + Player.jumpHeight += 5; + player.jumpSpeedBoost += 0.6f; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/StatigelHeadgear.cs b/Items/Armor/StatigelHeadgear.cs index ef25bf8d36..a582051763 100644 --- a/Items/Armor/StatigelHeadgear.cs +++ b/Items/Armor/StatigelHeadgear.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class StatigelHeadgear : ModItem { public override void SetStaticDefaults() @@ -33,15 +33,15 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - player.setBonus = "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + - "Grants an extra jump and increased jump height\n" + - "12% increased jump speed"; - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.statigelSet = true; - modPlayer.statigelJump = true; - Player.jumpHeight += 5; - player.jumpSpeedBoost += 0.6f; - } + player.setBonus = "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + + "Grants an extra jump and increased jump height\n" + + "12% increased jump speed"; + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.statigelSet = true; + modPlayer.statigelJump = true; + Player.jumpHeight += 5; + player.jumpSpeedBoost += 0.6f; + } public override void UpdateEquip(Player player) { diff --git a/Items/Armor/StatigelHelm.cs b/Items/Armor/StatigelHelm.cs index a0c8ffd036..26d60bde8d 100644 --- a/Items/Armor/StatigelHelm.cs +++ b/Items/Armor/StatigelHelm.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class StatigelHelm : ModItem { public override void SetStaticDefaults() @@ -33,17 +33,17 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - player.setBonus = "Enemies are more likely to target you\n" + - "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + - "Grants an extra jump and increased jump height\n" + - "12% increased jump speed"; - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.statigelSet = true; - modPlayer.statigelJump = true; - Player.jumpHeight += 5; - player.jumpSpeedBoost += 0.6f; + player.setBonus = "Enemies are more likely to target you\n" + + "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + + "Grants an extra jump and increased jump height\n" + + "12% increased jump speed"; + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.statigelSet = true; + modPlayer.statigelJump = true; + Player.jumpHeight += 5; + player.jumpSpeedBoost += 0.6f; player.aggro += 400; - } + } public override void UpdateEquip(Player player) { diff --git a/Items/Armor/StatigelHood.cs b/Items/Armor/StatigelHood.cs index d71e1bdab0..f43d33fbdc 100644 --- a/Items/Armor/StatigelHood.cs +++ b/Items/Armor/StatigelHood.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class StatigelHood : ModItem { public override void SetStaticDefaults() @@ -34,20 +34,20 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - player.setBonus = "18% increased minion damage and +1 max minion\n" + + player.setBonus = "18% increased minion damage and +1 max minion\n" + "Summons a mini slime god to fight for you, the type depends on what world evil you have\n" + "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + "Grants an extra jump and increased jump height\n" + - "12% increased jump speed"; + "12% increased jump speed"; CalamityPlayer modPlayer = player.Calamity(); modPlayer.statigelSet = true; modPlayer.slimeGod = true; - modPlayer.statigelJump = true; - Player.jumpHeight += 5; - player.jumpSpeedBoost += 0.6f; - player.minionDamage += 0.18f; - player.maxMinions++; - if (player.whoAmI == Main.myPlayer) + modPlayer.statigelJump = true; + Player.jumpHeight += 5; + player.jumpSpeedBoost += 0.6f; + player.minionDamage += 0.18f; + player.maxMinions++; + if (player.whoAmI == Main.myPlayer) { if (player.FindBuffIndex(ModContent.BuffType()) == -1) { diff --git a/Items/Armor/StatigelMask.cs b/Items/Armor/StatigelMask.cs index 93fbb3e2b1..6f7b7a1813 100644 --- a/Items/Armor/StatigelMask.cs +++ b/Items/Armor/StatigelMask.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class StatigelMask : ModItem { public override void SetStaticDefaults() @@ -33,21 +33,21 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - player.setBonus = "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + + player.setBonus = "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + "Grants an extra jump and increased jump height\n" + - "12% increased jump speed\n" + + "12% increased jump speed\n" + "Rogue stealth builds while not attacking and slower while moving, up to a max of 100\n" + "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + "The higher your rogue stealth the higher your rogue damage, crit, and movement speed"; CalamityPlayer modPlayer = player.Calamity(); modPlayer.statigelSet = true; - modPlayer.statigelJump = true; + modPlayer.statigelJump = true; modPlayer.rogueStealthMax += 1f; modPlayer.wearingRogueArmor = true; - Player.jumpHeight += 5; - player.jumpSpeedBoost += 0.6f; - } + Player.jumpHeight += 5; + player.jumpSpeedBoost += 0.6f; + } public override void UpdateEquip(Player player) { diff --git a/Items/Armor/TarragonBreastplate.cs b/Items/Armor/TarragonBreastplate.cs index bbb980ad81..6a0d3b7278 100644 --- a/Items/Armor/TarragonBreastplate.cs +++ b/Items/Armor/TarragonBreastplate.cs @@ -12,8 +12,8 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Tarragon Breastplate"); Tooltip.SetDefault("Breastplate of the exiler\n" + - "10% increased damage and 5% increased critical strike chance\n" + - "+2 life regen and +40 max life"); + "10% increased damage and 5% increased critical strike chance\n" + + "+2 life regen and +40 max life"); } public override void SetDefaults() diff --git a/Items/Armor/TarragonHelm.cs b/Items/Armor/TarragonHelm.cs index 7a9e34c56d..b42529a8e3 100644 --- a/Items/Armor/TarragonHelm.cs +++ b/Items/Armor/TarragonHelm.cs @@ -6,14 +6,14 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class TarragonHelm : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Tarragon Helm"); Tooltip.SetDefault("Helm of the disciple of ancients\n" + - "Temporary immunity to lava\n" + + "Temporary immunity to lava\n" + "Can move freely through liquids\n" + "5% increased damage reduction\n" + "10% increased melee damage and critical strike chance"); diff --git a/Items/Armor/TarragonHelmet.cs b/Items/Armor/TarragonHelmet.cs index 0ba7f55afb..83ceeca2a9 100644 --- a/Items/Armor/TarragonHelmet.cs +++ b/Items/Armor/TarragonHelmet.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class TarragonHelmet : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/TarragonHornedHelm.cs b/Items/Armor/TarragonHornedHelm.cs index e616b065b0..748aea4eea 100644 --- a/Items/Armor/TarragonHornedHelm.cs +++ b/Items/Armor/TarragonHornedHelm.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class TarragonHornedHelm : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/TarragonLeggings.cs b/Items/Armor/TarragonLeggings.cs index cad09f7571..600a886823 100644 --- a/Items/Armor/TarragonLeggings.cs +++ b/Items/Armor/TarragonLeggings.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Tarragon Leggings"); Tooltip.SetDefault("Leggings of a fabled explorer\n" + - "10% increased movement speed\n" + + "10% increased movement speed\n" + "8% increased damage and critical strike chance"); } diff --git a/Items/Armor/TarragonMask.cs b/Items/Armor/TarragonMask.cs index 1141475e60..7871f2d7b5 100644 --- a/Items/Armor/TarragonMask.cs +++ b/Items/Armor/TarragonMask.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class TarragonMask : ModItem { public override void SetStaticDefaults() diff --git a/Items/Armor/TarragonVisage.cs b/Items/Armor/TarragonVisage.cs index 9846a594b9..dce042d8c8 100644 --- a/Items/Armor/TarragonVisage.cs +++ b/Items/Armor/TarragonVisage.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class TarragonVisage : ModItem { public override void SetStaticDefaults() @@ -46,7 +46,7 @@ namespace CalamityMod.Items.Armor player.setBonus = "Reduces enemy spawn rates\n" + "Increased heart pickup range\n" + "Enemies have a chance to drop extra hearts on death\n" + - "Ranged projectiles split into homing life energy and leaves on death"; + "Ranged projectiles split into homing life energy and leaves on death"; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/TitanHeartBoots.cs b/Items/Armor/TitanHeartBoots.cs index f7e4f342a6..b09cb2a9f3 100644 --- a/Items/Armor/TitanHeartBoots.cs +++ b/Items/Armor/TitanHeartBoots.cs @@ -6,39 +6,39 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Legs)] - public class TitanHeartBoots : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Titan Heart Boots"); - Tooltip.SetDefault("4% increased rogue damage, 10% increased rogue velocity, and 5% increased rogue knockback"); - } + [AutoloadEquip(EquipType.Legs)] + public class TitanHeartBoots : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Titan Heart Boots"); + Tooltip.SetDefault("4% increased rogue damage, 10% increased rogue velocity, and 5% increased rogue knockback"); + } - public override void SetDefaults() - { - item.width = 18; - item.height = 18; - item.value = Item.buyPrice(0, 12, 0, 0); - item.rare = ItemRarityID.LightRed; - item.defense = 14; - } + public override void SetDefaults() + { + item.width = 18; + item.height = 18; + item.value = Item.buyPrice(0, 12, 0, 0); + item.rare = ItemRarityID.LightRed; + item.defense = 14; + } - public override void UpdateEquip(Player player) - { - player.Calamity().titanHeartBoots = true; - player.Calamity().throwingVelocity += 0.1f; - player.Calamity().throwingDamage += 0.04f; - } + public override void UpdateEquip(Player player) + { + player.Calamity().titanHeartBoots = true; + player.Calamity().throwingVelocity += 0.1f; + player.Calamity().throwingDamage += 0.04f; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 14); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 14); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Armor/TitanHeartMantle.cs b/Items/Armor/TitanHeartMantle.cs index e0f610a783..bc090360ac 100644 --- a/Items/Armor/TitanHeartMantle.cs +++ b/Items/Armor/TitanHeartMantle.cs @@ -6,40 +6,40 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Body)] - public class TitanHeartMantle : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Titan Heart Mantle"); - Tooltip.SetDefault("45% chance to not consume rogue items\n" + - "5% boosted rogue knockback but 15% lowered rogue attack speed"); - } + [AutoloadEquip(EquipType.Body)] + public class TitanHeartMantle : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Titan Heart Mantle"); + Tooltip.SetDefault("45% chance to not consume rogue items\n" + + "5% boosted rogue knockback but 15% lowered rogue attack speed"); + } - public override void SetDefaults() - { - item.width = 18; - item.height = 18; - item.value = Item.buyPrice(0, 12, 0, 0); - item.rare = ItemRarityID.LightRed; - item.defense = 17; - } + public override void SetDefaults() + { + item.width = 18; + item.height = 18; + item.value = Item.buyPrice(0, 12, 0, 0); + item.rare = ItemRarityID.LightRed; + item.defense = 17; + } - public override void UpdateEquip(Player player) - { - player.Calamity().titanHeartMantle = true; - player.Calamity().throwingAmmoCost *= 0.55f; + public override void UpdateEquip(Player player) + { + player.Calamity().titanHeartMantle = true; + player.Calamity().throwingAmmoCost *= 0.55f; player.Calamity().rogueUseSpeedFactor -= 0.15f; - } + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 20); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Armor/TitanHeartMask.cs b/Items/Armor/TitanHeartMask.cs index 135b1f06bc..66c3424c64 100644 --- a/Items/Armor/TitanHeartMask.cs +++ b/Items/Armor/TitanHeartMask.cs @@ -7,62 +7,62 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] - public class TitanHeartMask : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Titan Heart Mask"); - Tooltip.SetDefault("5% increased rogue damage and knockback\n" + - "Rogue weapons inflict the Astral Infection debuff"); - } + [AutoloadEquip(EquipType.Head)] + public class TitanHeartMask : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Titan Heart Mask"); + Tooltip.SetDefault("5% increased rogue damage and knockback\n" + + "Rogue weapons inflict the Astral Infection debuff"); + } - public override void SetDefaults() - { - item.width = 18; - item.height = 18; - item.value = Item.buyPrice(0, 12, 0, 0); - item.rare = ItemRarityID.LightRed; - item.defense = 12; //43 - } + public override void SetDefaults() + { + item.width = 18; + item.height = 18; + item.value = Item.buyPrice(0, 12, 0, 0); + item.rare = ItemRarityID.LightRed; + item.defense = 12; //43 + } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) + { + return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + } - public override void UpdateArmorSet(Player player) - { - player.setBonus = "15% increased rogue damage and knockback\n" + - "Stealth strikes deal double knockback and cause an astral explosion\n" + - "Grants immunity to knockback\n" + - "Rogue stealth builds while not attacking and slower while moving, up to a max of 100\n" + - "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + - "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + - "The higher your rogue stealth the higher your rogue damage, crit, and movement speed"; - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.titanHeartSet = true; - modPlayer.throwingDamage += 0.15f; - modPlayer.rogueStealthMax += 1f; - modPlayer.wearingRogueArmor = true; - player.noKnockback = true; - } + public override void UpdateArmorSet(Player player) + { + player.setBonus = "15% increased rogue damage and knockback\n" + + "Stealth strikes deal double knockback and cause an astral explosion\n" + + "Grants immunity to knockback\n" + + "Rogue stealth builds while not attacking and slower while moving, up to a max of 100\n" + + "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + + "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + + "The higher your rogue stealth the higher your rogue damage, crit, and movement speed"; + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.titanHeartSet = true; + modPlayer.throwingDamage += 0.15f; + modPlayer.rogueStealthMax += 1f; + modPlayer.wearingRogueArmor = true; + player.noKnockback = true; + } - public override void UpdateEquip(Player player) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.titanHeartMask = true; - modPlayer.throwingDamage += 0.05f; - } + public override void UpdateEquip(Player player) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.titanHeartMask = true; + modPlayer.throwingDamage += 0.05f; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Armor/UmbraphileBoots.cs b/Items/Armor/UmbraphileBoots.cs index 23c01f056a..86cdea58ee 100644 --- a/Items/Armor/UmbraphileBoots.cs +++ b/Items/Armor/UmbraphileBoots.cs @@ -27,16 +27,16 @@ namespace CalamityMod.Items.Armor public override void UpdateEquip(Player player) { player.moveSpeed += 0.2f; - player.Calamity().throwingDamage += 0.09f; - player.Calamity().throwingCrit += 6; + player.Calamity().throwingDamage += 0.09f; + player.Calamity().throwingCrit += 6; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 14); - recipe.AddIngredient(ItemID.HallowedBar, 11); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.HallowedBar, 11); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/UmbraphileHood.cs b/Items/Armor/UmbraphileHood.cs index d4edd7eb06..bfe13744ea 100644 --- a/Items/Armor/UmbraphileHood.cs +++ b/Items/Armor/UmbraphileHood.cs @@ -40,8 +40,8 @@ namespace CalamityMod.Items.Armor modPlayer.umbraphileSet = true; modPlayer.rogueStealthMax += 1.1f; player.setBonus = "Rogue weapons have a chance to create explosions on hit\n" + - "Stealth strikes always create an explosion\n" + - "Penumbra potions always build stealth at max effectiveness\n" + + "Stealth strikes always create an explosion\n" + + "Penumbra potions always build stealth at max effectiveness\n" + "Rogue stealth builds while not attacking and slower while moving, up to a max of 110\n" + "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + @@ -51,16 +51,16 @@ namespace CalamityMod.Items.Armor public override void UpdateEquip(Player player) { - player.Calamity().throwingDamage += 0.08f; - player.Calamity().throwingVelocity += 0.1f; + player.Calamity().throwingDamage += 0.08f; + player.Calamity().throwingVelocity += 0.1f; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ItemID.HallowedBar, 8); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.HallowedBar, 8); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/UmbraphileRegalia.cs b/Items/Armor/UmbraphileRegalia.cs index b19250cbe1..b882f73bb3 100644 --- a/Items/Armor/UmbraphileRegalia.cs +++ b/Items/Armor/UmbraphileRegalia.cs @@ -25,16 +25,16 @@ namespace CalamityMod.Items.Armor public override void UpdateEquip(Player player) { - player.Calamity().throwingDamage += 0.1f; - player.Calamity().throwingCrit += 10; + player.Calamity().throwingDamage += 0.1f; + player.Calamity().throwingCrit += 10; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 18); - recipe.AddIngredient(ItemID.HallowedBar, 15); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.HallowedBar, 15); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/Vanity/ApolloMask.cs b/Items/Armor/Vanity/ApolloMask.cs index f478a39f96..dd6d439108 100644 --- a/Items/Armor/Vanity/ApolloMask.cs +++ b/Items/Armor/Vanity/ApolloMask.cs @@ -5,7 +5,7 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Items.Armor.Vanity { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class ApolloMask : ModItem, IExtendedHat { public override void SetStaticDefaults() diff --git a/Items/Armor/Vanity/ArtemisMask.cs b/Items/Armor/Vanity/ArtemisMask.cs index 166a9cef23..4215c99c55 100644 --- a/Items/Armor/Vanity/ArtemisMask.cs +++ b/Items/Armor/Vanity/ArtemisMask.cs @@ -5,7 +5,7 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Items.Armor.Vanity { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class ArtemisMask : ModItem, IExtendedHat { public override void SetStaticDefaults() diff --git a/Items/Armor/Vanity/SilvaHelm.cs b/Items/Armor/Vanity/SilvaHelm.cs index 7fc1cb8504..ba566100d9 100644 --- a/Items/Armor/Vanity/SilvaHelm.cs +++ b/Items/Armor/Vanity/SilvaHelm.cs @@ -18,9 +18,9 @@ namespace CalamityMod.Items.Armor.Vanity item.height = 20; item.value = Item.buyPrice(0, 8, 0, 0); item.vanity = true; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + } public override bool IsArmorSet(Item head, Item body, Item legs) { diff --git a/Items/Armor/Vanity/SilvaHornedHelm.cs b/Items/Armor/Vanity/SilvaHornedHelm.cs index caf92cbee2..1603cf3c9a 100644 --- a/Items/Armor/Vanity/SilvaHornedHelm.cs +++ b/Items/Armor/Vanity/SilvaHornedHelm.cs @@ -18,9 +18,9 @@ namespace CalamityMod.Items.Armor.Vanity item.height = 24; item.value = Item.buyPrice(0, 8, 0, 0); item.vanity = true; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + } public override bool IsArmorSet(Item head, Item body, Item legs) { diff --git a/Items/Armor/Vanity/SilvaMask.cs b/Items/Armor/Vanity/SilvaMask.cs index b57b140c58..471d5cd418 100644 --- a/Items/Armor/Vanity/SilvaMask.cs +++ b/Items/Armor/Vanity/SilvaMask.cs @@ -18,9 +18,9 @@ namespace CalamityMod.Items.Armor.Vanity item.height = 26; item.value = Item.buyPrice(0, 8, 0, 0); item.vanity = true; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + } public override bool IsArmorSet(Item head, Item body, Item legs) { diff --git a/Items/Armor/VictideHelm.cs b/Items/Armor/VictideHelm.cs index 2b5f34be26..7f0897b6f2 100644 --- a/Items/Armor/VictideHelm.cs +++ b/Items/Armor/VictideHelm.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { player.setBonus = "Enemies are more likely to target you\n" + - "+3 life regen and 10% increased melee damage while submerged in liquid\n" + + "+3 life regen and 10% increased melee damage while submerged in liquid\n" + "When using any weapon you have a 10% chance to throw a returning seashell projectile\n" + "This seashell does true damage and does not benefit from any damage class\n" + "Provides increased underwater mobility and slightly reduces breath loss in the abyss"; diff --git a/Items/Armor/VictideHelmet.cs b/Items/Armor/VictideHelmet.cs index 757c5ba1f1..295ef51def 100644 --- a/Items/Armor/VictideHelmet.cs +++ b/Items/Armor/VictideHelmet.cs @@ -38,12 +38,12 @@ namespace CalamityMod.Items.Armor "When using any weapon you have a 10% chance to throw a returning seashell projectile\n" + "This seashell does true damage and does not benefit from any damage class\n" + "Provides increased underwater mobility and slightly reduces breath loss in the abyss\n" + - "+1 max minion"; + "+1 max minion"; CalamityPlayer modPlayer = player.Calamity(); modPlayer.victideSet = true; modPlayer.urchin = true; - player.maxMinions++; - if (player.whoAmI == Main.myPlayer) + player.maxMinions++; + if (player.whoAmI == Main.myPlayer) { if (player.FindBuffIndex(ModContent.BuffType()) == -1) { diff --git a/Items/Armor/WulfrumHelm.cs b/Items/Armor/WulfrumHelm.cs index ab3d00f6c9..973b2ffe21 100644 --- a/Items/Armor/WulfrumHelm.cs +++ b/Items/Armor/WulfrumHelm.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { player.setBonus = "Enemies are more likely to target you\n" + - "+3 defense\n" + + "+3 defense\n" + "+5 defense when below 50% life"; player.statDefense += 3; //11 if (player.statLife <= (int)(player.statLifeMax2 * 0.5)) diff --git a/Items/Armor/WulfrumHelmet.cs b/Items/Armor/WulfrumHelmet.cs index a67ed7e7ea..8241722f7e 100644 --- a/Items/Armor/WulfrumHelmet.cs +++ b/Items/Armor/WulfrumHelmet.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Armor player.setBonus = "+3 defense and +1 max minion\n" + "+5 defense when below 50% life"; player.statDefense += 3; //8 - player.maxMinions++; - if (player.statLife <= (int)(player.statLifeMax2 * 0.5)) + player.maxMinions++; + if (player.statLife <= (int)(player.statLifeMax2 * 0.5)) { player.statDefense += 5; //13 } diff --git a/Items/Armor/XerocCuisses.cs b/Items/Armor/XerocCuisses.cs index 449eb27d3f..3a8e01bdb9 100644 --- a/Items/Armor/XerocCuisses.cs +++ b/Items/Armor/XerocCuisses.cs @@ -12,8 +12,8 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Empyrean Cuisses"); Tooltip.SetDefault("Speed of the cosmos\n" + - "5% increased rogue damage and critical strike chance\n" + - "15% increased movement speed"); + "5% increased rogue damage and critical strike chance\n" + + "15% increased movement speed"); } public override void SetDefaults() diff --git a/Items/Armor/XerocMask.cs b/Items/Armor/XerocMask.cs index 7c4b7386a1..94f59b7b8e 100644 --- a/Items/Armor/XerocMask.cs +++ b/Items/Armor/XerocMask.cs @@ -6,14 +6,14 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { - [AutoloadEquip(EquipType.Head)] + [AutoloadEquip(EquipType.Head)] public class XerocMask : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Empyrean Mask"); Tooltip.SetDefault("Wrath of the cosmos\n" + - "11% increased rogue damage and critical strike chance, 5% increased movement speed\n" + + "11% increased rogue damage and critical strike chance, 5% increased movement speed\n" + "Temporary immunity to lava"); } @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Armor { player.armorEffectDrawShadow = true; player.armorEffectDrawOutlines = true; - player.Calamity().meldTransformation = true; + player.Calamity().meldTransformation = true; player.Calamity().meldTransformationForce = true; } diff --git a/Items/Armor/XerocPlateMail.cs b/Items/Armor/XerocPlateMail.cs index e0fa88129c..cf9e3cc40f 100644 --- a/Items/Armor/XerocPlateMail.cs +++ b/Items/Armor/XerocPlateMail.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Empyrean Cloak"); Tooltip.SetDefault("Armor of the cosmos\n" + - "+20 max life\n" + + "+20 max life\n" + "7% increased rogue damage and critical strike chance"); } diff --git a/Items/BleachBall.cs b/Items/BleachBall.cs index a0765d209a..106dcf67da 100644 --- a/Items/BleachBall.cs +++ b/Items/BleachBall.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Items public override void UpdateInventory(Player player) { - if (item.favorited) - player.Calamity().disableNaturalScourgeSpawns = true; + if (item.favorited) + player.Calamity().disableNaturalScourgeSpawns = true; } public override void AddRecipes() diff --git a/Items/BrokenWaterFilter.cs b/Items/BrokenWaterFilter.cs index 78b9b13e2e..41053a2a71 100644 --- a/Items/BrokenWaterFilter.cs +++ b/Items/BrokenWaterFilter.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Items { - public class BrokenWaterFilter : ModItem + public class BrokenWaterFilter : ModItem { public override void SetStaticDefaults() { @@ -20,8 +20,8 @@ namespace CalamityMod.Items } public override void UpdateInventory(Player player) { - if (item.favorited) - player.Calamity().noStupidNaturalARSpawns = true; + if (item.favorited) + player.Calamity().noStupidNaturalARSpawns = true; } public override void AddRecipes() { diff --git a/Items/CalamityGlobalItemLoot.cs b/Items/CalamityGlobalItemLoot.cs index 9c70e5b221..636e9cc583 100644 --- a/Items/CalamityGlobalItemLoot.cs +++ b/Items/CalamityGlobalItemLoot.cs @@ -13,317 +13,317 @@ using Terraria.ModLoader; namespace CalamityMod.Items { - public class CalamityGlobalItemLoot : GlobalItem - { - public override bool InstancePerEntity => false; - public override bool CloneNewInstances => false; + public class CalamityGlobalItemLoot : GlobalItem + { + public override bool InstancePerEntity => false; + public override bool CloneNewInstances => false; - // NOTE: this function applies to all right-click-to-open items, even modded ones (despite the name). - // This means it applies to boss bags, crates, lockboxes, herb bags, goodie bags, and presents. - // The internal names of these cases are as follows (TML 0.11 API): - // bossBag, crate, lockBox, herbBag, goodieBag, present - public override void OpenVanillaBag(string context, Player player, int itemID) - { - if (context == "crate") - CrateLoot(player, itemID); + // NOTE: this function applies to all right-click-to-open items, even modded ones (despite the name). + // This means it applies to boss bags, crates, lockboxes, herb bags, goodie bags, and presents. + // The internal names of these cases are as follows (TML 0.11 API): + // bossBag, crate, lockBox, herbBag, goodieBag, present + public override void OpenVanillaBag(string context, Player player, int itemID) + { + if (context == "crate") + CrateLoot(player, itemID); - else if (context == "bossBag") - BossBagLoot(player, itemID); + else if (context == "bossBag") + BossBagLoot(player, itemID); - // Bat Hook is now acquired from Vampires. - else if (context == "goodieBag") - DropHelper.BlockDrops(ItemID.BatHook); - } + // Bat Hook is now acquired from Vampires. + else if (context == "goodieBag") + DropHelper.BlockDrops(ItemID.BatHook); + } - #region Boss Bags - private static void BossBagLoot(Player player, int itemID) - { - // Give a chance for Laudanum, Stress Pills and Heart of Darkness from every boss bag - DropHelper.DropRevBagAccessories(player); + #region Boss Bags + private static void BossBagLoot(Player player, int itemID) + { + // Give a chance for Laudanum, Stress Pills and Heart of Darkness from every boss bag + DropHelper.DropRevBagAccessories(player); - switch (itemID) - { - case ItemID.KingSlimeBossBag: - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); - break; + switch (itemID) + { + case ItemID.KingSlimeBossBag: + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); + break; - case ItemID.EyeOfCthulhuBossBag: - DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateFloat); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); - break; + case ItemID.EyeOfCthulhuBossBag: + DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateFloat); + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); + break; - case ItemID.EaterOfWorldsBossBag: - DropHelper.DropItemCondition(player, ItemID.ShadowScale, CalamityWorld.revenge, 60, 120); - DropHelper.DropItemCondition(player, ItemID.DemoniteOre, CalamityWorld.revenge, 120, 240); - break; + case ItemID.EaterOfWorldsBossBag: + DropHelper.DropItemCondition(player, ItemID.ShadowScale, CalamityWorld.revenge, 60, 120); + DropHelper.DropItemCondition(player, ItemID.DemoniteOre, CalamityWorld.revenge, 120, 240); + break; - case ItemID.BrainOfCthulhuBossBag: - DropHelper.DropItemCondition(player, ItemID.TissueSample, CalamityWorld.revenge, 60, 120); - DropHelper.DropItemCondition(player, ItemID.CrimtaneOre, CalamityWorld.revenge, 100, 180); - break; + case ItemID.BrainOfCthulhuBossBag: + DropHelper.DropItemCondition(player, ItemID.TissueSample, CalamityWorld.revenge, 60, 120); + DropHelper.DropItemCondition(player, ItemID.CrimtaneOre, CalamityWorld.revenge, 100, 180); + break; - case ItemID.QueenBeeBossBag: - // Drop weapons Calamity style instead of mutually exclusive. - int[] queenBeeWeapons = new int[] - { - ItemID.BeeKeeper, - ItemID.BeesKnees, - ItemID.BeeGun - }; - DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, queenBeeWeapons); - DropHelper.BlockDrops(queenBeeWeapons); + case ItemID.QueenBeeBossBag: + // Drop weapons Calamity style instead of mutually exclusive. + int[] queenBeeWeapons = new int[] + { + ItemID.BeeKeeper, + ItemID.BeesKnees, + ItemID.BeeGun + }; + DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, queenBeeWeapons); + DropHelper.BlockDrops(queenBeeWeapons); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); - DropHelper.DropItem(player, ItemID.Stinger, 8, 12); // Extra stingers - DropHelper.DropItem(player, ModContent.ItemType(), 50, 75); - break; + DropHelper.DropItem(player, ItemID.Stinger, 8, 12); // Extra stingers + DropHelper.DropItem(player, ModContent.ItemType(), 50, 75); + break; - case ItemID.WallOfFleshBossBag: - // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. - int[] wofWeapons = new int[] - { - ItemID.BreakerBlade, - ItemID.ClockworkAssaultRifle, - ModContent.ItemType(), - ItemID.LaserRifle, - ModContent.ItemType(), - ModContent.ItemType() - }; - DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, wofWeapons); - DropHelper.BlockDrops(wofWeapons); + case ItemID.WallOfFleshBossBag: + // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. + int[] wofWeapons = new int[] + { + ItemID.BreakerBlade, + ItemID.ClockworkAssaultRifle, + ModContent.ItemType(), + ItemID.LaserRifle, + ModContent.ItemType(), + ModContent.ItemType() + }; + DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, wofWeapons); + DropHelper.BlockDrops(wofWeapons); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); - // Drop emblems Calamity style instead of mutually exclusive -- this includes the Rogue Emblem. - int[] emblems = new int[] - { - ItemID.WarriorEmblem, - ItemID.RangerEmblem, - ItemID.SorcererEmblem, - ItemID.SummonerEmblem, - ModContent.ItemType(), - }; - DropHelper.DropEntireSet(player, 0.25f, emblems); - DropHelper.BlockDrops(emblems); - break; + // Drop emblems Calamity style instead of mutually exclusive -- this includes the Rogue Emblem. + int[] emblems = new int[] + { + ItemID.WarriorEmblem, + ItemID.RangerEmblem, + ItemID.SorcererEmblem, + ItemID.SummonerEmblem, + ModContent.ItemType(), + }; + DropHelper.DropEntireSet(player, 0.25f, emblems); + DropHelper.BlockDrops(emblems); + break; - case ItemID.DestroyerBossBag: - // Only drop hallowed bars after all mechs are down. - if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) - DropHelper.BlockDrops(ItemID.HallowedBar); + case ItemID.DestroyerBossBag: + // Only drop hallowed bars after all mechs are down. + if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) + DropHelper.BlockDrops(ItemID.HallowedBar); - break; + break; - case ItemID.TwinsBossBag: - // Only drop hallowed bars after all mechs are down. - if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) - DropHelper.BlockDrops(ItemID.HallowedBar); + case ItemID.TwinsBossBag: + // Only drop hallowed bars after all mechs are down. + if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) + DropHelper.BlockDrops(ItemID.HallowedBar); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); - break; + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); + break; - case ItemID.SkeletronPrimeBossBag: - // Only drop hallowed bars after all mechs are down. - if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) - DropHelper.BlockDrops(ItemID.HallowedBar); + case ItemID.SkeletronPrimeBossBag: + // Only drop hallowed bars after all mechs are down. + if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) + DropHelper.BlockDrops(ItemID.HallowedBar); - break; + break; - case ItemID.PlanteraBossBag: - // Drop weapons Calamity style instead of mutually exclusive. - int[] planteraWeapons = new int[] - { - ItemID.FlowerPow, - ItemID.Seedler, - ItemID.GrenadeLauncher, - ItemID.VenusMagnum, - ItemID.LeafBlower, - ItemID.NettleBurst, - ItemID.WaspGun, - ModContent.ItemType() - }; - DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, planteraWeapons); - DropHelper.BlockDrops(planteraWeapons); + case ItemID.PlanteraBossBag: + // Drop weapons Calamity style instead of mutually exclusive. + int[] planteraWeapons = new int[] + { + ItemID.FlowerPow, + ItemID.Seedler, + ItemID.GrenadeLauncher, + ItemID.VenusMagnum, + ItemID.LeafBlower, + ItemID.NettleBurst, + ItemID.WaspGun, + ModContent.ItemType() + }; + DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, planteraWeapons); + DropHelper.BlockDrops(planteraWeapons); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); - DropHelper.DropItem(player, ModContent.ItemType(), 16, 22); - break; + DropHelper.DropItem(player, ModContent.ItemType(), 16, 22); + break; - case ItemID.GolemBossBag: - // Drop loot Calamity style instead of mutually exclusive. - int[] golemItems = new int[] - { - ItemID.GolemFist, - ItemID.PossessedHatchet, - ItemID.Stynger, - ItemID.HeatRay, - ItemID.StaffofEarth, - ItemID.EyeoftheGolem, - ItemID.SunStone - }; - DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, golemItems); - DropHelper.BlockDrops(golemItems); + case ItemID.GolemBossBag: + // Drop loot Calamity style instead of mutually exclusive. + int[] golemItems = new int[] + { + ItemID.GolemFist, + ItemID.PossessedHatchet, + ItemID.Stynger, + ItemID.HeatRay, + ItemID.StaffofEarth, + ItemID.EyeoftheGolem, + ItemID.SunStone + }; + DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, golemItems); + DropHelper.BlockDrops(golemItems); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); - // The Picksaw always drops if the player doesn't have one in their inventory. Otherwise it has a 25% chance. - bool playerHasPicksaw = player.InventoryHas(ItemID.Picksaw); - DropHelper.DropItemChance(player, ItemID.Picksaw, playerHasPicksaw ? 0.25f : 1.0f); + // The Picksaw always drops if the player doesn't have one in their inventory. Otherwise it has a 25% chance. + bool playerHasPicksaw = player.InventoryHas(ItemID.Picksaw); + DropHelper.DropItemChance(player, ItemID.Picksaw, playerHasPicksaw ? 0.25f : 1.0f); - DropHelper.DropItem(player, ModContent.ItemType(), 8, 13); - break; + DropHelper.DropItem(player, ModContent.ItemType(), 8, 13); + break; - case ItemID.BossBagBetsy: - // Drop weapons Calamity style instead of mutually exclusive. - int[] betsyWeapons = new int[] - { - ItemID.DD2SquireBetsySword, // Flying Dragon - ItemID.MonkStaffT3, // Sky Dragon's Fury - ItemID.DD2BetsyBow, // Aerial Bane - ItemID.ApprenticeStaffT3, // Betsy's Wrath - }; - DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, betsyWeapons); - DropHelper.BlockDrops(betsyWeapons); - break; + case ItemID.BossBagBetsy: + // Drop weapons Calamity style instead of mutually exclusive. + int[] betsyWeapons = new int[] + { + ItemID.DD2SquireBetsySword, // Flying Dragon + ItemID.MonkStaffT3, // Sky Dragon's Fury + ItemID.DD2BetsyBow, // Aerial Bane + ItemID.ApprenticeStaffT3, // Betsy's Wrath + }; + DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, betsyWeapons); + DropHelper.BlockDrops(betsyWeapons); + break; - case ItemID.FishronBossBag: - // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. - int[] dukeWeapons = new int[] - { - ItemID.Flairon, - ItemID.Tsunami, - ItemID.BubbleGun, - ItemID.RazorbladeTyphoon, - ItemID.TempestStaff, - ItemID.FishronWings, - ModContent.ItemType() - }; - DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, dukeWeapons); - DropHelper.BlockDrops(dukeWeapons); + case ItemID.FishronBossBag: + // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. + int[] dukeWeapons = new int[] + { + ItemID.Flairon, + ItemID.Tsunami, + ItemID.BubbleGun, + ItemID.RazorbladeTyphoon, + ItemID.TempestStaff, + ItemID.FishronWings, + ModContent.ItemType() + }; + DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, dukeWeapons); + DropHelper.BlockDrops(dukeWeapons); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); - break; + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); + break; - case ItemID.MoonLordBossBag: - // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. - int[] moonLordWeapons = new int[] - { - ItemID.Meowmere, - ItemID.StarWrath, - ItemID.Terrarian, - ItemID.FireworksLauncher, // Celebration - // ItemID.CelebrationMK2, - ItemID.SDMG, - ItemID.LastPrism, - ItemID.LunarFlareBook, - ItemID.MoonlordTurretStaff, // Lunar Portal Staff - ItemID.RainbowCrystalStaff, - ModContent.ItemType(), - }; - DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, moonLordWeapons); - DropHelper.BlockDrops(moonLordWeapons); + case ItemID.MoonLordBossBag: + // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. + int[] moonLordWeapons = new int[] + { + ItemID.Meowmere, + ItemID.StarWrath, + ItemID.Terrarian, + ItemID.FireworksLauncher, // Celebration + // ItemID.CelebrationMK2, + ItemID.SDMG, + ItemID.LastPrism, + ItemID.LunarFlareBook, + ItemID.MoonlordTurretStaff, // Lunar Portal Staff + ItemID.RainbowCrystalStaff, + ModContent.ItemType(), + }; + DropHelper.DropEntireSet(player, DropHelper.BagWeaponDropRateFloat, moonLordWeapons); + DropHelper.BlockDrops(moonLordWeapons); - // The Celestial Onion only drops if the player hasn't used one and doesn't have one in their inventory. - int celestialOnion = ModContent.ItemType(); - DropHelper.DropItemCondition(player, celestialOnion, !player.Calamity().extraAccessoryML && !player.InventoryHas(celestialOnion)); - break; - } - } - #endregion + // The Celestial Onion only drops if the player hasn't used one and doesn't have one in their inventory. + int celestialOnion = ModContent.ItemType(); + DropHelper.DropItemCondition(player, celestialOnion, !player.Calamity().extraAccessoryML && !player.InventoryHas(celestialOnion)); + break; + } + } + #endregion - #region Fishing Crates - private static void CrateLoot(Player player, int itemID) - { - switch (itemID) - { - case ItemID.WoodenCrate: - BlockCrateDrops(); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f, 3, 5); - break; + #region Fishing Crates + private static void CrateLoot(Player player, int itemID) + { + switch (itemID) + { + case ItemID.WoodenCrate: + BlockCrateDrops(); + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f, 3, 5); + break; - case ItemID.IronCrate: - BlockCrateDrops(); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f, 5, 8); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f, 5, 8); - break; + case ItemID.IronCrate: + BlockCrateDrops(); + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f, 5, 8); + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f, 5, 8); + break; - case ItemID.GoldenCrate: - BlockCrateDrops(); - break; + case ItemID.GoldenCrate: + BlockCrateDrops(); + break; - case ItemID.CorruptFishingCrate: - case ItemID.CrimsonFishingCrate: - BlockCrateDrops(); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.15f, 5, 8); - break; + case ItemID.CorruptFishingCrate: + case ItemID.CrimsonFishingCrate: + BlockCrateDrops(); + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.15f, 5, 8); + break; - case ItemID.HallowedFishingCrate: - BlockCrateDrops(); - int potion = WorldGen.crimson ? ModContent.ItemType() : ModContent.ItemType(); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedProvidence, 0.15f, 5, 10); - DropHelper.DropItemCondition(player, potion, CalamityWorld.downedProvidence, 0.1f, 1, 2); - break; + case ItemID.HallowedFishingCrate: + BlockCrateDrops(); + int potion = WorldGen.crimson ? ModContent.ItemType() : ModContent.ItemType(); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedProvidence, 0.15f, 5, 10); + DropHelper.DropItemCondition(player, potion, CalamityWorld.downedProvidence, 0.1f, 1, 2); + break; - case ItemID.DungeonFishingCrate: - BlockCrateDrops(); - DropHelper.DropItemCondition(player, ItemID.Ectoplasm, NPC.downedPlantBoss, 0.1f, 1, 5); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedPolterghast, 0.1f, 1, 5); - break; + case ItemID.DungeonFishingCrate: + BlockCrateDrops(); + DropHelper.DropItemCondition(player, ItemID.Ectoplasm, NPC.downedPlantBoss, 0.1f, 1, 5); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedPolterghast, 0.1f, 1, 5); + break; - case ItemID.JungleFishingCrate: - BlockCrateDrops(); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.2f, 1, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.hardMode, 0.2f, 1, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.hardMode, 0.2f, 1, 3); - DropHelper.DropItemCondition(player, ItemID.ChlorophyteBar, CalamityWorld.downedCalamitas || NPC.downedPlantBoss, 0.1f, 1, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), NPC.downedPlantBoss, 0.1f, 1, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), NPC.downedGolemBoss, 0.2f, 3, 6); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedProvidence, 0.1f, 1, 3); - break; + case ItemID.JungleFishingCrate: + BlockCrateDrops(); + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.2f, 1, 3); + DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.hardMode, 0.2f, 1, 3); + DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.hardMode, 0.2f, 1, 3); + DropHelper.DropItemCondition(player, ItemID.ChlorophyteBar, CalamityWorld.downedCalamitas || NPC.downedPlantBoss, 0.1f, 1, 3); + DropHelper.DropItemCondition(player, ModContent.ItemType(), NPC.downedPlantBoss, 0.1f, 1, 3); + DropHelper.DropItemCondition(player, ModContent.ItemType(), NPC.downedGolemBoss, 0.2f, 3, 6); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedProvidence, 0.1f, 1, 3); + break; - case ItemID.FloatingIslandFishingCrate: - BlockCrateDrops(); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedHiveMind || CalamityWorld.downedPerforator, 0.1f, 1, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.hardMode, 0.2f, 2, 4); - DropHelper.DropItemCondition(player, ModContent.ItemType(), NPC.downedMoonlord, 0.1f, 1, 3); - break; - } - } + case ItemID.FloatingIslandFishingCrate: + BlockCrateDrops(); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedHiveMind || CalamityWorld.downedPerforator, 0.1f, 1, 3); + DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.hardMode, 0.2f, 2, 4); + DropHelper.DropItemCondition(player, ModContent.ItemType(), NPC.downedMoonlord, 0.1f, 1, 3); + break; + } + } - private static void BlockCrateDrops() - { - bool twoMechsDowned = - (NPC.downedMechBoss1 && NPC.downedMechBoss2) || - (NPC.downedMechBoss2 && NPC.downedMechBoss3) || - (NPC.downedMechBoss3 && NPC.downedMechBoss1); - int[] preMechBlockedDrops_Crate = new int[] - { - ItemID.MythrilOre, - ItemID.OrichalcumOre, - ItemID.AdamantiteOre, - ItemID.TitaniumOre, - ItemID.MythrilBar, - ItemID.OrichalcumBar, - ItemID.AdamantiteBar, - ItemID.TitaniumBar, - }; - int[] postOneMechBlockedDrops_Crate = new int[] - { - ItemID.AdamantiteOre, - ItemID.TitaniumOre, - ItemID.AdamantiteBar, - ItemID.TitaniumBar, - }; - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) - { - if (!NPC.downedMechBossAny) - DropHelper.BlockDrops(preMechBlockedDrops_Crate); - else if (!twoMechsDowned) - DropHelper.BlockDrops(postOneMechBlockedDrops_Crate); - } - } - #endregion - } + private static void BlockCrateDrops() + { + bool twoMechsDowned = + (NPC.downedMechBoss1 && NPC.downedMechBoss2) || + (NPC.downedMechBoss2 && NPC.downedMechBoss3) || + (NPC.downedMechBoss3 && NPC.downedMechBoss1); + int[] preMechBlockedDrops_Crate = new int[] + { + ItemID.MythrilOre, + ItemID.OrichalcumOre, + ItemID.AdamantiteOre, + ItemID.TitaniumOre, + ItemID.MythrilBar, + ItemID.OrichalcumBar, + ItemID.AdamantiteBar, + ItemID.TitaniumBar, + }; + int[] postOneMechBlockedDrops_Crate = new int[] + { + ItemID.AdamantiteOre, + ItemID.TitaniumOre, + ItemID.AdamantiteBar, + ItemID.TitaniumBar, + }; + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) + { + if (!NPC.downedMechBossAny) + DropHelper.BlockDrops(preMechBlockedDrops_Crate); + else if (!twoMechsDowned) + DropHelper.BlockDrops(postOneMechBlockedDrops_Crate); + } + } + #endregion + } } diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index 77c04d4448..f9027f861e 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -5,1120 +5,1120 @@ using Terraria.ModLoader; namespace CalamityMod.Items { - public partial class CalamityGlobalItem : GlobalItem - { - #region Database and Initialization - internal static SortedDictionary currentTweaks = null; - - internal static void LoadTweaks() - { - // Various shorthands for items which receive very simple changes, such as setting one flag. - IItemTweak[] trueMelee = Do(TrueMelee); - IItemTweak[] pointBlank = Do(PointBlank); - IItemTweak[] autoReuse = Do(AutoReuse); - IItemTweak[] maxStack999 = Do(MaxStack(999)); - IItemTweak[] nonConsumableBossSummon = Do(MaxStack(1), NotConsumable); - - // Please keep this strictly alphabetical. It's the only way to keep it sane. Thanks in advance. - // - Ozzatron - currentTweaks = new SortedDictionary - { - { ItemID.Abeemination, nonConsumableBossSummon }, - { ItemID.AdamantiteChainsaw, Do(TrueMelee, AxePower(90), UseTimeExact(4), TileBoostExact(+0)) }, - { ItemID.AdamantiteDrill, Do(TrueMelee, PickPower(180), UseTimeExact(4), TileBoostExact(+1)) }, - { ItemID.AdamantiteGlaive, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(65), ShootSpeedRatio(1.25f)) }, - { ItemID.AdamantitePickaxe, Do(PickPower(180), UseTimeExact(8), TileBoostExact(+1)) }, - { ItemID.AdamantiteRepeater, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.AdamantiteSword, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(77)) }, - { ItemID.AdamantiteWaraxe, Do(AxePower(160), UseTimeExact(10), TileBoostExact(+1)) }, - { ItemID.Amarok, autoReuse }, - { ItemID.AmberStaff, Do(DamageRatio(1.33f), UseTimeExact(15), UseAnimationExact(40)) }, - { ItemID.AmethystStaff, Do(ManaExact(2)) }, - { ItemID.Anchor, Do(DamageExact(107)) }, - { ItemID.AnkhShield, Do(DefenseDelta(+8)) }, - { ItemID.AntlionClaw, Do(ScaleRatio(1.5f), DamageRatio(1.5f)) }, - { ItemID.AquaScepter, Do(DamageExact(21), ShootSpeedExact(25f)) }, - { ItemID.Arkhalis, trueMelee }, - // { ItemID.BabyBirdStaff, Do(AutoReuse, UseExact(35)) }, - { ItemID.BallOHurt, Do(DamageRatio(2f)) }, - { ItemID.Bananarang, Do(DamageExact(110)) }, - { ItemID.BatScepter, Do(DamageRatio(1.1f)) }, - { ItemID.BeamSword, Do(AutoReuse, DamageExact(360), UseAnimationExact(60), ShootSpeedExact(23f)) }, - { ItemID.BeeGun, Do(DamageExact(11)) }, - { ItemID.BeeKeeper, Do(UseTurn, ScaleRatio(1.5f), DamageRatio(2.5f)) }, - { ItemID.BeesKnees, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.BladedGlove, Do(DamageExact(15), UseExact(7)) }, - { ItemID.BladeofGrass, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageExact(65)) }, - { ItemID.Bladetongue, Do(UseTurn, UseRatio(0.8f), DamageExact(120), ScaleRatio(1.75f)) }, - { ItemID.BlizzardStaff, Do(DamageExact(41), ManaExact(7)) }, - { ItemID.BloodButcherer, Do(AutoReuse, UseTurn, DamageRatio(1.66f)) }, - { ItemID.BloodLustCluster, Do(AxePower(100), UseTimeExact(13), TileBoostExact(+0)) }, - { ItemID.BloodyMachete, Do(AutoReuse, DamageExact(30)) }, - { ItemID.BloodySpine, nonConsumableBossSummon }, - { ItemID.Blowgun, pointBlank }, - { ItemID.Blowpipe, pointBlank }, - { ItemID.BlueMoon, Do(DamageRatio(2f)) }, - { ItemID.BluePhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, - { ItemID.BluePhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, - { ItemID.BlueSolution, Do(Value(Item.buyPrice(silver: 5))) }, - { ItemID.BoneArrow, Do(DamageRatio(1.1f)) }, - { ItemID.BonePickaxe, Do(PickPower(55), UseTimeExact(6)) }, - { ItemID.BoneSword, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(1.25f)) }, - { ItemID.BookofSkulls, Do(ManaExact(12), ShootSpeedExact(9f)) }, - { ItemID.BookStaff, Do(ManaExact(10), DamageRatio(1.25f)) }, - { ItemID.Boomstick, pointBlank }, - { ItemID.BorealWoodBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.BorealWoodHammer, Do(HammerPower(25), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.BorealWoodSword, Do(AutoReuse, UseTurn) }, - { ItemID.BouncyBomb, maxStack999 }, - { ItemID.BouncyDynamite, maxStack999 }, - { ItemID.BreakerBlade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageExact(97)) }, - { ItemID.ButchersChainsaw, Do(TrueMelee, AxePower(150), UseTimeExact(3), TileBoostExact(+0)) }, - { ItemID.CactusPickaxe, Do(PickPower(34), UseTimeExact(9)) }, - { ItemID.CactusSword, Do(AutoReuse, UseTurn) }, - { ItemID.CnadyCanePickaxe, Do(PickPower(55), UseTimeExact(9), TileBoostExact(+1)) }, // intentionally not in alphabetical order to correct for typo - { ItemID.CandyCaneSword, Do(AutoReuse, DamageRatio(1.25f)) }, - { ItemID.CandyCornRifle, pointBlank }, - { ItemID.Cascade, Do(AutoReuse, DamageExact(39)) }, - { ItemID.CelestialSigil, nonConsumableBossSummon }, - { ItemID.ChainGuillotines, Do(DamageExact(100)) }, - { ItemID.ChainGun, pointBlank }, - { ItemID.ChainKnife, Do(AutoReuse, DamageExact(14)) }, - { ItemID.ChargedBlasterCannon, Do(DamageRatio(1.33f)) }, - { ItemID.Chik, autoReuse }, - { ItemID.ChlorophyteArrow, Do(DamageRatio(1.1f)) }, - { ItemID.ChlorophyteChainsaw, Do(TrueMelee, AxePower(120), UseTimeExact(3), TileBoostExact(+0)) }, - { ItemID.ChlorophyteDrill, Do(TrueMelee, PickPower(200), UseTimeExact(4), TileBoostExact(+2)) }, - { ItemID.ChlorophyteGreataxe, Do(AxePower(165), UseTimeExact(7), TileBoostExact(+2)) }, - { ItemID.ChlorophyteJackhammer, Do(TrueMelee, HammerPower(90), UseTimeExact(5), TileBoostExact(+0)) }, - { ItemID.ChlorophytePartisan, Do(AutoReuse, UseRatio(0.8f), DamageExact(100)) }, - { ItemID.ChlorophytePickaxe, Do(PickPower(200), UseTimeExact(7), TileBoostExact(+2)) }, - { ItemID.ChlorophyteSaber, Do(DamageExact(80), UseTimeExact(10)) }, - { ItemID.ChlorophyteShotbow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.ChlorophyteWarhammer, Do(HammerPower(90), UseTimeExact(8), TileBoostExact(+2)) }, - { ItemID.ChristmasTreeSword, Do(AutoReuse, UseTurn, DamageExact(155)) }, - { ItemID.ClingerStaff, Do(DamageRatio(1.33f)) }, - { ItemID.ClockworkAssaultRifle, pointBlank }, - { ItemID.CobaltBreastplate, Do(DefenseDelta(+3)) }, - { ItemID.CobaltChainsaw, Do(TrueMelee, AxePower(70), UseTimeExact(4), TileBoostExact(-1)) }, - { ItemID.CobaltDrill, Do(TrueMelee, PickPower(130), UseTimeExact(5)) }, - { ItemID.CobaltHat, Do(DefenseDelta(+2)) }, - { ItemID.CobaltHelmet, Do(DefenseDelta(+5)) }, - { ItemID.CobaltLeggings, Do(DefenseDelta(+3)) }, - { ItemID.CobaltMask, Do(DefenseDelta(+3)) }, - { ItemID.CobaltNaginata, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(90)) }, - { ItemID.CobaltPickaxe, Do(PickPower(130), UseTimeExact(9)) }, - { ItemID.CobaltRepeater, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.CobaltShield, Do(DefenseDelta(+3)) }, - { ItemID.CobaltSword, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(80)) }, - { ItemID.CobaltWaraxe, Do(AxePower(125), UseTimeExact(12), TileBoostExact(+0)) }, - { ItemID.Code1, Do(AutoReuse, DamageExact(25)) }, - { ItemID.Code2, autoReuse }, - { ItemID.CopperAxe, Do(AxePower(50), UseTimeExact(16), TileBoostExact(+0)) }, - { ItemID.CopperBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.CopperBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.CopperHammer, Do(HammerPower(35), UseTimeExact(12), TileBoostExact(+0)) }, - { ItemID.CopperPickaxe, Do(PickPower(35), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.CopperShortsword, autoReuse }, - { ItemID.CorruptYoyo, Do(AutoReuse, DamageExact(27)) }, - { ItemID.CrimsonYoyo, Do(AutoReuse, DamageExact(30)) }, - { ItemID.CrystalSerpent, Do(DamageExact(45)) }, - { ItemID.CrystalVileShard, Do(DamageRatio(1.33f)) }, - { ItemID.CursedArrow, Do(DamageRatio(1.1f)) }, - { ItemID.Cutlass, Do(UseRatio(0.8f), DamageRatio(2f)) }, - { ItemID.DaedalusStormbow, Do(DamageRatio(0.9f)) }, - { ItemID.DaoofPow, Do(DamageExact(160)) }, - { ItemID.DarkBlueSolution, Do(Value(Item.buyPrice(silver: 5))) }, - { ItemID.DarkLance, Do(AutoReuse, TrueMelee, DamageExact(68)) }, - { ItemID.DartPistol, pointBlank }, - { ItemID.DartRifle, pointBlank }, - { ItemID.DayBreak, Do(DamageRatio(1.5f)) }, // TODO -- replace with 1.4 behavior of Daybreak spears exploding on death for 100% damage - { ItemID.DD2BallistraTowerT1Popper, Do(UseExact(30)) }, - { ItemID.DD2BallistraTowerT2Popper, Do(UseExact(25)) }, - { ItemID.DD2BallistraTowerT3Popper, Do(UseExact(20)) }, - { ItemID.DD2BetsyBow, Do(DamageRatio(1.1f)) }, // Aerial Bane's ridiculous multiplier is removed, so this compensates for that - { ItemID.DD2ExplosiveTrapT1Popper, Do(UseExact(30)) }, - { ItemID.DD2ExplosiveTrapT2Popper, Do(UseExact(25)) }, - { ItemID.DD2ExplosiveTrapT3Popper, Do(UseExact(20)) }, - { ItemID.DD2FlameburstTowerT1Popper, Do(UseExact(30)) }, - { ItemID.DD2FlameburstTowerT2Popper, Do(UseExact(25)) }, - { ItemID.DD2FlameburstTowerT3Popper, Do(UseExact(20)) }, - { ItemID.DD2LightningAuraT1Popper, Do(UseExact(30)) }, - { ItemID.DD2LightningAuraT2Popper, Do(UseExact(25)) }, - { ItemID.DD2LightningAuraT3Popper, Do(UseExact(20)) }, - { ItemID.DD2PhoenixBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.DD2SquireDemonSword, Do(DamageExact(110)) }, - { ItemID.DeadlySphereStaff, Do(UseExact(20)) }, - { ItemID.DeathbringerPickaxe, Do(PickPower(70), UseTimeExact(10)) }, - { ItemID.DeathSickle, Do(DamageExact(82), ShootSpeedExact(15f)) }, - { ItemID.DemonBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.DemonScythe, Do(AutoReuse, DamageExact(33), ManaExact(10)) }, - { ItemID.DiamondStaff, Do(DamageExact(26)) }, - { ItemID.Drax, Do(TrueMelee, PickPower(200), AxePower(110), UseTimeExact(4), TileBoostExact(+1)) }, - { ItemID.DyeTradersScimitar, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(1.33f)) }, - { ItemID.Dynamite, maxStack999 }, - { ItemID.EbonwoodBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.EbonwoodHammer, Do(HammerPower(25), UseTimeExact(9), TileBoostExact(+0)) }, - { ItemID.EbonwoodSword, Do(AutoReuse, UseTurn) }, - { ItemID.ElectrosphereLauncher, Do(DamageRatio(1.1f)) }, - { ItemID.EldMelter, Do(DamageRatio(1.5f)) }, // intentionally not in alphabetical order to correct for typo - { ItemID.EmeraldStaff, Do(DamageExact(28)) }, - // { ItemID.EmpressBlade, Do(UseExact(20)) }, - { ItemID.EnchantedBoomerang, Do(DamageRatio(2f)) }, - { ItemID.EnchantedSword, Do(ScaleRatio(1.5f), DamageExact(42), UseAnimationExact(20), ShootSpeedExact(15f)) }, - { ItemID.EndlessQuiver, Do(DamageRatio(1.1f)) }, - { ItemID.EoCShield, Do(DefenseDelta(+1)) }, - // { ItemID.Eventide, pointBlank }, - { ItemID.Excalibur, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(125)) }, - { ItemID.FalconBlade, Do(UseTurn, ScaleRatio(1.5f), DamageExact(40)) }, - { ItemID.FieryGreatsword, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageExact(98), UseExact(45)) }, - { ItemID.FireworksLauncher, Do(DamageRatio(2f)) }, - { ItemID.Flamarang, Do(DamageRatio(2f)) }, - { ItemID.Flamelash, Do(DamageExact(75), UseExact(38)) }, - { ItemID.Flamethrower, Do(DamageRatio(1.5f)) }, - { ItemID.FlamingArrow, Do(DamageRatio(1.1f)) }, - { ItemID.FlareGun, pointBlank }, - { ItemID.FleshGrinder, Do(HammerPower(70), UseTimeExact(13), TileBoostExact(+0)) }, - { ItemID.FlintlockPistol, pointBlank }, - // { ItemID.FlinxStaff, Do(AutoReuse, UseExact(35)) }, - { ItemID.FlowerofFire, Do(AutoReuse, DamageExact(60)) }, - { ItemID.FlowerofFrost, Do(DamageRatio(1.2f)) }, - { ItemID.FlowerPow, Do(DamageRatio(2f)) }, - { ItemID.FlyingKnife, Do(DamageExact(70)) }, - { ItemID.FormatC, autoReuse }, - { ItemID.Frostbrand, Do(DamageExact(140), UseTimeExact(20)) }, - { ItemID.FrostburnArrow, Do(DamageRatio(1.1f)) }, - { ItemID.FrostStaff, Do(ManaExact(9), DamageExact(215), UseTimeExact(50), UseAnimationExact(50), ShootSpeedExact(40f)) }, - { ItemID.FrozenTurtleShell, Do(DefenseDelta(+6)) }, - { ItemID.FruitcakeChakram, Do(DamageRatio(2f)) }, - { ItemID.Gatligator, pointBlank }, - { ItemID.GladiatorBreastplate, Do(DefenseDelta(+2)) }, - { ItemID.GladiatorHelmet, Do(DefenseDelta(+1)) }, - { ItemID.GladiatorLeggings, Do(DefenseDelta(+2)) }, - { ItemID.GoblinBattleStandard, nonConsumableBossSummon }, - { ItemID.GoldAxe, Do(AxePower(80), UseTimeExact(14), TileBoostExact(+0)) }, - { ItemID.GoldBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.GoldBroadsword, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, - { ItemID.GoldHammer, Do(HammerPower(60), UseTimeExact(9), TileBoostExact(+0)) }, - { ItemID.GoldPickaxe, Do(PickPower(55), UseTimeExact(9)) }, - { ItemID.GoldShortsword, Do(AutoReuse, DamageRatio(2f)) }, - { ItemID.GolemFist, Do(DamageExact(150)) }, - { ItemID.Gradient, autoReuse }, - { ItemID.GreenPhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, - { ItemID.GreenPhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, - { ItemID.GreenSolution, Do(Value(Item.buyPrice(silver: 5))) }, - { ItemID.GrenadeLauncher, Do(DamageRatio(2f)) }, - { ItemID.Gungnir, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(92), ShootSpeedRatio(1.25f)) }, - { ItemID.HallowedGreaves, Do(DefenseDelta(+2)) }, - { ItemID.HallowedPlateMail, Do(DefenseDelta(+3)) }, - { ItemID.HallowedRepeater, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.Hammush, Do(HammerPower(85), UseTimeExact(10), TileBoostExact(+1)) }, - { ItemID.Handgun, pointBlank }, - { ItemID.Harpoon, pointBlank }, - { ItemID.HelFire, autoReuse }, - { ItemID.HellfireArrow, Do(DamageRatio(1.1f)) }, - { ItemID.HellwingBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.HolyArrow, Do(DamageRatio(1.1f)) }, - { ItemID.HornetStaff, Do(AutoReuse, UseExact(30)) }, - { ItemID.IceBlade, Do(DamageExact(26), UseTimeExact(33)) }, - { ItemID.IceBoomerang, Do(DamageRatio(2f)) }, - { ItemID.IceBow, Do(PointBlank, DamageRatio(1.5f)) }, - { ItemID.IceSickle, Do(AutoReuse, DamageExact(95), ShootSpeedExact(20f)) }, - { ItemID.IchorArrow, Do(DamageRatio(1.1f)) }, - { ItemID.ImpStaff, Do(AutoReuse, UseExact(30)) }, - { ItemID.InfernoFork, Do(DamageRatio(1.66f)) }, - { ItemID.InfluxWaver, Do(DamageRatio(0.75f)) }, - { ItemID.IronAxe, Do(AxePower(60), UseTimeExact(15), TileBoostExact(+0)) }, - { ItemID.IronBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.IronBroadsword, Do(AutoReuse, UseTurn, DamageRatio(1.25f)) }, - { ItemID.IronHammer, Do(HammerPower(45), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.IronPickaxe, Do(PickPower(40), UseTimeExact(8)) }, - { ItemID.IronShortsword, Do(AutoReuse, DamageRatio(1.25f)) }, - { ItemID.JestersArrow, Do(DamageRatio(1.1f)) }, - { ItemID.JungleYoyo, autoReuse }, - { ItemID.Katana, Do(UseExact(15), DamageRatio(1.5f)) }, - { ItemID.Keybrand, Do(UseTurn, ScaleRatio(1.5f), DamageExact(184), UseExact(18)) }, - { ItemID.KOCannon, Do(DamageRatio(3f)) }, - { ItemID.Kraken, autoReuse }, - { ItemID.LaserDrill, Do(PickPower(220), AxePower(120), UseTimeExact(4)) }, - { ItemID.LastPrism, Do(DamageRatio(0.75f)) }, - { ItemID.LeadAxe, Do(AxePower(60), UseTimeExact(15), TileBoostExact(+0)) }, - { ItemID.LeadBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.LeadBroadsword, Do(AutoReuse, UseTurn, DamageRatio(1.25f)) }, - { ItemID.LeadHammer, Do(HammerPower(45), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.LeadPickaxe, Do(PickPower(40), UseTimeExact(8)) }, - { ItemID.LeadShortsword, Do(AutoReuse, DamageRatio(1.25f)) }, - { ItemID.LightDisc, Do(DamageExact(128)) }, - { ItemID.LightsBane, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, - { ItemID.LunarFlareBook, Do(DamageRatio(1.5f)) }, - { ItemID.LunarHamaxeNebula, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, - { ItemID.LunarHamaxeSolar, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, - { ItemID.LunarHamaxeStardust, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, - { ItemID.LunarHamaxeVortex, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, - { ItemID.MagicDagger, autoReuse }, - { ItemID.MagicMissile, Do(DamageExact(48), UseExact(15)) }, - { ItemID.MagnetSphere, Do(DamageRatio(1.1f)) }, - { ItemID.Marrow, Do(PointBlank, DamageRatio(1.5f)) }, - { ItemID.MechanicalEye, nonConsumableBossSummon }, - { ItemID.MechanicalSkull, nonConsumableBossSummon }, - { ItemID.MechanicalWorm, nonConsumableBossSummon }, - { ItemID.MedusaHead, Do(DamageRatio(1.66f)) }, - { ItemID.Megashark, pointBlank }, - { ItemID.Meowmere, Do(DamageRatio(1.33f)) }, - { ItemID.MeteorHamaxe, Do(HammerPower(70), AxePower(100), UseTimeExact(16), TileBoostExact(+0)) }, - { ItemID.MeteorStaff, Do(DamageExact(58), ManaExact(7), ShootSpeedExact(13f)) }, - { ItemID.Minishark, pointBlank }, - { ItemID.MoltenFury, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.MoltenHamaxe, Do(HammerPower(75), AxePower(125), UseTimeExact(14), TileBoostExact(+0)) }, - { ItemID.MoltenPickaxe, Do(PickPower(100), UseTimeExact(10)) }, - { ItemID.MonkStaffT1, Do(TrueMelee, DamageExact(110)) }, - { ItemID.MonkStaffT2, Do(AutoReuse, TrueMelee, DamageRatio(2f)) }, - { ItemID.MonkStaffT3, Do(DamageExact(225)) }, - { ItemID.MoonlordArrow, Do(DamageRatio(1.1f)) }, - { ItemID.MoonlordTurretStaff, Do(UseExact(15), DamageRatio(1.5f)) }, - { ItemID.Muramasa, Do(ScaleRatio(1.5f), DamageRatio(2f)) }, - { ItemID.MushroomSpear, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(100)) }, - { ItemID.Musket, pointBlank }, - { ItemID.MythrilChainsaw, Do(TrueMelee, AxePower(80), UseTimeExact(4), TileBoostExact(-1)) }, - { ItemID.MythrilDrill, Do(TrueMelee, PickPower(160), UseTimeExact(4)) }, - { ItemID.MythrilHalberd, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(95), ShootSpeedRatio(1.25f)) }, - { ItemID.MythrilPickaxe, Do(PickPower(160), UseTimeExact(8)) }, - { ItemID.MythrilRepeater, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.MythrilSword, Do(UseTurn, ScaleRatio(1.5f), DamageExact(100), UseExact(25)) }, - { ItemID.MythrilWaraxe, Do(AxePower(140), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.NaughtyPresent, nonConsumableBossSummon }, - { ItemID.NebulaChainsaw, trueMelee }, - { ItemID.NebulaDrill, Do(TrueMelee, PickPower(225), UseTimeExact(3), TileBoostExact(+4)) }, - { ItemID.NebulaPickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, - { ItemID.NettleBurst, Do(DamageRatio(1.33f)) }, - { ItemID.NightmarePickaxe, Do(PickPower(66), UseTimeExact(9)) }, - { ItemID.NightsEdge, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(3f)) }, - { ItemID.NorthPole, autoReuse }, - { ItemID.ObsidianShield, Do(DefenseDelta(+5)) }, - { ItemID.ObsidianSkull, Do(DefenseDelta(+1)) }, - { ItemID.ObsidianSwordfish, Do(AutoReuse, TrueMelee, DamageExact(45)) }, - { ItemID.OnyxBlaster, pointBlank }, - { ItemID.OpticStaff, Do(AutoReuse, UseExact(25), DamageRatio(0.75f)) }, // NOTE: Optic Staff minions have local iframes, so they should be much better overall - { ItemID.OrichalcumBreastplate, Do(DefenseDelta(+3)) }, - { ItemID.OrichalcumChainsaw, Do(TrueMelee, AxePower(80), UseTimeExact(4), TileBoostExact(-1)) }, - { ItemID.OrichalcumDrill, Do(TrueMelee, PickPower(160), UseTimeExact(4)) }, - { ItemID.OrichalcumHalberd, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(98), ShootSpeedRatio(1.25f)) }, - { ItemID.OrichalcumHeadgear, Do(DefenseDelta(+2)) }, - { ItemID.OrichalcumHelmet, Do(DefenseDelta(+3)) }, - { ItemID.OrichalcumLeggings, Do(DefenseDelta(+4)) }, - { ItemID.OrichalcumMask, Do(DefenseDelta(+3)) }, - { ItemID.OrichalcumPickaxe, Do(PickPower(160), UseTimeExact(8)) }, - { ItemID.OrichalcumRepeater, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.OrichalcumSword, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(82)) }, - { ItemID.OrichalcumWaraxe, Do(AxePower(140), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.PainterPaintballGun, pointBlank }, - { ItemID.PaladinsHammer, Do(AutoReuse, DamageExact(100)) }, - { ItemID.PaladinsShield, Do(DefenseDelta(+3)) }, - { ItemID.PalladiumBreastplate, Do(DefenseDelta(+3)) }, - { ItemID.PalladiumChainsaw, Do(TrueMelee, AxePower(70), UseTimeExact(4), TileBoostExact(-1)) }, - { ItemID.PalladiumDrill, Do(TrueMelee, PickPower(130), UseTimeExact(5)) }, - { ItemID.PalladiumHeadgear, Do(DefenseDelta(+2)) }, - { ItemID.PalladiumHelmet, Do(DefenseDelta(+3)) }, - { ItemID.PalladiumMask, Do(DefenseDelta(+1)) }, - { ItemID.PalladiumLeggings, Do(DefenseDelta(+3)) }, - { ItemID.PalladiumPickaxe, Do(PickPower(130), UseTimeExact(9)) }, - { ItemID.PalladiumPike, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageRatio(3f)) }, - { ItemID.PalladiumRepeater, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.PalladiumSword, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(100)) }, - { ItemID.PalladiumWaraxe, Do(AxePower(125), UseTimeExact(12), TileBoostExact(+0)) }, - { ItemID.PalmWoodBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.PalmWoodHammer, Do(HammerPower(25), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.PalmWoodSword, Do(AutoReuse, UseTurn, DamageRatio(4f)) }, - { ItemID.PearlwoodBow, Do(AutoReuse, PointBlank, DamageRatio(2.31f), UseDelta(+8), ShootSpeedDelta(+3.4f), KnockbackDelta(+1f)) }, - { ItemID.PearlwoodHammer, Do(HammerPower(25), UseTimeExact(4), UseAnimationExact(20), DamageRatio(4f), TileBoostExact(+0)) }, - { ItemID.PearlwoodSword, autoReuse }, - { ItemID.Phantasm, pointBlank }, - { ItemID.PhoenixBlaster, Do(AutoReuse, PointBlank, DamageRatio(0.75f)) }, // Phoenix Blaster is nerfed to compensate for autofire - { ItemID.PickaxeAxe, Do(PickPower(200), AxePower(110), UseTimeExact(7), TileBoostExact(+1)) }, - { ItemID.Picksaw, Do(PickPower(210), AxePower(125), UseTimeExact(6), TileBoostExact(+1)) }, - { ItemID.PirateMap, nonConsumableBossSummon }, - { ItemID.PirateStaff, Do(AutoReuse, UseExact(25)) }, - { ItemID.PlatinumAxe, Do(AxePower(80), UseTimeExact(14), TileBoostExact(+0)) }, - { ItemID.PlatinumBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.PlatinumBroadsword, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, - { ItemID.PlatinumHammer, Do(HammerPower(60), UseTimeExact(9), TileBoostExact(+0)) }, - { ItemID.PlatinumPickaxe, Do(PickPower(55), UseTimeExact(9)) }, - { ItemID.PlatinumShortsword, Do(AutoReuse, DamageRatio(2f)) }, - { ItemID.PoisonStaff, Do(DamageRatio(1.2f)) }, - { ItemID.ProximityMineLauncher, Do(DamageRatio(2f)) }, - { ItemID.PsychoKnife, Do(UseTurn, DamageRatio(4f)) }, - { ItemID.PulseBow, Do(PointBlank, DamageRatio(1.66f)) }, - { ItemID.PumpkinMoonMedallion, nonConsumableBossSummon }, - { ItemID.PurpleClubberfish, Do(UseTurn, ScaleRatio(1.5f), DamageExact(45), KnockbackExact(10f)) }, - { ItemID.PurplePhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, - { ItemID.PurplePhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, - { ItemID.PurpleSolution, Do(Value(Item.buyPrice(silver: 5))) }, - { ItemID.Pwnhammer, Do(HammerPower(80), UseTimeExact(11), TileBoostExact(+1)) }, - { ItemID.PygmyStaff, Do(UseExact(20)) }, - // { ItemID.QuadBarrelShotgun, pointBlank }, - { ItemID.QueenSpiderStaff, Do(UseExact(25)) }, - { ItemID.RainbowCrystalStaff, Do(UseExact(15)) }, - { ItemID.RainbowRod, Do(DamageExact(130)) }, - { ItemID.Rally, Do(AutoReuse, DamageExact(20)) }, - { ItemID.RavenStaff, Do(UseExact(20)) }, - { ItemID.Razorpine, Do(DamageRatio(0.75f)) }, - { ItemID.ReaverShark, Do(PickPower(100), UseTimeExact(16)) }, - { ItemID.RedPhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, - { ItemID.RedPhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, - { ItemID.RedRyder, pointBlank }, - { ItemID.RedSolution, Do(Value(Item.buyPrice(silver: 5))) }, - { ItemID.RedsYoyo, autoReuse }, - { ItemID.Revolver, pointBlank }, - { ItemID.RichMahoganyBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.RichMahoganyHammer, Do(HammerPower(25), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.RichMahoganySword, Do(AutoReuse, UseTurn) }, - { ItemID.RocketIII, Do(DamageRatio(0.75f)) }, - { ItemID.RocketIV, Do(DamageRatio(0.75f)) }, - { ItemID.RocketLauncher, Do(DamageRatio(2f)) }, - { ItemID.Rockfish, Do(HammerPower(50), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.RubyStaff, Do(DamageExact(25)) }, - { ItemID.Sandgun, pointBlank }, - { ItemID.SapphireStaff, Do(AutoReuse, DamageExact(25)) }, - // { ItemID.SanguineStaff, Do(AutoReuse, UseExact(25)) }, - { ItemID.SawtoothShark, Do(TrueMelee, AxePower(45), UseTimeExact(4), TileBoostExact(-1)) }, - { ItemID.SDMG, pointBlank }, - { ItemID.Seedler, Do(DamageRatio(1.5f)) }, - { ItemID.Shackle, Do(DefenseDelta(+2)) }, - { ItemID.ShadewoodBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.ShadewoodHammer, Do(HammerPower(25), UseTimeExact(9), TileBoostExact(+0)) }, - { ItemID.ShadewoodSword, Do(AutoReuse, UseTurn) }, - { ItemID.ShadowbeamStaff, Do(DamageRatio(2f)) }, - { ItemID.ShadowFlameBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.ShadowFlameKnife, Do(DamageExact(70)) }, - { ItemID.Shotgun, pointBlank }, - { ItemID.ShroomiteDiggingClaw, Do(PickPower(200), AxePower(125), UseTimeExact(4), TileBoostExact(-1)) }, - { ItemID.SilverAxe, Do(AxePower(70), UseTimeExact(14), TileBoostExact(+0)) }, - { ItemID.SilverBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.SilverBroadsword, Do(AutoReuse, UseTurn, DamageRatio(1.5f)) }, - { ItemID.SilverHammer, Do(HammerPower(55), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.SilverPickaxe, Do(PickPower(50), UseTimeExact(11)) }, - { ItemID.SilverShortsword, Do(AutoReuse, DamageRatio(1.5f)) }, - { ItemID.SkyFracture, Do(DamageExact(54), ShootSpeedExact(30f)) }, - { ItemID.SlapHand, Do(UseTurn, ScaleRatio(1.5f), DamageExact(120)) }, - { ItemID.SlimeCrown, nonConsumableBossSummon }, - { ItemID.SlimeStaff, Do(AutoReuse, UseExact(30)) }, - // { ItemID.Smolstar, Do(AutoReuse, UseExact(25)) }, - { ItemID.SniperRifle, pointBlank }, - { ItemID.SnowballCannon, pointBlank }, - { ItemID.SnowGlobe, nonConsumableBossSummon }, - { ItemID.SolarEruption, Do(DamageRatio(1.5f)) }, - { ItemID.SolarFlareBreastplate, Do(DefenseDelta(+7)) }, - { ItemID.SolarFlareChainsaw, trueMelee }, - { ItemID.SolarFlareDrill, Do(TrueMelee, PickPower(225), UseTimeExact(3), TileBoostExact(+4)) }, - { ItemID.SolarFlareHelmet, Do(DefenseDelta(+5)) }, - { ItemID.SolarFlareLeggings, Do(DefenseDelta(+4)) }, - { ItemID.SolarFlarePickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, - { ItemID.SolarTablet, nonConsumableBossSummon }, - { ItemID.SoulDrain, Do(DamageRatio(1.33f)) }, - { ItemID.SpaceGun, Do(DamageExact(25)) }, - { ItemID.Spear, Do(AutoReuse, TrueMelee, DamageRatio(2f)) }, - { ItemID.SpectreHamaxe, Do(HammerPower(90), AxePower(170), UseTimeExact(8), TileBoostExact(+4)) }, - { ItemID.SpectrePickaxe, Do(PickPower(200), UseTimeExact(8), TileBoostExact(+4)) }, - { ItemID.SpectreStaff, Do(DamageRatio(3f)) }, - { ItemID.SpiderStaff, Do(AutoReuse, UseExact(25)) }, - { ItemID.StaffofEarth, Do(DamageRatio(1.66f)) }, - { ItemID.StaffoftheFrostHydra, Do(UseExact(20)) }, - { ItemID.StakeLauncher, Do(PointBlank, DamageRatio(1.25f)) }, - { ItemID.StardustCellStaff, Do(UseExact(20)) }, - { ItemID.StardustChainsaw, trueMelee }, - { ItemID.StardustDragonStaff, Do(AutoReuse, DamageExact(20), UseExact(19)) }, - { ItemID.StardustDrill, Do(TrueMelee, PickPower(225), UseTimeExact(3), TileBoostExact(+4)) }, - { ItemID.StardustPickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, - { ItemID.Starfury, autoReuse }, - { ItemID.StarWrath, Do(DamageRatio(0.9f)) }, - { ItemID.StickyBomb, maxStack999 }, - { ItemID.StickyDynamite, maxStack999 }, - // { ItemID.StormSpear, autoReuse }, - // { ItemID.StormTigerStaff, UseExact(20) }, - { ItemID.StylistKilLaKillScissorsIWish, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageExact(33)) }, - { ItemID.Sunfury, Do(DamageRatio(2f)) }, - { ItemID.SuspiciousLookingEye, nonConsumableBossSummon }, - { ItemID.Swordfish, Do(AutoReuse, TrueMelee, DamageExact(38)) }, - { ItemID.TacticalShotgun, Do(PointBlank, DamageRatio(1.2f)) }, - { ItemID.TaxCollectorsStickOfDoom, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(70)) }, - { ItemID.TempestStaff, Do(UseExact(20)) }, - { ItemID.TendonBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.Terrarian, Do(AutoReuse, DamageExact(352)) }, - { ItemID.TheAxe, Do(HammerPower(100), AxePower(175), UseTimeExact(7), TileBoostExact(+1)) }, - { ItemID.TheBreaker, Do(HammerPower(70), UseTimeExact(13), TileBoostExact(+0)) }, - { ItemID.TheEyeOfCthulhu, autoReuse }, - { ItemID.TheHorsemansBlade, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(95)) }, - { ItemID.TheMeatball, Do(DamageRatio(2f)) }, - { ItemID.TheRottedFork, Do(AutoReuse, TrueMelee, DamageExact(20)) }, - { ItemID.TheUndertaker, pointBlank }, - { ItemID.ThornChakram, Do(DamageRatio(2f)) }, - { ItemID.TinAxe, Do(AxePower(50), UseTimeExact(16), TileBoostExact(+0)) }, - { ItemID.TinBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.TinBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.TinHammer, Do(HammerPower(35), UseTimeExact(12), TileBoostExact(+0)) }, - { ItemID.TinPickaxe, Do(PickPower(35), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.TinShortsword, autoReuse }, - { ItemID.TitaniumChainsaw, Do(TrueMelee, AxePower(90), UseTimeExact(4), TileBoostExact(+0)) }, - { ItemID.TitaniumDrill, Do(TrueMelee, PickPower(180), UseTimeExact(4), TileBoostExact(+1)) }, - { ItemID.TitaniumPickaxe, Do(PickPower(180), UseTimeExact(8), TileBoostExact(+1)) }, - { ItemID.TitaniumRepeater, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.TitaniumSword, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(77)) }, - { ItemID.TitaniumTrident, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(72), ShootSpeedRatio(1.25f)) }, - { ItemID.TitaniumWaraxe, Do(AxePower(160), UseTimeExact(10), TileBoostExact(+1)) }, - { ItemID.TopazStaff, Do(ManaExact(2)) }, - { ItemID.Trident, Do(AutoReuse, TrueMelee, DamageRatio(2f)) }, - { ItemID.TrueExcalibur, Do(AutoReuse, UseTurn, DamageExact(82)) }, - { ItemID.TrueNightsEdge, Do(AutoReuse, UseTurn, DamageExact(160), ShootSpeedExact(16), ScaleRatio(1.5f)) }, - { ItemID.Tsunami, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.TungstenAxe, Do(AxePower(70), UseTimeExact(14), TileBoostExact(+0)) }, - { ItemID.TungstenBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.TungstenBroadsword, Do(AutoReuse, UseTurn, DamageRatio(1.5f)) }, - { ItemID.TungstenHammer, Do(HammerPower(55), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.TungstenPickaxe, Do(PickPower(50), UseTimeExact(11)) }, - { ItemID.TungstenShortsword, Do(AutoReuse, DamageRatio(1.5f)) }, - { ItemID.UnholyArrow, Do(DamageRatio(1.1f)) }, - { ItemID.UnholyTrident, Do(ManaExact(14)) }, - { ItemID.Uzi, pointBlank }, - { ItemID.ValkyrieYoyo, autoReuse }, - // { ItemID.VampireFrogStaff, Do(AutoReuse, UseExact(30)) } - { ItemID.VampireKnives, Do(DamageRatio(1.33f)) }, - { ItemID.VenomArrow, Do(DamageRatio(1.1f)) }, - { ItemID.VenomStaff, Do(DamageRatio(1.33f)) }, - { ItemID.VenusMagnum, Do(AutoReuse, PointBlank) }, - { ItemID.Vilethorn, Do(DamageExact(14)) }, - { ItemID.VortexBeater, pointBlank }, - { ItemID.VortexChainsaw, trueMelee }, - { ItemID.VortexDrill, Do(TrueMelee, PickPower(225), UseTimeExact(3), TileBoostExact(+4)) }, - { ItemID.VortexPickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, - { ItemID.WandofSparking, Do(AutoReuse, DamageExact(15)) }, - { ItemID.WarAxeoftheNight, Do(AxePower(100), UseTimeExact(13), TileBoostExact(+0)) }, - { ItemID.WaspGun, Do(DamageRatio(1.5f)) }, - { ItemID.WaterBolt, Do(DamageExact(28)) }, - { ItemID.WhitePhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, - { ItemID.WhitePhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, - { ItemID.WoodenArrow, Do(DamageRatio(1.1f)) }, - { ItemID.WoodenBoomerang, Do(DamageRatio(2f)) }, - { ItemID.WoodenBow, Do(PointBlank, DamageRatio(1.1f)) }, - { ItemID.WoodenHammer, Do(HammerPower(25), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.WoodenSword, Do(AutoReuse, UseTurn) }, - { ItemID.WoodYoyo, autoReuse }, - { ItemID.WormFood, nonConsumableBossSummon }, - { ItemID.Xenopopper, Do(DamageRatio(0.75f)) }, - { ItemID.XenoStaff, Do(UseExact(20)) }, - { ItemID.Yelets, autoReuse }, - { ItemID.YellowPhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, - { ItemID.YellowPhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, - { ItemID.ZombieArm, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, - }; - } - - internal static void UnloadTweaks() - { - currentTweaks.Clear(); - currentTweaks = null; - } - #endregion - - #region SetDefaults (Item Tweaks Applied Here) - internal void SetDefaults_ApplyTweaks(Item item) - { - // Do nothing if the tweaks database is not defined. - if (currentTweaks is null) - return; - - // Grab the tweaking or balancing to apply, if any. If nothing comes back, do nothing. - bool needsTweaking = currentTweaks.TryGetValue(item.type, out IItemTweak[] tweaks); - if (!needsTweaking) - return; - - // Apply all alterations sequentially, assuming they are relevant. - foreach (IItemTweak tweak in tweaks) - if (tweak.AppliesTo(item)) - tweak.ApplyTweak(item); - } - #endregion - - #region Internal Structures - - // This function simply concatenates a bunch of Item Tweaks into an array. - // It looks a lot nicer than constantly typing "new IItemTweak[]". - internal static IItemTweak[] Do(params IItemTweak[] r) => r; - - #region Applicability Lambdas - internal static bool DealsDamage(Item it) => it.damage > 0; - internal static bool HasDefense(Item it) => it.defense > 0; - internal static bool HasKnockback(Item it) => !it.accessory & !it.vanity; // how to check if something is wearable armor? - internal static bool IsAxe(Item it) => it.axe > 0; - internal static bool IsHammer(Item it) => it.hammer > 0; - internal static bool IsMelee(Item it) => it.melee; - internal static bool IsPickaxe(Item it) => it.pick > 0; - internal static bool IsScalable(Item it) => it.damage > 0 && it.melee; // sanity check: only melee weapons get scaled - internal static bool IsUsable(Item it) => it.useStyle != 0 && it.useTime > 0 && it.useAnimation > 0; - internal static bool UsesMana(Item it) => IsUsable(it); // Only usable items cost mana, but items must be able to have their mana cost disabled or enabled at will. - #endregion - - #region Item Tweak Definitions - internal interface IItemTweak - { - bool AppliesTo(Item it); - void ApplyTweak(Item it); - } - - internal class AutoReuseRule : IItemTweak - { - internal readonly bool flag = true; - - public AutoReuseRule(bool ar) => flag = ar; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) => it.autoReuse = flag; - } - internal static IItemTweak AutoReuse => new AutoReuseRule(true); - internal static IItemTweak NoAutoReuse => new AutoReuseRule(false); - - // Uses the values shown by Terraria, which are multiplied by 5, not the internal values - internal class AxePowerRule : IItemTweak - { - internal readonly int newAxePower = 0; - - public AxePowerRule(int newDisplayedAxePower) => newAxePower = newDisplayedAxePower / 5; - public bool AppliesTo(Item it) => IsAxe(it); - public void ApplyTweak(Item it) - { - it.axe = newAxePower; - if (it.axe < 0) - it.axe = 0; - } - } - internal static IItemTweak AxePower(int a) => new AxePowerRule(a); - - internal class ConsumableRule : IItemTweak - { - internal readonly bool flag = false; - - public ConsumableRule(bool c) => flag = c; - public bool AppliesTo(Item it) => true; - public void ApplyTweak(Item it) => it.consumable = flag; - } - internal static IItemTweak Consumable => new ConsumableRule(true); - internal static IItemTweak NotConsumable => new ConsumableRule(false); - - #region Damage - internal class DamageDeltaRule : IItemTweak - { - internal readonly int delta = 0; - - public DamageDeltaRule(int d) => delta = d; - public bool AppliesTo(Item it) => DealsDamage(it); - public void ApplyTweak(Item it) - { - it.damage += delta; - if (it.damage < 0) - it.damage = 0; - } - } - internal static IItemTweak DamageDelta(int d) => new DamageDeltaRule(d); - - internal class DamageExactRule : IItemTweak - { - internal readonly int newDamage = 0; - - public DamageExactRule(int dmg) => newDamage = dmg; - public bool AppliesTo(Item it) => DealsDamage(it); - public void ApplyTweak(Item it) - { - it.damage = newDamage; - if (it.damage < 0) - it.damage = 0; - } - } - internal static IItemTweak DamageExact(int d) => new DamageExactRule(d); - - internal class DamageRatioRule : IItemTweak - { - internal readonly float ratio = 1f; - - public DamageRatioRule(float f) => ratio = f; - public bool AppliesTo(Item it) => DealsDamage(it); - public void ApplyTweak(Item it) - { - it.damage = (int)(it.damage * ratio); - if (it.damage < 0) - it.damage = 0; - } - } - internal static IItemTweak DamageRatio(float f) => new DamageRatioRule(f); - #endregion - - internal class DefenseDeltaRule : IItemTweak - { - internal readonly int delta = 0; - - public DefenseDeltaRule(int d) => delta = d; - public bool AppliesTo(Item it) => HasDefense(it); - public void ApplyTweak(Item it) - { - it.defense += delta; - if (it.defense < 0) - it.defense = 0; - } - } - internal static IItemTweak DefenseDelta(int d) => new DefenseDeltaRule(d); - - internal class DefenseExactRule : IItemTweak - { - internal readonly int newDefense = 0; - - public DefenseExactRule(int def) => newDefense = def; - public bool AppliesTo(Item it) => HasDefense(it); - public void ApplyTweak(Item it) - { - it.defense = newDefense; - if (it.defense < 0) - it.defense = 0; - } - } - internal static IItemTweak DefenseExact(int d) => new DefenseExactRule(d); - - internal class HammerPowerRule : IItemTweak - { - internal readonly int newHammerPower = 0; - - public HammerPowerRule(int h) => newHammerPower = h; - public bool AppliesTo(Item it) => IsHammer(it); - public void ApplyTweak(Item it) - { - it.hammer = newHammerPower; - if (it.hammer < 0) - it.hammer = 0; - } - } - internal static IItemTweak HammerPower(int h) => new HammerPowerRule(h); - - #region Knockback - internal class KnockbackDeltaRule : IItemTweak - { - internal readonly float delta = 0; - - public KnockbackDeltaRule(float d) => delta = d; - public bool AppliesTo(Item it) => HasKnockback(it); - public void ApplyTweak(Item it) - { - it.knockBack += delta; - if (it.knockBack < 0f) - it.knockBack = 0f; - } - } - internal static IItemTweak KnockbackDelta(float d) => new KnockbackDeltaRule(d); - - internal class KnockbackExactRule : IItemTweak - { - internal readonly float newKnockback = 0; - - public KnockbackExactRule(float kb) => newKnockback = kb; - public bool AppliesTo(Item it) => HasKnockback(it); - public void ApplyTweak(Item it) - { - it.knockBack = newKnockback; - if (it.knockBack < 0f) - it.knockBack = 0f; - } - } - internal static IItemTweak KnockbackExact(float kb) => new KnockbackExactRule(kb); - - internal class KnockbackRatioRule : IItemTweak - { - internal readonly float ratio = 1f; - - public KnockbackRatioRule(float f) => ratio = f; - public bool AppliesTo(Item it) => HasKnockback(it); - public void ApplyTweak(Item it) - { - it.knockBack *= ratio; - if (it.knockBack < 0f) - it.knockBack = 0f; - } - } - internal static IItemTweak KnockbackRatio(float r) => new KnockbackRatioRule(r); - #endregion - - #region Mana Cost - internal class ManaDeltaRule : IItemTweak - { - internal readonly int delta = 0; - - public ManaDeltaRule(int d) => delta = d; - public bool AppliesTo(Item it) => UsesMana(it); - public void ApplyTweak(Item it) - { - it.mana += delta; - if (it.mana < 0) - it.mana = 0; - } - } - internal static IItemTweak ManaDelta(int d) => new ManaDeltaRule(d); - - internal class ManaExactRule : IItemTweak - { - internal readonly int newMana = 0; - - public ManaExactRule(int m) => newMana = m; - public bool AppliesTo(Item it) => UsesMana(it); - public void ApplyTweak(Item it) - { - it.mana = newMana; - if (it.mana < 0) - it.mana = 0; - } - } - internal static IItemTweak ManaExact(int m) => new ManaExactRule(m); - - internal class ManaRatioRule : IItemTweak - { - internal readonly float ratio = 1f; - - public ManaRatioRule(float f) => ratio = f; - public bool AppliesTo(Item it) => UsesMana(it); - public void ApplyTweak(Item it) - { - it.mana = (int)(it.mana * ratio); - if (it.mana < 0) - it.mana = 0; - } - } - internal static IItemTweak ManaRatio(float f) => new ManaRatioRule(f); - #endregion - - internal class MaxStackRule : IItemTweak // max stack plus - calamity style - { - internal readonly int newMaxStack = 999; - - public MaxStackRule(int stk) => newMaxStack = stk; - public bool AppliesTo(Item it) => true; - public void ApplyTweak(Item it) - { - it.maxStack = newMaxStack; - if (it.maxStack < 1) - it.maxStack = 1; - } - } - internal static IItemTweak MaxStack(int stk) => new MaxStackRule(stk); - - internal class PickPowerRule : IItemTweak - { - internal readonly int newPickPower = 0; - - public PickPowerRule(int p) => newPickPower = p; - public bool AppliesTo(Item it) => IsPickaxe(it); - public void ApplyTweak(Item it) - { - it.pick = newPickPower; - if (it.pick < 0) - it.pick = 0; - } - } - internal static IItemTweak PickPower(int p) => new PickPowerRule(p); - - internal class PointBlankRule : IItemTweak - { - public bool AppliesTo(Item it) => true; - public void ApplyTweak(Item it) => it.Calamity().canFirePointBlankShots = true; - } - internal static IItemTweak PointBlank => new PointBlankRule(); - - #region Scale (True Melee) - internal class ScaleDeltaRule : IItemTweak - { - internal readonly float delta = 0; - - public ScaleDeltaRule(float d) => delta = d; - public bool AppliesTo(Item it) => IsScalable(it); - public void ApplyTweak(Item it) - { - it.scale += delta; - if (it.scale < 0f) - it.scale = 0f; - } - } - internal static IItemTweak ScaleDelta(float d) => new ScaleDeltaRule(d); - - internal class ScaleExactRule : IItemTweak - { - internal readonly float newScale = 0; - - public ScaleExactRule(float s) => newScale = s; - public bool AppliesTo(Item it) => IsScalable(it); - public void ApplyTweak(Item it) - { - it.scale = newScale; - if (it.scale < 0f) - it.scale = 0f; - } - } - internal static IItemTweak ScaleExact(float s) => new ScaleExactRule(s); - - internal class ScaleRatioRule : IItemTweak - { - internal readonly float ratio = 1f; - - public ScaleRatioRule(float f) => ratio = f; - public bool AppliesTo(Item it) => IsScalable(it); - public void ApplyTweak(Item it) - { - it.scale *= ratio; - if (it.scale < 0f) - it.scale = 0f; - } - } - internal static IItemTweak ScaleRatio(float f) => new ScaleRatioRule(f); - #endregion - - #region Shoot Speed (Velocity) - internal class ShootSpeedDeltaRule : IItemTweak - { - internal readonly float delta = 0; - - public ShootSpeedDeltaRule(float d) => delta = d; - public bool AppliesTo(Item it) => IsScalable(it); - public void ApplyTweak(Item it) - { - it.shootSpeed += delta; - if (it.shootSpeed < 0f) - it.shootSpeed = 0f; - } - } - internal static IItemTweak ShootSpeedDelta(float d) => new ShootSpeedDeltaRule(d); - - internal class ShootSpeedExactRule : IItemTweak - { - internal readonly float newShootSpeed = 0; - - public ShootSpeedExactRule(float ss) => newShootSpeed = ss; - public bool AppliesTo(Item it) => IsScalable(it); - public void ApplyTweak(Item it) - { - it.shootSpeed = newShootSpeed; - if (it.shootSpeed < 0f) - it.shootSpeed = 0f; - } - } - internal static IItemTweak ShootSpeedExact(float s) => new ShootSpeedExactRule(s); - - internal class ShootSpeedRatioRule : IItemTweak - { - internal readonly float ratio = 1f; - - public ShootSpeedRatioRule(float f) => ratio = f; - public bool AppliesTo(Item it) => IsScalable(it); - public void ApplyTweak(Item it) - { - it.shootSpeed *= ratio; - if (it.shootSpeed < 0f) - it.shootSpeed = 0f; - } - } - internal static IItemTweak ShootSpeedRatio(float f) => new ShootSpeedRatioRule(f); - #endregion - - internal class TileBoostDeltaRule : IItemTweak - { - private readonly int delta = 0; - - public TileBoostDeltaRule(int d) => delta = d; - public bool AppliesTo(Item it) => true; - public void ApplyTweak(Item it) => it.tileBoost += delta; - } - internal static IItemTweak TileBoostDelta(int d) => new TileBoostDeltaRule(d); - - internal class TileBoostExactRule : IItemTweak - { - private readonly int newTileBoost = 0; - - public TileBoostExactRule(int tb) => newTileBoost = tb; - public bool AppliesTo(Item it) => true; - public void ApplyTweak(Item it) => it.tileBoost = newTileBoost; - } - internal static IItemTweak TileBoostExact(int tb) => new TileBoostExactRule(tb); - - internal class TrueMeleeRule : IItemTweak - { - public bool AppliesTo(Item it) => IsMelee(it); - public void ApplyTweak(Item it) => it.Calamity().trueMelee = true; - } - internal static IItemTweak TrueMelee => new TrueMeleeRule(); - - #region Use Time and Use Animation - internal class UseDeltaRule : IItemTweak - { - internal readonly int delta = 0; - - public UseDeltaRule(int d) => delta = d; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) - { - it.useAnimation += delta; - it.useTime += delta; - if (it.useAnimation < 1) - it.useAnimation = 1; - if (it.useTime < 1) - it.useTime = 1; - } - } - internal static IItemTweak UseDelta(int d) => new UseDeltaRule(d); - - internal class UseExactRule : IItemTweak - { - internal readonly int newUseTime = 0; - - public UseExactRule(int ut) => newUseTime = ut; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) - { - it.useAnimation = newUseTime; - it.useTime = newUseTime; - if (it.useAnimation < 1) - it.useAnimation = 1; - if (it.useTime < 1) - it.useTime = 1; - } - } - internal static IItemTweak UseExact(int ut) => new UseExactRule(ut); - - internal class UseRatioRule : IItemTweak - { - internal readonly float ratio = 1f; - - public UseRatioRule(float f) => ratio = f; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) - { - it.useAnimation = (int)(it.useAnimation * ratio); - it.useTime = (int)(it.useTime * ratio); - if (it.useAnimation < 1) - it.useAnimation = 1; - if (it.useTime < 1) - it.useTime = 1; - } - } - internal static IItemTweak UseRatio(float f) => new UseRatioRule(f); - - internal class UseAnimationDeltaRule : IItemTweak - { - internal readonly int delta = 0; - - public UseAnimationDeltaRule(int d) => delta = d; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) - { - it.useAnimation += delta; - if (it.useAnimation < 1) - it.useAnimation = 1; - } - } - internal static IItemTweak UseAnimationDelta(int d) => new UseAnimationDeltaRule(d); - - internal class UseAnimationExactRule : IItemTweak - { - internal readonly int newUseAnimation = 0; - - public UseAnimationExactRule(int ua) => newUseAnimation = ua; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) - { - it.useAnimation = newUseAnimation; - if (it.useAnimation < 1) - it.useAnimation = 1; - } - } - internal static IItemTweak UseAnimationExact(int ua) => new UseAnimationExactRule(ua); - - internal class UseAnimationRatioRule : IItemTweak - { - internal readonly float ratio = 1f; - - public UseAnimationRatioRule(float f) => ratio = f; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) - { - it.useAnimation = (int)(it.useAnimation * ratio); - if (it.useAnimation < 1) - it.useAnimation = 1; - } - } - internal static IItemTweak UseAnimationRatio(float f) => new UseAnimationRatioRule(f); - - internal class UseTimeDeltaRule : IItemTweak - { - internal readonly int delta = 0; - - public UseTimeDeltaRule(int d) => delta = d; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) - { - it.useTime += delta; - if (it.useTime < 1) - it.useTime = 1; - } - } - internal static IItemTweak UseTimeDelta(int d) => new UseTimeDeltaRule(d); - - internal class UseTimeExactRule : IItemTweak - { - internal readonly int newUseTime = 0; - - public UseTimeExactRule(int ut) => newUseTime = ut; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) - { - it.useTime = newUseTime; - if (it.useTime < 1) - it.useTime = 1; - } - } - internal static IItemTweak UseTimeExact(int ut) => new UseTimeExactRule(ut); - - internal class UseTimeRatioRule : IItemTweak - { - internal readonly float ratio = 1f; - - public UseTimeRatioRule(float f) => ratio = f; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) - { - it.useTime = (int)(it.useTime * ratio); - if (it.useTime < 1) - it.useTime = 1; - } - } - internal static IItemTweak UseTimeRatio(float f) => new UseTimeRatioRule(f); - #endregion - - internal class UseTurnRule : IItemTweak - { - internal readonly bool flag = true; - - public UseTurnRule(bool ut) => flag = ut; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) => it.useTurn = flag; - } - internal static IItemTweak UseTurn => new UseTurnRule(true); - internal static IItemTweak NoUseTurn => new UseTurnRule(false); - - internal class ValueRule : IItemTweak - { - internal readonly int newValue = 0; - - public ValueRule(int v) => newValue = v; - public bool AppliesTo(Item it) => true; - public void ApplyTweak(Item it) - { - it.value = newValue; - if (it.value < 0) - it.value = 0; - } - } - internal static IItemTweak Value(int v) => new ValueRule(v); - internal static IItemTweak Worthless => new ValueRule(0); - #endregion - #endregion - } + public partial class CalamityGlobalItem : GlobalItem + { + #region Database and Initialization + internal static SortedDictionary currentTweaks = null; + + internal static void LoadTweaks() + { + // Various shorthands for items which receive very simple changes, such as setting one flag. + IItemTweak[] trueMelee = Do(TrueMelee); + IItemTweak[] pointBlank = Do(PointBlank); + IItemTweak[] autoReuse = Do(AutoReuse); + IItemTweak[] maxStack999 = Do(MaxStack(999)); + IItemTweak[] nonConsumableBossSummon = Do(MaxStack(1), NotConsumable); + + // Please keep this strictly alphabetical. It's the only way to keep it sane. Thanks in advance. + // - Ozzatron + currentTweaks = new SortedDictionary + { + { ItemID.Abeemination, nonConsumableBossSummon }, + { ItemID.AdamantiteChainsaw, Do(TrueMelee, AxePower(90), UseTimeExact(4), TileBoostExact(+0)) }, + { ItemID.AdamantiteDrill, Do(TrueMelee, PickPower(180), UseTimeExact(4), TileBoostExact(+1)) }, + { ItemID.AdamantiteGlaive, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(65), ShootSpeedRatio(1.25f)) }, + { ItemID.AdamantitePickaxe, Do(PickPower(180), UseTimeExact(8), TileBoostExact(+1)) }, + { ItemID.AdamantiteRepeater, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.AdamantiteSword, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(77)) }, + { ItemID.AdamantiteWaraxe, Do(AxePower(160), UseTimeExact(10), TileBoostExact(+1)) }, + { ItemID.Amarok, autoReuse }, + { ItemID.AmberStaff, Do(DamageRatio(1.33f), UseTimeExact(15), UseAnimationExact(40)) }, + { ItemID.AmethystStaff, Do(ManaExact(2)) }, + { ItemID.Anchor, Do(DamageExact(107)) }, + { ItemID.AnkhShield, Do(DefenseDelta(+8)) }, + { ItemID.AntlionClaw, Do(ScaleRatio(1.5f), DamageRatio(1.5f)) }, + { ItemID.AquaScepter, Do(DamageExact(21), ShootSpeedExact(25f)) }, + { ItemID.Arkhalis, trueMelee }, + // { ItemID.BabyBirdStaff, Do(AutoReuse, UseExact(35)) }, + { ItemID.BallOHurt, Do(DamageRatio(2f)) }, + { ItemID.Bananarang, Do(DamageExact(110)) }, + { ItemID.BatScepter, Do(DamageRatio(1.1f)) }, + { ItemID.BeamSword, Do(AutoReuse, DamageExact(360), UseAnimationExact(60), ShootSpeedExact(23f)) }, + { ItemID.BeeGun, Do(DamageExact(11)) }, + { ItemID.BeeKeeper, Do(UseTurn, ScaleRatio(1.5f), DamageRatio(2.5f)) }, + { ItemID.BeesKnees, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.BladedGlove, Do(DamageExact(15), UseExact(7)) }, + { ItemID.BladeofGrass, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageExact(65)) }, + { ItemID.Bladetongue, Do(UseTurn, UseRatio(0.8f), DamageExact(120), ScaleRatio(1.75f)) }, + { ItemID.BlizzardStaff, Do(DamageExact(41), ManaExact(7)) }, + { ItemID.BloodButcherer, Do(AutoReuse, UseTurn, DamageRatio(1.66f)) }, + { ItemID.BloodLustCluster, Do(AxePower(100), UseTimeExact(13), TileBoostExact(+0)) }, + { ItemID.BloodyMachete, Do(AutoReuse, DamageExact(30)) }, + { ItemID.BloodySpine, nonConsumableBossSummon }, + { ItemID.Blowgun, pointBlank }, + { ItemID.Blowpipe, pointBlank }, + { ItemID.BlueMoon, Do(DamageRatio(2f)) }, + { ItemID.BluePhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, + { ItemID.BluePhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, + { ItemID.BlueSolution, Do(Value(Item.buyPrice(silver: 5))) }, + { ItemID.BoneArrow, Do(DamageRatio(1.1f)) }, + { ItemID.BonePickaxe, Do(PickPower(55), UseTimeExact(6)) }, + { ItemID.BoneSword, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(1.25f)) }, + { ItemID.BookofSkulls, Do(ManaExact(12), ShootSpeedExact(9f)) }, + { ItemID.BookStaff, Do(ManaExact(10), DamageRatio(1.25f)) }, + { ItemID.Boomstick, pointBlank }, + { ItemID.BorealWoodBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.BorealWoodHammer, Do(HammerPower(25), UseTimeExact(11), TileBoostExact(+0)) }, + { ItemID.BorealWoodSword, Do(AutoReuse, UseTurn) }, + { ItemID.BouncyBomb, maxStack999 }, + { ItemID.BouncyDynamite, maxStack999 }, + { ItemID.BreakerBlade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageExact(97)) }, + { ItemID.ButchersChainsaw, Do(TrueMelee, AxePower(150), UseTimeExact(3), TileBoostExact(+0)) }, + { ItemID.CactusPickaxe, Do(PickPower(34), UseTimeExact(9)) }, + { ItemID.CactusSword, Do(AutoReuse, UseTurn) }, + { ItemID.CnadyCanePickaxe, Do(PickPower(55), UseTimeExact(9), TileBoostExact(+1)) }, // intentionally not in alphabetical order to correct for typo + { ItemID.CandyCaneSword, Do(AutoReuse, DamageRatio(1.25f)) }, + { ItemID.CandyCornRifle, pointBlank }, + { ItemID.Cascade, Do(AutoReuse, DamageExact(39)) }, + { ItemID.CelestialSigil, nonConsumableBossSummon }, + { ItemID.ChainGuillotines, Do(DamageExact(100)) }, + { ItemID.ChainGun, pointBlank }, + { ItemID.ChainKnife, Do(AutoReuse, DamageExact(14)) }, + { ItemID.ChargedBlasterCannon, Do(DamageRatio(1.33f)) }, + { ItemID.Chik, autoReuse }, + { ItemID.ChlorophyteArrow, Do(DamageRatio(1.1f)) }, + { ItemID.ChlorophyteChainsaw, Do(TrueMelee, AxePower(120), UseTimeExact(3), TileBoostExact(+0)) }, + { ItemID.ChlorophyteDrill, Do(TrueMelee, PickPower(200), UseTimeExact(4), TileBoostExact(+2)) }, + { ItemID.ChlorophyteGreataxe, Do(AxePower(165), UseTimeExact(7), TileBoostExact(+2)) }, + { ItemID.ChlorophyteJackhammer, Do(TrueMelee, HammerPower(90), UseTimeExact(5), TileBoostExact(+0)) }, + { ItemID.ChlorophytePartisan, Do(AutoReuse, UseRatio(0.8f), DamageExact(100)) }, + { ItemID.ChlorophytePickaxe, Do(PickPower(200), UseTimeExact(7), TileBoostExact(+2)) }, + { ItemID.ChlorophyteSaber, Do(DamageExact(80), UseTimeExact(10)) }, + { ItemID.ChlorophyteShotbow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.ChlorophyteWarhammer, Do(HammerPower(90), UseTimeExact(8), TileBoostExact(+2)) }, + { ItemID.ChristmasTreeSword, Do(AutoReuse, UseTurn, DamageExact(155)) }, + { ItemID.ClingerStaff, Do(DamageRatio(1.33f)) }, + { ItemID.ClockworkAssaultRifle, pointBlank }, + { ItemID.CobaltBreastplate, Do(DefenseDelta(+3)) }, + { ItemID.CobaltChainsaw, Do(TrueMelee, AxePower(70), UseTimeExact(4), TileBoostExact(-1)) }, + { ItemID.CobaltDrill, Do(TrueMelee, PickPower(130), UseTimeExact(5)) }, + { ItemID.CobaltHat, Do(DefenseDelta(+2)) }, + { ItemID.CobaltHelmet, Do(DefenseDelta(+5)) }, + { ItemID.CobaltLeggings, Do(DefenseDelta(+3)) }, + { ItemID.CobaltMask, Do(DefenseDelta(+3)) }, + { ItemID.CobaltNaginata, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(90)) }, + { ItemID.CobaltPickaxe, Do(PickPower(130), UseTimeExact(9)) }, + { ItemID.CobaltRepeater, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.CobaltShield, Do(DefenseDelta(+3)) }, + { ItemID.CobaltSword, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(80)) }, + { ItemID.CobaltWaraxe, Do(AxePower(125), UseTimeExact(12), TileBoostExact(+0)) }, + { ItemID.Code1, Do(AutoReuse, DamageExact(25)) }, + { ItemID.Code2, autoReuse }, + { ItemID.CopperAxe, Do(AxePower(50), UseTimeExact(16), TileBoostExact(+0)) }, + { ItemID.CopperBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.CopperBroadsword, Do(AutoReuse, UseTurn) }, + { ItemID.CopperHammer, Do(HammerPower(35), UseTimeExact(12), TileBoostExact(+0)) }, + { ItemID.CopperPickaxe, Do(PickPower(35), UseTimeExact(10), TileBoostExact(+0)) }, + { ItemID.CopperShortsword, autoReuse }, + { ItemID.CorruptYoyo, Do(AutoReuse, DamageExact(27)) }, + { ItemID.CrimsonYoyo, Do(AutoReuse, DamageExact(30)) }, + { ItemID.CrystalSerpent, Do(DamageExact(45)) }, + { ItemID.CrystalVileShard, Do(DamageRatio(1.33f)) }, + { ItemID.CursedArrow, Do(DamageRatio(1.1f)) }, + { ItemID.Cutlass, Do(UseRatio(0.8f), DamageRatio(2f)) }, + { ItemID.DaedalusStormbow, Do(DamageRatio(0.9f)) }, + { ItemID.DaoofPow, Do(DamageExact(160)) }, + { ItemID.DarkBlueSolution, Do(Value(Item.buyPrice(silver: 5))) }, + { ItemID.DarkLance, Do(AutoReuse, TrueMelee, DamageExact(68)) }, + { ItemID.DartPistol, pointBlank }, + { ItemID.DartRifle, pointBlank }, + { ItemID.DayBreak, Do(DamageRatio(1.5f)) }, // TODO -- replace with 1.4 behavior of Daybreak spears exploding on death for 100% damage + { ItemID.DD2BallistraTowerT1Popper, Do(UseExact(30)) }, + { ItemID.DD2BallistraTowerT2Popper, Do(UseExact(25)) }, + { ItemID.DD2BallistraTowerT3Popper, Do(UseExact(20)) }, + { ItemID.DD2BetsyBow, Do(DamageRatio(1.1f)) }, // Aerial Bane's ridiculous multiplier is removed, so this compensates for that + { ItemID.DD2ExplosiveTrapT1Popper, Do(UseExact(30)) }, + { ItemID.DD2ExplosiveTrapT2Popper, Do(UseExact(25)) }, + { ItemID.DD2ExplosiveTrapT3Popper, Do(UseExact(20)) }, + { ItemID.DD2FlameburstTowerT1Popper, Do(UseExact(30)) }, + { ItemID.DD2FlameburstTowerT2Popper, Do(UseExact(25)) }, + { ItemID.DD2FlameburstTowerT3Popper, Do(UseExact(20)) }, + { ItemID.DD2LightningAuraT1Popper, Do(UseExact(30)) }, + { ItemID.DD2LightningAuraT2Popper, Do(UseExact(25)) }, + { ItemID.DD2LightningAuraT3Popper, Do(UseExact(20)) }, + { ItemID.DD2PhoenixBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.DD2SquireDemonSword, Do(DamageExact(110)) }, + { ItemID.DeadlySphereStaff, Do(UseExact(20)) }, + { ItemID.DeathbringerPickaxe, Do(PickPower(70), UseTimeExact(10)) }, + { ItemID.DeathSickle, Do(DamageExact(82), ShootSpeedExact(15f)) }, + { ItemID.DemonBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.DemonScythe, Do(AutoReuse, DamageExact(33), ManaExact(10)) }, + { ItemID.DiamondStaff, Do(DamageExact(26)) }, + { ItemID.Drax, Do(TrueMelee, PickPower(200), AxePower(110), UseTimeExact(4), TileBoostExact(+1)) }, + { ItemID.DyeTradersScimitar, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(1.33f)) }, + { ItemID.Dynamite, maxStack999 }, + { ItemID.EbonwoodBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.EbonwoodHammer, Do(HammerPower(25), UseTimeExact(9), TileBoostExact(+0)) }, + { ItemID.EbonwoodSword, Do(AutoReuse, UseTurn) }, + { ItemID.ElectrosphereLauncher, Do(DamageRatio(1.1f)) }, + { ItemID.EldMelter, Do(DamageRatio(1.5f)) }, // intentionally not in alphabetical order to correct for typo + { ItemID.EmeraldStaff, Do(DamageExact(28)) }, + // { ItemID.EmpressBlade, Do(UseExact(20)) }, + { ItemID.EnchantedBoomerang, Do(DamageRatio(2f)) }, + { ItemID.EnchantedSword, Do(ScaleRatio(1.5f), DamageExact(42), UseAnimationExact(20), ShootSpeedExact(15f)) }, + { ItemID.EndlessQuiver, Do(DamageRatio(1.1f)) }, + { ItemID.EoCShield, Do(DefenseDelta(+1)) }, + // { ItemID.Eventide, pointBlank }, + { ItemID.Excalibur, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(125)) }, + { ItemID.FalconBlade, Do(UseTurn, ScaleRatio(1.5f), DamageExact(40)) }, + { ItemID.FieryGreatsword, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageExact(98), UseExact(45)) }, + { ItemID.FireworksLauncher, Do(DamageRatio(2f)) }, + { ItemID.Flamarang, Do(DamageRatio(2f)) }, + { ItemID.Flamelash, Do(DamageExact(75), UseExact(38)) }, + { ItemID.Flamethrower, Do(DamageRatio(1.5f)) }, + { ItemID.FlamingArrow, Do(DamageRatio(1.1f)) }, + { ItemID.FlareGun, pointBlank }, + { ItemID.FleshGrinder, Do(HammerPower(70), UseTimeExact(13), TileBoostExact(+0)) }, + { ItemID.FlintlockPistol, pointBlank }, + // { ItemID.FlinxStaff, Do(AutoReuse, UseExact(35)) }, + { ItemID.FlowerofFire, Do(AutoReuse, DamageExact(60)) }, + { ItemID.FlowerofFrost, Do(DamageRatio(1.2f)) }, + { ItemID.FlowerPow, Do(DamageRatio(2f)) }, + { ItemID.FlyingKnife, Do(DamageExact(70)) }, + { ItemID.FormatC, autoReuse }, + { ItemID.Frostbrand, Do(DamageExact(140), UseTimeExact(20)) }, + { ItemID.FrostburnArrow, Do(DamageRatio(1.1f)) }, + { ItemID.FrostStaff, Do(ManaExact(9), DamageExact(215), UseTimeExact(50), UseAnimationExact(50), ShootSpeedExact(40f)) }, + { ItemID.FrozenTurtleShell, Do(DefenseDelta(+6)) }, + { ItemID.FruitcakeChakram, Do(DamageRatio(2f)) }, + { ItemID.Gatligator, pointBlank }, + { ItemID.GladiatorBreastplate, Do(DefenseDelta(+2)) }, + { ItemID.GladiatorHelmet, Do(DefenseDelta(+1)) }, + { ItemID.GladiatorLeggings, Do(DefenseDelta(+2)) }, + { ItemID.GoblinBattleStandard, nonConsumableBossSummon }, + { ItemID.GoldAxe, Do(AxePower(80), UseTimeExact(14), TileBoostExact(+0)) }, + { ItemID.GoldBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.GoldBroadsword, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, + { ItemID.GoldHammer, Do(HammerPower(60), UseTimeExact(9), TileBoostExact(+0)) }, + { ItemID.GoldPickaxe, Do(PickPower(55), UseTimeExact(9)) }, + { ItemID.GoldShortsword, Do(AutoReuse, DamageRatio(2f)) }, + { ItemID.GolemFist, Do(DamageExact(150)) }, + { ItemID.Gradient, autoReuse }, + { ItemID.GreenPhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, + { ItemID.GreenPhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, + { ItemID.GreenSolution, Do(Value(Item.buyPrice(silver: 5))) }, + { ItemID.GrenadeLauncher, Do(DamageRatio(2f)) }, + { ItemID.Gungnir, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(92), ShootSpeedRatio(1.25f)) }, + { ItemID.HallowedGreaves, Do(DefenseDelta(+2)) }, + { ItemID.HallowedPlateMail, Do(DefenseDelta(+3)) }, + { ItemID.HallowedRepeater, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.Hammush, Do(HammerPower(85), UseTimeExact(10), TileBoostExact(+1)) }, + { ItemID.Handgun, pointBlank }, + { ItemID.Harpoon, pointBlank }, + { ItemID.HelFire, autoReuse }, + { ItemID.HellfireArrow, Do(DamageRatio(1.1f)) }, + { ItemID.HellwingBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.HolyArrow, Do(DamageRatio(1.1f)) }, + { ItemID.HornetStaff, Do(AutoReuse, UseExact(30)) }, + { ItemID.IceBlade, Do(DamageExact(26), UseTimeExact(33)) }, + { ItemID.IceBoomerang, Do(DamageRatio(2f)) }, + { ItemID.IceBow, Do(PointBlank, DamageRatio(1.5f)) }, + { ItemID.IceSickle, Do(AutoReuse, DamageExact(95), ShootSpeedExact(20f)) }, + { ItemID.IchorArrow, Do(DamageRatio(1.1f)) }, + { ItemID.ImpStaff, Do(AutoReuse, UseExact(30)) }, + { ItemID.InfernoFork, Do(DamageRatio(1.66f)) }, + { ItemID.InfluxWaver, Do(DamageRatio(0.75f)) }, + { ItemID.IronAxe, Do(AxePower(60), UseTimeExact(15), TileBoostExact(+0)) }, + { ItemID.IronBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.IronBroadsword, Do(AutoReuse, UseTurn, DamageRatio(1.25f)) }, + { ItemID.IronHammer, Do(HammerPower(45), UseTimeExact(11), TileBoostExact(+0)) }, + { ItemID.IronPickaxe, Do(PickPower(40), UseTimeExact(8)) }, + { ItemID.IronShortsword, Do(AutoReuse, DamageRatio(1.25f)) }, + { ItemID.JestersArrow, Do(DamageRatio(1.1f)) }, + { ItemID.JungleYoyo, autoReuse }, + { ItemID.Katana, Do(UseExact(15), DamageRatio(1.5f)) }, + { ItemID.Keybrand, Do(UseTurn, ScaleRatio(1.5f), DamageExact(184), UseExact(18)) }, + { ItemID.KOCannon, Do(DamageRatio(3f)) }, + { ItemID.Kraken, autoReuse }, + { ItemID.LaserDrill, Do(PickPower(220), AxePower(120), UseTimeExact(4)) }, + { ItemID.LastPrism, Do(DamageRatio(0.75f)) }, + { ItemID.LeadAxe, Do(AxePower(60), UseTimeExact(15), TileBoostExact(+0)) }, + { ItemID.LeadBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.LeadBroadsword, Do(AutoReuse, UseTurn, DamageRatio(1.25f)) }, + { ItemID.LeadHammer, Do(HammerPower(45), UseTimeExact(11), TileBoostExact(+0)) }, + { ItemID.LeadPickaxe, Do(PickPower(40), UseTimeExact(8)) }, + { ItemID.LeadShortsword, Do(AutoReuse, DamageRatio(1.25f)) }, + { ItemID.LightDisc, Do(DamageExact(128)) }, + { ItemID.LightsBane, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, + { ItemID.LunarFlareBook, Do(DamageRatio(1.5f)) }, + { ItemID.LunarHamaxeNebula, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, + { ItemID.LunarHamaxeSolar, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, + { ItemID.LunarHamaxeStardust, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, + { ItemID.LunarHamaxeVortex, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, + { ItemID.MagicDagger, autoReuse }, + { ItemID.MagicMissile, Do(DamageExact(48), UseExact(15)) }, + { ItemID.MagnetSphere, Do(DamageRatio(1.1f)) }, + { ItemID.Marrow, Do(PointBlank, DamageRatio(1.5f)) }, + { ItemID.MechanicalEye, nonConsumableBossSummon }, + { ItemID.MechanicalSkull, nonConsumableBossSummon }, + { ItemID.MechanicalWorm, nonConsumableBossSummon }, + { ItemID.MedusaHead, Do(DamageRatio(1.66f)) }, + { ItemID.Megashark, pointBlank }, + { ItemID.Meowmere, Do(DamageRatio(1.33f)) }, + { ItemID.MeteorHamaxe, Do(HammerPower(70), AxePower(100), UseTimeExact(16), TileBoostExact(+0)) }, + { ItemID.MeteorStaff, Do(DamageExact(58), ManaExact(7), ShootSpeedExact(13f)) }, + { ItemID.Minishark, pointBlank }, + { ItemID.MoltenFury, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.MoltenHamaxe, Do(HammerPower(75), AxePower(125), UseTimeExact(14), TileBoostExact(+0)) }, + { ItemID.MoltenPickaxe, Do(PickPower(100), UseTimeExact(10)) }, + { ItemID.MonkStaffT1, Do(TrueMelee, DamageExact(110)) }, + { ItemID.MonkStaffT2, Do(AutoReuse, TrueMelee, DamageRatio(2f)) }, + { ItemID.MonkStaffT3, Do(DamageExact(225)) }, + { ItemID.MoonlordArrow, Do(DamageRatio(1.1f)) }, + { ItemID.MoonlordTurretStaff, Do(UseExact(15), DamageRatio(1.5f)) }, + { ItemID.Muramasa, Do(ScaleRatio(1.5f), DamageRatio(2f)) }, + { ItemID.MushroomSpear, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(100)) }, + { ItemID.Musket, pointBlank }, + { ItemID.MythrilChainsaw, Do(TrueMelee, AxePower(80), UseTimeExact(4), TileBoostExact(-1)) }, + { ItemID.MythrilDrill, Do(TrueMelee, PickPower(160), UseTimeExact(4)) }, + { ItemID.MythrilHalberd, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(95), ShootSpeedRatio(1.25f)) }, + { ItemID.MythrilPickaxe, Do(PickPower(160), UseTimeExact(8)) }, + { ItemID.MythrilRepeater, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.MythrilSword, Do(UseTurn, ScaleRatio(1.5f), DamageExact(100), UseExact(25)) }, + { ItemID.MythrilWaraxe, Do(AxePower(140), UseTimeExact(11), TileBoostExact(+0)) }, + { ItemID.NaughtyPresent, nonConsumableBossSummon }, + { ItemID.NebulaChainsaw, trueMelee }, + { ItemID.NebulaDrill, Do(TrueMelee, PickPower(225), UseTimeExact(3), TileBoostExact(+4)) }, + { ItemID.NebulaPickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, + { ItemID.NettleBurst, Do(DamageRatio(1.33f)) }, + { ItemID.NightmarePickaxe, Do(PickPower(66), UseTimeExact(9)) }, + { ItemID.NightsEdge, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(3f)) }, + { ItemID.NorthPole, autoReuse }, + { ItemID.ObsidianShield, Do(DefenseDelta(+5)) }, + { ItemID.ObsidianSkull, Do(DefenseDelta(+1)) }, + { ItemID.ObsidianSwordfish, Do(AutoReuse, TrueMelee, DamageExact(45)) }, + { ItemID.OnyxBlaster, pointBlank }, + { ItemID.OpticStaff, Do(AutoReuse, UseExact(25), DamageRatio(0.75f)) }, // NOTE: Optic Staff minions have local iframes, so they should be much better overall + { ItemID.OrichalcumBreastplate, Do(DefenseDelta(+3)) }, + { ItemID.OrichalcumChainsaw, Do(TrueMelee, AxePower(80), UseTimeExact(4), TileBoostExact(-1)) }, + { ItemID.OrichalcumDrill, Do(TrueMelee, PickPower(160), UseTimeExact(4)) }, + { ItemID.OrichalcumHalberd, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(98), ShootSpeedRatio(1.25f)) }, + { ItemID.OrichalcumHeadgear, Do(DefenseDelta(+2)) }, + { ItemID.OrichalcumHelmet, Do(DefenseDelta(+3)) }, + { ItemID.OrichalcumLeggings, Do(DefenseDelta(+4)) }, + { ItemID.OrichalcumMask, Do(DefenseDelta(+3)) }, + { ItemID.OrichalcumPickaxe, Do(PickPower(160), UseTimeExact(8)) }, + { ItemID.OrichalcumRepeater, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.OrichalcumSword, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(82)) }, + { ItemID.OrichalcumWaraxe, Do(AxePower(140), UseTimeExact(11), TileBoostExact(+0)) }, + { ItemID.PainterPaintballGun, pointBlank }, + { ItemID.PaladinsHammer, Do(AutoReuse, DamageExact(100)) }, + { ItemID.PaladinsShield, Do(DefenseDelta(+3)) }, + { ItemID.PalladiumBreastplate, Do(DefenseDelta(+3)) }, + { ItemID.PalladiumChainsaw, Do(TrueMelee, AxePower(70), UseTimeExact(4), TileBoostExact(-1)) }, + { ItemID.PalladiumDrill, Do(TrueMelee, PickPower(130), UseTimeExact(5)) }, + { ItemID.PalladiumHeadgear, Do(DefenseDelta(+2)) }, + { ItemID.PalladiumHelmet, Do(DefenseDelta(+3)) }, + { ItemID.PalladiumMask, Do(DefenseDelta(+1)) }, + { ItemID.PalladiumLeggings, Do(DefenseDelta(+3)) }, + { ItemID.PalladiumPickaxe, Do(PickPower(130), UseTimeExact(9)) }, + { ItemID.PalladiumPike, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageRatio(3f)) }, + { ItemID.PalladiumRepeater, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.PalladiumSword, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(100)) }, + { ItemID.PalladiumWaraxe, Do(AxePower(125), UseTimeExact(12), TileBoostExact(+0)) }, + { ItemID.PalmWoodBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.PalmWoodHammer, Do(HammerPower(25), UseTimeExact(11), TileBoostExact(+0)) }, + { ItemID.PalmWoodSword, Do(AutoReuse, UseTurn, DamageRatio(4f)) }, + { ItemID.PearlwoodBow, Do(AutoReuse, PointBlank, DamageRatio(2.31f), UseDelta(+8), ShootSpeedDelta(+3.4f), KnockbackDelta(+1f)) }, + { ItemID.PearlwoodHammer, Do(HammerPower(25), UseTimeExact(4), UseAnimationExact(20), DamageRatio(4f), TileBoostExact(+0)) }, + { ItemID.PearlwoodSword, autoReuse }, + { ItemID.Phantasm, pointBlank }, + { ItemID.PhoenixBlaster, Do(AutoReuse, PointBlank, DamageRatio(0.75f)) }, // Phoenix Blaster is nerfed to compensate for autofire + { ItemID.PickaxeAxe, Do(PickPower(200), AxePower(110), UseTimeExact(7), TileBoostExact(+1)) }, + { ItemID.Picksaw, Do(PickPower(210), AxePower(125), UseTimeExact(6), TileBoostExact(+1)) }, + { ItemID.PirateMap, nonConsumableBossSummon }, + { ItemID.PirateStaff, Do(AutoReuse, UseExact(25)) }, + { ItemID.PlatinumAxe, Do(AxePower(80), UseTimeExact(14), TileBoostExact(+0)) }, + { ItemID.PlatinumBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.PlatinumBroadsword, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, + { ItemID.PlatinumHammer, Do(HammerPower(60), UseTimeExact(9), TileBoostExact(+0)) }, + { ItemID.PlatinumPickaxe, Do(PickPower(55), UseTimeExact(9)) }, + { ItemID.PlatinumShortsword, Do(AutoReuse, DamageRatio(2f)) }, + { ItemID.PoisonStaff, Do(DamageRatio(1.2f)) }, + { ItemID.ProximityMineLauncher, Do(DamageRatio(2f)) }, + { ItemID.PsychoKnife, Do(UseTurn, DamageRatio(4f)) }, + { ItemID.PulseBow, Do(PointBlank, DamageRatio(1.66f)) }, + { ItemID.PumpkinMoonMedallion, nonConsumableBossSummon }, + { ItemID.PurpleClubberfish, Do(UseTurn, ScaleRatio(1.5f), DamageExact(45), KnockbackExact(10f)) }, + { ItemID.PurplePhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, + { ItemID.PurplePhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, + { ItemID.PurpleSolution, Do(Value(Item.buyPrice(silver: 5))) }, + { ItemID.Pwnhammer, Do(HammerPower(80), UseTimeExact(11), TileBoostExact(+1)) }, + { ItemID.PygmyStaff, Do(UseExact(20)) }, + // { ItemID.QuadBarrelShotgun, pointBlank }, + { ItemID.QueenSpiderStaff, Do(UseExact(25)) }, + { ItemID.RainbowCrystalStaff, Do(UseExact(15)) }, + { ItemID.RainbowRod, Do(DamageExact(130)) }, + { ItemID.Rally, Do(AutoReuse, DamageExact(20)) }, + { ItemID.RavenStaff, Do(UseExact(20)) }, + { ItemID.Razorpine, Do(DamageRatio(0.75f)) }, + { ItemID.ReaverShark, Do(PickPower(100), UseTimeExact(16)) }, + { ItemID.RedPhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, + { ItemID.RedPhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, + { ItemID.RedRyder, pointBlank }, + { ItemID.RedSolution, Do(Value(Item.buyPrice(silver: 5))) }, + { ItemID.RedsYoyo, autoReuse }, + { ItemID.Revolver, pointBlank }, + { ItemID.RichMahoganyBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.RichMahoganyHammer, Do(HammerPower(25), UseTimeExact(10), TileBoostExact(+0)) }, + { ItemID.RichMahoganySword, Do(AutoReuse, UseTurn) }, + { ItemID.RocketIII, Do(DamageRatio(0.75f)) }, + { ItemID.RocketIV, Do(DamageRatio(0.75f)) }, + { ItemID.RocketLauncher, Do(DamageRatio(2f)) }, + { ItemID.Rockfish, Do(HammerPower(50), UseTimeExact(10), TileBoostExact(+0)) }, + { ItemID.RubyStaff, Do(DamageExact(25)) }, + { ItemID.Sandgun, pointBlank }, + { ItemID.SapphireStaff, Do(AutoReuse, DamageExact(25)) }, + // { ItemID.SanguineStaff, Do(AutoReuse, UseExact(25)) }, + { ItemID.SawtoothShark, Do(TrueMelee, AxePower(45), UseTimeExact(4), TileBoostExact(-1)) }, + { ItemID.SDMG, pointBlank }, + { ItemID.Seedler, Do(DamageRatio(1.5f)) }, + { ItemID.Shackle, Do(DefenseDelta(+2)) }, + { ItemID.ShadewoodBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.ShadewoodHammer, Do(HammerPower(25), UseTimeExact(9), TileBoostExact(+0)) }, + { ItemID.ShadewoodSword, Do(AutoReuse, UseTurn) }, + { ItemID.ShadowbeamStaff, Do(DamageRatio(2f)) }, + { ItemID.ShadowFlameBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.ShadowFlameKnife, Do(DamageExact(70)) }, + { ItemID.Shotgun, pointBlank }, + { ItemID.ShroomiteDiggingClaw, Do(PickPower(200), AxePower(125), UseTimeExact(4), TileBoostExact(-1)) }, + { ItemID.SilverAxe, Do(AxePower(70), UseTimeExact(14), TileBoostExact(+0)) }, + { ItemID.SilverBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.SilverBroadsword, Do(AutoReuse, UseTurn, DamageRatio(1.5f)) }, + { ItemID.SilverHammer, Do(HammerPower(55), UseTimeExact(10), TileBoostExact(+0)) }, + { ItemID.SilverPickaxe, Do(PickPower(50), UseTimeExact(11)) }, + { ItemID.SilverShortsword, Do(AutoReuse, DamageRatio(1.5f)) }, + { ItemID.SkyFracture, Do(DamageExact(54), ShootSpeedExact(30f)) }, + { ItemID.SlapHand, Do(UseTurn, ScaleRatio(1.5f), DamageExact(120)) }, + { ItemID.SlimeCrown, nonConsumableBossSummon }, + { ItemID.SlimeStaff, Do(AutoReuse, UseExact(30)) }, + // { ItemID.Smolstar, Do(AutoReuse, UseExact(25)) }, + { ItemID.SniperRifle, pointBlank }, + { ItemID.SnowballCannon, pointBlank }, + { ItemID.SnowGlobe, nonConsumableBossSummon }, + { ItemID.SolarEruption, Do(DamageRatio(1.5f)) }, + { ItemID.SolarFlareBreastplate, Do(DefenseDelta(+7)) }, + { ItemID.SolarFlareChainsaw, trueMelee }, + { ItemID.SolarFlareDrill, Do(TrueMelee, PickPower(225), UseTimeExact(3), TileBoostExact(+4)) }, + { ItemID.SolarFlareHelmet, Do(DefenseDelta(+5)) }, + { ItemID.SolarFlareLeggings, Do(DefenseDelta(+4)) }, + { ItemID.SolarFlarePickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, + { ItemID.SolarTablet, nonConsumableBossSummon }, + { ItemID.SoulDrain, Do(DamageRatio(1.33f)) }, + { ItemID.SpaceGun, Do(DamageExact(25)) }, + { ItemID.Spear, Do(AutoReuse, TrueMelee, DamageRatio(2f)) }, + { ItemID.SpectreHamaxe, Do(HammerPower(90), AxePower(170), UseTimeExact(8), TileBoostExact(+4)) }, + { ItemID.SpectrePickaxe, Do(PickPower(200), UseTimeExact(8), TileBoostExact(+4)) }, + { ItemID.SpectreStaff, Do(DamageRatio(3f)) }, + { ItemID.SpiderStaff, Do(AutoReuse, UseExact(25)) }, + { ItemID.StaffofEarth, Do(DamageRatio(1.66f)) }, + { ItemID.StaffoftheFrostHydra, Do(UseExact(20)) }, + { ItemID.StakeLauncher, Do(PointBlank, DamageRatio(1.25f)) }, + { ItemID.StardustCellStaff, Do(UseExact(20)) }, + { ItemID.StardustChainsaw, trueMelee }, + { ItemID.StardustDragonStaff, Do(AutoReuse, DamageExact(20), UseExact(19)) }, + { ItemID.StardustDrill, Do(TrueMelee, PickPower(225), UseTimeExact(3), TileBoostExact(+4)) }, + { ItemID.StardustPickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, + { ItemID.Starfury, autoReuse }, + { ItemID.StarWrath, Do(DamageRatio(0.9f)) }, + { ItemID.StickyBomb, maxStack999 }, + { ItemID.StickyDynamite, maxStack999 }, + // { ItemID.StormSpear, autoReuse }, + // { ItemID.StormTigerStaff, UseExact(20) }, + { ItemID.StylistKilLaKillScissorsIWish, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageExact(33)) }, + { ItemID.Sunfury, Do(DamageRatio(2f)) }, + { ItemID.SuspiciousLookingEye, nonConsumableBossSummon }, + { ItemID.Swordfish, Do(AutoReuse, TrueMelee, DamageExact(38)) }, + { ItemID.TacticalShotgun, Do(PointBlank, DamageRatio(1.2f)) }, + { ItemID.TaxCollectorsStickOfDoom, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(70)) }, + { ItemID.TempestStaff, Do(UseExact(20)) }, + { ItemID.TendonBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.Terrarian, Do(AutoReuse, DamageExact(352)) }, + { ItemID.TheAxe, Do(HammerPower(100), AxePower(175), UseTimeExact(7), TileBoostExact(+1)) }, + { ItemID.TheBreaker, Do(HammerPower(70), UseTimeExact(13), TileBoostExact(+0)) }, + { ItemID.TheEyeOfCthulhu, autoReuse }, + { ItemID.TheHorsemansBlade, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(95)) }, + { ItemID.TheMeatball, Do(DamageRatio(2f)) }, + { ItemID.TheRottedFork, Do(AutoReuse, TrueMelee, DamageExact(20)) }, + { ItemID.TheUndertaker, pointBlank }, + { ItemID.ThornChakram, Do(DamageRatio(2f)) }, + { ItemID.TinAxe, Do(AxePower(50), UseTimeExact(16), TileBoostExact(+0)) }, + { ItemID.TinBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.TinBroadsword, Do(AutoReuse, UseTurn) }, + { ItemID.TinHammer, Do(HammerPower(35), UseTimeExact(12), TileBoostExact(+0)) }, + { ItemID.TinPickaxe, Do(PickPower(35), UseTimeExact(10), TileBoostExact(+0)) }, + { ItemID.TinShortsword, autoReuse }, + { ItemID.TitaniumChainsaw, Do(TrueMelee, AxePower(90), UseTimeExact(4), TileBoostExact(+0)) }, + { ItemID.TitaniumDrill, Do(TrueMelee, PickPower(180), UseTimeExact(4), TileBoostExact(+1)) }, + { ItemID.TitaniumPickaxe, Do(PickPower(180), UseTimeExact(8), TileBoostExact(+1)) }, + { ItemID.TitaniumRepeater, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.TitaniumSword, Do(UseTurn, ScaleRatio(1.5f), UseRatio(0.8f), DamageExact(77)) }, + { ItemID.TitaniumTrident, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(72), ShootSpeedRatio(1.25f)) }, + { ItemID.TitaniumWaraxe, Do(AxePower(160), UseTimeExact(10), TileBoostExact(+1)) }, + { ItemID.TopazStaff, Do(ManaExact(2)) }, + { ItemID.Trident, Do(AutoReuse, TrueMelee, DamageRatio(2f)) }, + { ItemID.TrueExcalibur, Do(AutoReuse, UseTurn, DamageExact(82)) }, + { ItemID.TrueNightsEdge, Do(AutoReuse, UseTurn, DamageExact(160), ShootSpeedExact(16), ScaleRatio(1.5f)) }, + { ItemID.Tsunami, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.TungstenAxe, Do(AxePower(70), UseTimeExact(14), TileBoostExact(+0)) }, + { ItemID.TungstenBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.TungstenBroadsword, Do(AutoReuse, UseTurn, DamageRatio(1.5f)) }, + { ItemID.TungstenHammer, Do(HammerPower(55), UseTimeExact(10), TileBoostExact(+0)) }, + { ItemID.TungstenPickaxe, Do(PickPower(50), UseTimeExact(11)) }, + { ItemID.TungstenShortsword, Do(AutoReuse, DamageRatio(1.5f)) }, + { ItemID.UnholyArrow, Do(DamageRatio(1.1f)) }, + { ItemID.UnholyTrident, Do(ManaExact(14)) }, + { ItemID.Uzi, pointBlank }, + { ItemID.ValkyrieYoyo, autoReuse }, + // { ItemID.VampireFrogStaff, Do(AutoReuse, UseExact(30)) } + { ItemID.VampireKnives, Do(DamageRatio(1.33f)) }, + { ItemID.VenomArrow, Do(DamageRatio(1.1f)) }, + { ItemID.VenomStaff, Do(DamageRatio(1.33f)) }, + { ItemID.VenusMagnum, Do(AutoReuse, PointBlank) }, + { ItemID.Vilethorn, Do(DamageExact(14)) }, + { ItemID.VortexBeater, pointBlank }, + { ItemID.VortexChainsaw, trueMelee }, + { ItemID.VortexDrill, Do(TrueMelee, PickPower(225), UseTimeExact(3), TileBoostExact(+4)) }, + { ItemID.VortexPickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, + { ItemID.WandofSparking, Do(AutoReuse, DamageExact(15)) }, + { ItemID.WarAxeoftheNight, Do(AxePower(100), UseTimeExact(13), TileBoostExact(+0)) }, + { ItemID.WaspGun, Do(DamageRatio(1.5f)) }, + { ItemID.WaterBolt, Do(DamageExact(28)) }, + { ItemID.WhitePhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, + { ItemID.WhitePhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, + { ItemID.WoodenArrow, Do(DamageRatio(1.1f)) }, + { ItemID.WoodenBoomerang, Do(DamageRatio(2f)) }, + { ItemID.WoodenBow, Do(PointBlank, DamageRatio(1.1f)) }, + { ItemID.WoodenHammer, Do(HammerPower(25), UseTimeExact(11), TileBoostExact(+0)) }, + { ItemID.WoodenSword, Do(AutoReuse, UseTurn) }, + { ItemID.WoodYoyo, autoReuse }, + { ItemID.WormFood, nonConsumableBossSummon }, + { ItemID.Xenopopper, Do(DamageRatio(0.75f)) }, + { ItemID.XenoStaff, Do(UseExact(20)) }, + { ItemID.Yelets, autoReuse }, + { ItemID.YellowPhaseblade, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, + { ItemID.YellowPhasesaber, Do(ScaleRatio(1.5f), DamageExact(72), UseExact(20)) }, + { ItemID.ZombieArm, Do(AutoReuse, UseTurn, ScaleRatio(1.5f), DamageRatio(2f)) }, + }; + } + + internal static void UnloadTweaks() + { + currentTweaks.Clear(); + currentTweaks = null; + } + #endregion + + #region SetDefaults (Item Tweaks Applied Here) + internal void SetDefaults_ApplyTweaks(Item item) + { + // Do nothing if the tweaks database is not defined. + if (currentTweaks is null) + return; + + // Grab the tweaking or balancing to apply, if any. If nothing comes back, do nothing. + bool needsTweaking = currentTweaks.TryGetValue(item.type, out IItemTweak[] tweaks); + if (!needsTweaking) + return; + + // Apply all alterations sequentially, assuming they are relevant. + foreach (IItemTweak tweak in tweaks) + if (tweak.AppliesTo(item)) + tweak.ApplyTweak(item); + } + #endregion + + #region Internal Structures + + // This function simply concatenates a bunch of Item Tweaks into an array. + // It looks a lot nicer than constantly typing "new IItemTweak[]". + internal static IItemTweak[] Do(params IItemTweak[] r) => r; + + #region Applicability Lambdas + internal static bool DealsDamage(Item it) => it.damage > 0; + internal static bool HasDefense(Item it) => it.defense > 0; + internal static bool HasKnockback(Item it) => !it.accessory & !it.vanity; // how to check if something is wearable armor? + internal static bool IsAxe(Item it) => it.axe > 0; + internal static bool IsHammer(Item it) => it.hammer > 0; + internal static bool IsMelee(Item it) => it.melee; + internal static bool IsPickaxe(Item it) => it.pick > 0; + internal static bool IsScalable(Item it) => it.damage > 0 && it.melee; // sanity check: only melee weapons get scaled + internal static bool IsUsable(Item it) => it.useStyle != 0 && it.useTime > 0 && it.useAnimation > 0; + internal static bool UsesMana(Item it) => IsUsable(it); // Only usable items cost mana, but items must be able to have their mana cost disabled or enabled at will. + #endregion + + #region Item Tweak Definitions + internal interface IItemTweak + { + bool AppliesTo(Item it); + void ApplyTweak(Item it); + } + + internal class AutoReuseRule : IItemTweak + { + internal readonly bool flag = true; + + public AutoReuseRule(bool ar) => flag = ar; + public bool AppliesTo(Item it) => IsUsable(it); + public void ApplyTweak(Item it) => it.autoReuse = flag; + } + internal static IItemTweak AutoReuse => new AutoReuseRule(true); + internal static IItemTweak NoAutoReuse => new AutoReuseRule(false); + + // Uses the values shown by Terraria, which are multiplied by 5, not the internal values + internal class AxePowerRule : IItemTweak + { + internal readonly int newAxePower = 0; + + public AxePowerRule(int newDisplayedAxePower) => newAxePower = newDisplayedAxePower / 5; + public bool AppliesTo(Item it) => IsAxe(it); + public void ApplyTweak(Item it) + { + it.axe = newAxePower; + if (it.axe < 0) + it.axe = 0; + } + } + internal static IItemTweak AxePower(int a) => new AxePowerRule(a); + + internal class ConsumableRule : IItemTweak + { + internal readonly bool flag = false; + + public ConsumableRule(bool c) => flag = c; + public bool AppliesTo(Item it) => true; + public void ApplyTweak(Item it) => it.consumable = flag; + } + internal static IItemTweak Consumable => new ConsumableRule(true); + internal static IItemTweak NotConsumable => new ConsumableRule(false); + + #region Damage + internal class DamageDeltaRule : IItemTweak + { + internal readonly int delta = 0; + + public DamageDeltaRule(int d) => delta = d; + public bool AppliesTo(Item it) => DealsDamage(it); + public void ApplyTweak(Item it) + { + it.damage += delta; + if (it.damage < 0) + it.damage = 0; + } + } + internal static IItemTweak DamageDelta(int d) => new DamageDeltaRule(d); + + internal class DamageExactRule : IItemTweak + { + internal readonly int newDamage = 0; + + public DamageExactRule(int dmg) => newDamage = dmg; + public bool AppliesTo(Item it) => DealsDamage(it); + public void ApplyTweak(Item it) + { + it.damage = newDamage; + if (it.damage < 0) + it.damage = 0; + } + } + internal static IItemTweak DamageExact(int d) => new DamageExactRule(d); + + internal class DamageRatioRule : IItemTweak + { + internal readonly float ratio = 1f; + + public DamageRatioRule(float f) => ratio = f; + public bool AppliesTo(Item it) => DealsDamage(it); + public void ApplyTweak(Item it) + { + it.damage = (int)(it.damage * ratio); + if (it.damage < 0) + it.damage = 0; + } + } + internal static IItemTweak DamageRatio(float f) => new DamageRatioRule(f); + #endregion + + internal class DefenseDeltaRule : IItemTweak + { + internal readonly int delta = 0; + + public DefenseDeltaRule(int d) => delta = d; + public bool AppliesTo(Item it) => HasDefense(it); + public void ApplyTweak(Item it) + { + it.defense += delta; + if (it.defense < 0) + it.defense = 0; + } + } + internal static IItemTweak DefenseDelta(int d) => new DefenseDeltaRule(d); + + internal class DefenseExactRule : IItemTweak + { + internal readonly int newDefense = 0; + + public DefenseExactRule(int def) => newDefense = def; + public bool AppliesTo(Item it) => HasDefense(it); + public void ApplyTweak(Item it) + { + it.defense = newDefense; + if (it.defense < 0) + it.defense = 0; + } + } + internal static IItemTweak DefenseExact(int d) => new DefenseExactRule(d); + + internal class HammerPowerRule : IItemTweak + { + internal readonly int newHammerPower = 0; + + public HammerPowerRule(int h) => newHammerPower = h; + public bool AppliesTo(Item it) => IsHammer(it); + public void ApplyTweak(Item it) + { + it.hammer = newHammerPower; + if (it.hammer < 0) + it.hammer = 0; + } + } + internal static IItemTweak HammerPower(int h) => new HammerPowerRule(h); + + #region Knockback + internal class KnockbackDeltaRule : IItemTweak + { + internal readonly float delta = 0; + + public KnockbackDeltaRule(float d) => delta = d; + public bool AppliesTo(Item it) => HasKnockback(it); + public void ApplyTweak(Item it) + { + it.knockBack += delta; + if (it.knockBack < 0f) + it.knockBack = 0f; + } + } + internal static IItemTweak KnockbackDelta(float d) => new KnockbackDeltaRule(d); + + internal class KnockbackExactRule : IItemTweak + { + internal readonly float newKnockback = 0; + + public KnockbackExactRule(float kb) => newKnockback = kb; + public bool AppliesTo(Item it) => HasKnockback(it); + public void ApplyTweak(Item it) + { + it.knockBack = newKnockback; + if (it.knockBack < 0f) + it.knockBack = 0f; + } + } + internal static IItemTweak KnockbackExact(float kb) => new KnockbackExactRule(kb); + + internal class KnockbackRatioRule : IItemTweak + { + internal readonly float ratio = 1f; + + public KnockbackRatioRule(float f) => ratio = f; + public bool AppliesTo(Item it) => HasKnockback(it); + public void ApplyTweak(Item it) + { + it.knockBack *= ratio; + if (it.knockBack < 0f) + it.knockBack = 0f; + } + } + internal static IItemTweak KnockbackRatio(float r) => new KnockbackRatioRule(r); + #endregion + + #region Mana Cost + internal class ManaDeltaRule : IItemTweak + { + internal readonly int delta = 0; + + public ManaDeltaRule(int d) => delta = d; + public bool AppliesTo(Item it) => UsesMana(it); + public void ApplyTweak(Item it) + { + it.mana += delta; + if (it.mana < 0) + it.mana = 0; + } + } + internal static IItemTweak ManaDelta(int d) => new ManaDeltaRule(d); + + internal class ManaExactRule : IItemTweak + { + internal readonly int newMana = 0; + + public ManaExactRule(int m) => newMana = m; + public bool AppliesTo(Item it) => UsesMana(it); + public void ApplyTweak(Item it) + { + it.mana = newMana; + if (it.mana < 0) + it.mana = 0; + } + } + internal static IItemTweak ManaExact(int m) => new ManaExactRule(m); + + internal class ManaRatioRule : IItemTweak + { + internal readonly float ratio = 1f; + + public ManaRatioRule(float f) => ratio = f; + public bool AppliesTo(Item it) => UsesMana(it); + public void ApplyTweak(Item it) + { + it.mana = (int)(it.mana * ratio); + if (it.mana < 0) + it.mana = 0; + } + } + internal static IItemTweak ManaRatio(float f) => new ManaRatioRule(f); + #endregion + + internal class MaxStackRule : IItemTweak // max stack plus - calamity style + { + internal readonly int newMaxStack = 999; + + public MaxStackRule(int stk) => newMaxStack = stk; + public bool AppliesTo(Item it) => true; + public void ApplyTweak(Item it) + { + it.maxStack = newMaxStack; + if (it.maxStack < 1) + it.maxStack = 1; + } + } + internal static IItemTweak MaxStack(int stk) => new MaxStackRule(stk); + + internal class PickPowerRule : IItemTweak + { + internal readonly int newPickPower = 0; + + public PickPowerRule(int p) => newPickPower = p; + public bool AppliesTo(Item it) => IsPickaxe(it); + public void ApplyTweak(Item it) + { + it.pick = newPickPower; + if (it.pick < 0) + it.pick = 0; + } + } + internal static IItemTweak PickPower(int p) => new PickPowerRule(p); + + internal class PointBlankRule : IItemTweak + { + public bool AppliesTo(Item it) => true; + public void ApplyTweak(Item it) => it.Calamity().canFirePointBlankShots = true; + } + internal static IItemTweak PointBlank => new PointBlankRule(); + + #region Scale (True Melee) + internal class ScaleDeltaRule : IItemTweak + { + internal readonly float delta = 0; + + public ScaleDeltaRule(float d) => delta = d; + public bool AppliesTo(Item it) => IsScalable(it); + public void ApplyTweak(Item it) + { + it.scale += delta; + if (it.scale < 0f) + it.scale = 0f; + } + } + internal static IItemTweak ScaleDelta(float d) => new ScaleDeltaRule(d); + + internal class ScaleExactRule : IItemTweak + { + internal readonly float newScale = 0; + + public ScaleExactRule(float s) => newScale = s; + public bool AppliesTo(Item it) => IsScalable(it); + public void ApplyTweak(Item it) + { + it.scale = newScale; + if (it.scale < 0f) + it.scale = 0f; + } + } + internal static IItemTweak ScaleExact(float s) => new ScaleExactRule(s); + + internal class ScaleRatioRule : IItemTweak + { + internal readonly float ratio = 1f; + + public ScaleRatioRule(float f) => ratio = f; + public bool AppliesTo(Item it) => IsScalable(it); + public void ApplyTweak(Item it) + { + it.scale *= ratio; + if (it.scale < 0f) + it.scale = 0f; + } + } + internal static IItemTweak ScaleRatio(float f) => new ScaleRatioRule(f); + #endregion + + #region Shoot Speed (Velocity) + internal class ShootSpeedDeltaRule : IItemTweak + { + internal readonly float delta = 0; + + public ShootSpeedDeltaRule(float d) => delta = d; + public bool AppliesTo(Item it) => IsScalable(it); + public void ApplyTweak(Item it) + { + it.shootSpeed += delta; + if (it.shootSpeed < 0f) + it.shootSpeed = 0f; + } + } + internal static IItemTweak ShootSpeedDelta(float d) => new ShootSpeedDeltaRule(d); + + internal class ShootSpeedExactRule : IItemTweak + { + internal readonly float newShootSpeed = 0; + + public ShootSpeedExactRule(float ss) => newShootSpeed = ss; + public bool AppliesTo(Item it) => IsScalable(it); + public void ApplyTweak(Item it) + { + it.shootSpeed = newShootSpeed; + if (it.shootSpeed < 0f) + it.shootSpeed = 0f; + } + } + internal static IItemTweak ShootSpeedExact(float s) => new ShootSpeedExactRule(s); + + internal class ShootSpeedRatioRule : IItemTweak + { + internal readonly float ratio = 1f; + + public ShootSpeedRatioRule(float f) => ratio = f; + public bool AppliesTo(Item it) => IsScalable(it); + public void ApplyTweak(Item it) + { + it.shootSpeed *= ratio; + if (it.shootSpeed < 0f) + it.shootSpeed = 0f; + } + } + internal static IItemTweak ShootSpeedRatio(float f) => new ShootSpeedRatioRule(f); + #endregion + + internal class TileBoostDeltaRule : IItemTweak + { + private readonly int delta = 0; + + public TileBoostDeltaRule(int d) => delta = d; + public bool AppliesTo(Item it) => true; + public void ApplyTweak(Item it) => it.tileBoost += delta; + } + internal static IItemTweak TileBoostDelta(int d) => new TileBoostDeltaRule(d); + + internal class TileBoostExactRule : IItemTweak + { + private readonly int newTileBoost = 0; + + public TileBoostExactRule(int tb) => newTileBoost = tb; + public bool AppliesTo(Item it) => true; + public void ApplyTweak(Item it) => it.tileBoost = newTileBoost; + } + internal static IItemTweak TileBoostExact(int tb) => new TileBoostExactRule(tb); + + internal class TrueMeleeRule : IItemTweak + { + public bool AppliesTo(Item it) => IsMelee(it); + public void ApplyTweak(Item it) => it.Calamity().trueMelee = true; + } + internal static IItemTweak TrueMelee => new TrueMeleeRule(); + + #region Use Time and Use Animation + internal class UseDeltaRule : IItemTweak + { + internal readonly int delta = 0; + + public UseDeltaRule(int d) => delta = d; + public bool AppliesTo(Item it) => IsUsable(it); + public void ApplyTweak(Item it) + { + it.useAnimation += delta; + it.useTime += delta; + if (it.useAnimation < 1) + it.useAnimation = 1; + if (it.useTime < 1) + it.useTime = 1; + } + } + internal static IItemTweak UseDelta(int d) => new UseDeltaRule(d); + + internal class UseExactRule : IItemTweak + { + internal readonly int newUseTime = 0; + + public UseExactRule(int ut) => newUseTime = ut; + public bool AppliesTo(Item it) => IsUsable(it); + public void ApplyTweak(Item it) + { + it.useAnimation = newUseTime; + it.useTime = newUseTime; + if (it.useAnimation < 1) + it.useAnimation = 1; + if (it.useTime < 1) + it.useTime = 1; + } + } + internal static IItemTweak UseExact(int ut) => new UseExactRule(ut); + + internal class UseRatioRule : IItemTweak + { + internal readonly float ratio = 1f; + + public UseRatioRule(float f) => ratio = f; + public bool AppliesTo(Item it) => IsUsable(it); + public void ApplyTweak(Item it) + { + it.useAnimation = (int)(it.useAnimation * ratio); + it.useTime = (int)(it.useTime * ratio); + if (it.useAnimation < 1) + it.useAnimation = 1; + if (it.useTime < 1) + it.useTime = 1; + } + } + internal static IItemTweak UseRatio(float f) => new UseRatioRule(f); + + internal class UseAnimationDeltaRule : IItemTweak + { + internal readonly int delta = 0; + + public UseAnimationDeltaRule(int d) => delta = d; + public bool AppliesTo(Item it) => IsUsable(it); + public void ApplyTweak(Item it) + { + it.useAnimation += delta; + if (it.useAnimation < 1) + it.useAnimation = 1; + } + } + internal static IItemTweak UseAnimationDelta(int d) => new UseAnimationDeltaRule(d); + + internal class UseAnimationExactRule : IItemTweak + { + internal readonly int newUseAnimation = 0; + + public UseAnimationExactRule(int ua) => newUseAnimation = ua; + public bool AppliesTo(Item it) => IsUsable(it); + public void ApplyTweak(Item it) + { + it.useAnimation = newUseAnimation; + if (it.useAnimation < 1) + it.useAnimation = 1; + } + } + internal static IItemTweak UseAnimationExact(int ua) => new UseAnimationExactRule(ua); + + internal class UseAnimationRatioRule : IItemTweak + { + internal readonly float ratio = 1f; + + public UseAnimationRatioRule(float f) => ratio = f; + public bool AppliesTo(Item it) => IsUsable(it); + public void ApplyTweak(Item it) + { + it.useAnimation = (int)(it.useAnimation * ratio); + if (it.useAnimation < 1) + it.useAnimation = 1; + } + } + internal static IItemTweak UseAnimationRatio(float f) => new UseAnimationRatioRule(f); + + internal class UseTimeDeltaRule : IItemTweak + { + internal readonly int delta = 0; + + public UseTimeDeltaRule(int d) => delta = d; + public bool AppliesTo(Item it) => IsUsable(it); + public void ApplyTweak(Item it) + { + it.useTime += delta; + if (it.useTime < 1) + it.useTime = 1; + } + } + internal static IItemTweak UseTimeDelta(int d) => new UseTimeDeltaRule(d); + + internal class UseTimeExactRule : IItemTweak + { + internal readonly int newUseTime = 0; + + public UseTimeExactRule(int ut) => newUseTime = ut; + public bool AppliesTo(Item it) => IsUsable(it); + public void ApplyTweak(Item it) + { + it.useTime = newUseTime; + if (it.useTime < 1) + it.useTime = 1; + } + } + internal static IItemTweak UseTimeExact(int ut) => new UseTimeExactRule(ut); + + internal class UseTimeRatioRule : IItemTweak + { + internal readonly float ratio = 1f; + + public UseTimeRatioRule(float f) => ratio = f; + public bool AppliesTo(Item it) => IsUsable(it); + public void ApplyTweak(Item it) + { + it.useTime = (int)(it.useTime * ratio); + if (it.useTime < 1) + it.useTime = 1; + } + } + internal static IItemTweak UseTimeRatio(float f) => new UseTimeRatioRule(f); + #endregion + + internal class UseTurnRule : IItemTweak + { + internal readonly bool flag = true; + + public UseTurnRule(bool ut) => flag = ut; + public bool AppliesTo(Item it) => IsUsable(it); + public void ApplyTweak(Item it) => it.useTurn = flag; + } + internal static IItemTweak UseTurn => new UseTurnRule(true); + internal static IItemTweak NoUseTurn => new UseTurnRule(false); + + internal class ValueRule : IItemTweak + { + internal readonly int newValue = 0; + + public ValueRule(int v) => newValue = v; + public bool AppliesTo(Item it) => true; + public void ApplyTweak(Item it) + { + it.value = newValue; + if (it.value < 0) + it.value = 0; + } + } + internal static IItemTweak Value(int v) => new ValueRule(v); + internal static IItemTweak Worthless => new ValueRule(0); + #endregion + #endregion + } } diff --git a/Items/DifficultyItems/BallAndChain.cs b/Items/DifficultyItems/BallAndChain.cs index a0d9ea4fee..c1d6401f56 100644 --- a/Items/DifficultyItems/BallAndChain.cs +++ b/Items/DifficultyItems/BallAndChain.cs @@ -4,39 +4,39 @@ using Terraria.ModLoader; namespace CalamityMod.Items.DifficultyItems { - public class BallAndChain : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ball and Chain"); - Tooltip.SetDefault("So heavy...\n" + - "Favorite this item to disable any dashes granted by equipment."); - } + public class BallAndChain : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ball and Chain"); + Tooltip.SetDefault("So heavy...\n" + + "Favorite this item to disable any dashes granted by equipment."); + } - public override void SetDefaults() - { - item.width = 32; - item.height = 50; - item.rare = ItemRarityID.Blue; - } + public override void SetDefaults() + { + item.width = 32; + item.height = 50; + item.rare = ItemRarityID.Blue; + } - public override bool CanUseItem(Player player) => false; + public override bool CanUseItem(Player player) => false; - public override void UpdateInventory(Player player) - { - if (item.favorited) - player.Calamity().blockAllDashes = true; - } + public override void UpdateInventory(Player player) + { + if (item.favorited) + player.Calamity().blockAllDashes = true; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.IronBar, 10); - recipe.anyIronBar = true; - recipe.AddIngredient(ItemID.Chain); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.IronBar, 10); + recipe.anyIronBar = true; + recipe.AddIngredient(ItemID.Chain); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/DifficultyItems/Death.cs b/Items/DifficultyItems/Death.cs index 4b54262eb8..f32dc7b52a 100644 --- a/Items/DifficultyItems/Death.cs +++ b/Items/DifficultyItems/Death.cs @@ -15,24 +15,24 @@ namespace CalamityMod.Items.DifficultyItems DisplayName.SetDefault("Death"); Tooltip.SetDefault("Enables/disables Death Mode, can only be used in Revengeance Mode.\n" + - // Rev Mode line - "All effects from Revengeance Mode are enabled, including the following:\n" + + // Rev Mode line + "All effects from Revengeance Mode are enabled, including the following:\n" + - // Biome effect lines + // Biome effect lines "Greatly boosts enemy spawn rates during the Blood Moon.\n" + "Makes the Abyss more treacherous to navigate.\n" + - // General enemy lines - "Certain non-boss enemies and projectiles deal between 6% and 15% more damage.\n" + + // General enemy lines + "Certain non-boss enemies and projectiles deal between 6% and 15% more damage.\n" + - // Misc lines - "Nerfs the effectiveness of life steal a bit more.\n" + - "The Nurse no longer heals you while a boss is alive.\n" + - "Increases damage done by 50% for several debuffs and all alcohols that reduce life regen.\n" + + // Misc lines + "Nerfs the effectiveness of life steal a bit more.\n" + + "The Nurse no longer heals you while a boss is alive.\n" + + "Increases damage done by 50% for several debuffs and all alcohols that reduce life regen.\n" + - // Boss lines - "Changes all boss AIs and most enemy AIs.\n" + - "Increases the damage of all bosses a bit more."); + // Boss lines + "Changes all boss AIs and most enemy AIs.\n" + + "Increases the damage of all bosses a bit more."); } public override void SetDefaults() diff --git a/Items/DifficultyItems/Malice.cs b/Items/DifficultyItems/Malice.cs index 5a22184932..e7e2137db2 100644 --- a/Items/DifficultyItems/Malice.cs +++ b/Items/DifficultyItems/Malice.cs @@ -18,8 +18,8 @@ namespace CalamityMod.Items.DifficultyItems DisplayName.SetDefault("Malice"); Tooltip.SetDefault("Enables/disables Malice Mode, can only be used in Death Mode.\n" + - // Overall description and warning lines - "[c/c01818:This mode is subjective, play how you want, don't expect to live.]\n" + + // Overall description and warning lines + "[c/c01818:This mode is subjective, play how you want, don't expect to live.]\n" + // Rev Mode line "All effects from Death Mode are enabled, including the following:\n" + @@ -65,42 +65,42 @@ namespace CalamityMod.Items.DifficultyItems return false; } - // Can only be used in Death Mode. + // Can only be used in Death Mode. public override bool CanUseItem(Player player) => CalamityWorld.death || CalamityWorld.malice; - public override bool UseItem(Player player) - { - // This world syncing code should only be run by one entity- the server, to prevent a race condition - // with the packets. - if (Main.netMode == NetmodeID.MultiplayerClient) - return true; + public override bool UseItem(Player player) + { + // This world syncing code should only be run by one entity- the server, to prevent a race condition + // with the packets. + if (Main.netMode == NetmodeID.MultiplayerClient) + return true; - if (CalamityPlayer.areThereAnyDamnBosses || CalamityWorld.DoGSecondStageCountdown > 0 || BossRushEvent.BossRushActive) - { - string key = "Mods.CalamityMod.ChangingTheRules"; - Color messageColor = Color.Crimson; - CalamityUtils.DisplayLocalizedText(key, messageColor); - return true; - } - if (!CalamityWorld.malice) - { - CalamityWorld.malice = true; - string key = "Mods.CalamityMod.MaliceText"; - Color messageColor = Color.Crimson; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - else - { - CalamityWorld.malice = false; - string key = "Mods.CalamityMod.MaliceText2"; - Color messageColor = Color.Crimson; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - CalamityWorld.DoGSecondStageCountdown = 0; - CalamityNetcode.SyncWorld(); + if (CalamityPlayer.areThereAnyDamnBosses || CalamityWorld.DoGSecondStageCountdown > 0 || BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.ChangingTheRules"; + Color messageColor = Color.Crimson; + CalamityUtils.DisplayLocalizedText(key, messageColor); + return true; + } + if (!CalamityWorld.malice) + { + CalamityWorld.malice = true; + string key = "Mods.CalamityMod.MaliceText"; + Color messageColor = Color.Crimson; + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + else + { + CalamityWorld.malice = false; + string key = "Mods.CalamityMod.MaliceText2"; + Color messageColor = Color.Crimson; + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + CalamityWorld.DoGSecondStageCountdown = 0; + CalamityNetcode.SyncWorld(); - return true; - } + return true; + } public override void AddRecipes() { diff --git a/Items/DifficultyItems/Revenge.cs b/Items/DifficultyItems/Revenge.cs index bcc31c68ec..47d63c63a1 100644 --- a/Items/DifficultyItems/Revenge.cs +++ b/Items/DifficultyItems/Revenge.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Items.DifficultyItems } } - // Can only be used in Expert worlds. The Revengeance check is a failsafe that allows you to disable rev in normal mode worlds if it gets enabled for whatever reason. + // Can only be used in Expert worlds. The Revengeance check is a failsafe that allows you to disable rev in normal mode worlds if it gets enabled for whatever reason. public override bool CanUseItem(Player player) => Main.expertMode || CalamityWorld.revenge; public override bool UseItem(Player player) @@ -106,14 +106,14 @@ namespace CalamityMod.Items.DifficultyItems messageColor = Color.Crimson; CalamityUtils.DisplayLocalizedText(key, messageColor); } - if (CalamityWorld.malice) - { - CalamityWorld.malice = false; - key = "Mods.CalamityMod.MaliceText2"; - messageColor = Color.Crimson; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - CalamityWorld.DoGSecondStageCountdown = 0; + if (CalamityWorld.malice) + { + CalamityWorld.malice = false; + key = "Mods.CalamityMod.MaliceText2"; + messageColor = Color.Crimson; + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + CalamityWorld.DoGSecondStageCountdown = 0; CalamityNetcode.SyncWorld(); } return true; diff --git a/Items/DraedonMisc/AuricQuantumCoolingCell.cs b/Items/DraedonMisc/AuricQuantumCoolingCell.cs index 61fa02adb2..433cb42608 100644 --- a/Items/DraedonMisc/AuricQuantumCoolingCell.cs +++ b/Items/DraedonMisc/AuricQuantumCoolingCell.cs @@ -12,7 +12,7 @@ using System.Linq; namespace CalamityMod.Items.DraedonMisc { - public class AuricQuantumCoolingCell : ModItem + public class AuricQuantumCoolingCell : ModItem { public override void SetStaticDefaults() { diff --git a/Items/DraedonMisc/DecryptionComputer.cs b/Items/DraedonMisc/DecryptionComputer.cs index 1c6d3339f9..676ab97432 100644 --- a/Items/DraedonMisc/DecryptionComputer.cs +++ b/Items/DraedonMisc/DecryptionComputer.cs @@ -60,10 +60,10 @@ namespace CalamityMod.Items.DraedonMisc ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); recipe.AddIngredient(ModContent.ItemType(), 18); recipe.AddIngredient(ModContent.ItemType(), 10); - // You do not need the Decryption Computer for the Tier 1 (Sunken Sea) schematic. - // As such, its recipe can contain anything that is pre-Mechs (where Tier 2 is). - // Wires are thus fair game to include without causing any issues. - recipe.AddIngredient(ItemID.Wire, 100); + // You do not need the Decryption Computer for the Tier 1 (Sunken Sea) schematic. + // As such, its recipe can contain anything that is pre-Mechs (where Tier 2 is). + // Wires are thus fair game to include without causing any issues. + recipe.AddIngredient(ItemID.Wire, 100); recipe.AddRecipeGroup("AnyCopperBar", 10); recipe.AddIngredient(ItemID.Glass, 15); recipe.AddTile(TileID.Anvils); diff --git a/Items/DraedonMisc/EncryptedSchematicIce.cs b/Items/DraedonMisc/EncryptedSchematicIce.cs index 694f4f66cf..3a228efd52 100644 --- a/Items/DraedonMisc/EncryptedSchematicIce.cs +++ b/Items/DraedonMisc/EncryptedSchematicIce.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.DraedonMisc { - public class EncryptedSchematicIce : ModItem + public class EncryptedSchematicIce : ModItem { public override void SetStaticDefaults() { diff --git a/Items/DraedonMisc/LongRangedSensorArray.cs b/Items/DraedonMisc/LongRangedSensorArray.cs index f9be5f1b83..8943b1dbb4 100644 --- a/Items/DraedonMisc/LongRangedSensorArray.cs +++ b/Items/DraedonMisc/LongRangedSensorArray.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Items.DraedonMisc recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddRecipeGroup("AnyMythrilBar", 10); - recipe.AddIngredient(ItemID.Wire, 50); + recipe.AddIngredient(ItemID.Wire, 50); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this, 1); recipe.AddRecipe(); diff --git a/Items/Dyes/AerialiteDye.cs b/Items/Dyes/AerialiteDye.cs index 543ea982fa..056bf6e549 100644 --- a/Items/Dyes/AerialiteDye.cs +++ b/Items/Dyes/AerialiteDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Aerialite Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Orange; item.value = Item.sellPrice(0, 0, 50, 0); } diff --git a/Items/Dyes/AstralBlueDye.cs b/Items/Dyes/AstralBlueDye.cs index 869a47b3ef..ff8dd5a82e 100644 --- a/Items/Dyes/AstralBlueDye.cs +++ b/Items/Dyes/AstralBlueDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Astral Blue Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Cyan; item.value = Item.sellPrice(0, 2, 0, 0); } diff --git a/Items/Dyes/AstralDye.cs b/Items/Dyes/AstralDye.cs index a42e9f20ec..f2cad53ca5 100644 --- a/Items/Dyes/AstralDye.cs +++ b/Items/Dyes/AstralDye.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Dyes } public override void SafeSetDefaults() - { + { item.rare = ItemRarityID.LightRed; item.value = Item.sellPrice(0, 0, 65, 0); } diff --git a/Items/Dyes/AstralOrangeDye.cs b/Items/Dyes/AstralOrangeDye.cs index 02bbb26691..f93cfbc463 100644 --- a/Items/Dyes/AstralOrangeDye.cs +++ b/Items/Dyes/AstralOrangeDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Astral Orange Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Cyan; item.value = Item.sellPrice(0, 2, 0, 0); } diff --git a/Items/Dyes/AstralSwirlDye.cs b/Items/Dyes/AstralSwirlDye.cs index fb756ba046..c7a0c6a7ca 100644 --- a/Items/Dyes/AstralSwirlDye.cs +++ b/Items/Dyes/AstralSwirlDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Astral Swirl Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Cyan; item.value = Item.sellPrice(0, 3, 0, 0); } diff --git a/Items/Dyes/AuricDye.cs b/Items/Dyes/AuricDye.cs index e1af711994..4f08a25dcd 100644 --- a/Items/Dyes/AuricDye.cs +++ b/Items/Dyes/AuricDye.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { - public class AuricDye : BaseDye + public class AuricDye : BaseDye { public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/AuricDyeShader")), "DyePass"). UseColor(new Color(170, 96, 60)).UseSecondaryColor(new Color(226, 196, 106)).SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/SharpNoise")); @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Auric Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Purple; item.Calamity().customRarity = CalamityRarity.Violet; item.value = Item.sellPrice(0, 9, 0, 0); diff --git a/Items/Dyes/BaseDye.cs b/Items/Dyes/BaseDye.cs index 65d718738e..cabca9dac2 100644 --- a/Items/Dyes/BaseDye.cs +++ b/Items/Dyes/BaseDye.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Dyes SafeSetStaticDefaults(); } public sealed override void SetDefaults() - { + { byte dye = item.dye; item.CloneDefaults(ItemID.GelDye); item.dye = dye; diff --git a/Items/Dyes/BloodflareDye.cs b/Items/Dyes/BloodflareDye.cs index c48e0567da..4f4cfb7ab9 100644 --- a/Items/Dyes/BloodflareDye.cs +++ b/Items/Dyes/BloodflareDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Bloodflare Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Red; item.Calamity().customRarity = CalamityRarity.PureGreen; item.value = Item.sellPrice(0, 4, 0, 0); diff --git a/Items/Dyes/BlueCosmicFlameDye.cs b/Items/Dyes/BlueCosmicFlameDye.cs index be095f9472..1318af35e0 100644 --- a/Items/Dyes/BlueCosmicFlameDye.cs +++ b/Items/Dyes/BlueCosmicFlameDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Blue Cosmic Flame Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Purple; item.Calamity().customRarity = CalamityRarity.DarkBlue; item.value = Item.sellPrice(0, 5, 0, 0); diff --git a/Items/Dyes/BlueStatigelDye.cs b/Items/Dyes/BlueStatigelDye.cs index 2aa6f87d3a..32f1febfb4 100644 --- a/Items/Dyes/BlueStatigelDye.cs +++ b/Items/Dyes/BlueStatigelDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Blue Statigel Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.LightRed; item.value = Item.sellPrice(0, 0, 60, 0); } diff --git a/Items/Dyes/BrimflameDye.cs b/Items/Dyes/BrimflameDye.cs index 0083481256..8822ef67e3 100644 --- a/Items/Dyes/BrimflameDye.cs +++ b/Items/Dyes/BrimflameDye.cs @@ -8,7 +8,7 @@ using CalamityMod.Items.Placeables; namespace CalamityMod.Items.Dyes { - public class BrimflameDye : BaseDye + public class BrimflameDye : BaseDye { public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/BrimflameDyeShader")), "DyePass"). UseColor(new Color(252, 147, 34)).UseSecondaryColor(new Color(216, 41, 26)).UseImage("Images/Misc/Perlin"); @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Brimflame Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Pink; item.value = Item.sellPrice(0, 0, 75, 0); } diff --git a/Items/Dyes/CalamitousDye.cs b/Items/Dyes/CalamitousDye.cs index ce329f8051..ebe80492e2 100644 --- a/Items/Dyes/CalamitousDye.cs +++ b/Items/Dyes/CalamitousDye.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { - public class CalamitousDye : BaseDye + public class CalamitousDye : BaseDye { public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/CalamitousDyeShader")), "DyePass"). UseColor(new Color(227, 79, 79)).UseSecondaryColor(new Color(145, 27, 135)).UseImage("Images/Misc/Perlin"); @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Calamitous Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Purple; item.Calamity().customRarity = CalamityRarity.Violet; item.value = Item.sellPrice(0, 10, 0, 0); diff --git a/Items/Dyes/CeaselessDye.cs b/Items/Dyes/CeaselessDye.cs index 9a92a9b23a..699b6b7cee 100644 --- a/Items/Dyes/CeaselessDye.cs +++ b/Items/Dyes/CeaselessDye.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Ceaseless Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Red; //Shouldn't this be purple smh :/ item.Calamity().customRarity = CalamityRarity.Turquoise; item.value = Item.sellPrice(0, 4, 0, 0); diff --git a/Items/Dyes/CosmiliteDye.cs b/Items/Dyes/CosmiliteDye.cs index 5d3dfe2439..8e4a231ec7 100644 --- a/Items/Dyes/CosmiliteDye.cs +++ b/Items/Dyes/CosmiliteDye.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Dyes } public override void SafeSetDefaults() - { + { item.rare = ItemRarityID.Red; item.Calamity().customRarity = CalamityRarity.DarkBlue; item.value = Item.sellPrice(0, 5, 0, 0); diff --git a/Items/Dyes/CryonicDye.cs b/Items/Dyes/CryonicDye.cs index 86fd0e89bc..2c3df3a373 100644 --- a/Items/Dyes/CryonicDye.cs +++ b/Items/Dyes/CryonicDye.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { - public class CryonicDye : BaseDye + public class CryonicDye : BaseDye { public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/CryonicDyeShader")), "DyePass"). UseColor(new Color(138, 225, 255)).UseSecondaryColor(new Color(90, 90, 204)).UseImage("Images/Misc/Perlin"); @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Cryonic Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Pink; item.value = Item.sellPrice(0, 0, 75, 0); } diff --git a/Items/Dyes/DefiledFlameDye.cs b/Items/Dyes/DefiledFlameDye.cs index 5b29481bf8..07a1fff7b0 100644 --- a/Items/Dyes/DefiledFlameDye.cs +++ b/Items/Dyes/DefiledFlameDye.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Defiled Flame Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.LightRed; item.value = CalamityGlobalItem.Rarity4BuyPrice; } diff --git a/Items/Dyes/DragonSoulDye.cs b/Items/Dyes/DragonSoulDye.cs index 7e79c1fcf2..2ff97c2abb 100644 --- a/Items/Dyes/DragonSoulDye.cs +++ b/Items/Dyes/DragonSoulDye.cs @@ -7,7 +7,7 @@ using Terraria.Graphics.Shaders; namespace CalamityMod.Items.Dyes { - public class DragonSoulDye : BaseDye + public class DragonSoulDye : BaseDye { public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/DragonSoulDyeShader")), "DyePass"); public override void SafeSetStaticDefaults() @@ -15,8 +15,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Dragon Soul Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Red; item.Calamity().customRarity = CalamityRarity.Violet; item.value = Item.sellPrice(0, 8, 0, 0); diff --git a/Items/Dyes/ElementalDye.cs b/Items/Dyes/ElementalDye.cs index c4765eb24f..c38efef92e 100644 --- a/Items/Dyes/ElementalDye.cs +++ b/Items/Dyes/ElementalDye.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Elemental Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Purple; item.value = Item.sellPrice(0, 2, 50, 0); } diff --git a/Items/Dyes/EndothermicDye.cs b/Items/Dyes/EndothermicDye.cs index 3b18dce169..2e6500a4c3 100644 --- a/Items/Dyes/EndothermicDye.cs +++ b/Items/Dyes/EndothermicDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Endothermic Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Red; item.Calamity().customRarity = CalamityRarity.DarkBlue; item.value = Item.sellPrice(0, 5, 0, 0); diff --git a/Items/Dyes/ExoDye.cs b/Items/Dyes/ExoDye.cs index 1e2f58d72c..38be0f00f2 100644 --- a/Items/Dyes/ExoDye.cs +++ b/Items/Dyes/ExoDye.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { - public class ExoDye : BaseDye + public class ExoDye : BaseDye { public override ArmorShaderData ShaderDataToBind { @@ -19,8 +19,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Exo Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Purple; item.Calamity().customRarity = CalamityRarity.Violet; item.value = Item.sellPrice(0, 10, 0, 0); diff --git a/Items/Dyes/HairDye/AdrenalineHairDye.cs b/Items/Dyes/HairDye/AdrenalineHairDye.cs index 3616b4909b..a4e00b13a9 100644 --- a/Items/Dyes/HairDye/AdrenalineHairDye.cs +++ b/Items/Dyes/HairDye/AdrenalineHairDye.cs @@ -11,19 +11,19 @@ namespace CalamityMod.Items.Dyes.HairDye DisplayName.SetDefault("Adrenaline Hair Dye"); } - public override void SetDefaults() - { - item.width = 20; - item.height = 26; - item.maxStack = 99; - item.value = Item.buyPrice(gold: 7, silver: 50); - item.rare = ItemRarityID.Green; - item.UseSound = SoundID.Item3; - item.useStyle = ItemUseStyleID.EatingUsing; - item.useTurn = true; - item.useAnimation = 17; - item.useTime = 17; - item.consumable = true; - } - } + public override void SetDefaults() + { + item.width = 20; + item.height = 26; + item.maxStack = 99; + item.value = Item.buyPrice(gold: 7, silver: 50); + item.rare = ItemRarityID.Green; + item.UseSound = SoundID.Item3; + item.useStyle = ItemUseStyleID.EatingUsing; + item.useTurn = true; + item.useAnimation = 17; + item.useTime = 17; + item.consumable = true; + } + } } \ No newline at end of file diff --git a/Items/Dyes/HairDye/RageHairDye.cs b/Items/Dyes/HairDye/RageHairDye.cs index f7f543d0d3..660ab09519 100644 --- a/Items/Dyes/HairDye/RageHairDye.cs +++ b/Items/Dyes/HairDye/RageHairDye.cs @@ -11,19 +11,19 @@ namespace CalamityMod.Items.Dyes.HairDye DisplayName.SetDefault("Rage Hair Dye"); } - public override void SetDefaults() - { - item.width = 20; - item.height = 26; - item.maxStack = 99; - item.value = Item.buyPrice(gold: 7, silver: 50); - item.rare = ItemRarityID.Green; - item.UseSound = SoundID.Item3; - item.useStyle = ItemUseStyleID.EatingUsing; - item.useTurn = true; - item.useAnimation = 17; - item.useTime = 17; - item.consumable = true; - } - } + public override void SetDefaults() + { + item.width = 20; + item.height = 26; + item.maxStack = 99; + item.value = Item.buyPrice(gold: 7, silver: 50); + item.rare = ItemRarityID.Green; + item.UseSound = SoundID.Item3; + item.useStyle = ItemUseStyleID.EatingUsing; + item.useTurn = true; + item.useAnimation = 17; + item.useTime = 17; + item.consumable = true; + } + } } \ No newline at end of file diff --git a/Items/Dyes/HairDye/StealthHairDye.cs b/Items/Dyes/HairDye/StealthHairDye.cs index 2dfe7b5bfb..8f1c076db1 100644 --- a/Items/Dyes/HairDye/StealthHairDye.cs +++ b/Items/Dyes/HairDye/StealthHairDye.cs @@ -11,19 +11,19 @@ namespace CalamityMod.Items.Dyes.HairDye DisplayName.SetDefault("Stealth Hair Dye"); } - public override void SetDefaults() - { - item.width = 20; - item.height = 26; - item.maxStack = 99; - item.value = Item.buyPrice(gold: 5); - item.rare = ItemRarityID.Green; - item.UseSound = SoundID.Item3; - item.useStyle = ItemUseStyleID.EatingUsing; - item.useTurn = true; - item.useAnimation = 17; - item.useTime = 17; - item.consumable = true; - } - } + public override void SetDefaults() + { + item.width = 20; + item.height = 26; + item.maxStack = 99; + item.value = Item.buyPrice(gold: 5); + item.rare = ItemRarityID.Green; + item.UseSound = SoundID.Item3; + item.useStyle = ItemUseStyleID.EatingUsing; + item.useTurn = true; + item.useAnimation = 17; + item.useTime = 17; + item.consumable = true; + } + } } \ No newline at end of file diff --git a/Items/Dyes/HairDye/WingTimeHairDye.cs b/Items/Dyes/HairDye/WingTimeHairDye.cs index 7ebf91ff02..b399be8623 100644 --- a/Items/Dyes/HairDye/WingTimeHairDye.cs +++ b/Items/Dyes/HairDye/WingTimeHairDye.cs @@ -11,19 +11,19 @@ namespace CalamityMod.Items.Dyes.HairDye DisplayName.SetDefault("Wing Time Hair Dye"); } - public override void SetDefaults() - { - item.width = 20; - item.height = 26; - item.maxStack = 99; - item.value = Item.buyPrice(gold: 7, silver: 50); - item.rare = ItemRarityID.Green; - item.UseSound = SoundID.Item3; - item.useStyle = ItemUseStyleID.EatingUsing; - item.useTurn = true; - item.useAnimation = 17; - item.useTime = 17; - item.consumable = true; - } - } + public override void SetDefaults() + { + item.width = 20; + item.height = 26; + item.maxStack = 99; + item.value = Item.buyPrice(gold: 7, silver: 50); + item.rare = ItemRarityID.Green; + item.UseSound = SoundID.Item3; + item.useStyle = ItemUseStyleID.EatingUsing; + item.useTurn = true; + item.useAnimation = 17; + item.useTime = 17; + item.consumable = true; + } + } } \ No newline at end of file diff --git a/Items/Dyes/NightmareDye.cs b/Items/Dyes/NightmareDye.cs index 5d8a0c30c8..ff27568820 100644 --- a/Items/Dyes/NightmareDye.cs +++ b/Items/Dyes/NightmareDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Nightmare Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Red; item.Calamity().customRarity = CalamityRarity.DarkBlue; item.value = Item.sellPrice(0, 5, 0, 0); diff --git a/Items/Dyes/PhantoplasmDye.cs b/Items/Dyes/PhantoplasmDye.cs index 993f77f826..34103a178d 100644 --- a/Items/Dyes/PhantoplasmDye.cs +++ b/Items/Dyes/PhantoplasmDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Phantoplasm Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Purple; item.value = Item.sellPrice(0, 2, 50, 0); } diff --git a/Items/Dyes/PinkCosmicFlameDye.cs b/Items/Dyes/PinkCosmicFlameDye.cs index 9c953cf4bd..a51f323caf 100644 --- a/Items/Dyes/PinkCosmicFlameDye.cs +++ b/Items/Dyes/PinkCosmicFlameDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Pink Cosmic Flame Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Purple; item.Calamity().customRarity = CalamityRarity.DarkBlue; item.value = Item.sellPrice(0, 5, 0, 0); diff --git a/Items/Dyes/PinkStatigelDye.cs b/Items/Dyes/PinkStatigelDye.cs index 5a2034794c..8432a6e900 100644 --- a/Items/Dyes/PinkStatigelDye.cs +++ b/Items/Dyes/PinkStatigelDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Pink Statigel Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.LightRed; item.value = Item.sellPrice(0, 0, 60, 0); } diff --git a/Items/Dyes/ProfanedFlameDye.cs b/Items/Dyes/ProfanedFlameDye.cs index e777cce2b1..fa9173298f 100644 --- a/Items/Dyes/ProfanedFlameDye.cs +++ b/Items/Dyes/ProfanedFlameDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Profaned Flame Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Purple; item.value = Item.sellPrice(0, 2, 50, 0); } diff --git a/Items/Dyes/ProfanedMoonlightDye.cs b/Items/Dyes/ProfanedMoonlightDye.cs index 73d6fd094f..7c925e4997 100644 --- a/Items/Dyes/ProfanedMoonlightDye.cs +++ b/Items/Dyes/ProfanedMoonlightDye.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Profaned Moonlight Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Red; item.Calamity().customRarity = CalamityRarity.Turquoise; item.value = Item.sellPrice(0, 10, 0, 0); diff --git a/Items/Dyes/ReaverDye.cs b/Items/Dyes/ReaverDye.cs index 1806ecf205..aedee4f776 100644 --- a/Items/Dyes/ReaverDye.cs +++ b/Items/Dyes/ReaverDye.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { - public class ReaverDye : BaseDye + 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)); @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Reaver Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Lime; item.value = Item.sellPrice(0, 1, 0, 0); } diff --git a/Items/Dyes/ShadowspecDye.cs b/Items/Dyes/ShadowspecDye.cs index dd405cc505..c977e60376 100644 --- a/Items/Dyes/ShadowspecDye.cs +++ b/Items/Dyes/ShadowspecDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Shadowspec Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Red; item.Calamity().customRarity = CalamityRarity.HotPink; item.value = Item.sellPrice(0, 10, 0, 0); diff --git a/Items/Dyes/SlimeGodDye.cs b/Items/Dyes/SlimeGodDye.cs index d960280902..e7230c2d37 100644 --- a/Items/Dyes/SlimeGodDye.cs +++ b/Items/Dyes/SlimeGodDye.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Slime God Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.LightRed; item.value = Item.sellPrice(0, 0, 65, 0); } diff --git a/Items/Dyes/StratusDye.cs b/Items/Dyes/StratusDye.cs index edf443a7e0..61dbd4e940 100644 --- a/Items/Dyes/StratusDye.cs +++ b/Items/Dyes/StratusDye.cs @@ -18,8 +18,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Stratus Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Red; item.Calamity().customRarity = CalamityRarity.PureGreen; item.value = Item.sellPrice(0, 4, 50, 0); diff --git a/Items/Dyes/SwirlingCosmicFlameDye.cs b/Items/Dyes/SwirlingCosmicFlameDye.cs index 497dc8518c..118909462e 100644 --- a/Items/Dyes/SwirlingCosmicFlameDye.cs +++ b/Items/Dyes/SwirlingCosmicFlameDye.cs @@ -16,8 +16,8 @@ namespace CalamityMod.Items.Dyes DisplayName.SetDefault("Swirling Cosmic Flame Dye"); } - public override void SafeSetDefaults() - { + public override void SafeSetDefaults() + { item.rare = ItemRarityID.Purple; item.Calamity().customRarity = CalamityRarity.DarkBlue; item.value = Item.sellPrice(0, 7, 50, 0); diff --git a/Items/Fishing/AstralCatches/AstralCrate.cs b/Items/Fishing/AstralCatches/AstralCrate.cs index 953a98e3c9..c836b08d45 100644 --- a/Items/Fishing/AstralCatches/AstralCrate.cs +++ b/Items/Fishing/AstralCatches/AstralCrate.cs @@ -48,12 +48,12 @@ namespace CalamityMod.Items.Fishing.AstralCatches //Modded materials DropHelper.DropItem(player, ModContent.ItemType(), 5, 10); DropHelper.DropItem(player, ItemID.FallenStar, 5, 10); - DropHelper.DropItemChance(player, ItemID.Meteorite, 0.2f, 10, 20); - DropHelper.DropItemChance(player, ItemID.MeteoriteBar, 0.1f, 1, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedAstrageldon, 0.2f, 2, 5); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedStarGod, 0.2f, 10, 20); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedStarGod, 0.1f, 1, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedStarGod, 0.25f, 5, 10); + DropHelper.DropItemChance(player, ItemID.Meteorite, 0.2f, 10, 20); + DropHelper.DropItemChance(player, ItemID.MeteoriteBar, 0.1f, 1, 3); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedAstrageldon, 0.2f, 2, 5); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedStarGod, 0.2f, 10, 20); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedStarGod, 0.1f, 1, 3); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedStarGod, 0.25f, 5, 10); // Weapons DropHelper.DropItemFromSetCondition(player, CalamityWorld.downedAstrageldon, 0.1f, @@ -83,26 +83,26 @@ namespace CalamityMod.Items.Fishing.AstralCatches DropHelper.DropItemChance(player, ItemID.MiningPotion, 10, 1, 3); DropHelper.DropItemChance(player, ItemID.HeartreachPotion, 10, 1, 3); DropHelper.DropItemChance(player, ItemID.TrapsightPotion, 10, 1, 3); //Dangersense Potion - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedAstrageldon, 0.1f, 1, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedAstrageldon, 0.1f, 1, 3); - int healingPotID = ItemID.HealingPotion; - int manaPotID = ItemID.ManaPotion; - if (CalamityWorld.downedDoG) - { - healingPotID = ModContent.ItemType(); - manaPotID = ModContent.ItemType(); - } - else if (CalamityWorld.downedProvidence) - { - healingPotID = ItemID.SuperHealingPotion; - manaPotID = ItemID.SuperManaPotion; - } - else if (NPC.downedMechBossAny) - { - healingPotID = ItemID.GreaterHealingPotion; - manaPotID = ItemID.GreaterManaPotion; - } - DropHelper.DropItemChance(player, Main.rand.NextBool(2) ? healingPotID : manaPotID, 0.25f, 2, 5); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedAstrageldon, 0.1f, 1, 3); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedAstrageldon, 0.1f, 1, 3); + int healingPotID = ItemID.HealingPotion; + int manaPotID = ItemID.ManaPotion; + if (CalamityWorld.downedDoG) + { + healingPotID = ModContent.ItemType(); + manaPotID = ModContent.ItemType(); + } + else if (CalamityWorld.downedProvidence) + { + healingPotID = ItemID.SuperHealingPotion; + manaPotID = ItemID.SuperManaPotion; + } + else if (NPC.downedMechBossAny) + { + healingPotID = ItemID.GreaterHealingPotion; + manaPotID = ItemID.GreaterManaPotion; + } + DropHelper.DropItemChance(player, Main.rand.NextBool(2) ? healingPotID : manaPotID, 0.25f, 2, 5); //Money DropHelper.DropItem(player, ItemID.SilverCoin, 10, 90); diff --git a/Items/Fishing/AstralCatches/GacruxianMollusk.cs b/Items/Fishing/AstralCatches/GacruxianMollusk.cs index c33c7a8fbf..70b1d3cd54 100644 --- a/Items/Fishing/AstralCatches/GacruxianMollusk.cs +++ b/Items/Fishing/AstralCatches/GacruxianMollusk.cs @@ -45,8 +45,8 @@ namespace CalamityMod.Items.Fishing.AstralCatches if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Fishing/AstralCatches/UrsaSergeant.cs b/Items/Fishing/AstralCatches/UrsaSergeant.cs index 0f45b2091c..1de4d7c563 100644 --- a/Items/Fishing/AstralCatches/UrsaSergeant.cs +++ b/Items/Fishing/AstralCatches/UrsaSergeant.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Fishing.AstralCatches public override void SetDefaults() { - item.defense = 20; + item.defense = 20; item.width = 36; item.height = 26; item.value = CalamityGlobalItem.Rarity4BuyPrice; diff --git a/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs b/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs index 611852fe6c..88e094fedb 100644 --- a/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs +++ b/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs @@ -5,10 +5,10 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.BrimstoneCragCatches { - public class Bloodfin : ModItem + public class Bloodfin : ModItem { - public static int BuffType = ModContent.BuffType(); - public static int BuffDuration = 600; + public static int BuffType = ModContent.BuffType(); + public static int BuffDuration = 600; public override void SetStaticDefaults() { @@ -26,9 +26,9 @@ The life regen boost is stronger if below 75% health item.maxStack = 30; item.useTurn = true; item.value = Item.sellPrice(gold: 5); - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.useAnimation = 17; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.useAnimation = 17; item.useTime = 17; item.useStyle = ItemUseStyleID.EatingUsing; item.UseSound = SoundID.Item3; diff --git a/Items/Fishing/BrimstoneCragCatches/Brimlish.cs b/Items/Fishing/BrimstoneCragCatches/Brimlish.cs index 0c9d4919f3..dae832b165 100644 --- a/Items/Fishing/BrimstoneCragCatches/Brimlish.cs +++ b/Items/Fishing/BrimstoneCragCatches/Brimlish.cs @@ -4,37 +4,37 @@ using CalamityMod.World; namespace CalamityMod.Items.Fishing.BrimstoneCragCatches { - public class Brimlish : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Brimlish"); - } + public class Brimlish : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brimlish"); + } - public override void SetDefaults() - { - item.questItem = true; - item.maxStack = 1; - item.width = 36; - item.height = 30; - item.uniqueStack = true; - item.rare = ItemRarityID.Quest; - } + public override void SetDefaults() + { + item.questItem = true; + item.maxStack = 1; + item.width = 36; + item.height = 30; + item.uniqueStack = true; + item.rare = ItemRarityID.Quest; + } - public override bool IsQuestFish() - { - return true; - } + public override bool IsQuestFish() + { + return true; + } - public override bool IsAnglerQuestAvailable() - { - return CalamityWorld.downedBrimstoneElemental; - } + public override bool IsAnglerQuestAvailable() + { + return CalamityWorld.downedBrimstoneElemental; + } - public override void AnglerQuestChat(ref string description, ref string catchLocation) - { - description = "When you defeated the ancient goddess, her children fell in the lava as a result of the aftermath. Rumors say they mutated a fish, and I'd love if you fetched one for my new lava-filled fish tank."; - catchLocation = "Caught in the Brimstone Crag."; - } - } + public override void AnglerQuestChat(ref string description, ref string catchLocation) + { + description = "When you defeated the ancient goddess, her children fell in the lava as a result of the aftermath. Rumors say they mutated a fish, and I'd love if you fetched one for my new lava-filled fish tank."; + catchLocation = "Caught in the Brimstone Crag."; + } + } } diff --git a/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs b/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs index a2cc321282..1d1e8f4f43 100644 --- a/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs +++ b/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs @@ -36,13 +36,13 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches public override void RightClick(Player player) { - //Vanilla materials - DropHelper.DropItem(player, ItemID.Obsidian, 2, 5); - DropHelper.DropItemChance(player, ItemID.Hellstone, 0.25f, 2, 5); - DropHelper.DropItemChance(player, ItemID.HellstoneBar, 0.1f, 1, 3); + //Vanilla materials + DropHelper.DropItem(player, ItemID.Obsidian, 2, 5); + DropHelper.DropItemChance(player, ItemID.Hellstone, 0.25f, 2, 5); + DropHelper.DropItemChance(player, ItemID.HellstoneBar, 0.1f, 1, 3); //Modded materials - DropHelper.DropItem(player, ModContent.ItemType(), 1, 4); + DropHelper.DropItem(player, ModContent.ItemType(), 1, 4); DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.hardMode, 0.2f, 2, 4); DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.hardMode, 0.15f, 2, 6); DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedBrimstoneElemental, 0.1f, 1, 3); @@ -65,29 +65,29 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches DropHelper.DropItemChance(player, ItemID.HeartreachPotion, 10, 1, 3); DropHelper.DropItemChance(player, ItemID.TrapsightPotion, 10, 1, 3); //Dangersense Potion DropHelper.DropItemChance(player, ItemID.InfernoPotion, 10, 1, 3); - int healingPotID = ItemID.LesserHealingPotion; - int manaPotID = ItemID.LesserManaPotion; - if (CalamityWorld.downedDoG) - { - healingPotID = ModContent.ItemType(); - manaPotID = ModContent.ItemType(); - } - else if (CalamityWorld.downedProvidence) - { - healingPotID = ItemID.SuperHealingPotion; - manaPotID = ItemID.SuperManaPotion; - } - else if (NPC.downedMechBossAny) - { - healingPotID = ItemID.GreaterHealingPotion; - manaPotID = ItemID.GreaterManaPotion; - } - else if (NPC.downedBoss3) - { - healingPotID = ItemID.HealingPotion; - manaPotID = ItemID.ManaPotion; - } - DropHelper.DropItemChance(player, Main.rand.NextBool(2) ? healingPotID : manaPotID, 0.25f, 2, 5); + int healingPotID = ItemID.LesserHealingPotion; + int manaPotID = ItemID.LesserManaPotion; + if (CalamityWorld.downedDoG) + { + healingPotID = ModContent.ItemType(); + manaPotID = ModContent.ItemType(); + } + else if (CalamityWorld.downedProvidence) + { + healingPotID = ItemID.SuperHealingPotion; + manaPotID = ItemID.SuperManaPotion; + } + else if (NPC.downedMechBossAny) + { + healingPotID = ItemID.GreaterHealingPotion; + manaPotID = ItemID.GreaterManaPotion; + } + else if (NPC.downedBoss3) + { + healingPotID = ItemID.HealingPotion; + manaPotID = ItemID.ManaPotion; + } + DropHelper.DropItemChance(player, Main.rand.NextBool(2) ? healingPotID : manaPotID, 0.25f, 2, 5); //Money DropHelper.DropItem(player, ItemID.SilverCoin, 10, 90); diff --git a/Items/Fishing/BrimstoneCragCatches/ChaoticFish.cs b/Items/Fishing/BrimstoneCragCatches/ChaoticFish.cs index d758811eb5..61b04dc2b4 100644 --- a/Items/Fishing/BrimstoneCragCatches/ChaoticFish.cs +++ b/Items/Fishing/BrimstoneCragCatches/ChaoticFish.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches { DisplayName.SetDefault("Chaotic Fish"); Tooltip.SetDefault("The horns lay a curse on those who touch it\n" + - "Right click to extract essence"); + "Right click to extract essence"); } public override void SetDefaults() diff --git a/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs b/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs index 55e015aece..25036bcd38 100644 --- a/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs +++ b/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.BrimstoneCragCatches { - public class DragoonDrizzlefish : ModItem + public class DragoonDrizzlefish : ModItem { public override void SetStaticDefaults() { @@ -43,19 +43,19 @@ Revenge is a dish best served flaming hot"); 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 rotated = new Vector2(speedX, speedY); - rotated = rotated.RotatedByRandom(MathHelper.ToRadians(10f)); - speedX = rotated.X; - speedY = rotated.Y; - int shotType = ModContent.ProjectileType(); - if (Main.rand.NextBool(2)) - { - shotType = ModContent.ProjectileType(); - } - else - { - shotType = ModContent.ProjectileType(); - } + Vector2 rotated = new Vector2(speedX, speedY); + rotated = rotated.RotatedByRandom(MathHelper.ToRadians(10f)); + speedX = rotated.X; + speedY = rotated.Y; + int shotType = ModContent.ProjectileType(); + if (Main.rand.NextBool(2)) + { + shotType = ModContent.ProjectileType(); + } + else + { + shotType = ModContent.ProjectileType(); + } Projectile.NewProjectile(position.X, position.Y, speedX, speedY, shotType, damage, knockBack, player.whoAmI, 0f, Main.rand.Next(2)); return false; } diff --git a/Items/Fishing/BrimstoneCragCatches/Slurpfish.cs b/Items/Fishing/BrimstoneCragCatches/Slurpfish.cs index a9ee414dbb..70a2b0e4e0 100644 --- a/Items/Fishing/BrimstoneCragCatches/Slurpfish.cs +++ b/Items/Fishing/BrimstoneCragCatches/Slurpfish.cs @@ -4,37 +4,37 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.BrimstoneCragCatches { - public class Slurpfish : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Slurpfish"); - } + public class Slurpfish : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Slurpfish"); + } - public override void SetDefaults() - { - item.questItem = true; - item.maxStack = 1; - item.width = 30; - item.height = 30; - item.uniqueStack = true; - item.rare = ItemRarityID.Quest; - } + public override void SetDefaults() + { + item.questItem = true; + item.maxStack = 1; + item.width = 30; + item.height = 30; + item.uniqueStack = true; + item.rare = ItemRarityID.Quest; + } - public override bool IsQuestFish() - { - return true; - } + public override bool IsQuestFish() + { + return true; + } - public override bool IsAnglerQuestAvailable() - { - return NPC.downedBoss3; - } + public override bool IsAnglerQuestAvailable() + { + return NPC.downedBoss3; + } - public override void AnglerQuestChat(ref string description, ref string catchLocation) - { - description = "Y'know, it'd be an absolute calamity if I sent you to the ancient ruins in the depths of hell to catch a fish. And I plan to do just that. Now scram! The fish isn't going to catch itself."; - catchLocation = "Caught in the Brimstone Crag."; - } - } + public override void AnglerQuestChat(ref string description, ref string catchLocation) + { + description = "Y'know, it'd be an absolute calamity if I sent you to the ancient ruins in the depths of hell to catch a fish. And I plan to do just that. Now scram! The fish isn't going to catch itself."; + catchLocation = "Caught in the Brimstone Crag."; + } + } } diff --git a/Items/Fishing/EnchantedStarfish.cs b/Items/Fishing/EnchantedStarfish.cs index e5ebe9223c..3b65be6909 100644 --- a/Items/Fishing/EnchantedStarfish.cs +++ b/Items/Fishing/EnchantedStarfish.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; using Terraria.GameContent.Achievements; namespace CalamityMod.Items.Fishing { - public class EnchantedStarfish : ModItem + public class EnchantedStarfish : ModItem { public override void SetStaticDefaults() { @@ -22,23 +22,23 @@ namespace CalamityMod.Items.Fishing item.useStyle = ItemUseStyleID.HoldingUp; item.UseSound = SoundID.Item29; item.consumable = true; - item.maxStack = 999; + item.maxStack = 999; item.value = Item.sellPrice(silver: 50); } public override bool UseItem(Player player) { - if (player.itemAnimation > 0 && (player.statManaMax < 200 && player.itemTime == 0)) - { - player.itemTime = item.useTime; - player.statManaMax = player.statManaMax + 20; - player.statManaMax2 = player.statManaMax2 + 20; - player.statMana = player.statMana + 20; - if (Main.myPlayer == player.whoAmI) - player.ManaEffect(20); - AchievementsHelper.HandleSpecialEvent(player, 1); - } - return false; + if (player.itemAnimation > 0 && (player.statManaMax < 200 && player.itemTime == 0)) + { + player.itemTime = item.useTime; + player.statManaMax = player.statManaMax + 20; + player.statManaMax2 = player.statManaMax2 + 20; + player.statMana = player.statMana + 20; + if (Main.myPlayer == player.whoAmI) + player.ManaEffect(20); + AchievementsHelper.HandleSpecialEvent(player, 1); + } + return false; } } } diff --git a/Items/Fishing/FishingRods/ChaoticSpreadRod.cs b/Items/Fishing/FishingRods/ChaoticSpreadRod.cs index 71222fa069..077b1acca2 100644 --- a/Items/Fishing/FishingRods/ChaoticSpreadRod.cs +++ b/Items/Fishing/FishingRods/ChaoticSpreadRod.cs @@ -6,27 +6,27 @@ using Terraria.ModLoader; using CalamityMod.Items.Materials; namespace CalamityMod.Items.Fishing.FishingRods { - public class ChaoticSpreadRod : ModItem + public class ChaoticSpreadRod : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Rift Reeler"); Tooltip.SetDefault("Fires three to five lines at once. Can fish in lava.\n" + - "The battlefield is a scene of constant chaos.\n" + //Napoleon Bonaparte quote reference - "The winner will be the one who controls that chaos, both the pole and the fish."); + "The battlefield is a scene of constant chaos.\n" + //Napoleon Bonaparte quote reference + "The winner will be the one who controls that chaos, both the pole and the fish."); } public override void SetDefaults() { - item.width = 24; - item.height = 28; - item.useAnimation = 8; - item.useTime = 8; - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.fishingPole = 45; - item.shootSpeed = 17f; - item.shoot = ModContent.ProjectileType(); + item.width = 24; + item.height = 28; + item.useAnimation = 8; + item.useTime = 8; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.fishingPole = 45; + item.shootSpeed = 17f; + item.shoot = ModContent.ProjectileType(); item.value = Item.buyPrice(0, 80, 0, 0); item.rare = ItemRarityID.Yellow; } diff --git a/Items/Fishing/FishingRods/EarlyBloomRod.cs b/Items/Fishing/FishingRods/EarlyBloomRod.cs index f608ff5fdc..af47b4661b 100644 --- a/Items/Fishing/FishingRods/EarlyBloomRod.cs +++ b/Items/Fishing/FishingRods/EarlyBloomRod.cs @@ -6,26 +6,26 @@ using Terraria.ModLoader; using CalamityMod.Items.Materials; namespace CalamityMod.Items.Fishing.FishingRods { - public class EarlyBloomRod : ModItem + public class EarlyBloomRod : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Early Bloom Rod"); Tooltip.SetDefault("Fires six lines at once. Line never snaps.\n" + - "The early bird catches the fish."); + "The early bird catches the fish."); } public override void SetDefaults() { - item.width = 24; - item.height = 28; - item.useAnimation = 8; - item.useTime = 8; - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.fishingPole = 60; - item.shootSpeed = 18f; - item.shoot = ModContent.ProjectileType(); + item.width = 24; + item.height = 28; + item.useAnimation = 8; + item.useTime = 8; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.fishingPole = 60; + item.shootSpeed = 18f; + item.shoot = ModContent.ProjectileType(); item.value = Item.buyPrice(1, 20, 0, 0); item.rare = ItemRarityID.Red; item.Calamity().customRarity = CalamityRarity.Turquoise; diff --git a/Items/Fishing/FishingRods/FeralDoubleRod.cs b/Items/Fishing/FishingRods/FeralDoubleRod.cs index 6bf4d37bc4..c67acdab73 100644 --- a/Items/Fishing/FishingRods/FeralDoubleRod.cs +++ b/Items/Fishing/FishingRods/FeralDoubleRod.cs @@ -6,26 +6,26 @@ using Terraria.ModLoader; using CalamityMod.Items.Materials; namespace CalamityMod.Items.Fishing.FishingRods { - public class FeralDoubleRod : ModItem + public class FeralDoubleRod : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Feral Double Rod"); Tooltip.SetDefault("Fires two lines at once.\n" + - "Just as you have tamed the jungle monster, you can now tame the fish in the sea."); + "Just as you have tamed the jungle monster, you can now tame the fish in the sea."); } public override void SetDefaults() { - item.width = 24; - item.height = 28; - item.useAnimation = 8; - item.useTime = 8; + item.width = 24; + item.height = 28; + item.useAnimation = 8; + item.useTime = 8; item.useStyle = ItemUseStyleID.SwingThrow; item.UseSound = SoundID.Item1; - item.fishingPole = 40; - item.shootSpeed = 16f; - item.shoot = ModContent.ProjectileType(); + item.fishingPole = 40; + item.shootSpeed = 16f; + item.shoot = ModContent.ProjectileType(); item.value = Item.buyPrice(0, 60, 0, 0); item.rare = ItemRarityID.Lime; } diff --git a/Items/Fishing/FishingRods/HeronRod.cs b/Items/Fishing/FishingRods/HeronRod.cs index d185626e8b..1f962b167a 100644 --- a/Items/Fishing/FishingRods/HeronRod.cs +++ b/Items/Fishing/FishingRods/HeronRod.cs @@ -5,27 +5,27 @@ using Terraria.ModLoader; using CalamityMod.Items.Materials; namespace CalamityMod.Items.Fishing.FishingRods { - public class HeronRod : ModItem + public class HeronRod : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Heron Rod"); Tooltip.SetDefault("Increased fishing power in space.\n" + //John Steinbeck quote but fish instead of snake - "A silent head and beak lanced down and plucked it out by the head,\n" + - "and the beak swallowed the little fish while its tail waved frantically."); + "A silent head and beak lanced down and plucked it out by the head,\n" + + "and the beak swallowed the little fish while its tail waved frantically."); } public override void SetDefaults() { - item.width = 24; - item.height = 28; - item.useAnimation = 8; - item.useTime = 8; - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.fishingPole = 25; - item.shootSpeed = 14.5f; - item.shoot = ModContent.ProjectileType(); + item.width = 24; + item.height = 28; + item.useAnimation = 8; + item.useTime = 8; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.fishingPole = 25; + item.shootSpeed = 14.5f; + item.shoot = ModContent.ProjectileType(); item.value = Item.buyPrice(0, 4, 0, 0); item.rare = ItemRarityID.Orange; } diff --git a/Items/Fishing/FishingRods/NavyFishingRod.cs b/Items/Fishing/FishingRods/NavyFishingRod.cs index 3c8e6c5962..95099505a2 100644 --- a/Items/Fishing/FishingRods/NavyFishingRod.cs +++ b/Items/Fishing/FishingRods/NavyFishingRod.cs @@ -11,21 +11,21 @@ namespace CalamityMod.Items.Fishing.FishingRods { DisplayName.SetDefault("Navy Fishing Rod"); Tooltip.SetDefault("While held, slowly electrifies nearby enemies.\n" + - "The sea is a city.\n" + //Life of Pi ref Ch.59 - "Just below are highways, boulevards, streets and roundabouts bustling with submarine traffic."); + "The sea is a city.\n" + //Life of Pi ref Ch.59 + "Just below are highways, boulevards, streets and roundabouts bustling with submarine traffic."); } public override void SetDefaults() { - item.width = 24; - item.height = 28; - item.useAnimation = 8; - item.useTime = 8; - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.fishingPole = 20; - item.shootSpeed = 13f; - item.shoot = ModContent.ProjectileType(); + item.width = 24; + item.height = 28; + item.useAnimation = 8; + item.useTime = 8; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.fishingPole = 20; + item.shootSpeed = 13f; + item.shoot = ModContent.ProjectileType(); item.value = Item.buyPrice(0, 2, 0, 0); item.rare = ItemRarityID.Green; } diff --git a/Items/Fishing/FishingRods/SlurperPole.cs b/Items/Fishing/FishingRods/SlurperPole.cs index 8bf2926cab..b22856012a 100644 --- a/Items/Fishing/FishingRods/SlurperPole.cs +++ b/Items/Fishing/FishingRods/SlurperPole.cs @@ -4,26 +4,26 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.FishingRods { - public class SlurperPole : ModItem + public class SlurperPole : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Slurper Pole"); Tooltip.SetDefault("Can fish in lava.\n" + //Charles Spurgeon quote - "It is the burning lava of the soul that has a furnace within--a very volcano of grief and sorrow."); + "It is the burning lava of the soul that has a furnace within--a very volcano of grief and sorrow."); } public override void SetDefaults() { - item.width = 24; - item.height = 28; - item.useAnimation = 8; - item.useTime = 8; - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.fishingPole = 25; - item.shootSpeed = 14f; - item.shoot = ModContent.ProjectileType(); + item.width = 24; + item.height = 28; + item.useAnimation = 8; + item.useTime = 8; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.fishingPole = 25; + item.shootSpeed = 14f; + item.shoot = ModContent.ProjectileType(); item.value = Item.buyPrice(0, 4, 0, 0); item.rare = ItemRarityID.Orange; } diff --git a/Items/Fishing/FishingRods/VerstaltiteFishingRod.cs b/Items/Fishing/FishingRods/VerstaltiteFishingRod.cs index b89e13ab6f..533c466513 100644 --- a/Items/Fishing/FishingRods/VerstaltiteFishingRod.cs +++ b/Items/Fishing/FishingRods/VerstaltiteFishingRod.cs @@ -5,26 +5,26 @@ using Terraria.ModLoader; using CalamityMod.Items.Materials; namespace CalamityMod.Items.Fishing.FishingRods { - public class VerstaltiteFishingRod : ModItem + public class VerstaltiteFishingRod : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Verstaltite Fishing Rod"); Tooltip.SetDefault("Increased fishing power when in the tundra\n" + - "The ancient alloy's prismatic qualities are perfect for attracting fish"); + "The ancient alloy's prismatic qualities are perfect for attracting fish"); } public override void SetDefaults() { - item.width = 24; - item.height = 28; - item.useAnimation = 8; - item.useTime = 8; - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.fishingPole = 35; - item.shootSpeed = 15f; - item.shoot = ModContent.ProjectileType(); + item.width = 24; + item.height = 28; + item.useAnimation = 8; + item.useTime = 8; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.fishingPole = 35; + item.shootSpeed = 15f; + item.shoot = ModContent.ProjectileType(); item.value = Item.buyPrice(0, 36, 0, 0); item.rare = ItemRarityID.Pink; } diff --git a/Items/Fishing/FishingRods/WulfrumRod.cs b/Items/Fishing/FishingRods/WulfrumRod.cs index b8feceae21..9a6b380aa1 100644 --- a/Items/Fishing/FishingRods/WulfrumRod.cs +++ b/Items/Fishing/FishingRods/WulfrumRod.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; using CalamityMod.Items.Materials; namespace CalamityMod.Items.Fishing.FishingRods { - public class WulfrumRod : ModItem + public class WulfrumRod : ModItem { public override void SetStaticDefaults() { @@ -15,17 +15,17 @@ namespace CalamityMod.Items.Fishing.FishingRods public override void SetDefaults() { - item.width = 24; - item.height = 28; - item.useAnimation = 8; - item.useTime = 8; - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.rare = ItemRarityID.Blue; - item.fishingPole = 10; - item.shootSpeed = 10f; - item.shoot = ModContent.ProjectileType(); - item.value = Item.buyPrice(0, 1, 0, 0); + item.width = 24; + item.height = 28; + item.useAnimation = 8; + item.useTime = 8; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.rare = ItemRarityID.Blue; + item.fishingPole = 10; + item.shootSpeed = 10f; + item.shoot = ModContent.ProjectileType(); + item.value = Item.buyPrice(0, 1, 0, 0); } public override void AddRecipes() diff --git a/Items/Fishing/GlimmeringGemfish.cs b/Items/Fishing/GlimmeringGemfish.cs index bc5867add3..dc6f6d79c9 100644 --- a/Items/Fishing/GlimmeringGemfish.cs +++ b/Items/Fishing/GlimmeringGemfish.cs @@ -40,11 +40,11 @@ namespace CalamityMod.Items.Fishing DropHelper.DropItemChance(player, ItemID.Amber, 0.25f, gemMin, gemMax); Mod thorium = CalamityMod.Instance.thorium; if (thorium != null) - { - DropHelper.DropItemChance(player, thorium.ItemType("Pearl"), 0.25f, gemMin, gemMax); - DropHelper.DropItemChance(player, thorium.ItemType("Opal"), 0.25f, gemMin, gemMax); - DropHelper.DropItemChance(player, thorium.ItemType("Onyx"), 0.25f, gemMin, gemMax); - } + { + DropHelper.DropItemChance(player, thorium.ItemType("Pearl"), 0.25f, gemMin, gemMax); + DropHelper.DropItemChance(player, thorium.ItemType("Opal"), 0.25f, gemMin, gemMax); + DropHelper.DropItemChance(player, thorium.ItemType("Onyx"), 0.25f, gemMin, gemMax); + } } } } diff --git a/Items/Fishing/StuffedFish.cs b/Items/Fishing/StuffedFish.cs index 503018b1ac..31ddac5f23 100644 --- a/Items/Fishing/StuffedFish.cs +++ b/Items/Fishing/StuffedFish.cs @@ -56,23 +56,23 @@ namespace CalamityMod.Items.Fishing DropHelper.DropItemCondition(player, ItemID.HallowedSeeds, Main.hardMode, 0.05f, seedMin, seedMax); Mod thorium = CalamityMod.Instance.thorium; if (thorium != null) - { - DropHelper.DropItemChance(player, thorium.ItemType("MarineKelp"), 0.25f, herbMin, herbMax); - DropHelper.DropItemChance(player, thorium.ItemType("MarineKelpSeeds"), 0.1f, seedMin, seedMax); - } + { + DropHelper.DropItemChance(player, thorium.ItemType("MarineKelp"), 0.25f, herbMin, herbMax); + DropHelper.DropItemChance(player, thorium.ItemType("MarineKelpSeeds"), 0.1f, seedMin, seedMax); + } Mod soa = CalamityMod.Instance.soa; if (soa != null) - { - DropHelper.DropItemChance(player, soa.ItemType("Welkinbell"), 0.25f, herbMin, herbMax); - DropHelper.DropItemChance(player, soa.ItemType("WelkinbellSeeds"), 0.1f, seedMin, seedMax); - DropHelper.DropItemCondition(player, soa.ItemType("Illumifern"), Main.hardMode, 0.25f, herbMin, herbMax); - DropHelper.DropItemCondition(player, soa.ItemType("IllumifernSeeds"), Main.hardMode, 0.1f, seedMin, seedMax); + { + DropHelper.DropItemChance(player, soa.ItemType("Welkinbell"), 0.25f, herbMin, herbMax); + DropHelper.DropItemChance(player, soa.ItemType("WelkinbellSeeds"), 0.1f, seedMin, seedMax); + DropHelper.DropItemCondition(player, soa.ItemType("Illumifern"), Main.hardMode, 0.25f, herbMin, herbMax); + DropHelper.DropItemCondition(player, soa.ItemType("IllumifernSeeds"), Main.hardMode, 0.1f, seedMin, seedMax); - // TODO -- There is no way to determine if SoA's Abaddon is dead without reflection. + // TODO -- There is no way to determine if SoA's Abaddon is dead without reflection. // Dan Yami has confirmed that downed calls will be added to SoA eventually. - //DropHelper.DropItemCondition(player, shadowsOfAbaddon.ItemType("Enduflora"), SacredTools.ModdedWorld.downedAbaddon, 0.25f, herbMin, herbMax); - //DropHelper.DropItemCondition(player, shadowsOfAbaddon.ItemType("EndufloraSeeds"), SacredTools.ModdedWorld.downedAbaddon, 0.1f, seedMin, seedMax); - } + //DropHelper.DropItemCondition(player, shadowsOfAbaddon.ItemType("Enduflora"), SacredTools.ModdedWorld.downedAbaddon, 0.25f, herbMin, herbMax); + //DropHelper.DropItemCondition(player, shadowsOfAbaddon.ItemType("EndufloraSeeds"), SacredTools.ModdedWorld.downedAbaddon, 0.1f, seedMin, seedMax); + } } } } diff --git a/Items/Fishing/SulphurCatches/AbyssalCrate.cs b/Items/Fishing/SulphurCatches/AbyssalCrate.cs index d0f3985d50..705e8d149e 100644 --- a/Items/Fishing/SulphurCatches/AbyssalCrate.cs +++ b/Items/Fishing/SulphurCatches/AbyssalCrate.cs @@ -18,7 +18,7 @@ using CrateTile = CalamityMod.Tiles.Abyss.AbyssalCrateTile; namespace CalamityMod.Items.Fishing.SulphurCatches { - public class AbyssalCrate : ModItem + public class AbyssalCrate : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Fishing/SunkenSeaCatches/EutrophicSandfish.cs b/Items/Fishing/SunkenSeaCatches/EutrophicSandfish.cs index b81ec1af9e..38c2df697d 100644 --- a/Items/Fishing/SunkenSeaCatches/EutrophicSandfish.cs +++ b/Items/Fishing/SunkenSeaCatches/EutrophicSandfish.cs @@ -4,37 +4,37 @@ using CalamityMod.World; namespace CalamityMod.Items.Fishing.SunkenSeaCatches { - public class EutrophicSandfish : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Eutrophic Sandfish"); - } + public class EutrophicSandfish : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eutrophic Sandfish"); + } - public override void SetDefaults() - { - item.questItem = true; - item.maxStack = 1; - item.width = 40; - item.height = 28; - item.uniqueStack = true; - item.rare = ItemRarityID.Quest; - } + public override void SetDefaults() + { + item.questItem = true; + item.maxStack = 1; + item.width = 40; + item.height = 28; + item.uniqueStack = true; + item.rare = ItemRarityID.Quest; + } - public override bool IsQuestFish() - { - return true; - } + public override bool IsQuestFish() + { + return true; + } - public override bool IsAnglerQuestAvailable() - { - return CalamityWorld.downedDesertScourge; - } + public override bool IsAnglerQuestAvailable() + { + return CalamityWorld.downedDesertScourge; + } - public override void AnglerQuestChat(ref string description, ref string catchLocation) - { - description = "You ever get to see what would happen if a lizard that lived in the desert scurried too deep underground? I did, and they sure are cool! But it’s way too slippery for me to get my hands on it now. You go and get it so I can keep it as a pet!"; - catchLocation = "Caught in the Sunken Sea."; - } - } + public override void AnglerQuestChat(ref string description, ref string catchLocation) + { + description = "You ever get to see what would happen if a lizard that lived in the desert scurried too deep underground? I did, and they sure are cool! But it’s way too slippery for me to get my hands on it now. You go and get it so I can keep it as a pet!"; + catchLocation = "Caught in the Sunken Sea."; + } + } } diff --git a/Items/Fishing/SunkenSeaCatches/SerpentsBite.cs b/Items/Fishing/SunkenSeaCatches/SerpentsBite.cs index 7a0c14880e..c9c90a612c 100644 --- a/Items/Fishing/SunkenSeaCatches/SerpentsBite.cs +++ b/Items/Fishing/SunkenSeaCatches/SerpentsBite.cs @@ -5,27 +5,27 @@ using CalamityMod.Projectiles.Typeless; namespace CalamityMod.Items.Fishing.SunkenSeaCatches { - public class SerpentsBite : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Serpent's Bite"); + public class SerpentsBite : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Serpent's Bite"); Tooltip.SetDefault($@"Reach: {SerpentsBiteHook.GrappleRangInTiles} Launch Velocity: {SerpentsBiteHook.LaunchSpeed} Reelback Velocity: {SerpentsBiteHook.ReelbackSpeed} Pull Velocity: {SerpentsBiteHook.PullSpeed}"); - } + } - public override void SetDefaults() - { - // Instead of copying these values, we can clone and modify the ones we want to copy - item.CloneDefaults(ItemID.AmethystHook); - item.shootSpeed = SerpentsBiteHook.LaunchSpeed; // how quickly the hook is shot. - item.shoot = ProjectileType(); - item.value = CalamityGlobalItem.Rarity4BuyPrice; - item.rare = ItemRarityID.LightRed; - item.width = 30; - item.height = 32; - } - } + public override void SetDefaults() + { + // Instead of copying these values, we can clone and modify the ones we want to copy + item.CloneDefaults(ItemID.AmethystHook); + item.shootSpeed = SerpentsBiteHook.LaunchSpeed; // how quickly the hook is shot. + item.shoot = ProjectileType(); + item.value = CalamityGlobalItem.Rarity4BuyPrice; + item.rare = ItemRarityID.LightRed; + item.width = 30; + item.height = 32; + } + } } diff --git a/Items/Fishing/SunkenSeaCatches/Serpentuna.cs b/Items/Fishing/SunkenSeaCatches/Serpentuna.cs index 6b744e446e..e4382d700e 100644 --- a/Items/Fishing/SunkenSeaCatches/Serpentuna.cs +++ b/Items/Fishing/SunkenSeaCatches/Serpentuna.cs @@ -4,37 +4,37 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.SunkenSeaCatches { - public class Serpentuna : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Serpentuna"); - } + public class Serpentuna : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Serpentuna"); + } - public override void SetDefaults() - { - item.questItem = true; - item.maxStack = 1; - item.width = 36; - item.height = 40; - item.uniqueStack = true; - item.rare = ItemRarityID.Quest; - } + public override void SetDefaults() + { + item.questItem = true; + item.maxStack = 1; + item.width = 36; + item.height = 40; + item.uniqueStack = true; + item.rare = ItemRarityID.Quest; + } - public override bool IsQuestFish() - { - return true; - } + public override bool IsQuestFish() + { + return true; + } - public override bool IsAnglerQuestAvailable() - { - return Main.hardMode; - } + public override bool IsAnglerQuestAvailable() + { + return Main.hardMode; + } - public override void AnglerQuestChat(ref string description, ref string catchLocation) - { - description = "Sea serpents are pretty but not as pretty as the look on someone's face when they find one in their chair. I need you to fetch me the props for my next big scare, and the deadline is tomorrow."; - catchLocation = "Caught in the Sunken Sea."; - } - } + public override void AnglerQuestChat(ref string description, ref string catchLocation) + { + description = "Sea serpents are pretty but not as pretty as the look on someone's face when they find one in their chair. I need you to fetch me the props for my next big scare, and the deadline is tomorrow."; + catchLocation = "Caught in the Sunken Sea."; + } + } } diff --git a/Items/Fishing/SunkenSeaCatches/SparklingEmpress.cs b/Items/Fishing/SunkenSeaCatches/SparklingEmpress.cs index 4e4c1c1e5a..9ed3d1cc76 100644 --- a/Items/Fishing/SunkenSeaCatches/SparklingEmpress.cs +++ b/Items/Fishing/SunkenSeaCatches/SparklingEmpress.cs @@ -6,40 +6,40 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Items.Fishing.SunkenSeaCatches { - public class SparklingEmpress : ModItem - { + public class SparklingEmpress : ModItem + { public static int BaseDamage = 10; - public override void SetStaticDefaults() - { + public override void SetStaticDefaults() + { DisplayName.SetDefault("Sparkling Empress"); Tooltip.SetDefault("Fires a concentrated laser to annihilate your foes\n" + "Defeated enemies explode into prism shards"); Item.staff[item.type] = true; //so it doesn't look weird af when holding it - } + } - public override void SetDefaults() - { - item.damage = BaseDamage; - item.noMelee = true; - item.magic = true; - item.channel = true; //Channel so that you can hold the weapon [Important] - item.rare = ItemRarityID.Green; - item.mana = 5; - item.width = 42; - item.height = 34; - item.useTime = 20; - item.useAnimation = 20; - item.UseSound = SoundID.Item13; - item.useStyle = ItemUseStyleID.HoldingOut; - item.shootSpeed = 14f; - item.shoot = ModContent.ProjectileType(); - item.value = Item.sellPrice(silver: 40); - } + public override void SetDefaults() + { + item.damage = BaseDamage; + item.noMelee = true; + item.magic = true; + item.channel = true; //Channel so that you can hold the weapon [Important] + item.rare = ItemRarityID.Green; + item.mana = 5; + item.width = 42; + item.height = 34; + item.useTime = 20; + item.useAnimation = 20; + item.UseSound = SoundID.Item13; + item.useStyle = ItemUseStyleID.HoldingOut; + item.shootSpeed = 14f; + item.shoot = ModContent.ProjectileType(); + item.value = Item.sellPrice(silver: 40); + } public override Vector2? HoldoutOrigin() //so it looks normal when holding { return new Vector2(10, 10); } - } + } } diff --git a/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs b/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs index 2f7f2b0008..5582be1bd0 100644 --- a/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs +++ b/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs @@ -14,7 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.SunkenSeaCatches { - public class SunkenCrate : ModItem + public class SunkenCrate : ModItem { public override void SetStaticDefaults() { @@ -43,11 +43,11 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches public override void RightClick(Player player) { //Modded materials - DropHelper.DropItem(player, ModContent.ItemType(), 10, 30); - DropHelper.DropItem(player, ModContent.ItemType(), 10, 30); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedDesertScourge, 5, 10); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedDesertScourge, 0.2f, 2, 5); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedCLAMHardMode, 0.12f, 2, 5); + DropHelper.DropItem(player, ModContent.ItemType(), 10, 30); + DropHelper.DropItem(player, ModContent.ItemType(), 10, 30); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedDesertScourge, 5, 10); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedDesertScourge, 0.2f, 2, 5); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedCLAMHardMode, 0.12f, 2, 5); // Weapons DropHelper.DropItemFromSetCondition(player, CalamityWorld.downedCLAMHardMode, 0.07f, @@ -71,29 +71,29 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches DropHelper.DropItemChance(player, ItemID.MiningPotion, 10, 1, 3); DropHelper.DropItemChance(player, ItemID.HeartreachPotion, 10, 1, 3); DropHelper.DropItemChance(player, ItemID.TrapsightPotion, 10, 1, 3); //Dangersense Potion - int healingPotID = ItemID.LesserHealingPotion; - int manaPotID = ItemID.LesserManaPotion; - if (CalamityWorld.downedDoG) - { - healingPotID = ModContent.ItemType(); - manaPotID = ModContent.ItemType(); - } - else if (CalamityWorld.downedProvidence) - { - healingPotID = ItemID.SuperHealingPotion; - manaPotID = ItemID.SuperManaPotion; - } - else if (NPC.downedMechBossAny) - { - healingPotID = ItemID.GreaterHealingPotion; - manaPotID = ItemID.GreaterManaPotion; - } - else if (NPC.downedBoss3) - { - healingPotID = ItemID.HealingPotion; - manaPotID = ItemID.ManaPotion; - } - DropHelper.DropItemChance(player, Main.rand.NextBool(2) ? healingPotID : manaPotID, 0.25f, 2, 5); + int healingPotID = ItemID.LesserHealingPotion; + int manaPotID = ItemID.LesserManaPotion; + if (CalamityWorld.downedDoG) + { + healingPotID = ModContent.ItemType(); + manaPotID = ModContent.ItemType(); + } + else if (CalamityWorld.downedProvidence) + { + healingPotID = ItemID.SuperHealingPotion; + manaPotID = ItemID.SuperManaPotion; + } + else if (NPC.downedMechBossAny) + { + healingPotID = ItemID.GreaterHealingPotion; + manaPotID = ItemID.GreaterManaPotion; + } + else if (NPC.downedBoss3) + { + healingPotID = ItemID.HealingPotion; + manaPotID = ItemID.ManaPotion; + } + DropHelper.DropItemChance(player, Main.rand.NextBool(2) ? healingPotID : manaPotID, 0.25f, 2, 5); //Money DropHelper.DropItem(player, ItemID.SilverCoin, 10, 90); diff --git a/Items/Fishing/SunkenSeaCatches/SurfClam.cs b/Items/Fishing/SunkenSeaCatches/SurfClam.cs index 79010ed121..346f6833b6 100644 --- a/Items/Fishing/SunkenSeaCatches/SurfClam.cs +++ b/Items/Fishing/SunkenSeaCatches/SurfClam.cs @@ -4,37 +4,37 @@ using CalamityMod.World; namespace CalamityMod.Items.Fishing.SunkenSeaCatches { - public class SurfClam : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Surf Clam"); - } + public class SurfClam : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Surf Clam"); + } - public override void SetDefaults() - { - item.questItem = true; - item.maxStack = 1; - item.width = 20; - item.height = 20; - item.uniqueStack = true; - item.rare = ItemRarityID.Quest; - } + public override void SetDefaults() + { + item.questItem = true; + item.maxStack = 1; + item.width = 20; + item.height = 20; + item.uniqueStack = true; + item.rare = ItemRarityID.Quest; + } - public override bool IsQuestFish() - { - return true; - } + public override bool IsQuestFish() + { + return true; + } - public override bool IsAnglerQuestAvailable() - { - return CalamityWorld.downedDesertScourge; - } + public override bool IsAnglerQuestAvailable() + { + return CalamityWorld.downedDesertScourge; + } - public override void AnglerQuestChat(ref string description, ref string catchLocation) - { - description = "Did you know that clams are a delicacy? Rumor has it that a big colony lives beneath the Desert. Just talking about them makes me hungry. I need you to fetch one for me, so I can practice my culinary skills and curb my hunger."; - catchLocation = "Caught in the Sunken Sea."; - } - } + public override void AnglerQuestChat(ref string description, ref string catchLocation) + { + description = "Did you know that clams are a delicacy? Rumor has it that a big colony lives beneath the Desert. Just talking about them makes me hungry. I need you to fetch one for me, so I can practice my culinary skills and curb my hunger."; + catchLocation = "Caught in the Sunken Sea."; + } + } } diff --git a/Items/Fishing/Xerocodile.cs b/Items/Fishing/Xerocodile.cs index e010266ee3..b51b72304d 100644 --- a/Items/Fishing/Xerocodile.cs +++ b/Items/Fishing/Xerocodile.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Items.Fishing { - public class Xerocodile : ModItem + public class Xerocodile : ModItem { public override void SetStaticDefaults() { @@ -34,15 +34,15 @@ namespace CalamityMod.Items.Fishing /*public override void RightClick(Player player) { - if (Main.rand.NextBool(3)) - DropHelper.DropItem(player, ModContent.ItemType(), 1, 1); - else if (Main.rand.NextBool(2)) - DropHelper.DropItem(player, ModContent.ItemType(), 1, 1); - else - { - DropHelper.DropItem(player, ModContent.ItemType(), 1, 1); - DropHelper.DropItem(player, ModContent.ItemType(), 1, 1); - } + if (Main.rand.NextBool(3)) + DropHelper.DropItem(player, ModContent.ItemType(), 1, 1); + else if (Main.rand.NextBool(2)) + DropHelper.DropItem(player, ModContent.ItemType(), 1, 1); + else + { + DropHelper.DropItem(player, ModContent.ItemType(), 1, 1); + DropHelper.DropItem(player, ModContent.ItemType(), 1, 1); + } }*/ } } diff --git a/Items/LabFinders/CyanSeekingMechanism.cs b/Items/LabFinders/CyanSeekingMechanism.cs index 76ac4b77c6..268e979faf 100644 --- a/Items/LabFinders/CyanSeekingMechanism.cs +++ b/Items/LabFinders/CyanSeekingMechanism.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.LabFinders item.Calamity().MaxCharge = 100; item.Calamity().ChargePerUse = 15; item.Calamity().UsesCharge = true; - item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.Calamity().customRarity = CalamityRarity.DraedonRust; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && CalamityWorld.SunkenSeaLabCenter != Vector2.Zero; diff --git a/Items/LabFinders/GreenSeekingMechanism.cs b/Items/LabFinders/GreenSeekingMechanism.cs index da3188e614..b1ce55d990 100644 --- a/Items/LabFinders/GreenSeekingMechanism.cs +++ b/Items/LabFinders/GreenSeekingMechanism.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.LabFinders item.Calamity().MaxCharge = 100; item.Calamity().ChargePerUse = 15; item.Calamity().UsesCharge = true; - item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.Calamity().customRarity = CalamityRarity.DraedonRust; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && CalamityWorld.JungleLabCenter != Vector2.Zero; diff --git a/Items/LabFinders/MysteriousMechanism.cs b/Items/LabFinders/MysteriousMechanism.cs index b714b302eb..73c75a3dba 100644 --- a/Items/LabFinders/MysteriousMechanism.cs +++ b/Items/LabFinders/MysteriousMechanism.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LabFinders { - public class MysteriousMechanism : ModItem + public class MysteriousMechanism : ModItem { public override void SetStaticDefaults() { @@ -16,7 +16,7 @@ namespace CalamityMod.Items.LabFinders { item.width = 24; item.height = 26; - item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.Calamity().customRarity = CalamityRarity.DraedonRust; } public override void AddRecipes() diff --git a/Items/LabFinders/PurpleSeekingMechanism.cs b/Items/LabFinders/PurpleSeekingMechanism.cs index 28e08b4a5b..f09ebbb682 100644 --- a/Items/LabFinders/PurpleSeekingMechanism.cs +++ b/Items/LabFinders/PurpleSeekingMechanism.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.LabFinders item.Calamity().MaxCharge = 100; item.Calamity().ChargePerUse = 15; item.Calamity().UsesCharge = true; - item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.Calamity().customRarity = CalamityRarity.DraedonRust; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && CalamityWorld.PlanetoidLabCenter != Vector2.Zero; diff --git a/Items/LabFinders/RedSeekingMechanism.cs b/Items/LabFinders/RedSeekingMechanism.cs index ffd99cb84d..6294e83d20 100644 --- a/Items/LabFinders/RedSeekingMechanism.cs +++ b/Items/LabFinders/RedSeekingMechanism.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.LabFinders item.Calamity().MaxCharge = 100; item.Calamity().ChargePerUse = 15; item.Calamity().UsesCharge = true; - item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.Calamity().customRarity = CalamityRarity.DraedonRust; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && CalamityWorld.HellLabCenter != Vector2.Zero; diff --git a/Items/LabFinders/YellowSeekingMechanism.cs b/Items/LabFinders/YellowSeekingMechanism.cs index a54448c777..245eed0f52 100644 --- a/Items/LabFinders/YellowSeekingMechanism.cs +++ b/Items/LabFinders/YellowSeekingMechanism.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.LabFinders item.Calamity().MaxCharge = 100; item.Calamity().ChargePerUse = 15; item.Calamity().UsesCharge = true; - item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.Calamity().customRarity = CalamityRarity.DraedonRust; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && CalamityWorld.IceLabCenter != Vector2.Zero; diff --git a/Items/LoreItems/KnowledgeAquaticScourge.cs b/Items/LoreItems/KnowledgeAquaticScourge.cs index 1a24637fa2..fecd7d84a5 100644 --- a/Items/LoreItems/KnowledgeAquaticScourge.cs +++ b/Items/LoreItems/KnowledgeAquaticScourge.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeAquaticScourge : LoreItem + public class KnowledgeAquaticScourge : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeAstrumAureus.cs b/Items/LoreItems/KnowledgeAstrumAureus.cs index d25b618608..0d51d1f8d5 100644 --- a/Items/LoreItems/KnowledgeAstrumAureus.cs +++ b/Items/LoreItems/KnowledgeAstrumAureus.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeAstrumAureus : LoreItem + public class KnowledgeAstrumAureus : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeAstrumDeus.cs b/Items/LoreItems/KnowledgeAstrumDeus.cs index 90ae20cb78..e83f641dcb 100644 --- a/Items/LoreItems/KnowledgeAstrumDeus.cs +++ b/Items/LoreItems/KnowledgeAstrumDeus.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeAstrumDeus : LoreItem + public class KnowledgeAstrumDeus : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeBrainofCthulhu.cs b/Items/LoreItems/KnowledgeBrainofCthulhu.cs index ff19164db4..24a90fa7ee 100644 --- a/Items/LoreItems/KnowledgeBrainofCthulhu.cs +++ b/Items/LoreItems/KnowledgeBrainofCthulhu.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeBrainofCthulhu : LoreItem + public class KnowledgeBrainofCthulhu : LoreItem { public override void SetStaticDefaults() { @@ -27,12 +27,12 @@ namespace CalamityMod.Items.LoreItems item.consumable = false; } - public override bool CanUseItem(Player player) - { - return false; - } + public override bool CanUseItem(Player player) + { + return false; + } - public override void AddRecipes() + public override void AddRecipes() { ModRecipe r = new ModRecipe(mod); r.SetResult(this); diff --git a/Items/LoreItems/KnowledgeBrimstoneElemental.cs b/Items/LoreItems/KnowledgeBrimstoneElemental.cs index 05990d441d..394839c54e 100644 --- a/Items/LoreItems/KnowledgeBrimstoneElemental.cs +++ b/Items/LoreItems/KnowledgeBrimstoneElemental.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeBrimstoneElemental : LoreItem + public class KnowledgeBrimstoneElemental : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeCalamitas.cs b/Items/LoreItems/KnowledgeCalamitas.cs index f0d30ea340..0f0c673392 100644 --- a/Items/LoreItems/KnowledgeCalamitas.cs +++ b/Items/LoreItems/KnowledgeCalamitas.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeCalamitas : LoreItem + public class KnowledgeCalamitas : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeCalamitasClone.cs b/Items/LoreItems/KnowledgeCalamitasClone.cs index 7dd0a08d1c..bcac5714fa 100644 --- a/Items/LoreItems/KnowledgeCalamitasClone.cs +++ b/Items/LoreItems/KnowledgeCalamitasClone.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeCalamitasClone : LoreItem + public class KnowledgeCalamitasClone : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeCorruption.cs b/Items/LoreItems/KnowledgeCorruption.cs index 96a98c5ce6..3ae1371ac0 100644 --- a/Items/LoreItems/KnowledgeCorruption.cs +++ b/Items/LoreItems/KnowledgeCorruption.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeCorruption : LoreItem + public class KnowledgeCorruption : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeCrabulon.cs b/Items/LoreItems/KnowledgeCrabulon.cs index db28419cf7..eeb512a32f 100644 --- a/Items/LoreItems/KnowledgeCrabulon.cs +++ b/Items/LoreItems/KnowledgeCrabulon.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeCrabulon : LoreItem + public class KnowledgeCrabulon : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeCrimson.cs b/Items/LoreItems/KnowledgeCrimson.cs index 57734af451..e72e23e9de 100644 --- a/Items/LoreItems/KnowledgeCrimson.cs +++ b/Items/LoreItems/KnowledgeCrimson.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeCrimson : LoreItem + public class KnowledgeCrimson : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeCryogen.cs b/Items/LoreItems/KnowledgeCryogen.cs index bf395436c8..b7fcd15af6 100644 --- a/Items/LoreItems/KnowledgeCryogen.cs +++ b/Items/LoreItems/KnowledgeCryogen.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeCryogen : LoreItem + public class KnowledgeCryogen : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeDestroyer.cs b/Items/LoreItems/KnowledgeDestroyer.cs index 1cbdc66450..f09fa48043 100644 --- a/Items/LoreItems/KnowledgeDestroyer.cs +++ b/Items/LoreItems/KnowledgeDestroyer.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeDestroyer : LoreItem + public class KnowledgeDestroyer : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeDevourerofGods.cs b/Items/LoreItems/KnowledgeDevourerofGods.cs index 1df33476c0..c90ba6935d 100644 --- a/Items/LoreItems/KnowledgeDevourerofGods.cs +++ b/Items/LoreItems/KnowledgeDevourerofGods.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeDevourerofGods : LoreItem + public class KnowledgeDevourerofGods : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeDukeFishron.cs b/Items/LoreItems/KnowledgeDukeFishron.cs index fd730e32ae..a49154256d 100644 --- a/Items/LoreItems/KnowledgeDukeFishron.cs +++ b/Items/LoreItems/KnowledgeDukeFishron.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeDukeFishron : LoreItem + public class KnowledgeDukeFishron : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeEaterofWorlds.cs b/Items/LoreItems/KnowledgeEaterofWorlds.cs index db0ca12f8f..7bab4cf417 100644 --- a/Items/LoreItems/KnowledgeEaterofWorlds.cs +++ b/Items/LoreItems/KnowledgeEaterofWorlds.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeEaterofWorlds : LoreItem + public class KnowledgeEaterofWorlds : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeGolem.cs b/Items/LoreItems/KnowledgeGolem.cs index e96ce291b8..294b10353f 100644 --- a/Items/LoreItems/KnowledgeGolem.cs +++ b/Items/LoreItems/KnowledgeGolem.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeGolem : LoreItem + public class KnowledgeGolem : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeHiveMind.cs b/Items/LoreItems/KnowledgeHiveMind.cs index 9c7e76ec69..6d02f0417a 100644 --- a/Items/LoreItems/KnowledgeHiveMind.cs +++ b/Items/LoreItems/KnowledgeHiveMind.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeHiveMind : LoreItem + public class KnowledgeHiveMind : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeKingSlime.cs b/Items/LoreItems/KnowledgeKingSlime.cs index 6287981aac..a3abde01f7 100644 --- a/Items/LoreItems/KnowledgeKingSlime.cs +++ b/Items/LoreItems/KnowledgeKingSlime.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeKingSlime : LoreItem + public class KnowledgeKingSlime : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeLeviathanandSiren.cs b/Items/LoreItems/KnowledgeLeviathanandSiren.cs index 8ad524aab7..9475c6584d 100644 --- a/Items/LoreItems/KnowledgeLeviathanandSiren.cs +++ b/Items/LoreItems/KnowledgeLeviathanandSiren.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeLeviathanandSiren : LoreItem + public class KnowledgeLeviathanandSiren : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeLunaticCultist.cs b/Items/LoreItems/KnowledgeLunaticCultist.cs index 38458dcd4b..ecb940d5f7 100644 --- a/Items/LoreItems/KnowledgeLunaticCultist.cs +++ b/Items/LoreItems/KnowledgeLunaticCultist.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeLunaticCultist : LoreItem + public class KnowledgeLunaticCultist : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeMoonLord.cs b/Items/LoreItems/KnowledgeMoonLord.cs index 37e738668f..cfa258c212 100644 --- a/Items/LoreItems/KnowledgeMoonLord.cs +++ b/Items/LoreItems/KnowledgeMoonLord.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeMoonLord : LoreItem + public class KnowledgeMoonLord : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeOcean.cs b/Items/LoreItems/KnowledgeOcean.cs index f04d5c85e4..1f4d9f5695 100644 --- a/Items/LoreItems/KnowledgeOcean.cs +++ b/Items/LoreItems/KnowledgeOcean.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeOcean : LoreItem + public class KnowledgeOcean : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeOldDuke.cs b/Items/LoreItems/KnowledgeOldDuke.cs index 31548e7913..31f4ada2f9 100644 --- a/Items/LoreItems/KnowledgeOldDuke.cs +++ b/Items/LoreItems/KnowledgeOldDuke.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeOldDuke : LoreItem + public class KnowledgeOldDuke : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgePerforators.cs b/Items/LoreItems/KnowledgePerforators.cs index df55d1d45f..a975dcd4ba 100644 --- a/Items/LoreItems/KnowledgePerforators.cs +++ b/Items/LoreItems/KnowledgePerforators.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgePerforators : LoreItem + public class KnowledgePerforators : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgePlaguebringerGoliath.cs b/Items/LoreItems/KnowledgePlaguebringerGoliath.cs index 6ce4335811..5ed6663fa7 100644 --- a/Items/LoreItems/KnowledgePlaguebringerGoliath.cs +++ b/Items/LoreItems/KnowledgePlaguebringerGoliath.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgePlaguebringerGoliath : LoreItem + public class KnowledgePlaguebringerGoliath : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgePlantera.cs b/Items/LoreItems/KnowledgePlantera.cs index d872694eb9..20914afe80 100644 --- a/Items/LoreItems/KnowledgePlantera.cs +++ b/Items/LoreItems/KnowledgePlantera.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgePlantera : LoreItem + public class KnowledgePlantera : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgePolterghast.cs b/Items/LoreItems/KnowledgePolterghast.cs index 15a86f588d..41bc94b7e9 100644 --- a/Items/LoreItems/KnowledgePolterghast.cs +++ b/Items/LoreItems/KnowledgePolterghast.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgePolterghast : LoreItem + public class KnowledgePolterghast : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeProvidence.cs b/Items/LoreItems/KnowledgeProvidence.cs index f955de8a21..cfd24f48a8 100644 --- a/Items/LoreItems/KnowledgeProvidence.cs +++ b/Items/LoreItems/KnowledgeProvidence.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeProvidence : LoreItem + public class KnowledgeProvidence : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeQueenBee.cs b/Items/LoreItems/KnowledgeQueenBee.cs index 9b18394e44..50a87ac513 100644 --- a/Items/LoreItems/KnowledgeQueenBee.cs +++ b/Items/LoreItems/KnowledgeQueenBee.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeQueenBee : LoreItem + public class KnowledgeQueenBee : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeRavager.cs b/Items/LoreItems/KnowledgeRavager.cs index 4c63c47214..a3e6480e5c 100644 --- a/Items/LoreItems/KnowledgeRavager.cs +++ b/Items/LoreItems/KnowledgeRavager.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeRavager : LoreItem + public class KnowledgeRavager : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeSkeletron.cs b/Items/LoreItems/KnowledgeSkeletron.cs index a2036775e5..f9e8fe573c 100644 --- a/Items/LoreItems/KnowledgeSkeletron.cs +++ b/Items/LoreItems/KnowledgeSkeletron.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeSkeletron : LoreItem + public class KnowledgeSkeletron : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeSkeletronPrime.cs b/Items/LoreItems/KnowledgeSkeletronPrime.cs index 3c67d1b2aa..9db68d5dbc 100644 --- a/Items/LoreItems/KnowledgeSkeletronPrime.cs +++ b/Items/LoreItems/KnowledgeSkeletronPrime.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeSkeletronPrime : LoreItem + public class KnowledgeSkeletronPrime : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeSlimeGod.cs b/Items/LoreItems/KnowledgeSlimeGod.cs index d8157b3d55..19d51513be 100644 --- a/Items/LoreItems/KnowledgeSlimeGod.cs +++ b/Items/LoreItems/KnowledgeSlimeGod.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeSlimeGod : LoreItem + public class KnowledgeSlimeGod : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeSulphurSea.cs b/Items/LoreItems/KnowledgeSulphurSea.cs index e7100a4c06..62d8848606 100644 --- a/Items/LoreItems/KnowledgeSulphurSea.cs +++ b/Items/LoreItems/KnowledgeSulphurSea.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeSulphurSea : LoreItem + public class KnowledgeSulphurSea : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeTwins.cs b/Items/LoreItems/KnowledgeTwins.cs index ae96523129..be494a8056 100644 --- a/Items/LoreItems/KnowledgeTwins.cs +++ b/Items/LoreItems/KnowledgeTwins.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeTwins : LoreItem + public class KnowledgeTwins : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeUnderworld.cs b/Items/LoreItems/KnowledgeUnderworld.cs index 74c39029ac..61eef92eb1 100644 --- a/Items/LoreItems/KnowledgeUnderworld.cs +++ b/Items/LoreItems/KnowledgeUnderworld.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeUnderworld : LoreItem + public class KnowledgeUnderworld : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeWallofFlesh.cs b/Items/LoreItems/KnowledgeWallofFlesh.cs index 4dc231e56b..44b2083a22 100644 --- a/Items/LoreItems/KnowledgeWallofFlesh.cs +++ b/Items/LoreItems/KnowledgeWallofFlesh.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeWallofFlesh : LoreItem + public class KnowledgeWallofFlesh : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/LoreItems/KnowledgeYharon.cs b/Items/LoreItems/KnowledgeYharon.cs index 79e0ea04a6..85c5e1680a 100644 --- a/Items/LoreItems/KnowledgeYharon.cs +++ b/Items/LoreItems/KnowledgeYharon.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public class KnowledgeYharon : LoreItem + public class KnowledgeYharon : LoreItem { public override void SetStaticDefaults() { diff --git a/Items/Materials/AerialiteBar.cs b/Items/Materials/AerialiteBar.cs index 97c2a2a2a1..f4c5a38c59 100644 --- a/Items/Materials/AerialiteBar.cs +++ b/Items/Materials/AerialiteBar.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Materials { - public class AerialiteBar : ModItem + public class AerialiteBar : ModItem { public override void SetStaticDefaults() { @@ -15,18 +15,18 @@ namespace CalamityMod.Items.Materials public override void SetDefaults() { - item.createTile = ModContent.TileType(); + item.createTile = ModContent.TileType(); item.width = 30; item.height = 24; item.maxStack = 999; item.value = Item.sellPrice(silver: 30); item.rare = ItemRarityID.Orange; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTurn = true; - item.useAnimation = 15; - item.useTime = 10; - item.autoReuse = true; - item.consumable = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; } public override void AddRecipes() diff --git a/Items/Materials/ArmoredShell.cs b/Items/Materials/ArmoredShell.cs index 2de86fba10..08ab88d223 100644 --- a/Items/Materials/ArmoredShell.cs +++ b/Items/Materials/ArmoredShell.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Materials item.height = 34; item.maxStack = 999; item.value = Item.buyPrice(0, 7, 0, 0); - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } } } diff --git a/Items/Materials/Bloodstone.cs b/Items/Materials/Bloodstone.cs index 056620a328..be993f3852 100644 --- a/Items/Materials/Bloodstone.cs +++ b/Items/Materials/Bloodstone.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Materials item.height = 10; item.maxStack = 999; item.value = Item.sellPrice(silver: 60); - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } } } diff --git a/Items/Materials/BloodstoneCore.cs b/Items/Materials/BloodstoneCore.cs index 6ecd83f661..1d46f0bb0d 100644 --- a/Items/Materials/BloodstoneCore.cs +++ b/Items/Materials/BloodstoneCore.cs @@ -17,9 +17,9 @@ namespace CalamityMod.Items.Materials item.height = 12; item.maxStack = 999; item.value = Item.sellPrice(gold: 4); - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } public override void AddRecipes() { diff --git a/Items/Materials/CoreofCalamity.cs b/Items/Materials/CoreofCalamity.cs index 2fcf5f319c..9749c51e27 100644 --- a/Items/Materials/CoreofCalamity.cs +++ b/Items/Materials/CoreofCalamity.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Items.Materials item.rare = ItemRarityID.Yellow; } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Materials/CoreofCalamityGlow")); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Materials/CoreofCalamityGlow")); + } public override void AddRecipes() { diff --git a/Items/Materials/CoreofChaos.cs b/Items/Materials/CoreofChaos.cs index 40848f27c2..99b7d5015e 100644 --- a/Items/Materials/CoreofChaos.cs +++ b/Items/Materials/CoreofChaos.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Items.Materials item.rare = ItemRarityID.Yellow; } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Materials/CoreofChaosGlow")); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Materials/CoreofChaosGlow")); + } public override void Update(ref float gravity, ref float maxFallSpeed) { diff --git a/Items/Materials/CoreofCinder.cs b/Items/Materials/CoreofCinder.cs index f07ea70713..4d39d70b24 100644 --- a/Items/Materials/CoreofCinder.cs +++ b/Items/Materials/CoreofCinder.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Items.Materials item.rare = ItemRarityID.Yellow; } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Materials/CoreofCinderGlow")); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Materials/CoreofCinderGlow")); + } public override void Update(ref float gravity, ref float maxFallSpeed) { diff --git a/Items/Materials/CoreofEleum.cs b/Items/Materials/CoreofEleum.cs index 7a817c49e9..b88aa4581b 100644 --- a/Items/Materials/CoreofEleum.cs +++ b/Items/Materials/CoreofEleum.cs @@ -22,10 +22,10 @@ namespace CalamityMod.Items.Materials item.rare = ItemRarityID.Yellow; } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Materials/CoreofEleumGlow")); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Materials/CoreofEleumGlow")); + } public override void Update(ref float gravity, ref float maxFallSpeed) { diff --git a/Items/Materials/CosmiliteBar.cs b/Items/Materials/CosmiliteBar.cs index 5f620b9366..a1177e0edb 100644 --- a/Items/Materials/CosmiliteBar.cs +++ b/Items/Materials/CosmiliteBar.cs @@ -7,52 +7,52 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Materials { - public class CosmiliteBar : ModItem - { - public int frameCounter = 0; - public int frame = 0; + public class CosmiliteBar : ModItem + { + public int frameCounter = 0; + public int frame = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cosmilite Bar"); - Tooltip.SetDefault("A chunk of durable and highly resilient cosmic steel"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cosmilite Bar"); + Tooltip.SetDefault("A chunk of durable and highly resilient cosmic steel"); + } - public override void SetDefaults() - { - item.createTile = ModContent.TileType(); - item.width = 30; - item.height = 24; - item.maxStack = 999; - item.value = Item.sellPrice(gold: 20); - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTurn = true; - item.useAnimation = 15; - item.useTime = 10; - item.autoReuse = true; - item.consumable = true; - } + public override void SetDefaults() + { + item.createTile = ModContent.TileType(); + item.width = 30; + item.height = 24; + item.maxStack = 999; + item.value = Item.sellPrice(gold: 20); + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + } - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/CosmiliteBar_Animated"); - spriteBatch.Draw(texture, position, item.GetCurrentFrame(ref frame, ref frameCounter, 6, 6), Color.White, 0f, origin, scale, SpriteEffects.None, 0); - return false; - } + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/CosmiliteBar_Animated"); + spriteBatch.Draw(texture, position, item.GetCurrentFrame(ref frame, ref frameCounter, 6, 6), Color.White, 0f, origin, scale, SpriteEffects.None, 0); + return false; + } - public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/CosmiliteBar_Animated"); - spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 6, 6), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); - return false; - } + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/CosmiliteBar_Animated"); + spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 6, 6), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + return false; + } - public override void Update(ref float gravity, ref float maxFallSpeed) - { - float brightness = Main.essScale * Main.rand.NextFloat(0.9f, 1.1f); - Lighting.AddLight(item.Center, 0.5f * brightness, 0f, 0.5f * brightness); - } - } + public override void Update(ref float gravity, ref float maxFallSpeed) + { + float brightness = Main.essScale * Main.rand.NextFloat(0.9f, 1.1f); + Lighting.AddLight(item.Center, 0.5f * brightness, 0f, 0.5f * brightness); + } + } } diff --git a/Items/Materials/CruptixBar.cs b/Items/Materials/CruptixBar.cs index 1affd84a15..d284021faf 100644 --- a/Items/Materials/CruptixBar.cs +++ b/Items/Materials/CruptixBar.cs @@ -8,53 +8,53 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Materials { - public class CruptixBar : ModItem - { - public int frameCounter = 0; - public int frame = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Scoria Bar"); - Tooltip.SetDefault("The smoke feels warm"); - } + public class CruptixBar : ModItem + { + public int frameCounter = 0; + public int frame = 0; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Scoria Bar"); + Tooltip.SetDefault("The smoke feels warm"); + } - public override void SetDefaults() - { - item.createTile = ModContent.TileType(); - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTurn = true; - item.useAnimation = 15; - item.useTime = 10; - item.autoReuse = true; - item.consumable = true; - item.width = 40; - item.height = 52; - item.maxStack = 999; - item.value = Item.sellPrice(gold: 1, silver: 20); - item.rare = ItemRarityID.Yellow; - } + public override void SetDefaults() + { + item.createTile = ModContent.TileType(); + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 40; + item.height = 52; + item.maxStack = 999; + item.value = Item.sellPrice(gold: 1, silver: 20); + item.rare = ItemRarityID.Yellow; + } - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/CruptixBar_Animated"); - spriteBatch.Draw(texture, position, item.GetCurrentFrame(ref frame, ref frameCounter, 6, 6), Color.White, 0f, origin, scale, SpriteEffects.None, 0); - return false; - } + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/CruptixBar_Animated"); + spriteBatch.Draw(texture, position, item.GetCurrentFrame(ref frame, ref frameCounter, 6, 6), Color.White, 0f, origin, scale, SpriteEffects.None, 0); + return false; + } - public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/CruptixBar_Animated"); - spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 6, 6), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); - return false; - } + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/CruptixBar_Animated"); + spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 6, 6), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.AdamantiteForge); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.AdamantiteForge); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Materials/DarkPlasma.cs b/Items/Materials/DarkPlasma.cs index f1363323b2..138dd0e45d 100644 --- a/Items/Materials/DarkPlasma.cs +++ b/Items/Materials/DarkPlasma.cs @@ -19,9 +19,9 @@ namespace CalamityMod.Items.Materials item.height = 12; item.maxStack = 999; item.value = Item.buyPrice(0, 7, 0, 0); - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } public override void Update(ref float gravity, ref float maxFallSpeed) { diff --git a/Items/Materials/EbonianGel.cs b/Items/Materials/EbonianGel.cs index 6e7acb8983..39b623f0b4 100644 --- a/Items/Materials/EbonianGel.cs +++ b/Items/Materials/EbonianGel.cs @@ -22,24 +22,24 @@ namespace CalamityMod.Items.Materials item.rare = ItemRarityID.Blue; } - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - if (item.notAmmo) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/EbonianGelRed"); - spriteBatch.Draw(texture, position, frame, Color.White, 0f, origin, scale, SpriteEffects.None, 0); - } - return !item.notAmmo; - } + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + if (item.notAmmo) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/EbonianGelRed"); + spriteBatch.Draw(texture, position, frame, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + return !item.notAmmo; + } - public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) - { - if (item.notAmmo) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/EbonianGelRed"); - spriteBatch.Draw(texture, item.position - Main.screenPosition, new Rectangle(0, 0, item.width, item.height), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); - } - return !item.notAmmo; - } + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + if (item.notAmmo) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Materials/EbonianGelRed"); + spriteBatch.Draw(texture, item.position - Main.screenPosition, new Rectangle(0, 0, item.width, item.height), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + return !item.notAmmo; + } } } diff --git a/Items/Materials/EffulgentFeather.cs b/Items/Materials/EffulgentFeather.cs index acd0765fa9..94c5b78f56 100644 --- a/Items/Materials/EffulgentFeather.cs +++ b/Items/Materials/EffulgentFeather.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Materials item.height = 24; item.maxStack = 999; item.value = Item.buyPrice(0, 6, 50, 0); - item.rare = ItemRarityID.Purple; - } + item.rare = ItemRarityID.Purple; + } } } diff --git a/Items/Materials/EssenceofChaos.cs b/Items/Materials/EssenceofChaos.cs index f7fd40192f..0ad852d8eb 100644 --- a/Items/Materials/EssenceofChaos.cs +++ b/Items/Materials/EssenceofChaos.cs @@ -23,10 +23,10 @@ namespace CalamityMod.Items.Materials item.rare = ItemRarityID.LightRed; } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, Main.itemTexture[item.type]); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, Main.itemTexture[item.type]); + } public override void Update(ref float gravity, ref float maxFallSpeed) { diff --git a/Items/Materials/EssenceofCinder.cs b/Items/Materials/EssenceofCinder.cs index 4d0050b240..0c16fb6b14 100644 --- a/Items/Materials/EssenceofCinder.cs +++ b/Items/Materials/EssenceofCinder.cs @@ -23,10 +23,10 @@ namespace CalamityMod.Items.Materials item.rare = ItemRarityID.LightRed; } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, Main.itemTexture[item.type]); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, Main.itemTexture[item.type]); + } public override void Update(ref float gravity, ref float maxFallSpeed) { diff --git a/Items/Materials/EssenceofEleum.cs b/Items/Materials/EssenceofEleum.cs index 4a8283b294..b59908fea1 100644 --- a/Items/Materials/EssenceofEleum.cs +++ b/Items/Materials/EssenceofEleum.cs @@ -23,10 +23,10 @@ namespace CalamityMod.Items.Materials item.rare = ItemRarityID.LightRed; } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, Main.itemTexture[item.type]); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, Main.itemTexture[item.type]); + } public override void Update(ref float gravity, ref float maxFallSpeed) { diff --git a/Items/Materials/MiracleMatter.cs b/Items/Materials/MiracleMatter.cs index 7e4199965b..3cc51582b5 100644 --- a/Items/Materials/MiracleMatter.cs +++ b/Items/Materials/MiracleMatter.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Items.Materials return true; } - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) { item.velocity.X = 0f; DrawBackAfterimage(spriteBatch, position, frame, scale); diff --git a/Items/Materials/PlasmaDriveCore.cs b/Items/Materials/PlasmaDriveCore.cs index 87f5b5a636..213c8f762c 100644 --- a/Items/Materials/PlasmaDriveCore.cs +++ b/Items/Materials/PlasmaDriveCore.cs @@ -8,7 +8,7 @@ using System; namespace CalamityMod.Items.Materials { - public class PlasmaDriveCore : ModItem + public class PlasmaDriveCore : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Materials/TwistingNether.cs b/Items/Materials/TwistingNether.cs index 41111e0007..8e0f08e4a8 100644 --- a/Items/Materials/TwistingNether.cs +++ b/Items/Materials/TwistingNether.cs @@ -17,9 +17,9 @@ namespace CalamityMod.Items.Materials item.height = 12; item.maxStack = 999; item.value = Item.buyPrice(0, 7, 0, 0); - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } public override void Update(ref float gravity, ref float maxFallSpeed) { diff --git a/Items/Materials/UeliaceBar.cs b/Items/Materials/UeliaceBar.cs index 442e25be7f..e8c0da1c73 100644 --- a/Items/Materials/UeliaceBar.cs +++ b/Items/Materials/UeliaceBar.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Materials { - public class UeliaceBar : ModItem + public class UeliaceBar : ModItem { public override void SetStaticDefaults() { @@ -15,19 +15,19 @@ namespace CalamityMod.Items.Materials public override void SetDefaults() { - item.createTile = ModContent.TileType(); + item.createTile = ModContent.TileType(); item.width = 15; item.height = 12; item.maxStack = 999; item.rare = ItemRarityID.Red; item.value = Item.sellPrice(gold: 3); item.Calamity().customRarity = CalamityRarity.Turquoise; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTurn = true; - item.useAnimation = 15; - item.useTime = 10; - item.autoReuse = true; - item.consumable = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; } public override void AddRecipes() diff --git a/Items/Materials/UnholyEssence.cs b/Items/Materials/UnholyEssence.cs index 0a5784f6a5..b9799b88aa 100644 --- a/Items/Materials/UnholyEssence.cs +++ b/Items/Materials/UnholyEssence.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Items.Materials item.width = 15; item.height = 12; item.maxStack = 999; - item.rare = ItemRarityID.Purple; - item.value = Item.buyPrice(0, 6, 50, 0); + item.rare = ItemRarityID.Purple; + item.value = Item.buyPrice(0, 6, 50, 0); } public override void Update(ref float gravity, ref float maxFallSpeed) diff --git a/Items/Mounts/AlicornMount.cs b/Items/Mounts/AlicornMount.cs index cf26698eb5..bf2ece551b 100644 --- a/Items/Mounts/AlicornMount.cs +++ b/Items/Mounts/AlicornMount.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Mounts mountData.blockExtraJumps = false; mountData.totalFrames = 15; mountData.constantJump = false; - int baseYOffset = 26; + int baseYOffset = 26; int[] array = new int[mountData.totalFrames]; for (int l = 0; l < array.Length; l++) { @@ -67,56 +67,56 @@ namespace CalamityMod.Items.Mounts } } - public override void SetMount(Player player, ref bool skipDust) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].type == ModContent.NPCType()) - { - Main.npc[i].active = false; - Main.npc[i].netUpdate = true; - break; - } - } - } + public override void SetMount(Player player, ref bool skipDust) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].type == ModContent.NPCType()) + { + Main.npc[i].active = false; + Main.npc[i].netUpdate = true; + break; + } + } + } - public override void Dismount(Player player, ref bool skipDust) - { - bool anyPlayerOnFabMount = false; - for (int i = 0; i < Main.maxPlayers; i++) - { - Player player2 = Main.player[i]; - if (!player2.active) - continue; + public override void Dismount(Player player, ref bool skipDust) + { + bool anyPlayerOnFabMount = false; + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player2 = Main.player[i]; + if (!player2.active) + continue; - // The player that is dismounting is technically not on the mount anymore. - if (player2.Calamity().fab && player2.whoAmI != player.whoAmI) - { - anyPlayerOnFabMount = true; - break; - } - } + // The player that is dismounting is technically not on the mount anymore. + if (player2.Calamity().fab && player2.whoAmI != player.whoAmI) + { + anyPlayerOnFabMount = true; + break; + } + } - // Spawn Cirrus if no other players are on the Alicorn mount. - if (!anyPlayerOnFabMount) - { - if (!NPC.AnyNPCs(ModContent.NPCType())) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.NewNPC((int)player.Center.X, (int)player.Center.Y, ModContent.NPCType()); - } - } - } + // Spawn Cirrus if no other players are on the Alicorn mount. + if (!anyPlayerOnFabMount) + { + if (!NPC.AnyNPCs(ModContent.NPCType())) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC((int)player.Center.X, (int)player.Center.Y, ModContent.NPCType()); + } + } + } - public override void UpdateEffects(Player player) + public override void UpdateEffects(Player player) { CalamityPlayer modPlayer = player.Calamity(); if (modPlayer.fabsolVodka) - player.allDamage += 0.1f; + player.allDamage += 0.1f; if (player.velocity.Length() > 9f) { - int rand = Main.rand.Next(2); + int rand = Main.rand.Next(2); bool momo = false; if (rand == 1) { diff --git a/Items/Mounts/BUMBLEDOGE.cs b/Items/Mounts/BUMBLEDOGE.cs index 8e61ba969f..66a14277a8 100644 --- a/Items/Mounts/BUMBLEDOGE.cs +++ b/Items/Mounts/BUMBLEDOGE.cs @@ -79,8 +79,8 @@ namespace CalamityMod.Items.Mounts int damage = (int)(180 * player.AverageDamage()); float kb = 1f; Projectile birb = Projectile.NewProjectileDirect(pos, vel, ModContent.ProjectileType(), damage, kb, player.whoAmI); - if (birb.whoAmI.WithinBounds(Main.maxProjectiles)) - birb.Calamity().forceTypeless = true; + if (birb.whoAmI.WithinBounds(Main.maxProjectiles)) + birb.Calamity().forceTypeless = true; } } } diff --git a/Items/Mounts/ExoThrone.cs b/Items/Mounts/ExoThrone.cs index 48ad28348c..7ccda6c0ba 100644 --- a/Items/Mounts/ExoThrone.cs +++ b/Items/Mounts/ExoThrone.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Mounts DisplayName.SetDefault("Exo Box"); Tooltip.SetDefault("Materializes a quite cozy and extremely nimble flying Exo throne\n" + "Replaced\n" + - "Also replaced\n" + + "Also replaced\n" + "A comfortable gamer is a dangerous gamer"); } diff --git a/Items/Mounts/Fabsol.cs b/Items/Mounts/Fabsol.cs index 30549091b9..08e0acc438 100644 --- a/Items/Mounts/Fabsol.cs +++ b/Items/Mounts/Fabsol.cs @@ -9,9 +9,9 @@ namespace CalamityMod.Items.Mounts public override void SetStaticDefaults() { DisplayName.SetDefault("Princess Spirit in a Bottle"); - Tooltip.SetDefault("Summons the spirit of Cirrus, the Drunk Princess, in her alicorn form\n" + - "Mounting will transform Cirrus, dismounting transforms her back"); - } + Tooltip.SetDefault("Summons the spirit of Cirrus, the Drunk Princess, in her alicorn form\n" + + "Mounting will transform Cirrus, dismounting transforms her back"); + } public override void SetDefaults() { diff --git a/Items/Mounts/Minecarts/DoGCartMount.cs b/Items/Mounts/Minecarts/DoGCartMount.cs index f686e58dbd..0147709534 100644 --- a/Items/Mounts/Minecarts/DoGCartMount.cs +++ b/Items/Mounts/Minecarts/DoGCartMount.cs @@ -11,142 +11,142 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Mounts.Minecarts { - public class DoGCartMount : ModMountData + public class DoGCartMount : ModMountData { - public const int SegmentCount = 18; - public override void SetDefaults() - { - mountData.Minecart = true; - mountData.MinecartDust = CreateSparkDust; - MountID.Sets.Cart[ModContent.MountType()] = true; + public const int SegmentCount = 18; + public override void SetDefaults() + { + mountData.Minecart = true; + mountData.MinecartDust = CreateSparkDust; + MountID.Sets.Cart[ModContent.MountType()] = true; - mountData.spawnDust = 173; - mountData.buff = ModContent.BuffType(); + mountData.spawnDust = 173; + mountData.buff = ModContent.BuffType(); - // Movement fields. - mountData.flightTimeMax = 0; - mountData.fallDamage = 1f; + // Movement fields. + mountData.flightTimeMax = 0; + mountData.fallDamage = 1f; - // Mechanical Cart in vanilla uses 20f and 0.1f respectively for these fields. - mountData.runSpeed = 22f; - mountData.acceleration = 0.16f; + // Mechanical Cart in vanilla uses 20f and 0.1f respectively for these fields. + mountData.runSpeed = 22f; + mountData.acceleration = 0.16f; - mountData.jumpHeight = 16; - mountData.jumpSpeed = 5.2f; - mountData.blockExtraJumps = true; - mountData.heightBoost = 12; + mountData.jumpHeight = 16; + mountData.jumpSpeed = 5.2f; + mountData.blockExtraJumps = true; + mountData.heightBoost = 12; - // Drawing fields. - mountData.playerYOffsets = new int[] { 6, 6, 6 }; - mountData.xOffset = 2; - mountData.yOffset = 12; - mountData.bodyFrame = 3; + // Drawing fields. + mountData.playerYOffsets = new int[] { 6, 6, 6 }; + mountData.xOffset = 2; + mountData.yOffset = 12; + mountData.bodyFrame = 3; - // Animation fields. - mountData.totalFrames = 3; - mountData.standingFrameCount = 1; - mountData.standingFrameDelay = 12; - mountData.standingFrameStart = 0; - mountData.runningFrameCount = 3; - mountData.runningFrameDelay = 12; - mountData.runningFrameStart = 0; - mountData.flyingFrameCount = 0; - mountData.flyingFrameDelay = 0; - mountData.flyingFrameStart = 0; - mountData.inAirFrameCount = 0; - mountData.inAirFrameDelay = 0; - mountData.inAirFrameStart = 0; - mountData.idleFrameCount = 1; - mountData.idleFrameDelay = 10; - mountData.idleFrameStart = 0; - mountData.idleFrameLoop = false; - if (Main.netMode != NetmodeID.Server) - { - mountData.textureWidth = 74; - mountData.textureHeight = 114; - } - } + // Animation fields. + mountData.totalFrames = 3; + mountData.standingFrameCount = 1; + mountData.standingFrameDelay = 12; + mountData.standingFrameStart = 0; + mountData.runningFrameCount = 3; + mountData.runningFrameDelay = 12; + mountData.runningFrameStart = 0; + mountData.flyingFrameCount = 0; + mountData.flyingFrameDelay = 0; + mountData.flyingFrameStart = 0; + mountData.inAirFrameCount = 0; + mountData.inAirFrameDelay = 0; + mountData.inAirFrameStart = 0; + mountData.idleFrameCount = 1; + mountData.idleFrameDelay = 10; + mountData.idleFrameStart = 0; + mountData.idleFrameLoop = false; + if (Main.netMode != NetmodeID.Server) + { + mountData.textureWidth = 74; + mountData.textureHeight = 114; + } + } - public void CreateSparkDust(Vector2 dustPosition) - { - Vector2 offsetDirection = DelegateMethods.Minecart.rotation.ToRotationVector2(); - offsetDirection *= new Vector2(Main.rand.NextBool().ToDirectionInt(), 1f) * 13f; - dustPosition += offsetDirection; + public void CreateSparkDust(Vector2 dustPosition) + { + Vector2 offsetDirection = DelegateMethods.Minecart.rotation.ToRotationVector2(); + offsetDirection *= new Vector2(Main.rand.NextBool().ToDirectionInt(), 1f) * 13f; + dustPosition += offsetDirection; - Dust spark = Dust.NewDustPerfect(dustPosition, 234); - spark.velocity = Main.rand.NextVector2Circular(4f, 4f); - spark.velocity.X *= Main.rand.NextFloat(0.25f, 1f); - spark.velocity.Y -= Main.rand.NextFloat(1.25f, 3f); - spark.position.Y -= 4f; - spark.scale = Main.rand.NextFloat(0.9f, 1.4f); - spark.noGravity = true; + Dust spark = Dust.NewDustPerfect(dustPosition, 234); + spark.velocity = Main.rand.NextVector2Circular(4f, 4f); + spark.velocity.X *= Main.rand.NextFloat(0.25f, 1f); + spark.velocity.Y -= Main.rand.NextFloat(1.25f, 3f); + spark.position.Y -= 4f; + spark.scale = Main.rand.NextFloat(0.9f, 1.4f); + spark.noGravity = true; - if (Main.rand.NextBool(8)) - spark.scale *= 1.5f; - if (Main.rand.NextBool(8)) - spark.scale *= 0.667f; + if (Main.rand.NextBool(8)) + spark.scale *= 1.5f; + if (Main.rand.NextBool(8)) + spark.scale *= 0.667f; - if (Main.rand.NextBool(3)) - spark.scale *= 0.65f; - else - spark.noGravity = false; - } + if (Main.rand.NextBool(3)) + spark.scale *= 0.65f; + else + spark.noGravity = false; + } - public static float CalculateIdealWormRotation(Player player) - { - int direction = (player.velocity.SafeNormalize(Vector2.UnitX * player.direction).X > 0f).ToDirectionInt(); - if (player.velocity.X == 0f) - direction = player.direction; - return (direction == 1 ? 0f : MathHelper.Pi) - DelegateMethods.Minecart.rotation * 0.1f; - } + public static float CalculateIdealWormRotation(Player player) + { + int direction = (player.velocity.SafeNormalize(Vector2.UnitX * player.direction).X > 0f).ToDirectionInt(); + if (player.velocity.X == 0f) + direction = player.direction; + return (direction == 1 ? 0f : MathHelper.Pi) - DelegateMethods.Minecart.rotation * 0.1f; + } - public static Vector2 CalculateSegmentWaveOffset(int index, Player player) - { - Vector2 baseDirection = (CalculateIdealWormRotation(player) - MathHelper.PiOver2 + DelegateMethods.Minecart.rotation).ToRotationVector2(); - Vector2 waveOffset = baseDirection * (float)Math.Sin(MathHelper.Pi * index / player.Calamity().DoGCartSegments.Length + Main.GameUpdateCount / 14f) * 5f; - waveOffset *= Utils.InverseLerp(10f, 4f, player.velocity.Length(), true); + public static Vector2 CalculateSegmentWaveOffset(int index, Player player) + { + Vector2 baseDirection = (CalculateIdealWormRotation(player) - MathHelper.PiOver2 + DelegateMethods.Minecart.rotation).ToRotationVector2(); + Vector2 waveOffset = baseDirection * (float)Math.Sin(MathHelper.Pi * index / player.Calamity().DoGCartSegments.Length + Main.GameUpdateCount / 14f) * 5f; + waveOffset *= Utils.InverseLerp(10f, 4f, player.velocity.Length(), true); - return waveOffset; - } + return waveOffset; + } public override bool Draw(List playerDrawData, int drawType, Player drawPlayer, ref Texture2D texture, ref Texture2D glowTexture, ref Vector2 drawPosition, ref Rectangle frame, ref Color drawColor, ref Color glowColor, ref float rotation, ref SpriteEffects spriteEffects, ref Vector2 drawOrigin, ref float drawScale, float shadow) { - if (drawPlayer.Calamity().DoGCartSegments is null || drawPlayer.Calamity().DoGCartSegments[0] is null) - return true; + if (drawPlayer.Calamity().DoGCartSegments is null || drawPlayer.Calamity().DoGCartSegments[0] is null) + return true; - // Account for stupid rotational issues. - List rotationAdjustedPositions = new List() - { - drawPlayer.Calamity().DoGCartSegments[0].Center - }; - - for (int i = 1; i < drawPlayer.Calamity().DoGCartSegments.Length; i++) - { - rotationAdjustedPositions.Add(drawPlayer.Center - (drawPlayer.Center - drawPlayer.Calamity().DoGCartSegments[i].Center).RotatedBy(-drawPlayer.Calamity().SmoothenedMinecartRotation)); - } - - for (int i = 0; i < SegmentCount; i++) + // Account for stupid rotational issues. + List rotationAdjustedPositions = new List() { - DoGCartSegment segment = drawPlayer.Calamity().DoGCartSegments[i]; - if (segment is null) - break; + drawPlayer.Calamity().DoGCartSegments[0].Center + }; - Texture2D segmentTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/DoGCartBody"); - if (i == SegmentCount - 1) - segmentTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/DoGCartTail"); - Vector2 segmentDrawPosition = rotationAdjustedPositions[i] + CalculateSegmentWaveOffset(i, drawPlayer); + for (int i = 1; i < drawPlayer.Calamity().DoGCartSegments.Length; i++) + { + rotationAdjustedPositions.Add(drawPlayer.Center - (drawPlayer.Center - drawPlayer.Calamity().DoGCartSegments[i].Center).RotatedBy(-drawPlayer.Calamity().SmoothenedMinecartRotation)); + } - Color segmentColor = Lighting.GetColor((int)segmentDrawPosition.X / 16, (int)segmentDrawPosition.Y / 16); - Vector2 origin = segmentTexture.Size() * 0.5f; - float segmentRotation = segment.Rotation - DelegateMethods.Minecart.rotation; - DrawData segmentDrawData = new DrawData(segmentTexture, segmentDrawPosition - Main.screenPosition, null, segmentColor, segmentRotation, origin, Vector2.One, SpriteEffects.None, 0) - { - shader = Mount.currentShader - }; + for (int i = 0; i < SegmentCount; i++) + { + DoGCartSegment segment = drawPlayer.Calamity().DoGCartSegments[i]; + if (segment is null) + break; - playerDrawData.Add(segmentDrawData); - } - return true; + Texture2D segmentTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/DoGCartBody"); + if (i == SegmentCount - 1) + segmentTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/DoGCartTail"); + Vector2 segmentDrawPosition = rotationAdjustedPositions[i] + CalculateSegmentWaveOffset(i, drawPlayer); + + Color segmentColor = Lighting.GetColor((int)segmentDrawPosition.X / 16, (int)segmentDrawPosition.Y / 16); + Vector2 origin = segmentTexture.Size() * 0.5f; + float segmentRotation = segment.Rotation - DelegateMethods.Minecart.rotation; + DrawData segmentDrawData = new DrawData(segmentTexture, segmentDrawPosition - Main.screenPosition, null, segmentColor, segmentRotation, origin, Vector2.One, SpriteEffects.None, 0) + { + shader = Mount.currentShader + }; + + playerDrawData.Add(segmentDrawData); + } + return true; } } } diff --git a/Items/Mounts/OnyxExcavator.cs b/Items/Mounts/OnyxExcavator.cs index 8b339be75c..1de6b2eaa3 100644 --- a/Items/Mounts/OnyxExcavator.cs +++ b/Items/Mounts/OnyxExcavator.cs @@ -11,222 +11,222 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Mounts { - public class OnyxExcavator : ModMountData - { - public override void SetDefaults() - { - mountData.spawnDust = 109; - mountData.spawnDustNoGravity = true; - mountData.buff = ModContent.BuffType(); - mountData.heightBoost = 10; - mountData.fallDamage = 0f; - mountData.runSpeed = 8f; - mountData.flightTimeMax = 0; - mountData.jumpHeight = 5; - mountData.acceleration = 0.2f; - mountData.jumpSpeed = 3f; - mountData.swimSpeed = 0.5f; - mountData.totalFrames = 8; - int[] array = new int[mountData.totalFrames]; - for (int l = 0; l < array.Length; l++) - { - array[l] = 2; - } - array[1] = 0; - array[5] = 0; - mountData.playerYOffsets = array; - mountData.xOffset = 0; //-6 - mountData.bodyFrame = 3; - mountData.yOffset = -1; //done - mountData.playerHeadOffset = 10; - mountData.standingFrameCount = 1; - mountData.standingFrameDelay = 12; - mountData.standingFrameStart = 0; - mountData.runningFrameCount = 8; - mountData.runningFrameDelay = 36; //36 - mountData.runningFrameStart = mountData.standingFrameStart; - mountData.inAirFrameCount = mountData.standingFrameCount; - mountData.inAirFrameDelay = mountData.standingFrameDelay; - mountData.inAirFrameStart = mountData.standingFrameStart; - mountData.idleFrameCount = mountData.standingFrameCount; - mountData.idleFrameDelay = mountData.standingFrameDelay; - mountData.idleFrameStart = mountData.standingFrameStart; - mountData.idleFrameLoop = false; - mountData.swimFrameCount = mountData.inAirFrameCount; - mountData.swimFrameDelay = mountData.inAirFrameDelay; - mountData.swimFrameStart = mountData.inAirFrameStart; - if (Main.netMode != NetmodeID.Server) - { - mountData.backTextureExtra = ModContent.GetTexture("CalamityMod/Items/Mounts/OnyxExcavatorExtra"); - mountData.frontTextureExtra = ModContent.GetTexture("CalamityMod/Items/Mounts/OnyxExcavatorExtra2"); - mountData.textureWidth = mountData.backTexture.Width; - mountData.textureHeight = mountData.backTexture.Height; - } - } + public class OnyxExcavator : ModMountData + { + public override void SetDefaults() + { + mountData.spawnDust = 109; + mountData.spawnDustNoGravity = true; + mountData.buff = ModContent.BuffType(); + mountData.heightBoost = 10; + mountData.fallDamage = 0f; + mountData.runSpeed = 8f; + mountData.flightTimeMax = 0; + mountData.jumpHeight = 5; + mountData.acceleration = 0.2f; + mountData.jumpSpeed = 3f; + mountData.swimSpeed = 0.5f; + mountData.totalFrames = 8; + int[] array = new int[mountData.totalFrames]; + for (int l = 0; l < array.Length; l++) + { + array[l] = 2; + } + array[1] = 0; + array[5] = 0; + mountData.playerYOffsets = array; + mountData.xOffset = 0; //-6 + mountData.bodyFrame = 3; + mountData.yOffset = -1; //done + mountData.playerHeadOffset = 10; + mountData.standingFrameCount = 1; + mountData.standingFrameDelay = 12; + mountData.standingFrameStart = 0; + mountData.runningFrameCount = 8; + mountData.runningFrameDelay = 36; //36 + mountData.runningFrameStart = mountData.standingFrameStart; + mountData.inAirFrameCount = mountData.standingFrameCount; + mountData.inAirFrameDelay = mountData.standingFrameDelay; + mountData.inAirFrameStart = mountData.standingFrameStart; + mountData.idleFrameCount = mountData.standingFrameCount; + mountData.idleFrameDelay = mountData.standingFrameDelay; + mountData.idleFrameStart = mountData.standingFrameStart; + mountData.idleFrameLoop = false; + mountData.swimFrameCount = mountData.inAirFrameCount; + mountData.swimFrameDelay = mountData.inAirFrameDelay; + mountData.swimFrameStart = mountData.inAirFrameStart; + if (Main.netMode != NetmodeID.Server) + { + mountData.backTextureExtra = ModContent.GetTexture("CalamityMod/Items/Mounts/OnyxExcavatorExtra"); + mountData.frontTextureExtra = ModContent.GetTexture("CalamityMod/Items/Mounts/OnyxExcavatorExtra2"); + mountData.textureWidth = mountData.backTexture.Width; + mountData.textureHeight = mountData.backTexture.Height; + } + } - public override bool UpdateFrame(Player mountedPlayer, int state, Vector2 velocity) - { - bool speed = Math.Abs(velocity.X) > mountedPlayer.mount.RunSpeed / 2f; - float direction = Math.Sign(mountedPlayer.velocity.X); - Lighting.AddLight(mountedPlayer.Center, 0.5f, 0.5f, 0.4f); - if (speed && velocity.Y == 0f) - { - for (int i = 0; i < 2; i++) - { - Dust dust = Dust.NewDustDirect(mountedPlayer.BottomLeft, mountedPlayer.width, 6, 192, 0f, 0f, 0, default, 1f); - dust.velocity = new Vector2(velocity.X * 0.15f, Main.rand.NextFloat() * -2f); - dust.noLight = true; - dust.scale = 0.2f + Main.rand.NextFloat() * 0.8f; - dust.fadeIn = 0.5f + Main.rand.NextFloat() * 1f; - dust.shader = GameShaders.Armor.GetSecondaryShader(mountedPlayer.cMount, mountedPlayer); - } - if (mountedPlayer.cMount == 0) - { - mountedPlayer.position += new Vector2(direction * 24f, 0f); - mountedPlayer.FloorVisuals(true); - mountedPlayer.position -= new Vector2(direction * 24f, 0f); - } - } - return true; - } + public override bool UpdateFrame(Player mountedPlayer, int state, Vector2 velocity) + { + bool speed = Math.Abs(velocity.X) > mountedPlayer.mount.RunSpeed / 2f; + float direction = Math.Sign(mountedPlayer.velocity.X); + Lighting.AddLight(mountedPlayer.Center, 0.5f, 0.5f, 0.4f); + if (speed && velocity.Y == 0f) + { + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustDirect(mountedPlayer.BottomLeft, mountedPlayer.width, 6, 192, 0f, 0f, 0, default, 1f); + dust.velocity = new Vector2(velocity.X * 0.15f, Main.rand.NextFloat() * -2f); + dust.noLight = true; + dust.scale = 0.2f + Main.rand.NextFloat() * 0.8f; + dust.fadeIn = 0.5f + Main.rand.NextFloat() * 1f; + dust.shader = GameShaders.Armor.GetSecondaryShader(mountedPlayer.cMount, mountedPlayer); + } + if (mountedPlayer.cMount == 0) + { + mountedPlayer.position += new Vector2(direction * 24f, 0f); + mountedPlayer.FloorVisuals(true); + mountedPlayer.position -= new Vector2(direction * 24f, 0f); + } + } + return true; + } - public override void UseAbility(Player player, Vector2 mousePosition, bool toggleOn) - { - if (Main.mouseLeft && !player.mouseInterface && !Main.blockMouse) - { - if (Main.myPlayer == player.whoAmI) - { - int highestPickPower = 35; //35% if you have no pickaxes. - for (int item = 0; item < Main.maxInventory; item++) - { - if (player.inventory[item].pick <= 0) - continue; - if (player.inventory[item].pick > highestPickPower) - { - highestPickPower = player.inventory[item].pick; - } - } + public override void UseAbility(Player player, Vector2 mousePosition, bool toggleOn) + { + if (Main.mouseLeft && !player.mouseInterface && !Main.blockMouse) + { + if (Main.myPlayer == player.whoAmI) + { + int highestPickPower = 35; //35% if you have no pickaxes. + for (int item = 0; item < Main.maxInventory; item++) + { + if (player.inventory[item].pick <= 0) + continue; + if (player.inventory[item].pick > highestPickPower) + { + highestPickPower = player.inventory[item].pick; + } + } - float direction = Math.Sign(player.velocity.X); - if (Math.Abs(direction) < 0.1f) - direction = player.direction == 1 ? 0.1f : -0.1f; - float yOffset = 12f; - float xOffset = 40f; - Vector2 source = player.Center + new Vector2(direction * xOffset, yOffset); - int mineHeight = 3; - int xRight = (int)(source.X / 16 - mineHeight); - int xLeft = (int)(source.X / 16 + mineHeight); - int yTop = (int)(source.Y / 16 - mineHeight); - int yBottom = (int)(source.Y / 16 + mineHeight); - if (xRight < 0) - { - xRight = 0; - } - if (xLeft > Main.maxTilesX) - { - xLeft = Main.maxTilesX; - } - if (yTop < 0) - { - yTop = 0; - } - if (yBottom > Main.maxTilesY) - { - yBottom = Main.maxTilesY; - } - //AchievementsHelper.CurrentlyMining = true; - for (int x = xRight; x <= xLeft; x++) - { - for (int y = yTop; y <= yBottom; y++) - { - source.Y -= 2f; - Vector2 tileVec = new Vector2(Math.Abs(x - source.X / 16f), Math.Abs(y - source.Y / 16f)); - float tileDist = tileVec.Length(); - Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + float direction = Math.Sign(player.velocity.X); + if (Math.Abs(direction) < 0.1f) + direction = player.direction == 1 ? 0.1f : -0.1f; + float yOffset = 12f; + float xOffset = 40f; + Vector2 source = player.Center + new Vector2(direction * xOffset, yOffset); + int mineHeight = 3; + int xRight = (int)(source.X / 16 - mineHeight); + int xLeft = (int)(source.X / 16 + mineHeight); + int yTop = (int)(source.Y / 16 - mineHeight); + int yBottom = (int)(source.Y / 16 + mineHeight); + if (xRight < 0) + { + xRight = 0; + } + if (xLeft > Main.maxTilesX) + { + xLeft = Main.maxTilesX; + } + if (yTop < 0) + { + yTop = 0; + } + if (yBottom > Main.maxTilesY) + { + yBottom = Main.maxTilesY; + } + //AchievementsHelper.CurrentlyMining = true; + for (int x = xRight; x <= xLeft; x++) + { + for (int y = yTop; y <= yBottom; y++) + { + source.Y -= 2f; + Vector2 tileVec = new Vector2(Math.Abs(x - source.X / 16f), Math.Abs(y - source.Y / 16f)); + float tileDist = tileVec.Length(); + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - int pickReq = 0; - ModTile moddedTile = TileLoader.GetTile(tile.type); - if (moddedTile != null) - { - pickReq = moddedTile.minPick; - } - else - { - switch (tile.type) - { - case TileID.Chlorophyte: - pickReq = 200; - break; - case TileID.Ebonstone: - case TileID.Crimstone: - case TileID.Pearlstone: - case TileID.DesertFossil: - case TileID.Obsidian: - case TileID.Hellstone: - pickReq = 65; - break; - case TileID.Meteorite: - pickReq = 50; - break; - case TileID.Demonite: - case TileID.Crimtane: - if (y > Main.worldSurface) - pickReq = 55; - break; - case TileID.LihzahrdBrick: - case TileID.LihzahrdAltar: - pickReq = 210; - break; - case TileID.Cobalt: - case TileID.Palladium: - pickReq = 100; - break; - case TileID.Mythril: - case TileID.Orichalcum: - pickReq = 110; - break; - case TileID.Adamantite: - case TileID.Titanium: - pickReq = 150; - break; - default: - break; - } - } - if (Main.tileDungeon[tile.type]) - { - if (x < Main.maxTilesX * 0.35 || x > Main.maxTilesX * 0.65) - pickReq = 65; - } + int pickReq = 0; + ModTile moddedTile = TileLoader.GetTile(tile.type); + if (moddedTile != null) + { + pickReq = moddedTile.minPick; + } + else + { + switch (tile.type) + { + case TileID.Chlorophyte: + pickReq = 200; + break; + case TileID.Ebonstone: + case TileID.Crimstone: + case TileID.Pearlstone: + case TileID.DesertFossil: + case TileID.Obsidian: + case TileID.Hellstone: + pickReq = 65; + break; + case TileID.Meteorite: + pickReq = 50; + break; + case TileID.Demonite: + case TileID.Crimtane: + if (y > Main.worldSurface) + pickReq = 55; + break; + case TileID.LihzahrdBrick: + case TileID.LihzahrdAltar: + pickReq = 210; + break; + case TileID.Cobalt: + case TileID.Palladium: + pickReq = 100; + break; + case TileID.Mythril: + case TileID.Orichalcum: + pickReq = 110; + break; + case TileID.Adamantite: + case TileID.Titanium: + pickReq = 150; + break; + default: + break; + } + } + if (Main.tileDungeon[tile.type]) + { + if (x < Main.maxTilesX * 0.35 || x > Main.maxTilesX * 0.65) + pickReq = 65; + } - if (tileDist < mineHeight) - { - bool t = 1 == 1; - bool f = 1 == 2; - bool canBreakTileCheck = TileLoader.CanKillTile(x, y, tile.type, ref t) && TileLoader.CanKillTile(x, y, tile.type, ref f); - List tileExcludeList = new List() - { - ModContent.TileType(), - ModContent.TileType(), - TileID.DemonAltar, - TileID.ElderCrystalStand - }; + if (tileDist < mineHeight) + { + bool t = 1 == 1; + bool f = 1 == 2; + bool canBreakTileCheck = TileLoader.CanKillTile(x, y, tile.type, ref t) && TileLoader.CanKillTile(x, y, tile.type, ref f); + List tileExcludeList = new List() + { + ModContent.TileType(), + ModContent.TileType(), + TileID.DemonAltar, + TileID.ElderCrystalStand + }; - if (tile.active() && !player.noBuilding && !Main.tileContainer[tile.type] && - tileExcludeList.TrueForAll(z => tile.type != z) && pickReq < highestPickPower && canBreakTileCheck) - { - WorldGen.KillTile(x, y, false, false, false); - if (!Main.tile[x, y].active() && Main.netMode != NetmodeID.SinglePlayer) - { - NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, x, y, 0f, 0, 0, 0); - } - } - } - } - } - //AchievementsHelper.CurrentlyMining = false; - } - } - } - } + if (tile.active() && !player.noBuilding && !Main.tileContainer[tile.type] && + tileExcludeList.TrueForAll(z => tile.type != z) && pickReq < highestPickPower && canBreakTileCheck) + { + WorldGen.KillTile(x, y, false, false, false); + if (!Main.tile[x, y].active() && Main.netMode != NetmodeID.SinglePlayer) + { + NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, x, y, 0f, 0, 0, 0); + } + } + } + } + } + //AchievementsHelper.CurrentlyMining = false; + } + } + } + } } diff --git a/Items/Mounts/OnyxExcavatorKey.cs b/Items/Mounts/OnyxExcavatorKey.cs index 5484ed0ff3..45d2f833b3 100644 --- a/Items/Mounts/OnyxExcavatorKey.cs +++ b/Items/Mounts/OnyxExcavatorKey.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Mounts Tooltip.SetDefault("Summons a drill to drill through the world so you can destroy all the neat world generation\n" + "with complete disregard for all the creatures that inhabit these lands. I am sure the EPA and PETA would like\n" + "to have a word with you afterwards.\n" + - "The power of the destruction scales with the highest powered pickaxe in your inventory"); + "The power of the destruction scales with the highest powered pickaxe in your inventory"); } public override void SetDefaults() diff --git a/Items/Mounts/SquishyBean.cs b/Items/Mounts/SquishyBean.cs index d3c864354b..038cc96c3e 100644 --- a/Items/Mounts/SquishyBean.cs +++ b/Items/Mounts/SquishyBean.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Mounts mountData.acceleration = 0.1f; mountData.jumpSpeed = 20f; mountData.totalFrames = 4; - mountData.blockExtraJumps = true; + mountData.blockExtraJumps = true; int[] array = new int[mountData.totalFrames]; for (int l = 0; l < array.Length; l++) { @@ -74,13 +74,13 @@ namespace CalamityMod.Items.Mounts public override void UpdateEffects(Player player) { - if (player.velocity.Y > 0f || player.controlDown) - { - player.gravity = 1f; - player.maxFallSpeed = 20f; - } + if (player.velocity.Y > 0f || player.controlDown) + { + player.gravity = 1f; + player.maxFallSpeed = 20f; + } player.noFallDmg = true; } - } + } } diff --git a/Items/NormalityRelocator.cs b/Items/NormalityRelocator.cs index f164ce66e1..d67ca50788 100644 --- a/Items/NormalityRelocator.cs +++ b/Items/NormalityRelocator.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items DisplayName.SetDefault("Normality Relocator"); Tooltip.SetDefault("I'll be there in the blink of an eye\n" + "This line is modified below\n" + - "Fall speed is doubled for 30 frames after teleporting\n" + + "Fall speed is doubled for 30 frames after teleporting\n" + "Teleportation is disabled while Chaos State is active\n" + "Works while in the inventory"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 7)); diff --git a/Items/PermanentBoosters/BloodOrange.cs b/Items/PermanentBoosters/BloodOrange.cs index 61de1eacc5..440ba8ca27 100644 --- a/Items/PermanentBoosters/BloodOrange.cs +++ b/Items/PermanentBoosters/BloodOrange.cs @@ -57,12 +57,12 @@ namespace CalamityMod.Items.PermanentBoosters { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.LifeFruit, 5); - recipe.AddIngredient(ItemID.OrangeBloodroot); + recipe.AddIngredient(ItemID.OrangeBloodroot); recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddIngredient(ItemID.SoulofMight, 5); recipe.AddIngredient(ItemID.SoulofSight, 5); - recipe.AddIngredient(ItemID.SoulofFright, 5); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.SoulofFright, 5); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/PermanentBoosters/Ectoheart.cs b/Items/PermanentBoosters/Ectoheart.cs index dc88420955..a8d9d1ada8 100644 --- a/Items/PermanentBoosters/Ectoheart.cs +++ b/Items/PermanentBoosters/Ectoheart.cs @@ -7,61 +7,61 @@ using Terraria.ModLoader; namespace CalamityMod.Items.PermanentBoosters { - public class Ectoheart : ModItem - { - public int frameCounter = 0; - public int frame = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ectoheart"); - Tooltip.SetDefault("Permanently increases Adrenaline Mode damage by 15% and damage reduction by 5%\n" + - "Revengeance drop"); - } + public class Ectoheart : ModItem + { + public int frameCounter = 0; + public int frame = 0; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ectoheart"); + Tooltip.SetDefault("Permanently increases Adrenaline Mode damage by 15% and damage reduction by 5%\n" + + "Revengeance drop"); + } - public override void SetDefaults() - { - item.width = 42; - item.height = 44; - item.useAnimation = 30; - item.useTime = 30; - item.useStyle = ItemUseStyleID.HoldingUp; - item.UseSound = SoundID.Item122; - item.consumable = true; - item.rare = ItemRarityID.Red; - item.Calamity().customRarity = CalamityRarity.PureGreen; - } + public override void SetDefaults() + { + item.width = 42; + item.height = 44; + item.useAnimation = 30; + item.useTime = 30; + item.useStyle = ItemUseStyleID.HoldingUp; + item.UseSound = SoundID.Item122; + item.consumable = true; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.PureGreen; + } - public override bool CanUseItem(Player player) => !player.Calamity().adrenalineBoostThree; + public override bool CanUseItem(Player player) => !player.Calamity().adrenalineBoostThree; - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/Ectoheart_Animated"); - spriteBatch.Draw(texture, position, item.GetCurrentFrame(ref frame, ref frameCounter, 8, 3), Color.White, 0f, origin, scale, SpriteEffects.None, 0); - return false; - } + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/Ectoheart_Animated"); + spriteBatch.Draw(texture, position, item.GetCurrentFrame(ref frame, ref frameCounter, 8, 3), Color.White, 0f, origin, scale, SpriteEffects.None, 0); + return false; + } - public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/Ectoheart_Animated"); - spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 8, 3), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); - return false; - } + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/Ectoheart_Animated"); + spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 8, 3), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + return false; + } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/EctoheartGlow"); - spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 8, 3, false), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/EctoheartGlow"); + spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 8, 3, false), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } - public override bool UseItem(Player player) - { - if (player.itemAnimation > 0 && player.itemTime == 0) - { - player.itemTime = item.useTime; - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.adrenalineBoostThree = true; - } - return true; - } - } + public override bool UseItem(Player player) + { + if (player.itemAnimation > 0 && player.itemTime == 0) + { + player.itemTime = item.useTime; + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.adrenalineBoostThree = true; + } + return true; + } + } } diff --git a/Items/PermanentBoosters/Elderberry.cs b/Items/PermanentBoosters/Elderberry.cs index 6c578c6593..4381176f38 100644 --- a/Items/PermanentBoosters/Elderberry.cs +++ b/Items/PermanentBoosters/Elderberry.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Items.PermanentBoosters item.height = 20; item.useAnimation = 30; item.rare = ItemRarityID.Red; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.useTime = 30; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.useTime = 30; item.useStyle = ItemUseStyleID.HoldingUp; item.UseSound = SoundID.Item4; item.consumable = true; @@ -58,8 +58,8 @@ namespace CalamityMod.Items.PermanentBoosters { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.LifeFruit, 5); - recipe.AddIngredient(ItemID.BlueBerries); - recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ItemID.BlueBerries); + recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(TileID.LunarCraftingStation); diff --git a/Items/PermanentBoosters/MiracleFruit.cs b/Items/PermanentBoosters/MiracleFruit.cs index 03cd58ed88..fdb5016e8e 100644 --- a/Items/PermanentBoosters/MiracleFruit.cs +++ b/Items/PermanentBoosters/MiracleFruit.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.PermanentBoosters { - public class MiracleFruit : ModItem + public class MiracleFruit : ModItem { public override void SetStaticDefaults() { @@ -57,10 +57,10 @@ namespace CalamityMod.Items.PermanentBoosters { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.LifeFruit, 5); - recipe.AddIngredient(ItemID.TealMushroom); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ItemID.TealMushroom); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/PermanentBoosters/RedLightningContainer.cs b/Items/PermanentBoosters/RedLightningContainer.cs index 51fedc6db7..70902d9807 100644 --- a/Items/PermanentBoosters/RedLightningContainer.cs +++ b/Items/PermanentBoosters/RedLightningContainer.cs @@ -7,60 +7,60 @@ using Terraria.ModLoader; namespace CalamityMod.Items.PermanentBoosters { - public class RedLightningContainer : ModItem - { - public int frameCounter = 0; - public int frame = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Red Lightning Container"); - Tooltip.SetDefault("Permanently increases the duration of Rage Mode by 1 second\n" + - "Revengeance drop"); - } + public class RedLightningContainer : ModItem + { + public int frameCounter = 0; + public int frame = 0; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Red Lightning Container"); + Tooltip.SetDefault("Permanently increases the duration of Rage Mode by 1 second\n" + + "Revengeance drop"); + } - public override void SetDefaults() - { - item.width = 30; - item.height = 40; - item.useAnimation = 30; - item.useTime = 30; - item.useStyle = ItemUseStyleID.HoldingUp; - item.UseSound = SoundID.Item122; - item.consumable = true; - item.rare = ItemRarityID.Purple; - } + public override void SetDefaults() + { + item.width = 30; + item.height = 40; + item.useAnimation = 30; + item.useTime = 30; + item.useStyle = ItemUseStyleID.HoldingUp; + item.UseSound = SoundID.Item122; + item.consumable = true; + item.rare = ItemRarityID.Purple; + } - public override bool CanUseItem(Player player) => !player.Calamity().rageBoostThree; + public override bool CanUseItem(Player player) => !player.Calamity().rageBoostThree; - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/RedLightningContainer_Animated"); - spriteBatch.Draw(texture, position, item.GetCurrentFrame(ref frame, ref frameCounter, 5, 6), Color.White, 0f, origin, scale, SpriteEffects.None, 0); - return false; - } + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/RedLightningContainer_Animated"); + spriteBatch.Draw(texture, position, item.GetCurrentFrame(ref frame, ref frameCounter, 5, 6), Color.White, 0f, origin, scale, SpriteEffects.None, 0); + return false; + } - public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/RedLightningContainer_Animated"); - spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 5, 6), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); - return false; - } + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/RedLightningContainer_Animated"); + spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 5, 6), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + return false; + } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/RedLightningContainerGlow"); - spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 5, 6, false), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/PermanentBoosters/RedLightningContainerGlow"); + spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, 5, 6, false), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } - public override bool UseItem(Player player) - { - if (player.itemAnimation > 0 && player.itemTime == 0) - { - player.itemTime = item.useTime; - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.rageBoostThree = true; - } - return true; - } - } + public override bool UseItem(Player player) + { + if (player.itemAnimation > 0 && player.itemTime == 0) + { + player.itemTime = item.useTime; + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.rageBoostThree = true; + } + return true; + } + } } diff --git a/Items/Pets/PineapplePet.cs b/Items/Pets/PineapplePet.cs index 5b2ccef808..7f24fdf6e7 100644 --- a/Items/Pets/PineapplePet.cs +++ b/Items/Pets/PineapplePet.cs @@ -6,38 +6,38 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Pets { - public class PineapplePet : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pineapple"); - Tooltip.SetDefault("Summons a pineapple"); - } + public class PineapplePet : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pineapple"); + Tooltip.SetDefault("Summons a pineapple"); + } - public override void SetDefaults() - { - item.damage = 0; - item.useTime = item.useAnimation = 20; - item.shoot = ModContent.ProjectileType(); - item.buffType = ModContent.BuffType(); + public override void SetDefaults() + { + item.damage = 0; + item.useTime = item.useAnimation = 20; + item.shoot = ModContent.ProjectileType(); + item.buffType = ModContent.BuffType(); - item.width = 32; - item.height = 34; - item.useStyle = ItemUseStyleID.SwingThrow; - item.noMelee = true; - item.UseSound = SoundID.Item2; + item.width = 32; + item.height = 34; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.UseSound = SoundID.Item2; - item.value = Item.buyPrice(gold: 4); - item.rare = ItemRarityID.Orange; - item.Calamity().donorItem = true; - } + item.value = Item.buyPrice(gold: 4); + item.rare = ItemRarityID.Orange; + item.Calamity().donorItem = true; + } - public override void UseStyle(Player player) - { - if (player.whoAmI == Main.myPlayer && player.itemTime == 0) - { - player.AddBuff(item.buffType, 3600, true); - } - } - } + public override void UseStyle(Player player) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(item.buffType, 3600, true); + } + } + } } diff --git a/Items/Pets/RotomRemote.cs b/Items/Pets/RotomRemote.cs index 92db953f88..5b65ee46f9 100644 --- a/Items/Pets/RotomRemote.cs +++ b/Items/Pets/RotomRemote.cs @@ -10,56 +10,56 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Pets { - public class RotomRemote : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Triboluminescent Etomer"); - Tooltip.SetDefault("Summons an electric troublemaker\n" + - "A little note is attached:\n" + - "Thank you, Aloe! Very much appreciated from Ben"); - } + public class RotomRemote : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Triboluminescent Etomer"); + Tooltip.SetDefault("Summons an electric troublemaker\n" + + "A little note is attached:\n" + + "Thank you, Aloe! Very much appreciated from Ben"); + } - public override void SetDefaults() - { - item.damage = 0; - item.useTime = item.useAnimation = 20; - item.shoot = ModContent.ProjectileType(); - item.buffType = ModContent.BuffType(); + public override void SetDefaults() + { + item.damage = 0; + item.useTime = item.useAnimation = 20; + item.shoot = ModContent.ProjectileType(); + item.buffType = ModContent.BuffType(); - item.width = 30; - item.height = 34; - item.useStyle = ItemUseStyleID.SwingThrow; - item.noMelee = true; - item.UseSound = SoundID.Item113; + item.width = 30; + item.height = 34; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.UseSound = SoundID.Item113; - item.value = Item.buyPrice(gold: 4); - item.rare = ItemRarityID.Orange; - item.Calamity().devItem = true; - } + item.value = Item.buyPrice(gold: 4); + item.rare = ItemRarityID.Orange; + item.Calamity().devItem = true; + } - public override void UseStyle(Player player) - { - if (player.whoAmI == Main.myPlayer && player.itemTime == 0) - { - player.AddBuff(item.buffType, 3600, true); - } - } + public override void UseStyle(Player player) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(item.buffType, 3600, true); + } + } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Pets/RotomRemoteGlow")); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Pets/RotomRemoteGlow")); + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddRecipeGroup("AnyGoldBar", 8); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddRecipeGroup("AnyGoldBar", 8); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Pets/RottingEyeball.cs b/Items/Pets/RottingEyeball.cs index 0e6955b1a9..9632cefddb 100644 --- a/Items/Pets/RottingEyeball.cs +++ b/Items/Pets/RottingEyeball.cs @@ -6,37 +6,37 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Pets { - public class RottingEyeball : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Rotting Eyeball"); - Tooltip.SetDefault("Summons a corrupted conglomeration"); - } + public class RottingEyeball : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rotting Eyeball"); + Tooltip.SetDefault("Summons a corrupted conglomeration"); + } - public override void SetDefaults() - { - /*item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); - item.rare = -13;*/ - item.value = Item.buyPrice(0, 4, 0, 0); - item.damage = 0; - item.useTime = item.useAnimation = 20; - item.useStyle = 1; - item.noMelee = true; - item.width = 16; - item.height = 30; - item.UseSound = SoundID.NPCHit2; - item.rare = 3; - item.shoot = ModContent.ProjectileType(); - item.buffType = ModContent.BuffType(); - } + public override void SetDefaults() + { + /*item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); + item.rare = -13;*/ + item.value = Item.buyPrice(0, 4, 0, 0); + item.damage = 0; + item.useTime = item.useAnimation = 20; + item.useStyle = 1; + item.noMelee = true; + item.width = 16; + item.height = 30; + item.UseSound = SoundID.NPCHit2; + item.rare = 3; + item.shoot = ModContent.ProjectileType(); + item.buffType = ModContent.BuffType(); + } - public override void UseStyle(Player player) - { - if (player.whoAmI == Main.myPlayer && player.itemTime == 0) - { - player.AddBuff(item.buffType, 3600, true); - } - } - } + public override void UseStyle(Player player) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(item.buffType, 3600, true); + } + } + } } diff --git a/Items/Placeables/AstralFossil.cs b/Items/Placeables/AstralFossil.cs index a16bb08606..aba66f1ec7 100644 --- a/Items/Placeables/AstralFossil.cs +++ b/Items/Placeables/AstralFossil.cs @@ -41,18 +41,18 @@ namespace CalamityMod.Items.Placeables public override void ExtractinatorUse(ref int resultType, ref int resultStack) { - /* + /* Celestial remains will give stardust, fallen stars, ancient bone dust, gems and HM ores always by default When Astrum Deus has been defeated, it will give Astral Ore */ - bool twoMechsDowned = - (NPC.downedMechBoss1 && NPC.downedMechBoss2 && !NPC.downedMechBoss3) || - (NPC.downedMechBoss2 && NPC.downedMechBoss3 && !NPC.downedMechBoss1) || - (NPC.downedMechBoss3 && NPC.downedMechBoss1 && !NPC.downedMechBoss2) || - (NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3); + bool twoMechsDowned = + (NPC.downedMechBoss1 && NPC.downedMechBoss2 && !NPC.downedMechBoss3) || + (NPC.downedMechBoss2 && NPC.downedMechBoss3 && !NPC.downedMechBoss1) || + (NPC.downedMechBoss3 && NPC.downedMechBoss1 && !NPC.downedMechBoss2) || + (NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3); - float val = Main.rand.NextFloat(100); + float val = Main.rand.NextFloat(100); if (val < 20f) { resultType = ItemID.CopperCoin; diff --git a/Items/Placeables/AstralSand.cs b/Items/Placeables/AstralSand.cs index c7cea90d4f..8ee7e654df 100644 --- a/Items/Placeables/AstralSand.cs +++ b/Items/Placeables/AstralSand.cs @@ -20,13 +20,13 @@ namespace CalamityMod.Items.Placeables // item.notAmmo = true; // item.shootSpeed = 15f; item.useStyle = ItemUseStyleID.SwingThrow; - item.useTurn = true; - item.useAnimation = 15; - item.useTime = 10; - item.autoReuse = true; - item.consumable = true; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; item.createTile = ModContent.TileType(); - item.noMelee = true; + item.noMelee = true; } } } diff --git a/Items/Placeables/AstralSilt.cs b/Items/Placeables/AstralSilt.cs index b50a00e6ea..807dfcd11d 100644 --- a/Items/Placeables/AstralSilt.cs +++ b/Items/Placeables/AstralSilt.cs @@ -29,18 +29,18 @@ namespace CalamityMod.Items.Placeables } public override void ExtractinatorUse(ref int resultType, ref int resultStack) { - /* + /* Novae slag will give stardust, fallen stars, gems and HM ores always by default When Astrum Deus has been defeated, it will give Astral Ore */ - bool twoMechsDowned = - (NPC.downedMechBoss1 && NPC.downedMechBoss2 && !NPC.downedMechBoss3) || - (NPC.downedMechBoss2 && NPC.downedMechBoss3 && !NPC.downedMechBoss1) || - (NPC.downedMechBoss3 && NPC.downedMechBoss1 && !NPC.downedMechBoss2) || - (NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3); + bool twoMechsDowned = + (NPC.downedMechBoss1 && NPC.downedMechBoss2 && !NPC.downedMechBoss3) || + (NPC.downedMechBoss2 && NPC.downedMechBoss3 && !NPC.downedMechBoss1) || + (NPC.downedMechBoss3 && NPC.downedMechBoss1 && !NPC.downedMechBoss2) || + (NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3); - float val = Main.rand.NextFloat(100); + float val = Main.rand.NextFloat(100); if (val < 30f) { resultType = ItemID.CopperCoin; @@ -119,17 +119,17 @@ namespace CalamityMod.Items.Placeables else if (val < 83.03f) { resultType = CalamityConfig.Instance.EarlyHardmodeProgressionRework ? (!NPC.downedMechBossAny ? ItemID.CobaltOre : ItemID.MythrilOre) : ItemID.MythrilOre; - resultStack = Main.rand.Next(1, 17); + resultStack = Main.rand.Next(1, 17); } else if (val < 85.03f) { resultType = CalamityConfig.Instance.EarlyHardmodeProgressionRework ? (!NPC.downedMechBossAny ? ItemID.PalladiumOre : ItemID.OrichalcumOre) : ItemID.OrichalcumOre; - resultStack = Main.rand.Next(1, 17); + resultStack = Main.rand.Next(1, 17); } else if (val < 86.78f) { resultType = CalamityConfig.Instance.EarlyHardmodeProgressionRework ? (!NPC.downedMechBossAny ? ItemID.CobaltOre : !twoMechsDowned ? ItemID.MythrilOre : ItemID.AdamantiteOre) : ItemID.AdamantiteOre; - resultStack = Main.rand.Next(1, 17); + resultStack = Main.rand.Next(1, 17); } else if (val < 88.53f) { diff --git a/Items/Placeables/Banners/FlakBabyBanner.cs b/Items/Placeables/Banners/FlakBabyBanner.cs index 2ac17b460b..e3c0329f20 100644 --- a/Items/Placeables/Banners/FlakBabyBanner.cs +++ b/Items/Placeables/Banners/FlakBabyBanner.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Placeables.Banners { public override void SetStaticDefaults() { - DisplayName.SetDefault("Baby Flak Crab Banner"); + DisplayName.SetDefault("Baby Flak Crab Banner"); Tooltip.SetDefault("{$CommonItemTooltip.BannerBonus}Baby Flak Crab"); } diff --git a/Items/Placeables/Banners/GhostBellSmallBanner.cs b/Items/Placeables/Banners/GhostBellSmallBanner.cs index f9f3409259..be8aa2c057 100644 --- a/Items/Placeables/Banners/GhostBellSmallBanner.cs +++ b/Items/Placeables/Banners/GhostBellSmallBanner.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Placeables.Banners { public override void SetStaticDefaults() { - DisplayName.SetDefault("Baby Ghost Bell Banner"); + DisplayName.SetDefault("Baby Ghost Bell Banner"); Tooltip.SetDefault("{$CommonItemTooltip.BannerBonus}Baby Ghost Bell"); } diff --git a/Items/Placeables/Banners/PrismTurtleBanner.cs b/Items/Placeables/Banners/PrismTurtleBanner.cs index e67509ea71..5bccc2a9f7 100644 --- a/Items/Placeables/Banners/PrismTurtleBanner.cs +++ b/Items/Placeables/Banners/PrismTurtleBanner.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Items.Placeables.Banners { public override void SetStaticDefaults() { - DisplayName.SetDefault("Prism-Back Banner"); + DisplayName.SetDefault("Prism-Back Banner"); Tooltip.SetDefault("{$CommonItemTooltip.BannerBonus}Prism-Back"); } diff --git a/Items/Placeables/Banners/SulfurousSkaterBanner.cs b/Items/Placeables/Banners/SulfurousSkaterBanner.cs index a37ac96fca..6042436633 100644 --- a/Items/Placeables/Banners/SulfurousSkaterBanner.cs +++ b/Items/Placeables/Banners/SulfurousSkaterBanner.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Items.Placeables.Banners { public override void SetStaticDefaults() { - DisplayName.SetDefault("Sulphurous Skater Banner"); + DisplayName.SetDefault("Sulphurous Skater Banner"); Tooltip.SetDefault("{$CommonItemTooltip.BannerBonus}Sulphurous Skater"); } diff --git a/Items/Placeables/EutrophicSand.cs b/Items/Placeables/EutrophicSand.cs index 7c2c95d0b1..ee38234b3a 100644 --- a/Items/Placeables/EutrophicSand.cs +++ b/Items/Placeables/EutrophicSand.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Placeables recipe.AddTile(TileID.WorkBenches); recipe.SetResult(this); recipe.AddRecipe(); - recipe = new ModRecipe(mod); + recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 4); recipe.AddTile(TileID.WorkBenches); recipe.SetResult(this); diff --git a/Items/Placeables/Furniture/AstralBeaconItem.cs b/Items/Placeables/Furniture/AstralBeaconItem.cs index f11c13b919..241c5d33c0 100644 --- a/Items/Placeables/Furniture/AstralBeaconItem.cs +++ b/Items/Placeables/Furniture/AstralBeaconItem.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture { - public class AstralBeaconItem : ModItem + public class AstralBeaconItem : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/Furniture/BabyFlakHermitCage.cs b/Items/Placeables/Furniture/BabyFlakHermitCage.cs index c2d3a2e74f..810f62463e 100644 --- a/Items/Placeables/Furniture/BabyFlakHermitCage.cs +++ b/Items/Placeables/Furniture/BabyFlakHermitCage.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture { - public class BabyFlakHermitCage : ModItem + public class BabyFlakHermitCage : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/Furniture/BabyGhostBellJar.cs b/Items/Placeables/Furniture/BabyGhostBellJar.cs index bc1c7e26f8..0f18113a4a 100644 --- a/Items/Placeables/Furniture/BabyGhostBellJar.cs +++ b/Items/Placeables/Furniture/BabyGhostBellJar.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture { - public class BabyGhostBellJar : ModItem + public class BabyGhostBellJar : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/Furniture/CraftingStations/StaticRefiner.cs b/Items/Placeables/Furniture/CraftingStations/StaticRefiner.cs index 66512422f3..3dbbe9a346 100644 --- a/Items/Placeables/Furniture/CraftingStations/StaticRefiner.cs +++ b/Items/Placeables/Furniture/CraftingStations/StaticRefiner.cs @@ -3,7 +3,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture.CraftingStations { - public class StaticRefiner : ModItem + public class StaticRefiner : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/Furniture/SeaMinnowJar.cs b/Items/Placeables/Furniture/SeaMinnowJar.cs index 75c7243f49..42fcf92d32 100644 --- a/Items/Placeables/Furniture/SeaMinnowJar.cs +++ b/Items/Placeables/Furniture/SeaMinnowJar.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture { - public class SeaMinnowJar : ModItem + public class SeaMinnowJar : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/Furniture/ThaumaticChair.cs b/Items/Placeables/Furniture/ThaumaticChair.cs index 132c38822d..b76a409f38 100644 --- a/Items/Placeables/Furniture/ThaumaticChair.cs +++ b/Items/Placeables/Furniture/ThaumaticChair.cs @@ -19,12 +19,12 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture { - public class ThaumaticChair : ModItem + public class ThaumaticChair : ModItem { public override void SetStaticDefaults() { - DisplayName.SetDefault("Thaumatic Chair"); // for Deallly#3625 who apparently deleted their account. how do I contact them?????? - Tooltip.SetDefault("One of Chloe's finest creations"); // who is Chloe? + DisplayName.SetDefault("Thaumatic Chair"); // for Deallly#3625 who apparently deleted their account. how do I contact them?????? + Tooltip.SetDefault("One of Chloe's finest creations"); // who is Chloe? } public override void SetDefaults() @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Placeables.Furniture item.consumable = true; item.createTile = ModContent.TileType(); item.Calamity().customRarity = CalamityRarity.Violet; - item.Calamity().donorItem = true; + item.Calamity().donorItem = true; } public override void AddRecipes() diff --git a/Items/Placeables/Furniture/TranquilityCandle.cs b/Items/Placeables/Furniture/TranquilityCandle.cs index ead77f5fc0..abd1eb4ff8 100644 --- a/Items/Placeables/Furniture/TranquilityCandle.cs +++ b/Items/Placeables/Furniture/TranquilityCandle.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Placeables.Furniture public override void HoldItem(Player player) { - player.Calamity().tranquilityCandle = true; + player.Calamity().tranquilityCandle = true; if (Main.rand.Next(player.itemAnimation > 0 ? 10 : 20) == 0) { Dust.NewDust(new Vector2(player.itemLocation.X + 10f * player.direction, player.itemLocation.Y - 12f * player.gravDir), 4, 4, 62); @@ -59,8 +59,8 @@ namespace CalamityMod.Items.Placeables.Furniture ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.PeaceCandle, 3); recipe.AddIngredient(ItemID.SoulofLight, 3); - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType()); recipe.SetResult(this); recipe.AddTile(TileID.WorkBenches); recipe.AddRecipe(); diff --git a/Items/Placeables/Furniture/TwinklerInABottle.cs b/Items/Placeables/Furniture/TwinklerInABottle.cs index 0e87a4155e..2cba65fb3b 100644 --- a/Items/Placeables/Furniture/TwinklerInABottle.cs +++ b/Items/Placeables/Furniture/TwinklerInABottle.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture { - public class TwinklerInABottle : ModItem + public class TwinklerInABottle : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureAbyss/AbyssTorch.cs b/Items/Placeables/FurnitureAbyss/AbyssTorch.cs index bbe515f6e7..912e141407 100644 --- a/Items/Placeables/FurnitureAbyss/AbyssTorch.cs +++ b/Items/Placeables/FurnitureAbyss/AbyssTorch.cs @@ -46,10 +46,10 @@ namespace CalamityMod.Items.Placeables.FurnitureAbyss Lighting.AddLight((int)((item.position.X + item.width / 2) / 16f), (int)((item.position.Y + item.height / 2) / 16f), 1f, 1f, 1f); } - public override void AutoLightSelect(ref bool dryTorch, ref bool wetTorch, ref bool glowstick) - { - wetTorch = true; - } + public override void AutoLightSelect(ref bool dryTorch, ref bool wetTorch, ref bool glowstick) + { + wetTorch = true; + } public override void AddRecipes() { diff --git a/Items/Placeables/FurnitureCosmilite/CosmiliteBasin.cs b/Items/Placeables/FurnitureCosmilite/CosmiliteBasin.cs index 2dc03b99d4..b042032cbc 100644 --- a/Items/Placeables/FurnitureCosmilite/CosmiliteBasin.cs +++ b/Items/Placeables/FurnitureCosmilite/CosmiliteBasin.cs @@ -5,28 +5,28 @@ using CalamityMod.Tiles.Furniture.CraftingStations; namespace CalamityMod.Items.Placeables.FurnitureCosmilite { - public class CosmiliteBasin : ModItem - { - public override void SetStaticDefaults() - { + public class CosmiliteBasin : ModItem + { + public override void SetStaticDefaults() + { DisplayName.SetDefault("Cosmilite Basin"); - } + } - public override void SetDefaults() - { - item.width = 8; - item.height = 10; - item.maxStack = 999; - item.useTurn = true; - item.autoReuse = true; - item.useAnimation = 15; - item.useTime = 10; - item.useStyle = ItemUseStyleID.SwingThrow; - item.consumable = true; - item.createTile = ModContent.TileType(); - } + public override void SetDefaults() + { + item.width = 8; + item.height = 10; + item.maxStack = 999; + item.useTurn = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useTime = 10; + item.useStyle = ItemUseStyleID.SwingThrow; + item.consumable = true; + item.createTile = ModContent.TileType(); + } - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 10); @@ -36,5 +36,5 @@ namespace CalamityMod.Items.Placeables.FurnitureCosmilite recipe.AddTile(ModContent.TileType()); recipe.AddRecipe(); } - } + } } \ No newline at end of file diff --git a/Items/Placeables/FurnitureOccult/OccultBathtub.cs b/Items/Placeables/FurnitureOccult/OccultBathtub.cs index b593e18334..42b3460998 100644 --- a/Items/Placeables/FurnitureOccult/OccultBathtub.cs +++ b/Items/Placeables/FurnitureOccult/OccultBathtub.cs @@ -2,7 +2,7 @@ using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultBathtub : ModItem + public class OccultBathtub : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultBed.cs b/Items/Placeables/FurnitureOccult/OccultBed.cs index 720f76eed7..f911a8ef9c 100644 --- a/Items/Placeables/FurnitureOccult/OccultBed.cs +++ b/Items/Placeables/FurnitureOccult/OccultBed.cs @@ -2,7 +2,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultBed : ModItem + public class OccultBed : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultBookcase.cs b/Items/Placeables/FurnitureOccult/OccultBookcase.cs index 2f3b539535..a60631c54c 100644 --- a/Items/Placeables/FurnitureOccult/OccultBookcase.cs +++ b/Items/Placeables/FurnitureOccult/OccultBookcase.cs @@ -2,7 +2,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultBookcase : ModItem + public class OccultBookcase : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultCandelabra.cs b/Items/Placeables/FurnitureOccult/OccultCandelabra.cs index 84261e7920..cd5fdeafdd 100644 --- a/Items/Placeables/FurnitureOccult/OccultCandelabra.cs +++ b/Items/Placeables/FurnitureOccult/OccultCandelabra.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultCandelabra : ModItem + public class OccultCandelabra : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultCandle.cs b/Items/Placeables/FurnitureOccult/OccultCandle.cs index fde1177ce2..097b587dc2 100644 --- a/Items/Placeables/FurnitureOccult/OccultCandle.cs +++ b/Items/Placeables/FurnitureOccult/OccultCandle.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultCandle : ModItem + public class OccultCandle : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultChair.cs b/Items/Placeables/FurnitureOccult/OccultChair.cs index 78f8e3a276..c266c51739 100644 --- a/Items/Placeables/FurnitureOccult/OccultChair.cs +++ b/Items/Placeables/FurnitureOccult/OccultChair.cs @@ -2,7 +2,7 @@ using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultChair : ModItem + public class OccultChair : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultChandelier.cs b/Items/Placeables/FurnitureOccult/OccultChandelier.cs index 0ec527fd4f..ec3e568ab1 100644 --- a/Items/Placeables/FurnitureOccult/OccultChandelier.cs +++ b/Items/Placeables/FurnitureOccult/OccultChandelier.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultChandelier : ModItem + public class OccultChandelier : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultChest.cs b/Items/Placeables/FurnitureOccult/OccultChest.cs index 52d06e0014..9df2f9375d 100644 --- a/Items/Placeables/FurnitureOccult/OccultChest.cs +++ b/Items/Placeables/FurnitureOccult/OccultChest.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultChest : ModItem + public class OccultChest : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultClock.cs b/Items/Placeables/FurnitureOccult/OccultClock.cs index a276af79a3..80552c398d 100644 --- a/Items/Placeables/FurnitureOccult/OccultClock.cs +++ b/Items/Placeables/FurnitureOccult/OccultClock.cs @@ -3,7 +3,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultClock : ModItem + public class OccultClock : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultDoor.cs b/Items/Placeables/FurnitureOccult/OccultDoor.cs index 1ab5225897..2422810188 100644 --- a/Items/Placeables/FurnitureOccult/OccultDoor.cs +++ b/Items/Placeables/FurnitureOccult/OccultDoor.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultDoor : ModItem + public class OccultDoor : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultDresser.cs b/Items/Placeables/FurnitureOccult/OccultDresser.cs index 53c7988bf1..19c7a2bacd 100644 --- a/Items/Placeables/FurnitureOccult/OccultDresser.cs +++ b/Items/Placeables/FurnitureOccult/OccultDresser.cs @@ -2,7 +2,7 @@ using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultDresser : ModItem + public class OccultDresser : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultLamp.cs b/Items/Placeables/FurnitureOccult/OccultLamp.cs index 12d1994dc0..79159d3ac6 100644 --- a/Items/Placeables/FurnitureOccult/OccultLamp.cs +++ b/Items/Placeables/FurnitureOccult/OccultLamp.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultLamp : ModItem + public class OccultLamp : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultLantern.cs b/Items/Placeables/FurnitureOccult/OccultLantern.cs index b767560386..da19d118ab 100644 --- a/Items/Placeables/FurnitureOccult/OccultLantern.cs +++ b/Items/Placeables/FurnitureOccult/OccultLantern.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultLantern : ModItem + public class OccultLantern : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultPiano.cs b/Items/Placeables/FurnitureOccult/OccultPiano.cs index f81d4d0de2..3d868f0094 100644 --- a/Items/Placeables/FurnitureOccult/OccultPiano.cs +++ b/Items/Placeables/FurnitureOccult/OccultPiano.cs @@ -2,7 +2,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultPiano : ModItem + public class OccultPiano : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultPlatform.cs b/Items/Placeables/FurnitureOccult/OccultPlatform.cs index 4e25c9874f..e8f471fcb5 100644 --- a/Items/Placeables/FurnitureOccult/OccultPlatform.cs +++ b/Items/Placeables/FurnitureOccult/OccultPlatform.cs @@ -2,7 +2,7 @@ using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultPlatform : ModItem + public class OccultPlatform : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultSink.cs b/Items/Placeables/FurnitureOccult/OccultSink.cs index d2dd749a42..1b2fb0fc01 100644 --- a/Items/Placeables/FurnitureOccult/OccultSink.cs +++ b/Items/Placeables/FurnitureOccult/OccultSink.cs @@ -2,7 +2,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultSink : ModItem + public class OccultSink : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultSofa.cs b/Items/Placeables/FurnitureOccult/OccultSofa.cs index 18a6d28b9a..65167e7293 100644 --- a/Items/Placeables/FurnitureOccult/OccultSofa.cs +++ b/Items/Placeables/FurnitureOccult/OccultSofa.cs @@ -2,7 +2,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultSofa : ModItem + public class OccultSofa : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultTable.cs b/Items/Placeables/FurnitureOccult/OccultTable.cs index 830c19a807..7ae0a18269 100644 --- a/Items/Placeables/FurnitureOccult/OccultTable.cs +++ b/Items/Placeables/FurnitureOccult/OccultTable.cs @@ -2,7 +2,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultTable : ModItem + public class OccultTable : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureOccult/OccultWorkBench.cs b/Items/Placeables/FurnitureOccult/OccultWorkBench.cs index a92af709b3..27ea99ef90 100644 --- a/Items/Placeables/FurnitureOccult/OccultWorkBench.cs +++ b/Items/Placeables/FurnitureOccult/OccultWorkBench.cs @@ -2,7 +2,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureOccult { - public class OccultWorkBench : ModItem + public class OccultWorkBench : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/FurnitureStratus/StratusBricks.cs b/Items/Placeables/FurnitureStratus/StratusBricks.cs index ccdb41dd75..0bf021d1b2 100644 --- a/Items/Placeables/FurnitureStratus/StratusBricks.cs +++ b/Items/Placeables/FurnitureStratus/StratusBricks.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus { public override void SetStaticDefaults() { - DisplayName.SetDefault("Stratus Brick"); + DisplayName.SetDefault("Stratus Brick"); } public override void SetDefaults() diff --git a/Items/Placeables/LivingFire/LivingBrimstoneFireBlock.cs b/Items/Placeables/LivingFire/LivingBrimstoneFireBlock.cs index 74de282172..ddbaeba912 100644 --- a/Items/Placeables/LivingFire/LivingBrimstoneFireBlock.cs +++ b/Items/Placeables/LivingFire/LivingBrimstoneFireBlock.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.LivingFire { - public class LivingBrimstoneFireBlock : ModItem + public class LivingBrimstoneFireBlock : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/LivingFire/LivingGodSlayerFireBlock.cs b/Items/Placeables/LivingFire/LivingGodSlayerFireBlock.cs index 7d726351e8..c5f042cdb9 100644 --- a/Items/Placeables/LivingFire/LivingGodSlayerFireBlock.cs +++ b/Items/Placeables/LivingFire/LivingGodSlayerFireBlock.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.LivingFire { - public class LivingGodSlayerFireBlock : ModItem + public class LivingGodSlayerFireBlock : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/LivingFire/LivingHolyFireBlock.cs b/Items/Placeables/LivingFire/LivingHolyFireBlock.cs index 09a9064b41..a7049a8776 100644 --- a/Items/Placeables/LivingFire/LivingHolyFireBlock.cs +++ b/Items/Placeables/LivingFire/LivingHolyFireBlock.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.LivingFire { - public class LivingHolyFireBlock : ModItem + public class LivingHolyFireBlock : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Placeables/Navystone.cs b/Items/Placeables/Navystone.cs index f23e8440eb..21ec60bf42 100644 --- a/Items/Placeables/Navystone.cs +++ b/Items/Placeables/Navystone.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Placeables recipe.AddTile(TileID.WorkBenches); recipe.SetResult(this); recipe.AddRecipe(); - recipe = new ModRecipe(mod); + recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 4); recipe.AddTile(TileID.WorkBenches); recipe.SetResult(this); diff --git a/Items/Placeables/PlantyMush.cs b/Items/Placeables/PlantyMush.cs index b9c09fdcee..e7964f1b60 100644 --- a/Items/Placeables/PlantyMush.cs +++ b/Items/Placeables/PlantyMush.cs @@ -27,9 +27,9 @@ namespace CalamityMod.Items.Placeables item.rare = ItemRarityID.Orange; } - public override void CaughtFishStack(ref int stack) - { - stack = Main.rand.Next(5,16); - } + public override void CaughtFishStack(ref int stack) + { + stack = Main.rand.Next(5,16); + } } } diff --git a/Items/Potions/Alcohol/FabsolsVodka.cs b/Items/Potions/Alcohol/FabsolsVodka.cs index 7c50c75795..8a288a5818 100644 --- a/Items/Potions/Alcohol/FabsolsVodka.cs +++ b/Items/Potions/Alcohol/FabsolsVodka.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Potions.Alcohol DisplayName.SetDefault("Fabsol's Vodka"); Tooltip.SetDefault("Boosts all damage stats by 8% but lowers defense by 10%\n" + "Increases immune time after being struck\n" + - "This magical liquor is highly sought by those with a refined palate"); + "This magical liquor is highly sought by those with a refined palate"); } public override void SetDefaults() diff --git a/Items/Potions/Alcohol/GrapeBeer.cs b/Items/Potions/Alcohol/GrapeBeer.cs index 8ff803402b..76f64046df 100644 --- a/Items/Potions/Alcohol/GrapeBeer.cs +++ b/Items/Potions/Alcohol/GrapeBeer.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Potions.Alcohol { - public class GrapeBeer : ModItem + public class GrapeBeer : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Potions/Alcohol/Margarita.cs b/Items/Potions/Alcohol/Margarita.cs index 46ffa94eef..3a42797009 100644 --- a/Items/Potions/Alcohol/Margarita.cs +++ b/Items/Potions/Alcohol/Margarita.cs @@ -5,10 +5,10 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Potions.Alcohol { - public class Margarita : ModItem + public class Margarita : ModItem { - public static int BuffType = ModContent.BuffType(); - public static int BuffDuration = 10800; + public static int BuffType = ModContent.BuffType(); + public static int BuffDuration = 10800; public override void SetStaticDefaults() { diff --git a/Items/Potions/Alcohol/RedWine.cs b/Items/Potions/Alcohol/RedWine.cs index 0744e225ef..8630bccb2e 100644 --- a/Items/Potions/Alcohol/RedWine.cs +++ b/Items/Potions/Alcohol/RedWine.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Potions.Alcohol { - public class RedWine : ModItem + public class RedWine : ModItem { public override void SetStaticDefaults() { @@ -33,7 +33,7 @@ Reduces life regen by 1"); public override bool CanUseItem(Player player) { - item.healLife = player.Calamity().baguette ? 250 : 200; + item.healLife = player.Calamity().baguette ? 250 : 200; return base.CanUseItem(player); } diff --git a/Items/Potions/Alcohol/WhiteWine.cs b/Items/Potions/Alcohol/WhiteWine.cs index a5ec69cdce..115a68b157 100644 --- a/Items/Potions/Alcohol/WhiteWine.cs +++ b/Items/Potions/Alcohol/WhiteWine.cs @@ -34,23 +34,23 @@ Reduces defense by 6% and life regen by 1"); item.value = Item.buyPrice(0, 4, 0, 0); } - public override bool UseItem(Player player) - { - if (PlayerInput.Triggers.JustPressed.QuickBuff) - { - player.statMana += item.healMana; - if (player.statMana > player.statManaMax2) - { - player.statMana = player.statManaMax2; - } - player.AddBuff(BuffID.ManaSickness, Player.manaSickTime, true); - if (Main.myPlayer == player.whoAmI) - { - player.ManaEffect(item.healMana); - } - } + public override bool UseItem(Player player) + { + if (PlayerInput.Triggers.JustPressed.QuickBuff) + { + player.statMana += item.healMana; + if (player.statMana > player.statManaMax2) + { + player.statMana = player.statManaMax2; + } + player.AddBuff(BuffID.ManaSickness, Player.manaSickTime, true); + if (Main.myPlayer == player.whoAmI) + { + player.ManaEffect(item.healMana); + } + } player.AddBuff(item.buffType, item.buffTime); - return true; - } + return true; + } } } diff --git a/Items/Potions/AstralInjection.cs b/Items/Potions/AstralInjection.cs index 8a7c428163..3b10f5ab58 100644 --- a/Items/Potions/AstralInjection.cs +++ b/Items/Potions/AstralInjection.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Items.Potions recipe.AddTile(TileID.AlchemyTable); recipe.SetResult(this, 4); recipe.AddRecipe(); - // Blood orb recipes don't get the alchemy table effect + // Blood orb recipes don't get the alchemy table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater, 4); recipe.AddIngredient(ModContent.ItemType(), 5); diff --git a/Items/Potions/AstralJelly.cs b/Items/Potions/AstralJelly.cs index 6ecf79c388..17b55bc7a5 100644 --- a/Items/Potions/AstralJelly.cs +++ b/Items/Potions/AstralJelly.cs @@ -31,24 +31,24 @@ namespace CalamityMod.Items.Potions item.buffTime = CalamityUtils.SecondsToFrames(360f); } - public override bool UseItem(Player player) - { - if (PlayerInput.Triggers.JustPressed.QuickBuff) - { - player.statMana += item.healMana; - if (player.statMana > player.statManaMax2) - { - player.statMana = player.statManaMax2; - } - player.AddBuff(BuffID.ManaSickness, Player.manaSickTime, true); - if (Main.myPlayer == player.whoAmI) - { - player.ManaEffect(item.healMana); - } - } + public override bool UseItem(Player player) + { + if (PlayerInput.Triggers.JustPressed.QuickBuff) + { + player.statMana += item.healMana; + if (player.statMana > player.statManaMax2) + { + player.statMana = player.statManaMax2; + } + player.AddBuff(BuffID.ManaSickness, Player.manaSickTime, true); + if (Main.myPlayer == player.whoAmI) + { + player.ManaEffect(item.healMana); + } + } player.AddBuff(BuffID.MagicPower, item.buffTime); player.AddBuff(BuffID.ManaRegeneration, item.buffTime); - return true; - } + return true; + } } } diff --git a/Items/Potions/CeaselessHungerPotion.cs b/Items/Potions/CeaselessHungerPotion.cs index e824ec8a04..eceb1fd13b 100644 --- a/Items/Potions/CeaselessHungerPotion.cs +++ b/Items/Potions/CeaselessHungerPotion.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this, 4); recipe.AddRecipe(); - // Blood orb recipes don't get the Alchemy table effect + // Blood orb recipes don't get the Alchemy table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater, 4); recipe.AddIngredient(ModContent.ItemType(), 20); diff --git a/Items/Potions/CrumblingPotion.cs b/Items/Potions/CrumblingPotion.cs index 7cf3a82ba1..7aed85d396 100644 --- a/Items/Potions/CrumblingPotion.cs +++ b/Items/Potions/CrumblingPotion.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this, 5); recipe.AddRecipe(); - // Blood Orb recipes don't get the Alchemy Table effect + // Blood Orb recipes don't get the Alchemy Table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 20); diff --git a/Items/Potions/GravityNormalizerPotion.cs b/Items/Potions/GravityNormalizerPotion.cs index 2157fc87e4..2d6e15e32a 100644 --- a/Items/Potions/GravityNormalizerPotion.cs +++ b/Items/Potions/GravityNormalizerPotion.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this); recipe.AddRecipe(); - // Blood orb recipes don't get the Alchemy Table effect + // Blood orb recipes don't get the Alchemy Table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 10); diff --git a/Items/Potions/HolyWrathPotion.cs b/Items/Potions/HolyWrathPotion.cs index ddad455ed0..224933323a 100644 --- a/Items/Potions/HolyWrathPotion.cs +++ b/Items/Potions/HolyWrathPotion.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this); recipe.AddRecipe(); - // Blood orb recipes don't get the alchemy table effect + // Blood orb recipes don't get the alchemy table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 40); diff --git a/Items/Potions/PenumbraPotion.cs b/Items/Potions/PenumbraPotion.cs index 267d4dec2c..8f33a27e07 100644 --- a/Items/Potions/PenumbraPotion.cs +++ b/Items/Potions/PenumbraPotion.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this); recipe.AddRecipe(); - // Blood orb recipes don't get the Alchemy Table effect + // Blood orb recipes don't get the Alchemy Table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 30); diff --git a/Items/Potions/PhotosynthesisPotion.cs b/Items/Potions/PhotosynthesisPotion.cs index b6c4addfc9..bd704521b4 100644 --- a/Items/Potions/PhotosynthesisPotion.cs +++ b/Items/Potions/PhotosynthesisPotion.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this); recipe.AddRecipe(); - // Blood orb recipes don't get the alchemy table effect + // Blood orb recipes don't get the alchemy table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 40); diff --git a/Items/Potions/PotionofOmniscience.cs b/Items/Potions/PotionofOmniscience.cs index 15cb46fae3..95a3244c7e 100644 --- a/Items/Potions/PotionofOmniscience.cs +++ b/Items/Potions/PotionofOmniscience.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Potions { DisplayName.SetDefault("Potion of Omniscience"); Tooltip.SetDefault("Highlights nearby creatures, enemy projectiles,\n" + - "danger sources, and treasure"); + "danger sources, and treasure"); } public override void SetDefaults() diff --git a/Items/Potions/ProfanedRagePotion.cs b/Items/Potions/ProfanedRagePotion.cs index e1b9156735..c0aada37fa 100644 --- a/Items/Potions/ProfanedRagePotion.cs +++ b/Items/Potions/ProfanedRagePotion.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this); recipe.AddRecipe(); - // Blood orb recipe = no alchemy table effect + // Blood orb recipe = no alchemy table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 40); diff --git a/Items/Potions/PurifiedJam.cs b/Items/Potions/PurifiedJam.cs index 6605e0d100..681b4919c8 100644 --- a/Items/Potions/PurifiedJam.cs +++ b/Items/Potions/PurifiedJam.cs @@ -35,16 +35,16 @@ namespace CalamityMod.Items.Potions public override void ModifyTooltips(List list) { - if (CalamityWorld.death || BossRushEvent.BossRushActive) - { - foreach (TooltipLine line2 in list) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Makes you immune to all damage and most debuffs for 5 seconds"; - } - } - } + if (CalamityWorld.death || BossRushEvent.BossRushActive) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Makes you immune to all damage and most debuffs for 5 seconds"; + } + } + } } public override bool CanUseItem(Player player) diff --git a/Items/Potions/RevivifyPotion.cs b/Items/Potions/RevivifyPotion.cs index 6518581b46..55ff9260f8 100644 --- a/Items/Potions/RevivifyPotion.cs +++ b/Items/Potions/RevivifyPotion.cs @@ -28,8 +28,8 @@ namespace CalamityMod.Items.Potions item.value = Item.buyPrice(0, 2, 0, 0); item.rare = ItemRarityID.LightRed; item.consumable = true; - item.buffType = ModContent.BuffType(); - item.buffTime = CalamityUtils.SecondsToFrames(180f); + item.buffType = ModContent.BuffType(); + item.buffTime = CalamityUtils.SecondsToFrames(180f); } public override void AddRecipes() @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this, 5); recipe.AddRecipe(); - // Blood orb recipes no alch table effect + // Blood orb recipes no alch table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.HolyWater, 5); recipe.AddIngredient(ModContent.ItemType(), 100); diff --git a/Items/Potions/ShadowPotion.cs b/Items/Potions/ShadowPotion.cs index 992c5d9a3e..00685b6663 100644 --- a/Items/Potions/ShadowPotion.cs +++ b/Items/Potions/ShadowPotion.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Items.Potions { DisplayName.SetDefault("Shadow Potion"); Tooltip.SetDefault("Causes the player to disappear while not attacking\n" + - "Holding different types of rogue weapons give the player boosts\n" + - "Different types of rogue weapons spawn different projectiles on hit\n" + - "Stealth generation is increased by 10%"); + "Holding different types of rogue weapons give the player boosts\n" + + "Different types of rogue weapons spawn different projectiles on hit\n" + + "Stealth generation is increased by 10%"); } public override void SetDefaults() @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this, 2); recipe.AddRecipe(); - // blood orb recipes no alch table effect + // blood orb recipes no alch table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 20); diff --git a/Items/Potions/ShatteringPotion.cs b/Items/Potions/ShatteringPotion.cs index c7ba9fbc12..22ca491545 100644 --- a/Items/Potions/ShatteringPotion.cs +++ b/Items/Potions/ShatteringPotion.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this); recipe.AddRecipe(); - // Blood Orb recipes don't get the alchemy table effect + // Blood Orb recipes don't get the alchemy table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 30); diff --git a/Items/Potions/SoaringPotion.cs b/Items/Potions/SoaringPotion.cs index e5c11d7630..871ea15cc8 100644 --- a/Items/Potions/SoaringPotion.cs +++ b/Items/Potions/SoaringPotion.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.Potions { DisplayName.SetDefault("Soaring Potion"); Tooltip.SetDefault("Increases flight time and horizontal flight speed by 10%\n" + - "Restores a fraction of your wing flight time after a true melee strike\n" + - "The amount of flight time restored scales with your melee stats and weapon swing speed"); + "Restores a fraction of your wing flight time after a true melee strike\n" + + "The amount of flight time restored scales with your melee stats and weapon swing speed"); } public override void SetDefaults() @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this); recipe.AddRecipe(); - // Blood orb recipes don't get the alchemy table effect + // Blood orb recipes don't get the alchemy table effect recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 30); diff --git a/Items/Potions/SunkenStew.cs b/Items/Potions/SunkenStew.cs index 2aced13087..d726e64f8f 100644 --- a/Items/Potions/SunkenStew.cs +++ b/Items/Potions/SunkenStew.cs @@ -7,49 +7,49 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Potions { - public class SunkenStew : ModItem - { - public static int BuffType = BuffID.WellFed; - public static int BuffDuration = 216000; + public class SunkenStew : ModItem + { + public static int BuffType = BuffID.WellFed; + public static int BuffDuration = 216000; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Hadal Stew"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Hadal Stew"); Tooltip.SetDefault("Only gives 50 seconds of Potion Sickness\n" + "Grants Well Fed\n" + "60 minute duration"); - } + } - public override void SetDefaults() - { - item.width = 28; - item.height = 18; - item.useTurn = true; - item.maxStack = 30; - item.useAnimation = 17; - item.useTime = 17; - item.value = Item.buyPrice(0, 2, 0, 0); - item.rare = ItemRarityID.Green; - item.useStyle = ItemUseStyleID.EatingUsing; - item.UseSound = SoundID.Item3; - item.consumable = true; - item.potion = true; - item.healLife = 120; - item.healMana = 150; - } + public override void SetDefaults() + { + item.width = 28; + item.height = 18; + item.useTurn = true; + item.maxStack = 30; + item.useAnimation = 17; + item.useTime = 17; + item.value = Item.buyPrice(0, 2, 0, 0); + item.rare = ItemRarityID.Green; + item.useStyle = ItemUseStyleID.EatingUsing; + item.UseSound = SoundID.Item3; + item.consumable = true; + item.potion = true; + item.healLife = 120; + item.healMana = 150; + } public override void ModifyTooltips(List list) { - if (Main.LocalPlayer.pStone) - { - foreach (TooltipLine line2 in list) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Only gives 37 seconds of Potion Sickness"; - } - } - } + if (Main.LocalPlayer.pStone) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Only gives 37 seconds of Potion Sickness"; + } + } + } } public override bool CanUseItem(Player player) @@ -57,32 +57,32 @@ namespace CalamityMod.Items.Potions return player.potionDelay <= 0 && player.Calamity().potionTimer <= 0; } - public override bool UseItem(Player player) - { + public override bool UseItem(Player player) + { player.AddBuff(BuffType, BuffDuration); - // fixes hardcoded potion sickness duration from quick heal (see CalamityPlayerMiscEffects.cs) - player.Calamity().potionTimer = 2; - return true; - } + // fixes hardcoded potion sickness duration from quick heal (see CalamityPlayerMiscEffects.cs) + player.Calamity().potionTimer = 2; + return true; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.Honeyfin); - recipe.AddIngredient(ItemID.Bowl, 2); - recipe.AddTile(TileID.CookingPots); - recipe.SetResult(this, 2); - recipe.AddRecipe(); - recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.Honeyfin); - recipe.AddIngredient(ItemID.Bowl, 2); - recipe.AddTile(TileID.CookingPots); - recipe.SetResult(this, 2); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.Honeyfin); + recipe.AddIngredient(ItemID.Bowl, 2); + recipe.AddTile(TileID.CookingPots); + recipe.SetResult(this, 2); + recipe.AddRecipe(); + recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.Honeyfin); + recipe.AddIngredient(ItemID.Bowl, 2); + recipe.AddTile(TileID.CookingPots); + recipe.SetResult(this, 2); + recipe.AddRecipe(); + } + } } diff --git a/Items/Potions/SupremeHealingPotion.cs b/Items/Potions/SupremeHealingPotion.cs index fd67792cbf..af35a115f3 100644 --- a/Items/Potions/SupremeHealingPotion.cs +++ b/Items/Potions/SupremeHealingPotion.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Items.Potions item.UseSound = SoundID.Item3; item.consumable = true; item.potion = true; - item.rare = ItemRarityID.Purple; - item.value = Item.buyPrice(0, 6, 50, 0); + item.rare = ItemRarityID.Purple; + item.value = Item.buyPrice(0, 6, 50, 0); } public override void AddRecipes() diff --git a/Items/Potions/SupremeManaPotion.cs b/Items/Potions/SupremeManaPotion.cs index 887953dd45..59b7991aa3 100644 --- a/Items/Potions/SupremeManaPotion.cs +++ b/Items/Potions/SupremeManaPotion.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Items.Potions item.useStyle = ItemUseStyleID.EatingUsing; item.UseSound = SoundID.Item3; item.consumable = true; - item.rare = ItemRarityID.Purple; - item.value = Item.buyPrice(0, 6, 50, 0); + item.rare = ItemRarityID.Purple; + item.value = Item.buyPrice(0, 6, 50, 0); } public override void AddRecipes() diff --git a/Items/Potions/TeslaPotion.cs b/Items/Potions/TeslaPotion.cs index 797fe31de6..0a6eceea06 100644 --- a/Items/Potions/TeslaPotion.cs +++ b/Items/Potions/TeslaPotion.cs @@ -8,49 +8,49 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Potions { - public class TeslaPotion : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tesla Potion"); - Tooltip.SetDefault("Summons an aura of electricity that electrifies and slows enemies\n" + - "Aura damage is reduced on bosses\n" + - "Reduces the duration of the Electrified debuff"); - } + public class TeslaPotion : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tesla Potion"); + Tooltip.SetDefault("Summons an aura of electricity that electrifies and slows enemies\n" + + "Aura damage is reduced on bosses\n" + + "Reduces the duration of the Electrified debuff"); + } - public override void SetDefaults() - { - item.width = 24; - item.height = 26; - item.useTurn = true; - item.maxStack = 30; - item.rare = ItemRarityID.Orange; - item.useAnimation = 17; - item.useTime = 17; - item.useStyle = ItemUseStyleID.EatingUsing; - item.UseSound = SoundID.Item3; - item.consumable = true; - item.buffType = ModContent.BuffType(); - item.buffTime = CalamityUtils.SecondsToFrames(480f); - item.value = Item.buyPrice(0, 2, 0, 0); - } + public override void SetDefaults() + { + item.width = 24; + item.height = 26; + item.useTurn = true; + item.maxStack = 30; + item.rare = ItemRarityID.Orange; + item.useAnimation = 17; + item.useTime = 17; + item.useStyle = ItemUseStyleID.EatingUsing; + item.UseSound = SoundID.Item3; + item.consumable = true; + item.buffType = ModContent.BuffType(); + item.buffTime = CalamityUtils.SecondsToFrames(480f); + item.value = Item.buyPrice(0, 2, 0, 0); + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.BottledWater); - recipe.AddIngredient(ModContent.ItemType(), 2); + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater); + recipe.AddIngredient(ModContent.ItemType(), 2); recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.Bottles); - recipe.SetResult(this, 5); - recipe.AddRecipe(); - recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.BottledWater); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddTile(TileID.AlchemyTable); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.Bottles); + recipe.SetResult(this, 5); + recipe.AddRecipe(); + recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddTile(TileID.AlchemyTable); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Potions/TitanScalePotion.cs b/Items/Potions/TitanScalePotion.cs index 5373b78abe..796eca82b7 100644 --- a/Items/Potions/TitanScalePotion.cs +++ b/Items/Potions/TitanScalePotion.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Potions { DisplayName.SetDefault("Titan Scale Potion"); Tooltip.SetDefault("Increases knockback, defense by 5 and damage reduction by 5%\n" + - "Increases defense by 25 and damage reduction by 10% for a few seconds after a true melee strike"); + "Increases defense by 25 and damage reduction by 10% for a few seconds after a true melee strike"); } public override void SetDefaults() @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Potions recipe.alchemy = true; recipe.SetResult(this, 4); recipe.AddRecipe(); - // Alch table effect not on blood orb recipes + // Alch table effect not on blood orb recipes recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater, 4); recipe.AddIngredient(ModContent.ItemType(), 40); diff --git a/Items/Potions/YharimsStimulants.cs b/Items/Potions/YharimsStimulants.cs index 8daafb66d9..824857815f 100644 --- a/Items/Potions/YharimsStimulants.cs +++ b/Items/Potions/YharimsStimulants.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Potions public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddRecipeGroup("AnyFood"); + recipe.AddRecipeGroup("AnyFood"); recipe.AddIngredient(ItemID.EndurancePotion); recipe.AddIngredient(ItemID.IronskinPotion); recipe.AddIngredient(ItemID.SwiftnessPotion); diff --git a/Items/RelicOfConvergence.cs b/Items/RelicOfConvergence.cs index c4b4556fb7..31fff277d7 100644 --- a/Items/RelicOfConvergence.cs +++ b/Items/RelicOfConvergence.cs @@ -26,9 +26,9 @@ namespace CalamityMod.Items item.noMelee = true; item.noUseGraphic = true; item.channel = true; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.shoot = ModContent.ProjectileType(); } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; diff --git a/Items/SirenproofEarMuffs.cs b/Items/SirenproofEarMuffs.cs index 08d020de02..3ec928eddc 100644 --- a/Items/SirenproofEarMuffs.cs +++ b/Items/SirenproofEarMuffs.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Items public override void UpdateInventory(Player player) { - if (item.favorited) - player.Calamity().disableAnahitaSpawns = true; + if (item.favorited) + player.Calamity().disableAnahitaSpawns = true; } public override void AddRecipes() diff --git a/Items/SummonItems/Abomination.cs b/Items/SummonItems/Abomination.cs index 884ffe950a..008dd5e187 100644 --- a/Items/SummonItems/Abomination.cs +++ b/Items/SummonItems/Abomination.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Abombination"); Tooltip.SetDefault("Calls in the airborne abomination\n" + - "Summons the Plaguebringer Goliath when used in the jungle\n" + + "Summons the Plaguebringer Goliath when used in the jungle\n" + "Not consumable"); } @@ -35,11 +35,11 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { - Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + Main.PlaySound(SoundID.Roar, player.position, 0); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); return true; } diff --git a/Items/SummonItems/AncientMedallion.cs b/Items/SummonItems/AncientMedallion.cs index c0ca016b22..c8227d26bc 100644 --- a/Items/SummonItems/AncientMedallion.cs +++ b/Items/SummonItems/AncientMedallion.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.SummonItems DisplayName.SetDefault("Death Whistle"); Tooltip.SetDefault("A very old temple whistle\n" + "Summons the Ravager\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() @@ -33,17 +33,17 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { - Main.PlaySound(SoundID.Roar, player.position, 2); + Main.PlaySound(SoundID.Roar, player.position, 2); if (Main.netMode != NetmodeID.MultiplayerClient) { int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-250, 251)), (int)(player.position.Y - 500f), ModContent.NPCType(), 1); - Main.npc[npc].timeLeft *= 20; - CalamityUtils.BossAwakenMessage(npc); + Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); } - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/AstralChunk.cs b/Items/SummonItems/AstralChunk.cs index 7bd2d0455e..8eee1f7f57 100644 --- a/Items/SummonItems/AstralChunk.cs +++ b/Items/SummonItems/AstralChunk.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Astral Chunk"); Tooltip.SetDefault("Summons Astrum Aureus when used in the astral infection during nighttime\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() @@ -34,17 +34,17 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { - Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) + Main.PlaySound(SoundID.Roar, player.position, 0); + if (Main.netMode != NetmodeID.MultiplayerClient) { int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-250, 251)), (int)(player.position.Y - 500f), ModContent.NPCType(), 1); - Main.npc[npc].timeLeft *= 20; - CalamityUtils.BossAwakenMessage(npc); + Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); } - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/BirbPheromones.cs b/Items/SummonItems/BirbPheromones.cs index 1b3849bb06..29551e26e4 100644 --- a/Items/SummonItems/BirbPheromones.cs +++ b/Items/SummonItems/BirbPheromones.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Exotic Pheromones"); Tooltip.SetDefault("Attracts the failed draconic experiment\n" + - "Summons The Dragonfolly when used in the jungle\n" + - "Not consumable"); + "Summons The Dragonfolly when used in the jungle\n" + + "Not consumable"); } public override void SetDefaults() @@ -35,11 +35,11 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { - Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + Main.PlaySound(SoundID.Roar, player.position, 0); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); return true; } diff --git a/Items/SummonItems/BlightedEyeball.cs b/Items/SummonItems/BlightedEyeball.cs index e1fe94519f..2439f1272c 100644 --- a/Items/SummonItems/BlightedEyeball.cs +++ b/Items/SummonItems/BlightedEyeball.cs @@ -36,12 +36,12 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/BloodwormItem.cs b/Items/SummonItems/BloodwormItem.cs index ad5d227e85..a892b8a014 100644 --- a/Items/SummonItems/BloodwormItem.cs +++ b/Items/SummonItems/BloodwormItem.cs @@ -4,13 +4,13 @@ using Terraria.ID; namespace CalamityMod.Items.SummonItems { - public class BloodwormItem : ModItem + public class BloodwormItem : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Bloodworm"); - Tooltip.SetDefault("Summons The Old Duke if used as bait in the sulphur sea"); - } + Tooltip.SetDefault("Summons The Old Duke if used as bait in the sulphur sea"); + } public override void SetDefaults() { diff --git a/Items/SummonItems/BloodyWormFood.cs b/Items/SummonItems/BloodyWormFood.cs index 24cc3bb6e1..bab3800f65 100644 --- a/Items/SummonItems/BloodyWormFood.cs +++ b/Items/SummonItems/BloodyWormFood.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Bloody Worm Food"); Tooltip.SetDefault("Summons the Perforator Hive when used in the crimson\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() @@ -35,12 +35,12 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/BulbofDoom.cs b/Items/SummonItems/BulbofDoom.cs index 16ffa9695c..1d83e75853 100644 --- a/Items/SummonItems/BulbofDoom.cs +++ b/Items/SummonItems/BulbofDoom.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Portabulb"); Tooltip.SetDefault("Summons Plantera when used in the jungle\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() @@ -34,12 +34,12 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, NPCID.Plantera); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.Plantera); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, NPCID.Plantera); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.Plantera); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/CharredIdol.cs b/Items/SummonItems/CharredIdol.cs index 6a010474fb..65a2322ca8 100644 --- a/Items/SummonItems/CharredIdol.cs +++ b/Items/SummonItems/CharredIdol.cs @@ -14,8 +14,8 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Charred Idol"); Tooltip.SetDefault("Use at your own risk\n" + - "Summons the Brimstone Elemental when used in the brimstone crags\n" + - "Not consumable"); + "Summons the Brimstone Elemental when used in the brimstone crags\n" + + "Not consumable"); } public override void SetDefaults() @@ -38,12 +38,12 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() @@ -51,8 +51,8 @@ namespace CalamityMod.Items.SummonItems ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.SoulofNight, 5); recipe.AddIngredient(ModContent.ItemType(), 7); - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(TileID.Hellforge); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddTile(TileID.Hellforge); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/SummonItems/ChickenEgg.cs b/Items/SummonItems/ChickenEgg.cs index 732b7ed9ac..6681cd4a50 100644 --- a/Items/SummonItems/ChickenEgg.cs +++ b/Items/SummonItems/ChickenEgg.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Jungle Dragon Egg"); Tooltip.SetDefault("An imitation of the egg that bore the loyal guardian of the tyrant king\n" + - "Summons Jungle Dragon, Yharon when used in the jungle\n" + + "Summons Jungle Dragon, Yharon when used in the jungle\n" + "Not consumable"); } @@ -25,9 +25,9 @@ namespace CalamityMod.Items.SummonItems item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; item.consumable = false; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + } public override bool CanUseItem(Player player) { @@ -37,12 +37,12 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/CosmicWorm.cs b/Items/SummonItems/CosmicWorm.cs index a0ae2417a4..3ed1d4eac6 100644 --- a/Items/SummonItems/CosmicWorm.cs +++ b/Items/SummonItems/CosmicWorm.cs @@ -16,8 +16,8 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Cosmic Worm"); Tooltip.SetDefault("Summons the Devourer of Gods\n" + - "SENTINEL WARNING TOOLTIP LINE HERE\n" + - "Not consumable"); + "SENTINEL WARNING TOOLTIP LINE HERE\n" + + "Not consumable"); } public override void SetDefaults() @@ -28,23 +28,23 @@ namespace CalamityMod.Items.SummonItems item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; item.consumable = false; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } - public override void ModifyTooltips(List list) - { - foreach (TooltipLine line2 in list) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - bool sentinelsNotDefeated = !CalamityWorld.downedSentinel1 || !CalamityWorld.downedSentinel2 || !CalamityWorld.downedSentinel3; - line2.text = sentinelsNotDefeated ? "WARNING! Some sentinels have not been truly defeated yet and will spawn at full power during this fight!" : ""; - } - } - } + public override void ModifyTooltips(List list) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + bool sentinelsNotDefeated = !CalamityWorld.downedSentinel1 || !CalamityWorld.downedSentinel2 || !CalamityWorld.downedSentinel3; + line2.text = sentinelsNotDefeated ? "WARNING! Some sentinels have not been truly defeated yet and will spawn at full power during this fight!" : ""; + } + } + } - public override bool CanUseItem(Player player) + public override bool CanUseItem(Player player) { return !NPC.AnyNPCs(ModContent.NPCType()) && CalamityWorld.DoGSecondStageCountdown <= 0 && !BossRushEvent.BossRushActive; } @@ -56,12 +56,12 @@ namespace CalamityMod.Items.SummonItems CalamityUtils.DisplayLocalizedText(key, messageColor); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerSpawn"), (int)player.position.X, (int)player.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() @@ -73,17 +73,17 @@ namespace CalamityMod.Items.SummonItems recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); - recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.IronBar, 30); - recipe.anyIronBar = true; - recipe.AddIngredient(ItemID.LunarBar, 10); - recipe.AddIngredient(ModContent.ItemType(), 20); - recipe.AddIngredient(ItemID.SoulofLight, 20); - recipe.AddIngredient(ItemID.SoulofNight, 20); - recipe.AddIngredient(ModContent.ItemType(), 30); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } + recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.IronBar, 30); + recipe.anyIronBar = true; + recipe.AddIngredient(ItemID.LunarBar, 10); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ItemID.SoulofLight, 20); + recipe.AddIngredient(ItemID.SoulofNight, 20); + recipe.AddIngredient(ModContent.ItemType(), 30); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } } } diff --git a/Items/SummonItems/CryoKey.cs b/Items/SummonItems/CryoKey.cs index 8dca6885d8..ea02e9cf77 100644 --- a/Items/SummonItems/CryoKey.cs +++ b/Items/SummonItems/CryoKey.cs @@ -34,12 +34,12 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/DecapoditaSprout.cs b/Items/SummonItems/DecapoditaSprout.cs index 80bca9bb44..07d821f553 100644 --- a/Items/SummonItems/DecapoditaSprout.cs +++ b/Items/SummonItems/DecapoditaSprout.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Decapodita Sprout"); Tooltip.SetDefault("Summons Crabulon when used in the mushroom biome\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() @@ -32,17 +32,17 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { - Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) + Main.PlaySound(SoundID.Roar, player.position, 0); + if (Main.netMode != NetmodeID.MultiplayerClient) { int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-250, 251)), (int)(player.position.Y - 500f), ModContent.NPCType(), 1); - Main.npc[npc].timeLeft *= 20; - CalamityUtils.BossAwakenMessage(npc); + Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); } - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/DraedonsRemote.cs b/Items/SummonItems/DraedonsRemote.cs index 86a4467c8e..42231f371c 100644 --- a/Items/SummonItems/DraedonsRemote.cs +++ b/Items/SummonItems/DraedonsRemote.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Draedon's Remote"); Tooltip.SetDefault("Mayhem...\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() @@ -36,22 +36,22 @@ namespace CalamityMod.Items.SummonItems CalamityGlobalNPC.DraedonMayhem = true; CalamityNetcode.SyncWorld(); Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.SpawnOnPlayer(player.whoAmI, NPCID.TheDestroyer); - NPC.SpawnOnPlayer(player.whoAmI, NPCID.SkeletronPrime); - NPC.SpawnOnPlayer(player.whoAmI, NPCID.Spazmatism); - NPC.SpawnOnPlayer(player.whoAmI, NPCID.Retinazer); - } - else - { - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.TheDestroyer); - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.SkeletronPrime); - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.Spazmatism); - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.Retinazer); - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.SpawnOnPlayer(player.whoAmI, NPCID.TheDestroyer); + NPC.SpawnOnPlayer(player.whoAmI, NPCID.SkeletronPrime); + NPC.SpawnOnPlayer(player.whoAmI, NPCID.Spazmatism); + NPC.SpawnOnPlayer(player.whoAmI, NPCID.Retinazer); + } + else + { + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.TheDestroyer); + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.SkeletronPrime); + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.Spazmatism); + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.Retinazer); + } - return true; + return true; } } } diff --git a/Items/SummonItems/DriedSeafood.cs b/Items/SummonItems/DriedSeafood.cs index 7bd17b383d..265cad3f59 100644 --- a/Items/SummonItems/DriedSeafood.cs +++ b/Items/SummonItems/DriedSeafood.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Desert Medallion"); Tooltip.SetDefault("Summons the Desert Scourge when used in the desert\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() @@ -36,25 +36,25 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - if (CalamityWorld.revenge) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (CalamityWorld.revenge) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - } + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + } - return true; + return true; } public override void AddRecipes() @@ -62,8 +62,8 @@ namespace CalamityMod.Items.SummonItems ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.SandBlock, 25); recipe.AddIngredient(ItemID.Cactus, 15); - recipe.AddIngredient(ItemID.AntlionMandible, 4); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ItemID.AntlionMandible, 4); + recipe.AddIngredient(ModContent.ItemType(), 2); recipe.AddTile(TileID.DemonAltar); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/EidolonTablet.cs b/Items/SummonItems/EidolonTablet.cs index a4df7280b6..bc374668ca 100644 --- a/Items/SummonItems/EidolonTablet.cs +++ b/Items/SummonItems/EidolonTablet.cs @@ -11,9 +11,9 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Eidolon Tablet"); - Tooltip.SetDefault("Summons the Lunatic Cultist\n" + - "Not consumable"); - } + Tooltip.SetDefault("Summons the Lunatic Cultist\n" + + "Not consumable"); + } public override void SetDefaults() { @@ -37,13 +37,13 @@ namespace CalamityMod.Items.SummonItems { int npc = NPC.NewNPC((int)player.Center.X + 30, (int)player.Center.Y - 90, NPCID.CultistBoss, 1); Main.npc[npc].direction = Main.npc[npc].spriteDirection = Math.Sign(player.Center.X - player.Center.X - 30f); - Main.npc[npc].timeLeft *= 20; - CalamityUtils.BossAwakenMessage(npc); - } - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.CultistBoss); + Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); + } + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.CultistBoss); - return true; + return true; } } } diff --git a/Items/SummonItems/EyeofExtinction.cs b/Items/SummonItems/EyeofExtinction.cs index 01529ef2a9..96314f7a4e 100644 --- a/Items/SummonItems/EyeofExtinction.cs +++ b/Items/SummonItems/EyeofExtinction.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.SummonItems { - public class EyeofExtinction : ModItem + public class EyeofExtinction : ModItem { public override void SetStaticDefaults() { diff --git a/Items/SummonItems/Invasion/MartianDistressBeacon.cs b/Items/SummonItems/Invasion/MartianDistressBeacon.cs index 9d191e2c4e..862249ff72 100644 --- a/Items/SummonItems/Invasion/MartianDistressBeacon.cs +++ b/Items/SummonItems/Invasion/MartianDistressBeacon.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.SummonItems.Invasion { - public class MartianDistressBeacon : ModItem + public class MartianDistressBeacon : ModItem { public override void SetStaticDefaults() { diff --git a/Items/SummonItems/NecroplasmicBeacon.cs b/Items/SummonItems/NecroplasmicBeacon.cs index 3d0b7c5220..8c06e9b525 100644 --- a/Items/SummonItems/NecroplasmicBeacon.cs +++ b/Items/SummonItems/NecroplasmicBeacon.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Necroplasmic Beacon"); Tooltip.SetDefault("It's spooky\n" + - "Summons Polterghast when used in the dungeon\n" + + "Summons Polterghast when used in the dungeon\n" + "Not consumable"); } @@ -27,16 +27,16 @@ namespace CalamityMod.Items.SummonItems item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; item.consumable = false; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/SummonItems/NecroplasmicBeaconGlow")); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/SummonItems/NecroplasmicBeaconGlow")); + } - public override bool CanUseItem(Player player) + public override bool CanUseItem(Player player) { return player.ZoneDungeon && !NPC.AnyNPCs(ModContent.NPCType()) && !BossRushEvent.BossRushActive; } @@ -44,18 +44,18 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.SpookyWood, 25); + recipe.AddIngredient(ItemID.SpookyWood, 25); recipe.AddIngredient(ModContent.ItemType(), 50); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); diff --git a/Items/SummonItems/OldPowerCell.cs b/Items/SummonItems/OldPowerCell.cs index 9f0eae21d3..c00c881e0a 100644 --- a/Items/SummonItems/OldPowerCell.cs +++ b/Items/SummonItems/OldPowerCell.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Old Power Cell"); Tooltip.SetDefault("Summons the Golem when used in the temple\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() @@ -43,12 +43,12 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, NPCID.Golem); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.Golem); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, NPCID.Golem); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.Golem); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/OverloadedSludge.cs b/Items/SummonItems/OverloadedSludge.cs index 9b98b072e3..944fa6fb3a 100644 --- a/Items/SummonItems/OverloadedSludge.cs +++ b/Items/SummonItems/OverloadedSludge.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems DisplayName.SetDefault("Overloaded Sludge"); Tooltip.SetDefault("It looks corrupted\n" + "Summons the Slime God\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() @@ -37,12 +37,12 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/ProfanedCoreUnlimited.cs b/Items/SummonItems/ProfanedCoreUnlimited.cs index fb8f732847..4f4b264d76 100644 --- a/Items/SummonItems/ProfanedCoreUnlimited.cs +++ b/Items/SummonItems/ProfanedCoreUnlimited.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Profaned Core"); Tooltip.SetDefault("The core of the unholy flame\n" + - "Summons Providence when used in the hallow or underworld\n" + + "Summons Providence when used in the hallow or underworld\n" + "Should be used during daytime\n" + "Not consumable"); } @@ -25,8 +25,8 @@ namespace CalamityMod.Items.SummonItems item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; item.consumable = false; - item.rare = ItemRarityID.Purple; - } + item.rare = ItemRarityID.Purple; + } public override bool CanUseItem(Player player) { @@ -35,17 +35,17 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceSpawn"), (int)player.position.X, (int)player.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-500, 501)), (int)(player.position.Y - 250f), ModContent.NPCType(), 1); - Main.npc[npc].timeLeft *= 20; - CalamityUtils.BossAwakenMessage(npc); - } - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceSpawn"), (int)player.position.X, (int)player.position.Y); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-500, 501)), (int)(player.position.Y - 250f), ModContent.NPCType(), 1); + Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); + } + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } } } diff --git a/Items/SummonItems/ProfanedShard.cs b/Items/SummonItems/ProfanedShard.cs index 6f507c1771..84b78db7e9 100644 --- a/Items/SummonItems/ProfanedShard.cs +++ b/Items/SummonItems/ProfanedShard.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Profaned Shard"); Tooltip.SetDefault("A shard of the unholy flame\n" + - "Summons the Profaned Guardians when used in the hallow or underworld during daytime\n" + - "Not consumable"); + "Summons the Profaned Guardians when used in the hallow or underworld during daytime\n" + + "Not consumable"); } public override void SetDefaults() @@ -25,8 +25,8 @@ namespace CalamityMod.Items.SummonItems item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; item.consumable = false; - item.rare = ItemRarityID.Purple; - } + item.rare = ItemRarityID.Purple; + } public override bool CanUseItem(Player player) { @@ -36,12 +36,12 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/RuneofCos.cs b/Items/SummonItems/RuneofCos.cs index 1974eb290e..9da3051468 100644 --- a/Items/SummonItems/RuneofCos.cs +++ b/Items/SummonItems/RuneofCos.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.SummonItems { - public class RuneofCos : ModItem + public class RuneofCos : ModItem { public override void SetStaticDefaults() { @@ -30,41 +30,41 @@ namespace CalamityMod.Items.SummonItems item.useStyle = ItemUseStyleID.HoldingUp; item.UseSound = SoundID.Item44; item.consumable = false; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } public override bool CanUseItem(Player player) { return (player.ZoneSkyHeight || player.ZoneUnderworldHeight || player.ZoneDungeon) && !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && - CalamityWorld.DoGSecondStageCountdown <= 0 && !BossRushEvent.BossRushActive; + CalamityWorld.DoGSecondStageCountdown <= 0 && !BossRushEvent.BossRushActive; } public override bool UseItem(Player player) { - Main.PlaySound(SoundID.Roar, player.position, 0); - if (player.ZoneDungeon) + Main.PlaySound(SoundID.Roar, player.position, 0); + if (player.ZoneDungeon) { - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - } + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + } else if (player.ZoneUnderworldHeight) { - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - } + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + } else if (player.ZoneSkyHeight) { - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - } + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + } return true; } @@ -73,8 +73,8 @@ namespace CalamityMod.Items.SummonItems { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 40); - recipe.AddIngredient(ItemID.FragmentSolar, 5); - recipe.AddIngredient(ItemID.LunarBar, 3); + recipe.AddIngredient(ItemID.FragmentSolar, 5); + recipe.AddIngredient(ItemID.LunarBar, 3); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/SandstormsCore.cs b/Items/SummonItems/SandstormsCore.cs index f4b582c3e5..3b4302b1dd 100644 --- a/Items/SummonItems/SandstormsCore.cs +++ b/Items/SummonItems/SandstormsCore.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Sandstorm's Core"); Tooltip.SetDefault("Summons the Great Sand Shark when used in the desert\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() @@ -32,12 +32,12 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() @@ -45,8 +45,8 @@ namespace CalamityMod.Items.SummonItems ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.Ectoplasm, 10); recipe.AddIngredient(ItemID.HallowedBar, 5); - recipe.AddIngredient(ItemID.AncientBattleArmorMaterial, 3); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.AncientBattleArmorMaterial, 3); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/SummonItems/Seafood.cs b/Items/SummonItems/Seafood.cs index 98464205aa..187be1cf65 100644 --- a/Items/SummonItems/Seafood.cs +++ b/Items/SummonItems/Seafood.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Seafood"); Tooltip.SetDefault("Summons the Aquatic Scourge when used in the sulphur sea\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() @@ -37,12 +37,12 @@ namespace CalamityMod.Items.SummonItems public override bool UseItem(Player player) { Main.PlaySound(SoundID.Roar, player.position, 0); - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - return true; + return true; } public override void AddRecipes() diff --git a/Items/SummonItems/Teratoma.cs b/Items/SummonItems/Teratoma.cs index daba67e955..481f1146eb 100644 --- a/Items/SummonItems/Teratoma.cs +++ b/Items/SummonItems/Teratoma.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.SummonItems { DisplayName.SetDefault("Teratoma"); Tooltip.SetDefault("Summons the Hive Mind when used in the corruption\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() diff --git a/Items/SuperDummy.cs b/Items/SuperDummy.cs index afe75dc6e9..e5911650da 100644 --- a/Items/SuperDummy.cs +++ b/Items/SuperDummy.cs @@ -5,102 +5,102 @@ using Terraria.ModLoader; namespace CalamityMod.Items { - public class SuperDummy : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Super Dummy"); - Tooltip.SetDefault("Creates a super dummy\n" + - "Regenerates 1 million life per second\n" + - "Will not die when taking damage over time from debuffs\n" + - "Right click to kill all super dummies"); - } - - public override void SetDefaults() - { - item.damage = 0; - item.width = 20; - item.height = 30; - item.useTime = 15; - item.useAnimation = 15; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTurn = true; - item.value = 0; - item.rare = ItemRarityID.Blue; - item.autoReuse = true; - } - - public override bool AltFunctionUse(Player player) - { - return true; - } - - public static void DeleteDummies() + public class SuperDummy : ModItem + { + public override void SetStaticDefaults() { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.type == ModContent.NPCType() && npc.active) - { - npc.life = 0; - npc.active = false; + DisplayName.SetDefault("Super Dummy"); + Tooltip.SetDefault("Creates a super dummy\n" + + "Regenerates 1 million life per second\n" + + "Will not die when taking damage over time from debuffs\n" + + "Right click to kill all super dummies"); + } - if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i); - } - } - } + public override void SetDefaults() + { + item.damage = 0; + item.width = 20; + item.height = 30; + item.useTime = 15; + item.useAnimation = 15; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTurn = true; + item.value = 0; + item.rare = ItemRarityID.Blue; + item.autoReuse = true; + } - public override bool UseItem(Player player) - { - if (player.altFunctionUse == 2) - { - if (Main.myPlayer == player.whoAmI) - { - if (Main.netMode == NetmodeID.SinglePlayer) - DeleteDummies(); + public override bool AltFunctionUse(Player player) + { + return true; + } - // A custom packet must be sent so that the deletion can be done on the server. This hook does not run there. - // Why? Well, netUpdate/MessageID.SyncNPC packets do not send data to the server. They only send data to other clients. What this means is that prior to this fix - // what would happen was every client EXCEPT THE SERVER would be told by this player that the dummies disappeared. - // However, since the server isn't notified, it is inevitable that the server will do a sync of its own, unaware that the - // dummies are gone, and cause them to reappear, making the deletion moot. - else - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DeleteAllSuperDummies); - netMessage.Send(); - } - } - } - else if (player.whoAmI == Main.myPlayer) - { - int x = (int)Main.MouseWorld.X - 9; - int y = (int)Main.MouseWorld.Y - 20; + public static void DeleteDummies() + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.type == ModContent.NPCType() && npc.active) + { + npc.life = 0; + npc.active = false; - // In single player, just spawn the dummy. - if (Main.netMode == NetmodeID.SinglePlayer) - NPC.NewNPC(x, y, ModContent.NPCType()); + if (Main.netMode == NetmodeID.Server) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i); + } + } + } - // Otherwise, send a message to the server indicating that a Super Dummy should be spawned at this position. - else - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.SpawnSuperDummy); - netMessage.Write(x); - netMessage.Write(y); - netMessage.Send(); - } - } - return true; - } + public override bool UseItem(Player player) + { + if (player.altFunctionUse == 2) + { + if (Main.myPlayer == player.whoAmI) + { + if (Main.netMode == NetmodeID.SinglePlayer) + DeleteDummies(); - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.TargetDummy); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + // A custom packet must be sent so that the deletion can be done on the server. This hook does not run there. + // Why? Well, netUpdate/MessageID.SyncNPC packets do not send data to the server. They only send data to other clients. What this means is that prior to this fix + // what would happen was every client EXCEPT THE SERVER would be told by this player that the dummies disappeared. + // However, since the server isn't notified, it is inevitable that the server will do a sync of its own, unaware that the + // dummies are gone, and cause them to reappear, making the deletion moot. + else + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.DeleteAllSuperDummies); + netMessage.Send(); + } + } + } + else if (player.whoAmI == Main.myPlayer) + { + int x = (int)Main.MouseWorld.X - 9; + int y = (int)Main.MouseWorld.Y - 20; + + // In single player, just spawn the dummy. + if (Main.netMode == NetmodeID.SinglePlayer) + NPC.NewNPC(x, y, ModContent.NPCType()); + + // Otherwise, send a message to the server indicating that a Super Dummy should be spawned at this position. + else + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.SpawnSuperDummy); + netMessage.Write(x); + netMessage.Write(y); + netMessage.Send(); + } + } + return true; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.TargetDummy); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Tools/AstralHamaxe.cs b/Items/Tools/AstralHamaxe.cs index bc2522dc46..17043e2ae3 100644 --- a/Items/Tools/AstralHamaxe.cs +++ b/Items/Tools/AstralHamaxe.cs @@ -35,8 +35,8 @@ namespace CalamityMod.Items.Tools item.autoReuse = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; public override void MeleeEffects(Player player, Rectangle hitbox) { diff --git a/Items/Tools/AstralPickaxe.cs b/Items/Tools/AstralPickaxe.cs index f352ce89fa..c6431f8ad4 100644 --- a/Items/Tools/AstralPickaxe.cs +++ b/Items/Tools/AstralPickaxe.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Tools item.autoReuse = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; public override void AddRecipes() { diff --git a/Items/Tools/BobbitHook.cs b/Items/Tools/BobbitHook.cs index 904c086a72..4e36e3eca9 100644 --- a/Items/Tools/BobbitHook.cs +++ b/Items/Tools/BobbitHook.cs @@ -7,29 +7,29 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Tools { - public class BobbitHook : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bobbit Hook"); + public class BobbitHook : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bobbit Hook"); Tooltip.SetDefault($@"Retracts upon attaching to a tile with extreme speeds Reach: {BobbitHead.GrappleRangInTiles} Launch Velocity: {BobbitHead.LaunchSpeed} Reelback Velocity: {BobbitHead.ReelbackSpeed} Pull Velocity: {BobbitHead.PullSpeed}"); - } + } - public override void SetDefaults() - { - // Instead of copying these values, we can clone and modify the ones we want to copy - item.CloneDefaults(ItemID.AmethystHook); - item.shootSpeed = BobbitHead.LaunchSpeed; // How quickly the hook is shot. - item.shoot = ProjectileType(); + public override void SetDefaults() + { + // Instead of copying these values, we can clone and modify the ones we want to copy + item.CloneDefaults(ItemID.AmethystHook); + item.shootSpeed = BobbitHead.LaunchSpeed; // How quickly the hook is shot. + item.shoot = ProjectileType(); item.value = Item.buyPrice(1, 40, 0, 0); item.rare = ItemRarityID.Red; item.Calamity().customRarity = (CalamityRarity)13; - item.width = 30; - item.height = 32; - } - } + item.width = 30; + item.height = 32; + } + } } diff --git a/Items/Tools/ChaoswarpedSlashaxe.cs b/Items/Tools/ChaoswarpedSlashaxe.cs index 8fc8c72c80..73750dc7b6 100644 --- a/Items/Tools/ChaoswarpedSlashaxe.cs +++ b/Items/Tools/ChaoswarpedSlashaxe.cs @@ -50,8 +50,8 @@ namespace CalamityMod.Items.Tools } if (Main.rand.NextBool(5)) { - int smoke = Gore.NewGore(new Vector2(hitbox.X, hitbox.Y), default, Main.rand.Next(375, 378), 0.75f); - Main.gore[smoke].behindTiles = true; + int smoke = Gore.NewGore(new Vector2(hitbox.X, hitbox.Y), default, Main.rand.Next(375, 378), 0.75f); + Main.gore[smoke].behindTiles = true; } } diff --git a/Items/Tools/ClimateChange/AridArtifact.cs b/Items/Tools/ClimateChange/AridArtifact.cs index aedae06677..b47f47805a 100644 --- a/Items/Tools/ClimateChange/AridArtifact.cs +++ b/Items/Tools/ClimateChange/AridArtifact.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Tools.ClimateChange DisplayName.SetDefault("Arid Artifact"); Tooltip.SetDefault("Summons a sandstorm\n" + "The sandstorm will happen shortly after the item is used\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() diff --git a/Items/Tools/ClimateChange/BloodIdol.cs b/Items/Tools/ClimateChange/BloodIdol.cs index b019263074..537ab93d2a 100644 --- a/Items/Tools/ClimateChange/BloodIdol.cs +++ b/Items/Tools/ClimateChange/BloodIdol.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Tools.ClimateChange { DisplayName.SetDefault("Blood Relic"); Tooltip.SetDefault("Summons a blood moon\n" + - "Not consumable"); + "Not consumable"); } public override void SetDefaults() diff --git a/Items/Tools/ClimateChange/Cosmolight.cs b/Items/Tools/ClimateChange/Cosmolight.cs index 0bd382d4da..e876ee13fa 100644 --- a/Items/Tools/ClimateChange/Cosmolight.cs +++ b/Items/Tools/ClimateChange/Cosmolight.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Tools.ClimateChange { DisplayName.SetDefault("Cosmolight"); Tooltip.SetDefault("Changes night to day and vice versa\n" + - "Does not work while a boss is alive"); + "Does not work while a boss is alive"); } public override void SetDefaults() @@ -54,10 +54,10 @@ namespace CalamityMod.Items.Tools.ClimateChange { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.FallenStar, 10); // Made it slightly more expensive than requested. - Merkalto - recipe.AddIngredient(ItemID.SoulofLight, 7); - recipe.AddIngredient(ItemID.SoulofNight, 7); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.Anvils); + recipe.AddIngredient(ItemID.SoulofLight, 7); + recipe.AddIngredient(ItemID.SoulofNight, 7); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.Anvils); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Tools/ClimateChange/TorrentialTear.cs b/Items/Tools/ClimateChange/TorrentialTear.cs index 9fa2832cf2..efcc0d4229 100644 --- a/Items/Tools/ClimateChange/TorrentialTear.cs +++ b/Items/Tools/ClimateChange/TorrentialTear.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Tools.ClimateChange { - public class TorrentialTear : ModItem + public class TorrentialTear : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Tools/CrystylCrusher.cs b/Items/Tools/CrystylCrusher.cs index 5928726c5d..6345574661 100644 --- a/Items/Tools/CrystylCrusher.cs +++ b/Items/Tools/CrystylCrusher.cs @@ -9,124 +9,124 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Tools { - public class CrystylCrusher : ModItem - { - private static int PickPower = 1000; - private static float LaserSpeed = 14f; + public class CrystylCrusher : ModItem + { + private static int PickPower = 1000; + private static float LaserSpeed = 14f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Crystyl Crusher"); - Tooltip.SetDefault("Gotta dig faster, gotta go deeper\n" + - "Right click to swing normally"); - Item.staff[item.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Crystyl Crusher"); + Tooltip.SetDefault("Gotta dig faster, gotta go deeper\n" + + "Right click to swing normally"); + Item.staff[item.type] = true; + } - public override void SetDefaults() - { - item.damage = 400; - item.knockBack = 9f; - item.useTime = 2; - item.useAnimation = 2; - item.pick = PickPower; - // tile boost intentionally missing, usually 50 + public override void SetDefaults() + { + item.damage = 400; + item.knockBack = 9f; + item.useTime = 2; + item.useAnimation = 2; + item.pick = PickPower; + // tile boost intentionally missing, usually 50 - item.melee = true; - item.noMelee = true; - item.channel = true; - item.width = 70; - item.height = 70; - item.useStyle = ItemUseStyleID.HoldingOut; - item.shootSpeed = LaserSpeed; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/CrystylCharge"); - item.shoot = ModContent.ProjectileType(); + item.melee = true; + item.noMelee = true; + item.channel = true; + item.width = 70; + item.height = 70; + item.useStyle = ItemUseStyleID.HoldingOut; + item.shootSpeed = LaserSpeed; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/CrystylCharge"); + item.shoot = ModContent.ProjectileType(); - item.value = CalamityGlobalItem.Rarity16BuyPrice; - item.Calamity().customRarity = CalamityRarity.HotPink; - item.Calamity().devItem = true; - } + item.value = CalamityGlobalItem.Rarity16BuyPrice; + item.Calamity().customRarity = CalamityRarity.HotPink; + item.Calamity().devItem = true; + } - public override Vector2? HoldoutOrigin() - { - if (item.useStyle == ItemUseStyleID.SwingThrow) - return null; - return new Vector2(10, 10); - } + public override Vector2? HoldoutOrigin() + { + if (item.useStyle == ItemUseStyleID.SwingThrow) + return null; + return new Vector2(10, 10); + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; - public override bool AltFunctionUse(Player player) => true; + public override bool AltFunctionUse(Player player) => true; public override void HoldItem(Player player) { - if (Main.myPlayer == player.whoAmI) - player.Calamity().rightClickListener = true; + if (Main.myPlayer == player.whoAmI) + player.Calamity().rightClickListener = true; - if (player.Calamity().mouseRight && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) - { - item.shoot = ProjectileID.None; - item.shootSpeed = 0f; - item.tileBoost = 50; - item.UseSound = SoundID.Item1; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTurn = true; - item.autoReuse = true; - item.noMelee = false; - } - else - { - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = LaserSpeed; - item.tileBoost = -6; - item.UseSound = null; - item.useStyle = ItemUseStyleID.HoldingOut; - item.useTurn = false; - item.autoReuse = false; - item.noMelee = true; - } - } + if (player.Calamity().mouseRight && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) + { + item.shoot = ProjectileID.None; + item.shootSpeed = 0f; + item.tileBoost = 50; + item.UseSound = SoundID.Item1; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTurn = true; + item.autoReuse = true; + item.noMelee = false; + } + else + { + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = LaserSpeed; + item.tileBoost = -6; + item.UseSound = null; + item.useStyle = ItemUseStyleID.HoldingOut; + item.useTurn = false; + item.autoReuse = false; + item.noMelee = true; + } + } - public override void ModifyTooltips(List list) - { - if (item.useStyle == ItemUseStyleID.HoldingOut) - { - foreach (TooltipLine line2 in list) - { - if (line2.mod == "Terraria" && line2.Name == "TileBoost") - { - line2.text = ""; - } - } - } - } + public override void ModifyTooltips(List list) + { + if (item.useStyle == ItemUseStyleID.HoldingOut) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "TileBoost") + { + line2.text = ""; + } + } + } + } - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (player.altFunctionUse == 2) - return; + public override void MeleeEffects(Player player, Rectangle hitbox) + { + if (player.altFunctionUse == 2) + return; - if (Main.rand.NextBool(3)) - { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 173, - 57, - 58 - }); - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, dustType); - } - } + if (Main.rand.NextBool(3)) + { + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 173, + 57, + 58 + }); + int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, dustType); + } + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddRecipeGroup("LunarPickaxe"); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddRecipeGroup("LunarPickaxe"); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Tools/InfernaCutter.cs b/Items/Tools/InfernaCutter.cs index 2bdf2fc62b..b66ae38b26 100644 --- a/Items/Tools/InfernaCutter.cs +++ b/Items/Tools/InfernaCutter.cs @@ -37,8 +37,8 @@ namespace CalamityMod.Items.Tools item.autoReuse = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; public override void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox) { diff --git a/Items/Tools/MarniteObliterator.cs b/Items/Tools/MarniteObliterator.cs index d5bc6245a0..4efaf1e66f 100644 --- a/Items/Tools/MarniteObliterator.cs +++ b/Items/Tools/MarniteObliterator.cs @@ -3,7 +3,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Tools { - public class MarniteObliterator : ModItem + public class MarniteObliterator : ModItem { public override void SetStaticDefaults() { @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Tools item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 40f; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } public override void AddRecipes() { diff --git a/Items/TreasureBags/AbyssalTreasure.cs b/Items/TreasureBags/AbyssalTreasure.cs index 2e96a17958..96e2e8a87d 100644 --- a/Items/TreasureBags/AbyssalTreasure.cs +++ b/Items/TreasureBags/AbyssalTreasure.cs @@ -26,122 +26,122 @@ namespace CalamityMod.Items.TreasureBags public override void RightClick(Player player) { - // Loops 4 times to compensate for dropping only one treasure now - for (int i = 0; i < 4; i++) - { - if (Main.rand.NextBool(10)) - { - int potionType = Utils.SelectRandom(WorldGen.genRand, new int[] - { - ItemID.SpelunkerPotion, - ItemID.MagicPowerPotion, - ItemID.ShinePotion, - ItemID.WaterWalkingPotion, - ItemID.ObsidianSkinPotion, - ItemID.WaterWalkingPotion, - ItemID.GravitationPotion, - ItemID.RegenerationPotion, - ModContent.ItemType(), - ModContent.ItemType(), - ItemID.GillsPotion, - ItemID.EndurancePotion, - ItemID.HeartreachPotion, - ItemID.FlipperPotion, - ItemID.LifeforcePotion, - ItemID.InfernoPotion - }); - DropHelper.DropItem(player, potionType); - } - else - { - switch (Main.rand.Next(10)) - { - case 0: - int sglowstickAmt = Main.rand.Next(2, 6); - if (Main.expertMode) - { - sglowstickAmt += Main.rand.Next(1, 7); - } - DropHelper.DropItem(player, ItemID.SpelunkerGlowstick, sglowstickAmt); - break; - case 1: - DropHelper.DropItem(player, ItemID.HellfireArrow, 10, 20); - break; - case 2: - DropHelper.DropItem(player, ModContent.ItemType()); - break; - case 3: - DropHelper.DropItem(player, ItemID.StickyDynamite); - break; - default: - int coinCount = 5000 + Main.rand.Next(-100, 101); - while (coinCount > 0) - { - if (coinCount > 1000000) - { - int ptCoinAmt = coinCount / 1000000; - if (ptCoinAmt > 50 && Main.rand.NextBool(2)) - { - ptCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - ptCoinAmt /= Main.rand.Next(3) + 1; - } - coinCount -= 1000000 * ptCoinAmt; - DropHelper.DropItem(player, ItemID.PlatinumCoin, ptCoinAmt); - } - else if (coinCount > 10000) - { - int auCoinAmt = coinCount / 10000; - if (auCoinAmt > 50 && Main.rand.NextBool(2)) - { - auCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - auCoinAmt /= Main.rand.Next(3) + 1; - } - coinCount -= 10000 * auCoinAmt; - DropHelper.DropItem(player, ItemID.GoldCoin, auCoinAmt); - } - else if (coinCount > 100) - { - int agCoinAmt = coinCount / 100; - if (agCoinAmt > 50 && Main.rand.NextBool(2)) - { - agCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - agCoinAmt /= Main.rand.Next(3) + 1; - } - coinCount -= 100 * agCoinAmt; - DropHelper.DropItem(player, ItemID.SilverCoin, agCoinAmt); - } - else - { - int cuCoinAmt = coinCount; - if (cuCoinAmt > 50 && Main.rand.NextBool(2)) - { - cuCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - cuCoinAmt /= Main.rand.Next(4) + 1; - } - if (cuCoinAmt < 1) - { - cuCoinAmt = 1; - } - coinCount -= cuCoinAmt; - DropHelper.DropItem(player, ItemID.CopperCoin, cuCoinAmt); - } - } - break; - } - } - } + // Loops 4 times to compensate for dropping only one treasure now + for (int i = 0; i < 4; i++) + { + if (Main.rand.NextBool(10)) + { + int potionType = Utils.SelectRandom(WorldGen.genRand, new int[] + { + ItemID.SpelunkerPotion, + ItemID.MagicPowerPotion, + ItemID.ShinePotion, + ItemID.WaterWalkingPotion, + ItemID.ObsidianSkinPotion, + ItemID.WaterWalkingPotion, + ItemID.GravitationPotion, + ItemID.RegenerationPotion, + ModContent.ItemType(), + ModContent.ItemType(), + ItemID.GillsPotion, + ItemID.EndurancePotion, + ItemID.HeartreachPotion, + ItemID.FlipperPotion, + ItemID.LifeforcePotion, + ItemID.InfernoPotion + }); + DropHelper.DropItem(player, potionType); + } + else + { + switch (Main.rand.Next(10)) + { + case 0: + int sglowstickAmt = Main.rand.Next(2, 6); + if (Main.expertMode) + { + sglowstickAmt += Main.rand.Next(1, 7); + } + DropHelper.DropItem(player, ItemID.SpelunkerGlowstick, sglowstickAmt); + break; + case 1: + DropHelper.DropItem(player, ItemID.HellfireArrow, 10, 20); + break; + case 2: + DropHelper.DropItem(player, ModContent.ItemType()); + break; + case 3: + DropHelper.DropItem(player, ItemID.StickyDynamite); + break; + default: + int coinCount = 5000 + Main.rand.Next(-100, 101); + while (coinCount > 0) + { + if (coinCount > 1000000) + { + int ptCoinAmt = coinCount / 1000000; + if (ptCoinAmt > 50 && Main.rand.NextBool(2)) + { + ptCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + ptCoinAmt /= Main.rand.Next(3) + 1; + } + coinCount -= 1000000 * ptCoinAmt; + DropHelper.DropItem(player, ItemID.PlatinumCoin, ptCoinAmt); + } + else if (coinCount > 10000) + { + int auCoinAmt = coinCount / 10000; + if (auCoinAmt > 50 && Main.rand.NextBool(2)) + { + auCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + auCoinAmt /= Main.rand.Next(3) + 1; + } + coinCount -= 10000 * auCoinAmt; + DropHelper.DropItem(player, ItemID.GoldCoin, auCoinAmt); + } + else if (coinCount > 100) + { + int agCoinAmt = coinCount / 100; + if (agCoinAmt > 50 && Main.rand.NextBool(2)) + { + agCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + agCoinAmt /= Main.rand.Next(3) + 1; + } + coinCount -= 100 * agCoinAmt; + DropHelper.DropItem(player, ItemID.SilverCoin, agCoinAmt); + } + else + { + int cuCoinAmt = coinCount; + if (cuCoinAmt > 50 && Main.rand.NextBool(2)) + { + cuCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + cuCoinAmt /= Main.rand.Next(4) + 1; + } + if (cuCoinAmt < 1) + { + cuCoinAmt = 1; + } + coinCount -= cuCoinAmt; + DropHelper.DropItem(player, ItemID.CopperCoin, cuCoinAmt); + } + } + break; + } + } + } } } } diff --git a/Items/TreasureBags/AquaticScourgeBag.cs b/Items/TreasureBags/AquaticScourgeBag.cs index 27307cb2f7..f1c2e1d135 100644 --- a/Items/TreasureBags/AquaticScourgeBag.cs +++ b/Items/TreasureBags/AquaticScourgeBag.cs @@ -12,7 +12,7 @@ using CalamityMod.Items.Armor.Vanity; namespace CalamityMod.Items.TreasureBags { - public class AquaticScourgeBag : ModItem + public class AquaticScourgeBag : ModItem { public override int BossBagNPC => ModContent.NPCType(); @@ -53,11 +53,11 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); diff --git a/Items/TreasureBags/AstrageldonBag.cs b/Items/TreasureBags/AstrageldonBag.cs index 5992744dc2..0f904d08be 100644 --- a/Items/TreasureBags/AstrageldonBag.cs +++ b/Items/TreasureBags/AstrageldonBag.cs @@ -56,10 +56,10 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w) - ); + ); - // Equipment - DropHelper.DropItemCondition(player, ModContent.ItemType(), NPC.downedMoonlord); + // Equipment + DropHelper.DropItemCondition(player, ModContent.ItemType(), NPC.downedMoonlord); DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); diff --git a/Items/TreasureBags/AstrumDeusBag.cs b/Items/TreasureBags/AstrumDeusBag.cs index d3e70a1eda..2b512f1dcd 100644 --- a/Items/TreasureBags/AstrumDeusBag.cs +++ b/Items/TreasureBags/AstrumDeusBag.cs @@ -54,14 +54,14 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w) - ); + ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); - DropHelper.DropItemChance(player, ModContent.ItemType(), 5); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); + DropHelper.DropItemChance(player, ModContent.ItemType(), 5); - // Vanity - DropHelper.DropItemChance(player, ModContent.ItemType(), 7); + // Vanity + DropHelper.DropItemChance(player, ModContent.ItemType(), 7); } } } diff --git a/Items/TreasureBags/BleachedAnglingKit.cs b/Items/TreasureBags/BleachedAnglingKit.cs index 8531429827..c00db3076a 100644 --- a/Items/TreasureBags/BleachedAnglingKit.cs +++ b/Items/TreasureBags/BleachedAnglingKit.cs @@ -4,13 +4,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.TreasureBags { - public class BleachedAnglingKit : ModItem + public class BleachedAnglingKit : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Bleached Angling Kit"); Tooltip.SetDefault("Has a chance to contain various fishing gear\n" + - "{$CommonItemTooltip.RightClickToOpen}"); + "{$CommonItemTooltip.RightClickToOpen}"); } public override void SetDefaults() @@ -26,27 +26,27 @@ namespace CalamityMod.Items.TreasureBags public override void RightClick(Player player) { - int anglerTackleBagChance = !Main.expertMode ? 18 : 15; - int fishingAccChance = !Main.expertMode ? 12 : 10; - int fishFindAccChance = !Main.expertMode ? 9 : 8; - int anglerArmorChance = !Main.expertMode ? 4 : 2; - int potionChance = !Main.expertMode ? 4 : 2; - int bugNetChance = !Main.expertMode ? 15 : 12; - // Fishing - DropHelper.DropItemChance(player, ItemID.AnglerTackleBag, anglerTackleBagChance, 1, 1); - DropHelper.DropItemChance(player, ItemID.HighTestFishingLine, fishingAccChance); - DropHelper.DropItemChance(player, ItemID.TackleBox, fishingAccChance); - DropHelper.DropItemChance(player, ItemID.AnglerEarring, fishingAccChance); - DropHelper.DropItemChance(player, ItemID.FishermansGuide, fishFindAccChance); - DropHelper.DropItemChance(player, ItemID.WeatherRadio, fishFindAccChance); - DropHelper.DropItemChance(player, ItemID.Sextant, fishFindAccChance); - DropHelper.DropItemChance(player, ItemID.AnglerHat, anglerArmorChance); - DropHelper.DropItemChance(player, ItemID.AnglerVest, anglerArmorChance); - DropHelper.DropItemChance(player, ItemID.AnglerPants, anglerArmorChance); - DropHelper.DropItemChance(player, ItemID.FishingPotion, potionChance, 2, 3); - DropHelper.DropItemChance(player, ItemID.SonarPotion, potionChance, 2, 3); - DropHelper.DropItemChance(player, ItemID.CratePotion, potionChance, 2, 3); - DropHelper.DropItemChance(player, ItemID.GoldenBugNet, bugNetChance, 1, 1); + int anglerTackleBagChance = !Main.expertMode ? 18 : 15; + int fishingAccChance = !Main.expertMode ? 12 : 10; + int fishFindAccChance = !Main.expertMode ? 9 : 8; + int anglerArmorChance = !Main.expertMode ? 4 : 2; + int potionChance = !Main.expertMode ? 4 : 2; + int bugNetChance = !Main.expertMode ? 15 : 12; + // Fishing + DropHelper.DropItemChance(player, ItemID.AnglerTackleBag, anglerTackleBagChance, 1, 1); + DropHelper.DropItemChance(player, ItemID.HighTestFishingLine, fishingAccChance); + DropHelper.DropItemChance(player, ItemID.TackleBox, fishingAccChance); + DropHelper.DropItemChance(player, ItemID.AnglerEarring, fishingAccChance); + DropHelper.DropItemChance(player, ItemID.FishermansGuide, fishFindAccChance); + DropHelper.DropItemChance(player, ItemID.WeatherRadio, fishFindAccChance); + DropHelper.DropItemChance(player, ItemID.Sextant, fishFindAccChance); + DropHelper.DropItemChance(player, ItemID.AnglerHat, anglerArmorChance); + DropHelper.DropItemChance(player, ItemID.AnglerVest, anglerArmorChance); + DropHelper.DropItemChance(player, ItemID.AnglerPants, anglerArmorChance); + DropHelper.DropItemChance(player, ItemID.FishingPotion, potionChance, 2, 3); + DropHelper.DropItemChance(player, ItemID.SonarPotion, potionChance, 2, 3); + DropHelper.DropItemChance(player, ItemID.CratePotion, potionChance, 2, 3); + DropHelper.DropItemChance(player, ItemID.GoldenBugNet, bugNetChance, 1, 1); } } } diff --git a/Items/TreasureBags/BrimstoneWaifuBag.cs b/Items/TreasureBags/BrimstoneWaifuBag.cs index 2715801a1b..aada6b3b37 100644 --- a/Items/TreasureBags/BrimstoneWaifuBag.cs +++ b/Items/TreasureBags/BrimstoneWaifuBag.cs @@ -54,18 +54,18 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedProvidence); - // Vanity - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.revenge); + // Vanity + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.revenge); DropHelper.DropItemChance(player, ModContent.ItemType(), 7); } } diff --git a/Items/TreasureBags/BumblebirbBag.cs b/Items/TreasureBags/BumblebirbBag.cs index 578a3f66ea..b78110169d 100644 --- a/Items/TreasureBags/BumblebirbBag.cs +++ b/Items/TreasureBags/BumblebirbBag.cs @@ -49,8 +49,8 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); // Equipment DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); diff --git a/Items/TreasureBags/CalamitasBag.cs b/Items/TreasureBags/CalamitasBag.cs index 6d9332c275..ad23515da7 100644 --- a/Items/TreasureBags/CalamitasBag.cs +++ b/Items/TreasureBags/CalamitasBag.cs @@ -13,7 +13,7 @@ using Terraria.ID; namespace CalamityMod.Items.TreasureBags { - public class CalamitasBag : ModItem + public class CalamitasBag : ModItem { public override int BossBagNPC => ModContent.NPCType(); @@ -55,8 +55,8 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); // Equipment DropHelper.DropItem(player, ModContent.ItemType()); @@ -64,11 +64,11 @@ namespace CalamityMod.Items.TreasureBags // Vanity DropHelper.DropItemChance(player, ModContent.ItemType(), 7); - if (Main.rand.NextBool(10)) - { - DropHelper.DropItem(player, ModContent.ItemType()); - DropHelper.DropItem(player, ModContent.ItemType()); - } + if (Main.rand.NextBool(10)) + { + DropHelper.DropItem(player, ModContent.ItemType()); + DropHelper.DropItem(player, ModContent.ItemType()); + } } } } diff --git a/Items/TreasureBags/CeaselessVoidBag.cs b/Items/TreasureBags/CeaselessVoidBag.cs index 8967387b90..8a9b832d7e 100644 --- a/Items/TreasureBags/CeaselessVoidBag.cs +++ b/Items/TreasureBags/CeaselessVoidBag.cs @@ -38,20 +38,20 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItem(player, ModContent.ItemType(), 4, 6); // Weapons - DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); + DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + DropHelper.DropItem(player, ModContent.ItemType()); - // Vanity - DropHelper.DropItemChance(player, ModContent.ItemType(), 7); - if (Main.rand.NextBool(20)) - { - DropHelper.DropItem(player, ModContent.ItemType()); - DropHelper.DropItem(player, ModContent.ItemType()); - DropHelper.DropItem(player, ModContent.ItemType()); - } + // Vanity + DropHelper.DropItemChance(player, ModContent.ItemType(), 7); + if (Main.rand.NextBool(20)) + { + DropHelper.DropItem(player, ModContent.ItemType()); + DropHelper.DropItem(player, ModContent.ItemType()); + DropHelper.DropItem(player, ModContent.ItemType()); + } } } } diff --git a/Items/TreasureBags/CrabulonBag.cs b/Items/TreasureBags/CrabulonBag.cs index 7ad0e87be8..a7c76ff9bc 100644 --- a/Items/TreasureBags/CrabulonBag.cs +++ b/Items/TreasureBags/CrabulonBag.cs @@ -59,8 +59,8 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.revenge && !player.Calamity().rageBoostOne); - // Vanity - DropHelper.DropItemChance(player, ModContent.ItemType(), 7); + // Vanity + DropHelper.DropItemChance(player, ModContent.ItemType(), 7); } } } diff --git a/Items/TreasureBags/CryogenBag.cs b/Items/TreasureBags/CryogenBag.cs index 497311eb0f..30e761de7b 100644 --- a/Items/TreasureBags/CryogenBag.cs +++ b/Items/TreasureBags/CryogenBag.cs @@ -15,7 +15,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.TreasureBags { - public class CryogenBag : ModItem + public class CryogenBag : ModItem { public override int BossBagNPC => ModContent.NPCType(); @@ -55,12 +55,12 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); // Vanity diff --git a/Items/TreasureBags/DesertScourgeBag.cs b/Items/TreasureBags/DesertScourgeBag.cs index a73be72d85..9936fb48f6 100644 --- a/Items/TreasureBags/DesertScourgeBag.cs +++ b/Items/TreasureBags/DesertScourgeBag.cs @@ -55,12 +55,12 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); // Vanity DropHelper.DropItemChance(player, ModContent.ItemType(), 7); diff --git a/Items/TreasureBags/DevourerofGodsBag.cs b/Items/TreasureBags/DevourerofGodsBag.cs index b9bb5ab344..45228a0f1b 100644 --- a/Items/TreasureBags/DevourerofGodsBag.cs +++ b/Items/TreasureBags/DevourerofGodsBag.cs @@ -18,7 +18,7 @@ using Terraria.ID; namespace CalamityMod.Items.TreasureBags { - public class DevourerofGodsBag : ModItem + public class DevourerofGodsBag : ModItem { public override int BossBagNPC => ModContent.NPCType(); @@ -64,10 +64,10 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w) - ); + ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); diff --git a/Items/TreasureBags/DraedonTreasureBag.cs b/Items/TreasureBags/DraedonTreasureBag.cs index 7749029d2d..50a6496654 100644 --- a/Items/TreasureBags/DraedonTreasureBag.cs +++ b/Items/TreasureBags/DraedonTreasureBag.cs @@ -13,82 +13,82 @@ using Terraria.ModLoader; namespace CalamityMod.Items.TreasureBags { - public class DraedonTreasureBag : ModItem - { - public override int BossBagNPC => ModContent.NPCType(); + public class DraedonTreasureBag : ModItem + { + public override int BossBagNPC => ModContent.NPCType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Treasure Bag"); - Tooltip.SetDefault("{$CommonItemTooltip.RightClickToOpen}"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Treasure Bag"); + Tooltip.SetDefault("{$CommonItemTooltip.RightClickToOpen}"); + } - public override void SetDefaults() - { - item.maxStack = 999; - item.consumable = true; - item.width = 24; - item.height = 24; - item.rare = ItemRarityID.Cyan; - item.expert = true; - } + public override void SetDefaults() + { + item.maxStack = 999; + item.consumable = true; + item.width = 24; + item.height = 24; + item.rare = ItemRarityID.Cyan; + item.expert = true; + } - public override bool CanRightClick() => true; + public override bool CanRightClick() => true; - public override void PostUpdate() => CalamityUtils.ForceItemIntoWorld(item); + public override void PostUpdate() => CalamityUtils.ForceItemIntoWorld(item); - public override void OpenBossBag(Player player) - { - player.TryGettingDevArmor(); + public override void OpenBossBag(Player player) + { + player.TryGettingDevArmor(); - // Materials - DropHelper.DropItem(player, ModContent.ItemType(), 30, 40); + // Materials + DropHelper.DropItem(player, ModContent.ItemType(), 30, 40); - // Weapons - // Higher chance due to how the drops work - float w = DropHelper.BagWeaponDropRateFloat * 2f; - if (CalamityWorld.downedAres) - { - DropHelper.DropEntireWeightedSet(player, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - } - if (CalamityWorld.downedThanatos) - { - DropHelper.DropEntireWeightedSet(player, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - } - if (CalamityWorld.downedArtemisAndApollo) - { - DropHelper.DropEntireWeightedSet(player, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - } + // Weapons + // Higher chance due to how the drops work + float w = DropHelper.BagWeaponDropRateFloat * 2f; + if (CalamityWorld.downedAres) + { + DropHelper.DropEntireWeightedSet(player, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); + } + if (CalamityWorld.downedThanatos) + { + DropHelper.DropEntireWeightedSet(player, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); + } + if (CalamityWorld.downedArtemisAndApollo) + { + DropHelper.DropEntireWeightedSet(player, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); + } - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); + DropHelper.DropItem(player, ModContent.ItemType()); - // Vanity - // Higher chance due to how the drops work - float maskDropRate = 1f / 3.5f; - if (CalamityWorld.downedThanatos) - DropHelper.DropItemChance(player, ModContent.ItemType(), maskDropRate); + // Vanity + // Higher chance due to how the drops work + float maskDropRate = 1f / 3.5f; + if (CalamityWorld.downedThanatos) + DropHelper.DropItemChance(player, ModContent.ItemType(), maskDropRate); - if (CalamityWorld.downedArtemisAndApollo) - { - DropHelper.DropItemChance(player, ModContent.ItemType(), maskDropRate); - DropHelper.DropItemChance(player, ModContent.ItemType(), maskDropRate); - } + if (CalamityWorld.downedArtemisAndApollo) + { + DropHelper.DropItemChance(player, ModContent.ItemType(), maskDropRate); + DropHelper.DropItemChance(player, ModContent.ItemType(), maskDropRate); + } - if (CalamityWorld.downedAres) - DropHelper.DropItemChance(player, ModContent.ItemType(), maskDropRate); + if (CalamityWorld.downedAres) + DropHelper.DropItemChance(player, ModContent.ItemType(), maskDropRate); - DropHelper.DropItemChance(player, ModContent.ItemType(), maskDropRate); - } - } + DropHelper.DropItemChance(player, ModContent.ItemType(), maskDropRate); + } + } } diff --git a/Items/TreasureBags/HiveMindBag.cs b/Items/TreasureBags/HiveMindBag.cs index b14b3b14ba..1b97e39b2d 100644 --- a/Items/TreasureBags/HiveMindBag.cs +++ b/Items/TreasureBags/HiveMindBag.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItem(player, ItemID.DemoniteBar, 9, 14); DropHelper.DropItem(player, ItemID.RottenChunk, 10, 20); DropHelper.DropItemCondition(player, ItemID.CursedFlame, Main.hardMode, 15, 30); - DropHelper.DropItem(player, ItemID.CorruptSeeds, 10, 15); + DropHelper.DropItem(player, ItemID.CorruptSeeds, 10, 15); // Weapons float w = DropHelper.BagWeaponDropRateFloat; @@ -58,11 +58,11 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w, 50, 75), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); // Vanity DropHelper.DropItemChance(player, ModContent.ItemType(), 7); diff --git a/Items/TreasureBags/LeviathanBag.cs b/Items/TreasureBags/LeviathanBag.cs index c6080fd3bc..1e8db0aabb 100644 --- a/Items/TreasureBags/LeviathanBag.cs +++ b/Items/TreasureBags/LeviathanBag.cs @@ -12,7 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.TreasureBags { - public class LeviathanBag : ModItem + public class LeviathanBag : ModItem { public override int BossBagNPC => ModContent.NPCType(); @@ -52,8 +52,8 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); // Equipment DropHelper.DropItem(player, ModContent.ItemType()); diff --git a/Items/TreasureBags/OldDukeBag.cs b/Items/TreasureBags/OldDukeBag.cs index f6f84c64db..9e88ca3b7b 100644 --- a/Items/TreasureBags/OldDukeBag.cs +++ b/Items/TreasureBags/OldDukeBag.cs @@ -52,10 +52,10 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); - // Equipment + // Equipment DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); diff --git a/Items/TreasureBags/PerforatorBag.cs b/Items/TreasureBags/PerforatorBag.cs index 3f64bb8d65..23e49e6a13 100644 --- a/Items/TreasureBags/PerforatorBag.cs +++ b/Items/TreasureBags/PerforatorBag.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItem(player, ItemID.CrimtaneBar, 15, 20); DropHelper.DropItem(player, ItemID.Vertebrae, 15, 20); DropHelper.DropItemCondition(player, ItemID.Ichor, Main.hardMode, 15, 30); - DropHelper.DropItem(player, ItemID.CrimsonSeeds, 10, 15); + DropHelper.DropItem(player, ItemID.CrimsonSeeds, 10, 15); // Weapons float w = DropHelper.BagWeaponDropRateFloat; @@ -59,11 +59,11 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w, 50, 75), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); // Vanity DropHelper.DropItemChance(player, ModContent.ItemType(), 7); diff --git a/Items/TreasureBags/PlaguebringerGoliathBag.cs b/Items/TreasureBags/PlaguebringerGoliathBag.cs index 402312b882..7d568d86ac 100644 --- a/Items/TreasureBags/PlaguebringerGoliathBag.cs +++ b/Items/TreasureBags/PlaguebringerGoliathBag.cs @@ -14,7 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.TreasureBags { - public class PlaguebringerGoliathBag : ModItem + public class PlaguebringerGoliathBag : ModItem { public override int BossBagNPC => ModContent.NPCType(); @@ -59,10 +59,10 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w) - ); + ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); // Vanity diff --git a/Items/TreasureBags/PolterghastBag.cs b/Items/TreasureBags/PolterghastBag.cs index be28fa6e52..9bb5802ae7 100644 --- a/Items/TreasureBags/PolterghastBag.cs +++ b/Items/TreasureBags/PolterghastBag.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.TreasureBags public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/TreasureBags/PolterghastBagGlow")); + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/TreasureBags/PolterghastBagGlow")); } public override bool CanRightClick() => true; @@ -64,8 +64,8 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w) ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.revenge && !player.Calamity().adrenalineBoostThree); // Vanity diff --git a/Items/TreasureBags/ProvidenceBag.cs b/Items/TreasureBags/ProvidenceBag.cs index ba78a62164..708ae4e029 100644 --- a/Items/TreasureBags/ProvidenceBag.cs +++ b/Items/TreasureBags/ProvidenceBag.cs @@ -13,7 +13,7 @@ using Terraria.ID; namespace CalamityMod.Items.TreasureBags { - public class ProvidenceBag : ModItem + public class ProvidenceBag : ModItem { public override int BossBagNPC => ModContent.NPCType(); @@ -56,10 +56,10 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w) - ); + ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); // Vanity diff --git a/Items/TreasureBags/RavagerBag.cs b/Items/TreasureBags/RavagerBag.cs index e9edc1bcc1..71fdaf7ab0 100644 --- a/Items/TreasureBags/RavagerBag.cs +++ b/Items/TreasureBags/RavagerBag.cs @@ -14,7 +14,7 @@ using Terraria.ID; namespace CalamityMod.Items.TreasureBags { - public class RavagerBag : ModItem + public class RavagerBag : ModItem { public override int BossBagNPC => ModContent.NPCType(); @@ -55,11 +55,11 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w) - ); + ); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.05f); - // Equipment - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.5f); + // Equipment + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.5f); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.5f); DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedProvidence); DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.revenge && !player.Calamity().rageBoostTwo); diff --git a/Items/TreasureBags/SandyAnglingKit.cs b/Items/TreasureBags/SandyAnglingKit.cs index e89723b3ed..8d43603ca4 100644 --- a/Items/TreasureBags/SandyAnglingKit.cs +++ b/Items/TreasureBags/SandyAnglingKit.cs @@ -4,13 +4,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.TreasureBags { - public class SandyAnglingKit : ModItem + public class SandyAnglingKit : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Sandy Angling Kit"); Tooltip.SetDefault("Has a chance to contain various fishing gear\n" + - "{$CommonItemTooltip.RightClickToOpen}"); + "{$CommonItemTooltip.RightClickToOpen}"); } public override void SetDefaults() @@ -26,25 +26,25 @@ namespace CalamityMod.Items.TreasureBags public override void RightClick(Player player) { - int fishingAccChance = !Main.expertMode ? 15 : 12; - int fishFindAccChance = !Main.expertMode ? 10 : 9; - int anglerArmorChance = !Main.expertMode ? 5 : 4; - int potionChance = !Main.expertMode ? 5 : 4; - int bugNetChance = !Main.expertMode ? 20 : 18; - // Fishing - DropHelper.DropItemChance(player, ItemID.HighTestFishingLine, fishingAccChance); - DropHelper.DropItemChance(player, ItemID.TackleBox, fishingAccChance); - DropHelper.DropItemChance(player, ItemID.AnglerEarring, fishingAccChance); - DropHelper.DropItemChance(player, ItemID.FishermansGuide, fishFindAccChance); - DropHelper.DropItemChance(player, ItemID.WeatherRadio, fishFindAccChance); - DropHelper.DropItemChance(player, ItemID.Sextant, fishFindAccChance); - DropHelper.DropItemChance(player, ItemID.AnglerHat, anglerArmorChance); - DropHelper.DropItemChance(player, ItemID.AnglerVest, anglerArmorChance); - DropHelper.DropItemChance(player, ItemID.AnglerPants, anglerArmorChance); - DropHelper.DropItemChance(player, ItemID.FishingPotion, potionChance, 2, 3); - DropHelper.DropItemChance(player, ItemID.SonarPotion, potionChance, 2, 3); - DropHelper.DropItemChance(player, ItemID.CratePotion, potionChance, 2, 3); - DropHelper.DropItemCondition(player, ItemID.GoldenBugNet, NPC.downedBoss3, bugNetChance, 1, 1); + int fishingAccChance = !Main.expertMode ? 15 : 12; + int fishFindAccChance = !Main.expertMode ? 10 : 9; + int anglerArmorChance = !Main.expertMode ? 5 : 4; + int potionChance = !Main.expertMode ? 5 : 4; + int bugNetChance = !Main.expertMode ? 20 : 18; + // Fishing + DropHelper.DropItemChance(player, ItemID.HighTestFishingLine, fishingAccChance); + DropHelper.DropItemChance(player, ItemID.TackleBox, fishingAccChance); + DropHelper.DropItemChance(player, ItemID.AnglerEarring, fishingAccChance); + DropHelper.DropItemChance(player, ItemID.FishermansGuide, fishFindAccChance); + DropHelper.DropItemChance(player, ItemID.WeatherRadio, fishFindAccChance); + DropHelper.DropItemChance(player, ItemID.Sextant, fishFindAccChance); + DropHelper.DropItemChance(player, ItemID.AnglerHat, anglerArmorChance); + DropHelper.DropItemChance(player, ItemID.AnglerVest, anglerArmorChance); + DropHelper.DropItemChance(player, ItemID.AnglerPants, anglerArmorChance); + DropHelper.DropItemChance(player, ItemID.FishingPotion, potionChance, 2, 3); + DropHelper.DropItemChance(player, ItemID.SonarPotion, potionChance, 2, 3); + DropHelper.DropItemChance(player, ItemID.CratePotion, potionChance, 2, 3); + DropHelper.DropItemCondition(player, ItemID.GoldenBugNet, NPC.downedBoss3, bugNetChance, 1, 1); } } } diff --git a/Items/TreasureBags/SignusBag.cs b/Items/TreasureBags/SignusBag.cs index 37f5bb241c..b3f5a964ff 100644 --- a/Items/TreasureBags/SignusBag.cs +++ b/Items/TreasureBags/SignusBag.cs @@ -38,20 +38,20 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItem(player, ModContent.ItemType(), 3, 4); // Weapons - DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); - DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); + DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); + DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); // Vanity - DropHelper.DropItemChance(player, ModContent.ItemType(), 7); - if (Main.rand.NextBool(20)) - { - DropHelper.DropItem(player, ModContent.ItemType()); - DropHelper.DropItem(player, ModContent.ItemType()); - DropHelper.DropItem(player, ModContent.ItemType()); - } + DropHelper.DropItemChance(player, ModContent.ItemType(), 7); + if (Main.rand.NextBool(20)) + { + DropHelper.DropItem(player, ModContent.ItemType()); + DropHelper.DropItem(player, ModContent.ItemType()); + DropHelper.DropItem(player, ModContent.ItemType()); + } } } } diff --git a/Items/TreasureBags/StarterBag.cs b/Items/TreasureBags/StarterBag.cs index 946d4144c2..20c7bf2409 100644 --- a/Items/TreasureBags/StarterBag.cs +++ b/Items/TreasureBags/StarterBag.cs @@ -51,9 +51,9 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItem(player, ItemID.Torch, 25); DropHelper.DropItem(player, ItemID.Chest, 3); - // Difficulty items (Revengeance, Death and Malice don't drop in Normal) - DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); - DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); + // Difficulty items (Revengeance, Death and Malice don't drop in Normal) + DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); + DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); DropHelper.DropItemCondition(player, ModContent.ItemType(), Main.expertMode); // The Lad diff --git a/Items/TreasureBags/StormWeaverBag.cs b/Items/TreasureBags/StormWeaverBag.cs index 0c516b29f5..87d505e97d 100644 --- a/Items/TreasureBags/StormWeaverBag.cs +++ b/Items/TreasureBags/StormWeaverBag.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.TreasureBags { - public class StormWeaverBag : ModItem + public class StormWeaverBag : ModItem { public override int BossBagNPC => ModContent.NPCType(); @@ -38,20 +38,20 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItem(player, ModContent.ItemType(), 7, 10); // Weapons - DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); - DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); - DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); + DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); + DropHelper.DropItemChance(player, ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); - // Equipment (None yet boohoo) + // Equipment (None yet boohoo) - // Vanity - DropHelper.DropItemChance(player, ModContent.ItemType(), 7); - if (Main.rand.NextBool(20)) - { - DropHelper.DropItem(player, ModContent.ItemType()); - DropHelper.DropItem(player, ModContent.ItemType()); - DropHelper.DropItem(player, ModContent.ItemType()); - } + // Vanity + DropHelper.DropItemChance(player, ModContent.ItemType(), 7); + if (Main.rand.NextBool(20)) + { + DropHelper.DropItem(player, ModContent.ItemType()); + DropHelper.DropItem(player, ModContent.ItemType()); + DropHelper.DropItem(player, ModContent.ItemType()); + } // Light Pet DropHelper.DropItemChance(player, ModContent.ItemType(), 8); diff --git a/Items/TreasureBags/SulphuricTreasure.cs b/Items/TreasureBags/SulphuricTreasure.cs index e853004cbd..058ef047c7 100644 --- a/Items/TreasureBags/SulphuricTreasure.cs +++ b/Items/TreasureBags/SulphuricTreasure.cs @@ -26,122 +26,122 @@ namespace CalamityMod.Items.TreasureBags public override void RightClick(Player player) { - // Loops 4 times to compensate for dropping only one treasure now - for (int i = 0; i < 4; i++) - { - if (Main.rand.NextBool(15)) - { - int potionType = Utils.SelectRandom(WorldGen.genRand, new int[] - { - ItemID.SpelunkerPotion, - ItemID.MagicPowerPotion, - ItemID.ShinePotion, - ItemID.WaterWalkingPotion, - ItemID.ObsidianSkinPotion, - ItemID.WaterWalkingPotion, - ItemID.GravitationPotion, - ItemID.RegenerationPotion, - ModContent.ItemType(), - ModContent.ItemType(), - ItemID.GillsPotion, - ItemID.EndurancePotion, - ItemID.HeartreachPotion, - ItemID.FlipperPotion, - ItemID.LifeforcePotion, - ItemID.InfernoPotion - }); - DropHelper.DropItem(player, potionType); - } - else - { - switch (Main.rand.Next(10)) - { - case 0: - int glowstickAmt = Main.rand.Next(2, 6); - if (Main.expertMode) - { - glowstickAmt += Main.rand.Next(1, 7); - } - DropHelper.DropItem(player, ItemID.Glowstick, glowstickAmt); - break; - case 1: - DropHelper.DropItem(player, ItemID.JestersArrow, 10, 20); - break; - case 2: - DropHelper.DropItem(player, ItemID.HealingPotion); - break; - case 3: - DropHelper.DropItem(player, ItemID.Bomb, 5, 8); - break; - default: - int coinCount = 5000 + Main.rand.Next(-100, 101); - while (coinCount > 0) - { - if (coinCount > 1000000) - { - int ptCoinAmt = coinCount / 1000000; - if (ptCoinAmt > 50 && Main.rand.NextBool(2)) - { - ptCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - ptCoinAmt /= Main.rand.Next(3) + 1; - } - coinCount -= 1000000 * ptCoinAmt; - DropHelper.DropItem(player, ItemID.PlatinumCoin, ptCoinAmt); - } - else if (coinCount > 10000) - { - int auCoinAmt = coinCount / 10000; - if (auCoinAmt > 50 && Main.rand.NextBool(2)) - { - auCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - auCoinAmt /= Main.rand.Next(3) + 1; - } - coinCount -= 10000 * auCoinAmt; - DropHelper.DropItem(player, ItemID.GoldCoin, auCoinAmt); - } - else if (coinCount > 100) - { - int agCoinAmt = coinCount / 100; - if (agCoinAmt > 50 && Main.rand.NextBool(2)) - { - agCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - agCoinAmt /= Main.rand.Next(3) + 1; - } - coinCount -= 100 * agCoinAmt; - DropHelper.DropItem(player, ItemID.SilverCoin, agCoinAmt); - } - else - { - int cuCoinAmt = coinCount; - if (cuCoinAmt > 50 && Main.rand.NextBool(2)) - { - cuCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - cuCoinAmt /= Main.rand.Next(4) + 1; - } - if (cuCoinAmt < 1) - { - cuCoinAmt = 1; - } - coinCount -= cuCoinAmt; - DropHelper.DropItem(player, ItemID.CopperCoin, cuCoinAmt); - } - } - break; - } - } - } + // Loops 4 times to compensate for dropping only one treasure now + for (int i = 0; i < 4; i++) + { + if (Main.rand.NextBool(15)) + { + int potionType = Utils.SelectRandom(WorldGen.genRand, new int[] + { + ItemID.SpelunkerPotion, + ItemID.MagicPowerPotion, + ItemID.ShinePotion, + ItemID.WaterWalkingPotion, + ItemID.ObsidianSkinPotion, + ItemID.WaterWalkingPotion, + ItemID.GravitationPotion, + ItemID.RegenerationPotion, + ModContent.ItemType(), + ModContent.ItemType(), + ItemID.GillsPotion, + ItemID.EndurancePotion, + ItemID.HeartreachPotion, + ItemID.FlipperPotion, + ItemID.LifeforcePotion, + ItemID.InfernoPotion + }); + DropHelper.DropItem(player, potionType); + } + else + { + switch (Main.rand.Next(10)) + { + case 0: + int glowstickAmt = Main.rand.Next(2, 6); + if (Main.expertMode) + { + glowstickAmt += Main.rand.Next(1, 7); + } + DropHelper.DropItem(player, ItemID.Glowstick, glowstickAmt); + break; + case 1: + DropHelper.DropItem(player, ItemID.JestersArrow, 10, 20); + break; + case 2: + DropHelper.DropItem(player, ItemID.HealingPotion); + break; + case 3: + DropHelper.DropItem(player, ItemID.Bomb, 5, 8); + break; + default: + int coinCount = 5000 + Main.rand.Next(-100, 101); + while (coinCount > 0) + { + if (coinCount > 1000000) + { + int ptCoinAmt = coinCount / 1000000; + if (ptCoinAmt > 50 && Main.rand.NextBool(2)) + { + ptCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + ptCoinAmt /= Main.rand.Next(3) + 1; + } + coinCount -= 1000000 * ptCoinAmt; + DropHelper.DropItem(player, ItemID.PlatinumCoin, ptCoinAmt); + } + else if (coinCount > 10000) + { + int auCoinAmt = coinCount / 10000; + if (auCoinAmt > 50 && Main.rand.NextBool(2)) + { + auCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + auCoinAmt /= Main.rand.Next(3) + 1; + } + coinCount -= 10000 * auCoinAmt; + DropHelper.DropItem(player, ItemID.GoldCoin, auCoinAmt); + } + else if (coinCount > 100) + { + int agCoinAmt = coinCount / 100; + if (agCoinAmt > 50 && Main.rand.NextBool(2)) + { + agCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + agCoinAmt /= Main.rand.Next(3) + 1; + } + coinCount -= 100 * agCoinAmt; + DropHelper.DropItem(player, ItemID.SilverCoin, agCoinAmt); + } + else + { + int cuCoinAmt = coinCount; + if (cuCoinAmt > 50 && Main.rand.NextBool(2)) + { + cuCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + cuCoinAmt /= Main.rand.Next(4) + 1; + } + if (cuCoinAmt < 1) + { + cuCoinAmt = 1; + } + coinCount -= cuCoinAmt; + DropHelper.DropItem(player, ItemID.CopperCoin, cuCoinAmt); + } + } + break; + } + } + } } } } diff --git a/Items/TreasureBags/YharonBag.cs b/Items/TreasureBags/YharonBag.cs index 60b3623e70..ce17aa1601 100644 --- a/Items/TreasureBags/YharonBag.cs +++ b/Items/TreasureBags/YharonBag.cs @@ -53,10 +53,10 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), // Yharon Kindle Staff DropHelper.WeightStack(w), // Infernal Spear DropHelper.WeightStack(w) - ); + ); - // Equipment - DropHelper.DropItem(player, ModContent.ItemType()); + // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.1f); diff --git a/Items/VanillaArmorChanges/EskimoArmorSetChange.cs b/Items/VanillaArmorChanges/EskimoArmorSetChange.cs index 0829660a68..e0a5803b4c 100644 --- a/Items/VanillaArmorChanges/EskimoArmorSetChange.cs +++ b/Items/VanillaArmorChanges/EskimoArmorSetChange.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { - public class EskimoArmorSetChange : VanillaArmorChange + public class EskimoArmorSetChange : VanillaArmorChange { public override int? HeadPieceID => ItemID.EskimoHood; diff --git a/Items/VanillaArmorChanges/MoltenArmorSetChange.cs b/Items/VanillaArmorChanges/MoltenArmorSetChange.cs index ca2c09d1b4..fd4036f74e 100644 --- a/Items/VanillaArmorChanges/MoltenArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MoltenArmorSetChange.cs @@ -3,7 +3,7 @@ using Terraria.ID; namespace CalamityMod.Items.VanillaArmorChanges { - public class MoltenArmorSetChange : VanillaArmorChange + public class MoltenArmorSetChange : VanillaArmorChange { public override int? HeadPieceID => ItemID.MoltenHelmet; diff --git a/Items/VanillaArmorChanges/MythrilArmorSetChange.cs b/Items/VanillaArmorChanges/MythrilArmorSetChange.cs index 8168a69fc1..c031c92402 100644 --- a/Items/VanillaArmorChanges/MythrilArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MythrilArmorSetChange.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { - public class MythrilArmorSetChange : VanillaArmorChange + public class MythrilArmorSetChange : VanillaArmorChange { public override int? HeadPieceID => ItemID.MythrilHelmet; diff --git a/Items/VanillaArmorChanges/ObsidianArmorSetChange.cs b/Items/VanillaArmorChanges/ObsidianArmorSetChange.cs index 08a09bbc92..4eca14452c 100644 --- a/Items/VanillaArmorChanges/ObsidianArmorSetChange.cs +++ b/Items/VanillaArmorChanges/ObsidianArmorSetChange.cs @@ -3,7 +3,7 @@ using Terraria.ID; namespace CalamityMod.Items.VanillaArmorChanges { - public class ObsidianArmorSetChange : VanillaArmorChange + public class ObsidianArmorSetChange : VanillaArmorChange { public override int? HeadPieceID => ItemID.ObsidianHelm; diff --git a/Items/VanillaArmorChanges/OrichalcumArmorSetChange.cs b/Items/VanillaArmorChanges/OrichalcumArmorSetChange.cs index 1e162c0460..55f10a9cf8 100644 --- a/Items/VanillaArmorChanges/OrichalcumArmorSetChange.cs +++ b/Items/VanillaArmorChanges/OrichalcumArmorSetChange.cs @@ -3,7 +3,7 @@ using Terraria.ID; namespace CalamityMod.Items.VanillaArmorChanges { - public class OrichalcumArmorSetChange : VanillaArmorChange + public class OrichalcumArmorSetChange : VanillaArmorChange { public override int? HeadPieceID => ItemID.OrichalcumHelmet; diff --git a/Items/VanillaArmorChanges/PalladiumArmorSetChange.cs b/Items/VanillaArmorChanges/PalladiumArmorSetChange.cs index 74cffa46c3..8ae600683a 100644 --- a/Items/VanillaArmorChanges/PalladiumArmorSetChange.cs +++ b/Items/VanillaArmorChanges/PalladiumArmorSetChange.cs @@ -3,7 +3,7 @@ using Terraria.ID; namespace CalamityMod.Items.VanillaArmorChanges { - public class PalladiumArmorSetChange : VanillaArmorChange + public class PalladiumArmorSetChange : VanillaArmorChange { public override int? HeadPieceID => ItemID.PalladiumHelmet; diff --git a/Items/VoodooDemonVoodooDoll.cs b/Items/VoodooDemonVoodooDoll.cs index cf14e05b19..943ce7e713 100644 --- a/Items/VoodooDemonVoodooDoll.cs +++ b/Items/VoodooDemonVoodooDoll.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Items public override void UpdateInventory(Player player) { - if (item.favorited) - player.Calamity().disableVoodooSpawns = true; + if (item.favorited) + player.Calamity().disableVoodooSpawns = true; } public override void AddRecipes() diff --git a/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs b/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs index 86e70c4c7a..0381a77ef3 100644 --- a/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs +++ b/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs @@ -10,71 +10,71 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class FrequencyManipulator : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Frequency Manipulator"); - Tooltip.SetDefault("A long device, used in the tuning of some rather... original machines\n" + - "Swings a spear around and then throws it\n" + - "On collision, the spear releases a burst of homing energy\n" + - "Stealth strikes release more energy and explode on collision"); - } + public class FrequencyManipulator : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Frequency Manipulator"); + Tooltip.SetDefault("A long device, used in the tuning of some rather... original machines\n" + + "Swings a spear around and then throws it\n" + + "On collision, the spear releases a burst of homing energy\n" + + "Stealth strikes release more energy and explode on collision"); + } - public override void SafeSetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SafeSetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.damage = 80; - modItem.rogue = true; - item.noMelee = true; - item.noUseGraphic = true; - item.width = 26; - item.height = 44; - item.useTime = 56; - item.useAnimation = 56; - item.autoReuse = true; - item.useStyle = ItemUseStyleID.SwingThrow; - item.knockBack = 5f; + item.damage = 80; + modItem.rogue = true; + item.noMelee = true; + item.noUseGraphic = true; + item.width = 26; + item.height = 44; + item.useTime = 56; + item.useAnimation = 56; + item.autoReuse = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.knockBack = 5f; - item.value = CalamityGlobalItem.Rarity5BuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; - item.UseSound = SoundID.Item1; + item.value = CalamityGlobalItem.Rarity5BuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; + item.UseSound = SoundID.Item1; - item.shootSpeed = 16f; - item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 16f; + item.shoot = ModContent.ProjectileType(); - modItem.UsesCharge = true; - modItem.MaxCharge = 85f; - modItem.ChargePerUse = 0.04f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 85f; + modItem.ChargePerUse = 0.04f; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void SafeModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override void SafeModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); - 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()) - damage = (int)(damage * 0.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) + { + if (player.Calamity().StealthStrikeAvailable()) + damage = (int)(damage * 0.9f); - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - return false; - } + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + return false; + } - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddRecipeGroup("AnyMythrilBar", 10); + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddRecipeGroup("AnyMythrilBar", 10); recipe.AddIngredient(ItemID.SoulofSight, 20); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs b/Items/Weapons/DraedonsArsenal/GatlingLaser.cs index b840a460f0..914f4bb57e 100644 --- a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs +++ b/Items/Weapons/DraedonsArsenal/GatlingLaser.cs @@ -9,71 +9,71 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class GatlingLaser : ModItem - { - // This is the amount of charge consumed every time the holdout projectile fires a laser. - public const float HoldoutChargeUse = 0.0075f; + public class GatlingLaser : ModItem + { + // This is the amount of charge consumed every time the holdout projectile fires a laser. + public const float HoldoutChargeUse = 0.0075f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gatling Laser"); - Tooltip.SetDefault("Large laser cannon used primarily by Yharim's fleet and base defense force"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gatling Laser"); + Tooltip.SetDefault("Large laser cannon used primarily by Yharim's fleet and base defense force"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 43; - item.height = 24; - item.magic = true; - item.damage = 43; - item.knockBack = 1f; - item.useTime = 2; - item.useAnimation = 2; - item.noUseGraphic = true; - item.autoReuse = false; - item.channel = true; - item.mana = 6; + item.width = 43; + item.height = 24; + item.magic = true; + item.damage = 43; + item.knockBack = 1f; + item.useTime = 2; + item.useAnimation = 2; + item.noUseGraphic = true; + item.autoReuse = false; + item.channel = true; + item.mana = 6; - item.useStyle = ItemUseStyleID.HoldingOut; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GatlingLaserFireStart"); - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GatlingLaserFireStart"); + item.noMelee = true; - item.value = CalamityGlobalItem.Rarity8BuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity8BuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 24f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 24f; - modItem.UsesCharge = true; - modItem.MaxCharge = 135f; - modItem.ChargePerUse = 0f; // This weapon is a holdout. Charge is consumed by the holdout projectile. - } + modItem.UsesCharge = true; + modItem.MaxCharge = 135f; + modItem.ChargePerUse = 0f; // This weapon is a holdout. Charge is consumed by the holdout projectile. + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); - 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; - } + 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; + } - public override Vector2? HoldoutOffset() => new Vector2(-20, 0); + public override Vector2? HoldoutOffset() => new Vector2(-20, 0); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/GaussPistol.cs b/Items/Weapons/DraedonsArsenal/GaussPistol.cs index fa5cbdaac4..ec599d7291 100644 --- a/Items/Weapons/DraedonsArsenal/GaussPistol.cs +++ b/Items/Weapons/DraedonsArsenal/GaussPistol.cs @@ -7,56 +7,56 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class GaussPistol : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gauss Pistol"); - Tooltip.SetDefault("A simple pistol that utilizes magic power; a weapon for the more magically adept\n" + - "Fires a devastating high velocity blast with extreme knockback"); - } + public class GaussPistol : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gauss Pistol"); + Tooltip.SetDefault("A simple pistol that utilizes magic power; a weapon for the more magically adept\n" + + "Fires a devastating high velocity blast with extreme knockback"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 40; - item.height = 22; - item.magic = true; - item.mana = 6; - item.damage = 110; - item.knockBack = 11f; - item.useTime = item.useAnimation = 20; - item.autoReuse = true; + item.width = 40; + item.height = 22; + item.magic = true; + item.mana = 6; + item.damage = 110; + item.knockBack = 11f; + item.useTime = item.useAnimation = 20; + item.autoReuse = true; - item.useStyle = ItemUseStyleID.HoldingOut; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GaussWeaponFire"); - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GaussWeaponFire"); + item.noMelee = true; - item.value = CalamityGlobalItem.Rarity5BuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity5BuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 14f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 14f; - modItem.MaxCharge = 85f; - modItem.UsesCharge = true; - modItem.ChargePerUse = 0.05f; - } + modItem.MaxCharge = 85f; + modItem.UsesCharge = true; + modItem.ChargePerUse = 0.05f; + } - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddRecipeGroup("AnyMythrilBar", 10); + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddRecipeGroup("AnyMythrilBar", 10); recipe.AddIngredient(ItemID.SoulofMight, 20); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/GaussRifle.cs b/Items/Weapons/DraedonsArsenal/GaussRifle.cs index d4e4499822..015d9c8b9f 100644 --- a/Items/Weapons/DraedonsArsenal/GaussRifle.cs +++ b/Items/Weapons/DraedonsArsenal/GaussRifle.cs @@ -9,61 +9,61 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class GaussRifle : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gauss Rifle"); - Tooltip.SetDefault("A large and slow weapon, the concussive force of its projectiles do well in clearing large groups\n" + - "Fires a devastating high velocity blast with absurd knockback"); - } + public class GaussRifle : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gauss Rifle"); + Tooltip.SetDefault("A large and slow weapon, the concussive force of its projectiles do well in clearing large groups\n" + + "Fires a devastating high velocity blast with absurd knockback"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 112; - item.height = 36; - item.ranged = true; - item.damage = 150; - item.knockBack = 30f; - item.useTime = item.useAnimation = 32; - item.autoReuse = true; + item.width = 112; + item.height = 36; + item.ranged = true; + item.damage = 150; + item.knockBack = 30f; + item.useTime = item.useAnimation = 32; + item.autoReuse = true; - item.useStyle = ItemUseStyleID.HoldingOut; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GaussWeaponFire"); - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GaussWeaponFire"); + item.noMelee = true; - item.value = CalamityGlobalItem.Rarity8BuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity8BuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 27f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 27f; - modItem.UsesCharge = true; - modItem.MaxCharge = 135f; - modItem.ChargePerUse = 0.1125f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 135f; + modItem.ChargePerUse = 0.1125f; + } - 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - return false; - } + 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + return false; + } - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); - recipe.AddIngredient(ModContent.ItemType(), 18); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); + recipe.AddIngredient(ModContent.ItemType(), 18); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs b/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs index 72986c51ea..ce4b271b01 100644 --- a/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs +++ b/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs @@ -46,13 +46,13 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal item.melee = true; item.channel = true; - modItem.trueMelee = true; + modItem.trueMelee = true; modItem.UsesCharge = true; modItem.MaxCharge = 85f; modItem.ChargePerUse = 0f; // This weapon is a holdout. Charge is consumed by the holdout projectile. } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && item.Calamity().Charge > 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && item.Calamity().Charge > 0; public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); diff --git a/Items/Weapons/DraedonsArsenal/LaserRifle.cs b/Items/Weapons/DraedonsArsenal/LaserRifle.cs index 73a6126b4d..a9d8641509 100644 --- a/Items/Weapons/DraedonsArsenal/LaserRifle.cs +++ b/Items/Weapons/DraedonsArsenal/LaserRifle.cs @@ -9,77 +9,77 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class LaserRifle : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Heavy Laser Rifle"); - Tooltip.SetDefault("Laser weapon used by heavy infantry units in Yharim's army"); - } + public class LaserRifle : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Heavy Laser Rifle"); + Tooltip.SetDefault("Laser weapon used by heavy infantry units in Yharim's army"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 84; - item.height = 28; - item.ranged = true; - item.damage = 185; - item.knockBack = 4f; - item.useTime = 25; - item.useAnimation = 25; - item.autoReuse = true; + item.width = 84; + item.height = 28; + item.ranged = true; + item.damage = 185; + item.knockBack = 4f; + item.useTime = 25; + item.useAnimation = 25; + item.autoReuse = true; - item.useStyle = ItemUseStyleID.HoldingOut; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserRifleFire"); - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserRifleFire"); + item.noMelee = true; - item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 5f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 5f; - modItem.UsesCharge = true; - modItem.MaxCharge = 190f; - modItem.ChargePerUse = 0.125f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 190f; + modItem.ChargePerUse = 0.125f; + } - 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) - { - velocity.Normalize(); - velocity *= 5f; - } - for (int i = 0; i < 2; i++) - { - float SpeedX = velocity.X + Main.rand.Next(-1, 2) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-1, 2) * 0.05f; - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, i, 0f); - } - return false; - } + 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) + { + velocity.Normalize(); + velocity *= 5f; + } + for (int i = 0; i < 2; i++) + { + float SpeedX = velocity.X + Main.rand.Next(-1, 2) * 0.05f; + float SpeedY = velocity.Y + Main.rand.Next(-1, 2) * 0.05f; + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, i, 0f); + } + return false; + } - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); - public override Vector2? HoldoutOffset() - { - return new Vector2(-20, 0); - } + public override Vector2? HoldoutOffset() + { + return new Vector2(-20, 0); + } - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ItemID.LunarBar, 4); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ItemID.LunarBar, 4); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/MatterModulator.cs b/Items/Weapons/DraedonsArsenal/MatterModulator.cs index 6c2876d7ae..e508f0c71b 100644 --- a/Items/Weapons/DraedonsArsenal/MatterModulator.cs +++ b/Items/Weapons/DraedonsArsenal/MatterModulator.cs @@ -9,65 +9,65 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class MatterModulator : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Matter Modulator"); - Tooltip.SetDefault("Using extra mass gained from collision with solid materials, it causes extra damage\n" + - "Fires a burst of unstable matter that does significant damage after striking a tile\n" + - "Before striking a tile, the matter pierces infinitely but deals little damage"); - } + public class MatterModulator : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Matter Modulator"); + Tooltip.SetDefault("Using extra mass gained from collision with solid materials, it causes extra damage\n" + + "Fires a burst of unstable matter that does significant damage after striking a tile\n" + + "Before striking a tile, the matter pierces infinitely but deals little damage"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 40; - item.height = 22; - item.ranged = true; - item.damage = 84; - item.knockBack = 11f; - item.useTime = item.useAnimation = 33; - item.autoReuse = true; + item.width = 40; + item.height = 22; + item.ranged = true; + item.damage = 84; + item.knockBack = 11f; + item.useTime = item.useAnimation = 33; + item.autoReuse = true; - item.useStyle = ItemUseStyleID.HoldingOut; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBolt"); - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBolt"); + item.noMelee = true; - item.value = CalamityGlobalItem.Rarity5BuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity5BuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 7f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 7f; - modItem.UsesCharge = true; - modItem.MaxCharge = 85f; - modItem.ChargePerUse = 0.075f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 85f; + modItem.ChargePerUse = 0.075f; + } - 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 < Main.rand.Next(3, 5 + 1); i++) - { - Projectile.NewProjectile(position, new Vector2(speedX, speedY).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.8f, 1.3f), type, damage, knockBack, player.whoAmI); - } - return false; - } + 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 < Main.rand.Next(3, 5 + 1); i++) + { + Projectile.NewProjectile(position, new Vector2(speedX, speedY).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.8f, 1.3f), type, damage, knockBack, player.whoAmI); + } + return false; + } - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddRecipeGroup("AnyMythrilBar", 10); + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddRecipeGroup("AnyMythrilBar", 10); recipe.AddIngredient(ItemID.SoulofFright, 20); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/MountedScanner.cs b/Items/Weapons/DraedonsArsenal/MountedScanner.cs index ef19b4bf9d..a0ec9f4015 100644 --- a/Items/Weapons/DraedonsArsenal/MountedScanner.cs +++ b/Items/Weapons/DraedonsArsenal/MountedScanner.cs @@ -9,94 +9,94 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class MountedScanner : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Mounted Scanner"); - Tooltip.SetDefault("Laser technology used in this case for both targeting and defense\n" + - "Summons a powerful weapon above your head that fires lasers at nearby enemies"); - } + public class MountedScanner : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mounted Scanner"); + Tooltip.SetDefault("Laser technology used in this case for both targeting and defense\n" + + "Summons a powerful weapon above your head that fires lasers at nearby enemies"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 26; - item.height = 26; - item.summon = true; - item.damage = 41; - item.knockBack = 2f; - item.mana = 10; - item.useTime = item.useAnimation = 24; - item.autoReuse = true; + item.width = 26; + item.height = 26; + item.summon = true; + item.damage = 41; + item.knockBack = 2f; + item.mana = 10; + item.useTime = item.useAnimation = 24; + item.autoReuse = true; - item.useStyle = ItemUseStyleID.HoldingUp; - item.UseSound = SoundID.Item15; - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingUp; + item.UseSound = SoundID.Item15; + item.noMelee = true; - item.value = CalamityGlobalItem.Rarity5BuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity5BuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 1f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 1f; - modItem.UsesCharge = true; - modItem.MaxCharge = 85f; - modItem.ChargePerUse = 0.85f; - modItem.ChargePerAltUse = 0f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 85f; + modItem.ChargePerUse = 0.85f; + modItem.ChargePerAltUse = 0f; + } - 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(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI); - int totalOwnedScanners = player.ownedProjectileCounts[type]; - int currentScannerIndex = 0; - foreach (Projectile projectile in Main.projectile) - { - if (!projectile.active) - continue; - if (projectile.type != type) - continue; - if (projectile.owner != player.whoAmI) - continue; - float completionRatio = currentScannerIndex / (float)totalOwnedScanners; - - // ai[0] is the angular offset relative to the projectile's owner. - // For the first 15 summons, wrap around the player angularly, but not at a perfect angle, a bit like the Dazzling Stabbers when idle. - // But once the total summon count is greater than 15, just create a perfect circle depending on the total amount of summons. - if (totalOwnedScanners <= 14) - { - projectile.ai[0] = Utils.AngleLerp(0f, MathHelper.Pi, currentScannerIndex / 15f); - if (currentScannerIndex % 2f == 1f) - projectile.ai[0] = -Utils.AngleLerp(0f, MathHelper.Pi, (currentScannerIndex + 1) / 15f); - } - else - { - projectile.ai[0] = MathHelper.TwoPi / totalOwnedScanners * currentScannerIndex; - } + 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(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI); + int totalOwnedScanners = player.ownedProjectileCounts[type]; + int currentScannerIndex = 0; + foreach (Projectile projectile in Main.projectile) + { + if (!projectile.active) + continue; + if (projectile.type != type) + continue; + if (projectile.owner != player.whoAmI) + continue; + float completionRatio = currentScannerIndex / (float)totalOwnedScanners; + + // ai[0] is the angular offset relative to the projectile's owner. + // For the first 15 summons, wrap around the player angularly, but not at a perfect angle, a bit like the Dazzling Stabbers when idle. + // But once the total summon count is greater than 15, just create a perfect circle depending on the total amount of summons. + if (totalOwnedScanners <= 14) + { + projectile.ai[0] = Utils.AngleLerp(0f, MathHelper.Pi, currentScannerIndex / 15f); + if (currentScannerIndex % 2f == 1f) + projectile.ai[0] = -Utils.AngleLerp(0f, MathHelper.Pi, (currentScannerIndex + 1) / 15f); + } + else + { + projectile.ai[0] = MathHelper.TwoPi / totalOwnedScanners * currentScannerIndex; + } - // Add a specific offset so that the scanners spawn above the player at first and not to the side. - projectile.ai[0] -= MathHelper.PiOver2; - projectile.netUpdate = true; - currentScannerIndex++; - } - return false; - } + // Add a specific offset so that the scanners spawn above the player at first and not to the side. + projectile.ai[0] -= MathHelper.PiOver2; + projectile.netUpdate = true; + currentScannerIndex++; + } + return false; + } - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddRecipeGroup("AnyMythrilBar", 10); + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddRecipeGroup("AnyMythrilBar", 10); recipe.AddIngredient(ItemID.SoulofFright, 20); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/Phaseslayer.cs b/Items/Weapons/DraedonsArsenal/Phaseslayer.cs index bd6671a5a0..9bded24fc8 100644 --- a/Items/Weapons/DraedonsArsenal/Phaseslayer.cs +++ b/Items/Weapons/DraedonsArsenal/Phaseslayer.cs @@ -10,78 +10,78 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class Phaseslayer : ModItem - { - public const int Damage = 980; - // When below this percentage of charge, the sword is small instead of big. - public const float SizeChargeThreshold = 0.25f; - // The small sword barely affects damage on its own because damage is already dropping significantly at low charge. - public const float SmallDamageMultiplier = 0.9f; - // This is the amount of charge consumed every frame the holdout projectile is summoned, i.e. the weapon is in use. - public const float HoldoutChargeUse = 0.005f; - // This is the amount of charge consumed every time a sword beam is fired. - public const float SwordBeamChargeUse = 0.1f; + public class Phaseslayer : ModItem + { + public const int Damage = 980; + // When below this percentage of charge, the sword is small instead of big. + public const float SizeChargeThreshold = 0.25f; + // The small sword barely affects damage on its own because damage is already dropping significantly at low charge. + public const float SmallDamageMultiplier = 0.9f; + // This is the amount of charge consumed every frame the holdout projectile is summoned, i.e. the weapon is in use. + public const float HoldoutChargeUse = 0.005f; + // This is the amount of charge consumed every time a sword beam is fired. + public const float SwordBeamChargeUse = 0.1f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Phaseslayer"); - Tooltip.SetDefault("A rough prototype of the Murasama blade, it is formed entirely from laser energy\n" + - "Wield a colossal laser blade which is controlled by the cursor\n" + - "Faster swings deal more damage and release sword beams\n" + - "When at low charge, the blade is smaller and weaker"); - } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Phaseslayer"); + Tooltip.SetDefault("A rough prototype of the Murasama blade, it is formed entirely from laser energy\n" + + "Wield a colossal laser blade which is controlled by the cursor\n" + + "Faster swings deal more damage and release sword beams\n" + + "When at low charge, the blade is smaller and weaker"); + } + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.damage = Damage; - item.melee = true; - item.width = 26; - item.height = 26; - item.useTime = 24; - item.useAnimation = 24; - item.useStyle = ItemUseStyleID.HoldingOut; - item.useTurn = false; - item.knockBack = 7f; + item.damage = Damage; + item.melee = true; + item.width = 26; + item.height = 26; + item.useTime = 24; + item.useAnimation = 24; + item.useStyle = ItemUseStyleID.HoldingOut; + item.useTurn = false; + item.knockBack = 7f; - item.noUseGraphic = true; + item.noUseGraphic = true; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + modItem.customRarity = CalamityRarity.DraedonRust; - item.UseSound = SoundID.Item1; - item.autoReuse = true; + item.UseSound = SoundID.Item1; + item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.channel = true; + item.shoot = ModContent.ProjectileType(); + item.channel = true; - modItem.UsesCharge = true; - modItem.MaxCharge = 250f; - modItem.ChargePerUse = 0f; // This weapon is a holdout. Charge is consumed by the holdout projectile. - } + modItem.UsesCharge = true; + modItem.MaxCharge = 250f; + modItem.ChargePerUse = 0f; // This weapon is a holdout. Charge is consumed by the holdout projectile. + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && item.Calamity().Charge > 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && item.Calamity().Charge > 0; - 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 blade = Projectile.NewProjectileDirect(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); - blade.rotation = blade.AngleTo(Main.MouseWorld); - return false; - } + 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 blade = Projectile.NewProjectileDirect(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); + blade.rotation = blade.AngleTo(Main.MouseWorld); + return false; + } - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 25); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 25); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs b/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs index 945a93449a..1b65c7fd69 100644 --- a/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs +++ b/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs @@ -9,105 +9,105 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - // still awkward that the item called Plasma Rifle is the same class and exact same tier as this item - public class PlasmaCaster : ModItem - { - public const int BaseDamage = 705; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Plasma Caster"); - Tooltip.SetDefault("Industrial tool used to fuse metal together with super-heated plasma\n" + - "Right click for turbo mode"); - } + // still awkward that the item called Plasma Rifle is the same class and exact same tier as this item + public class PlasmaCaster : ModItem + { + public const int BaseDamage = 705; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plasma Caster"); + Tooltip.SetDefault("Industrial tool used to fuse metal together with super-heated plasma\n" + + "Right click for turbo mode"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 62; - item.height = 30; - item.magic = true; - item.damage = BaseDamage; - item.knockBack = 7f; - item.useTime = 45; - item.useAnimation = 45; - item.autoReuse = true; - item.mana = 24; + item.width = 62; + item.height = 30; + item.magic = true; + item.damage = BaseDamage; + item.knockBack = 7f; + item.useTime = 45; + item.useAnimation = 45; + item.autoReuse = true; + item.mana = 24; - item.useStyle = ItemUseStyleID.HoldingOut; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaCasterFire"); - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaCasterFire"); + item.noMelee = true; - item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 5f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 5f; - modItem.UsesCharge = true; - modItem.MaxCharge = 190f; - modItem.ChargePerUse = 0.32f; - modItem.ChargePerAltUse = 0.12f; // turbo mode is more energy inefficient - } + modItem.UsesCharge = true; + modItem.MaxCharge = 190f; + modItem.ChargePerUse = 0.32f; + modItem.ChargePerAltUse = 0.12f; // turbo mode is more energy inefficient + } - public override bool AltFunctionUse(Player player) => true; + public override bool AltFunctionUse(Player player) => true; - public override float UseTimeMultiplier (Player player) - { - if (player.altFunctionUse == 2) - return 3f; - return 1f; - } + public override float UseTimeMultiplier (Player player) + { + if (player.altFunctionUse == 2) + return 3f; + return 1f; + } - public override void ModifyManaCost(Player player, ref float reduce, ref float mult) - { - if (player.altFunctionUse == 2) - mult /= 3f; - } + public override void ModifyManaCost(Player player, ref float reduce, ref float mult) + { + if (player.altFunctionUse == 2) + mult /= 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) - { - Vector2 velocity = new Vector2(speedX, speedY); - if (velocity.Length() > 5f) - { - velocity.Normalize(); - velocity *= 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) + { + Vector2 velocity = new Vector2(speedX, speedY); + if (velocity.Length() > 5f) + { + velocity.Normalize(); + velocity *= 5f; + } - float SpeedX = velocity.X + Main.rand.Next(-3, 4) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-3, 4) * 0.05f; - float damageMult = 1f; - float kbMult = 1f; - if (player.altFunctionUse == 2) - { - SpeedX = velocity.X + Main.rand.Next(-15, 16) * 0.05f; - SpeedY = velocity.Y + Main.rand.Next(-15, 16) * 0.05f; - damageMult = 0.3333f; - kbMult = 3f / 7f; - } + float SpeedX = velocity.X + Main.rand.Next(-3, 4) * 0.05f; + float SpeedY = velocity.Y + Main.rand.Next(-3, 4) * 0.05f; + float damageMult = 1f; + float kbMult = 1f; + if (player.altFunctionUse == 2) + { + SpeedX = velocity.X + Main.rand.Next(-15, 16) * 0.05f; + SpeedY = velocity.Y + Main.rand.Next(-15, 16) * 0.05f; + damageMult = 0.3333f; + kbMult = 3f / 7f; + } - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * damageMult), knockBack * kbMult, player.whoAmI, 0f, 0f); - return false; - } + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * damageMult), knockBack * kbMult, player.whoAmI, 0f, 0f); + return false; + } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } + public override Vector2? HoldoutOffset() + { + return new Vector2(-10, 0); + } - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); - recipe.AddIngredient(ModContent.ItemType(), 18); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ItemID.LunarBar, 4); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); + recipe.AddIngredient(ModContent.ItemType(), 18); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ItemID.LunarBar, 4); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/PoleWarper.cs b/Items/Weapons/DraedonsArsenal/PoleWarper.cs index 4f7c2e152b..3a10cf0a30 100644 --- a/Items/Weapons/DraedonsArsenal/PoleWarper.cs +++ b/Items/Weapons/DraedonsArsenal/PoleWarper.cs @@ -10,91 +10,91 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class PoleWarper : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pole Warper"); - Tooltip.SetDefault("Magnetic devices which tear at foes by propelling themselves off their opposite counterparts\n" + - "Incredibly dangerous\n" + - "Summons a pair of floating magnets that repel each other and relentlessly swarm enemies"); - } + public class PoleWarper : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pole Warper"); + Tooltip.SetDefault("Magnetic devices which tear at foes by propelling themselves off their opposite counterparts\n" + + "Incredibly dangerous\n" + + "Summons a pair of floating magnets that repel each other and relentlessly swarm enemies"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.shootSpeed = 10f; - item.damage = 310; - item.mana = 12; - item.width = 38; - item.height = 24; - item.useTime = item.useAnimation = 9; - item.useStyle = ItemUseStyleID.HoldingUp; - item.noMelee = true; - item.knockBack = 8f; + item.shootSpeed = 10f; + item.damage = 310; + item.mana = 12; + item.width = 38; + item.height = 24; + item.useTime = item.useAnimation = 9; + item.useStyle = ItemUseStyleID.HoldingUp; + item.noMelee = true; + item.knockBack = 8f; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + modItem.customRarity = CalamityRarity.DraedonRust; - item.UseSound = SoundID.Item15; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 10f; - item.summon = true; + item.UseSound = SoundID.Item15; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; - modItem.UsesCharge = true; - modItem.MaxCharge = 250f; - modItem.ChargePerUse = 1.25f; - modItem.ChargePerAltUse = 0f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 250f; + modItem.ChargePerUse = 1.25f; + modItem.ChargePerAltUse = 0f; + } - 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 north = Projectile.NewProjectileDirect(Main.MouseWorld + Vector2.UnitY * 30f, Vector2.Zero, type, damage, knockBack, player.whoAmI); - Projectile south = Projectile.NewProjectileDirect(Main.MouseWorld - Vector2.UnitY * 30f, Vector2.Zero, type, damage, knockBack, player.whoAmI); - north.ai[1] = 1f; - south.ai[1] = 0f; + 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 north = Projectile.NewProjectileDirect(Main.MouseWorld + Vector2.UnitY * 30f, Vector2.Zero, type, damage, knockBack, player.whoAmI); + Projectile south = Projectile.NewProjectileDirect(Main.MouseWorld - Vector2.UnitY * 30f, Vector2.Zero, type, damage, knockBack, player.whoAmI); + north.ai[1] = 1f; + south.ai[1] = 0f; - float magnetCount = 0f; + float magnetCount = 0f; - for (int i = 0; i < Main.projectile.Length; i++) - { - if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) - { - magnetCount++; - } - } + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) + { + magnetCount++; + } + } - // Adjust the offset of all existing magnets such that they form a psuedo-circle. - // This offset is used when determining where a magnet should move to relative to its true destination (such as the player or an enemy). - int magnetIndex = 0; - for (int i = 0; i < Main.projectile.Length; i++) - { - if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) - { - ((PoleWarperSummon)Main.projectile[i].modProjectile).Time = 0f; - ((PoleWarperSummon)Main.projectile[i].modProjectile).AngularOffset = MathHelper.TwoPi * magnetIndex / magnetCount; - magnetIndex++; - } - } + // Adjust the offset of all existing magnets such that they form a psuedo-circle. + // This offset is used when determining where a magnet should move to relative to its true destination (such as the player or an enemy). + int magnetIndex = 0; + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) + { + ((PoleWarperSummon)Main.projectile[i].modProjectile).Time = 0f; + ((PoleWarperSummon)Main.projectile[i].modProjectile).AngularOffset = MathHelper.TwoPi * magnetIndex / magnetCount; + magnetIndex++; + } + } - return false; - } + return false; + } - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); - recipe.AddIngredient(ModContent.ItemType(), 25); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); + recipe.AddIngredient(ModContent.ItemType(), 25); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/PulsePistol.cs b/Items/Weapons/DraedonsArsenal/PulsePistol.cs index d869be0ff3..1bb1c457d2 100644 --- a/Items/Weapons/DraedonsArsenal/PulsePistol.cs +++ b/Items/Weapons/DraedonsArsenal/PulsePistol.cs @@ -10,62 +10,62 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class PulsePistol : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pulse Pistol"); - Tooltip.SetDefault("Fires a pulse that arcs to a new target on enemy hits"); - } + public class PulsePistol : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pulse Pistol"); + Tooltip.SetDefault("Fires a pulse that arcs to a new target on enemy hits"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 62; - item.height = 22; - item.magic = true; - item.damage = 26; - item.knockBack = 0f; - item.useTime = item.useAnimation = 20; - item.autoReuse = true; + item.width = 62; + item.height = 22; + item.magic = true; + item.damage = 26; + item.knockBack = 0f; + item.useTime = item.useAnimation = 20; + item.autoReuse = true; - item.useStyle = ItemUseStyleID.HoldingOut; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PulseRifleFire"); - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PulseRifleFire"); + item.noMelee = true; - item.value = CalamityGlobalItem.Rarity3BuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity3BuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 5.2f; // This may seem low but the shot has 10 extra updates. + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 5.2f; // This may seem low but the shot has 10 extra updates. - modItem.UsesCharge = true; - modItem.MaxCharge = 50f; - modItem.ChargePerUse = 0.05f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 50f; + modItem.ChargePerUse = 0.05f; + } - 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - return false; - } + 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } - public override Vector2? HoldoutOffset() => new Vector2(10f, 0f); + public override Vector2? HoldoutOffset() => new Vector2(10f, 0f); - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 7); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddIngredient(ModContent.ItemType(), 7); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 7); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ModContent.ItemType(), 7); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/PulseRifle.cs b/Items/Weapons/DraedonsArsenal/PulseRifle.cs index 92d78c26a2..a953c148de 100644 --- a/Items/Weapons/DraedonsArsenal/PulseRifle.cs +++ b/Items/Weapons/DraedonsArsenal/PulseRifle.cs @@ -10,76 +10,76 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class PulseRifle : ModItem - { - private int BaseDamage = 1420; + public class PulseRifle : ModItem + { + private int BaseDamage = 1420; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pulse Rifle"); - Tooltip.SetDefault("Draedon's former pulse rifle, used in emergencies for creations which turned against him\n" + - "When the pulse hits a target it will arc to another nearby target"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pulse Rifle"); + Tooltip.SetDefault("Draedon's former pulse rifle, used in emergencies for creations which turned against him\n" + + "When the pulse hits a target it will arc to another nearby target"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 62; - item.height = 22; - item.ranged = true; - item.damage = BaseDamage; - item.knockBack = 0f; - item.useTime = 35; - item.useAnimation = 35; - item.autoReuse = true; + item.width = 62; + item.height = 22; + item.ranged = true; + item.damage = BaseDamage; + item.knockBack = 0f; + item.useTime = 35; + item.useAnimation = 35; + item.autoReuse = true; - item.useStyle = ItemUseStyleID.HoldingOut; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PulseRifleFire"); - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PulseRifleFire"); + item.noMelee = true; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 5f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 5f; - modItem.UsesCharge = true; - modItem.MaxCharge = 250f; - modItem.ChargePerUse = 0.24f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 250f; + modItem.ChargePerUse = 0.24f; + } - 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) - { - velocity.Normalize(); - velocity *= 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) + { + Vector2 velocity = new Vector2(speedX, speedY); + if (velocity.Length() > 5f) + { + velocity.Normalize(); + velocity *= 5f; + } - float SpeedX = velocity.X + (float)Main.rand.Next(-1, 2) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-1, 2) * 0.05f; + float SpeedX = velocity.X + (float)Main.rand.Next(-1, 2) * 0.05f; + float SpeedY = velocity.Y + (float)Main.rand.Next(-1, 2) * 0.05f; - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - return false; - } + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); - recipe.AddIngredient(ModContent.ItemType(), 20); - recipe.AddIngredient(ModContent.ItemType(), 20); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs b/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs index 38262d9360..a6922abb88 100644 --- a/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs +++ b/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs @@ -9,67 +9,67 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class PulseTurretRemote : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pulse Turret Remote"); - Tooltip.SetDefault("A device used to defend against the weaker, less cognizant rogue creations of Draedon\n" + - "Summons a pulse turret which eradicates nearby foes with focused energy blasts\n" + - "Only one pulse turret may exist at a time"); - } + public class PulseTurretRemote : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pulse Turret Remote"); + Tooltip.SetDefault("A device used to defend against the weaker, less cognizant rogue creations of Draedon\n" + + "Summons a pulse turret which eradicates nearby foes with focused energy blasts\n" + + "Only one pulse turret may exist at a time"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 28; - item.height = 26; - item.summon = true; - item.sentry = true; - item.damage = 100; - item.knockBack = 0f; - item.mana = 10; - item.useTime = item.useAnimation = 24; - item.autoReuse = true; + item.width = 28; + item.height = 26; + item.summon = true; + item.sentry = true; + item.damage = 100; + item.knockBack = 0f; + item.mana = 10; + item.useTime = item.useAnimation = 24; + item.autoReuse = true; - item.useStyle = ItemUseStyleID.HoldingUp; - item.UseSound = SoundID.Item15; - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingUp; + item.UseSound = SoundID.Item15; + item.noMelee = true; - item.value = CalamityGlobalItem.Rarity8BuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity8BuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 1f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 1f; - modItem.UsesCharge = true; - modItem.MaxCharge = 135f; - modItem.ChargePerUse = 1f; - modItem.ChargePerAltUse = 0f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 135f; + modItem.ChargePerUse = 1f; + modItem.ChargePerAltUse = 0f; + } - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - CalamityUtils.OnlyOneSentry(player, type); - Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); - player.UpdateMaxTurrets(); - return false; - } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + CalamityUtils.OnlyOneSentry(player, type); + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); + player.UpdateMaxTurrets(); + return false; + } - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ModContent.ItemType(), 18); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddIngredient(ModContent.ItemType(), 18); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/SnakeEyes.cs b/Items/Weapons/DraedonsArsenal/SnakeEyes.cs index a03de00f3f..2f18304e93 100644 --- a/Items/Weapons/DraedonsArsenal/SnakeEyes.cs +++ b/Items/Weapons/DraedonsArsenal/SnakeEyes.cs @@ -9,63 +9,63 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class SnakeEyes : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Snake Eyes"); - Tooltip.SetDefault("Surveillance drones equipped with a strong electric field which can be directed at enemies\n" + - "Summons a mechanical watcher that zaps and flies around enemies"); - } + public class SnakeEyes : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Snake Eyes"); + Tooltip.SetDefault("Surveillance drones equipped with a strong electric field which can be directed at enemies\n" + + "Summons a mechanical watcher that zaps and flies around enemies"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.shootSpeed = 10f; - item.damage = 36; - item.mana = 12; - item.width = 38; - item.height = 24; - item.useTime = item.useAnimation = 14; - item.useStyle = ItemUseStyleID.HoldingUp; - item.noMelee = true; - item.knockBack = 3f; + item.shootSpeed = 10f; + item.damage = 36; + item.mana = 12; + item.width = 38; + item.height = 24; + item.useTime = item.useAnimation = 14; + item.useStyle = ItemUseStyleID.HoldingUp; + item.noMelee = true; + item.knockBack = 3f; - item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; - item.UseSound = SoundID.Item15; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 10f; - item.summon = true; + item.UseSound = SoundID.Item15; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; - modItem.UsesCharge = true; - modItem.MaxCharge = 190f; - modItem.ChargePerUse = 1f; - modItem.ChargePerAltUse = 0f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 190f; + modItem.ChargePerUse = 1f; + modItem.ChargePerAltUse = 0f; + } - 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(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); - return false; - } + 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(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); + return false; + } - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); - recipe.AddIngredient(ModContent.ItemType(), 18); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ItemID.LunarBar, 4); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); + recipe.AddIngredient(ModContent.ItemType(), 18); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ItemID.LunarBar, 4); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/StarSwallowerContainmentUnit.cs b/Items/Weapons/DraedonsArsenal/StarSwallowerContainmentUnit.cs index 7462aea9ae..5086b1dd4d 100644 --- a/Items/Weapons/DraedonsArsenal/StarSwallowerContainmentUnit.cs +++ b/Items/Weapons/DraedonsArsenal/StarSwallowerContainmentUnit.cs @@ -10,65 +10,65 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class StarSwallowerContainmentUnit : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Star Swallower Containment Unit"); - Tooltip.SetDefault("Small novelties created to easily transport and fire plasma, strangely popular with humans\n" + - "Summons a biomechanical frog that vomits plasma onto enemies"); - } + public class StarSwallowerContainmentUnit : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Star Swallower Containment Unit"); + Tooltip.SetDefault("Small novelties created to easily transport and fire plasma, strangely popular with humans\n" + + "Summons a biomechanical frog that vomits plasma onto enemies"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.shootSpeed = 10f; - item.damage = 24; - item.mana = 10; - item.width = 18; - item.height = 28; - item.useTime = item.useAnimation = 30; - item.useStyle = ItemUseStyleID.HoldingUp; - item.noMelee = true; - item.knockBack = 2.25f; - item.value = CalamityGlobalItem.Rarity3BuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; - item.UseSound = SoundID.Item15; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 10f; - item.summon = true; + item.shootSpeed = 10f; + item.damage = 24; + item.mana = 10; + item.width = 18; + item.height = 28; + item.useTime = item.useAnimation = 30; + item.useStyle = ItemUseStyleID.HoldingUp; + item.noMelee = true; + item.knockBack = 2.25f; + item.value = CalamityGlobalItem.Rarity3BuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; + item.UseSound = SoundID.Item15; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; - modItem.UsesCharge = true; - modItem.MaxCharge = 50f; - modItem.ChargePerUse = 0.8f; - modItem.ChargePerAltUse = 0f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 50f; + modItem.ChargePerUse = 0.8f; + modItem.ChargePerAltUse = 0f; + } - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - Point mouseTileCoords = Main.MouseWorld.ToTileCoordinates(); - if (!CalamityUtils.ParanoidTileRetrieval(mouseTileCoords.X, mouseTileCoords.Y).active()) - { - Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); - } - return false; - } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Point mouseTileCoords = Main.MouseWorld.ToTileCoordinates(); + if (!CalamityUtils.ParanoidTileRetrieval(mouseTileCoords.X, mouseTileCoords.Y).active()) + { + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); + } + return false; + } - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddIngredient(ModContent.ItemType(), 7); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ModContent.ItemType(), 7); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/SystemBane.cs b/Items/Weapons/DraedonsArsenal/SystemBane.cs index 897eb303c3..115c81c338 100644 --- a/Items/Weapons/DraedonsArsenal/SystemBane.cs +++ b/Items/Weapons/DraedonsArsenal/SystemBane.cs @@ -54,9 +54,9 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal 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, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/DraedonsArsenal/Taser.cs b/Items/Weapons/DraedonsArsenal/Taser.cs index 233beb2a04..b93bacb7f6 100644 --- a/Items/Weapons/DraedonsArsenal/Taser.cs +++ b/Items/Weapons/DraedonsArsenal/Taser.cs @@ -9,57 +9,57 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class Taser : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Taser"); - Tooltip.SetDefault("A slow, simple electric weapon, meant only for low ranking guards\n" + - "Shoots a hook that attaches to enemies and electrocutes them before returning"); - } + public class Taser : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Taser"); + Tooltip.SetDefault("A slow, simple electric weapon, meant only for low ranking guards\n" + + "Shoots a hook that attaches to enemies and electrocutes them before returning"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 50; - item.height = 26; - item.ranged = true; - item.damage = 22; - item.knockBack = 0f; - item.useTime = item.useAnimation = 28; - item.autoReuse = true; + item.width = 50; + item.height = 26; + item.ranged = true; + item.damage = 22; + item.knockBack = 0f; + item.useTime = item.useAnimation = 28; + item.autoReuse = true; - item.useStyle = ItemUseStyleID.HoldingOut; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBolt"); - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBolt"); + item.noMelee = true; - item.value = CalamityGlobalItem.Rarity3BuyPrice; - item.rare = ItemRarityID.Red; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity3BuyPrice; + item.rare = ItemRarityID.Red; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 15f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 15f; - modItem.UsesCharge = true; - modItem.MaxCharge = 50f; - modItem.ChargePerUse = 0.05f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 50f; + modItem.ChargePerUse = 0.05f; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); - recipe.AddIngredient(ModContent.ItemType(), 7); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddIngredient(ModContent.ItemType(), 7); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); + recipe.AddIngredient(ModContent.ItemType(), 7); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ModContent.ItemType(), 7); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/TeslaCannon.cs b/Items/Weapons/DraedonsArsenal/TeslaCannon.cs index 434c6363a8..09270afd3f 100644 --- a/Items/Weapons/DraedonsArsenal/TeslaCannon.cs +++ b/Items/Weapons/DraedonsArsenal/TeslaCannon.cs @@ -10,77 +10,77 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.DraedonsArsenal { - public class TeslaCannon : ModItem - { - private int BaseDamage = 1050; + public class TeslaCannon : ModItem + { + private int BaseDamage = 1050; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tesla Cannon"); - Tooltip.SetDefault("Lightweight energy cannon that blasts an intense electrical beam that explodes\n" + - "Beams can arc to nearby targets"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tesla Cannon"); + Tooltip.SetDefault("Lightweight energy cannon that blasts an intense electrical beam that explodes\n" + + "Beams can arc to nearby targets"); + } - public override void SetDefaults() - { - CalamityGlobalItem modItem = item.Calamity(); + public override void SetDefaults() + { + CalamityGlobalItem modItem = item.Calamity(); - item.width = 78; - item.height = 28; - item.magic = true; - item.damage = BaseDamage; - item.knockBack = 10f; - item.useTime = 90; - item.useAnimation = 90; - item.autoReuse = true; - item.mana = 30; + item.width = 78; + item.height = 28; + item.magic = true; + item.damage = BaseDamage; + item.knockBack = 10f; + item.useTime = 90; + item.useAnimation = 90; + item.autoReuse = true; + item.mana = 30; - item.useStyle = ItemUseStyleID.HoldingOut; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"); - item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"); + item.noMelee = true; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - modItem.customRarity = CalamityRarity.DraedonRust; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + modItem.customRarity = CalamityRarity.DraedonRust; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 5f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 5f; - modItem.UsesCharge = true; - modItem.MaxCharge = 250f; - modItem.ChargePerUse = 0.9f; - } + modItem.UsesCharge = true; + modItem.MaxCharge = 250f; + modItem.ChargePerUse = 0.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) - { - Vector2 velocity = new Vector2(speedX, speedY); - if (velocity.Length() > 5f) - { - velocity.Normalize(); - velocity *= 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) + { + Vector2 velocity = new Vector2(speedX, speedY); + if (velocity.Length() > 5f) + { + velocity.Normalize(); + velocity *= 5f; + } - float SpeedX = velocity.X + (float)Main.rand.Next(-1, 2) * 0.02f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-1, 2) * 0.02f; + float SpeedX = velocity.X + (float)Main.rand.Next(-1, 2) * 0.02f; + float SpeedY = velocity.Y + (float)Main.rand.Next(-1, 2) * 0.02f; - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - return false; - } + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } - public override Vector2? HoldoutOffset() => new Vector2(-20, 0); + public override Vector2? HoldoutOffset() => new Vector2(-20, 0); - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); - public override void AddRecipes() - { - ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); - recipe.AddIngredient(ModContent.ItemType(), 25); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); + recipe.AddIngredient(ModContent.ItemType(), 25); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/DraedonsArsenal/WavePounder.cs b/Items/Weapons/DraedonsArsenal/WavePounder.cs index fbb1d3b52e..e28cbbc3c5 100644 --- a/Items/Weapons/DraedonsArsenal/WavePounder.cs +++ b/Items/Weapons/DraedonsArsenal/WavePounder.cs @@ -52,9 +52,9 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal 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, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/Magic/AbyssShocker.cs b/Items/Weapons/Magic/AbyssShocker.cs index af9667c370..eab64db7c8 100644 --- a/Items/Weapons/Magic/AbyssShocker.cs +++ b/Items/Weapons/Magic/AbyssShocker.cs @@ -6,7 +6,7 @@ using CalamityMod.Projectiles.Magic; namespace CalamityMod.Items.Weapons.Magic { - public class AbyssShocker : ModItem + public class AbyssShocker : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Magic/AlphaRay.cs b/Items/Weapons/Magic/AlphaRay.cs index 2b174b4e93..bcf064f2a7 100644 --- a/Items/Weapons/Magic/AlphaRay.cs +++ b/Items/Weapons/Magic/AlphaRay.cs @@ -47,15 +47,15 @@ namespace CalamityMod.Items.Weapons.Magic if (player.altFunctionUse == 2) { Projectile.NewProjectile(position.X, position.Y, speedX * 1.35f, speedY * 1.35f, ModContent.ProjectileType(), (int)(damage * 1.6625), knockBack, player.whoAmI); - int laserAmt = 3; - float SpeedX = speedX + Main.rand.NextFloat(-1f, 1f); - float SpeedY = speedY + Main.rand.NextFloat(-1f, 1f); - for (int i = 0; i < laserAmt; ++i) - { - int laser = Projectile.NewProjectile(position.X, position.Y, SpeedX * 1.15f, SpeedY * 1.15f, ProjectileID.LaserMachinegunLaser, (int)(damage * 0.4), knockBack * 0.4f, player.whoAmI); - Main.projectile[laser].timeLeft = 120; + int laserAmt = 3; + float SpeedX = speedX + Main.rand.NextFloat(-1f, 1f); + float SpeedY = speedY + Main.rand.NextFloat(-1f, 1f); + for (int i = 0; i < laserAmt; ++i) + { + int laser = Projectile.NewProjectile(position.X, position.Y, SpeedX * 1.15f, SpeedY * 1.15f, ProjectileID.LaserMachinegunLaser, (int)(damage * 0.4), knockBack * 0.4f, player.whoAmI); + Main.projectile[laser].timeLeft = 120; Main.projectile[laser].tileCollide = false; - } + } } else { diff --git a/Items/Weapons/Magic/AlulaAustralis.cs b/Items/Weapons/Magic/AlulaAustralis.cs index dcbcecd9bb..9c5537991d 100644 --- a/Items/Weapons/Magic/AlulaAustralis.cs +++ b/Items/Weapons/Magic/AlulaAustralis.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class AlulaAustralis : ModItem + public class AlulaAustralis : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Magic/ApoctosisArray.cs b/Items/Weapons/Magic/ApoctosisArray.cs index cccd16b66f..d5d8da02e9 100644 --- a/Items/Weapons/Magic/ApoctosisArray.cs +++ b/Items/Weapons/Magic/ApoctosisArray.cs @@ -6,62 +6,62 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class ApoctosisArray : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Apoctosis Array"); - Tooltip.SetDefault("Fires ion blasts that speed up and then explode\n" + - "Damage scales with how full your mana is\n" + - "Using Astral Injection reduces the effectiveness of the mana boost"); - } + public class ApoctosisArray : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Apoctosis Array"); + Tooltip.SetDefault("Fires ion blasts that speed up and then explode\n" + + "Damage scales with how full your mana is\n" + + "Using Astral Injection reduces the effectiveness of the mana boost"); + } - public override void SetDefaults() - { - item.damage = 99; - item.width = 98; - item.height = 34; - item.magic = true; - item.mana = 12; - item.useAnimation = 7; - item.useTime = 7; - item.useStyle = ItemUseStyleID.HoldingOut; - item.knockBack = 6.75f; - item.UseSound = SoundID.Item91; - item.autoReuse = true; - item.noMelee = true; + public override void SetDefaults() + { + item.damage = 99; + item.width = 98; + item.height = 34; + item.magic = true; + item.mana = 12; + item.useAnimation = 7; + item.useTime = 7; + item.useStyle = ItemUseStyleID.HoldingOut; + item.knockBack = 6.75f; + item.UseSound = SoundID.Item91; + item.autoReuse = true; + item.noMelee = true; item.value = CalamityGlobalItem.Rarity10BuyPrice; item.rare = ItemRarityID.Red; item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 8f; - } + item.shootSpeed = 8f; + } - public override Vector2? HoldoutOffset() => new Vector2(-25, 0); + public override Vector2? HoldoutOffset() => new Vector2(-25, 0); - 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 manaRatio = (float)player.statMana / player.statManaMax2; - bool injectionNerf = player.Calamity().astralInjection; - if (injectionNerf) - manaRatio = MathHelper.Min(manaRatio, 0.65f); + 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 manaRatio = (float)player.statMana / player.statManaMax2; + bool injectionNerf = player.Calamity().astralInjection; + if (injectionNerf) + manaRatio = MathHelper.Min(manaRatio, 0.65f); - // 20% to 160% damage. Astral Injection caps it at 111% damage. - float damageRatio = 0.2f + 1.4f * manaRatio; - int finalDamage = (int)(damage * damageRatio); + // 20% to 160% damage. Astral Injection caps it at 111% damage. + float damageRatio = 0.2f + 1.4f * manaRatio; + int finalDamage = (int)(damage * damageRatio); - Projectile proj = Projectile.NewProjectileDirect(position, new Vector2(speedX, speedY), type, finalDamage, knockBack, player.whoAmI); - proj.scale = 0.75f + 0.75f * manaRatio; - return false; - } + Projectile proj = Projectile.NewProjectileDirect(position, new Vector2(speedX, speedY), type, finalDamage, knockBack, player.whoAmI); + proj.scale = 0.75f + 0.75f * manaRatio; + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.LunarBar, 5); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.LunarBar, 5); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Magic/Apotheosis.cs b/Items/Weapons/Magic/Apotheosis.cs index 8a9128440a..eeecd55e66 100644 --- a/Items/Weapons/Magic/Apotheosis.cs +++ b/Items/Weapons/Magic/Apotheosis.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class Apotheosis : ModItem + public class Apotheosis : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Magic/AstralStaff.cs b/Items/Weapons/Magic/AstralStaff.cs index 943febf838..2519157290 100644 --- a/Items/Weapons/Magic/AstralStaff.cs +++ b/Items/Weapons/Magic/AstralStaff.cs @@ -36,8 +36,8 @@ namespace CalamityMod.Items.Weapons.Magic item.shootSpeed = 15f; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 15; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 15; public override Vector2? HoldoutOrigin() => new Vector2(15, 15); diff --git a/Items/Weapons/Magic/BelchingSaxophone.cs b/Items/Weapons/Magic/BelchingSaxophone.cs index 58b90587df..cc97d02b33 100644 --- a/Items/Weapons/Magic/BelchingSaxophone.cs +++ b/Items/Weapons/Magic/BelchingSaxophone.cs @@ -9,14 +9,14 @@ namespace CalamityMod.Items.Weapons.Magic { public class BelchingSaxophone : ModItem { - public const int BaseDamage = 32; - private int counter = 0; + public const int BaseDamage = 32; + private int counter = 0; public override void SetStaticDefaults() { DisplayName.SetDefault("Belching Saxophone"); Tooltip.SetDefault("Doot\n" + - "Fires an array of dirty reeds, music notes, and sulphuric bubbles"); + "Fires an array of dirty reeds, music notes, and sulphuric bubbles"); } public override void SetDefaults() @@ -35,13 +35,13 @@ namespace CalamityMod.Items.Weapons.Magic item.rare = ItemRarityID.Pink; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); - //If a saxophone actually fired reeds, I'd be concerned. + //If a saxophone actually fired reeds, I'd be concerned. 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) { - counter++; + counter++; if (Main.rand.NextBool(2)) { @@ -58,19 +58,19 @@ namespace CalamityMod.Items.Weapons.Magic if (Main.rand.NextBool(2)) { - int noteProj = Utils.SelectRandom(Main.rand, new int[] - { - ProjectileID.QuarterNote, - ProjectileID.EighthNote, - ProjectileID.TiedEighthNote - }); + int noteProj = Utils.SelectRandom(Main.rand, new int[] + { + ProjectileID.QuarterNote, + ProjectileID.EighthNote, + ProjectileID.TiedEighthNote + }); int note = Projectile.NewProjectile(position.X, position.Y, speedX * 0.75f, speedY * 0.75f, noteProj, (int)(damage * 0.75), knockBack, player.whoAmI); - if (note.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[note].Calamity().forceMagic = true; //why are these notes also internally ranged - Main.projectile[note].usesLocalNPCImmunity = true; - Main.projectile[note].localNPCHitCooldown = 10; - } + if (note.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[note].Calamity().forceMagic = true; //why are these notes also internally ranged + Main.projectile[note].usesLocalNPCImmunity = true; + Main.projectile[note].localNPCHitCooldown = 10; + } } return false; } diff --git a/Items/Weapons/Magic/ClamorNoctus.cs b/Items/Weapons/Magic/ClamorNoctus.cs index f8f8821756..16daf38e5d 100644 --- a/Items/Weapons/Magic/ClamorNoctus.cs +++ b/Items/Weapons/Magic/ClamorNoctus.cs @@ -72,15 +72,15 @@ Fires night wyverns and stars from the sky that stick to enemies and tiles and e { float damageMult = 1f; float kbMult = 1f; - if (Main.rand.NextBool(10)) - { - type = ModContent.ProjectileType(); - } - if (type == ModContent.ProjectileType()) - { - damageMult = 25f; - kbMult = 1.5f; - } + if (Main.rand.NextBool(10)) + { + type = ModContent.ProjectileType(); + } + if (type == ModContent.ProjectileType()) + { + damageMult = 25f; + kbMult = 1.5f; + } vector2 = new Vector2(player.Center.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.Center.X), player.MountedCenter.Y - 600f); vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); vector2.Y -= (float)(100 * num108); diff --git a/Items/Weapons/Magic/ClothiersWrath.cs b/Items/Weapons/Magic/ClothiersWrath.cs index 045c22cf39..6a8ec8adbe 100644 --- a/Items/Weapons/Magic/ClothiersWrath.cs +++ b/Items/Weapons/Magic/ClothiersWrath.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetStaticDefaults() { DisplayName.SetDefault("Clothier's Wrath"); - Tooltip.SetDefault("Shoots 3 shadowflame skulls"); - } + Tooltip.SetDefault("Shoots 3 shadowflame skulls"); + } public override void SetDefaults() { @@ -26,12 +26,12 @@ namespace CalamityMod.Items.Weapons.Magic item.noMelee = true; item.knockBack = 3f; item.value = CalamityGlobalItem.Rarity4BuyPrice; - item.rare = ItemRarityID.LightRed; + item.rare = ItemRarityID.LightRed; item.UseSound = SoundID.Item8; item.autoReuse = true; item.shoot = ProjectileID.ClothiersCurse; item.shootSpeed = 6f; - } + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -41,8 +41,8 @@ namespace CalamityMod.Items.Weapons.Magic { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); int proj = Projectile.NewProjectile(position, perturbedSpeed, type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMagic = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMagic = true; } return false; } diff --git a/Items/Weapons/Magic/CosmicRainbow.cs b/Items/Weapons/Magic/CosmicRainbow.cs index c83f21e62a..d312dba61f 100644 --- a/Items/Weapons/Magic/CosmicRainbow.cs +++ b/Items/Weapons/Magic/CosmicRainbow.cs @@ -66,8 +66,8 @@ namespace CalamityMod.Items.Weapons.Magic value9 -= vector7; } int rainbow = Projectile.NewProjectile(vector.X + value9.X, vector.Y + value9.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[rainbow].usesLocalNPCImmunity = true; - Main.projectile[rainbow].localNPCHitCooldown = 10; + Main.projectile[rainbow].usesLocalNPCImmunity = true; + Main.projectile[rainbow].localNPCHitCooldown = 10; } float num72 = item.shootSpeed; Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); @@ -111,8 +111,8 @@ namespace CalamityMod.Items.Weapons.Magic float speedX4 = num78 + (float)Main.rand.Next(-15, 16) * 0.01f; float speedY5 = num79 + (float)Main.rand.Next(-15, 16) * 0.01f; int rainbow2 = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[rainbow2].usesLocalNPCImmunity = true; - Main.projectile[rainbow2].localNPCHitCooldown = 10; + Main.projectile[rainbow2].usesLocalNPCImmunity = true; + Main.projectile[rainbow2].localNPCHitCooldown = 10; } return false; } diff --git a/Items/Weapons/Magic/Cryophobia.cs b/Items/Weapons/Magic/Cryophobia.cs index 3bc9f5140c..ab99577618 100644 --- a/Items/Weapons/Magic/Cryophobia.cs +++ b/Items/Weapons/Magic/Cryophobia.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Magic { DisplayName.SetDefault("Cryophobia"); Tooltip.SetDefault("Chill\n" + - "Fires an icy wave that splits multiple times and explodes into shards"); + "Fires an icy wave that splits multiple times and explodes into shards"); } public override void SetDefaults() @@ -26,13 +26,13 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 1.5f; - item.value = CalamityGlobalItem.Rarity6BuyPrice; - item.rare = ItemRarityID.LightPurple; - item.UseSound = SoundID.Item117; + item.value = CalamityGlobalItem.Rarity6BuyPrice; + item.rare = ItemRarityID.LightPurple; + item.UseSound = SoundID.Item117; item.autoReuse = true; item.shootSpeed = 12f; item.shoot = ModContent.ProjectileType(); - } + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Magic/DeathValley.cs b/Items/Weapons/Magic/DeathValley.cs index 5419f29124..5104ce1355 100644 --- a/Items/Weapons/Magic/DeathValley.cs +++ b/Items/Weapons/Magic/DeathValley.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class DeathValley : ModItem + public class DeathValley : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Magic/DeathhailStaff.cs b/Items/Weapons/Magic/DeathhailStaff.cs index 52a464e690..de1ad0f35a 100644 --- a/Items/Weapons/Magic/DeathhailStaff.cs +++ b/Items/Weapons/Magic/DeathhailStaff.cs @@ -30,10 +30,10 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 4f; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.UseSound = SoundID.Item12; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.UseSound = SoundID.Item12; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 18f; @@ -46,7 +46,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Magic/DeathhailStaffGlow")); + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Magic/DeathhailStaffGlow")); } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) diff --git a/Items/Weapons/Magic/EldritchTome.cs b/Items/Weapons/Magic/EldritchTome.cs index c68dc98534..9e6c206394 100644 --- a/Items/Weapons/Magic/EldritchTome.cs +++ b/Items/Weapons/Magic/EldritchTome.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Magic item.shootSpeed = 12f; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 5; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 5; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Magic/ElementalRay.cs b/Items/Weapons/Magic/ElementalRay.cs index bcf4e87f8c..270f71c14a 100644 --- a/Items/Weapons/Magic/ElementalRay.cs +++ b/Items/Weapons/Magic/ElementalRay.cs @@ -28,14 +28,14 @@ namespace CalamityMod.Items.Weapons.Magic item.width = 62; item.height = 62; item.useTime = 4; - item.useAnimation = 16; + item.useAnimation = 16; item.reuseDelay = 14; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 7.5f; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.UseSound = SoundID.Item60; + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.UseSound = SoundID.Item60; item.autoReuse = true; item.shoot = 1; item.shootSpeed = 6f; @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Magic public override Vector2? HoldoutOrigin() => new Vector2(15); - public override bool Shoot(Player player, ref 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 offsetAngle = MathHelper.TwoPi * player.itemAnimation / player.itemAnimationMax; offsetAngle += MathHelper.PiOver4 + Main.rand.NextFloat(0f, 1.3f); @@ -77,9 +77,9 @@ namespace CalamityMod.Items.Weapons.Magic Main.projectile[beam].ai[1] = Main.rand.Next(100); } return false; - } + } - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); diff --git a/Items/Weapons/Magic/EventHorizon.cs b/Items/Weapons/Magic/EventHorizon.cs index c523d60ef4..3a48d472ba 100644 --- a/Items/Weapons/Magic/EventHorizon.cs +++ b/Items/Weapons/Magic/EventHorizon.cs @@ -7,14 +7,14 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class EventHorizon : ModItem + public class EventHorizon : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Event Horizon"); Tooltip.SetDefault("Nothing, not even light, can return.\n" + - "Fires a ring of stars to home in on nearby enemies\n" + - "Stars spawn black holes on enemy hits"); + "Fires a ring of stars to home in on nearby enemies\n" + + "Stars spawn black holes on enemy hits"); } public override void SetDefaults() @@ -32,11 +32,11 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.autoReuse = true; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.UseSound = SoundID.Item84; + item.UseSound = SoundID.Item84; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 25f; } diff --git a/Items/Weapons/Magic/FrigidflashBolt.cs b/Items/Weapons/Magic/FrigidflashBolt.cs index 0fe3c1f1e8..9e5b10f31e 100644 --- a/Items/Weapons/Magic/FrigidflashBolt.cs +++ b/Items/Weapons/Magic/FrigidflashBolt.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class FrigidflashBolt : ModItem + public class FrigidflashBolt : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Magic/GammaFusillade.cs b/Items/Weapons/Magic/GammaFusillade.cs index 38e230ff06..327973e85c 100644 --- a/Items/Weapons/Magic/GammaFusillade.cs +++ b/Items/Weapons/Magic/GammaFusillade.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class GammaFusillade : ModItem + public class GammaFusillade : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Magic/GloriousEnd.cs b/Items/Weapons/Magic/GloriousEnd.cs index fc73ce92a5..29f361ea8a 100644 --- a/Items/Weapons/Magic/GloriousEnd.cs +++ b/Items/Weapons/Magic/GloriousEnd.cs @@ -5,41 +5,41 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class GloriousEnd : ModItem - { - public static int PlayerExplosionDmgMin = 50; - public static int PlayerExplosionDmgMax = 60; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Glorious End"); - Tooltip.SetDefault("Casts a meteor star for the player to ride in the direction of the cursor\n" + - "The meteor star explodes after hitting an enemy, crashing into a wall, or after 6 seconds\n" + - "This explosion hurts both enemies and the player\n" + - "Releasing the cursor before the star explodes will cause it to explode prematurely for less damage\n" + - "Mounts are disabled while this weapon is in use"); - } + public class GloriousEnd : ModItem + { + public static int PlayerExplosionDmgMin = 50; + public static int PlayerExplosionDmgMax = 60; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Glorious End"); + Tooltip.SetDefault("Casts a meteor star for the player to ride in the direction of the cursor\n" + + "The meteor star explodes after hitting an enemy, crashing into a wall, or after 6 seconds\n" + + "This explosion hurts both enemies and the player\n" + + "Releasing the cursor before the star explodes will cause it to explode prematurely for less damage\n" + + "Mounts are disabled while this weapon is in use"); + } - public override void SetDefaults() - { - item.damage = 120; - item.knockBack = 10f; - item.useTime = item.useAnimation = 30; - item.mana = 20; - item.magic = true; - item.channel = true; - item.shootSpeed = 7f; - item.shoot = ModContent.ProjectileType(); + public override void SetDefaults() + { + item.damage = 120; + item.knockBack = 10f; + item.useTime = item.useAnimation = 30; + item.mana = 20; + item.magic = true; + item.channel = true; + item.shootSpeed = 7f; + item.shoot = ModContent.ProjectileType(); - item.width = 30; - item.height = 58; - item.useStyle = ItemUseStyleID.SwingThrow; - item.noMelee = true; - item.UseSound = SoundID.Item9; - item.value = CalamityGlobalItem.Rarity4BuyPrice; - item.rare = ItemRarityID.LightRed; - item.Calamity().donorItem = true; - } + item.width = 30; + item.height = 58; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.UseSound = SoundID.Item9; + item.value = CalamityGlobalItem.Rarity4BuyPrice; + item.rare = ItemRarityID.LightRed; + item.Calamity().donorItem = true; + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - } + } } diff --git a/Items/Weapons/Magic/HyphaeRod.cs b/Items/Weapons/Magic/HyphaeRod.cs index 5e04ef45e2..33683c0588 100644 --- a/Items/Weapons/Magic/HyphaeRod.cs +++ b/Items/Weapons/Magic/HyphaeRod.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Magic Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true); float xDist = (float)Main.mouseX + Main.screenPosition.X + source.X; float yDist = (float)Main.mouseY + Main.screenPosition.Y + source.Y; - Vector2 spawnVec = new Vector2(xDist, yDist); + Vector2 spawnVec = new Vector2(xDist, yDist); if (player.gravDir == -1f) { spawnVec.Y = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + source.Y; @@ -82,11 +82,11 @@ namespace CalamityMod.Items.Weapons.Magic spawnVec.X += (float)Main.rand.Next(-180, 181) * 0.02f; spawnVec.Y += (float)Main.rand.Next(-180, 181) * 0.02f; int proj = Projectile.NewProjectile(source, spawnVec, type, damage, knockBack, player.whoAmI, 0f, Main.rand.Next(3)); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().forceMagic = true; - Main.projectile[proj].timeLeft = CalamityUtils.SecondsToFrames(3f); - } + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMagic = true; + Main.projectile[proj].timeLeft = CalamityUtils.SecondsToFrames(3f); + } } return false; } diff --git a/Items/Weapons/Magic/InfernalRift.cs b/Items/Weapons/Magic/InfernalRift.cs index 58d9113b40..36d71476c6 100644 --- a/Items/Weapons/Magic/InfernalRift.cs +++ b/Items/Weapons/Magic/InfernalRift.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class InfernalRift : ModItem + public class InfernalRift : ModItem { public override void SetStaticDefaults() { @@ -37,8 +37,8 @@ namespace CalamityMod.Items.Weapons.Magic item.shootSpeed = 16f; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; public override Vector2? HoldoutOrigin() => new Vector2(15, 15); diff --git a/Items/Weapons/Magic/IonBlaster.cs b/Items/Weapons/Magic/IonBlaster.cs index e1cf2a27fc..d3d8136d8f 100644 --- a/Items/Weapons/Magic/IonBlaster.cs +++ b/Items/Weapons/Magic/IonBlaster.cs @@ -6,63 +6,63 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class IonBlaster : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ion Blaster"); - Tooltip.SetDefault("Fires ion blasts that speed up and then explode\n" + - "Damage scales with how full your mana is\n" + - "Using Astral Injection reduces the effectiveness of the mana boost"); - } + public class IonBlaster : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ion Blaster"); + Tooltip.SetDefault("Fires ion blasts that speed up and then explode\n" + + "Damage scales with how full your mana is\n" + + "Using Astral Injection reduces the effectiveness of the mana boost"); + } - public override void SetDefaults() - { - item.damage = 43; - item.width = 44; - item.height = 28; - item.magic = true; - item.mana = 6; - item.useAnimation = 10; - item.useTime = 10; - item.useStyle = ItemUseStyleID.HoldingOut; - item.knockBack = 5.5f; - item.UseSound = SoundID.Item91; - item.autoReuse = true; - item.noMelee = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 3f; + public override void SetDefaults() + { + item.damage = 43; + item.width = 44; + item.height = 28; + item.magic = true; + item.mana = 6; + item.useAnimation = 10; + item.useTime = 10; + item.useStyle = ItemUseStyleID.HoldingOut; + item.knockBack = 5.5f; + item.UseSound = SoundID.Item91; + item.autoReuse = true; + item.noMelee = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 3f; - item.value = CalamityGlobalItem.Rarity5BuyPrice; - item.rare = ItemRarityID.Pink; - } + item.value = CalamityGlobalItem.Rarity5BuyPrice; + item.rare = ItemRarityID.Pink; + } - public override Vector2? HoldoutOffset() => new Vector2(-5, 0); + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); - 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 manaRatio = (float)player.statMana / player.statManaMax2; - bool injectionNerf = player.Calamity().astralInjection; - if (injectionNerf) - manaRatio = MathHelper.Min(manaRatio, 0.65f); + 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 manaRatio = (float)player.statMana / player.statManaMax2; + bool injectionNerf = player.Calamity().astralInjection; + if (injectionNerf) + manaRatio = MathHelper.Min(manaRatio, 0.65f); - // 20% to 160% damage. Astral Injection caps it at 111% damage. - float damageRatio = 0.2f + 1.4f * manaRatio; - int finalDamage = (int)(damage * damageRatio); + // 20% to 160% damage. Astral Injection caps it at 111% damage. + float damageRatio = 0.2f + 1.4f * manaRatio; + int finalDamage = (int)(damage * damageRatio); - Projectile proj = Projectile.NewProjectileDirect(position, new Vector2(speedX, speedY), type, finalDamage, knockBack, player.whoAmI); - proj.scale = 0.75f + 0.75f * manaRatio; - return false; - } + Projectile proj = Projectile.NewProjectileDirect(position, new Vector2(speedX, speedY), type, finalDamage, knockBack, player.whoAmI); + proj.scale = 0.75f + 0.75f * manaRatio; + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.SoulofFright, 10); - recipe.AddRecipeGroup("AnyAdamantiteBar", 7); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.SoulofFright, 10); + recipe.AddRecipeGroup("AnyAdamantiteBar", 7); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Magic/Miasma.cs b/Items/Weapons/Magic/Miasma.cs index 0d3a500df8..692ca5cd0e 100644 --- a/Items/Weapons/Magic/Miasma.cs +++ b/Items/Weapons/Magic/Miasma.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Magic item.noMelee = true; item.knockBack = 3f; item.value = Item.buyPrice(0, 36, 0, 0); - item.rare = ItemRarityID.Pink; + item.rare = ItemRarityID.Pink; item.UseSound = SoundID.Item8; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Magic/Mistlestorm.cs b/Items/Weapons/Magic/Mistlestorm.cs index 5e1ddb257f..8e75f7779c 100644 --- a/Items/Weapons/Magic/Mistlestorm.cs +++ b/Items/Weapons/Magic/Mistlestorm.cs @@ -28,10 +28,10 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 3.5f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item39; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item39; item.autoReuse = true; item.shoot = ProjectileID.PineNeedleFriendly; item.shootSpeed = 24f; diff --git a/Items/Weapons/Magic/ParasiticSceptor.cs b/Items/Weapons/Magic/ParasiticSceptor.cs index 7c05664e6c..23f5b851a7 100644 --- a/Items/Weapons/Magic/ParasiticSceptor.cs +++ b/Items/Weapons/Magic/ParasiticSceptor.cs @@ -6,89 +6,89 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class ParasiticSceptor : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Parasitic Scepter"); - Tooltip.SetDefault("Fires a spread of water leeches that latch onto enemies, dealing a stacking damage over time"); - Item.staff[item.type] = true; - } + public class ParasiticSceptor : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Parasitic Scepter"); + Tooltip.SetDefault("Fires a spread of water leeches that latch onto enemies, dealing a stacking damage over time"); + Item.staff[item.type] = true; + } - public override void SetDefaults() - { - item.damage = 12; - item.knockBack = 3f; - item.mana = 10; - item.useTime = item.useAnimation = 35; - item.autoReuse = true; - item.magic = true; - item.shootSpeed = 10f; - item.shoot = ModContent.ProjectileType(); + public override void SetDefaults() + { + item.damage = 12; + item.knockBack = 3f; + item.mana = 10; + item.useTime = item.useAnimation = 35; + item.autoReuse = true; + item.magic = true; + item.shootSpeed = 10f; + item.shoot = ModContent.ProjectileType(); - item.width = item.height = 52; - item.UseSound = SoundID.Item46; - item.noMelee = true; - item.useStyle = ItemUseStyleID.HoldingOut; - item.rare = ItemRarityID.Green; - item.value = CalamityGlobalItem.Rarity2BuyPrice; - } + item.width = item.height = 52; + item.UseSound = SoundID.Item46; + item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.rare = ItemRarityID.Green; + item.value = CalamityGlobalItem.Rarity2BuyPrice; + } - public override Vector2? HoldoutOrigin() => new Vector2(15, 15); + public override Vector2? HoldoutOrigin() => new Vector2(15, 15); - 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 speed = item.shootSpeed; - Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float xDist = Main.mouseX + Main.screenPosition.X - playerPos.X; - float yDist = Main.mouseY + Main.screenPosition.Y - playerPos.Y; - if (player.gravDir == -1f) - { - yDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - playerPos.Y; - } - Vector2 vector = new Vector2(xDist, yDist); - float speedMult = vector.Length(); - if ((float.IsNaN(xDist) && float.IsNaN(yDist)) || (xDist == 0f && yDist == 0f)) - { - xDist = player.direction; - yDist = 0f; - speedMult = speed; - } - else - { - speedMult = speed / speedMult; - } - xDist *= speedMult; - yDist *= speedMult; - int leechAmt = 2; - if (Main.rand.NextBool(3)) - { - leechAmt++; - } - if (Main.rand.NextBool(4)) - { - leechAmt++; - } - if (Main.rand.NextBool(5)) - { - leechAmt ++; - } - for (int i = 0; i < leechAmt; i++) - { - float xVec = xDist; - float yVec = yDist; - float spreadMult = 0.05f * i; - xVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; - yVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; - Vector2 directionToShoot = new Vector2(xVec, yVec); - speedMult = directionToShoot.Length(); - speedMult = speed / speedMult; - xVec *= speedMult; - yVec *= speedMult; - directionToShoot = new Vector2(xVec, yVec); - Projectile.NewProjectile(playerPos, directionToShoot, type, damage, knockBack, player.whoAmI, 0f, 0f); - } - return false; - } - } + 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 speed = item.shootSpeed; + Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float xDist = Main.mouseX + Main.screenPosition.X - playerPos.X; + float yDist = Main.mouseY + Main.screenPosition.Y - playerPos.Y; + if (player.gravDir == -1f) + { + yDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - playerPos.Y; + } + Vector2 vector = new Vector2(xDist, yDist); + float speedMult = vector.Length(); + if ((float.IsNaN(xDist) && float.IsNaN(yDist)) || (xDist == 0f && yDist == 0f)) + { + xDist = player.direction; + yDist = 0f; + speedMult = speed; + } + else + { + speedMult = speed / speedMult; + } + xDist *= speedMult; + yDist *= speedMult; + int leechAmt = 2; + if (Main.rand.NextBool(3)) + { + leechAmt++; + } + if (Main.rand.NextBool(4)) + { + leechAmt++; + } + if (Main.rand.NextBool(5)) + { + leechAmt ++; + } + for (int i = 0; i < leechAmt; i++) + { + float xVec = xDist; + float yVec = yDist; + float spreadMult = 0.05f * i; + xVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; + yVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; + Vector2 directionToShoot = new Vector2(xVec, yVec); + speedMult = directionToShoot.Length(); + speedMult = speed / speedMult; + xVec *= speedMult; + yVec *= speedMult; + directionToShoot = new Vector2(xVec, yVec); + Projectile.NewProjectile(playerPos, directionToShoot, type, damage, knockBack, player.whoAmI, 0f, 0f); + } + return false; + } + } } diff --git a/Items/Weapons/Magic/PhoenixFlameBarrage.cs b/Items/Weapons/Magic/PhoenixFlameBarrage.cs index f055de87a5..6a924d41bb 100644 --- a/Items/Weapons/Magic/PhoenixFlameBarrage.cs +++ b/Items/Weapons/Magic/PhoenixFlameBarrage.cs @@ -29,10 +29,10 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 3.5f; - item.value = CalamityGlobalItem.Rarity15BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Violet; - item.UseSound = SoundID.Item20; + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.UseSound = SoundID.Item20; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 30f; diff --git a/Items/Weapons/Magic/PlasmaRifle.cs b/Items/Weapons/Magic/PlasmaRifle.cs index 157177884f..07738ded8d 100644 --- a/Items/Weapons/Magic/PlasmaRifle.cs +++ b/Items/Weapons/Magic/PlasmaRifle.cs @@ -27,10 +27,10 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 4f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBlast"); + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBlast"); item.autoReuse = true; item.shootSpeed = 12f; item.shoot = ModContent.ProjectileType(); @@ -53,18 +53,18 @@ namespace CalamityMod.Items.Weapons.Magic return base.CanUseItem(player); } - public override void ModifyManaCost(Player player, ref float reduce, ref float mult) - { - if (player.altFunctionUse == 2) - mult *= 0.25f; - } + public override void ModifyManaCost(Player player, ref float reduce, ref float mult) + { + if (player.altFunctionUse == 2) + mult *= 0.25f; + } - public override float UseTimeMultiplier (Player player) - { - if (player.altFunctionUse == 2) - return 1f; - return 0.2f; - } + public override float UseTimeMultiplier (Player player) + { + if (player.altFunctionUse == 2) + return 1f; + return 0.2f; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Magic/Poseidon.cs b/Items/Weapons/Magic/Poseidon.cs index d508d8ffb8..9337d5f241 100644 --- a/Items/Weapons/Magic/Poseidon.cs +++ b/Items/Weapons/Magic/Poseidon.cs @@ -36,9 +36,9 @@ namespace CalamityMod.Items.Weapons.Magic 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 typhoon = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[typhoon].penetrate = Main.rand.Next(4,11); - return false; + int typhoon = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); + Main.projectile[typhoon].penetrate = Main.rand.Next(4,11); + return false; } } } diff --git a/Items/Weapons/Magic/PrimordialAncient.cs b/Items/Weapons/Magic/PrimordialAncient.cs index 964be97af6..493f1a97e2 100644 --- a/Items/Weapons/Magic/PrimordialAncient.cs +++ b/Items/Weapons/Magic/PrimordialAncient.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class PrimordialAncient : ModItem + public class PrimordialAncient : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Magic/RelicofRuin.cs b/Items/Weapons/Magic/RelicofRuin.cs index 52f71bb43d..4064bfe708 100644 --- a/Items/Weapons/Magic/RelicofRuin.cs +++ b/Items/Weapons/Magic/RelicofRuin.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class RelicofRuin : ModItem + public class RelicofRuin : ModItem { public override void SetStaticDefaults() { @@ -36,12 +36,12 @@ namespace CalamityMod.Items.Weapons.Magic 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 totalProjectiles = 12; - float radians = MathHelper.TwoPi / totalProjectiles; + int totalProjectiles = 12; + float radians = MathHelper.TwoPi / totalProjectiles; for (int i = 0; i < totalProjectiles; i++) { - Vector2 vector = new Vector2(0f, -item.shootSpeed).RotatedBy(radians * i); - Projectile.NewProjectile(position, vector, type, damage, knockBack, Main.myPlayer); + Vector2 vector = new Vector2(0f, -item.shootSpeed).RotatedBy(radians * i); + Projectile.NewProjectile(position, vector, type, damage, knockBack, Main.myPlayer); } return false; } diff --git a/Items/Weapons/Magic/RougeSlash.cs b/Items/Weapons/Magic/RougeSlash.cs index 68f6878d6c..b1ecc32bf4 100644 --- a/Items/Weapons/Magic/RougeSlash.cs +++ b/Items/Weapons/Magic/RougeSlash.cs @@ -27,9 +27,9 @@ namespace CalamityMod.Items.Weapons.Magic item.noMelee = true; item.knockBack = 7.5f; item.UseSound = SoundID.Item91; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.autoReuse = true; + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 24f; } diff --git a/Items/Weapons/Magic/SHPC.cs b/Items/Weapons/Magic/SHPC.cs index e608f2b692..6da0f0a752 100644 --- a/Items/Weapons/Magic/SHPC.cs +++ b/Items/Weapons/Magic/SHPC.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Magic item.value = CalamityGlobalItem.Rarity5BuyPrice; item.rare = ItemRarityID.Pink; - } + } public override Vector2? HoldoutOffset() { @@ -59,18 +59,18 @@ namespace CalamityMod.Items.Weapons.Magic return base.CanUseItem(player); } - public override void ModifyManaCost(Player player, ref float reduce, ref float mult) - { - if (player.altFunctionUse == 2) - mult *= 0.3f; - } + public override void ModifyManaCost(Player player, ref float reduce, ref float mult) + { + if (player.altFunctionUse == 2) + mult *= 0.3f; + } - public override float UseTimeMultiplier (Player player) - { - if (player.altFunctionUse == 2) - return 1f; - return 0.14f; - } + public override float UseTimeMultiplier (Player player) + { + if (player.altFunctionUse == 2) + return 1f; + return 0.14f; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Magic/SanguineFlare.cs b/Items/Weapons/Magic/SanguineFlare.cs index a4d62c4d3c..08799bb6a3 100644 --- a/Items/Weapons/Magic/SanguineFlare.cs +++ b/Items/Weapons/Magic/SanguineFlare.cs @@ -28,10 +28,10 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 8f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item20; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item20; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 14f; diff --git a/Items/Weapons/Magic/ShiftingSands.cs b/Items/Weapons/Magic/ShiftingSands.cs index 49303807f9..4ecf5dce59 100644 --- a/Items/Weapons/Magic/ShiftingSands.cs +++ b/Items/Weapons/Magic/ShiftingSands.cs @@ -6,58 +6,58 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class ShiftingSands : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shifting Sands"); - Tooltip.SetDefault("Casts a sand shard that follows the mouse cursor"); - } + public class ShiftingSands : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shifting Sands"); + Tooltip.SetDefault("Casts a sand shard that follows the mouse cursor"); + } - public override void SetDefaults() - { - item.damage = 61; - item.knockBack = 5f; - item.useTime = item.useAnimation = 30; - item.mana = 20; - item.magic = true; - item.channel = true; - item.autoReuse = true; - item.shootSpeed = 7f; - item.shoot = ModContent.ProjectileType(); + public override void SetDefaults() + { + item.damage = 61; + item.knockBack = 5f; + item.useTime = item.useAnimation = 30; + item.mana = 20; + item.magic = true; + item.channel = true; + item.autoReuse = true; + item.shootSpeed = 7f; + item.shoot = ModContent.ProjectileType(); - item.width = item.height = 58; - item.useStyle = ItemUseStyleID.SwingThrow; - item.noMelee = true; - item.UseSound = SoundID.Item20; - item.value = Item.buyPrice(0, 60, 0, 0); - item.rare = ItemRarityID.Lime; - } + item.width = item.height = 58; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.UseSound = SoundID.Item20; + item.value = Item.buyPrice(0, 60, 0, 0); + item.rare = ItemRarityID.Lime; + } - public override bool CanUseItem(Player player) - { - int projCount = 0; - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile proj = Main.projectile[x]; - if (proj.active && proj.owner == player.whoAmI && proj.type == item.shoot && proj.ai[0] <= 0f) - { - projCount++; - } - } - return projCount <= 0; - } + public override bool CanUseItem(Player player) + { + int projCount = 0; + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile proj = Main.projectile[x]; + if (proj.active && proj.owner == player.whoAmI && proj.type == item.shoot && proj.ai[0] <= 0f) + { + projCount++; + } + } + return projCount <= 0; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.MagicMissile); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.AncientBattleArmorMaterial, 2); - recipe.AddIngredient(ItemID.SpectreBar, 5); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.MagicMissile); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.AncientBattleArmorMaterial, 2); + recipe.AddIngredient(ItemID.SpectreBar, 5); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Magic/SirensSong.cs b/Items/Weapons/Magic/SirensSong.cs index eba4543f7b..6782c0c2a6 100644 --- a/Items/Weapons/Magic/SirensSong.cs +++ b/Items/Weapons/Magic/SirensSong.cs @@ -37,21 +37,21 @@ namespace CalamityMod.Items.Weapons.Magic 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 xDist = Main.mouseX + Main.screenPosition.X - position.X; - float yDist = Main.mouseY + Main.screenPosition.Y - position.Y; - Vector2 mouseDist = new Vector2(xDist, yDist); - float soundMult = mouseDist.Length() / (Main.screenHeight / 2f); - if (soundMult > 1f) - soundMult = 1f; - float soundPitch = soundMult * 2f - 1f; - soundPitch = MathHelper.Clamp(soundPitch, -1f, 1f); + float xDist = Main.mouseX + Main.screenPosition.X - position.X; + float yDist = Main.mouseY + Main.screenPosition.Y - position.Y; + Vector2 mouseDist = new Vector2(xDist, yDist); + float soundMult = mouseDist.Length() / (Main.screenHeight / 2f); + if (soundMult > 1f) + soundMult = 1f; + float soundPitch = soundMult * 2f - 1f; + soundPitch = MathHelper.Clamp(soundPitch, -1f, 1f); speedX += Main.rand.NextFloat(-0.75f, 0.75f); speedY += Main.rand.NextFloat(-0.75f, 0.75f); - speedX *= soundMult + 0.25f; - speedY *= soundMult + 0.25f; + speedX *= soundMult + 0.25f; + speedY *= soundMult + 0.25f; - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, soundPitch, 0f); + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, soundPitch, 0f); return false; } } diff --git a/Items/Weapons/Magic/StardustStaff.cs b/Items/Weapons/Magic/StardustStaff.cs index 611dd47c5f..5228445f68 100644 --- a/Items/Weapons/Magic/StardustStaff.cs +++ b/Items/Weapons/Magic/StardustStaff.cs @@ -29,10 +29,10 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 7f; - item.value = Item.buyPrice(1, 40, 0, 0); - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.PureGreen; - item.UseSound = SoundID.Item43; + item.value = Item.buyPrice(1, 40, 0, 0); + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.PureGreen; + item.UseSound = SoundID.Item43; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; diff --git a/Items/Weapons/Magic/StratusSphere.cs b/Items/Weapons/Magic/StratusSphere.cs index e57510c61a..0d6b738777 100644 --- a/Items/Weapons/Magic/StratusSphere.cs +++ b/Items/Weapons/Magic/StratusSphere.cs @@ -7,52 +7,52 @@ using CalamityMod.Items.Placeables.Ores; namespace CalamityMod.Items.Weapons.Magic { - public class StratusSphere : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Stratus Sphere"); - Tooltip.SetDefault("Fires an energy orb containing the essence of our stratosphere\n" + - "Up to six of these can be active at a time"); - } - public override void SetDefaults() - { - item.damage = 251; - item.noMelee = true; - item.magic = true; - item.width = 22; - item.height = 24; - item.useTime = 45; - item.useAnimation = 45; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 7f; - item.useStyle = ItemUseStyleID.HoldingOut; - item.mana = 30; - item.knockBack = 2; - item.UseSound = SoundID.Item20; - item.rare = ItemRarityID.LightRed; - item.autoReuse = true; - item.useTurn = true; - item.noUseGraphic = true; - item.holdStyle = 3; + public class StratusSphere : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Stratus Sphere"); + Tooltip.SetDefault("Fires an energy orb containing the essence of our stratosphere\n" + + "Up to six of these can be active at a time"); + } + public override void SetDefaults() + { + item.damage = 251; + item.noMelee = true; + item.magic = true; + item.width = 22; + item.height = 24; + item.useTime = 45; + item.useAnimation = 45; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 7f; + item.useStyle = ItemUseStyleID.HoldingOut; + item.mana = 30; + item.knockBack = 2; + item.UseSound = SoundID.Item20; + item.rare = ItemRarityID.LightRed; + item.autoReuse = true; + item.useTurn = true; + item.noUseGraphic = true; + item.holdStyle = 3; item.value = Item.buyPrice(1, 40, 0, 0); item.rare = ItemRarityID.Red; item.Calamity().customRarity = CalamityRarity.PureGreen; - } + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 6; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 6; - public override void AddRecipes() - { + public override void AddRecipes() + { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.NebulaArcanum); - recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ItemID.NebulaArcanum); + recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType(), 4); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); - } - } + } + } } diff --git a/Items/Weapons/Magic/TacticiansTrumpCard.cs b/Items/Weapons/Magic/TacticiansTrumpCard.cs index 78fc1645e5..198d07b7a6 100644 --- a/Items/Weapons/Magic/TacticiansTrumpCard.cs +++ b/Items/Weapons/Magic/TacticiansTrumpCard.cs @@ -7,74 +7,74 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class TacticiansTrumpCard : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tactician's Trump Card"); - Tooltip.SetDefault("Faint memories of a Princess from the future cross your mind...\n" + - "Fires a sword beam that electrifies enemies on hit"); - } + public class TacticiansTrumpCard : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tactician's Trump Card"); + Tooltip.SetDefault("Faint memories of a Princess from the future cross your mind...\n" + + "Fires a sword beam that electrifies enemies on hit"); + } - public override void SetDefaults() - { - item.width = 74; - item.height = 70; - item.damage = 248; - item.knockBack = 7f; - item.magic = true; - item.useAnimation = item.useTime = 12; - item.mana = 20; - item.useTurn = true; - item.autoReuse = true; - item.shootSpeed = 13.5f; - item.shoot = ModContent.ProjectileType(); - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; + public override void SetDefaults() + { + item.width = 74; + item.height = 70; + item.damage = 248; + item.knockBack = 7f; + item.magic = true; + item.useAnimation = item.useTime = 12; + item.mana = 20; + item.useTurn = true; + item.autoReuse = true; + item.shootSpeed = 13.5f; + item.shoot = ModContent.ProjectileType(); + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; item.Calamity().donorItem = true; } - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(3)) - { - int dustType = Main.rand.NextBool() ? 132 : 264; - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, dustType); - Main.dust[dust].noGravity = true; - } - } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + if (Main.rand.NextBool(3)) + { + int dustType = Main.rand.NextBool() ? 132 : 264; + int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, dustType); + Main.dust[dust].noGravity = true; + } + } - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) => target.AddBuff(BuffID.Electrified, 300); + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) => target.AddBuff(BuffID.Electrified, 300); - public override void OnHitPvp(Player player, Player target, int damage, bool crit) => target.AddBuff(BuffID.Electrified, 300); + public override void OnHitPvp(Player player, Player target, int damage, bool crit) => target.AddBuff(BuffID.Electrified, 300); - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.CopperShortsword); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.TinShortsword); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.CopperShortsword); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.TinShortsword); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Magic/TerraRay.cs b/Items/Weapons/Magic/TerraRay.cs index 2eaacb9a7a..2bf0859af7 100644 --- a/Items/Weapons/Magic/TerraRay.cs +++ b/Items/Weapons/Magic/TerraRay.cs @@ -42,15 +42,15 @@ namespace CalamityMod.Items.Weapons.Magic return new Vector2(15, 15); } - public override bool Shoot(Player player, ref 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 shootVelocity = new Vector2(speedX, speedY); Vector2 shootPosition = position + shootVelocity * 8f; Projectile.NewProjectile(shootPosition, shootVelocity, type, damage, knockBack, player.whoAmI); return false; - } + } - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); diff --git a/Items/Weapons/Magic/TheSwarmer.cs b/Items/Weapons/Magic/TheSwarmer.cs index 92460c68ee..3f582f82e2 100644 --- a/Items/Weapons/Magic/TheSwarmer.cs +++ b/Items/Weapons/Magic/TheSwarmer.cs @@ -55,22 +55,22 @@ namespace CalamityMod.Items.Weapons.Magic float SpeedX = speedX + (float)Main.rand.Next(-35, 36) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-35, 36) * 0.05f; int wasps = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, 0f, player.whoAmI); - if (wasps.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[wasps].penetrate = 1; - Main.projectile[wasps].Calamity().forceMagic = true; - } + if (wasps.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[wasps].penetrate = 1; + Main.projectile[wasps].Calamity().forceMagic = true; + } } for (int i = 0; i <= 3; i++) { float SpeedX2 = speedX + (float)Main.rand.Next(-35, 36) * 0.05f; float SpeedY2 = speedY + (float)Main.rand.Next(-35, 36) * 0.05f; int bees = Projectile.NewProjectile(position.X, position.Y, SpeedX2, SpeedY2, player.beeType(), player.beeDamage(item.damage), player.beeKB(0f), player.whoAmI); - if (bees.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[bees].penetrate = 1; - Main.projectile[bees].Calamity().forceMagic = true; - } + if (bees.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bees].penetrate = 1; + Main.projectile[bees].Calamity().forceMagic = true; + } } return false; } diff --git a/Items/Weapons/Magic/Thunderstorm.cs b/Items/Weapons/Magic/Thunderstorm.cs index 5ca17d6ef9..4cda9dc316 100644 --- a/Items/Weapons/Magic/Thunderstorm.cs +++ b/Items/Weapons/Magic/Thunderstorm.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Magic item.autoReuse = true; item.shootSpeed = 6f; item.shoot = ModContent.ProjectileType(); - } + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Magic/TomeofFates.cs b/Items/Weapons/Magic/TomeofFates.cs index a24f6ad852..be6b59507d 100644 --- a/Items/Weapons/Magic/TomeofFates.cs +++ b/Items/Weapons/Magic/TomeofFates.cs @@ -36,8 +36,8 @@ namespace CalamityMod.Items.Weapons.Magic item.shootSpeed = 17f; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 3; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 3; public override void AddRecipes() { diff --git a/Items/Weapons/Magic/UltraLiquidator.cs b/Items/Weapons/Magic/UltraLiquidator.cs index 1abb86540b..8f12b82caa 100644 --- a/Items/Weapons/Magic/UltraLiquidator.cs +++ b/Items/Weapons/Magic/UltraLiquidator.cs @@ -8,80 +8,80 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class UltraLiquidator : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ultra Liquidator"); - Tooltip.SetDefault("Summons liquidation blades that summon more blades on enemy hits\n" + - "The blades inflict ichor, cursed inferno and brimstone flames"); - Item.staff[item.type] = true; - } + public class UltraLiquidator : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ultra Liquidator"); + Tooltip.SetDefault("Summons liquidation blades that summon more blades on enemy hits\n" + + "The blades inflict ichor, cursed inferno and brimstone flames"); + Item.staff[item.type] = true; + } - public override void SetDefaults() - { - item.damage = 120; - item.knockBack = 5f; - item.useTime = 3; - item.reuseDelay = item.useAnimation = 15; - item.mana = 25; - item.magic = true; - item.autoReuse = true; - item.shootSpeed = 16f; - item.shoot = ModContent.ProjectileType(); + public override void SetDefaults() + { + item.damage = 120; + item.knockBack = 5f; + item.useTime = 3; + item.reuseDelay = item.useAnimation = 15; + item.mana = 25; + item.magic = true; + item.autoReuse = true; + item.shootSpeed = 16f; + item.shoot = ModContent.ProjectileType(); - item.width = item.height = 16; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.UseSound = SoundID.Item9; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - } + item.width = item.height = 16; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.UseSound = SoundID.Item9; + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 30; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 30; - public override Vector2? HoldoutOrigin() => new Vector2(15, 15); + public override Vector2? HoldoutOrigin() => new Vector2(15, 15); - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.AquaScepter); - recipe.AddRecipeGroup("CursedFlameIchor", 20); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ItemID.LunarBar, 5); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.AquaScepter); + recipe.AddRecipeGroup("CursedFlameIchor", 20); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ItemID.LunarBar, 5); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } - 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 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float speed = item.shootSpeed; - float xVec = Main.mouseX + Main.screenPosition.X - playerPos.X; - float yVec = Main.mouseY + Main.screenPosition.Y - playerPos.Y; - float f = Main.rand.NextFloat() * MathHelper.TwoPi; - float lowerBoundOffset = 20f; - float upperBoundOffset = 60f; - Vector2 source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(lowerBoundOffset, upperBoundOffset, Main.rand.NextFloat()); - for (int i = 0; i < 50; i++) - { - source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(lowerBoundOffset, upperBoundOffset, Main.rand.NextFloat()); - if (Collision.CanHit(playerPos, 0, 0, source + (source - playerPos).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) - { - break; - } - f = Main.rand.NextFloat() * MathHelper.TwoPi; - } - Vector2 velocity = Main.MouseWorld - source; - Vector2 upperVelocityLimit = new Vector2(xVec, yVec).SafeNormalize(Vector2.UnitY) * speed; - velocity = velocity.SafeNormalize(upperVelocityLimit) * speed; - velocity = Vector2.Lerp(velocity, upperVelocityLimit, 0.25f); - Projectile.NewProjectile(source, velocity, type, damage, knockBack, player.whoAmI, 0f, 0f); - return false; - } - } + 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 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float speed = item.shootSpeed; + float xVec = Main.mouseX + Main.screenPosition.X - playerPos.X; + float yVec = Main.mouseY + Main.screenPosition.Y - playerPos.Y; + float f = Main.rand.NextFloat() * MathHelper.TwoPi; + float lowerBoundOffset = 20f; + float upperBoundOffset = 60f; + Vector2 source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(lowerBoundOffset, upperBoundOffset, Main.rand.NextFloat()); + for (int i = 0; i < 50; i++) + { + source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(lowerBoundOffset, upperBoundOffset, Main.rand.NextFloat()); + if (Collision.CanHit(playerPos, 0, 0, source + (source - playerPos).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) + { + break; + } + f = Main.rand.NextFloat() * MathHelper.TwoPi; + } + Vector2 velocity = Main.MouseWorld - source; + Vector2 upperVelocityLimit = new Vector2(xVec, yVec).SafeNormalize(Vector2.UnitY) * speed; + velocity = velocity.SafeNormalize(upperVelocityLimit) * speed; + velocity = Vector2.Lerp(velocity, upperVelocityLimit, 0.25f); + Projectile.NewProjectile(source, velocity, type, damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + } } diff --git a/Items/Weapons/Magic/Vesuvius.cs b/Items/Weapons/Magic/Vesuvius.cs index 85da54edf2..fcdbdf8bd0 100644 --- a/Items/Weapons/Magic/Vesuvius.cs +++ b/Items/Weapons/Magic/Vesuvius.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Magic item.value = CalamityGlobalItem.Rarity8BuyPrice; item.rare = ItemRarityID.Yellow; - } + } public override bool AltFunctionUse(Player player) { @@ -48,18 +48,18 @@ namespace CalamityMod.Items.Weapons.Magic return base.CanUseItem(player); } - public override void ModifyManaCost(Player player, ref float reduce, ref float mult) - { - if (player.altFunctionUse == 2) - mult *= 1.5f; - } + public override void ModifyManaCost(Player player, ref float reduce, ref float mult) + { + if (player.altFunctionUse == 2) + mult *= 1.5f; + } - public override float UseTimeMultiplier (Player player) - { - if (player.altFunctionUse != 2) - return 1f; - return 0.75f; - } + public override float UseTimeMultiplier (Player player) + { + if (player.altFunctionUse != 2) + return 1f; + return 0.75f; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Magic/Viscera.cs b/Items/Weapons/Magic/Viscera.cs index d682546636..090371ad19 100644 --- a/Items/Weapons/Magic/Viscera.cs +++ b/Items/Weapons/Magic/Viscera.cs @@ -29,10 +29,10 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 6f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item20; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item20; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 6f; diff --git a/Items/Weapons/Magic/WintersFury.cs b/Items/Weapons/Magic/WintersFury.cs index a89e79c531..6ba3c33194 100644 --- a/Items/Weapons/Magic/WintersFury.cs +++ b/Items/Weapons/Magic/WintersFury.cs @@ -45,8 +45,8 @@ namespace CalamityMod.Items.Weapons.Magic speed *= 15f; speed.Y -= Math.Abs(speed.X) * 0.2f; int p = Projectile.NewProjectile(position, speed, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().forceMagic = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().forceMagic = true; } if (Main.rand.NextBool(4)) { diff --git a/Items/Weapons/Magic/WrathoftheAncients.cs b/Items/Weapons/Magic/WrathoftheAncients.cs index 961996b0fb..a158d1f31c 100644 --- a/Items/Weapons/Magic/WrathoftheAncients.cs +++ b/Items/Weapons/Magic/WrathoftheAncients.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class WrathoftheAncients : ModItem + public class WrathoftheAncients : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Magic/WulfrumStaff.cs b/Items/Weapons/Magic/WulfrumStaff.cs index d653260e53..1e9c2bf5a4 100644 --- a/Items/Weapons/Magic/WulfrumStaff.cs +++ b/Items/Weapons/Magic/WulfrumStaff.cs @@ -7,46 +7,46 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Magic { - public class WulfrumStaff : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Wulfrum Staff"); - Tooltip.SetDefault("Casts a wulfrum bolt"); - //Item.staff[item.type] = true; - } + public class WulfrumStaff : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wulfrum Staff"); + Tooltip.SetDefault("Casts a wulfrum bolt"); + //Item.staff[item.type] = true; + } - public override void SetDefaults() - { - item.damage = 13; - item.magic = true; - item.mana = 2; - item.width = 44; - item.height = 46; - item.useTime = 20; - item.useAnimation = 20; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 3; - item.value = Item.buyPrice(0, 1, 0, 0); - item.rare = ItemRarityID.Blue; - item.UseSound = SoundID.Item43; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 9f; - } + public override void SetDefaults() + { + item.damage = 13; + item.magic = true; + item.mana = 2; + item.width = 44; + item.height = 46; + item.useTime = 20; + item.useAnimation = 20; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 3; + item.value = Item.buyPrice(0, 1, 0, 0); + item.rare = ItemRarityID.Blue; + item.UseSound = SoundID.Item43; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 9f; + } - //public override Vector2? HoldoutOrigin() => new Vector2(8, 15); + //public override Vector2? HoldoutOrigin() => new Vector2(8, 15); - public override Vector2? HoldoutOffset() => new Vector2(-3, 0); + public override Vector2? HoldoutOffset() => new Vector2(-3, 0); - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Magic/WyvernsCall.cs b/Items/Weapons/Magic/WyvernsCall.cs index 4661786fcb..ee9bb910a7 100644 --- a/Items/Weapons/Magic/WyvernsCall.cs +++ b/Items/Weapons/Magic/WyvernsCall.cs @@ -69,28 +69,28 @@ Fires wyverns and colored feathers from the sky that stick to enemies and tiles { float damageMult = 1f; float kbMult = 1f; - if (Main.rand.NextBool(10)) - { - type = ModContent.ProjectileType(); - } - else if (Main.rand.NextBool(3)) - { - type = ModContent.ProjectileType(); - } - else if (Main.rand.NextBool(2)) - { - type = ModContent.ProjectileType(); - } - if (type == ModContent.ProjectileType()) - { - damageMult = 20f; - kbMult = 1.5f; - } - if (type == ModContent.ProjectileType()) - { - damageMult = 1.2f; - kbMult = 2f; - } + if (Main.rand.NextBool(10)) + { + type = ModContent.ProjectileType(); + } + else if (Main.rand.NextBool(3)) + { + type = ModContent.ProjectileType(); + } + else if (Main.rand.NextBool(2)) + { + type = ModContent.ProjectileType(); + } + if (type == ModContent.ProjectileType()) + { + damageMult = 20f; + kbMult = 1.5f; + } + if (type == ModContent.ProjectileType()) + { + damageMult = 1.2f; + kbMult = 2f; + } vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); vector2.Y -= (float)(100 * num108); diff --git a/Items/Weapons/Magic/YharimsCrystal.cs b/Items/Weapons/Magic/YharimsCrystal.cs index a50b7439db..f866afdbbb 100644 --- a/Items/Weapons/Magic/YharimsCrystal.cs +++ b/Items/Weapons/Magic/YharimsCrystal.cs @@ -32,10 +32,10 @@ namespace CalamityMod.Items.Weapons.Magic item.shoot = ModContent.ProjectileType(); item.shootSpeed = 30f; - item.rare = ItemRarityID.Purple; + item.rare = ItemRarityID.Purple; item.value = CalamityGlobalItem.Rarity15BuyPrice; item.Calamity().customRarity = CalamityRarity.Violet; - } + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; } diff --git a/Items/Weapons/Magic/Zapper.cs b/Items/Weapons/Magic/Zapper.cs index d4f9ae86ee..b37ab92eb9 100644 --- a/Items/Weapons/Magic/Zapper.cs +++ b/Items/Weapons/Magic/Zapper.cs @@ -37,12 +37,12 @@ namespace CalamityMod.Items.Weapons.Magic 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; - } + { + 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; + Main.projectile[laser].usesLocalNPCImmunity = true; + Main.projectile[laser].localNPCHitCooldown = 10; return false; } diff --git a/Items/Weapons/Melee/AbsoluteZero.cs b/Items/Weapons/Melee/AbsoluteZero.cs index c03569fb0d..861365a576 100644 --- a/Items/Weapons/Melee/AbsoluteZero.cs +++ b/Items/Weapons/Melee/AbsoluteZero.cs @@ -38,10 +38,10 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.Frostburn, 300); target.AddBuff(ModContent.BuffType(), 60); - if (crit) - damage /= 2; + if (crit) + damage /= 2; - int p = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, knockBack * 3f, player.whoAmI); + int p = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, knockBack * 3f, player.whoAmI); Main.projectile[p].Kill(); } @@ -50,10 +50,10 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.Frostburn, 300); target.AddBuff(ModContent.BuffType(), 60); - if (crit) - damage /= 2; + if (crit) + damage /= 2; - int p = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 12f, player.whoAmI); + int p = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 12f, player.whoAmI); Main.projectile[p].Kill(); } } diff --git a/Items/Weapons/Melee/AegisBlade.cs b/Items/Weapons/Melee/AegisBlade.cs index 2f9a1168e3..a4084ac265 100644 --- a/Items/Weapons/Melee/AegisBlade.cs +++ b/Items/Weapons/Melee/AegisBlade.cs @@ -18,9 +18,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 72; - item.height = 72; - item.scale = 1.2f; - item.damage = 108; + item.height = 72; + item.scale = 1.2f; + item.damage = 108; item.melee = true; item.useAnimation = item.useTime = 15; item.useTurn = true; @@ -56,12 +56,12 @@ namespace CalamityMod.Items.Weapons.Melee return base.CanUseItem(player); } - public override float UseTimeMultiplier (Player player) - { - if (player.altFunctionUse != 2) - return 1f; - return 0.75f; - } + public override float UseTimeMultiplier (Player player) + { + if (player.altFunctionUse != 2) + return 1f; + return 0.75f; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -77,18 +77,18 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, Main.myPlayer); + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, Main.myPlayer); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, item.knockBack, Main.myPlayer); + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, item.knockBack, Main.myPlayer); } } } diff --git a/Items/Weapons/Melee/Aftershock.cs b/Items/Weapons/Melee/Aftershock.cs index 9a2bb94e2b..3c23aa08e2 100644 --- a/Items/Weapons/Melee/Aftershock.cs +++ b/Items/Weapons/Melee/Aftershock.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee item.melee = true; item.width = 54; item.height = 58; - item.scale = 1.75f; + item.scale = 1.75f; item.useTime = 28; item.useAnimation = 28; item.useTurn = true; diff --git a/Items/Weapons/Melee/AirSpinner.cs b/Items/Weapons/Melee/AirSpinner.cs index 119ce26753..2e3afe05d6 100644 --- a/Items/Weapons/Melee/AirSpinner.cs +++ b/Items/Weapons/Melee/AirSpinner.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Air Spinner"); Tooltip.SetDefault("Fires feathers when enemies are near\n" + - "A very agile yoyo"); + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/AnarchyBlade.cs b/Items/Weapons/Melee/AnarchyBlade.cs index e4ae226485..55229f5aca 100644 --- a/Items/Weapons/Melee/AnarchyBlade.cs +++ b/Items/Weapons/Melee/AnarchyBlade.cs @@ -66,10 +66,10 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, Main.myPlayer); + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, Main.myPlayer); target.AddBuff(ModContent.BuffType(), 300); if (player.statLife < (player.statLifeMax2 * 0.5f) && Main.rand.NextBool(5)) @@ -86,10 +86,10 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, item.knockBack, Main.myPlayer); + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, item.knockBack, Main.myPlayer); target.AddBuff(ModContent.BuffType(), 300); } } diff --git a/Items/Weapons/Melee/Aorta.cs b/Items/Weapons/Melee/Aorta.cs index 7e811a7688..da3370ed7e 100644 --- a/Items/Weapons/Melee/Aorta.cs +++ b/Items/Weapons/Melee/Aorta.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Aorta"); Tooltip.SetDefault("Fires homing blood when enemies are near\n" + - "An exceptionally agile yoyo"); + "An exceptionally agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/AquaticDissolution.cs b/Items/Weapons/Melee/AquaticDissolution.cs index b7cfd38703..fbf51f9bb1 100644 --- a/Items/Weapons/Melee/AquaticDissolution.cs +++ b/Items/Weapons/Melee/AquaticDissolution.cs @@ -29,10 +29,10 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item60; item.autoReuse = true; item.height = 72; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; } diff --git a/Items/Weapons/Melee/ArkoftheAncients.cs b/Items/Weapons/Melee/ArkoftheAncients.cs index fe240116a7..0155be0f6f 100644 --- a/Items/Weapons/Melee/ArkoftheAncients.cs +++ b/Items/Weapons/Melee/ArkoftheAncients.cs @@ -13,7 +13,7 @@ using System.Collections.Generic; namespace CalamityMod.Items.Weapons.Melee { - public class ArkoftheAncients : ModItem + public class ArkoftheAncients : ModItem { public float Combo = 1f; public float Charge = 0f; diff --git a/Items/Weapons/Melee/ArkoftheCosmos.cs b/Items/Weapons/Melee/ArkoftheCosmos.cs index 9c3f9621da..6b53c99e87 100644 --- a/Items/Weapons/Melee/ArkoftheCosmos.cs +++ b/Items/Weapons/Melee/ArkoftheCosmos.cs @@ -14,7 +14,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Melee { - public class ArkoftheCosmos : ModItem + public class ArkoftheCosmos : ModItem { public float Combo = 0f; public float Charge = 0f; diff --git a/Items/Weapons/Melee/ArkoftheElements.cs b/Items/Weapons/Melee/ArkoftheElements.cs index be14aecde3..991716e4b2 100644 --- a/Items/Weapons/Melee/ArkoftheElements.cs +++ b/Items/Weapons/Melee/ArkoftheElements.cs @@ -13,7 +13,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Melee { - public class ArkoftheElements : ModItem + public class ArkoftheElements : ModItem { public float Combo = 0f; public float Charge = 0f; @@ -88,14 +88,14 @@ namespace CalamityMod.Items.Weapons.Melee item.knockBack = 8.5f; item.UseSound = null; item.autoReuse = true; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.shoot = ProjectileID.PurificationPowder; + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 16f; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; public override bool AltFunctionUse(Player player) => true; diff --git a/Items/Weapons/Melee/AstralBlade.cs b/Items/Weapons/Melee/AstralBlade.cs index 69f0dba75c..9cebd10ace 100644 --- a/Items/Weapons/Melee/AstralBlade.cs +++ b/Items/Weapons/Melee/AstralBlade.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Astral Blade"); - Tooltip.SetDefault("Deals more damage the more life an enemy has left"); - } + Tooltip.SetDefault("Deals more damage the more life an enemy has left"); + } public override void SetDefaults() { @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee item.melee = true; item.width = 80; item.height = 80; - item.scale = 1.5f; + item.scale = 1.5f; item.useTime = 9; item.useAnimation = 9; item.useTurn = true; @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Melee item.autoReuse = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; public override void AddRecipes() { @@ -68,33 +68,33 @@ namespace CalamityMod.Items.Weapons.Melee } } - public override void ModifyHitNPC(Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) - { - float lifeRatio = target.life / (float)target.lifeMax; - float multiplier = MathHelper.Lerp(1f, 2f, lifeRatio); + public override void ModifyHitNPC(Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) + { + float lifeRatio = target.life / (float)target.lifeMax; + float multiplier = MathHelper.Lerp(1f, 2f, lifeRatio); - damage = (int)(damage * multiplier); - knockBack *= multiplier; + damage = (int)(damage * multiplier); + knockBack *= multiplier; - if (!crit) - crit = Main.rand.NextBool((int)MathHelper.Clamp((item.crit + player.meleeCrit) * multiplier, 0f, 99f), 100); + if (!crit) + crit = Main.rand.NextBool((int)MathHelper.Clamp((item.crit + player.meleeCrit) * multiplier, 0f, 99f), 100); - if (multiplier > 1.5f) - { - Main.PlaySound(SoundID.Item105, Main.player[Main.myPlayer].position); - bool blue = Main.rand.NextBool(); - float angleStart = Main.rand.NextFloat(0f, MathHelper.TwoPi); - float var = 0.05f + (2f - multiplier); - for (float angle = 0f; angle < MathHelper.TwoPi; angle += var) - { - blue = !blue; - Vector2 velocity = angle.ToRotationVector2() * (2f + (float)(Math.Sin(angleStart + angle * 3f) + 1) * 2.5f) * Main.rand.NextFloat(0.95f, 1.05f); - Dust d = Dust.NewDustPerfect(target.Center, blue ? ModContent.DustType() : ModContent.DustType(), velocity); - d.customData = 0.025f; - d.scale = multiplier - 0.75f; - d.noLight = false; - } - } - } - } + if (multiplier > 1.5f) + { + Main.PlaySound(SoundID.Item105, Main.player[Main.myPlayer].position); + bool blue = Main.rand.NextBool(); + float angleStart = Main.rand.NextFloat(0f, MathHelper.TwoPi); + float var = 0.05f + (2f - multiplier); + for (float angle = 0f; angle < MathHelper.TwoPi; angle += var) + { + blue = !blue; + Vector2 velocity = angle.ToRotationVector2() * (2f + (float)(Math.Sin(angleStart + angle * 3f) + 1) * 2.5f) * Main.rand.NextFloat(0.95f, 1.05f); + Dust d = Dust.NewDustPerfect(target.Center, blue ? ModContent.DustType() : ModContent.DustType(), velocity); + d.customData = 0.025f; + d.scale = multiplier - 0.75f; + d.noLight = false; + } + } + } + } } diff --git a/Items/Weapons/Melee/AstralPike.cs b/Items/Weapons/Melee/AstralPike.cs index f2220b17a8..5ba246dfb1 100644 --- a/Items/Weapons/Melee/AstralPike.cs +++ b/Items/Weapons/Melee/AstralPike.cs @@ -33,11 +33,11 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Cyan; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 13f; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; public override void AddRecipes() { diff --git a/Items/Weapons/Melee/Avalanche.cs b/Items/Weapons/Melee/Avalanche.cs index ce30ce4f8d..1a9374b5df 100644 --- a/Items/Weapons/Melee/Avalanche.cs +++ b/Items/Weapons/Melee/Avalanche.cs @@ -18,9 +18,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 64; - item.height = 64; - item.scale = 1.5f; - item.damage = 100; + item.height = 64; + item.scale = 1.5f; + item.damage = 100; item.melee = true; item.useAnimation = 35; item.useTime = 35; @@ -35,37 +35,37 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - float velocity = 4f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(target.Center, vector255, type, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), knockback, Main.myPlayer); - } + int totalProjectiles = 4; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + float velocity = 4f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(target.Center, vector255, type, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), knockback, Main.myPlayer); + } } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - float velocity = 4f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(target.Center, vector255, type, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), 0f, Main.myPlayer); - } - } + int totalProjectiles = 4; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + float velocity = 4f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(target.Center, vector255, type, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), 0f, Main.myPlayer); + } + } public override void MeleeEffects(Player player, Rectangle hitbox) { diff --git a/Items/Weapons/Melee/Azathoth.cs b/Items/Weapons/Melee/Azathoth.cs index 30b428cdb8..c04f70007c 100644 --- a/Items/Weapons/Melee/Azathoth.cs +++ b/Items/Weapons/Melee/Azathoth.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Azathoth"); Tooltip.SetDefault("Fires cosmic orbs that blast nearby enemies with lasers\n" + - "A very agile yoyo\n" + - "Destroy the universe in the blink of an eye"); + "A very agile yoyo\n" + + "Destroy the universe in the blink of an eye"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/BalefulHarvester.cs b/Items/Weapons/Melee/BalefulHarvester.cs index d62800c9c5..02dbf30e15 100644 --- a/Items/Weapons/Melee/BalefulHarvester.cs +++ b/Items/Weapons/Melee/BalefulHarvester.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee item.damage = 90; item.width = 66; item.height = 66; - item.scale = 1.5f; + item.scale = 1.5f; item.melee = true; item.useAnimation = 22; item.useStyle = ItemUseStyleID.SwingThrow; @@ -45,21 +45,21 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ProjectileID.FlamingJack; + int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ProjectileID.FlamingJack; CalamityPlayer.HorsemansBladeOnHit(player, target.whoAmI, (int)(damage * 1.5f), knockback, 0, type); target.AddBuff(BuffID.OnFire, 300); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ProjectileID.FlamingJack; - CalamityPlayer.HorsemansBladeOnHit(player, -1, (int)(damage * 1.5f), item.knockBack, 0, type); + int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ProjectileID.FlamingJack; + CalamityPlayer.HorsemansBladeOnHit(player, -1, (int)(damage * 1.5f), item.knockBack, 0, type); target.AddBuff(BuffID.OnFire, 300); } } diff --git a/Items/Weapons/Melee/Basher.cs b/Items/Weapons/Melee/Basher.cs index f43b058532..f4c5a43b90 100644 --- a/Items/Weapons/Melee/Basher.cs +++ b/Items/Weapons/Melee/Basher.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 56; item.height = 60; item.damage = 30; - item.scale = 1.05f; + item.scale = 1.05f; item.melee = true; item.useAnimation = item.useTime = 26; item.useStyle = ItemUseStyleID.SwingThrow; diff --git a/Items/Weapons/Melee/BladeofEnmity.cs b/Items/Weapons/Melee/BladeofEnmity.cs index 74e2ac5542..ea01561a9c 100644 --- a/Items/Weapons/Melee/BladeofEnmity.cs +++ b/Items/Weapons/Melee/BladeofEnmity.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.width = 60; item.height = 64; - item.scale = 1.5f; + item.scale = 1.5f; item.damage = 190; item.melee = true; item.useAnimation = 10; diff --git a/Items/Weapons/Melee/BloodyEdge.cs b/Items/Weapons/Melee/BloodyEdge.cs index 746cd6113c..b40bca1128 100644 --- a/Items/Weapons/Melee/BloodyEdge.cs +++ b/Items/Weapons/Melee/BloodyEdge.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Bloody Edge"); Tooltip.SetDefault("Chance to heal the player on enemy hits\n" + - "Inflicts Burning Blood"); + "Inflicts Burning Blood"); } public override void SetDefaults() @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Melee item.autoReuse = true; item.useTurn = true; item.height = 60; - item.scale = 1.25f; + item.scale = 1.25f; item.value = Item.buyPrice(0, 4, 0, 0); item.rare = ItemRarityID.Orange; } @@ -61,9 +61,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(ModContent.BuffType(), 60); - if (!target.canGhostHeal || player.moonLeech) + if (!target.canGhostHeal || player.moonLeech) return; int healAmount = Main.rand.Next(2) + 2; @@ -73,9 +73,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(ModContent.BuffType(), 60); - int healAmount = Main.rand.Next(2) + 2; + int healAmount = Main.rand.Next(2) + 2; if (!player.moonLeech) { player.statLife += healAmount; diff --git a/Items/Weapons/Melee/Bonebreaker.cs b/Items/Weapons/Melee/Bonebreaker.cs index 97301553dc..8acdbdf2b1 100644 --- a/Items/Weapons/Melee/Bonebreaker.cs +++ b/Items/Weapons/Melee/Bonebreaker.cs @@ -6,9 +6,9 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class Bonebreaker : ModItem + public class Bonebreaker : ModItem { - public const int BaseDamage = 60; + public const int BaseDamage = 60; public override void SetStaticDefaults() { diff --git a/Items/Weapons/Melee/Brimlance.cs b/Items/Weapons/Melee/Brimlance.cs index d86e76ed6a..85b157d041 100644 --- a/Items/Weapons/Melee/Brimlance.cs +++ b/Items/Weapons/Melee/Brimlance.cs @@ -32,9 +32,9 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Pink; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + } } diff --git a/Items/Weapons/Melee/BrimlashBuster.cs b/Items/Weapons/Melee/BrimlashBuster.cs index a1b5386b70..02df521f38 100644 --- a/Items/Weapons/Melee/BrimlashBuster.cs +++ b/Items/Weapons/Melee/BrimlashBuster.cs @@ -56,23 +56,23 @@ namespace CalamityMod.Items.Weapons.Melee } public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) - { - float damageMult = 0f; + { + float damageMult = 0f; if (player.Calamity().brimlashBusterBoost) - damageMult = 2f; - mult += damageMult; - } + damageMult = 2f; + mult += damageMult; + } public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 300); - player.Calamity().brimlashBusterBoost = Main.rand.NextBool(3); + player.Calamity().brimlashBusterBoost = Main.rand.NextBool(3); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 300); - player.Calamity().brimlashBusterBoost = Main.rand.NextBool(3); + player.Calamity().brimlashBusterBoost = Main.rand.NextBool(3); } } } diff --git a/Items/Weapons/Melee/BrinyBaron.cs b/Items/Weapons/Melee/BrinyBaron.cs index 5df0db9741..841e9442a2 100644 --- a/Items/Weapons/Melee/BrinyBaron.cs +++ b/Items/Weapons/Melee/BrinyBaron.cs @@ -27,13 +27,13 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 100; item.height = 102; - item.scale = 1.5f; + item.scale = 1.5f; item.useStyle = ItemUseStyleID.SwingThrow; item.UseSound = SoundID.Item1; item.value = CalamityGlobalItem.Rarity8BuyPrice; item.rare = ItemRarityID.Yellow; - } + } public override bool AltFunctionUse(Player player) => true; @@ -56,12 +56,12 @@ namespace CalamityMod.Items.Weapons.Melee return base.CanUseItem(player); } - public override float UseTimeMultiplier (Player player) - { - if (player.altFunctionUse == 2) - return 1f; - return 0.75f; - } + public override float UseTimeMultiplier (Player player) + { + if (player.altFunctionUse == 2) + return 1f; + return 0.75f; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -77,20 +77,20 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - if (player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - if (player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, item.knockBack, player.whoAmI); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, item.knockBack, player.whoAmI); } } } diff --git a/Items/Weapons/Melee/Carnage.cs b/Items/Weapons/Melee/Carnage.cs index 6433c7a98d..0013515458 100644 --- a/Items/Weapons/Melee/Carnage.cs +++ b/Items/Weapons/Melee/Carnage.cs @@ -27,10 +27,10 @@ namespace CalamityMod.Items.Weapons.Melee item.autoReuse = true; item.useTurn = true; item.height = 60; - item.scale = 1.25f; - item.value = CalamityGlobalItem.Rarity4BuyPrice; - item.rare = ItemRarityID.LightRed; - } + item.scale = 1.25f; + item.value = CalamityGlobalItem.Rarity4BuyPrice; + item.rare = ItemRarityID.LightRed; + } public override void MeleeEffects(Player player, Rectangle hitbox) { @@ -42,12 +42,12 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - OnHitEffects(player, target.life <= 0, target.Center, target.width, target.height, knockback); + OnHitEffects(player, target.life <= 0, target.Center, target.width, target.height, knockback); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - OnHitEffects(player, target.statLife <= 0, target.Center, target.width, target.height, item.knockBack); + OnHitEffects(player, target.statLife <= 0, target.Center, target.width, target.height, item.knockBack); } private void OnHitEffects(Player player, bool health, Vector2 targetPos, int targetWidth, int targetHeight, float kBack) @@ -80,7 +80,7 @@ namespace CalamityMod.Items.Weapons.Melee int bloodAmt = Main.rand.Next(4, 6); for (int i = 0; i < bloodAmt; i++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(targetPos, velocity, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), kBack, player.whoAmI, 0f, 0f); } } diff --git a/Items/Weapons/Melee/CatastropheClaymore.cs b/Items/Weapons/Melee/CatastropheClaymore.cs index 4021ac6f0f..50acdb28a0 100644 --- a/Items/Weapons/Melee/CatastropheClaymore.cs +++ b/Items/Weapons/Melee/CatastropheClaymore.cs @@ -35,12 +35,12 @@ 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) { - type = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType() - }); + type = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() + }); Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, Main.myPlayer); return false; diff --git a/Items/Weapons/Melee/CausticEdge.cs b/Items/Weapons/Melee/CausticEdge.cs index 13a7d3b177..847ce05427 100644 --- a/Items/Weapons/Melee/CausticEdge.cs +++ b/Items/Weapons/Melee/CausticEdge.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.width = 46; item.damage = 70; - item.scale = 1.4f; + item.scale = 1.4f; item.melee = true; item.useTurn = true; item.useAnimation = 27; @@ -36,12 +36,12 @@ namespace CalamityMod.Items.Weapons.Melee ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BladeofGrass); recipe.AddIngredient(ItemID.LavaBucket); - recipe.AddRecipeGroup("Boss2Material", 3); - recipe.AddIngredient(ItemID.Deathweed, 5); + recipe.AddRecipeGroup("Boss2Material", 3); + recipe.AddIngredient(ItemID.Deathweed, 5); recipe.AddTile(TileID.DemonAltar); recipe.SetResult(this); recipe.AddRecipe(); - } + } public override void MeleeEffects(Player player, Rectangle hitbox) { diff --git a/Items/Weapons/Melee/Chaotrix.cs b/Items/Weapons/Melee/Chaotrix.cs index 22d03cee2f..055650767e 100644 --- a/Items/Weapons/Melee/Chaotrix.cs +++ b/Items/Weapons/Melee/Chaotrix.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Fault Line"); Tooltip.SetDefault("Explodes on enemy hits\n" + - "A very agile yoyo"); + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/Cnidarian.cs b/Items/Weapons/Melee/Cnidarian.cs index 5a207b3725..6b8e711144 100644 --- a/Items/Weapons/Melee/Cnidarian.cs +++ b/Items/Weapons/Melee/Cnidarian.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Cnidarian"); Tooltip.SetDefault("Fires a seashell when enemies are near\n" + - "A very agile yoyo"); + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/CometQuasher.cs b/Items/Weapons/Melee/CometQuasher.cs index 79259b0776..606bde380d 100644 --- a/Items/Weapons/Melee/CometQuasher.cs +++ b/Items/Weapons/Melee/CometQuasher.cs @@ -18,9 +18,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 46; - item.height = 62; - item.scale = 1.5f; - item.damage = 90; + item.height = 62; + item.scale = 1.5f; + item.damage = 90; item.melee = true; item.useAnimation = 22; item.useStyle = ItemUseStyleID.SwingThrow; @@ -56,10 +56,10 @@ namespace CalamityMod.Items.Weapons.Melee num80 = num72 / num80; } - if (crit) - damage /= 2; + if (crit) + damage /= 2; - for (int num113 = 0; num113 < 2; num113++) + for (int num113 = 0; num113 < 2; num113++) { vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); @@ -107,8 +107,8 @@ namespace CalamityMod.Items.Weapons.Melee num80 = num72 / num80; } - if (crit) - damage /= 2; + if (crit) + damage /= 2; for (int num113 = 0; num113 < 2; num113++) { diff --git a/Items/Weapons/Melee/CorruptedCrusherBlade.cs b/Items/Weapons/Melee/CorruptedCrusherBlade.cs index 77afa4b526..fc42f2b21e 100644 --- a/Items/Weapons/Melee/CorruptedCrusherBlade.cs +++ b/Items/Weapons/Melee/CorruptedCrusherBlade.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class CorruptedCrusherBlade : ModItem + public class CorruptedCrusherBlade : ModItem { public override void SetStaticDefaults() { @@ -20,8 +20,8 @@ namespace CalamityMod.Items.Weapons.Melee item.melee = true; item.width = 66; item.height = 80; - item.scale = 1.25f; - item.useTime = 26; + item.scale = 1.25f; + item.useTime = 26; item.useAnimation = 26; item.useTurn = true; item.useStyle = ItemUseStyleID.SwingThrow; @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Melee { target.AddBuff(BuffID.CursedInferno, 120); if (crit) - target.Calamity().miscDefenseLoss = 10; + target.Calamity().miscDefenseLoss = 10; } public override void OnHitPvp(Player player, Player target, int damage, bool crit) diff --git a/Items/Weapons/Melee/CosmicDischarge.cs b/Items/Weapons/Melee/CosmicDischarge.cs index b9a90e6db8..593d74fa10 100644 --- a/Items/Weapons/Melee/CosmicDischarge.cs +++ b/Items/Weapons/Melee/CosmicDischarge.cs @@ -33,10 +33,10 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 24f; item.shoot = ModContent.ProjectileType(); - item.rare = ItemRarityID.Purple; + item.rare = ItemRarityID.Purple; item.value = CalamityGlobalItem.Rarity14BuyPrice; item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Melee/CosmicShiv.cs b/Items/Weapons/Melee/CosmicShiv.cs index fc65462585..9e3853eb58 100644 --- a/Items/Weapons/Melee/CosmicShiv.cs +++ b/Items/Weapons/Melee/CosmicShiv.cs @@ -9,7 +9,7 @@ using CalamityMod.Tiles.Furniture.CraftingStations; namespace CalamityMod.Items.Weapons.Melee { - public class CosmicShiv : ModItem + public class CosmicShiv : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Melee/CrescentMoon.cs b/Items/Weapons/Melee/CrescentMoon.cs index 25df18d875..4ba3fb522b 100644 --- a/Items/Weapons/Melee/CrescentMoon.cs +++ b/Items/Weapons/Melee/CrescentMoon.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Crescent Moon"); Tooltip.SetDefault("People wanted the moon, let's bring the moon to them.\n" + - "Fires a whip sword that summons homing crescent moons"); + "Fires a whip sword that summons homing crescent moons"); } public override void SetDefaults() diff --git a/Items/Weapons/Melee/CrimsonCrusherBlade.cs b/Items/Weapons/Melee/CrimsonCrusherBlade.cs index 499ce62cd6..afe0b2f862 100644 --- a/Items/Weapons/Melee/CrimsonCrusherBlade.cs +++ b/Items/Weapons/Melee/CrimsonCrusherBlade.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Items.Weapons.Melee item.melee = true; item.width = 70; item.height = 80; - item.scale = 1.25f; - item.useTime = 28; + item.scale = 1.25f; + item.useTime = 28; item.useAnimation = 28; item.useTurn = true; item.useStyle = ItemUseStyleID.SwingThrow; @@ -47,8 +47,8 @@ namespace CalamityMod.Items.Weapons.Melee if (target.damage > 0 && crit && !CalamityPlayer.areThereAnyDamnBosses) { target.damage = target.defDamage - 5; - if (target.damage < 1) - target.damage = 1; + if (target.damage < 1) + target.damage = 1; } } diff --git a/Items/Weapons/Melee/CrystalBlade.cs b/Items/Weapons/Melee/CrystalBlade.cs index 05c44eea65..c96bed9210 100644 --- a/Items/Weapons/Melee/CrystalBlade.cs +++ b/Items/Weapons/Melee/CrystalBlade.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class CrystalBlade : ModItem + public class CrystalBlade : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Melee/DarklightGreatsword.cs b/Items/Weapons/Melee/DarklightGreatsword.cs index 9b32d8955d..874745e86c 100644 --- a/Items/Weapons/Melee/DarklightGreatsword.cs +++ b/Items/Weapons/Melee/DarklightGreatsword.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item1; item.autoReuse = true; item.height = 60; - item.scale = 1.5f; + item.scale = 1.5f; item.value = Item.buyPrice(0, 36, 0, 0); item.rare = ItemRarityID.Pink; item.shoot = ModContent.ProjectileType(); @@ -37,7 +37,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) { - type = Main.rand.NextBool(2) ? type : ModContent.ProjectileType(); + type = Main.rand.NextBool(2) ? type : ModContent.ProjectileType(); Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)(damage * 0.8), knockBack, player.whoAmI); return false; } diff --git a/Items/Weapons/Melee/DevilsDevastation.cs b/Items/Weapons/Melee/DevilsDevastation.cs index db5f09f860..8e2e78ba52 100644 --- a/Items/Weapons/Melee/DevilsDevastation.cs +++ b/Items/Weapons/Melee/DevilsDevastation.cs @@ -41,15 +41,15 @@ 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) { - //Shoot 3 oathblades in a spread - int index = 8; + //Shoot 3 oathblades in a spread + int index = 8; for (int j = -index; j <= index; j += index) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(j)); Projectile.NewProjectile(position, perturbedSpeed, type, damage, knockBack, player.whoAmI); } - //Not actually sure what this middle code does + //Not actually sure what this middle code does float speed = item.shootSpeed; Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true); float directionX = (float)Main.mouseX + Main.screenPosition.X - source.X; @@ -58,7 +58,7 @@ namespace CalamityMod.Items.Weapons.Melee { directionY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - source.Y; } - Vector2 direction = new Vector2(directionX, directionY); + Vector2 direction = new Vector2(directionX, directionY); float aimDist = direction.Length(); if ((float.IsNaN(direction.X) && float.IsNaN(direction.Y)) || (direction.X == 0f && direction.Y == 0f)) { @@ -71,7 +71,7 @@ namespace CalamityMod.Items.Weapons.Melee aimDist = speed / aimDist; } - //Shoot 9 tridents from below + //Shoot 9 tridents from below int projAmt = 3; //Since the method spawns 3 projectiles, it spawns 9 total for (int projIndex = 0; projIndex < projAmt; projIndex++) { @@ -94,7 +94,7 @@ namespace CalamityMod.Items.Weapons.Melee direction.Y *= aimDist; direction.X += Main.rand.NextFloat(-40f, 40f) * 0.02f; direction.Y += Main.rand.NextFloat(-40f, 40f) * 0.02f; - direction.Y *= -1; + direction.Y *= -1; Projectile.NewProjectile(source, direction, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, Main.rand.Next(5)); Projectile.NewProjectile(source, direction, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, Main.rand.Next(3)); Projectile.NewProjectile(source, direction, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); @@ -126,7 +126,7 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.OnFire, 300); if (crit) { - damage /= 2; + damage /= 2; target.AddBuff(BuffID.ShadowFlame, 450); target.AddBuff(BuffID.OnFire, 900); player.ApplyDamageToNPC(target, damage * 4, 0f, 0, false); diff --git a/Items/Weapons/Melee/DevilsSunrise.cs b/Items/Weapons/Melee/DevilsSunrise.cs index 85facd6e4d..694331a188 100644 --- a/Items/Weapons/Melee/DevilsSunrise.cs +++ b/Items/Weapons/Melee/DevilsSunrise.cs @@ -36,8 +36,8 @@ namespace CalamityMod.Items.Weapons.Melee item.Calamity().customRarity = CalamityRarity.Turquoise; item.Calamity().donorItem = true; - item.Calamity().trueMelee = true; - item.shoot = ModContent.ProjectileType(); + item.Calamity().trueMelee = true; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 24f; } diff --git a/Items/Weapons/Melee/DiseasedPike.cs b/Items/Weapons/Melee/DiseasedPike.cs index a7988c2481..a75c934412 100644 --- a/Items/Weapons/Melee/DiseasedPike.cs +++ b/Items/Weapons/Melee/DiseasedPike.cs @@ -32,9 +32,9 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Yellow; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + } } diff --git a/Items/Weapons/Melee/DivineHatchet.cs b/Items/Weapons/Melee/DivineHatchet.cs index 276ef7bafc..b75d91d43a 100644 --- a/Items/Weapons/Melee/DivineHatchet.cs +++ b/Items/Weapons/Melee/DivineHatchet.cs @@ -5,13 +5,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class DivineHatchet : ModItem + public class DivineHatchet : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Seeking Scorcher"); Tooltip.SetDefault("May your enemies burn in hell for the sins they have committed\n" + - "Throws a holy boomerang that seeks out up to three enemies before returning to the player"); + "Throws a holy boomerang that seeks out up to three enemies before returning to the player"); } public override void SetDefaults() @@ -30,9 +30,9 @@ namespace CalamityMod.Items.Weapons.Melee item.height = 62; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 14f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; } public override void AddRecipes() diff --git a/Items/Weapons/Melee/DragonPow.cs b/Items/Weapons/Melee/DragonPow.cs index 96f61a1cfb..dbe17614b3 100644 --- a/Items/Weapons/Melee/DragonPow.cs +++ b/Items/Weapons/Melee/DragonPow.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class DragonPow : ModItem + public class DragonPow : ModItem { public static float Speed = 13f; public static float ReturnSpeed = 20f; diff --git a/Items/Weapons/Melee/DragonRage.cs b/Items/Weapons/Melee/DragonRage.cs index f8cef730b4..294b611c21 100644 --- a/Items/Weapons/Melee/DragonRage.cs +++ b/Items/Weapons/Melee/DragonRage.cs @@ -4,13 +4,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class DragonRage : ModItem + public class DragonRage : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Dragon Rage"); Tooltip.SetDefault("Twirls a baton that causes explosions on enemy hits\n" + - "Every ten hits will summon a ring of fireballs"); + "Every ten hits will summon a ring of fireballs"); } public override void SetDefaults() @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Melee item.value = CalamityGlobalItem.Rarity15BuyPrice; item.rare = ItemRarityID.Purple; item.Calamity().customRarity = CalamityRarity.Violet; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } } } diff --git a/Items/Weapons/Melee/Earth.cs b/Items/Weapons/Melee/Earth.cs index 68f6d23c3d..732f262048 100644 --- a/Items/Weapons/Melee/Earth.cs +++ b/Items/Weapons/Melee/Earth.cs @@ -89,8 +89,8 @@ namespace CalamityMod.Items.Weapons.Melee Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); } - if (target.Calamity().miscDefenseLoss < target.defense) - target.Calamity().miscDefenseLoss += 1; + if (target.Calamity().miscDefenseLoss < target.defense) + target.Calamity().miscDefenseLoss += 1; if (!target.canGhostHeal || player.moonLeech) return; diff --git a/Items/Weapons/Melee/EarthenPike.cs b/Items/Weapons/Melee/EarthenPike.cs index 550c84bcc1..66cb16f138 100644 --- a/Items/Weapons/Melee/EarthenPike.cs +++ b/Items/Weapons/Melee/EarthenPike.cs @@ -35,6 +35,6 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 8f; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + } } diff --git a/Items/Weapons/Melee/ElementalExcalibur.cs b/Items/Weapons/Melee/ElementalExcalibur.cs index 2218a5e1ef..40b455ff56 100644 --- a/Items/Weapons/Melee/ElementalExcalibur.cs +++ b/Items/Weapons/Melee/ElementalExcalibur.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class ElementalExcalibur : ModItem + public class ElementalExcalibur : ModItem { private static int BaseDamage = 2000; private int BeamType = 0; @@ -143,10 +143,10 @@ namespace CalamityMod.Items.Weapons.Melee { target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(ModContent.BuffType(), 240); - target.AddBuff(BuffID.Frostburn, 300); - target.AddBuff(BuffID.OnFire, 360); + target.AddBuff(BuffID.Frostburn, 300); + target.AddBuff(BuffID.OnFire, 360); - if (!target.canGhostHeal || player.moonLeech) + if (!target.canGhostHeal || player.moonLeech) return; int healAmount = Main.rand.Next(3) + 10; @@ -157,11 +157,11 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 60); - target.AddBuff(ModContent.BuffType(), 240); - target.AddBuff(BuffID.Frostburn, 300); - target.AddBuff(BuffID.OnFire, 360); + target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(BuffID.Frostburn, 300); + target.AddBuff(BuffID.OnFire, 360); - if (player.moonLeech) + if (player.moonLeech) return; int healAmount = Main.rand.Next(3) + 10; diff --git a/Items/Weapons/Melee/ElementalShortsword.cs b/Items/Weapons/Melee/ElementalShortsword.cs index 415452a139..02f916ea36 100644 --- a/Items/Weapons/Melee/ElementalShortsword.cs +++ b/Items/Weapons/Melee/ElementalShortsword.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class ElementalShortsword : ModItem + public class ElementalShortsword : ModItem { public override void SetStaticDefaults() { @@ -33,9 +33,9 @@ namespace CalamityMod.Items.Weapons.Melee item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 14f; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - } + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -66,16 +66,16 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(ModContent.BuffType(), 120); + } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(ModContent.BuffType(), 120); + } } } diff --git a/Items/Weapons/Melee/EmpyreanKnives.cs b/Items/Weapons/Melee/EmpyreanKnives.cs index 5c173f9264..8f03327839 100644 --- a/Items/Weapons/Melee/EmpyreanKnives.cs +++ b/Items/Weapons/Melee/EmpyreanKnives.cs @@ -31,10 +31,10 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item39; item.autoReuse = true; item.height = 20; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 15f; } diff --git a/Items/Weapons/Melee/EutrophicScimitar.cs b/Items/Weapons/Melee/EutrophicScimitar.cs index e56f711d72..0c894116c7 100644 --- a/Items/Weapons/Melee/EutrophicScimitar.cs +++ b/Items/Weapons/Melee/EutrophicScimitar.cs @@ -43,14 +43,14 @@ namespace CalamityMod.Items.Weapons.Melee dust.fadeIn = 0.9473684f; } - for (int projectiles = 0; projectiles < 2; projectiles++) - { - float SpeedX = speedX + Main.rand.Next(-15, 16) * 0.05f; - float SpeedY = speedY + Main.rand.Next(-15, 16) * 0.05f; - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.7), knockBack, player.whoAmI); - } + for (int projectiles = 0; projectiles < 2; projectiles++) + { + float SpeedX = speedX + Main.rand.Next(-15, 16) * 0.05f; + float SpeedY = speedY + Main.rand.Next(-15, 16) * 0.05f; + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.7), knockBack, player.whoAmI); + } - return false; + return false; } } } diff --git a/Items/Weapons/Melee/EvilSmasher.cs b/Items/Weapons/Melee/EvilSmasher.cs index 64d4e49a71..163a13681d 100644 --- a/Items/Weapons/Melee/EvilSmasher.cs +++ b/Items/Weapons/Melee/EvilSmasher.cs @@ -4,24 +4,24 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class EvilSmasher : ModItem + public class EvilSmasher : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Evil Smasher"); Tooltip.SetDefault("EViL! sMaSH eVIl! SmAsh... ER!\n" + - "For every enemy you kill this hammer gains stat bonuses\n" + - "These bonuses stack until a cap is reached\n" + - "The bonus stacks will reset if you select a different item\n" + - "The bonus stacks will be reduced by 1 every time you get hit"); + "For every enemy you kill this hammer gains stat bonuses\n" + + "These bonuses stack until a cap is reached\n" + + "The bonus stacks will reset if you select a different item\n" + + "The bonus stacks will be reduced by 1 every time you get hit"); } public override void SetDefaults() { item.width = 64; - item.height = 66; - item.scale = 2f; - item.damage = 100; + item.height = 66; + item.scale = 2f; + item.damage = 100; item.melee = true; item.useAnimation = item.useTime = 38; item.useStyle = ItemUseStyleID.SwingThrow; @@ -31,18 +31,18 @@ namespace CalamityMod.Items.Weapons.Melee item.autoReuse = true; item.value = CalamityGlobalItem.Rarity4BuyPrice; item.rare = ItemRarityID.LightRed; - } + } - public override float UseTimeMultiplier (Player player) => 1f + (player.Calamity().evilSmasherBoost * 0.1f); + public override float UseTimeMultiplier (Player player) => 1f + (player.Calamity().evilSmasherBoost * 0.1f); public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) => mult += player.Calamity().evilSmasherBoost * 0.1f; public override void GetWeaponKnockback(Player player, ref float knockback) => knockback *= 1f + (player.Calamity().evilSmasherBoost * 0.1f); - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (target.life <= 0 && player.Calamity().evilSmasherBoost < 10) - player.Calamity().evilSmasherBoost += 1; - } + if (target.life <= 0 && player.Calamity().evilSmasherBoost < 10) + player.Calamity().evilSmasherBoost += 1; + } } } diff --git a/Items/Weapons/Melee/Excelsus.cs b/Items/Weapons/Melee/Excelsus.cs index c401366564..0eb5e8a9a5 100644 --- a/Items/Weapons/Melee/Excelsus.cs +++ b/Items/Weapons/Melee/Excelsus.cs @@ -29,16 +29,16 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item1; item.autoReuse = true; item.height = 94; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Melee/ExcelsusGlow")); + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Melee/ExcelsusGlow")); } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) diff --git a/Items/Weapons/Melee/ExsanguinationLance.cs b/Items/Weapons/Melee/ExsanguinationLance.cs index 82160962de..a792d8b1fb 100644 --- a/Items/Weapons/Melee/ExsanguinationLance.cs +++ b/Items/Weapons/Melee/ExsanguinationLance.cs @@ -33,12 +33,12 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Yellow; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 10); diff --git a/Items/Weapons/Melee/FeralthornClaymore.cs b/Items/Weapons/Melee/FeralthornClaymore.cs index 3fef252d59..c0aa985957 100644 --- a/Items/Weapons/Melee/FeralthornClaymore.cs +++ b/Items/Weapons/Melee/FeralthornClaymore.cs @@ -51,10 +51,10 @@ namespace CalamityMod.Items.Weapons.Melee { target.AddBuff(BuffID.Venom, 300); - if (crit) - damage /= 2; + if (crit) + damage /= 2; - Projectile.NewProjectile(player.position.X + 40f + Main.rand.Next(0, 151), player.position.Y + 36f, 0f, -18f, ModContent.ProjectileType(), (int)(damage * 0.25), 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X + 40f + Main.rand.Next(0, 151), player.position.Y + 36f, 0f, -18f, ModContent.ProjectileType(), (int)(damage * 0.25), 0f, Main.myPlayer); Projectile.NewProjectile(player.position.X - 40f + Main.rand.Next(-150, 1), player.position.Y + 36f, 0f, -18f, ModContent.ProjectileType(), (int)(damage * 0.25), 0f, Main.myPlayer); } @@ -62,10 +62,10 @@ namespace CalamityMod.Items.Weapons.Melee { target.AddBuff(BuffID.Venom, 300); - if (crit) - damage /= 2; + if (crit) + damage /= 2; - Projectile.NewProjectile(player.position.X + 40f + Main.rand.Next(0, 151), player.position.Y + 36f, 0f, -18f, ModContent.ProjectileType(), (int)(damage * 0.25), 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X + 40f + Main.rand.Next(0, 151), player.position.Y + 36f, 0f, -18f, ModContent.ProjectileType(), (int)(damage * 0.25), 0f, Main.myPlayer); Projectile.NewProjectile(player.position.X - 40f + Main.rand.Next(-150, 1), player.position.Y + 36f, 0f, -18f, ModContent.ProjectileType(), (int)(damage * 0.25), 0f, Main.myPlayer); } } diff --git a/Items/Weapons/Melee/FlameburstShortsword.cs b/Items/Weapons/Melee/FlameburstShortsword.cs index 9318d9fabe..44f5a7d8ab 100644 --- a/Items/Weapons/Melee/FlameburstShortsword.cs +++ b/Items/Weapons/Melee/FlameburstShortsword.cs @@ -47,18 +47,18 @@ namespace CalamityMod.Items.Weapons.Melee Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 6); } - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - int boom = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * 0.75f * player.MeleeDamage()), knockback, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (boom.WithinBounds(Main.maxProjectiles)) - Main.projectile[boom].Calamity().forceMelee = true; - } + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) + { + int boom = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * 0.75f * player.MeleeDamage()), knockback, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceMelee = true; + } - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - int boom = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * 0.75f * player.MeleeDamage()), item.knockBack, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (boom.WithinBounds(Main.maxProjectiles)) - Main.projectile[boom].Calamity().forceMelee = true; - } + public override void OnHitPvp(Player player, Player target, int damage, bool crit) + { + int boom = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * 0.75f * player.MeleeDamage()), item.knockBack, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceMelee = true; + } } } diff --git a/Items/Weapons/Melee/Floodtide.cs b/Items/Weapons/Melee/Floodtide.cs index a0b2733e6c..62aaba7b73 100644 --- a/Items/Weapons/Melee/Floodtide.cs +++ b/Items/Weapons/Melee/Floodtide.cs @@ -47,8 +47,8 @@ namespace CalamityMod.Items.Weapons.Melee float SpeedX = speedX + (float)Main.rand.Next(-20, 21) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-20, 21) * 0.05f; int proj = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } return false; } diff --git a/Items/Weapons/Melee/ForbiddenOathblade.cs b/Items/Weapons/Melee/ForbiddenOathblade.cs index f1b6a03edd..cd082e0ce8 100644 --- a/Items/Weapons/Melee/ForbiddenOathblade.cs +++ b/Items/Weapons/Melee/ForbiddenOathblade.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.width = 74; item.height = 74; - item.scale = 1.5f; + item.scale = 1.5f; item.damage = 110; item.melee = true; item.useAnimation = 25; diff --git a/Items/Weapons/Melee/ForsakenSaber.cs b/Items/Weapons/Melee/ForsakenSaber.cs index 18532a4374..039cdd503e 100644 --- a/Items/Weapons/Melee/ForsakenSaber.cs +++ b/Items/Weapons/Melee/ForsakenSaber.cs @@ -35,12 +35,12 @@ 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 projectiles = 0; projectiles < 3; projectiles++) - { - float SpeedX = speedX + Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = speedY + Main.rand.Next(-40, 41) * 0.05f; - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.8), knockBack, player.whoAmI); - } + for (int projectiles = 0; projectiles < 3; projectiles++) + { + float SpeedX = speedX + Main.rand.Next(-40, 41) * 0.05f; + float SpeedY = speedY + Main.rand.Next(-40, 41) * 0.05f; + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.8), knockBack, player.whoAmI); + } return false; } diff --git a/Items/Weapons/Melee/FourSeasonsGalaxia.cs b/Items/Weapons/Melee/FourSeasonsGalaxia.cs index e8ade02b1a..e112df0b30 100644 --- a/Items/Weapons/Melee/FourSeasonsGalaxia.cs +++ b/Items/Weapons/Melee/FourSeasonsGalaxia.cs @@ -17,7 +17,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Melee { - public class FourSeasonsGalaxia : ModItem + public class FourSeasonsGalaxia : ModItem { public Attunement mainAttunement = null; @@ -140,7 +140,7 @@ namespace CalamityMod.Items.Weapons.Melee item.Calamity().customRarity = CalamityRarity.DarkBlue; } - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemType()); diff --git a/Items/Weapons/Melee/FulgurationHalberd.cs b/Items/Weapons/Melee/FulgurationHalberd.cs index bae24131f6..70732fcc5a 100644 --- a/Items/Weapons/Melee/FulgurationHalberd.cs +++ b/Items/Weapons/Melee/FulgurationHalberd.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.width = 60; item.height = 64; - item.scale = 1.5f; + item.scale = 1.5f; item.damage = 70; item.melee = true; item.useAnimation = 22; @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Melee item.value = Item.buyPrice(0, 36, 0, 0); item.rare = ItemRarityID.Pink; item.shootSpeed = 8f; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } public override bool AltFunctionUse(Player player) { @@ -49,19 +49,19 @@ namespace CalamityMod.Items.Weapons.Melee item.noUseGraphic = true; item.useStyle = ItemUseStyleID.HoldingOut; item.shoot = ModContent.ProjectileType(); - return player.ownedProjectileCounts[item.shoot] <= 0; - } + return player.ownedProjectileCounts[item.shoot] <= 0; + } else { item.noMelee = false; item.noUseGraphic = false; item.useStyle = ItemUseStyleID.SwingThrow; item.shoot = ProjectileID.None; - return base.CanUseItem(player); - } + 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) + 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/GalacticaBlade.cs b/Items/Weapons/Melee/GalacticaBlade.cs index 11fe14c84f..78c3763430 100644 --- a/Items/Weapons/Melee/GalacticaBlade.cs +++ b/Items/Weapons/Melee/GalacticaBlade.cs @@ -31,10 +31,10 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item105; item.autoReuse = true; item.height = 58; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 23f; } diff --git a/Items/Weapons/Melee/GalileoGladius.cs b/Items/Weapons/Melee/GalileoGladius.cs index 92558412f7..2e5db9a154 100644 --- a/Items/Weapons/Melee/GalileoGladius.cs +++ b/Items/Weapons/Melee/GalileoGladius.cs @@ -9,88 +9,88 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class GalileoGladius : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Galileo Gladius"); - Tooltip.SetDefault("Don't underestimate the power of small space swords\n" + - "Shoots a homing crescent moon\n" + - "Spawns planetoids on enemy hits"); - } + public class GalileoGladius : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Galileo Gladius"); + Tooltip.SetDefault("Don't underestimate the power of small space swords\n" + + "Shoots a homing crescent moon\n" + + "Spawns planetoids on enemy hits"); + } - public override void SetDefaults() - { - item.useStyle = ItemUseStyleID.Stabbing; - item.useTurn = false; - item.useAnimation = 10; - item.useTime = 10; - item.width = 44; - item.height = 44; - item.damage = 110; - item.melee = true; - item.knockBack = 10f; - item.UseSound = SoundID.Item1; - item.useTurn = true; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 14f; + public override void SetDefaults() + { + item.useStyle = ItemUseStyleID.Stabbing; + item.useTurn = false; + item.useAnimation = 10; + item.useTime = 10; + item.width = 44; + item.height = 44; + item.damage = 110; + item.melee = true; + item.knockBack = 10f; + item.UseSound = SoundID.Item1; + item.useTurn = true; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 14f; - item.value = CalamityGlobalItem.Rarity13BuyPrice; - item.Calamity().customRarity = CalamityRarity.PureGreen; - } + item.value = CalamityGlobalItem.Rarity13BuyPrice; + item.Calamity().customRarity = CalamityRarity.PureGreen; + } - 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 moonDamage = (int)(damage * 0.3333f); - Projectile.NewProjectile(position.X, position.Y, item.shootSpeed * player.direction, 0f, type, moonDamage, knockBack, player.whoAmI, 0f, 0f); - return false; - } + 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 moonDamage = (int)(damage * 0.3333f); + Projectile.NewProjectile(position.X, position.Y, item.shootSpeed * player.direction, 0f, type, moonDamage, knockBack, player.whoAmI, 0f, 0f); + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(5)) - { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, (Main.rand.NextBool(2) ? 20 : 176), (float)(player.direction * 2), 0f, 150, default, 1.3f); - Main.dust[num250].velocity *= 0.2f; - Main.dust[num250].noGravity = true; - } - } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + if (Main.rand.NextBool(5)) + { + int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, (Main.rand.NextBool(2) ? 20 : 176), (float)(player.direction * 2), 0f, 150, default, 1.3f); + Main.dust[num250].velocity *= 0.2f; + Main.dust[num250].noGravity = true; + } + } - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - SpawnMeteor(player); - } + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + SpawnMeteor(player); + } - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - SpawnMeteor(player); - } + public override void OnHitPvp(Player player, Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + SpawnMeteor(player); + } - private void SpawnMeteor(Player player) - { - if (player.whoAmI == Main.myPlayer) - { - if (player.Calamity().galileoCooldown <= 0) - { - int damage = player.GetWeaponDamage(player.ActiveItem()) * 2; - CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 25f, ModContent.ProjectileType(), damage, 15f, player.whoAmI); - player.Calamity().galileoCooldown = 15; - } - } - } - } + private void SpawnMeteor(Player player) + { + if (player.whoAmI == Main.myPlayer) + { + if (player.Calamity().galileoCooldown <= 0) + { + int damage = player.GetWeaponDamage(player.ActiveItem()) * 2; + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 25f, ModContent.ProjectileType(), damage, 15f, player.whoAmI); + player.Calamity().galileoCooldown = 15; + } + } + } + } } diff --git a/Items/Weapons/Melee/GildedProboscis.cs b/Items/Weapons/Melee/GildedProboscis.cs index 45e411a0e3..c357fb1217 100644 --- a/Items/Weapons/Melee/GildedProboscis.cs +++ b/Items/Weapons/Melee/GildedProboscis.cs @@ -28,13 +28,13 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item1; item.autoReuse = true; item.height = 66; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 13f; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + } } diff --git a/Items/Weapons/Melee/GlacialCrusher.cs b/Items/Weapons/Melee/GlacialCrusher.cs index 029a4c9ff0..d6df380344 100644 --- a/Items/Weapons/Melee/GlacialCrusher.cs +++ b/Items/Weapons/Melee/GlacialCrusher.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item1; item.autoReuse = true; item.height = 58; - item.scale = 2f; + item.scale = 2f; item.value = Item.buyPrice(0, 36, 0, 0); item.rare = ItemRarityID.Pink; item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Melee/GoldplumeSpear.cs b/Items/Weapons/Melee/GoldplumeSpear.cs index 2de3f41ac1..38273af846 100644 --- a/Items/Weapons/Melee/GoldplumeSpear.cs +++ b/Items/Weapons/Melee/GoldplumeSpear.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 8f; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 10); diff --git a/Items/Weapons/Melee/GrandGuardian.cs b/Items/Weapons/Melee/GrandGuardian.cs index 1623de2546..61b0bdd9d7 100644 --- a/Items/Weapons/Melee/GrandGuardian.cs +++ b/Items/Weapons/Melee/GrandGuardian.cs @@ -38,36 +38,36 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 12f; } - public override void UseStyle(Player player) - { - player.itemLocation += new Vector2(-32f * player.direction, 12f * player.gravDir).RotatedBy(player.itemRotation); - } + public override void UseStyle(Player player) + { + player.itemLocation += new Vector2(-32f * player.direction, 12f * player.gravDir).RotatedBy(player.itemRotation); + } public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (target.Calamity().miscDefenseLoss < target.defense) - target.Calamity().miscDefenseLoss += 1; + if (target.Calamity().miscDefenseLoss < target.defense) + target.Calamity().miscDefenseLoss += 1; - if (target.Calamity().miscDefenseLoss >= target.defense && target.canGhostHeal && !player.moonLeech) + if (target.Calamity().miscDefenseLoss >= target.defense && target.canGhostHeal && !player.moonLeech) { player.statLife += 4; player.HealEffect(4); } - OnHitEffects(player, target.Center, target.life, target.lifeMax, knockback, damage, crit); + OnHitEffects(player, target.Center, target.life, target.lifeMax, knockback, damage, crit); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - OnHitEffects(player, target.Center, target.statLife, target.statLifeMax2, item.knockBack, damage, crit); + OnHitEffects(player, target.Center, target.statLife, target.statLifeMax2, item.knockBack, damage, crit); } - private void OnHitEffects(Player player, Vector2 targetPos, int targetLife, int targetMaxLife, float knockback, int damage, bool crit) - { - if (crit) - damage /= 2; + private void OnHitEffects(Player player, Vector2 targetPos, int targetLife, int targetMaxLife, float knockback, int damage, bool crit) + { + if (crit) + damage /= 2; - Projectile.NewProjectile(targetPos, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.5f), 0f, player.whoAmI); + Projectile.NewProjectile(targetPos, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.5f), 0f, player.whoAmI); if (targetLife <= (targetMaxLife * 0.5f) && player.ownedProjectileCounts[ModContent.ProjectileType()] < 3) { float randomSpeedX = Main.rand.Next(6, 13); @@ -84,7 +84,7 @@ namespace CalamityMod.Items.Weapons.Melee Projectile.NewProjectile(targetPos.X, targetPos.Y, randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), 0, 0f, player.whoAmI); Projectile.NewProjectile(targetPos.X, targetPos.Y, 0f, -randomSpeedY, ModContent.ProjectileType(), 0, 0f, player.whoAmI); } - } + } public override void MeleeEffects(Player player, Rectangle hitbox) { diff --git a/Items/Weapons/Melee/GreatswordofBlah.cs b/Items/Weapons/Melee/GreatswordofBlah.cs index baa618281a..089f46dc4d 100644 --- a/Items/Weapons/Melee/GreatswordofBlah.cs +++ b/Items/Weapons/Melee/GreatswordofBlah.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class GreatswordofBlah : ModItem + public class GreatswordofBlah : ModItem { public override void SetStaticDefaults() { @@ -30,10 +30,10 @@ namespace CalamityMod.Items.Weapons.Melee item.knockBack = 7f; item.UseSound = SoundID.Item1; item.autoReuse = true; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 6f; } diff --git a/Items/Weapons/Melee/GreatswordofJudgement.cs b/Items/Weapons/Melee/GreatswordofJudgement.cs index d94080ec22..45b7704d5f 100644 --- a/Items/Weapons/Melee/GreatswordofJudgement.cs +++ b/Items/Weapons/Melee/GreatswordofJudgement.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class GreatswordofJudgement : ModItem + public class GreatswordofJudgement : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Melee/Greentide.cs b/Items/Weapons/Melee/Greentide.cs index 90963a5a7d..fbef373a83 100644 --- a/Items/Weapons/Melee/Greentide.cs +++ b/Items/Weapons/Melee/Greentide.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class Greentide : ModItem + public class Greentide : ModItem { public override void SetStaticDefaults() { @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee item.melee = true; item.width = 62; item.height = 62; - item.scale = 1.5f; + item.scale = 1.5f; item.useTime = 24; item.useAnimation = 24; item.useTurn = true; diff --git a/Items/Weapons/Melee/HellfireFlamberge.cs b/Items/Weapons/Melee/HellfireFlamberge.cs index 68ba09cb76..dc5c72208d 100644 --- a/Items/Weapons/Melee/HellfireFlamberge.cs +++ b/Items/Weapons/Melee/HellfireFlamberge.cs @@ -41,7 +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; + float damageMult = 0.5f; switch (index) { case 0: @@ -50,7 +50,7 @@ namespace CalamityMod.Items.Weapons.Melee break; case 2: type = ModContent.ProjectileType(); - damageMult = 0.75f; + damageMult = 0.75f; break; default: break; @@ -77,8 +77,8 @@ namespace CalamityMod.Items.Weapons.Melee } if (Main.rand.NextBool(5)) { - int smoke = Gore.NewGore(new Vector2(hitbox.X, hitbox.Y), default, Main.rand.Next(375, 378), 0.75f); - Main.gore[smoke].behindTiles = true; + int smoke = Gore.NewGore(new Vector2(hitbox.X, hitbox.Y), default, Main.rand.Next(375, 378), 0.75f); + Main.gore[smoke].behindTiles = true; } } diff --git a/Items/Weapons/Melee/HellionFlowerSpear.cs b/Items/Weapons/Melee/HellionFlowerSpear.cs index 7b62fab1b1..11c9527ae9 100644 --- a/Items/Weapons/Melee/HellionFlowerSpear.cs +++ b/Items/Weapons/Melee/HellionFlowerSpear.cs @@ -36,9 +36,9 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 8f; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 12); diff --git a/Items/Weapons/Melee/HolyCollider.cs b/Items/Weapons/Melee/HolyCollider.cs index a1ee34def1..b4f3e47b7d 100644 --- a/Items/Weapons/Melee/HolyCollider.cs +++ b/Items/Weapons/Melee/HolyCollider.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Melee item.autoReuse = true; item.shootSpeed = 10f; - item.rare = ItemRarityID.Purple; + item.rare = ItemRarityID.Purple; item.value = CalamityGlobalItem.Rarity12BuyPrice; item.Calamity().customRarity = CalamityRarity.Turquoise; } diff --git a/Items/Weapons/Melee/Lacerator.cs b/Items/Weapons/Melee/Lacerator.cs index 3171828253..50f3e46b18 100644 --- a/Items/Weapons/Melee/Lacerator.cs +++ b/Items/Weapons/Melee/Lacerator.cs @@ -5,14 +5,14 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class Lacerator : ModItem + public class Lacerator : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Lacerator"); Tooltip.SetDefault("Enemies that are hit by the yoyo will have their life drained\n" + - "A very agile yoyo\n" + - "Someone thought this was a viable weapon against DoG at one point lol"); + "A very agile yoyo\n" + + "Someone thought this was a viable weapon against DoG at one point lol"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; @@ -38,10 +38,10 @@ namespace CalamityMod.Items.Weapons.Melee item.shoot = ModContent.ProjectileType(); item.shootSpeed = 16f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } public override void AddRecipes() { diff --git a/Items/Weapons/Melee/LifefruitScythe.cs b/Items/Weapons/Melee/LifefruitScythe.cs index 70a5c80be0..fe58f2da53 100644 --- a/Items/Weapons/Melee/LifefruitScythe.cs +++ b/Items/Weapons/Melee/LifefruitScythe.cs @@ -28,10 +28,10 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item71; item.autoReuse = true; item.height = 72; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; } @@ -61,8 +61,8 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - if (player.moonLeech) - return; + if (player.moonLeech) + return; player.statLife += 5; player.HealEffect(5); diff --git a/Items/Weapons/Melee/MajesticGuard.cs b/Items/Weapons/Melee/MajesticGuard.cs index f9de47fc29..abf453a1a8 100644 --- a/Items/Weapons/Melee/MajesticGuard.cs +++ b/Items/Weapons/Melee/MajesticGuard.cs @@ -16,9 +16,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 100; - item.height = 100; - item.scale = 1.5f; - item.damage = 70; + item.height = 100; + item.scale = 1.5f; + item.damage = 70; item.melee = true; item.useAnimation = 22; item.useStyle = ItemUseStyleID.SwingThrow; @@ -33,11 +33,11 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (target.Calamity().miscDefenseLoss < target.defense) - target.Calamity().miscDefenseLoss += 1; + if (target.Calamity().miscDefenseLoss < target.defense) + target.Calamity().miscDefenseLoss += 1; - // Healing effect does not trigger versus dummies - if (player.moonLeech) + // Healing effect does not trigger versus dummies + if (player.moonLeech) return; if (target.Calamity().miscDefenseLoss >= target.defense && target.canGhostHeal) diff --git a/Items/Weapons/Melee/MantisClaws.cs b/Items/Weapons/Melee/MantisClaws.cs index 1593ec0ae0..2c47e493ce 100644 --- a/Items/Weapons/Melee/MantisClaws.cs +++ b/Items/Weapons/Melee/MantisClaws.cs @@ -41,13 +41,13 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - //does no damage. Explosion is visual + //does no damage. Explosion is visual Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - //does no damage. Explosion is visual + //does no damage. Explosion is visual int boom = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); } } diff --git a/Items/Weapons/Melee/Mariana.cs b/Items/Weapons/Melee/Mariana.cs index c16741b9e2..33fa376894 100644 --- a/Items/Weapons/Melee/Mariana.cs +++ b/Items/Weapons/Melee/Mariana.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee item.damage = 90; item.width = 54; item.height = 62; - item.scale = 1.5f; + item.scale = 1.5f; item.melee = true; item.useAnimation = 24; item.useStyle = ItemUseStyleID.SwingThrow; @@ -50,73 +50,73 @@ namespace CalamityMod.Items.Weapons.Melee recipe.AddRecipe(); } - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - int num251 = Main.rand.Next(2, 4); - 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) - { - value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(target.Center.X, target.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), knockback, player.whoAmI, 0f, 0f); - } - for (int num621 = 0; num621 < 30; num621++) - { - int num622 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 50; num623++) - { - int num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) + { + int num251 = Main.rand.Next(2, 4); + 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) + { + value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + } + value15.Normalize(); + value15 *= Main.rand.Next(70, 101) * 0.1f; + Projectile.NewProjectile(target.Center.X, target.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), knockback, player.whoAmI, 0f, 0f); + } + for (int num621 = 0; num621 < 30; num621++) + { + int num622 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 50; num623++) + { + int num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - int num251 = Main.rand.Next(2, 4); - 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) - { - value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(target.Center.X, target.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), item.knockBack, player.whoAmI, 0f, 0f); - } - for (int num621 = 0; num621 < 30; num621++) - { - int num622 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 50; num623++) - { - int num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } + public override void OnHitPvp(Player player, Player target, int damage, bool crit) + { + int num251 = Main.rand.Next(2, 4); + 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) + { + value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + } + value15.Normalize(); + value15 *= Main.rand.Next(70, 101) * 0.1f; + Projectile.NewProjectile(target.Center.X, target.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), item.knockBack, player.whoAmI, 0f, 0f); + } + for (int num621 = 0; num621 < 30; num621++) + { + int num622 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 50; num623++) + { + int num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 59, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } public override void MeleeEffects(Player player, Rectangle hitbox) { diff --git a/Items/Weapons/Melee/MarniteSpear.cs b/Items/Weapons/Melee/MarniteSpear.cs index 4cbf218a64..4034b044fe 100644 --- a/Items/Weapons/Melee/MarniteSpear.cs +++ b/Items/Weapons/Melee/MarniteSpear.cs @@ -31,12 +31,12 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Blue; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 5f; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddRecipeGroup("AnyGoldBar", 5); diff --git a/Items/Weapons/Melee/MirrorBlade.cs b/Items/Weapons/Melee/MirrorBlade.cs index 441977cd3c..6f1814ec50 100644 --- a/Items/Weapons/Melee/MirrorBlade.cs +++ b/Items/Weapons/Melee/MirrorBlade.cs @@ -30,10 +30,10 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item1; item.autoReuse = true; item.height = 62; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.shootSpeed = 9f; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.shootSpeed = 9f; item.shoot = ModContent.ProjectileType(); } diff --git a/Items/Weapons/Melee/Mourningstar.cs b/Items/Weapons/Melee/Mourningstar.cs index 4bd2ad4ab5..93e87923de 100644 --- a/Items/Weapons/Melee/Mourningstar.cs +++ b/Items/Weapons/Melee/Mourningstar.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class Mourningstar : ModItem + public class Mourningstar : ModItem { public override void SetStaticDefaults() { @@ -30,10 +30,10 @@ namespace CalamityMod.Items.Weapons.Melee item.useStyle = ItemUseStyleID.HoldingOut; item.knockBack = 2.5f; item.UseSound = SoundID.Item116; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.shootSpeed = 24f; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.shootSpeed = 24f; item.shoot = ModContent.ProjectileType(); } diff --git a/Items/Weapons/Melee/Murasama.cs b/Items/Weapons/Melee/Murasama.cs index 24abe58de2..13a9addd9c 100644 --- a/Items/Weapons/Melee/Murasama.cs +++ b/Items/Weapons/Melee/Murasama.cs @@ -9,77 +9,77 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class Murasama : ModItem - { - public int frameCounter = 0; - public int frame = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Murasama"); - Tooltip.SetDefault("There will be blood!\n" + - "ID and power-level locked\n" + - "Prove your strength or have the correct user ID to wield this sword"); - Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 13)); - } + public class Murasama : ModItem + { + public int frameCounter = 0; + public int frame = 0; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Murasama"); + Tooltip.SetDefault("There will be blood!\n" + + "ID and power-level locked\n" + + "Prove your strength or have the correct user ID to wield this sword"); + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 13)); + } - public override void SetDefaults() - { - item.height = 128; - item.width = 56; - item.damage = 3001; - item.melee = true; - item.noMelee = true; - item.noUseGraphic = true; - item.channel = true; - item.useAnimation = 25; - item.useStyle = ItemUseStyleID.HoldingOut; - item.useTime = 5; - item.knockBack = 6.5f; - item.autoReuse = false; - item.value = Item.buyPrice(2, 50, 0, 0); - item.rare = ItemRarityID.Red; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 24f; - item.Calamity().customRarity = CalamityRarity.Violet; - Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(5, 14)); - item.Calamity().trueMelee = true; - } + public override void SetDefaults() + { + item.height = 128; + item.width = 56; + item.damage = 3001; + item.melee = true; + item.noMelee = true; + item.noUseGraphic = true; + item.channel = true; + item.useAnimation = 25; + item.useStyle = ItemUseStyleID.HoldingOut; + item.useTime = 5; + item.knockBack = 6.5f; + item.autoReuse = false; + item.value = Item.buyPrice(2, 50, 0, 0); + item.rare = ItemRarityID.Red; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 24f; + item.Calamity().customRarity = CalamityRarity.Violet; + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(5, 14)); + item.Calamity().trueMelee = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 30; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 30; - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - //0 = 6 frames, 8 = 3 frames] - Texture2D texture = ModContent.GetTexture(Texture); - spriteBatch.Draw(texture, position, item.GetCurrentFrame(ref frame, ref frameCounter, frame == 0 ? 36 : frame == 8 ? 24 : 6, 13), Color.White, 0f, origin, scale, SpriteEffects.None, 0); - return false; - } + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + //0 = 6 frames, 8 = 3 frames] + Texture2D texture = ModContent.GetTexture(Texture); + spriteBatch.Draw(texture, position, item.GetCurrentFrame(ref frame, ref frameCounter, frame == 0 ? 36 : frame == 8 ? 24 : 6, 13), Color.White, 0f, origin, scale, SpriteEffects.None, 0); + return false; + } - public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) - { - Texture2D texture = ModContent.GetTexture(Texture); - spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, frame == 0 ? 36 : frame == 8 ? 24 : 6, 13), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); - return false; - } + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture = ModContent.GetTexture(Texture); + spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, frame == 0 ? 36 : frame == 8 ? 24 : 6, 13), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + return false; + } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Weapons/Melee/MurasamaGlow"); - spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, frame == 0 ? 36 : frame == 8 ? 24 : 6, 13, false), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Weapons/Melee/MurasamaGlow"); + spriteBatch.Draw(texture, item.position - Main.screenPosition, item.GetCurrentFrame(ref frame, ref frameCounter, frame == 0 ? 36 : frame == 8 ? 24 : 6, 13, false), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } - public override bool CanUseItem(Player player) - { - if (player.ownedProjectileCounts[item.shoot] > 0) - return false; - return CalamityWorld.downedYharon || player.name == "Jetstream Sam" || player.name == "Samuel Rodrigues"; - } + public override bool CanUseItem(Player player) + { + if (player.ownedProjectileCounts[item.shoot] > 0) + return false; + return CalamityWorld.downedYharon || player.name == "Jetstream Sam" || player.name == "Samuel Rodrigues"; + } - 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, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - return false; - } - } + 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, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + } } diff --git a/Items/Weapons/Melee/NightsStabber.cs b/Items/Weapons/Melee/NightsStabber.cs index ef7bb40c70..f5e44856c5 100644 --- a/Items/Weapons/Melee/NightsStabber.cs +++ b/Items/Weapons/Melee/NightsStabber.cs @@ -59,14 +59,14 @@ namespace CalamityMod.Items.Weapons.Melee Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 14); } - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), knockback, Main.myPlayer); - } + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) + { + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), knockback, Main.myPlayer); + } - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), item.knockBack, Main.myPlayer); - } + public override void OnHitPvp(Player player, Player target, int damage, bool crit) + { + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), item.knockBack, Main.myPlayer); + } } } diff --git a/Items/Weapons/Melee/OmegaBiomeBlade.cs b/Items/Weapons/Melee/OmegaBiomeBlade.cs index bc7498418d..ed95e5f867 100644 --- a/Items/Weapons/Melee/OmegaBiomeBlade.cs +++ b/Items/Weapons/Melee/OmegaBiomeBlade.cs @@ -17,7 +17,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Melee { - public class OmegaBiomeBlade : ModItem + public class OmegaBiomeBlade : ModItem { public Attunement mainAttunement = null; public Attunement secondaryAttunement = null; diff --git a/Items/Weapons/Melee/Omniblade.cs b/Items/Weapons/Melee/Omniblade.cs index 39fae23d88..a6ee7bc00a 100644 --- a/Items/Weapons/Melee/Omniblade.cs +++ b/Items/Weapons/Melee/Omniblade.cs @@ -34,11 +34,11 @@ namespace CalamityMod.Items.Weapons.Melee item.shoot = ModContent.ProjectileType(); item.shootSpeed = 24f; item.rare = ItemRarityID.Yellow; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 45; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 45; public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; diff --git a/Items/Weapons/Melee/PhoenixBlade.cs b/Items/Weapons/Melee/PhoenixBlade.cs index 8166f627c6..98bb09fa95 100644 --- a/Items/Weapons/Melee/PhoenixBlade.cs +++ b/Items/Weapons/Melee/PhoenixBlade.cs @@ -37,28 +37,28 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { if (target.life <= 0) - OnHitEffects(player, target.Center, knockback, damage, crit); + OnHitEffects(player, target.Center, knockback, damage, crit); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { if (target.statLife <= 0) - OnHitEffects(player, target.Center, item.knockBack, damage, crit); - } + OnHitEffects(player, target.Center, item.knockBack, damage, crit); + } - private void OnHitEffects(Player player, Vector2 targetPos, float kBack, int damage, bool crit) - { - if (crit) - damage /= 2; + private void OnHitEffects(Player player, Vector2 targetPos, float kBack, int damage, bool crit) + { + if (crit) + damage /= 2; - int boom = Projectile.NewProjectile(targetPos, Vector2.Zero, ModContent.ProjectileType(), damage, kBack, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (boom.WithinBounds(Main.maxProjectiles)) - Main.projectile[boom].Calamity().forceMelee = true; + int boom = Projectile.NewProjectile(targetPos, Vector2.Zero, ModContent.ProjectileType(), damage, kBack, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceMelee = true; - float randomSpeedX = Main.rand.Next(5); - float randomSpeedY = Main.rand.Next(3, 7); - Projectile.NewProjectile(targetPos.X, targetPos.Y, -randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), damage, kBack, player.whoAmI); - Projectile.NewProjectile(targetPos.X, targetPos.Y, randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), damage, kBack, player.whoAmI); + float randomSpeedX = Main.rand.Next(5); + float randomSpeedY = Main.rand.Next(3, 7); + Projectile.NewProjectile(targetPos.X, targetPos.Y, -randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), damage, kBack, player.whoAmI); + Projectile.NewProjectile(targetPos.X, targetPos.Y, randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), damage, kBack, player.whoAmI); } public override void MeleeEffects(Player player, Rectangle hitbox) diff --git a/Items/Weapons/Melee/PhosphorescentGauntlet.cs b/Items/Weapons/Melee/PhosphorescentGauntlet.cs index bcc6b09eee..3fce375e59 100644 --- a/Items/Weapons/Melee/PhosphorescentGauntlet.cs +++ b/Items/Weapons/Melee/PhosphorescentGauntlet.cs @@ -6,48 +6,48 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class PhosphorescentGauntlet : ModItem - { - public const int OnHitIFrames = 15; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Phosphorescent Gauntlet"); - Tooltip.SetDefault("Releases rapid sulphurous punches\n" + - "On use, you lunge in the direction of the mouse\n" + - "On collision, you are knocked back"); - } + public class PhosphorescentGauntlet : ModItem + { + public const int OnHitIFrames = 15; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Phosphorescent Gauntlet"); + Tooltip.SetDefault("Releases rapid sulphurous punches\n" + + "On use, you lunge in the direction of the mouse\n" + + "On collision, you are knocked back"); + } - public override void SetDefaults() - { - item.width = item.height = 40; - item.damage = 2705; - item.melee = true; - item.noMelee = true; - item.noUseGraphic = true; - item.channel = true; - item.useAnimation = item.useTime = 40; - item.useTurn = true; - item.useStyle = ItemUseStyleID.SwingThrow; - item.knockBack = 9f; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 1f; - item.Calamity().customRarity = CalamityRarity.PureGreen; - item.Calamity().trueMelee = true; - } + public override void SetDefaults() + { + item.width = item.height = 40; + item.damage = 2705; + item.melee = true; + item.noMelee = true; + item.noUseGraphic = true; + item.channel = true; + item.useAnimation = item.useTime = 40; + item.useTurn = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.knockBack = 9f; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 1f; + item.Calamity().customRarity = CalamityRarity.PureGreen; + item.Calamity().trueMelee = true; + } - // Terraria seems to really dislike high crit values in SetDefaults. - public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; + // Terraria seems to really dislike high crit values in SetDefaults. + public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - 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, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - return false; - } - } + 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, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + return false; + } + } } diff --git a/Items/Weapons/Melee/PhotonRipper.cs b/Items/Weapons/Melee/PhotonRipper.cs index 3fd4212e8f..ca83611f00 100644 --- a/Items/Weapons/Melee/PhotonRipper.cs +++ b/Items/Weapons/Melee/PhotonRipper.cs @@ -6,51 +6,51 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class PhotonRipper : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Photon Ripper"); - Tooltip.SetDefault("Projects a directed stream of hardlight teeth at ultra high velocity\n" + - "This weapon and its projectiles function as a chainsaw"); - } + public class PhotonRipper : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Photon Ripper"); + Tooltip.SetDefault("Projects a directed stream of hardlight teeth at ultra high velocity\n" + + "This weapon and its projectiles function as a chainsaw"); + } - public override void SetDefaults() - { - item.damage = 3725; - item.knockBack = 12f; - item.useTime = 5; - item.useAnimation = 25; - // In-game, the displayed axe power is 5x the value set here. - // This corrects for trees having 500% hardness internally. - // So that the axe power in the code looks like the axe power you see on screen, divide by 5. - item.axe = 3000 / 5; - // Photon Ripper's axe power is entirely for show. Its projectiles instantly one shot trees. + public override void SetDefaults() + { + item.damage = 3725; + item.knockBack = 12f; + item.useTime = 5; + item.useAnimation = 25; + // In-game, the displayed axe power is 5x the value set here. + // This corrects for trees having 500% hardness internally. + // So that the axe power in the code looks like the axe power you see on screen, divide by 5. + item.axe = 3000 / 5; + // Photon Ripper's axe power is entirely for show. Its projectiles instantly one shot trees. - item.height = 134; - item.width = 54; - item.melee = true; - item.noMelee = true; - item.noUseGraphic = true; - item.channel = true; - item.useStyle = ItemUseStyleID.HoldingOut; - item.autoReuse = false; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 1f; + item.height = 134; + item.width = 54; + item.melee = true; + item.noMelee = true; + item.noUseGraphic = true; + item.channel = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.autoReuse = false; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 1f; - item.rare = ItemRarityID.Red; - item.Calamity().customRarity = CalamityRarity.Violet; - item.value = CalamityGlobalItem.RarityVioletBuyPrice; - } + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.Violet; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + } - public override void GetWeaponCrit(Player player, ref int crit) => crit += 18; + public override void GetWeaponCrit(Player player, ref int crit) => crit += 18; - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - 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, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - return false; - } - } + 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, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + } } diff --git a/Items/Weapons/Melee/PlagueKeeper.cs b/Items/Weapons/Melee/PlagueKeeper.cs index 01663b33b9..632ad05c54 100644 --- a/Items/Weapons/Melee/PlagueKeeper.cs +++ b/Items/Weapons/Melee/PlagueKeeper.cs @@ -50,10 +50,10 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(ModContent.BuffType(), 300); for (int i = 0; i < 3; i++) { int bee = Projectile.NewProjectile(player.Center, Vector2.Zero, player.beeType(), @@ -68,10 +68,10 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(ModContent.BuffType(), 300); for (int i = 0; i < 3; i++) { int bee = Projectile.NewProjectile(player.Center, Vector2.Zero, player.beeType(), diff --git a/Items/Weapons/Melee/PrismaticBreaker.cs b/Items/Weapons/Melee/PrismaticBreaker.cs index 34c1e5d641..b26c27508d 100644 --- a/Items/Weapons/Melee/PrismaticBreaker.cs +++ b/Items/Weapons/Melee/PrismaticBreaker.cs @@ -12,7 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class PrismaticBreaker : ModItem + public class PrismaticBreaker : ModItem { private int alpha = 50; public Color[] colors = new Color[] @@ -134,9 +134,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 300); - target.AddBuff(BuffID.Daybreak, 300); - } + target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(BuffID.Daybreak, 300); + } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { diff --git a/Items/Weapons/Melee/ProfanedSword.cs b/Items/Weapons/Melee/ProfanedSword.cs index 06916b6641..ae9fcb0994 100644 --- a/Items/Weapons/Melee/ProfanedSword.cs +++ b/Items/Weapons/Melee/ProfanedSword.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee item.damage = 100; item.melee = true; item.width = item.height = 52; - item.scale = 1.5f; + item.scale = 1.5f; item.useTime = 23; item.useAnimation = 23; item.useTurn = true; @@ -66,19 +66,19 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(ModContent.BuffType(), 300); Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, Main.myPlayer); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(ModContent.BuffType(), 300); Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, item.knockBack, Main.myPlayer); } diff --git a/Items/Weapons/Melee/PwnagehammerMelee.cs b/Items/Weapons/Melee/PwnagehammerMelee.cs index 733978f19c..44b64b1b2f 100644 --- a/Items/Weapons/Melee/PwnagehammerMelee.cs +++ b/Items/Weapons/Melee/PwnagehammerMelee.cs @@ -35,8 +35,8 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 24.4f; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Melee/RemsRevenge.cs b/Items/Weapons/Melee/RemsRevenge.cs index a6656829d0..f70f381d5e 100644 --- a/Items/Weapons/Melee/RemsRevenge.cs +++ b/Items/Weapons/Melee/RemsRevenge.cs @@ -5,46 +5,46 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class RemsRevenge : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Rem's Revenge"); - Tooltip.SetDefault("Wielded by the most powerful fighter.\n" + - "Summons blood explosions and lowers enemy defense on hit"); - } + public class RemsRevenge : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rem's Revenge"); + Tooltip.SetDefault("Wielded by the most powerful fighter.\n" + + "Summons blood explosions and lowers enemy defense on hit"); + } - public override void SetDefaults() - { - item.damage = 375; - item.melee = true; - item.width = 44; - item.height = 34; - item.useTime = 15; - item.useAnimation = 15; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.noUseGraphic = true; - item.knockBack = 10f; - item.value = CalamityGlobalItem.Rarity10BuyPrice; - item.rare = ItemRarityID.Red; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.channel = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 12f; - item.Calamity().donorItem = true; - } + public override void SetDefaults() + { + item.damage = 375; + item.melee = true; + item.width = 44; + item.height = 34; + item.useTime = 15; + item.useAnimation = 15; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.noUseGraphic = true; + item.knockBack = 10f; + item.value = CalamityGlobalItem.Rarity10BuyPrice; + item.rare = ItemRarityID.Red; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.channel = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 12f; + item.Calamity().donorItem = true; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.BlueMoon); - recipe.AddIngredient(ItemID.LunarBar, 5); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BlueMoon); + recipe.AddIngredient(ItemID.LunarBar, 5); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Melee/SausageMaker.cs b/Items/Weapons/Melee/SausageMaker.cs index 9476c43707..05aab76c8f 100644 --- a/Items/Weapons/Melee/SausageMaker.cs +++ b/Items/Weapons/Melee/SausageMaker.cs @@ -33,12 +33,12 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Orange; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 6f; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 8); diff --git a/Items/Weapons/Melee/ScourgeoftheCosmos.cs b/Items/Weapons/Melee/ScourgeoftheCosmos.cs index ba4f7a97e0..0be8bbd7fb 100644 --- a/Items/Weapons/Melee/ScourgeoftheCosmos.cs +++ b/Items/Weapons/Melee/ScourgeoftheCosmos.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class ScourgeoftheCosmos : ModItem + public class ScourgeoftheCosmos : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Melee/SeashineSword.cs b/Items/Weapons/Melee/SeashineSword.cs index cf161bcfc8..0dffad7822 100644 --- a/Items/Weapons/Melee/SeashineSword.cs +++ b/Items/Weapons/Melee/SeashineSword.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.CloneDefaults(ItemID.EnchantedSword); - item.useTime = 30; + item.useTime = 30; item.damage = 26; item.melee = true; item.value = Item.buyPrice(0, 2, 0, 0); diff --git a/Items/Weapons/Melee/Shimmerspark.cs b/Items/Weapons/Melee/Shimmerspark.cs index c4318404ac..be27df15ac 100644 --- a/Items/Weapons/Melee/Shimmerspark.cs +++ b/Items/Weapons/Melee/Shimmerspark.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Shimmerspark"); Tooltip.SetDefault("Fires stars when enemies are near\n" + - "A very agile yoyo"); + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/SolarFlare.cs b/Items/Weapons/Melee/SolarFlare.cs index 1c5b8d4e3c..4f6693beff 100644 --- a/Items/Weapons/Melee/SolarFlare.cs +++ b/Items/Weapons/Melee/SolarFlare.cs @@ -4,13 +4,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class SolarFlare : ModItem + public class SolarFlare : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Solar Flare"); Tooltip.SetDefault("Emits large holy explosions on hit\n" + - "A very agile yoyo"); + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; @@ -36,9 +36,9 @@ namespace CalamityMod.Items.Weapons.Melee item.shoot = ModContent.ProjectileType(); item.shootSpeed = 16f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } } } diff --git a/Items/Weapons/Melee/SoulHarvester.cs b/Items/Weapons/Melee/SoulHarvester.cs index d764bf0ef4..42f3b9d485 100644 --- a/Items/Weapons/Melee/SoulHarvester.cs +++ b/Items/Weapons/Melee/SoulHarvester.cs @@ -62,8 +62,8 @@ namespace CalamityMod.Items.Weapons.Melee if (target.life <= (target.lifeMax * 0.15f)) { Main.PlaySound(SoundID.Item14, target.position); - player.ApplyDamageToNPC(target, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), 0f, 0, false); - for (int num621 = 0; num621 < 10; num621++) + player.ApplyDamageToNPC(target, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), 0f, 0, false); + for (int num621 = 0; num621 < 10; num621++) { int num622 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; @@ -91,7 +91,7 @@ namespace CalamityMod.Items.Weapons.Melee if (target.statLife <= (target.statLifeMax * 0.15f)) { Main.PlaySound(SoundID.Item14, target.position); - for (int num621 = 0; num621 < 10; num621++) + for (int num621 = 0; num621 < 10; num621++) { int num622 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; diff --git a/Items/Weapons/Melee/SpatialLance.cs b/Items/Weapons/Melee/SpatialLance.cs index c65e022c4b..29bae9772a 100644 --- a/Items/Weapons/Melee/SpatialLance.cs +++ b/Items/Weapons/Melee/SpatialLance.cs @@ -30,15 +30,15 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item1; item.autoReuse = true; item.height = 88; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); diff --git a/Items/Weapons/Melee/SporeKnife.cs b/Items/Weapons/Melee/SporeKnife.cs index f583a37dd2..715353c52e 100644 --- a/Items/Weapons/Melee/SporeKnife.cs +++ b/Items/Weapons/Melee/SporeKnife.cs @@ -47,18 +47,18 @@ namespace CalamityMod.Items.Weapons.Melee Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 2); } - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - int proj = Projectile.NewProjectile(target.Center, Vector2.Zero, Main.rand.Next(569, 572), (int)(item.damage * 0.5f * player.MeleeDamage()), knockback, Main.myPlayer); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMelee = true; - } + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) + { + int proj = Projectile.NewProjectile(target.Center, Vector2.Zero, Main.rand.Next(569, 572), (int)(item.damage * 0.5f * player.MeleeDamage()), knockback, Main.myPlayer); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; + } - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - int proj = Projectile.NewProjectile(target.Center, Vector2.Zero, Main.rand.Next(569, 572), (int)(item.damage * 0.5f * player.MeleeDamage()), item.knockBack, Main.myPlayer); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMelee = true; - } + public override void OnHitPvp(Player player, Player target, int damage, bool crit) + { + int proj = Projectile.NewProjectile(target.Center, Vector2.Zero, Main.rand.Next(569, 572), (int)(item.damage * 0.5f * player.MeleeDamage()), item.knockBack, Main.myPlayer); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; + } } } diff --git a/Items/Weapons/Melee/StarnightLance.cs b/Items/Weapons/Melee/StarnightLance.cs index 45cb2212e3..f2d30b2ddd 100644 --- a/Items/Weapons/Melee/StarnightLance.cs +++ b/Items/Weapons/Melee/StarnightLance.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 6f; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 12); diff --git a/Items/Weapons/Melee/StellarContemptMelee.cs b/Items/Weapons/Melee/StellarContemptMelee.cs index 7b364b220b..7438ddb351 100644 --- a/Items/Weapons/Melee/StellarContemptMelee.cs +++ b/Items/Weapons/Melee/StellarContemptMelee.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class StellarContemptMelee : ModItem + public class StellarContemptMelee : ModItem { public override string Texture => "CalamityMod/Items/Weapons/Melee/StellarContempt"; diff --git a/Items/Weapons/Melee/StellarStriker.cs b/Items/Weapons/Melee/StellarStriker.cs index 907358ef3b..d343184673 100644 --- a/Items/Weapons/Melee/StellarStriker.cs +++ b/Items/Weapons/Melee/StellarStriker.cs @@ -17,9 +17,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 84; - item.height = 90; - item.scale = 1.5f; - item.damage = 480; + item.height = 90; + item.scale = 1.5f; + item.damage = 480; item.melee = true; item.useAnimation = 25; item.useStyle = ItemUseStyleID.SwingThrow; @@ -69,10 +69,10 @@ namespace CalamityMod.Items.Weapons.Melee num80 = num72 / num80; } - if (crit) - damage /= 2; + if (crit) + damage /= 2; - int num112 = 2; + int num112 = 2; for (int num113 = 0; num113 < num112; num113++) { vector2 = new Vector2(player.Center.X + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); @@ -95,8 +95,8 @@ namespace CalamityMod.Items.Weapons.Melee float num114 = num78; float num115 = num79 + (float)Main.rand.Next(-80, 81) * 0.02f; int proj = Projectile.NewProjectile(vector2.X, vector2.Y, num114, num115, ProjectileID.LunarFlare, (int)(damage * 0.5), knockBack, i, 0f, (float)Main.rand.Next(3)); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } } diff --git a/Items/Weapons/Melee/StormSaber.cs b/Items/Weapons/Melee/StormSaber.cs index 72b08cc8fb..70c5d24f4b 100644 --- a/Items/Weapons/Melee/StormSaber.cs +++ b/Items/Weapons/Melee/StormSaber.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Storm Saber"); Tooltip.SetDefault("Fires two homing storm beams\n" + - "One from blade and one from the sky"); + "One from blade and one from the sky"); } public override void SetDefaults() diff --git a/Items/Weapons/Melee/SubmarineShocker.cs b/Items/Weapons/Melee/SubmarineShocker.cs index 1678372b82..81433e938f 100644 --- a/Items/Weapons/Melee/SubmarineShocker.cs +++ b/Items/Weapons/Melee/SubmarineShocker.cs @@ -42,18 +42,18 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.7f), knockback, Main.myPlayer); + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.7f), knockback, Main.myPlayer); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.7f), item.knockBack, Main.myPlayer); + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.7f), item.knockBack, Main.myPlayer); } } } diff --git a/Items/Weapons/Melee/SulphurousGrabber.cs b/Items/Weapons/Melee/SulphurousGrabber.cs index 50399f2161..7f9a560304 100644 --- a/Items/Weapons/Melee/SulphurousGrabber.cs +++ b/Items/Weapons/Melee/SulphurousGrabber.cs @@ -11,8 +11,8 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Sulphurous Grabber"); Tooltip.SetDefault("Occasionally releases a ring of colored bubbles\n" + - "The yoyo powers up after touching a green bubble\n" + - "A very agile yoyo"); + "The yoyo powers up after touching a green bubble\n" + + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/Swordsplosion.cs b/Items/Weapons/Melee/Swordsplosion.cs index a6960d25ff..e3f9146165 100644 --- a/Items/Weapons/Melee/Swordsplosion.cs +++ b/Items/Weapons/Melee/Swordsplosion.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class Swordsplosion : ModItem + public class Swordsplosion : ModItem { public override void SetStaticDefaults() { @@ -29,11 +29,11 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item60; item.autoReuse = true; item.height = 90; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.shoot = ModContent.ProjectileType(); 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) { @@ -103,16 +103,16 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(ModContent.BuffType(), 120); + } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(ModContent.BuffType(), 120); + } } } diff --git a/Items/Weapons/Melee/TeardropCleaver.cs b/Items/Weapons/Melee/TeardropCleaver.cs index 2fc64c639b..f1a22e8771 100644 --- a/Items/Weapons/Melee/TeardropCleaver.cs +++ b/Items/Weapons/Melee/TeardropCleaver.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Melee item.height = 66; item.value = Item.buyPrice(0, 2, 0, 0); item.rare = ItemRarityID.Green; - } + } public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { diff --git a/Items/Weapons/Melee/TemporalFloeSword.cs b/Items/Weapons/Melee/TemporalFloeSword.cs index 64f99ab03b..932fb9efc2 100644 --- a/Items/Weapons/Melee/TemporalFloeSword.cs +++ b/Items/Weapons/Melee/TemporalFloeSword.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Melee DisplayName.SetDefault("Temporal Floe Sword"); Tooltip.SetDefault("The iceman cometh...\n" + "Fires a frozen sword beam that splits into two more beams\n" + - "The direction of the beams depends on in game time"); + "The direction of the beams depends on in game time"); } public override void SetDefaults() diff --git a/Items/Weapons/Melee/TerraEdge.cs b/Items/Weapons/Melee/TerraEdge.cs index 9c25e6c7c6..598be68852 100644 --- a/Items/Weapons/Melee/TerraEdge.cs +++ b/Items/Weapons/Melee/TerraEdge.cs @@ -19,9 +19,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 58; - item.height = 58; - item.scale = 1.5f; - item.damage = 112; + item.height = 58; + item.scale = 1.5f; + item.damage = 112; item.melee = true; item.useAnimation = 17; item.useStyle = ItemUseStyleID.SwingThrow; @@ -68,9 +68,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - target.AddBuff(BuffID.Ichor, 90); + target.AddBuff(BuffID.Ichor, 90); - if (!target.canGhostHeal || player.moonLeech) + if (!target.canGhostHeal || player.moonLeech) return; int healAmount = Main.rand.Next(2) + 2; @@ -80,10 +80,10 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - target.AddBuff(BuffID.Ichor, 90); + target.AddBuff(BuffID.Ichor, 90); - if (player.moonLeech) - return; + if (player.moonLeech) + return; int healAmount = Main.rand.Next(2) + 2; player.statLife += healAmount; diff --git a/Items/Weapons/Melee/TerraLance.cs b/Items/Weapons/Melee/TerraLance.cs index 9d9a6e54a8..58165c7268 100644 --- a/Items/Weapons/Melee/TerraLance.cs +++ b/Items/Weapons/Melee/TerraLance.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 11f; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.ChlorophytePartisan); diff --git a/Items/Weapons/Melee/Terracotta.cs b/Items/Weapons/Melee/Terracotta.cs index 11a4fa4edb..a7d9e7597a 100644 --- a/Items/Weapons/Melee/Terracotta.cs +++ b/Items/Weapons/Melee/Terracotta.cs @@ -19,9 +19,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 50; - item.height = 62; - item.scale = 1.5f; - item.damage = 110; + item.height = 62; + item.scale = 1.5f; + item.damage = 110; item.melee = true; item.useAnimation = 15; item.useTime = 15; diff --git a/Items/Weapons/Melee/Terratomere.cs b/Items/Weapons/Melee/Terratomere.cs index 9845f0c13d..1f44eb5560 100644 --- a/Items/Weapons/Melee/Terratomere.cs +++ b/Items/Weapons/Melee/Terratomere.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Melee item.height = 66; item.value = CalamityGlobalItem.Rarity12BuyPrice; item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.shoot = ModContent.ProjectileType(); + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 20f; } @@ -94,8 +94,8 @@ namespace CalamityMod.Items.Weapons.Melee { target.AddBuff(ModContent.BuffType(), 30); - if (player.moonLeech) - return; + if (player.moonLeech) + return; int healAmount = Main.rand.Next(3) + 2; player.statLife += healAmount; diff --git a/Items/Weapons/Melee/TheEyeofCalamitas.cs b/Items/Weapons/Melee/TheEyeofCalamitas.cs index dff35447e7..c381b19273 100644 --- a/Items/Weapons/Melee/TheEyeofCalamitas.cs +++ b/Items/Weapons/Melee/TheEyeofCalamitas.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Oblivion"); Tooltip.SetDefault("Fires brimstone lasers when enemies are near\n" + - "A very agile yoyo"); + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/TheGodsGambit.cs b/Items/Weapons/Melee/TheGodsGambit.cs index 9cefd4e1b1..5f52a38b9a 100644 --- a/Items/Weapons/Melee/TheGodsGambit.cs +++ b/Items/Weapons/Melee/TheGodsGambit.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("The God's Gambit"); Tooltip.SetDefault("Fires a stream of slime when enemies are near\n" + - "A very agile yoyo"); + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/TheLastMourning.cs b/Items/Weapons/Melee/TheLastMourning.cs index 0fe39c8c1b..6967497e0c 100644 --- a/Items/Weapons/Melee/TheLastMourning.cs +++ b/Items/Weapons/Melee/TheLastMourning.cs @@ -41,8 +41,8 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; bool isDoGSegment = target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); if (!isDoGSegment || Main.rand.NextBool(3)) @@ -54,8 +54,8 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - if (crit) - damage /= 2; + if (crit) + damage /= 2; CalamityPlayer.HorsemansBladeOnHit(player, -1, damage, item.knockBack, 0, ModContent.ProjectileType()); CalamityPlayer.HorsemansBladeOnHit(player, -1, damage, item.knockBack, 1); diff --git a/Items/Weapons/Melee/TheMicrowave.cs b/Items/Weapons/Melee/TheMicrowave.cs index a241dd93cd..44b954fb0d 100644 --- a/Items/Weapons/Melee/TheMicrowave.cs +++ b/Items/Weapons/Melee/TheMicrowave.cs @@ -11,8 +11,8 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("The Microwave"); Tooltip.SetDefault("Fries nearby enemies with radiation\n" + - "A very agile yoyo\n" + - "Cooking, Astral Infection style"); + "A very agile yoyo\n" + + "Cooking, Astral Infection style"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/TheObliterator.cs b/Items/Weapons/Melee/TheObliterator.cs index 288b99f75e..9f45373a5d 100644 --- a/Items/Weapons/Melee/TheObliterator.cs +++ b/Items/Weapons/Melee/TheObliterator.cs @@ -4,13 +4,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class TheObliterator : ModItem + public class TheObliterator : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("The Obliterator"); Tooltip.SetDefault("Ruins nearby enemies with death lasers\n" + - "An exceptionally agile yoyo"); + "An exceptionally agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; @@ -36,9 +36,9 @@ namespace CalamityMod.Items.Weapons.Melee item.shoot = ModContent.ProjectileType(); item.shootSpeed = 16f; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + } } } diff --git a/Items/Weapons/Melee/ThePlaguebringer.cs b/Items/Weapons/Melee/ThePlaguebringer.cs index 4c28fa7b40..b611f134d1 100644 --- a/Items/Weapons/Melee/ThePlaguebringer.cs +++ b/Items/Weapons/Melee/ThePlaguebringer.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Pandemic"); Tooltip.SetDefault("Fires plague seekers when enemies are near\n" + - "A very agile yoyo"); + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/TitanArm.cs b/Items/Weapons/Melee/TitanArm.cs index 3c744a4724..304de01ac6 100644 --- a/Items/Weapons/Melee/TitanArm.cs +++ b/Items/Weapons/Melee/TitanArm.cs @@ -5,13 +5,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class TitanArm : ModItem + public class TitanArm : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Titan Arm"); Tooltip.SetDefault("Slap Hand but better\n" + - "Sends enemies straight to the stars at the speed of light"); + "Sends enemies straight to the stars at the speed of light"); } public override void SetDefaults() @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 46; item.height = 58; item.damage = 69; - item.scale = 1.75f; + item.scale = 1.75f; item.knockBack = 20f; //This number doesn't mean anything, but it's not 9001f because that caused bugs. item.useAnimation = item.useTime = 12; item.melee = true; @@ -31,13 +31,13 @@ namespace CalamityMod.Items.Weapons.Melee item.value = CalamityGlobalItem.Rarity7BuyPrice; } - // Boosting crit in SetDefaults along with knockback seemed to severely inflate the reforging price. Guaranteed crits for more knockback. - public override void GetWeaponCrit(Player player, ref int crit) => crit = 100; + // Boosting crit in SetDefaults along with knockback seemed to severely inflate the reforging price. Guaranteed crits for more knockback. + public override void GetWeaponCrit(Player player, ref int crit) => crit = 100; public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 300); - YeetEnemies(player, target, crit); + YeetEnemies(player, target, crit); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) @@ -45,18 +45,18 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(ModContent.BuffType(), 300); } - private void YeetEnemies(Player player, NPC target, bool crit) - { - // Manually doing knockback because it is capped in vanilla. This lets Titan Arm reach its full potential. =D - // This is modified vanilla code from StrikeNPC method in NPC.cs - // Extra Note: Will cause an out of bounds error on enemies that don't despawn and are affected. See Blue Cultist Archer. - // Extra (extra) Note: Fails in ModifyHitNPC if the enemy has too much health due to velocity clamping if you don't do enough damage. - float kbAmt = player.GetWeaponKnockback(item, item.knockBack) * 9001f * target.knockBackResist; //That obligatory over 9000 reference - if (crit) - kbAmt *= 1.4f; - float kbAmtY = target.noGravity ? kbAmt * -0.5f : kbAmt * -0.75f; - target.velocity.Y += kbAmtY; - target.velocity.X += kbAmt * player.direction; - } + private void YeetEnemies(Player player, NPC target, bool crit) + { + // Manually doing knockback because it is capped in vanilla. This lets Titan Arm reach its full potential. =D + // This is modified vanilla code from StrikeNPC method in NPC.cs + // Extra Note: Will cause an out of bounds error on enemies that don't despawn and are affected. See Blue Cultist Archer. + // Extra (extra) Note: Fails in ModifyHitNPC if the enemy has too much health due to velocity clamping if you don't do enough damage. + float kbAmt = player.GetWeaponKnockback(item, item.knockBack) * 9001f * target.knockBackResist; //That obligatory over 9000 reference + if (crit) + kbAmt *= 1.4f; + float kbAmtY = target.noGravity ? kbAmt * -0.5f : kbAmt * -0.75f; + target.velocity.Y += kbAmtY; + target.velocity.X += kbAmt * player.direction; + } } } diff --git a/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMightMelee.cs b/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMightMelee.cs index 0e7c639c42..ac89398f1f 100644 --- a/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMightMelee.cs +++ b/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMightMelee.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class TriactisTruePaladinianMageHammerofMightMelee : ModItem + public class TriactisTruePaladinianMageHammerofMightMelee : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Melee/Trinity.cs b/Items/Weapons/Melee/Trinity.cs index 48a643fd04..cc7c8360d3 100644 --- a/Items/Weapons/Melee/Trinity.cs +++ b/Items/Weapons/Melee/Trinity.cs @@ -35,22 +35,22 @@ 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) { - type = Utils.SelectRandom(Main.rand, new int[] - { - ProjectileID.RubyBolt, - ProjectileID.SapphireBolt, - ProjectileID.AmethystBolt - }); + type = Utils.SelectRandom(Main.rand, new int[] + { + ProjectileID.RubyBolt, + ProjectileID.SapphireBolt, + ProjectileID.AmethystBolt + }); for (int projectiles = 0; projectiles <= 3; projectiles++) { float SpeedX = speedX + (float)Main.rand.Next(-30, 31) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-30, 31) * 0.05f; int proj = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.6), knockBack, Main.myPlayer); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].penetrate = 1; - } + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].penetrate = 1; + } } return false; } diff --git a/Items/Weapons/Melee/TrueArkoftheAncients.cs b/Items/Weapons/Melee/TrueArkoftheAncients.cs index 429953df7d..d6a735e2a7 100644 --- a/Items/Weapons/Melee/TrueArkoftheAncients.cs +++ b/Items/Weapons/Melee/TrueArkoftheAncients.cs @@ -13,7 +13,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Melee { - public class TrueArkoftheAncients : ModItem + public class TrueArkoftheAncients : ModItem { public float Combo = 1f; public float Charge = 0f; diff --git a/Items/Weapons/Melee/TrueBloodyEdge.cs b/Items/Weapons/Melee/TrueBloodyEdge.cs index e782746813..6bfdf46c90 100644 --- a/Items/Weapons/Melee/TrueBloodyEdge.cs +++ b/Items/Weapons/Melee/TrueBloodyEdge.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("True Bloody Edge"); Tooltip.SetDefault("Chance to heal the player on enemy hits\n" + - "Inflicts Burning Blood\n" + + "Inflicts Burning Blood\n" + "Fires a bloody blade"); } @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item1; item.autoReuse = true; item.height = 64; - item.scale = 1.5f; + item.scale = 1.5f; item.value = Item.buyPrice(0, 80, 0, 0); item.rare = ItemRarityID.Yellow; item.shoot = ModContent.ProjectileType(); @@ -54,22 +54,22 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - target.AddBuff(BuffID.Ichor, 60); - target.AddBuff(ModContent.BuffType(), 60); - OnHitEffects(player); + target.AddBuff(BuffID.Ichor, 60); + target.AddBuff(ModContent.BuffType(), 60); + OnHitEffects(player); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - target.AddBuff(BuffID.Ichor, 60); - target.AddBuff(ModContent.BuffType(), 60); - OnHitEffects(player); + target.AddBuff(BuffID.Ichor, 60); + target.AddBuff(ModContent.BuffType(), 60); + OnHitEffects(player); } - private void OnHitEffects(Player player) - { - if (player.moonLeech) - return; + private void OnHitEffects(Player player) + { + if (player.moonLeech) + return; int healAmount = Main.rand.Next(3) + 3; if (Main.rand.NextBool(2)) @@ -77,6 +77,6 @@ namespace CalamityMod.Items.Weapons.Melee player.statLife += healAmount; player.HealEffect(healAmount); } - } + } } } diff --git a/Items/Weapons/Melee/TrueForbiddenOathblade.cs b/Items/Weapons/Melee/TrueForbiddenOathblade.cs index 539ba78ea9..66578e5063 100644 --- a/Items/Weapons/Melee/TrueForbiddenOathblade.cs +++ b/Items/Weapons/Melee/TrueForbiddenOathblade.cs @@ -38,7 +38,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) { - int index = 8; + int index = 8; for (int i = -index; i <= index; i += index) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); @@ -120,7 +120,7 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(ModContent.BuffType(), 450); target.AddBuff(BuffID.OnFire, 900); Main.PlaySound(SoundID.Item14, target.position); - } + } } } } diff --git a/Items/Weapons/Melee/TruePaladinsHammerMelee.cs b/Items/Weapons/Melee/TruePaladinsHammerMelee.cs index e93aca2520..4137554fed 100644 --- a/Items/Weapons/Melee/TruePaladinsHammerMelee.cs +++ b/Items/Weapons/Melee/TruePaladinsHammerMelee.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class TruePaladinsHammerMelee : ModItem + public class TruePaladinsHammerMelee : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Melee/TrueTyrantYharimsUltisword.cs b/Items/Weapons/Melee/TrueTyrantYharimsUltisword.cs index 3360dd1edf..41a82e08b8 100644 --- a/Items/Weapons/Melee/TrueTyrantYharimsUltisword.cs +++ b/Items/Weapons/Melee/TrueTyrantYharimsUltisword.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class TrueTyrantYharimsUltisword : ModItem + public class TrueTyrantYharimsUltisword : ModItem { public override void SetStaticDefaults() { @@ -31,10 +31,10 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item1; item.autoReuse = true; item.height = 102; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; } @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Weapons.Melee break; } int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, Main.myPlayer); - Main.projectile[proj].extraUpdates += 1; + Main.projectile[proj].extraUpdates += 1; return false; } @@ -81,15 +81,15 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { player.AddBuff(ModContent.BuffType(), 300); - target.AddBuff(BuffID.Poisoned, 300); - target.AddBuff(BuffID.Venom, 150); + target.AddBuff(BuffID.Poisoned, 300); + target.AddBuff(BuffID.Venom, 150); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 300); - target.AddBuff(BuffID.Poisoned, 300); - target.AddBuff(BuffID.Venom, 150); + target.AddBuff(BuffID.Poisoned, 300); + target.AddBuff(BuffID.Venom, 150); } } } diff --git a/Items/Weapons/Melee/UltimusCleaver.cs b/Items/Weapons/Melee/UltimusCleaver.cs index dda7bcc398..91467ddb18 100644 --- a/Items/Weapons/Melee/UltimusCleaver.cs +++ b/Items/Weapons/Melee/UltimusCleaver.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class UltimusCleaver : ModItem + public class UltimusCleaver : ModItem { public override void SetStaticDefaults() @@ -19,11 +19,11 @@ namespace CalamityMod.Items.Weapons.Melee { item.damage = 130; item.melee = true; - item.useTurn = true; + item.useTurn = true; item.rare = ItemRarityID.Yellow; item.width = 72; item.height = 62; - item.scale = 1.5f; + item.scale = 1.5f; item.useTime = 20; item.useAnimation = 20; item.useStyle = ItemUseStyleID.SwingThrow; @@ -33,50 +33,50 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item1; } - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.OnFire, 360); - player.ApplyDamageToNPC(target, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), 0f, 0, false); - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (target.rotation - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); - Main.PlaySound(SoundID.Item14, target.position); - int num3; - for (int num53 = 0; num53 < 40; num53 = num3 + 1) - { - int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; - dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; - dust.noGravity = true; - dust.velocity.Y -= 6f; - dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, num51); - dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; - dust.velocity.Y -= 6f; - dust.velocity *= 2f; - dust.noGravity = true; - dust.fadeIn = 1f; - dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; - } - for (int num55 = 0; num55 < 20; num55 = num3 + 1) - { - int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; - dust.position = target.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f; - dust.noGravity = true; - dust.velocity.Y -= 6f; - dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; - } - } + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.OnFire, 360); + player.ApplyDamageToNPC(target, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), 0f, 0, false); + float num50 = 1.7f; + float num51 = 0.8f; + float num52 = 2f; + Vector2 value3 = (target.rotation - 1.57079637f).ToRotationVector2(); + Vector2 value4 = value3 * target.velocity.Length(); + Main.PlaySound(SoundID.Item14, target.position); + int num3; + for (int num53 = 0; num53 < 40; num53 = num3 + 1) + { + int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, num50); + Dust dust = Main.dust[num54]; + dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; + dust.noGravity = true; + dust.velocity.Y -= 6f; + dust.velocity *= 3f; + dust.velocity += value4 * Main.rand.NextFloat(); + num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, num51); + dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; + dust.velocity.Y -= 6f; + dust.velocity *= 2f; + dust.noGravity = true; + dust.fadeIn = 1f; + dust.color = Color.Crimson * 0.5f; + dust.velocity += value4 * Main.rand.NextFloat(); + num3 = num53; + } + for (int num55 = 0; num55 < 20; num55 = num3 + 1) + { + int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, num52); + Dust dust = Main.dust[num56]; + dust.position = target.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f; + dust.noGravity = true; + dust.velocity.Y -= 6f; + dust.velocity *= 0.5f; + dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); + num3 = num55; + } + } - public override void MeleeEffects(Player player, Rectangle hitbox) + public override void MeleeEffects(Player player, Rectangle hitbox) { if (player.whoAmI == Main.myPlayer) { diff --git a/Items/Weapons/Melee/UrchinSpear.cs b/Items/Weapons/Melee/UrchinSpear.cs index dac472febc..b219f343c1 100644 --- a/Items/Weapons/Melee/UrchinSpear.cs +++ b/Items/Weapons/Melee/UrchinSpear.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 4f; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override void AddRecipes() + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 4); diff --git a/Items/Weapons/Melee/Verdant.cs b/Items/Weapons/Melee/Verdant.cs index 4e4835c4f3..8af804a4d3 100644 --- a/Items/Weapons/Melee/Verdant.cs +++ b/Items/Weapons/Melee/Verdant.cs @@ -5,13 +5,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class Verdant : ModItem + public class Verdant : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Verdant"); Tooltip.SetDefault("Fires crystal leaves when enemies are near\n" + - "A very agile yoyo"); + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; @@ -38,10 +38,10 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 16f; item.autoReuse = true; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } public override void AddRecipes() { diff --git a/Items/Weapons/Melee/VirulentKatana.cs b/Items/Weapons/Melee/VirulentKatana.cs index 2c12186e18..47a696d740 100644 --- a/Items/Weapons/Melee/VirulentKatana.cs +++ b/Items/Weapons/Melee/VirulentKatana.cs @@ -7,47 +7,47 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class VirulentKatana : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Virulence"); - Tooltip.SetDefault("Fires a plague cloud"); - } + public class VirulentKatana : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Virulence"); + Tooltip.SetDefault("Fires a plague cloud"); + } - public override void SetDefaults() - { - item.damage = 96; - item.knockBack = 5.5f; - item.useAnimation = item.useTime = 15; - item.melee = true; - item.useTurn = true; - item.autoReuse = true; - item.shootSpeed = 9f; - item.shoot = ModContent.ProjectileType(); + public override void SetDefaults() + { + item.damage = 96; + item.knockBack = 5.5f; + item.useAnimation = item.useTime = 15; + item.melee = true; + item.useTurn = true; + item.autoReuse = true; + item.shootSpeed = 9f; + item.shoot = ModContent.ProjectileType(); - item.width = 48; - item.height = 62; - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.value = Item.buyPrice(0, 80, 0, 0); - item.rare = ItemRarityID.Yellow; - } + item.width = 48; + item.height = 62; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.value = Item.buyPrice(0, 80, 0, 0); + item.rare = ItemRarityID.Yellow; + } - 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, new Vector2(speedX, speedY), type, (int)(damage * 0.85), knockBack, player.whoAmI, 0f, 0f); - return false; - } + 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, new Vector2(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(), 300); - } + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + } - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - } - } + public override void OnHitPvp(Player player, Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + } + } } diff --git a/Items/Weapons/Melee/Whirlpool.cs b/Items/Weapons/Melee/Whirlpool.cs index 147c4e36d2..f4e4b4d8c9 100644 --- a/Items/Weapons/Melee/Whirlpool.cs +++ b/Items/Weapons/Melee/Whirlpool.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Riptide"); Tooltip.SetDefault("Sprays a spiral of aqua streams in random directions\n" + - "A very agile yoyo"); + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Melee/XerocsGreatsword.cs b/Items/Weapons/Melee/XerocsGreatsword.cs index 6a3971658d..9cd5bfb37f 100644 --- a/Items/Weapons/Melee/XerocsGreatsword.cs +++ b/Items/Weapons/Melee/XerocsGreatsword.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Items.Weapons.Melee { float SpeedX = speedX + (float)Main.rand.Next(-20, 21) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-20, 21) * 0.05f; - float damageMult = 0.5f; + float damageMult = 0.5f; switch (index) { case 0: @@ -54,11 +54,11 @@ namespace CalamityMod.Items.Weapons.Melee break; case 1: type = ModContent.ProjectileType(); - damageMult = 0.65f; + damageMult = 0.65f; break; case 2: type = ModContent.ProjectileType(); - damageMult = 0.8f; + damageMult = 0.8f; break; default: break; diff --git a/Items/Weapons/Melee/YateveoBloom.cs b/Items/Weapons/Melee/YateveoBloom.cs index 13e18099e0..ec75ebfabd 100644 --- a/Items/Weapons/Melee/YateveoBloom.cs +++ b/Items/Weapons/Melee/YateveoBloom.cs @@ -45,38 +45,38 @@ namespace CalamityMod.Items.Weapons.Melee item.shoot = ModContent.ProjectileType(); item.shootSpeed = ShootSpeed; - item.Calamity().trueMelee = true; - } + item.Calamity().trueMelee = true; + } public override bool AltFunctionUse(Player player) => true; - public override float UseTimeMultiplier (Player player) - { - if (player.altFunctionUse != 2) - return 1f; - return 0.66f; - } + public override float UseTimeMultiplier (Player player) + { + if (player.altFunctionUse != 2) + return 1f; + return 0.66f; + } public override bool CanUseItem(Player player) { - // Spear + // Spear if (player.altFunctionUse == 2) { item.channel = false; item.autoReuse = true; } - // Flail + // Flail else { item.channel = true; item.autoReuse = false; } - return player.ownedProjectileCounts[item.shoot] + player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + return player.ownedProjectileCounts[item.shoot] + player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; } 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 speedMult = SpearSpeed / ShootSpeed; + float speedMult = SpearSpeed / ShootSpeed; if (player.altFunctionUse == 2) Projectile.NewProjectile(position.X, position.Y, speedX * speedMult, speedY * speedMult, ModContent.ProjectileType(), (int)(damage * 0.666666f), knockBack, player.whoAmI); else diff --git a/Items/Weapons/Melee/YinYo.cs b/Items/Weapons/Melee/YinYo.cs index bff5376919..459ba67961 100644 --- a/Items/Weapons/Melee/YinYo.cs +++ b/Items/Weapons/Melee/YinYo.cs @@ -4,14 +4,14 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class YinYo : ModItem + public class YinYo : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Yin-Yo"); Tooltip.SetDefault("Fires light or dark shards when enemies are near\n" + "Shards fly back and forth\n" + - "A very agile yoyo"); + "A very agile yoyo"); ItemID.Sets.Yoyo[item.type] = true; ItemID.Sets.GamepadExtraRange[item.type] = 15; ItemID.Sets.GamepadSmartQuickReach[item.type] = true; diff --git a/Items/Weapons/Ranged/Alluvion.cs b/Items/Weapons/Ranged/Alluvion.cs index 3f4f4807ea..c301c3f691 100644 --- a/Items/Weapons/Ranged/Alluvion.cs +++ b/Items/Weapons/Ranged/Alluvion.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class Alluvion : ModItem + public class Alluvion : ModItem { public override void SetStaticDefaults() { @@ -37,8 +37,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 12f; item.useAmmo = AmmoID.Arrow; item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { @@ -58,28 +58,28 @@ namespace CalamityMod.Items.Weapons.Ranged if (type == ProjectileID.WoodenArrowFriendly) { - int newType = type; - switch (i) - { - case 0: - case 5: - newType = ModContent.ProjectileType(); - break; - case 1: - case 4: - newType = ModContent.ProjectileType(); - break; - case 2: - case 3: - newType = ModContent.ProjectileType(); - break; - } + int newType = type; + switch (i) + { + case 0: + case 5: + newType = ModContent.ProjectileType(); + break; + case 1: + case 4: + newType = ModContent.ProjectileType(); + break; + case 2: + case 3: + newType = ModContent.ProjectileType(); + break; + } int proj = Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, newType, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].arrow = true; - Main.projectile[proj].extraUpdates += 1; - } + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].arrow = true; + Main.projectile[proj].extraUpdates += 1; + } } else { diff --git a/Items/Weapons/Ranged/AngelicShotgun.cs b/Items/Weapons/Ranged/AngelicShotgun.cs index c7dbbbf0d5..030450980b 100644 --- a/Items/Weapons/Ranged/AngelicShotgun.cs +++ b/Items/Weapons/Ranged/AngelicShotgun.cs @@ -44,8 +44,8 @@ Fighting 'til the war's won"); item.shootSpeed = BulletSpeed; item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { @@ -64,11 +64,11 @@ Fighting 'til the war's won"); float dy = Main.rand.NextFloat(-1.3f, 1.3f); Vector2 randomVelocity = baseVelocity + new Vector2(dx, dy); - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(position, randomVelocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position, randomVelocity, type, damage, knockBack, player.whoAmI); - } + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position, randomVelocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position, randomVelocity, type, damage, knockBack, player.whoAmI); + } // Spawn a beam from the sky ala Deathhail Staff or Lunar Flare float laserSpeed = 8f; diff --git a/Items/Weapons/Ranged/Animosity.cs b/Items/Weapons/Ranged/Animosity.cs index b51b1c2387..2f4c0137ac 100644 --- a/Items/Weapons/Ranged/Animosity.cs +++ b/Items/Weapons/Ranged/Animosity.cs @@ -34,8 +34,8 @@ Right click to fire a burst of bullets"); item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 11f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Ranged/AquashardShotgun.cs b/Items/Weapons/Ranged/AquashardShotgun.cs index 0aaa347433..aa4a6b01b2 100644 --- a/Items/Weapons/Ranged/AquashardShotgun.cs +++ b/Items/Weapons/Ranged/AquashardShotgun.cs @@ -33,12 +33,12 @@ namespace CalamityMod.Items.Weapons.Ranged item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 22f; - item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.useAmmo = AmmoID.Bullet; + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 6; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 6; public override Vector2? HoldoutOffset() => new Vector2(-10, 0); @@ -50,14 +50,14 @@ namespace CalamityMod.Items.Weapons.Ranged float SpeedX = speedX + Main.rand.Next(-40, 41) * 0.05f; float SpeedY = speedY + Main.rand.Next(-40, 41) * 0.05f; - if (type == ProjectileID.Bullet) - { - int projectile = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - Main.projectile[projectile].timeLeft = 200; - } - else - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); - } + if (type == ProjectileID.Bullet) + { + int projectile = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + Main.projectile[projectile].timeLeft = 200; + } + else + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); + } return false; } @@ -65,8 +65,8 @@ namespace CalamityMod.Items.Weapons.Ranged { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.Boomstick); - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddTile(TileID.Anvils); diff --git a/Items/Weapons/Ranged/Arbalest.cs b/Items/Weapons/Ranged/Arbalest.cs index b31ca1afd7..f8175595a5 100644 --- a/Items/Weapons/Ranged/Arbalest.cs +++ b/Items/Weapons/Ranged/Arbalest.cs @@ -7,15 +7,15 @@ namespace CalamityMod.Items.Weapons.Ranged { public class Arbalest : ModItem { - private int totalProjectiles = 1; - private float arrowScale = 0.5f; + private int totalProjectiles = 1; + private float arrowScale = 0.5f; public override void SetStaticDefaults() { DisplayName.SetDefault("Arbalest"); Tooltip.SetDefault("Fires a volley of 10 high-speed arrows\n" + - "Arrows start off small and grow in size with continuous fire\n" + - "Arrow damage, spread and knockback scale with arrow size"); + "Arrows start off small and grow in size with continuous fire\n" + + "Arrow damage, spread and knockback scale with arrow size"); } public override void SetDefaults() @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.width = 82; item.height = 34; item.useTime = 7; - item.reuseDelay = 30; + item.reuseDelay = 30; item.useAnimation = 28; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; @@ -37,42 +37,42 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 12f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Main.PlaySound(SoundID.Item5, (int)player.Center.X, (int)player.Center.Y); + Main.PlaySound(SoundID.Item5, (int)player.Center.X, (int)player.Center.Y); - if (totalProjectiles > 4) - { - totalProjectiles = 1; + if (totalProjectiles > 4) + { + totalProjectiles = 1; - if (arrowScale < 1.5f) - arrowScale += 0.05f; - } + if (arrowScale < 1.5f) + arrowScale += 0.05f; + } - float spreadScale = arrowScale * arrowScale; - int spread = (int)(30f * spreadScale); - for (int i = 0; i < totalProjectiles; i++) - { - float SpeedX = speedX + Main.rand.Next(-spread, spread + 1) * 0.05f; - float SpeedY = speedY + Main.rand.Next(-spread, spread + 1) * 0.05f; - int proj = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * arrowScale), knockBack * arrowScale, player.whoAmI); - Main.projectile[proj].scale = arrowScale; - Main.projectile[proj].extraUpdates += 1; - Main.projectile[proj].noDropItem = true; - } + float spreadScale = arrowScale * arrowScale; + int spread = (int)(30f * spreadScale); + for (int i = 0; i < totalProjectiles; i++) + { + float SpeedX = speedX + Main.rand.Next(-spread, spread + 1) * 0.05f; + float SpeedY = speedY + Main.rand.Next(-spread, spread + 1) * 0.05f; + int proj = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * arrowScale), knockBack * arrowScale, player.whoAmI); + Main.projectile[proj].scale = arrowScale; + Main.projectile[proj].extraUpdates += 1; + Main.projectile[proj].noDropItem = true; + } - totalProjectiles++; + totalProjectiles++; - if (arrowScale >= 1.5f) - arrowScale = 0.5f; + if (arrowScale >= 1.5f) + arrowScale = 0.5f; - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/Archerfish.cs b/Items/Weapons/Ranged/Archerfish.cs index 8b6ec50918..f9bb7b4297 100644 --- a/Items/Weapons/Ranged/Archerfish.cs +++ b/Items/Weapons/Ranged/Archerfish.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 11f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { @@ -42,12 +42,12 @@ 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) { - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/ArterialAssault.cs b/Items/Weapons/Ranged/ArterialAssault.cs index 2540705c3e..f74e50ee45 100644 --- a/Items/Weapons/Ranged/ArterialAssault.cs +++ b/Items/Weapons/Ranged/ArterialAssault.cs @@ -29,10 +29,10 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 4.25f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item102; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item102; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 30f; diff --git a/Items/Weapons/Ranged/AstralBlaster.cs b/Items/Weapons/Ranged/AstralBlaster.cs index 6255a3defb..7d679dc49c 100644 --- a/Items/Weapons/Ranged/AstralBlaster.cs +++ b/Items/Weapons/Ranged/AstralBlaster.cs @@ -33,22 +33,22 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 12f; item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; public override Vector2? HoldoutOffset() => new Vector2(-5, 0); 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 (type == ProjectileID.Bullet) - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/AstralRepeater.cs b/Items/Weapons/Ranged/AstralRepeater.cs index 1ae1daabb4..f77c15bd4f 100644 --- a/Items/Weapons/Ranged/AstralRepeater.cs +++ b/Items/Weapons/Ranged/AstralRepeater.cs @@ -32,11 +32,11 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.WoodenArrowFriendly; item.shootSpeed = 16f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/AstrealDefeat.cs b/Items/Weapons/Ranged/AstrealDefeat.cs index aeed81c8cc..6ffd8c23a4 100644 --- a/Items/Weapons/Ranged/AstrealDefeat.cs +++ b/Items/Weapons/Ranged/AstrealDefeat.cs @@ -36,8 +36,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 4f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { diff --git a/Items/Weapons/Ranged/Auralis.cs b/Items/Weapons/Ranged/Auralis.cs index 90dce58d66..8e3913bc71 100644 --- a/Items/Weapons/Ranged/Auralis.cs +++ b/Items/Weapons/Ranged/Auralis.cs @@ -45,8 +45,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.value = CalamityGlobalItem.Rarity12BuyPrice; item.Calamity().customRarity = CalamityRarity.Turquoise; item.Calamity().donorItem = true; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) { diff --git a/Items/Weapons/Ranged/AuroraBlazer.cs b/Items/Weapons/Ranged/AuroraBlazer.cs index aa1f32c2c2..41d94c7105 100644 --- a/Items/Weapons/Ranged/AuroraBlazer.cs +++ b/Items/Weapons/Ranged/AuroraBlazer.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Aurora Blazer"); Tooltip.SetDefault("Spews astral flames that travel in a star-shaped patterns\n" + - "60% chance to not consume gel"); + "60% chance to not consume gel"); } public override void SetDefaults() @@ -39,15 +39,15 @@ 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) { - float SpeedX = speedX + Main.rand.NextFloat(-15f, 15f) * 0.05f; - float SpeedY = speedY + Main.rand.NextFloat(-15f, 15f) * 0.05f; - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, Main.rand.Next(4, 11), 0f); + float SpeedX = speedX + Main.rand.NextFloat(-15f, 15f) * 0.05f; + float SpeedY = speedY + Main.rand.NextFloat(-15f, 15f) * 0.05f; + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, Main.rand.Next(4, 11), 0f); return false; } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Ranged/AuroraBlazerGlow")); + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Ranged/AuroraBlazerGlow")); } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); diff --git a/Items/Weapons/Ranged/Barinade.cs b/Items/Weapons/Ranged/Barinade.cs index 869e4e609e..859982ecce 100644 --- a/Items/Weapons/Ranged/Barinade.cs +++ b/Items/Weapons/Ranged/Barinade.cs @@ -32,17 +32,17 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 14f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { - if (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.WoodenArrowFriendly) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/Barinautical.cs b/Items/Weapons/Ranged/Barinautical.cs index f31c43fc25..baf2b046dd 100644 --- a/Items/Weapons/Ranged/Barinautical.cs +++ b/Items/Weapons/Ranged/Barinautical.cs @@ -33,17 +33,17 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 15f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { - if (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.WoodenArrowFriendly) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/BladedgeGreatbow.cs b/Items/Weapons/Ranged/BladedgeGreatbow.cs index bb0ec23516..3c3c4ff9ab 100644 --- a/Items/Weapons/Ranged/BladedgeGreatbow.cs +++ b/Items/Weapons/Ranged/BladedgeGreatbow.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 14f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { @@ -66,8 +66,8 @@ namespace CalamityMod.Items.Weapons.Ranged value9 -= vector7; } int projectile = Projectile.NewProjectile(vector2.X + value9.X, vector2.Y + value9.Y, speedX, speedY, ProjectileID.Leaf, damage / 2, 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].Calamity().forceRanged = true; + if (projectile.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile].Calamity().forceRanged = true; } return false; } diff --git a/Items/Weapons/Ranged/BlissfulBombardier.cs b/Items/Weapons/Ranged/BlissfulBombardier.cs index cce61b9cec..e94de44a0a 100644 --- a/Items/Weapons/Ranged/BlissfulBombardier.cs +++ b/Items/Weapons/Ranged/BlissfulBombardier.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Blissful Bombardier"); Tooltip.SetDefault("Fires flare rockets\n" + - "Rockets will destroy tiles with tile-destroying ammo"); + "Rockets will destroy tiles with tile-destroying ammo"); } public override void SetDefaults() @@ -28,8 +28,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.knockBack = 7.5f; item.value = CalamityGlobalItem.Rarity12BuyPrice; item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item11; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item11; item.autoReuse = true; item.shootSpeed = 24f; item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Ranged/BlossomFlux.cs b/Items/Weapons/Ranged/BlossomFlux.cs index 22bdc2550e..5b1e038464 100644 --- a/Items/Weapons/Ranged/BlossomFlux.cs +++ b/Items/Weapons/Ranged/BlossomFlux.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.value = CalamityGlobalItem.Rarity7BuyPrice; item.rare = ItemRarityID.Lime; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override bool AltFunctionUse(Player player) { diff --git a/Items/Weapons/Ranged/BrimstoneFury.cs b/Items/Weapons/Ranged/BrimstoneFury.cs index c4cb43dbc0..161d4b374e 100644 --- a/Items/Weapons/Ranged/BrimstoneFury.cs +++ b/Items/Weapons/Ranged/BrimstoneFury.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 13f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { @@ -44,14 +44,14 @@ namespace CalamityMod.Items.Weapons.Ranged { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - if (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - { - int proj = Projectile.NewProjectile(position, perturbedSpeed, type, damage, knockBack, player.whoAmI); - Main.projectile[proj].noDropItem = true; - } - } + if (type == ProjectileID.WoodenArrowFriendly) + Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + { + int proj = Projectile.NewProjectile(position, perturbedSpeed, type, damage, knockBack, player.whoAmI); + Main.projectile[proj].noDropItem = true; + } + } return false; } diff --git a/Items/Weapons/Ranged/BulletFilledShotgun.cs b/Items/Weapons/Ranged/BulletFilledShotgun.cs index 9ea733ff60..5a830f4168 100644 --- a/Items/Weapons/Ranged/BulletFilledShotgun.cs +++ b/Items/Weapons/Ranged/BulletFilledShotgun.cs @@ -7,13 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class BulletFilledShotgun : ModItem + public class BulletFilledShotgun : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Bullet-Filled Shotgun"); Tooltip.SetDefault("Fires a massive spread of bouncing bullets\n" + - "Consumes five bullets per-use\n" + + "Consumes five bullets per-use\n" + "Aim? What's that?"); } public override void SetDefaults() @@ -35,8 +35,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.value = CalamityGlobalItem.Rarity3BuyPrice; item.rare = ItemRarityID.Orange; item.Calamity().donorItem = true; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-7, 0); @@ -48,7 +48,7 @@ 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) { type = item.shoot; - int bulletAmt = Main.rand.Next(25,35); + int bulletAmt = Main.rand.Next(25,35); for (int i = 0; i < bulletAmt; i++) { float newSpeedX = speedX + Main.rand.NextFloat(-15f, 15f); diff --git a/Items/Weapons/Ranged/Butcher.cs b/Items/Weapons/Ranged/Butcher.cs index e14ca55a35..9605ef6973 100644 --- a/Items/Weapons/Ranged/Butcher.cs +++ b/Items/Weapons/Ranged/Butcher.cs @@ -7,55 +7,55 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class Butcher : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Butcher"); - Tooltip.SetDefault("Fires faster and more accurately the longer you hold the trigger"); - } + public class Butcher : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Butcher"); + Tooltip.SetDefault("Fires faster and more accurately the longer you hold the trigger"); + } - public override void SetDefaults() - { - item.damage = 18; - item.width = 20; - item.height = 12; - item.useTime = 40; - item.useAnimation = 40; - item.useStyle = ItemUseStyleID.HoldingOut; - item.knockBack = 1f; - item.value = CalamityGlobalItem.Rarity4BuyPrice; - item.rare = ItemRarityID.LightRed; - item.UseSound = SoundID.Item38; - item.noMelee = true; - item.noUseGraphic = true; - item.ranged = true; - item.channel = true; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 12f; - item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + public override void SetDefaults() + { + item.damage = 18; + item.width = 20; + item.height = 12; + item.useTime = 40; + item.useAnimation = 40; + item.useStyle = ItemUseStyleID.HoldingOut; + item.knockBack = 1f; + item.value = CalamityGlobalItem.Rarity4BuyPrice; + item.rare = ItemRarityID.LightRed; + item.UseSound = SoundID.Item38; + item.noMelee = true; + item.noUseGraphic = true; + item.ranged = true; + item.channel = true; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 12f; + item.useAmmo = AmmoID.Bullet; + item.Calamity().canFirePointBlankShots = true; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - return false; - } + 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.Shotgun); - recipe.AddIngredient(ItemID.IllegalGunParts); - recipe.AddRecipeGroup("AnyCobaltBar", 5); + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.Shotgun); + recipe.AddIngredient(ItemID.IllegalGunParts); + recipe.AddRecipeGroup("AnyCobaltBar", 5); recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/ChargedDartRifle.cs b/Items/Weapons/Ranged/ChargedDartRifle.cs index 003b8c2857..df66c54b21 100644 --- a/Items/Weapons/Ranged/ChargedDartRifle.cs +++ b/Items/Weapons/Ranged/ChargedDartRifle.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Charged Dart Blaster"); Tooltip.SetDefault("Fires a shotgun spread of darts and a splitting energy blast\n" + - "Right click to fire a more powerful exploding energy blast that bounces"); + "Right click to fire a more powerful exploding energy blast that bounces"); } public override void SetDefaults() @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 22f; item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Dart; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { @@ -56,13 +56,13 @@ namespace CalamityMod.Items.Weapons.Ranged } else { - int num6 = Main.rand.Next(2, 5); - for (int index = 0; index < num6; ++index) - { - float SpeedX = speedX + (float)Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = speedY + (float)Main.rand.Next(-40, 41) * 0.05f; - int projectile = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage / 2, knockBack, player.whoAmI, 0f, 0f); - } + int num6 = Main.rand.Next(2, 5); + for (int index = 0; index < num6; ++index) + { + float SpeedX = speedX + (float)Main.rand.Next(-40, 41) * 0.05f; + float SpeedY = speedY + (float)Main.rand.Next(-40, 41) * 0.05f; + int projectile = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage / 2, knockBack, player.whoAmI, 0f, 0f); + } Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); return false; } diff --git a/Items/Weapons/Ranged/ChickenCannon.cs b/Items/Weapons/Ranged/ChickenCannon.cs index 19fe2d0b8f..9f57cedd25 100644 --- a/Items/Weapons/Ranged/ChickenCannon.cs +++ b/Items/Weapons/Ranged/ChickenCannon.cs @@ -33,14 +33,14 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 14.5f; item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Rocket; - item.channel = true; + item.channel = true; } public override void HoldItem(Player player) - { - item.channel = player.altFunctionUse != 2; + { + item.channel = player.altFunctionUse != 2; item.noUseGraphic = player.altFunctionUse != 2; - } + } public override Vector2? HoldoutOffset() => new Vector2(-20, 0); @@ -61,7 +61,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), 0, 0f, player.whoAmI, 1); + Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), 0, 0f, player.whoAmI, 1); // Otherwise just play a grenade launcher sound and fire a rocket. //Main.PlaySound(SoundID.Item61, position); //Projectile.NewProjectile(position, new Vector2(speedX, speedY), item.shoot, damage, knockBack, player.whoAmI); diff --git a/Items/Weapons/Ranged/ClamorRifle.cs b/Items/Weapons/Ranged/ClamorRifle.cs index ff6720a85e..2d9bde56c1 100644 --- a/Items/Weapons/Ranged/ClamorRifle.cs +++ b/Items/Weapons/Ranged/ClamorRifle.cs @@ -6,45 +6,45 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class ClamorRifle : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Clamor Rifle"); - Tooltip.SetDefault("Converts musket balls into homing energy bolts"); - } + public class ClamorRifle : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Clamor Rifle"); + Tooltip.SetDefault("Converts musket balls into homing energy bolts"); + } - public override void SetDefaults() - { - item.damage = 23; - item.ranged = true; - item.width = 64; - item.height = 30; - item.useTime = 15; - item.useAnimation = 15; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 2.5f; - item.value = Item.buyPrice(0, 36, 0, 0); - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBolt"); - item.autoReuse = true; - item.rare = ItemRarityID.Pink; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 15f; - item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + public override void SetDefaults() + { + item.damage = 23; + item.ranged = true; + item.width = 64; + item.height = 30; + item.useTime = 15; + item.useAnimation = 15; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 2.5f; + item.value = Item.buyPrice(0, 36, 0, 0); + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBolt"); + item.autoReuse = true; + item.rare = ItemRarityID.Pink; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 15f; + item.useAmmo = AmmoID.Bullet; + item.Calamity().canFirePointBlankShots = true; + } - public override Vector2? HoldoutOffset() => new Vector2(-5, 0); + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); - 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 (type == ProjectileID.Bullet) - Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + 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 (type == ProjectileID.Bullet) + Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - return false; - } - } + return false; + } + } } diff --git a/Items/Weapons/Ranged/ClaretCannon.cs b/Items/Weapons/Ranged/ClaretCannon.cs index 4e436716c7..25c03cf826 100644 --- a/Items/Weapons/Ranged/ClaretCannon.cs +++ b/Items/Weapons/Ranged/ClaretCannon.cs @@ -28,16 +28,16 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 5.5f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item40; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item40; item.autoReuse = true; item.shootSpeed = 24f; item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); @@ -52,12 +52,12 @@ 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) { - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/ClockGatlignum.cs b/Items/Weapons/Ranged/ClockGatlignum.cs index 99d9dabe11..ca7cf124a4 100644 --- a/Items/Weapons/Ranged/ClockGatlignum.cs +++ b/Items/Weapons/Ranged/ClockGatlignum.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 20f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); @@ -44,12 +44,12 @@ namespace CalamityMod.Items.Weapons.Ranged float SpeedX = speedX + Main.rand.Next(-15, 16) * 0.05f; float SpeedY = speedY + Main.rand.Next(-15, 16) * 0.05f; - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ProjectileID.BulletHighVelocity, damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ProjectileID.BulletHighVelocity, damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } public override bool ConsumeAmmo(Player player) diff --git a/Items/Weapons/Ranged/CoralCannon.cs b/Items/Weapons/Ranged/CoralCannon.cs index 7c52f826c1..9b29516543 100644 --- a/Items/Weapons/Ranged/CoralCannon.cs +++ b/Items/Weapons/Ranged/CoralCannon.cs @@ -31,11 +31,11 @@ namespace CalamityMod.Items.Weapons.Ranged item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; public override Vector2? HoldoutOffset() => new Vector2(-10, 0); diff --git a/Items/Weapons/Ranged/CorrodedCaustibow.cs b/Items/Weapons/Ranged/CorrodedCaustibow.cs index 1b20ab0e1c..cd7d1ec356 100644 --- a/Items/Weapons/Ranged/CorrodedCaustibow.cs +++ b/Items/Weapons/Ranged/CorrodedCaustibow.cs @@ -33,20 +33,20 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 5f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; 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 (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.WoodenArrowFriendly) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/CosmicBolter.cs b/Items/Weapons/Ranged/CosmicBolter.cs index cd239d280f..aa6d48c325 100644 --- a/Items/Weapons/Ranged/CosmicBolter.cs +++ b/Items/Weapons/Ranged/CosmicBolter.cs @@ -7,13 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class CosmicBolter : ModItem + public class CosmicBolter : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Cosmic Bolter"); Tooltip.SetDefault("Fires three arrows at once\n" + - "Converts wooden arrows into sliding energy bolts"); + "Converts wooden arrows into sliding energy bolts"); } public override void SetDefaults() @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { @@ -53,14 +53,14 @@ namespace CalamityMod.Items.Weapons.Ranged if (!canHit) offset -= velocity; - if (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - { - int proj = Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[proj].noDropItem = true; - } - } + if (type == ProjectileID.WoodenArrowFriendly) + Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + { + int proj = Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + Main.projectile[proj].noDropItem = true; + } + } return false; } diff --git a/Items/Weapons/Ranged/CursedCapper.cs b/Items/Weapons/Ranged/CursedCapper.cs index 19e3af16c1..84e64132a4 100644 --- a/Items/Weapons/Ranged/CursedCapper.cs +++ b/Items/Weapons/Ranged/CursedCapper.cs @@ -31,8 +31,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 14f; item.shoot = ProjectileID.CursedBullet; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { diff --git a/Items/Weapons/Ranged/DaemonsFlame.cs b/Items/Weapons/Ranged/DaemonsFlame.cs index b6d40846c7..cfea8adc69 100644 --- a/Items/Weapons/Ranged/DaemonsFlame.cs +++ b/Items/Weapons/Ranged/DaemonsFlame.cs @@ -36,8 +36,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.value = CalamityGlobalItem.Rarity13BuyPrice; item.Calamity().customRarity = CalamityRarity.PureGreen; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; diff --git a/Items/Weapons/Ranged/DarkechoGreatbow.cs b/Items/Weapons/Ranged/DarkechoGreatbow.cs index 6221cf189a..9e3c7ce1c9 100644 --- a/Items/Weapons/Ranged/DarkechoGreatbow.cs +++ b/Items/Weapons/Ranged/DarkechoGreatbow.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 12f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { diff --git a/Items/Weapons/Ranged/Deathwind.cs b/Items/Weapons/Ranged/Deathwind.cs index 1134e3999e..b3239f7dc7 100644 --- a/Items/Weapons/Ranged/Deathwind.cs +++ b/Items/Weapons/Ranged/Deathwind.cs @@ -27,20 +27,20 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 5f; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.UseSound = SoundID.Item5; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.UseSound = SoundID.Item5; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 20f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Ranged/DeathwindGlow")); + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Ranged/DeathwindGlow")); } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) diff --git a/Items/Weapons/Ranged/DodusHandcannon.cs b/Items/Weapons/Ranged/DodusHandcannon.cs index bfd6545b47..c8f9cbed03 100644 --- a/Items/Weapons/Ranged/DodusHandcannon.cs +++ b/Items/Weapons/Ranged/DodusHandcannon.cs @@ -40,8 +40,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.value = CalamityGlobalItem.Rarity13BuyPrice; item.Calamity().customRarity = CalamityRarity.PureGreen; item.Calamity().donorItem = true; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { diff --git a/Items/Weapons/Ranged/DragonsBreath.cs b/Items/Weapons/Ranged/DragonsBreath.cs index 0b1d3006b5..5fc7c0519c 100644 --- a/Items/Weapons/Ranged/DragonsBreath.cs +++ b/Items/Weapons/Ranged/DragonsBreath.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? FullAutoFireRateMult : 1f; - public override bool Shoot(Player player, ref 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) { Main.PlaySound(SoundID.Item38, position); bool doDust = false; diff --git a/Items/Weapons/Ranged/Dualpoon.cs b/Items/Weapons/Ranged/Dualpoon.cs index d921ba3cbe..db956b26ce 100644 --- a/Items/Weapons/Ranged/Dualpoon.cs +++ b/Items/Weapons/Ranged/Dualpoon.cs @@ -32,35 +32,35 @@ namespace CalamityMod.Items.Weapons.Ranged item.autoReuse = true; item.shootSpeed = 20f; item.shoot = ModContent.ProjectileType(); - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { return new Vector2(-5, 0); } - 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 source = player.RotatedRelativePoint(player.MountedCenter, true); - float piOverTen = MathHelper.Pi * 0.1f; - int projCount = 2; - Vector2 velocity = new Vector2(speedX, speedY); - velocity.Normalize(); - velocity *= 40f; - bool canHit = Collision.CanHit(source, 0, 0, source + velocity, 0, 0); - for (int projIndex = 0; projIndex < projCount; projIndex++) - { - float num120 = projIndex - (projCount - 1f) / 2f; - Vector2 offset = velocity.RotatedBy((double)(piOverTen * num120), default); - if (!canHit) - { - offset -= velocity; - } - Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - } - return false; - } + 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 source = player.RotatedRelativePoint(player.MountedCenter, true); + float piOverTen = MathHelper.Pi * 0.1f; + int projCount = 2; + Vector2 velocity = new Vector2(speedX, speedY); + velocity.Normalize(); + velocity *= 40f; + bool canHit = Collision.CanHit(source, 0, 0, source + velocity, 0, 0); + for (int projIndex = 0; projIndex < projCount; projIndex++) + { + float num120 = projIndex - (projCount - 1f) / 2f; + Vector2 offset = velocity.RotatedBy((double)(piOverTen * num120), default); + if (!canHit) + { + offset -= velocity; + } + Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + } + return false; + } public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/EffluviumBow.cs b/Items/Weapons/Ranged/EffluviumBow.cs index 45eeade8dc..c43d39581b 100644 --- a/Items/Weapons/Ranged/EffluviumBow.cs +++ b/Items/Weapons/Ranged/EffluviumBow.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Effluvium Bow"); Tooltip.SetDefault("Fires two arrows at once\n" + - "Converts wooden arrows into mist arrows"); + "Converts wooden arrows into mist arrows"); } public override void SetDefaults() @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { @@ -43,14 +43,14 @@ namespace CalamityMod.Items.Weapons.Ranged float SpeedX = speedX + Main.rand.Next(-30, 31) * 0.05f; float SpeedY = speedY + Main.rand.Next(-30, 31) * 0.05f; - if (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - { - int proj = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); - Main.projectile[proj].noDropItem = true; - } - } + if (type == ProjectileID.WoodenArrowFriendly) + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + { + int proj = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); + Main.projectile[proj].noDropItem = true; + } + } return false; } } diff --git a/Items/Weapons/Ranged/EternalBlizzard.cs b/Items/Weapons/Ranged/EternalBlizzard.cs index 55791beb74..f8f6608d70 100644 --- a/Items/Weapons/Ranged/EternalBlizzard.cs +++ b/Items/Weapons/Ranged/EternalBlizzard.cs @@ -32,15 +32,15 @@ namespace CalamityMod.Items.Weapons.Ranged item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 11f; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { - float SpeedX = speedX + (float)Main.rand.Next(-10, 11) * 0.05f; - float SpeedY = speedY + (float)Main.rand.Next(-10, 11) * 0.05f; - int index = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * 0.7f), knockBack, player.whoAmI); - Main.projectile[index].noDropItem = true; + float SpeedX = speedX + (float)Main.rand.Next(-10, 11) * 0.05f; + float SpeedY = speedY + (float)Main.rand.Next(-10, 11) * 0.05f; + int index = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * 0.7f), knockBack, player.whoAmI); + Main.projectile[index].noDropItem = true; return true; } diff --git a/Items/Weapons/Ranged/Eviscerator.cs b/Items/Weapons/Ranged/Eviscerator.cs index ccfc2e8e32..8f0bafdeca 100644 --- a/Items/Weapons/Ranged/Eviscerator.cs +++ b/Items/Weapons/Ranged/Eviscerator.cs @@ -33,22 +33,22 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 22f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; public override Vector2? HoldoutOffset() => new Vector2(-7, 0); 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 (type == ProjectileID.Bullet) - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/FetidEmesis.cs b/Items/Weapons/Ranged/FetidEmesis.cs index acdd07c794..17152af4d3 100644 --- a/Items/Weapons/Ranged/FetidEmesis.cs +++ b/Items/Weapons/Ranged/FetidEmesis.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Fetid Emesis"); Tooltip.SetDefault("40% chance to not consume ammo\n" + - "Has a chance to release rotten chunks instead of bullets"); + "Has a chance to release rotten chunks instead of bullets"); } public override void SetDefaults() @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.value = CalamityGlobalItem.Rarity13BuyPrice; item.Calamity().customRarity = CalamityRarity.PureGreen; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) > 40; diff --git a/Items/Weapons/Ranged/FirestormCannon.cs b/Items/Weapons/Ranged/FirestormCannon.cs index 4acca964fc..64356fd6e5 100644 --- a/Items/Weapons/Ranged/FirestormCannon.cs +++ b/Items/Weapons/Ranged/FirestormCannon.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.Flare; item.shootSpeed = 5.5f; item.useAmmo = AmmoID.Flare; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); @@ -42,12 +42,12 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool AltFunctionUse(Player player) => true; - public override float UseTimeMultiplier (Player player) - { - if (player.altFunctionUse == 2) - return 0.3333f; - return 1f; - } + public override float UseTimeMultiplier (Player player) + { + if (player.altFunctionUse == 2) + return 0.3333f; + return 1f; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -59,12 +59,12 @@ namespace CalamityMod.Items.Weapons.Ranged float SpeedX = speedX + (float)Main.rand.Next(-50, 51) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-50, 51) * 0.05f; int flare = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)((double)damage * 1.4), knockBack, player.whoAmI); - if (flare.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[flare].penetrate = 1; - Main.projectile[flare].timeLeft = 600; - Main.projectile[flare].Calamity().forceRanged = true; - } + if (flare.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flare].penetrate = 1; + Main.projectile[flare].timeLeft = 600; + Main.projectile[flare].Calamity().forceRanged = true; + } } return false; } @@ -76,12 +76,12 @@ namespace CalamityMod.Items.Weapons.Ranged float SpeedX = speedX + (float)Main.rand.Next(-40, 41) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-40, 41) * 0.05f; int flare = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); - if (flare.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[flare].Calamity().forceRanged = true; - Main.projectile[flare].timeLeft = 200; - Main.projectile[flare].penetrate = 3; - } + if (flare.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flare].Calamity().forceRanged = true; + Main.projectile[flare].timeLeft = 200; + Main.projectile[flare].penetrate = 3; + } } return false; } diff --git a/Items/Weapons/Ranged/FlarewingBow.cs b/Items/Weapons/Ranged/FlarewingBow.cs index 42469537a9..b25c06b9cb 100644 --- a/Items/Weapons/Ranged/FlarewingBow.cs +++ b/Items/Weapons/Ranged/FlarewingBow.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.WoodenArrowFriendly; item.shootSpeed = 16f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { diff --git a/Items/Weapons/Ranged/FlurrystormCannon.cs b/Items/Weapons/Ranged/FlurrystormCannon.cs index 87c51210bc..8855cf8230 100644 --- a/Items/Weapons/Ranged/FlurrystormCannon.cs +++ b/Items/Weapons/Ranged/FlurrystormCannon.cs @@ -40,8 +40,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Snowball; item.shootSpeed = 18f; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; diff --git a/Items/Weapons/Ranged/FrostbiteBlaster.cs b/Items/Weapons/Ranged/FrostbiteBlaster.cs index e38efa1bd7..efebf4605a 100644 --- a/Items/Weapons/Ranged/FrostbiteBlaster.cs +++ b/Items/Weapons/Ranged/FrostbiteBlaster.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Frostbite Blaster"); Tooltip.SetDefault("Fires a spread of 6 bullets\n" + - "Converts musket balls into icicles"); + "Converts musket balls into icicles"); } public override void SetDefaults() @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.autoReuse = true; item.shoot = ProjectileID.Blizzard; item.shootSpeed = 9f; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { @@ -45,15 +45,15 @@ namespace CalamityMod.Items.Weapons.Ranged float newSpeedX = speedX + Main.rand.Next(-40, 41) * 0.06f; float newSpeedY = speedY + Main.rand.Next(-40, 41) * 0.06f; - if (type == ProjectileID.Bullet) - { - int p = Projectile.NewProjectile(position.X, position.Y, newSpeedX, newSpeedY, ProjectileID.Blizzard, damage, knockBack, player.whoAmI); - Main.projectile[p].magic = false; - Main.projectile[p].ranged = true; - } - else - Projectile.NewProjectile(position.X, position.Y, newSpeedX, newSpeedY, type, damage, knockBack, player.whoAmI); - } + if (type == ProjectileID.Bullet) + { + int p = Projectile.NewProjectile(position.X, position.Y, newSpeedX, newSpeedY, ProjectileID.Blizzard, damage, knockBack, player.whoAmI); + Main.projectile[p].magic = false; + Main.projectile[p].ranged = true; + } + else + Projectile.NewProjectile(position.X, position.Y, newSpeedX, newSpeedY, type, damage, knockBack, player.whoAmI); + } return false; } } diff --git a/Items/Weapons/Ranged/Fungicide.cs b/Items/Weapons/Ranged/Fungicide.cs index 7b135c185f..eedb13dc08 100644 --- a/Items/Weapons/Ranged/Fungicide.cs +++ b/Items/Weapons/Ranged/Fungicide.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 14f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { @@ -42,12 +42,12 @@ 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) { - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/Galeforce.cs b/Items/Weapons/Ranged/Galeforce.cs index c91ba8a8ea..d6ff788e0f 100644 --- a/Items/Weapons/Ranged/Galeforce.cs +++ b/Items/Weapons/Ranged/Galeforce.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.WoodenArrowFriendly; item.shootSpeed = 20f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { diff --git a/Items/Weapons/Ranged/GoldenEagle.cs b/Items/Weapons/Ranged/GoldenEagle.cs index ce1c8d6cd5..be25b628af 100644 --- a/Items/Weapons/Ranged/GoldenEagle.cs +++ b/Items/Weapons/Ranged/GoldenEagle.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Items.Weapons.Ranged { public class GoldenEagle : ModItem { - private const float Spread = 0.0425f; + private const float Spread = 0.0425f; public override void SetStaticDefaults() { @@ -33,23 +33,23 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.Bullet; item.shootSpeed = 20f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); 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); + Vector2 velocity = new Vector2(speedX, speedY); - // Fire extra bullets to the left and right - for (int i = 0; i < 2; i++) - { - Projectile.NewProjectile(position, velocity.RotatedBy(-Spread * (i + 1)), type, damage, knockBack, player.whoAmI); - Projectile.NewProjectile(position, velocity.RotatedBy(+Spread * (i + 1)), type, damage, knockBack, player.whoAmI); - } + // Fire extra bullets to the left and right + for (int i = 0; i < 2; i++) + { + Projectile.NewProjectile(position, velocity.RotatedBy(-Spread * (i + 1)), type, damage, knockBack, player.whoAmI); + Projectile.NewProjectile(position, velocity.RotatedBy(+Spread * (i + 1)), type, damage, knockBack, player.whoAmI); + } - return true; - } + return true; + } } } diff --git a/Items/Weapons/Ranged/Goobow.cs b/Items/Weapons/Ranged/Goobow.cs index da1b21c01d..5bcb0ed366 100644 --- a/Items/Weapons/Ranged/Goobow.cs +++ b/Items/Weapons/Ranged/Goobow.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.WoodenArrowFriendly; item.shootSpeed = 12f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { @@ -54,12 +54,12 @@ namespace CalamityMod.Items.Weapons.Ranged offset -= velocity; } int index = Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY) * 0.6f, ProjectileID.SlimeGun, damage / 4, 0f, player.whoAmI); - if (index.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[index].Calamity().forceRanged = true; - Main.projectile[index].usesLocalNPCImmunity = true; - Main.projectile[index].localNPCHitCooldown = 10; - } + if (index.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[index].Calamity().forceRanged = true; + Main.projectile[index].usesLocalNPCImmunity = true; + Main.projectile[index].localNPCHitCooldown = 10; + } } return true; } diff --git a/Items/Weapons/Ranged/GreatbowofTurmoil.cs b/Items/Weapons/Ranged/GreatbowofTurmoil.cs index 43fea7ed39..0135828382 100644 --- a/Items/Weapons/Ranged/GreatbowofTurmoil.cs +++ b/Items/Weapons/Ranged/GreatbowofTurmoil.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Continental Greatbow"); Tooltip.SetDefault("Wooden arrows are set alight with fire\n" + - "Fires 3 arrows at once\n" + + "Fires 3 arrows at once\n" + "Fires 2 additional cursed, hellfire, or ichor arrows"); } @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.WoodenArrowFriendly; item.shootSpeed = 17f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { @@ -54,10 +54,10 @@ namespace CalamityMod.Items.Weapons.Ranged { offset -= velocity; } - if (type == ProjectileID.WoodenArrowFriendly) - { - type = ProjectileID.FireArrow; - } + if (type == ProjectileID.WoodenArrowFriendly) + { + type = ProjectileID.FireArrow; + } int num121 = Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); Main.projectile[num121].noDropItem = true; } @@ -65,12 +65,12 @@ namespace CalamityMod.Items.Weapons.Ranged { float SpeedX = speedX + (float)Main.rand.Next(-10, 11) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-10, 11) * 0.05f; - type = Utils.SelectRandom(Main.rand, new int[] - { - ProjectileID.CursedArrow, - ProjectileID.HellfireArrow, - ProjectileID.IchorArrow - }); + type = Utils.SelectRandom(Main.rand, new int[] + { + ProjectileID.CursedArrow, + ProjectileID.HellfireArrow, + ProjectileID.IchorArrow + }); int index = Projectile.NewProjectile(position, new Vector2(SpeedX, SpeedY), type, (int)(damage * 0.5f), knockBack, player.whoAmI); Main.projectile[index].noDropItem = true; Main.projectile[index].usesLocalNPCImmunity = true; diff --git a/Items/Weapons/Ranged/GunkShot.cs b/Items/Weapons/Ranged/GunkShot.cs index 37489dd7dd..db3d417ea7 100644 --- a/Items/Weapons/Ranged/GunkShot.cs +++ b/Items/Weapons/Ranged/GunkShot.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 5f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Ranged/HalibutCannon.cs b/Items/Weapons/Ranged/HalibutCannon.cs index ec0d89ae76..755a102e17 100644 --- a/Items/Weapons/Ranged/HalibutCannon.cs +++ b/Items/Weapons/Ranged/HalibutCannon.cs @@ -31,16 +31,16 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.Bullet; item.shootSpeed = 12f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-15, 0); public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Main.PlaySound(SoundID.Item38, (int)player.Center.X, (int)player.Center.Y); + Main.PlaySound(SoundID.Item38, (int)player.Center.X, (int)player.Center.Y); - int bulletAmt = Main.rand.Next(25, 36); + int bulletAmt = Main.rand.Next(25, 36); for (int index = 0; index < bulletAmt; ++index) { float SpeedX = speedX + Main.rand.Next(-10, 11) * 0.05f; diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index bfefc41eef..588f7ca2b1 100644 --- a/Items/Weapons/Ranged/HalleysInferno.cs +++ b/Items/Weapons/Ranged/HalleysInferno.cs @@ -8,55 +8,55 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class HalleysInferno : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Halley's Inferno"); - Tooltip.SetDefault("Halley came sooner than expected\n" + - "Fires a flaming comet\n" + - "50% chance to not consume gel\n" + - "Right click to zoom out"); - } + public class HalleysInferno : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Halley's Inferno"); + Tooltip.SetDefault("Halley came sooner than expected\n" + + "Fires a flaming comet\n" + + "50% chance to not consume gel\n" + + "Right click to zoom out"); + } - public override void SetDefaults() - { - item.damage = 1350; - item.knockBack = 5f; - item.ranged = true; - item.useTime = item.useAnimation = 30; - item.autoReuse = true; - item.useAmmo = AmmoID.Gel; - item.shootSpeed = 14.6f; - item.shoot = ModContent.ProjectileType(); + public override void SetDefaults() + { + item.damage = 1350; + item.knockBack = 5f; + item.ranged = true; + item.useTime = item.useAnimation = 30; + item.autoReuse = true; + item.useAmmo = AmmoID.Gel; + item.shootSpeed = 14.6f; + item.shoot = ModContent.ProjectileType(); - item.width = 84; - item.height = 34; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.UseSound = SoundID.Item34; - item.value = Item.buyPrice(1, 40, 0, 0); - item.rare = ItemRarityID.Red; - item.Calamity().customRarity = CalamityRarity.PureGreen; - } + item.width = 84; + item.height = 34; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.UseSound = SoundID.Item34; + item.value = Item.buyPrice(1, 40, 0, 0); + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.PureGreen; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; - public override Vector2? HoldoutOffset() => new Vector2(-15, 0); + public override Vector2? HoldoutOffset() => new Vector2(-15, 0); - public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 50; + public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 50; - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.SniperScope); - recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.SniperScope); + recipe.AddIngredient(ModContent.ItemType(), 6); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/HeavenlyGale.cs b/Items/Weapons/Ranged/HeavenlyGale.cs index 180360e186..1b5fce7058 100644 --- a/Items/Weapons/Ranged/HeavenlyGale.cs +++ b/Items/Weapons/Ranged/HeavenlyGale.cs @@ -9,111 +9,111 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Ranged { - public class HeavenlyGale : ModItem - { - public const float NormalArrowDamageMult = 1.25f; - private static int[] ExoArrows; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Heavenly Gale"); - Tooltip.SetDefault("Converts wooden arrows into barrages of 5 random exo arrows\n" + - "Green exo arrows erupt into swirling tornadoes\n" + - "Blue exo arrows burst into barrages of following arrows\n" + - "Orange exo arrows explode into flames\n" + - "Teal exo arrows pierce infinitely and ignore immunity frames\n" + - $"Any non-wooden arrows used will deal {NormalArrowDamageMult}x damage\n" + - "66% chance to not consume ammo"); + public class HeavenlyGale : ModItem + { + public const float NormalArrowDamageMult = 1.25f; + private static int[] ExoArrows; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Heavenly Gale"); + Tooltip.SetDefault("Converts wooden arrows into barrages of 5 random exo arrows\n" + + "Green exo arrows erupt into swirling tornadoes\n" + + "Blue exo arrows burst into barrages of following arrows\n" + + "Orange exo arrows explode into flames\n" + + "Teal exo arrows pierce infinitely and ignore immunity frames\n" + + $"Any non-wooden arrows used will deal {NormalArrowDamageMult}x damage\n" + + "66% chance to not consume ammo"); - ExoArrows = new int[] - { - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType() - }; - } + ExoArrows = new int[] + { + ProjectileType(), + ProjectileType(), + ProjectileType(), + ProjectileType() + }; + } - public override void SetDefaults() - { - item.damage = 198; - item.ranged = true; - item.width = 44; - item.height = 58; - item.useTime = 15; - item.useAnimation = 30; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 4f; - item.UseSound = SoundID.Item5; - item.autoReuse = true; - item.shoot = ProjectileID.WoodenArrowFriendly; - item.shootSpeed = 12f; - item.useAmmo = AmmoID.Arrow; - item.Calamity().customRarity = CalamityRarity.Violet; - item.value = CalamityGlobalItem.RarityVioletBuyPrice; - item.Calamity().canFirePointBlankShots = true; - } + public override void SetDefaults() + { + item.damage = 198; + item.ranged = true; + item.width = 44; + item.height = 58; + item.useTime = 15; + item.useAnimation = 30; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 4f; + item.UseSound = SoundID.Item5; + item.autoReuse = true; + item.shoot = ProjectileID.WoodenArrowFriendly; + item.shootSpeed = 12f; + item.useAmmo = AmmoID.Arrow; + item.Calamity().customRarity = CalamityRarity.Violet; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.Calamity().canFirePointBlankShots = 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) - { - Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 vel = new Vector2(speedX, speedY); - float piOver10 = MathHelper.Pi * 0.1f; + 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 source = player.RotatedRelativePoint(player.MountedCenter, true); + Vector2 vel = new Vector2(speedX, speedY); + float piOver10 = MathHelper.Pi * 0.1f; - // This is not related to speed, but rather placing the arrows correctly along the large bow. - Vector2 baseOffset = new Vector2(speedX, speedY); - baseOffset.Normalize(); - baseOffset *= 40f; + // This is not related to speed, but rather placing the arrows correctly along the large bow. + Vector2 baseOffset = new Vector2(speedX, speedY); + baseOffset.Normalize(); + baseOffset *= 40f; - bool againstWall = !Collision.CanHit(source, 0, 0, source + baseOffset, 0, 0); + bool againstWall = !Collision.CanHit(source, 0, 0, source + baseOffset, 0, 0); - int numArrows = 5; - for (int i = 0; i < numArrows; i++) - { - float offsetAmt = i - (numArrows - 1f) / 2f; - Vector2 offset = baseOffset.RotatedBy(piOver10 * offsetAmt); - if (againstWall) - offset -= baseOffset; + int numArrows = 5; + for (int i = 0; i < numArrows; i++) + { + float offsetAmt = i - (numArrows - 1f) / 2f; + Vector2 offset = baseOffset.RotatedBy(piOver10 * offsetAmt); + if (againstWall) + offset -= baseOffset; - if (type == ProjectileID.WoodenArrowFriendly) - { - int thisArrowType = Main.rand.Next(ExoArrows); - // Teal exo arrows deal less damage. - float dmgMult = thisArrowType == ProjectileType() ? 0.66f : 1f; - int finalDamage = (int)(damage * dmgMult); - Projectile.NewProjectile(source + offset, vel, thisArrowType, finalDamage, knockBack, player.whoAmI); - } - else - { - int normalArrowDamage = (int)(damage * NormalArrowDamageMult); - int proj = Projectile.NewProjectile(source + offset, vel, type, normalArrowDamage, knockBack, player.whoAmI); - Main.projectile[proj].noDropItem = true; - } - } - return false; - } + if (type == ProjectileID.WoodenArrowFriendly) + { + int thisArrowType = Main.rand.Next(ExoArrows); + // Teal exo arrows deal less damage. + float dmgMult = thisArrowType == ProjectileType() ? 0.66f : 1f; + int finalDamage = (int)(damage * dmgMult); + Projectile.NewProjectile(source + offset, vel, thisArrowType, finalDamage, knockBack, player.whoAmI); + } + else + { + int normalArrowDamage = (int)(damage * NormalArrowDamageMult); + int proj = Projectile.NewProjectile(source + offset, vel, type, normalArrowDamage, knockBack, player.whoAmI); + Main.projectile[proj].noDropItem = true; + } + } + return false; + } - public override bool ConsumeAmmo(Player player) - { - if (Main.rand.Next(0, 100) < 66) - return false; - return true; - } + public override bool ConsumeAmmo(Player player) + { + if (Main.rand.Next(0, 100) < 66) + return false; + return true; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemType()); - recipe.AddIngredient(ItemType()); - recipe.AddIngredient(ItemType()); - recipe.AddIngredient(ItemType()); - recipe.AddIngredient(ItemType()); - recipe.AddIngredient(ItemType()); - recipe.AddIngredient(ItemType()); - recipe.AddTile(TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddTile(TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/Hellborn.cs b/Items/Weapons/Ranged/Hellborn.cs index 551649502f..3149745025 100644 --- a/Items/Weapons/Ranged/Hellborn.cs +++ b/Items/Weapons/Ranged/Hellborn.cs @@ -11,10 +11,10 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Hellborn"); Tooltip.SetDefault("Fires a spread of 3 bullets\n" + - "Converts musket balls into explosive bullets\n" + + "Converts musket balls into explosive bullets\n" + "Enemies that touch the gun while it's being fired trigger a massive explosion\n" + - "After the explosion, this gun gains a massive boost to damage, fire rate and knockback for 10 seconds\n" + - "These stat bonuses slowly decay over time"); + "After the explosion, this gun gains a massive boost to damage, fire rate and knockback for 10 seconds\n" + + "These stat bonuses slowly decay over time"); } public override void SetDefaults() @@ -27,23 +27,23 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAnimation = 15; item.useStyle = ItemUseStyleID.HoldingOut; item.knockBack = 2f; - item.value = CalamityGlobalItem.Rarity5BuyPrice; - item.rare = ItemRarityID.Pink; - item.UseSound = SoundID.Item11; + item.value = CalamityGlobalItem.Rarity5BuyPrice; + item.rare = ItemRarityID.Pink; + item.UseSound = SoundID.Item11; item.autoReuse = true; item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 12f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - public override float UseTimeMultiplier(Player player) => 1f + (player.Calamity().hellbornBoost * (1f / 600f)); + public override float UseTimeMultiplier(Player player) => 1f + (player.Calamity().hellbornBoost * (1f / 600f)); - public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) => mult += player.Calamity().hellbornBoost * (1f / 600f); + public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) => mult += player.Calamity().hellbornBoost * (1f / 600f); - public override void GetWeaponKnockback(Player player, ref float knockback) => knockback *= 1f + (player.Calamity().hellbornBoost * (1f / 600f)); + public override void GetWeaponKnockback(Player player, ref float knockback) => knockback *= 1f + (player.Calamity().hellbornBoost * (1f / 600f)); - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -52,58 +52,58 @@ namespace CalamityMod.Items.Weapons.Ranged float SpeedX = speedX + Main.rand.Next(-15, 16) * 0.05f; float SpeedY = speedY + Main.rand.Next(-15, 16) * 0.05f; - if (type == ProjectileID.Bullet) - { - int bullet = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ProjectileID.ExplosiveBullet, damage, knockBack, player.whoAmI); - Main.projectile[bullet].usesLocalNPCImmunity = true; - Main.projectile[bullet].localNPCHitCooldown = 10; - } - else - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); - } + if (type == ProjectileID.Bullet) + { + int bullet = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ProjectileID.ExplosiveBullet, damage, knockBack, player.whoAmI); + Main.projectile[bullet].usesLocalNPCImmunity = true; + Main.projectile[bullet].localNPCHitCooldown = 10; + } + else + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); + } return false; } public override void ModifyHitNPC(Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) { - player.Calamity().hellbornBoost = 600; + player.Calamity().hellbornBoost = 600; damage *= 10; - player.ApplyDamageToNPC(target, (int)(item.damage * (player.allDamage + player.rangedDamage - 1f)), 0f, 0, false); - float num50 = 3.4f; - float num51 = 1.6f; - float num52 = 4f; - Vector2 value3 = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); - Main.PlaySound(SoundID.Item14, target.position); - for (int num53 = 0; num53 < 80; num53++) - { - int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; - dust.position = target.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * target.width / 2f; - dust.noGravity = true; - dust.velocity.Y -= 6f; - dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, num51); - dust.position = target.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * target.width / 2f; - dust.velocity.Y -= 6f; - dust.velocity *= 2f; - dust.noGravity = true; - dust.fadeIn = 1f; - dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); - } - for (int num55 = 0; num55 < 40; num55++) - { - int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; - dust.position = target.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(target.velocity.ToRotation()) * target.width / 3f; - dust.noGravity = true; - dust.velocity.Y -= 6f; - dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - } - } + player.ApplyDamageToNPC(target, (int)(item.damage * (player.allDamage + player.rangedDamage - 1f)), 0f, 0, false); + float num50 = 3.4f; + float num51 = 1.6f; + float num52 = 4f; + Vector2 value3 = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); + Vector2 value4 = value3 * target.velocity.Length(); + Main.PlaySound(SoundID.Item14, target.position); + for (int num53 = 0; num53 < 80; num53++) + { + int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, num50); + Dust dust = Main.dust[num54]; + dust.position = target.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * target.width / 2f; + dust.noGravity = true; + dust.velocity.Y -= 6f; + dust.velocity *= 3f; + dust.velocity += value4 * Main.rand.NextFloat(); + num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, num51); + dust.position = target.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * target.width / 2f; + dust.velocity.Y -= 6f; + dust.velocity *= 2f; + dust.noGravity = true; + dust.fadeIn = 1f; + dust.color = Color.Crimson * 0.5f; + dust.velocity += value4 * Main.rand.NextFloat(); + } + for (int num55 = 0; num55 < 40; num55++) + { + int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, num52); + Dust dust = Main.dust[num56]; + dust.position = target.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(target.velocity.ToRotation()) * target.width / 3f; + dust.noGravity = true; + dust.velocity.Y -= 6f; + dust.velocity *= 0.5f; + dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); + } + } public override void ModifyHitPvp(Player player, Player target, ref int damage, ref bool crit) { diff --git a/Items/Weapons/Ranged/Helstorm.cs b/Items/Weapons/Ranged/Helstorm.cs index ee77c727ed..716f28811b 100644 --- a/Items/Weapons/Ranged/Helstorm.cs +++ b/Items/Weapons/Ranged/Helstorm.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 11.5f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Ranged/Impaler.cs b/Items/Weapons/Ranged/Impaler.cs index 0e61f4b93b..07d8a7d995 100644 --- a/Items/Weapons/Ranged/Impaler.cs +++ b/Items/Weapons/Ranged/Impaler.cs @@ -34,11 +34,11 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; item.useAmmo = AmmoID.Stake; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 14; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 14; public override Vector2? HoldoutOffset() => new Vector2(0, -10); diff --git a/Items/Weapons/Ranged/Infinity.cs b/Items/Weapons/Ranged/Infinity.cs index 10f957303b..d4e3267c6f 100644 --- a/Items/Weapons/Ranged/Infinity.cs +++ b/Items/Weapons/Ranged/Infinity.cs @@ -32,16 +32,16 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 1f; - item.value = Item.buyPrice(1, 80, 0, 0); - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.UseSound = SoundID.Item31; + item.value = Item.buyPrice(1, 80, 0, 0); + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.UseSound = SoundID.Item31; item.autoReuse = true; item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 12f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { @@ -112,14 +112,14 @@ namespace CalamityMod.Items.Weapons.Ranged } } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/Interfacer.cs b/Items/Weapons/Ranged/Interfacer.cs index b283fb0136..95ee1a73c1 100644 --- a/Items/Weapons/Ranged/Interfacer.cs +++ b/Items/Weapons/Ranged/Interfacer.cs @@ -5,13 +5,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class Interfacer : ModItem + public class Interfacer : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Disseminator"); Tooltip.SetDefault("@everyone\n" + - "50% chance to not consume ammo"); + "50% chance to not consume ammo"); } public override void SetDefaults() @@ -48,101 +48,101 @@ 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) { - Vector2 velocity = new Vector2(speedX, speedY); - int bulletAmt = 4; - for (int index = 0; index < bulletAmt; ++index) - { - velocity.X += Main.rand.Next(-15, 16) * 0.05f; - velocity.Y += Main.rand.Next(-15, 16) * 0.05f; - int proj = Projectile.NewProjectile(position, velocity, type, damage, knockBack, player.whoAmI); - Main.projectile[proj].extraUpdates += 2; - } + Vector2 velocity = new Vector2(speedX, speedY); + int bulletAmt = 4; + for (int index = 0; index < bulletAmt; ++index) + { + velocity.X += Main.rand.Next(-15, 16) * 0.05f; + velocity.Y += Main.rand.Next(-15, 16) * 0.05f; + int proj = Projectile.NewProjectile(position, velocity, type, damage, knockBack, player.whoAmI); + Main.projectile[proj].extraUpdates += 2; + } - int maxTargets = 8; - int[] targets = new int[maxTargets]; - int targetArrayIndex = 0; - Rectangle rectangle = new Rectangle((int)player.Center.X - 960, (int)player.Center.Y - 540, 1920, 1080); - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.active && npc.chaseable && npc.lifeMax > 5 && !npc.dontTakeDamage && !npc.friendly && !npc.immortal) - { - if (npc.Hitbox.Intersects(rectangle)) - { - if (targetArrayIndex < maxTargets) - { - targets[targetArrayIndex] = i; - targetArrayIndex++; - } - else - break; - } - } - } + int maxTargets = 8; + int[] targets = new int[maxTargets]; + int targetArrayIndex = 0; + Rectangle rectangle = new Rectangle((int)player.Center.X - 960, (int)player.Center.Y - 540, 1920, 1080); + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.active && npc.chaseable && npc.lifeMax > 5 && !npc.dontTakeDamage && !npc.friendly && !npc.immortal) + { + if (npc.Hitbox.Intersects(rectangle)) + { + if (targetArrayIndex < maxTargets) + { + targets[targetArrayIndex] = i; + targetArrayIndex++; + } + else + break; + } + } + } - if (targetArrayIndex == 0) - return false; + if (targetArrayIndex == 0) + return false; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - int extraBulletDamage = (int)(damage * 0.7); + Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); + int extraBulletDamage = (int)(damage * 0.7); - for (int j = 0; j < targetArrayIndex; j++) - { - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100 * j; + for (int j = 0; j < targetArrayIndex; j++) + { + vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + vector2.Y -= 100 * j; - Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[j]].Center - vector2) * item.shootSpeed; + Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[j]].Center - vector2) * item.shootSpeed; - int proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); - Main.projectile[proj].extraUpdates += 2; - Main.projectile[proj].tileCollide = false; - Main.projectile[proj].timeLeft /= 2; + int proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); + Main.projectile[proj].extraUpdates += 2; + Main.projectile[proj].tileCollide = false; + Main.projectile[proj].timeLeft /= 2; - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y += 100 * j; + vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); + vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + vector2.Y += 100 * j; - velocity2 = Vector2.Normalize(Main.npc[targets[j]].Center - vector2) * item.shootSpeed; + velocity2 = Vector2.Normalize(Main.npc[targets[j]].Center - vector2) * item.shootSpeed; - proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); - Main.projectile[proj].extraUpdates += 2; - Main.projectile[proj].tileCollide = false; - Main.projectile[proj].timeLeft /= 2; - } + proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); + Main.projectile[proj].extraUpdates += 2; + Main.projectile[proj].tileCollide = false; + Main.projectile[proj].timeLeft /= 2; + } - if (targetArrayIndex == 12) - return false; + if (targetArrayIndex == 12) + return false; - // Fire bullets at the same targets if 12 unique targets aren't found - for (int k = 0; k < maxTargets - targetArrayIndex; k++) - { - int randomTarget = Main.rand.Next(targetArrayIndex); + // Fire bullets at the same targets if 12 unique targets aren't found + for (int k = 0; k < maxTargets - targetArrayIndex; k++) + { + int randomTarget = Main.rand.Next(targetArrayIndex); - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100 * randomTarget; + vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + vector2.Y -= 100 * randomTarget; - Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * item.shootSpeed; + Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * item.shootSpeed; - int proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); - Main.projectile[proj].extraUpdates += 2; - Main.projectile[proj].tileCollide = false; - Main.projectile[proj].timeLeft /= 2; + int proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); + Main.projectile[proj].extraUpdates += 2; + Main.projectile[proj].tileCollide = false; + Main.projectile[proj].timeLeft /= 2; - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y += 100 * randomTarget; + vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); + vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + vector2.Y += 100 * randomTarget; - velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * item.shootSpeed; + velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * item.shootSpeed; - proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); - Main.projectile[proj].extraUpdates += 2; - Main.projectile[proj].tileCollide = false; - Main.projectile[proj].timeLeft /= 2; - } + proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); + Main.projectile[proj].extraUpdates += 2; + Main.projectile[proj].tileCollide = false; + Main.projectile[proj].timeLeft /= 2; + } - return false; + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/Karasawa.cs b/Items/Weapons/Ranged/Karasawa.cs index 9628012909..a75fa0cf70 100644 --- a/Items/Weapons/Ranged/Karasawa.cs +++ b/Items/Weapons/Ranged/Karasawa.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class Karasawa : ModItem + public class Karasawa : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Ranged/Leviatitan.cs b/Items/Weapons/Ranged/Leviatitan.cs index 1e44e0b934..69e8d2d2a2 100644 --- a/Items/Weapons/Ranged/Leviatitan.cs +++ b/Items/Weapons/Ranged/Leviatitan.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class Leviatitan : ModItem + public class Leviatitan : ModItem { public override void SetStaticDefaults() { @@ -31,9 +31,9 @@ namespace CalamityMod.Items.Weapons.Ranged item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; - item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.useAmmo = AmmoID.Bullet; + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { @@ -45,17 +45,17 @@ namespace CalamityMod.Items.Weapons.Ranged float SpeedX = speedX + Main.rand.Next(-10, 11) * 0.05f; float SpeedY = speedY + Main.rand.Next(-10, 11) * 0.05f; - if (type == ProjectileID.Bullet) - { - if (Main.rand.NextBool(3)) - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * 1.5), knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - } - else - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + { + if (Main.rand.NextBool(3)) + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * 1.5), knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + } + else + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/LunarianBow.cs b/Items/Weapons/Ranged/LunarianBow.cs index a6f63363c0..46b38daff4 100644 --- a/Items/Weapons/Ranged/LunarianBow.cs +++ b/Items/Weapons/Ranged/LunarianBow.cs @@ -7,13 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class LunarianBow : ModItem + public class LunarianBow : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Lunarian Bow"); Tooltip.SetDefault("Fires two arrows at once\n" + - "Converts wooden arrows into sliding energy bolts"); + "Converts wooden arrows into sliding energy bolts"); } public override void SetDefaults() @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 8f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { @@ -53,14 +53,14 @@ namespace CalamityMod.Items.Weapons.Ranged if (!canHit) offset -= velocity; - if (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - { - int proj = Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[proj].noDropItem = true; - } - } + if (type == ProjectileID.WoodenArrowFriendly) + Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + { + int proj = Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + Main.projectile[proj].noDropItem = true; + } + } return false; } diff --git a/Items/Weapons/Ranged/MagnaStriker.cs b/Items/Weapons/Ranged/MagnaStriker.cs index 77800c71bd..ada40dd626 100644 --- a/Items/Weapons/Ranged/MagnaStriker.cs +++ b/Items/Weapons/Ranged/MagnaStriker.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 15f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Ranged/Malevolence.cs b/Items/Weapons/Ranged/Malevolence.cs index 0c716b2a55..b07c34cd23 100644 --- a/Items/Weapons/Ranged/Malevolence.cs +++ b/Items/Weapons/Ranged/Malevolence.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Malevolence"); Tooltip.SetDefault("Fires two arrows at once\n" + - "Converts wooden arrows into plague arrows that explode into bees on death"); + "Converts wooden arrows into plague arrows that explode into bees on death"); } public override void SetDefaults() @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 12f; item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { @@ -43,14 +43,14 @@ namespace CalamityMod.Items.Weapons.Ranged float SpeedX = speedX + Main.rand.Next(-20, 21) * 0.05f; float SpeedY = speedY + Main.rand.Next(-20, 21) * 0.05f; - if (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - { - int proj = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); - Main.projectile[proj].noDropItem = true; - } - } + if (type == ProjectileID.WoodenArrowFriendly) + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + { + int proj = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); + Main.projectile[proj].noDropItem = true; + } + } return false; } } diff --git a/Items/Weapons/Ranged/MandibleBow.cs b/Items/Weapons/Ranged/MandibleBow.cs index 509c79b3e2..79b5055833 100644 --- a/Items/Weapons/Ranged/MandibleBow.cs +++ b/Items/Weapons/Ranged/MandibleBow.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 15f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } } } diff --git a/Items/Weapons/Ranged/MarksmanBow.cs b/Items/Weapons/Ranged/MarksmanBow.cs index 449cbaa2db..8b713a23f9 100644 --- a/Items/Weapons/Ranged/MarksmanBow.cs +++ b/Items/Weapons/Ranged/MarksmanBow.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Marksman Bow"); Tooltip.SetDefault("Fires three arrows at once\n" + - "Wooden arrows are converted into Jester's arrows"); + "Wooden arrows are converted into Jester's arrows"); } public override void SetDefaults() @@ -34,33 +34,33 @@ namespace CalamityMod.Items.Weapons.Ranged item.value = Item.buyPrice(gold: 80); // crafted out of nothing but 31 ectoplasm so it has unique pricing item.rare = ItemRarityID.Yellow; item.Calamity().donorItem = true; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; public override Vector2? HoldoutOffset() => new Vector2(-4, 0); public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - //Convert wooden arrows to Jester's Arrows - if (type == ProjectileID.WoodenArrowFriendly) - type = ProjectileID.JestersArrow; + //Convert wooden arrows to Jester's Arrows + if (type == ProjectileID.WoodenArrowFriendly) + type = ProjectileID.JestersArrow; for (int i = 0; i < 3; i++) { - int randomExtraUpdates = Main.rand.Next(3); + int randomExtraUpdates = Main.rand.Next(3); float SpeedX = speedX + Main.rand.NextFloat(-10f, 10f) * 0.05f; float SpeedY = speedY + Main.rand.NextFloat(-10f, 10f) * 0.05f; int arrow = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); Main.projectile[arrow].noDropItem = true; - Main.projectile[arrow].extraUpdates += randomExtraUpdates; //0 to 2 extra updates - if (type == ProjectileID.JestersArrow) - { - Main.projectile[arrow].localNPCHitCooldown = 10 * (randomExtraUpdates + 1); - Main.projectile[arrow].usesLocalNPCImmunity = true; - } + Main.projectile[arrow].extraUpdates += randomExtraUpdates; //0 to 2 extra updates + if (type == ProjectileID.JestersArrow) + { + Main.projectile[arrow].localNPCHitCooldown = 10 * (randomExtraUpdates + 1); + Main.projectile[arrow].usesLocalNPCImmunity = true; + } } return false; } diff --git a/Items/Weapons/Ranged/MarniteRifleSpear.cs b/Items/Weapons/Ranged/MarniteRifleSpear.cs index d960b3200f..915b43e067 100644 --- a/Items/Weapons/Ranged/MarniteRifleSpear.cs +++ b/Items/Weapons/Ranged/MarniteRifleSpear.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class MarniteRifleSpear : ModItem + public class MarniteRifleSpear : ModItem { public override void SetStaticDefaults() { @@ -28,8 +28,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 22f; item.useAmmo = AmmoID.Bullet; item.shoot = ProjectileID.PurificationPowder; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/Megalodon.cs b/Items/Weapons/Ranged/Megalodon.cs index d42e35f5e0..b88dcbbbbf 100644 --- a/Items/Weapons/Ranged/Megalodon.cs +++ b/Items/Weapons/Ranged/Megalodon.cs @@ -37,8 +37,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 16f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Ranged/MolecularManipulator.cs b/Items/Weapons/Ranged/MolecularManipulator.cs index 58c13450e9..a7292f6164 100644 --- a/Items/Weapons/Ranged/MolecularManipulator.cs +++ b/Items/Weapons/Ranged/MolecularManipulator.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class MolecularManipulator : ModItem + public class MolecularManipulator : ModItem { public override void SetStaticDefaults() { @@ -27,15 +27,15 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 8f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item33; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item33; item.autoReuse = true; item.shootSpeed = 25f; item.shoot = ModContent.ProjectileType(); - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Ranged/Monsoon.cs b/Items/Weapons/Ranged/Monsoon.cs index cda1a9d3b3..5abebce4dc 100644 --- a/Items/Weapons/Ranged/Monsoon.cs +++ b/Items/Weapons/Ranged/Monsoon.cs @@ -35,8 +35,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.WoodenArrowFriendly; item.shootSpeed = 12f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { @@ -56,25 +56,25 @@ namespace CalamityMod.Items.Weapons.Ranged if (type == ProjectileID.WoodenArrowFriendly) { - int newType = type; - switch (p) - { - case 0: - case 1: - case 3: - case 4: - newType = ModContent.ProjectileType(); - break; - case 2: - newType = ModContent.ProjectileType(); - break; - } + int newType = type; + switch (p) + { + case 0: + case 1: + case 3: + case 4: + newType = ModContent.ProjectileType(); + break; + case 2: + newType = ModContent.ProjectileType(); + break; + } int proj = Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, newType, (int)(damage * 1.1), knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].arrow = true; - Main.projectile[proj].extraUpdates += 1; - } + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].arrow = true; + Main.projectile[proj].extraUpdates += 1; + } } else { diff --git a/Items/Weapons/Ranged/Needler.cs b/Items/Weapons/Ranged/Needler.cs index 3891e4f2b3..ea666beee0 100644 --- a/Items/Weapons/Ranged/Needler.cs +++ b/Items/Weapons/Ranged/Needler.cs @@ -41,12 +41,12 @@ 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) { - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/NettlelineGreatbow.cs b/Items/Weapons/Ranged/NettlelineGreatbow.cs index abc109ad35..d6f1143939 100644 --- a/Items/Weapons/Ranged/NettlelineGreatbow.cs +++ b/Items/Weapons/Ranged/NettlelineGreatbow.cs @@ -26,16 +26,16 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 3f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item5; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item5; item.autoReuse = true; item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 16f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { diff --git a/Items/Weapons/Ranged/Norfleet.cs b/Items/Weapons/Ranged/Norfleet.cs index 284b4ccc8c..8c0266a853 100644 --- a/Items/Weapons/Ranged/Norfleet.cs +++ b/Items/Weapons/Ranged/Norfleet.cs @@ -11,8 +11,8 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetStaticDefaults() { DisplayName.SetDefault("Norfleet"); - Tooltip.SetDefault("Fire everything!"); - } + Tooltip.SetDefault("Fire everything!"); + } public override void SetDefaults() { @@ -27,17 +27,17 @@ namespace CalamityMod.Items.Weapons.Ranged item.height = 42; item.UseSound = SoundID.Item92; item.shoot = ModContent.ProjectileType(); - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.noMelee = true; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.noMelee = true; item.noUseGraphic = true; item.ranged = true; item.channel = true; item.useTurn = false; item.useAmmo = AmmoID.FallenStar; item.autoReuse = true; - } + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; diff --git a/Items/Weapons/Ranged/NullificationRifle.cs b/Items/Weapons/Ranged/NullificationRifle.cs index a96881df49..978fe91d6e 100644 --- a/Items/Weapons/Ranged/NullificationRifle.cs +++ b/Items/Weapons/Ranged/NullificationRifle.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class NullificationRifle : ModItem + public class NullificationRifle : ModItem { public override void SetStaticDefaults() { @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.autoReuse = true; item.shootSpeed = 25f; item.shoot = ModContent.ProjectileType(); - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Ranged/OnyxChainBlaster.cs b/Items/Weapons/Ranged/OnyxChainBlaster.cs index 401fae9275..cc301f6a0a 100644 --- a/Items/Weapons/Ranged/OnyxChainBlaster.cs +++ b/Items/Weapons/Ranged/OnyxChainBlaster.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.BlackBolt; item.shootSpeed = 24f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Ranged/Onyxia.cs b/Items/Weapons/Ranged/Onyxia.cs index 184b09b546..b07f964234 100644 --- a/Items/Weapons/Ranged/Onyxia.cs +++ b/Items/Weapons/Ranged/Onyxia.cs @@ -28,16 +28,16 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 4.5f; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.UseSound = SoundID.Item36; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.UseSound = SoundID.Item36; item.autoReuse = true; item.shoot = ProjectileID.BlackBolt; item.shootSpeed = 28f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Ranged/OpalStriker.cs b/Items/Weapons/Ranged/OpalStriker.cs index a02e22c36e..0c8150aa35 100644 --- a/Items/Weapons/Ranged/OpalStriker.cs +++ b/Items/Weapons/Ranged/OpalStriker.cs @@ -6,54 +6,54 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class OpalStriker : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Opal Striker"); - Tooltip.SetDefault("Fires a string of opal strikes"); - } + public class OpalStriker : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Opal Striker"); + Tooltip.SetDefault("Fires a string of opal strikes"); + } - public override void SetDefaults() - { - item.damage = 9; - item.ranged = true; - item.width = 46; - item.height = 30; - item.useTime = 5; - item.reuseDelay = 25; - item.useAnimation = 20; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 0f; - item.value = Item.buyPrice(0, 2, 0, 0); - item.rare = ItemRarityID.Green; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/OpalStrike"); - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 6f; - item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + public override void SetDefaults() + { + item.damage = 9; + item.ranged = true; + item.width = 46; + item.height = 30; + item.useTime = 5; + item.reuseDelay = 25; + item.useAnimation = 20; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 0f; + item.value = Item.buyPrice(0, 2, 0, 0); + item.rare = ItemRarityID.Green; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/OpalStrike"); + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 6f; + item.useAmmo = AmmoID.Bullet; + item.Calamity().canFirePointBlankShots = true; + } - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - return false; - } + 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.Marble, 20); - recipe.AddIngredient(ItemID.Amber, 5); - recipe.AddIngredient(ItemID.Diamond, 3); - recipe.AddIngredient(ItemID.FlintlockPistol); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.Marble, 20); + recipe.AddIngredient(ItemID.Amber, 5); + recipe.AddIngredient(ItemID.Diamond, 3); + recipe.AddIngredient(ItemID.FlintlockPistol); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/P90.cs b/Items/Weapons/Ranged/P90.cs index 3d23dc7730..c6ad413195 100644 --- a/Items/Weapons/Ranged/P90.cs +++ b/Items/Weapons/Ranged/P90.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class P90 : ModItem + public class P90 : ModItem { public override void SetStaticDefaults() { @@ -32,21 +32,21 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.Bullet; item.shootSpeed = 7f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { return new Vector2(-14, -1); } - 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 + Main.rand.Next(-15, 16) * 0.05f; - float SpeedY = speedY + Main.rand.Next(-15, 16) * 0.05f; - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - return false; - } + 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 + Main.rand.Next(-15, 16) * 0.05f; + float SpeedY = speedY + Main.rand.Next(-15, 16) * 0.05f; + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } public override bool ConsumeAmmo(Player player) => Main.rand.NextFloat() < 0.5f; } diff --git a/Items/Weapons/Ranged/PaintballBlaster.cs b/Items/Weapons/Ranged/PaintballBlaster.cs index 977dfbdca6..b4c0d11856 100644 --- a/Items/Weapons/Ranged/PaintballBlaster.cs +++ b/Items/Weapons/Ranged/PaintballBlaster.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.autoReuse = true; item.shootSpeed = 20f; item.shoot = ProjectileID.PainterPaintball; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { diff --git a/Items/Weapons/Ranged/PearlGod.cs b/Items/Weapons/Ranged/PearlGod.cs index 80ec75b10f..9816fe5208 100644 --- a/Items/Weapons/Ranged/PearlGod.cs +++ b/Items/Weapons/Ranged/PearlGod.cs @@ -8,16 +8,16 @@ namespace CalamityMod.Items.Weapons.Ranged { public class PearlGod : ModItem { - private const int defaultSpread = 1; - private int spread = defaultSpread; - private bool finalShot = false; + private const int defaultSpread = 1; + private int spread = defaultSpread; + private bool finalShot = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Pearl God"); Tooltip.SetDefault("Your life is mine...\n" + - "Fires shockblast rounds that emit massive explosions and steal enemy life as well as additional bullets\n" + - "Every seventh shot fires a massive shockblast"); + "Fires shockblast rounds that emit massive explosions and steal enemy life as well as additional bullets\n" + + "Every seventh shot fires a massive shockblast"); } public override void SetDefaults() @@ -31,15 +31,15 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 3f; - item.value = CalamityGlobalItem.Rarity8BuyPrice; - item.rare = ItemRarityID.Yellow; - item.UseSound = SoundID.Item41; + item.value = CalamityGlobalItem.Rarity8BuyPrice; + item.rare = ItemRarityID.Yellow; + item.UseSound = SoundID.Item41; item.autoReuse = true; item.shootSpeed = 12f; item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { @@ -48,68 +48,68 @@ 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) { - if (spread > 6) - { - spread = defaultSpread; - finalShot = true; - } + if (spread > 6) + { + spread = defaultSpread; + finalShot = true; + } - Vector2 velocity = new Vector2(speedX, speedY); - float rotation = MathHelper.ToRadians(spread); - if (!finalShot) - { - int totalLoops = 1; - switch (spread) - { - case 1: - case 2: - break; - case 3: - case 4: - totalLoops = 2; - break; - case 5: - case 6: - totalLoops = 3; - break; - } + Vector2 velocity = new Vector2(speedX, speedY); + float rotation = MathHelper.ToRadians(spread); + if (!finalShot) + { + int totalLoops = 1; + switch (spread) + { + case 1: + case 2: + break; + case 3: + case 4: + totalLoops = 2; + break; + case 5: + case 6: + totalLoops = 3; + break; + } - for (int i = 0; i < totalLoops; i++) - { - int proj = Projectile.NewProjectile(position, velocity.RotatedBy(-rotation * (i + 1)), type, (int)(damage * 0.5), knockBack * 0.5f, player.whoAmI); - Main.projectile[proj].extraUpdates += spread; - int proj2 = Projectile.NewProjectile(position, velocity.RotatedBy(+rotation * (i + 1)), type, (int)(damage * 0.5), knockBack * 0.5f, player.whoAmI); - Main.projectile[proj2].extraUpdates += spread; - } + for (int i = 0; i < totalLoops; i++) + { + int proj = Projectile.NewProjectile(position, velocity.RotatedBy(-rotation * (i + 1)), type, (int)(damage * 0.5), knockBack * 0.5f, player.whoAmI); + Main.projectile[proj].extraUpdates += spread; + int proj2 = Projectile.NewProjectile(position, velocity.RotatedBy(+rotation * (i + 1)), type, (int)(damage * 0.5), knockBack * 0.5f, player.whoAmI); + Main.projectile[proj2].extraUpdates += spread; + } - int proj3 = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, spread); - Main.projectile[proj3].extraUpdates += spread; + int proj3 = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, spread); + Main.projectile[proj3].extraUpdates += spread; - spread++; - } - else - { - for (int i = 0; i < 3; i++) - { - int proj = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), damage * 2, knockBack * 2f, player.whoAmI, 0f, 10f); - Main.projectile[proj].extraUpdates += 9; - } + spread++; + } + else + { + for (int i = 0; i < 3; i++) + { + int proj = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), damage * 2, knockBack * 2f, player.whoAmI, 0f, 10f); + Main.projectile[proj].extraUpdates += 9; + } - finalShot = false; - } + finalShot = false; + } - return false; + return false; } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.SpectreBar, 5); - recipe.AddIngredient(ItemID.ShroomiteBar, 5); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.SpectreBar, 5); + recipe.AddIngredient(ItemID.ShroomiteBar, 5); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/PestilentDefiler.cs b/Items/Weapons/Ranged/PestilentDefiler.cs index d3a9ceb651..4ec1975f6b 100644 --- a/Items/Weapons/Ranged/PestilentDefiler.cs +++ b/Items/Weapons/Ranged/PestilentDefiler.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 12f; item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { @@ -42,13 +42,13 @@ 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) { - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/PrideHuntersPlanarRipper.cs b/Items/Weapons/Ranged/PrideHuntersPlanarRipper.cs index 5ce6a6ca45..d373bbb1f8 100644 --- a/Items/Weapons/Ranged/PrideHuntersPlanarRipper.cs +++ b/Items/Weapons/Ranged/PrideHuntersPlanarRipper.cs @@ -44,8 +44,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.value = CalamityGlobalItem.Rarity11BuyPrice; item.rare = ItemRarityID.Purple; item.Calamity().donorItem = true; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-12, -6); diff --git a/Items/Weapons/Ranged/PristineFury.cs b/Items/Weapons/Ranged/PristineFury.cs index 4436a3ec29..a3e1285c4e 100644 --- a/Items/Weapons/Ranged/PristineFury.cs +++ b/Items/Weapons/Ranged/PristineFury.cs @@ -37,10 +37,10 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 11f; item.useAmmo = AmmoID.Gel; - item.rare = ItemRarityID.Purple; + item.rare = ItemRarityID.Purple; item.value = CalamityGlobalItem.Rarity12BuyPrice; item.Calamity().customRarity = CalamityRarity.Turquoise; - } + } public override Vector2? HoldoutOffset() => new Vector2(-25, -10); diff --git a/Items/Weapons/Ranged/ProporsePistol.cs b/Items/Weapons/Ranged/ProporsePistol.cs index e926330fd5..566b27ccf5 100644 --- a/Items/Weapons/Ranged/ProporsePistol.cs +++ b/Items/Weapons/Ranged/ProporsePistol.cs @@ -31,8 +31,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.autoReuse = true; item.shootSpeed = 20f; item.shoot = ModContent.ProjectileType(); - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { diff --git a/Items/Weapons/Ranged/RaidersGlory.cs b/Items/Weapons/Ranged/RaidersGlory.cs index ef08ed1baf..aa17b06832 100644 --- a/Items/Weapons/Ranged/RaidersGlory.cs +++ b/Items/Weapons/Ranged/RaidersGlory.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Raider's Glory"); Tooltip.SetDefault("Fires ichor arrows with increased velocity\n" + - "These arrows also cause enemies to drop more money"); + "These arrows also cause enemies to drop more money"); } public override void SetDefaults() @@ -32,11 +32,11 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 15f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Ranged/RealmRavager.cs b/Items/Weapons/Ranged/RealmRavager.cs index da4d1c8c9d..f6b63062eb 100644 --- a/Items/Weapons/Ranged/RealmRavager.cs +++ b/Items/Weapons/Ranged/RealmRavager.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Realm Ravager"); Tooltip.SetDefault("Shoots a burst of 3 to 4 bullets\n" + - "Converts musket balls into explosive bullets"); + "Converts musket balls into explosive bullets"); } public override void SetDefaults() @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 30f; item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); @@ -46,11 +46,11 @@ namespace CalamityMod.Items.Weapons.Ranged float SpeedX = speedX + Main.rand.Next(-75, 76) * 0.05f; float SpeedY = speedY + Main.rand.Next(-75, 76) * 0.05f; - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); - } + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); + } return false; } } diff --git a/Items/Weapons/Ranged/RubicoPrime.cs b/Items/Weapons/Ranged/RubicoPrime.cs index 27a6db10f2..cc76f1ca79 100644 --- a/Items/Weapons/Ranged/RubicoPrime.cs +++ b/Items/Weapons/Ranged/RubicoPrime.cs @@ -38,8 +38,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.value = CalamityGlobalItem.Rarity14BuyPrice; item.Calamity().customRarity = CalamityRarity.DarkBlue; item.Calamity().donorItem = true; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } // Terraria seems to really dislike high crit values in SetDefaults public override void GetWeaponCrit(Player player, ref int crit) => crit += 40; diff --git a/Items/Weapons/Ranged/SDFMG.cs b/Items/Weapons/Ranged/SDFMG.cs index d38d896958..b60d92a89a 100644 --- a/Items/Weapons/Ranged/SDFMG.cs +++ b/Items/Weapons/Ranged/SDFMG.cs @@ -37,11 +37,11 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 16f; item.useAmmo = AmmoID.Bullet; item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 15; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 15; public override Vector2? HoldoutOffset() => new Vector2(-10, 0); diff --git a/Items/Weapons/Ranged/SandstormGun.cs b/Items/Weapons/Ranged/SandstormGun.cs index b4ecebc218..161a197fc4 100644 --- a/Items/Weapons/Ranged/SandstormGun.cs +++ b/Items/Weapons/Ranged/SandstormGun.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Sandstorm"); Tooltip.SetDefault("Fires sand bullets that explode and slow enemies on hit\n" + - "50% chance to not consume sand"); + "50% chance to not consume sand"); } public override void SetDefaults() @@ -34,22 +34,22 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 12f; item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Sand; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { return new Vector2(-10, 0); } - public override bool ConsumeAmmo(Player player) - { - if (Main.rand.Next(0, 100) < 50) - return false; - return true; - } + public override bool ConsumeAmmo(Player player) + { + if (Main.rand.Next(0, 100) < 50) + return false; + return 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) + 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); return false; diff --git a/Items/Weapons/Ranged/ScorchedEarth.cs b/Items/Weapons/Ranged/ScorchedEarth.cs index 8fb322f21e..26f8c0fa47 100644 --- a/Items/Weapons/Ranged/ScorchedEarth.cs +++ b/Items/Weapons/Ranged/ScorchedEarth.cs @@ -8,69 +8,69 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class ScorchedEarth : ModItem - { - private int counter = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Scorched Earth"); - Tooltip.SetDefault("Fires a burst of four fuel-air rockets which explode into cluster bombs\n" + - "Each burst consumes two rockets each\n" + - "Burns your targets to a fine crisp"); - } + public class ScorchedEarth : ModItem + { + private int counter = 0; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Scorched Earth"); + Tooltip.SetDefault("Fires a burst of four fuel-air rockets which explode into cluster bombs\n" + + "Each burst consumes two rockets each\n" + + "Burns your targets to a fine crisp"); + } - public override void SetDefaults() - { - item.damage = 500; - item.ranged = true; - item.useTime = 8; - item.useAnimation = 32; // 4 shots in just over half a second - item.reuseDelay = 60; // 1 second recharge - item.width = 104; - item.height = 44; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 8.7f; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.autoReuse = true; - item.shootSpeed = 12.6f; - item.shoot = ModContent.ProjectileType(); - item.useAmmo = AmmoID.Rocket; - item.Calamity().donorItem = true; - } + public override void SetDefaults() + { + item.damage = 500; + item.ranged = true; + item.useTime = 8; + item.useAnimation = 32; // 4 shots in just over half a second + item.reuseDelay = 60; // 1 second recharge + item.width = 104; + item.height = 44; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 8.7f; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.autoReuse = true; + item.shootSpeed = 12.6f; + item.shoot = ModContent.ProjectileType(); + item.useAmmo = AmmoID.Rocket; + item.Calamity().donorItem = true; + } - // Consume two ammo per fire - public override bool ConsumeAmmo(Player player) => counter % 2 == 0; + // Consume two ammo per fire + public override bool ConsumeAmmo(Player player) => counter % 2 == 0; - public override Vector2? HoldoutOffset() => new Vector2(-30, 0); + public override Vector2? HoldoutOffset() => new Vector2(-30, 0); - 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - if (counter == 0) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ScorchedEarthShot" + Main.rand.Next(1,4)), position); - } + if (counter == 0) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ScorchedEarthShot" + Main.rand.Next(1,4)), position); + } - counter++; - if (counter == 4) - counter = 0; - return false; - } + counter++; + if (counter == 4) + counter = 0; + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ItemID.FragmentSolar, 50); - recipe.AddRecipeGroup("AnyAdamantiteBar", 15); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ItemID.FragmentSolar, 50); + recipe.AddRecipeGroup("AnyAdamantiteBar", 15); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/Scorpion.cs b/Items/Weapons/Ranged/Scorpion.cs index 0ccb6b0610..e23c603bcb 100644 --- a/Items/Weapons/Ranged/Scorpion.cs +++ b/Items/Weapons/Ranged/Scorpion.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Ranged DisplayName.SetDefault("Scorpio"); Tooltip.SetDefault("BOOM\n" + "Right click to fire a nuke\n" + - "Rockets will destroy tiles with tile-destroying ammo"); + "Rockets will destroy tiles with tile-destroying ammo"); } public override void SetDefaults() @@ -23,9 +23,9 @@ namespace CalamityMod.Items.Weapons.Ranged item.width = 58; item.height = 26; item.useTime = 13; - item.reuseDelay = 30; - item.useAnimation = 39; - item.useStyle = ItemUseStyleID.HoldingOut; + item.reuseDelay = 30; + item.useAnimation = 39; + item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 6.5f; item.value = CalamityGlobalItem.Rarity10BuyPrice; @@ -52,12 +52,12 @@ namespace CalamityMod.Items.Weapons.Ranged return base.CanUseItem(player); } - public override float UseTimeMultiplier(Player player) - { - if (player.altFunctionUse == 2) - return 13f/39f; - return 1f; - } + public override float UseTimeMultiplier(Player player) + { + if (player.altFunctionUse == 2) + return 13f/39f; + return 1f; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Ranged/Seabow.cs b/Items/Weapons/Ranged/Seabow.cs index 3c457a1b88..79aca6ca84 100644 --- a/Items/Weapons/Ranged/Seabow.cs +++ b/Items/Weapons/Ranged/Seabow.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 16f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { diff --git a/Items/Weapons/Ranged/Seadragon.cs b/Items/Weapons/Ranged/Seadragon.cs index 0588f83a19..f934440104 100644 --- a/Items/Weapons/Ranged/Seadragon.cs +++ b/Items/Weapons/Ranged/Seadragon.cs @@ -32,16 +32,16 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 2.5f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item11; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item11; item.autoReuse = true; item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 16f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Ranged/SeasSearing.cs b/Items/Weapons/Ranged/SeasSearing.cs index 97d16daf6c..cfcb09daaf 100644 --- a/Items/Weapons/Ranged/SeasSearing.cs +++ b/Items/Weapons/Ranged/SeasSearing.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.value = CalamityGlobalItem.Rarity5BuyPrice; item.rare = ItemRarityID.Pink; - } + } public override Vector2? HoldoutOffset() { @@ -54,13 +54,13 @@ namespace CalamityMod.Items.Weapons.Ranged { item.useTime = 30; item.useAnimation = 30; - item.reuseDelay = 0; + item.reuseDelay = 0; } else { item.useTime = 5; item.useAnimation = 15; - item.reuseDelay = 20; + item.reuseDelay = 20; } return base.CanUseItem(player); } @@ -69,13 +69,13 @@ namespace CalamityMod.Items.Weapons.Ranged { if (player.altFunctionUse == 2) { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), (int)(damage * 1.22f), knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), (int)(damage * 1.22f), knockBack, player.whoAmI, 0f, 0f); } else { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 1f, 0f); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 1f, 0f); } - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/SepticSkewer.cs b/Items/Weapons/Ranged/SepticSkewer.cs index d996f36aeb..933ecc105c 100644 --- a/Items/Weapons/Ranged/SepticSkewer.cs +++ b/Items/Weapons/Ranged/SepticSkewer.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.value = CalamityGlobalItem.Rarity13BuyPrice; item.Calamity().customRarity = CalamityRarity.PureGreen; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); } diff --git a/Items/Weapons/Ranged/Shellshooter.cs b/Items/Weapons/Ranged/Shellshooter.cs index 02e0b70984..8485edfeb8 100644 --- a/Items/Weapons/Ranged/Shellshooter.cs +++ b/Items/Weapons/Ranged/Shellshooter.cs @@ -32,20 +32,20 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 1.5f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 15; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 15; 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 (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.WoodenArrowFriendly) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/Shredder.cs b/Items/Weapons/Ranged/Shredder.cs index 2576ddcb16..b8a48fc74e 100644 --- a/Items/Weapons/Ranged/Shredder.cs +++ b/Items/Weapons/Ranged/Shredder.cs @@ -36,8 +36,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.Bullet; item.shootSpeed = 12f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); diff --git a/Items/Weapons/Ranged/Shroomer.cs b/Items/Weapons/Ranged/Shroomer.cs index 1cec9a7d72..eae78a77f4 100644 --- a/Items/Weapons/Ranged/Shroomer.cs +++ b/Items/Weapons/Ranged/Shroomer.cs @@ -32,11 +32,11 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.Bullet; item.shootSpeed = 10f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 35; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 35; public override Vector2? HoldoutOffset() => new Vector2(-25, 0); diff --git a/Items/Weapons/Ranged/SlagMagnum.cs b/Items/Weapons/Ranged/SlagMagnum.cs index 0906533a84..e2e011213b 100644 --- a/Items/Weapons/Ranged/SlagMagnum.cs +++ b/Items/Weapons/Ranged/SlagMagnum.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 12f; item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { @@ -42,12 +42,12 @@ 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) { - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } } } diff --git a/Items/Weapons/Ranged/SparkSpreader.cs b/Items/Weapons/Ranged/SparkSpreader.cs index ba1ef75c9d..7a4645a6e0 100644 --- a/Items/Weapons/Ranged/SparkSpreader.cs +++ b/Items/Weapons/Ranged/SparkSpreader.cs @@ -6,48 +6,48 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class SparkSpreader : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Spark Spreader"); - Tooltip.SetDefault("70% chance to not consume gel"); - } + public class SparkSpreader : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Spark Spreader"); + Tooltip.SetDefault("70% chance to not consume gel"); + } - public override void SetDefaults() - { - item.damage = 7; - item.knockBack = 1f; - item.ranged = true; - item.autoReuse = true; - item.useTime = 10; - item.useAnimation = 30; - item.useAmmo = AmmoID.Gel; - item.shootSpeed = 5f; - item.shoot = ModContent.ProjectileType(); + public override void SetDefaults() + { + item.damage = 7; + item.knockBack = 1f; + item.ranged = true; + item.autoReuse = true; + item.useTime = 10; + item.useAnimation = 30; + item.useAmmo = AmmoID.Gel; + item.shootSpeed = 5f; + item.shoot = ModContent.ProjectileType(); - item.width = 52; - item.height = 20; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.UseSound = SoundID.Item34; - item.value = Item.buyPrice(0, 1, 0, 0); - item.rare = ItemRarityID.Blue; - } + item.width = 52; + item.height = 20; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.UseSound = SoundID.Item34; + item.value = Item.buyPrice(0, 1, 0, 0); + item.rare = ItemRarityID.Blue; + } - public override Vector2? HoldoutOffset() => new Vector2(-4, 0); + public override Vector2? HoldoutOffset() => new Vector2(-4, 0); - public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 70; + public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 70; - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.FlareGun); - recipe.AddIngredient(ItemID.Ruby); - recipe.AddIngredient(ItemID.Gel, 12); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.FlareGun); + recipe.AddIngredient(ItemID.Ruby); + recipe.AddIngredient(ItemID.Gel, 12); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/SpectralstormCannon.cs b/Items/Weapons/Ranged/SpectralstormCannon.cs index cb43f803ea..fba5da3023 100644 --- a/Items/Weapons/Ranged/SpectralstormCannon.cs +++ b/Items/Weapons/Ranged/SpectralstormCannon.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.Flare; item.shootSpeed = 9.5f; item.useAmmo = AmmoID.Flare; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); @@ -47,24 +47,24 @@ 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) { - float SpeedX = speedX + (float)Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = speedY + (float)Main.rand.Next(-40, 41) * 0.05f; - int flare = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); - if (flare.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[flare].timeLeft = 200; - Main.projectile[flare].Calamity().forceRanged = true; - } + float SpeedX = speedX + (float)Main.rand.Next(-40, 41) * 0.05f; + float SpeedY = speedY + (float)Main.rand.Next(-40, 41) * 0.05f; + int flare = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); + if (flare.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flare].timeLeft = 200; + Main.projectile[flare].Calamity().forceRanged = true; + } - float SpeedX2 = speedX + (float)Main.rand.Next(-20, 21) * 0.05f; - float SpeedY2 = speedY + (float)Main.rand.Next(-20, 21) * 0.05f; + float SpeedX2 = speedX + (float)Main.rand.Next(-20, 21) * 0.05f; + float SpeedY2 = speedY + (float)Main.rand.Next(-20, 21) * 0.05f; int soul = Projectile.NewProjectile(position.X, position.Y, SpeedX2, SpeedY2, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 2f, 0f); - if (soul.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[soul].timeLeft = 600; - Main.projectile[soul].Calamity().forceRanged = true; - Main.projectile[soul].frame = Main.rand.Next(4); - } + if (soul.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[soul].timeLeft = 600; + Main.projectile[soul].Calamity().forceRanged = true; + Main.projectile[soul].frame = Main.rand.Next(4); + } return false; } diff --git a/Items/Weapons/Ranged/SpectreRifle.cs b/Items/Weapons/Ranged/SpectreRifle.cs index 3d7363a860..b7099f03a5 100644 --- a/Items/Weapons/Ranged/SpectreRifle.cs +++ b/Items/Weapons/Ranged/SpectreRifle.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class SpectreRifle : ModItem + public class SpectreRifle : ModItem { public override void SetStaticDefaults() { @@ -32,26 +32,26 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.LostSoulFriendly; item.shootSpeed = 12f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 22; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 22; public override Vector2? HoldoutOffset() => new Vector2(-10, 0); 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 (type == ProjectileID.Bullet) - { - int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ProjectileID.LostSoulFriendly, damage, knockBack, player.whoAmI, 2f, 0f); - Main.projectile[proj].Calamity().forceRanged = true; - Main.projectile[proj].extraUpdates += 2; - } - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + { + int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ProjectileID.LostSoulFriendly, damage, knockBack, player.whoAmI, 2f, 0f); + Main.projectile[proj].Calamity().forceRanged = true; + Main.projectile[proj].extraUpdates += 2; + } + else + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/Spyker.cs b/Items/Weapons/Ranged/Spyker.cs index 3b80d4a580..46b30f43bb 100644 --- a/Items/Weapons/Ranged/Spyker.cs +++ b/Items/Weapons/Ranged/Spyker.cs @@ -26,10 +26,10 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 6f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item108; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item108; item.autoReuse = true; item.shootSpeed = 9f; item.shoot = ModContent.ProjectileType(); @@ -43,12 +43,12 @@ 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) { - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.Bullet) + Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - return false; + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/StarCannonEX.cs b/Items/Weapons/Ranged/StarCannonEX.cs index ed8b29d2da..a71b428b51 100644 --- a/Items/Weapons/Ranged/StarCannonEX.cs +++ b/Items/Weapons/Ranged/StarCannonEX.cs @@ -46,15 +46,15 @@ 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; - type = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), - ProjectileID.Starfury, - ModContent.ProjectileType() - }); + type = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ProjectileID.Starfury, + ModContent.ProjectileType() + }); int star = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); - if (star.WithinBounds(Main.maxProjectiles)) - Main.projectile[star].Calamity().forceRanged = true; + if (star.WithinBounds(Main.maxProjectiles)) + Main.projectile[star].Calamity().forceRanged = true; } return false; } diff --git a/Items/Weapons/Ranged/StarSputter.cs b/Items/Weapons/Ranged/StarSputter.cs index 0f3ca2af5f..b48a29f7c5 100644 --- a/Items/Weapons/Ranged/StarSputter.cs +++ b/Items/Weapons/Ranged/StarSputter.cs @@ -8,14 +8,14 @@ namespace CalamityMod.Items.Weapons.Ranged { public class StarSputter : ModItem { - private int counter = 0; + private int counter = 0; public override void SetStaticDefaults() { DisplayName.SetDefault("Star Sputter"); Tooltip.SetDefault("Fires a chain of comets\n" + - "Fires a bigger, more powerful comet every four rounds\n" + - "Look to the stars for a galaxy far, far away"); + "Fires a bigger, more powerful comet every four rounds\n" + + "Look to the stars for a galaxy far, far away"); } public override void SetDefaults() @@ -53,12 +53,12 @@ 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) { - counter++; + counter++; if (counter == 10) { Projectile.NewProjectile(position.X, position.Y, speedX * 0.8f, speedY * 0.8f, ModContent.ProjectileType(), (int)(damage * 1.5f), knockBack, player.whoAmI, 0f, 0f); } - if (counter >= 12) + if (counter >= 12) counter = 0; return true; } diff --git a/Items/Weapons/Ranged/StormDragoon.cs b/Items/Weapons/Ranged/StormDragoon.cs index bb848061a3..8afe54e6ba 100644 --- a/Items/Weapons/Ranged/StormDragoon.cs +++ b/Items/Weapons/Ranged/StormDragoon.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Storm Dragoon"); Tooltip.SetDefault("Fires a spray of bullets\n" + - "90% chance to not consume ammo"); + "90% chance to not consume ammo"); } public override void SetDefaults() @@ -26,16 +26,16 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 3.25f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item31; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item31; item.autoReuse = true; item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 18f; item.useAmmo = AmmoID.Bullet; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { diff --git a/Items/Weapons/Ranged/TelluricGlare.cs b/Items/Weapons/Ranged/TelluricGlare.cs index abdf89fff4..739e9290ac 100644 --- a/Items/Weapons/Ranged/TelluricGlare.cs +++ b/Items/Weapons/Ranged/TelluricGlare.cs @@ -36,8 +36,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 18f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() => new Vector2(-14f, 0f); diff --git a/Items/Weapons/Ranged/TheBallista.cs b/Items/Weapons/Ranged/TheBallista.cs index 346e55e7e0..530d0a6f2f 100644 --- a/Items/Weapons/Ranged/TheBallista.cs +++ b/Items/Weapons/Ranged/TheBallista.cs @@ -32,17 +32,17 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ModContent.ProjectileType(); item.shootSpeed = 20f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { - if (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.WoodenArrowFriendly) + Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + else + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - return false; + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/TheHive.cs b/Items/Weapons/Ranged/TheHive.cs index 426ca03c28..7342831ce4 100644 --- a/Items/Weapons/Ranged/TheHive.cs +++ b/Items/Weapons/Ranged/TheHive.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("The Hive"); Tooltip.SetDefault("Launches a variety of rockets that explode into bees on death\n" + - "Rockets will destroy tiles with tile-destroying ammo"); + "Rockets will destroy tiles with tile-destroying ammo"); } public override void SetDefaults() diff --git a/Items/Weapons/Ranged/TheMaelstrom.cs b/Items/Weapons/Ranged/TheMaelstrom.cs index cefac1bddb..2c8a58dfb4 100644 --- a/Items/Weapons/Ranged/TheMaelstrom.cs +++ b/Items/Weapons/Ranged/TheMaelstrom.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class TheMaelstrom : ModItem + public class TheMaelstrom : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Ranged/TheStorm.cs b/Items/Weapons/Ranged/TheStorm.cs index 21453f6289..db94a77d51 100644 --- a/Items/Weapons/Ranged/TheStorm.cs +++ b/Items/Weapons/Ranged/TheStorm.cs @@ -27,10 +27,10 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 3.5f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item122; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item122; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 28f; diff --git a/Items/Weapons/Ranged/TitaniumRailgun.cs b/Items/Weapons/Ranged/TitaniumRailgun.cs index 86fb0cd8d0..e8e2e65b88 100644 --- a/Items/Weapons/Ranged/TitaniumRailgun.cs +++ b/Items/Weapons/Ranged/TitaniumRailgun.cs @@ -40,8 +40,8 @@ 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) { - Vector2 velocity = Vector2.Normalize(new Vector2(speedX, speedY)); - velocity *= item.shootSpeed; + Vector2 velocity = Vector2.Normalize(new Vector2(speedX, speedY)); + velocity *= item.shootSpeed; Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); return false; } diff --git a/Items/Weapons/Ranged/Toxibow.cs b/Items/Weapons/Ranged/Toxibow.cs index c76bc20bda..15db136023 100644 --- a/Items/Weapons/Ranged/Toxibow.cs +++ b/Items/Weapons/Ranged/Toxibow.cs @@ -33,17 +33,17 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 15f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = 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) { - if (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, 0f, player.whoAmI); - else - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (type == ProjectileID.WoodenArrowFriendly) + Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, 0f, player.whoAmI); + else + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - return false; + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/Triploon.cs b/Items/Weapons/Ranged/Triploon.cs index c867012af2..3bd5c23094 100644 --- a/Items/Weapons/Ranged/Triploon.cs +++ b/Items/Weapons/Ranged/Triploon.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.autoReuse = true; item.shootSpeed = 20f; item.shoot = ModContent.ProjectileType(); - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override Vector2? HoldoutOffset() { @@ -43,23 +43,23 @@ 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) { - Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true); - float piOverTen = MathHelper.Pi * 0.1f; - int projCount = 3; - Vector2 velocity = new Vector2(speedX, speedY); - velocity.Normalize(); - velocity *= 30f; - bool canHit = Collision.CanHit(source, 0, 0, source + velocity, 0, 0); - for (int projIndex = 0; projIndex < projCount; projIndex++) - { - float num120 = projIndex - (projCount - 1f) / 2f; - Vector2 offset = velocity.RotatedBy(piOverTen * num120); - if (!canHit) - { - offset -= velocity; - } - Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - } + Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true); + float piOverTen = MathHelper.Pi * 0.1f; + int projCount = 3; + Vector2 velocity = new Vector2(speedX, speedY); + velocity.Normalize(); + velocity *= 30f; + bool canHit = Collision.CanHit(source, 0, 0, source + velocity, 0, 0); + for (int projIndex = 0; projIndex < projCount; projIndex++) + { + float num120 = projIndex - (projCount - 1f) / 2f; + Vector2 offset = velocity.RotatedBy(piOverTen * num120); + if (!canHit) + { + offset -= velocity; + } + Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + } return false; } diff --git a/Items/Weapons/Ranged/TrueConferenceCall.cs b/Items/Weapons/Ranged/TrueConferenceCall.cs index b9ea53f44e..7e29994d07 100644 --- a/Items/Weapons/Ranged/TrueConferenceCall.cs +++ b/Items/Weapons/Ranged/TrueConferenceCall.cs @@ -5,13 +5,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class TrueConferenceCall : ModItem + public class TrueConferenceCall : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Conference Call"); Tooltip.SetDefault("@everyone\n" + - "50% chance to not consume ammo"); + "50% chance to not consume ammo"); } public override void SetDefaults() @@ -26,29 +26,29 @@ namespace CalamityMod.Items.Weapons.Ranged item.noMelee = true; item.knockBack = 4.5f; item.value = CalamityGlobalItem.Rarity9BuyPrice; - item.rare = ItemRarityID.Cyan; + item.rare = ItemRarityID.Cyan; item.UseSound = SoundID.Item38; item.autoReuse = true; item.shootSpeed = 12f; item.shoot = ProjectileID.PurificationPowder; item.useAmmo = AmmoID.Bullet; - } + } public override Vector2? HoldoutOffset() { return new Vector2(-10, 0); } - public override bool ConsumeAmmo(Player player) - { - if (Main.rand.Next(0, 100) < 50) - return false; - return 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) + public override bool ConsumeAmmo(Player player) { - Vector2 velocity = new Vector2(speedX, speedY); + if (Main.rand.Next(0, 100) < 50) + return false; + return 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) + { + Vector2 velocity = new Vector2(speedX, speedY); int bulletAmt = 4; for (int index = 0; index < bulletAmt; ++index) { @@ -58,33 +58,33 @@ namespace CalamityMod.Items.Weapons.Ranged Main.projectile[proj].extraUpdates += 2; } - int maxTargets = 12; - int[] targets = new int[maxTargets]; - int targetArrayIndex = 0; - Rectangle rectangle = new Rectangle((int)player.Center.X - 960, (int)player.Center.Y - 540, 1920, 1080); - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.active && npc.chaseable && npc.lifeMax > 5 && !npc.dontTakeDamage && !npc.friendly && !npc.immortal) - { - if (npc.Hitbox.Intersects(rectangle)) - { - if (targetArrayIndex < maxTargets) - { - targets[targetArrayIndex] = i; - targetArrayIndex++; - } - else - break; - } - } - } + int maxTargets = 12; + int[] targets = new int[maxTargets]; + int targetArrayIndex = 0; + Rectangle rectangle = new Rectangle((int)player.Center.X - 960, (int)player.Center.Y - 540, 1920, 1080); + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.active && npc.chaseable && npc.lifeMax > 5 && !npc.dontTakeDamage && !npc.friendly && !npc.immortal) + { + if (npc.Hitbox.Intersects(rectangle)) + { + if (targetArrayIndex < maxTargets) + { + targets[targetArrayIndex] = i; + targetArrayIndex++; + } + else + break; + } + } + } - if (targetArrayIndex == 0) - return false; + if (targetArrayIndex == 0) + return false; Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - int extraBulletDamage = (int)(damage * 0.7); + int extraBulletDamage = (int)(damage * 0.7); for (int j = 0; j < targetArrayIndex; j++) { @@ -92,45 +92,45 @@ namespace CalamityMod.Items.Weapons.Ranged vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); vector2.Y -= 100 * j; - Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[j]].Center - vector2) * item.shootSpeed; + Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[j]].Center - vector2) * item.shootSpeed; - int proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); + int proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); Main.projectile[proj].extraUpdates += 2; - Main.projectile[proj].tileCollide = false; - Main.projectile[proj].timeLeft /= 2; + Main.projectile[proj].tileCollide = false; + Main.projectile[proj].timeLeft /= 2; } - if (targetArrayIndex == 12) - return false; + if (targetArrayIndex == 12) + return false; - // Fire bullets at the same targets if 12 unique targets aren't found - for (int k = 0; k < maxTargets - targetArrayIndex; k++) - { - int randomTarget = Main.rand.Next(targetArrayIndex); + // Fire bullets at the same targets if 12 unique targets aren't found + for (int k = 0; k < maxTargets - targetArrayIndex; k++) + { + int randomTarget = Main.rand.Next(targetArrayIndex); - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100 * randomTarget; + vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + vector2.Y -= 100 * randomTarget; - Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * item.shootSpeed; + Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * item.shootSpeed; - int proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); - Main.projectile[proj].extraUpdates += 2; - Main.projectile[proj].tileCollide = false; - Main.projectile[proj].timeLeft /= 2; - } + int proj = Projectile.NewProjectile(vector2, velocity2, type, extraBulletDamage, knockBack, player.whoAmI); + Main.projectile[proj].extraUpdates += 2; + Main.projectile[proj].tileCollide = false; + Main.projectile[proj].timeLeft /= 2; + } return false; } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.TacticalShotgun); - recipe.AddIngredient(ItemID.FragmentVortex, 7); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.TacticalShotgun); + recipe.AddIngredient(ItemID.FragmentVortex, 7); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/TyrannysEnd.cs b/Items/Weapons/Ranged/TyrannysEnd.cs index 3cc474a04a..c75bbe04e5 100644 --- a/Items/Weapons/Ranged/TyrannysEnd.cs +++ b/Items/Weapons/Ranged/TyrannysEnd.cs @@ -8,60 +8,60 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class TyrannysEnd : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tyranny's End"); - Tooltip.SetDefault("Pierce the heart of even the most heavily-armored foe\n" + - "Fires a .70 caliber sniper round that bypasses enemy defense and DR\n" + - "Rounds mark enemies for death and summon a swarm of additional bullets on crits"); - } + public class TyrannysEnd : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tyranny's End"); + Tooltip.SetDefault("Pierce the heart of even the most heavily-armored foe\n" + + "Fires a .70 caliber sniper round that bypasses enemy defense and DR\n" + + "Rounds mark enemies for death and summon a swarm of additional bullets on crits"); + } - public override void SetDefaults() - { - item.damage = 2250; - item.knockBack = 9.5f; - item.ranged = true; - item.useTime = 55; - item.useAnimation = 55; - item.shoot = ProjectileID.BulletHighVelocity; - item.shootSpeed = 12f; - item.useAmmo = AmmoID.Bullet; - item.autoReuse = true; + public override void SetDefaults() + { + item.damage = 2250; + item.knockBack = 9.5f; + item.ranged = true; + item.useTime = 55; + item.useAnimation = 55; + item.shoot = ProjectileID.BulletHighVelocity; + item.shootSpeed = 12f; + item.useAmmo = AmmoID.Bullet; + item.autoReuse = true; - item.width = 94; - item.height = 32; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"); + item.width = 94; + item.height = 32; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"); - item.value = CalamityGlobalItem.Rarity15BuyPrice; - item.Calamity().customRarity = CalamityRarity.Violet; - item.Calamity().donorItem = true; - item.Calamity().canFirePointBlankShots = true; - } + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.Calamity().customRarity = CalamityRarity.Violet; + item.Calamity().donorItem = true; + item.Calamity().canFirePointBlankShots = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 35; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 35; - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override Vector2? HoldoutOffset() => new Vector2(-10, 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(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } - 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - return false; - } - } + 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + } } diff --git a/Items/Weapons/Ranged/UniversalGenesis.cs b/Items/Weapons/Ranged/UniversalGenesis.cs index f07f417de5..507afacced 100644 --- a/Items/Weapons/Ranged/UniversalGenesis.cs +++ b/Items/Weapons/Ranged/UniversalGenesis.cs @@ -10,113 +10,113 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class UniversalGenesis : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Universal Genesis"); - Tooltip.SetDefault("Let the starry sky fall upon your enemies\n" + - "Fires a spread of bullets from the gun and a flurry of stars to rain down on the cursor\n" + - "Converts musket balls into starcaller shots that summon additional stars on enemy hits\n" + - "50% chance to not consume ammo"); - } + public class UniversalGenesis : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Universal Genesis"); + Tooltip.SetDefault("Let the starry sky fall upon your enemies\n" + + "Fires a spread of bullets from the gun and a flurry of stars to rain down on the cursor\n" + + "Converts musket balls into starcaller shots that summon additional stars on enemy hits\n" + + "50% chance to not consume ammo"); + } - public override void SetDefaults() - { - item.damage = 192; - item.ranged = true; - item.useTime = item.useAnimation = 26; - item.knockBack = 6.5f; - item.useAmmo = AmmoID.Bullet; - item.shoot = ProjectileID.Bullet; - item.shootSpeed = 20f; - item.autoReuse = true; - item.Calamity().canFirePointBlankShots = true; + public override void SetDefaults() + { + item.damage = 192; + item.ranged = true; + item.useTime = item.useAnimation = 26; + item.knockBack = 6.5f; + item.useAmmo = AmmoID.Bullet; + item.shoot = ProjectileID.Bullet; + item.shootSpeed = 20f; + item.autoReuse = true; + item.Calamity().canFirePointBlankShots = true; - item.width = 158; - item.height = 60; - item.noMelee = true; - item.UseSound = SoundID.Item38; - item.useStyle = ItemUseStyleID.HoldingOut; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.Calamity().donorItem = true; - item.Calamity().canFirePointBlankShots = true; - } + item.width = 158; + item.height = 60; + item.noMelee = true; + item.UseSound = SoundID.Item38; + item.useStyle = ItemUseStyleID.HoldingOut; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.Calamity().donorItem = true; + item.Calamity().canFirePointBlankShots = true; + } - public override Vector2? HoldoutOffset() => new Vector2(-50f, -8f); + public override Vector2? HoldoutOffset() => new Vector2(-50f, -8f); - 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 shootVelocity = new Vector2(speedX, speedY); - Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction); - Vector2 gunTip = position + shootDirection * item.scale * 100f; - gunTip.Y -= 10f; - float tightness = 1f; - if (type == ProjectileID.Bullet) - type = ModContent.ProjectileType(); - for (float i = -tightness * 5f; i <= tightness * 5f; i += tightness * 2f) - { - Vector2 perturbedSpeed = shootVelocity.RotatedBy(MathHelper.ToRadians(i)); - Projectile.NewProjectile(gunTip, perturbedSpeed, type, damage, knockBack, player.whoAmI); - } + 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 shootVelocity = new Vector2(speedX, speedY); + Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction); + Vector2 gunTip = position + shootDirection * item.scale * 100f; + gunTip.Y -= 10f; + float tightness = 1f; + if (type == ProjectileID.Bullet) + type = ModContent.ProjectileType(); + for (float i = -tightness * 5f; i <= tightness * 5f; i += tightness * 2f) + { + Vector2 perturbedSpeed = shootVelocity.RotatedBy(MathHelper.ToRadians(i)); + Projectile.NewProjectile(gunTip, perturbedSpeed, type, damage, knockBack, player.whoAmI); + } - // Stars from above - float speed = item.shootSpeed; - Vector2 spawnPos = player.RotatedRelativePoint(player.MountedCenter, true); - int starAmt = 6; - int starDmg = (int)(damage * 0.4); - for (int i = 0; i < starAmt; i++) - { - spawnPos = new Vector2(player.Center.X + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - spawnPos.X = (spawnPos.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - spawnPos.Y -= 100 + i; - float xDist = Main.mouseX + Main.screenPosition.X - spawnPos.X; - float yDist = Main.mouseY + Main.screenPosition.Y - spawnPos.Y; - if (yDist < 0f) - { - yDist *= -1f; - } - if (yDist < 20f) - { - yDist = 20f; - } - float travelDist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - travelDist = speed / travelDist; - xDist *= travelDist; - yDist *= travelDist; - float xVel = xDist + Main.rand.NextFloat(-0.6f, 0.6f); - float yVel = yDist + Main.rand.NextFloat(-0.6f, 0.6f); - int star = Projectile.NewProjectile(spawnPos.X, spawnPos.Y, xVel, yVel, ModContent.ProjectileType(), starDmg, knockBack, player.whoAmI, i, 1f); - Main.projectile[star].extraUpdates = 2; - Main.projectile[star].localNPCHitCooldown = 30; - } - return false; - } + // Stars from above + float speed = item.shootSpeed; + Vector2 spawnPos = player.RotatedRelativePoint(player.MountedCenter, true); + int starAmt = 6; + int starDmg = (int)(damage * 0.4); + for (int i = 0; i < starAmt; i++) + { + spawnPos = new Vector2(player.Center.X + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + spawnPos.X = (spawnPos.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + spawnPos.Y -= 100 + i; + float xDist = Main.mouseX + Main.screenPosition.X - spawnPos.X; + float yDist = Main.mouseY + Main.screenPosition.Y - spawnPos.Y; + if (yDist < 0f) + { + yDist *= -1f; + } + if (yDist < 20f) + { + yDist = 20f; + } + float travelDist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); + travelDist = speed / travelDist; + xDist *= travelDist; + yDist *= travelDist; + float xVel = xDist + Main.rand.NextFloat(-0.6f, 0.6f); + float yVel = yDist + Main.rand.NextFloat(-0.6f, 0.6f); + int star = Projectile.NewProjectile(spawnPos.X, spawnPos.Y, xVel, yVel, ModContent.ProjectileType(), starDmg, knockBack, player.whoAmI, i, 1f); + Main.projectile[star].extraUpdates = 2; + Main.projectile[star].localNPCHitCooldown = 30; + } + return false; + } - public override bool ConsumeAmmo(Player player) => Main.rand.NextBool(); + public override bool ConsumeAmmo(Player player) => Main.rand.NextBool(); - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.StarCloak, 3); // and that's how you know it's a donor item - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - // but why - recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.StarCloak, 3); // and that's how you know it's a donor item - recipe.AddIngredient(ModContent.ItemType(), 2); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.StarCloak, 3); // and that's how you know it's a donor item + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + // but why + recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.StarCloak, 3); // and that's how you know it's a donor item + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/WulfrumBow.cs b/Items/Weapons/Ranged/WulfrumBow.cs index 0d62042ba2..ea6ea2de5a 100644 --- a/Items/Weapons/Ranged/WulfrumBow.cs +++ b/Items/Weapons/Ranged/WulfrumBow.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.shoot = ProjectileID.PurificationPowder; item.shootSpeed = 12f; item.useAmmo = AmmoID.Arrow; - item.Calamity().canFirePointBlankShots = true; - } + item.Calamity().canFirePointBlankShots = true; + } public override void AddRecipes() { diff --git a/Items/Weapons/Rogue/AccretionDisk.cs b/Items/Weapons/Rogue/AccretionDisk.cs index ecb0466b2b..10fc56876b 100644 --- a/Items/Weapons/Rogue/AccretionDisk.cs +++ b/Items/Weapons/Rogue/AccretionDisk.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Elemental Disk"); Tooltip.SetDefault("Throws a disk that has a chance to generate several disks if enemies are near it\n" + - "Stealth strikes fly slower but travel farther, pierce through enemies, and spawn extra disks more frequently"); + "Stealth strikes fly slower but travel farther, pierce through enemies, and spawn extra disks more frequently"); } public override void SafeSetDefaults() @@ -29,28 +29,28 @@ namespace CalamityMod.Items.Weapons.Rogue item.knockBack = 9f; item.UseSound = SoundID.Item1; item.height = 38; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 13f; item.Calamity().rogue = 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) { - if (player.Calamity().StealthStrikeAvailable()) - { - speedX *= 0.7f; - speedY *= 0.7f; - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().stealthStrike = true; - Main.projectile[proj].timeLeft *= 3; - Main.projectile[proj].localNPCHitCooldown *= 2; - } - return false; - } + if (player.Calamity().StealthStrikeAvailable()) + { + speedX *= 0.7f; + speedY *= 0.7f; + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().stealthStrike = true; + Main.projectile[proj].timeLeft *= 3; + Main.projectile[proj].localNPCHitCooldown *= 2; + } + return false; + } return true; } diff --git a/Items/Weapons/Rogue/AcidicRainBarrel.cs b/Items/Weapons/Rogue/AcidicRainBarrel.cs index f742dc62ba..a2c36d4323 100644 --- a/Items/Weapons/Rogue/AcidicRainBarrel.cs +++ b/Items/Weapons/Rogue/AcidicRainBarrel.cs @@ -41,8 +41,8 @@ namespace CalamityMod.Items.Weapons.Rogue Vector2 initialVelocity = new Vector2(speedX, speedY); int p = Projectile.NewProjectile(position - Vector2.UnitY * 12f, initialVelocity, type, damage, knockBack, player.whoAmI); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } public override void AddRecipes() diff --git a/Items/Weapons/Rogue/AdamantiteThrowingAxe.cs b/Items/Weapons/Rogue/AdamantiteThrowingAxe.cs index 22412bd062..da5343961b 100644 --- a/Items/Weapons/Rogue/AdamantiteThrowingAxe.cs +++ b/Items/Weapons/Rogue/AdamantiteThrowingAxe.cs @@ -37,17 +37,17 @@ 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) { - if (player.Calamity().StealthStrikeAvailable()) - { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; - } - return false; - } - return true; + if (player.Calamity().StealthStrikeAvailable()) + { + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } + return false; + } + return true; } public override void AddRecipes() diff --git a/Items/Weapons/Rogue/Apoctolith.cs b/Items/Weapons/Rogue/Apoctolith.cs index 50c77b4602..5760d02d8e 100644 --- a/Items/Weapons/Rogue/Apoctolith.cs +++ b/Items/Weapons/Rogue/Apoctolith.cs @@ -9,67 +9,67 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class Apoctolith : RogueWeapon - { - public override void SetStaticDefaults() - { - Tooltip.SetDefault("Maybe catching bricks with your face isn't such a hot idea...\n" + - "Critical hits tear away enemy defense\n" + - "Stealth strikes shatter and briefly stun enemies"); - DisplayName.SetDefault("Apoctolith"); - } + public class Apoctolith : RogueWeapon + { + public override void SetStaticDefaults() + { + Tooltip.SetDefault("Maybe catching bricks with your face isn't such a hot idea...\n" + + "Critical hits tear away enemy defense\n" + + "Stealth strikes shatter and briefly stun enemies"); + DisplayName.SetDefault("Apoctolith"); + } - public override void SafeSetDefaults() - { - item.damage = 120; - item.shootSpeed = 15f; - item.shoot = ModContent.ProjectileType(); - item.width = 66; - item.height = 64; - item.useTime = 24; - item.useAnimation = 24; - item.useStyle = ItemUseStyleID.SwingThrow; - item.knockBack = 10f; - item.value = CalamityGlobalItem.Rarity7BuyPrice; - item.rare = ItemRarityID.Lime; - item.UseSound = SoundID.Item1; - item.noMelee = true; - item.noUseGraphic = true; - item.Calamity().rogue = true; - item.autoReuse = true; - } + public override void SafeSetDefaults() + { + item.damage = 120; + item.shootSpeed = 15f; + item.shoot = ModContent.ProjectileType(); + item.width = 66; + item.height = 64; + item.useTime = 24; + item.useAnimation = 24; + item.useStyle = ItemUseStyleID.SwingThrow; + item.knockBack = 10f; + item.value = CalamityGlobalItem.Rarity7BuyPrice; + item.rare = ItemRarityID.Lime; + item.UseSound = SoundID.Item1; + item.noMelee = true; + item.noUseGraphic = true; + item.Calamity().rogue = true; + item.autoReuse = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - //Check if stealth is full - if (player.Calamity().StealthStrikeAvailable()) - { - int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)(damage * 1.25f), knockBack, player.whoAmI); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; - return false; - } - return 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) + { + //Check if stealth is full + if (player.Calamity().StealthStrikeAvailable()) + { + int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)(damage * 1.25f), knockBack, player.whoAmI); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; + return false; + } + return true; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 100); - recipe.AddIngredient(ModContent.ItemType(), 20); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 100); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/ApoctolithGlow")); - } - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/ApoctolithGlow")); + } + } } diff --git a/Items/Weapons/Rogue/AshenStalactite.cs b/Items/Weapons/Rogue/AshenStalactite.cs index e73b043d3d..4860f2b041 100644 --- a/Items/Weapons/Rogue/AshenStalactite.cs +++ b/Items/Weapons/Rogue/AshenStalactite.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.shoot = ModContent.ProjectileType(); item.shootSpeed = 15f; item.Calamity().rogue = 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) { @@ -45,8 +45,8 @@ namespace CalamityMod.Items.Weapons.Rogue float stealthDamageMult = 1.15f; float stealthKnockbackMult = 2.5f; int p = Projectile.NewProjectile(position.X, position.Y, speedX * stealthSpeedMult, speedY * stealthSpeedMult, stealthType, (int)(damage * stealthDamageMult), (int)(knockBack * stealthKnockbackMult), player.whoAmI, 0f, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/AuroradicalThrow.cs b/Items/Weapons/Rogue/AuroradicalThrow.cs index f3a1b695be..05cc49b363 100644 --- a/Items/Weapons/Rogue/AuroradicalThrow.cs +++ b/Items/Weapons/Rogue/AuroradicalThrow.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Auroradical Throw"); Tooltip.SetDefault("Launches a star that splits after a short period of time\n" + - "Split stars home in on nearby enemies after a few seconds\n" + - "Stealth strikes summon a meteor upon enemy impact"); + "Split stars home in on nearby enemies after a few seconds\n" + + "Stealth strikes summon a meteor upon enemy impact"); } public override void SafeSetDefaults() @@ -42,15 +42,15 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) damage = (int)(damage * 1.2f); - int star = Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (star.WithinBounds(Main.maxProjectiles)) - Main.projectile[star].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int star = Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (star.WithinBounds(Main.maxProjectiles)) + Main.projectile[star].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, Main.itemTexture[item.type]); + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, Main.itemTexture[item.type]); } } } diff --git a/Items/Weapons/Rogue/BallisticPoisonBomb.cs b/Items/Weapons/Rogue/BallisticPoisonBomb.cs index 16e6c9fc34..d9a0b82c6f 100644 --- a/Items/Weapons/Rogue/BallisticPoisonBomb.cs +++ b/Items/Weapons/Rogue/BallisticPoisonBomb.cs @@ -9,13 +9,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class BallisticPoisonBomb : RogueWeapon + public class BallisticPoisonBomb : RogueWeapon { public override void SetStaticDefaults() { DisplayName.SetDefault("Ballistic Poison Bomb"); Tooltip.SetDefault("Throws a sticky bomb that explodes into spikes and poison clouds\n" + - "Stealth strikes throw three at once"); + "Stealth strikes throw three at once"); } public override void SafeSetDefaults() @@ -47,8 +47,8 @@ namespace CalamityMod.Items.Weapons.Rogue { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread)); int proj = Projectile.NewProjectile(position, perturbedspeed, type, Math.Max(damage / 3, 1), knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; spread -= Main.rand.Next(2,6); } return false; diff --git a/Items/Weapons/Rogue/BlazingStar.cs b/Items/Weapons/Rogue/BlazingStar.cs index c7abf343cb..4856d6e514 100644 --- a/Items/Weapons/Rogue/BlazingStar.cs +++ b/Items/Weapons/Rogue/BlazingStar.cs @@ -38,8 +38,8 @@ namespace CalamityMod.Items.Weapons.Rogue item.shoot = ModContent.ProjectileType(); } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -53,15 +53,15 @@ namespace CalamityMod.Items.Weapons.Rogue { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-MathHelper.ToRadians(8f), MathHelper.ToRadians(8f), i / (float)(item.stack - 1))); Projectile proj = Projectile.NewProjectileDirect(position, perturbedSpeed, type, damage, knockBack, player.whoAmI); - if (proj.whoAmI.WithinBounds(Main.maxProjectiles)) - proj.Calamity().stealthStrike = true; + if (proj.whoAmI.WithinBounds(Main.maxProjectiles)) + proj.Calamity().stealthStrike = true; Projectile projectile = Projectile.NewProjectileDirect(position, perturbedSpeed, type, damage, knockBack, player.whoAmI); - if (projectile.whoAmI.WithinBounds(Main.maxProjectiles)) - { - projectile.penetrate = -1; - projectile.Calamity().stealthStrike = true; - } + if (projectile.whoAmI.WithinBounds(Main.maxProjectiles)) + { + projectile.penetrate = -1; + projectile.Calamity().stealthStrike = true; + } } return false; diff --git a/Items/Weapons/Rogue/BloodsoakedCrasher.cs b/Items/Weapons/Rogue/BloodsoakedCrasher.cs index fbfc79c7d6..90f87a74ca 100644 --- a/Items/Weapons/Rogue/BloodsoakedCrasher.cs +++ b/Items/Weapons/Rogue/BloodsoakedCrasher.cs @@ -7,53 +7,53 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class BloodsoakedCrasher : RogueWeapon //This weapon has been coded by Ben || Termi - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bloodsoaked Crasher"); - Tooltip.SetDefault("Slows down when hitting an enemy. Speeds up otherwise\n" + - "Heals on enemy hits\n" + - "Stealth strikes spawn homing blood on enemy hits"); - } + public class BloodsoakedCrasher : RogueWeapon //This weapon has been coded by Ben || Termi + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bloodsoaked Crasher"); + Tooltip.SetDefault("Slows down when hitting an enemy. Speeds up otherwise\n" + + "Heals on enemy hits\n" + + "Stealth strikes spawn homing blood on enemy hits"); + } - public override void SafeSetDefaults() - { - item.damage = 245; - item.knockBack = 3f; - item.autoReuse = true; - item.Calamity().rogue = true; - item.useAnimation = item.useTime = 24; - item.shootSpeed = 9f; - item.shoot = ModContent.ProjectileType(); + public override void SafeSetDefaults() + { + item.damage = 245; + item.knockBack = 3f; + item.autoReuse = true; + item.Calamity().rogue = true; + item.useAnimation = item.useTime = 24; + item.shootSpeed = 9f; + item.shoot = ModContent.ProjectileType(); - item.width = 66; - item.height = 64; - item.noMelee = true; - item.noUseGraphic = true; - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.width = 66; + item.height = 64; + item.noMelee = true; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } - 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, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - return false; - } + 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, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/BouncingEyeball.cs b/Items/Weapons/Rogue/BouncingEyeball.cs index e4842ad5af..d0743247df 100644 --- a/Items/Weapons/Rogue/BouncingEyeball.cs +++ b/Items/Weapons/Rogue/BouncingEyeball.cs @@ -46,8 +46,8 @@ namespace CalamityMod.Items.Weapons.Rogue { initialVelocity *= 2f; int p = Projectile.NewProjectile(position, initialVelocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; } else { diff --git a/Items/Weapons/Rogue/BouncySpikyBall.cs b/Items/Weapons/Rogue/BouncySpikyBall.cs index 1d1dc2d57d..b56c1aa236 100644 --- a/Items/Weapons/Rogue/BouncySpikyBall.cs +++ b/Items/Weapons/Rogue/BouncySpikyBall.cs @@ -28,8 +28,8 @@ Stealth strikes provide a bigger boost after richocheting"); item.knockBack = 1f; item.UseSound = SoundID.Item1; item.autoReuse = true; - item.consumable = true; - item.maxStack = 999; + item.consumable = true; + item.maxStack = 999; item.height = 14; item.value = Item.buyPrice(0, 0, 1, 0); item.rare = ItemRarityID.Blue; @@ -43,8 +43,8 @@ Stealth strikes provide a bigger boost after richocheting"); if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/BrackishFlask.cs b/Items/Weapons/Rogue/BrackishFlask.cs index e34a9a68e2..856abca3ab 100644 --- a/Items/Weapons/Rogue/BrackishFlask.cs +++ b/Items/Weapons/Rogue/BrackishFlask.cs @@ -6,13 +6,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class BrackishFlask : RogueWeapon + public class BrackishFlask : RogueWeapon { public override void SetStaticDefaults() { DisplayName.SetDefault("Brackish Flask"); Tooltip.SetDefault("Explodes into poisonous seawater blasts\n" + - "Stealth strikes summon a brackish spear spike"); + "Stealth strikes summon a brackish spear spike"); } public override void SafeSetDefaults() @@ -40,8 +40,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 0.85f), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/Brimblade.cs b/Items/Weapons/Rogue/Brimblade.cs index 2ee7a022f4..5d24032ad3 100644 --- a/Items/Weapons/Rogue/Brimblade.cs +++ b/Items/Weapons/Rogue/Brimblade.cs @@ -8,13 +8,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class Brimblade : RogueWeapon + public class Brimblade : RogueWeapon { public override void SetStaticDefaults() { DisplayName.SetDefault("Brimblade"); Tooltip.SetDefault("Throws a blade that splits on enemy hits\n" + - "Stealth strikes split further and cause the player to launch a barrage of brimstone darts"); + "Stealth strikes split further and cause the player to launch a barrage of brimstone darts"); } public override void SafeSetDefaults() @@ -39,22 +39,22 @@ 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) { - if (player.Calamity().StealthStrikeAvailable()) - { - int blade = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (blade.WithinBounds(Main.maxProjectiles)) - Main.projectile[blade].Calamity().stealthStrike = true; + if (player.Calamity().StealthStrikeAvailable()) + { + int blade = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (blade.WithinBounds(Main.maxProjectiles)) + Main.projectile[blade].Calamity().stealthStrike = true; - for (int i = -6; i <= 6; i += 4) - { - Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - int dart = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage, knockBack * 0.5f, player.whoAmI); - if (dart.WithinBounds(Main.maxProjectiles)) - Main.projectile[dart].Calamity().forceRogue = true; - } - return false; - } - return true; + for (int i = -6; i <= 6; i += 4) + { + Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); + int dart = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage, knockBack * 0.5f, player.whoAmI); + if (dart.WithinBounds(Main.maxProjectiles)) + Main.projectile[dart].Calamity().forceRogue = true; + } + return false; + } + return true; } public override void AddRecipes() diff --git a/Items/Weapons/Rogue/BurningStrife.cs b/Items/Weapons/Rogue/BurningStrife.cs index 1c72194fb9..84a5bcbdc2 100644 --- a/Items/Weapons/Rogue/BurningStrife.cs +++ b/Items/Weapons/Rogue/BurningStrife.cs @@ -37,15 +37,15 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 8; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 8; 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 speedMult = 1f; if (player.Calamity().StealthStrikeAvailable()) - { - speedMult = 1.25f; + { + speedMult = 1.25f; damage = (int)(damage * 1.3f); } int proj = Projectile.NewProjectile(position, new Vector2(speedX * speedMult, speedY * speedMult), type, damage, knockBack, player.whoAmI); diff --git a/Items/Weapons/Rogue/Celestus.cs b/Items/Weapons/Rogue/Celestus.cs index 6a571f8c47..9eeb21e24a 100644 --- a/Items/Weapons/Rogue/Celestus.cs +++ b/Items/Weapons/Rogue/Celestus.cs @@ -8,58 +8,58 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class Celestus : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Celestus"); - Tooltip.SetDefault("Throws a scythe that splits into multiple scythes on enemy hits\n" + - "Stealth strikes reverse direction and home in on enemies after returning to the player"); - } + public class Celestus : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Celestus"); + Tooltip.SetDefault("Throws a scythe that splits into multiple scythes on enemy hits\n" + + "Stealth strikes reverse direction and home in on enemies after returning to the player"); + } - public override void SafeSetDefaults() - { - item.damage = 280; - item.knockBack = 6f; - item.useAnimation = item.useTime = 22; - item.Calamity().rogue = true; - item.autoReuse = true; - item.shootSpeed = 25f; - item.shoot = ModContent.ProjectileType(); + public override void SafeSetDefaults() + { + item.damage = 280; + item.knockBack = 6f; + item.useAnimation = item.useTime = 22; + item.Calamity().rogue = true; + item.autoReuse = true; + item.shootSpeed = 25f; + item.shoot = ModContent.ProjectileType(); - item.width = item.height = 20; - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.noMelee = true; - item.noUseGraphic = true; - item.value = CalamityGlobalItem.Rarity15BuyPrice; - item.rare = ItemRarityID.Red; - item.Calamity().customRarity = CalamityRarity.Violet; - } + item.width = item.height = 20; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.noMelee = true; + item.noUseGraphic = true; + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.Violet; + } - 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()) //setting the stealth strike - { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 0.4), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - } - return 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) + { + if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike + { + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 0.4), knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + } + return true; + } - 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.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + 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.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/Cinquedea.cs b/Items/Weapons/Rogue/Cinquedea.cs index 502a3e6f14..d72772bf9e 100644 --- a/Items/Weapons/Rogue/Cinquedea.cs +++ b/Items/Weapons/Rogue/Cinquedea.cs @@ -38,16 +38,16 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 8; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 8; 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()) { int p = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ConsecratedWater.cs b/Items/Weapons/Rogue/ConsecratedWater.cs index 6b7734562e..ec0e3526fb 100644 --- a/Items/Weapons/Rogue/ConsecratedWater.cs +++ b/Items/Weapons/Rogue/ConsecratedWater.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Consecrated Water"); Tooltip.SetDefault("The bottle is surprisingly dusty\n" + - "Throws a holy flask of water that explodes into a sacred flame pillar on death\n" + + "Throws a holy flask of water that explodes into a sacred flame pillar on death\n" + "The pillar is destroyed if there's no tiles below it\n" + "Stealth strikes create three flame pillars instead of one on impact"); } @@ -53,8 +53,8 @@ namespace CalamityMod.Items.Weapons.Rogue { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.HolyWater, 100); - recipe.AddRecipeGroup("AnyAdamantiteBar", 5); - recipe.AddIngredient(ItemID.CrystalShard, 10); + recipe.AddRecipeGroup("AnyAdamantiteBar", 5); + recipe.AddIngredient(ItemID.CrystalShard, 10); recipe.AddIngredient(ItemID.SoulofLight, 7); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); diff --git a/Items/Weapons/Rogue/ContaminatedBile.cs b/Items/Weapons/Rogue/ContaminatedBile.cs index 48ffaac962..f315d7b0e7 100644 --- a/Items/Weapons/Rogue/ContaminatedBile.cs +++ b/Items/Weapons/Rogue/ContaminatedBile.cs @@ -37,8 +37,8 @@ namespace CalamityMod.Items.Weapons.Rogue { Vector2 velocity = new Vector2(speedX, speedY); int p = Projectile.NewProjectile(position, velocity, type, damage, knockBack, player.whoAmI); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } public override void AddRecipes() diff --git a/Items/Weapons/Rogue/CorpusAvertor.cs b/Items/Weapons/Rogue/CorpusAvertor.cs index ba5ee592f6..825bb590c1 100644 --- a/Items/Weapons/Rogue/CorpusAvertor.cs +++ b/Items/Weapons/Rogue/CorpusAvertor.cs @@ -6,57 +6,57 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class CorpusAvertor : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Corpus Avertor"); - Tooltip.SetDefault("Seems like it has worn down over time\n" + - "Attacks grant lifesteal based on damage dealt\n" + - "The lower your HP the more damage this weapon does and heals the player on enemy hits\n" + - "Stealth strikes throw a single rainbow outlined dagger\n" + - "On enemy hits, this dagger boosts the damage and life regen of all members of your team\n" + - "However, there is a small chance it will cut your health in half instead"); - } + public class CorpusAvertor : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Corpus Avertor"); + Tooltip.SetDefault("Seems like it has worn down over time\n" + + "Attacks grant lifesteal based on damage dealt\n" + + "The lower your HP the more damage this weapon does and heals the player on enemy hits\n" + + "Stealth strikes throw a single rainbow outlined dagger\n" + + "On enemy hits, this dagger boosts the damage and life regen of all members of your team\n" + + "However, there is a small chance it will cut your health in half instead"); + } - public override void SafeSetDefaults() - { - item.width = 18; - item.height = 32; - item.damage = 98; - item.noMelee = true; - item.noUseGraphic = true; - item.useAnimation = 15; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 15; - item.knockBack = 3f; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.value = Item.buyPrice(gold: 80); - item.rare = ItemRarityID.Yellow; - item.Calamity().donorItem = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 8.5f; - item.Calamity().rogue = true; - } + public override void SafeSetDefaults() + { + item.width = 18; + item.height = 32; + item.damage = 98; + item.noMelee = true; + item.noUseGraphic = true; + item.useAnimation = 15; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = 15; + item.knockBack = 3f; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.value = Item.buyPrice(gold: 80); + item.rare = ItemRarityID.Yellow; + item.Calamity().donorItem = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 8.5f; + item.Calamity().rogue = true; + } - // Gains 10% of missing health as base damage. - public override void SafeModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) - { - int lifeAmount = player.statLifeMax2 - player.statLife; - flat += lifeAmount * 0.1f * player.RogueDamage(); - } + // Gains 10% of missing health as base damage. + public override void SafeModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) + { + int lifeAmount = player.statLifeMax2 - player.statLife; + flat += lifeAmount * 0.1f * player.RogueDamage(); + } - 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()) - { - int dagger = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), (int)(damage * 3.5f), knockBack * 2f, player.whoAmI); - if (dagger.WithinBounds(Main.maxProjectiles)) - Main.projectile[dagger].Calamity().stealthStrike = true; - return false; - } - return 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) + { + if (player.Calamity().StealthStrikeAvailable()) + { + int dagger = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), (int)(damage * 3.5f), knockBack * 2f, player.whoAmI); + if (dagger.WithinBounds(Main.maxProjectiles)) + Main.projectile[dagger].Calamity().stealthStrike = true; + return false; + } + return true; + } + } } diff --git a/Items/Weapons/Rogue/CosmicKunai.cs b/Items/Weapons/Rogue/CosmicKunai.cs index 23fb6214f9..13d9ac27e4 100644 --- a/Items/Weapons/Rogue/CosmicKunai.cs +++ b/Items/Weapons/Rogue/CosmicKunai.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Items.Weapons.Rogue { public class CosmicKunai : RogueWeapon { - private int counter = 0; + private int counter = 0; public override void SetStaticDefaults() { @@ -31,13 +31,13 @@ namespace CalamityMod.Items.Weapons.Rogue item.UseSound = SoundID.Item109; item.autoReuse = true; item.height = 48; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 28f; item.Calamity().rogue = 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) { @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable() && player.ownedProjectileCounts[ModContent.ProjectileType()] < 10 && counter == 0 && stealth.WithinBounds(Main.maxProjectiles)) { damage = (int)(damage * 3.21); - Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].Calamity().stealthStrike = true; Main.PlaySound(SoundID.Item73, player.position); for (float i = 0; i < 5; i++) { @@ -54,9 +54,9 @@ namespace CalamityMod.Items.Weapons.Rogue } } - counter++; - if (counter >= item.useAnimation / item.useTime) - counter = 0; + counter++; + if (counter >= item.useAnimation / item.useTime) + counter = 0; return false; } } diff --git a/Items/Weapons/Rogue/CraniumSmasher.cs b/Items/Weapons/Rogue/CraniumSmasher.cs index e6b20c1e8a..061b1ac8fe 100644 --- a/Items/Weapons/Rogue/CraniumSmasher.cs +++ b/Items/Weapons/Rogue/CraniumSmasher.cs @@ -6,55 +6,55 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class CraniumSmasher : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cranium Smasher"); - Tooltip.SetDefault("Throws disks that roll on the ground, occasionally launches an explosive disk\n" + - "Stealth strikes launch an explosive disk that can pierce several enemies"); - } + public class CraniumSmasher : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cranium Smasher"); + Tooltip.SetDefault("Throws disks that roll on the ground, occasionally launches an explosive disk\n" + + "Stealth strikes launch an explosive disk that can pierce several enemies"); + } - public override void SafeSetDefaults() - { - item.width = 50; - item.height = 50; - item.damage = 120; - item.noMelee = true; - item.noUseGraphic = true; - item.autoReuse = true; - item.useAnimation = 15; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 15; - item.knockBack = 4f; - item.UseSound = SoundID.Item1; - item.value = Item.buyPrice(0, 80, 0, 0); - item.rare = ItemRarityID.Yellow; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 20f; - item.Calamity().rogue = true; - } + public override void SafeSetDefaults() + { + item.width = 50; + item.height = 50; + item.damage = 120; + item.noMelee = true; + item.noUseGraphic = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = 15; + item.knockBack = 4f; + item.UseSound = SoundID.Item1; + item.value = Item.buyPrice(0, 80, 0, 0); + item.rare = ItemRarityID.Yellow; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 20f; + item.Calamity().rogue = 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) - { - if (player.Calamity().StealthStrikeAvailable()) - { - damage = (int)(damage * 1.75f); - type = ModContent.ProjectileType(); - } - else if (Main.rand.NextBool(5)) - { - damage = (int)(damage * 1.25f); - type = ModContent.ProjectileType(); - } - else - { - type = ModContent.ProjectileType(); - } - int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - return false; - } - } + 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()) + { + damage = (int)(damage * 1.75f); + type = ModContent.ProjectileType(); + } + else if (Main.rand.NextBool(5)) + { + damage = (int)(damage * 1.25f); + type = ModContent.ProjectileType(); + } + else + { + type = ModContent.ProjectileType(); + } + int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + return false; + } + } } diff --git a/Items/Weapons/Rogue/CrushsawCrasher.cs b/Items/Weapons/Rogue/CrushsawCrasher.cs index 633409e307..1b71f1c3a6 100644 --- a/Items/Weapons/Rogue/CrushsawCrasher.cs +++ b/Items/Weapons/Rogue/CrushsawCrasher.cs @@ -8,13 +8,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class CrushsawCrasher : RogueWeapon + public class CrushsawCrasher : RogueWeapon { public override void SetStaticDefaults() { DisplayName.SetDefault("Crushsaw Crasher"); Tooltip.SetDefault("Throws bouncing axes\n" + - "Stealth strikes throw five at once"); + "Stealth strikes throw five at once"); } public override void SafeSetDefaults() @@ -44,12 +44,12 @@ namespace CalamityMod.Items.Weapons.Rogue { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread)); int proj = Projectile.NewProjectile(position, perturbedspeed, type, Math.Max(damage / 5, 1), knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().stealthStrike = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 10; - } + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().stealthStrike = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 10; + } spread -= Main.rand.Next(1,4); } return false; diff --git a/Items/Weapons/Rogue/CrystalPiercer.cs b/Items/Weapons/Rogue/CrystalPiercer.cs index 78b38ddcb2..c639d66dde 100644 --- a/Items/Weapons/Rogue/CrystalPiercer.cs +++ b/Items/Weapons/Rogue/CrystalPiercer.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Crystal Piercer"); Tooltip.SetDefault("Throws a crystal javelin that pierces infinitely\n" + - "Stealth strikes travel through blocks, ignore gravity, and summon crystal shards as they fly"); + "Stealth strikes travel through blocks, ignore gravity, and summon crystal shards as they fly"); } public override void SafeSetDefaults() @@ -43,13 +43,13 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].aiStyle = -1; - Main.projectile[stealth].tileCollide = false; - Main.projectile[stealth].usesLocalNPCImmunity = true; - } + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].aiStyle = -1; + Main.projectile[stealth].tileCollide = false; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } return false; } return true; diff --git a/Items/Weapons/Rogue/Crystalline.cs b/Items/Weapons/Rogue/Crystalline.cs index 0db18b60e3..5df04ff611 100644 --- a/Items/Weapons/Rogue/Crystalline.cs +++ b/Items/Weapons/Rogue/Crystalline.cs @@ -35,8 +35,8 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; public override void AddRecipes() { @@ -54,8 +54,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/CursedDagger.cs b/Items/Weapons/Rogue/CursedDagger.cs index 36bb27c842..bba4375662 100644 --- a/Items/Weapons/Rogue/CursedDagger.cs +++ b/Items/Weapons/Rogue/CursedDagger.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Cursed Dagger"); Tooltip.SetDefault("Throws bouncing daggers\n" + - "Stealth strikes are showered in cursed fireballs"); + "Stealth strikes are showered in cursed fireballs"); } public override void SafeSetDefaults() @@ -40,11 +40,11 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; - } + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } return false; } return true; diff --git a/Items/Weapons/Rogue/DeepWounder.cs b/Items/Weapons/Rogue/DeepWounder.cs index 65d337a302..98862c6e5e 100644 --- a/Items/Weapons/Rogue/DeepWounder.cs +++ b/Items/Weapons/Rogue/DeepWounder.cs @@ -46,8 +46,8 @@ namespace CalamityMod.Items.Weapons.Rogue velocity *= item.shootSpeed * stealthSpeedMult; int p = Projectile.NewProjectile(position, velocity, type, damage, knockBack, player.whoAmI, 0f, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/DefectiveSphere.cs b/Items/Weapons/Rogue/DefectiveSphere.cs index 9f19678db6..74035864c3 100644 --- a/Items/Weapons/Rogue/DefectiveSphere.cs +++ b/Items/Weapons/Rogue/DefectiveSphere.cs @@ -6,7 +6,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Rogue { - public class DefectiveSphere : RogueWeapon + public class DefectiveSphere : RogueWeapon { public static int BaseDamage = 130; public static float Speed = 15f; @@ -30,7 +30,7 @@ Stealth strikes launch all 4 sphere types at once"); item.autoReuse = true; item.noMelee = true; item.noUseGraphic = true; - item.maxStack = 5; + item.maxStack = 5; item.useStyle = ItemUseStyleID.SwingThrow; item.UseSound = SoundID.Item15; //phaseblade sound effect @@ -45,56 +45,56 @@ Stealth strikes launch all 4 sphere types at once"); public override bool CanUseItem(Player player) { - int UseMax = item.stack; + int UseMax = item.stack; - if (player.Calamity().StealthStrikeAvailable()) - { - return true; - } - else if ((player.ownedProjectileCounts[item.shoot] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()]) >= UseMax) - { - return false; - } - else - { - return true; - } + if (player.Calamity().StealthStrikeAvailable()) + { + return true; + } + else if ((player.ownedProjectileCounts[item.shoot] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()]) >= UseMax) + { + return false; + } + else + { + return 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) { - int sphereType = Utils.SelectRandom(Main.rand, new int[] - { - type, - ProjectileType(), - ProjectileType(), - ProjectileType() - }); + int sphereType = Utils.SelectRandom(Main.rand, new int[] + { + type, + ProjectileType(), + ProjectileType(), + ProjectileType() + }); if (player.Calamity().StealthStrikeAvailable()) - { - // This is done to allow looping when creating projectiles, instead of having to create many projectile/velocity variables all at once, - // which this shoot code used to do. - int[] projectilesToShoot = new int[] - { - type, - ProjectileType(), - ProjectileType(), - ProjectileType() - }; + { + // This is done to allow looping when creating projectiles, instead of having to create many projectile/velocity variables all at once, + // which this shoot code used to do. + int[] projectilesToShoot = new int[] + { + type, + ProjectileType(), + ProjectileType(), + ProjectileType() + }; - foreach (int projectileType in projectilesToShoot) - { - Vector2 shootVelocity = new Vector2(speedX, speedY) + Main.rand.NextVector2Square(-1.5f, 1.5f); - int stealth = Projectile.NewProjectile(position, shootVelocity, projectileType, (int)(damage * 0.625f), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - } - } - else - { - Projectile.NewProjectile(position, new Vector2(speedX, speedY), sphereType, damage, knockBack, player.whoAmI, 0f, 0f); - } + foreach (int projectileType in projectilesToShoot) + { + Vector2 shootVelocity = new Vector2(speedX, speedY) + Main.rand.NextVector2Square(-1.5f, 1.5f); + int stealth = Projectile.NewProjectile(position, shootVelocity, projectileType, (int)(damage * 0.625f), knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + } + } + else + { + Projectile.NewProjectile(position, new Vector2(speedX, speedY), sphereType, damage, knockBack, player.whoAmI, 0f, 0f); + } return false; } } diff --git a/Items/Weapons/Rogue/DesecratedWater.cs b/Items/Weapons/Rogue/DesecratedWater.cs index 28913d0ab1..d7374ae0b7 100644 --- a/Items/Weapons/Rogue/DesecratedWater.cs +++ b/Items/Weapons/Rogue/DesecratedWater.cs @@ -41,8 +41,8 @@ Stealth strikes spawn additional bubbles that inflict Ichor and Cursed Inferno") if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/DukesDecapitator.cs b/Items/Weapons/Rogue/DukesDecapitator.cs index 67ca6cbe35..01c16a05bc 100644 --- a/Items/Weapons/Rogue/DukesDecapitator.cs +++ b/Items/Weapons/Rogue/DukesDecapitator.cs @@ -6,45 +6,45 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Rogue { - public class DukesDecapitator : RogueWeapon + public class DukesDecapitator : RogueWeapon { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Duke's Decapitator"); - Tooltip.SetDefault("Throws a hydro axe which shreds enemies when it comes into contact with them\n" - +"The faster it’s spinning, the more times it hits before disappearing\n" - +"Stealth Strikes make it emit short-ranged bubbles."); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Duke's Decapitator"); + Tooltip.SetDefault("Throws a hydro axe which shreds enemies when it comes into contact with them\n" + +"The faster it’s spinning, the more times it hits before disappearing\n" + +"Stealth Strikes make it emit short-ranged bubbles."); + } - public override void SafeSetDefaults() - { - item.width = 60; - item.height = 64; - item.damage = 90; - item.noMelee = true; - item.noUseGraphic = true; - item.autoReuse = true; - item.useAnimation = 30; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 30; - item.knockBack = 2f; - item.UseSound = SoundID.Item1; + public override void SafeSetDefaults() + { + item.width = 60; + item.height = 64; + item.damage = 90; + item.noMelee = true; + item.noUseGraphic = true; + item.autoReuse = true; + item.useAnimation = 30; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = 30; + item.knockBack = 2f; + item.UseSound = SoundID.Item1; item.value = Item.buyPrice(0, 80, 0, 0); item.rare = ItemRarityID.Yellow; item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 15f; + item.shootSpeed = 15f; item.Calamity().rogue = 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) - { - if (player.Calamity().StealthStrikeAvailable()) - damage = (int)(damage * 1.2f); + 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()) + damage = (int)(damage * 1.2f); - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (Main.projectile.IndexInRange(proj)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - return false; - } - } + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (Main.projectile.IndexInRange(proj)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + return false; + } + } } diff --git a/Items/Weapons/Rogue/DuneHopper.cs b/Items/Weapons/Rogue/DuneHopper.cs index b901ce4733..f993510105 100644 --- a/Items/Weapons/Rogue/DuneHopper.cs +++ b/Items/Weapons/Rogue/DuneHopper.cs @@ -36,7 +36,7 @@ Stealth strikes throw three high speed spears"); item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; item.Calamity().rogue = 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) { @@ -48,24 +48,24 @@ Stealth strikes throw three high speed spears"); { Vector2 perturbedSpeed = new Vector2(speedX - 3f, speedY - 3f).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); int stealth = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), Math.Max(damage / 3, 1), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } return false; } return true; } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 20); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/DuststormInABottle.cs b/Items/Weapons/Rogue/DuststormInABottle.cs index 56ccfb079e..26eb9aa4e7 100644 --- a/Items/Weapons/Rogue/DuststormInABottle.cs +++ b/Items/Weapons/Rogue/DuststormInABottle.cs @@ -7,56 +7,56 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class DuststormInABottle : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Duststorm in a Bottle"); - Tooltip.SetDefault("Explodes into a dust cloud\n" + - "Stealth strikes form a more intense and longer lasting dust cloud"); - } + public class DuststormInABottle : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Duststorm in a Bottle"); + Tooltip.SetDefault("Explodes into a dust cloud\n" + + "Stealth strikes form a more intense and longer lasting dust cloud"); + } - public override void SafeSetDefaults() - { - item.width = 20; - item.damage = 47; - item.noMelee = true; - item.noUseGraphic = true; - item.useAnimation = 25; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 25; - item.knockBack = 5f; - item.UseSound = SoundID.Item106; - item.autoReuse = true; - item.height = 24; - item.value = Item.buyPrice(0, 60, 0, 0); - item.rare = ItemRarityID.Lime; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 12f; - item.Calamity().rogue = true; - } + public override void SafeSetDefaults() + { + item.width = 20; + item.damage = 47; + item.noMelee = true; + item.noUseGraphic = true; + item.useAnimation = 25; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = 25; + item.knockBack = 5f; + item.UseSound = SoundID.Item106; + item.autoReuse = true; + item.height = 24; + item.value = Item.buyPrice(0, 60, 0, 0); + item.rare = ItemRarityID.Lime; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 12f; + item.Calamity().rogue = 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) - { - if (player.Calamity().StealthStrikeAvailable()) - { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - return false; - } - return 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) + { + if (player.Calamity().StealthStrikeAvailable()) + { + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + return false; + } + return true; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.SandstorminaBottle); - recipe.AddIngredient(ItemID.HolyWater, 20); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.SandstorminaBottle); + recipe.AddIngredient(ItemID.HolyWater, 20); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/EclipsesFall.cs b/Items/Weapons/Rogue/EclipsesFall.cs index 660bf75dc4..0da6b9b7dc 100644 --- a/Items/Weapons/Rogue/EclipsesFall.cs +++ b/Items/Weapons/Rogue/EclipsesFall.cs @@ -8,57 +8,57 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class EclipsesFall : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Eclipse's Fall"); - Tooltip.SetDefault("When the sun goes dark, you will know judgment\n" + - "Summons spears from the sky on hit\n" + - "Stealth strikes impale enemies and summon a constant barrage of spears over time"); - } + public class EclipsesFall : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eclipse's Fall"); + Tooltip.SetDefault("When the sun goes dark, you will know judgment\n" + + "Summons spears from the sky on hit\n" + + "Stealth strikes impale enemies and summon a constant barrage of spears over time"); + } - public override void SafeSetDefaults() - { - item.damage = 564; - item.knockBack = 3.5f; - item.useAnimation = item.useTime = 21; - item.autoReuse = true; - item.Calamity().rogue = true; - item.shootSpeed = 15f; - item.shoot = ModContent.ProjectileType(); + public override void SafeSetDefaults() + { + item.damage = 564; + item.knockBack = 3.5f; + item.useAnimation = item.useTime = 21; + item.autoReuse = true; + item.Calamity().rogue = true; + item.shootSpeed = 15f; + item.shoot = ModContent.ProjectileType(); - item.useStyle = ItemUseStyleID.SwingThrow; - item.width = item.height = 72; - item.noMelee = true; - item.noUseGraphic = true; - item.UseSound = SoundID.Item1; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + item.useStyle = ItemUseStyleID.SwingThrow; + item.width = item.height = 72; + item.noMelee = true; + item.noUseGraphic = true; + item.UseSound = SoundID.Item1; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + } - 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()) - type = ModContent.ProjectileType(); + 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()) + type = ModContent.ProjectileType(); - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - return false; - } + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/EnchantedAxe.cs b/Items/Weapons/Rogue/EnchantedAxe.cs index c46532259c..dc3aeb6d3a 100644 --- a/Items/Weapons/Rogue/EnchantedAxe.cs +++ b/Items/Weapons/Rogue/EnchantedAxe.cs @@ -44,8 +44,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/EpidemicShredder.cs b/Items/Weapons/Rogue/EpidemicShredder.cs index b29f3fe296..f0d979c024 100644 --- a/Items/Weapons/Rogue/EpidemicShredder.cs +++ b/Items/Weapons/Rogue/EpidemicShredder.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Epidemic Shredder"); Tooltip.SetDefault("Contrary to its name, it will probably cause an epidemic if used incorrectly\n" + - "Throws a plagued boomerang that releases plague seekers when it hits tiles or enemies\n" + + "Throws a plagued boomerang that releases plague seekers when it hits tiles or enemies\n" + "Stealth strikes cause the boomerang to release plague seekers constantly as it travels"); } diff --git a/Items/Weapons/Rogue/Equanimity.cs b/Items/Weapons/Rogue/Equanimity.cs index 8672b5a01f..733e0155aa 100644 --- a/Items/Weapons/Rogue/Equanimity.cs +++ b/Items/Weapons/Rogue/Equanimity.cs @@ -35,15 +35,15 @@ namespace CalamityMod.Items.Weapons.Rogue item.shoot = ModContent.ProjectileType(); item.shootSpeed = 30f; item.Calamity().rogue = 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) { if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ExecutionersBlade.cs b/Items/Weapons/Rogue/ExecutionersBlade.cs index 872722424b..70f4a249ec 100644 --- a/Items/Weapons/Rogue/ExecutionersBlade.cs +++ b/Items/Weapons/Rogue/ExecutionersBlade.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.shoot = ModContent.ProjectileType(); item.shootSpeed = 26f; item.Calamity().rogue = true; - item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.Calamity().customRarity = CalamityRarity.DarkBlue; } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) diff --git a/Items/Weapons/Rogue/Exorcism.cs b/Items/Weapons/Rogue/Exorcism.cs index c3abe9fc3b..e2771293a6 100644 --- a/Items/Weapons/Rogue/Exorcism.cs +++ b/Items/Weapons/Rogue/Exorcism.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class Exorcism : RogueWeapon + public class Exorcism : RogueWeapon { public override void SetStaticDefaults() { @@ -42,8 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)(damage * 1.15f), knockBack, player.whoAmI, 2f, damage); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; } else { @@ -57,9 +57,9 @@ namespace CalamityMod.Items.Weapons.Rogue ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.HolyWater, 10); recipe.AddIngredient(ItemID.HallowedBar, 12); - recipe.AddIngredient(ItemID.SoulofMight, 6); - recipe.AddIngredient(ItemID.SoulofSight, 6); - recipe.AddIngredient(ItemID.SoulofFright, 6); + recipe.AddIngredient(ItemID.SoulofMight, 6); + recipe.AddIngredient(ItemID.SoulofSight, 6); + recipe.AddIngredient(ItemID.SoulofFright, 6); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this, 1); recipe.AddRecipe(); diff --git a/Items/Weapons/Rogue/FantasyTalisman.cs b/Items/Weapons/Rogue/FantasyTalisman.cs index aad0095869..4e40f8a249 100644 --- a/Items/Weapons/Rogue/FantasyTalisman.cs +++ b/Items/Weapons/Rogue/FantasyTalisman.cs @@ -44,8 +44,8 @@ Stealth strikes release more souls and leave behind souls as they travel"); if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), (int)(damage * 0.8f), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/FeatherKnife.cs b/Items/Weapons/Rogue/FeatherKnife.cs index 1289b67463..557c58e41a 100644 --- a/Items/Weapons/Rogue/FeatherKnife.cs +++ b/Items/Weapons/Rogue/FeatherKnife.cs @@ -35,7 +35,7 @@ Stealth strike throws a volley of knives"); item.shootSpeed = 25f; item.Calamity().rogue = true; - item.value = Item.sellPrice(copper: 60); + item.value = Item.sellPrice(copper: 60); item.rare = ItemRarityID.Orange; } diff --git a/Items/Weapons/Rogue/FinalDawn.cs b/Items/Weapons/Rogue/FinalDawn.cs index e8f4f344ce..2d4aa405b1 100644 --- a/Items/Weapons/Rogue/FinalDawn.cs +++ b/Items/Weapons/Rogue/FinalDawn.cs @@ -5,45 +5,45 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Rogue { - public class FinalDawn : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Final Dawn"); - Tooltip.SetDefault("We shall ride into the sunrise once more\n" + - "Attack enemies with a giant scythe swing to replenish stealth\n" + - "Press up and attack to throw the scythe \n" + - "Stealth strikes perform a horizontal swing that leaves a lingering fire aura\n" + - "Stealth strikes performed while pressing up fling yourself at the enemy and slice through them, causing homing fireballs to emerge"); - } + public class FinalDawn : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("The Final Dawn"); + Tooltip.SetDefault("We shall ride into the sunrise once more\n" + + "Attack enemies with a giant scythe swing to replenish stealth\n" + + "Press up and attack to throw the scythe \n" + + "Stealth strikes perform a horizontal swing that leaves a lingering fire aura\n" + + "Stealth strikes performed while pressing up fling yourself at the enemy and slice through them, causing homing fireballs to emerge"); + } - public override void SafeSetDefaults() - { - item.damage = 1500; - item.Calamity().rogue = true; - item.width = 78; - item.height = 66; - item.noMelee = true; - item.useTime = item.useAnimation = 15; - item.useStyle = ItemUseStyleID.SwingThrow; - item.knockBack = 4; + public override void SafeSetDefaults() + { + item.damage = 1500; + item.Calamity().rogue = true; + item.width = 78; + item.height = 66; + item.noMelee = true; + item.useTime = item.useAnimation = 15; + item.useStyle = ItemUseStyleID.SwingThrow; + item.knockBack = 4; - item.value = CalamityGlobalItem.Rarity15BuyPrice; - item.Calamity().customRarity = CalamityRarity.Violet; - item.Calamity().donorItem = true; + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.Calamity().customRarity = CalamityRarity.Violet; + item.Calamity().donorItem = true; - item.autoReuse = false; - item.shoot = ProjectileType(); - item.shootSpeed = 1f; - item.useTurn = false; - item.channel = true; - item.noUseGraphic = true; - } + item.autoReuse = false; + item.shoot = ProjectileType(); + item.shootSpeed = 1f; + item.useTurn = false; + item.channel = true; + item.noUseGraphic = true; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] + - player.ownedProjectileCounts[ProjectileType()] + - player.ownedProjectileCounts[ProjectileType()] + - player.ownedProjectileCounts[ProjectileType()] + - player.ownedProjectileCounts[ProjectileType()] <= 0; - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] + + player.ownedProjectileCounts[ProjectileType()] + + player.ownedProjectileCounts[ProjectileType()] + + player.ownedProjectileCounts[ProjectileType()] + + player.ownedProjectileCounts[ProjectileType()] <= 0; + } } \ No newline at end of file diff --git a/Items/Weapons/Rogue/FlameScythe.cs b/Items/Weapons/Rogue/FlameScythe.cs index ee85b8edcd..cec270b0fa 100644 --- a/Items/Weapons/Rogue/FlameScythe.cs +++ b/Items/Weapons/Rogue/FlameScythe.cs @@ -7,13 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class FlameScythe : RogueWeapon + public class FlameScythe : RogueWeapon { public override void SetStaticDefaults() { DisplayName.SetDefault("Subduction Slicer"); Tooltip.SetDefault("Throws a scythe that explodes on enemy hits\n" + - "Stealth strikes also summon an orange pillar of fire on enemy hits"); + "Stealth strikes also summon an orange pillar of fire on enemy hits"); } public override void SafeSetDefaults() @@ -39,8 +39,8 @@ 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 proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/Rogue/FrostcrushValari.cs b/Items/Weapons/Rogue/FrostcrushValari.cs index 7b1a4edaea..5f8ab95286 100644 --- a/Items/Weapons/Rogue/FrostcrushValari.cs +++ b/Items/Weapons/Rogue/FrostcrushValari.cs @@ -41,8 +41,8 @@ Stealth strikes throw three short ranged boomerangs along with a spread of icicl item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 16; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 16; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -55,12 +55,12 @@ Stealth strikes throw three short ranged boomerangs along with a spread of icicl { Vector2 perturbedspeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(spread)); int proj = Projectile.NewProjectile(position, perturbedspeed, type, Math.Max((int)(damage / 2.7272f), 1), knockBack / 3f, player.whoAmI, 0f, 1f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; spread -= 10; } int spread2 = 3; - int icicleAmt = Main.rand.Next(6,11); + int icicleAmt = Main.rand.Next(6,11); for (int i = 0; i < icicleAmt; i++) { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread2)); diff --git a/Items/Weapons/Rogue/FrostyFlare.cs b/Items/Weapons/Rogue/FrostyFlare.cs index d48f0bc7d1..461536ea97 100644 --- a/Items/Weapons/Rogue/FrostyFlare.cs +++ b/Items/Weapons/Rogue/FrostyFlare.cs @@ -12,9 +12,9 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Frosty Flare"); Tooltip.SetDefault("Do not insert in flare gun\n" + - "Sticks to enemies\n" + + "Sticks to enemies\n" + "Generates a localized hailstorm\n" + - "Stealth strikes trail snowflakes and summon phantom copies instead of ice shards"); + "Stealth strikes trail snowflakes and summon phantom copies instead of ice shards"); } public override void SafeSetDefaults() @@ -42,14 +42,14 @@ 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) { - if (player.Calamity().StealthStrikeAvailable()) - { - int flare = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), (int)(damage * 0.9f), knockBack, player.whoAmI); - if (flare.WithinBounds(Main.maxProjectiles)) - Main.projectile[flare].Calamity().stealthStrike = true; - return false; - } - return true; + if (player.Calamity().StealthStrikeAvailable()) + { + int flare = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), (int)(damage * 0.9f), knockBack, player.whoAmI); + if (flare.WithinBounds(Main.maxProjectiles)) + Main.projectile[flare].Calamity().stealthStrike = true; + return false; + } + return true; } } } diff --git a/Items/Weapons/Rogue/GelDart.cs b/Items/Weapons/Rogue/GelDart.cs index c5b20465ae..556b150001 100644 --- a/Items/Weapons/Rogue/GelDart.cs +++ b/Items/Weapons/Rogue/GelDart.cs @@ -6,14 +6,14 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class GelDart : RogueWeapon + public class GelDart : RogueWeapon { public override void SetStaticDefaults() { DisplayName.SetDefault("Gel Dart"); Tooltip.SetDefault("Throws bouncing darts\n" + - "Stealth strikes ignore gravity and bounce more vigorously\n" + - "They additionally leak slime and cover enemies in dark sludge"); + "Stealth strikes ignore gravity and bounce more vigorously\n" + + "They additionally leak slime and cover enemies in dark sludge"); } public override void SafeSetDefaults() @@ -43,13 +43,13 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; - Main.projectile[stealth].penetrate = 6; - Main.projectile[stealth].aiStyle = -1; - } + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + Main.projectile[stealth].penetrate = 6; + Main.projectile[stealth].aiStyle = -1; + } return false; } return true; diff --git a/Items/Weapons/Rogue/GhoulishGouger.cs b/Items/Weapons/Rogue/GhoulishGouger.cs index c63c8be709..e3ae13baf5 100644 --- a/Items/Weapons/Rogue/GhoulishGouger.cs +++ b/Items/Weapons/Rogue/GhoulishGouger.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.shootSpeed = 16f; item.Calamity().rogue = true; - item.value = CalamityGlobalItem.Rarity13BuyPrice; + item.value = CalamityGlobalItem.Rarity13BuyPrice; item.Calamity().customRarity = CalamityRarity.PureGreen; } diff --git a/Items/Weapons/Rogue/GildedDagger.cs b/Items/Weapons/Rogue/GildedDagger.cs index dc9c1efa04..46ce03eaff 100644 --- a/Items/Weapons/Rogue/GildedDagger.cs +++ b/Items/Weapons/Rogue/GildedDagger.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue DisplayName.SetDefault("Gilded Dagger"); Tooltip.SetDefault("Throws a shiny blade that ricochets towards another enemy on hit\n" + "Stealth strikes cause the blade to home in after ricocheting, with each ricochet dealing 20% more damage\n" + - "Stealth strikes also have increased piercing"); + "Stealth strikes also have increased piercing"); } public override void SafeSetDefaults() @@ -42,11 +42,11 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[p].Calamity().stealthStrike = true; - Main.projectile[p].penetrate = 4; - } + if (p.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[p].Calamity().stealthStrike = true; + Main.projectile[p].penetrate = 4; + } return false; } return true; diff --git a/Items/Weapons/Rogue/Glaive.cs b/Items/Weapons/Rogue/Glaive.cs index ccd3245ffd..eb89994092 100644 --- a/Items/Weapons/Rogue/Glaive.cs +++ b/Items/Weapons/Rogue/Glaive.cs @@ -41,8 +41,8 @@ Stealth strikes are super fast and pierce infinitely"); item.shoot = ModContent.ProjectileType(); } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Rogue/GleamingDagger.cs b/Items/Weapons/Rogue/GleamingDagger.cs index beea3e7562..0de383e16a 100644 --- a/Items/Weapons/Rogue/GleamingDagger.cs +++ b/Items/Weapons/Rogue/GleamingDagger.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue DisplayName.SetDefault("Gleaming Dagger"); Tooltip.SetDefault("Throws a shiny blade that ricochets towards another enemy on hit\n" + "Stealth strikes cause the blade to home in after ricocheting, with each ricochet dealing 20% more damage\n" + - "Stealth strikes also have increased piercing"); + "Stealth strikes also have increased piercing"); } public override void SafeSetDefaults() @@ -42,11 +42,11 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[p].Calamity().stealthStrike = true; - Main.projectile[p].penetrate = 4; - } + if (p.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[p].Calamity().stealthStrike = true; + Main.projectile[p].penetrate = 4; + } return false; } return true; diff --git a/Items/Weapons/Rogue/HardenedHoneycomb.cs b/Items/Weapons/Rogue/HardenedHoneycomb.cs index 5b86ea89fb..7475d4708d 100644 --- a/Items/Weapons/Rogue/HardenedHoneycomb.cs +++ b/Items/Weapons/Rogue/HardenedHoneycomb.cs @@ -43,11 +43,11 @@ Stealth strikes can bounce off walls and enemies"); if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].penetrate = 3; - } + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].penetrate = 3; + } return false; } return true; diff --git a/Items/Weapons/Rogue/HeavenfallenStardisk.cs b/Items/Weapons/Rogue/HeavenfallenStardisk.cs index 02786065be..f44c9b2865 100644 --- a/Items/Weapons/Rogue/HeavenfallenStardisk.cs +++ b/Items/Weapons/Rogue/HeavenfallenStardisk.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue DisplayName.SetDefault("Heavenfallen Stardisk"); Tooltip.SetDefault("Throws a stardisk upwards which then launches itself towards your mouse cursor,\n" + "explodes into several astral energy bolts if the thrower is moving vertically when throwing it and during its impact\n" + - "Stealth strikes rain astral energy bolts from the sky"); + "Stealth strikes rain astral energy bolts from the sky"); } public override void SafeSetDefaults() @@ -36,21 +36,21 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; 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()) { int proj = Projectile.NewProjectile(position.X, position.Y, 0f, -10f, type, (int)(damage * 1.25f), knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; } - else - { - Projectile.NewProjectile(position.X, position.Y, 0f, -10f, type, damage, knockBack, player.whoAmI); - } + else + { + Projectile.NewProjectile(position.X, position.Y, 0f, -10f, type, damage, knockBack, player.whoAmI); + } return false; } } diff --git a/Items/Weapons/Rogue/Hypothermia.cs b/Items/Weapons/Rogue/Hypothermia.cs index f21e1a2e0a..daa44fd7eb 100644 --- a/Items/Weapons/Rogue/Hypothermia.cs +++ b/Items/Weapons/Rogue/Hypothermia.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().customRarity = CalamityRarity.DarkBlue; item.Calamity().rogue = true; - } + } // Terraria seems to really dislike high crit values in SetDefaults public override void GetWeaponCrit(Player player, ref int crit) => crit += 16; diff --git a/Items/Weapons/Rogue/IceStar.cs b/Items/Weapons/Rogue/IceStar.cs index 7cc67de187..5af7dfe50e 100644 --- a/Items/Weapons/Rogue/IceStar.cs +++ b/Items/Weapons/Rogue/IceStar.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class IceStar : RogueWeapon + public class IceStar : RogueWeapon { public override void SetStaticDefaults() { @@ -37,16 +37,16 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 7; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 7; 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()) { int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/Icebreaker.cs b/Items/Weapons/Rogue/Icebreaker.cs index 5b9b716648..4f2ce81809 100644 --- a/Items/Weapons/Rogue/Icebreaker.cs +++ b/Items/Weapons/Rogue/Icebreaker.cs @@ -39,8 +39,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/IchorSpear.cs b/Items/Weapons/Rogue/IchorSpear.cs index 8c49f1808a..d9e84f553b 100644 --- a/Items/Weapons/Rogue/IchorSpear.cs +++ b/Items/Weapons/Rogue/IchorSpear.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Ichor Spear"); Tooltip.SetDefault("Throws an ichor tipped trident\n" + - "Stealth strikes are showered in splashes of ichor"); + "Stealth strikes are showered in splashes of ichor"); } public override void SafeSetDefaults() @@ -40,11 +40,11 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 1.6), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; - } + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } return false; } return true; diff --git a/Items/Weapons/Rogue/InfernalKris.cs b/Items/Weapons/Rogue/InfernalKris.cs index 923bc083b4..6a26b153a0 100644 --- a/Items/Weapons/Rogue/InfernalKris.cs +++ b/Items/Weapons/Rogue/InfernalKris.cs @@ -42,8 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/IronFrancisca.cs b/Items/Weapons/Rogue/IronFrancisca.cs index da6ec9a684..e4446e1e36 100644 --- a/Items/Weapons/Rogue/IronFrancisca.cs +++ b/Items/Weapons/Rogue/IronFrancisca.cs @@ -42,8 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/KelvinCatalyst.cs b/Items/Weapons/Rogue/KelvinCatalyst.cs index 20ef68b336..4d455dca21 100644 --- a/Items/Weapons/Rogue/KelvinCatalyst.cs +++ b/Items/Weapons/Rogue/KelvinCatalyst.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class KelvinCatalyst : RogueWeapon + public class KelvinCatalyst : RogueWeapon { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Rogue/Kylie.cs b/Items/Weapons/Rogue/Kylie.cs index ee839e2811..bc08cad7c6 100644 --- a/Items/Weapons/Rogue/Kylie.cs +++ b/Items/Weapons/Rogue/Kylie.cs @@ -37,8 +37,8 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 16; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 16; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -51,8 +51,8 @@ namespace CalamityMod.Items.Weapons.Rogue { Vector2 perturbedspeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(spread)); int proj = Projectile.NewProjectile(position, perturbedspeed, ModContent.ProjectileType(), Math.Max(damage / 3, 1), knockBack / 3f, player.whoAmI, 0f, 1f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; spread -= 10; } return false; diff --git a/Items/Weapons/Rogue/LatcherMine.cs b/Items/Weapons/Rogue/LatcherMine.cs index a11c7a099f..94a2beb08d 100644 --- a/Items/Weapons/Rogue/LatcherMine.cs +++ b/Items/Weapons/Rogue/LatcherMine.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class LatcherMine : RogueWeapon + public class LatcherMine : RogueWeapon { public const int BaseDamage = 80; public override void SetStaticDefaults() @@ -42,8 +42,8 @@ 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 stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } } diff --git a/Items/Weapons/Rogue/LeadTomahawk.cs b/Items/Weapons/Rogue/LeadTomahawk.cs index 0456d3e129..e71013fc87 100644 --- a/Items/Weapons/Rogue/LeadTomahawk.cs +++ b/Items/Weapons/Rogue/LeadTomahawk.cs @@ -42,8 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/LeonidProgenitor.cs b/Items/Weapons/Rogue/LeonidProgenitor.cs index feafeb2a4c..519a265ae8 100644 --- a/Items/Weapons/Rogue/LeonidProgenitor.cs +++ b/Items/Weapons/Rogue/LeonidProgenitor.cs @@ -7,90 +7,90 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class LeonidProgenitor : RogueWeapon - { + public class LeonidProgenitor : RogueWeapon + { public static readonly Color blueColor = new Color(48, 208, 255); public static readonly Color purpleColor = new Color(208, 125, 218); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Leonid Progenitor"); - Tooltip.SetDefault("Throws a bombshell that explodes, summoning a meteor to impact the site\n" + - "Right click to throw a spread of gravity affected comets that explode, leaving behind a star\n" + - "Stealth strikes lob a bombshell that additionally splits into comets on hit"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Leonid Progenitor"); + Tooltip.SetDefault("Throws a bombshell that explodes, summoning a meteor to impact the site\n" + + "Right click to throw a spread of gravity affected comets that explode, leaving behind a star\n" + + "Stealth strikes lob a bombshell that additionally splits into comets on hit"); + } - public override void SafeSetDefaults() - { - item.damage = 64; - item.Calamity().rogue = true; - item.knockBack = 3f; - item.useTime = item.useAnimation = 15; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 12f; + public override void SafeSetDefaults() + { + item.damage = 64; + item.Calamity().rogue = true; + item.knockBack = 3f; + item.useTime = item.useAnimation = 15; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 12f; - item.width = 32; - item.height = 48; - item.useStyle = ItemUseStyleID.SwingThrow; - item.noMelee = true; - item.noUseGraphic = true; - item.UseSound = SoundID.Item61; + item.width = 32; + item.height = 48; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.noUseGraphic = true; + item.UseSound = SoundID.Item61; - item.value = CalamityGlobalItem.Rarity7BuyPrice; - item.rare = ItemRarityID.Lime; - } + item.value = CalamityGlobalItem.Rarity7BuyPrice; + item.rare = ItemRarityID.Lime; + } - public override bool AltFunctionUse(Player player) => true; + public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) - { - if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse != 2) - { - item.UseSound = SoundID.Item61; - item.shoot = ModContent.ProjectileType(); - } - else - { - item.UseSound = SoundID.Item88; - item.shoot = ModContent.ProjectileType(); - } - return base.CanUseItem(player); - } + public override bool CanUseItem(Player player) + { + if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse != 2) + { + item.UseSound = SoundID.Item61; + item.shoot = ModContent.ProjectileType(); + } + else + { + item.UseSound = SoundID.Item88; + item.shoot = ModContent.ProjectileType(); + } + return base.CanUseItem(player); + } - public override float SafeSetUseTimeMultiplier(Player player) - { - if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse != 2) - return 1f; - return 0.75f; - } + public override float SafeSetUseTimeMultiplier(Player player) + { + if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse != 2) + return 1f; + return 0.75f; + } - 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 stealthDamageFactor = player.Calamity().StealthStrikeAvailable() ? 1.25f : 1f; + 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 stealthDamageFactor = player.Calamity().StealthStrikeAvailable() ? 1.25f : 1f; - if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse != 2) - { - int bomb = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * stealthDamageFactor), knockBack, player.whoAmI); - if (bomb.WithinBounds(Main.maxProjectiles)) - Main.projectile[bomb].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - return false; - } - else - { - float dmgMult = 0.5f; - for (float i = -2.5f; i < 3f; ++i) - { - Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - Projectile.NewProjectile(position, perturbedSpeed, type, (int)(damage * dmgMult * stealthDamageFactor), knockBack, player.whoAmI); - } - } - return false; - } + if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse != 2) + { + int bomb = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * stealthDamageFactor), knockBack, player.whoAmI); + if (bomb.WithinBounds(Main.maxProjectiles)) + Main.projectile[bomb].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + return false; + } + else + { + float dmgMult = 0.5f; + for (float i = -2.5f; i < 3f; ++i) + { + Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); + Projectile.NewProjectile(position, perturbedSpeed, type, (int)(damage * dmgMult * stealthDamageFactor), knockBack, player.whoAmI); + } + } + return false; + } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/LeonidProgenitorGlow")); - } - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/LeonidProgenitorGlow")); + } + } } diff --git a/Items/Weapons/Rogue/LeviathanTeeth.cs b/Items/Weapons/Rogue/LeviathanTeeth.cs index c3bc789cdd..fde5f61e7f 100644 --- a/Items/Weapons/Rogue/LeviathanTeeth.cs +++ b/Items/Weapons/Rogue/LeviathanTeeth.cs @@ -61,17 +61,17 @@ namespace CalamityMod.Items.Weapons.Rogue if (stealthStrike) { int tooth = Projectile.NewProjectile(position.X, position.Y, offsetSpeedX * 1.5f, offsetSpeedY * 1.5f, type, damage, knockBack * 10f, player.whoAmI); - if (tooth.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[tooth].Calamity().stealthStrike = true; - Main.projectile[tooth].Calamity().lineColor = Main.rand.Next(3); - } + if (tooth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[tooth].Calamity().stealthStrike = true; + Main.projectile[tooth].Calamity().lineColor = Main.rand.Next(3); + } } else { int tooth = Projectile.NewProjectile(position.X, position.Y, offsetSpeedX, offsetSpeedY, type, damage, knockBack, player.whoAmI); - if (tooth.WithinBounds(Main.maxProjectiles)) - Main.projectile[tooth].Calamity().lineColor = Main.rand.Next(3); + if (tooth.WithinBounds(Main.maxProjectiles)) + Main.projectile[tooth].Calamity().lineColor = Main.rand.Next(3); } } return false; diff --git a/Items/Weapons/Rogue/Lionfish.cs b/Items/Weapons/Rogue/Lionfish.cs index 05dbb31f43..9254fec701 100644 --- a/Items/Weapons/Rogue/Lionfish.cs +++ b/Items/Weapons/Rogue/Lionfish.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Lionfish"); Tooltip.SetDefault("Sticks to enemies and injects a potent toxin\n" + - "Stealth strikes are trailed by homing urchin spikes"); + "Stealth strikes are trailed by homing urchin spikes"); } public override void SafeSetDefaults() @@ -40,8 +40,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/LuminousStriker.cs b/Items/Weapons/Rogue/LuminousStriker.cs index d3ee1bff1b..57838e2611 100644 --- a/Items/Weapons/Rogue/LuminousStriker.cs +++ b/Items/Weapons/Rogue/LuminousStriker.cs @@ -7,21 +7,21 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Rogue { - public class LuminousStriker : RogueWeapon + public class LuminousStriker : RogueWeapon { public override void SetStaticDefaults() { DisplayName.SetDefault("Luminous Striker"); - Tooltip.SetDefault("Send the stars back to where they belong\n" - +"Throws a stardust javelin trailed by rising stardust shards\n" + Tooltip.SetDefault("Send the stars back to where they belong\n" + +"Throws a stardust javelin trailed by rising stardust shards\n" +"Explodes into additional stardust shards upon hitting enemies\n" - +"Stealth strikes cause the stardust shards to fly alongside the javelin instead of rising"); + +"Stealth strikes cause the stardust shards to fly alongside the javelin instead of rising"); } public override void SafeSetDefaults() { item.width = 86; - item.height = 102; + item.height = 102; item.damage = 149; item.noMelee = true; item.noUseGraphic = true; @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.shoot = ModContent.ProjectileType(); item.shootSpeed = 20f; item.Calamity().rogue = 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) { @@ -49,11 +49,11 @@ namespace CalamityMod.Items.Weapons.Rogue 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(), 10); - recipe.AddIngredient(ItemID.FragmentStardust, 10); + recipe.AddIngredient(ItemID.FragmentStardust, 10); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this, 1); recipe.AddRecipe(); diff --git a/Items/Weapons/Rogue/LunarKunai.cs b/Items/Weapons/Rogue/LunarKunai.cs index de5dff7ce4..14071eabcc 100644 --- a/Items/Weapons/Rogue/LunarKunai.cs +++ b/Items/Weapons/Rogue/LunarKunai.cs @@ -7,23 +7,23 @@ using CalamityMod.Projectiles.Rogue; namespace CalamityMod.Items.Weapons.Rogue { - public class LunarKunai : RogueWeapon + public class LunarKunai : RogueWeapon { public override void SetStaticDefaults() { DisplayName.SetDefault("Lunar Kunai"); - Tooltip.SetDefault("Throws out a set of three kunai that ignore gravity and slightly home in on enemies\n" - +"After traveling enough distance, the kunai supercharge with lunar energy, homing in far more aggressively and exploding on impact\n" - +"Stealth strikes instantly throw eight supercharged Kunai"); + Tooltip.SetDefault("Throws out a set of three kunai that ignore gravity and slightly home in on enemies\n" + +"After traveling enough distance, the kunai supercharge with lunar energy, homing in far more aggressively and exploding on impact\n" + +"Stealth strikes instantly throw eight supercharged Kunai"); } public override void SafeSetDefaults() { item.width = 38; - item.height = 38; + item.height = 38; item.damage = 120; - item.maxStack = 999; - item.consumable = true; + item.maxStack = 999; + item.consumable = true; item.noMelee = true; item.noUseGraphic = true; item.useAnimation = 10; @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.shoot = ModContent.ProjectileType(); item.shootSpeed = 22f; item.Calamity().rogue = 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) { @@ -62,52 +62,52 @@ namespace CalamityMod.Items.Weapons.Rogue } num78 *= num80; num79 *= num80; - if (player.Calamity().StealthStrikeAvailable()) - { - for (int i = 0; i < 8; i++) - { - float num148 = num78; - float num149 = num79; - float num150 = 0.05f * (float)i; - num148 += (float)Main.rand.Next(-35, 36) * num150; - num149 += (float)Main.rand.Next(-35, 36) * num150; - num80 = (float)Math.Sqrt((double)(num148 * num148 + num149 * num149)); - num80 = num72 / num80; - num148 *= num80; - num149 *= num80; - float x4 = vector2.X; - float y4 = vector2.Y; - int stealth = Projectile.NewProjectile(x4, y4, num148, num149, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - } - } - else - { - for (int i = 0; i < 3; i++) - { - float num148 = num78; - float num149 = num79; - float num150 = 0.05f * (float)i; - num148 += (float)Main.rand.Next(-35, 36) * num150; - num149 += (float)Main.rand.Next(-35, 36) * num150; - num80 = (float)Math.Sqrt((double)(num148 * num148 + num149 * num149)); - num80 = num72 / num80; - num148 *= num80; - num149 *= num80; - float x4 = vector2.X; - float y4 = vector2.Y; - Projectile.NewProjectile(x4, y4, num148, num149, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - } - } - return false; + if (player.Calamity().StealthStrikeAvailable()) + { + for (int i = 0; i < 8; i++) + { + float num148 = num78; + float num149 = num79; + float num150 = 0.05f * (float)i; + num148 += (float)Main.rand.Next(-35, 36) * num150; + num149 += (float)Main.rand.Next(-35, 36) * num150; + num80 = (float)Math.Sqrt((double)(num148 * num148 + num149 * num149)); + num80 = num72 / num80; + num148 *= num80; + num149 *= num80; + float x4 = vector2.X; + float y4 = vector2.Y; + int stealth = Projectile.NewProjectile(x4, y4, num148, num149, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + } + } + else + { + for (int i = 0; i < 3; i++) + { + float num148 = num78; + float num149 = num79; + float num150 = 0.05f * (float)i; + num148 += (float)Main.rand.Next(-35, 36) * num150; + num149 += (float)Main.rand.Next(-35, 36) * num150; + num80 = (float)Math.Sqrt((double)(num148 * num148 + num149 * num149)); + num80 = num72 / num80; + num148 *= num80; + num149 *= num80; + float x4 = vector2.X; + float y4 = vector2.Y; + Projectile.NewProjectile(x4, y4, num148, num149, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + } + } + return false; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.LunarBar, 5); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this, 333); recipe.AddRecipe(); } diff --git a/Items/Weapons/Rogue/Malachite.cs b/Items/Weapons/Rogue/Malachite.cs index 801be7a072..8578433a9b 100644 --- a/Items/Weapons/Rogue/Malachite.cs +++ b/Items/Weapons/Rogue/Malachite.cs @@ -6,89 +6,89 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class Malachite : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Malachite"); - Tooltip.SetDefault("Throws a stream of kunai that stick to enemies and explode\n" + - "Right click to throw a single kunai that pierces, after piercing an enemy it emits a massive explosion on the next enemy hit\n" + - "Stealth strikes fire three kunai that home in, stick to enemies, and explode"); - } + public class Malachite : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Malachite"); + Tooltip.SetDefault("Throws a stream of kunai that stick to enemies and explode\n" + + "Right click to throw a single kunai that pierces, after piercing an enemy it emits a massive explosion on the next enemy hit\n" + + "Stealth strikes fire three kunai that home in, stick to enemies, and explode"); + } - public override void SafeSetDefaults() - { - item.width = 26; - item.damage = 50; - item.noMelee = true; - item.noUseGraphic = true; - item.useTime = item.useAnimation = 10; - item.useStyle = ItemUseStyleID.SwingThrow; - item.knockBack = 1.25f; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.height = 58; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 10f; - item.Calamity().rogue = true; + public override void SafeSetDefaults() + { + item.width = 26; + item.damage = 50; + item.noMelee = true; + item.noUseGraphic = true; + item.useTime = item.useAnimation = 10; + item.useStyle = ItemUseStyleID.SwingThrow; + item.knockBack = 1.25f; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.height = 58; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.Calamity().rogue = true; - item.value = CalamityGlobalItem.Rarity8BuyPrice; - item.rare = ItemRarityID.Yellow; - } + item.value = CalamityGlobalItem.Rarity8BuyPrice; + item.rare = ItemRarityID.Yellow; + } - public override bool AltFunctionUse(Player player) => true; + public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) - { - if (player.Calamity().StealthStrikeAvailable()) - { - item.UseSound = SoundID.Item109; - item.shoot = ModContent.ProjectileType(); - } - else if (player.altFunctionUse == 2) - { - item.UseSound = SoundID.Item109; - item.shoot = ModContent.ProjectileType(); - } - else - { - item.UseSound = SoundID.Item1; - item.shoot = ModContent.ProjectileType(); - } - return base.CanUseItem(player); - } + public override bool CanUseItem(Player player) + { + if (player.Calamity().StealthStrikeAvailable()) + { + item.UseSound = SoundID.Item109; + item.shoot = ModContent.ProjectileType(); + } + else if (player.altFunctionUse == 2) + { + item.UseSound = SoundID.Item109; + item.shoot = ModContent.ProjectileType(); + } + else + { + item.UseSound = SoundID.Item1; + item.shoot = ModContent.ProjectileType(); + } + return base.CanUseItem(player); + } - public override float SafeSetUseTimeMultiplier(Player player) - { - if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse == 2) - return 1f; - return 2f; - } + public override float SafeSetUseTimeMultiplier(Player player) + { + if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse == 2) + return 1f; + return 2f; + } - 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 dmgMult = 1f; - if (player.Calamity().StealthStrikeAvailable()) - { - for (float i = -6.5f; i <= 6.5f; i += 6.5f) - { - Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - int stealth = Projectile.NewProjectile(position, perturbedSpeed, type, damage * 2, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - } - return false; - } - else if (player.altFunctionUse == 2) - { - dmgMult = 1.75f; - } - else - { - dmgMult = 1f; - } - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * dmgMult), knockBack, player.whoAmI); - return false; - } - } + 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 dmgMult = 1f; + if (player.Calamity().StealthStrikeAvailable()) + { + for (float i = -6.5f; i <= 6.5f; i += 6.5f) + { + Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); + int stealth = Projectile.NewProjectile(position, perturbedSpeed, type, damage * 2, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + } + return false; + } + else if (player.altFunctionUse == 2) + { + dmgMult = 1.75f; + } + else + { + dmgMult = 1f; + } + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * dmgMult), knockBack, player.whoAmI); + return false; + } + } } diff --git a/Items/Weapons/Rogue/MangroveChakram.cs b/Items/Weapons/Rogue/MangroveChakram.cs index e3790b1745..41b9b67ab6 100644 --- a/Items/Weapons/Rogue/MangroveChakram.cs +++ b/Items/Weapons/Rogue/MangroveChakram.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class MangroveChakram : RogueWeapon + public class MangroveChakram : RogueWeapon { public override void SetStaticDefaults() { @@ -41,8 +41,8 @@ namespace CalamityMod.Items.Weapons.Rogue damage = (int)(damage * 1.25f); int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/Rogue/MetalMonstrosity.cs b/Items/Weapons/Rogue/MetalMonstrosity.cs index e52a058c1e..c10f74ca2f 100644 --- a/Items/Weapons/Rogue/MetalMonstrosity.cs +++ b/Items/Weapons/Rogue/MetalMonstrosity.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Metal Monstrosity"); Tooltip.SetDefault("This has to hurt\n" + - "Hurls a heavy metal ball that shatters on impact\n" + + "Hurls a heavy metal ball that shatters on impact\n" + "Stealth strikes cause the ball to release spikes as it travels"); } diff --git a/Items/Weapons/Rogue/MeteorFist.cs b/Items/Weapons/Rogue/MeteorFist.cs index cbcdbbab28..5b1fe77328 100644 --- a/Items/Weapons/Rogue/MeteorFist.cs +++ b/Items/Weapons/Rogue/MeteorFist.cs @@ -50,8 +50,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 4f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/MonkeyDarts.cs b/Items/Weapons/Rogue/MonkeyDarts.cs index 0b7255241a..68a210b2fe 100644 --- a/Items/Weapons/Rogue/MonkeyDarts.cs +++ b/Items/Weapons/Rogue/MonkeyDarts.cs @@ -37,8 +37,8 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 18; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 18; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -50,8 +50,8 @@ namespace CalamityMod.Items.Weapons.Rogue { Vector2 perturbedspeed = new Vector2(speedX * 1.25f, speedY * 1.25f).RotatedBy(MathHelper.ToRadians(spread)); int p = Projectile.NewProjectile(position, perturbedspeed, ModContent.ProjectileType(), Math.Max(damage / 3, 1), knockBack, player.whoAmI, 1); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; spread -= 7; } return false; diff --git a/Items/Weapons/Rogue/MythrilKnife.cs b/Items/Weapons/Rogue/MythrilKnife.cs index 832eb81f83..cb3c93b286 100644 --- a/Items/Weapons/Rogue/MythrilKnife.cs +++ b/Items/Weapons/Rogue/MythrilKnife.cs @@ -5,55 +5,55 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class MythrilKnife : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Mythril Knife"); - Tooltip.SetDefault("Stealth strikes inflict a wide assortment of debuffs"); - } + public class MythrilKnife : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mythril Knife"); + Tooltip.SetDefault("Stealth strikes inflict a wide assortment of debuffs"); + } - public override void SafeSetDefaults() - { - item.width = 12; - item.damage = 40; - item.noMelee = true; - item.consumable = true; - item.noUseGraphic = true; - item.useAnimation = 10; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 10; - item.knockBack = 1.75f; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.height = 30; - item.maxStack = 999; - item.value = 1100; - item.rare = ItemRarityID.LightRed; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 12f; - item.Calamity().rogue = true; - } + public override void SafeSetDefaults() + { + item.width = 12; + item.damage = 40; + item.noMelee = true; + item.consumable = true; + item.noUseGraphic = true; + item.useAnimation = 10; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = 10; + item.knockBack = 1.75f; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.height = 30; + item.maxStack = 999; + item.value = 1100; + item.rare = ItemRarityID.LightRed; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 12f; + item.Calamity().rogue = 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) - { - if (player.Calamity().StealthStrikeAvailable()) - { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - return false; - } - return 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) + { + if (player.Calamity().StealthStrikeAvailable()) + { + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + return false; + } + return true; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.MythrilBar); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this, 100); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.MythrilBar); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this, 100); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/NastyCholla.cs b/Items/Weapons/Rogue/NastyCholla.cs index 506b2327bd..c99ff47fcc 100644 --- a/Items/Weapons/Rogue/NastyCholla.cs +++ b/Items/Weapons/Rogue/NastyCholla.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class NastyCholla : RogueWeapon + public class NastyCholla : RogueWeapon { public static int BaseDamage = 9; @@ -25,8 +25,8 @@ Stealth strikes throw five at once"); item.damage = BaseDamage; item.noMelee = true; item.noUseGraphic = true; - item.maxStack = 999; - item.consumable = true; + item.maxStack = 999; + item.consumable = true; item.useAnimation = 20; item.useStyle = ItemUseStyleID.SwingThrow; item.useTime = 20; @@ -49,8 +49,8 @@ Stealth strikes throw five at once"); { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread)); int proj = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; spread -= Main.rand.Next(1,4); } return false; diff --git a/Items/Weapons/Rogue/Nychthemeron.cs b/Items/Weapons/Rogue/Nychthemeron.cs index 96db7a9a2d..fd837b4049 100644 --- a/Items/Weapons/Rogue/Nychthemeron.cs +++ b/Items/Weapons/Rogue/Nychthemeron.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Rogue "Once the spiky ball disappears the orbs will home in on the nearest target\n" + "Stacks up to 10\n" + "Stealth strikes cause all spiky balls and orbs to be thrown at once\n" + - "Right click to recall all existing spiky balls"); + "Right click to recall all existing spiky balls"); } public override void SafeSetDefaults() @@ -64,8 +64,8 @@ namespace CalamityMod.Items.Weapons.Rogue float spread = 2; int pIndex = Projectile.NewProjectile(position.X, position.Y, speedX + Main.rand.NextFloat(-spread, spread), speedY + Main.rand.NextFloat(-spread, spread), type, Math.Max(damage / 3, 1), knockBack, player.whoAmI, 0f, 1f); Projectile p = Main.projectile[pIndex]; - if (pIndex.WithinBounds(Main.maxProjectiles)) - p.Calamity().stealthStrike = true; + if (pIndex.WithinBounds(Main.maxProjectiles)) + p.Calamity().stealthStrike = true; int pID = p.identity; CreateOrbs(position, (int)(orbDamage * 0.675f), knockBack, pID, player, true); @@ -81,22 +81,22 @@ namespace CalamityMod.Items.Weapons.Rogue return false; } - public override bool CanUseItem(Player player) - { - if (player.altFunctionUse == 2) - { - item.shoot = ProjectileID.None; - item.shootSpeed = 0f; - return player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; - } - else - { - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 6f; - int UseMax = item.stack; - return player.ownedProjectileCounts[ModContent.ProjectileType()] < UseMax; - } - } + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse == 2) + { + item.shoot = ProjectileID.None; + item.shootSpeed = 0f; + return player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; + } + else + { + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 6f; + int UseMax = item.stack; + return player.ownedProjectileCounts[ModContent.ProjectileType()] < UseMax; + } + } public override void AddRecipes() { @@ -104,8 +104,8 @@ namespace CalamityMod.Items.Weapons.Rogue recipe.AddIngredient(ItemID.SpikyBall, 30); recipe.AddIngredient(ItemID.LightShard); recipe.AddIngredient(ItemID.DarkShard); - recipe.AddRecipeGroup("AnyMythrilBar", 2); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddRecipeGroup("AnyMythrilBar", 2); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } @@ -158,18 +158,18 @@ namespace CalamityMod.Items.Weapons.Rogue int orb1 = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, orb1Col, projectileID); int orb2 = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, orb2Col, projectileID); - if (orb1.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[orb1].localAI[1] = pos; - Main.projectile[orb1].rotation = rotationOffset; - Main.projectile[orb1].Calamity().lineColor = stealth ? 1 : 0; - } - if (orb2.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[orb2].localAI[1] = pos; - Main.projectile[orb2].rotation = rotationOffset + MathHelper.ToRadians(180f); - Main.projectile[orb2].Calamity().lineColor = stealth ? 1 : 0; - } + if (orb1.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[orb1].localAI[1] = pos; + Main.projectile[orb1].rotation = rotationOffset; + Main.projectile[orb1].Calamity().lineColor = stealth ? 1 : 0; + } + if (orb2.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[orb2].localAI[1] = pos; + Main.projectile[orb2].rotation = rotationOffset + MathHelper.ToRadians(180f); + Main.projectile[orb2].Calamity().lineColor = stealth ? 1 : 0; + } } } } diff --git a/Items/Weapons/Rogue/OrichalcumSpikedGemstone.cs b/Items/Weapons/Rogue/OrichalcumSpikedGemstone.cs index 7779835a32..ae59bfabcd 100644 --- a/Items/Weapons/Rogue/OrichalcumSpikedGemstone.cs +++ b/Items/Weapons/Rogue/OrichalcumSpikedGemstone.cs @@ -38,19 +38,19 @@ 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) { - if (player.Calamity().StealthStrikeAvailable()) - { - int gemstone = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (gemstone.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[gemstone].Calamity().stealthStrike = true; - Main.projectile[gemstone].usesLocalNPCImmunity = true; - Main.projectile[gemstone].timeLeft = 900; - Main.projectile[gemstone].penetrate = -1; - } - return false; - } - return true; + if (player.Calamity().StealthStrikeAvailable()) + { + int gemstone = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (gemstone.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[gemstone].Calamity().stealthStrike = true; + Main.projectile[gemstone].usesLocalNPCImmunity = true; + Main.projectile[gemstone].timeLeft = 900; + Main.projectile[gemstone].penetrate = -1; + } + return false; + } + return true; } public override void AddRecipes() diff --git a/Items/Weapons/Rogue/PalladiumJavelin.cs b/Items/Weapons/Rogue/PalladiumJavelin.cs index fd4e8e5326..3a8b5596d8 100644 --- a/Items/Weapons/Rogue/PalladiumJavelin.cs +++ b/Items/Weapons/Rogue/PalladiumJavelin.cs @@ -42,13 +42,13 @@ namespace CalamityMod.Items.Weapons.Rogue damage = (int)(damage * 1.425f); int javelin = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (javelin.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[javelin].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - if (!player.Calamity().StealthStrikeAvailable()) - Main.projectile[javelin].usesLocalNPCImmunity = false; - } - return false; + if (javelin.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[javelin].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (!player.Calamity().StealthStrikeAvailable()) + Main.projectile[javelin].usesLocalNPCImmunity = false; + } + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Rogue/PhantomLance.cs b/Items/Weapons/Rogue/PhantomLance.cs index 390129866a..b3966815ae 100644 --- a/Items/Weapons/Rogue/PhantomLance.cs +++ b/Items/Weapons/Rogue/PhantomLance.cs @@ -48,8 +48,8 @@ Stealth strikes don't slow down and souls always deal full damage"); if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 1.75f), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/PoisonPack.cs b/Items/Weapons/Rogue/PoisonPack.cs index 1585f1d558..aa002a7804 100644 --- a/Items/Weapons/Rogue/PoisonPack.cs +++ b/Items/Weapons/Rogue/PoisonPack.cs @@ -7,7 +7,7 @@ using CalamityMod.CalPlayer; namespace CalamityMod.Items.Weapons.Rogue { - public class PoisonPack : RogueWeapon + public class PoisonPack : RogueWeapon { private static int baseDamage = 20; private static float baseKnockback = 1.8f; @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Rogue DisplayName.SetDefault("Poison Pack"); Tooltip.SetDefault("Throws a poisonous spiky ball. Stacks up to 3.\n" + "Stealth strikes cause the balls to release spore clouds\n" + - "Right click to delete all existing spiky balls"); + "Right click to delete all existing spiky balls"); } public override void SafeSetDefaults() @@ -41,35 +41,35 @@ namespace CalamityMod.Items.Weapons.Rogue item.shoot = ModContent.ProjectileType(); } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; - public override bool CanUseItem(Player player) - { - if (player.altFunctionUse == 2) - { - item.shoot = ProjectileID.None; - item.shootSpeed = 0f; - return player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; - } - else - { - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 7f; - int UseMax = item.stack; - return player.ownedProjectileCounts[ModContent.ProjectileType()] < UseMax; - } - } + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse == 2) + { + item.shoot = ProjectileID.None; + item.shootSpeed = 0f; + return player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; + } + else + { + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 7f; + int UseMax = item.stack; + return player.ownedProjectileCounts[ModContent.ProjectileType()] < UseMax; + } + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.killSpikyBalls = false; + modPlayer.killSpikyBalls = false; if (modPlayer.StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; @@ -78,7 +78,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool AltFunctionUse(Player player) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.killSpikyBalls = true; + modPlayer.killSpikyBalls = true; return true; } diff --git a/Items/Weapons/Rogue/Prismalline.cs b/Items/Weapons/Rogue/Prismalline.cs index 923092e91f..7813bde34f 100644 --- a/Items/Weapons/Rogue/Prismalline.cs +++ b/Items/Weapons/Rogue/Prismalline.cs @@ -8,59 +8,59 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class Prismalline : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Prismalline"); - Tooltip.SetDefault("Throws daggers that split after a while\n" + - "Stealth strikes additionally explode into prism shards and briefly stun enemies"); - } + public class Prismalline : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Prismalline"); + Tooltip.SetDefault("Throws daggers that split after a while\n" + + "Stealth strikes additionally explode into prism shards and briefly stun enemies"); + } - public override void SafeSetDefaults() - { - item.width = 46; - item.damage = 24; - item.noMelee = true; - item.noUseGraphic = true; - item.useAnimation = 16; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 16; - item.knockBack = 5f; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.height = 46; - item.value = Item.buyPrice(0, 36, 0, 0); - item.rare = ItemRarityID.Pink; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 16f; - item.Calamity().rogue = true; - } + public override void SafeSetDefaults() + { + item.width = 46; + item.damage = 24; + item.noMelee = true; + item.noUseGraphic = true; + item.useAnimation = 16; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = 16; + item.knockBack = 5f; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.height = 46; + item.value = Item.buyPrice(0, 36, 0, 0); + item.rare = ItemRarityID.Pink; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 16f; + item.Calamity().rogue = true; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; - 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()) - { - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 1.15f), knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; - return false; - } - return 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) + { + if (player.Calamity().StealthStrikeAvailable()) + { + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 1.15f), knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; + return false; + } + return true; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/RadiantStar.cs b/Items/Weapons/Rogue/RadiantStar.cs index cdba3b3bae..9afa81ef80 100644 --- a/Items/Weapons/Rogue/RadiantStar.cs +++ b/Items/Weapons/Rogue/RadiantStar.cs @@ -37,8 +37,8 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 8; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 8; public override void AddRecipes() { @@ -57,8 +57,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/RefractionRotor.cs b/Items/Weapons/Rogue/RefractionRotor.cs index 48056eeaad..ed74c60309 100644 --- a/Items/Weapons/Rogue/RefractionRotor.cs +++ b/Items/Weapons/Rogue/RefractionRotor.cs @@ -6,45 +6,45 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class RefractionRotor : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Refraction Rotor"); - Tooltip.SetDefault("Fires a huge prismatic disk shuriken\n" + - "The shuriken shatters moments after impact into homing rockets\n" + - "Stealth strikes shatter into many more rockets"); - } + public class RefractionRotor : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Refraction Rotor"); + Tooltip.SetDefault("Fires a huge prismatic disk shuriken\n" + + "The shuriken shatters moments after impact into homing rockets\n" + + "Stealth strikes shatter into many more rockets"); + } - public override void SafeSetDefaults() - { - item.width = item.height = 120; - item.damage = 616; - item.knockBack = 8.5f; - item.useAnimation = item.useTime = 17; - item.Calamity().rogue = true; - item.autoReuse = true; - item.shootSpeed = 18f; - item.shoot = ModContent.ProjectileType(); + public override void SafeSetDefaults() + { + item.width = item.height = 120; + item.damage = 616; + item.knockBack = 8.5f; + item.useAnimation = item.useTime = 17; + item.Calamity().rogue = true; + item.autoReuse = true; + item.shootSpeed = 18f; + item.shoot = ModContent.ProjectileType(); - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.noMelee = true; - item.noUseGraphic = true; - item.value = CalamityGlobalItem.RarityVioletBuyPrice; - item.rare = ItemRarityID.Red; - item.Calamity().customRarity = CalamityRarity.Violet; - } + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.noMelee = true; + item.noUseGraphic = true; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.Violet; + } - 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()) - damage = (int)(damage * 0.75D); + 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()) + damage = (int)(damage * 0.75D); - int shuriken = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable() && Main.projectile.IndexInRange(shuriken)) - Main.projectile[shuriken].Calamity().stealthStrike = true; - return false; - } - } + int shuriken = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (player.Calamity().StealthStrikeAvailable() && Main.projectile.IndexInRange(shuriken)) + Main.projectile[shuriken].Calamity().stealthStrike = true; + return false; + } + } } diff --git a/Items/Weapons/Rogue/RegulusRiot.cs b/Items/Weapons/Rogue/RegulusRiot.cs index 550b3013a4..bfa4f4e584 100644 --- a/Items/Weapons/Rogue/RegulusRiot.cs +++ b/Items/Weapons/Rogue/RegulusRiot.cs @@ -6,7 +6,7 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Rogue { - public class RegulusRiot : RogueWeapon + public class RegulusRiot : RogueWeapon { public override void SetStaticDefaults() { @@ -43,8 +43,8 @@ Stealth strikes explode into energy stars"); if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 1.2f), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/RogueWeapon.cs b/Items/Weapons/Rogue/RogueWeapon.cs index 2eaf823ad0..b829e2df3e 100644 --- a/Items/Weapons/Rogue/RogueWeapon.cs +++ b/Items/Weapons/Rogue/RogueWeapon.cs @@ -8,163 +8,163 @@ using Terraria.Utilities; namespace CalamityMod.Items.Weapons.Rogue { - public abstract class RogueWeapon : ModItem - { - public virtual void SafeSetDefaults() - { - } + public abstract class RogueWeapon : ModItem + { + public virtual void SafeSetDefaults() + { + } - public float StealthStrikePrefixBonus; + public float StealthStrikePrefixBonus; - public RogueWeapon() - { - StealthStrikePrefixBonus = 1f; - } + public RogueWeapon() + { + StealthStrikePrefixBonus = 1f; + } - public override ModItem Clone(Item itemClone) - { - RogueWeapon myClone = (RogueWeapon)base.Clone(itemClone); - myClone.StealthStrikePrefixBonus = StealthStrikePrefixBonus; - return myClone; - } + public override ModItem Clone(Item itemClone) + { + RogueWeapon myClone = (RogueWeapon)base.Clone(itemClone); + myClone.StealthStrikePrefixBonus = StealthStrikePrefixBonus; + return myClone; + } - public override int ChoosePrefix(UnifiedRandom rand) - { - WeightedRandom newPrefix = new WeightedRandom(); - newPrefix.Add("Pointy", 1); - newPrefix.Add("Sharp", 1); - newPrefix.Add("Feathered", 1); - newPrefix.Add("Sleek", 1); - newPrefix.Add("Hefty", 1); - newPrefix.Add("Mighty", 1); - newPrefix.Add("Glorious", 1); - newPrefix.Add("Serrated", 1); - newPrefix.Add("Vicious", 1); - newPrefix.Add("Lethal", 1); - newPrefix.Add("Flawless", 1); - newPrefix.Add("Radical", 1); - newPrefix.Add("Blunt", 1); - newPrefix.Add("Flimsy", 1); - newPrefix.Add("Unbalanced", 1); - newPrefix.Add("Atrocious", 1); - return mod.GetPrefix(newPrefix).Type; - } + public override int ChoosePrefix(UnifiedRandom rand) + { + WeightedRandom newPrefix = new WeightedRandom(); + newPrefix.Add("Pointy", 1); + newPrefix.Add("Sharp", 1); + newPrefix.Add("Feathered", 1); + newPrefix.Add("Sleek", 1); + newPrefix.Add("Hefty", 1); + newPrefix.Add("Mighty", 1); + newPrefix.Add("Glorious", 1); + newPrefix.Add("Serrated", 1); + newPrefix.Add("Vicious", 1); + newPrefix.Add("Lethal", 1); + newPrefix.Add("Flawless", 1); + newPrefix.Add("Radical", 1); + newPrefix.Add("Blunt", 1); + newPrefix.Add("Flimsy", 1); + newPrefix.Add("Unbalanced", 1); + newPrefix.Add("Atrocious", 1); + return mod.GetPrefix(newPrefix).Type; + } - public override bool NewPreReforge() - { - StealthStrikePrefixBonus = 1f; - return true; - } + public override bool NewPreReforge() + { + StealthStrikePrefixBonus = 1f; + return true; + } - public override bool? PrefixChance(int pre, UnifiedRandom rand) - { - if (item.maxStack > 1) - { - return false; - } - return null; - } + public override bool? PrefixChance(int pre, UnifiedRandom rand) + { + if (item.maxStack > 1) + { + return false; + } + return null; + } - public sealed override void SetDefaults() - { - SafeSetDefaults(); - item.melee = false; - item.ranged = false; - item.magic = false; - item.thrown = true; - item.summon = false; - } + public sealed override void SetDefaults() + { + SafeSetDefaults(); + item.melee = false; + item.ranged = false; + item.magic = false; + item.thrown = true; + item.summon = false; + } - // Add both the player's dedicated rogue damage and stealth strike damage as applicable. - // 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 sealed override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) - { - CalamityPlayer mp = player.Calamity(); + // Add both the player's dedicated rogue damage and stealth strike damage as applicable. + // 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 sealed override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) + { + CalamityPlayer mp = player.Calamity(); - SafeModifyWeaponDamage(player, ref add, ref mult, ref flat); + SafeModifyWeaponDamage(player, ref add, ref mult, ref flat); - // Both regular rogue damage stat and stealth damage are added to the weapon simultaneously. - add += mp.throwingDamage + mp.stealthDamage - 1f; + // Both regular rogue damage stat and stealth damage are added to the weapon simultaneously. + add += mp.throwingDamage + mp.stealthDamage - 1f; - // Boost (or lower) the weapon's damage if it has a stealth strike available and an associated prefix - if (mp.StealthStrikeAvailable() && item.prefix > 0) - mult += StealthStrikePrefixBonus - 1f; - } + // Boost (or lower) the weapon's damage if it has a stealth strike available and an associated prefix + if (mp.StealthStrikeAvailable() && item.prefix > 0) + mult += StealthStrikePrefixBonus - 1f; + } - public virtual void SafeModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) { } + public virtual void SafeModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) { } - // 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 += player.Calamity().throwingCrit; - } + // 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 += player.Calamity().throwingCrit; + } - public sealed override float UseTimeMultiplier(Player player) - { - float baseMultiplier = SafeSetUseTimeMultiplier(player); - float rogueAS = baseMultiplier == -1f ? 1f : baseMultiplier; - if (item.useTime == item.useAnimation) - { - rogueAS += player.Calamity().rogueUseSpeedFactor; - } - return rogueAS; - } + public sealed override float UseTimeMultiplier(Player player) + { + float baseMultiplier = SafeSetUseTimeMultiplier(player); + float rogueAS = baseMultiplier == -1f ? 1f : baseMultiplier; + if (item.useTime == item.useAnimation) + { + rogueAS += player.Calamity().rogueUseSpeedFactor; + } + return rogueAS; + } - public virtual float SafeSetUseTimeMultiplier(Player player) => -1f; + public virtual float SafeSetUseTimeMultiplier(Player player) => -1f; - public virtual void SafeModifyTooltips(List tooltips) - { - } + public virtual void SafeModifyTooltips(List tooltips) + { + } - public override void ModifyTooltips(List tooltips) - { - TooltipLine damageTooltip = tooltips.FirstOrDefault(x => x.Name == "Damage" && x.mod == "Terraria"); - if (damageTooltip != null) - { - // Replace the word "throwing" with "rogue" in the item's damage line. - string text = damageTooltip.text.Replace(" throwing ", " rogue "); + public override void ModifyTooltips(List tooltips) + { + TooltipLine damageTooltip = tooltips.FirstOrDefault(x => x.Name == "Damage" && x.mod == "Terraria"); + if (damageTooltip != null) + { + // Replace the word "throwing" with "rogue" in the item's damage line. + string text = damageTooltip.text.Replace(" throwing ", " rogue "); - // Split visible damage into stealth and non-stealth damage values if the player has the stealth mechanic available to them. - Player p = Main.LocalPlayer; - CalamityPlayer mp = p.Calamity(); - if (mp.rogueStealthMax > 0f) - { - int damageNumberSubstringIndex = text.IndexOf(' '); - if (damageNumberSubstringIndex >= 0) - { - string restOfTooltip = text.Substring(damageNumberSubstringIndex); - int damageWithStealth = int.Parse(text.Substring(0, damageNumberSubstringIndex)); + // Split visible damage into stealth and non-stealth damage values if the player has the stealth mechanic available to them. + Player p = Main.LocalPlayer; + CalamityPlayer mp = p.Calamity(); + if (mp.rogueStealthMax > 0f) + { + int damageNumberSubstringIndex = text.IndexOf(' '); + if (damageNumberSubstringIndex >= 0) + { + string restOfTooltip = text.Substring(damageNumberSubstringIndex); + int damageWithStealth = int.Parse(text.Substring(0, damageNumberSubstringIndex)); - int damageWithoutStealth = (int)(item.damage * (p.allDamage + p.thrownDamage + mp.throwingDamage - 2f)); - text = damageWithoutStealth + restOfTooltip + " : " + damageWithStealth + " stealth strike damage"; - } - } + int damageWithoutStealth = (int)(item.damage * (p.allDamage + p.thrownDamage + mp.throwingDamage - 2f)); + text = damageWithoutStealth + restOfTooltip + " : " + damageWithStealth + " stealth strike damage"; + } + } - damageTooltip.text = text; - } + damageTooltip.text = text; + } - // Add a tooltip line for the stealth strike damage bonus of the item's prefix, if applicable. - if (item.prefix > 0) - { - float ssDmgBoost = StealthStrikePrefixBonus - 1f; - if (ssDmgBoost != 0f) - { - bool badModifier = ssDmgBoost < 0f; - string txt = (badModifier ? "-" : "+") + Math.Round(Math.Abs(ssDmgBoost) * 100f) + "% stealth strike damage"; - TooltipLine stealthTooltip = new TooltipLine(mod, "PrefixSSDmg", txt) - { - isModifier = true, - isModifierBad = badModifier - }; - tooltips.Add(stealthTooltip); - } - } + // Add a tooltip line for the stealth strike damage bonus of the item's prefix, if applicable. + if (item.prefix > 0) + { + float ssDmgBoost = StealthStrikePrefixBonus - 1f; + if (ssDmgBoost != 0f) + { + bool badModifier = ssDmgBoost < 0f; + string txt = (badModifier ? "-" : "+") + Math.Round(Math.Abs(ssDmgBoost) * 100f) + "% stealth strike damage"; + TooltipLine stealthTooltip = new TooltipLine(mod, "PrefixSSDmg", txt) + { + isModifier = true, + isModifierBad = badModifier + }; + tooltips.Add(stealthTooltip); + } + } - SafeModifyTooltips(tooltips); - } + SafeModifyTooltips(tooltips); + } - public override bool ConsumeItem(Player player) => Main.rand.NextFloat() <= player.Calamity().throwingAmmoCost; - } + public override bool ConsumeItem(Player player) => Main.rand.NextFloat() <= player.Calamity().throwingAmmoCost; + } } diff --git a/Items/Weapons/Rogue/RotBall.cs b/Items/Weapons/Rogue/RotBall.cs index bcb7b28055..57cc10981c 100644 --- a/Items/Weapons/Rogue/RotBall.cs +++ b/Items/Weapons/Rogue/RotBall.cs @@ -37,19 +37,19 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 8; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 8; 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()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; - } + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } return false; } return true; diff --git a/Items/Weapons/Rogue/SandDollar.cs b/Items/Weapons/Rogue/SandDollar.cs index 0abf17e0e7..9484b5ed1f 100644 --- a/Items/Weapons/Rogue/SandDollar.cs +++ b/Items/Weapons/Rogue/SandDollar.cs @@ -7,13 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class SandDollar : RogueWeapon + public class SandDollar : RogueWeapon { public override void SetStaticDefaults() { DisplayName.SetDefault("Sand Dollar"); Tooltip.SetDefault("Stacks up to 2\n" + - "Stealth strikes throw 2 long ranged sand dollars that explode into coral shards on enemy hits"); + "Stealth strikes throw 2 long ranged sand dollars that explode into coral shards on enemy hits"); } public override void SafeSetDefaults() @@ -40,16 +40,16 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool CanUseItem(Player player) { - int UseMax = item.stack - 1; + int UseMax = item.stack - 1; - if (player.ownedProjectileCounts[item.shoot] > UseMax && !player.Calamity().StealthStrikeAvailable()) - { - return false; - } - else - { - return true; - } + if (player.ownedProjectileCounts[item.shoot] > UseMax && !player.Calamity().StealthStrikeAvailable()) + { + return false; + } + else + { + return 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) @@ -60,12 +60,12 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = 0; i < 2; i++) { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-2,3), speedY + Main.rand.Next(-2,3)).RotatedBy(MathHelper.ToRadians(spread)); - int stealth = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X * 1.5f, perturbedspeed.Y * 1.5f, ModContent.ProjectileType(), Math.Max((int)(damage * 0.75), 1), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X * 1.5f, perturbedspeed.Y * 1.5f, ModContent.ProjectileType(), Math.Max((int)(damage * 0.75), 1), knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; spread -= Main.rand.Next(1,3); - } - return false; + } + return false; } return true; } diff --git a/Items/Weapons/Rogue/Sandslasher.cs b/Items/Weapons/Rogue/Sandslasher.cs index 25600caea7..77975c031c 100644 --- a/Items/Weapons/Rogue/Sandslasher.cs +++ b/Items/Weapons/Rogue/Sandslasher.cs @@ -7,58 +7,58 @@ using CalamityMod.Projectiles.Rogue; namespace CalamityMod.Items.Weapons.Rogue { - public class Sandslasher : RogueWeapon + public class Sandslasher : RogueWeapon { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Sandslasher"); - Tooltip.SetDefault("Throws a huge shuriken made out of fused sand unaffected by gravity which slowly accelerates horizontally\n" - +"It does more damage depending on how fast it goes horizontally and how long it has been flying for\n" + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sandslasher"); + Tooltip.SetDefault("Throws a huge shuriken made out of fused sand unaffected by gravity which slowly accelerates horizontally\n" + +"It does more damage depending on how fast it goes horizontally and how long it has been flying for\n" +"Stealth strikes periodically release sand clouds"); } - public override void SafeSetDefaults() - { - item.width = 40; - item.height = 40; - item.damage = 115; - item.noMelee = true; - item.noUseGraphic = true; - item.useAnimation = 20; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 20; - item.knockBack = 5f; - item.UseSound = SoundID.Item1; - item.autoReuse = true; + public override void SafeSetDefaults() + { + item.width = 40; + item.height = 40; + item.damage = 115; + item.noMelee = true; + item.noUseGraphic = true; + item.useAnimation = 20; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = 20; + item.knockBack = 5f; + item.UseSound = SoundID.Item1; + item.autoReuse = true; item.value = Item.buyPrice(0, 60, 0, 0); item.rare = ItemRarityID.Lime; item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 7f; + item.shootSpeed = 7f; item.Calamity().rogue = 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) { if (player.Calamity().StealthStrikeAvailable()) { int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; } public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 6); + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 6); recipe.AddRecipeGroup("AnyGoldBar", 10); recipe.AddIngredient(ItemID.HardenedSand, 25); recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/ScarletDevil.cs b/Items/Weapons/Rogue/ScarletDevil.cs index 773094afa7..0f4dc56507 100644 --- a/Items/Weapons/Rogue/ScarletDevil.cs +++ b/Items/Weapons/Rogue/ScarletDevil.cs @@ -48,8 +48,8 @@ namespace CalamityMod.Items.Weapons.Rogue return false; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; public override void AddRecipes() { diff --git a/Items/Weapons/Rogue/ScourgeoftheDesert.cs b/Items/Weapons/Rogue/ScourgeoftheDesert.cs index 8fe1619e99..00c77de07b 100644 --- a/Items/Weapons/Rogue/ScourgeoftheDesert.cs +++ b/Items/Weapons/Rogue/ScourgeoftheDesert.cs @@ -40,8 +40,8 @@ Stealth strikes gain damage as they damage enemies"); if (player.Calamity().StealthStrikeAvailable()) { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ScourgeoftheSeas.cs b/Items/Weapons/Rogue/ScourgeoftheSeas.cs index 1082f1fc05..3246ab5208 100644 --- a/Items/Weapons/Rogue/ScourgeoftheSeas.cs +++ b/Items/Weapons/Rogue/ScourgeoftheSeas.cs @@ -6,45 +6,45 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class ScourgeoftheSeas : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Scourge of the Seas"); - Tooltip.SetDefault("Snaps apart into a venomous cloud upon striking an enemy\n" + - "Stealth strikes are coated with vile toxins, afflicting enemies with a powerful debuff"); - } + public class ScourgeoftheSeas : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Scourge of the Seas"); + Tooltip.SetDefault("Snaps apart into a venomous cloud upon striking an enemy\n" + + "Stealth strikes are coated with vile toxins, afflicting enemies with a powerful debuff"); + } - public override void SafeSetDefaults() - { - item.damage = 45; - item.knockBack = 3.5f; - item.useAnimation = item.useTime = 20; - item.autoReuse = true; - item.Calamity().rogue = true; - item.shootSpeed = 8f; - item.shoot = ModContent.ProjectileType(); + public override void SafeSetDefaults() + { + item.damage = 45; + item.knockBack = 3.5f; + item.useAnimation = item.useTime = 20; + item.autoReuse = true; + item.Calamity().rogue = true; + item.shootSpeed = 8f; + item.shoot = ModContent.ProjectileType(); - item.width = 64; - item.height = 66; - item.noMelee = true; - item.noUseGraphic = true; - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.rare = ItemRarityID.Pink; - item.value = Item.buyPrice(0, 36, 0, 0); - } + item.width = 64; + item.height = 66; + item.noMelee = true; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.rare = ItemRarityID.Pink; + item.value = Item.buyPrice(0, 36, 0, 0); + } - 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()) //setting the stealth strike - { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - return false; - } - return 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) + { + if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike + { + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + return false; + } + return true; + } + } } diff --git a/Items/Weapons/Rogue/SeafoamBomb.cs b/Items/Weapons/Rogue/SeafoamBomb.cs index cd7a4a64b9..40ac008327 100644 --- a/Items/Weapons/Rogue/SeafoamBomb.cs +++ b/Items/Weapons/Rogue/SeafoamBomb.cs @@ -51,8 +51,8 @@ Stealth strikes are faster and explode into 5 bubbles"); if (player.Calamity().StealthStrikeAvailable()) { int stealth = Projectile.NewProjectile(position, new Vector2(speedX + speedX / 3, speedY + speedY / 3), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SealedSingularity.cs b/Items/Weapons/Rogue/SealedSingularity.cs index 29ecb86a76..7e2c0f6b56 100644 --- a/Items/Weapons/Rogue/SealedSingularity.cs +++ b/Items/Weapons/Rogue/SealedSingularity.cs @@ -7,57 +7,57 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class SealedSingularity : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Sealed Singularity"); - Tooltip.SetDefault("Shatters on impact, summoning a black hole that sucks in nearby enemies\n" + - "Stealth strikes summon a black hole that lasts longer and sucks enemies with stronger force"); - } + public class SealedSingularity : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sealed Singularity"); + Tooltip.SetDefault("Shatters on impact, summoning a black hole that sucks in nearby enemies\n" + + "Stealth strikes summon a black hole that lasts longer and sucks enemies with stronger force"); + } - public override void SafeSetDefaults() - { - item.damage = 260; - item.knockBack = 5f; - item.useAnimation = item.useTime = 25; - item.useStyle = ItemUseStyleID.SwingThrow; - item.Calamity().rogue = true; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 14f; + public override void SafeSetDefaults() + { + item.damage = 260; + item.knockBack = 5f; + item.useAnimation = item.useTime = 25; + item.useStyle = ItemUseStyleID.SwingThrow; + item.Calamity().rogue = true; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 14f; - item.noMelee = item.noUseGraphic = true; - item.height = item.width = 34; - item.UseSound = SoundID.Item106; + item.noMelee = item.noUseGraphic = true; + item.height = item.width = 34; + item.UseSound = SoundID.Item106; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.Calamity().donorItem = true; - } + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.Calamity().donorItem = 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) - { - if (player.Calamity().StealthStrikeAvailable()) - { - // Directly nerf stealth strikes by 32%, but only stealth strikes. - int stealthDamage = (int)(damage * 0.72f); - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, stealthDamage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - return false; - } - return 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) + { + if (player.Calamity().StealthStrikeAvailable()) + { + // Directly nerf stealth strikes by 32%, but only stealth strikes. + int stealthDamage = (int)(damage * 0.72f); + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, stealthDamage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + return false; + } + return true; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/SearedPan.cs b/Items/Weapons/Rogue/SearedPan.cs index 659285bab8..82ef99fe57 100644 --- a/Items/Weapons/Rogue/SearedPan.cs +++ b/Items/Weapons/Rogue/SearedPan.cs @@ -8,66 +8,66 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class SearedPan : RogueWeapon - { - // Attacks must be within 40 frames of each other to count as "consecutive" hits - // This is a little less than double the use time + public class SearedPan : RogueWeapon + { + // Attacks must be within 40 frames of each other to count as "consecutive" hits + // This is a little less than double the use time public static int ConsecutiveHitOpening = 40; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Seared Pan"); - Tooltip.SetDefault("dAMaGe iS rAthEr cOnSisTeNT\n" + - "Fires a frying pan at high velocity\n" + - "Enemy hits summon fireballs that linger around the target\n" + - "Landing three consecutive hits grants will launch a golden pan\n" + - "Golden pans cause all fireballs to aggressively home in on their target\n" + - "Stealth strikes act similar to golden pans but also explode into golden sparks\n" + - "Stealth strikes also summon additional fireballs on hit"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Seared Pan"); + Tooltip.SetDefault("dAMaGe iS rAthEr cOnSisTeNT\n" + + "Fires a frying pan at high velocity\n" + + "Enemy hits summon fireballs that linger around the target\n" + + "Landing three consecutive hits grants will launch a golden pan\n" + + "Golden pans cause all fireballs to aggressively home in on their target\n" + + "Stealth strikes act similar to golden pans but also explode into golden sparks\n" + + "Stealth strikes also summon additional fireballs on hit"); + } - public override void SafeSetDefaults() - { - item.width = 60; - item.height = 36; - item.damage = 2222; - item.Calamity().rogue = true; - item.knockBack = 10f; - item.noMelee = true; - item.noUseGraphic = true; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = item.useAnimation = 25; - item.reuseDelay = 1; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.value = CalamityGlobalItem.Rarity15BuyPrice; + public override void SafeSetDefaults() + { + item.width = 60; + item.height = 36; + item.damage = 2222; + item.Calamity().rogue = true; + item.knockBack = 10f; + item.noMelee = true; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = item.useAnimation = 25; + item.reuseDelay = 1; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.value = CalamityGlobalItem.Rarity15BuyPrice; item.Calamity().customRarity = CalamityRarity.Violet; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 15f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 15f; item.Calamity().donorItem = 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) - { - float mode = 1f; - if (player.Calamity().searedPanCounter >= 3) - { - player.Calamity().searedPanCounter = 0; - mode = 2f; - } - if (player.Calamity().StealthStrikeAvailable()) - { - player.Calamity().searedPanCounter = 0; - mode = 3f; - } - int pan = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, mode); - if (mode > 1f && pan.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[pan].extraUpdates++; - if (mode == 3f) - Main.projectile[pan].Calamity().stealthStrike = true; - } - return false; - } + 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 mode = 1f; + if (player.Calamity().searedPanCounter >= 3) + { + player.Calamity().searedPanCounter = 0; + mode = 2f; + } + if (player.Calamity().StealthStrikeAvailable()) + { + player.Calamity().searedPanCounter = 0; + mode = 3f; + } + int pan = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, mode); + if (mode > 1f && pan.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[pan].extraUpdates++; + if (mode == 3f) + Main.projectile[pan].Calamity().stealthStrike = true; + } + return false; + } public override void AddRecipes() { @@ -82,5 +82,5 @@ namespace CalamityMod.Items.Weapons.Rogue recipe.SetResult(this); recipe.AddRecipe(); } - } + } } diff --git a/Items/Weapons/Rogue/SeashellBoomerang.cs b/Items/Weapons/Rogue/SeashellBoomerang.cs index d627f75c7f..d0110856d6 100644 --- a/Items/Weapons/Rogue/SeashellBoomerang.cs +++ b/Items/Weapons/Rogue/SeashellBoomerang.cs @@ -37,8 +37,8 @@ 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 proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/Rogue/ShinobiBlade.cs b/Items/Weapons/Rogue/ShinobiBlade.cs index 30b34b2e43..50ef87df8f 100644 --- a/Items/Weapons/Rogue/ShinobiBlade.cs +++ b/Items/Weapons/Rogue/ShinobiBlade.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Shinobi Blade"); Tooltip.SetDefault("Throws a fast blade that spawns healing orbs when it kills an enemy\n" + - "Stealth strikes cause 3 blades to be thrown at once"); + "Stealth strikes cause 3 blades to be thrown at once"); } public override void SafeSetDefaults() @@ -49,8 +49,8 @@ namespace CalamityMod.Items.Weapons.Rogue Vector2 currentDirection = baseDirection.RotatedBy(spreadAngle * i); int p = Projectile.NewProjectile(position, currentDirection, type, damage, knockBack, player.whoAmI); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; } return false; } diff --git a/Items/Weapons/Rogue/ShockGrenade.cs b/Items/Weapons/Rogue/ShockGrenade.cs index 4be340d1d9..4830e28981 100644 --- a/Items/Weapons/Rogue/ShockGrenade.cs +++ b/Items/Weapons/Rogue/ShockGrenade.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class ShockGrenade : RogueWeapon + public class ShockGrenade : RogueWeapon { public override void SetStaticDefaults() { @@ -42,8 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; @@ -51,7 +51,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/ShockGrenadeGlow")); + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/ShockGrenadeGlow")); } public override void AddRecipes() diff --git a/Items/Weapons/Rogue/Shroomerang.cs b/Items/Weapons/Rogue/Shroomerang.cs index 8244457b6f..97dfa83c5b 100644 --- a/Items/Weapons/Rogue/Shroomerang.cs +++ b/Items/Weapons/Rogue/Shroomerang.cs @@ -39,8 +39,8 @@ Stealth strikes grant the Mushy buff to the user on enemy hits and summon homing if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SkyStabber.cs b/Items/Weapons/Rogue/SkyStabber.cs index 14f982357b..fbfc5c6c90 100644 --- a/Items/Weapons/Rogue/SkyStabber.cs +++ b/Items/Weapons/Rogue/SkyStabber.cs @@ -8,7 +8,7 @@ using CalamityMod.CalPlayer; namespace CalamityMod.Items.Weapons.Rogue { - public class SkyStabber : RogueWeapon + public class SkyStabber : RogueWeapon { private static int damage = 50; private static int knockBack = 2; @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Rogue DisplayName.SetDefault("Sky Stabber"); Tooltip.SetDefault("Shoots a gravity-defying spiky ball. Stacks up to 4.\n" + "Stealth strikes make the balls rain feathers onto enemies when they hit\n" + - "Right click to delete all existing spiky balls"); + "Right click to delete all existing spiky balls"); } public override void SafeSetDefaults() @@ -42,35 +42,35 @@ namespace CalamityMod.Items.Weapons.Rogue item.shoot = ModContent.ProjectileType(); } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; - public override bool CanUseItem(Player player) - { - if (player.altFunctionUse == 2) - { - item.shoot = ProjectileID.None; - item.shootSpeed = 0f; - return player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; - } - else - { - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 2f; - int UseMax = item.stack; - return player.ownedProjectileCounts[ModContent.ProjectileType()] < UseMax; - } - } + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse == 2) + { + item.shoot = ProjectileID.None; + item.shootSpeed = 0f; + return player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; + } + else + { + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 2f; + int UseMax = item.stack; + return player.ownedProjectileCounts[ModContent.ProjectileType()] < UseMax; + } + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.killSpikyBalls = false; + modPlayer.killSpikyBalls = false; if (modPlayer.StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; @@ -79,7 +79,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool AltFunctionUse(Player player) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.killSpikyBalls = true; + modPlayer.killSpikyBalls = true; return true; } diff --git a/Items/Weapons/Rogue/SkyfinBombers.cs b/Items/Weapons/Rogue/SkyfinBombers.cs index 9d306bee9b..84cb194a03 100644 --- a/Items/Weapons/Rogue/SkyfinBombers.cs +++ b/Items/Weapons/Rogue/SkyfinBombers.cs @@ -6,14 +6,14 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class SkyfinBombers : RogueWeapon + public class SkyfinBombers : RogueWeapon { public override void SetStaticDefaults() { DisplayName.SetDefault("Skyfin Bombers"); Tooltip.SetDefault("Fishy bombers inbound!\n" + - "Launches a skyfin nuke that homes in on enemies below it\n" + - "Stealth strikes rapidly home in regardless of enemy position"); + "Launches a skyfin nuke that homes in on enemies below it\n" + + "Stealth strikes rapidly home in regardless of enemy position"); } public override void SafeSetDefaults() @@ -40,9 +40,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SlickCane.cs b/Items/Weapons/Rogue/SlickCane.cs index 38e737ccd9..141dfe50c4 100644 --- a/Items/Weapons/Rogue/SlickCane.cs +++ b/Items/Weapons/Rogue/SlickCane.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.rare = ItemRarityID.LightRed; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 22f; - item.Calamity().rogue = true; + item.Calamity().rogue = true; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; @@ -44,8 +44,8 @@ namespace CalamityMod.Items.Weapons.Rogue { float ai0 = Main.rand.NextFloat() * item.shootSpeed * 0.75f * (float)player.direction; int projectileIndex = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, ai0, 0f); - if (projectileIndex.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectileIndex].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (projectileIndex.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectileIndex].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } } diff --git a/Items/Weapons/Rogue/SludgeSplotch.cs b/Items/Weapons/Rogue/SludgeSplotch.cs index 9910087e9c..6f139c257e 100644 --- a/Items/Weapons/Rogue/SludgeSplotch.cs +++ b/Items/Weapons/Rogue/SludgeSplotch.cs @@ -44,8 +44,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX * 1.2f, speedY * 1.2f, type, damage, knockBack * 3, player.whoAmI, 0f, 1f); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SnapClam.cs b/Items/Weapons/Rogue/SnapClam.cs index 84e160580f..3a2ca3ed62 100644 --- a/Items/Weapons/Rogue/SnapClam.cs +++ b/Items/Weapons/Rogue/SnapClam.cs @@ -7,13 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class SnapClam : RogueWeapon + public class SnapClam : RogueWeapon { public override void SetStaticDefaults() { DisplayName.SetDefault("Snap Clam"); Tooltip.SetDefault("Can latch on enemies and deal damage over time\n" + - "Stealth strikes throw five clams at once that cause increased damage over time"); + "Stealth strikes throw five clams at once that cause increased damage over time"); } public override void SafeSetDefaults() @@ -46,8 +46,8 @@ namespace CalamityMod.Items.Weapons.Rogue { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread)); int proj = Projectile.NewProjectile(position, perturbedspeed, ModContent.ProjectileType(), Math.Max(damage / 5, 1), knockBack / 5f, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; spread -= Main.rand.Next(1,3); } return false; diff --git a/Items/Weapons/Rogue/SpearofDestiny.cs b/Items/Weapons/Rogue/SpearofDestiny.cs index c572e6967f..3259e42949 100644 --- a/Items/Weapons/Rogue/SpearofDestiny.cs +++ b/Items/Weapons/Rogue/SpearofDestiny.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Spear of Destiny"); Tooltip.SetDefault("Throws three spears with the outer two having homing capabilities\n" + - "Stealth strikes cause all three spears to home in, ignore tiles, and pierce more"); + "Stealth strikes cause all three spears to home in, ignore tiles, and pierce more"); } public override void SafeSetDefaults() @@ -30,34 +30,34 @@ namespace CalamityMod.Items.Weapons.Rogue item.height = 52; item.value = CalamityGlobalItem.Rarity6BuyPrice; item.rare = ItemRarityID.LightPurple; - item.shoot = ModContent.ProjectileType(); + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 20f; item.Calamity().rogue = 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) { - int index = 7; + int index = 7; for (int i = -index; i <= index; i += index) { - int projType = (i != 0 || player.Calamity().StealthStrikeAvailable()) ? type : ModContent.ProjectileType(); + int projType = (i != 0 || player.Calamity().StealthStrikeAvailable()) ? type : ModContent.ProjectileType(); Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); int spear = Projectile.NewProjectile(position, perturbedSpeed, projType, damage, knockBack, player.whoAmI); - if (spear.WithinBounds(Main.maxProjectiles)) - Main.projectile[spear].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (spear.WithinBounds(Main.maxProjectiles)) + Main.projectile[spear].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); } return false; } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.HallowedBar, 7); - recipe.AddIngredient(ItemID.SoulofLight, 5); - recipe.AddIngredient(ItemID.SoulofFright, 5); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.HallowedBar, 7); + recipe.AddIngredient(ItemID.SoulofLight, 5); + recipe.AddIngredient(ItemID.SoulofFright, 5); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/SpearofPaleolith.cs b/Items/Weapons/Rogue/SpearofPaleolith.cs index 991c6a3e25..28c6fbcee9 100644 --- a/Items/Weapons/Rogue/SpearofPaleolith.cs +++ b/Items/Weapons/Rogue/SpearofPaleolith.cs @@ -51,8 +51,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int stabDevice = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stabDevice.WithinBounds(Main.maxProjectiles)) - Main.projectile[stabDevice].Calamity().stealthStrike = true; + if (stabDevice.WithinBounds(Main.maxProjectiles)) + Main.projectile[stabDevice].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SpentFuelContainer.cs b/Items/Weapons/Rogue/SpentFuelContainer.cs index 68139a4fe4..09e52b7ceb 100644 --- a/Items/Weapons/Rogue/SpentFuelContainer.cs +++ b/Items/Weapons/Rogue/SpentFuelContainer.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Spent Fuel Container"); Tooltip.SetDefault("War Never Changes\n" + //Fallout reference breh, pls don't fall out with me :cri: - "Throws a fuel container with trace amounts of plutonium that causes a nuclear explosion\n" + + "Throws a fuel container with trace amounts of plutonium that causes a nuclear explosion\n" + "The explosion does not occur if there are no tiles below it\n" + "Stealth strikes leave a lingering irradiated zone after the explosion dissipates"); } diff --git a/Items/Weapons/Rogue/StarofDestruction.cs b/Items/Weapons/Rogue/StarofDestruction.cs index 06ed8ee1ef..78e3873e05 100644 --- a/Items/Weapons/Rogue/StarofDestruction.cs +++ b/Items/Weapons/Rogue/StarofDestruction.cs @@ -41,8 +41,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 0.8f), knockBack, player.whoAmI, 0f, 1f); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/StellarKnife.cs b/Items/Weapons/Rogue/StellarKnife.cs index 0f6b0f662c..fe004803f1 100644 --- a/Items/Weapons/Rogue/StellarKnife.cs +++ b/Items/Weapons/Rogue/StellarKnife.cs @@ -38,8 +38,8 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 4; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Rogue/StickySpikyBall.cs b/Items/Weapons/Rogue/StickySpikyBall.cs index 2581fb174d..8bbcd1006e 100644 --- a/Items/Weapons/Rogue/StickySpikyBall.cs +++ b/Items/Weapons/Rogue/StickySpikyBall.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class StickySpikyBall : RogueWeapon + public class StickySpikyBall : RogueWeapon { public override void SetStaticDefaults() { @@ -21,8 +21,8 @@ Stealth strikes throw seven at once and last a lot longer"); item.damage = 10; item.noMelee = true; item.noUseGraphic = true; - item.maxStack = 999; - item.consumable = true; + item.maxStack = 999; + item.consumable = true; item.useAnimation = 20; item.useStyle = ItemUseStyleID.SwingThrow; item.useTime = 20; @@ -45,12 +45,12 @@ Stealth strikes throw seven at once and last a lot longer"); { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread)); int proj = Projectile.NewProjectile(position, perturbedspeed, type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().stealthStrike = true; - Main.projectile[proj].timeLeft *= 4; - Main.projectile[proj].localNPCHitCooldown += 15; - } + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().stealthStrike = true; + Main.projectile[proj].timeLeft *= 4; + Main.projectile[proj].localNPCHitCooldown += 15; + } spread -= Main.rand.Next(1,4); } return false; diff --git a/Items/Weapons/Rogue/SylvanSlasher.cs b/Items/Weapons/Rogue/SylvanSlasher.cs index c7e12d69ae..18fc774372 100644 --- a/Items/Weapons/Rogue/SylvanSlasher.cs +++ b/Items/Weapons/Rogue/SylvanSlasher.cs @@ -20,7 +20,7 @@ Does not consume stealth and cannot stealth strike"); item.width = 72; item.damage = 52; item.Calamity().rogue = true; - item.noMelee = true; + item.noMelee = true; item.noUseGraphic = true; item.channel = true; item.useAnimation = 25; @@ -29,16 +29,16 @@ Does not consume stealth and cannot stealth strike"); item.knockBack = 3f; item.autoReuse = false; item.height = 78; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 24f; } 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); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); return false; } } diff --git a/Items/Weapons/Rogue/TerraDisk.cs b/Items/Weapons/Rogue/TerraDisk.cs index 333446397c..abb02beeaf 100644 --- a/Items/Weapons/Rogue/TerraDisk.cs +++ b/Items/Weapons/Rogue/TerraDisk.cs @@ -44,23 +44,23 @@ Stealth strikes travel slower and are rapidly orbited by the smaller disks"); } public override bool CanUseItem(Player player) - { - //Stealth strikes ignore the proj cap - int terraDiskCount = 0; - for (int p = 0; p < Main.maxProjectiles; p++) - { - Projectile proj = Main.projectile[p]; - if (!proj.active || proj.owner != player.whoAmI) - continue; - if (proj.type == item.shoot && !proj.Calamity().stealthStrike) - { - terraDiskCount++; - } - if (terraDiskCount >= 3) - break; - } - return terraDiskCount < 3; - } + { + //Stealth strikes ignore the proj cap + int terraDiskCount = 0; + for (int p = 0; p < Main.maxProjectiles; p++) + { + Projectile proj = Main.projectile[p]; + if (!proj.active || proj.owner != player.whoAmI) + continue; + if (proj.type == item.shoot && !proj.Calamity().stealthStrike) + { + terraDiskCount++; + } + if (terraDiskCount >= 3) + break; + } + return terraDiskCount < 3; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -71,10 +71,10 @@ Stealth strikes travel slower and are rapidly orbited by the smaller disks"); damage = (int)(damage * 0.9f); } int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().stealthStrike = true; - } + if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().stealthStrike = true; + } return false; } diff --git a/Items/Weapons/Rogue/TerrorTalons.cs b/Items/Weapons/Rogue/TerrorTalons.cs index 121506e8b8..0f650af1bd 100644 --- a/Items/Weapons/Rogue/TerrorTalons.cs +++ b/Items/Weapons/Rogue/TerrorTalons.cs @@ -43,8 +43,8 @@ namespace CalamityMod.Items.Weapons.Rogue { float stealthDamageMult = 4.875f; int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), (int)(damage * stealthDamageMult), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } else { diff --git a/Items/Weapons/Rogue/TheAtomSplitter.cs b/Items/Weapons/Rogue/TheAtomSplitter.cs index 88663f93a8..d28e79f11e 100644 --- a/Items/Weapons/Rogue/TheAtomSplitter.cs +++ b/Items/Weapons/Rogue/TheAtomSplitter.cs @@ -6,43 +6,43 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class TheAtomSplitter : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Atom Splitter"); - Tooltip.SetDefault("Throws a quantum-superimposed javelin that strikes from numerous timelines at once\n" + - "Stealth strikes perform far more simultaneous strikes"); - } + public class TheAtomSplitter : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("The Atom Splitter"); + Tooltip.SetDefault("Throws a quantum-superimposed javelin that strikes from numerous timelines at once\n" + + "Stealth strikes perform far more simultaneous strikes"); + } - public override void SafeSetDefaults() - { - item.width = item.height = 128; - item.damage = 320; - item.knockBack = 7f; - item.useAnimation = item.useTime = 25; - item.Calamity().rogue = true; - item.autoReuse = true; - item.shootSpeed = 24f; - item.shoot = ModContent.ProjectileType(); + public override void SafeSetDefaults() + { + item.width = item.height = 128; + item.damage = 320; + item.knockBack = 7f; + item.useAnimation = item.useTime = 25; + item.Calamity().rogue = true; + item.autoReuse = true; + item.shootSpeed = 24f; + item.shoot = ModContent.ProjectileType(); - item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item1; - item.noMelee = true; - item.noUseGraphic = true; - item.value = CalamityGlobalItem.RarityVioletBuyPrice; - item.rare = ItemRarityID.Red; - item.Calamity().customRarity = CalamityRarity.Violet; - } + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.noMelee = true; + item.noUseGraphic = true; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.Violet; + } - 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 javelin = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, -1f); - if (player.Calamity().StealthStrikeAvailable() && Main.projectile.IndexInRange(javelin)) { - Main.projectile[javelin].Calamity().stealthStrike = true; - Main.projectile[javelin].damage = (int)(1.10 * Main.projectile[javelin].damage); - } - return false; - } - } + 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 javelin = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, -1f); + if (player.Calamity().StealthStrikeAvailable() && Main.projectile.IndexInRange(javelin)) { + Main.projectile[javelin].Calamity().stealthStrike = true; + Main.projectile[javelin].damage = (int)(1.10 * Main.projectile[javelin].damage); + } + return false; + } + } } diff --git a/Items/Weapons/Rogue/TheReaper.cs b/Items/Weapons/Rogue/TheReaper.cs index 05b31a534a..ef967f8909 100644 --- a/Items/Weapons/Rogue/TheReaper.cs +++ b/Items/Weapons/Rogue/TheReaper.cs @@ -33,9 +33,9 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; item.value = CalamityGlobalItem.Rarity13BuyPrice; - item.Calamity().customRarity = CalamityRarity.PureGreen; - item.rare = ItemRarityID.Purple; - } + item.Calamity().customRarity = CalamityRarity.PureGreen; + item.rare = ItemRarityID.Purple; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Rogue/TheSyringe.cs b/Items/Weapons/Rogue/TheSyringe.cs index 0beac46880..d4b08f3f65 100644 --- a/Items/Weapons/Rogue/TheSyringe.cs +++ b/Items/Weapons/Rogue/TheSyringe.cs @@ -6,7 +6,7 @@ using CalamityMod.Projectiles.Rogue; namespace CalamityMod.Items.Weapons.Rogue { - public class TheSyringe : RogueWeapon + public class TheSyringe : RogueWeapon { public static int BaseDamage = 60; public static float Knockback = 5f; @@ -16,8 +16,8 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("The Syringe"); Tooltip.SetDefault("Throws a high velocity syringe that increases damage as it travels\n" + - "Shatters into glass and plague cinders on impact\n" + - "Stealth strikes also shatter into plague bees\n" + + "Shatters into glass and plague cinders on impact\n" + + "Stealth strikes also shatter into plague bees\n" + "'I'm pretty sure this isn't healthy'"); } @@ -46,8 +46,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 1.2f), knockBack, player.whoAmI, 0f, 1f); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ThrowingBrick.cs b/Items/Weapons/Rogue/ThrowingBrick.cs index 4e0a84a112..93fe2bc40f 100644 --- a/Items/Weapons/Rogue/ThrowingBrick.cs +++ b/Items/Weapons/Rogue/ThrowingBrick.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 20; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -43,8 +43,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 1); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/TitaniumShuriken.cs b/Items/Weapons/Rogue/TitaniumShuriken.cs index d0949574c6..7a3d87a2b3 100644 --- a/Items/Weapons/Rogue/TitaniumShuriken.cs +++ b/Items/Weapons/Rogue/TitaniumShuriken.cs @@ -35,21 +35,21 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 10; 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()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; - Main.projectile[stealth].aiStyle = -1; - Main.projectile[stealth].extraUpdates = 1; - } + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + Main.projectile[stealth].aiStyle = -1; + Main.projectile[stealth].extraUpdates = 1; + } return false; } return true; diff --git a/Items/Weapons/Rogue/ToothBall.cs b/Items/Weapons/Rogue/ToothBall.cs index ccac5d3507..e003f6d94d 100644 --- a/Items/Weapons/Rogue/ToothBall.cs +++ b/Items/Weapons/Rogue/ToothBall.cs @@ -37,19 +37,19 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().rogue = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 8; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 8; 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()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; - } + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } return false; } return true; diff --git a/Items/Weapons/Rogue/TotalityBreakers.cs b/Items/Weapons/Rogue/TotalityBreakers.cs index abb6601cfb..82c7221af3 100644 --- a/Items/Weapons/Rogue/TotalityBreakers.cs +++ b/Items/Weapons/Rogue/TotalityBreakers.cs @@ -42,8 +42,8 @@ Stealth strikes leak tar as they fly"); if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 1.15f), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ToxicantTwister.cs b/Items/Weapons/Rogue/ToxicantTwister.cs index d4733c4c90..f2ac0a33b1 100644 --- a/Items/Weapons/Rogue/ToxicantTwister.cs +++ b/Items/Weapons/Rogue/ToxicantTwister.cs @@ -6,42 +6,42 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class ToxicantTwister : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Toxicant Twister"); - Tooltip.SetDefault("Throws a slow moving boomerang\n" + - "After a few moments, the boomerang chooses a target and rapidly homes in\n" + - "Stealth strikes home in faster and rapidly release sand"); - } + public class ToxicantTwister : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Toxicant Twister"); + Tooltip.SetDefault("Throws a slow moving boomerang\n" + + "After a few moments, the boomerang chooses a target and rapidly homes in\n" + + "Stealth strikes home in faster and rapidly release sand"); + } - public override void SafeSetDefaults() - { - item.width = 42; - item.height = 46; - item.damage = 323; - item.noMelee = true; - item.noUseGraphic = true; - item.useAnimation = item.useTime = 20; - item.useStyle = ItemUseStyleID.SwingThrow; - item.knockBack = 5f; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 18f; - item.Calamity().rogue = true; + public override void SafeSetDefaults() + { + item.width = 42; + item.height = 46; + item.damage = 323; + item.noMelee = true; + item.noUseGraphic = true; + item.useAnimation = item.useTime = 20; + item.useStyle = ItemUseStyleID.SwingThrow; + item.knockBack = 5f; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 18f; + item.Calamity().rogue = true; - item.value = CalamityGlobalItem.Rarity13BuyPrice; - item.Calamity().customRarity = CalamityRarity.PureGreen; - } + item.value = CalamityGlobalItem.Rarity13BuyPrice; + item.Calamity().customRarity = CalamityRarity.PureGreen; + } - 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 boomer = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (boomer.WithinBounds(Main.maxProjectiles)) - Main.projectile[boomer].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - return false; - } - } + 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 boomer = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (boomer.WithinBounds(Main.maxProjectiles)) + Main.projectile[boomer].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + return false; + } + } } diff --git a/Items/Weapons/Rogue/Turbulance.cs b/Items/Weapons/Rogue/Turbulance.cs index 789380eaa1..f68e33ec53 100644 --- a/Items/Weapons/Rogue/Turbulance.cs +++ b/Items/Weapons/Rogue/Turbulance.cs @@ -42,8 +42,8 @@ Stealth strikes are trailed by homing wind slashes"); if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/UtensilPoker.cs b/Items/Weapons/Rogue/UtensilPoker.cs index 4500d58c06..4ed157dadc 100644 --- a/Items/Weapons/Rogue/UtensilPoker.cs +++ b/Items/Weapons/Rogue/UtensilPoker.cs @@ -7,84 +7,84 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class UtensilPoker : RogueWeapon - { - private int counter = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Utensil Poker"); - Tooltip.SetDefault("Space chickens, that is all.\n" + - "Fires random utensils in bursts of three\n" + - "Grants Well Fed on enemy hits\n" + - "Stealth strikes replace any utensil with a powerful butcher knife"); - } + public class UtensilPoker : RogueWeapon + { + private int counter = 0; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Utensil Poker"); + Tooltip.SetDefault("Space chickens, that is all.\n" + + "Fires random utensils in bursts of three\n" + + "Grants Well Fed on enemy hits\n" + + "Stealth strikes replace any utensil with a powerful butcher knife"); + } - public override void SafeSetDefaults() - { - item.width = 44; - item.height = 66; - item.damage = 333; - item.Calamity().rogue = true; - item.knockBack = 8f; - item.noMelee = true; - item.noUseGraphic = true; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 15; - item.reuseDelay = 15; - item.useAnimation = 45; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 12f; - } + public override void SafeSetDefaults() + { + item.width = 44; + item.height = 66; + item.damage = 333; + item.Calamity().rogue = true; + item.knockBack = 8f; + item.noMelee = true; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = 15; + item.reuseDelay = 15; + item.useAnimation = 45; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 12f; + } - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - CalamityPlayer mp = player.Calamity(); + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + CalamityPlayer mp = player.Calamity(); - if (mp.StealthStrikeAvailable()) - { - int stealthDamage = damage * 2; - float stealthSpeedMult = 1.4f; - Vector2 stealthVelocity = new Vector2(speedX, speedY) * stealthSpeedMult; - int stealth = Projectile.NewProjectile(position, stealthVelocity, ModContent.ProjectileType(), stealthDamage, knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - } - else - { - int utensil = item.shoot; - double dmgMult = 1D; - float kbMult = 1f; - switch (Main.rand.Next(3)) - { - case 0: - utensil = item.shoot; - dmgMult = 1.1; - kbMult = 2f; - break; - case 1: - utensil = ModContent.ProjectileType(); - dmgMult = 1.2; - kbMult = 1f; - break; - case 2: - utensil = ModContent.ProjectileType(); - dmgMult = 1D; - kbMult = 1f; - break; - default: - break; - } - Projectile.NewProjectile(position, new Vector2(speedX, speedY), utensil, (int)(damage * dmgMult), knockBack * kbMult, player.whoAmI); - } + if (mp.StealthStrikeAvailable()) + { + int stealthDamage = damage * 2; + float stealthSpeedMult = 1.4f; + Vector2 stealthVelocity = new Vector2(speedX, speedY) * stealthSpeedMult; + int stealth = Projectile.NewProjectile(position, stealthVelocity, ModContent.ProjectileType(), stealthDamage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + } + else + { + int utensil = item.shoot; + double dmgMult = 1D; + float kbMult = 1f; + switch (Main.rand.Next(3)) + { + case 0: + utensil = item.shoot; + dmgMult = 1.1; + kbMult = 2f; + break; + case 1: + utensil = ModContent.ProjectileType(); + dmgMult = 1.2; + kbMult = 1f; + break; + case 2: + utensil = ModContent.ProjectileType(); + dmgMult = 1D; + kbMult = 1f; + break; + default: + break; + } + Projectile.NewProjectile(position, new Vector2(speedX, speedY), utensil, (int)(damage * dmgMult), knockBack * kbMult, player.whoAmI); + } - counter++; - if (counter == 3) - counter = 0; - return false; - } - } + counter++; + if (counter == 3) + counter = 0; + return false; + } + } } diff --git a/Items/Weapons/Rogue/WebBall.cs b/Items/Weapons/Rogue/WebBall.cs index c781573ae6..729fecd6a9 100644 --- a/Items/Weapons/Rogue/WebBall.cs +++ b/Items/Weapons/Rogue/WebBall.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class WebBall : RogueWeapon + public class WebBall : RogueWeapon { public override void SetStaticDefaults() { @@ -21,8 +21,8 @@ Stealth strikes slow enemies down longer"); item.damage = 8; item.noMelee = true; item.noUseGraphic = true; - item.maxStack = 999; - item.consumable = true; + item.maxStack = 999; + item.consumable = true; item.useAnimation = 20; item.useStyle = ItemUseStyleID.SwingThrow; item.useTime = 20; @@ -40,9 +40,9 @@ Stealth strikes slow enemies down longer"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/WulfrumKnife.cs b/Items/Weapons/Rogue/WulfrumKnife.cs index e5627f493f..3b05bd5fb3 100644 --- a/Items/Weapons/Rogue/WulfrumKnife.cs +++ b/Items/Weapons/Rogue/WulfrumKnife.cs @@ -52,13 +52,13 @@ namespace CalamityMod.Items.Weapons.Rogue { int p = Projectile.NewProjectile(position, new Vector2(speedX, speedY) * 1.3f, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); Projectile proj = Main.projectile[p]; - if (p.WithinBounds(Main.maxProjectiles)) - { - proj.Calamity().stealthStrike = true; - proj.penetrate = 4; - proj.usesLocalNPCImmunity = true; - proj.localNPCHitCooldown = 1; - } + if (p.WithinBounds(Main.maxProjectiles)) + { + proj.Calamity().stealthStrike = true; + proj.penetrate = 4; + proj.usesLocalNPCImmunity = true; + proj.localNPCHitCooldown = 1; + } return false; } return true; diff --git a/Items/Weapons/Rogue/XerocPitchfork.cs b/Items/Weapons/Rogue/XerocPitchfork.cs index 416e77f6a5..4113846d81 100644 --- a/Items/Weapons/Rogue/XerocPitchfork.cs +++ b/Items/Weapons/Rogue/XerocPitchfork.cs @@ -7,54 +7,54 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class XerocPitchfork : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shard of Antumbra"); - Tooltip.SetDefault("Stealth strikes leave homing stars in their wake"); - } + public class XerocPitchfork : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shard of Antumbra"); + Tooltip.SetDefault("Stealth strikes leave homing stars in their wake"); + } - public override void SafeSetDefaults() - { - item.width = 48; - item.damage = 280; - item.noMelee = true; - item.consumable = true; - item.noUseGraphic = true; - item.useAnimation = 19; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 19; - item.knockBack = 8f; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.height = 48; - item.maxStack = 999; - item.value = 10000; - item.rare = ItemRarityID.Cyan; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 24f; - item.Calamity().rogue = true; - } + public override void SafeSetDefaults() + { + item.width = 48; + item.damage = 280; + item.noMelee = true; + item.consumable = true; + item.noUseGraphic = true; + item.useAnimation = 19; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = 19; + item.knockBack = 8f; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.height = 48; + item.maxStack = 999; + item.value = 10000; + item.rare = ItemRarityID.Cyan; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 24f; + item.Calamity().rogue = 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) - { - if (player.Calamity().StealthStrikeAvailable()) - { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 1.5f), knockBack, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - } - return !player.Calamity().StealthStrikeAvailable(); - } + 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()) + { + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 1.5f), knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + } + return !player.Calamity().StealthStrikeAvailable(); + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this, 100); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this, 100); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Summon/AbandonedSlimeStaff.cs b/Items/Weapons/Summon/AbandonedSlimeStaff.cs index 360170fd0b..2be2e612ea 100644 --- a/Items/Weapons/Summon/AbandonedSlimeStaff.cs +++ b/Items/Weapons/Summon/AbandonedSlimeStaff.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class AbandonedSlimeStaff : ModItem + public class AbandonedSlimeStaff : ModItem { int slimeSlots; public override void SetStaticDefaults() diff --git a/Items/Weapons/Summon/BelladonnaSpiritStaff.cs b/Items/Weapons/Summon/BelladonnaSpiritStaff.cs index cbcbbe8c80..46dd263154 100644 --- a/Items/Weapons/Summon/BelladonnaSpiritStaff.cs +++ b/Items/Weapons/Summon/BelladonnaSpiritStaff.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class BelladonnaSpiritStaff : ModItem + public class BelladonnaSpiritStaff : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Summon/BensUmbrella.cs b/Items/Weapons/Summon/BensUmbrella.cs index 4de24cf4a7..dbafc104cf 100644 --- a/Items/Weapons/Summon/BensUmbrella.cs +++ b/Items/Weapons/Summon/BensUmbrella.cs @@ -8,57 +8,57 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class BensUmbrella : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Temporal Umbrella"); - Tooltip.SetDefault("Surprisingly sturdy, I reckon this could defeat the Mafia in a single blow\n" + - "Summons a magic hat to hover above your head\n" + - "The hat will release a variety of objects to assault your foes\n" + - "Requires 5 minion slots to use and there can only be one hat"); - } + public class BensUmbrella : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Temporal Umbrella"); + Tooltip.SetDefault("Surprisingly sturdy, I reckon this could defeat the Mafia in a single blow\n" + + "Summons a magic hat to hover above your head\n" + + "The hat will release a variety of objects to assault your foes\n" + + "Requires 5 minion slots to use and there can only be one hat"); + } - public override void SetDefaults() - { - item.damage = 193; - item.knockBack = 1f; - item.mana = 99; - item.useTime = item.useAnimation = 10; - item.summon = true; - item.shootSpeed = 0f; - item.shoot = ModContent.ProjectileType(); + public override void SetDefaults() + { + item.damage = 193; + item.knockBack = 1f; + item.mana = 99; + item.useTime = item.useAnimation = 10; + item.summon = true; + item.shootSpeed = 0f; + item.shoot = ModContent.ProjectileType(); - item.useStyle = ItemUseStyleID.SwingThrow; - item.width = 74; - item.height = 72; - item.noMelee = true; - item.UseSound = SoundID.Item68; - item.value = CalamityGlobalItem.Rarity16BuyPrice; - item.Calamity().customRarity = CalamityRarity.HotPink; - item.Calamity().devItem = true; - } + item.useStyle = ItemUseStyleID.SwingThrow; + item.width = 74; + item.height = 72; + item.noMelee = true; + item.UseSound = SoundID.Item68; + item.value = CalamityGlobalItem.Rarity16BuyPrice; + item.Calamity().customRarity = CalamityRarity.HotPink; + item.Calamity().devItem = true; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.maxMinions >= 5; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.maxMinions >= 5; - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - CalamityUtils.KillShootProjectiles(true, type, player); - Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); - return false; - } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + CalamityUtils.KillShootProjectiles(true, type, player); + Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.Umbrella); - recipe.AddIngredient(ItemID.TopHat); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.Umbrella); + recipe.AddIngredient(ItemID.TopHat); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Summon/BlackHawkRemote.cs b/Items/Weapons/Summon/BlackHawkRemote.cs index 56a6c3813c..e3cca5f82e 100644 --- a/Items/Weapons/Summon/BlackHawkRemote.cs +++ b/Items/Weapons/Summon/BlackHawkRemote.cs @@ -37,13 +37,13 @@ namespace CalamityMod.Items.Weapons.Summon { if (player.altFunctionUse != 2) { - if (player.whoAmI == Main.myPlayer) - { - position = Main.MouseWorld; - speedX = 0; - speedY = 0; - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - } + if (player.whoAmI == Main.myPlayer) + { + position = Main.MouseWorld; + speedX = 0; + speedY = 0; + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); + } } return false; } diff --git a/Items/Weapons/Summon/BlightedEyeStaff.cs b/Items/Weapons/Summon/BlightedEyeStaff.cs index 9a8c4511f9..a017fad1ce 100644 --- a/Items/Weapons/Summon/BlightedEyeStaff.cs +++ b/Items/Weapons/Summon/BlightedEyeStaff.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Entropy's Vigil"); Tooltip.SetDefault("Summons Calamitas and her brothers to protect you\n" + - "One minion trio takes two minion slots"); + "One minion trio takes two minion slots"); } public override void SetDefaults() diff --git a/Items/Weapons/Summon/BorealisBomber.cs b/Items/Weapons/Summon/BorealisBomber.cs index 96de882fc1..0964b66593 100644 --- a/Items/Weapons/Summon/BorealisBomber.cs +++ b/Items/Weapons/Summon/BorealisBomber.cs @@ -12,8 +12,8 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Borealis Bomber"); Tooltip.SetDefault("Summons aureus bombers to fight for you\n" + - "Aureus bombers explode on enemy impact\n" + - "Does not consume minion slots"); + "Aureus bombers explode on enemy impact\n" + + "Does not consume minion slots"); Item.staff[item.type] = true; } diff --git a/Items/Weapons/Summon/CadaverousCarrion.cs b/Items/Weapons/Summon/CadaverousCarrion.cs index f1ac1c215f..62df9fb9fd 100644 --- a/Items/Weapons/Summon/CadaverousCarrion.cs +++ b/Items/Weapons/Summon/CadaverousCarrion.cs @@ -36,9 +36,9 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - //CalamityUtils.OnlyOneSentry(player, type); - Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); - player.UpdateMaxTurrets(); + //CalamityUtils.OnlyOneSentry(player, type); + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); + player.UpdateMaxTurrets(); return false; } } diff --git a/Items/Weapons/Summon/CausticCroakerStaff.cs b/Items/Weapons/Summon/CausticCroakerStaff.cs index 5665175e71..54e8bfd5e2 100644 --- a/Items/Weapons/Summon/CausticCroakerStaff.cs +++ b/Items/Weapons/Summon/CausticCroakerStaff.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class CausticCroakerStaff : ModItem + public class CausticCroakerStaff : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Summon/CinderBlossomStaff.cs b/Items/Weapons/Summon/CinderBlossomStaff.cs index b56d261768..bc7c51bc0f 100644 --- a/Items/Weapons/Summon/CinderBlossomStaff.cs +++ b/Items/Weapons/Summon/CinderBlossomStaff.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Cinder Blossom Staff"); Tooltip.SetDefault("Summons a really hot flower over your head\n" + - "There can only be one flower"); + "There can only be one flower"); } public override void SetDefaults() @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityUtils.KillShootProjectiles(true, type, player); + CalamityUtils.KillShootProjectiles(true, type, player); Projectile.NewProjectile(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 0f); return false; } diff --git a/Items/Weapons/Summon/ColdDivinity.cs b/Items/Weapons/Summon/ColdDivinity.cs index 02d6fb85a2..d16e867a0e 100644 --- a/Items/Weapons/Summon/ColdDivinity.cs +++ b/Items/Weapons/Summon/ColdDivinity.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class ColdDivinity : ModItem + public class ColdDivinity : ModItem { public override void SetStaticDefaults() { @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Summon item.value = CalamityGlobalItem.Rarity5BuyPrice; item.rare = ItemRarityID.Pink; - } + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Summon/Cosmilamp.cs b/Items/Weapons/Summon/Cosmilamp.cs index 27a60c8411..f40fd09661 100644 --- a/Items/Weapons/Summon/Cosmilamp.cs +++ b/Items/Weapons/Summon/Cosmilamp.cs @@ -26,10 +26,10 @@ namespace CalamityMod.Items.Weapons.Summon item.useStyle = ItemUseStyleID.SwingThrow; item.noMelee = true; item.knockBack = 4f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item44; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.Item44; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; diff --git a/Items/Weapons/Summon/DaedalusGolemStaff.cs b/Items/Weapons/Summon/DaedalusGolemStaff.cs index 3cad138015..2360407978 100644 --- a/Items/Weapons/Summon/DaedalusGolemStaff.cs +++ b/Items/Weapons/Summon/DaedalusGolemStaff.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Daedalus Golem Staff"); Tooltip.SetDefault("Summons a Daedalus Golem soldier that fires pellets and electricity\n" + - "Shining god of greed"); // Funny Hollow Knight reference. + "Shining god of greed"); // Funny Hollow Knight reference. } public override void SetDefaults() diff --git a/Items/Weapons/Summon/DazzlingStabberStaff.cs b/Items/Weapons/Summon/DazzlingStabberStaff.cs index e0b3b8f0ff..0c9fc8490f 100644 --- a/Items/Weapons/Summon/DazzlingStabberStaff.cs +++ b/Items/Weapons/Summon/DazzlingStabberStaff.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class DazzlingStabberStaff : ModItem + public class DazzlingStabberStaff : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Summon/DeathstareRod.cs b/Items/Weapons/Summon/DeathstareRod.cs index 3a94e26b67..d8011a5341 100644 --- a/Items/Weapons/Summon/DeathstareRod.cs +++ b/Items/Weapons/Summon/DeathstareRod.cs @@ -6,13 +6,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class DeathstareRod : ModItem + public class DeathstareRod : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Deathstare Rod"); Tooltip.SetDefault("Summons an eye above your head that watches you and shoots at enemies\n" + - "There can only be one eye"); + "There can only be one eye"); } public override void SetDefaults() @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityUtils.KillShootProjectiles(true, type, player); + CalamityUtils.KillShootProjectiles(true, type, player); Projectile.NewProjectile(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 0f); return false; } diff --git a/Items/Weapons/Summon/DormantBrimseeker.cs b/Items/Weapons/Summon/DormantBrimseeker.cs index 54d423f24c..8b8f1312ba 100644 --- a/Items/Weapons/Summon/DormantBrimseeker.cs +++ b/Items/Weapons/Summon/DormantBrimseeker.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Items.Weapons.Summon DisplayName.SetDefault("Dormant Brimseeker"); Tooltip.SetDefault("You could've sworn that they turned even scarier when you looked at their reflections in a mirror\n" + "Summons a brimseeker to keep you company\n" + - "Firing another brimseeker when all minion slots are filled summons a brimstone aura\n" + - "The aura empowers your brimseeker summons and produces damaging fireballs\n" + - "Only one aura can persist at a time"); + "Firing another brimseeker when all minion slots are filled summons a brimstone aura\n" + + "The aura empowers your brimseeker summons and produces damaging fireballs\n" + + "Only one aura can persist at a time"); } public override void SetDefaults() diff --git a/Items/Weapons/Summon/DragonbloodDisgorger.cs b/Items/Weapons/Summon/DragonbloodDisgorger.cs index d81b6f5988..097102aa57 100644 --- a/Items/Weapons/Summon/DragonbloodDisgorger.cs +++ b/Items/Weapons/Summon/DragonbloodDisgorger.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class DragonbloodDisgorger : ModItem + public class DragonbloodDisgorger : ModItem { public override void SetStaticDefaults() { @@ -27,10 +27,10 @@ namespace CalamityMod.Items.Weapons.Summon item.useStyle = ItemUseStyleID.SwingThrow; item.noMelee = true; item.knockBack = 4f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.DD2_SkeletonDeath; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.UseSound = SoundID.DD2_SkeletonDeath; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; item.summon = true; diff --git a/Items/Weapons/Summon/DreadmineStaff.cs b/Items/Weapons/Summon/DreadmineStaff.cs index d9cde879ff..f7ca9734ed 100644 --- a/Items/Weapons/Summon/DreadmineStaff.cs +++ b/Items/Weapons/Summon/DreadmineStaff.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - //CalamityUtils.OnlyOneSentry(player, type); + //CalamityUtils.OnlyOneSentry(player, type); Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); player.UpdateMaxTurrets(); return false; diff --git a/Items/Weapons/Summon/ElementalAxe.cs b/Items/Weapons/Summon/ElementalAxe.cs index 8556f3c823..9cf8b969d0 100644 --- a/Items/Weapons/Summon/ElementalAxe.cs +++ b/Items/Weapons/Summon/ElementalAxe.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class ElementalAxe : ModItem + public class ElementalAxe : ModItem { public override void SetStaticDefaults() { @@ -26,9 +26,9 @@ namespace CalamityMod.Items.Weapons.Summon item.useStyle = ItemUseStyleID.SwingThrow; item.noMelee = true; item.knockBack = 5f; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.UseSound = SoundID.Item44; + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.UseSound = SoundID.Item44; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; diff --git a/Items/Weapons/Summon/EnergyStaff.cs b/Items/Weapons/Summon/EnergyStaff.cs index d73f0648ca..da78003b86 100644 --- a/Items/Weapons/Summon/EnergyStaff.cs +++ b/Items/Weapons/Summon/EnergyStaff.cs @@ -27,17 +27,17 @@ namespace CalamityMod.Items.Weapons.Summon item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 5f; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.autoReuse = true; + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.autoReuse = true; item.shoot = ModContent.ProjectileType(); } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - //CalamityUtils.OnlyOneSentry(player, type); - Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI, 16f); - player.UpdateMaxTurrets(); + //CalamityUtils.OnlyOneSentry(player, type); + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI, 16f); + player.UpdateMaxTurrets(); return false; } } diff --git a/Items/Weapons/Summon/EtherealSubjugator.cs b/Items/Weapons/Summon/EtherealSubjugator.cs index a20e2333e8..ea867d501d 100644 --- a/Items/Weapons/Summon/EtherealSubjugator.cs +++ b/Items/Weapons/Summon/EtherealSubjugator.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Ethereal Subjugator"); Tooltip.SetDefault("Summons a phantom to protect you\n" + - "Each phantom takes only half of a minion slot"); + "Each phantom takes only half of a minion slot"); } public override void SetDefaults() @@ -37,47 +37,47 @@ namespace CalamityMod.Items.Weapons.Summon item.Calamity().customRarity = CalamityRarity.PureGreen; } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Summon/EtherealSubjugatorGlow")); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/Weapons/Summon/EtherealSubjugatorGlow")); + } - public override bool Shoot(Player player, ref 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) { - int i = Main.myPlayer; - float num72 = item.shootSpeed; - float num74 = knockBack; - num74 = player.GetWeaponKnockback(item, num74); - player.itemTime = item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (player.gravDir == -1f) - { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; - } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) - { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; - } - else - { - num80 = num72 / num80; - } - num78 *= num80; - num79 *= num80; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - Vector2 spinningpoint = new Vector2(num78, num79); - spinningpoint = spinningpoint.RotatedBy(1.5707963705062866, default); - Projectile.NewProjectile(vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, num74, i, 0f, 1f); - } - return false; + int i = Main.myPlayer; + float num72 = item.shootSpeed; + float num74 = knockBack; + num74 = player.GetWeaponKnockback(item, num74); + player.itemTime = item.useTime; + Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); + float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; + float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + if (player.gravDir == -1f) + { + num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + } + float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); + if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + { + num78 = (float)player.direction; + num79 = 0f; + num80 = num72; + } + else + { + num80 = num72 / num80; + } + num78 *= num80; + num79 *= num80; + vector2.X = (float)Main.mouseX + Main.screenPosition.X; + vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; + Vector2 spinningpoint = new Vector2(num78, num79); + spinningpoint = spinningpoint.RotatedBy(1.5707963705062866, default); + Projectile.NewProjectile(vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, num74, i, 0f, 1f); + } + return false; } } } diff --git a/Items/Weapons/Summon/EyeOfNight.cs b/Items/Weapons/Summon/EyeOfNight.cs index 21d103c79c..104c3d5b80 100644 --- a/Items/Weapons/Summon/EyeOfNight.cs +++ b/Items/Weapons/Summon/EyeOfNight.cs @@ -6,7 +6,7 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Summon { - public class EyeOfNight : ModItem + public class EyeOfNight : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Summon/FleshOfInfidelity.cs b/Items/Weapons/Summon/FleshOfInfidelity.cs index 14a5fcc448..c030c545f1 100644 --- a/Items/Weapons/Summon/FleshOfInfidelity.cs +++ b/Items/Weapons/Summon/FleshOfInfidelity.cs @@ -5,7 +5,7 @@ using CalamityMod.Projectiles.Summon; namespace CalamityMod.Items.Weapons.Summon { - public class FleshOfInfidelity : ModItem + public class FleshOfInfidelity : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Summon/FlowersOfMortality.cs b/Items/Weapons/Summon/FlowersOfMortality.cs index 7b3abfe730..374497f9cc 100644 --- a/Items/Weapons/Summon/FlowersOfMortality.cs +++ b/Items/Weapons/Summon/FlowersOfMortality.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityUtils.KillShootProjectiles(false, type, player); + CalamityUtils.KillShootProjectiles(false, type, player); for (int i = 0; i < 5; i++) { Projectile blossom = Projectile.NewProjectileDirect(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 0f); diff --git a/Items/Weapons/Summon/FrostBlossomStaff.cs b/Items/Weapons/Summon/FrostBlossomStaff.cs index 5093ae2abc..bae48b4531 100644 --- a/Items/Weapons/Summon/FrostBlossomStaff.cs +++ b/Items/Weapons/Summon/FrostBlossomStaff.cs @@ -6,13 +6,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class FrostBlossomStaff : ModItem + public class FrostBlossomStaff : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Frost Blossom Staff"); Tooltip.SetDefault("Summons a frozen flower over your head\n" + - "There can only be one flower"); + "There can only be one flower"); } public override void SetDefaults() @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityUtils.KillShootProjectiles(true, type, player); + CalamityUtils.KillShootProjectiles(true, type, player); Projectile.NewProjectile(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 0f); return false; } diff --git a/Items/Weapons/Summon/GastricBelcherStaff.cs b/Items/Weapons/Summon/GastricBelcherStaff.cs index 241533941e..4f6fa85b2a 100644 --- a/Items/Weapons/Summon/GastricBelcherStaff.cs +++ b/Items/Weapons/Summon/GastricBelcherStaff.cs @@ -7,13 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class GastricBelcherStaff : ModItem + public class GastricBelcherStaff : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Gastric Belcher Staff"); Tooltip.SetDefault("Summons aquatic aberrations to protect you\n" + - "Aberrations fire vomit at nearby enemies with every third attack firing bubbles"); + "Aberrations fire vomit at nearby enemies with every third attack firing bubbles"); } public override void SetDefaults() @@ -32,41 +32,41 @@ namespace CalamityMod.Items.Weapons.Summon item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; item.summon = true; - item.autoReuse = true; + item.autoReuse = 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) + 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) { - player.itemTime = item.useTime; - Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float directionX = Main.mouseX + Main.screenPosition.X - playerPos.X; - float directionY = Main.mouseY + Main.screenPosition.Y - playerPos.Y; - if (player.gravDir == -1f) - { - directionY = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - playerPos.Y; - } - Vector2 spinningpoint = new Vector2(directionX, directionY); - float dist = spinningpoint.Length(); - if ((float.IsNaN(spinningpoint.X) && float.IsNaN(spinningpoint.Y)) || (spinningpoint.X == 0f && spinningpoint.Y == 0f)) - { - spinningpoint.X = player.direction; - spinningpoint.Y = 0f; - dist = item.shootSpeed; - } - else - { - dist = item.shootSpeed / dist; - } - spinningpoint.X *= dist; - spinningpoint.Y *= dist; - playerPos.X = Main.mouseX + Main.screenPosition.X; - playerPos.Y = Main.mouseY + Main.screenPosition.Y; - spinningpoint = spinningpoint.RotatedBy(Math.PI / 2D, default); - Projectile.NewProjectile(playerPos + spinningpoint, spinningpoint, type, damage, knockBack, player.whoAmI, 0f, 1f); - } - return false; + player.itemTime = item.useTime; + Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float directionX = Main.mouseX + Main.screenPosition.X - playerPos.X; + float directionY = Main.mouseY + Main.screenPosition.Y - playerPos.Y; + if (player.gravDir == -1f) + { + directionY = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - playerPos.Y; + } + Vector2 spinningpoint = new Vector2(directionX, directionY); + float dist = spinningpoint.Length(); + if ((float.IsNaN(spinningpoint.X) && float.IsNaN(spinningpoint.Y)) || (spinningpoint.X == 0f && spinningpoint.Y == 0f)) + { + spinningpoint.X = player.direction; + spinningpoint.Y = 0f; + dist = item.shootSpeed; + } + else + { + dist = item.shootSpeed / dist; + } + spinningpoint.X *= dist; + spinningpoint.Y *= dist; + playerPos.X = Main.mouseX + Main.screenPosition.X; + playerPos.Y = Main.mouseY + Main.screenPosition.Y; + spinningpoint = spinningpoint.RotatedBy(Math.PI / 2D, default); + Projectile.NewProjectile(playerPos + spinningpoint, spinningpoint, type, damage, knockBack, player.whoAmI, 0f, 1f); + } + return false; } } } diff --git a/Items/Weapons/Summon/HauntedScroll.cs b/Items/Weapons/Summon/HauntedScroll.cs index 7e65216d0e..0f41631c53 100644 --- a/Items/Weapons/Summon/HauntedScroll.cs +++ b/Items/Weapons/Summon/HauntedScroll.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class HauntedScroll : ModItem + public class HauntedScroll : ModItem { public override void SetStaticDefaults() { @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Summon speedX = 0; speedY = 0; Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 30f); - //projectile.ai[1] is attack cooldown. Setting it here prevents immediate attacks + //projectile.ai[1] is attack cooldown. Setting it here prevents immediate attacks } return false; } diff --git a/Items/Weapons/Summon/HerringStaff.cs b/Items/Weapons/Summon/HerringStaff.cs index ede1b24df2..a6ba33bee2 100644 --- a/Items/Weapons/Summon/HerringStaff.cs +++ b/Items/Weapons/Summon/HerringStaff.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Herring Staff"); Tooltip.SetDefault("Summons a herring to fight for you\n" + - "Each herring takes only half of a minion slot"); + "Each herring takes only half of a minion slot"); } public override void SetDefaults() diff --git a/Items/Weapons/Summon/HivePod.cs b/Items/Weapons/Summon/HivePod.cs index 9d02b848d5..341c0285ff 100644 --- a/Items/Weapons/Summon/HivePod.cs +++ b/Items/Weapons/Summon/HivePod.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - //CalamityUtils.OnlyOneSentry(player, type); - Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); - player.UpdateMaxTurrets(); + //CalamityUtils.OnlyOneSentry(player, type); + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); + player.UpdateMaxTurrets(); return false; } } diff --git a/Items/Weapons/Summon/LanternoftheSoul.cs b/Items/Weapons/Summon/LanternoftheSoul.cs index f7ecb0b817..4ff573cc76 100644 --- a/Items/Weapons/Summon/LanternoftheSoul.cs +++ b/Items/Weapons/Summon/LanternoftheSoul.cs @@ -6,13 +6,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class LanternoftheSoul : ModItem + public class LanternoftheSoul : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Guidelight of Oblivion"); Tooltip.SetDefault("Shadows dream of endless fire, flames devour and embers swoop\n" + - "Summons a lantern turret to fight for you"); + "Summons a lantern turret to fight for you"); } public override void SetDefaults() @@ -27,17 +27,17 @@ namespace CalamityMod.Items.Weapons.Summon item.useStyle = ItemUseStyleID.SwingThrow; item.noMelee = true; item.knockBack = 5f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.rare = ItemRarityID.Purple; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.rare = ItemRarityID.Purple; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); - item.UseSound = SoundID.Item44; + item.UseSound = SoundID.Item44; } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - //CalamityUtils.OnlyOneSentry(player, type); + //CalamityUtils.OnlyOneSentry(player, type); Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); player.UpdateMaxTurrets(); return false; diff --git a/Items/Weapons/Summon/OrthoceraShell.cs b/Items/Weapons/Summon/OrthoceraShell.cs index bd46b3580e..01db61efe2 100644 --- a/Items/Weapons/Summon/OrthoceraShell.cs +++ b/Items/Weapons/Summon/OrthoceraShell.cs @@ -37,9 +37,9 @@ namespace CalamityMod.Items.Weapons.Summon { if (player.altFunctionUse != 2) { - if (player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 1f); + if (player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 1f); player.UpdateMaxTurrets(); } } diff --git a/Items/Weapons/Summon/Perdition.cs b/Items/Weapons/Summon/Perdition.cs index 2b18a2a3d5..c7d2506d15 100644 --- a/Items/Weapons/Summon/Perdition.cs +++ b/Items/Weapons/Summon/Perdition.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Summon DisplayName.SetDefault("Perdition"); Tooltip.SetDefault("Summons a beacon at the position of the mouse\n" + "When a target is manually selected via right click it releases torrents of souls from below onto the target\n" + - "Only one beacon may exist at a time"); + "Only one beacon may exist at a time"); } public override void SetDefaults() @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Summon { if (player.altFunctionUse != 2) { - CalamityUtils.OnlyOneSentry(player, type); + CalamityUtils.OnlyOneSentry(player, type); Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); player.UpdateMaxTurrets(); } diff --git a/Items/Weapons/Summon/PlantationStaff.cs b/Items/Weapons/Summon/PlantationStaff.cs index f071bfc809..6a8109c65a 100644 --- a/Items/Weapons/Summon/PlantationStaff.cs +++ b/Items/Weapons/Summon/PlantationStaff.cs @@ -7,92 +7,92 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class PlantationStaff : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Plantation Staff"); - Tooltip.SetDefault("Summons a miniature plantera to protect you\n" + - "Fires seeds, spiky balls, and spore clouds from afar to poison targets\n" + - "Enrages when you get under 75% health and begins ramming enemies\n" + - "Occupies 3 minion slots and there can only be one"); - } + public class PlantationStaff : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plantation Staff"); + Tooltip.SetDefault("Summons a miniature plantera to protect you\n" + + "Fires seeds, spiky balls, and spore clouds from afar to poison targets\n" + + "Enrages when you get under 75% health and begins ramming enemies\n" + + "Occupies 3 minion slots and there can only be one"); + } - public override void SetDefaults() - { - item.damage = 55; - item.mana = 10; - item.width = 66; - item.height = 70; - item.useTime = item.useAnimation = 20; - item.useStyle = ItemUseStyleID.SwingThrow; - item.noMelee = true; - item.knockBack = 1f; - item.value = Item.buyPrice(0, 80, 0, 0); - item.rare = ItemRarityID.Yellow; - item.UseSound = SoundID.Item76; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 10f; - item.summon = true; - } + public override void SetDefaults() + { + item.damage = 55; + item.mana = 10; + item.width = 66; + item.height = 70; + item.useTime = item.useAnimation = 20; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 1f; + item.value = Item.buyPrice(0, 80, 0, 0); + item.rare = ItemRarityID.Yellow; + item.UseSound = SoundID.Item76; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.maxMinions >= 3; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.maxMinions >= 3; - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.OpticStaff); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.OpticStaff); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ItemID.OpticStaff); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } - 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) - { - CalamityUtils.KillShootProjectileMany(player, new int[] { type, ModContent.ProjectileType() }); + 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) + { + CalamityUtils.KillShootProjectileMany(player, new int[] { type, ModContent.ProjectileType() }); - float speed = item.shootSpeed; - player.itemTime = item.useTime; - Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float directionX = (float)Main.mouseX + Main.screenPosition.X - playerPos.X; - float directionY = (float)Main.mouseY + Main.screenPosition.Y - playerPos.Y; - if (player.gravDir == -1f) - { - directionY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - playerPos.Y; - } - Vector2 spinningpoint = new Vector2(directionX, directionY); - float vectorDist = spinningpoint.Length(); - if ((float.IsNaN(spinningpoint.X) && float.IsNaN(spinningpoint.Y)) || (spinningpoint.X == 0f && spinningpoint.Y == 0f)) - { - spinningpoint.X = (float)player.direction; - spinningpoint.Y = 0f; - vectorDist = speed; - } - else - { - vectorDist = speed / vectorDist; - } - spinningpoint.X *= vectorDist; - spinningpoint.Y *= vectorDist; - playerPos.X = (float)Main.mouseX + Main.screenPosition.X; - playerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; - spinningpoint = spinningpoint.RotatedBy(MathHelper.PiOver2, default); - Projectile.NewProjectile(playerPos + spinningpoint, spinningpoint, type, damage, knockBack, player.whoAmI, 0f, 0f); - } - return false; - } - } + float speed = item.shootSpeed; + player.itemTime = item.useTime; + Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float directionX = (float)Main.mouseX + Main.screenPosition.X - playerPos.X; + float directionY = (float)Main.mouseY + Main.screenPosition.Y - playerPos.Y; + if (player.gravDir == -1f) + { + directionY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - playerPos.Y; + } + Vector2 spinningpoint = new Vector2(directionX, directionY); + float vectorDist = spinningpoint.Length(); + if ((float.IsNaN(spinningpoint.X) && float.IsNaN(spinningpoint.Y)) || (spinningpoint.X == 0f && spinningpoint.Y == 0f)) + { + spinningpoint.X = (float)player.direction; + spinningpoint.Y = 0f; + vectorDist = speed; + } + else + { + vectorDist = speed / vectorDist; + } + spinningpoint.X *= vectorDist; + spinningpoint.Y *= vectorDist; + playerPos.X = (float)Main.mouseX + Main.screenPosition.X; + playerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; + spinningpoint = spinningpoint.RotatedBy(MathHelper.PiOver2, default); + Projectile.NewProjectile(playerPos + spinningpoint, spinningpoint, type, damage, knockBack, player.whoAmI, 0f, 0f); + } + return false; + } + } } diff --git a/Items/Weapons/Summon/PolypLauncher.cs b/Items/Weapons/Summon/PolypLauncher.cs index faee489bb3..0c0d7327fc 100644 --- a/Items/Weapons/Summon/PolypLauncher.cs +++ b/Items/Weapons/Summon/PolypLauncher.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - //CalamityUtils.OnlyOneSentry(player, type); - Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI, 20f); - player.UpdateMaxTurrets(); + //CalamityUtils.OnlyOneSentry(player, type); + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI, 20f); + player.UpdateMaxTurrets(); return false; } } diff --git a/Items/Weapons/Summon/ResurrectionButterfly.cs b/Items/Weapons/Summon/ResurrectionButterfly.cs index 99394c1985..87ee2c0ba7 100644 --- a/Items/Weapons/Summon/ResurrectionButterfly.cs +++ b/Items/Weapons/Summon/ResurrectionButterfly.cs @@ -14,8 +14,8 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Resurrection Butterfly"); Tooltip.SetDefault("Remembering the melancholy of human existence\n" + - "Even ghosts stray from the path of righteousness\n" + - "Summons a pair of butterflies to fight for you"); + "Even ghosts stray from the path of righteousness\n" + + "Summons a pair of butterflies to fight for you"); } public override void SetDefaults() diff --git a/Items/Weapons/Summon/ScabRipper.cs b/Items/Weapons/Summon/ScabRipper.cs index f678df48a3..46619e3fa4 100644 --- a/Items/Weapons/Summon/ScabRipper.cs +++ b/Items/Weapons/Summon/ScabRipper.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class ScabRipper : ModItem + public class ScabRipper : ModItem { public override void SetStaticDefaults() { @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Weapons.Summon } return false; } - + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); diff --git a/Items/Weapons/Summon/Sirius.cs b/Items/Weapons/Summon/Sirius.cs index f56085f4f7..de8136f35a 100644 --- a/Items/Weapons/Summon/Sirius.cs +++ b/Items/Weapons/Summon/Sirius.cs @@ -10,13 +10,13 @@ namespace CalamityMod.Items.Weapons.Summon { public class Sirius : ModItem { - int siriusSlots; + int siriusSlots; public override void SetStaticDefaults() { DisplayName.SetDefault("Sirius"); Tooltip.SetDefault("Summons the brightest star in the night sky to shine upon your foes\n" + "Consumes all of the remaining minion slots on use\n" + - "Must be used from the hotbar\n" + + "Must be used from the hotbar\n" + "Increased power based on the number of minion slots used"); } @@ -41,28 +41,28 @@ namespace CalamityMod.Items.Weapons.Summon item.Calamity().customRarity = CalamityRarity.PureGreen; } - public override void HoldItem(Player player) + public override void HoldItem(Player player) { - double minionCount = 0; - for (int j = 0; j < Main.projectile.Length; j++) - { + double minionCount = 0; + for (int j = 0; j < Main.projectile.Length; j++) + { Projectile proj = Main.projectile[j]; - if (proj.active && proj.owner == player.whoAmI && proj.minion && proj.type != item.shoot) - { - minionCount += proj.minionSlots; - } - } - siriusSlots = (int)(player.maxMinions - minionCount); - } + if (proj.active && proj.owner == player.whoAmI && proj.minion && proj.type != item.shoot) + { + minionCount += proj.minionSlots; + } + } + siriusSlots = (int)(player.maxMinions - minionCount); + } public override bool CanUseItem(Player player) - { - return siriusSlots >= 1; - } + { + return siriusSlots >= 1; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityUtils.KillShootProjectiles(true, type, player); + CalamityUtils.KillShootProjectiles(true, type, player); Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI, siriusSlots, 30f); return false; } diff --git a/Items/Weapons/Summon/SpikecragStaff.cs b/Items/Weapons/Summon/SpikecragStaff.cs index 3768abcc23..2f68237582 100644 --- a/Items/Weapons/Summon/SpikecragStaff.cs +++ b/Items/Weapons/Summon/SpikecragStaff.cs @@ -36,9 +36,9 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - //CalamityUtils.OnlyOneSentry(player, type); - Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI, 120f, 0f); - player.UpdateMaxTurrets(); + //CalamityUtils.OnlyOneSentry(player, type); + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI, 120f, 0f); + player.UpdateMaxTurrets(); return false; } } diff --git a/Items/Weapons/Summon/SquirrelSquireStaff.cs b/Items/Weapons/Summon/SquirrelSquireStaff.cs index f2a50917cb..f68304606e 100644 --- a/Items/Weapons/Summon/SquirrelSquireStaff.cs +++ b/Items/Weapons/Summon/SquirrelSquireStaff.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class SquirrelSquireStaff : ModItem + public class SquirrelSquireStaff : ModItem { public override void SetStaticDefaults() { @@ -48,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Summon return false; } - //in case you lose it and want another for some bizzare reason + //in case you lose it and want another for some bizzare reason public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); diff --git a/Items/Weapons/Summon/StaffoftheMechworm.cs b/Items/Weapons/Summon/StaffoftheMechworm.cs index addae8e27e..08ac5ca82e 100644 --- a/Items/Weapons/Summon/StaffoftheMechworm.cs +++ b/Items/Weapons/Summon/StaffoftheMechworm.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class StaffoftheMechworm : ModItem + public class StaffoftheMechworm : ModItem { // This value is also referenced by the God Slayer and Auric summoner helmets. public const int BaseDamage = 161; // originally 325 @@ -27,10 +27,10 @@ namespace CalamityMod.Items.Weapons.Summon item.useStyle = ItemUseStyleID.SwingThrow; item.noMelee = true; item.knockBack = 2f; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.UseSound = SoundID.Item113; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.UseSound = SoundID.Item113; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; diff --git a/Items/Weapons/Summon/SunGodStaff.cs b/Items/Weapons/Summon/SunGodStaff.cs index a36d1a8493..2c2996fea3 100644 --- a/Items/Weapons/Summon/SunGodStaff.cs +++ b/Items/Weapons/Summon/SunGodStaff.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Sun God Staff"); Tooltip.SetDefault("Summons a solar god spirit to protect you\n" + - "There can only be one spirit"); + "There can only be one spirit"); } public override void SetDefaults() @@ -50,7 +50,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityUtils.KillShootProjectiles(true, type, player); + CalamityUtils.KillShootProjectiles(true, type, player); Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); return false; } diff --git a/Items/Weapons/Summon/SunSpiritStaff.cs b/Items/Weapons/Summon/SunSpiritStaff.cs index 0b97d2c0d4..934c007f5e 100644 --- a/Items/Weapons/Summon/SunSpiritStaff.cs +++ b/Items/Weapons/Summon/SunSpiritStaff.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Sun Spirit Staff"); Tooltip.SetDefault("Summons a solar spirit to protect you\n" + - "There can only be one spirit"); + "There can only be one spirit"); } public override void SetDefaults() @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityUtils.KillShootProjectiles(true, type, player); + CalamityUtils.KillShootProjectiles(true, type, player); Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); return false; } diff --git a/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs b/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs index 73b9515ac7..6bd3b1dc2c 100644 --- a/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs +++ b/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Tundra Flame Blossoms Staff"); Tooltip.SetDefault("Summons three unusual flowers over your head\n" + - "Each flower consumes one minion slot"); + "Each flower consumes one minion slot"); } public override void SetDefaults() @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityUtils.KillShootProjectiles(false, type, player); + CalamityUtils.KillShootProjectiles(false, type, player); 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/Summon/VileFeeder.cs b/Items/Weapons/Summon/VileFeeder.cs index 5e467293a5..d0ffa427e6 100644 --- a/Items/Weapons/Summon/VileFeeder.cs +++ b/Items/Weapons/Summon/VileFeeder.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class VileFeeder : ModItem + public class VileFeeder : ModItem { public static int BaseDamage = 9; @@ -36,44 +36,44 @@ namespace CalamityMod.Items.Weapons.Summon item.summon = 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) + 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) { - int i = Main.myPlayer; - float num72 = item.shootSpeed; - float knockback = knockBack; - knockback = player.GetWeaponKnockback(item, knockback); - player.itemTime = item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (player.gravDir == -1f) - { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; - } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) - { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; - } - else - { - num80 = num72 / num80; - } - num78 *= num80; - num79 *= num80; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - Vector2 spinningpoint = new Vector2(num78, num79); - spinningpoint = spinningpoint.RotatedBy(MathHelper.PiOver2, default); - Projectile.NewProjectile(vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockback, i, 0f, 0f); - } - return false; + int i = Main.myPlayer; + float num72 = item.shootSpeed; + float knockback = knockBack; + knockback = player.GetWeaponKnockback(item, knockback); + player.itemTime = item.useTime; + Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); + float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; + float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + if (player.gravDir == -1f) + { + num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + } + float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); + if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + { + num78 = (float)player.direction; + num79 = 0f; + num80 = num72; + } + else + { + num80 = num72 / num80; + } + num78 *= num80; + num79 *= num80; + vector2.X = (float)Main.mouseX + Main.screenPosition.X; + vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; + Vector2 spinningpoint = new Vector2(num78, num79); + spinningpoint = spinningpoint.RotatedBy(MathHelper.PiOver2, default); + Projectile.NewProjectile(vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockback, i, 0f, 0f); + } + return false; } - + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); diff --git a/Items/Weapons/Summon/ViridVanguard.cs b/Items/Weapons/Summon/ViridVanguard.cs index bf8f8f526f..95590df969 100644 --- a/Items/Weapons/Summon/ViridVanguard.cs +++ b/Items/Weapons/Summon/ViridVanguard.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Virid Vanguard"); Tooltip.SetDefault("Summons 2 blades that rotate around you\n" + - "Each pair of blades take up three minion slots\n" + + "Each pair of blades take up three minion slots\n" + "Right clicking prompts all blades to fly upward and redirect towards the mouse"); Item.staff[item.type] = true; } diff --git a/Items/Weapons/Summon/VoidConcentrationStaff.cs b/Items/Weapons/Summon/VoidConcentrationStaff.cs index a6fe01c422..e56ec7a81d 100644 --- a/Items/Weapons/Summon/VoidConcentrationStaff.cs +++ b/Items/Weapons/Summon/VoidConcentrationStaff.cs @@ -7,13 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - class VoidConcentrationStaff : ModItem + class VoidConcentrationStaff : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Void Concentration Staff"); Tooltip.SetDefault("Summons a foreboding aura that attacks by firing void orbs\n" + //If you have flavour text ideas, feel free to implement, my brain is still like nonexistant as per usual yeah. - "Minion damage is increased by 5% while the aura is active\n" + + "Minion damage is increased by 5% while the aura is active\n" + "Requires three minion slots to use\n" + "Only one may exist\n" + "Right click to launch a black hole that grows in size"); diff --git a/Items/Weapons/Summon/WitherBlossomsStaff.cs b/Items/Weapons/Summon/WitherBlossomsStaff.cs index 9e3412207b..5ac2398371 100644 --- a/Items/Weapons/Summon/WitherBlossomsStaff.cs +++ b/Items/Weapons/Summon/WitherBlossomsStaff.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityUtils.KillShootProjectiles(false, type, player); + CalamityUtils.KillShootProjectiles(false, type, player); for (int i = 0; i < 4; i++) { Projectile blossom = Projectile.NewProjectileDirect(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 0f); diff --git a/Items/Weapons/Typeless/AeroDynamite.cs b/Items/Weapons/Typeless/AeroDynamite.cs index aff4a6a8a3..90f5ce05ac 100644 --- a/Items/Weapons/Typeless/AeroDynamite.cs +++ b/Items/Weapons/Typeless/AeroDynamite.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Typeless { - public class AeroDynamite : ModItem + public class AeroDynamite : ModItem { public static int Damage = 250; public static float Knockback = 10f; @@ -15,22 +15,22 @@ namespace CalamityMod.Items.Weapons.Typeless { DisplayName.SetDefault("Skynamite"); Tooltip.SetDefault("You don't need an aerodynamics major to use this\n" + - "Throws a floaty explosive that defies gravity"); + "Throws a floaty explosive that defies gravity"); } public override void SetDefaults() { item.useTime = item.useAnimation = 40; - item.maxStack = 999; - item.consumable = true; - item.shootSpeed = 5f; - item.shoot = ModContent.ProjectileType(); + item.maxStack = 999; + item.consumable = true; + item.shootSpeed = 5f; + item.shoot = ModContent.ProjectileType(); - item.width = 8; - item.height = 28; + item.width = 8; + item.height = 28; item.useStyle = ItemUseStyleID.SwingThrow; item.noMelee = true; - item.noUseGraphic = true; + item.noUseGraphic = true; item.UseSound = SoundID.Item1; item.value = Item.buyPrice(0, 0, 40, 0); // Crafted 10 at a time item.rare = ItemRarityID.Orange; @@ -38,10 +38,10 @@ namespace CalamityMod.Items.Weapons.Typeless public override void UpdateInventory(Player player) { - //Get the Demolitionist to spawn. Also check for Merchant because he does that. - if (NPC.FindFirstNPC(NPCID.Merchant) != -1 && NPC.FindFirstNPC(NPCID.Demolitionist) == -1) - Main.townNPCCanSpawn[NPCID.Demolitionist] = true; - } + //Get the Demolitionist to spawn. Also check for Merchant because he does that. + if (NPC.FindFirstNPC(NPCID.Merchant) != -1 && NPC.FindFirstNPC(NPCID.Demolitionist) == -1) + Main.townNPCCanSpawn[NPCID.Demolitionist] = true; + } public override void AddRecipes() { diff --git a/Items/Weapons/Typeless/AethersWhisper.cs b/Items/Weapons/Typeless/AethersWhisper.cs index e16b8bea53..f4b10321a6 100644 --- a/Items/Weapons/Typeless/AethersWhisper.cs +++ b/Items/Weapons/Typeless/AethersWhisper.cs @@ -9,99 +9,99 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Typeless { - public class AethersWhisper : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Aether's Whisper"); - Tooltip.SetDefault("Inflicts long-lasting shadowflame and splits on tile hits\n" + - "Projectiles gain damage as they travel\n" + - "Right click to change from magic to ranged damage\n" + - "Right click consumes no mana"); - } + public class AethersWhisper : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Aether's Whisper"); + Tooltip.SetDefault("Inflicts long-lasting shadowflame and splits on tile hits\n" + + "Projectiles gain damage as they travel\n" + + "Right click to change from magic to ranged damage\n" + + "Right click consumes no mana"); + } - public override void SetDefaults() - { - item.damage = 504; - item.knockBack = 5.5f; - item.useTime = item.useAnimation = 24; - item.shootSpeed = 12f; - item.shoot = ModContent.ProjectileType(); - item.mana = 30; - item.magic = true; - item.autoReuse = true; + public override void SetDefaults() + { + item.damage = 504; + item.knockBack = 5.5f; + item.useTime = item.useAnimation = 24; + item.shootSpeed = 12f; + item.shoot = ModContent.ProjectileType(); + item.mana = 30; + item.magic = true; + item.autoReuse = true; - item.width = 134; - item.height = 44; - item.noMelee = true; - item.useStyle = ItemUseStyleID.HoldingOut; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"); + item.width = 134; + item.height = 44; + item.noMelee = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"); - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override bool AltFunctionUse(Player player) => true; + public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) - { - if (player.altFunctionUse == 2) - { - item.ranged = true; - item.magic = false; - } - else - { - item.ranged = false; - item.magic = true; - } - return base.CanUseItem(player); - } + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse == 2) + { + item.ranged = true; + item.magic = false; + } + else + { + item.ranged = false; + item.magic = true; + } + return base.CanUseItem(player); + } - public override bool OnPickup(Player player) - { - item.ranged = false; - item.magic = true; - return true; - } + public override bool OnPickup(Player player) + { + item.ranged = false; + item.magic = true; + return true; + } - public override void UpdateInventory(Player player) - { - // Reset to magic if not using an item to prevent sorting bugs. - if (player.itemAnimation <= 0) - { - item.ranged = false; - item.magic = true; - } - } + public override void UpdateInventory(Player player) + { + // Reset to magic if not using an item to prevent sorting bugs. + if (player.itemAnimation <= 0) + { + item.ranged = false; + item.magic = true; + } + } - public override void ModifyManaCost(Player player, ref float reduce, ref float mult) - { - if (player.altFunctionUse == 2) - mult *= 0f; - } + public override void ModifyManaCost(Player player, ref float reduce, ref float mult) + { + if (player.altFunctionUse == 2) + mult *= 0f; + } - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - // This is coded weirdly because it defaults to using magic boosts without this. - int dmg = player.GetWeaponDamage(player.ActiveItem()); - float ai0 = player.altFunctionUse == 2 ? 1f : 0f; - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, dmg, knockBack, player.whoAmI, ai0, 0f); - return false; - } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + // This is coded weirdly because it defaults to using magic boosts without this. + int dmg = player.GetWeaponDamage(player.ActiveItem()); + float ai0 = player.altFunctionUse == 2 ? 1f : 0f; + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, dmg, knockBack, player.whoAmI, ai0, 0f); + return false; + } - 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(), 3); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + 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(), 3); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Typeless/EyeofMagnus.cs b/Items/Weapons/Typeless/EyeofMagnus.cs index f81d830b40..637ca91cbc 100644 --- a/Items/Weapons/Typeless/EyeofMagnus.cs +++ b/Items/Weapons/Typeless/EyeofMagnus.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Typeless { DisplayName.SetDefault("Eye of Magnus"); Tooltip.SetDefault("Fires powerful beams that reduce enemy protection\n" + - "This weapon scales with all your damage stats at once\n" + + "This weapon scales with all your damage stats at once\n" + "Heals mana and health on hit"); } @@ -30,35 +30,35 @@ namespace CalamityMod.Items.Weapons.Typeless item.noMelee = true; item.height = 50; item.value = CalamityGlobalItem.Rarity9BuyPrice; - item.shoot = ModContent.ProjectileType(); + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; - } + } public override Vector2? HoldoutOffset() { return new Vector2(-15, 0); } - // Eye of Magnus scales off of all damage types simultaneously (meaning it scales 5x from universal damage boosts). - public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) - { - float formula = 5f * (player.allDamage - 1f); - formula += player.meleeDamage - 1f; - formula += player.rangedDamage - 1f; - formula += player.magicDamage - 1f; - formula += player.minionDamage - 1f; - formula += player.Calamity().throwingDamage - 1f; - add += formula; - } + // Eye of Magnus scales off of all damage types simultaneously (meaning it scales 5x from universal damage boosts). + public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) + { + float formula = 5f * (player.allDamage - 1f); + formula += player.meleeDamage - 1f; + formula += player.rangedDamage - 1f; + formula += player.magicDamage - 1f; + formula += player.minionDamage - 1f; + formula += player.Calamity().throwingDamage - 1f; + add += formula; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.FragmentNebula, 10); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.FragmentNebula, 10); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Typeless/FiniteUse/Bazooka.cs b/Items/Weapons/Typeless/FiniteUse/Bazooka.cs index 07e543c777..cf731b21a5 100644 --- a/Items/Weapons/Typeless/FiniteUse/Bazooka.cs +++ b/Items/Weapons/Typeless/FiniteUse/Bazooka.cs @@ -66,8 +66,8 @@ namespace CalamityMod.Items.Weapons.Typeless.FiniteUse { if (CalamityPlayer.areThereAnyDamnBosses) { - player.HeldItem.Calamity().timesUsed++; - for (int i = 0; i < Main.maxInventory; i++) + player.HeldItem.Calamity().timesUsed++; + for (int i = 0; i < Main.maxInventory; i++) { if (player.inventory[i].type == item.type && player.inventory[i] != player.HeldItem) player.inventory[i].Calamity().timesUsed++; diff --git a/Items/Weapons/Typeless/FiniteUse/ElephantKiller.cs b/Items/Weapons/Typeless/FiniteUse/ElephantKiller.cs index fe24d84767..7c15189718 100644 --- a/Items/Weapons/Typeless/FiniteUse/ElephantKiller.cs +++ b/Items/Weapons/Typeless/FiniteUse/ElephantKiller.cs @@ -38,8 +38,8 @@ namespace CalamityMod.Items.Weapons.Typeless.FiniteUse item.Calamity().timesUsed = 3; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 66; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 66; public override bool OnPickup(Player player) { @@ -63,13 +63,13 @@ namespace CalamityMod.Items.Weapons.Typeless.FiniteUse { if (CalamityPlayer.areThereAnyDamnBosses) { - player.HeldItem.Calamity().timesUsed++; - for (int i = 0; i < Main.maxInventory; i++) - { - if (player.inventory[i].type == item.type && player.inventory[i] != player.HeldItem) - player.inventory[i].Calamity().timesUsed++; - } - } + player.HeldItem.Calamity().timesUsed++; + for (int i = 0; i < Main.maxInventory; i++) + { + if (player.inventory[i].type == item.type && player.inventory[i] != player.HeldItem) + player.inventory[i].Calamity().timesUsed++; + } + } return true; } diff --git a/Items/Weapons/Typeless/FiniteUse/Hydra.cs b/Items/Weapons/Typeless/FiniteUse/Hydra.cs index 8377358a6c..d77a5b522d 100644 --- a/Items/Weapons/Typeless/FiniteUse/Hydra.cs +++ b/Items/Weapons/Typeless/FiniteUse/Hydra.cs @@ -73,13 +73,13 @@ namespace CalamityMod.Items.Weapons.Typeless.FiniteUse if (CalamityPlayer.areThereAnyDamnBosses) { - player.HeldItem.Calamity().timesUsed++; - for (int i = 0; i < Main.maxInventory; i++) - { - if (player.inventory[i].type == item.type && player.inventory[i] != player.HeldItem) - player.inventory[i].Calamity().timesUsed++; - } - } + player.HeldItem.Calamity().timesUsed++; + for (int i = 0; i < Main.maxInventory; i++) + { + if (player.inventory[i].type == item.type && player.inventory[i] != player.HeldItem) + player.inventory[i].Calamity().timesUsed++; + } + } return false; } diff --git a/Items/Weapons/Typeless/FiniteUse/LightningHawk.cs b/Items/Weapons/Typeless/FiniteUse/LightningHawk.cs index 8ef31761a2..9077afaa6f 100644 --- a/Items/Weapons/Typeless/FiniteUse/LightningHawk.cs +++ b/Items/Weapons/Typeless/FiniteUse/LightningHawk.cs @@ -38,8 +38,8 @@ namespace CalamityMod.Items.Weapons.Typeless.FiniteUse item.Calamity().timesUsed = 3; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 56; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 56; public override bool OnPickup(Player player) { @@ -63,13 +63,13 @@ namespace CalamityMod.Items.Weapons.Typeless.FiniteUse { if (CalamityPlayer.areThereAnyDamnBosses) { - player.HeldItem.Calamity().timesUsed++; - for (int i = 0; i < Main.maxInventory; i++) - { - if (player.inventory[i].type == item.type && player.inventory[i] != player.HeldItem) - player.inventory[i].Calamity().timesUsed++; - } - } + player.HeldItem.Calamity().timesUsed++; + for (int i = 0; i < Main.maxInventory; i++) + { + if (player.inventory[i].type == item.type && player.inventory[i] != player.HeldItem) + player.inventory[i].Calamity().timesUsed++; + } + } return true; } diff --git a/Items/Weapons/Typeless/FiniteUse/Magnum.cs b/Items/Weapons/Typeless/FiniteUse/Magnum.cs index 60994af987..e38964799b 100644 --- a/Items/Weapons/Typeless/FiniteUse/Magnum.cs +++ b/Items/Weapons/Typeless/FiniteUse/Magnum.cs @@ -38,8 +38,8 @@ namespace CalamityMod.Items.Weapons.Typeless.FiniteUse item.Calamity().timesUsed = 3; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 46; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 46; public override bool OnPickup(Player player) { @@ -63,13 +63,13 @@ namespace CalamityMod.Items.Weapons.Typeless.FiniteUse { if (CalamityPlayer.areThereAnyDamnBosses) { - player.HeldItem.Calamity().timesUsed++; - for (int i = 0; i < Main.maxInventory; i++) - { - if (player.inventory[i].type == item.type && player.inventory[i] != player.HeldItem) - player.inventory[i].Calamity().timesUsed++; - } - } + player.HeldItem.Calamity().timesUsed++; + for (int i = 0; i < Main.maxInventory; i++) + { + if (player.inventory[i].type == item.type && player.inventory[i] != player.HeldItem) + player.inventory[i].Calamity().timesUsed++; + } + } return true; } diff --git a/Items/Weapons/Typeless/RelicOfDeliverance.cs b/Items/Weapons/Typeless/RelicOfDeliverance.cs index f64cf9cfa1..1aac787078 100644 --- a/Items/Weapons/Typeless/RelicOfDeliverance.cs +++ b/Items/Weapons/Typeless/RelicOfDeliverance.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Typeless { - public class RelicOfDeliverance : ModItem + public class RelicOfDeliverance : ModItem { public override void SetStaticDefaults() { @@ -28,14 +28,14 @@ namespace CalamityMod.Items.Weapons.Typeless item.noMelee = true; item.noUseGraphic = true; item.channel = true; - item.value = CalamityGlobalItem.Rarity11BuyPrice; - item.rare = ItemRarityID.Purple; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity11BuyPrice; + item.rare = ItemRarityID.Purple; + item.shoot = ModContent.ProjectileType(); item.Calamity().CannotBeEnchanted = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 16; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 16; public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; } diff --git a/Items/Weapons/Typeless/StarStruckWater.cs b/Items/Weapons/Typeless/StarStruckWater.cs index ab30d2a0ff..a0790aa944 100644 --- a/Items/Weapons/Typeless/StarStruckWater.cs +++ b/Items/Weapons/Typeless/StarStruckWater.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Typeless { - public class StarStruckWater : ModItem + public class StarStruckWater : ModItem { public override void SetStaticDefaults() { @@ -15,22 +15,22 @@ namespace CalamityMod.Items.Weapons.Typeless public override void SetDefaults() { - item.useStyle = ItemUseStyleID.SwingThrow; - item.shootSpeed = 14f; - item.rare = ItemRarityID.Orange; - item.damage = 20; - item.shoot = ModContent.ProjectileType(); - item.width = 18; - item.height = 20; - item.maxStack = 999; - item.consumable = true; - item.knockBack = 3f; - item.UseSound = SoundID.Item1; - item.useAnimation = 15; - item.useTime = 15; - item.noUseGraphic = true; - item.noMelee = true; - item.value = 200; + item.useStyle = ItemUseStyleID.SwingThrow; + item.shootSpeed = 14f; + item.rare = ItemRarityID.Orange; + item.damage = 20; + item.shoot = ModContent.ProjectileType(); + item.width = 18; + item.height = 20; + item.maxStack = 999; + item.consumable = true; + item.knockBack = 3f; + item.UseSound = SoundID.Item1; + item.useAnimation = 15; + item.useTime = 15; + item.noUseGraphic = true; + item.noMelee = true; + item.value = 200; } public override void AddRecipes() diff --git a/Items/Weapons/Typeless/YanmeisKnife.cs b/Items/Weapons/Typeless/YanmeisKnife.cs index b190a9f7f5..26eb37f694 100644 --- a/Items/Weapons/Typeless/YanmeisKnife.cs +++ b/Items/Weapons/Typeless/YanmeisKnife.cs @@ -7,64 +7,64 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Typeless { - public class YanmeisKnife : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Yanmei's Knife"); - Tooltip.SetDefault("When hitting a boss, miniboss, or their minions, you gain various boosts and cripple the enemy hit\n" + - "A knife from an unknown world\n" + - "An owner whose heart is pure and free of taint\n" + - "A heart of iron and valor"); - } + public class YanmeisKnife : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Yanmei's Knife"); + Tooltip.SetDefault("When hitting a boss, miniboss, or their minions, you gain various boosts and cripple the enemy hit\n" + + "A knife from an unknown world\n" + + "An owner whose heart is pure and free of taint\n" + + "A heart of iron and valor"); + } - public override void SetDefaults() - { - item.height = 44; - item.width = 48; - item.damage = 8; - item.noMelee = true; - item.noUseGraphic = true; - item.useAnimation = item.useTime = 32; - item.useStyle = ItemUseStyleID.HoldingOut; - item.knockBack = 4.5f; - item.autoReuse = false; - item.value = CalamityGlobalItem.Rarity8BuyPrice; - item.rare = ItemRarityID.Yellow; - item.Calamity().donorItem = true; - item.UseSound = SoundID.Item71; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 24f; - } + public override void SetDefaults() + { + item.height = 44; + item.width = 48; + item.damage = 8; + item.noMelee = true; + item.noUseGraphic = true; + item.useAnimation = item.useTime = 32; + item.useStyle = ItemUseStyleID.HoldingOut; + item.knockBack = 4.5f; + item.autoReuse = false; + item.value = CalamityGlobalItem.Rarity8BuyPrice; + item.rare = ItemRarityID.Yellow; + item.Calamity().donorItem = true; + item.UseSound = SoundID.Item71; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 24f; + } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 6; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 6; - public override bool CanUseItem(Player player) - { - if (player.Calamity().KameiBladeUseDelay > 0) - return false; - return base.CanUseItem(player); - } + public override bool CanUseItem(Player player) + { + if (player.Calamity().KameiBladeUseDelay > 0) + return false; + 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) - { - player.Calamity().KameiBladeUseDelay = 180; - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - return false; - } + 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.Calamity().KameiBladeUseDelay = 180; + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.PsychoKnife); - recipe.AddIngredient(ItemID.Obsidian, 10); - recipe.AddIngredient(ItemID.IronBar, 20); - recipe.anyIronBar = true; - recipe.AddIngredient(ModContent.ItemType(), 50); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.PsychoKnife); + recipe.AddIngredient(ItemID.Obsidian, 10); + recipe.AddIngredient(ItemID.IronBar, 20); + recipe.anyIronBar = true; + recipe.AddIngredient(ModContent.ItemType(), 50); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index 6c056cc7b8..61f6aefc5b 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -15,2004 +15,2004 @@ using Terraria.ModLoader; namespace CalamityMod { - public class ModCalls - { - #region Boss / Event Downed - /// - /// Returns whether the Calamity boss or event corresponding to the given string has been defeated. - /// - /// The boss or event name to check. Many aliases are accepted. - /// Whether the boss or event has been defeated. - public static bool GetBossDowned(string boss) - { - switch (boss.ToLower()) - { - default: - return false; - - // Because this value will always be true if Acid Rain at any point in the game is beaten. - case "acid rain": - case "acidrain": - - case "acid rain 1": - case "acidrain 1": - case "acidrain1": - case "acid rain eoc": - case "acidrain eoc": - case "acidraineoc": - return CalamityWorld.downedEoCAcidRain; - - case "desertscourge": - case "desert scourge": - return CalamityWorld.downedDesertScourge; - - case "clam": - case "giantclam": - case "giant clam": - return CalamityWorld.downedCLAM; - - case "crabulon": - return CalamityWorld.downedCrabulon; - - case "hivemind": - case "hive mind": - case "thehivemind": - case "the hive mind": - return CalamityWorld.downedHiveMind; - - case "perforator": - case "perforators": - case "theperforators": - case "the perforators": - case "perforatorhive": - case "perforator hive": - case "theperforatorhive": - case "the perforator hive": - return CalamityWorld.downedPerforator; - - case "slimegod": - case "slime god": - case "theslimegod": - case "the slime god": - return CalamityWorld.downedSlimeGod; - - case "hmclam": - case "clamhm": - case "hm clam": - case "clam hm": - case "hmgiantclam": - case "giantclamhm": - case "hm giant clam": - case "giant clam hm": - case "hardmodeclam": - case "hardmode clam": - case "hardmodegiantclam": - case "hardmode giant clam": - return CalamityWorld.downedCLAMHardMode; - - case "cryogen": - return CalamityWorld.downedCryogen; - - case "acid rain 2": - case "acidrain 2": - case "acidrain2": - case "acid rain scourge": - case "acid rain aquatic scourge": - case "acid rain aquaticscourge": - case "acidrain scourge": - case "acidrain aquatic scourge": - case "acidrain aquaticscourge": - case "acidrainscourge": - case "acidrainaquaticscourge": - return CalamityWorld.downedAquaticScourgeAcidRain; - - case "aquaticscourge": - case "aquatic scourge": - return CalamityWorld.downedAquaticScourge; - - case "brimstoneelemental": - case "brimstone elemental": - return CalamityWorld.downedBrimstoneElemental; - - case "calamitas": - case "clone": - case "calamitasclone": - case "calamitas clone": - case "clonelamitas": - case "calamitasdoppelganger": - case "calamitas doppelganger": - return CalamityWorld.downedCalamitas; - - case "gss": - case "greatsandshark": - case "great sand shark": - return CalamityWorld.downedGSS; - - // Don't remove the old references to "Siren" here to avoid breaking other mods - case "sirenleviathan": - case "siren leviathan": - case "sirenandleviathan": - case "siren and leviathan": - case "the siren and the leviathan": - case "siren": - case "thesiren": - case "the siren": - case "anahita": - case "leviathan": - case "theleviathan": - case "the leviathan": - case "anahitaleviathan": - case "anahita leviathan": - case "anahitaandleviathan": - case "anahita and leviathan": - case "anahita and the leviathan": - return CalamityWorld.downedLeviathan; - - case "aureus": - case "astrumaureus": - case "astrum aureus": - return CalamityWorld.downedAstrageldon; - - case "pbg": - case "plaguebringer": - case "plaguebringergoliath": - case "plaguebringer goliath": - case "theplaguebringergoliath": - case "the plaguebringer goliath": - return CalamityWorld.downedPlaguebringer; - - case "scavenger": // backwards compatibility - case "ravager": - return CalamityWorld.downedScavenger; - - case "stargod": // backwards compatibility - case "star god": // backwards compatibility - case "astrumdeus": - case "astrum deus": - return CalamityWorld.downedStarGod; - - case "guardians": - case "donuts": - case "profanedguardians": - case "profaned guardians": - case "theprofanedguardians": - case "the profaned guardians": - return CalamityWorld.downedGuardians; - - case "dragonfolly": - case "the dragonfolly": - case "bumblebirb": - case "bumblefuck": - return CalamityWorld.downedBumble; - - case "providence": - case "providencetheprofanedgoddess": - case "providence the profaned goddess": - case "providence, the profaned goddess": - return CalamityWorld.downedProvidence; - - case "polterghast": - case "necroghast": - case "necroplasm": - return CalamityWorld.downedPolterghast; - - // Old Duke is also Acid Rain tier 3, so he gets those names too - case "oldduke": - case "old duke": - case "theoldduke": - case "the old duke": - case "boomerduke": - case "boomer duke": - case "sulphurduke": - case "sulphur duke": - case "sulfurduke": - case "sulfur duke": - case "acid rain 3": - case "acidrain 3": - case "acidrain3": - case "acid rain duke": - case "acidrain duke": - case "acidrainduke": - return CalamityWorld.downedBoomerDuke; - - case "sentinel1": // backwards compatibility - case "void": - case "ceaselessvoid": - case "ceaseless void": - return CalamityWorld.downedSentinel1; - - case "sentinel2": // backwards compatibility - case "stormweaver": - case "storm weaver": - return CalamityWorld.downedSentinel2; - - case "sentinel3": // backwards compatibility - case "cosmicwraith": - case "cosmic wraith": - case "signus": - case "signusenvoyofthedevourer": - case "signus envoy of the devourer": - case "signus, envoy of the devourer": - return CalamityWorld.downedSentinel3; - - case "sentinelany": // backwards compatibility - case "anysentinel": - case "any sentinel": - case "onesentinel": - case "one sentinel": - case "sentinel": - return CalamityWorld.downedSentinel1 || CalamityWorld.downedSentinel2 || CalamityWorld.downedSentinel3; - - case "sentinelall": // backwards compatibility - case "sentinels": - case "allsentinel": - case "allsentinels": - case "all sentinels": - return CalamityWorld.downedSentinel1 && CalamityWorld.downedSentinel2 && CalamityWorld.downedSentinel3; - - case "dog": - case "devourerofgods": - case "devourer of gods": - case "thedevourerofgods": - case "the devourer of gods": - return CalamityWorld.downedDoG; - - case "yharon": - case "jungledragonyharon": - case "jungle dragon yharon": - case "jungle dragon, yharon": - return CalamityWorld.downedYharon; - - case "draedon": - case "exomechs": - case "exo mechs": - case "the exo mechs": - case "apollo": - case "artemis": - case "thanatos": - case "ares": - return CalamityWorld.downedExoMechs; - - case "scal": - case "supremecalamitas": - case "supreme calamitas": - return CalamityWorld.downedSCal; - - case "adulteidolonwyrm": - case "adult eidolon wyrm": - case "adultwyrm": - case "adult wyrm": - case "adulteidolon": - case "adult eidolon": - return CalamityWorld.downedAdultEidolonWyrm; - } - } - #endregion - - #region Player in Zone / Area - /// - /// Returns whether the specified player is in the Calamity biome or area corresponding to the given string. - /// - /// The player whose locale is being questioned. - /// The zone or area name to check. Many aliases are accepted. - /// Whether the player is currently in the zone. - public static bool GetInZone(Player p, string zone) - { - CalamityPlayer mp = p.Calamity(); - switch (zone.ToLower()) - { - default: - return false; - - case "calamity": // backwards compatibility - case "calamitybiome": - case "calamity biome": - case "crag": - case "crags": - - case "profanedcrag": // remove these four when the actual profaned biome is added - case "profaned crag": - case "profanedcrags": - case "profaned crags": - - case "brimstone": - case "brimstonecrag": - case "brimstone crag": - case "brimstonecrags": - case "brimstone crags": - return mp.ZoneCalamity; - - case "astral": - case "astralbiome": - case "astral biome": - case "astralinfection": - case "astral infection": - return mp.ZoneAstral; - - case "sunkensea": - case "sunken sea": - case "thesunkensea": - case "the sunken sea": - return mp.ZoneSunkenSea; - - case "sulfur": - case "sulphur": - case "sulfursea": - case "sulfur sea": - case "sulphursea": - case "sulphur sea": - case "sulfuroussea": - case "sulfurous sea": - case "sulphuroussea": - case "sulphurous sea": - return mp.ZoneSulphur; - - case "abyss": - case "theabyss": - case "the abyss": - case "anyabyss": - case "any abyss": - case "abyssany": - case "any abyss layer": - return mp.ZoneAbyss; - - case "abyss1": - case "abyss 1": - case "abyss_1": - case "layer1": - case "layer 1": - case "layer_1": - case "abysslayer1": - case "abyss layer 1": - return mp.ZoneAbyssLayer1; - - case "abyss2": - case "abyss 2": - case "abyss_2": - case "layer2": - case "layer 2": - case "layer_2": - case "abysslayer2": - case "abyss layer 2": - return mp.ZoneAbyssLayer2; - - case "abyss3": - case "abyss 3": - case "abyss_3": - case "layer3": - case "layer 3": - case "layer_3": - case "abysslayer3": - case "abyss layer 3": - return mp.ZoneAbyssLayer3; - - case "abyss4": - case "abyss 4": - case "abyss_4": - case "layer4": - case "layer 4": - case "layer_4": - case "abysslayer4": - case "abyss layer 4": - return mp.ZoneAbyssLayer4; - } - } - #endregion - - #region Difficulty Modes - /// - /// Returns whether the Calamity difficulty modifier corresponding to the given string is currently active. - /// - /// The difficulty modifier to check for. - /// Whether the difficulty is currently active. - public static bool GetDifficultyActive(string difficulty) - { - switch (difficulty.ToLower()) - { - default: - return false; - - case "revengeance": - case "rev": - case "revengeancemode": - case "revengeance mode": - return CalamityWorld.revenge; - - case "death": - case "deathmode": - case "death mode": - return CalamityWorld.death; - - case "malice": - case "malicemode": - case "malice mode": - return CalamityWorld.malice; - - case "br": - case "bossrush": - case "boss rush": - case "bossrushactive": - case "boss rush active": - return BossRushEvent.BossRushActive; - - case "armageddon": - case "arma": - case "instakill": - case "instagib": - case "armageddonmode": - case "armageddon mode": - return CalamityWorld.armageddon; - } - } - - /// - /// Either enables or disables the Calamity difficulty modifier corresponding to the given string.

- /// Unlike the in-game mode changing items, this has no ancillary effects such as failing if a boss is alive or instantly killing players. - ///
- /// The difficulty modifier to edit. - /// Whether to enable or disable the difficulty. - /// - public static bool SetDifficultyActive(string difficulty, bool enabled) - { - switch (difficulty.ToLower()) - { - default: - return false; - - case "revengeance": - case "rev": - case "revengeancemode": - case "revengeance mode": - return CalamityWorld.revenge = enabled; - - case "death": - case "deathmode": - case "death mode": - return CalamityWorld.death = enabled; - - case "malice": - case "malicemode": - case "malice mode": - return CalamityWorld.malice = enabled; - - case "br": - case "bossrush": - case "boss rush": - case "bossrushactive": - case "boss rush active": - return BossRushEvent.BossRushActive = enabled; - - case "armageddon": - case "arma": - case "instakill": - case "instagib": - case "armageddonmode": - case "armageddon mode": - return CalamityWorld.armageddon = enabled; - } - } - #endregion - - #region Rogue Class - /// - /// Gets a player's current rogue damage stat. - /// - /// The player whose rogue damage is being queried. - /// Current rogue damage boost. 1f is no bonus, 2f is +100%. - public static float GetRogueDamage(Player p) => p?.Calamity()?.throwingDamage ?? 1f; - - /// - /// Adds a flat amount of rogue damage stat to a player. This amount can be negative. - /// - /// The player whose rogue damage is being modified. - /// The amount of rogue damage to add or subtract (if negative). - /// The player's new rogue damage stat. - public static float AddRogueDamage(Player p, float add) => p is null ? 1f : (p.Calamity().throwingDamage += add); - - /// - /// Gets a player's current rogue critical strike chance. - /// - /// The player whose rogue crit is being queried. - /// Current rogue critical strike chance. 0 is no additional crit, 8 is +8% crit chance. - public static int GetRogueCrit(Player p) => p?.Calamity()?.throwingCrit ?? 0; - - /// - /// Adds a flat amount of rogue crit to a player. This amount can be negative. - /// - /// The player whose rogue crit is being modified. - /// The amount of rogue crit to add or subtract (if negative). - /// The player's new rogue crit stat. - public static int AddRogueCrit(Player p, int add) => p is null ? 0 : (p.Calamity().throwingCrit += add); - - /// - /// Gets a player's current rogue projectile velocity multiplier. - /// - /// The player whose rogue velocity is being queried. - /// Current rogue projectile velocity multiplier. 1f is no bonus, 2f doubles projectile speed. - public static float GetRogueVelocity(Player p) => p?.Calamity()?.throwingVelocity ?? 1f; - - /// - /// Adds a flat amount of rogue velocity stat to a player. This amount can be negative. - /// - /// The player whose rogue velocity is being modified. - /// The amount of rogue velocity to add or subtract (if negative). - /// The player's new rogue velocity stat. - public static float AddRogueVelocity(Player p, float add) => p is null ? 1f : (p.Calamity().throwingVelocity += add); - - public static float GetCurrentStealth(Player p) => p?.Calamity()?.rogueStealth ?? 0f; - - public static float GetMaxStealth(Player p) => p?.Calamity()?.rogueStealthMax ?? 0f; - - public static float AddMaxStealth(Player p, float add) => p is null ? 0f : (p.Calamity().rogueStealthMax += add); - - /// - /// Gets whether the given item is classified as a rogue weapon. - /// - /// The item which is being checked. - /// Whether the item is a rogue weapon. - public static bool IsRogue(Item it) - { - if (it is null || it.Calamity() is null) - return false; - CalamityGlobalItem cgi = it.Calamity(); - return cgi.rogue; - } - - /// - /// Sets whether the given item is classified as a rogue weapon. - /// - /// The item whose rogue classification is being toggled. - /// The value to apply. - /// Whether the item is now a rogue weapon. - public static bool SetRogue(Item it, bool isRogue) - { - if (it is null || it.Calamity() is null) - return false; - CalamityGlobalItem cgi = it.Calamity(); - cgi.rogue = isRogue; - return cgi.rogue; - } - - /// - /// Gets whether the given projectile is classified as rogue. - /// - /// The projectile which is being checked. - /// Whether the projectile is rogue. - public static bool IsRogue(Projectile p) - { - if (p is null || p.Calamity() is null) - return false; - CalamityGlobalProjectile cgp = p.Calamity(); - return cgp.rogue | cgp.forceRogue; - } - - /// - /// Sets whether the given projectile is classified as rogue. If set to true, also forces the projectile to be rogue every single frame. - /// - /// The projectile whose rogue classification is being toggled. - /// The value to apply. - /// Whether the projectile is now rogue. - public static bool SetRogue(Projectile p, bool isRogue) - { - if (p is null || p.Calamity() is null) - return false; - CalamityGlobalProjectile cgp = p.Calamity(); - cgp.forceRogue = cgp.rogue = isRogue; - return cgp.rogue; - } - #endregion - - #region Player Armor Set Bonuses - /// - /// Returns whether the specified player has the set bonus corresponding to the given string. - /// - /// The player whose set bonuses are being questioned. - /// The set bonus to check for. - /// Whether the player currently has the set bonus. - public static bool GetSetBonus(Player p, string setBonus) - { - CalamityPlayer mp = p.Calamity(); - - setBonus = setBonus.ToLower(); - - // LATER -- no summon set bonuses are written well. all use two bools, neither of which actually controls the function - - // Desert Prowler - if (setBonus == "desertprowler" || setBonus == "desert prowler") - return mp.desertProwler; - - // Snow Ruffian - if (setBonus == "snowruffian" || setBonus == "snow ruffian") - return mp.snowRuffianSet; - - // Sulphurous - if (setBonus == "sulfur" || setBonus == "sulphur" || setBonus == "sulfurous" || setBonus == "sulphurous") - return mp.sulfurSet; - - // Victide - if (setBonus == "victide_summon" || setBonus == "victide summon") - return mp.urchin; // the bool set directly by VictideHelmet.UpdateArmorSet - else if (setBonus == "victide" || setBonus.StartsWith("victide_") || setBonus.StartsWith("victide ")) - return mp.victideSet; - - // Aerospec - if (setBonus == "aerospec_summon" || setBonus == "aerospec summon") - return mp.valkyrie; // the bool set directly by AerospecHelmet.UpdateArmorSet - else if (setBonus == "aerospec" || setBonus.StartsWith("aerospec_") || setBonus.StartsWith("aerospec ")) - return mp.aeroSet; - - // Statigel - if (setBonus == "statigel_summon" || setBonus == "statigel summon") - return mp.slimeGod; // the bool set directly by StatigelHood.UpdateArmorSet - if (setBonus == "statigel" || setBonus.StartsWith("statigel_") || setBonus.StartsWith("statigel ")) - return mp.statigelSet; - - // Mollusk - if (setBonus == "mollusk") - return mp.molluskSet; - - // Titan Heart - if (setBonus == "titanheart" || setBonus == "titan heart") - return mp.titanHeartSet; - - // Forbidden Circlet - if (setBonus == "forbidden_circlet" || setBonus == "forbidden circlet") - return mp.forbiddenCirclet; - - // Daedalus - switch (setBonus) - { - default: - break; - case "daedalus": - return mp.daedalusReflect || mp.daedalusShard || mp.daedalusAbsorb || mp.daedalusCrystal || mp.daedalusSplit; - case "daedalus_melee": - case "daedalus melee": - return mp.daedalusReflect; - case "daedalus_ranged": - case "daedalus ranged": - return mp.daedalusShard; - case "daedalus_magic": - case "daedalus magic": - return mp.daedalusAbsorb; - case "daedalus_summon": - case "daedalus summon": - return mp.daedalusCrystal; - case "daedalus_rogue": - case "daedalus rogue": - return mp.daedalusSplit; - } - - // Reaver - switch (setBonus) - { - default: - break; - case "reaver": - return mp.reaverSpeed || mp.reaverExplore || mp.reaverDefense; - case "reaver_speed": - case "reaver speed": - return mp.reaverSpeed; - case "reaver_explore": - case "reaver explore": - case "reaver_exploration": - case "reaver exploration": - return mp.reaverExplore; - case "reaver_defense": - case "reaver defense": - case "reaver_tank": - case "reaver tank": - return mp.reaverDefense; - } - - // Fathom Swarmer - if (setBonus == "fathomswarmer" || setBonus == "fathom swarmer") - return mp.fathomSwarmer; - - // Brimflame - if (setBonus == "brimflame") - return mp.brimflameSet; - - // Umbraphile - if (setBonus == "umbraphile") - return mp.umbraphileSet; - - // Hydrothermic (Ataxia is legacy name) - switch (setBonus) - { - default: - break; - case "ataxia": - case "hydrothermic": - case "hydrothermal": - return mp.ataxiaBlaze; - case "ataxia_melee": - case "ataxia melee": - case "hydrothermic_melee": - case "hydrothermic melee": - case "hydrothermal_melee": - case "hydrothermal melee": - return mp.ataxiaGeyser; - case "ataxia_ranged": - case "ataxia ranged": - case "hydrothermic_ranged": - case "hydrothermic ranged": - case "hydrothermal_ranged": - case "hydrothermal ranged": - return mp.ataxiaBolt; - case "ataxia_magic": - case "ataxia magic": - case "hydrothermic_magic": - case "hydrothermic magic": - case "hydrothermal_magic": - case "hydrothermal magic": - return mp.ataxiaMage; - case "ataxia_summon": - case "ataxia summon": - case "hydrothermic_summon": - case "hydrothermic summon": - case "hydrothermal_summon": - case "hydrothermal summon": - return mp.chaosSpirit; - case "ataxia_rogue": - case "ataxia rogue": - case "hydrothermic_rogue": - case "hydrothermic rogue": - case "hydrothermal_rogue": - case "hydrothermal rogue": - return mp.ataxiaVolley; - } - - // Plague Reaper - if (setBonus == "plaguereaper" || setBonus == "plague reaper") - return mp.plagueReaper; - - // Plaguebringer - if (setBonus == "plaguebringer" || setBonus == "plaguebringerpatron" || setBonus == "plaguebringer patron") - return mp.plaguebringerPatronSet; - - // Astral - if (setBonus == "astral") - return mp.astralStarRain; - - // Empyrean (formerly Xeroc) - if (setBonus == "empyrean" || setBonus == "xeroc") - return mp.xerocSet; - - // Tarragon - switch (setBonus) - { - default: - break; - case "tarragon": - return mp.tarraSet; - case "tarragon_melee": - case "tarragon melee": - return mp.tarraMelee; - case "tarragon_ranged": - case "tarragon ranged": - return mp.tarraRanged; - case "tarragon_magic": - case "tarragon magic": - return mp.tarraMage; - case "tarragon_summon": - case "tarragon summon": - return mp.tarraSummon; - case "tarragon_rogue": - case "tarragon rogue": - return mp.tarraThrowing; - } - - // Prismatic - if (setBonus == "prismatic" || setBonus == "prism") - return mp.prismaticSet; - - // Bloodflare - switch (setBonus) - { - default: - break; - case "bloodflare": - return mp.bloodflareSet; - case "bloodflare_melee": - case "bloodflare melee": - return mp.bloodflareMelee; - case "bloodflare_ranged": - case "bloodflare ranged": - return mp.bloodflareRanged; - case "bloodflare_magic": - case "bloodflare magic": - return mp.bloodflareMage; - case "bloodflare_summon": - case "bloodflare summon": - return mp.bloodflareSummon; - case "bloodflare_rogue": - case "bloodflare rogue": - return mp.bloodflareThrowing; - } - - // Omega Blue - if (setBonus == "omegablue" || setBonus == "omega blue") - return mp.omegaBlueSet; - - // God Slayer - switch (setBonus) - { - default: - break; - case "godslayer": - case "god slayer": - return mp.godSlayer; - case "godslayer_melee": - case "godslayer melee": - case "god slayer melee": - return mp.godSlayerDamage; // melee helm's unique damage reducing property - case "godslayer_ranged": - case "godslayer ranged": - case "god slayer ranged": - return mp.godSlayerRanged; - // God Slayer Mage was removed in the Draedon Update - case "godslayer_magic": - case "godslayer magic": - case "god slayer magic": - return false; // mp.godSlayerMage; - // God Slayer Summon was removed in the Draedon Update - case "godslayer_summon": - case "godslayer summon": - case "god slayer summon": - return false; // mp.godSlayerSummon; - - case "godslayer_rogue": - case "godslayer rogue": - case "god slayer rogue": - return mp.godSlayerThrowing; - } - - // Fearmonger - if (setBonus == "fearmonger") - return mp.fearmongerSet; - - // Silva - switch (setBonus) - { - default: - break; - case "silva": - return mp.silvaSet; - - // Silva Melee was removed in the Draedon Update - case "silva_melee": - case "silva melee": - return false; // mp.silvaMelee; - // Silva Ranged was removed in the Draedon Update - case "silva_ranged": - case "silva ranged": - return false; // mp.silvaRanged; - case "silva_magic": - case "silva magic": - return mp.silvaMage; - case "silva_summon": - case "silva summon": - return mp.silvaSummon; - // Silva Rogue was removed in the Draedon Update - case "silva_rogue": - case "silva rogue": - return false; // mp.silvaThrowing; - } - - // Auric Tesla - if (setBonus == "auric" || setBonus == "aurictesla" || setBonus == "auric tesla") - return mp.auricSet; - - // Demonshade - if (setBonus == "demonshade") - return mp.dsSetBonus; - - return false; - } - - /// - /// Turns the set bonus corresponding to the given string on or off for the specified player. - /// - /// The player whose set bonuses are being toggled. - /// The set bonus to check for. - /// Whether the set bonus should be enabled (true) or disabled (false). - /// Whether any set bonus was adjusted. - public static bool SetSetBonus(Player p, string setBonus, bool enabled) - { - CalamityPlayer mp = p.Calamity(); - setBonus = setBonus.ToLower(); - - // Desert Prowler - if (setBonus == "desertprowler" || setBonus == "desert prowler") - { - mp.desertProwler = enabled; - return true; - } - - // Snow Ruffian - if (setBonus == "snowruffian" || setBonus == "snow ruffian") - { - mp.snowRuffianSet = enabled; - return true; - } - - // Sulphurous - if (setBonus == "sulfur" || setBonus == "sulphur" || setBonus == "sulfurous" || setBonus == "sulphurous") - { - mp.sulfurSet = enabled; - mp.sulfurJump = enabled; - return true; - } - - // Victide - if (setBonus == "victide_summon" || setBonus == "victide summon") - { - mp.victideSet = enabled; - mp.urchin = enabled; // LATER -- remove this when player.urchin actually controls victide summoner - return true; - } - else if (setBonus == "victide" || setBonus.StartsWith("victide_") || setBonus.StartsWith("victide ")) - { - mp.victideSet = true; - return true; - } - - // Aerospec - if (setBonus == "aerospec_summon" || setBonus == "aerospec summon") - { - mp.aeroSet = enabled; - mp.valkyrie = enabled; // LATER -- remove this when player.valkyrie actually controls aerospec summoner - return true; - } - else if (setBonus == "aerospec" || setBonus.StartsWith("aerospec_") || setBonus.StartsWith("aerospec ")) - { - mp.aeroSet = enabled; - return true; - } - - // Statigel - if (setBonus == "statigel_summon" || setBonus == "statigel summon") - { - mp.statigelSet = enabled; - mp.slimeGod = enabled; // LATER -- remove this when player.slimeGod actually controls statigel summoner - return true; - } - else if (setBonus == "statigel" || setBonus.StartsWith("statigel_") || setBonus.StartsWith("statigel ")) - { - mp.statigelSet = enabled; - return true; - } - - // Mollusk - if (setBonus == "mollusk") - { - mp.molluskSet = enabled; - return true; - } - - // Titan Heart - if (setBonus == "titanheart" || setBonus == "titan heart") - { - mp.titanHeartMask = enabled; - mp.titanHeartMantle = enabled; - mp.titanHeartBoots = enabled; - mp.titanHeartSet = enabled; - return true; - } - - // Forbidden Circlet - if (setBonus == "forbidden_circlet" || setBonus == "forbidden circlet") - { - mp.forbiddenCirclet = enabled; - return true; - } - - // Daedalus - switch (setBonus) - { - default: - break; - case "daedalus_melee": - case "daedalus melee": - mp.daedalusReflect = enabled; - return true; - case "daedalus_ranged": - case "daedalus ranged": - mp.daedalusShard = enabled; - return true; - case "daedalus_magic": - case "daedalus magic": - mp.daedalusAbsorb = enabled; - return true; - case "daedalus_summon": - case "daedalus summon": - mp.daedalusCrystal = enabled; // LATER -- remove this when player.daedalusCrystal actually controls daedalus summoner - return true; - case "daedalus_rogue": - case "daedalus rogue": - mp.daedalusSplit = enabled; - return true; - } - - // Reaver - switch (setBonus) - { - default: - break; - case "reaver_speed": - case "reaver speed": - mp.reaverSpeed = enabled; - return true; - case "reaver_explore": - case "reaver explore": - case "reaver_exploration": - case "reaver exploration": - mp.reaverExplore = enabled; - return true; - case "reaver_defense": - case "reaver defense": - case "reaver_tank": - case "reaver tank": - mp.reaverDefense = enabled; - return true; - } - - // Fathom Swarmer - if (setBonus == "fathomswarmer" || setBonus == "fathom swarmer") - { - mp.fathomSwarmer = enabled; - return true; - } - - // Brimflame - if (setBonus == "brimflame") - { - mp.brimflameSet = enabled; - return true; - } - - // Umbraphile - if (setBonus == "umbraphile") - { - mp.umbraphileSet = enabled; - return true; - } - - // Hydrothermic (Ataxia as legacy name) - switch (setBonus) - { - default: - break; - case "ataxia": - case "hydrothermic": - case "hydrothermal": - mp.ataxiaBlaze = enabled; - return true; - case "ataxia_melee": - case "ataxia melee": - case "hydrothermic_melee": - case "hydrothermic melee": - case "hydrothermal_melee": - case "hydrothermal melee": - mp.ataxiaBlaze = enabled; - mp.ataxiaGeyser = enabled; - return true; - case "ataxia_ranged": - case "ataxia ranged": - case "hydrothermic_ranged": - case "hydrothermic ranged": - case "hydrothermal_ranged": - case "hydrothermal ranged": - mp.ataxiaBlaze = enabled; - mp.ataxiaBolt = enabled; - return true; - case "ataxia_magic": - case "ataxia magic": - case "hydrothermic_magic": - case "hydrothermic magic": - case "hydrothermal_magic": - case "hydrothermal magic": - mp.ataxiaBlaze = enabled; - mp.ataxiaMage = enabled; - return true; - case "ataxia_summon": - case "ataxia summon": - case "hydrothermic_summon": - case "hydrothermic summon": - case "hydrothermal_summon": - case "hydrothermal summon": - mp.ataxiaBlaze = enabled; - mp.chaosSpirit = enabled; // LATER -- remove this when player.chaosSpirit actually controls ataxia summoner - return true; - case "ataxia_rogue": - case "ataxia rogue": - case "hydrothermic_rogue": - case "hydrothermic rogue": - case "hydrothermal_rogue": - case "hydrothermal rogue": - mp.ataxiaBlaze = enabled; - mp.ataxiaVolley = enabled; - return true; - } - - // Plague Reaper - if (setBonus == "plaguereaper" || setBonus == "plague reaper") - { - mp.plagueReaper = enabled; - return true; - } - - // Plaguebringer - if (setBonus == "plaguebringer" || setBonus == "plaguebringerpatron" || setBonus == "plaguebringer patron") - { - mp.plaguebringerPatronSet = enabled; - return true; - } - - // Astral - if (setBonus == "astral") - { - mp.astralStarRain = enabled; - return true; - } - - // Xeroc - if (setBonus == "empyrean" || setBonus == "xeroc") - { - mp.xerocSet = enabled; - return true; - } - - // Tarragon - switch (setBonus) - { - default: - break; - case "tarragon": - mp.tarraSet = enabled; - return true; - case "tarragon_melee": - case "tarragon melee": - mp.tarraSet = enabled; - mp.tarraMelee = enabled; - return true; - case "tarragon_ranged": - case "tarragon ranged": - mp.tarraSet = enabled; - mp.tarraRanged = enabled; - return true; - case "tarragon_magic": - case "tarragon magic": - mp.tarraSet = enabled; - mp.tarraMage = enabled; - return true; - case "tarragon_summon": - case "tarragon summon": - mp.tarraSet = enabled; - mp.tarraSummon = enabled; // LATER -- remove this when player.tarraSummon actually controls life aura - return true; - case "tarragon_rogue": - case "tarragon rogue": - mp.tarraSet = enabled; - mp.tarraThrowing = enabled; - return true; - } - - // Prismatic - if (setBonus == "prismatic" || setBonus == "prism") - { - mp.prismaticSet = enabled; - return true; - } - - // Bloodflare - switch (setBonus) - { - default: - break; - case "bloodflare": - mp.bloodflareSet = enabled; - return true; - case "bloodflare_melee": - case "bloodflare melee": - mp.bloodflareSet = enabled; - mp.bloodflareMelee = enabled; - return true; - case "bloodflare_ranged": - case "bloodflare ranged": - mp.bloodflareSet = enabled; - mp.bloodflareRanged = enabled; - return true; - case "bloodflare_magic": - case "bloodflare magic": - mp.bloodflareSet = enabled; - mp.bloodflareMage = enabled; - return true; - case "bloodflare_summon": - case "bloodflare summon": - mp.bloodflareSet = enabled; - mp.bloodflareSummon = enabled; // LATER -- remove this when player.bloodflareSummon actually controls bloodflare orbs - return true; - case "bloodflare_rogue": - case "bloodflare rogue": - mp.bloodflareSet = enabled; - mp.bloodflareThrowing = enabled; - return true; - } - - // Omega Blue - if (setBonus == "omegablue" || setBonus == "omega blue") - { - mp.omegaBlueSet = enabled; - return true; - } - - // God Slayer - switch (setBonus) - { - default: - break; - case "godslayer": - case "god slayer": - mp.godSlayer = enabled; - return true; - case "godslayer_melee": - case "godslayer melee": - case "god slayer melee": - mp.godSlayer = enabled; - mp.godSlayerDamage = enabled; // melee helm's unique damage reducing property - return true; - case "godslayer_ranged": - case "godslayer ranged": - case "god slayer ranged": - mp.godSlayer = enabled; - mp.godSlayerRanged = enabled; - return true; - // God Slayer Mage and Summon were removed in the Draedon Update - /* - case "godslayer_magic": - case "godslayer magic": - case "god slayer magic": - mp.godSlayer = enabled; - mp.godSlayerMage = enabled; - return true; - case "godslayer_summon": - case "godslayer summon": - case "god slayer summon": - mp.godSlayer = enabled; - mp.godSlayerSummon = enabled; - return true; - */ - case "godslayer_rogue": - case "godslayer rogue": - case "god slayer rogue": - mp.godSlayer = enabled; - mp.godSlayerThrowing = enabled; - return true; - } - - // Fearmonger - if (setBonus == "fearmonger") - { - mp.fearmongerSet = enabled; - return true; - } - - // Silva - switch (setBonus) - { - default: - break; - case "silva": - mp.silvaSet = enabled; - return true; - case "silva_magic": - case "silva magic": - mp.silvaSet = enabled; - mp.silvaMage = enabled; - return true; - case "silva_summon": - case "silva summon": - mp.silvaSet = enabled; - mp.silvaSummon = enabled; // LATER -- remove this when player.silvaSummon actually controls silva crystal - return true; - // Silva Melee, Ranged and Rogue were removed in the Draedon Update - /* - case "silva_melee": - case "silva melee": - mp.silvaSet = enabled; - mp.silvaMelee = enabled; - return true; - case "silva_ranged": - case "silva ranged": - mp.silvaSet = enabled; - mp.silvaRanged = enabled; - return true; - case "silva_rogue": - case "silva rogue": - mp.silvaSet = enabled; - mp.silvaThrowing = enabled; - return true; - */ - } - - // Auric Tesla (includes all components) - switch (setBonus) - { - default: - break; - case "auric": - case "aurictesla": - case "auric tesla": - mp.tarraSet = enabled; - mp.bloodflareSet = enabled; - mp.godSlayer = enabled; - mp.silvaSet = enabled; - mp.auricSet = enabled; - return true; - case "auric_melee": - case "auric melee": - case "aurictesla_melee": - case "aurictesla melee": - case "auric tesla melee": - mp.tarraSet = enabled; - mp.tarraMelee = enabled; - mp.bloodflareSet = enabled; - mp.bloodflareMelee = enabled; - mp.godSlayer = enabled; - mp.godSlayerDamage = enabled; - mp.silvaSet = enabled; - // mp.silvaMelee = enabled; - mp.auricSet = enabled; - return true; - case "auric_ranged": - case "auric ranged": - case "aurictesla_ranged": - case "aurictesla ranged": - case "auric tesla ranged": - mp.tarraSet = enabled; - mp.tarraRanged = enabled; - mp.bloodflareSet = enabled; - mp.bloodflareRanged = enabled; - mp.godSlayer = enabled; - mp.godSlayerRanged = enabled; - mp.silvaSet = enabled; - // mp.silvaRanged = enabled; - mp.auricSet = enabled; - return true; - case "auric_magic": - case "auric magic": - case "aurictesla_magic": - case "aurictesla magic": - case "auric tesla magic": - mp.tarraSet = enabled; - mp.tarraMage = enabled; - mp.bloodflareSet = enabled; - mp.bloodflareMage = enabled; - mp.godSlayer = enabled; - // mp.godSlayerMage = enabled; - mp.silvaSet = enabled; - mp.silvaMage = enabled; - mp.auricSet = enabled; - return true; - case "auric_summon": - case "auric summon": - case "aurictesla_summon": - case "aurictesla summon": - case "auric tesla summon": - mp.tarraSet = enabled; - mp.tarraSummon = enabled; - mp.bloodflareSet = enabled; - mp.bloodflareSummon = enabled; - mp.godSlayer = enabled; - // mp.godSlayerSummon = enabled; - mp.silvaSet = enabled; - mp.silvaSummon = enabled; - mp.auricSet = enabled; - return true; - case "auric_rogue": - case "auric rogue": - case "aurictesla_rogue": - case "aurictesla rogue": - case "auric tesla rogue": - mp.tarraSet = enabled; - mp.tarraThrowing = enabled; - mp.bloodflareSet = enabled; - mp.bloodflareThrowing = enabled; - mp.godSlayer = enabled; - mp.godSlayerThrowing = enabled; - mp.silvaSet = enabled; - // mp.silvaThrowing = enabled; - mp.auricSet = enabled; - return true; - } - - // Demonshade - if (setBonus == "demonshade") - { - mp.dsSetBonus = enabled; - mp.rDevil = enabled; // LATER -- remove this when player.rDevil controls demonshade summoned minion - return true; - } - - return false; - } - #endregion - - #region Other Player Stats - public static int GetLightStrength(Player p) => p?.Calamity()?.GetTotalLightStrength() ?? 0; - - public static void AddAbyssLightStrength(Player p, int add) - { - if (p != null) - p.Calamity().externalAbyssLight += add; - } - - public static bool MakeColdImmune(Player p) => p is null ? false : (p.Calamity().externalColdImmunity = true); - public static bool MakeHeatImmune(Player p) => p is null ? false : (p.Calamity().externalHeatImmunity = true); - #endregion - - #region Set Damage Reduction - public static float SetDamageReduction(int npcID, float dr) - { - CalamityMod.DRValues.TryGetValue(npcID, out float oldDR); - CalamityMod.DRValues.Remove(npcID); - CalamityMod.DRValues.Add(npcID, dr); - return oldDR; - } - #endregion - - #region Boss Health Bars - public static bool BossHealthBarVisible() => Main.LocalPlayer.Calamity().drawBossHPBar; - - public static bool SetBossHealthBarVisible(bool visible) => Main.LocalPlayer.Calamity().drawBossHPBar = visible; - #endregion - - #region Dodge Disabling - public static bool AreDodgesDisabled() => Main.LocalPlayer.Calamity().disableAllDodges; - - public static bool DisableAllDodges(bool disable) => Main.LocalPlayer.Calamity().disableAllDodges = disable; - #endregion - - #region Item Rarity - public static int GetCalamityRarity(Item item) - { - CalamityGlobalItem cgi = item.Calamity(); - CalamityRarity calrare = cgi.customRarity; - if (calrare == CalamityRarity.NoEffect) - return item.rare; - return (int)calrare; - } - - public static bool SetCalamityRarity(Item item, int rarityNum) - { - CalamityGlobalItem cgi = item.Calamity(); - cgi.customRarity = (CalamityRarity)rarityNum; - return cgi.customRarity != CalamityRarity.NoEffect; - } - #endregion - - #region Call - - public static object Call(params object[] args) - { - bool isValidPlayerArg(object o) => o is int || o is Player; - bool isValidItemArg(object o) => o is int || o is Item; - bool isValidProjectileArg(object o) => o is int || o is Projectile; - - Player castPlayer(object o) - { - if (o is int i) - return Main.player[i]; - else if (o is Player p) - return p; - return null; - } - - Item castItem(object o) - { - if (o is int i) - return Main.item[i]; - else if (o is Item it) - return it; - return null; - } - - Projectile castProjectile(object o) - { - if (o is int i) - return Main.projectile[i]; - else if (o is Projectile p) - return p; - return null; - } - - // Certain IDs in vanilla's files are shorts instead of ints for some reason. - // Instead of expecting developers to have to manually cast these IDs, this function is used - // to handle IDs that are either ints OR shorts, without the worry of missing a cast and wondering why - // the Mod Call did nothing. - bool castID(object o, out int id) - { - id = -1; - if (!(o is int) && !(o is short)) - return false; - - if (o is short shortID) - id = shortID; - if (o is int intID) - id = intID; - - return true; - } - - if (args is null || args.Length <= 0) - return new ArgumentNullException("ERROR: No function name specified. First argument must be a function name."); - if (!(args[0] is string)) - return new ArgumentException("ERROR: First argument must be a string function name."); - - string methodName = args[0].ToString(); - switch (methodName) - { - case "Downed": - case "GetDowned": - case "BossDowned": - case "GetBossDowned": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a boss or event name as a string."); - if (!(args[1] is string)) - return new ArgumentException("ERROR: The argument to \"Downed\" must be a string."); - return GetBossDowned(args[1].ToString()); - - case "Zone": - case "GetZone": - case "InZone": - case "GetInZone": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and a zone name as a string."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify a zone name as a string."); - if (!(args[2] is string)) - return new ArgumentException("ERROR: The second argument to \"InZone\" must be a string."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"InZone\" must be a Player or an int."); - return GetInZone(castPlayer(args[1]), args[2].ToString()); - - case "Difficulty": - case "GetDifficulty": - case "DifficultyActive": - case "GetDifficultyActive": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a difficulty mode name as a string."); - if (!(args[1] is string)) - return new ArgumentException("ERROR: The argument to \"Difficulty\" must be a string."); - return GetDifficultyActive(args[1].ToString()); - - case "SetDifficulty": - case "SetDifficultyActive": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a difficulty mode name as a string and a bool."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify a bool."); - if (!(args[2] is bool enabled)) - return new ArgumentException("ERROR: The second argument to \"SetDifficulty\" must be a bool."); - if (!(args[1] is string)) - return new ArgumentException("ERROR: The first argument to \"SetDifficulty\" must be a string."); - return SetDifficultyActive(args[1].ToString(), enabled); - - case "GetLight": - case "GetLightLevel": - case "GetLightStrength": - case "GetAbyssLight": - case "GetAbyssLightLevel": - case "GetAbyssLightStrength": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if(!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The argument to \"GetLightStrength\" must be a Player or an int."); - return GetLightStrength(castPlayer(args[1])); - - case "AddLight": - case "AddLightLevel": - case "AddLightStrength": - case "AddAbyssLight": - case "AddAbyssLightLevel": - case "AddAbyssLightStrength": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and light strength change as an int."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify light strength change as an int."); - if (!(args[2] is int light)) - return new ArgumentException("ERROR: The second argument to \"AddLightStrength\" must be an int."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"AddLightStrength\" must be a Player or an int."); - AddAbyssLightStrength(castPlayer(args[1]), light); - return null; - - case "GetRogueDamage": - case "GetRogueDmg": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The argument to \"GetRogueDamage\" must be a Player or an int."); - return GetRogueDamage(castPlayer(args[1])); - - case "GetRogueCrit": - case "GetRogueCritChance": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The argument to \"GetRogueCrit\" must be a Player or an int."); - return GetRogueCrit(castPlayer(args[1])); - - case "GetRogueVelocity": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The argument to \"GetRogueVelocity\" must be a Player or an int."); - return GetRogueVelocity(castPlayer(args[1])); - - case "AddRogueDamage": - case "AddRogueDmg": - case "ModifyRogueDamage": - case "ModifyRogueDmg": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue damage change as a float."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify rogue damage change as a float."); - if (!(args[2] is float damage)) - return new ArgumentException("ERROR: The second argument to \"AddRogueDamage\" must be a float."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"AddRogueDamage\" must be a Player or an int."); - return AddRogueDamage(castPlayer(args[1]), damage); - - case "AddRogueCrit": - case "AddRogueCritChance": - case "ModifyRogueCrit": - case "ModifyRogueCritChance": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue crit change as an int."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify rogue crit change as a float."); - if (!(args[2] is int crit)) - return new ArgumentException("ERROR: The second argument to \"AddRogueCrit\" must be an int."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"AddRogueCrit\" must be a Player or an int."); - return AddRogueCrit(castPlayer(args[1]), crit); - - case "AddRogueVelocity": - case "ModifyRogueVelocity": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue velocity change as a float."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify rogue velocity change as a float."); - if (!(args[2] is float velocity)) - return new ArgumentException("ERROR: The second argument to \"AddRogueVelocity\" must be a float."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"AddRogueVelocity\" must be a Player or an int."); - return AddRogueVelocity(castPlayer(args[1]), velocity); - - case "GetStealth": - case "GetCurrentStealth": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"GetStealth\" must be a Player or an int."); - return GetCurrentStealth(castPlayer(args[1])); - - case "GetMaxStealth": - case "GetStealthCap": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"GetMaxStealth\" must be a Player or an int."); - return GetMaxStealth(castPlayer(args[1])); - - case "AddMaxStealth": - case "ModifyMaxStealth": - case "ModifyStealthCap": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue max stealth as a float."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify rogue max stealth as a float."); - if (!(args[2] is float maxStealth)) - return new ArgumentException("ERROR: The second argument to \"AddMaxStealth\" must be a float."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"AddMaxStealth\" must be a Player or an int."); - return AddMaxStealth(castPlayer(args[1]), maxStealth); - - case "IsItemRogue": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify an Item object (or int index of an Item in the Main.item array)."); - if (!isValidItemArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"IsItemRogue\" must be an Item or an int."); - return IsRogue(castItem(args[1])); - - case "SetItemRogue": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both an Item object (or int index of an Item in the Main.item array) and a bool."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify rogue status as a bool."); - if (!(args[2] is bool isItemRogue)) - return new ArgumentException("ERROR: The second argument to \"SetItemRogue\" must be a bool."); - if (!isValidItemArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"SetItemRogue\" must be an Item or an int."); - return SetRogue(castItem(args[1]), isItemRogue); - - case "IsRogue": - case "IsProjRogue": - case "IsProjectileRogue": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a Projectile object (or int index of a Projectile)."); - if (!isValidProjectileArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"IsRogue\" must be a Projectile or an int."); - return IsRogue(castProjectile(args[1])); - - case "SetRogue": - case "SetProjRogue": - case "SetProjectileRogue": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both a Projectile object (or int index of a Projectile) and a bool."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify rogue status as a bool."); - if (!(args[2] is bool isRogue)) - return new ArgumentException("ERROR: The second argument to \"SetRogue\" must be a bool."); - if (!isValidProjectileArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"SetRogue\" must be a Projectile or an int."); - return SetRogue(castProjectile(args[1]), isRogue); - - case "DR": - case "DamageReduction": - case "SetDR": - case "SetDamageReduction": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both NPC ID as an int and damage reduction as a float or double."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify damage reduction as a float or double."); - if (!(args[2] is float) && !(args[2] is double)) - return new ArgumentException("ERROR: The second argument to \"SetDamageReduction\" must be a float or a double."); - if (!castID(args[1], out int npcID)) - return new ArgumentException("ERROR: The first argument to \"SetDamageReduction\" must be an int or short ID."); - - float DR = (float)args[2]; - return SetDamageReduction(npcID, DR); - - case "BossHealthBarVisible": - case "BossHealthBarsVisible": - case "GetBossHealthBarVisible": - case "GetBossHealthBarsVisible": - return BossHealthBarVisible(); - - case "SetBossHealthBarVisible": - case "SetBossHealthBarsVisible": - if (args.Length < 2 || !(args[1] is bool bossBarEnabled)) - return new ArgumentNullException("ERROR: Must specify a bool."); - return SetBossHealthBarVisible(bossBarEnabled); - - case "NoDodges": - case "DodgesDisabled": - case "GetDodgesDisabled": - return AreDodgesDisabled(); - - case "DisableDodges": - case "DisableAllDodges": - case "SetDodgesDisabled": - if (args.Length < 2 || !(args[1] is bool disableDodges)) - return new ArgumentNullException("ERROR: Must specify a bool."); - return DisableAllDodges(disableDodges); - - case "GetRarity": - case "GetItemRarity": - case "GetCalamityRarity": - case "GetPostMLRarity": - case "GetPostMoonLordRarity": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify an Item."); - if (!(args[1] is Item)) - return new ArgumentException("ERROR: The first argument to \"GetCalamityRarity\" must be an Item."); - Item itemToGet = (Item)args[1]; - return GetCalamityRarity(itemToGet); - - case "SetRarity": - case "SetItemRarity": - case "SetCalamityRarity": - case "SetPostMLRarity": - case "SetPostMoonLordRarity": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both an Item and desired rarity as an int or short ID."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify desired rarity as an int or short ID."); - if (!castID(args[2], out int rarity)) - return new ArgumentException("ERROR: The second argument to \"SetCalamityRarity\" must be an int or short ID."); - if (!(args[1] is Item)) - return new ArgumentException("ERROR: The first argument to \"SetCalamityRarity\" must be an Item."); - - Item itemToSet = (Item)args[1]; - return SetCalamityRarity(itemToSet, rarity); - - case "GetDoGCountdown": - case "GetDoGFightCountdown": - case "GetDoGStage2Countdown": - return CalamityWorld.DoGSecondStageCountdown; - - case "AcidRainActive": - case "IsAcidRainActive": - case "GetAcidRainActive": - return CalamityWorld.rainingAcid; - - case "StartAcidRain": - AcidRainEvent.TryStartEvent(true); - CalamityNetcode.SyncWorld(); - return true; - - case "StopAcidRain": - if (CalamityWorld.rainingAcid) - { - CalamityWorld.acidRainPoints = 0; - CalamityWorld.triedToSummonOldDuke = false; - AcidRainEvent.UpdateInvasion(false); - } - return true; - - // This is intentionally separate from the above because it will stop other events when they are added. - case "AbominationnClearEvents": - bool eventActive = CalamityWorld.rainingAcid; - bool canClear = Convert.ToBoolean(args[1]); //This is to indicate whether abomm is able to clear the event due to a cooldown - if (eventActive && canClear) //adjust based on other events when added. - { - CalamityWorld.acidRainPoints = 0; - CalamityWorld.triedToSummonOldDuke = false; - AcidRainEvent.UpdateInvasion(false); - } - return eventActive; - - case "ExcludeMinionsFromResurrection": - // This assumes all arguments after the calling command name are projectile types. - IEnumerable secondaryArguments = args.Skip(1); - if (secondaryArguments.Any(argument => !castID(argument, out _))) - return new ArgumentException("ERROR: All arguments after the calling command to \"ExcludeMinionsFromResurrection\" must be int or short IDs."); - - CalamityLists.MinionsToNotResurrectList.AddRange(secondaryArguments.Select(argument => - { - castID(argument, out int id); - return id; - })); - return null; - - case "CreateEnchantment": - case "RegisterEnchantment": - EnchantmentManager.ConstructFromModcall(args.Skip(1)); - return null; - - case "MakeItemExhumable": - if (args.Length != 3) - return new ArgumentNullException("ERROR: Must specify two Item types as an int."); - if (!castID(args[1], out int toExhume)) - return new ArgumentException("ERROR: The first argument to \"MakeItemExhumable\" must be an int or short ID."); - if (!castID(args[2], out int result)) - return new ArgumentException("ERROR: The second argument to \"MakeItemExhumable\" must be an int or short ID."); - EnchantmentManager.ItemUpgradeRelationship[toExhume] = result; - return null; - - case "DeclareMiniboss": - case "DeclareMinibossForHealthBar": - if (args.Length != 2) - return new ArgumentNullException("ERROR: Must specify both an NPC type as an int."); - if (!castID(args[1], out int npcType)) - return new ArgumentException("ERROR: The first argument to \"DeclareMiniboss\" must be an int or short ID."); - - BossHealthBarManager.MinibossHPBarList.Add(npcType); - return null; - - case "ExcludeBossFromHealthBar": - if (args.Length != 2) - return new ArgumentNullException("ERROR: Must specify both an NPC type as an int."); - if (!castID(args[1], out int npcType2)) - return new ArgumentException("ERROR: The first argument to \"ExcludeBossFromHealthBar\" must be an int or short ID."); - - BossHealthBarManager.BossExclusionList.Add(npcType2); - return null; - - case "DeclareOneToManyRelationshipForHealthBar": - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify both an NPC type as an int for the first argument and the other NPC types in the relationship as ints for the rest of the arguments."); - if (!args.Skip(1).All(a => castID(a, out _))) - return new ArgumentException("ERROR: All secondary and onward arguments to \"DeclareOneToManyRelationshipForHealthBar\" must be int or short IDs."); - - castID(args[1], out int npcType3); - - int[] npcsInRelationship = args.Skip(2).Select(a => (int)a).ToArray(); - BossHealthBarManager.OneToMany[npcType3] = npcsInRelationship; - return null; - - // For context, the boolean argument in the second delegate refers to whether the function should be accumulating max life (true) or just life (false), and the returned long should be the accumulated health. - case "DeclareSpecialHPCalculationDecisionForHealthBar": - if (args.Length != 3) - return new ArgumentNullException("ERROR: Must specify both a usage requirement as a Func and a health calculator function as a Func."); - if (!(args[1] is Func usageRequirement)) - return new ArgumentException("ERROR: The first argument to \"DeclareSpecialHPCalculationDecisionForHealthBar\" must be a Func."); - if (!(args[2] is Func healthCalculatorFunction)) - return new ArgumentException("ERROR: The first argument to \"DeclareSpecialHPCalculationDecisionForHealthBar\" must be a Func."); - - BossHealthBarManager.SpecialHPRequirements[new BossHealthBarManager.NPCSpecialHPGetRequirement(usageRequirement)] = new BossHealthBarManager.NPCSpecialHPGetFunction(healthCalculatorFunction); - return null; - - case "CreateNameExtensionHandlerForHealthBar": - if (args.Length < 4) - return new ArgumentNullException("ERROR: Must specify a extension name as a string, the main NPC type as an int, and the other NPC types to check for as ints the rest of the arguments."); - if (!(args[1] is string name)) - return new ArgumentException("ERROR: The first argument to \"CreateNameExtensionHandlerForHealthBar\" must be a string."); - if (!castID(args[1], out int npcType4)) - return new ArgumentException("ERROR: The second argument to \"CreateNameExtensionHandlerForHealthBar\" must be an int or short ID."); - if (!args.Skip(3).All(a => a is int)) - return new ArgumentException("ERROR: All ternary and onward arguments to \"CreateNameExtensionHandlerForHealthBar\" must be ints."); - - int[] npcsToCheckFor = args.Skip(3).Select(a => (int)a).ToArray(); - BossHealthBarManager.EntityExtensionHandler[npcType4] = new BossHealthBarManager.BossEntityExtension(name, npcsToCheckFor); - return null; - - // In the following two mod calls, the first argument is the NPC type, the second is the time change context (-1 being night, 0 being nothing, and 1 being day), - // the third being the boss spawning function, the fourth being the overriding countdown to use, the fifth being whether the boss uses a special sound on spawning, - // the sixth being the dimness factor that Boss Rush should become once the boss is currently present, the seventh being the array of NPCs present in the battle that - // should not be deleted by the Boss Rush itself, and the eight being the potential NPCs that will end up killing, assuming the initial boss isn't - // that (such as P1 Hive Mind turning into its second form and you being expected to kill that). - case "GetBossRushEntries": - var entries = new List<(int, int, Action, int, bool, float, int[], int[])>(); - foreach (BossRushEvent.Boss boss in BossRushEvent.Bosses) - { - int[] deathEntries = BossRushEvent.BossIDsAfterDeath.ContainsKey(boss.EntityID) ? BossRushEvent.BossIDsAfterDeath[boss.EntityID] : null; - entries.Add((boss.EntityID, (int)boss.ToChangeTimeTo, new Action(boss.SpawnContext), boss.SpecialSpawnCountdown, boss.UsesSpecialSound, boss.DimnessFactor, boss.HostileNPCsToNotDelete.ToArray(), deathEntries)); - } - - return entries; - - case "SetBossRushEntries": - if (args.Length != 2) - return new ArgumentNullException("ERROR: Must specify a list of bosses as a List<(int, int, Action, int, bool, int[], int[])>."); - if (!(args[1] is List<(int, int, Action, int, bool, float, int[], int[])> entries2)) - return new ArgumentException("ERROR: The first argument to \"SetBossRushEntries\" must be a List<(int, int, Action, int, bool, int[], int[])>."); - - BossRushEvent.Bosses.Clear(); - BossRushEvent.BossIDsAfterDeath.Clear(); - foreach (var entry in entries2) - { - if (entry.Item8 != null) - BossRushEvent.BossIDsAfterDeath[entry.Item1] = entry.Item8; - BossRushEvent.Bosses.Add(new BossRushEvent.Boss(entry.Item1, (BossRushEvent.TimeChangeContext)entry.Item2, new BossRushEvent.Boss.OnSpawnContext(entry.Item3), entry.Item4, entry.Item5, entry.Item6, entry.Item7)); - } - - return null; - - case "CreateCustomDeathEffectForBossRush": - if (args.Length != 3) - return new ArgumentNullException("ERROR: Must specify both an NPC type and an Action that determines what happens when the NPC is killed."); - if (!castID(args[1], out int npcType5)) - return new ArgumentException("ERROR: The first argument to \"CreateCustomDeathEffectForBossRush\" must be an int or short ID."); - if (!(args[2] is Action deathEffect)) - return new ArgumentException("ERROR: The first argument to \"CreateCustomDeathEffectForBossRush\" must be an Action."); - - BossRushEvent.BossDeathEffects[npcType5] = deathEffect; - return null; - - case "LoadParticleInstances": - if (args.Length != 2 || !(args[1] is Mod)) - return new ArgumentNullException("ERROR: Must specify a Mod instance to load particles from."); - - GeneralParticleHandler.LoadModParticleInstances(args[1] as Mod); - return null; - - case "RegisterModCooldowns": - if (args.Length != 2 || !(args[1] is Mod)) - return new ArgumentNullException("ERROR: Must specify a Mod instance to register cooldowns from."); - - CooldownRegistry.RegisterModCooldowns(args[1] as Mod); - return null; - - - default: - return new ArgumentException("ERROR: Invalid method name."); - } - } - #endregion - } + public class ModCalls + { + #region Boss / Event Downed + /// + /// Returns whether the Calamity boss or event corresponding to the given string has been defeated. + /// + /// The boss or event name to check. Many aliases are accepted. + /// Whether the boss or event has been defeated. + public static bool GetBossDowned(string boss) + { + switch (boss.ToLower()) + { + default: + return false; + + // Because this value will always be true if Acid Rain at any point in the game is beaten. + case "acid rain": + case "acidrain": + + case "acid rain 1": + case "acidrain 1": + case "acidrain1": + case "acid rain eoc": + case "acidrain eoc": + case "acidraineoc": + return CalamityWorld.downedEoCAcidRain; + + case "desertscourge": + case "desert scourge": + return CalamityWorld.downedDesertScourge; + + case "clam": + case "giantclam": + case "giant clam": + return CalamityWorld.downedCLAM; + + case "crabulon": + return CalamityWorld.downedCrabulon; + + case "hivemind": + case "hive mind": + case "thehivemind": + case "the hive mind": + return CalamityWorld.downedHiveMind; + + case "perforator": + case "perforators": + case "theperforators": + case "the perforators": + case "perforatorhive": + case "perforator hive": + case "theperforatorhive": + case "the perforator hive": + return CalamityWorld.downedPerforator; + + case "slimegod": + case "slime god": + case "theslimegod": + case "the slime god": + return CalamityWorld.downedSlimeGod; + + case "hmclam": + case "clamhm": + case "hm clam": + case "clam hm": + case "hmgiantclam": + case "giantclamhm": + case "hm giant clam": + case "giant clam hm": + case "hardmodeclam": + case "hardmode clam": + case "hardmodegiantclam": + case "hardmode giant clam": + return CalamityWorld.downedCLAMHardMode; + + case "cryogen": + return CalamityWorld.downedCryogen; + + case "acid rain 2": + case "acidrain 2": + case "acidrain2": + case "acid rain scourge": + case "acid rain aquatic scourge": + case "acid rain aquaticscourge": + case "acidrain scourge": + case "acidrain aquatic scourge": + case "acidrain aquaticscourge": + case "acidrainscourge": + case "acidrainaquaticscourge": + return CalamityWorld.downedAquaticScourgeAcidRain; + + case "aquaticscourge": + case "aquatic scourge": + return CalamityWorld.downedAquaticScourge; + + case "brimstoneelemental": + case "brimstone elemental": + return CalamityWorld.downedBrimstoneElemental; + + case "calamitas": + case "clone": + case "calamitasclone": + case "calamitas clone": + case "clonelamitas": + case "calamitasdoppelganger": + case "calamitas doppelganger": + return CalamityWorld.downedCalamitas; + + case "gss": + case "greatsandshark": + case "great sand shark": + return CalamityWorld.downedGSS; + + // Don't remove the old references to "Siren" here to avoid breaking other mods + case "sirenleviathan": + case "siren leviathan": + case "sirenandleviathan": + case "siren and leviathan": + case "the siren and the leviathan": + case "siren": + case "thesiren": + case "the siren": + case "anahita": + case "leviathan": + case "theleviathan": + case "the leviathan": + case "anahitaleviathan": + case "anahita leviathan": + case "anahitaandleviathan": + case "anahita and leviathan": + case "anahita and the leviathan": + return CalamityWorld.downedLeviathan; + + case "aureus": + case "astrumaureus": + case "astrum aureus": + return CalamityWorld.downedAstrageldon; + + case "pbg": + case "plaguebringer": + case "plaguebringergoliath": + case "plaguebringer goliath": + case "theplaguebringergoliath": + case "the plaguebringer goliath": + return CalamityWorld.downedPlaguebringer; + + case "scavenger": // backwards compatibility + case "ravager": + return CalamityWorld.downedScavenger; + + case "stargod": // backwards compatibility + case "star god": // backwards compatibility + case "astrumdeus": + case "astrum deus": + return CalamityWorld.downedStarGod; + + case "guardians": + case "donuts": + case "profanedguardians": + case "profaned guardians": + case "theprofanedguardians": + case "the profaned guardians": + return CalamityWorld.downedGuardians; + + case "dragonfolly": + case "the dragonfolly": + case "bumblebirb": + case "bumblefuck": + return CalamityWorld.downedBumble; + + case "providence": + case "providencetheprofanedgoddess": + case "providence the profaned goddess": + case "providence, the profaned goddess": + return CalamityWorld.downedProvidence; + + case "polterghast": + case "necroghast": + case "necroplasm": + return CalamityWorld.downedPolterghast; + + // Old Duke is also Acid Rain tier 3, so he gets those names too + case "oldduke": + case "old duke": + case "theoldduke": + case "the old duke": + case "boomerduke": + case "boomer duke": + case "sulphurduke": + case "sulphur duke": + case "sulfurduke": + case "sulfur duke": + case "acid rain 3": + case "acidrain 3": + case "acidrain3": + case "acid rain duke": + case "acidrain duke": + case "acidrainduke": + return CalamityWorld.downedBoomerDuke; + + case "sentinel1": // backwards compatibility + case "void": + case "ceaselessvoid": + case "ceaseless void": + return CalamityWorld.downedSentinel1; + + case "sentinel2": // backwards compatibility + case "stormweaver": + case "storm weaver": + return CalamityWorld.downedSentinel2; + + case "sentinel3": // backwards compatibility + case "cosmicwraith": + case "cosmic wraith": + case "signus": + case "signusenvoyofthedevourer": + case "signus envoy of the devourer": + case "signus, envoy of the devourer": + return CalamityWorld.downedSentinel3; + + case "sentinelany": // backwards compatibility + case "anysentinel": + case "any sentinel": + case "onesentinel": + case "one sentinel": + case "sentinel": + return CalamityWorld.downedSentinel1 || CalamityWorld.downedSentinel2 || CalamityWorld.downedSentinel3; + + case "sentinelall": // backwards compatibility + case "sentinels": + case "allsentinel": + case "allsentinels": + case "all sentinels": + return CalamityWorld.downedSentinel1 && CalamityWorld.downedSentinel2 && CalamityWorld.downedSentinel3; + + case "dog": + case "devourerofgods": + case "devourer of gods": + case "thedevourerofgods": + case "the devourer of gods": + return CalamityWorld.downedDoG; + + case "yharon": + case "jungledragonyharon": + case "jungle dragon yharon": + case "jungle dragon, yharon": + return CalamityWorld.downedYharon; + + case "draedon": + case "exomechs": + case "exo mechs": + case "the exo mechs": + case "apollo": + case "artemis": + case "thanatos": + case "ares": + return CalamityWorld.downedExoMechs; + + case "scal": + case "supremecalamitas": + case "supreme calamitas": + return CalamityWorld.downedSCal; + + case "adulteidolonwyrm": + case "adult eidolon wyrm": + case "adultwyrm": + case "adult wyrm": + case "adulteidolon": + case "adult eidolon": + return CalamityWorld.downedAdultEidolonWyrm; + } + } + #endregion + + #region Player in Zone / Area + /// + /// Returns whether the specified player is in the Calamity biome or area corresponding to the given string. + /// + /// The player whose locale is being questioned. + /// The zone or area name to check. Many aliases are accepted. + /// Whether the player is currently in the zone. + public static bool GetInZone(Player p, string zone) + { + CalamityPlayer mp = p.Calamity(); + switch (zone.ToLower()) + { + default: + return false; + + case "calamity": // backwards compatibility + case "calamitybiome": + case "calamity biome": + case "crag": + case "crags": + + case "profanedcrag": // remove these four when the actual profaned biome is added + case "profaned crag": + case "profanedcrags": + case "profaned crags": + + case "brimstone": + case "brimstonecrag": + case "brimstone crag": + case "brimstonecrags": + case "brimstone crags": + return mp.ZoneCalamity; + + case "astral": + case "astralbiome": + case "astral biome": + case "astralinfection": + case "astral infection": + return mp.ZoneAstral; + + case "sunkensea": + case "sunken sea": + case "thesunkensea": + case "the sunken sea": + return mp.ZoneSunkenSea; + + case "sulfur": + case "sulphur": + case "sulfursea": + case "sulfur sea": + case "sulphursea": + case "sulphur sea": + case "sulfuroussea": + case "sulfurous sea": + case "sulphuroussea": + case "sulphurous sea": + return mp.ZoneSulphur; + + case "abyss": + case "theabyss": + case "the abyss": + case "anyabyss": + case "any abyss": + case "abyssany": + case "any abyss layer": + return mp.ZoneAbyss; + + case "abyss1": + case "abyss 1": + case "abyss_1": + case "layer1": + case "layer 1": + case "layer_1": + case "abysslayer1": + case "abyss layer 1": + return mp.ZoneAbyssLayer1; + + case "abyss2": + case "abyss 2": + case "abyss_2": + case "layer2": + case "layer 2": + case "layer_2": + case "abysslayer2": + case "abyss layer 2": + return mp.ZoneAbyssLayer2; + + case "abyss3": + case "abyss 3": + case "abyss_3": + case "layer3": + case "layer 3": + case "layer_3": + case "abysslayer3": + case "abyss layer 3": + return mp.ZoneAbyssLayer3; + + case "abyss4": + case "abyss 4": + case "abyss_4": + case "layer4": + case "layer 4": + case "layer_4": + case "abysslayer4": + case "abyss layer 4": + return mp.ZoneAbyssLayer4; + } + } + #endregion + + #region Difficulty Modes + /// + /// Returns whether the Calamity difficulty modifier corresponding to the given string is currently active. + /// + /// The difficulty modifier to check for. + /// Whether the difficulty is currently active. + public static bool GetDifficultyActive(string difficulty) + { + switch (difficulty.ToLower()) + { + default: + return false; + + case "revengeance": + case "rev": + case "revengeancemode": + case "revengeance mode": + return CalamityWorld.revenge; + + case "death": + case "deathmode": + case "death mode": + return CalamityWorld.death; + + case "malice": + case "malicemode": + case "malice mode": + return CalamityWorld.malice; + + case "br": + case "bossrush": + case "boss rush": + case "bossrushactive": + case "boss rush active": + return BossRushEvent.BossRushActive; + + case "armageddon": + case "arma": + case "instakill": + case "instagib": + case "armageddonmode": + case "armageddon mode": + return CalamityWorld.armageddon; + } + } + + /// + /// Either enables or disables the Calamity difficulty modifier corresponding to the given string.

+ /// Unlike the in-game mode changing items, this has no ancillary effects such as failing if a boss is alive or instantly killing players. + ///
+ /// The difficulty modifier to edit. + /// Whether to enable or disable the difficulty. + /// + public static bool SetDifficultyActive(string difficulty, bool enabled) + { + switch (difficulty.ToLower()) + { + default: + return false; + + case "revengeance": + case "rev": + case "revengeancemode": + case "revengeance mode": + return CalamityWorld.revenge = enabled; + + case "death": + case "deathmode": + case "death mode": + return CalamityWorld.death = enabled; + + case "malice": + case "malicemode": + case "malice mode": + return CalamityWorld.malice = enabled; + + case "br": + case "bossrush": + case "boss rush": + case "bossrushactive": + case "boss rush active": + return BossRushEvent.BossRushActive = enabled; + + case "armageddon": + case "arma": + case "instakill": + case "instagib": + case "armageddonmode": + case "armageddon mode": + return CalamityWorld.armageddon = enabled; + } + } + #endregion + + #region Rogue Class + /// + /// Gets a player's current rogue damage stat. + /// + /// The player whose rogue damage is being queried. + /// Current rogue damage boost. 1f is no bonus, 2f is +100%. + public static float GetRogueDamage(Player p) => p?.Calamity()?.throwingDamage ?? 1f; + + /// + /// Adds a flat amount of rogue damage stat to a player. This amount can be negative. + /// + /// The player whose rogue damage is being modified. + /// The amount of rogue damage to add or subtract (if negative). + /// The player's new rogue damage stat. + public static float AddRogueDamage(Player p, float add) => p is null ? 1f : (p.Calamity().throwingDamage += add); + + /// + /// Gets a player's current rogue critical strike chance. + /// + /// The player whose rogue crit is being queried. + /// Current rogue critical strike chance. 0 is no additional crit, 8 is +8% crit chance. + public static int GetRogueCrit(Player p) => p?.Calamity()?.throwingCrit ?? 0; + + /// + /// Adds a flat amount of rogue crit to a player. This amount can be negative. + /// + /// The player whose rogue crit is being modified. + /// The amount of rogue crit to add or subtract (if negative). + /// The player's new rogue crit stat. + public static int AddRogueCrit(Player p, int add) => p is null ? 0 : (p.Calamity().throwingCrit += add); + + /// + /// Gets a player's current rogue projectile velocity multiplier. + /// + /// The player whose rogue velocity is being queried. + /// Current rogue projectile velocity multiplier. 1f is no bonus, 2f doubles projectile speed. + public static float GetRogueVelocity(Player p) => p?.Calamity()?.throwingVelocity ?? 1f; + + /// + /// Adds a flat amount of rogue velocity stat to a player. This amount can be negative. + /// + /// The player whose rogue velocity is being modified. + /// The amount of rogue velocity to add or subtract (if negative). + /// The player's new rogue velocity stat. + public static float AddRogueVelocity(Player p, float add) => p is null ? 1f : (p.Calamity().throwingVelocity += add); + + public static float GetCurrentStealth(Player p) => p?.Calamity()?.rogueStealth ?? 0f; + + public static float GetMaxStealth(Player p) => p?.Calamity()?.rogueStealthMax ?? 0f; + + public static float AddMaxStealth(Player p, float add) => p is null ? 0f : (p.Calamity().rogueStealthMax += add); + + /// + /// Gets whether the given item is classified as a rogue weapon. + /// + /// The item which is being checked. + /// Whether the item is a rogue weapon. + public static bool IsRogue(Item it) + { + if (it is null || it.Calamity() is null) + return false; + CalamityGlobalItem cgi = it.Calamity(); + return cgi.rogue; + } + + /// + /// Sets whether the given item is classified as a rogue weapon. + /// + /// The item whose rogue classification is being toggled. + /// The value to apply. + /// Whether the item is now a rogue weapon. + public static bool SetRogue(Item it, bool isRogue) + { + if (it is null || it.Calamity() is null) + return false; + CalamityGlobalItem cgi = it.Calamity(); + cgi.rogue = isRogue; + return cgi.rogue; + } + + /// + /// Gets whether the given projectile is classified as rogue. + /// + /// The projectile which is being checked. + /// Whether the projectile is rogue. + public static bool IsRogue(Projectile p) + { + if (p is null || p.Calamity() is null) + return false; + CalamityGlobalProjectile cgp = p.Calamity(); + return cgp.rogue | cgp.forceRogue; + } + + /// + /// Sets whether the given projectile is classified as rogue. If set to true, also forces the projectile to be rogue every single frame. + /// + /// The projectile whose rogue classification is being toggled. + /// The value to apply. + /// Whether the projectile is now rogue. + public static bool SetRogue(Projectile p, bool isRogue) + { + if (p is null || p.Calamity() is null) + return false; + CalamityGlobalProjectile cgp = p.Calamity(); + cgp.forceRogue = cgp.rogue = isRogue; + return cgp.rogue; + } + #endregion + + #region Player Armor Set Bonuses + /// + /// Returns whether the specified player has the set bonus corresponding to the given string. + /// + /// The player whose set bonuses are being questioned. + /// The set bonus to check for. + /// Whether the player currently has the set bonus. + public static bool GetSetBonus(Player p, string setBonus) + { + CalamityPlayer mp = p.Calamity(); + + setBonus = setBonus.ToLower(); + + // LATER -- no summon set bonuses are written well. all use two bools, neither of which actually controls the function + + // Desert Prowler + if (setBonus == "desertprowler" || setBonus == "desert prowler") + return mp.desertProwler; + + // Snow Ruffian + if (setBonus == "snowruffian" || setBonus == "snow ruffian") + return mp.snowRuffianSet; + + // Sulphurous + if (setBonus == "sulfur" || setBonus == "sulphur" || setBonus == "sulfurous" || setBonus == "sulphurous") + return mp.sulfurSet; + + // Victide + if (setBonus == "victide_summon" || setBonus == "victide summon") + return mp.urchin; // the bool set directly by VictideHelmet.UpdateArmorSet + else if (setBonus == "victide" || setBonus.StartsWith("victide_") || setBonus.StartsWith("victide ")) + return mp.victideSet; + + // Aerospec + if (setBonus == "aerospec_summon" || setBonus == "aerospec summon") + return mp.valkyrie; // the bool set directly by AerospecHelmet.UpdateArmorSet + else if (setBonus == "aerospec" || setBonus.StartsWith("aerospec_") || setBonus.StartsWith("aerospec ")) + return mp.aeroSet; + + // Statigel + if (setBonus == "statigel_summon" || setBonus == "statigel summon") + return mp.slimeGod; // the bool set directly by StatigelHood.UpdateArmorSet + if (setBonus == "statigel" || setBonus.StartsWith("statigel_") || setBonus.StartsWith("statigel ")) + return mp.statigelSet; + + // Mollusk + if (setBonus == "mollusk") + return mp.molluskSet; + + // Titan Heart + if (setBonus == "titanheart" || setBonus == "titan heart") + return mp.titanHeartSet; + + // Forbidden Circlet + if (setBonus == "forbidden_circlet" || setBonus == "forbidden circlet") + return mp.forbiddenCirclet; + + // Daedalus + switch (setBonus) + { + default: + break; + case "daedalus": + return mp.daedalusReflect || mp.daedalusShard || mp.daedalusAbsorb || mp.daedalusCrystal || mp.daedalusSplit; + case "daedalus_melee": + case "daedalus melee": + return mp.daedalusReflect; + case "daedalus_ranged": + case "daedalus ranged": + return mp.daedalusShard; + case "daedalus_magic": + case "daedalus magic": + return mp.daedalusAbsorb; + case "daedalus_summon": + case "daedalus summon": + return mp.daedalusCrystal; + case "daedalus_rogue": + case "daedalus rogue": + return mp.daedalusSplit; + } + + // Reaver + switch (setBonus) + { + default: + break; + case "reaver": + return mp.reaverSpeed || mp.reaverExplore || mp.reaverDefense; + case "reaver_speed": + case "reaver speed": + return mp.reaverSpeed; + case "reaver_explore": + case "reaver explore": + case "reaver_exploration": + case "reaver exploration": + return mp.reaverExplore; + case "reaver_defense": + case "reaver defense": + case "reaver_tank": + case "reaver tank": + return mp.reaverDefense; + } + + // Fathom Swarmer + if (setBonus == "fathomswarmer" || setBonus == "fathom swarmer") + return mp.fathomSwarmer; + + // Brimflame + if (setBonus == "brimflame") + return mp.brimflameSet; + + // Umbraphile + if (setBonus == "umbraphile") + return mp.umbraphileSet; + + // Hydrothermic (Ataxia is legacy name) + switch (setBonus) + { + default: + break; + case "ataxia": + case "hydrothermic": + case "hydrothermal": + return mp.ataxiaBlaze; + case "ataxia_melee": + case "ataxia melee": + case "hydrothermic_melee": + case "hydrothermic melee": + case "hydrothermal_melee": + case "hydrothermal melee": + return mp.ataxiaGeyser; + case "ataxia_ranged": + case "ataxia ranged": + case "hydrothermic_ranged": + case "hydrothermic ranged": + case "hydrothermal_ranged": + case "hydrothermal ranged": + return mp.ataxiaBolt; + case "ataxia_magic": + case "ataxia magic": + case "hydrothermic_magic": + case "hydrothermic magic": + case "hydrothermal_magic": + case "hydrothermal magic": + return mp.ataxiaMage; + case "ataxia_summon": + case "ataxia summon": + case "hydrothermic_summon": + case "hydrothermic summon": + case "hydrothermal_summon": + case "hydrothermal summon": + return mp.chaosSpirit; + case "ataxia_rogue": + case "ataxia rogue": + case "hydrothermic_rogue": + case "hydrothermic rogue": + case "hydrothermal_rogue": + case "hydrothermal rogue": + return mp.ataxiaVolley; + } + + // Plague Reaper + if (setBonus == "plaguereaper" || setBonus == "plague reaper") + return mp.plagueReaper; + + // Plaguebringer + if (setBonus == "plaguebringer" || setBonus == "plaguebringerpatron" || setBonus == "plaguebringer patron") + return mp.plaguebringerPatronSet; + + // Astral + if (setBonus == "astral") + return mp.astralStarRain; + + // Empyrean (formerly Xeroc) + if (setBonus == "empyrean" || setBonus == "xeroc") + return mp.xerocSet; + + // Tarragon + switch (setBonus) + { + default: + break; + case "tarragon": + return mp.tarraSet; + case "tarragon_melee": + case "tarragon melee": + return mp.tarraMelee; + case "tarragon_ranged": + case "tarragon ranged": + return mp.tarraRanged; + case "tarragon_magic": + case "tarragon magic": + return mp.tarraMage; + case "tarragon_summon": + case "tarragon summon": + return mp.tarraSummon; + case "tarragon_rogue": + case "tarragon rogue": + return mp.tarraThrowing; + } + + // Prismatic + if (setBonus == "prismatic" || setBonus == "prism") + return mp.prismaticSet; + + // Bloodflare + switch (setBonus) + { + default: + break; + case "bloodflare": + return mp.bloodflareSet; + case "bloodflare_melee": + case "bloodflare melee": + return mp.bloodflareMelee; + case "bloodflare_ranged": + case "bloodflare ranged": + return mp.bloodflareRanged; + case "bloodflare_magic": + case "bloodflare magic": + return mp.bloodflareMage; + case "bloodflare_summon": + case "bloodflare summon": + return mp.bloodflareSummon; + case "bloodflare_rogue": + case "bloodflare rogue": + return mp.bloodflareThrowing; + } + + // Omega Blue + if (setBonus == "omegablue" || setBonus == "omega blue") + return mp.omegaBlueSet; + + // God Slayer + switch (setBonus) + { + default: + break; + case "godslayer": + case "god slayer": + return mp.godSlayer; + case "godslayer_melee": + case "godslayer melee": + case "god slayer melee": + return mp.godSlayerDamage; // melee helm's unique damage reducing property + case "godslayer_ranged": + case "godslayer ranged": + case "god slayer ranged": + return mp.godSlayerRanged; + // God Slayer Mage was removed in the Draedon Update + case "godslayer_magic": + case "godslayer magic": + case "god slayer magic": + return false; // mp.godSlayerMage; + // God Slayer Summon was removed in the Draedon Update + case "godslayer_summon": + case "godslayer summon": + case "god slayer summon": + return false; // mp.godSlayerSummon; + + case "godslayer_rogue": + case "godslayer rogue": + case "god slayer rogue": + return mp.godSlayerThrowing; + } + + // Fearmonger + if (setBonus == "fearmonger") + return mp.fearmongerSet; + + // Silva + switch (setBonus) + { + default: + break; + case "silva": + return mp.silvaSet; + + // Silva Melee was removed in the Draedon Update + case "silva_melee": + case "silva melee": + return false; // mp.silvaMelee; + // Silva Ranged was removed in the Draedon Update + case "silva_ranged": + case "silva ranged": + return false; // mp.silvaRanged; + case "silva_magic": + case "silva magic": + return mp.silvaMage; + case "silva_summon": + case "silva summon": + return mp.silvaSummon; + // Silva Rogue was removed in the Draedon Update + case "silva_rogue": + case "silva rogue": + return false; // mp.silvaThrowing; + } + + // Auric Tesla + if (setBonus == "auric" || setBonus == "aurictesla" || setBonus == "auric tesla") + return mp.auricSet; + + // Demonshade + if (setBonus == "demonshade") + return mp.dsSetBonus; + + return false; + } + + /// + /// Turns the set bonus corresponding to the given string on or off for the specified player. + /// + /// The player whose set bonuses are being toggled. + /// The set bonus to check for. + /// Whether the set bonus should be enabled (true) or disabled (false). + /// Whether any set bonus was adjusted. + public static bool SetSetBonus(Player p, string setBonus, bool enabled) + { + CalamityPlayer mp = p.Calamity(); + setBonus = setBonus.ToLower(); + + // Desert Prowler + if (setBonus == "desertprowler" || setBonus == "desert prowler") + { + mp.desertProwler = enabled; + return true; + } + + // Snow Ruffian + if (setBonus == "snowruffian" || setBonus == "snow ruffian") + { + mp.snowRuffianSet = enabled; + return true; + } + + // Sulphurous + if (setBonus == "sulfur" || setBonus == "sulphur" || setBonus == "sulfurous" || setBonus == "sulphurous") + { + mp.sulfurSet = enabled; + mp.sulfurJump = enabled; + return true; + } + + // Victide + if (setBonus == "victide_summon" || setBonus == "victide summon") + { + mp.victideSet = enabled; + mp.urchin = enabled; // LATER -- remove this when player.urchin actually controls victide summoner + return true; + } + else if (setBonus == "victide" || setBonus.StartsWith("victide_") || setBonus.StartsWith("victide ")) + { + mp.victideSet = true; + return true; + } + + // Aerospec + if (setBonus == "aerospec_summon" || setBonus == "aerospec summon") + { + mp.aeroSet = enabled; + mp.valkyrie = enabled; // LATER -- remove this when player.valkyrie actually controls aerospec summoner + return true; + } + else if (setBonus == "aerospec" || setBonus.StartsWith("aerospec_") || setBonus.StartsWith("aerospec ")) + { + mp.aeroSet = enabled; + return true; + } + + // Statigel + if (setBonus == "statigel_summon" || setBonus == "statigel summon") + { + mp.statigelSet = enabled; + mp.slimeGod = enabled; // LATER -- remove this when player.slimeGod actually controls statigel summoner + return true; + } + else if (setBonus == "statigel" || setBonus.StartsWith("statigel_") || setBonus.StartsWith("statigel ")) + { + mp.statigelSet = enabled; + return true; + } + + // Mollusk + if (setBonus == "mollusk") + { + mp.molluskSet = enabled; + return true; + } + + // Titan Heart + if (setBonus == "titanheart" || setBonus == "titan heart") + { + mp.titanHeartMask = enabled; + mp.titanHeartMantle = enabled; + mp.titanHeartBoots = enabled; + mp.titanHeartSet = enabled; + return true; + } + + // Forbidden Circlet + if (setBonus == "forbidden_circlet" || setBonus == "forbidden circlet") + { + mp.forbiddenCirclet = enabled; + return true; + } + + // Daedalus + switch (setBonus) + { + default: + break; + case "daedalus_melee": + case "daedalus melee": + mp.daedalusReflect = enabled; + return true; + case "daedalus_ranged": + case "daedalus ranged": + mp.daedalusShard = enabled; + return true; + case "daedalus_magic": + case "daedalus magic": + mp.daedalusAbsorb = enabled; + return true; + case "daedalus_summon": + case "daedalus summon": + mp.daedalusCrystal = enabled; // LATER -- remove this when player.daedalusCrystal actually controls daedalus summoner + return true; + case "daedalus_rogue": + case "daedalus rogue": + mp.daedalusSplit = enabled; + return true; + } + + // Reaver + switch (setBonus) + { + default: + break; + case "reaver_speed": + case "reaver speed": + mp.reaverSpeed = enabled; + return true; + case "reaver_explore": + case "reaver explore": + case "reaver_exploration": + case "reaver exploration": + mp.reaverExplore = enabled; + return true; + case "reaver_defense": + case "reaver defense": + case "reaver_tank": + case "reaver tank": + mp.reaverDefense = enabled; + return true; + } + + // Fathom Swarmer + if (setBonus == "fathomswarmer" || setBonus == "fathom swarmer") + { + mp.fathomSwarmer = enabled; + return true; + } + + // Brimflame + if (setBonus == "brimflame") + { + mp.brimflameSet = enabled; + return true; + } + + // Umbraphile + if (setBonus == "umbraphile") + { + mp.umbraphileSet = enabled; + return true; + } + + // Hydrothermic (Ataxia as legacy name) + switch (setBonus) + { + default: + break; + case "ataxia": + case "hydrothermic": + case "hydrothermal": + mp.ataxiaBlaze = enabled; + return true; + case "ataxia_melee": + case "ataxia melee": + case "hydrothermic_melee": + case "hydrothermic melee": + case "hydrothermal_melee": + case "hydrothermal melee": + mp.ataxiaBlaze = enabled; + mp.ataxiaGeyser = enabled; + return true; + case "ataxia_ranged": + case "ataxia ranged": + case "hydrothermic_ranged": + case "hydrothermic ranged": + case "hydrothermal_ranged": + case "hydrothermal ranged": + mp.ataxiaBlaze = enabled; + mp.ataxiaBolt = enabled; + return true; + case "ataxia_magic": + case "ataxia magic": + case "hydrothermic_magic": + case "hydrothermic magic": + case "hydrothermal_magic": + case "hydrothermal magic": + mp.ataxiaBlaze = enabled; + mp.ataxiaMage = enabled; + return true; + case "ataxia_summon": + case "ataxia summon": + case "hydrothermic_summon": + case "hydrothermic summon": + case "hydrothermal_summon": + case "hydrothermal summon": + mp.ataxiaBlaze = enabled; + mp.chaosSpirit = enabled; // LATER -- remove this when player.chaosSpirit actually controls ataxia summoner + return true; + case "ataxia_rogue": + case "ataxia rogue": + case "hydrothermic_rogue": + case "hydrothermic rogue": + case "hydrothermal_rogue": + case "hydrothermal rogue": + mp.ataxiaBlaze = enabled; + mp.ataxiaVolley = enabled; + return true; + } + + // Plague Reaper + if (setBonus == "plaguereaper" || setBonus == "plague reaper") + { + mp.plagueReaper = enabled; + return true; + } + + // Plaguebringer + if (setBonus == "plaguebringer" || setBonus == "plaguebringerpatron" || setBonus == "plaguebringer patron") + { + mp.plaguebringerPatronSet = enabled; + return true; + } + + // Astral + if (setBonus == "astral") + { + mp.astralStarRain = enabled; + return true; + } + + // Xeroc + if (setBonus == "empyrean" || setBonus == "xeroc") + { + mp.xerocSet = enabled; + return true; + } + + // Tarragon + switch (setBonus) + { + default: + break; + case "tarragon": + mp.tarraSet = enabled; + return true; + case "tarragon_melee": + case "tarragon melee": + mp.tarraSet = enabled; + mp.tarraMelee = enabled; + return true; + case "tarragon_ranged": + case "tarragon ranged": + mp.tarraSet = enabled; + mp.tarraRanged = enabled; + return true; + case "tarragon_magic": + case "tarragon magic": + mp.tarraSet = enabled; + mp.tarraMage = enabled; + return true; + case "tarragon_summon": + case "tarragon summon": + mp.tarraSet = enabled; + mp.tarraSummon = enabled; // LATER -- remove this when player.tarraSummon actually controls life aura + return true; + case "tarragon_rogue": + case "tarragon rogue": + mp.tarraSet = enabled; + mp.tarraThrowing = enabled; + return true; + } + + // Prismatic + if (setBonus == "prismatic" || setBonus == "prism") + { + mp.prismaticSet = enabled; + return true; + } + + // Bloodflare + switch (setBonus) + { + default: + break; + case "bloodflare": + mp.bloodflareSet = enabled; + return true; + case "bloodflare_melee": + case "bloodflare melee": + mp.bloodflareSet = enabled; + mp.bloodflareMelee = enabled; + return true; + case "bloodflare_ranged": + case "bloodflare ranged": + mp.bloodflareSet = enabled; + mp.bloodflareRanged = enabled; + return true; + case "bloodflare_magic": + case "bloodflare magic": + mp.bloodflareSet = enabled; + mp.bloodflareMage = enabled; + return true; + case "bloodflare_summon": + case "bloodflare summon": + mp.bloodflareSet = enabled; + mp.bloodflareSummon = enabled; // LATER -- remove this when player.bloodflareSummon actually controls bloodflare orbs + return true; + case "bloodflare_rogue": + case "bloodflare rogue": + mp.bloodflareSet = enabled; + mp.bloodflareThrowing = enabled; + return true; + } + + // Omega Blue + if (setBonus == "omegablue" || setBonus == "omega blue") + { + mp.omegaBlueSet = enabled; + return true; + } + + // God Slayer + switch (setBonus) + { + default: + break; + case "godslayer": + case "god slayer": + mp.godSlayer = enabled; + return true; + case "godslayer_melee": + case "godslayer melee": + case "god slayer melee": + mp.godSlayer = enabled; + mp.godSlayerDamage = enabled; // melee helm's unique damage reducing property + return true; + case "godslayer_ranged": + case "godslayer ranged": + case "god slayer ranged": + mp.godSlayer = enabled; + mp.godSlayerRanged = enabled; + return true; + // God Slayer Mage and Summon were removed in the Draedon Update + /* + case "godslayer_magic": + case "godslayer magic": + case "god slayer magic": + mp.godSlayer = enabled; + mp.godSlayerMage = enabled; + return true; + case "godslayer_summon": + case "godslayer summon": + case "god slayer summon": + mp.godSlayer = enabled; + mp.godSlayerSummon = enabled; + return true; + */ + case "godslayer_rogue": + case "godslayer rogue": + case "god slayer rogue": + mp.godSlayer = enabled; + mp.godSlayerThrowing = enabled; + return true; + } + + // Fearmonger + if (setBonus == "fearmonger") + { + mp.fearmongerSet = enabled; + return true; + } + + // Silva + switch (setBonus) + { + default: + break; + case "silva": + mp.silvaSet = enabled; + return true; + case "silva_magic": + case "silva magic": + mp.silvaSet = enabled; + mp.silvaMage = enabled; + return true; + case "silva_summon": + case "silva summon": + mp.silvaSet = enabled; + mp.silvaSummon = enabled; // LATER -- remove this when player.silvaSummon actually controls silva crystal + return true; + // Silva Melee, Ranged and Rogue were removed in the Draedon Update + /* + case "silva_melee": + case "silva melee": + mp.silvaSet = enabled; + mp.silvaMelee = enabled; + return true; + case "silva_ranged": + case "silva ranged": + mp.silvaSet = enabled; + mp.silvaRanged = enabled; + return true; + case "silva_rogue": + case "silva rogue": + mp.silvaSet = enabled; + mp.silvaThrowing = enabled; + return true; + */ + } + + // Auric Tesla (includes all components) + switch (setBonus) + { + default: + break; + case "auric": + case "aurictesla": + case "auric tesla": + mp.tarraSet = enabled; + mp.bloodflareSet = enabled; + mp.godSlayer = enabled; + mp.silvaSet = enabled; + mp.auricSet = enabled; + return true; + case "auric_melee": + case "auric melee": + case "aurictesla_melee": + case "aurictesla melee": + case "auric tesla melee": + mp.tarraSet = enabled; + mp.tarraMelee = enabled; + mp.bloodflareSet = enabled; + mp.bloodflareMelee = enabled; + mp.godSlayer = enabled; + mp.godSlayerDamage = enabled; + mp.silvaSet = enabled; + // mp.silvaMelee = enabled; + mp.auricSet = enabled; + return true; + case "auric_ranged": + case "auric ranged": + case "aurictesla_ranged": + case "aurictesla ranged": + case "auric tesla ranged": + mp.tarraSet = enabled; + mp.tarraRanged = enabled; + mp.bloodflareSet = enabled; + mp.bloodflareRanged = enabled; + mp.godSlayer = enabled; + mp.godSlayerRanged = enabled; + mp.silvaSet = enabled; + // mp.silvaRanged = enabled; + mp.auricSet = enabled; + return true; + case "auric_magic": + case "auric magic": + case "aurictesla_magic": + case "aurictesla magic": + case "auric tesla magic": + mp.tarraSet = enabled; + mp.tarraMage = enabled; + mp.bloodflareSet = enabled; + mp.bloodflareMage = enabled; + mp.godSlayer = enabled; + // mp.godSlayerMage = enabled; + mp.silvaSet = enabled; + mp.silvaMage = enabled; + mp.auricSet = enabled; + return true; + case "auric_summon": + case "auric summon": + case "aurictesla_summon": + case "aurictesla summon": + case "auric tesla summon": + mp.tarraSet = enabled; + mp.tarraSummon = enabled; + mp.bloodflareSet = enabled; + mp.bloodflareSummon = enabled; + mp.godSlayer = enabled; + // mp.godSlayerSummon = enabled; + mp.silvaSet = enabled; + mp.silvaSummon = enabled; + mp.auricSet = enabled; + return true; + case "auric_rogue": + case "auric rogue": + case "aurictesla_rogue": + case "aurictesla rogue": + case "auric tesla rogue": + mp.tarraSet = enabled; + mp.tarraThrowing = enabled; + mp.bloodflareSet = enabled; + mp.bloodflareThrowing = enabled; + mp.godSlayer = enabled; + mp.godSlayerThrowing = enabled; + mp.silvaSet = enabled; + // mp.silvaThrowing = enabled; + mp.auricSet = enabled; + return true; + } + + // Demonshade + if (setBonus == "demonshade") + { + mp.dsSetBonus = enabled; + mp.rDevil = enabled; // LATER -- remove this when player.rDevil controls demonshade summoned minion + return true; + } + + return false; + } + #endregion + + #region Other Player Stats + public static int GetLightStrength(Player p) => p?.Calamity()?.GetTotalLightStrength() ?? 0; + + public static void AddAbyssLightStrength(Player p, int add) + { + if (p != null) + p.Calamity().externalAbyssLight += add; + } + + public static bool MakeColdImmune(Player p) => p is null ? false : (p.Calamity().externalColdImmunity = true); + public static bool MakeHeatImmune(Player p) => p is null ? false : (p.Calamity().externalHeatImmunity = true); + #endregion + + #region Set Damage Reduction + public static float SetDamageReduction(int npcID, float dr) + { + CalamityMod.DRValues.TryGetValue(npcID, out float oldDR); + CalamityMod.DRValues.Remove(npcID); + CalamityMod.DRValues.Add(npcID, dr); + return oldDR; + } + #endregion + + #region Boss Health Bars + public static bool BossHealthBarVisible() => Main.LocalPlayer.Calamity().drawBossHPBar; + + public static bool SetBossHealthBarVisible(bool visible) => Main.LocalPlayer.Calamity().drawBossHPBar = visible; + #endregion + + #region Dodge Disabling + public static bool AreDodgesDisabled() => Main.LocalPlayer.Calamity().disableAllDodges; + + public static bool DisableAllDodges(bool disable) => Main.LocalPlayer.Calamity().disableAllDodges = disable; + #endregion + + #region Item Rarity + public static int GetCalamityRarity(Item item) + { + CalamityGlobalItem cgi = item.Calamity(); + CalamityRarity calrare = cgi.customRarity; + if (calrare == CalamityRarity.NoEffect) + return item.rare; + return (int)calrare; + } + + public static bool SetCalamityRarity(Item item, int rarityNum) + { + CalamityGlobalItem cgi = item.Calamity(); + cgi.customRarity = (CalamityRarity)rarityNum; + return cgi.customRarity != CalamityRarity.NoEffect; + } + #endregion + + #region Call + + public static object Call(params object[] args) + { + bool isValidPlayerArg(object o) => o is int || o is Player; + bool isValidItemArg(object o) => o is int || o is Item; + bool isValidProjectileArg(object o) => o is int || o is Projectile; + + Player castPlayer(object o) + { + if (o is int i) + return Main.player[i]; + else if (o is Player p) + return p; + return null; + } + + Item castItem(object o) + { + if (o is int i) + return Main.item[i]; + else if (o is Item it) + return it; + return null; + } + + Projectile castProjectile(object o) + { + if (o is int i) + return Main.projectile[i]; + else if (o is Projectile p) + return p; + return null; + } + + // Certain IDs in vanilla's files are shorts instead of ints for some reason. + // Instead of expecting developers to have to manually cast these IDs, this function is used + // to handle IDs that are either ints OR shorts, without the worry of missing a cast and wondering why + // the Mod Call did nothing. + bool castID(object o, out int id) + { + id = -1; + if (!(o is int) && !(o is short)) + return false; + + if (o is short shortID) + id = shortID; + if (o is int intID) + id = intID; + + return true; + } + + if (args is null || args.Length <= 0) + return new ArgumentNullException("ERROR: No function name specified. First argument must be a function name."); + if (!(args[0] is string)) + return new ArgumentException("ERROR: First argument must be a string function name."); + + string methodName = args[0].ToString(); + switch (methodName) + { + case "Downed": + case "GetDowned": + case "BossDowned": + case "GetBossDowned": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify a boss or event name as a string."); + if (!(args[1] is string)) + return new ArgumentException("ERROR: The argument to \"Downed\" must be a string."); + return GetBossDowned(args[1].ToString()); + + case "Zone": + case "GetZone": + case "InZone": + case "GetInZone": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and a zone name as a string."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify a zone name as a string."); + if (!(args[2] is string)) + return new ArgumentException("ERROR: The second argument to \"InZone\" must be a string."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"InZone\" must be a Player or an int."); + return GetInZone(castPlayer(args[1]), args[2].ToString()); + + case "Difficulty": + case "GetDifficulty": + case "DifficultyActive": + case "GetDifficultyActive": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify a difficulty mode name as a string."); + if (!(args[1] is string)) + return new ArgumentException("ERROR: The argument to \"Difficulty\" must be a string."); + return GetDifficultyActive(args[1].ToString()); + + case "SetDifficulty": + case "SetDifficultyActive": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify a difficulty mode name as a string and a bool."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify a bool."); + if (!(args[2] is bool enabled)) + return new ArgumentException("ERROR: The second argument to \"SetDifficulty\" must be a bool."); + if (!(args[1] is string)) + return new ArgumentException("ERROR: The first argument to \"SetDifficulty\" must be a string."); + return SetDifficultyActive(args[1].ToString(), enabled); + + case "GetLight": + case "GetLightLevel": + case "GetLightStrength": + case "GetAbyssLight": + case "GetAbyssLightLevel": + case "GetAbyssLightStrength": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); + if(!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The argument to \"GetLightStrength\" must be a Player or an int."); + return GetLightStrength(castPlayer(args[1])); + + case "AddLight": + case "AddLightLevel": + case "AddLightStrength": + case "AddAbyssLight": + case "AddAbyssLightLevel": + case "AddAbyssLightStrength": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and light strength change as an int."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify light strength change as an int."); + if (!(args[2] is int light)) + return new ArgumentException("ERROR: The second argument to \"AddLightStrength\" must be an int."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"AddLightStrength\" must be a Player or an int."); + AddAbyssLightStrength(castPlayer(args[1]), light); + return null; + + case "GetRogueDamage": + case "GetRogueDmg": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The argument to \"GetRogueDamage\" must be a Player or an int."); + return GetRogueDamage(castPlayer(args[1])); + + case "GetRogueCrit": + case "GetRogueCritChance": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The argument to \"GetRogueCrit\" must be a Player or an int."); + return GetRogueCrit(castPlayer(args[1])); + + case "GetRogueVelocity": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The argument to \"GetRogueVelocity\" must be a Player or an int."); + return GetRogueVelocity(castPlayer(args[1])); + + case "AddRogueDamage": + case "AddRogueDmg": + case "ModifyRogueDamage": + case "ModifyRogueDmg": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue damage change as a float."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify rogue damage change as a float."); + if (!(args[2] is float damage)) + return new ArgumentException("ERROR: The second argument to \"AddRogueDamage\" must be a float."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"AddRogueDamage\" must be a Player or an int."); + return AddRogueDamage(castPlayer(args[1]), damage); + + case "AddRogueCrit": + case "AddRogueCritChance": + case "ModifyRogueCrit": + case "ModifyRogueCritChance": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue crit change as an int."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify rogue crit change as a float."); + if (!(args[2] is int crit)) + return new ArgumentException("ERROR: The second argument to \"AddRogueCrit\" must be an int."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"AddRogueCrit\" must be a Player or an int."); + return AddRogueCrit(castPlayer(args[1]), crit); + + case "AddRogueVelocity": + case "ModifyRogueVelocity": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue velocity change as a float."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify rogue velocity change as a float."); + if (!(args[2] is float velocity)) + return new ArgumentException("ERROR: The second argument to \"AddRogueVelocity\" must be a float."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"AddRogueVelocity\" must be a Player or an int."); + return AddRogueVelocity(castPlayer(args[1]), velocity); + + case "GetStealth": + case "GetCurrentStealth": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"GetStealth\" must be a Player or an int."); + return GetCurrentStealth(castPlayer(args[1])); + + case "GetMaxStealth": + case "GetStealthCap": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"GetMaxStealth\" must be a Player or an int."); + return GetMaxStealth(castPlayer(args[1])); + + case "AddMaxStealth": + case "ModifyMaxStealth": + case "ModifyStealthCap": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue max stealth as a float."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify rogue max stealth as a float."); + if (!(args[2] is float maxStealth)) + return new ArgumentException("ERROR: The second argument to \"AddMaxStealth\" must be a float."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"AddMaxStealth\" must be a Player or an int."); + return AddMaxStealth(castPlayer(args[1]), maxStealth); + + case "IsItemRogue": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify an Item object (or int index of an Item in the Main.item array)."); + if (!isValidItemArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"IsItemRogue\" must be an Item or an int."); + return IsRogue(castItem(args[1])); + + case "SetItemRogue": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both an Item object (or int index of an Item in the Main.item array) and a bool."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify rogue status as a bool."); + if (!(args[2] is bool isItemRogue)) + return new ArgumentException("ERROR: The second argument to \"SetItemRogue\" must be a bool."); + if (!isValidItemArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"SetItemRogue\" must be an Item or an int."); + return SetRogue(castItem(args[1]), isItemRogue); + + case "IsRogue": + case "IsProjRogue": + case "IsProjectileRogue": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify a Projectile object (or int index of a Projectile)."); + if (!isValidProjectileArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"IsRogue\" must be a Projectile or an int."); + return IsRogue(castProjectile(args[1])); + + case "SetRogue": + case "SetProjRogue": + case "SetProjectileRogue": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both a Projectile object (or int index of a Projectile) and a bool."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify rogue status as a bool."); + if (!(args[2] is bool isRogue)) + return new ArgumentException("ERROR: The second argument to \"SetRogue\" must be a bool."); + if (!isValidProjectileArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"SetRogue\" must be a Projectile or an int."); + return SetRogue(castProjectile(args[1]), isRogue); + + case "DR": + case "DamageReduction": + case "SetDR": + case "SetDamageReduction": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both NPC ID as an int and damage reduction as a float or double."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify damage reduction as a float or double."); + if (!(args[2] is float) && !(args[2] is double)) + return new ArgumentException("ERROR: The second argument to \"SetDamageReduction\" must be a float or a double."); + if (!castID(args[1], out int npcID)) + return new ArgumentException("ERROR: The first argument to \"SetDamageReduction\" must be an int or short ID."); + + float DR = (float)args[2]; + return SetDamageReduction(npcID, DR); + + case "BossHealthBarVisible": + case "BossHealthBarsVisible": + case "GetBossHealthBarVisible": + case "GetBossHealthBarsVisible": + return BossHealthBarVisible(); + + case "SetBossHealthBarVisible": + case "SetBossHealthBarsVisible": + if (args.Length < 2 || !(args[1] is bool bossBarEnabled)) + return new ArgumentNullException("ERROR: Must specify a bool."); + return SetBossHealthBarVisible(bossBarEnabled); + + case "NoDodges": + case "DodgesDisabled": + case "GetDodgesDisabled": + return AreDodgesDisabled(); + + case "DisableDodges": + case "DisableAllDodges": + case "SetDodgesDisabled": + if (args.Length < 2 || !(args[1] is bool disableDodges)) + return new ArgumentNullException("ERROR: Must specify a bool."); + return DisableAllDodges(disableDodges); + + case "GetRarity": + case "GetItemRarity": + case "GetCalamityRarity": + case "GetPostMLRarity": + case "GetPostMoonLordRarity": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify an Item."); + if (!(args[1] is Item)) + return new ArgumentException("ERROR: The first argument to \"GetCalamityRarity\" must be an Item."); + Item itemToGet = (Item)args[1]; + return GetCalamityRarity(itemToGet); + + case "SetRarity": + case "SetItemRarity": + case "SetCalamityRarity": + case "SetPostMLRarity": + case "SetPostMoonLordRarity": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both an Item and desired rarity as an int or short ID."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify desired rarity as an int or short ID."); + if (!castID(args[2], out int rarity)) + return new ArgumentException("ERROR: The second argument to \"SetCalamityRarity\" must be an int or short ID."); + if (!(args[1] is Item)) + return new ArgumentException("ERROR: The first argument to \"SetCalamityRarity\" must be an Item."); + + Item itemToSet = (Item)args[1]; + return SetCalamityRarity(itemToSet, rarity); + + case "GetDoGCountdown": + case "GetDoGFightCountdown": + case "GetDoGStage2Countdown": + return CalamityWorld.DoGSecondStageCountdown; + + case "AcidRainActive": + case "IsAcidRainActive": + case "GetAcidRainActive": + return CalamityWorld.rainingAcid; + + case "StartAcidRain": + AcidRainEvent.TryStartEvent(true); + CalamityNetcode.SyncWorld(); + return true; + + case "StopAcidRain": + if (CalamityWorld.rainingAcid) + { + CalamityWorld.acidRainPoints = 0; + CalamityWorld.triedToSummonOldDuke = false; + AcidRainEvent.UpdateInvasion(false); + } + return true; + + // This is intentionally separate from the above because it will stop other events when they are added. + case "AbominationnClearEvents": + bool eventActive = CalamityWorld.rainingAcid; + bool canClear = Convert.ToBoolean(args[1]); //This is to indicate whether abomm is able to clear the event due to a cooldown + if (eventActive && canClear) //adjust based on other events when added. + { + CalamityWorld.acidRainPoints = 0; + CalamityWorld.triedToSummonOldDuke = false; + AcidRainEvent.UpdateInvasion(false); + } + return eventActive; + + case "ExcludeMinionsFromResurrection": + // This assumes all arguments after the calling command name are projectile types. + IEnumerable secondaryArguments = args.Skip(1); + if (secondaryArguments.Any(argument => !castID(argument, out _))) + return new ArgumentException("ERROR: All arguments after the calling command to \"ExcludeMinionsFromResurrection\" must be int or short IDs."); + + CalamityLists.MinionsToNotResurrectList.AddRange(secondaryArguments.Select(argument => + { + castID(argument, out int id); + return id; + })); + return null; + + case "CreateEnchantment": + case "RegisterEnchantment": + EnchantmentManager.ConstructFromModcall(args.Skip(1)); + return null; + + case "MakeItemExhumable": + if (args.Length != 3) + return new ArgumentNullException("ERROR: Must specify two Item types as an int."); + if (!castID(args[1], out int toExhume)) + return new ArgumentException("ERROR: The first argument to \"MakeItemExhumable\" must be an int or short ID."); + if (!castID(args[2], out int result)) + return new ArgumentException("ERROR: The second argument to \"MakeItemExhumable\" must be an int or short ID."); + EnchantmentManager.ItemUpgradeRelationship[toExhume] = result; + return null; + + case "DeclareMiniboss": + case "DeclareMinibossForHealthBar": + if (args.Length != 2) + return new ArgumentNullException("ERROR: Must specify both an NPC type as an int."); + if (!castID(args[1], out int npcType)) + return new ArgumentException("ERROR: The first argument to \"DeclareMiniboss\" must be an int or short ID."); + + BossHealthBarManager.MinibossHPBarList.Add(npcType); + return null; + + case "ExcludeBossFromHealthBar": + if (args.Length != 2) + return new ArgumentNullException("ERROR: Must specify both an NPC type as an int."); + if (!castID(args[1], out int npcType2)) + return new ArgumentException("ERROR: The first argument to \"ExcludeBossFromHealthBar\" must be an int or short ID."); + + BossHealthBarManager.BossExclusionList.Add(npcType2); + return null; + + case "DeclareOneToManyRelationshipForHealthBar": + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify both an NPC type as an int for the first argument and the other NPC types in the relationship as ints for the rest of the arguments."); + if (!args.Skip(1).All(a => castID(a, out _))) + return new ArgumentException("ERROR: All secondary and onward arguments to \"DeclareOneToManyRelationshipForHealthBar\" must be int or short IDs."); + + castID(args[1], out int npcType3); + + int[] npcsInRelationship = args.Skip(2).Select(a => (int)a).ToArray(); + BossHealthBarManager.OneToMany[npcType3] = npcsInRelationship; + return null; + + // For context, the boolean argument in the second delegate refers to whether the function should be accumulating max life (true) or just life (false), and the returned long should be the accumulated health. + case "DeclareSpecialHPCalculationDecisionForHealthBar": + if (args.Length != 3) + return new ArgumentNullException("ERROR: Must specify both a usage requirement as a Func and a health calculator function as a Func."); + if (!(args[1] is Func usageRequirement)) + return new ArgumentException("ERROR: The first argument to \"DeclareSpecialHPCalculationDecisionForHealthBar\" must be a Func."); + if (!(args[2] is Func healthCalculatorFunction)) + return new ArgumentException("ERROR: The first argument to \"DeclareSpecialHPCalculationDecisionForHealthBar\" must be a Func."); + + BossHealthBarManager.SpecialHPRequirements[new BossHealthBarManager.NPCSpecialHPGetRequirement(usageRequirement)] = new BossHealthBarManager.NPCSpecialHPGetFunction(healthCalculatorFunction); + return null; + + case "CreateNameExtensionHandlerForHealthBar": + if (args.Length < 4) + return new ArgumentNullException("ERROR: Must specify a extension name as a string, the main NPC type as an int, and the other NPC types to check for as ints the rest of the arguments."); + if (!(args[1] is string name)) + return new ArgumentException("ERROR: The first argument to \"CreateNameExtensionHandlerForHealthBar\" must be a string."); + if (!castID(args[1], out int npcType4)) + return new ArgumentException("ERROR: The second argument to \"CreateNameExtensionHandlerForHealthBar\" must be an int or short ID."); + if (!args.Skip(3).All(a => a is int)) + return new ArgumentException("ERROR: All ternary and onward arguments to \"CreateNameExtensionHandlerForHealthBar\" must be ints."); + + int[] npcsToCheckFor = args.Skip(3).Select(a => (int)a).ToArray(); + BossHealthBarManager.EntityExtensionHandler[npcType4] = new BossHealthBarManager.BossEntityExtension(name, npcsToCheckFor); + return null; + + // In the following two mod calls, the first argument is the NPC type, the second is the time change context (-1 being night, 0 being nothing, and 1 being day), + // the third being the boss spawning function, the fourth being the overriding countdown to use, the fifth being whether the boss uses a special sound on spawning, + // the sixth being the dimness factor that Boss Rush should become once the boss is currently present, the seventh being the array of NPCs present in the battle that + // should not be deleted by the Boss Rush itself, and the eight being the potential NPCs that will end up killing, assuming the initial boss isn't + // that (such as P1 Hive Mind turning into its second form and you being expected to kill that). + case "GetBossRushEntries": + var entries = new List<(int, int, Action, int, bool, float, int[], int[])>(); + foreach (BossRushEvent.Boss boss in BossRushEvent.Bosses) + { + int[] deathEntries = BossRushEvent.BossIDsAfterDeath.ContainsKey(boss.EntityID) ? BossRushEvent.BossIDsAfterDeath[boss.EntityID] : null; + entries.Add((boss.EntityID, (int)boss.ToChangeTimeTo, new Action(boss.SpawnContext), boss.SpecialSpawnCountdown, boss.UsesSpecialSound, boss.DimnessFactor, boss.HostileNPCsToNotDelete.ToArray(), deathEntries)); + } + + return entries; + + case "SetBossRushEntries": + if (args.Length != 2) + return new ArgumentNullException("ERROR: Must specify a list of bosses as a List<(int, int, Action, int, bool, int[], int[])>."); + if (!(args[1] is List<(int, int, Action, int, bool, float, int[], int[])> entries2)) + return new ArgumentException("ERROR: The first argument to \"SetBossRushEntries\" must be a List<(int, int, Action, int, bool, int[], int[])>."); + + BossRushEvent.Bosses.Clear(); + BossRushEvent.BossIDsAfterDeath.Clear(); + foreach (var entry in entries2) + { + if (entry.Item8 != null) + BossRushEvent.BossIDsAfterDeath[entry.Item1] = entry.Item8; + BossRushEvent.Bosses.Add(new BossRushEvent.Boss(entry.Item1, (BossRushEvent.TimeChangeContext)entry.Item2, new BossRushEvent.Boss.OnSpawnContext(entry.Item3), entry.Item4, entry.Item5, entry.Item6, entry.Item7)); + } + + return null; + + case "CreateCustomDeathEffectForBossRush": + if (args.Length != 3) + return new ArgumentNullException("ERROR: Must specify both an NPC type and an Action that determines what happens when the NPC is killed."); + if (!castID(args[1], out int npcType5)) + return new ArgumentException("ERROR: The first argument to \"CreateCustomDeathEffectForBossRush\" must be an int or short ID."); + if (!(args[2] is Action deathEffect)) + return new ArgumentException("ERROR: The first argument to \"CreateCustomDeathEffectForBossRush\" must be an Action."); + + BossRushEvent.BossDeathEffects[npcType5] = deathEffect; + return null; + + case "LoadParticleInstances": + if (args.Length != 2 || !(args[1] is Mod)) + return new ArgumentNullException("ERROR: Must specify a Mod instance to load particles from."); + + GeneralParticleHandler.LoadModParticleInstances(args[1] as Mod); + return null; + + case "RegisterModCooldowns": + if (args.Length != 2 || !(args[1] is Mod)) + return new ArgumentNullException("ERROR: Must specify a Mod instance to register cooldowns from."); + + CooldownRegistry.RegisterModCooldowns(args[1] as Mod); + return null; + + + default: + return new ArgumentException("ERROR: Invalid method name."); + } + } + #endregion + } } diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 9fcd13533b..b4e452ef27 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -77,869 +77,869 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { - internal class Downed - { - public static readonly Func DownedDesertScourge = () => CalamityWorld.downedDesertScourge; - public static readonly Func DownedGiantClam = () => CalamityWorld.downedCLAM; - public static readonly Func DownedCrabulon = () => CalamityWorld.downedCrabulon; - public static readonly Func DownedHiveMind = () => CalamityWorld.downedHiveMind; - public static readonly Func DownedPerfs = () => CalamityWorld.downedPerforator; - public static readonly Func DownedSlimeGod = () => CalamityWorld.downedSlimeGod; - public static readonly Func DownedCryogen = () => CalamityWorld.downedCryogen; - public static readonly Func DownedBrimstoneElemental = () => CalamityWorld.downedBrimstoneElemental; - public static readonly Func DownedAquaticScourge = () => CalamityWorld.downedAquaticScourge; - public static readonly Func DownedCalamitas = () => CalamityWorld.downedCalamitas; - public static readonly Func DownedGSS = () => CalamityWorld.downedGSS; - public static readonly Func DownedLeviathan = () => CalamityWorld.downedLeviathan; - public static readonly Func DownedAureus = () => CalamityWorld.downedAstrageldon; - public static readonly Func DownedPBG = () => CalamityWorld.downedPlaguebringer; - public static readonly Func DownedRavager = () => CalamityWorld.downedScavenger; - public static readonly Func DownedDeus = () => CalamityWorld.downedStarGod; - public static readonly Func DownedGuardians = () => CalamityWorld.downedGuardians; - public static readonly Func DownedBirb = () => CalamityWorld.downedBumble; - public static readonly Func DownedProvidence = () => CalamityWorld.downedProvidence; - public static readonly Func DownedCeaselessVoid = () => CalamityWorld.downedSentinel1; - public static readonly Func DownedStormWeaver = () => CalamityWorld.downedSentinel2; - public static readonly Func DownedSignus = () => CalamityWorld.downedSentinel3; - public static readonly Func DownedPolterghast = () => CalamityWorld.downedPolterghast; - public static readonly Func DownedBoomerDuke = () => CalamityWorld.downedBoomerDuke; - public static readonly Func DownedDoG = () => CalamityWorld.downedDoG; - public static readonly Func DownedYharon = () => CalamityWorld.downedYharon; - public static readonly Func DownedExoMechs = () => CalamityWorld.downedExoMechs; - public static readonly Func DownedSCal = () => CalamityWorld.downedSCal; - public static readonly Func DownedAdultEidolonWyrm = () => CalamityWorld.downedAdultEidolonWyrm; - - public static readonly Func DownedAcidRainInitial = () => CalamityWorld.downedEoCAcidRain; - public static readonly Func DownedAcidRainHardmode = () => CalamityWorld.downedAquaticScourgeAcidRain; - } - - internal class WeakReferenceSupport - { - private static readonly Dictionary BossDifficulty = new Dictionary - { - { "DesertScourge", 1.5f }, - { "GiantClam", 1.6f }, - { "Crabulon", 2.5f }, - { "HiveMind", 3.5f }, - { "Perforators", 3.51f }, - { "SlimeGod", 5.5f }, - { "Cryogen", 6.5f }, - { "AquaticScourge", 7.5f }, - { "BrimstoneElemental", 8.5f }, - { "Calamitas", 9.7f }, - { "GreatSandShark", 10.09f }, - { "Leviathan", 10.5f }, - { "AstrumAureus", 10.6f }, - { "PlaguebringerGoliath", 11.5f }, - { "Ravager", 12.5f }, - { "AstrumDeus", 13.5f }, - { "ProfanedGuardians", 14.5f }, - { "Dragonfolly", 14.6f }, - { "Providence", 15.01f }, // Thorium's Ragnarok is 15f - { "CeaselessVoid", 15.5f }, - { "StormWeaver", 15.51f }, - { "Signus", 15.52f }, - { "Polterghast", 16f }, - { "OldDuke", 16.5f }, - { "DevourerOfGods", 17f }, - { "Yharon", 18f }, - { "ExoMechs", 18.5f }, - { "SupremeCalamitas", 19f }, - { "AdultEidolonWyrm", 19.5f }, - // { "Yharim", 20f }, - // { "Noxus", 120f }, - // { "Xeroc", 121f }, - }; - - private static readonly Dictionary InvasionDifficulty = new Dictionary - { - { "Acid Rain Initial", 2.4f }, - { "Acid Rain Aquatic Scourge", 7.51f }, - { "Acid Rain Polterghast", 16.49f } - }; - - public static void Setup() - { - BossChecklistSupport(); - FargosSupport(); - CensusSupport(); - SummonersAssociationSupport(); - } - - // Wrapper function to add bosses to Boss Checklist. - private static void AddBoss(Mod bossChecklist, Mod hostMod, string name, float difficulty, int npcType, Func downed, object summon, - List loot, List collection, string instructions, string despawn, string bossLogTex = null, string bossHeadTex = null) - { - bossChecklist.Call("AddBoss", difficulty, npcType, hostMod, name, downed, summon ?? null, collection, loot, instructions, despawn, bossLogTex, bossHeadTex); - } - - // Wrapper function to add bosses with multiple segments or phases to Boss Checklist. - private static void AddBoss(Mod bossChecklist, Mod hostMod, string name, float difficulty, List npcTypes, Func downed, object summon, - List loot, List collection, string instructions, string despawn, string bossLogTex = null, string bossHeadTex = null) - { - bossChecklist.Call("AddBoss", difficulty, npcTypes, hostMod, name, downed, summon ?? null, collection, loot, instructions, despawn, bossLogTex, bossHeadTex); - } - - // Wrapper function to add bosses with multiple segments or phases to Boss Checklist. - private static void AddInvasion(Mod bossChecklist, Mod hostMod, string name, float difficulty, List npcTypes, Func downed, object summon, - List loot, List collection, string instructions, string despawn, string invasionTexture = null, string iconTexture = null) - { - bossChecklist.Call("AddEventWithInfo", difficulty, npcTypes, hostMod, name, downed, summon ?? null, collection, loot, instructions, despawn, invasionTexture, iconTexture); - } - - // Wrapper function to add minibosses to Boss Checklist. - private static void AddMiniBoss(Mod bossChecklist, Mod hostMod, string name, float difficulty, int npcType, Func downed, object summon, - List loot, List collection, string instructions, string despawn, string bossLogTex = null, string bossHeadTex = null) - { - bossChecklist.Call("AddMiniBoss", difficulty, npcType, hostMod, name, downed, summon ?? null, collection, loot, instructions, despawn, bossLogTex, bossHeadTex); - } - - // Wrapper function to add loot and collection items to vanilla bosses for Boss Checklist. - private static void AddLoot(Mod bossChecklist, string bossName, List loot = null, List collection = null) - => AddLoot(bossChecklist, "Terraria", bossName, loot, collection); - - // Wrapper function to add loot and collection items to other mods' bosses for Boss Checklist. - private static void AddLoot(Mod bossChecklist, string mod, string bossName, List loot = null, List collection = null) - { - if (loot != null) - bossChecklist.Call("AddToBossLoot", mod, bossName, loot); - if (collection != null) - bossChecklist.Call("AddToBossCollection", mod, bossName, collection); - } - - // Wrapper function to add summon items to vanilla bosses for Boss Checklist. - private static void AddSummons(Mod bossChecklist, string bossName, List summons) => AddSummons(bossChecklist, "Terraria", bossName, summons); - - // Wrapper function to add summon items to other mods' bosses for Boss Checklist. - private static void AddSummons(Mod bossChecklist, string mod, string bossName, List summons) => bossChecklist.Call("AddToBossSpawnItems", mod, bossName, summons); - - /// - /// 1.0 = King Slime
- /// 2.0 = Eye of Cthulhu
- /// 3.0 = Eater of Worlds / Brain of Cthulhu
- /// 4.0 = Queen Bee
- /// 5.0 = Skeletron
- /// 6.0 = Wall of Flesh
- /// 7.0 = The Twins
- /// 8.0 = The Destroyer
- /// 9.0 = Skeletron Prime
- /// 10.0 = Plantera
- /// 11.0 = Golem
- /// 12.0 = Duke Fishron
- /// 13.0 = Lunatic Cultist
- /// 14.0 = Moon Lord - ///
- private static void BossChecklistSupport() - { - CalamityMod calamity = GetInstance(); - Mod bossChecklist = calamity.bossChecklist; - if (bossChecklist is null) - return; - - // Adds every single Calamity boss and miniboss to Boss Checklist's Boss Log. - AddCalamityBosses(bossChecklist, calamity); - - // Adds every single Calamity invasion to the Boss Checklist's Invasion Log. - AddCalamityInvasions(bossChecklist, calamity); - - // Loot which Calamity adds to vanilla bosses and events is also added to Boss Checklist's Boss Log. - AddCalamityBossLoot(bossChecklist); - AddCalamityEventLoot(bossChecklist); - } - - private static void AddCalamityBosses(Mod bossChecklist, Mod calamity) - { - // Desert Scourge - { - BossDifficulty.TryGetValue("DesertScourge", out float order); - List segments = new List() { NPCType(), NPCType(), NPCType() }; - int summon = ItemType(); - List loot = new List() { ItemType(), ItemID.SandBlock, ItemType(), ItemID.Coral, ItemID.Seashell, ItemID.Starfish, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.LesserHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}] in the Desert Biome"; - string despawn = CalamityUtils.ColorMessage("The scourge of the desert delved back into the sand.", new Color(0xEE, 0xE8, 0xAA)); - string bossLogTex = "CalamityMod/NPCs/DesertScourge/DesertScourge_BossChecklist"; - AddBoss(bossChecklist, calamity, "Desert Scourge", order, segments, DownedDesertScourge, summon, loot, collection, instructions, despawn, bossLogTex); - } - - // Giant Clam - { - BossDifficulty.TryGetValue("GiantClam", out float order); - int type = NPCType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = "Can spawn naturally in the Sunken Sea"; - string despawn = CalamityUtils.ColorMessage("The Giant Clam returns into hiding in its grotto.", new Color(0x7F, 0xFF, 0xD4)); - AddMiniBoss(bossChecklist, calamity, "Giant Clam", order, type, DownedGiantClam, null, loot, null, instructions, despawn); - } - - // Crabulon - { - BossDifficulty.TryGetValue("Crabulon", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemID.GlowingMushroom, ItemID.MushroomGrassSeeds, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.LesserHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}] in the Mushroom Biome"; - string despawn = CalamityUtils.ColorMessage("The mycleium crab has lost interest.", new Color(0x64, 0x95, 0xED)); - AddBoss(bossChecklist, calamity, "Crabulon", order, type, DownedCrabulon, summon, loot, collection, instructions, despawn); - } - - // Hive Mind - { - BossDifficulty.TryGetValue("HiveMind", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemID.DemoniteBar, ItemID.RottenChunk, ItemID.CorruptSeeds, ItemID.CursedFlame, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.LesserHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Kill a Cyst in the Corruption or use a [i:{summon}] in the Corruption"; - string despawn = CalamityUtils.ColorMessage("The corrupted colony began searching for a new breeding ground.", new Color(0x94, 0x00, 0xD3)); - AddBoss(bossChecklist, calamity, "Hive Mind", order, type, DownedHiveMind, summon, loot, collection, instructions, despawn); - } - - // Perforators - { - BossDifficulty.TryGetValue("Perforators", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemID.CrimtaneBar, ItemID.Vertebrae, ItemID.CrimsonSeeds, ItemID.Ichor, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.LesserHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Kill a Cyst in the Crimson or use a [i:{summon}] in the Crimson"; - string despawn = CalamityUtils.ColorMessage("The parasitic hive began searching for a new host.", new Color(0xDC, 0x14, 0x3C)); - AddBoss(bossChecklist, calamity, "The Perforators", order, type, DownedPerfs, summon, loot, collection, instructions, despawn); - } - - // Slime God - { - BossDifficulty.TryGetValue("SlimeGod", out float order); - List bosses = new List() { NPCType(), NPCType(), NPCType() }; - int summon = ItemType(); - List loot = new List() { ItemType(), ItemID.Gel, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.HealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Use an [i:{summon}]"; - string despawn = CalamityUtils.ColorMessage("The gelatinous monstrosity achieved vengeance for its brethren.", new Color(0xBA, 0x55, 0x33)); - AddBoss(bossChecklist, calamity, "Slime God", order, bosses, DownedSlimeGod, summon, loot, collection, instructions, despawn); - } - - // Cryogen - { - BossDifficulty.TryGetValue("Cryogen", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.FrozenKey, ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}] in the Snow Biome"; - string despawn = CalamityUtils.ColorMessage("Cryogen drifts away, carried on a freezing wind.", new Color(0x00, 0xFF, 0xFF)); - string bossLogTex = "CalamityMod/NPCs/Cryogen/Cryogen_BossChecklist"; - AddBoss(bossChecklist, calamity, "Cryogen", order, type, DownedCryogen, summon, loot, collection, instructions, despawn, bossLogTex); - } - - // Aquatic Scourge - { - BossDifficulty.TryGetValue("AquaticScourge", out float order); - List segments = new List() { NPCType(), NPCType(), NPCType(), NPCType() }; - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}] in the Sulphuric Sea or wait for it to spawn in the Sulphuric Sea"; - string despawn = CalamityUtils.ColorMessage("The Aquatic Scourge swam back into the open ocean.", new Color(0xF0, 0xE6, 0x8C)); - string bossLogTex = "CalamityMod/NPCs/AquaticScourge/AquaticScourge_BossChecklist"; - AddBoss(bossChecklist, calamity, "Aquatic Scourge", order, segments, DownedAquaticScourge, summon, loot, collection, instructions, despawn, bossLogTex); - } - - // Brimstone Elemental - { - BossDifficulty.TryGetValue("BrimstoneElemental", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}] in the Brimstone Crag"; - string despawn = CalamityUtils.ColorMessage("Brimstone Elemental withdraws to the ruins of her shrine.", new Color(0xDC, 0x14, 0x3C)); - AddBoss(bossChecklist, calamity, "Brimstone Elemental", order, type, DownedBrimstoneElemental, summon, loot, collection, instructions, despawn); - } - - // Calamitas - { - BossDifficulty.TryGetValue("Calamitas", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.BrokenHeroSword, ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Use an [i:{summon}] at Night"; - string despawn = CalamityUtils.ColorMessage("If you wanted a fight, you should've came more prepared.", new Color(0xFF, 0xA5, 0x00)); - AddBoss(bossChecklist, calamity, "Calamitas", order, type, DownedCalamitas, summon, loot, collection, instructions, despawn); - } - - // Great Sand Shark - { - BossDifficulty.TryGetValue("GreatSandShark", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemID.AncientBattleArmorMaterial }; - List collection = new List() { ItemID.MusicBoxSandstorm }; - string instructions = $"Kill 10 sand sharks after defeating Plantera or use a [i:{summon}] in the Desert Biome"; - string despawn = CalamityUtils.ColorMessage("The apex predator of the sands disappears into the dunes...", new Color(0xDA, 0xA5, 0x20)); - AddMiniBoss(bossChecklist, calamity, "Great Sand Shark", order, type, DownedGSS, summon, loot, collection, instructions, despawn); - } - - // Siren and Leviathan - { - BossDifficulty.TryGetValue("Leviathan", out float order); - List bosses = new List() { NPCType(), NPCType() }; - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.HotlineFishingHook, ItemID.BottomlessBucket, ItemID.SuperAbsorbantSponge, ItemID.FishingPotion, ItemID.SonarPotion, ItemID.CratePotion, ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = "By killing an unknown entity in the Ocean Biome"; - string despawn = CalamityUtils.ColorMessage("The aquatic entities sink back beneath the ocean depths.", new Color(0x7F, 0xFF, 0xD4)); - string bossLogTex = "CalamityMod/NPCs/Leviathan/SirenandLevi_BossChecklist"; - AddBoss(bossChecklist, calamity, "Leviathan", order, bosses, DownedLeviathan, null, loot, collection, instructions, despawn, bossLogTex); - } - - // Astrum Aureus - { - BossDifficulty.TryGetValue("AstrumAureus", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemID.FallenStar, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.HallowedKey, ItemType(), ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Use an [i:{summon}] at Night in the Astral Biome"; - string despawn = CalamityUtils.ColorMessage("Astrum Aureus’ program has been executed. Initiate recall.", new Color(0xFF, 0xD7, 0x00)); - string bossLogTex = "CalamityMod/NPCs/AstrumAureus/AstrumAureus_BossChecklist"; - AddBoss(bossChecklist, calamity, "Astrum Aureus", order, type, DownedAureus, summon, loot, collection, instructions, despawn, bossLogTex); - } - - // Plaguebringer Goliath - { - BossDifficulty.TryGetValue("PlaguebringerGoliath", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemID.Stinger, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Use an [i:{summon}] in the Jungle Biome"; - string despawn = CalamityUtils.ColorMessage("HOSTILE SPECIMENS TERMINATED. INITIATE RECALL TO HOME BASE.", new Color(0x00, 0xFF, 0x00)); - string bossLogTex = "CalamityMod/NPCs/PlaguebringerGoliath/PlaguebringerGoliath_BossChecklist"; - AddBoss(bossChecklist, calamity, "Plaguebringer Goliath", order, type, DownedPBG, summon, loot, collection, instructions, despawn, bossLogTex); - } - - // Ravager - { - BossDifficulty.TryGetValue("Ravager", out float order); - List segments = new List() { NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType() }; - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}]"; - string despawn = CalamityUtils.ColorMessage("The automaton of misshapen victims went looking for the true perpetrator.", new Color(0xB2, 0x22, 0x22)); - string bossLogTex = "CalamityMod/NPCs/Ravager/Ravager_BossChecklist"; - AddBoss(bossChecklist, calamity, "Ravager", order, segments, DownedRavager, summon, loot, collection, instructions, despawn, bossLogTex); - } - - // Astrum Deus - { - BossDifficulty.TryGetValue("AstrumDeus", out float order); - List segments = new List() { NPCType(), NPCType(), NPCType() }; - int summon1 = ItemType(); - int summon2 = ItemType(); - int altar = ItemType(); - List summons = new List() { summon1, summon2 }; - List loot = new List() { ItemType(), ItemType(), ItemID.FallenStar, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.FragmentSolar, ItemID.FragmentVortex, ItemID.FragmentNebula, ItemID.FragmentStardust, ItemID.GreaterHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon1}] or [i:{summon2}] as offering at an [i:{altar}]"; - string despawn = CalamityUtils.ColorMessage("The infected deity retreats to the heavens.", new Color(0xFF, 0xD7, 0x00)); - string bossLogTex = "CalamityMod/NPCs/AstrumDeus/AstrumDeus_BossChecklist"; - AddBoss(bossChecklist, calamity, "Astrum Deus", order, segments, DownedDeus, summons, loot, collection, instructions, despawn, bossLogTex); - } - - // Profaned Guardians - { - BossDifficulty.TryGetValue("ProfanedGuardians", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.SuperHealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}] in the Hallow or Underworld Biomes"; - string despawn = CalamityUtils.ColorMessage("The guardians must protect their goddess at all costs.", new Color(0xFF, 0xA5, 0x00)); - string bossLogTex = "CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardians_BossChecklist"; - AddBoss(bossChecklist, calamity, "Profaned Guardians", order, type, DownedGuardians, summon, loot, collection, instructions, despawn, bossLogTex); - } - - // Dragonfolly - { - BossDifficulty.TryGetValue("Dragonfolly", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Use [i:{summon}] in the Jungle Biome"; - string despawn = CalamityUtils.ColorMessage("The failed experiment returns to its reproductive routine.", new Color(0xFF, 0xD7, 0x00)); - AddBoss(bossChecklist, calamity, "Dragonfolly", order, type, DownedBirb, summon, loot, collection, instructions, despawn); - } - - // Providence - { - BossDifficulty.TryGetValue("Providence", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Use [i:{summon}] in the Hallow or Underworld Biomes"; - string despawn = CalamityUtils.ColorMessage("The Profaned Goddess vanishes in a burning blaze.", new Color(0xFF, 0xA5, 0x00)); - string bossLogTex = "CalamityMod/NPCs/Providence/Providence_BossChecklist"; - AddBoss(bossChecklist, calamity, "Providence", order, type, DownedProvidence, summon, loot, collection, instructions, despawn, bossLogTex); - } - - // Ceaseless Void - { - BossDifficulty.TryGetValue("CeaselessVoid", out float order); - List bosses = new List() { NPCType(), NPCType() }; - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}] in the Dungeon"; - string despawn = CalamityUtils.ColorMessage("The rift in time and space has moved away from your reach.", new Color(0x4B, 0x00, 0x82)); - AddBoss(bossChecklist, calamity, "Ceaseless Void", order, bosses, DownedCeaselessVoid, summon, loot, collection, instructions, despawn); - } - - // Storm Weaver - { - BossDifficulty.TryGetValue("StormWeaver", out float order); - List segments = new List() { NPCType(), NPCType(), NPCType() }; - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}] in Space"; - string despawn = CalamityUtils.ColorMessage("Storm Weaver hid itself once again within the stormfront.", new Color(0xEE, 0x82, 0xEE)); - string bossLogTex = "CalamityMod/NPCs/StormWeaver/StormWeaver_BossChecklist"; - AddBoss(bossChecklist, calamity, "Storm Weaver", order, segments, DownedStormWeaver, summon, loot, collection, instructions, despawn, bossLogTex); - } - - // Signus - { - BossDifficulty.TryGetValue("Signus", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}] in the Underworld"; - string despawn = CalamityUtils.ColorMessage("The Devourer's assassin has finished its easy task.", new Color(0xBA, 0x55, 0xD3)); - AddBoss(bossChecklist, calamity, "Signus", order, type, DownedSignus, summon, loot, collection, instructions, despawn); - } - - // Polterghast - { - BossDifficulty.TryGetValue("Polterghast", out float order); - List bosses = new List() { NPCType(), NPCType() }; - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Kill 30 phantom spirits or use a [i:{summon}] in the Dungeon"; - string despawn = CalamityUtils.ColorMessage("The volatile spirits disperse throughout the depths of the dungeon.", new Color(0xB0, 0xE0, 0xE6)); - AddBoss(bossChecklist, calamity, "Polterghast", order, bosses, DownedPolterghast, summon, loot, collection, instructions, despawn); - } - - // Old Duke - { - BossDifficulty.TryGetValue("OldDuke", out float order); - List bosses = new List() { NPCType() }; - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Defeat the Acid Rain event post-Polterghast or fish using a [i:{summon}] in the Sulphurous Sea"; - string despawn = CalamityUtils.ColorMessage("The old duke disappears amidst the acidic downpour.", new Color(0xF0, 0xE6, 0x8C)); - AddBoss(bossChecklist, calamity, "Old Duke", order, bosses, DownedBoomerDuke, summon, loot, collection, instructions, despawn); - } - - // Devourer of Gods - { - BossDifficulty.TryGetValue("DevourerOfGods", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}]"; - string despawn = CalamityUtils.ColorMessage("The Devourer of Gods has slain everyone and feasted on their essence.", new Color(0x00, 0xFF, 0xFF)); - string bossLogTex = "CalamityMod/NPCs/DevourerofGods/DevourerofGods_BossChecklist"; - string bossHeadTex = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_Head_Boss"; - AddBoss(bossChecklist, calamity, "Devourer of Gods", order, type, DownedDoG, summon, loot, collection, instructions, despawn, bossLogTex, bossHeadTex); - } - - // Yharon - { - BossDifficulty.TryGetValue("Yharon", out float order); - int type = NPCType(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), /*ItemType(), */ItemType() }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Use a [i:{summon}] in the Jungle Biome"; - string despawn = CalamityUtils.ColorMessage("Yharon found you too weak to stay near your gravestone.", new Color(0xFF, 0xA5, 0x00)); - string bossLogTex = "CalamityMod/NPCs/Yharon/Yharon_BossChecklist"; - AddBoss(bossChecklist, calamity, "Yharon", order, type, DownedYharon, summon, loot, collection, instructions, despawn, bossLogTex); - } - - // Exo Mechs - // Collection requires edits - // Instructions require edits - // Despawn requires edits - { - BossDifficulty.TryGetValue("ExoMechs", out float order); - List bosses = new List() { NPCType(), NPCType(), NPCType(), NPCType() }; - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = "By using a high-tech computer"; - string despawn = CalamityUtils.ColorMessage("An imperfection after all... what a shame.", new Color(0x7F, 0xFF, 0xD4)); - string bossLogTex = "CalamityMod/NPCs/ExoMechs/ExoMechs_BossChecklist"; - AddBoss(bossChecklist, calamity, "Exo Mechs", order, bosses, DownedExoMechs, null, loot, collection, instructions, despawn, bossLogTex); - } - - // Supreme Calamitas - { - BossDifficulty.TryGetValue("SupremeCalamitas", out float order); - int type = NPCType(); - int summon1 = ItemType(); - int summon2 = ItemType(); - int altar = ItemType(); - List summons = new List() { summon1, summon2 }; - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - string instructions = $"Use [i:{summon1}] or a [i:{summon2}] as offering at an [i:{altar}]"; - string despawn = CalamityUtils.ColorMessage("Please don't waste my time.", new Color(0xFF, 0xA5, 0x00)); - string bossHeadTex = "CalamityMod/NPCs/SupremeCalamitas/HoodedHeadIcon"; - AddBoss(bossChecklist, calamity, "Supreme Calamitas", order, type, DownedSCal, summons, loot, collection, instructions, despawn, null, bossHeadTex); - } - - // Adult Eidolon Wyrm - { - BossDifficulty.TryGetValue("AdultEidolonWyrm", out float order); - int type = NPCType(); - int summon = ItemID.RodofDiscord; - List loot = new List() { ItemType(), ItemType(), ItemID.Ectoplasm, ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { }; - string instructions = $"While in the Abyss, use an item that inflicts Chaos State"; - string despawn = CalamityUtils.ColorMessage("...", new Color(0x7F, 0xFF, 0xD4)); - string bossLogTex = "CalamityMod/NPCs/AdultEidolonWyrm/AdultEidolonWyrm_BossChecklist"; - AddBoss(bossChecklist, calamity, "Adult Eidolon Wyrm", order, type, DownedAdultEidolonWyrm, summon, loot, collection, instructions, despawn, bossLogTex); - } - } - - private static void AddCalamityInvasions(Mod bossChecklist, Mod calamity) - { - // Initial Acid Rain - { - InvasionDifficulty.TryGetValue("Acid Rain Initial", out float order); - List enemies = AcidRainEvent.PossibleEnemiesPreHM.Select(enemy => enemy.Key).ToList(); - int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType() }; - string instructions = $"Use a [i:{summon}] or wait for the invasion to occur naturally after the Eye of Cthulhu is defeated."; - string despawn = CalamityUtils.ColorMessage("The mysterious creatures of the sulphuric sea descended back into the ocean.", new Color(146, 183, 116)); - string bossLogTex = "CalamityMod/Events/AcidRainT1_BossChecklist"; - string iconTexture = "CalamityMod/ExtraTextures/UI/AcidRainIcon"; - AddInvasion(bossChecklist, calamity, "Acid Rain", order, enemies, DownedAcidRainInitial, summon, loot, collection, instructions, despawn, bossLogTex, iconTexture); - } - // Post-Aquatic Scourge Acid Rain - { - InvasionDifficulty.TryGetValue("Acid Rain Aquatic Scourge", out float order); - List enemies = AcidRainEvent.PossibleEnemiesAS.Select(enemy => enemy.Key).ToList(); - enemies.Add(ModContent.NPCType()); - enemies.AddRange(AcidRainEvent.PossibleMinibossesAS.Select(miniboss => miniboss.Key)); - List summons = new List() { ItemType() }; - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType() }; - string instructions = $"Use a [i:{ItemType()}] or wait for the invasion to occur naturally after the Aquatic Scourge is defeated"; - string despawn = CalamityUtils.ColorMessage("The mysterious creatures of the sulphuric sea descended back into the deep ocean.", new Color(146, 183, 116)); - string bossLogTex = "CalamityMod/Events/AcidRainT2_BossChecklist"; - string iconTexture = "CalamityMod/ExtraTextures/UI/AcidRainIcon"; - AddInvasion(bossChecklist, calamity, "Acid Rain (Post-AS)", order, enemies, DownedAcidRainHardmode, summons, loot, collection, instructions, despawn, bossLogTex, iconTexture); - } - // Post-Polterghast Acid Rain - { - InvasionDifficulty.TryGetValue("Acid Rain Polterghast", out float order); - List enemies = AcidRainEvent.PossibleEnemiesPolter.Select(enemy => enemy.Key).ToList(); - enemies.AddRange(AcidRainEvent.PossibleMinibossesPolter.Select(miniboss => miniboss.Key)); - List summons = new List() { ItemType() }; - List loot = new List() { ItemID.SharkFin, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; - List collection = new List() { ItemType() }; - string instructions = $"Use a [i:{ItemType()}] or wait for the invasion to occur naturally after the Polterghast is defeated"; - string despawn = CalamityUtils.ColorMessage("The mysterious creatures of the sulphuric sea descended back into the deep ocean.", new Color(146, 183, 116)); - string bossLogTex = "CalamityMod/Events/AcidRainT3_BossChecklist"; - string iconTexture = "CalamityMod/ExtraTextures/UI/AcidRainIcon"; - AddInvasion(bossChecklist, calamity, "Acid Rain (Post-Polter)", order, enemies, DownedBoomerDuke, summons, loot, collection, instructions, despawn, bossLogTex, iconTexture); - } - } - - private static void AddCalamityBossLoot(Mod bossChecklist) - { - // King Slime - AddLoot(bossChecklist, "KingSlime", - new List() { ItemType() }, - new List() { ItemType() } - ); - - // Eye of Cthulhu - AddLoot(bossChecklist, "EyeofCthulhu", - new List() { ItemType(), ItemType() }, - new List() { ItemType() } - ); - - // Eater of Worlds - AddLoot(bossChecklist, "EaterofWorldsHead", - null, - new List() { ItemType(), ItemType() } - ); - - // Brain of Cthulhu - AddLoot(bossChecklist, "BrainofCthulhu", - null, - new List() { ItemType(), ItemType() } - ); - - // Queen Bee - AddLoot(bossChecklist, "QueenBee", - new List() { ItemType(), ItemID.Stinger, ItemType() }, - new List() { ItemType() } - ); - - // Skeletron - AddLoot(bossChecklist, "SkeletronHead", - null, - new List() { ItemType() } - ); - - // Wall of Flesh - AddLoot(bossChecklist, "WallofFlesh", - new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.CorruptionKey, ItemID.CrimsonKey }, - new List() { ItemType(), ItemType(), ItemType() } - ); - - // The Twins - AddLoot(bossChecklist, "TheTwins", - new List() { ItemType() }, - new List() { ItemType(), ItemType() } - ); - - // The Destroyer - AddLoot(bossChecklist, "TheDestroyer", - new List() { ItemType(), ItemType() } - ); - - // Skeletron Prime - AddLoot(bossChecklist, "SkeletronPrime", - null, - new List() { ItemType(), ItemType() } - ); - - // Plantera - AddLoot(bossChecklist, "Plantera", - new List() { ItemType(), ItemType(), ItemType(), ItemID.JungleKey }, - new List() { ItemType() } - ); - AddSummons(bossChecklist, "Plantera", new List() { ItemType() }); - - // Golem - AddLoot(bossChecklist, "Golem", - new List() { ItemType(), ItemType() }, - new List() { ItemType() } - ); - AddSummons(bossChecklist, "Golem", new List() { ItemType() }); - - // Duke Fishron - AddLoot(bossChecklist, "DukeFishron", - new List() { ItemType(), ItemType() }, - new List() { ItemType() } - ); - - // Betsy - AddLoot(bossChecklist, "DD2Betsy", - null, - null - ); - - // Lunatic Cultist - AddLoot(bossChecklist, "CultistBoss", - null, - new List() { ItemType(), ItemType() } - ); - AddSummons(bossChecklist, "CultistBoss", new List() { ItemType() }); - - // Moon Lord - AddLoot(bossChecklist, "MoonLord", - new List() { ItemType(), ItemType() }, - new List() { ItemType() } - ); - } - - private static void AddCalamityEventLoot(Mod bossChecklist) - { - // Blood Moon - AddLoot(bossChecklist, "Blood Moon", - new List() { ItemType(), ItemType() }, - null - ); - AddSummons(bossChecklist, "Blood Moon", new List() { ItemType() }); - - // Goblin Army - AddLoot(bossChecklist, "Goblin Army", - new List() { ItemType(), ItemType(), ItemType(), ItemType() }, - null - ); - - // Pirates - AddLoot(bossChecklist, "Pirate Invasion", - new List() { ItemType(), ItemType() }, - null - ); - - // Solar Eclipse - AddLoot(bossChecklist, "Solar Eclipse", - new List() { ItemType(), ItemType(), ItemType() }, - null - ); - - // Pumpkin Moon - AddLoot(bossChecklist, "Pumpkin Moon", - new List() { ItemType() }, - null - ); - AddLoot(bossChecklist, "Pumpking", - new List() { ItemType() }, - null - ); - - // Frost Moon - AddLoot(bossChecklist, "Frost Moon", - new List() { ItemType() }, - null - ); - AddLoot(bossChecklist, "Ice Queen", - new List() { ItemType() }, - null - ); - - // Martian Madness - AddLoot(bossChecklist, "Martian Madness", - new List() { ItemType(), ItemType(), ItemType() }, - null - ); - AddLoot(bossChecklist, "Martian Saucer", - new List() { ItemType() }, - null - ); - - // Lunar Events - AddLoot(bossChecklist, "Lunar Event", - new List() { ItemType() }, - null - ); - } - - private static void FargosSupport() - { - Mod fargos = GetInstance().fargos; - if (fargos is null) - return; - - void AddToMutantShop(string bossName, string summonItemName, Func downed, int price) - { - BossDifficulty.TryGetValue(bossName, out float order); - fargos.Call("AddSummon", order, "CalamityMod", summonItemName, downed, price); - } - - fargos.Call("AbominationnClearEvents", "CalamityMod", CalamityWorld.rainingAcid, true); - - AddToMutantShop("OldDuke", "BloodwormItem", DownedBoomerDuke, Item.buyPrice(platinum: 2)); - } - - private static void CensusSupport() - { - Mod censusMod = GetInstance().census; - if (censusMod != null) - { - censusMod.Call("TownNPCCondition", NPCType(), "Defeat a Giant Clam after defeating the Desert Scourge"); - censusMod.Call("TownNPCCondition", NPCType(), "Have a [i:" + ItemID.PlatinumCoin + "] in your inventory after defeating Skeletron"); - censusMod.Call("TownNPCCondition", NPCType(), "Have [i:" + ItemType() + "] in your inventory in Hardmode"); - censusMod.Call("TownNPCCondition", NPCType(), "Defeat Cryogen"); - censusMod.Call("TownNPCCondition", NPCType(), "Defeat Supreme Calamitas"); - } - } - - private static void SummonersAssociationSupport() - { - Mod sAssociation = GetInstance().summonersAssociation; - if (sAssociation is null) - return; - - void RegisterSummon(int summonItem, int summonBuff, int summonProjectile) - { - sAssociation.Call("AddMinionInfo", summonItem, summonBuff, summonProjectile); - } - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); - - sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), new List() { ProjectileType(), ProjectileType(), ProjectileType()}, new List() {1-(1f/3f), 2f/3f, 2f/3f}); - //Entropy's Vigil is a bruh moment - sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), new List() { ProjectileType(), ProjectileType()}); - } - } + internal class Downed + { + public static readonly Func DownedDesertScourge = () => CalamityWorld.downedDesertScourge; + public static readonly Func DownedGiantClam = () => CalamityWorld.downedCLAM; + public static readonly Func DownedCrabulon = () => CalamityWorld.downedCrabulon; + public static readonly Func DownedHiveMind = () => CalamityWorld.downedHiveMind; + public static readonly Func DownedPerfs = () => CalamityWorld.downedPerforator; + public static readonly Func DownedSlimeGod = () => CalamityWorld.downedSlimeGod; + public static readonly Func DownedCryogen = () => CalamityWorld.downedCryogen; + public static readonly Func DownedBrimstoneElemental = () => CalamityWorld.downedBrimstoneElemental; + public static readonly Func DownedAquaticScourge = () => CalamityWorld.downedAquaticScourge; + public static readonly Func DownedCalamitas = () => CalamityWorld.downedCalamitas; + public static readonly Func DownedGSS = () => CalamityWorld.downedGSS; + public static readonly Func DownedLeviathan = () => CalamityWorld.downedLeviathan; + public static readonly Func DownedAureus = () => CalamityWorld.downedAstrageldon; + public static readonly Func DownedPBG = () => CalamityWorld.downedPlaguebringer; + public static readonly Func DownedRavager = () => CalamityWorld.downedScavenger; + public static readonly Func DownedDeus = () => CalamityWorld.downedStarGod; + public static readonly Func DownedGuardians = () => CalamityWorld.downedGuardians; + public static readonly Func DownedBirb = () => CalamityWorld.downedBumble; + public static readonly Func DownedProvidence = () => CalamityWorld.downedProvidence; + public static readonly Func DownedCeaselessVoid = () => CalamityWorld.downedSentinel1; + public static readonly Func DownedStormWeaver = () => CalamityWorld.downedSentinel2; + public static readonly Func DownedSignus = () => CalamityWorld.downedSentinel3; + public static readonly Func DownedPolterghast = () => CalamityWorld.downedPolterghast; + public static readonly Func DownedBoomerDuke = () => CalamityWorld.downedBoomerDuke; + public static readonly Func DownedDoG = () => CalamityWorld.downedDoG; + public static readonly Func DownedYharon = () => CalamityWorld.downedYharon; + public static readonly Func DownedExoMechs = () => CalamityWorld.downedExoMechs; + public static readonly Func DownedSCal = () => CalamityWorld.downedSCal; + public static readonly Func DownedAdultEidolonWyrm = () => CalamityWorld.downedAdultEidolonWyrm; + + public static readonly Func DownedAcidRainInitial = () => CalamityWorld.downedEoCAcidRain; + public static readonly Func DownedAcidRainHardmode = () => CalamityWorld.downedAquaticScourgeAcidRain; + } + + internal class WeakReferenceSupport + { + private static readonly Dictionary BossDifficulty = new Dictionary + { + { "DesertScourge", 1.5f }, + { "GiantClam", 1.6f }, + { "Crabulon", 2.5f }, + { "HiveMind", 3.5f }, + { "Perforators", 3.51f }, + { "SlimeGod", 5.5f }, + { "Cryogen", 6.5f }, + { "AquaticScourge", 7.5f }, + { "BrimstoneElemental", 8.5f }, + { "Calamitas", 9.7f }, + { "GreatSandShark", 10.09f }, + { "Leviathan", 10.5f }, + { "AstrumAureus", 10.6f }, + { "PlaguebringerGoliath", 11.5f }, + { "Ravager", 12.5f }, + { "AstrumDeus", 13.5f }, + { "ProfanedGuardians", 14.5f }, + { "Dragonfolly", 14.6f }, + { "Providence", 15.01f }, // Thorium's Ragnarok is 15f + { "CeaselessVoid", 15.5f }, + { "StormWeaver", 15.51f }, + { "Signus", 15.52f }, + { "Polterghast", 16f }, + { "OldDuke", 16.5f }, + { "DevourerOfGods", 17f }, + { "Yharon", 18f }, + { "ExoMechs", 18.5f }, + { "SupremeCalamitas", 19f }, + { "AdultEidolonWyrm", 19.5f }, + // { "Yharim", 20f }, + // { "Noxus", 120f }, + // { "Xeroc", 121f }, + }; + + private static readonly Dictionary InvasionDifficulty = new Dictionary + { + { "Acid Rain Initial", 2.4f }, + { "Acid Rain Aquatic Scourge", 7.51f }, + { "Acid Rain Polterghast", 16.49f } + }; + + public static void Setup() + { + BossChecklistSupport(); + FargosSupport(); + CensusSupport(); + SummonersAssociationSupport(); + } + + // Wrapper function to add bosses to Boss Checklist. + private static void AddBoss(Mod bossChecklist, Mod hostMod, string name, float difficulty, int npcType, Func downed, object summon, + List loot, List collection, string instructions, string despawn, string bossLogTex = null, string bossHeadTex = null) + { + bossChecklist.Call("AddBoss", difficulty, npcType, hostMod, name, downed, summon ?? null, collection, loot, instructions, despawn, bossLogTex, bossHeadTex); + } + + // Wrapper function to add bosses with multiple segments or phases to Boss Checklist. + private static void AddBoss(Mod bossChecklist, Mod hostMod, string name, float difficulty, List npcTypes, Func downed, object summon, + List loot, List collection, string instructions, string despawn, string bossLogTex = null, string bossHeadTex = null) + { + bossChecklist.Call("AddBoss", difficulty, npcTypes, hostMod, name, downed, summon ?? null, collection, loot, instructions, despawn, bossLogTex, bossHeadTex); + } + + // Wrapper function to add bosses with multiple segments or phases to Boss Checklist. + private static void AddInvasion(Mod bossChecklist, Mod hostMod, string name, float difficulty, List npcTypes, Func downed, object summon, + List loot, List collection, string instructions, string despawn, string invasionTexture = null, string iconTexture = null) + { + bossChecklist.Call("AddEventWithInfo", difficulty, npcTypes, hostMod, name, downed, summon ?? null, collection, loot, instructions, despawn, invasionTexture, iconTexture); + } + + // Wrapper function to add minibosses to Boss Checklist. + private static void AddMiniBoss(Mod bossChecklist, Mod hostMod, string name, float difficulty, int npcType, Func downed, object summon, + List loot, List collection, string instructions, string despawn, string bossLogTex = null, string bossHeadTex = null) + { + bossChecklist.Call("AddMiniBoss", difficulty, npcType, hostMod, name, downed, summon ?? null, collection, loot, instructions, despawn, bossLogTex, bossHeadTex); + } + + // Wrapper function to add loot and collection items to vanilla bosses for Boss Checklist. + private static void AddLoot(Mod bossChecklist, string bossName, List loot = null, List collection = null) + => AddLoot(bossChecklist, "Terraria", bossName, loot, collection); + + // Wrapper function to add loot and collection items to other mods' bosses for Boss Checklist. + private static void AddLoot(Mod bossChecklist, string mod, string bossName, List loot = null, List collection = null) + { + if (loot != null) + bossChecklist.Call("AddToBossLoot", mod, bossName, loot); + if (collection != null) + bossChecklist.Call("AddToBossCollection", mod, bossName, collection); + } + + // Wrapper function to add summon items to vanilla bosses for Boss Checklist. + private static void AddSummons(Mod bossChecklist, string bossName, List summons) => AddSummons(bossChecklist, "Terraria", bossName, summons); + + // Wrapper function to add summon items to other mods' bosses for Boss Checklist. + private static void AddSummons(Mod bossChecklist, string mod, string bossName, List summons) => bossChecklist.Call("AddToBossSpawnItems", mod, bossName, summons); + + /// + /// 1.0 = King Slime
+ /// 2.0 = Eye of Cthulhu
+ /// 3.0 = Eater of Worlds / Brain of Cthulhu
+ /// 4.0 = Queen Bee
+ /// 5.0 = Skeletron
+ /// 6.0 = Wall of Flesh
+ /// 7.0 = The Twins
+ /// 8.0 = The Destroyer
+ /// 9.0 = Skeletron Prime
+ /// 10.0 = Plantera
+ /// 11.0 = Golem
+ /// 12.0 = Duke Fishron
+ /// 13.0 = Lunatic Cultist
+ /// 14.0 = Moon Lord + ///
+ private static void BossChecklistSupport() + { + CalamityMod calamity = GetInstance(); + Mod bossChecklist = calamity.bossChecklist; + if (bossChecklist is null) + return; + + // Adds every single Calamity boss and miniboss to Boss Checklist's Boss Log. + AddCalamityBosses(bossChecklist, calamity); + + // Adds every single Calamity invasion to the Boss Checklist's Invasion Log. + AddCalamityInvasions(bossChecklist, calamity); + + // Loot which Calamity adds to vanilla bosses and events is also added to Boss Checklist's Boss Log. + AddCalamityBossLoot(bossChecklist); + AddCalamityEventLoot(bossChecklist); + } + + private static void AddCalamityBosses(Mod bossChecklist, Mod calamity) + { + // Desert Scourge + { + BossDifficulty.TryGetValue("DesertScourge", out float order); + List segments = new List() { NPCType(), NPCType(), NPCType() }; + int summon = ItemType(); + List loot = new List() { ItemType(), ItemID.SandBlock, ItemType(), ItemID.Coral, ItemID.Seashell, ItemID.Starfish, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.LesserHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}] in the Desert Biome"; + string despawn = CalamityUtils.ColorMessage("The scourge of the desert delved back into the sand.", new Color(0xEE, 0xE8, 0xAA)); + string bossLogTex = "CalamityMod/NPCs/DesertScourge/DesertScourge_BossChecklist"; + AddBoss(bossChecklist, calamity, "Desert Scourge", order, segments, DownedDesertScourge, summon, loot, collection, instructions, despawn, bossLogTex); + } + + // Giant Clam + { + BossDifficulty.TryGetValue("GiantClam", out float order); + int type = NPCType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = "Can spawn naturally in the Sunken Sea"; + string despawn = CalamityUtils.ColorMessage("The Giant Clam returns into hiding in its grotto.", new Color(0x7F, 0xFF, 0xD4)); + AddMiniBoss(bossChecklist, calamity, "Giant Clam", order, type, DownedGiantClam, null, loot, null, instructions, despawn); + } + + // Crabulon + { + BossDifficulty.TryGetValue("Crabulon", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemID.GlowingMushroom, ItemID.MushroomGrassSeeds, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.LesserHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}] in the Mushroom Biome"; + string despawn = CalamityUtils.ColorMessage("The mycleium crab has lost interest.", new Color(0x64, 0x95, 0xED)); + AddBoss(bossChecklist, calamity, "Crabulon", order, type, DownedCrabulon, summon, loot, collection, instructions, despawn); + } + + // Hive Mind + { + BossDifficulty.TryGetValue("HiveMind", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemID.DemoniteBar, ItemID.RottenChunk, ItemID.CorruptSeeds, ItemID.CursedFlame, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.LesserHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Kill a Cyst in the Corruption or use a [i:{summon}] in the Corruption"; + string despawn = CalamityUtils.ColorMessage("The corrupted colony began searching for a new breeding ground.", new Color(0x94, 0x00, 0xD3)); + AddBoss(bossChecklist, calamity, "Hive Mind", order, type, DownedHiveMind, summon, loot, collection, instructions, despawn); + } + + // Perforators + { + BossDifficulty.TryGetValue("Perforators", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemID.CrimtaneBar, ItemID.Vertebrae, ItemID.CrimsonSeeds, ItemID.Ichor, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.LesserHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Kill a Cyst in the Crimson or use a [i:{summon}] in the Crimson"; + string despawn = CalamityUtils.ColorMessage("The parasitic hive began searching for a new host.", new Color(0xDC, 0x14, 0x3C)); + AddBoss(bossChecklist, calamity, "The Perforators", order, type, DownedPerfs, summon, loot, collection, instructions, despawn); + } + + // Slime God + { + BossDifficulty.TryGetValue("SlimeGod", out float order); + List bosses = new List() { NPCType(), NPCType(), NPCType() }; + int summon = ItemType(); + List loot = new List() { ItemType(), ItemID.Gel, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.HealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Use an [i:{summon}]"; + string despawn = CalamityUtils.ColorMessage("The gelatinous monstrosity achieved vengeance for its brethren.", new Color(0xBA, 0x55, 0x33)); + AddBoss(bossChecklist, calamity, "Slime God", order, bosses, DownedSlimeGod, summon, loot, collection, instructions, despawn); + } + + // Cryogen + { + BossDifficulty.TryGetValue("Cryogen", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.FrozenKey, ItemID.GreaterHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}] in the Snow Biome"; + string despawn = CalamityUtils.ColorMessage("Cryogen drifts away, carried on a freezing wind.", new Color(0x00, 0xFF, 0xFF)); + string bossLogTex = "CalamityMod/NPCs/Cryogen/Cryogen_BossChecklist"; + AddBoss(bossChecklist, calamity, "Cryogen", order, type, DownedCryogen, summon, loot, collection, instructions, despawn, bossLogTex); + } + + // Aquatic Scourge + { + BossDifficulty.TryGetValue("AquaticScourge", out float order); + List segments = new List() { NPCType(), NPCType(), NPCType(), NPCType() }; + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.GreaterHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}] in the Sulphuric Sea or wait for it to spawn in the Sulphuric Sea"; + string despawn = CalamityUtils.ColorMessage("The Aquatic Scourge swam back into the open ocean.", new Color(0xF0, 0xE6, 0x8C)); + string bossLogTex = "CalamityMod/NPCs/AquaticScourge/AquaticScourge_BossChecklist"; + AddBoss(bossChecklist, calamity, "Aquatic Scourge", order, segments, DownedAquaticScourge, summon, loot, collection, instructions, despawn, bossLogTex); + } + + // Brimstone Elemental + { + BossDifficulty.TryGetValue("BrimstoneElemental", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.GreaterHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}] in the Brimstone Crag"; + string despawn = CalamityUtils.ColorMessage("Brimstone Elemental withdraws to the ruins of her shrine.", new Color(0xDC, 0x14, 0x3C)); + AddBoss(bossChecklist, calamity, "Brimstone Elemental", order, type, DownedBrimstoneElemental, summon, loot, collection, instructions, despawn); + } + + // Calamitas + { + BossDifficulty.TryGetValue("Calamitas", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.BrokenHeroSword, ItemID.GreaterHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Use an [i:{summon}] at Night"; + string despawn = CalamityUtils.ColorMessage("If you wanted a fight, you should've came more prepared.", new Color(0xFF, 0xA5, 0x00)); + AddBoss(bossChecklist, calamity, "Calamitas", order, type, DownedCalamitas, summon, loot, collection, instructions, despawn); + } + + // Great Sand Shark + { + BossDifficulty.TryGetValue("GreatSandShark", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemID.AncientBattleArmorMaterial }; + List collection = new List() { ItemID.MusicBoxSandstorm }; + string instructions = $"Kill 10 sand sharks after defeating Plantera or use a [i:{summon}] in the Desert Biome"; + string despawn = CalamityUtils.ColorMessage("The apex predator of the sands disappears into the dunes...", new Color(0xDA, 0xA5, 0x20)); + AddMiniBoss(bossChecklist, calamity, "Great Sand Shark", order, type, DownedGSS, summon, loot, collection, instructions, despawn); + } + + // Siren and Leviathan + { + BossDifficulty.TryGetValue("Leviathan", out float order); + List bosses = new List() { NPCType(), NPCType() }; + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.HotlineFishingHook, ItemID.BottomlessBucket, ItemID.SuperAbsorbantSponge, ItemID.FishingPotion, ItemID.SonarPotion, ItemID.CratePotion, ItemID.GreaterHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = "By killing an unknown entity in the Ocean Biome"; + string despawn = CalamityUtils.ColorMessage("The aquatic entities sink back beneath the ocean depths.", new Color(0x7F, 0xFF, 0xD4)); + string bossLogTex = "CalamityMod/NPCs/Leviathan/SirenandLevi_BossChecklist"; + AddBoss(bossChecklist, calamity, "Leviathan", order, bosses, DownedLeviathan, null, loot, collection, instructions, despawn, bossLogTex); + } + + // Astrum Aureus + { + BossDifficulty.TryGetValue("AstrumAureus", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemID.FallenStar, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.HallowedKey, ItemType(), ItemID.GreaterHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType() }; + string instructions = $"Use an [i:{summon}] at Night in the Astral Biome"; + string despawn = CalamityUtils.ColorMessage("Astrum Aureus’ program has been executed. Initiate recall.", new Color(0xFF, 0xD7, 0x00)); + string bossLogTex = "CalamityMod/NPCs/AstrumAureus/AstrumAureus_BossChecklist"; + AddBoss(bossChecklist, calamity, "Astrum Aureus", order, type, DownedAureus, summon, loot, collection, instructions, despawn, bossLogTex); + } + + // Plaguebringer Goliath + { + BossDifficulty.TryGetValue("PlaguebringerGoliath", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemID.Stinger, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.GreaterHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Use an [i:{summon}] in the Jungle Biome"; + string despawn = CalamityUtils.ColorMessage("HOSTILE SPECIMENS TERMINATED. INITIATE RECALL TO HOME BASE.", new Color(0x00, 0xFF, 0x00)); + string bossLogTex = "CalamityMod/NPCs/PlaguebringerGoliath/PlaguebringerGoliath_BossChecklist"; + AddBoss(bossChecklist, calamity, "Plaguebringer Goliath", order, type, DownedPBG, summon, loot, collection, instructions, despawn, bossLogTex); + } + + // Ravager + { + BossDifficulty.TryGetValue("Ravager", out float order); + List segments = new List() { NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType() }; + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.GreaterHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}]"; + string despawn = CalamityUtils.ColorMessage("The automaton of misshapen victims went looking for the true perpetrator.", new Color(0xB2, 0x22, 0x22)); + string bossLogTex = "CalamityMod/NPCs/Ravager/Ravager_BossChecklist"; + AddBoss(bossChecklist, calamity, "Ravager", order, segments, DownedRavager, summon, loot, collection, instructions, despawn, bossLogTex); + } + + // Astrum Deus + { + BossDifficulty.TryGetValue("AstrumDeus", out float order); + List segments = new List() { NPCType(), NPCType(), NPCType() }; + int summon1 = ItemType(); + int summon2 = ItemType(); + int altar = ItemType(); + List summons = new List() { summon1, summon2 }; + List loot = new List() { ItemType(), ItemType(), ItemID.FallenStar, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.FragmentSolar, ItemID.FragmentVortex, ItemID.FragmentNebula, ItemID.FragmentStardust, ItemID.GreaterHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon1}] or [i:{summon2}] as offering at an [i:{altar}]"; + string despawn = CalamityUtils.ColorMessage("The infected deity retreats to the heavens.", new Color(0xFF, 0xD7, 0x00)); + string bossLogTex = "CalamityMod/NPCs/AstrumDeus/AstrumDeus_BossChecklist"; + AddBoss(bossChecklist, calamity, "Astrum Deus", order, segments, DownedDeus, summons, loot, collection, instructions, despawn, bossLogTex); + } + + // Profaned Guardians + { + BossDifficulty.TryGetValue("ProfanedGuardians", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.SuperHealingPotion }; + List collection = new List() { ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}] in the Hallow or Underworld Biomes"; + string despawn = CalamityUtils.ColorMessage("The guardians must protect their goddess at all costs.", new Color(0xFF, 0xA5, 0x00)); + string bossLogTex = "CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardians_BossChecklist"; + AddBoss(bossChecklist, calamity, "Profaned Guardians", order, type, DownedGuardians, summon, loot, collection, instructions, despawn, bossLogTex); + } + + // Dragonfolly + { + BossDifficulty.TryGetValue("Dragonfolly", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType() }; + string instructions = $"Use [i:{summon}] in the Jungle Biome"; + string despawn = CalamityUtils.ColorMessage("The failed experiment returns to its reproductive routine.", new Color(0xFF, 0xD7, 0x00)); + AddBoss(bossChecklist, calamity, "Dragonfolly", order, type, DownedBirb, summon, loot, collection, instructions, despawn); + } + + // Providence + { + BossDifficulty.TryGetValue("Providence", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType() }; + string instructions = $"Use [i:{summon}] in the Hallow or Underworld Biomes"; + string despawn = CalamityUtils.ColorMessage("The Profaned Goddess vanishes in a burning blaze.", new Color(0xFF, 0xA5, 0x00)); + string bossLogTex = "CalamityMod/NPCs/Providence/Providence_BossChecklist"; + AddBoss(bossChecklist, calamity, "Providence", order, type, DownedProvidence, summon, loot, collection, instructions, despawn, bossLogTex); + } + + // Ceaseless Void + { + BossDifficulty.TryGetValue("CeaselessVoid", out float order); + List bosses = new List() { NPCType(), NPCType() }; + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}] in the Dungeon"; + string despawn = CalamityUtils.ColorMessage("The rift in time and space has moved away from your reach.", new Color(0x4B, 0x00, 0x82)); + AddBoss(bossChecklist, calamity, "Ceaseless Void", order, bosses, DownedCeaselessVoid, summon, loot, collection, instructions, despawn); + } + + // Storm Weaver + { + BossDifficulty.TryGetValue("StormWeaver", out float order); + List segments = new List() { NPCType(), NPCType(), NPCType() }; + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}] in Space"; + string despawn = CalamityUtils.ColorMessage("Storm Weaver hid itself once again within the stormfront.", new Color(0xEE, 0x82, 0xEE)); + string bossLogTex = "CalamityMod/NPCs/StormWeaver/StormWeaver_BossChecklist"; + AddBoss(bossChecklist, calamity, "Storm Weaver", order, segments, DownedStormWeaver, summon, loot, collection, instructions, despawn, bossLogTex); + } + + // Signus + { + BossDifficulty.TryGetValue("Signus", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}] in the Underworld"; + string despawn = CalamityUtils.ColorMessage("The Devourer's assassin has finished its easy task.", new Color(0xBA, 0x55, 0xD3)); + AddBoss(bossChecklist, calamity, "Signus", order, type, DownedSignus, summon, loot, collection, instructions, despawn); + } + + // Polterghast + { + BossDifficulty.TryGetValue("Polterghast", out float order); + List bosses = new List() { NPCType(), NPCType() }; + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType() }; + string instructions = $"Kill 30 phantom spirits or use a [i:{summon}] in the Dungeon"; + string despawn = CalamityUtils.ColorMessage("The volatile spirits disperse throughout the depths of the dungeon.", new Color(0xB0, 0xE0, 0xE6)); + AddBoss(bossChecklist, calamity, "Polterghast", order, bosses, DownedPolterghast, summon, loot, collection, instructions, despawn); + } + + // Old Duke + { + BossDifficulty.TryGetValue("OldDuke", out float order); + List bosses = new List() { NPCType() }; + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType() }; + string instructions = $"Defeat the Acid Rain event post-Polterghast or fish using a [i:{summon}] in the Sulphurous Sea"; + string despawn = CalamityUtils.ColorMessage("The old duke disappears amidst the acidic downpour.", new Color(0xF0, 0xE6, 0x8C)); + AddBoss(bossChecklist, calamity, "Old Duke", order, bosses, DownedBoomerDuke, summon, loot, collection, instructions, despawn); + } + + // Devourer of Gods + { + BossDifficulty.TryGetValue("DevourerOfGods", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}]"; + string despawn = CalamityUtils.ColorMessage("The Devourer of Gods has slain everyone and feasted on their essence.", new Color(0x00, 0xFF, 0xFF)); + string bossLogTex = "CalamityMod/NPCs/DevourerofGods/DevourerofGods_BossChecklist"; + string bossHeadTex = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_Head_Boss"; + AddBoss(bossChecklist, calamity, "Devourer of Gods", order, type, DownedDoG, summon, loot, collection, instructions, despawn, bossLogTex, bossHeadTex); + } + + // Yharon + { + BossDifficulty.TryGetValue("Yharon", out float order); + int type = NPCType(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), /*ItemType(), */ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Use a [i:{summon}] in the Jungle Biome"; + string despawn = CalamityUtils.ColorMessage("Yharon found you too weak to stay near your gravestone.", new Color(0xFF, 0xA5, 0x00)); + string bossLogTex = "CalamityMod/NPCs/Yharon/Yharon_BossChecklist"; + AddBoss(bossChecklist, calamity, "Yharon", order, type, DownedYharon, summon, loot, collection, instructions, despawn, bossLogTex); + } + + // Exo Mechs + // Collection requires edits + // Instructions require edits + // Despawn requires edits + { + BossDifficulty.TryGetValue("ExoMechs", out float order); + List bosses = new List() { NPCType(), NPCType(), NPCType(), NPCType() }; + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = "By using a high-tech computer"; + string despawn = CalamityUtils.ColorMessage("An imperfection after all... what a shame.", new Color(0x7F, 0xFF, 0xD4)); + string bossLogTex = "CalamityMod/NPCs/ExoMechs/ExoMechs_BossChecklist"; + AddBoss(bossChecklist, calamity, "Exo Mechs", order, bosses, DownedExoMechs, null, loot, collection, instructions, despawn, bossLogTex); + } + + // Supreme Calamitas + { + BossDifficulty.TryGetValue("SupremeCalamitas", out float order); + int type = NPCType(); + int summon1 = ItemType(); + int summon2 = ItemType(); + int altar = ItemType(); + List summons = new List() { summon1, summon2 }; + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + string instructions = $"Use [i:{summon1}] or a [i:{summon2}] as offering at an [i:{altar}]"; + string despawn = CalamityUtils.ColorMessage("Please don't waste my time.", new Color(0xFF, 0xA5, 0x00)); + string bossHeadTex = "CalamityMod/NPCs/SupremeCalamitas/HoodedHeadIcon"; + AddBoss(bossChecklist, calamity, "Supreme Calamitas", order, type, DownedSCal, summons, loot, collection, instructions, despawn, null, bossHeadTex); + } + + // Adult Eidolon Wyrm + { + BossDifficulty.TryGetValue("AdultEidolonWyrm", out float order); + int type = NPCType(); + int summon = ItemID.RodofDiscord; + List loot = new List() { ItemType(), ItemType(), ItemID.Ectoplasm, ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { }; + string instructions = $"While in the Abyss, use an item that inflicts Chaos State"; + string despawn = CalamityUtils.ColorMessage("...", new Color(0x7F, 0xFF, 0xD4)); + string bossLogTex = "CalamityMod/NPCs/AdultEidolonWyrm/AdultEidolonWyrm_BossChecklist"; + AddBoss(bossChecklist, calamity, "Adult Eidolon Wyrm", order, type, DownedAdultEidolonWyrm, summon, loot, collection, instructions, despawn, bossLogTex); + } + } + + private static void AddCalamityInvasions(Mod bossChecklist, Mod calamity) + { + // Initial Acid Rain + { + InvasionDifficulty.TryGetValue("Acid Rain Initial", out float order); + List enemies = AcidRainEvent.PossibleEnemiesPreHM.Select(enemy => enemy.Key).ToList(); + int summon = ItemType(); + List loot = new List() { ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType() }; + string instructions = $"Use a [i:{summon}] or wait for the invasion to occur naturally after the Eye of Cthulhu is defeated."; + string despawn = CalamityUtils.ColorMessage("The mysterious creatures of the sulphuric sea descended back into the ocean.", new Color(146, 183, 116)); + string bossLogTex = "CalamityMod/Events/AcidRainT1_BossChecklist"; + string iconTexture = "CalamityMod/ExtraTextures/UI/AcidRainIcon"; + AddInvasion(bossChecklist, calamity, "Acid Rain", order, enemies, DownedAcidRainInitial, summon, loot, collection, instructions, despawn, bossLogTex, iconTexture); + } + // Post-Aquatic Scourge Acid Rain + { + InvasionDifficulty.TryGetValue("Acid Rain Aquatic Scourge", out float order); + List enemies = AcidRainEvent.PossibleEnemiesAS.Select(enemy => enemy.Key).ToList(); + enemies.Add(ModContent.NPCType()); + enemies.AddRange(AcidRainEvent.PossibleMinibossesAS.Select(miniboss => miniboss.Key)); + List summons = new List() { ItemType() }; + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType() }; + string instructions = $"Use a [i:{ItemType()}] or wait for the invasion to occur naturally after the Aquatic Scourge is defeated"; + string despawn = CalamityUtils.ColorMessage("The mysterious creatures of the sulphuric sea descended back into the deep ocean.", new Color(146, 183, 116)); + string bossLogTex = "CalamityMod/Events/AcidRainT2_BossChecklist"; + string iconTexture = "CalamityMod/ExtraTextures/UI/AcidRainIcon"; + AddInvasion(bossChecklist, calamity, "Acid Rain (Post-AS)", order, enemies, DownedAcidRainHardmode, summons, loot, collection, instructions, despawn, bossLogTex, iconTexture); + } + // Post-Polterghast Acid Rain + { + InvasionDifficulty.TryGetValue("Acid Rain Polterghast", out float order); + List enemies = AcidRainEvent.PossibleEnemiesPolter.Select(enemy => enemy.Key).ToList(); + enemies.AddRange(AcidRainEvent.PossibleMinibossesPolter.Select(miniboss => miniboss.Key)); + List summons = new List() { ItemType() }; + List loot = new List() { ItemID.SharkFin, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType() }; + string instructions = $"Use a [i:{ItemType()}] or wait for the invasion to occur naturally after the Polterghast is defeated"; + string despawn = CalamityUtils.ColorMessage("The mysterious creatures of the sulphuric sea descended back into the deep ocean.", new Color(146, 183, 116)); + string bossLogTex = "CalamityMod/Events/AcidRainT3_BossChecklist"; + string iconTexture = "CalamityMod/ExtraTextures/UI/AcidRainIcon"; + AddInvasion(bossChecklist, calamity, "Acid Rain (Post-Polter)", order, enemies, DownedBoomerDuke, summons, loot, collection, instructions, despawn, bossLogTex, iconTexture); + } + } + + private static void AddCalamityBossLoot(Mod bossChecklist) + { + // King Slime + AddLoot(bossChecklist, "KingSlime", + new List() { ItemType() }, + new List() { ItemType() } + ); + + // Eye of Cthulhu + AddLoot(bossChecklist, "EyeofCthulhu", + new List() { ItemType(), ItemType() }, + new List() { ItemType() } + ); + + // Eater of Worlds + AddLoot(bossChecklist, "EaterofWorldsHead", + null, + new List() { ItemType(), ItemType() } + ); + + // Brain of Cthulhu + AddLoot(bossChecklist, "BrainofCthulhu", + null, + new List() { ItemType(), ItemType() } + ); + + // Queen Bee + AddLoot(bossChecklist, "QueenBee", + new List() { ItemType(), ItemID.Stinger, ItemType() }, + new List() { ItemType() } + ); + + // Skeletron + AddLoot(bossChecklist, "SkeletronHead", + null, + new List() { ItemType() } + ); + + // Wall of Flesh + AddLoot(bossChecklist, "WallofFlesh", + new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.CorruptionKey, ItemID.CrimsonKey }, + new List() { ItemType(), ItemType(), ItemType() } + ); + + // The Twins + AddLoot(bossChecklist, "TheTwins", + new List() { ItemType() }, + new List() { ItemType(), ItemType() } + ); + + // The Destroyer + AddLoot(bossChecklist, "TheDestroyer", + new List() { ItemType(), ItemType() } + ); + + // Skeletron Prime + AddLoot(bossChecklist, "SkeletronPrime", + null, + new List() { ItemType(), ItemType() } + ); + + // Plantera + AddLoot(bossChecklist, "Plantera", + new List() { ItemType(), ItemType(), ItemType(), ItemID.JungleKey }, + new List() { ItemType() } + ); + AddSummons(bossChecklist, "Plantera", new List() { ItemType() }); + + // Golem + AddLoot(bossChecklist, "Golem", + new List() { ItemType(), ItemType() }, + new List() { ItemType() } + ); + AddSummons(bossChecklist, "Golem", new List() { ItemType() }); + + // Duke Fishron + AddLoot(bossChecklist, "DukeFishron", + new List() { ItemType(), ItemType() }, + new List() { ItemType() } + ); + + // Betsy + AddLoot(bossChecklist, "DD2Betsy", + null, + null + ); + + // Lunatic Cultist + AddLoot(bossChecklist, "CultistBoss", + null, + new List() { ItemType(), ItemType() } + ); + AddSummons(bossChecklist, "CultistBoss", new List() { ItemType() }); + + // Moon Lord + AddLoot(bossChecklist, "MoonLord", + new List() { ItemType(), ItemType() }, + new List() { ItemType() } + ); + } + + private static void AddCalamityEventLoot(Mod bossChecklist) + { + // Blood Moon + AddLoot(bossChecklist, "Blood Moon", + new List() { ItemType(), ItemType() }, + null + ); + AddSummons(bossChecklist, "Blood Moon", new List() { ItemType() }); + + // Goblin Army + AddLoot(bossChecklist, "Goblin Army", + new List() { ItemType(), ItemType(), ItemType(), ItemType() }, + null + ); + + // Pirates + AddLoot(bossChecklist, "Pirate Invasion", + new List() { ItemType(), ItemType() }, + null + ); + + // Solar Eclipse + AddLoot(bossChecklist, "Solar Eclipse", + new List() { ItemType(), ItemType(), ItemType() }, + null + ); + + // Pumpkin Moon + AddLoot(bossChecklist, "Pumpkin Moon", + new List() { ItemType() }, + null + ); + AddLoot(bossChecklist, "Pumpking", + new List() { ItemType() }, + null + ); + + // Frost Moon + AddLoot(bossChecklist, "Frost Moon", + new List() { ItemType() }, + null + ); + AddLoot(bossChecklist, "Ice Queen", + new List() { ItemType() }, + null + ); + + // Martian Madness + AddLoot(bossChecklist, "Martian Madness", + new List() { ItemType(), ItemType(), ItemType() }, + null + ); + AddLoot(bossChecklist, "Martian Saucer", + new List() { ItemType() }, + null + ); + + // Lunar Events + AddLoot(bossChecklist, "Lunar Event", + new List() { ItemType() }, + null + ); + } + + private static void FargosSupport() + { + Mod fargos = GetInstance().fargos; + if (fargos is null) + return; + + void AddToMutantShop(string bossName, string summonItemName, Func downed, int price) + { + BossDifficulty.TryGetValue(bossName, out float order); + fargos.Call("AddSummon", order, "CalamityMod", summonItemName, downed, price); + } + + fargos.Call("AbominationnClearEvents", "CalamityMod", CalamityWorld.rainingAcid, true); + + AddToMutantShop("OldDuke", "BloodwormItem", DownedBoomerDuke, Item.buyPrice(platinum: 2)); + } + + private static void CensusSupport() + { + Mod censusMod = GetInstance().census; + if (censusMod != null) + { + censusMod.Call("TownNPCCondition", NPCType(), "Defeat a Giant Clam after defeating the Desert Scourge"); + censusMod.Call("TownNPCCondition", NPCType(), "Have a [i:" + ItemID.PlatinumCoin + "] in your inventory after defeating Skeletron"); + censusMod.Call("TownNPCCondition", NPCType(), "Have [i:" + ItemType() + "] in your inventory in Hardmode"); + censusMod.Call("TownNPCCondition", NPCType(), "Defeat Cryogen"); + censusMod.Call("TownNPCCondition", NPCType(), "Defeat Supreme Calamitas"); + } + } + + private static void SummonersAssociationSupport() + { + Mod sAssociation = GetInstance().summonersAssociation; + if (sAssociation is null) + return; + + void RegisterSummon(int summonItem, int summonBuff, int summonProjectile) + { + sAssociation.Call("AddMinionInfo", summonItem, summonBuff, summonProjectile); + } + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); + + sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), new List() { ProjectileType(), ProjectileType(), ProjectileType()}, new List() {1-(1f/3f), 2f/3f, 2f/3f}); + //Entropy's Vigil is a bruh moment + sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), new List() { ProjectileType(), ProjectileType()}); + } + } } diff --git a/NPCs/Abyss/Bloatfish.cs b/NPCs/Abyss/Bloatfish.cs index 1bf5de9768..614f190cae 100644 --- a/NPCs/Abyss/Bloatfish.cs +++ b/NPCs/Abyss/Bloatfish.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class Bloatfish : ModNPC + public class Bloatfish : ModNPC { public override void SetStaticDefaults() { @@ -35,11 +35,11 @@ namespace CalamityMod.NPCs.Abyss npc.knockBackResist = 0.9f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { diff --git a/NPCs/Abyss/BobbitWormHead.cs b/NPCs/Abyss/BobbitWormHead.cs index eb430f569a..fd85238eb6 100644 --- a/NPCs/Abyss/BobbitWormHead.cs +++ b/NPCs/Abyss/BobbitWormHead.cs @@ -12,7 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class BobbitWormHead : ModNPC + public class BobbitWormHead : ModNPC { public override void SetStaticDefaults() { @@ -23,13 +23,13 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { npc.lavaImmune = true; - npc.Calamity().canBreakPlayerDefense = true; - npc.aiStyle = -1; + npc.Calamity().canBreakPlayerDefense = true; + npc.aiStyle = -1; npc.damage = 150; npc.width = 80; npc.height = 40; npc.defense = 50; - npc.DR_NERD(0.25f); + npc.DR_NERD(0.25f); npc.lifeMax = 6000; npc.knockBackResist = 0f; aiType = -1; @@ -39,15 +39,15 @@ namespace CalamityMod.NPCs.Abyss npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { - if (!Main.npc[(int)npc.ai[2]].active || (int)npc.ai[2] < 0) + if (!Main.npc[(int)npc.ai[2]].active || (int)npc.ai[2] < 0) { npc.active = false; npc.netUpdate = true; diff --git a/NPCs/Abyss/BobbitWormSegment.cs b/NPCs/Abyss/BobbitWormSegment.cs index b29a1d839f..0292204ae4 100644 --- a/NPCs/Abyss/BobbitWormSegment.cs +++ b/NPCs/Abyss/BobbitWormSegment.cs @@ -31,18 +31,18 @@ namespace CalamityMod.NPCs.Abyss public override void AI() { - if (npc.ai[0] == 0f) - { - for (int i = 0; i < CalamityGlobalNPC.bobbitWormBottom.Length; i++) - { - if (CalamityGlobalNPC.bobbitWormBottom[i] == -1) - { - CalamityGlobalNPC.bobbitWormBottom[i] = npc.whoAmI; - npc.ai[0] = (float)i; - break; - } - } - } + if (npc.ai[0] == 0f) + { + for (int i = 0; i < CalamityGlobalNPC.bobbitWormBottom.Length; i++) + { + if (CalamityGlobalNPC.bobbitWormBottom[i] == -1) + { + CalamityGlobalNPC.bobbitWormBottom[i] = npc.whoAmI; + npc.ai[0] = (float)i; + break; + } + } + } if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -50,9 +50,9 @@ namespace CalamityMod.NPCs.Abyss { npc.ai[1] = 1f; int spawnedNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[spawnedNPC].ai[2] = (float)CalamityGlobalNPC.bobbitWormBottom[(int)npc.ai[0]]; - npc.ai[2] = (float)spawnedNPC; - } + Main.npc[spawnedNPC].ai[2] = (float)CalamityGlobalNPC.bobbitWormBottom[(int)npc.ai[0]]; + npc.ai[2] = (float)spawnedNPC; + } } if (!Main.npc[(int)npc.ai[2]].active || Main.npc[(int)npc.ai[2]].life <= 0) diff --git a/NPCs/Abyss/BoxJellyfish.cs b/NPCs/Abyss/BoxJellyfish.cs index 439bc7e27b..3bbf89540a 100644 --- a/NPCs/Abyss/BoxJellyfish.cs +++ b/NPCs/Abyss/BoxJellyfish.cs @@ -9,7 +9,7 @@ using CalamityMod.Items.Weapons.Magic; namespace CalamityMod.NPCs.Abyss { - public class BoxJellyfish : ModNPC + public class BoxJellyfish : ModNPC { public override void SetStaticDefaults() { @@ -33,11 +33,11 @@ namespace CalamityMod.NPCs.Abyss npc.DeathSound = SoundID.NPCDeath28; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { @@ -215,9 +215,9 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - int abyssShockerChance = Main.expertMode ? 40 : 50; + int abyssShockerChance = Main.expertMode ? 40 : 50; DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedBoss3, abyssShockerChance, 1, 1); - DropHelper.DropItemChance(npc, ItemID.JellyfishNecklace, 0.01f); - } + DropHelper.DropItemChance(npc, ItemID.JellyfishNecklace, 0.01f); + } } } diff --git a/NPCs/Abyss/ChaoticPuffer.cs b/NPCs/Abyss/ChaoticPuffer.cs index 94569d51d7..ea1705047e 100644 --- a/NPCs/Abyss/ChaoticPuffer.cs +++ b/NPCs/Abyss/ChaoticPuffer.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class ChaoticPuffer : ModNPC + public class ChaoticPuffer : ModNPC { public bool puffedUp = false; public bool puffing = false; @@ -40,11 +40,11 @@ namespace CalamityMod.NPCs.Abyss npc.DeathSound = SoundID.NPCDeath28; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { diff --git a/NPCs/Abyss/ColossalSquid.cs b/NPCs/Abyss/ColossalSquid.cs index 5f74c59786..12ad94eb58 100644 --- a/NPCs/Abyss/ColossalSquid.cs +++ b/NPCs/Abyss/ColossalSquid.cs @@ -15,7 +15,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class ColossalSquid : ModNPC + public class ColossalSquid : ModNPC { private bool hasBeenHit = false; diff --git a/NPCs/Abyss/Cuttlefish.cs b/NPCs/Abyss/Cuttlefish.cs index cee73e956b..c031fd7dea 100644 --- a/NPCs/Abyss/Cuttlefish.cs +++ b/NPCs/Abyss/Cuttlefish.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class Cuttlefish : ModNPC + public class Cuttlefish : ModNPC { public override void SetStaticDefaults() { @@ -35,11 +35,11 @@ namespace CalamityMod.NPCs.Abyss npc.knockBackResist = 0.3f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { @@ -58,82 +58,82 @@ namespace CalamityMod.NPCs.Abyss { npc.ai[2] = -16f; } - if (npc.collideX) - { - npc.velocity.X = npc.velocity.X * -1f; - npc.direction *= -1; - } - if (npc.collideY) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = Math.Abs(npc.velocity.Y) * -1f; - npc.directionY = -1; - npc.ai[0] = -1f; - } - else if (npc.velocity.Y < 0f) - { - npc.velocity.Y = Math.Abs(npc.velocity.Y); - npc.directionY = 1; - npc.ai[0] = 1f; - } - } - npc.velocity.X = npc.velocity.X + npc.direction * 0.02f; - npc.rotation = npc.velocity.X * 0.4f; - if (npc.velocity.X < -1f || npc.velocity.X > 1f) - { - npc.velocity.X = npc.velocity.X * 0.95f; - } - if (npc.ai[0] == -1f) - { - npc.velocity.Y = npc.velocity.Y - 0.01f; - if (npc.velocity.Y < -1f) - { - npc.ai[0] = 1f; - } - } - else - { - npc.velocity.Y = npc.velocity.Y + 0.01f; - if (npc.velocity.Y > 1f) - { - npc.ai[0] = -1f; - } - } - int num268 = (int)(npc.position.X + (npc.width / 2)) / 16; - int num269 = (int)(npc.position.Y + (npc.height / 2)) / 16; - if (Main.tile[num268, num269 - 1] == null) - { - Main.tile[num268, num269 - 1] = new Tile(); - } - if (Main.tile[num268, num269 + 1] == null) - { - Main.tile[num268, num269 + 1] = new Tile(); - } - if (Main.tile[num268, num269 + 2] == null) - { - Main.tile[num268, num269 + 2] = new Tile(); - } - if (Main.tile[num268, num269 - 1].liquid > 128) - { - if (Main.tile[num268, num269 + 1].active()) - { - npc.ai[0] = -1f; - } - else if (Main.tile[num268, num269 + 2].active()) - { - npc.ai[0] = -1f; - } - } - else - { - npc.ai[0] = 1f; - } - if (npc.velocity.Y > 1.2 || npc.velocity.Y < -1.2) - { - npc.velocity.Y = npc.velocity.Y * 0.99f; - } - return; + if (npc.collideX) + { + npc.velocity.X = npc.velocity.X * -1f; + npc.direction *= -1; + } + if (npc.collideY) + { + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = Math.Abs(npc.velocity.Y) * -1f; + npc.directionY = -1; + npc.ai[0] = -1f; + } + else if (npc.velocity.Y < 0f) + { + npc.velocity.Y = Math.Abs(npc.velocity.Y); + npc.directionY = 1; + npc.ai[0] = 1f; + } + } + npc.velocity.X = npc.velocity.X + npc.direction * 0.02f; + npc.rotation = npc.velocity.X * 0.4f; + if (npc.velocity.X < -1f || npc.velocity.X > 1f) + { + npc.velocity.X = npc.velocity.X * 0.95f; + } + if (npc.ai[0] == -1f) + { + npc.velocity.Y = npc.velocity.Y - 0.01f; + if (npc.velocity.Y < -1f) + { + npc.ai[0] = 1f; + } + } + else + { + npc.velocity.Y = npc.velocity.Y + 0.01f; + if (npc.velocity.Y > 1f) + { + npc.ai[0] = -1f; + } + } + int num268 = (int)(npc.position.X + (npc.width / 2)) / 16; + int num269 = (int)(npc.position.Y + (npc.height / 2)) / 16; + if (Main.tile[num268, num269 - 1] == null) + { + Main.tile[num268, num269 - 1] = new Tile(); + } + if (Main.tile[num268, num269 + 1] == null) + { + Main.tile[num268, num269 + 1] = new Tile(); + } + if (Main.tile[num268, num269 + 2] == null) + { + Main.tile[num268, num269 + 2] = new Tile(); + } + if (Main.tile[num268, num269 - 1].liquid > 128) + { + if (Main.tile[num268, num269 + 1].active()) + { + npc.ai[0] = -1f; + } + else if (Main.tile[num268, num269 + 2].active()) + { + npc.ai[0] = -1f; + } + } + else + { + npc.ai[0] = 1f; + } + if (npc.velocity.Y > 1.2 || npc.velocity.Y < -1.2) + { + npc.velocity.Y = npc.velocity.Y * 0.99f; + } + return; } if (npc.ai[2] < 0f) { @@ -148,8 +148,8 @@ namespace CalamityMod.NPCs.Abyss npc.ai[2] += 1f; if (npc.ai[2] == 0f) { - npc.ai[0] = 0f; - npc.ai[2] = 1f; + npc.ai[0] = 0f; + npc.ai[2] = 1f; npc.velocity.X = npc.direction * 2; } return; diff --git a/NPCs/Abyss/DevilFish.cs b/NPCs/Abyss/DevilFish.cs index 8c0a73bd36..08ef74869f 100644 --- a/NPCs/Abyss/DevilFish.cs +++ b/NPCs/Abyss/DevilFish.cs @@ -12,7 +12,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class DevilFish : ModNPC + public class DevilFish : ModNPC { public bool brokenMask = false; public int hitCounter = 0; @@ -27,8 +27,8 @@ namespace CalamityMod.NPCs.Abyss { npc.noGravity = true; npc.lavaImmune = true; - npc.Calamity().canBreakPlayerDefense = true; - npc.damage = 90; + npc.Calamity().canBreakPlayerDefense = true; + npc.damage = 90; npc.width = 126; npc.height = 66; npc.defense = 999999; @@ -41,11 +41,11 @@ namespace CalamityMod.NPCs.Abyss npc.knockBackResist = 0.85f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -127,8 +127,8 @@ namespace CalamityMod.NPCs.Abyss npc.TargetClosest(true); npc.velocity.X = npc.velocity.X + (float)npc.direction * (CalamityWorld.death ? 0.5f : 0.25f) * speedBoost; npc.velocity.Y = npc.velocity.Y + (float)npc.directionY * (CalamityWorld.death ? 0.3f : 0.15f) * speedBoost; - float velocity = CalamityWorld.death ? 12f : 6f; - if (npc.velocity.X > velocity * speedBoost) + float velocity = CalamityWorld.death ? 12f : 6f; + if (npc.velocity.X > velocity * speedBoost) { npc.velocity.X = velocity * speedBoost; } diff --git a/NPCs/Abyss/DevilFishAlt.cs b/NPCs/Abyss/DevilFishAlt.cs index 2c2bbd4f37..59a44daf01 100644 --- a/NPCs/Abyss/DevilFishAlt.cs +++ b/NPCs/Abyss/DevilFishAlt.cs @@ -12,7 +12,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class DevilFishAlt : ModNPC + public class DevilFishAlt : ModNPC { public bool brokenMask = false; public int hitCounter = 0; @@ -27,8 +27,8 @@ namespace CalamityMod.NPCs.Abyss { npc.noGravity = true; npc.lavaImmune = true; - npc.Calamity().canBreakPlayerDefense = true; - npc.damage = 90; + npc.Calamity().canBreakPlayerDefense = true; + npc.damage = 90; npc.width = 126; npc.height = 66; npc.defense = 999999; @@ -41,11 +41,11 @@ namespace CalamityMod.NPCs.Abyss npc.knockBackResist = 0.85f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/Abyss/EidolonWyrmBody.cs b/NPCs/Abyss/EidolonWyrmBody.cs index 5511ab5cce..864dd7e138 100644 --- a/NPCs/Abyss/EidolonWyrmBody.cs +++ b/NPCs/Abyss/EidolonWyrmBody.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class EidolonWyrmBody : ModNPC + public class EidolonWyrmBody : ModNPC { public override void SetStaticDefaults() { @@ -47,32 +47,32 @@ namespace CalamityMod.NPCs.Abyss if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/Abyss/EidolonWyrmBodyAlt.cs b/NPCs/Abyss/EidolonWyrmBodyAlt.cs index deab3a80ae..6d4f228fec 100644 --- a/NPCs/Abyss/EidolonWyrmBodyAlt.cs +++ b/NPCs/Abyss/EidolonWyrmBodyAlt.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class EidolonWyrmBodyAlt : ModNPC + public class EidolonWyrmBodyAlt : ModNPC { public override void SetStaticDefaults() { @@ -47,32 +47,32 @@ namespace CalamityMod.NPCs.Abyss if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index 127dd59941..4b4df09588 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -15,9 +15,9 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class EidolonWyrmHead : ModNPC + public class EidolonWyrmHead : ModNPC { - private Vector2 patrolSpot = Vector2.Zero; + private Vector2 patrolSpot = Vector2.Zero; public bool detectsPlayer = false; public const int minLength = 40; public const int maxLength = 41; @@ -32,13 +32,13 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 8f; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 8f; npc.damage = 170; npc.width = 126; //36 npc.height = 76; //20 npc.defense = 70; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 160000; npc.aiStyle = -1; aiType = -1; @@ -53,35 +53,35 @@ namespace CalamityMod.NPCs.Abyss npc.rarity = 2; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { - writer.WriteVector2(patrolSpot); + writer.WriteVector2(patrolSpot); writer.Write(detectsPlayer); writer.Write(npc.chaseable); } public override void ReceiveExtraAI(BinaryReader reader) { - patrolSpot = reader.ReadVector2(); + patrolSpot = reader.ReadVector2(); detectsPlayer = reader.ReadBoolean(); npc.chaseable = reader.ReadBoolean(); } public override void AI() { - bool adultWyrmAlive = false; - if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) - { - if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) - adultWyrmAlive = true; - } - if (npc.justHit || detectsPlayer || Main.player[npc.target].chaosState || adultWyrmAlive) + bool adultWyrmAlive = false; + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) + { + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + adultWyrmAlive = true; + } + if (npc.justHit || detectsPlayer || Main.player[npc.target].chaosState || adultWyrmAlive) { detectsPlayer = true; npc.damage = Main.expertMode ? 340 : 170; @@ -157,7 +157,7 @@ namespace CalamityMod.NPCs.Abyss int damage = adultWyrmAlive ? (Main.expertMode ? 150 : 200) : (Main.expertMode ? 60 : 80); float xPos = Main.rand.NextBool(2) ? npc.position.X + 200f : npc.position.X - 200f; Vector2 vector2 = new Vector2(xPos, npc.position.Y + Main.rand.Next(-200, 201)); - int randomAmt = adultWyrmAlive ? 2 : 3; + int randomAmt = adultWyrmAlive ? 2 : 3; int random = Main.rand.Next(randomAmt); if (random == 0) { @@ -215,24 +215,24 @@ namespace CalamityMod.NPCs.Abyss { npc.spriteDirection = 1; } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); + if (Main.player[npc.target].dead) + { + npc.TargetClosest(false); - npc.velocity.Y += 3f; - if (npc.position.Y > Main.worldSurface * 16.0) - npc.velocity.Y += 3f; + npc.velocity.Y += 3f; + if (npc.position.Y > Main.worldSurface * 16.0) + npc.velocity.Y += 3f; - if (npc.position.Y > (Main.maxTilesY - 200) * 16.0) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - } - npc.alpha -= 42; + if (npc.position.Y > (Main.maxTilesY - 200) * 16.0) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + } + } + npc.alpha -= 42; if (npc.alpha < 0) { npc.alpha = 0; @@ -246,27 +246,27 @@ namespace CalamityMod.NPCs.Abyss float num189 = turnSpeed; Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - if (patrolSpot == Vector2.Zero) - patrolSpot = Main.player[npc.target].Center; + if (patrolSpot == Vector2.Zero) + patrolSpot = Main.player[npc.target].Center; - float num191 = detectsPlayer ? Main.player[npc.target].Center.X : patrolSpot.X; + float num191 = detectsPlayer ? Main.player[npc.target].Center.X : patrolSpot.X; float num192 = detectsPlayer ? Main.player[npc.target].Center.Y : patrolSpot.Y; - if (!detectsPlayer) - { - num192 += 800; - if (Math.Abs(npc.Center.X - num191) < 400f) //500 - { - if (npc.velocity.X > 0f) - { - num191 += 500f; - } - else - { - num191 -= 500f; - } - } - } + if (!detectsPlayer) + { + num192 += 800; + if (Math.Abs(npc.Center.X - num191) < 400f) //500 + { + if (npc.velocity.X > 0f) + { + num191 += 500f; + } + else + { + num191 -= 500f; + } + } + } else { num188 = 7.5f; @@ -276,14 +276,14 @@ namespace CalamityMod.NPCs.Abyss num188 = 15f; num189 = 0.25f; } - if (adultWyrmAlive) - { - if (!Main.player[npc.target].Calamity().ZoneAbyssLayer4) - { - num188 = 22.5f; - num189 = 0.375f; - } - } + if (adultWyrmAlive) + { + if (!Main.player[npc.target].Calamity().ZoneAbyssLayer4) + { + num188 = 22.5f; + num189 = 0.375f; + } + } } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; @@ -410,37 +410,37 @@ namespace CalamityMod.NPCs.Abyss npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - bool adultWyrmAlive = false; - if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) - { - if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) - adultWyrmAlive = true; - } + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + bool adultWyrmAlive = false; + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) + { + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + adultWyrmAlive = true; + } - if (adultWyrmAlive) - cooldownSlot = 1; + if (adultWyrmAlive) + cooldownSlot = 1; - Rectangle targetHitbox = target.Hitbox; + Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= 40f; - } + return minDist <= 40f; + } - public override bool? CanBeHitByProjectile(Projectile projectile) + public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) { @@ -480,24 +480,24 @@ namespace CalamityMod.NPCs.Abyss return 0f; } - public override bool PreNPCLoot() - { - bool adultWyrmAlive = false; - if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) - { - if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) - adultWyrmAlive = true; - } + public override bool PreNPCLoot() + { + bool adultWyrmAlive = false; + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) + { + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + adultWyrmAlive = true; + } - return !adultWyrmAlive; - } + return !adultWyrmAlive; + } - public override void NPCLoot() + public override void NPCLoot() { DropHelper.DropItem(npc, ModContent.ItemType(), 30, 40); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedPolterghast, 3, 1, 1); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedPolterghast, 3, 1, 1); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedPolterghast, 10, 1, 1); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedPolterghast, 10, 1, 1); int minLumenyl = Main.expertMode ? 8 : 6; int maxLumenyl = Main.expertMode ? 11 : 8; DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 1f, minLumenyl, maxLumenyl); diff --git a/NPCs/Abyss/EidolonWyrmTail.cs b/NPCs/Abyss/EidolonWyrmTail.cs index c5c84478da..90f7774c04 100644 --- a/NPCs/Abyss/EidolonWyrmTail.cs +++ b/NPCs/Abyss/EidolonWyrmTail.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class EidolonWyrmTail : ModNPC + public class EidolonWyrmTail : ModNPC { public override void SetStaticDefaults() { @@ -47,32 +47,32 @@ namespace CalamityMod.NPCs.Abyss if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/Abyss/GiantSquid.cs b/NPCs/Abyss/GiantSquid.cs index 3c587490bb..22078eb740 100644 --- a/NPCs/Abyss/GiantSquid.cs +++ b/NPCs/Abyss/GiantSquid.cs @@ -13,7 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class GiantSquid : ModNPC + public class GiantSquid : ModNPC { private bool hasBeenHit = false; @@ -38,11 +38,11 @@ namespace CalamityMod.NPCs.Abyss npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/Abyss/GulperEelBody.cs b/NPCs/Abyss/GulperEelBody.cs index 4b84cdfbd6..4c105a2983 100644 --- a/NPCs/Abyss/GulperEelBody.cs +++ b/NPCs/Abyss/GulperEelBody.cs @@ -36,11 +36,11 @@ namespace CalamityMod.NPCs.Abyss npc.chaseable = false; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -52,32 +52,32 @@ namespace CalamityMod.NPCs.Abyss if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/Abyss/GulperEelBodyAlt.cs b/NPCs/Abyss/GulperEelBodyAlt.cs index f4b14fc831..e1871a5917 100644 --- a/NPCs/Abyss/GulperEelBodyAlt.cs +++ b/NPCs/Abyss/GulperEelBodyAlt.cs @@ -36,11 +36,11 @@ namespace CalamityMod.NPCs.Abyss npc.chaseable = false; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -52,32 +52,32 @@ namespace CalamityMod.NPCs.Abyss if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/Abyss/GulperEelHead.cs b/NPCs/Abyss/GulperEelHead.cs index c4bdeb92f4..5065c136a3 100644 --- a/NPCs/Abyss/GulperEelHead.cs +++ b/NPCs/Abyss/GulperEelHead.cs @@ -12,10 +12,10 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class GulperEelHead : ModNPC + public class GulperEelHead : ModNPC { - private Vector2 patrolSpot = Vector2.Zero; - public bool detectsPlayer = false; + private Vector2 patrolSpot = Vector2.Zero; + public bool detectsPlayer = false; public const int minLength = 20; public const int maxLength = 21; public float speed = 5f; //10 @@ -29,8 +29,8 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.damage = 135; + npc.Calamity().canBreakPlayerDefense = true; + npc.damage = 135; npc.width = 66; //36 npc.height = 86; //20 npc.defense = 10; @@ -47,23 +47,23 @@ namespace CalamityMod.NPCs.Abyss npc.netAlways = true; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { - writer.WriteVector2(patrolSpot); - writer.Write(detectsPlayer); + writer.WriteVector2(patrolSpot); + writer.Write(detectsPlayer); writer.Write(npc.chaseable); } public override void ReceiveExtraAI(BinaryReader reader) { - patrolSpot = reader.ReadVector2(); - detectsPlayer = reader.ReadBoolean(); + patrolSpot = reader.ReadVector2(); + detectsPlayer = reader.ReadBoolean(); npc.chaseable = reader.ReadBoolean(); } @@ -145,32 +145,32 @@ namespace CalamityMod.NPCs.Abyss float num189 = turnSpeed; Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - if (patrolSpot == Vector2.Zero) - patrolSpot = Main.player[npc.target].Center; + if (patrolSpot == Vector2.Zero) + patrolSpot = Main.player[npc.target].Center; - float num191 = detectsPlayer ? Main.player[npc.target].Center.X : patrolSpot.X; - float num192 = detectsPlayer ? Main.player[npc.target].Center.Y : patrolSpot.Y; + float num191 = detectsPlayer ? Main.player[npc.target].Center.X : patrolSpot.X; + float num192 = detectsPlayer ? Main.player[npc.target].Center.Y : patrolSpot.Y; - if (!detectsPlayer) - { - num192 += 500; - if (Math.Abs(npc.Center.X - num191) < 300f) //500 - { - if (npc.velocity.X > 0f) - { - num191 += 400f; - } - else - { - num191 -= 400f; - } - } - } - else - { - num188 *= 1.5f; - num189 *= 1.5f; - } + if (!detectsPlayer) + { + num192 += 500; + if (Math.Abs(npc.Center.X - num191) < 300f) //500 + { + if (npc.velocity.X > 0f) + { + num191 += 400f; + } + else + { + num191 -= 400f; + } + } + } + else + { + num188 *= 1.5f; + num189 *= 1.5f; + } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; float num50 = npc.velocity.Length(); diff --git a/NPCs/Abyss/GulperEelTail.cs b/NPCs/Abyss/GulperEelTail.cs index aae08a232e..4f79d40c22 100644 --- a/NPCs/Abyss/GulperEelTail.cs +++ b/NPCs/Abyss/GulperEelTail.cs @@ -36,11 +36,11 @@ namespace CalamityMod.NPCs.Abyss npc.chaseable = false; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -52,32 +52,32 @@ namespace CalamityMod.NPCs.Abyss if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/Abyss/Laserfish.cs b/NPCs/Abyss/Laserfish.cs index 9cc1339e88..1e5e82ac8b 100644 --- a/NPCs/Abyss/Laserfish.cs +++ b/NPCs/Abyss/Laserfish.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class Laserfish : ModNPC + public class Laserfish : ModNPC { public override void SetStaticDefaults() { @@ -35,11 +35,11 @@ namespace CalamityMod.NPCs.Abyss banner = npc.type; bannerItem = ModContent.ItemType(); npc.chaseable = false; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -53,8 +53,8 @@ namespace CalamityMod.NPCs.Abyss public override void AI() { - // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - npc.damage = 0; + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + npc.damage = 0; CalamityAI.PassiveSwimmingAI(npc, mod, 0, Main.player[npc.target].Calamity().GetAbyssAggro(400f, 200f), 0.15f, 0.15f, 4f, 4f, 0.1f); } diff --git a/NPCs/Abyss/LuminousCorvina.cs b/NPCs/Abyss/LuminousCorvina.cs index a605481c3e..bf70eacf06 100644 --- a/NPCs/Abyss/LuminousCorvina.cs +++ b/NPCs/Abyss/LuminousCorvina.cs @@ -14,7 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class LuminousCorvina : ModNPC + public class LuminousCorvina : ModNPC { private bool hasBeenHit = false; private int screamTimer = 0; @@ -41,11 +41,11 @@ namespace CalamityMod.NPCs.Abyss npc.knockBackResist = 0.85f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -86,7 +86,7 @@ namespace CalamityMod.NPCs.Abyss { ++screamTimer; - int screamLimit = CalamityWorld.death ? 120 : 180; + int screamLimit = CalamityWorld.death ? 120 : 180; if (screamTimer >= screamLimit) { if (screamTimer == screamLimit) @@ -287,7 +287,7 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 8, 15); + DropHelper.DropItem(npc, ModContent.ItemType(), 8, 15); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f); int minCells = Main.expertMode ? 2 : 1; int maxCells = Main.expertMode ? 3 : 2; diff --git a/NPCs/Abyss/MirageJelly.cs b/NPCs/Abyss/MirageJelly.cs index 6317ceb478..b8b9e63e2e 100644 --- a/NPCs/Abyss/MirageJelly.cs +++ b/NPCs/Abyss/MirageJelly.cs @@ -12,7 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class MirageJelly : ModNPC + public class MirageJelly : ModNPC { private bool teleporting = false; private bool rephasing = false; @@ -41,11 +41,11 @@ namespace CalamityMod.NPCs.Abyss npc.DeathSound = SoundID.NPCDeath28; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = false; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = false; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -106,10 +106,10 @@ namespace CalamityMod.NPCs.Abyss else num1250 -= Main.rand.Next(min, max); - min = 11; - max = 26; + min = 11; + max = 26; - num1251 += Main.rand.Next(min, max); + num1251 += Main.rand.Next(min, max); if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2((float)(num1250 * 16), (float)(num1251 * 16)), 1, 1, player.position, player.width, player.height) && Main.tile[num1250, num1251].liquid > 204) @@ -210,7 +210,7 @@ namespace CalamityMod.NPCs.Abyss DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 5 : 7); DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 5 : 7); DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 5 : 7); - DropHelper.DropItemChance(npc, ItemID.JellyfishNecklace, 0.01f); + DropHelper.DropItemChance(npc, ItemID.JellyfishNecklace, 0.01f); } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/Abyss/MorayEel.cs b/NPCs/Abyss/MorayEel.cs index 7ad3442a94..4ef95b4280 100644 --- a/NPCs/Abyss/MorayEel.cs +++ b/NPCs/Abyss/MorayEel.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class MorayEel : ModNPC + public class MorayEel : ModNPC { public override void SetStaticDefaults() { @@ -32,11 +32,11 @@ namespace CalamityMod.NPCs.Abyss banner = npc.type; bannerItem = ModContent.ItemType(); npc.chaseable = false; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/Abyss/OarfishBody.cs b/NPCs/Abyss/OarfishBody.cs index 823219e086..eda28aefba 100644 --- a/NPCs/Abyss/OarfishBody.cs +++ b/NPCs/Abyss/OarfishBody.cs @@ -34,11 +34,11 @@ namespace CalamityMod.NPCs.Abyss npc.chaseable = false; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -50,32 +50,32 @@ namespace CalamityMod.NPCs.Abyss if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index cfb05d13c9..e1ea3cbbe9 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -13,9 +13,9 @@ namespace CalamityMod.NPCs.Abyss { public class OarfishHead : ModNPC { - private Vector2 patrolSpot = Vector2.Zero; - public bool detectsPlayer = false; - public const int minLength = 40; + private Vector2 patrolSpot = Vector2.Zero; + public bool detectsPlayer = false; + public const int minLength = 40; public const int maxLength = 41; public float speed = 3f; //10 public float turnSpeed = 0.05f; //0.15 @@ -45,34 +45,34 @@ namespace CalamityMod.NPCs.Abyss npc.netAlways = true; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.WriteVector2(patrolSpot); - writer.Write(detectsPlayer); - writer.Write(npc.chaseable); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - patrolSpot = reader.ReadVector2(); - detectsPlayer = reader.ReadBoolean(); - npc.chaseable = reader.ReadBoolean(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - if ((Main.player[npc.target].Center - npc.Center).Length() < Main.player[npc.target].Calamity().GetAbyssAggro(250f, 150f) || npc.justHit) - detectsPlayer = true; + writer.WriteVector2(patrolSpot); + writer.Write(detectsPlayer); + writer.Write(npc.chaseable); + } - npc.chaseable = detectsPlayer; + public override void ReceiveExtraAI(BinaryReader reader) + { + patrolSpot = reader.ReadVector2(); + detectsPlayer = reader.ReadBoolean(); + npc.chaseable = reader.ReadBoolean(); + } - if (npc.ai[2] > 0f) + public override void AI() + { + if ((Main.player[npc.target].Center - npc.Center).Length() < Main.player[npc.target].Calamity().GetAbyssAggro(250f, 150f) || npc.justHit) + detectsPlayer = true; + + npc.chaseable = detectsPlayer; + + if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) @@ -124,32 +124,32 @@ namespace CalamityMod.NPCs.Abyss float num189 = turnSpeed; Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - if (patrolSpot == Vector2.Zero) - patrolSpot = Main.player[npc.target].Center; + if (patrolSpot == Vector2.Zero) + patrolSpot = Main.player[npc.target].Center; - float num191 = detectsPlayer ? Main.player[npc.target].Center.X : patrolSpot.X; - float num192 = detectsPlayer ? Main.player[npc.target].Center.Y : patrolSpot.Y; + float num191 = detectsPlayer ? Main.player[npc.target].Center.X : patrolSpot.X; + float num192 = detectsPlayer ? Main.player[npc.target].Center.Y : patrolSpot.Y; - if (!detectsPlayer) + if (!detectsPlayer) { - num192 += 300; - if (Math.Abs(npc.Center.X - num191) < 250f) //500 - { - if (npc.velocity.X > 0f) - { - num191 += 300f; - } - else - { - num191 -= 300f; - } - } + num192 += 300; + if (Math.Abs(npc.Center.X - num191) < 250f) //500 + { + if (npc.velocity.X > 0f) + { + num191 += 300f; + } + else + { + num191 -= 300f; + } + } + } + else + { + num188 *= 1.5f; + num189 *= 1.5f; } - else - { - num188 *= 1.5f; - num189 *= 1.5f; - } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; float num50 = npc.velocity.Length(); @@ -275,16 +275,16 @@ namespace CalamityMod.NPCs.Abyss npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; } - public override bool? CanBeHitByProjectile(Projectile projectile) - { - if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) - { - return detectsPlayer; - } - return null; - } + public override bool? CanBeHitByProjectile(Projectile projectile) + { + if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) + { + return detectsPlayer; + } + return null; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (spawnInfo.player.Calamity().ZoneAbyssLayer2 && spawnInfo.water && !NPC.AnyNPCs(ModContent.NPCType())) { @@ -321,7 +321,7 @@ namespace CalamityMod.NPCs.Abyss public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(ModContent.BuffType(), 90); + player.AddBuff(ModContent.BuffType(), 90); } } } diff --git a/NPCs/Abyss/OarfishTail.cs b/NPCs/Abyss/OarfishTail.cs index 9074126bfe..d56c8cdc1b 100644 --- a/NPCs/Abyss/OarfishTail.cs +++ b/NPCs/Abyss/OarfishTail.cs @@ -34,11 +34,11 @@ namespace CalamityMod.NPCs.Abyss npc.chaseable = false; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -50,32 +50,32 @@ namespace CalamityMod.NPCs.Abyss if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/Abyss/Reaper.cs b/NPCs/Abyss/Reaper.cs index 6feb7670d4..03ed832b26 100644 --- a/NPCs/Abyss/Reaper.cs +++ b/NPCs/Abyss/Reaper.cs @@ -14,7 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class Reaper : ModNPC + public class Reaper : ModNPC { public bool hasBeenHit = false; public bool reset = false; diff --git a/NPCs/Abyss/ToxicMinnow.cs b/NPCs/Abyss/ToxicMinnow.cs index 7fe13109fe..52fe87219e 100644 --- a/NPCs/Abyss/ToxicMinnow.cs +++ b/NPCs/Abyss/ToxicMinnow.cs @@ -12,7 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class ToxicMinnow : ModNPC + public class ToxicMinnow : ModNPC { public override void SetStaticDefaults() { @@ -37,11 +37,11 @@ namespace CalamityMod.NPCs.Abyss banner = npc.type; bannerItem = ModContent.ItemType(); npc.chaseable = false; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -55,7 +55,7 @@ namespace CalamityMod.NPCs.Abyss public override void AI() { - CalamityAI.PassiveSwimmingAI(npc, mod, 2, 0f, 0f, 0f, 0f, 0f, 0.1f); + CalamityAI.PassiveSwimmingAI(npc, mod, 2, 0f, 0f, 0f, 0f, 0f, 0.1f); } public override bool? CanBeHitByProjectile(Projectile projectile) diff --git a/NPCs/Abyss/Viperfish.cs b/NPCs/Abyss/Viperfish.cs index d6aeea6c23..dd8e5e419a 100644 --- a/NPCs/Abyss/Viperfish.cs +++ b/NPCs/Abyss/Viperfish.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class Viperfish : ModNPC + public class Viperfish : ModNPC { public override void SetStaticDefaults() { @@ -36,11 +36,11 @@ namespace CalamityMod.NPCs.Abyss banner = npc.type; bannerItem = ModContent.ItemType(); npc.chaseable = false; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/AcidRain/BloodwormFleeing.cs b/NPCs/AcidRain/BloodwormFleeing.cs index 0421bac8d6..04cce37700 100644 --- a/NPCs/AcidRain/BloodwormFleeing.cs +++ b/NPCs/AcidRain/BloodwormFleeing.cs @@ -42,7 +42,7 @@ namespace CalamityMod.NPCs.AcidRain // But always dig downward. npc.velocity.Y = Math.Abs(npc.velocity.Y); npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; - } + } public override void FindFrame(int frameHeight) { diff --git a/NPCs/AcidRain/BloodwormNormal.cs b/NPCs/AcidRain/BloodwormNormal.cs index 1bcaa5f906..8cb9c19eb6 100644 --- a/NPCs/AcidRain/BloodwormNormal.cs +++ b/NPCs/AcidRain/BloodwormNormal.cs @@ -31,12 +31,12 @@ namespace CalamityMod.NPCs.AcidRain npc.DeathSound = SoundID.NPCDeath1; npc.catchItem = (short)ModContent.ItemType(); npc.dontTakeDamageFromHostiles = true; - npc.rarity = 4; + npc.rarity = 4; } public override void AI() { - if (npc.collideY) + if (npc.collideY) { if (npc.ai[0] == 0f) { @@ -51,29 +51,29 @@ namespace CalamityMod.NPCs.AcidRain float xSpeed = 3f; npc.velocity.X = xSpeed * npc.ai[0]; npc.spriteDirection = (int)npc.ai[0]; - bool flee = false; - for (int i = 0; i < Main.player.Length; i++) - { - Player player = Main.player[i]; - if (player.active && !player.dead && Vector2.Distance(player.Center, npc.Center) <= 220f) - { - flee = true; - break; - } - } - int timeBeforeFlee = 60; - if (flee && npc.ai[1] < timeBeforeFlee) - { - npc.ai[1] += 1f; - } - if (npc.ai[1] == timeBeforeFlee && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.position.Y += 16f; - npc.Transform(ModContent.NPCType()); - npc.netUpdate = true; - return; - } - } + bool flee = false; + for (int i = 0; i < Main.player.Length; i++) + { + Player player = Main.player[i]; + if (player.active && !player.dead && Vector2.Distance(player.Center, npc.Center) <= 220f) + { + flee = true; + break; + } + } + int timeBeforeFlee = 60; + if (flee && npc.ai[1] < timeBeforeFlee) + { + npc.ai[1] += 1f; + } + if (npc.ai[1] == timeBeforeFlee && Main.netMode != NetmodeID.MultiplayerClient) + { + npc.position.Y += 16f; + npc.Transform(ModContent.NPCType()); + npc.netUpdate = true; + return; + } + } public override void FindFrame(int frameHeight) { @@ -99,16 +99,16 @@ namespace CalamityMod.NPCs.AcidRain public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (!spawnInfo.player.Calamity().ZoneSulphur || CalamityWorld.rainingAcid) - return 0f; + if (!spawnInfo.player.Calamity().ZoneSulphur || CalamityWorld.rainingAcid) + return 0f; - // Increase bloodworm spawn rate relative to the number of existing bloodworms, parabolic multiplier ranging from 5x spawn rate with 0 blood worms to 1x with 5 or more - int bloodwormAmt = NPC.CountNPCS(npc.type); - float spawnMult = bloodwormAmt > 5 ? 1f : (float)(0.16 * Math.Pow(5 - bloodwormAmt, 2)) + 1f; - float baseSpawnRate = CalamityWorld.encounteredOldDuke ? 2.569f : 5.138f; - float spawnRate = SpawnCondition.WormCritter.Chance * baseSpawnRate * spawnMult; + // Increase bloodworm spawn rate relative to the number of existing bloodworms, parabolic multiplier ranging from 5x spawn rate with 0 blood worms to 1x with 5 or more + int bloodwormAmt = NPC.CountNPCS(npc.type); + float spawnMult = bloodwormAmt > 5 ? 1f : (float)(0.16 * Math.Pow(5 - bloodwormAmt, 2)) + 1f; + float baseSpawnRate = CalamityWorld.encounteredOldDuke ? 2.569f : 5.138f; + float spawnRate = SpawnCondition.WormCritter.Chance * baseSpawnRate * spawnMult; - return spawnRate; + return spawnRate; } public override void OnCatchNPC(Player player, Item item) diff --git a/NPCs/AcidRain/FlakBaby.cs b/NPCs/AcidRain/FlakBaby.cs index bfbeb4f625..25a5819d83 100644 --- a/NPCs/AcidRain/FlakBaby.cs +++ b/NPCs/AcidRain/FlakBaby.cs @@ -10,7 +10,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.AcidRain { - public class FlakBaby : ModNPC + public class FlakBaby : ModNPC { public override void SetStaticDefaults() { @@ -44,25 +44,25 @@ namespace CalamityMod.NPCs.AcidRain { if (npc.localAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.rand.NextBool(20)) - npc.catchItem = (short)ModContent.ItemType(); + if (Main.rand.NextBool(20)) + npc.catchItem = (short)ModContent.ItemType(); npc.localAI[0] = 1f; npc.velocity.Y = -3f; npc.netUpdate = true; } if (Main.rand.NextBool(8) && npc.catchItem == (short)ModContent.ItemType()) - { - int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, (int)CalamityDusts.SulfurousSeaAcid, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 200, default, 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.1f; - Main.dust[dust].velocity.Y += 0.25f; - Main.dust[dust].noLight = true; - if (Main.rand.NextBool(2)) - { - Main.dust[dust].noGravity = false; - Main.dust[dust].scale *= 0.5f; - } - } + { + int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, (int)CalamityDusts.SulfurousSeaAcid, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 200, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.1f; + Main.dust[dust].velocity.Y += 0.25f; + Main.dust[dust].noLight = true; + if (Main.rand.NextBool(2)) + { + Main.dust[dust].noGravity = false; + Main.dust[dust].scale *= 0.5f; + } + } Player closest = Main.player[Player.FindClosest(npc.Top, 0, 0)]; if (Math.Abs(closest.Center.X - npc.Center.X) > 600f) { diff --git a/NPCs/AcidRain/FlakCrab.cs b/NPCs/AcidRain/FlakCrab.cs index c056d28704..f7eab0d95d 100644 --- a/NPCs/AcidRain/FlakCrab.cs +++ b/NPCs/AcidRain/FlakCrab.cs @@ -42,7 +42,7 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { npc.lifeMax = 4125; - npc.DR_NERD(0.2f); + npc.DR_NERD(0.2f); } npc.knockBackResist = 0f; @@ -54,11 +54,11 @@ namespace CalamityMod.NPCs.AcidRain npc.DeathSound = SoundID.DD2_WitherBeastDeath; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -74,8 +74,8 @@ namespace CalamityMod.NPCs.AcidRain public override void AI() { - // Enables expert scaling, if damage is 0 in set defaults expert scaling will not happen. - npc.damage = 0; + // Enables expert scaling, if damage is 0 in set defaults expert scaling will not happen. + npc.damage = 0; ChasabilityTimer++; npc.defense = TotalHits < TotalHitsNeededToDoDamage ? 999999 : 20; @@ -170,7 +170,7 @@ namespace CalamityMod.NPCs.AcidRain public override void NPCLoot() { DropHelper.DropItemChance(npc, ModContent.ItemType(), 3 * (CalamityWorld.downedPolterghast ? 5 : 1), 1, 3); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.05f); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.05f); } public override void FindFrame(int frameHeight) diff --git a/NPCs/AcidRain/GammaSlime.cs b/NPCs/AcidRain/GammaSlime.cs index 8976949f8c..7517105795 100644 --- a/NPCs/AcidRain/GammaSlime.cs +++ b/NPCs/AcidRain/GammaSlime.cs @@ -34,14 +34,14 @@ namespace CalamityMod.NPCs.AcidRain npc.width = 40; npc.height = 44; - npc.damage = 110; - npc.lifeMax = 5060; - npc.DR_NERD(0.15f); - npc.defense = 25; + npc.damage = 110; + npc.lifeMax = 5060; + npc.DR_NERD(0.15f); + npc.defense = 25; npc.aiStyle = aiType = -1; - npc.knockBackResist = 0f; + npc.knockBackResist = 0f; animationType = NPCID.CorruptSlime; npc.value = Item.buyPrice(0, 0, 8, 30); npc.alpha = 50; @@ -52,11 +52,11 @@ namespace CalamityMod.NPCs.AcidRain npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { diff --git a/NPCs/AcidRain/IrradiatedSlime.cs b/NPCs/AcidRain/IrradiatedSlime.cs index 1bfb568011..9634a3bcd0 100644 --- a/NPCs/AcidRain/IrradiatedSlime.cs +++ b/NPCs/AcidRain/IrradiatedSlime.cs @@ -31,7 +31,7 @@ namespace CalamityMod.NPCs.AcidRain npc.knockBackResist = 0f; animationType = NPCID.CorruptSlime; - aiType = NPCID.ToxicSludge; + aiType = NPCID.ToxicSludge; npc.value = Item.buyPrice(0, 0, 5, 0); npc.alpha = 50; npc.lavaImmune = false; @@ -41,11 +41,11 @@ namespace CalamityMod.NPCs.AcidRain npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -62,13 +62,13 @@ namespace CalamityMod.NPCs.AcidRain public override void AI() { Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.6f, 0.8f, 0.6f); - if (Falling) - { + if (Falling) + { npc.TargetClosest(false); Player player = Main.player[npc.target]; - npc.aiStyle = aiType = -1; + npc.aiStyle = aiType = -1; - npc.noTileCollide = npc.noGravity = true; + npc.noTileCollide = npc.noGravity = true; if (player.Top.Y < npc.Bottom.Y) { npc.noTileCollide = npc.noGravity = false; @@ -79,11 +79,11 @@ namespace CalamityMod.NPCs.AcidRain { npc.velocity = Vector2.UnitY * 6f; } - } - else - { - npc.aiStyle = 1; - } + } + else + { + npc.aiStyle = 1; + } } public override void HitEffect(int hitDirection, double damage) @@ -103,12 +103,12 @@ namespace CalamityMod.NPCs.AcidRain } } - public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) - { - CalamityGlobalNPC.DrawGlowmask(npc, spriteBatch, ModContent.GetTexture(Texture + "Glow")); - } + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + CalamityGlobalNPC.DrawGlowmask(npc, spriteBatch, ModContent.GetTexture(Texture + "Glow")); + } - public override void NPCLoot() + public override void NPCLoot() { DropHelper.DropItemChance(npc, ModContent.ItemType(), 30); } diff --git a/NPCs/AcidRain/NuclearTerror.cs b/NPCs/AcidRain/NuclearTerror.cs index 145a941b1c..879ff0793a 100644 --- a/NPCs/AcidRain/NuclearTerror.cs +++ b/NPCs/AcidRain/NuclearTerror.cs @@ -16,11 +16,11 @@ namespace CalamityMod.NPCs.AcidRain public class NuclearTerror : ModNPC { public enum SpecialAttackState - { + { DivergingBullets, ConeStreamOfBullets, ShotgunBurstOfBullets - } + } public int AttackIndex = 0; public int DelayTime = 0; @@ -32,13 +32,13 @@ namespace CalamityMod.NPCs.AcidRain public ref float AttackTime => ref npc.ai[0]; public ref float TeleportCountdown => ref npc.ai[1]; public Vector2 TeleportLocation - { + { get => new Vector2(npc.ai[2], npc.ai[3]); - set - { + set + { npc.ai[2] = value.X; npc.ai[3] = value.Y; - } + } } public ref float HorizontalCollisionCounterDelay => ref npc.localAI[0]; public ref float HorizontalCollisionSpamCounter => ref npc.localAI[1]; @@ -77,9 +77,9 @@ namespace CalamityMod.NPCs.AcidRain public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; + npc.Calamity().canBreakPlayerDefense = true; - npc.width = 176; + npc.width = 176; npc.height = 138; npc.aiStyle = aiType = -1; @@ -88,17 +88,17 @@ namespace CalamityMod.NPCs.AcidRain npc.damage = 135; npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 20, 0, 0); - npc.DR_NERD(0.3f); + npc.DR_NERD(0.3f); npc.lavaImmune = false; npc.noGravity = false; npc.noTileCollide = false; npc.HitSound = SoundID.NPCHit56; npc.DeathSound = SoundID.NPCDeath60; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(npc.dontTakeDamage); @@ -352,7 +352,7 @@ namespace CalamityMod.NPCs.AcidRain } public void PerformSpecialAttack(float wrappedAttackTime) - { + { Vector2 mouthPosition = npc.Center - Vector2.UnitY * 26f; mouthPosition.X += npc.spriteDirection * -54f; diff --git a/NPCs/AcidRain/Orthocera.cs b/NPCs/AcidRain/Orthocera.cs index c14b055d41..e1b810329a 100644 --- a/NPCs/AcidRain/Orthocera.cs +++ b/NPCs/AcidRain/Orthocera.cs @@ -19,15 +19,15 @@ namespace CalamityMod.NPCs.AcidRain public ref float Time => ref npc.ai[1]; public ref float HorizontalSpeed => ref npc.ai[2]; public bool PerformingJump - { + { get => npc.ai[3] == 1f; - set - { + set + { if (Main.netMode == NetmodeID.Server && value != PerformingJump) npc.netUpdate = true; npc.ai[3] = value.ToInt(); - } - } + } + } public override void SetStaticDefaults() { DisplayName.SetDefault("Orthocera"); @@ -43,14 +43,14 @@ namespace CalamityMod.NPCs.AcidRain npc.damage = 45; npc.lifeMax = 280; npc.defense = 15; - npc.DR_NERD(0.075f); + npc.DR_NERD(0.075f); if (CalamityWorld.downedPolterghast) { npc.damage = 120; npc.lifeMax = 3850; npc.defense = 35; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); } npc.knockBackResist = 0.6f; @@ -62,11 +62,11 @@ namespace CalamityMod.NPCs.AcidRain npc.DeathSound = SoundID.NPCDeath13; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { diff --git a/NPCs/AcidRain/Radiator.cs b/NPCs/AcidRain/Radiator.cs index 28c4172f15..9d7717b6d9 100644 --- a/NPCs/AcidRain/Radiator.cs +++ b/NPCs/AcidRain/Radiator.cs @@ -10,7 +10,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.NPCs.AcidRain { - public class Radiator : ModNPC + public class Radiator : ModNPC { public override void SetStaticDefaults() { @@ -47,32 +47,32 @@ namespace CalamityMod.NPCs.AcidRain npc.noTileCollide = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - aiType = NPCID.GlowingSnail; + aiType = NPCID.GlowingSnail; banner = npc.type; bannerItem = ModContent.ItemType(); npc.catchItem = (short)ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() - { + { Lighting.AddLight(npc.Center, 0.3f, 1.5f, 0.3f); int auraSize = 200; //roughly 12 blocks (half the size of Wither Beast aura) - Player player = Main.player[Main.myPlayer]; - if (!player.dead && player.active && (double) (player.Center - npc.Center).Length() < auraSize) - { - player.AddBuff(ModContent.BuffType(), 3, false); - player.AddBuff(BuffID.Poisoned, 2, false); - if (CalamityWorld.downedPolterghast) - { - player.AddBuff(ModContent.BuffType(), 3, false); - player.AddBuff(BuffID.Venom, 2, false); - } - } + Player player = Main.player[Main.myPlayer]; + if (!player.dead && player.active && (double) (player.Center - npc.Center).Length() < auraSize) + { + player.AddBuff(ModContent.BuffType(), 3, false); + player.AddBuff(BuffID.Poisoned, 2, false); + if (CalamityWorld.downedPolterghast) + { + player.AddBuff(ModContent.BuffType(), 3, false); + player.AddBuff(BuffID.Venom, 2, false); + } + } } public override void FindFrame(int frameHeight) diff --git a/NPCs/AcidRain/Skyfin.cs b/NPCs/AcidRain/Skyfin.cs index b3def5a406..6b375afb14 100644 --- a/NPCs/AcidRain/Skyfin.cs +++ b/NPCs/AcidRain/Skyfin.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AcidRain { - public class Skyfin : ModNPC + public class Skyfin : ModNPC { public ref float AttackState => ref npc.ai[0]; public ref float AttackTimer => ref npc.ai[1]; @@ -57,11 +57,11 @@ namespace CalamityMod.NPCs.AcidRain npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { diff --git a/NPCs/AcidRain/SulfurousSkater.cs b/NPCs/AcidRain/SulfurousSkater.cs index 5a0b5f4817..6f6dfe5763 100644 --- a/NPCs/AcidRain/SulfurousSkater.cs +++ b/NPCs/AcidRain/SulfurousSkater.cs @@ -60,11 +60,11 @@ namespace CalamityMod.NPCs.AcidRain bannerItem = ModContent.ItemType(); npc.aiStyle = aiType = -1; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { diff --git a/NPCs/AcidRain/Trilobite.cs b/NPCs/AcidRain/Trilobite.cs index e1d561be05..2eca32d08d 100644 --- a/NPCs/AcidRain/Trilobite.cs +++ b/NPCs/AcidRain/Trilobite.cs @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.AcidRain npc.damage = 45; npc.lifeMax = 300; npc.defense = 15; - npc.DR_NERD(0.25f); + npc.DR_NERD(0.25f); if (CalamityWorld.downedPolterghast) { @@ -53,11 +53,11 @@ namespace CalamityMod.NPCs.AcidRain npc.DeathSound = SoundID.NPCDeath27; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { diff --git a/NPCs/AcidRain/WaterLeech.cs b/NPCs/AcidRain/WaterLeech.cs index 14773e5557..a84ffd8dbf 100644 --- a/NPCs/AcidRain/WaterLeech.cs +++ b/NPCs/AcidRain/WaterLeech.cs @@ -15,10 +15,10 @@ namespace CalamityMod.NPCs.AcidRain { public Player Target => Main.player[npc.target]; public bool LatchingOntoTarget - { + { get => npc.ai[0] == 1f; set => npc.ai[0] = value.ToInt(); - } + } public ref float LackOfWaterDeathTimer => ref npc.ai[2]; public const float ChasePromptDistance = 55f; public const float ChaseMaxDistance = 140f; @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.AcidRain npc.height = 14; npc.lifeMax = 30; - npc.damage = 0; + npc.damage = 0; if (CalamityWorld.downedPolterghast) { @@ -53,11 +53,11 @@ namespace CalamityMod.NPCs.AcidRain npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) => writer.Write(npc.dontTakeDamage); @@ -147,7 +147,7 @@ namespace CalamityMod.NPCs.AcidRain } public void LatchOntoTarget() - { + { if (Main.netMode != NetmodeID.MultiplayerClient && npc.dontTakeDamage) { npc.dontTakeDamage = false; @@ -208,7 +208,7 @@ namespace CalamityMod.NPCs.AcidRain public override void NPCLoot() { - float dropChance = CalamityWorld.downedAquaticScourge ? 0.01f : 0.05f; + float dropChance = CalamityWorld.downedAquaticScourge ? 0.01f : 0.05f; DropHelper.DropItemChance(npc, ModContent.ItemType(), dropChance); } } diff --git a/NPCs/AdultEidolonWyrm/AEWSky.cs b/NPCs/AdultEidolonWyrm/AEWSky.cs index aadf37d301..c8cc1ea07c 100644 --- a/NPCs/AdultEidolonWyrm/AEWSky.cs +++ b/NPCs/AdultEidolonWyrm/AEWSky.cs @@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm if (AEWIndex != -1) x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[AEWIndex].Center); - return 1f - Utils.SmoothStep(3000f, 6000f, x); + return 1f - Utils.SmoothStep(3000f, 6000f, x); } return 0f; } diff --git a/NPCs/AdultEidolonWyrm/EidolonWyrmBodyAltHuge.cs b/NPCs/AdultEidolonWyrm/EidolonWyrmBodyAltHuge.cs index 5e3354cfb3..6e7b4a4d3a 100644 --- a/NPCs/AdultEidolonWyrm/EidolonWyrmBodyAltHuge.cs +++ b/NPCs/AdultEidolonWyrm/EidolonWyrmBodyAltHuge.cs @@ -22,13 +22,13 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm npc.width = 60; npc.height = 88; npc.defense = 0; - npc.LifeMaxNERB(2415000, 2898000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.LifeMaxNERB(2415000, 2898000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; - npc.Opacity = 0f; + npc.Opacity = 0f; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; @@ -40,105 +40,105 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm npc.chaseable = false; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.localAI[0]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.localAI[0]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.localAI[0] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.localAI[0] = reader.ReadSingle(); + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { npc.damage = 0; - // Difficulty modes - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death; - bool revenge = CalamityWorld.revenge; - bool expertMode = Main.expertMode; + // Difficulty modes + bool malice = CalamityWorld.malice; + bool death = CalamityWorld.death; + bool revenge = CalamityWorld.revenge; + bool expertMode = Main.expertMode; - if (npc.ai[2] > 0f) + if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; - float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; + float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; + float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; - bool invisiblePartOfChargePhase = calamityGlobalNPC_Head.newAI[2] >= chargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= chargePhaseGateValue + 1f && (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeOne || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeTwo || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FastCharge); - bool invisiblePartOfLightningChargePhase = calamityGlobalNPC_Head.newAI[2] >= lightningChargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= lightningChargePhaseGateValue + 1f && calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.LightningCharge; - bool invisiblePhase = calamityGlobalNPC_Head.newAI[0] == 1f || calamityGlobalNPC_Head.newAI[0] == 5f || calamityGlobalNPC_Head.newAI[0] == 7f; - if (!invisiblePartOfChargePhase && !invisiblePartOfLightningChargePhase && !invisiblePhase) - { - if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - } - else - { - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } + bool invisiblePartOfChargePhase = calamityGlobalNPC_Head.newAI[2] >= chargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= chargePhaseGateValue + 1f && (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeOne || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeTwo || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FastCharge); + bool invisiblePartOfLightningChargePhase = calamityGlobalNPC_Head.newAI[2] >= lightningChargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= lightningChargePhaseGateValue + 1f && calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.LightningCharge; + bool invisiblePhase = calamityGlobalNPC_Head.newAI[0] == 1f || calamityGlobalNPC_Head.newAI[0] == 5f || calamityGlobalNPC_Head.newAI[0] == 7f; + if (!invisiblePartOfChargePhase && !invisiblePartOfLightningChargePhase && !invisiblePhase) + { + if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } - bool shootShadowFireballs = (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ShadowFireballSpin && calamityGlobalNPC_Head.newAI[2] > 0f) || - (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FinalPhase && calamityGlobalNPC_Head.newAI[1] > 0f); - if (shootShadowFireballs && Main.netMode != NetmodeID.MultiplayerClient) - { - if (Vector2.Distance(npc.Center, Main.player[Main.npc[(int)npc.ai[2]].target].Center) > 160f) - { - npc.localAI[0] += 1f; - float shootShadowFireballGateValue = malice ? 60f : death ? 70f : revenge ? 75f : expertMode ? 80f : 90f; - float divisor = 2f; - if (npc.ai[3] % divisor == 0f && npc.localAI[0] >= shootShadowFireballGateValue) - { - npc.localAI[0] = 0f; - float distanceVelocityBoost = MathHelper.Clamp((Vector2.Distance(Main.npc[(int)npc.ai[2]].Center, Main.player[Main.npc[(int)npc.ai[2]].target].Center) - 1600f) * 0.025f, 0f, 16f); - float fireballVelocity = (Main.player[Main.npc[(int)npc.ai[2]].target].Calamity().ZoneAbyssLayer4 ? 6f : 8f) + distanceVelocityBoost; - Vector2 destination = Main.player[Main.npc[(int)npc.ai[2]].target].Center - npc.Center; - Vector2 velocity = Vector2.Normalize(destination) * fireballVelocity; - int type = ProjectileID.CultistBossFireBallClone; - int damage = npc.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(npc.Center, velocity, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].tileCollide = false; - } - } - } + bool shootShadowFireballs = (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ShadowFireballSpin && calamityGlobalNPC_Head.newAI[2] > 0f) || + (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FinalPhase && calamityGlobalNPC_Head.newAI[1] > 0f); + if (shootShadowFireballs && Main.netMode != NetmodeID.MultiplayerClient) + { + if (Vector2.Distance(npc.Center, Main.player[Main.npc[(int)npc.ai[2]].target].Center) > 160f) + { + npc.localAI[0] += 1f; + float shootShadowFireballGateValue = malice ? 60f : death ? 70f : revenge ? 75f : expertMode ? 80f : 90f; + float divisor = 2f; + if (npc.ai[3] % divisor == 0f && npc.localAI[0] >= shootShadowFireballGateValue) + { + npc.localAI[0] = 0f; + float distanceVelocityBoost = MathHelper.Clamp((Vector2.Distance(Main.npc[(int)npc.ai[2]].Center, Main.player[Main.npc[(int)npc.ai[2]].target].Center) - 1600f) * 0.025f, 0f, 16f); + float fireballVelocity = (Main.player[Main.npc[(int)npc.ai[2]].target].Calamity().ZoneAbyssLayer4 ? 6f : 8f) + distanceVelocityBoost; + Vector2 destination = Main.player[Main.npc[(int)npc.ai[2]].target].Center - npc.Center; + Vector2 velocity = Vector2.Normalize(destination) * fireballVelocity; + int type = ProjectileID.CultistBossFireBallClone; + int damage = npc.GetProjectileDamage(type); + int proj = Projectile.NewProjectile(npc.Center, velocity, type, damage, 0f, Main.myPlayer); + Main.projectile[proj].tileCollide = false; + } + } + } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); num191 = (int)(num191 / 16f) * 16; @@ -189,9 +189,9 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm new Microsoft.Xna.Framework.Rectangle?(npc.frame), Color.White, npc.rotation, vector11, 1f, spriteEffects, 0f); } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/AdultEidolonWyrm/EidolonWyrmBodyHuge.cs b/NPCs/AdultEidolonWyrm/EidolonWyrmBodyHuge.cs index 0a9f129d8f..36d3549680 100644 --- a/NPCs/AdultEidolonWyrm/EidolonWyrmBodyHuge.cs +++ b/NPCs/AdultEidolonWyrm/EidolonWyrmBodyHuge.cs @@ -22,10 +22,10 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm npc.width = 60; npc.height = 88; npc.defense = 0; - npc.LifeMaxNERB(2415000, 2898000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.LifeMaxNERB(2415000, 2898000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; npc.Opacity = 0f; @@ -40,105 +40,105 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm npc.chaseable = false; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.localAI[0]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.localAI[0]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.localAI[0] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.localAI[0] = reader.ReadSingle(); + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { npc.damage = 0; - // Difficulty modes - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death; - bool revenge = CalamityWorld.revenge; - bool expertMode = Main.expertMode; + // Difficulty modes + bool malice = CalamityWorld.malice; + bool death = CalamityWorld.death; + bool revenge = CalamityWorld.revenge; + bool expertMode = Main.expertMode; - if (npc.ai[2] > 0f) + if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; - float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; + float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; + float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; - bool invisiblePartOfChargePhase = calamityGlobalNPC_Head.newAI[2] >= chargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= chargePhaseGateValue + 1f && (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeOne || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeTwo || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FastCharge); - bool invisiblePartOfLightningChargePhase = calamityGlobalNPC_Head.newAI[2] >= lightningChargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= lightningChargePhaseGateValue + 1f && calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.LightningCharge; - bool invisiblePhase = calamityGlobalNPC_Head.newAI[0] == 1f || calamityGlobalNPC_Head.newAI[0] == 5f || calamityGlobalNPC_Head.newAI[0] == 7f; - if (!invisiblePartOfChargePhase && !invisiblePartOfLightningChargePhase && !invisiblePhase) - { - if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - } - else - { - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } + bool invisiblePartOfChargePhase = calamityGlobalNPC_Head.newAI[2] >= chargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= chargePhaseGateValue + 1f && (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeOne || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeTwo || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FastCharge); + bool invisiblePartOfLightningChargePhase = calamityGlobalNPC_Head.newAI[2] >= lightningChargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= lightningChargePhaseGateValue + 1f && calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.LightningCharge; + bool invisiblePhase = calamityGlobalNPC_Head.newAI[0] == 1f || calamityGlobalNPC_Head.newAI[0] == 5f || calamityGlobalNPC_Head.newAI[0] == 7f; + if (!invisiblePartOfChargePhase && !invisiblePartOfLightningChargePhase && !invisiblePhase) + { + if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } - bool spawnAncientLights = (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ShadowFireballSpin && calamityGlobalNPC_Head.newAI[2] > 0f) || - (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FinalPhase && calamityGlobalNPC_Head.newAI[1] > 0f); - if (spawnAncientLights && Main.netMode != NetmodeID.MultiplayerClient) - { - if (Vector2.Distance(npc.Center, Main.player[Main.npc[(int)npc.ai[2]].target].Center) > 160f) - { - npc.localAI[0] += 1f; - float spawnAncientLightGateValue = malice ? 90f : death ? 100f : revenge ? 105f : expertMode ? 110f : 120f; - float divisor = 4f; - if (npc.ai[3] % divisor == 0f && npc.localAI[0] >= spawnAncientLightGateValue) - { - npc.localAI[0] = 0f; - float distanceVelocityBoost = MathHelper.Clamp((Vector2.Distance(Main.npc[(int)npc.ai[2]].Center, Main.player[Main.npc[(int)npc.ai[2]].target].Center) - 1600f) * 0.025f, 0f, 16f); - float lightVelocity = (Main.player[Main.npc[(int)npc.ai[2]].target].Calamity().ZoneAbyssLayer4 ? 6f : 8f) + distanceVelocityBoost; - Vector2 destination = Main.player[Main.npc[(int)npc.ai[2]].target].Center - npc.Center; - Vector2 velocity = Vector2.Normalize(destination) * lightVelocity; - int type = NPCID.AncientLight; - float ai = (Main.rand.NextFloat() - 0.5f) * 0.3f * MathHelper.TwoPi / 60f; - int light = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, type, 0, 0f, ai, velocity.X, velocity.Y, 255); - Main.npc[light].velocity = velocity; - } - } - } + bool spawnAncientLights = (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ShadowFireballSpin && calamityGlobalNPC_Head.newAI[2] > 0f) || + (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FinalPhase && calamityGlobalNPC_Head.newAI[1] > 0f); + if (spawnAncientLights && Main.netMode != NetmodeID.MultiplayerClient) + { + if (Vector2.Distance(npc.Center, Main.player[Main.npc[(int)npc.ai[2]].target].Center) > 160f) + { + npc.localAI[0] += 1f; + float spawnAncientLightGateValue = malice ? 90f : death ? 100f : revenge ? 105f : expertMode ? 110f : 120f; + float divisor = 4f; + if (npc.ai[3] % divisor == 0f && npc.localAI[0] >= spawnAncientLightGateValue) + { + npc.localAI[0] = 0f; + float distanceVelocityBoost = MathHelper.Clamp((Vector2.Distance(Main.npc[(int)npc.ai[2]].Center, Main.player[Main.npc[(int)npc.ai[2]].target].Center) - 1600f) * 0.025f, 0f, 16f); + float lightVelocity = (Main.player[Main.npc[(int)npc.ai[2]].target].Calamity().ZoneAbyssLayer4 ? 6f : 8f) + distanceVelocityBoost; + Vector2 destination = Main.player[Main.npc[(int)npc.ai[2]].target].Center - npc.Center; + Vector2 velocity = Vector2.Normalize(destination) * lightVelocity; + int type = NPCID.AncientLight; + float ai = (Main.rand.NextFloat() - 0.5f) * 0.3f * MathHelper.TwoPi / 60f; + int light = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, type, 0, 0f, ai, velocity.X, velocity.Y, 255); + Main.npc[light].velocity = velocity; + } + } + } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); num191 = (int)(num191 / 16f) * 16; @@ -189,9 +189,9 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm new Microsoft.Xna.Framework.Rectangle?(npc.frame), Color.White, npc.rotation, vector11, 1f, spriteEffects, 0f); } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/AdultEidolonWyrm/EidolonWyrmHeadHuge.cs b/NPCs/AdultEidolonWyrm/EidolonWyrmHeadHuge.cs index 7f1b37d1cc..fbb8e30a84 100644 --- a/NPCs/AdultEidolonWyrm/EidolonWyrmHeadHuge.cs +++ b/NPCs/AdultEidolonWyrm/EidolonWyrmHeadHuge.cs @@ -19,60 +19,60 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AdultEidolonWyrm { - [AutoloadBossHead] - public class EidolonWyrmHeadHuge : ModNPC + [AutoloadBossHead] + public class EidolonWyrmHeadHuge : ModNPC { - public enum Phase - { - ChargeOne = 0, - LightningRain = 1, - FastCharge = 2, - EidolonWyrmSpawn = 3, - ChargeTwo = 4, - IceMist = 5, - ShadowFireballSpin = 6, - AncientDoomSummon = 7, - LightningCharge = 8, - EidolistSpawn = 9, - FinalPhase = 10 - } + public enum Phase + { + ChargeOne = 0, + LightningRain = 1, + FastCharge = 2, + EidolonWyrmSpawn = 3, + ChargeTwo = 4, + IceMist = 5, + ShadowFireballSpin = 6, + AncientDoomSummon = 7, + LightningCharge = 8, + EidolistSpawn = 9, + FinalPhase = 10 + } - public float AIState - { - get => npc.Calamity().newAI[0]; - set => npc.Calamity().newAI[0] = value; - } + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } - // Base distance from the target for most attacks - private const float baseDistance = 1000f; + // Base distance from the target for most attacks + private const float baseDistance = 1000f; - // Base distance from target location in order to continue turning - private const float baseTurnDistance = 160f; + // Base distance from target location in order to continue turning + private const float baseTurnDistance = 160f; - // The distance from target location in order to initiate an attack - private const float baseAttackTriggerDistance = 80f; + // The distance from target location in order to initiate an attack + private const float baseAttackTriggerDistance = 80f; - // Max distance from the target before they are unable to hear sound telegraphs - private const float soundDistance = 2800f; + // Max distance from the target before they are unable to hear sound telegraphs + private const float soundDistance = 2800f; - // The end location of each charge - Vector2 chargeDestination = default; + // The end location of each charge + Vector2 chargeDestination = default; - // Length variables - private const int minLength = 40; + // Length variables + private const int minLength = 40; private const int maxLength = 41; - // Variable used to stop the segment spawning loop + // Variable used to stop the segment spawning loop private bool TailSpawned = false; - // The direction to spin in during spin phases - private int rotationDirection = 0; + // The direction to spin in during spin phases + private int rotationDirection = 0; - // Used in the lerp to smoothly scale velocity up and down - private float chargeVelocityScalar = 0f; + // Used in the lerp to smoothly scale velocity up and down + private float chargeVelocityScalar = 0f; - // How much less time is needed before activating fast charge - private const float fastChargeGateValue = 120f; + // How much less time is needed before activating fast charge + private const float fastChargeGateValue = 120f; public override void SetStaticDefaults() { @@ -81,19 +81,19 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 50f; - npc.GetNPCDamage(); - npc.width = 254; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 50f; + npc.GetNPCDamage(); + npc.width = 254; npc.height = 138; npc.defense = 100; - npc.DR_NERD(0.4f); - npc.LifeMaxNERB(2415000, 2898000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.DR_NERD(0.4f); + npc.LifeMaxNERB(2415000, 2898000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; - npc.Opacity = 0f; + npc.Opacity = 0f; npc.knockBackResist = 0f; npc.value = Item.buyPrice(10, 0, 0, 0); npc.behindTiles = true; @@ -102,1225 +102,1225 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath6; npc.netAlways = true; - npc.boss = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ?? MusicID.Boss3; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.boss = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ?? MusicID.Boss3; + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { - writer.WriteVector2(chargeDestination); - writer.Write(rotationDirection); - writer.Write(chargeVelocityScalar); - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - writer.Write(npc.localAI[3]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + writer.WriteVector2(chargeDestination); + writer.Write(rotationDirection); + writer.Write(chargeVelocityScalar); + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + writer.Write(npc.localAI[3]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { - chargeDestination = reader.ReadVector2(); - rotationDirection = reader.ReadInt32(); - chargeVelocityScalar = reader.ReadSingle(); - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + chargeDestination = reader.ReadVector2(); + rotationDirection = reader.ReadInt32(); + chargeVelocityScalar = reader.ReadSingle(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - CalamityGlobalNPC.adultEidolonWyrmHead = npc.whoAmI; + CalamityGlobalNPC.adultEidolonWyrmHead = npc.whoAmI; - // Difficulty modes - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death; - bool revenge = CalamityWorld.revenge; - bool expertMode = Main.expertMode; + // Difficulty modes + bool malice = CalamityWorld.malice; + bool death = CalamityWorld.death; + bool revenge = CalamityWorld.revenge; + bool expertMode = Main.expertMode; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Phases - bool phase2 = lifeRatio < 0.8f; - bool phase3 = lifeRatio < 0.6f; - bool phase4 = lifeRatio < 0.4f; - bool phase5 = lifeRatio < 0.2f; - bool phase6 = lifeRatio < 0.05f; + // Phases + bool phase2 = lifeRatio < 0.8f; + bool phase3 = lifeRatio < 0.6f; + bool phase4 = lifeRatio < 0.4f; + bool phase5 = lifeRatio < 0.2f; + bool phase6 = lifeRatio < 0.05f; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - // Target variable - Player player = Main.player[npc.target]; + // Target variable + Player player = Main.player[npc.target]; - bool targetDownDeep = player.Calamity().ZoneAbyssLayer4; - bool targetOnMount = player.mount.Active; + bool targetDownDeep = player.Calamity().ZoneAbyssLayer4; + bool targetOnMount = player.mount.Active; - // Check whether enraged for the sake of the HP bar UI - npc.Calamity().CurrentlyEnraged = !targetDownDeep || malice; + // Check whether enraged for the sake of the HP bar UI + npc.Calamity().CurrentlyEnraged = !targetDownDeep || malice; - if (npc.ai[2] > 0f) + if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Play spawn sound - if (!TailSpawned && npc.ai[0] == 0f) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Scare"), Main.player[Main.myPlayer].Center); - } + // Play spawn sound + if (!TailSpawned && npc.ai[0] == 0f) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Scare"), Main.player[Main.myPlayer].Center); + } - // Spawn segments - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!TailSpawned && npc.ai[0] == 0f) - { - int Previous = npc.whoAmI; - for (int i = 0; i < maxLength; i++) - { - int lol; - if (i >= 0 && i < minLength) - { - if (i % 2 == 0) - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - else - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - else - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + // Spawn segments + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (!TailSpawned && npc.ai[0] == 0f) + { + int Previous = npc.whoAmI; + for (int i = 0; i < maxLength; i++) + { + int lol; + if (i >= 0 && i < minLength) + { + if (i % 2 == 0) + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + else + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + } + else + 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] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); - Previous = lol; - Main.npc[Previous].ai[3] = i / 2; - } - TailSpawned = true; - } - } + Main.npc[lol].realLife = npc.whoAmI; + Main.npc[lol].ai[2] = npc.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); + Previous = lol; + Main.npc[Previous].ai[3] = i / 2; + } + TailSpawned = true; + } + } - // Despawn if target is dead - bool targetDead = false; + // Despawn if target is dead + bool targetDead = false; if (player.dead) { npc.TargetClosest(false); - player = Main.player[npc.target]; - if (player.dead) - { - targetDead = true; - npc.ai[3] = 0f; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - npc.localAI[3] = 0f; - AIState = (float)Phase.ChargeOne; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - chargeVelocityScalar = 0f; - rotationDirection = 0; - - npc.velocity.Y += 3f; - if (npc.position.Y > Main.worldSurface * 16.0) - npc.velocity.Y += 3f; - - if (npc.position.Y > Main.rockLayer * 16.0) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - } - } - - // General AI pattern - // Charge - // Charge : Phase 2 - Spin around target and summon Shadow Fireballs - // Charge : Phase 4 - Swim to the right and dash towards the target, summon Lightning Bolts from above during it - // Turn invisible, swim above the target and summon predictive Lightning Bolts - // Turn visible and charge towards the target quickly 1 time, soon after the previous attack ends - // Spawn an Eidolon Wyrm and swim below the target for 10 seconds, or less, if the Wyrm dies - // Charge - // Charge : Phase 3 - Turn invisible and summon Ancient Dooms around the target - // Charge : Phase 4 - Turn visible, swim to the left and dash towards the target, summon Lightning Bolts from above during it - // Turn invisible, swim beneath the target and summon Ice Mist - // Turn visible and charge towards the target quickly 1 time, soon after the previous attack ends - // Spawn Eidolists and swim below the target for 10 seconds, or less, if the Eidolists die - - // Final phase - // Spin around the target and summon Ancient Dooms and Shadow Fireballs - - // Attack patterns - // Phase 1 - 0, 0, 0, 1, 2, 3, 4, 4, 4, 5, 2, 9 - // Phase 2 - 0, 6, 0, 1, 2, 3, 4, 4, 4, 5, 2, 9 - // Phase 3 - 0, 6, 0, 1, 2, 3, 4, 7, 4, 5, 2, 9 - // Phase 4 - 0, 6, 8, 1, 2, 3, 4, 7, 8, 5, 2, 9 - // Phase 5 - 0, 6, 8, 1, 2, 2, 4, 7, 8, 5, 2, 2 - // Phase 6 - 10 - - // Phase gate values - float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; - float lightningRainDuration = malice ? 150f : 180f; - float eidolonWyrmPhaseDuration = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; - float iceMistDuration = malice ? 150f : 180f; - float spinPhaseDuration = malice ? 210f : death ? 240f : revenge ? 255f : expertMode ? 270f : 300f; - float ancientDoomPhaseGateValue = 30f; - float ancientDoomGateValue = malice ? 80f : death ? 95f : revenge ? 100f : expertMode ? 105f : 120f; - float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; - - // Adjust slowing debuff immunity - bool immuneToSlowingDebuffs = AIState == (float)Phase.FinalPhase || AIState == (float)Phase.ShadowFireballSpin; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; - - // Adjust opacity - bool invisiblePartOfChargePhase = calamityGlobalNPC.newAI[2] >= chargePhaseGateValue && calamityGlobalNPC.newAI[2] <= chargePhaseGateValue + 1f && (AIState == (float)Phase.ChargeOne || AIState == (float)Phase.ChargeTwo || AIState == (float)Phase.FastCharge); - bool invisiblePartOfLightningChargePhase = calamityGlobalNPC.newAI[2] >= lightningChargePhaseGateValue && calamityGlobalNPC.newAI[2] <= lightningChargePhaseGateValue + 1f && AIState == (float)Phase.LightningCharge; - bool invisiblePhase = AIState == (float)Phase.LightningRain || AIState == (float)Phase.IceMist || AIState == (float)Phase.AncientDoomSummon; - if (!invisiblePartOfChargePhase && !invisiblePartOfLightningChargePhase && !invisiblePhase) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } - - // Rotation and direction - npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - int direction = npc.direction; - npc.direction = npc.spriteDirection = (npc.velocity.X > 0f) ? 1 : (-1); - if (direction != npc.direction) - npc.netUpdate = true; - - // Default vector to swim to - Vector2 destination = player.Center; - - // Charge variables - Vector2 chargeVector = Vector2.Zero; - float chargeDistance = baseDistance; - float turnDistance = baseTurnDistance; - float chargeLocationDistance = baseAttackTriggerDistance; - switch ((int)calamityGlobalNPC.newAI[1]) - { - case 0: - chargeVector.X -= chargeDistance; - break; - case 1: - chargeVector.X += chargeDistance; - break; - case 2: - chargeVector.Y -= chargeDistance; - break; - case 3: - chargeVector.Y += chargeDistance; - break; - case 4: - chargeVector.X -= chargeDistance; - chargeVector.Y -= chargeDistance; - break; - case 5: - chargeVector.X += chargeDistance; - chargeVector.Y += chargeDistance; - break; - case 6: - chargeVector.X -= chargeDistance; - chargeVector.Y += chargeDistance; - break; - case 7: - chargeVector.X += chargeDistance; - chargeVector.Y -= chargeDistance; - break; - } - Vector2 chargeLocation = destination + chargeVector; - Vector2 chargeVectorFlipped = chargeVector * -1f; - float chargePredictionAmt = malice ? 60f : death ? 50f : revenge ? 40f : expertMode ? 30f : 20f; - - // Lightning Rain variables - Vector2 lightningRainLocation = new Vector2(0f, -baseDistance); - float lightningRainLocationDistance = baseAttackTriggerDistance; - - // Wyrm and Eidolist variables - Vector2 eidolonWyrmPhaseLocation = new Vector2(0f, baseDistance); - float eidolonWyrmPhaseLocationDistance = baseAttackTriggerDistance; - int eidolistScale = malice ? 4 : death ? 3 : revenge ? 2 : expertMode ? 1 : 0; - int maxEidolists = (targetDownDeep ? 3 : 6) + eidolistScale; - - // Ice Mist variables - Vector2 iceMistLocation = new Vector2(0f, baseDistance); - float iceMistLocationDistance = baseAttackTriggerDistance; - - // Spin variables - float spinRadius = baseDistance; - Vector2 spinLocation = new Vector2(0f, -spinRadius); - float spinLocationDistance = baseAttackTriggerDistance; - - // Ancient Doom variables - Vector2 ancientDoomLocation = new Vector2(0f, -baseDistance); - float ancientDoomLocationDistance = baseAttackTriggerDistance; - int ancientDoomScale = malice ? 4 : death ? 3 : revenge ? 2 : expertMode ? 1 : 0; - int ancientDoomLimit = (targetDownDeep ? 4 : 8) + ancientDoomScale; - int ancientDoomDistance = malice ? 480 : death ? 520 : revenge ? 535 : expertMode ? 550 : 600; - float maxAncientDoomRings = 3f; - - // Lightning charge variables - Vector2 lightningChargeVector = npc.localAI[2] == 0f ? new Vector2(baseDistance, 0f) : new Vector2(-baseDistance, 0f); - float lightningChargeLocationDistance = baseAttackTriggerDistance; - Vector2 lightningChargeLocation = destination + lightningChargeVector; - Vector2 lightningChargeVectorFlipped = lightningChargeVector * -1f; - float lightningSpawnY = 540f; - Vector2 lightningSpawnLocation = new Vector2(npc.Center.X, npc.Center.Y - lightningSpawnY); - int numLightningBolts = malice ? 12 : death ? 10 : revenge ? 8 : expertMode ? 6 : 4; - float distanceBetweenBolts = lightningSpawnY * 2f / numLightningBolts; - - // Velocity and turn speed values - float velocityScale = malice ? 3f : death ? 1.8f : revenge ? 1.5f : expertMode ? 1.2f : 0f; - float baseVelocity = (targetDownDeep ? 12f : 24f) + (targetDownDeep ? velocityScale : velocityScale * 2f); - float turnSpeed = baseVelocity * 0.125f; - float normalChargeVelocityMult = MathHelper.Lerp(1f, 2f, chargeVelocityScalar); - float normalChargeTurnSpeedMult = MathHelper.Lerp(1f, 8f, chargeVelocityScalar); - float invisiblePhaseVelocityMult = MathHelper.Lerp(1f, 1.5f, chargeVelocityScalar); - float invisiblePhaseTurnSpeedMult = MathHelper.Lerp(1f, 6f, chargeVelocityScalar); - float fastChargeVelocityMult = MathHelper.Lerp(1f, 3f, chargeVelocityScalar); - float fastChargeTurnSpeedMult = MathHelper.Lerp(1f, 12f, chargeVelocityScalar); - float chargeVelocityScalarIncrement = 0.025f; - - // Telekinesis while enraged - if (!targetDownDeep) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - calamityGlobalNPC.newAI[3] += 1f; - if (calamityGlobalNPC.newAI[3] >= 300f) - { - calamityGlobalNPC.newAI[3] = 0f; - - Main.PlaySound(SoundID.Item117, player.position); - - for (int i = 0; i < 20; i++) - { - int dust = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 185, 0f, 0f, 100, default, 2f); - Main.dust[dust].velocity *= 0.6f; - if (Main.rand.NextBool(2)) - { - Main.dust[dust].scale = 0.5f; - Main.dust[dust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - for (int j = 0; j < 30; j++) - { - int dust = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 185, 0f, 0f, 100, default, 3f); - Main.dust[dust].noGravity = true; - dust = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 185, 0f, 0f, 100, default, 2f); - Main.dust[dust].velocity *= 0.2f; - } - - if (player.velocity.Length() > 0f) - player.velocity *= -3f; - } - } - } - - // Phase switch - switch ((int)AIState) - { - // First charge combo - case (int)Phase.ChargeOne: - - if (calamityGlobalNPC.newAI[2] >= chargePhaseGateValue) - { - ChargeDust(7, (float)Math.PI); - - // Use a lerp to smoothly scale up velocity and turn speed - chargeVelocityScalar += chargeVelocityScalarIncrement; - if (chargeVelocityScalar > 1f) - chargeVelocityScalar = 1f; - - baseVelocity *= normalChargeVelocityMult; - turnSpeed *= normalChargeTurnSpeedMult; - turnDistance = chargeLocationDistance; - - if ((chargeLocation - npc.Center).Length() < chargeLocationDistance || calamityGlobalNPC.newAI[2] > chargePhaseGateValue) - { - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] == chargePhaseGateValue + 1f) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose"), Main.player[Main.myPlayer].Center); - - chargeDestination = destination + chargeVectorFlipped + player.velocity * chargePredictionAmt; - npc.velocity = Vector2.Normalize(chargeDestination - npc.Center) * baseVelocity; - npc.netUpdate = true; - npc.netSpam -= 5; - } - else - { - // Charge - - // Become totally visible - npc.Opacity = 1f; - - destination = chargeDestination; - - if ((destination - npc.Center).Length() < chargeLocationDistance) - { - npc.ai[3] += 1f; - float maxCharges = phase4 ? 1 : phase2 ? 2 : 3; - if (npc.ai[3] >= maxCharges) - { - npc.ai[3] = 0f; - AIState = phase4 ? (float)Phase.ShadowFireballSpin : (float)Phase.LightningRain; - } - else if (phase2) - AIState = (float)Phase.ShadowFireballSpin; - - calamityGlobalNPC.newAI[1] += 1f; - if (calamityGlobalNPC.newAI[1] > 7f) - calamityGlobalNPC.newAI[1] = 0f; - - calamityGlobalNPC.newAI[2] = 0f; - chargeVelocityScalar = 0f; - FinalPhaseCheck(); - npc.TargetClosest(); - } - } - } - else - destination += chargeVector; - } - else - calamityGlobalNPC.newAI[2] += 1f; - - break; - - // Turn invisible, swim above and summon predictive lightning bolts - case (int)Phase.LightningRain: - - // Swim up - destination += lightningRainLocation; - turnDistance = lightningRainLocationDistance; - - // Use a lerp to smoothly scale up velocity and turn speed - chargeVelocityScalar += chargeVelocityScalarIncrement; - if (chargeVelocityScalar > 1f) - chargeVelocityScalar = 1f; - - baseVelocity *= invisiblePhaseVelocityMult; - turnSpeed *= invisiblePhaseTurnSpeedMult; - - if ((destination - npc.Center).Length() < lightningRainLocationDistance || calamityGlobalNPC.newAI[2] > 0f) - { - if (calamityGlobalNPC.newAI[2] % 30f == 0f && calamityGlobalNPC.newAI[2] < lightningRainDuration) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), Main.player[Main.myPlayer].Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int maxTargets = 2; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; - - for (int i = 0; i < Main.maxPlayers; i++) - { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, npc.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - float predictionAmt = targetDownDeep ? 45f : 60f; - float lightningVelocityScale = malice ? 1.5f : death ? 0.9f : revenge ? 0.75f : expertMode ? 0.6f : 0f; - float lightningVelocity = ((targetDownDeep && !targetOnMount) ? 6f : 9f) + ((targetDownDeep && !targetOnMount) ? lightningVelocityScale : lightningVelocityScale * 1.5f); - for (int i = 0; i < numProjectiles; i++) - { - // Predictive bolt - Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt - npc.Center; - float ai = Main.rand.Next(100); - Vector2 projectileVelocity = Vector2.Normalize(projectileDestination.RotatedByRandom(MathHelper.PiOver4)) * lightningVelocity; - int type = ProjectileID.CultistBossLightningOrbArc; - int damage = npc.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); - Main.projectile[proj].tileCollide = false; - - // Opposite bolt - projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt - npc.Center; - ai = Main.rand.Next(100); - projectileVelocity = Vector2.Normalize(projectileDestination.RotatedByRandom(MathHelper.PiOver4)) * lightningVelocity; - proj = Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); - Main.projectile[proj].tileCollide = false; - - // Normal bolt - projectileDestination = targetCenterArray[i] - npc.Center; - ai = Main.rand.Next(100); - projectileVelocity = Vector2.Normalize(projectileDestination.RotatedByRandom(MathHelper.PiOver4)) * lightningVelocity; - proj = Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); - Main.projectile[proj].tileCollide = false; - } - } - } - - calamityGlobalNPC.newAI[2] += 1f; - - Lighting.AddLight(npc.Center, 0.4f, 0.85f, 0.9f); - - float rotation = MathHelper.Clamp((float)Main.rand.NextDouble() * 1f - 0.5f, -0.5f, 0.5f); - Vector2 dustPosition = new Vector2(-npc.width * 0.2f * npc.scale, 0f).RotatedBy(rotation * ((float)Math.PI * 2f)).RotatedBy(npc.velocity.ToRotation()); - int dust = Dust.NewDust(npc.Center - Vector2.One * 5f, 10, 10, 226, (0f - npc.velocity.X) / 3f, (0f - npc.velocity.Y) / 3f, 150, Color.Transparent, 0.7f); - Main.dust[dust].position = npc.Center + dustPosition; - Main.dust[dust].velocity = Vector2.Normalize(Main.dust[dust].position - npc.Center) * 2f; - Main.dust[dust].noGravity = true; - - rotation = MathHelper.Clamp((float)Main.rand.NextDouble() * 1f - 0.5f, -0.5f, 0.5f); - dustPosition = new Vector2(-npc.width * 0.6f * npc.scale, 0f).RotatedBy(rotation * ((float)Math.PI * 2f)).RotatedBy(npc.velocity.ToRotation()); - dust = Dust.NewDust(npc.Center - Vector2.One * 5f, 10, 10, 226, (0f - npc.velocity.X) / 3f, (0f - npc.velocity.Y) / 3f, 150, Color.Transparent, 0.7f); - Main.dust[dust].velocity = Vector2.Zero; - Main.dust[dust].position = npc.Center + dustPosition; - Main.dust[dust].noGravity = true; - - if (calamityGlobalNPC.newAI[2] >= lightningRainDuration) - { - npc.localAI[0] = 0f; - AIState = (float)Phase.FastCharge; - calamityGlobalNPC.newAI[2] = fastChargeGateValue; - chargeVelocityScalar = 0f; - FinalPhaseCheck(); - npc.TargetClosest(); - } - } - - break; - - // Turn visible and charge quickly - case (int)Phase.FastCharge: - - if (calamityGlobalNPC.newAI[2] >= chargePhaseGateValue) - { - ChargeDust(7, (float)Math.PI); - - // Use a lerp to smoothly scale up velocity and turn speed - chargeVelocityScalar += chargeVelocityScalarIncrement; - if (chargeVelocityScalar > 1f) - chargeVelocityScalar = 1f; - - baseVelocity *= fastChargeVelocityMult; - turnSpeed *= fastChargeTurnSpeedMult; - turnDistance = chargeLocationDistance; - - if ((chargeLocation - npc.Center).Length() < chargeLocationDistance || calamityGlobalNPC.newAI[2] > chargePhaseGateValue) - { - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] == chargePhaseGateValue + 1f) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose"), Main.player[Main.myPlayer].Center); - - chargeDestination = destination + chargeVectorFlipped + player.velocity * chargePredictionAmt; - npc.velocity = Vector2.Normalize(chargeDestination - npc.Center) * baseVelocity; - npc.netUpdate = true; - npc.netSpam -= 5; - } - else - { - // Charge very quickly - - // Become totally visible - npc.Opacity = 1f; - - destination = chargeDestination; - - if ((destination - npc.Center).Length() < chargeLocationDistance) - { - if (!phase5) - { - AIState = npc.localAI[0] == 0f ? (float)Phase.EidolonWyrmSpawn : (float)Phase.EidolistSpawn; - calamityGlobalNPC.newAI[2] = 0f; - } - else - { - npc.ai[3] += 1f; - if (npc.ai[3] >= 2f) - { - npc.ai[3] = 0f; - AIState = npc.localAI[0] == 0f ? (float)Phase.ChargeTwo : (float)Phase.ChargeOne; - calamityGlobalNPC.newAI[2] = 0f; - } - else - calamityGlobalNPC.newAI[2] = fastChargeGateValue; - } - - calamityGlobalNPC.newAI[1] += 1f; - if (calamityGlobalNPC.newAI[1] > 7f) - calamityGlobalNPC.newAI[1] = 0f; - - chargeVelocityScalar = 0f; - FinalPhaseCheck(); - npc.TargetClosest(); - } - } - } - else - destination += chargeVector; - } - else - calamityGlobalNPC.newAI[2] += 1f; - - break; - - // Summon an Eidolon Wyrm and swim below the target for 3 seconds, or less, if the Wyrm dies - case (int)Phase.EidolonWyrmSpawn: - - destination += eidolonWyrmPhaseLocation; - turnDistance = eidolonWyrmPhaseLocationDistance; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (calamityGlobalNPC.newAI[2] == 0f) - { - if (!NPC.AnyNPCs(ModContent.NPCType())) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/WyrmScream"), Main.player[Main.myPlayer].Center); - - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); - } - } - } - - calamityGlobalNPC.newAI[2] += 1f; - - if (calamityGlobalNPC.newAI[2] >= eidolonWyrmPhaseDuration) - { - AIState = (float)Phase.ChargeTwo; - calamityGlobalNPC.newAI[2] = 0f; - FinalPhaseCheck(); - npc.TargetClosest(); - } - - break; - - // Second charge combo - case (int)Phase.ChargeTwo: - - if (calamityGlobalNPC.newAI[2] >= chargePhaseGateValue) - { - ChargeDust(7, (float)Math.PI); - - // Use a lerp to smoothly scale up velocity and turn speed - chargeVelocityScalar += chargeVelocityScalarIncrement; - if (chargeVelocityScalar > 1f) - chargeVelocityScalar = 1f; - - baseVelocity *= normalChargeVelocityMult; - turnSpeed *= normalChargeTurnSpeedMult; - turnDistance = chargeLocationDistance; - - if ((chargeLocation - npc.Center).Length() < chargeLocationDistance || calamityGlobalNPC.newAI[2] > chargePhaseGateValue) - { - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] == chargePhaseGateValue + 1f) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose"), Main.player[Main.myPlayer].Center); - - chargeDestination = destination + chargeVectorFlipped + player.velocity * chargePredictionAmt; - npc.velocity = Vector2.Normalize(chargeDestination - npc.Center) * baseVelocity; - npc.netUpdate = true; - npc.netSpam -= 5; - } - else - { - // Charge - - // Become totally visible - npc.Opacity = 1f; - - destination = chargeDestination; - - if ((destination - npc.Center).Length() < chargeLocationDistance) - { - npc.ai[3] += 1f; - float maxCharges = phase4 ? 1 : phase3 ? 2 : 3; - if (npc.ai[3] >= maxCharges) - { - npc.ai[3] = 0f; - AIState = phase4 ? (float)Phase.AncientDoomSummon : (float)Phase.IceMist; - } - else if (phase3) - AIState = (float)Phase.AncientDoomSummon; - - calamityGlobalNPC.newAI[1] += 1f; - if (calamityGlobalNPC.newAI[1] > 7f) - calamityGlobalNPC.newAI[1] = 0f; - - calamityGlobalNPC.newAI[2] = 0f; - chargeVelocityScalar = 0f; - FinalPhaseCheck(); - npc.TargetClosest(); - } - } - } - else - destination += chargeVector; - } - else - calamityGlobalNPC.newAI[2] += 1f; - - break; - - // Turn invisible, swim beneath the target and summon ice mist - case (int)Phase.IceMist: - - // Swim down - destination += iceMistLocation; - turnDistance = iceMistLocationDistance; - - // Use a lerp to smoothly scale up velocity and turn speed - chargeVelocityScalar += chargeVelocityScalarIncrement; - if (chargeVelocityScalar > 1f) - chargeVelocityScalar = 1f; - - baseVelocity *= invisiblePhaseVelocityMult; - turnSpeed *= invisiblePhaseTurnSpeedMult; - - if ((destination - npc.Center).Length() < iceMistLocationDistance || calamityGlobalNPC.newAI[2] > 0f) - { - if (calamityGlobalNPC.newAI[2] % 60f == 0f && calamityGlobalNPC.newAI[2] < iceMistDuration && Main.netMode != NetmodeID.MultiplayerClient) - { - int maxTargets = 2; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; - - for (int i = 0; i < Main.maxPlayers; i++) - { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, npc.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - float predictionAmt = targetDownDeep ? 90f : 120f; - float iceMistVelocityScale = malice ? 3f : death ? 1.8f : revenge ? 1.5f : expertMode ? 1.2f : 0f; - float iceMistVelocity = (targetDownDeep ? 12f : 18f) + (targetDownDeep ? iceMistVelocityScale : iceMistVelocityScale * 1.5f); - for (int i = 0; i < numProjectiles; i++) - { - // Predictive mist - Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt - npc.Center; - Vector2 projectileVelocity = Vector2.Normalize(projectileDestination) * iceMistVelocity; - int type = ProjectileID.CultistBossIceMist; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 1f); - - // Opposite mist - projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt - npc.Center; - projectileVelocity = Vector2.Normalize(projectileDestination) * iceMistVelocity; - Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 1f); - - // Normal bolt - projectileDestination = targetCenterArray[i] - npc.Center; - projectileVelocity = Vector2.Normalize(projectileDestination) * iceMistVelocity; - Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 1f); - } - } - - calamityGlobalNPC.newAI[2] += 1f; - - Lighting.AddLight(npc.Center, 0.3f, 0.75f, 0.9f); - - float rotation = MathHelper.Clamp((float)Main.rand.NextDouble() * 1f - 0.5f, -0.5f, 0.5f); - Vector2 dustPosition = new Vector2(-npc.width * 0.2f * npc.scale, 0f).RotatedBy(rotation * ((float)Math.PI * 2f)).RotatedBy(npc.velocity.ToRotation()); - int dust = Dust.NewDust(npc.Center - Vector2.One * 5f, 10, 10, 197, 0f, 0f, 100, Color.Transparent); - Main.dust[dust].position = npc.Center + dustPosition; - Main.dust[dust].velocity = Vector2.Normalize(Main.dust[dust].position - npc.Center) * 2f; - Main.dust[dust].noGravity = true; - - rotation = MathHelper.Clamp((float)Main.rand.NextDouble() * 1f - 0.5f, -0.5f, 0.5f); - dustPosition = new Vector2(-npc.width * 0.6f * npc.scale, 0f).RotatedBy(rotation * ((float)Math.PI * 2f)).RotatedBy(npc.velocity.ToRotation()); - dust = Dust.NewDust(npc.Center - Vector2.One * 5f, 10, 10, 197, 0f, 0f, 100, Color.Transparent); - Main.dust[dust].velocity = Vector2.Zero; - Main.dust[dust].position = npc.Center + dustPosition; - Main.dust[dust].noGravity = true; - - if (calamityGlobalNPC.newAI[2] >= iceMistDuration) - { - npc.localAI[0] = 1f; - AIState = (float)Phase.FastCharge; - calamityGlobalNPC.newAI[2] = fastChargeGateValue; - chargeVelocityScalar = 0f; - FinalPhaseCheck(); - npc.TargetClosest(); - } - } - - break; - - // Phase 2 attack - Get in position for spin, spin around target and summon shadow fireballs - case (int)Phase.ShadowFireballSpin: - - // Swim up - destination += spinLocation; - turnDistance = spinLocationDistance; - - // Use a lerp to smoothly scale up velocity and turn speed - chargeVelocityScalar += chargeVelocityScalarIncrement; - if (chargeVelocityScalar > 1f) - chargeVelocityScalar = 1f; - - baseVelocity *= invisiblePhaseVelocityMult; - turnSpeed *= invisiblePhaseTurnSpeedMult; - - // Spin around target - if ((destination - npc.Center).Length() < spinLocationDistance || calamityGlobalNPC.newAI[2] > 0f) - { - calamityGlobalNPC.newAI[2] += 1f; - - float spinVelocityDivisor = targetDownDeep ? 120f : 90f; - if (rotationDirection == 0) - { - // Set spin direction - if (Main.player[npc.target].velocity.X > 0f) - rotationDirection = 1; - else if (Main.player[npc.target].velocity.X < 0f) - rotationDirection = -1; - else - rotationDirection = player.direction; - - // Set spin velocity - npc.velocity.X = MathHelper.Pi * spinRadius / spinVelocityDivisor; - npc.velocity *= -rotationDirection; - npc.netUpdate = true; - } - else - { - npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / spinVelocityDivisor * -rotationDirection); - - if (calamityGlobalNPC.newAI[2] >= spinPhaseDuration) - { - rotationDirection = 0; - AIState = phase4 ? (float)Phase.LightningCharge : (float)Phase.ChargeOne; - calamityGlobalNPC.newAI[2] = 0f; - chargeVelocityScalar = 0f; - FinalPhaseCheck(); - npc.TargetClosest(); - } - } - - // Return to prevent other velocity code from being called - return; - } - - break; - - // Phase 3 attack - Swim above, turn invisible and summon ancient dooms around the target - case (int)Phase.AncientDoomSummon: - - // Swim up - destination += ancientDoomLocation; - turnDistance = ancientDoomLocationDistance; - - if (npc.localAI[1] < maxAncientDoomRings) - { - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] >= ancientDoomPhaseGateValue) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float aiGateValue = calamityGlobalNPC.newAI[2] - ancientDoomPhaseGateValue; - if (aiGateValue % ancientDoomGateValue == 0f) - { - // Spawn 3 (or more) circles of Ancient Dooms around the target - int ancientDoomScale2 = (int)(aiGateValue / ancientDoomGateValue); - ancientDoomLimit += ancientDoomScale2; - ancientDoomDistance += ancientDoomScale2 * 45; - int ancientDoomDegrees = 360 / ancientDoomLimit; - for (int i = 0; i < ancientDoomLimit; i++) - { - float ai2 = i * ancientDoomDegrees; - NPC.NewNPC((int)(player.Center.X + (float)(Math.Sin(i * ancientDoomDegrees) * ancientDoomDistance)), (int)(player.Center.Y + (float)(Math.Cos(i * ancientDoomDegrees) * ancientDoomDistance)), - NPCID.AncientDoom, 0, npc.whoAmI, 0f, ai2, 0f, Main.maxPlayers); - } - npc.localAI[1] += 1f; - npc.TargetClosest(); - } - } - } - } - - if (npc.localAI[1] >= maxAncientDoomRings) - { - npc.localAI[1] += 1f; - if (npc.localAI[1] >= ancientDoomGateValue + maxAncientDoomRings) - { - npc.localAI[1] = 0f; - AIState = phase4 ? (float)Phase.LightningCharge : (float)Phase.ChargeTwo; - calamityGlobalNPC.newAI[2] = 0f; - FinalPhaseCheck(); - npc.TargetClosest(); - } - } - - break; - - // Phase 4 attack - Swim to the right or left and charge towards the target, summon a wall of lightning bolts in the direction of the charge - case (int)Phase.LightningCharge: - - if (calamityGlobalNPC.newAI[2] >= lightningChargePhaseGateValue) - { - ChargeDust(7, (float)Math.PI); - - // Use a lerp to smoothly scale up velocity and turn speed - chargeVelocityScalar += chargeVelocityScalarIncrement; - if (chargeVelocityScalar > 1f) - chargeVelocityScalar = 1f; - - baseVelocity *= fastChargeVelocityMult; - turnSpeed *= fastChargeTurnSpeedMult; - turnDistance = lightningChargeLocationDistance; - - if ((lightningChargeLocation - npc.Center).Length() < lightningChargeLocationDistance || calamityGlobalNPC.newAI[2] > lightningChargePhaseGateValue) - { - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] == lightningChargePhaseGateValue + 1f) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose"), Main.player[Main.myPlayer].Center); - - chargeDestination = destination + lightningChargeVectorFlipped + player.velocity * chargePredictionAmt; - npc.velocity = Vector2.Normalize(chargeDestination - npc.Center) * baseVelocity; - npc.netUpdate = true; - npc.netSpam -= 5; - } - else - { - // Charge - - // Become totally visible - npc.Opacity = 1f; - - destination = chargeDestination; - - // Lightning barrage - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[3] == 0f) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), Main.player[Main.myPlayer].Center); - - npc.localAI[3] = 1f; - int type = ProjectileID.CultistBossLightningOrbArc; - int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < numLightningBolts; i++) - { - Vector2 projectileDestination = player.Center - lightningSpawnLocation; - float ai = Main.rand.Next(100); - int proj = Projectile.NewProjectile(lightningSpawnLocation, npc.velocity * 0.5f, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); - Main.projectile[proj].tileCollide = false; - lightningSpawnLocation.Y += distanceBetweenBolts; - if (i == numLightningBolts / 2) - lightningSpawnLocation.Y += distanceBetweenBolts; - } - } - - if ((destination - npc.Center).Length() < lightningChargeLocationDistance) - { - AIState = npc.localAI[2] == 0f ? (float)Phase.LightningRain : (float)Phase.IceMist; - calamityGlobalNPC.newAI[2] = 0f; - - npc.localAI[2] += 1f; - if (npc.localAI[2] > 1f) - npc.localAI[2] = 0f; - - npc.localAI[3] = 0f; - chargeVelocityScalar = 0f; - FinalPhaseCheck(); - npc.TargetClosest(); - } - } - } - else - destination += lightningChargeVector; - } - else - calamityGlobalNPC.newAI[2] += 1f; - - break; - - // Summon Eidolists and swim below the target for 3 seconds, or less, if the Eidolists die - case (int)Phase.EidolistSpawn: - - destination += eidolonWyrmPhaseLocation; - turnDistance = eidolonWyrmPhaseLocationDistance; - - if (calamityGlobalNPC.newAI[2] == 0f) - { - if (!NPC.AnyNPCs(ModContent.NPCType())) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/EidolistDeath"), Main.player[Main.myPlayer].Center); - - // Spawn Eidolists randomly around the target - for (int i = 0; i < maxEidolists; i++) - { - Point npcCenter = npc.Center.ToTileCoordinates(); - Point playerCenter = player.Center.ToTileCoordinates(); - Vector2 distance = player.Center - npc.Center; - - int baseSpawnDistance = 60; - int minDistance = 3; - int maxDistance = 7; - int collisionRange = 2; - int iterations = 0; - bool tooFar = distance.Length() > 2800f; - while (!tooFar && iterations < 100) - { - iterations++; - int randomX = Main.rand.Next(playerCenter.X - baseSpawnDistance, playerCenter.X + baseSpawnDistance + 1); - int randomY = Main.rand.Next(playerCenter.Y - baseSpawnDistance, playerCenter.Y + baseSpawnDistance + 1); - if ((randomY < playerCenter.Y - maxDistance || randomY > playerCenter.Y + maxDistance || randomX < playerCenter.X - maxDistance || randomX > playerCenter.X + maxDistance) && (randomY < npcCenter.Y - minDistance || randomY > npcCenter.Y + minDistance || randomX < npcCenter.X - minDistance || randomX > npcCenter.X + minDistance) && !Main.tile[randomX, randomY].nactive()) - { - bool canSpawn = true; - if (canSpawn && Collision.SolidTiles(randomX - collisionRange, randomX + collisionRange, randomY - collisionRange, randomY + collisionRange)) - canSpawn = false; - - if (canSpawn) - { - NPC.NewNPC(randomX * 16 + 8, randomY * 16 + 8, ModContent.NPCType()); - break; - } - } - } - } - } - } - - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] >= eidolonWyrmPhaseDuration) - { - AIState = (float)Phase.ChargeOne; - calamityGlobalNPC.newAI[2] = 0f; - FinalPhaseCheck(); - npc.TargetClosest(); - } - - break; - - // Spin around target, summon Ancient Dooms and shoot Shadow Fireballs from body segments - case (int)Phase.FinalPhase: - - // Ancient Dooms - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] >= ancientDoomPhaseGateValue) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float aiGateValue = calamityGlobalNPC.newAI[2] - ancientDoomPhaseGateValue; - if (aiGateValue % ancientDoomGateValue == 0f) - { - // Spawn 3 (or more) circles of Ancient Dooms around the target - int ancientDoomScale2 = (int)(aiGateValue / ancientDoomGateValue); - ancientDoomLimit += ancientDoomScale2; - ancientDoomDistance += ancientDoomScale2 * 45; - int ancientDoomDegrees = 360 / ancientDoomLimit; - for (int i = 0; i < ancientDoomLimit; i++) - { - float ai2 = i * ancientDoomDegrees; - NPC.NewNPC((int)(player.Center.X + (float)(Math.Sin(i * ancientDoomDegrees) * ancientDoomDistance)), (int)(player.Center.Y + (float)(Math.Cos(i * ancientDoomDegrees) * ancientDoomDistance)), - NPCID.AncientDoom, 0, npc.whoAmI, 0f, ai2, 0f, Main.maxPlayers); - } - - if (calamityGlobalNPC.newAI[2] >= 240f) - calamityGlobalNPC.newAI[2] = -90f; - - npc.TargetClosest(); - } - } - } - - // Swim up - destination += spinLocation; - turnDistance = spinLocationDistance; - - // Use a lerp to smoothly scale up velocity and turn speed - chargeVelocityScalar += chargeVelocityScalarIncrement; - if (chargeVelocityScalar > 1f) - chargeVelocityScalar = 1f; - - baseVelocity *= invisiblePhaseVelocityMult; - turnSpeed *= invisiblePhaseTurnSpeedMult; - - // Spin around target - if ((destination - npc.Center).Length() < spinLocationDistance || calamityGlobalNPC.newAI[1] > 0f) - { - calamityGlobalNPC.newAI[1] += 1f; - float spinVelocityDivisor = targetDownDeep ? 90f : 60f; - if (rotationDirection == 0) - { - // Set spin direction - if (Main.player[npc.target].velocity.X > 0f) - rotationDirection = 1; - else if (Main.player[npc.target].velocity.X < 0f) - rotationDirection = -1; - else - rotationDirection = player.direction; - - // Set spin velocity - npc.velocity.X = MathHelper.Pi * spinRadius / spinVelocityDivisor; - npc.velocity *= -rotationDirection; - npc.netUpdate = true; - } - else - { - npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / spinVelocityDivisor * -rotationDirection); - - // Swim above target again if enough time has passed - if (calamityGlobalNPC.newAI[1] >= spinPhaseDuration) - { - calamityGlobalNPC.newAI[1] = 0f; - - chargeVelocityScalar = 0f; - rotationDirection = 0; - - npc.TargetClosest(); - } - } - - // Return to prevent other velocity code from being called - return; - } - - break; - } - - void FinalPhaseCheck() - { - if (phase6) - { - npc.localAI[1] = 0f; - AIState = (float)Phase.FinalPhase; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - rotationDirection = 0; - } - } - - if (!targetDead) - { - // Increase velocity if velocity is ever zero - if (npc.velocity == Vector2.Zero) - npc.velocity = Vector2.Normalize(player.Center - npc.Center).SafeNormalize(Vector2.Zero) * baseVelocity; - - // Acceleration - if (!((destination - npc.Center).Length() < turnDistance)) - { - float targetAngle = npc.AngleTo(destination); - float f = npc.velocity.ToRotation().AngleTowards(targetAngle, turnSpeed); - npc.velocity = f.ToRotationVector2() * baseVelocity; - } - } - - // Velocity upper limit - if (npc.velocity.Length() > baseVelocity) - npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero) * baseVelocity; - } - - private void ChargeDust(int dustAmt, float pie) - { - for (int num1474 = 0; num1474 < dustAmt; num1474++) - { - Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; - vector171 = vector171.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)pie / (float)dustAmt) + npc.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 172, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= npc.velocity; - } - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - - Rectangle targetHitbox = target.Hitbox; - - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; - - return minDist <= 70f && npc.Opacity == 1f; - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - scale = 1.5f; - return null; - } - - public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + player = Main.player[npc.target]; + if (player.dead) + { + targetDead = true; + npc.ai[3] = 0f; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + npc.localAI[3] = 0f; + AIState = (float)Phase.ChargeOne; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + chargeVelocityScalar = 0f; + rotationDirection = 0; + + npc.velocity.Y += 3f; + if (npc.position.Y > Main.worldSurface * 16.0) + npc.velocity.Y += 3f; + + if (npc.position.Y > Main.rockLayer * 16.0) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + } + } + } + + // General AI pattern + // Charge + // Charge : Phase 2 - Spin around target and summon Shadow Fireballs + // Charge : Phase 4 - Swim to the right and dash towards the target, summon Lightning Bolts from above during it + // Turn invisible, swim above the target and summon predictive Lightning Bolts + // Turn visible and charge towards the target quickly 1 time, soon after the previous attack ends + // Spawn an Eidolon Wyrm and swim below the target for 10 seconds, or less, if the Wyrm dies + // Charge + // Charge : Phase 3 - Turn invisible and summon Ancient Dooms around the target + // Charge : Phase 4 - Turn visible, swim to the left and dash towards the target, summon Lightning Bolts from above during it + // Turn invisible, swim beneath the target and summon Ice Mist + // Turn visible and charge towards the target quickly 1 time, soon after the previous attack ends + // Spawn Eidolists and swim below the target for 10 seconds, or less, if the Eidolists die + + // Final phase + // Spin around the target and summon Ancient Dooms and Shadow Fireballs + + // Attack patterns + // Phase 1 - 0, 0, 0, 1, 2, 3, 4, 4, 4, 5, 2, 9 + // Phase 2 - 0, 6, 0, 1, 2, 3, 4, 4, 4, 5, 2, 9 + // Phase 3 - 0, 6, 0, 1, 2, 3, 4, 7, 4, 5, 2, 9 + // Phase 4 - 0, 6, 8, 1, 2, 3, 4, 7, 8, 5, 2, 9 + // Phase 5 - 0, 6, 8, 1, 2, 2, 4, 7, 8, 5, 2, 2 + // Phase 6 - 10 + + // Phase gate values + float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; + float lightningRainDuration = malice ? 150f : 180f; + float eidolonWyrmPhaseDuration = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; + float iceMistDuration = malice ? 150f : 180f; + float spinPhaseDuration = malice ? 210f : death ? 240f : revenge ? 255f : expertMode ? 270f : 300f; + float ancientDoomPhaseGateValue = 30f; + float ancientDoomGateValue = malice ? 80f : death ? 95f : revenge ? 100f : expertMode ? 105f : 120f; + float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; + + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = AIState == (float)Phase.FinalPhase || AIState == (float)Phase.ShadowFireballSpin; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + + // Adjust opacity + bool invisiblePartOfChargePhase = calamityGlobalNPC.newAI[2] >= chargePhaseGateValue && calamityGlobalNPC.newAI[2] <= chargePhaseGateValue + 1f && (AIState == (float)Phase.ChargeOne || AIState == (float)Phase.ChargeTwo || AIState == (float)Phase.FastCharge); + bool invisiblePartOfLightningChargePhase = calamityGlobalNPC.newAI[2] >= lightningChargePhaseGateValue && calamityGlobalNPC.newAI[2] <= lightningChargePhaseGateValue + 1f && AIState == (float)Phase.LightningCharge; + bool invisiblePhase = AIState == (float)Phase.LightningRain || AIState == (float)Phase.IceMist || AIState == (float)Phase.AncientDoomSummon; + if (!invisiblePartOfChargePhase && !invisiblePartOfLightningChargePhase && !invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Rotation and direction + npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; + int direction = npc.direction; + npc.direction = npc.spriteDirection = (npc.velocity.X > 0f) ? 1 : (-1); + if (direction != npc.direction) + npc.netUpdate = true; + + // Default vector to swim to + Vector2 destination = player.Center; + + // Charge variables + Vector2 chargeVector = Vector2.Zero; + float chargeDistance = baseDistance; + float turnDistance = baseTurnDistance; + float chargeLocationDistance = baseAttackTriggerDistance; + switch ((int)calamityGlobalNPC.newAI[1]) + { + case 0: + chargeVector.X -= chargeDistance; + break; + case 1: + chargeVector.X += chargeDistance; + break; + case 2: + chargeVector.Y -= chargeDistance; + break; + case 3: + chargeVector.Y += chargeDistance; + break; + case 4: + chargeVector.X -= chargeDistance; + chargeVector.Y -= chargeDistance; + break; + case 5: + chargeVector.X += chargeDistance; + chargeVector.Y += chargeDistance; + break; + case 6: + chargeVector.X -= chargeDistance; + chargeVector.Y += chargeDistance; + break; + case 7: + chargeVector.X += chargeDistance; + chargeVector.Y -= chargeDistance; + break; + } + Vector2 chargeLocation = destination + chargeVector; + Vector2 chargeVectorFlipped = chargeVector * -1f; + float chargePredictionAmt = malice ? 60f : death ? 50f : revenge ? 40f : expertMode ? 30f : 20f; + + // Lightning Rain variables + Vector2 lightningRainLocation = new Vector2(0f, -baseDistance); + float lightningRainLocationDistance = baseAttackTriggerDistance; + + // Wyrm and Eidolist variables + Vector2 eidolonWyrmPhaseLocation = new Vector2(0f, baseDistance); + float eidolonWyrmPhaseLocationDistance = baseAttackTriggerDistance; + int eidolistScale = malice ? 4 : death ? 3 : revenge ? 2 : expertMode ? 1 : 0; + int maxEidolists = (targetDownDeep ? 3 : 6) + eidolistScale; + + // Ice Mist variables + Vector2 iceMistLocation = new Vector2(0f, baseDistance); + float iceMistLocationDistance = baseAttackTriggerDistance; + + // Spin variables + float spinRadius = baseDistance; + Vector2 spinLocation = new Vector2(0f, -spinRadius); + float spinLocationDistance = baseAttackTriggerDistance; + + // Ancient Doom variables + Vector2 ancientDoomLocation = new Vector2(0f, -baseDistance); + float ancientDoomLocationDistance = baseAttackTriggerDistance; + int ancientDoomScale = malice ? 4 : death ? 3 : revenge ? 2 : expertMode ? 1 : 0; + int ancientDoomLimit = (targetDownDeep ? 4 : 8) + ancientDoomScale; + int ancientDoomDistance = malice ? 480 : death ? 520 : revenge ? 535 : expertMode ? 550 : 600; + float maxAncientDoomRings = 3f; + + // Lightning charge variables + Vector2 lightningChargeVector = npc.localAI[2] == 0f ? new Vector2(baseDistance, 0f) : new Vector2(-baseDistance, 0f); + float lightningChargeLocationDistance = baseAttackTriggerDistance; + Vector2 lightningChargeLocation = destination + lightningChargeVector; + Vector2 lightningChargeVectorFlipped = lightningChargeVector * -1f; + float lightningSpawnY = 540f; + Vector2 lightningSpawnLocation = new Vector2(npc.Center.X, npc.Center.Y - lightningSpawnY); + int numLightningBolts = malice ? 12 : death ? 10 : revenge ? 8 : expertMode ? 6 : 4; + float distanceBetweenBolts = lightningSpawnY * 2f / numLightningBolts; + + // Velocity and turn speed values + float velocityScale = malice ? 3f : death ? 1.8f : revenge ? 1.5f : expertMode ? 1.2f : 0f; + float baseVelocity = (targetDownDeep ? 12f : 24f) + (targetDownDeep ? velocityScale : velocityScale * 2f); + float turnSpeed = baseVelocity * 0.125f; + float normalChargeVelocityMult = MathHelper.Lerp(1f, 2f, chargeVelocityScalar); + float normalChargeTurnSpeedMult = MathHelper.Lerp(1f, 8f, chargeVelocityScalar); + float invisiblePhaseVelocityMult = MathHelper.Lerp(1f, 1.5f, chargeVelocityScalar); + float invisiblePhaseTurnSpeedMult = MathHelper.Lerp(1f, 6f, chargeVelocityScalar); + float fastChargeVelocityMult = MathHelper.Lerp(1f, 3f, chargeVelocityScalar); + float fastChargeTurnSpeedMult = MathHelper.Lerp(1f, 12f, chargeVelocityScalar); + float chargeVelocityScalarIncrement = 0.025f; + + // Telekinesis while enraged + if (!targetDownDeep) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= 300f) + { + calamityGlobalNPC.newAI[3] = 0f; + + Main.PlaySound(SoundID.Item117, player.position); + + for (int i = 0; i < 20; i++) + { + int dust = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 185, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 0.6f; + if (Main.rand.NextBool(2)) + { + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + for (int j = 0; j < 30; j++) + { + int dust = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 185, 0f, 0f, 100, default, 3f); + Main.dust[dust].noGravity = true; + dust = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 185, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 0.2f; + } + + if (player.velocity.Length() > 0f) + player.velocity *= -3f; + } + } + } + + // Phase switch + switch ((int)AIState) + { + // First charge combo + case (int)Phase.ChargeOne: + + if (calamityGlobalNPC.newAI[2] >= chargePhaseGateValue) + { + ChargeDust(7, (float)Math.PI); + + // Use a lerp to smoothly scale up velocity and turn speed + chargeVelocityScalar += chargeVelocityScalarIncrement; + if (chargeVelocityScalar > 1f) + chargeVelocityScalar = 1f; + + baseVelocity *= normalChargeVelocityMult; + turnSpeed *= normalChargeTurnSpeedMult; + turnDistance = chargeLocationDistance; + + if ((chargeLocation - npc.Center).Length() < chargeLocationDistance || calamityGlobalNPC.newAI[2] > chargePhaseGateValue) + { + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] == chargePhaseGateValue + 1f) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose"), Main.player[Main.myPlayer].Center); + + chargeDestination = destination + chargeVectorFlipped + player.velocity * chargePredictionAmt; + npc.velocity = Vector2.Normalize(chargeDestination - npc.Center) * baseVelocity; + npc.netUpdate = true; + npc.netSpam -= 5; + } + else + { + // Charge + + // Become totally visible + npc.Opacity = 1f; + + destination = chargeDestination; + + if ((destination - npc.Center).Length() < chargeLocationDistance) + { + npc.ai[3] += 1f; + float maxCharges = phase4 ? 1 : phase2 ? 2 : 3; + if (npc.ai[3] >= maxCharges) + { + npc.ai[3] = 0f; + AIState = phase4 ? (float)Phase.ShadowFireballSpin : (float)Phase.LightningRain; + } + else if (phase2) + AIState = (float)Phase.ShadowFireballSpin; + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] > 7f) + calamityGlobalNPC.newAI[1] = 0f; + + calamityGlobalNPC.newAI[2] = 0f; + chargeVelocityScalar = 0f; + FinalPhaseCheck(); + npc.TargetClosest(); + } + } + } + else + destination += chargeVector; + } + else + calamityGlobalNPC.newAI[2] += 1f; + + break; + + // Turn invisible, swim above and summon predictive lightning bolts + case (int)Phase.LightningRain: + + // Swim up + destination += lightningRainLocation; + turnDistance = lightningRainLocationDistance; + + // Use a lerp to smoothly scale up velocity and turn speed + chargeVelocityScalar += chargeVelocityScalarIncrement; + if (chargeVelocityScalar > 1f) + chargeVelocityScalar = 1f; + + baseVelocity *= invisiblePhaseVelocityMult; + turnSpeed *= invisiblePhaseTurnSpeedMult; + + if ((destination - npc.Center).Length() < lightningRainLocationDistance || calamityGlobalNPC.newAI[2] > 0f) + { + if (calamityGlobalNPC.newAI[2] % 30f == 0f && calamityGlobalNPC.newAI[2] < lightningRainDuration) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), Main.player[Main.myPlayer].Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int maxTargets = 2; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) + { + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, npc.Center); + if (distance < maxDistance) + { + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; + } + } + + float predictionAmt = targetDownDeep ? 45f : 60f; + float lightningVelocityScale = malice ? 1.5f : death ? 0.9f : revenge ? 0.75f : expertMode ? 0.6f : 0f; + float lightningVelocity = ((targetDownDeep && !targetOnMount) ? 6f : 9f) + ((targetDownDeep && !targetOnMount) ? lightningVelocityScale : lightningVelocityScale * 1.5f); + for (int i = 0; i < numProjectiles; i++) + { + // Predictive bolt + Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt - npc.Center; + float ai = Main.rand.Next(100); + Vector2 projectileVelocity = Vector2.Normalize(projectileDestination.RotatedByRandom(MathHelper.PiOver4)) * lightningVelocity; + int type = ProjectileID.CultistBossLightningOrbArc; + int damage = npc.GetProjectileDamage(type); + int proj = Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); + Main.projectile[proj].tileCollide = false; + + // Opposite bolt + projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt - npc.Center; + ai = Main.rand.Next(100); + projectileVelocity = Vector2.Normalize(projectileDestination.RotatedByRandom(MathHelper.PiOver4)) * lightningVelocity; + proj = Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); + Main.projectile[proj].tileCollide = false; + + // Normal bolt + projectileDestination = targetCenterArray[i] - npc.Center; + ai = Main.rand.Next(100); + projectileVelocity = Vector2.Normalize(projectileDestination.RotatedByRandom(MathHelper.PiOver4)) * lightningVelocity; + proj = Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); + Main.projectile[proj].tileCollide = false; + } + } + } + + calamityGlobalNPC.newAI[2] += 1f; + + Lighting.AddLight(npc.Center, 0.4f, 0.85f, 0.9f); + + float rotation = MathHelper.Clamp((float)Main.rand.NextDouble() * 1f - 0.5f, -0.5f, 0.5f); + Vector2 dustPosition = new Vector2(-npc.width * 0.2f * npc.scale, 0f).RotatedBy(rotation * ((float)Math.PI * 2f)).RotatedBy(npc.velocity.ToRotation()); + int dust = Dust.NewDust(npc.Center - Vector2.One * 5f, 10, 10, 226, (0f - npc.velocity.X) / 3f, (0f - npc.velocity.Y) / 3f, 150, Color.Transparent, 0.7f); + Main.dust[dust].position = npc.Center + dustPosition; + Main.dust[dust].velocity = Vector2.Normalize(Main.dust[dust].position - npc.Center) * 2f; + Main.dust[dust].noGravity = true; + + rotation = MathHelper.Clamp((float)Main.rand.NextDouble() * 1f - 0.5f, -0.5f, 0.5f); + dustPosition = new Vector2(-npc.width * 0.6f * npc.scale, 0f).RotatedBy(rotation * ((float)Math.PI * 2f)).RotatedBy(npc.velocity.ToRotation()); + dust = Dust.NewDust(npc.Center - Vector2.One * 5f, 10, 10, 226, (0f - npc.velocity.X) / 3f, (0f - npc.velocity.Y) / 3f, 150, Color.Transparent, 0.7f); + Main.dust[dust].velocity = Vector2.Zero; + Main.dust[dust].position = npc.Center + dustPosition; + Main.dust[dust].noGravity = true; + + if (calamityGlobalNPC.newAI[2] >= lightningRainDuration) + { + npc.localAI[0] = 0f; + AIState = (float)Phase.FastCharge; + calamityGlobalNPC.newAI[2] = fastChargeGateValue; + chargeVelocityScalar = 0f; + FinalPhaseCheck(); + npc.TargetClosest(); + } + } + + break; + + // Turn visible and charge quickly + case (int)Phase.FastCharge: + + if (calamityGlobalNPC.newAI[2] >= chargePhaseGateValue) + { + ChargeDust(7, (float)Math.PI); + + // Use a lerp to smoothly scale up velocity and turn speed + chargeVelocityScalar += chargeVelocityScalarIncrement; + if (chargeVelocityScalar > 1f) + chargeVelocityScalar = 1f; + + baseVelocity *= fastChargeVelocityMult; + turnSpeed *= fastChargeTurnSpeedMult; + turnDistance = chargeLocationDistance; + + if ((chargeLocation - npc.Center).Length() < chargeLocationDistance || calamityGlobalNPC.newAI[2] > chargePhaseGateValue) + { + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] == chargePhaseGateValue + 1f) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose"), Main.player[Main.myPlayer].Center); + + chargeDestination = destination + chargeVectorFlipped + player.velocity * chargePredictionAmt; + npc.velocity = Vector2.Normalize(chargeDestination - npc.Center) * baseVelocity; + npc.netUpdate = true; + npc.netSpam -= 5; + } + else + { + // Charge very quickly + + // Become totally visible + npc.Opacity = 1f; + + destination = chargeDestination; + + if ((destination - npc.Center).Length() < chargeLocationDistance) + { + if (!phase5) + { + AIState = npc.localAI[0] == 0f ? (float)Phase.EidolonWyrmSpawn : (float)Phase.EidolistSpawn; + calamityGlobalNPC.newAI[2] = 0f; + } + else + { + npc.ai[3] += 1f; + if (npc.ai[3] >= 2f) + { + npc.ai[3] = 0f; + AIState = npc.localAI[0] == 0f ? (float)Phase.ChargeTwo : (float)Phase.ChargeOne; + calamityGlobalNPC.newAI[2] = 0f; + } + else + calamityGlobalNPC.newAI[2] = fastChargeGateValue; + } + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] > 7f) + calamityGlobalNPC.newAI[1] = 0f; + + chargeVelocityScalar = 0f; + FinalPhaseCheck(); + npc.TargetClosest(); + } + } + } + else + destination += chargeVector; + } + else + calamityGlobalNPC.newAI[2] += 1f; + + break; + + // Summon an Eidolon Wyrm and swim below the target for 3 seconds, or less, if the Wyrm dies + case (int)Phase.EidolonWyrmSpawn: + + destination += eidolonWyrmPhaseLocation; + turnDistance = eidolonWyrmPhaseLocationDistance; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (calamityGlobalNPC.newAI[2] == 0f) + { + if (!NPC.AnyNPCs(ModContent.NPCType())) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/WyrmScream"), Main.player[Main.myPlayer].Center); + + NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); + } + } + } + + calamityGlobalNPC.newAI[2] += 1f; + + if (calamityGlobalNPC.newAI[2] >= eidolonWyrmPhaseDuration) + { + AIState = (float)Phase.ChargeTwo; + calamityGlobalNPC.newAI[2] = 0f; + FinalPhaseCheck(); + npc.TargetClosest(); + } + + break; + + // Second charge combo + case (int)Phase.ChargeTwo: + + if (calamityGlobalNPC.newAI[2] >= chargePhaseGateValue) + { + ChargeDust(7, (float)Math.PI); + + // Use a lerp to smoothly scale up velocity and turn speed + chargeVelocityScalar += chargeVelocityScalarIncrement; + if (chargeVelocityScalar > 1f) + chargeVelocityScalar = 1f; + + baseVelocity *= normalChargeVelocityMult; + turnSpeed *= normalChargeTurnSpeedMult; + turnDistance = chargeLocationDistance; + + if ((chargeLocation - npc.Center).Length() < chargeLocationDistance || calamityGlobalNPC.newAI[2] > chargePhaseGateValue) + { + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] == chargePhaseGateValue + 1f) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose"), Main.player[Main.myPlayer].Center); + + chargeDestination = destination + chargeVectorFlipped + player.velocity * chargePredictionAmt; + npc.velocity = Vector2.Normalize(chargeDestination - npc.Center) * baseVelocity; + npc.netUpdate = true; + npc.netSpam -= 5; + } + else + { + // Charge + + // Become totally visible + npc.Opacity = 1f; + + destination = chargeDestination; + + if ((destination - npc.Center).Length() < chargeLocationDistance) + { + npc.ai[3] += 1f; + float maxCharges = phase4 ? 1 : phase3 ? 2 : 3; + if (npc.ai[3] >= maxCharges) + { + npc.ai[3] = 0f; + AIState = phase4 ? (float)Phase.AncientDoomSummon : (float)Phase.IceMist; + } + else if (phase3) + AIState = (float)Phase.AncientDoomSummon; + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] > 7f) + calamityGlobalNPC.newAI[1] = 0f; + + calamityGlobalNPC.newAI[2] = 0f; + chargeVelocityScalar = 0f; + FinalPhaseCheck(); + npc.TargetClosest(); + } + } + } + else + destination += chargeVector; + } + else + calamityGlobalNPC.newAI[2] += 1f; + + break; + + // Turn invisible, swim beneath the target and summon ice mist + case (int)Phase.IceMist: + + // Swim down + destination += iceMistLocation; + turnDistance = iceMistLocationDistance; + + // Use a lerp to smoothly scale up velocity and turn speed + chargeVelocityScalar += chargeVelocityScalarIncrement; + if (chargeVelocityScalar > 1f) + chargeVelocityScalar = 1f; + + baseVelocity *= invisiblePhaseVelocityMult; + turnSpeed *= invisiblePhaseTurnSpeedMult; + + if ((destination - npc.Center).Length() < iceMistLocationDistance || calamityGlobalNPC.newAI[2] > 0f) + { + if (calamityGlobalNPC.newAI[2] % 60f == 0f && calamityGlobalNPC.newAI[2] < iceMistDuration && Main.netMode != NetmodeID.MultiplayerClient) + { + int maxTargets = 2; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) + { + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, npc.Center); + if (distance < maxDistance) + { + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; + } + } + + float predictionAmt = targetDownDeep ? 90f : 120f; + float iceMistVelocityScale = malice ? 3f : death ? 1.8f : revenge ? 1.5f : expertMode ? 1.2f : 0f; + float iceMistVelocity = (targetDownDeep ? 12f : 18f) + (targetDownDeep ? iceMistVelocityScale : iceMistVelocityScale * 1.5f); + for (int i = 0; i < numProjectiles; i++) + { + // Predictive mist + Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt - npc.Center; + Vector2 projectileVelocity = Vector2.Normalize(projectileDestination) * iceMistVelocity; + int type = ProjectileID.CultistBossIceMist; + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 1f); + + // Opposite mist + projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt - npc.Center; + projectileVelocity = Vector2.Normalize(projectileDestination) * iceMistVelocity; + Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 1f); + + // Normal bolt + projectileDestination = targetCenterArray[i] - npc.Center; + projectileVelocity = Vector2.Normalize(projectileDestination) * iceMistVelocity; + Projectile.NewProjectile(npc.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 1f); + } + } + + calamityGlobalNPC.newAI[2] += 1f; + + Lighting.AddLight(npc.Center, 0.3f, 0.75f, 0.9f); + + float rotation = MathHelper.Clamp((float)Main.rand.NextDouble() * 1f - 0.5f, -0.5f, 0.5f); + Vector2 dustPosition = new Vector2(-npc.width * 0.2f * npc.scale, 0f).RotatedBy(rotation * ((float)Math.PI * 2f)).RotatedBy(npc.velocity.ToRotation()); + int dust = Dust.NewDust(npc.Center - Vector2.One * 5f, 10, 10, 197, 0f, 0f, 100, Color.Transparent); + Main.dust[dust].position = npc.Center + dustPosition; + Main.dust[dust].velocity = Vector2.Normalize(Main.dust[dust].position - npc.Center) * 2f; + Main.dust[dust].noGravity = true; + + rotation = MathHelper.Clamp((float)Main.rand.NextDouble() * 1f - 0.5f, -0.5f, 0.5f); + dustPosition = new Vector2(-npc.width * 0.6f * npc.scale, 0f).RotatedBy(rotation * ((float)Math.PI * 2f)).RotatedBy(npc.velocity.ToRotation()); + dust = Dust.NewDust(npc.Center - Vector2.One * 5f, 10, 10, 197, 0f, 0f, 100, Color.Transparent); + Main.dust[dust].velocity = Vector2.Zero; + Main.dust[dust].position = npc.Center + dustPosition; + Main.dust[dust].noGravity = true; + + if (calamityGlobalNPC.newAI[2] >= iceMistDuration) + { + npc.localAI[0] = 1f; + AIState = (float)Phase.FastCharge; + calamityGlobalNPC.newAI[2] = fastChargeGateValue; + chargeVelocityScalar = 0f; + FinalPhaseCheck(); + npc.TargetClosest(); + } + } + + break; + + // Phase 2 attack - Get in position for spin, spin around target and summon shadow fireballs + case (int)Phase.ShadowFireballSpin: + + // Swim up + destination += spinLocation; + turnDistance = spinLocationDistance; + + // Use a lerp to smoothly scale up velocity and turn speed + chargeVelocityScalar += chargeVelocityScalarIncrement; + if (chargeVelocityScalar > 1f) + chargeVelocityScalar = 1f; + + baseVelocity *= invisiblePhaseVelocityMult; + turnSpeed *= invisiblePhaseTurnSpeedMult; + + // Spin around target + if ((destination - npc.Center).Length() < spinLocationDistance || calamityGlobalNPC.newAI[2] > 0f) + { + calamityGlobalNPC.newAI[2] += 1f; + + float spinVelocityDivisor = targetDownDeep ? 120f : 90f; + if (rotationDirection == 0) + { + // Set spin direction + if (Main.player[npc.target].velocity.X > 0f) + rotationDirection = 1; + else if (Main.player[npc.target].velocity.X < 0f) + rotationDirection = -1; + else + rotationDirection = player.direction; + + // Set spin velocity + npc.velocity.X = MathHelper.Pi * spinRadius / spinVelocityDivisor; + npc.velocity *= -rotationDirection; + npc.netUpdate = true; + } + else + { + npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / spinVelocityDivisor * -rotationDirection); + + if (calamityGlobalNPC.newAI[2] >= spinPhaseDuration) + { + rotationDirection = 0; + AIState = phase4 ? (float)Phase.LightningCharge : (float)Phase.ChargeOne; + calamityGlobalNPC.newAI[2] = 0f; + chargeVelocityScalar = 0f; + FinalPhaseCheck(); + npc.TargetClosest(); + } + } + + // Return to prevent other velocity code from being called + return; + } + + break; + + // Phase 3 attack - Swim above, turn invisible and summon ancient dooms around the target + case (int)Phase.AncientDoomSummon: + + // Swim up + destination += ancientDoomLocation; + turnDistance = ancientDoomLocationDistance; + + if (npc.localAI[1] < maxAncientDoomRings) + { + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= ancientDoomPhaseGateValue) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float aiGateValue = calamityGlobalNPC.newAI[2] - ancientDoomPhaseGateValue; + if (aiGateValue % ancientDoomGateValue == 0f) + { + // Spawn 3 (or more) circles of Ancient Dooms around the target + int ancientDoomScale2 = (int)(aiGateValue / ancientDoomGateValue); + ancientDoomLimit += ancientDoomScale2; + ancientDoomDistance += ancientDoomScale2 * 45; + int ancientDoomDegrees = 360 / ancientDoomLimit; + for (int i = 0; i < ancientDoomLimit; i++) + { + float ai2 = i * ancientDoomDegrees; + NPC.NewNPC((int)(player.Center.X + (float)(Math.Sin(i * ancientDoomDegrees) * ancientDoomDistance)), (int)(player.Center.Y + (float)(Math.Cos(i * ancientDoomDegrees) * ancientDoomDistance)), + NPCID.AncientDoom, 0, npc.whoAmI, 0f, ai2, 0f, Main.maxPlayers); + } + npc.localAI[1] += 1f; + npc.TargetClosest(); + } + } + } + } + + if (npc.localAI[1] >= maxAncientDoomRings) + { + npc.localAI[1] += 1f; + if (npc.localAI[1] >= ancientDoomGateValue + maxAncientDoomRings) + { + npc.localAI[1] = 0f; + AIState = phase4 ? (float)Phase.LightningCharge : (float)Phase.ChargeTwo; + calamityGlobalNPC.newAI[2] = 0f; + FinalPhaseCheck(); + npc.TargetClosest(); + } + } + + break; + + // Phase 4 attack - Swim to the right or left and charge towards the target, summon a wall of lightning bolts in the direction of the charge + case (int)Phase.LightningCharge: + + if (calamityGlobalNPC.newAI[2] >= lightningChargePhaseGateValue) + { + ChargeDust(7, (float)Math.PI); + + // Use a lerp to smoothly scale up velocity and turn speed + chargeVelocityScalar += chargeVelocityScalarIncrement; + if (chargeVelocityScalar > 1f) + chargeVelocityScalar = 1f; + + baseVelocity *= fastChargeVelocityMult; + turnSpeed *= fastChargeTurnSpeedMult; + turnDistance = lightningChargeLocationDistance; + + if ((lightningChargeLocation - npc.Center).Length() < lightningChargeLocationDistance || calamityGlobalNPC.newAI[2] > lightningChargePhaseGateValue) + { + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] == lightningChargePhaseGateValue + 1f) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose"), Main.player[Main.myPlayer].Center); + + chargeDestination = destination + lightningChargeVectorFlipped + player.velocity * chargePredictionAmt; + npc.velocity = Vector2.Normalize(chargeDestination - npc.Center) * baseVelocity; + npc.netUpdate = true; + npc.netSpam -= 5; + } + else + { + // Charge + + // Become totally visible + npc.Opacity = 1f; + + destination = chargeDestination; + + // Lightning barrage + if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[3] == 0f) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), Main.player[Main.myPlayer].Center); + + npc.localAI[3] = 1f; + int type = ProjectileID.CultistBossLightningOrbArc; + int damage = npc.GetProjectileDamage(type); + for (int i = 0; i < numLightningBolts; i++) + { + Vector2 projectileDestination = player.Center - lightningSpawnLocation; + float ai = Main.rand.Next(100); + int proj = Projectile.NewProjectile(lightningSpawnLocation, npc.velocity * 0.5f, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); + Main.projectile[proj].tileCollide = false; + lightningSpawnLocation.Y += distanceBetweenBolts; + if (i == numLightningBolts / 2) + lightningSpawnLocation.Y += distanceBetweenBolts; + } + } + + if ((destination - npc.Center).Length() < lightningChargeLocationDistance) + { + AIState = npc.localAI[2] == 0f ? (float)Phase.LightningRain : (float)Phase.IceMist; + calamityGlobalNPC.newAI[2] = 0f; + + npc.localAI[2] += 1f; + if (npc.localAI[2] > 1f) + npc.localAI[2] = 0f; + + npc.localAI[3] = 0f; + chargeVelocityScalar = 0f; + FinalPhaseCheck(); + npc.TargetClosest(); + } + } + } + else + destination += lightningChargeVector; + } + else + calamityGlobalNPC.newAI[2] += 1f; + + break; + + // Summon Eidolists and swim below the target for 3 seconds, or less, if the Eidolists die + case (int)Phase.EidolistSpawn: + + destination += eidolonWyrmPhaseLocation; + turnDistance = eidolonWyrmPhaseLocationDistance; + + if (calamityGlobalNPC.newAI[2] == 0f) + { + if (!NPC.AnyNPCs(ModContent.NPCType())) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/EidolistDeath"), Main.player[Main.myPlayer].Center); + + // Spawn Eidolists randomly around the target + for (int i = 0; i < maxEidolists; i++) + { + Point npcCenter = npc.Center.ToTileCoordinates(); + Point playerCenter = player.Center.ToTileCoordinates(); + Vector2 distance = player.Center - npc.Center; + + int baseSpawnDistance = 60; + int minDistance = 3; + int maxDistance = 7; + int collisionRange = 2; + int iterations = 0; + bool tooFar = distance.Length() > 2800f; + while (!tooFar && iterations < 100) + { + iterations++; + int randomX = Main.rand.Next(playerCenter.X - baseSpawnDistance, playerCenter.X + baseSpawnDistance + 1); + int randomY = Main.rand.Next(playerCenter.Y - baseSpawnDistance, playerCenter.Y + baseSpawnDistance + 1); + if ((randomY < playerCenter.Y - maxDistance || randomY > playerCenter.Y + maxDistance || randomX < playerCenter.X - maxDistance || randomX > playerCenter.X + maxDistance) && (randomY < npcCenter.Y - minDistance || randomY > npcCenter.Y + minDistance || randomX < npcCenter.X - minDistance || randomX > npcCenter.X + minDistance) && !Main.tile[randomX, randomY].nactive()) + { + bool canSpawn = true; + if (canSpawn && Collision.SolidTiles(randomX - collisionRange, randomX + collisionRange, randomY - collisionRange, randomY + collisionRange)) + canSpawn = false; + + if (canSpawn) + { + NPC.NewNPC(randomX * 16 + 8, randomY * 16 + 8, ModContent.NPCType()); + break; + } + } + } + } + } + } + + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= eidolonWyrmPhaseDuration) + { + AIState = (float)Phase.ChargeOne; + calamityGlobalNPC.newAI[2] = 0f; + FinalPhaseCheck(); + npc.TargetClosest(); + } + + break; + + // Spin around target, summon Ancient Dooms and shoot Shadow Fireballs from body segments + case (int)Phase.FinalPhase: + + // Ancient Dooms + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= ancientDoomPhaseGateValue) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float aiGateValue = calamityGlobalNPC.newAI[2] - ancientDoomPhaseGateValue; + if (aiGateValue % ancientDoomGateValue == 0f) + { + // Spawn 3 (or more) circles of Ancient Dooms around the target + int ancientDoomScale2 = (int)(aiGateValue / ancientDoomGateValue); + ancientDoomLimit += ancientDoomScale2; + ancientDoomDistance += ancientDoomScale2 * 45; + int ancientDoomDegrees = 360 / ancientDoomLimit; + for (int i = 0; i < ancientDoomLimit; i++) + { + float ai2 = i * ancientDoomDegrees; + NPC.NewNPC((int)(player.Center.X + (float)(Math.Sin(i * ancientDoomDegrees) * ancientDoomDistance)), (int)(player.Center.Y + (float)(Math.Cos(i * ancientDoomDegrees) * ancientDoomDistance)), + NPCID.AncientDoom, 0, npc.whoAmI, 0f, ai2, 0f, Main.maxPlayers); + } + + if (calamityGlobalNPC.newAI[2] >= 240f) + calamityGlobalNPC.newAI[2] = -90f; + + npc.TargetClosest(); + } + } + } + + // Swim up + destination += spinLocation; + turnDistance = spinLocationDistance; + + // Use a lerp to smoothly scale up velocity and turn speed + chargeVelocityScalar += chargeVelocityScalarIncrement; + if (chargeVelocityScalar > 1f) + chargeVelocityScalar = 1f; + + baseVelocity *= invisiblePhaseVelocityMult; + turnSpeed *= invisiblePhaseTurnSpeedMult; + + // Spin around target + if ((destination - npc.Center).Length() < spinLocationDistance || calamityGlobalNPC.newAI[1] > 0f) + { + calamityGlobalNPC.newAI[1] += 1f; + float spinVelocityDivisor = targetDownDeep ? 90f : 60f; + if (rotationDirection == 0) + { + // Set spin direction + if (Main.player[npc.target].velocity.X > 0f) + rotationDirection = 1; + else if (Main.player[npc.target].velocity.X < 0f) + rotationDirection = -1; + else + rotationDirection = player.direction; + + // Set spin velocity + npc.velocity.X = MathHelper.Pi * spinRadius / spinVelocityDivisor; + npc.velocity *= -rotationDirection; + npc.netUpdate = true; + } + else + { + npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / spinVelocityDivisor * -rotationDirection); + + // Swim above target again if enough time has passed + if (calamityGlobalNPC.newAI[1] >= spinPhaseDuration) + { + calamityGlobalNPC.newAI[1] = 0f; + + chargeVelocityScalar = 0f; + rotationDirection = 0; + + npc.TargetClosest(); + } + } + + // Return to prevent other velocity code from being called + return; + } + + break; + } + + void FinalPhaseCheck() + { + if (phase6) + { + npc.localAI[1] = 0f; + AIState = (float)Phase.FinalPhase; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + rotationDirection = 0; + } + } + + if (!targetDead) + { + // Increase velocity if velocity is ever zero + if (npc.velocity == Vector2.Zero) + npc.velocity = Vector2.Normalize(player.Center - npc.Center).SafeNormalize(Vector2.Zero) * baseVelocity; + + // Acceleration + if (!((destination - npc.Center).Length() < turnDistance)) + { + float targetAngle = npc.AngleTo(destination); + float f = npc.velocity.ToRotation().AngleTowards(targetAngle, turnSpeed); + npc.velocity = f.ToRotationVector2() * baseVelocity; + } + } + + // Velocity upper limit + if (npc.velocity.Length() > baseVelocity) + npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero) * baseVelocity; + } + + private void ChargeDust(int dustAmt, float pie) + { + for (int num1474 = 0; num1474 < dustAmt; num1474++) + { + Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; + vector171 = vector171.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)pie / (float)dustAmt) + npc.Center; + Vector2 value18 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 172, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); + Main.dust[num1475].noGravity = true; + Main.dust[num1475].noLight = true; + Main.dust[num1475].velocity /= 4f; + Main.dust[num1475].velocity -= npc.velocity; + } + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= 70f && npc.Opacity == 1f; + } + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + scale = 1.5f; + return null; + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) { SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Vector2 center = npc.Center; @@ -1332,23 +1332,23 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm new Microsoft.Xna.Framework.Rectangle?(npc.frame), Color.White, npc.rotation, vector11, 1f, spriteEffects, 0f); } - public override void BossLoot(ref string name, ref int potionType) - { - potionType = ModContent.ItemType(); - } - - public override void NPCLoot() + public override void BossLoot(ref string name, ref int potionType) { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + potionType = ModContent.ItemType(); + } + + public override void NPCLoot() + { + CalamityGlobalNPC.SetNewBossJustDowned(npc); DropHelper.DropItem(npc, ModContent.ItemType(), 80, 100); DropHelper.DropItem(npc, ModContent.ItemType()); DropHelper.DropItem(npc, ModContent.ItemType()); DropHelper.DropItem(npc, ModContent.ItemType()); - int minLumenyl = Main.expertMode ? 65 : 50; - int maxLumenyl = Main.expertMode ? 135 : 108; - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 1f, minLumenyl, maxLumenyl); + int minLumenyl = Main.expertMode ? 65 : 50; + int maxLumenyl = Main.expertMode ? 135 : 108; + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 1f, minLumenyl, maxLumenyl); DropHelper.DropItemCondition(npc, ItemID.Ectoplasm, NPC.downedPlantBoss, 1, 21, 32); // Mark Adult Eidolon Wyrm as defeated @@ -1356,32 +1356,32 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm CalamityNetcode.SyncWorld(); } - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 5; k++) - Dust.NewDust(npc.position, npc.width, npc.height, 4, hitDirection, -1f, 0, default, 1f); - - if (npc.life <= 0) - { - for (int k = 0; k < 15; k++) - Dust.NewDust(npc.position, npc.width, npc.height, 4, hitDirection, -1f, 0, default, 1f); - - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WyrmAdult"), 1f); - } - } - - public override bool CheckActive() => false; - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void HitEffect(int hitDirection, double damage) { - if (npc.Opacity == 1f) - player.AddBuff(ModContent.BuffType(), 600, true); + for (int k = 0; k < 5; k++) + Dust.NewDust(npc.position, npc.width, npc.height, 4, hitDirection, -1f, 0, default, 1f); + + if (npc.life <= 0) + { + for (int k = 0; k < 15; k++) + Dust.NewDust(npc.position, npc.width, npc.height, 4, hitDirection, -1f, 0, default, 1f); + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/WyrmAdult"), 1f); + } + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); + } + + public override void OnHitPlayer(Player player, int damage, bool crit) + { + if (npc.Opacity == 1f) + player.AddBuff(ModContent.BuffType(), 600, true); } } } diff --git a/NPCs/AdultEidolonWyrm/EidolonWyrmTailHuge.cs b/NPCs/AdultEidolonWyrm/EidolonWyrmTailHuge.cs index 81ed64bb23..2e6e4d2d33 100644 --- a/NPCs/AdultEidolonWyrm/EidolonWyrmTailHuge.cs +++ b/NPCs/AdultEidolonWyrm/EidolonWyrmTailHuge.cs @@ -23,11 +23,11 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm npc.defense = 0; npc.LifeMaxNERB(2415000, 2898000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; - npc.Opacity = 0f; + npc.Opacity = 0f; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; @@ -39,71 +39,71 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm npc.chaseable = false; } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { npc.damage = 0; - // Difficulty modes - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death; - bool revenge = CalamityWorld.revenge; - bool expertMode = Main.expertMode; + // Difficulty modes + bool malice = CalamityWorld.malice; + bool death = CalamityWorld.death; + bool revenge = CalamityWorld.revenge; + bool expertMode = Main.expertMode; - if (npc.ai[2] > 0f) + if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; - float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; + float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; + float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; - bool invisiblePartOfChargePhase = calamityGlobalNPC_Head.newAI[2] >= chargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= chargePhaseGateValue + 1f && (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeOne || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeTwo || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FastCharge); - bool invisiblePartOfLightningChargePhase = calamityGlobalNPC_Head.newAI[2] >= lightningChargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= lightningChargePhaseGateValue + 1f && calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.LightningCharge; - bool invisiblePhase = calamityGlobalNPC_Head.newAI[0] == 1f || calamityGlobalNPC_Head.newAI[0] == 5f || calamityGlobalNPC_Head.newAI[0] == 7f; - if (!invisiblePartOfChargePhase && !invisiblePartOfLightningChargePhase && !invisiblePhase) - { - if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - } - else - { - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } + bool invisiblePartOfChargePhase = calamityGlobalNPC_Head.newAI[2] >= chargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= chargePhaseGateValue + 1f && (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeOne || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeTwo || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FastCharge); + bool invisiblePartOfLightningChargePhase = calamityGlobalNPC_Head.newAI[2] >= lightningChargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= lightningChargePhaseGateValue + 1f && calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.LightningCharge; + bool invisiblePhase = calamityGlobalNPC_Head.newAI[0] == 1f || calamityGlobalNPC_Head.newAI[0] == 5f || calamityGlobalNPC_Head.newAI[0] == 7f; + if (!invisiblePartOfChargePhase && !invisiblePartOfLightningChargePhase && !invisiblePhase) + { + if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); num191 = (int)(num191 / 16f) * 16; @@ -154,9 +154,9 @@ namespace CalamityMod.NPCs.AdultEidolonWyrm new Microsoft.Xna.Framework.Rectangle?(npc.frame), Color.White, npc.rotation, vector11, 1f, spriteEffects, 0f); } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/AquaticScourge/AquaticParasite.cs b/NPCs/AquaticScourge/AquaticParasite.cs index 127d7d90e5..be7297ecd3 100644 --- a/NPCs/AquaticScourge/AquaticParasite.cs +++ b/NPCs/AquaticScourge/AquaticParasite.cs @@ -30,11 +30,11 @@ namespace CalamityMod.NPCs.AquaticScourge npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { diff --git a/NPCs/AquaticScourge/AquaticScourgeBody.cs b/NPCs/AquaticScourge/AquaticScourgeBody.cs index b4d8c1879e..007b371ff0 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBody.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBody.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AquaticScourge { - public class AquaticScourgeBody : ModNPC + public class AquaticScourgeBody : ModNPC { public override void SetStaticDefaults() { @@ -19,12 +19,12 @@ namespace CalamityMod.NPCs.AquaticScourge public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.width = 32; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.width = 32; npc.height = 32; npc.defense = 20; - npc.DR_NERD(0.1f); + npc.DR_NERD(0.1f); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; @@ -45,55 +45,55 @@ namespace CalamityMod.NPCs.AquaticScourge if (CalamityWorld.malice || BossRushEvent.BossRushActive) npc.scale = 1.25f; else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.chaseable); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.chaseable = reader.ReadBoolean(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; } public override void AI() { - CalamityAI.AquaticScourgeAI(npc, mod, false); - } + CalamityAI.AquaticScourgeAI(npc, mod, false); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Texture2D texture2D15 = Main.npcTexture[npc.type]; + 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { @@ -103,12 +103,12 @@ namespace CalamityMod.NPCs.AquaticScourge color = Color.Lerp(color, Color.SandyBrown, MathHelper.Clamp(Main.npc[(int)npc.ai[2]].localAI[3] / 90f, 0f, 1f)); } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool? CanBeHitByProjectile(Projectile projectile) + public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion) { diff --git a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs index 8b6e3af4a5..4341dacb97 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AquaticScourge { - public class AquaticScourgeBodyAlt : ModNPC + public class AquaticScourgeBodyAlt : ModNPC { public override void SetStaticDefaults() { @@ -19,11 +19,11 @@ namespace CalamityMod.NPCs.AquaticScourge public override void SetDefaults() { - npc.GetNPCDamage(); - npc.width = 32; + npc.GetNPCDamage(); + npc.width = 32; npc.height = 32; npc.defense = 15; - npc.DR_NERD(0.1f); + npc.DR_NERD(0.1f); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; @@ -51,48 +51,48 @@ namespace CalamityMod.NPCs.AquaticScourge npc.scale = 1.1f; npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.chaseable); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.chaseable = reader.ReadBoolean(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; } public override void AI() { - CalamityAI.AquaticScourgeAI(npc, mod, false); - } + CalamityAI.AquaticScourgeAI(npc, mod, false); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Texture2D texture2D15 = Main.npcTexture[npc.type]; + 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { @@ -104,10 +104,10 @@ namespace CalamityMod.NPCs.AquaticScourge spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool? CanBeHitByProjectile(Projectile projectile) + public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion) { diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index f1da5f0d29..b23ccc6df1 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -22,7 +22,7 @@ using CalamityMod.Items.Armor.Vanity; namespace CalamityMod.NPCs.AquaticScourge { - [AutoloadBossHead] + [AutoloadBossHead] public class AquaticScourgeHead : ModNPC { public override void SetStaticDefaults() @@ -33,12 +33,12 @@ namespace CalamityMod.NPCs.AquaticScourge public override void SetDefaults() { npc.npcSlots = 16f; - npc.GetNPCDamage(); - npc.Calamity().canBreakPlayerDefense = true; - npc.width = 90; + npc.GetNPCDamage(); + npc.Calamity().canBreakPlayerDefense = true; + npc.width = 90; npc.height = 90; npc.defense = 10; - npc.DR_NERD(0.05f); + npc.DR_NERD(0.05f); npc.aiStyle = -1; aiType = -1; npc.LifeMaxNERB(77000, 92000, 1000000); @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.AquaticScourge npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 40, 0, 0); npc.behindTiles = true; - npc.chaseable = false; + npc.chaseable = false; npc.noGravity = true; npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit1; @@ -65,52 +65,52 @@ namespace CalamityMod.NPCs.AquaticScourge npc.scale = 1.1f; npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.chaseable); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); writer.Write(npc.localAI[3]); for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + writer.Write(npc.Calamity().newAI[i]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.chaseable = reader.ReadBoolean(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); npc.localAI[3] = reader.ReadSingle(); for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void AI() { - if (npc.justHit || npc.life <= npc.lifeMax * 0.999 || BossRushEvent.BossRushActive) + if (npc.justHit || npc.life <= npc.lifeMax * 0.999 || BossRushEvent.BossRushActive) music = CalamityMod.Instance.GetMusicFromMusicMod("AquaticScourge") ?? MusicID.Boss2; - CalamityAI.AquaticScourgeAI(npc, mod, true); - } + CalamityAI.AquaticScourgeAI(npc, mod, true); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Texture2D texture2D15 = Main.npcTexture[npc.type]; + 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { @@ -122,10 +122,10 @@ namespace CalamityMod.NPCs.AquaticScourge spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { Rectangle targetHitbox = target.Hitbox; @@ -188,19 +188,19 @@ namespace CalamityMod.NPCs.AquaticScourge public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItem(npc, ItemID.GreaterHealingPotion, 8, 14); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedAquaticScourge); + DropHelper.DropItem(npc, ItemID.GreaterHealingPotion, 8, 14); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedAquaticScourge); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedAquaticScourge); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedAquaticScourge); + CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedAquaticScourge); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) { // Weapons float w = DropHelper.NormalWeaponDropRateFloat; @@ -210,11 +210,11 @@ namespace CalamityMod.NPCs.AquaticScourge DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); @@ -248,8 +248,8 @@ namespace CalamityMod.NPCs.AquaticScourge public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } + npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/AquaticScourge/AquaticScourgeTail.cs b/NPCs/AquaticScourge/AquaticScourgeTail.cs index da16f3788e..0ceff75ace 100644 --- a/NPCs/AquaticScourge/AquaticScourgeTail.cs +++ b/NPCs/AquaticScourge/AquaticScourgeTail.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AquaticScourge { - public class AquaticScourgeTail : ModNPC + public class AquaticScourgeTail : ModNPC { public override void SetStaticDefaults() { @@ -19,11 +19,11 @@ namespace CalamityMod.NPCs.AquaticScourge public override void SetDefaults() { - npc.GetNPCDamage(); - npc.width = 32; + npc.GetNPCDamage(); + npc.width = 32; npc.height = 32; npc.defense = 25; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; @@ -51,48 +51,48 @@ namespace CalamityMod.NPCs.AquaticScourge npc.scale = 1.1f; npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.chaseable); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.chaseable = reader.ReadBoolean(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; } public override void AI() { - CalamityAI.AquaticScourgeAI(npc, mod, false); - } + CalamityAI.AquaticScourgeAI(npc, mod, false); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Texture2D texture2D15 = Main.npcTexture[npc.type]; + 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { @@ -104,10 +104,10 @@ namespace CalamityMod.NPCs.AquaticScourge spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool? CanBeHitByProjectile(Projectile projectile) + public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion) { diff --git a/NPCs/AquaticScourge/AquaticSeekerBody.cs b/NPCs/AquaticScourge/AquaticSeekerBody.cs index 2e4b7fe52f..2a74e50460 100644 --- a/NPCs/AquaticScourge/AquaticSeekerBody.cs +++ b/NPCs/AquaticScourge/AquaticSeekerBody.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.AquaticScourge npc.width = 16; npc.height = 16; npc.defense = 10; - npc.lifeMax = 60; + npc.lifeMax = 60; npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; @@ -33,11 +33,11 @@ namespace CalamityMod.NPCs.AquaticScourge npc.dontCountMe = true; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -52,32 +52,32 @@ namespace CalamityMod.NPCs.AquaticScourge if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) npc.TargetClosest(true); - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/AquaticScourge/AquaticSeekerHead.cs b/NPCs/AquaticScourge/AquaticSeekerHead.cs index 6f955de7fe..8aeaae2e86 100644 --- a/NPCs/AquaticScourge/AquaticSeekerHead.cs +++ b/NPCs/AquaticScourge/AquaticSeekerHead.cs @@ -40,11 +40,11 @@ namespace CalamityMod.NPCs.AquaticScourge npc.netAlways = true; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { @@ -108,21 +108,21 @@ namespace CalamityMod.NPCs.AquaticScourge Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - if ((Main.player[npc.target].Center - npc.Center).Length() > 200f) - { - num192 -= 160; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 250f) - { - if (npc.velocity.X > 0f) - { - num191 = Main.player[npc.target].Center.X + 300f; - } - else - { - num191 = Main.player[npc.target].Center.X - 300f; - } - } - } + if ((Main.player[npc.target].Center - npc.Center).Length() > 200f) + { + num192 -= 160; + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 250f) + { + if (npc.velocity.X > 0f) + { + num191 = Main.player[npc.target].Center.X + 300f; + } + else + { + num191 = Main.player[npc.target].Center.X - 300f; + } + } + } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; float num50 = npc.velocity.Length(); diff --git a/NPCs/AquaticScourge/AquaticSeekerTail.cs b/NPCs/AquaticScourge/AquaticSeekerTail.cs index a1aae73db5..28c3c5a14c 100644 --- a/NPCs/AquaticScourge/AquaticSeekerTail.cs +++ b/NPCs/AquaticScourge/AquaticSeekerTail.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.AquaticScourge npc.width = 16; npc.height = 22; npc.defense = 20; - npc.lifeMax = 60; + npc.lifeMax = 60; npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; @@ -33,11 +33,11 @@ namespace CalamityMod.NPCs.AquaticScourge npc.dontCountMe = true; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -52,32 +52,32 @@ namespace CalamityMod.NPCs.AquaticScourge if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) npc.TargetClosest(true); - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/AquaticScourge/AquaticUrchin.cs b/NPCs/AquaticScourge/AquaticUrchin.cs index 5e13ef8e54..4d9a769eb6 100644 --- a/NPCs/AquaticScourge/AquaticUrchin.cs +++ b/NPCs/AquaticScourge/AquaticUrchin.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AquaticScourge { - public class AquaticUrchin : ModNPC + public class AquaticUrchin : ModNPC { public override void SetStaticDefaults() { @@ -30,11 +30,11 @@ namespace CalamityMod.NPCs.AquaticScourge npc.behindTiles = true; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { diff --git a/NPCs/Astral/Aries.cs b/NPCs/Astral/Aries.cs index 69f35bfd5b..ce678627ed 100644 --- a/NPCs/Astral/Aries.cs +++ b/NPCs/Astral/Aries.cs @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.Astral npc.height = 64; npc.aiStyle = 41; npc.defense = 14; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 300; npc.knockBackResist = 0.6f; npc.value = Item.buyPrice(0, 0, 10, 0); @@ -44,9 +44,9 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0.5f; npc.lifeMax = 450; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { diff --git a/NPCs/Astral/AstralProbe.cs b/NPCs/Astral/AstralProbe.cs index a398464fd4..862739994c 100644 --- a/NPCs/Astral/AstralProbe.cs +++ b/NPCs/Astral/AstralProbe.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.Astral npc.width = 30; //324 npc.height = 30; //216 npc.defense = 10; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 50; npc.aiStyle = -1; aiType = -1; @@ -43,16 +43,16 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0.85f; npc.lifeMax = 70; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { - // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - npc.damage = 0; + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + npc.damage = 0; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) { npc.TargetClosest(true); } @@ -213,28 +213,28 @@ namespace CalamityMod.NPCs.Astral } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + 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 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Astral/AstralProbeGlow"); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Astral/AstralProbeGlow"); - spriteBatch.Draw(texture2D15, vector43, npc.frame, Color.White * 0.6f, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, Color.White * 0.6f, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.soundDelay == 0) { @@ -255,9 +255,9 @@ namespace CalamityMod.NPCs.Astral if (npc.life <= 0) { - npc.position = npc.Center; + npc.position = npc.Center; npc.width = npc.height = 30; - npc.Center = npc.position; + npc.Center = npc.position; for (int d = 0; d < 5; d++) { int purple = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); @@ -276,7 +276,7 @@ namespace CalamityMod.NPCs.Astral cosmos = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); Main.dust[cosmos].velocity *= 2f; } - CalamityUtils.ExplosionGores(npc.Center, 3); + CalamityUtils.ExplosionGores(npc.Center, 3); } } diff --git a/NPCs/Astral/AstralSlime.cs b/NPCs/Astral/AstralSlime.cs index fd7d2a639c..321a47551b 100644 --- a/NPCs/Astral/AstralSlime.cs +++ b/NPCs/Astral/AstralSlime.cs @@ -42,9 +42,9 @@ namespace CalamityMod.NPCs.Astral npc.defense = 18; npc.lifeMax = 310; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { diff --git a/NPCs/Astral/AstralachneaGround.cs b/NPCs/Astral/AstralachneaGround.cs index 81f5c2f36e..6d70780c8d 100644 --- a/NPCs/Astral/AstralachneaGround.cs +++ b/NPCs/Astral/AstralachneaGround.cs @@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.Astral npc.aiStyle = 3; npc.damage = 55; npc.defense = 20; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 500; npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); npc.knockBackResist = 0.38f; @@ -52,9 +52,9 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0.28f; npc.lifeMax = 750; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { diff --git a/NPCs/Astral/AstralachneaWall.cs b/NPCs/Astral/AstralachneaWall.cs index a493d41cc1..d36b001a47 100644 --- a/NPCs/Astral/AstralachneaWall.cs +++ b/NPCs/Astral/AstralachneaWall.cs @@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.Astral npc.aiStyle = -1; npc.damage = 55; npc.defense = 20; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 500; npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); npc.knockBackResist = 0f; @@ -52,9 +52,9 @@ namespace CalamityMod.NPCs.Astral npc.defense = 30; npc.lifeMax = 750; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { diff --git a/NPCs/Astral/Atlas.cs b/NPCs/Astral/Atlas.cs index 3d292c03da..107a40b2b4 100644 --- a/NPCs/Astral/Atlas.cs +++ b/NPCs/Astral/Atlas.cs @@ -101,13 +101,13 @@ namespace CalamityMod.NPCs.Astral public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.lavaImmune = true; + npc.Calamity().canBreakPlayerDefense = true; + npc.lavaImmune = true; npc.width = 78; npc.height = 88; npc.damage = 70; npc.defense = 40; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 1200; npc.knockBackResist = 0.08f; npc.value = Item.buyPrice(0, 1, 0, 0); @@ -129,14 +129,14 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0f; npc.lifeMax = 2400; } - if (CalamityWorld.death) - { - target_walkAcceleration = 0.18f; - target_walkMaxSpeed = 3.2f; - } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + if (CalamityWorld.death) + { + target_walkAcceleration = 0.18f; + target_walkMaxSpeed = 3.2f; + } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/Astral/BigSightseer.cs b/NPCs/Astral/BigSightseer.cs index 4bbd7d8808..598c825e46 100644 --- a/NPCs/Astral/BigSightseer.cs +++ b/NPCs/Astral/BigSightseer.cs @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.Astral npc.height = 56; npc.damage = 50; npc.defense = 20; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 430; npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); npc.noGravity = true; @@ -46,9 +46,9 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0.7f; npc.lifeMax = 640; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { diff --git a/NPCs/Astral/EnchantedNightcrawler.cs b/NPCs/Astral/EnchantedNightcrawler.cs index 99cb60152e..2626890ffc 100644 --- a/NPCs/Astral/EnchantedNightcrawler.cs +++ b/NPCs/Astral/EnchantedNightcrawler.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Astral { - public class EnchantedNightcrawler : ModNPC + public class EnchantedNightcrawler : ModNPC { public override void SetStaticDefaults() { diff --git a/NPCs/Astral/FusionFeeder.cs b/NPCs/Astral/FusionFeeder.cs index 1281cd8dd4..0887dd01cb 100644 --- a/NPCs/Astral/FusionFeeder.cs +++ b/NPCs/Astral/FusionFeeder.cs @@ -33,7 +33,7 @@ namespace CalamityMod.NPCs.Astral npc.aiStyle = 103; npc.lifeMax = 400; npc.defense = 12; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.value = Item.buyPrice(0, 0, 20, 0); npc.knockBackResist = 0.8f; npc.behindTiles = true; @@ -48,9 +48,9 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0.7f; npc.lifeMax = 600; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { diff --git a/NPCs/Astral/Hadarian.cs b/NPCs/Astral/Hadarian.cs index 284d758a8e..f8f64d65d2 100644 --- a/NPCs/Astral/Hadarian.cs +++ b/NPCs/Astral/Hadarian.cs @@ -32,7 +32,7 @@ namespace CalamityMod.NPCs.Astral npc.aiStyle = -1; npc.damage = 50; npc.defense = 8; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 330; npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); npc.knockBackResist = 0.75f; @@ -46,9 +46,9 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0.65f; npc.lifeMax = 490; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { diff --git a/NPCs/Astral/Hive.cs b/NPCs/Astral/Hive.cs index 7ad53df4c6..8c83ed041f 100644 --- a/NPCs/Astral/Hive.cs +++ b/NPCs/Astral/Hive.cs @@ -31,7 +31,7 @@ namespace CalamityMod.NPCs.Astral npc.aiStyle = -1; npc.damage = 55; npc.defense = 15; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 470; npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); npc.knockBackResist = 0f; @@ -44,9 +44,9 @@ namespace CalamityMod.NPCs.Astral npc.defense = 25; npc.lifeMax = 700; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { diff --git a/NPCs/Astral/Hiveling.cs b/NPCs/Astral/Hiveling.cs index bfb859b41c..0efee48996 100644 --- a/NPCs/Astral/Hiveling.cs +++ b/NPCs/Astral/Hiveling.cs @@ -40,9 +40,9 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0.4f; npc.lifeMax = 220; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { @@ -65,18 +65,18 @@ namespace CalamityMod.NPCs.Astral else { CalamityGlobalNPC.DoFlyingAI(npc, (CalamityWorld.death ? 4.5f : 3f), (CalamityWorld.death ? 0.075f : 0.05f), 200f); - Player myTarget = Main.player[npc.target]; - Vector2 toTarget = myTarget.Center - npc.Center; - if (!myTarget.dead && myTarget.active) - { - npc.spriteDirection = npc.direction = (toTarget.X > 0).ToDirectionInt(); - } - else - { - npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); - } - if (npc.spriteDirection == 1) - npc.rotation += MathHelper.Pi; + Player myTarget = Main.player[npc.target]; + Vector2 toTarget = myTarget.Center - npc.Center; + if (!myTarget.dead && myTarget.active) + { + npc.spriteDirection = npc.direction = (toTarget.X > 0).ToDirectionInt(); + } + else + { + npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); + } + if (npc.spriteDirection == 1) + npc.rotation += MathHelper.Pi; } } diff --git a/NPCs/Astral/Mantis.cs b/NPCs/Astral/Mantis.cs index a70dac9c56..e65eabd0a4 100644 --- a/NPCs/Astral/Mantis.cs +++ b/NPCs/Astral/Mantis.cs @@ -28,13 +28,13 @@ namespace CalamityMod.NPCs.Astral public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.damage = 55; + npc.Calamity().canBreakPlayerDefense = true; + npc.damage = 55; npc.width = 60; npc.height = 58; npc.aiStyle = -1; npc.defense = 6; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 340; npc.knockBackResist = 0.2f; npc.value = Item.buyPrice(0, 0, 15, 0); @@ -48,9 +48,9 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0.1f; npc.lifeMax = 510; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { diff --git a/NPCs/Astral/Nova.cs b/NPCs/Astral/Nova.cs index 5f6bbaf14b..fda528223c 100644 --- a/NPCs/Astral/Nova.cs +++ b/NPCs/Astral/Nova.cs @@ -40,7 +40,7 @@ namespace CalamityMod.NPCs.Astral npc.height = 50; npc.damage = 45; npc.defense = 15; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 230; npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); npc.noGravity = true; @@ -56,14 +56,14 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0.4f; npc.lifeMax = 350; } - if (CalamityWorld.death) - { - travelAcceleration = 0.3f; - targetTime = 60f; - } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + if (CalamityWorld.death) + { + travelAcceleration = 0.3f; + targetTime = 60f; + } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { @@ -119,9 +119,9 @@ namespace CalamityMod.NPCs.Astral Vector2 between = target.Center - npc.Center; - //after locking target for x amount of time and being far enough away - int random = CalamityWorld.death ? 90 : 180; - if (between.Length() > 150 && npc.ai[3] >= targetTime && Main.rand.NextBool(random)) + //after locking target for x amount of time and being far enough away + int random = CalamityWorld.death ? 90 : 180; + if (between.Length() > 150 && npc.ai[3] >= targetTime && Main.rand.NextBool(random)) { //set ai mode to target and travel npc.ai[3] = -1f; diff --git a/NPCs/Astral/SmallSightseer.cs b/NPCs/Astral/SmallSightseer.cs index 5e9b33e5e0..949cebc579 100644 --- a/NPCs/Astral/SmallSightseer.cs +++ b/NPCs/Astral/SmallSightseer.cs @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.Astral npc.height = 40; npc.damage = 38; npc.defense = 16; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 310; npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AstralEnemyDeath"); npc.noGravity = true; @@ -46,9 +46,9 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0.48f; npc.lifeMax = 460; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { diff --git a/NPCs/Astral/StellarCulex.cs b/NPCs/Astral/StellarCulex.cs index 466f049742..5544fa4540 100644 --- a/NPCs/Astral/StellarCulex.cs +++ b/NPCs/Astral/StellarCulex.cs @@ -33,7 +33,7 @@ namespace CalamityMod.NPCs.Astral npc.npcSlots = 0.5f; //needed? npc.damage = 55; npc.defense = 18; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.knockBackResist = 0.65f; npc.lifeMax = 210; npc.value = Item.buyPrice(0, 0, 10, 0); @@ -48,9 +48,9 @@ namespace CalamityMod.NPCs.Astral npc.knockBackResist = 0.55f; npc.lifeMax = 320; } - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { diff --git a/NPCs/Astral/Twinkler.cs b/NPCs/Astral/Twinkler.cs index 56fe8cdb68..7bd5f49a0e 100644 --- a/NPCs/Astral/Twinkler.cs +++ b/NPCs/Astral/Twinkler.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Astral { - public class Twinkler : ModNPC + public class Twinkler : ModNPC { public override void SetStaticDefaults() { diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index 5a03d01603..6f7d2cd113 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -25,7 +25,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AstrumAureus { - [AutoloadBossHead] + [AutoloadBossHead] public class AstrumAureus : ModNPC { private bool stomping = false; @@ -34,20 +34,20 @@ namespace CalamityMod.NPCs.AstrumAureus { DisplayName.SetDefault("Astrum Aureus"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { npc.lavaImmune = true; - npc.noGravity = true; + npc.noGravity = true; npc.npcSlots = 15f; - npc.GetNPCDamage(); - npc.Calamity().canBreakPlayerDefense = true; - npc.width = 374; + npc.GetNPCDamage(); + npc.Calamity().canBreakPlayerDefense = true; + npc.width = 374; npc.height = 374; npc.defense = 40; - npc.DR_NERD(0.5f); + npc.DR_NERD(0.5f); npc.LifeMaxNERB(NPC.downedMoonlord ? 196000 : 98000, NPC.downedMoonlord ? 235200 : 117600, 740000); // 30 seconds in boss rush npc.aiStyle = -1; aiType = -1; @@ -59,27 +59,27 @@ namespace CalamityMod.NPCs.AstrumAureus bossBag = ModContent.ItemType(); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(stomping); + writer.Write(stomping); writer.Write(npc.alpha); writer.Write(npc.localAI[2]); for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { - stomping = reader.ReadBoolean(); + stomping = reader.ReadBoolean(); npc.alpha = reader.ReadInt32(); npc.localAI[2] = reader.ReadSingle(); for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void AI() { @@ -246,60 +246,60 @@ namespace CalamityMod.NPCs.AstrumAureus } } - int frameCount = Main.npcFrameCount[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / frameCount / 2); + int frameCount = Main.npcFrameCount[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / frameCount / 2); Rectangle frame = npc.frame; float scale = npc.scale; float rotation = npc.rotation; float offsetY = npc.gfxOffY; - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; - if (npc.ai[0] == 3f || npc.ai[0] == 4f) - num153 = 10; + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 7; + if (npc.ai[0] == 3f || npc.ai[0] == 4f) + num153 = 10; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; - vector41 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(NPCTexture, vector41, frame, color38, rotation, vector11, scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = drawColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; + vector41 += vector11 * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(NPCTexture, vector41, frame, color38, rotation, vector11, scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; - vector43 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(NPCTexture, vector43, frame, npc.GetAlpha(drawColor), rotation, vector11, scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; + vector43 += vector11 * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(NPCTexture, vector43, frame, npc.GetAlpha(drawColor), rotation, vector11, scale, spriteEffects, 0f); - if (npc.ai[0] != 1) //draw only if not recharging + if (npc.ai[0] != 1) //draw only if not recharging { Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Color.Gold); - Color color40 = Color.Lerp(Color.White, color, 0.5f); + Color color40 = Color.Lerp(Color.White, color, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color40; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(GlowMaskTexture.Width, GlowMaskTexture.Height / frameCount) * scale / 2f; - vector44 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(GlowMaskTexture, vector44, frame, color41, rotation, vector11, scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color40; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(GlowMaskTexture.Width, GlowMaskTexture.Height / frameCount) * scale / 2f; + vector44 += vector11 * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(GlowMaskTexture, vector44, frame, color41, rotation, vector11, scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(GlowMaskTexture, vector43, frame, color40, rotation, vector11, scale, spriteEffects, 0f); - } + spriteBatch.Draw(GlowMaskTexture, vector43, frame, color40, rotation, vector11, scale, spriteEffects, 0f); + } return false; } @@ -311,17 +311,17 @@ namespace CalamityMod.NPCs.AstrumAureus public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedAstrageldon); - CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Wizard, ModContent.NPCType() }, CalamityWorld.downedAstrageldon); + CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Wizard, ModContent.NPCType() }, CalamityWorld.downedAstrageldon); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) { // Materials DropHelper.DropItemSpray(npc, ModContent.ItemType(), 20, 30, 2); @@ -335,14 +335,14 @@ namespace CalamityMod.NPCs.AstrumAureus DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w) - ); + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedMoonlord); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedMoonlord); - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); // Other DropHelper.DropItem(npc, ModContent.ItemType(), 9, 12); @@ -353,8 +353,8 @@ namespace CalamityMod.NPCs.AstrumAureus // Other DropHelper.DropItemChance(npc, ItemID.HallowedKey, 3); - // Drop an Astral Meteor if applicable - ThreadPool.QueueUserWorkItem(_ => AstralBiome.PlaceAstralMeteor()); + // Drop an Astral Meteor if applicable + ThreadPool.QueueUserWorkItem(_ => AstralBiome.PlaceAstralMeteor()); // If Astrum Aureus has not yet been killed, notify players of new Astral enemy drops if (!CalamityWorld.downedAstrageldon) @@ -419,71 +419,71 @@ namespace CalamityMod.NPCs.AstrumAureus npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); } - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - Vector2 npcCenter = npc.Center; + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Vector2 npcCenter = npc.Center; - // NOTE: Right and left hitboxes are interchangeable, each hitbox is the same size and is located to the right or left of the center hitbox. - Rectangle leftHitbox = new Rectangle((int)(npcCenter.X - 93f - 5f + 4f), (int)(npcCenter.Y + 33f - 5f), 10, 10); - Rectangle bodyHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 4f)), (int)(npcCenter.Y - (npc.height / 2f) + 24f), npc.width / 2, npc.height); - Rectangle rightHitbox = new Rectangle((int)(npcCenter.X + 93f - 5f - 4f), (int)(npcCenter.Y + 33f - 5f), 10, 10); + // NOTE: Right and left hitboxes are interchangeable, each hitbox is the same size and is located to the right or left of the center hitbox. + Rectangle leftHitbox = new Rectangle((int)(npcCenter.X - 93f - 5f + 4f), (int)(npcCenter.Y + 33f - 5f), 10, 10); + Rectangle bodyHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 4f)), (int)(npcCenter.Y - (npc.height / 2f) + 24f), npc.width / 2, npc.height); + Rectangle rightHitbox = new Rectangle((int)(npcCenter.X + 93f - 5f - 4f), (int)(npcCenter.Y + 33f - 5f), 10, 10); - Vector2 leftHitboxCenter = new Vector2(leftHitbox.X + (leftHitbox.Width / 2), leftHitbox.Y + (leftHitbox.Height / 2)); - Vector2 bodyHitboxCenter = new Vector2(bodyHitbox.X + (bodyHitbox.Width / 2), bodyHitbox.Y + (bodyHitbox.Height / 2)); - Vector2 rightHitboxCenter = new Vector2(rightHitbox.X + (rightHitbox.Width / 2), rightHitbox.Y + (rightHitbox.Height / 2)); + Vector2 leftHitboxCenter = new Vector2(leftHitbox.X + (leftHitbox.Width / 2), leftHitbox.Y + (leftHitbox.Height / 2)); + Vector2 bodyHitboxCenter = new Vector2(bodyHitbox.X + (bodyHitbox.Width / 2), bodyHitbox.Y + (bodyHitbox.Height / 2)); + Vector2 rightHitboxCenter = new Vector2(rightHitbox.X + (rightHitbox.Width / 2), rightHitbox.Y + (rightHitbox.Height / 2)); - Rectangle targetHitbox = target.Hitbox; + Rectangle targetHitbox = target.Hitbox; - float leftDist1 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopLeft()); - float leftDist2 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopRight()); - float leftDist3 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomLeft()); - float leftDist4 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomRight()); + float leftDist1 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopLeft()); + float leftDist2 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopRight()); + float leftDist3 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomLeft()); + float leftDist4 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomRight()); - float minLeftDist = leftDist1; - if (leftDist2 < minLeftDist) - minLeftDist = leftDist2; - if (leftDist3 < minLeftDist) - minLeftDist = leftDist3; - if (leftDist4 < minLeftDist) - minLeftDist = leftDist4; + float minLeftDist = leftDist1; + if (leftDist2 < minLeftDist) + minLeftDist = leftDist2; + if (leftDist3 < minLeftDist) + minLeftDist = leftDist3; + if (leftDist4 < minLeftDist) + minLeftDist = leftDist4; - bool insideLeftHitbox = minLeftDist <= 120f; + bool insideLeftHitbox = minLeftDist <= 120f; - float bodyDist1 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopLeft()); - float bodyDist2 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopRight()); - float bodyDist3 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomLeft()); - float bodyDist4 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomRight()); + float bodyDist1 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopLeft()); + float bodyDist2 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopRight()); + float bodyDist3 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomLeft()); + float bodyDist4 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomRight()); - float minBodyDist = bodyDist1; - if (bodyDist2 < minBodyDist) - minBodyDist = bodyDist2; - if (bodyDist3 < minBodyDist) - minBodyDist = bodyDist3; - if (bodyDist4 < minBodyDist) - minBodyDist = bodyDist4; + float minBodyDist = bodyDist1; + if (bodyDist2 < minBodyDist) + minBodyDist = bodyDist2; + if (bodyDist3 < minBodyDist) + minBodyDist = bodyDist3; + if (bodyDist4 < minBodyDist) + minBodyDist = bodyDist4; - bool insideBodyHitbox = minBodyDist <= 160f; + bool insideBodyHitbox = minBodyDist <= 160f; - float rightDist1 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopLeft()); - float rightDist2 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopRight()); - float rightDist3 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomLeft()); - float rightDist4 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomRight()); + float rightDist1 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopLeft()); + float rightDist2 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopRight()); + float rightDist3 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomLeft()); + float rightDist4 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomRight()); - float minRightDist = rightDist1; - if (rightDist2 < minRightDist) - minRightDist = rightDist2; - if (rightDist3 < minRightDist) - minRightDist = rightDist3; - if (rightDist4 < minRightDist) - minRightDist = rightDist4; + float minRightDist = rightDist1; + if (rightDist2 < minRightDist) + minRightDist = rightDist2; + if (rightDist3 < minRightDist) + minRightDist = rightDist3; + if (rightDist4 < minRightDist) + minRightDist = rightDist4; - bool insideRightHitbox = minRightDist <= 120f; + bool insideRightHitbox = minRightDist <= 120f; - return (insideLeftHitbox || insideBodyHitbox || insideRightHitbox) && npc.alpha == 0 && npc.ai[0] > 1f; - } + return (insideLeftHitbox || insideBodyHitbox || insideRightHitbox) && npc.alpha == 0 && npc.ai[0] > 1f; + } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 240, true); } diff --git a/NPCs/AstrumAureus/AureusSpawn.cs b/NPCs/AstrumAureus/AureusSpawn.cs index 7b401cd88f..f20c19cf92 100644 --- a/NPCs/AstrumAureus/AureusSpawn.cs +++ b/NPCs/AstrumAureus/AureusSpawn.cs @@ -19,16 +19,16 @@ namespace CalamityMod.NPCs.AstrumAureus { DisplayName.SetDefault("Aureus Spawn"); Main.npcFrameCount[npc.type] = 4; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.aiStyle = -1; + npc.Calamity().canBreakPlayerDefense = true; + npc.aiStyle = -1; aiType = -1; - npc.GetNPCDamage(); - npc.width = 90; + npc.GetNPCDamage(); + npc.width = 90; npc.height = 60; npc.alpha = 255; npc.defense = 10; @@ -39,23 +39,23 @@ namespace CalamityMod.NPCs.AstrumAureus npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.dontTakeDamage = reader.ReadBoolean(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - npc.damage = 0; + writer.Write(npc.dontTakeDamage); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.dontTakeDamage = reader.ReadBoolean(); + } + + public override void AI() + { + npc.damage = 0; Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.6f, 0.25f, 0f); @@ -78,25 +78,25 @@ namespace CalamityMod.NPCs.AstrumAureus npc.TargetClosest(); - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - if (lifeRatio <= 0.5f || Main.dayTime) + if (lifeRatio <= 0.5f || Main.dayTime) { - npc.ai[1] += 1f; - npc.dontTakeDamage = true; + npc.ai[1] += 1f; + npc.dontTakeDamage = true; Vector2 vector = Main.player[npc.target].Center - npc.Center; Point point15 = npc.Center.ToTileCoordinates(); Tile tileSafely = Framing.GetTileSafely(point15); bool flag121 = tileSafely.nactive() && Main.tileSolid[tileSafely.type] && !Main.tileSolidTop[tileSafely.type] && !TileID.Sets.Platforms[tileSafely.type]; - if (npc.ai[1] > ((CalamityWorld.death || BossRushEvent.BossRushActive) ? 600f : 300f)) - { - npc.Calamity().newAI[0] += 1f; - npc.scale = MathHelper.Lerp(1f, 2f, npc.Calamity().newAI[0] / 45f); - } - if (vector.Length() < 60f || flag121 || npc.Calamity().newAI[0] >= 45f) + if (npc.ai[1] > ((CalamityWorld.death || BossRushEvent.BossRushActive) ? 600f : 300f)) { - npc.dontTakeDamage = false; + npc.Calamity().newAI[0] += 1f; + npc.scale = MathHelper.Lerp(1f, 2f, npc.Calamity().newAI[0] / 45f); + } + if (vector.Length() < 60f || flag121 || npc.Calamity().newAI[0] >= 45f) + { + npc.dontTakeDamage = false; CheckDead(); npc.life = 0; return; @@ -113,7 +113,7 @@ namespace CalamityMod.NPCs.AstrumAureus npc.velocity.Y = (npc.velocity.Y * 50f + num1374) / 51f; if (CalamityWorld.death || BossRushEvent.BossRushActive) - { + { float pushVelocity = 0.5f; for (int i = 0; i < Main.maxNPCs; i++) { @@ -224,7 +224,7 @@ namespace CalamityMod.NPCs.AstrumAureus } } - npc.ai[0] += 1f; + npc.ai[0] += 1f; if (npc.ai[0] >= num1447 && Main.netMode != NetmodeID.MultiplayerClient) { npc.ai[0] = 0f; @@ -268,69 +268,69 @@ namespace CalamityMod.NPCs.AstrumAureus } } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.5f * bossLifeScale); - } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.5f * bossLifeScale); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (npc.Calamity().newAI[0] >= 45f) - return false; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (npc.Calamity().newAI[0] >= 45f) + return false; - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 10; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 10; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/AstrumAureus/AureusSpawnGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/AstrumAureus/AureusSpawnGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -358,9 +358,9 @@ namespace CalamityMod.NPCs.AstrumAureus player.AddBuff(ModContent.BuffType(), 120, true); } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override bool CheckDead() + public override bool CheckDead() { Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 14); npc.position.X = npc.position.X + (float)(npc.width / 2); diff --git a/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs b/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs index 423c0c2436..a75810d95d 100644 --- a/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs @@ -16,19 +16,19 @@ namespace CalamityMod.NPCs.AstrumDeus public override void SetStaticDefaults() { DisplayName.SetDefault("Astrum Deus"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 38; npc.height = 44; npc.defense = 35; - npc.DR_NERD(0.2f); - npc.LifeMaxNERB(200000, 240000, 650000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.DR_NERD(0.2f); + npc.LifeMaxNERB(200000, 240000, 650000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -54,9 +54,9 @@ namespace CalamityMod.NPCs.AstrumDeus npc.boss = true; music = CalamityMod.Instance.GetMusicFromMusicMod("AstrumDeus") ?? MusicID.Boss3; npc.dontCountMe = true; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -79,91 +79,91 @@ namespace CalamityMod.NPCs.AstrumDeus public override void AI() { - CalamityAI.AstrumDeusAI(npc, mod, false); + CalamityAI.AstrumDeusAI(npc, mod, false); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - bool altBodyTextures = npc.localAI[3] == 1f; - bool drawCyan = npc.Calamity().newAI[3] >= 600f; + bool altBodyTextures = npc.localAI[3] == 1f; + bool drawCyan = npc.Calamity().newAI[3] >= 600f; bool deathModeEnragePhase = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 3f; bool doubleWormPhase = npc.Calamity().newAI[0] != 0f && !deathModeEnragePhase; - Texture2D texture2D15 = altBodyTextures ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltSpectral") : Main.npcTexture[npc.type]; - Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow2"); - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = deathModeEnragePhase ? 10 : 5; + Texture2D texture2D15 = altBodyTextures ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltSpectral") : Main.npcTexture[npc.type]; + Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow2"); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = deathModeEnragePhase ? 10 : 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = altBodyTextures ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltGlow") : ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow"); - Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; - if (doubleWormPhase) - { - texture2D15 = drawCyan ? texture2D15 : (altBodyTextures ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltGlow2") : ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow3")); - texture2D16 = drawCyan ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow4") : texture2D16; - } - Color color37 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Cyan, 0.5f) * (deathModeEnragePhase ? 1f : npc.Opacity); - Color color42 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : npc.Opacity); + texture2D15 = altBodyTextures ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltGlow") : ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow"); + Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; + if (doubleWormPhase) + { + texture2D15 = drawCyan ? texture2D15 : (altBodyTextures ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyAltGlow2") : ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow3")); + texture2D16 = drawCyan ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow4") : texture2D16; + } + Color color37 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Cyan, 0.5f) * (deathModeEnragePhase ? 1f : npc.Opacity); + Color color42 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : npc.Opacity); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - if (!altBodyTextures) - { - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } - } + if (!altBodyTextures) + { + Color color43 = color42; + color43 = Color.Lerp(color43, color36, amount9); + color43 *= (num153 - num163) / 15f; + spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + } - int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 1 : 2; - for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 1 : 2; + for (int i = 0; i < timesToDraw; i++) + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - if (!altBodyTextures) - { - timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; - for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + if (!altBodyTextures) + { + timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; + for (int i = 0; i < timesToDraw; i++) + spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } - return false; + return false; } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -171,7 +171,7 @@ namespace CalamityMod.NPCs.AstrumDeus return !npc.dontTakeDamage; } - public override bool CheckActive() + public override bool CheckActive() { return false; } diff --git a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs index cd534fa10e..e44c6d78d1 100644 --- a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs @@ -29,20 +29,20 @@ namespace CalamityMod.NPCs.AstrumDeus public override void SetStaticDefaults() { DisplayName.SetDefault("Astrum Deus"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 56; npc.height = 56; npc.defense = 20; - npc.DR_NERD(0.1f); - npc.LifeMaxNERB(200000, 240000, 650000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.DR_NERD(0.1f); + npc.LifeMaxNERB(200000, 240000, 650000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -68,9 +68,9 @@ namespace CalamityMod.NPCs.AstrumDeus npc.netAlways = true; music = CalamityMod.Instance.GetMusicFromMusicMod("AstrumDeus") ?? MusicID.Boss3; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -88,8 +88,8 @@ namespace CalamityMod.NPCs.AstrumDeus public override void AI() { - CalamityAI.AstrumDeusAI(npc, mod, true); - } + CalamityAI.AstrumDeusAI(npc, mod, true); + } public override bool CheckActive() { @@ -98,82 +98,82 @@ namespace CalamityMod.NPCs.AstrumDeus public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - bool drawCyan = npc.Calamity().newAI[3] >= 600f; + bool drawCyan = npc.Calamity().newAI[3] >= 600f; bool deathModeEnragePhase = npc.Calamity().newAI[0] == 3f; bool doubleWormPhase = npc.Calamity().newAI[0] != 0f && !deathModeEnragePhase; Texture2D texture2D15 = Main.npcTexture[npc.type]; - Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow2"); - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = deathModeEnragePhase ? 10 : 5; + Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow2"); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = deathModeEnragePhase ? 10 : 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow"); - Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; - if (doubleWormPhase) - { - texture2D15 = drawCyan ? texture2D15 : ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow3"); - texture2D16 = drawCyan ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow4") : texture2D16; - } - Color color37 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Cyan, 0.5f) * (deathModeEnragePhase ? 1f : npc.Opacity); - Color color42 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : npc.Opacity); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow"); + Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; + if (doubleWormPhase) + { + texture2D15 = drawCyan ? texture2D15 : ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow3"); + texture2D16 = drawCyan ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusHeadGlow4") : texture2D16; + } + Color color37 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Cyan, 0.5f) * (deathModeEnragePhase ? 1f : npc.Opacity); + Color color42 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : npc.Opacity); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + Color color43 = color42; + color43 = Color.Lerp(color43, color36, amount9); + color43 *= (num153 - num163) / 15f; + spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 1 : 2; - for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 1 : 2; + for (int i = 0; i < timesToDraw; i++) + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; - for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; + for (int i = 0; i < timesToDraw; i++) + spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; + return false; } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { @@ -208,10 +208,10 @@ namespace CalamityMod.NPCs.AstrumDeus public override bool SpecialNPCLoot() { - if (npc.Calamity().newAI[0] == 0f || ((CalamityWorld.death || BossRushEvent.BossRushActive) && npc.Calamity().newAI[0] != 3f)) - return false; + if (npc.Calamity().newAI[0] == 0f || ((CalamityWorld.death || BossRushEvent.BossRushActive) && npc.Calamity().newAI[0] != 3f)) + return false; - int closestSegmentID = DropHelper.FindClosestWormSegment(npc, + int closestSegmentID = DropHelper.FindClosestWormSegment(npc, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType()); @@ -220,15 +220,15 @@ namespace CalamityMod.NPCs.AstrumDeus return false; } - public override bool PreNPCLoot() + public override bool PreNPCLoot() { - // Unsplit Deus does not drop anything when killed/despawned. - if (npc.Calamity().newAI[0] == 0f || ((CalamityWorld.death || BossRushEvent.BossRushActive) && npc.Calamity().newAI[0] != 3f)) - return false; + // Unsplit Deus does not drop anything when killed/despawned. + if (npc.Calamity().newAI[0] == 0f || ((CalamityWorld.death || BossRushEvent.BossRushActive) && npc.Calamity().newAI[0] != 3f)) + return false; // Killing ANY split Deus makes all other Deus heads die immediately. for (int i = 0; i < Main.maxNPCs; ++i) - { + { NPC otherWormHead = Main.npc[i]; if (otherWormHead.active && otherWormHead.type == npc.type) { @@ -238,18 +238,18 @@ namespace CalamityMod.NPCs.AstrumDeus otherWormHead.checkDead(); otherWormHead.netUpdate = true; } - } + } return true; } public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItem(npc, ItemID.GreaterHealingPotion, 8, 14); + DropHelper.DropItem(npc, ItemID.GreaterHealingPotion, 8, 14); DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), !CalamityWorld.downedStarGod); DropHelper.DropItemCondition(npc, ModContent.ItemType(), !CalamityWorld.downedStarGod); @@ -276,11 +276,11 @@ namespace CalamityMod.NPCs.AstrumDeus DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w) - ); + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 5); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 5); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); diff --git a/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs b/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs index 01bacf6311..6f13b4c99e 100644 --- a/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs @@ -16,19 +16,19 @@ namespace CalamityMod.NPCs.AstrumDeus public override void SetStaticDefaults() { DisplayName.SetDefault("Astrum Deus"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 52; npc.height = 68; npc.defense = 50; - npc.DR_NERD(0.3f); - npc.LifeMaxNERB(200000, 240000, 650000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.DR_NERD(0.3f); + npc.LifeMaxNERB(200000, 240000, 650000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -54,9 +54,9 @@ namespace CalamityMod.NPCs.AstrumDeus npc.boss = true; music = CalamityMod.Instance.GetMusicFromMusicMod("AstrumDeus") ?? MusicID.Boss3; npc.dontCountMe = true; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -79,72 +79,72 @@ namespace CalamityMod.NPCs.AstrumDeus public override void AI() { - CalamityAI.AstrumDeusAI(npc, mod, false); - } + CalamityAI.AstrumDeusAI(npc, mod, false); + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - bool drawCyan = npc.Calamity().newAI[3] >= 600f; + bool drawCyan = npc.Calamity().newAI[3] >= 600f; bool deathModeEnragePhase = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 3f; bool doubleWormPhase = npc.Calamity().newAI[0] != 0f && !deathModeEnragePhase; Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = deathModeEnragePhase ? 10 : 5; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = deathModeEnragePhase ? 10 : 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusTailGlow"); - Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; - if (doubleWormPhase) - { - texture2D15 = drawCyan ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusTailGlow2") : texture2D15; - } - Color color37 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : npc.Opacity); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusTailGlow"); + Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; + if (doubleWormPhase) + { + texture2D15 = drawCyan ? ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusTailGlow2") : texture2D15; + } + Color color37 = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : npc.Opacity); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; - for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; + for (int i = 0; i < timesToDraw; i++) + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; + return false; } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -152,7 +152,7 @@ namespace CalamityMod.NPCs.AstrumDeus return !npc.dontTakeDamage; } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { diff --git a/NPCs/BrimstoneElemental/Brimling.cs b/NPCs/BrimstoneElemental/Brimling.cs index 57e0b19120..c6d1e05e78 100644 --- a/NPCs/BrimstoneElemental/Brimling.cs +++ b/NPCs/BrimstoneElemental/Brimling.cs @@ -31,7 +31,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental npc.width = 60; npc.height = 60; npc.defense = 0; - npc.DR_NERD(normalDR); + npc.DR_NERD(normalDR); npc.lifeMax = 2000; npc.knockBackResist = 0f; npc.noGravity = true; @@ -47,10 +47,10 @@ namespace CalamityMod.NPCs.BrimstoneElemental { npc.lifeMax = 10000; } - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -152,8 +152,8 @@ namespace CalamityMod.NPCs.BrimstoneElemental 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; + 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++) { @@ -245,17 +245,17 @@ namespace CalamityMod.NPCs.BrimstoneElemental } } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index d914a5821e..cbcd64170c 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.cs @@ -21,7 +21,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.BrimstoneElemental { - [AutoloadBossHead] + [AutoloadBossHead] public class BrimstoneElemental : ModNPC { public override void SetStaticDefaults() @@ -33,13 +33,13 @@ namespace CalamityMod.NPCs.BrimstoneElemental public override void SetDefaults() { npc.npcSlots = 64f; - npc.GetNPCDamage(); - npc.width = 100; + npc.GetNPCDamage(); + npc.width = 100; npc.height = 150; npc.defense = 15; npc.value = Item.buyPrice(0, 40, 0, 0); npc.LifeMaxNERB(41000, 49200, 780000); - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { npc.damage *= 3; @@ -60,35 +60,35 @@ namespace CalamityMod.NPCs.BrimstoneElemental npc.DeathSound = SoundID.NPCDeath39; music = CalamityMod.Instance.GetMusicFromMusicMod("BrimstoneElemental") ?? MusicID.Boss4; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(npc.chaseable); - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[3]); - for (int i = 0; i < 4; i++) + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[3]); + for (int i = 0; i < 4; i++) writer.Write(npc.Calamity().newAI[i]); } public override void ReceiveExtraAI(BinaryReader reader) { npc.chaseable = reader.ReadBoolean(); - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) npc.Calamity().newAI[i] = reader.ReadSingle(); - } + } public override void AI() { - CalamityAI.BrimstoneElementalAI(npc, mod); - } + CalamityAI.BrimstoneElementalAI(npc, mod); + } public override void OnHitPlayer(Player player, int damage, bool crit) { @@ -151,22 +151,22 @@ namespace CalamityMod.NPCs.BrimstoneElemental public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedBrimstoneElemental); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedBrimstoneElemental); - CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Wizard }, CalamityWorld.downedBrimstoneElemental); + CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Wizard }, CalamityWorld.downedBrimstoneElemental); - if (!Main.expertMode) + if (!Main.expertMode) { - //Materials + //Materials DropHelper.DropItemSpray(npc, ModContent.ItemType(), 4, 8); if (CalamityWorld.downedProvidence) - DropHelper.DropItemSpray(npc, ModContent.ItemType(), 20, 30, 2); + DropHelper.DropItemSpray(npc, ModContent.ItemType(), 20, 30, 2); // Weapons float w = DropHelper.NormalWeaponDropRateFloat; @@ -174,16 +174,16 @@ namespace CalamityMod.NPCs.BrimstoneElemental DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); DropHelper.DropItem(npc, ModContent.ItemType(), true); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence); - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); } DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); diff --git a/NPCs/Bumblebirb/Bumblefuck.cs b/NPCs/Bumblebirb/Bumblefuck.cs index 57c2c1ee8c..075e731a6a 100644 --- a/NPCs/Bumblebirb/Bumblefuck.cs +++ b/NPCs/Bumblebirb/Bumblefuck.cs @@ -28,66 +28,66 @@ namespace CalamityMod.NPCs.Bumblebirb { DisplayName.SetDefault("The Dragonfolly"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override string Texture => "CalamityMod/NPCs/Bumblebirb/Birb"; public override string BossHeadTexture => "CalamityMod/NPCs/Bumblebirb/Birb_Head_Boss"; public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 32f; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 32f; npc.aiStyle = -1; aiType = -1; - npc.GetNPCDamage(); - npc.width = 130; + npc.GetNPCDamage(); + npc.width = 130; npc.height = 100; npc.defense = 40; - npc.DR_NERD(0.1f); - npc.LifeMaxNERB(190200, 228240, 300000); // Old HP - 227500, 252500 + npc.DR_NERD(0.1f); + npc.LifeMaxNERB(190200, 228240, 300000); // Old HP - 227500, 252500 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; npc.boss = true; - npc.noTileCollide = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("Dragonfolly") ?? MusicID.Boss4; + npc.noTileCollide = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("Dragonfolly") ?? MusicID.Boss4; npc.lavaImmune = true; npc.noGravity = true; npc.value = Item.buyPrice(1, 25, 0, 0); npc.HitSound = SoundID.NPCHit51; npc.DeathSound = SoundID.NPCDeath46; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = false; + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = false; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - writer.Write(npc.localAI[3]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - CalamityAI.BumblebirbAI(npc, mod); - } + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + writer.Write(npc.localAI[3]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityAI.BumblebirbAI(npc, mod); + } public override bool CanHitPlayer(Player target, ref int cooldownSlot) { @@ -97,294 +97,294 @@ namespace CalamityMod.NPCs.Bumblebirb public override void FindFrame(int frameHeight) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Phases - bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death; - bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f); - bool birbSpawn = npc.ai[0] == 4f && npc.ai[1] > 0f; + // Phases + bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death; + bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f); + bool birbSpawn = npc.ai[0] == 4f && npc.ai[1] > 0f; - float newPhaseTimer = 180f; - bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || - (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); + float newPhaseTimer = 180f; + bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || + (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); - if (phaseSwitchPhase || birbSpawn) - { - float frameGateValue = birbSpawn ? npc.ai[1] : phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]; - int num116 = 180; - if (frameGateValue < (num116 - 60) || frameGateValue > (num116 - 20)) - { - npc.frameCounter += 1D; - if (npc.frameCounter > 5D) - { - npc.frameCounter = 0D; - npc.frame.Y += frameHeight; - } - if (npc.frame.Y >= frameHeight * 5) - { - npc.frame.Y = 0; - } - } - else - { - npc.frame.Y = frameHeight * 4; - if (frameGateValue > (num116 - 50) && frameGateValue < (num116 - 25)) - { - npc.frame.Y = frameHeight * 5; - } - } - } - else if (npc.ai[0] == 5f) - { - int num115 = 120; - if (npc.ai[1] < (num115 - 50) || npc.ai[1] > (num115 - 10)) - { - npc.frameCounter += 1D; - if (npc.frameCounter > 5D) - { - npc.frameCounter = 0D; - npc.frame.Y += frameHeight; - } - if (npc.frame.Y >= frameHeight * 5) - { - npc.frame.Y = 0; - } - } - else - { - npc.frame.Y = frameHeight * 4; - if (npc.ai[1] > (num115 - 40) && npc.ai[1] < (num115 - 15)) - { - npc.frame.Y = frameHeight * 5; - } - } - } + if (phaseSwitchPhase || birbSpawn) + { + float frameGateValue = birbSpawn ? npc.ai[1] : phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]; + int num116 = 180; + if (frameGateValue < (num116 - 60) || frameGateValue > (num116 - 20)) + { + npc.frameCounter += 1D; + if (npc.frameCounter > 5D) + { + npc.frameCounter = 0D; + npc.frame.Y += frameHeight; + } + if (npc.frame.Y >= frameHeight * 5) + { + npc.frame.Y = 0; + } + } + else + { + npc.frame.Y = frameHeight * 4; + if (frameGateValue > (num116 - 50) && frameGateValue < (num116 - 25)) + { + npc.frame.Y = frameHeight * 5; + } + } + } + else if (npc.ai[0] == 5f) + { + int num115 = 120; + if (npc.ai[1] < (num115 - 50) || npc.ai[1] > (num115 - 10)) + { + npc.frameCounter += 1D; + if (npc.frameCounter > 5D) + { + npc.frameCounter = 0D; + npc.frame.Y += frameHeight; + } + if (npc.frame.Y >= frameHeight * 5) + { + npc.frame.Y = 0; + } + } + else + { + npc.frame.Y = frameHeight * 4; + if (npc.ai[1] > (num115 - 40) && npc.ai[1] < (num115 - 15)) + { + npc.frame.Y = frameHeight * 5; + } + } + } else { - npc.frameCounter += (npc.ai[0] == 3.2f ? 1.5 : 1D); - if (npc.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base + npc.frameCounter += (npc.ai[0] == 3.2f ? 1.5 : 1D); + if (npc.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base { - npc.frameCounter = 0D; - npc.frame.Y += frameHeight; + npc.frameCounter = 0D; + npc.frame.Y += frameHeight; } - if (npc.frame.Y >= frameHeight * 5) - { - npc.frame.Y = 0; - } - } - } + if (npc.frame.Y >= frameHeight * 5) + { + npc.frame.Y = 0; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Phases - bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death; - bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f); + // Phases + bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death; + bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f); - float newPhaseTimer = 180f; - bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || - (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); + float newPhaseTimer = 180f; + bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || + (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color = lightColor; - Color color36 = Color.White; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color = lightColor; + Color color36 = Color.White; - float amount9 = 0f; - int num150 = 120; - int num151 = 60; + float amount9 = 0f; + int num150 = 120; + int num151 = 60; - if (phase3 && calamityGlobalNPC.newAI[3] == 1f) - { - color = CalamityGlobalNPC.buffColor(color, 0.9f, 0.6f, 0.2f, 1f); - } - else if (phase2 && calamityGlobalNPC.newAI[2] == 1f) - { - color = CalamityGlobalNPC.buffColor(color, 0.7f, 0.7f, 0.3f, 1f); - } - else if (phase2 && calamityGlobalNPC.newAI[0] > (float)num150) - { - float num152 = calamityGlobalNPC.newAI[0] - (float)num150; - num152 /= (float)num151; - color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * num152, 1f - 0.3f * num152, 1f - 0.7f * num152, 1f); - } + if (phase3 && calamityGlobalNPC.newAI[3] == 1f) + { + color = CalamityGlobalNPC.buffColor(color, 0.9f, 0.6f, 0.2f, 1f); + } + else if (phase2 && calamityGlobalNPC.newAI[2] == 1f) + { + color = CalamityGlobalNPC.buffColor(color, 0.7f, 0.7f, 0.3f, 1f); + } + else if (phase2 && calamityGlobalNPC.newAI[0] > (float)num150) + { + float num152 = calamityGlobalNPC.newAI[0] - (float)num150; + num152 /= (float)num151; + color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * num152, 1f - 0.3f * num152, 1f - 0.7f * num152, 1f); + } - int num153 = 10; - int num154 = 2; - if (npc.ai[0] == 0f || npc.ai[0] == 3.1f || npc.ai[0] == 4f || npc.ai[0] == 4.2f) - { - num153 = 4; - } - if (npc.ai[0] == 1f || npc.ai[0] == 3f || npc.ai[0] == 4.1f) - { - num153 = 7; - } - if (npc.ai[0] == 2f || npc.ai[0] == 3.2f || (phase2 && calamityGlobalNPC.newAI[2] == 1f)) - { - color36 = Color.Yellow; - amount9 = 0.5f; - } - else - { - color = lightColor; - } + int num153 = 10; + int num154 = 2; + if (npc.ai[0] == 0f || npc.ai[0] == 3.1f || npc.ai[0] == 4f || npc.ai[0] == 4.2f) + { + num153 = 4; + } + if (npc.ai[0] == 1f || npc.ai[0] == 3f || npc.ai[0] == 4.1f) + { + num153 = 7; + } + if (npc.ai[0] == 2f || npc.ai[0] == 3.2f || (phase2 && calamityGlobalNPC.newAI[2] == 1f)) + { + color36 = Color.Yellow; + amount9 = 0.5f; + } + else + { + color = lightColor; + } - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += num154) - { - Color color38 = color; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += num154) + { + Color color38 = color; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - int num156 = 0; - float num157 = 0f; - float scaleFactor9 = 0f; + int num156 = 0; + float num157 = 0f; + float scaleFactor9 = 0f; - if (npc.ai[0] == 0f || npc.ai[0] == 3.1f || npc.ai[0] == 4f || npc.ai[0] == 4.2f) - { - num156 = 4; - } + if (npc.ai[0] == 0f || npc.ai[0] == 3.1f || npc.ai[0] == 4f || npc.ai[0] == 4.2f) + { + num156 = 4; + } - if (npc.ai[0] == 5f) - { - int num158 = 60; - int num159 = 30; - if (npc.ai[1] > (float)num158) - { - num156 = 6; - num157 = 1f - (float)Math.Cos((double)((npc.ai[1] - (float)num158) / (float)num159 * MathHelper.TwoPi)); - num157 /= 3f; - scaleFactor9 = 40f; - } - } + if (npc.ai[0] == 5f) + { + int num158 = 60; + int num159 = 30; + if (npc.ai[1] > (float)num158) + { + num156 = 6; + num157 = 1f - (float)Math.Cos((double)((npc.ai[1] - (float)num158) / (float)num159 * MathHelper.TwoPi)); + num157 /= 3f; + scaleFactor9 = 40f; + } + } - if (phaseSwitchPhase) - { - if (phase3 && calamityGlobalNPC.newAI[1] > (float)num150) - { - num156 = 6; - num157 = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[1] - (float)num150) / (float)num151 * MathHelper.TwoPi)); - num157 /= 3f; - scaleFactor9 = 60f; - } - else if (phase2 && calamityGlobalNPC.newAI[0] > (float)num150) - { - num156 = 6; - num157 = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[0] - (float)num150) / (float)num151 * MathHelper.TwoPi)); - num157 /= 3f; - scaleFactor9 = 60f; - } - } + if (phaseSwitchPhase) + { + if (phase3 && calamityGlobalNPC.newAI[1] > (float)num150) + { + num156 = 6; + num157 = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[1] - (float)num150) / (float)num151 * MathHelper.TwoPi)); + num157 /= 3f; + scaleFactor9 = 60f; + } + else if (phase2 && calamityGlobalNPC.newAI[0] > (float)num150) + { + num156 = 6; + num157 = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[0] - (float)num150) / (float)num151 * MathHelper.TwoPi)); + num157 /= 3f; + scaleFactor9 = 60f; + } + } - if (CalamityConfig.Instance.Afterimages) - { - for (int num160 = 0; num160 < num156; num160++) - { - Color color39 = lightColor; - color39 = Color.Lerp(color39, color36, amount9); - color39 = npc.GetAlpha(color39); - color39 *= 1f - num157; - Vector2 vector42 = npc.Center + ((float)num160 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; - vector42 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector42 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector42, npc.frame, color39, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num160 = 0; num160 < num156; num160++) + { + Color color39 = lightColor; + color39 = Color.Lerp(color39, color36, amount9); + color39 = npc.GetAlpha(color39); + color39 *= 1f - num157; + Vector2 vector42 = npc.Center + ((float)num160 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; + vector42 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector42 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector42, npc.frame, color39, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Color color2 = lightColor; - color2 = Color.Lerp(color2, color36, amount9); - color2 = npc.GetAlpha(color2); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, (phase3 && calamityGlobalNPC.newAI[3] == 1f ? color2 : npc.GetAlpha(lightColor)), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Color color2 = lightColor; + color2 = Color.Lerp(color2, color36, amount9); + color2 = npc.GetAlpha(color2); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, (phase3 && calamityGlobalNPC.newAI[3] == 1f ? color2 : npc.GetAlpha(lightColor)), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - if (phase2) - { - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Bumblebirb/BirbGlow"); - Color color40 = Color.Lerp(Color.White, Color.Red, 0.5f); - color36 = Color.Red; + if (phase2) + { + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Bumblebirb/BirbGlow"); + Color color40 = Color.Lerp(Color.White, Color.Red, 0.5f); + color36 = Color.Red; - amount9 = 1f; - num157 = 0.5f; - scaleFactor9 = 10f; - num154 = 1; + amount9 = 1f; + num157 = 0.5f; + scaleFactor9 = 10f; + num154 = 1; - if (phaseSwitchPhase) - { - float num161 = (phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]) - (float)num150; - num161 /= (float)num151; - color36 *= num161; - color40 *= num161; - } + if (phaseSwitchPhase) + { + float num161 = (phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]) - (float)num150; + num161 /= (float)num151; + color36 *= num161; + color40 *= num161; + } - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163 += num154) - { - Color color41 = color40; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163 += num154) + { + Color color41 = color40; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } - for (int num164 = 1; num164 < num156; num164++) - { - Color color42 = color40; - color42 = Color.Lerp(color42, color36, amount9); - color42 = npc.GetAlpha(color42); - color42 *= 1f - num157; - Vector2 vector45 = npc.Center + ((float)num164 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; - vector45 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector45 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector45, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + for (int num164 = 1; num164 < num156; num164++) + { + Color color42 = color40; + color42 = Color.Lerp(color42, color36, amount9); + color42 = npc.GetAlpha(color42); + color42 *= 1f - num157; + Vector2 vector45 = npc.Center + ((float)num164 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; + vector45 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector45 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector45, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color40, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + spriteBatch.Draw(texture2D15, vector43, npc.frame, color40, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } - return false; - } + return false; + } - private static Color buffColor(Color newColor, float R, float G, float B, float A) - { - newColor.R = (byte)((float)newColor.R * R); - newColor.G = (byte)((float)newColor.G * G); - newColor.B = (byte)((float)newColor.B * B); - newColor.A = (byte)((float)newColor.A * A); - return newColor; - } + private static Color buffColor(Color newColor, float R, float G, float B, float A) + { + newColor.R = (byte)((float)newColor.R * R); + newColor.G = (byte)((float)newColor.G * G); + newColor.B = (byte)((float)newColor.B * B); + newColor.A = (byte)((float)newColor.A * A); + return newColor; + } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref string name, ref int potionType) { name = "A Dragonfolly"; potionType = ModContent.ItemType(); @@ -392,39 +392,39 @@ namespace CalamityMod.NPCs.Bumblebirb public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedBumble); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) { // Materials DropHelper.DropItemSpray(npc, ModContent.ItemType(), 11, 17); - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + // Weapons + float w = DropHelper.NormalWeaponDropRateFloat; + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); } - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); - // Mark The Dragonfolly as dead - CalamityWorld.downedBumble = true; + // Mark The Dragonfolly as dead + CalamityWorld.downedBumble = true; CalamityNetcode.SyncWorld(); } diff --git a/NPCs/Bumblebirb/Bumblefuck2.cs b/NPCs/Bumblebirb/Bumblefuck2.cs index 0ac60d5a81..5e8f210141 100644 --- a/NPCs/Bumblebirb/Bumblefuck2.cs +++ b/NPCs/Bumblebirb/Bumblefuck2.cs @@ -7,14 +7,14 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Bumblebirb { - public class Bumblefuck2 : ModNPC + public class Bumblefuck2 : ModNPC { public override void SetStaticDefaults() { DisplayName.SetDefault("Draconic Swarmer"); Main.npcFrameCount[npc.type] = 5; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override string Texture => "CalamityMod/NPCs/Bumblebirb/BumbleFolly"; @@ -23,104 +23,104 @@ namespace CalamityMod.NPCs.Bumblebirb npc.npcSlots = 1f; npc.aiStyle = -1; aiType = -1; - npc.GetNPCDamage(); - npc.width = 120; + npc.GetNPCDamage(); + npc.width = 120; npc.height = 80; npc.defense = 20; npc.LifeMaxNERB(9375, 11250, 5000); // Old HP - 12000, 15000 npc.knockBackResist = 0f; npc.lavaImmune = true; - npc.noTileCollide = true; + npc.noTileCollide = true; npc.noGravity = true; npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit51; npc.DeathSound = SoundID.NPCDeath46; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (spawnInfo.playerSafe || !NPC.downedMoonlord || spawnInfo.player.Calamity().ZoneSunkenSea || NPC.AnyNPCs(npc.type)) - { - return 0f; - } - return SpawnCondition.SurfaceJungle.Chance * 0.14f; - } - - public override void AI() - { - CalamityAI.Bumblebirb2AI(npc, mod, true); + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; } - public override bool PreNPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - return false; - } - - public override void FindFrame(int frameHeight) + public override float SpawnChance(NPCSpawnInfo spawnInfo) { - npc.frameCounter += npc.ai[0] == 2.1f ? 1.5 : 1D; - if (npc.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base - { - npc.frameCounter = 0D; - npc.frame.Y += frameHeight; - } - if (npc.frame.Y >= frameHeight * 4) - { - npc.frame.Y = 0; - } - } + if (spawnInfo.playerSafe || !NPC.downedMoonlord || spawnInfo.player.Calamity().ZoneSunkenSea || NPC.AnyNPCs(npc.type)) + { + return 0f; + } + return SpawnCondition.SurfaceJungle.Chance * 0.14f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override void AI() + { + CalamityAI.Bumblebirb2AI(npc, mod, true); + } - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Color color36 = Color.Gold; - float amount9 = 0.5f; - int num153 = npc.ai[0] == 2.1f ? 7 : 0; + public override bool PreNPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + return false; + } - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + public override void FindFrame(int frameHeight) + { + npc.frameCounter += npc.ai[0] == 2.1f ? 1.5 : 1D; + if (npc.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base + { + npc.frameCounter = 0D; + npc.frame.Y += frameHeight; + } + if (npc.frame.Y >= frameHeight * 4) + { + npc.frame.Y = 0; + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - return false; - } + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Color color36 = Color.Gold; + float amount9 = 0.5f; + int num153 = npc.ai[0] == 2.1f ? 7 : 0; - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - public override void HitEffect(int hitDirection, double damage) + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + return true; + } + + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/Calamitas/CalamitasRun.cs b/NPCs/Calamitas/CalamitasRun.cs index e09436f5ba..3a44016281 100644 --- a/NPCs/Calamitas/CalamitasRun.cs +++ b/NPCs/Calamitas/CalamitasRun.cs @@ -13,21 +13,21 @@ using System.IO; namespace CalamityMod.NPCs.Calamitas { - [AutoloadBossHead] + [AutoloadBossHead] public class CalamitasRun : ModNPC { public override void SetStaticDefaults() { DisplayName.SetDefault("Cataclysm"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 120; npc.height = 120; @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.Calamitas npc.scale = 1.2f; npc.defense = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 15 : 10; - npc.DR_NERD((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.225f : 0.15f); + npc.DR_NERD((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.225f : 0.15f); npc.LifeMaxNERB(11000, 13200, 80000); if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { @@ -53,24 +53,24 @@ namespace CalamityMod.NPCs.Calamitas npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; music = CalamityMod.Instance.GetMusicFromMusicMod("Calamitas") ?? MusicID.Boss2; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + public override void SendExtraAI(BinaryWriter writer) + { + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -80,81 +80,81 @@ namespace CalamityMod.NPCs.Calamitas public override void AI() { - CalamityAI.CataclysmAI(npc, mod); + CalamityAI.CataclysmAI(npc, mod); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 7; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Calamitas/CalamitasRunGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Calamitas/CalamitasRunGlow"); + Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CheckActive() + public override bool CheckActive() { return npc.Calamity().newAI[0] == 1f; } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int heartAmt = Main.rand.Next(3) + 3; + for (int i = 0; i < heartAmt; i++) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 4 : 5); - DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 4 : 5); - } + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 4 : 5); + DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 4 : 5); + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/Calamitas/CalamitasRun2.cs b/NPCs/Calamitas/CalamitasRun2.cs index edea3067a8..782256fa6b 100644 --- a/NPCs/Calamitas/CalamitasRun2.cs +++ b/NPCs/Calamitas/CalamitasRun2.cs @@ -13,30 +13,30 @@ using System.IO; namespace CalamityMod.NPCs.Calamitas { - [AutoloadBossHead] + [AutoloadBossHead] public class CalamitasRun2 : ModNPC { public override void SetStaticDefaults() { DisplayName.SetDefault("Catastrophe"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 120; npc.height = 120; - if (CalamityWorld.death || BossRushEvent.BossRushActive) - npc.scale = 1.2f; + if (CalamityWorld.death || BossRushEvent.BossRushActive) + npc.scale = 1.2f; - npc.defense = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 15 : 10; - npc.DR_NERD((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.225f : 0.15f); - npc.LifeMaxNERB(9200, 11025, 80000); + npc.defense = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 15 : 10; + npc.DR_NERD((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.225f : 0.15f); + npc.LifeMaxNERB(9200, 11025, 80000); if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { npc.damage *= 3; @@ -53,24 +53,24 @@ namespace CalamityMod.NPCs.Calamitas npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; music = CalamityMod.Instance.GetMusicFromMusicMod("Calamitas") ?? MusicID.Boss2; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + public override void SendExtraAI(BinaryWriter writer) + { + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -80,80 +80,80 @@ namespace CalamityMod.NPCs.Calamitas public override void AI() { - CalamityAI.CatastropheAI(npc, mod); + CalamityAI.CatastropheAI(npc, mod); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 7; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Calamitas/CalamitasRun2Glow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Calamitas/CalamitasRun2Glow"); + Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CheckActive() - { - return npc.Calamity().newAI[0] == 1f; - } + public override bool CheckActive() + { + return npc.Calamity().newAI[0] == 1f; + } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int heartAmt = Main.rand.Next(3) + 3; + for (int i = 0; i < heartAmt; i++) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 4 : 5); - } + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 4 : 5); + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/Calamitas/CalamitasRun3.cs b/NPCs/Calamitas/CalamitasRun3.cs index ab0976bf06..c51b061c11 100644 --- a/NPCs/Calamitas/CalamitasRun3.cs +++ b/NPCs/Calamitas/CalamitasRun3.cs @@ -22,21 +22,21 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Calamitas { - [AutoloadBossHead] + [AutoloadBossHead] public class CalamitasRun3 : ModNPC { public override void SetStaticDefaults() { DisplayName.SetDefault("Calamitas"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 14f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 14f; npc.width = 120; npc.height = 120; @@ -45,9 +45,9 @@ namespace CalamityMod.NPCs.Calamitas npc.defense = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 12 : 25; npc.value = Item.buyPrice(0, 50, 0, 0); - npc.DR_NERD((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.075f : 0.15f); - npc.LifeMaxNERB(37500, 45000, 520000); - if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) + npc.DR_NERD((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.075f : 0.15f); + npc.LifeMaxNERB(37500, 45000, 520000); + if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { npc.damage *= 3; npc.defense *= 3; @@ -66,14 +66,14 @@ namespace CalamityMod.NPCs.Calamitas npc.DeathSound = SoundID.NPCDeath14; music = CalamityMod.Instance.GetMusicFromMusicMod("Calamitas") ?? MusicID.Boss2; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(npc.dontTakeDamage); + writer.Write(npc.dontTakeDamage); writer.Write(npc.localAI[0]); writer.Write(npc.localAI[1]); writer.Write(npc.localAI[2]); @@ -84,7 +84,7 @@ namespace CalamityMod.NPCs.Calamitas public override void ReceiveExtraAI(BinaryReader reader) { - npc.dontTakeDamage = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); npc.localAI[0] = reader.ReadSingle(); npc.localAI[1] = reader.ReadSingle(); npc.localAI[2] = reader.ReadSingle(); @@ -103,82 +103,82 @@ namespace CalamityMod.NPCs.Calamitas public override void AI() { - CalamityAI.CalamitasCloneAI(npc, mod); + CalamityAI.CalamitasCloneAI(npc, mod); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture = Main.npcTexture[npc.type]; - Vector2 origin = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[npc.type] / 2)); - Color white = Color.White; - float colorLerpAmt = 0.5f; - int afterimageAmt = 7; - - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < afterimageAmt; i += 2) - { - Color color1 = lightColor; - color1 = Color.Lerp(color1, white, colorLerpAmt); - color1 = npc.GetAlpha(color1); - color1 *= (float)(afterimageAmt - i) / 15f; - Vector2 offset = npc.oldPos[i] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - offset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - offset += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, offset, npc.frame, color1, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - } - - Vector2 npcOffset = npc.Center - Main.screenPosition; - npcOffset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - npcOffset += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, npcOffset, npc.frame, npc.GetAlpha(lightColor), npc.rotation, origin, npc.scale, spriteEffects, 0f); - - texture = ModContent.GetTexture("CalamityMod/NPCs/Calamitas/CalamitasRun3Glow"); - Color color = Color.Lerp(Color.White, Color.Red, 0.5f); - - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < afterimageAmt; i++) - { - Color color2 = color; - color2 = Color.Lerp(color2, white, colorLerpAmt); - color2 *= (float)(afterimageAmt - i) / 15f; - Vector2 offset = npc.oldPos[i] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - offset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - offset += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, offset, npc.frame, color2, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(texture, npcOffset, npc.frame, color, npc.rotation, origin, npc.scale, spriteEffects, 0f); - - return false; - } - - public override void NPCLoot() + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - DropHelper.DropBags(npc); + Texture2D texture = Main.npcTexture[npc.type]; + Vector2 origin = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[npc.type] / 2)); + Color white = Color.White; + float colorLerpAmt = 0.5f; + int afterimageAmt = 7; - DropHelper.DropItem(npc, ItemID.BrokenHeroSword, true); + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < afterimageAmt; i += 2) + { + Color color1 = lightColor; + color1 = Color.Lerp(color1, white, colorLerpAmt); + color1 = npc.GetAlpha(color1); + color1 *= (float)(afterimageAmt - i) / 15f; + Vector2 offset = npc.oldPos[i] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + offset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + offset += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, offset, npc.frame, color1, npc.rotation, origin, npc.scale, spriteEffects, 0f); + } + } + + Vector2 npcOffset = npc.Center - Main.screenPosition; + npcOffset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + npcOffset += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, npcOffset, npc.frame, npc.GetAlpha(lightColor), npc.rotation, origin, npc.scale, spriteEffects, 0f); + + texture = ModContent.GetTexture("CalamityMod/NPCs/Calamitas/CalamitasRun3Glow"); + Color color = Color.Lerp(Color.White, Color.Red, 0.5f); + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < afterimageAmt; i++) + { + Color color2 = color; + color2 = Color.Lerp(color2, white, colorLerpAmt); + color2 *= (float)(afterimageAmt - i) / 15f; + Vector2 offset = npc.oldPos[i] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + offset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + offset += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, offset, npc.frame, color2, npc.rotation, origin, npc.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(texture, npcOffset, npc.frame, color, npc.rotation, origin, npc.scale, spriteEffects, 0f); + + return false; + } + + public override void NPCLoot() + { + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); + + DropHelper.DropItem(npc, ItemID.BrokenHeroSword, true); DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), !CalamityWorld.downedCalamitas); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedCalamitas); + CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedCalamitas); - if (!Main.expertMode) + if (!Main.expertMode) { - //Materials + //Materials DropHelper.DropItemSpray(npc, ModContent.ItemType(), 4, 8); DropHelper.DropItem(npc, ModContent.ItemType(), 9, 14); DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence, 1f, 30, 40); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence, 1f, 30, 40); // Weapons float w = DropHelper.NormalWeaponDropRateFloat; @@ -187,19 +187,19 @@ namespace CalamityMod.NPCs.Calamitas DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - if (Main.rand.NextBool(10)) - { - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - } + if (Main.rand.NextBool(10)) + { + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + } } DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); @@ -271,8 +271,8 @@ namespace CalamityMod.NPCs.Calamitas public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } + npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); + } public override void OnHitPlayer(Player player, int damage, bool crit) { diff --git a/NPCs/Calamitas/SoulSeeker.cs b/NPCs/Calamitas/SoulSeeker.cs index ae7d317129..4ae7c25032 100644 --- a/NPCs/Calamitas/SoulSeeker.cs +++ b/NPCs/Calamitas/SoulSeeker.cs @@ -19,9 +19,9 @@ namespace CalamityMod.NPCs.Calamitas public override void SetStaticDefaults() { DisplayName.SetDefault("Soul Seeker"); - Main.npcFrameCount[npc.type] = 5; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + Main.npcFrameCount[npc.type] = 5; + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -34,7 +34,7 @@ namespace CalamityMod.NPCs.Calamitas npc.canGhostHeal = false; npc.damage = 40; npc.defense = 10; - npc.DR_NERD(0.1f); + npc.DR_NERD(0.1f); npc.lifeMax = CalamityWorld.death ? 1500 : 2500; if (BossRushEvent.BossRushActive) { @@ -42,12 +42,12 @@ namespace CalamityMod.NPCs.Calamitas } npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -57,20 +57,20 @@ namespace CalamityMod.NPCs.Calamitas public override bool PreAI() { - // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - npc.damage = 0; + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + npc.damage = 0; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (CalamityGlobalNPC.calamitas < 0 || !Main.npc[CalamityGlobalNPC.calamitas].active) - { - npc.active = false; - npc.netUpdate = true; - return false; - } + if (CalamityGlobalNPC.calamitas < 0 || !Main.npc[CalamityGlobalNPC.calamitas].active) + { + npc.active = false; + npc.netUpdate = true; + return false; + } NPC parent = Main.npc[CalamityGlobalNPC.calamitas]; - if (start) + if (start) { for (int d = 0; d < 15; d++) { @@ -95,9 +95,9 @@ namespace CalamityMod.NPCs.Calamitas for (int d = 0; d < 3; d++) Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, velocity, type, damage, 1f, npc.target, 1f, 0f); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center, velocity, type, damage, 1f, npc.target, 1f, 0f); } timer = 0; } @@ -146,70 +146,70 @@ namespace CalamityMod.NPCs.Calamitas } } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture = Main.npcTexture[npc.type]; - Vector2 origin = new Vector2(texture.Width / 2f, texture.Height / Main.npcFrameCount[npc.type] / 2f); - Color white = Color.White; - float colorLerpAmt = 0.5f; - int afterImageAmt = 5; + Texture2D texture = Main.npcTexture[npc.type]; + Vector2 origin = new Vector2(texture.Width / 2f, texture.Height / Main.npcFrameCount[npc.type] / 2f); + Color white = Color.White; + float colorLerpAmt = 0.5f; + int afterImageAmt = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int a = 1; a < afterImageAmt; a += 2) - { - Color afterImageColor = lightColor; - afterImageColor = Color.Lerp(afterImageColor, white, colorLerpAmt); - afterImageColor = npc.GetAlpha(afterImageColor); - afterImageColor *= (afterImageAmt - a) / 15f; - Vector2 afterimagePos = npc.oldPos[a] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimagePos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - afterimagePos += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, afterimagePos, npc.frame, afterImageColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int a = 1; a < afterImageAmt; a += 2) + { + Color afterImageColor = lightColor; + afterImageColor = Color.Lerp(afterImageColor, white, colorLerpAmt); + afterImageColor = npc.GetAlpha(afterImageColor); + afterImageColor *= (afterImageAmt - a) / 15f; + Vector2 afterimagePos = npc.oldPos[a] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimagePos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + afterimagePos += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, afterimagePos, npc.frame, afterImageColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); + } + } - Vector2 drawPos = npc.Center - Main.screenPosition; - drawPos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - drawPos += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, drawPos, npc.frame, npc.GetAlpha(lightColor), npc.rotation, origin, npc.scale, spriteEffects, 0f); + Vector2 drawPos = npc.Center - Main.screenPosition; + drawPos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + drawPos += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, drawPos, npc.frame, npc.GetAlpha(lightColor), npc.rotation, origin, npc.scale, spriteEffects, 0f); - texture = ModContent.GetTexture("CalamityMod/NPCs/Calamitas/SoulSeekerGlow"); - Color glow = Color.Lerp(Color.White, Color.Red, colorLerpAmt); + texture = ModContent.GetTexture("CalamityMod/NPCs/Calamitas/SoulSeekerGlow"); + Color glow = Color.Lerp(Color.White, Color.Red, colorLerpAmt); - if (CalamityConfig.Instance.Afterimages) - { - for (int a = 1; a < afterImageAmt; a++) - { - Color glowColor = glow; - glowColor = Color.Lerp(glowColor, white, colorLerpAmt); - glowColor *= (afterImageAmt - a) / 15f; - Vector2 afterimagePos = npc.oldPos[a] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimagePos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - afterimagePos += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, afterimagePos, npc.frame, glowColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int a = 1; a < afterImageAmt; a++) + { + Color glowColor = glow; + glowColor = Color.Lerp(glowColor, white, colorLerpAmt); + glowColor *= (afterImageAmt - a) / 15f; + Vector2 afterimagePos = npc.oldPos[a] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimagePos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + afterimagePos += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, afterimagePos, npc.frame, glowColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture, drawPos, npc.frame, white, npc.rotation, origin, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, drawPos, npc.frame, white, npc.rotation, origin, npc.scale, spriteEffects, 0f); - return false; - } - } + return false; + } + } } diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 27591c7cf5..854ec1ab93 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -30,2466 +30,2466 @@ namespace CalamityMod.NPCs { public class CalamityAI { - #region Aquatic Scourge - public static void AquaticScourgeAI(NPC npc, Mod mod, bool head) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - // Adjust hostility and stats - if (npc.justHit || npc.life <= npc.lifeMax * 0.999 || BossRushEvent.BossRushActive) - { - if (calamityGlobalNPC.newAI[0] == 0f) - { - // Kiss my motherfucking ass you piece of shit game - npc.timeLeft *= 20; - CalamityMod.bossKillTimes.TryGetValue(npc.type, out int revKillTime); - calamityGlobalNPC.KillTime = revKillTime; - calamityGlobalNPC.newAI[0] = 1f; - npc.boss = head; - npc.chaseable = true; - npc.netUpdate = true; - } - npc.damage = npc.defDamage; - } - else - npc.damage = 0; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Phases - bool phase2 = lifeRatio < 0.75f; - bool phase3 = lifeRatio < 0.5f; - bool phase4 = lifeRatio < 0.25f; - - // Set worm variable - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - if (!head) - { - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; - } - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - bool notOcean = player.position.Y < 400f || - player.position.Y > Main.worldSurface * 16.0 || - (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); - - // Enrage - if (head) - { - if (notOcean && !player.Calamity().ZoneSulphur && !BossRushEvent.BossRushActive) - { - if (npc.localAI[2] > 0f) - npc.localAI[2] -= 1f; - } - else - npc.localAI[2] = CalamityGlobalNPC.biomeEnrageTimerMax; - } - - bool biomeEnraged = npc.localAI[2] <= 0f || malice; - - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; - if (biomeEnraged) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 2f; - } - - Vector2 vectorCenter = npc.Center; - - // Circular movement - bool doSpiral = false; - if (head && calamityGlobalNPC.newAI[0] == 1f && calamityGlobalNPC.newAI[2] == 1f && revenge) - { - bool doNotSpiral = !Collision.CanHit(npc.Center, 1, 1, player.position, player.width, player.height); - float ai3 = 660f; - calamityGlobalNPC.newAI[3] += 1f; - doSpiral = calamityGlobalNPC.newAI[1] == 0f && calamityGlobalNPC.newAI[3] >= ai3; - if (doSpiral) - { - // Barf - npc.localAI[3] = 90f; - float barfDivisor = malice ? 30f : expertMode ? 40f : 60f; - if (calamityGlobalNPC.newAI[3] % barfDivisor == 0f) - { - Main.PlaySound(SoundID.NPCKilled, (int)npc.position.X, (int)npc.position.Y, 13); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (phase3) - { - // Circle of toxic clouds - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int totalProjectiles = (phase4 ? 6 : 9) + (int)((calamityGlobalNPC.newAI[3] - ai3) / barfDivisor) * (phase4 ? 2 : 3); - float radians = MathHelper.TwoPi / totalProjectiles; - float cloudVelocity = 1f + enrageScale; - Vector2 spinningPoint = new Vector2(0f, -cloudVelocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(vectorCenter, vector255, type, damage, 0f, Main.myPlayer); - } - } - else - { - // Spread of directed sand blasts - float num742 = death ? 10f : 8f; - float num743 = player.Center.X - vectorCenter.X; - float num744 = player.Center.Y - vectorCenter.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); - - num745 = num742 / num745; - num743 *= num745; - num744 *= num745; - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int numProj = death ? 5 : 3; - int spread = death ? 60 : 36; - 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 / numProj; - double offsetAngle; - - for (int i = 0; i < numProj; i++) - { - offsetAngle = startAngle + deltaAngle * i; - int proj = Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[proj].tileCollide = false; - } - } - } - } - - // Velocity boost - if (calamityGlobalNPC.newAI[3] == ai3) - { - npc.velocity.Normalize(); - npc.velocity *= 24f; - } - - // Spin velocity - float velocity = (float)(Math.PI * 2D) / 120f; - 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 + 120f) - { - calamityGlobalNPC.newAI[3] = 0f; - float chargeVelocity = (death ? 16f : 12f) + 3f * enrageScale; - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * chargeVelocity; - npc.TargetClosest(); - } - } - else - { - if (doNotSpiral && calamityGlobalNPC.newAI[3] > 0f) - calamityGlobalNPC.newAI[3] -= 2f; - - if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; - - npc.localAI[1] = npc.Center.X - player.Center.X < 0 ? 1f : -1f; - } - } - - // Adjust slowing debuff immunity - bool immuneToSlowingDebuffs = doSpiral; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (head) - { - // Spawn segments - if (calamityGlobalNPC.newAI[2] == 0f && npc.ai[0] == 0f) - { - int maxLength = death ? 80 : revenge ? 40 : expertMode ? 35 : 30; - int Previous = npc.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) - { - int lol; - if (num36 >= 0 && num36 < maxLength - 1) - { - if (num36 % 2 == 0) - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - else - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - else - 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] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); - Previous = lol; - } - calamityGlobalNPC.newAI[2] = 1f; - } - - // Big barf attack - if (calamityGlobalNPC.newAI[0] == 1f && !doSpiral && phase2) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= (revenge ? 360f : 420f)) - { - if (Vector2.Distance(player.Center, npc.Center) > 320f) - { - npc.localAI[0] = 0f; - npc.netUpdate = true; - Main.PlaySound(SoundID.NPCKilled, (int)npc.position.X, (int)npc.position.Y, 13); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float velocity = death ? 9.5f : revenge ? 7.5f : 6.5f; - int totalProjectiles = malice ? 40 : expertMode ? 30 : 20; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float homing = phase4 ? 1f : 0f; - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 vector255 = new Vector2(0f, -velocity).RotatedBy(radians * i); - Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, homing, 0f); - } - - if (phase3) - { - int num320 = malice ? 21 : expertMode ? 14 : 7; - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - for (int num321 = 0; num321 < num320; num321++) - { - Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - vector15.Normalize(); - vector15 *= Main.rand.Next(death ? 200 : 50, 401) * 0.01f; - - float maximumVelocityMult = death ? 0.35f : 0.25f; - if (expertMode) - vector15 *= 1f + (maximumVelocityMult * (0.5f - lifeRatio) * 2f); - - Projectile.NewProjectile(npc.Center, vector15, type, damage, 0f, Main.myPlayer, 0f, Main.rand.Next(-45, 1)); - } - } - } - } - } - } - } - - // Fire sand blasts or teeth depending on body type - else - { - if (calamityGlobalNPC.newAI[0] == 1f && (!phase3 || phase4)) - { - npc.localAI[0] += 1f; - float shootProjectile = 300; - float timer = npc.ai[0] + 15f; - float divisor = timer + shootProjectile; - - if (npc.type == ModContent.NPCType()) - { - if (npc.localAI[0] % divisor == 0f && (npc.ai[0] % 3f == 0f || !death)) - { - npc.TargetClosest(); - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 17); - 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 type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float num941 = death ? 9f : 8f; - num944 = num941 / num944; - num942 *= num944; - num943 *= num944; - vector104.X += num942 * 5f; - vector104.Y += num943 * 5f; - float accelerate = phase4 ? 1f : 0f; - Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, type, damage, 0f, Main.myPlayer, accelerate, 0f); - npc.netUpdate = true; - } - } - } - else if (npc.type == ModContent.NPCType()) - { - if (npc.localAI[0] % divisor == 0f && (npc.ai[0] % 3f == 0f || !death)) - { - npc.TargetClosest(); - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - 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 type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float num941 = death ? 15f : 12f; - num944 = num941 / num944; - num942 *= num944; - num943 *= num944; - vector104.X += num942 * 5f; - vector104.Y += num943 * 5f; - float homing = phase4 ? 1f : 0f; - Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, type, damage, 0f, Main.myPlayer, homing, 0f); - npc.netUpdate = true; - } - } - } - } - } - } - - // Kill body and tail - if (!head) - { - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } - } - else - { - if (npc.life > Main.npc[(int)npc.ai[0]].life) - npc.life = Main.npc[(int)npc.ai[0]].life; - } - - float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f; - if (player.dead || Vector2.Distance(npc.Center, player.Center) > maxDistance) - { - calamityGlobalNPC.newAI[1] = 1f; - npc.TargetClosest(false); - npc.velocity.Y += 2f; - - if (npc.position.Y > Main.worldSurface * 16.0) - npc.velocity.Y += 2f; - - if (npc.position.Y > Main.worldSurface * 16.0) - { - for (int a = 0; a < Main.npc.Length; a++) - { - int type = Main.npc[a].type; - if (type == ModContent.NPCType() || type == ModContent.NPCType() || - type == ModContent.NPCType() || type == ModContent.NPCType()) - { - Main.npc[a].active = false; - } - } - } - } - else - calamityGlobalNPC.newAI[1] = 0f; - - // Change direction - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; - else if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - - // Alpha changes - if (head || Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - - // Velocity and movement - float num188 = 5f; - float num189 = 0.08f; - 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); - - if (head && !doSpiral) - { - if (calamityGlobalNPC.newAI[0] != 1f) - { - num192 += 400; - if (Math.Abs(npc.Center.X - player.Center.X) < 500f) - { - if (npc.velocity.X > 0f) - num191 = player.Center.X + 600f; - else - num191 = player.Center.X - 600f; - } - } - - if (calamityGlobalNPC.newAI[0] == 1f) - { - num188 = revenge ? 9f : 7f; - num189 = revenge ? 0.12f : 0.1f; - if (expertMode) - { - num188 += 8f * (1f - lifeRatio); - num189 += 0.06f * (1f - lifeRatio); - } - num188 += 3f * enrageScale; - num189 += 0.06f * enrageScale; - if (death) - { - num188 += 5f; - num189 -= 0.03f; - num188 += Vector2.Distance(player.Center, npc.Center) * 0.0015f; - num189 += Vector2.Distance(player.Center, npc.Center) * 0.00003f; - } - } - - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = npc.velocity.Length(); - if (num50 > 0f) - { - if (num50 > num48) - { - npc.velocity.Normalize(); - npc.velocity *= num48; - } - else if (num50 < num49) - { - npc.velocity.Normalize(); - npc.velocity *= num49; - } - } - } - - 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)Math.Sqrt(num191 * num191 + num192 * num192); - - if (!head) - { - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - 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)Math.Atan2(num192, num191) + MathHelper.PiOver2; - num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - { - npc.spriteDirection = -1; - } - else if (num191 > 0f) - { - npc.spriteDirection = 1; - } - } - } - else if (!doSpiral) - { - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - { - npc.velocity.X += num189; - } - else - { - if (npc.velocity.X > num191) - npc.velocity.X -= num189; - } - if (npc.velocity.Y < num192) - { - npc.velocity.Y += num189; - } - else - { - if (npc.velocity.Y > num192) - npc.velocity.Y -= num189; - } - 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 (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; - else - npc.velocity.X -= num189 * 2f; - } - } - else - { - if (num196 > num197) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189 * 1.1f; - else if (npc.velocity.X > num191) - npc.velocity.X -= num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num189; - else - npc.velocity.Y -= num189; - } - } - else - { - if (npc.velocity.Y < num192) - npc.velocity.Y += num189 * 1.1f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num189; - else - npc.velocity.X -= num189; - } - } - } - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - } - } - #endregion - - #region Brimstone Elemental - public static void BrimstoneElementalAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Used for Brimling AI states - CalamityGlobalNPC.brimstoneElemental = npc.whoAmI; - - // Emit light - 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; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - bool despawnDistance = Vector2.Distance(player.Center, vectorCenter) > CalamityGlobalNPC.CatchUpDistance350Tiles; - - if (!player.active || player.dead || despawnDistance) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || despawnDistance) - { - npc.rotation = npc.velocity.X * 0.04f; - - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[0] != 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.netUpdate = true; - } - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - CalamityPlayer modPlayer = player.Calamity(); - - // Reset defense - npc.defense = npc.defDefense; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = npc.ai[0] == 4f; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Variables for buffing the AI - bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - bool phase2 = lifeRatio < 0.5f && revenge; - bool phase3 = lifeRatio < 0.33f; - - // Enrage - if ((!player.ZoneUnderworldHeight || !modPlayer.ZoneCalamity) && !BossRushEvent.BossRushActive) - { - if (calamityGlobalNPC.newAI[3] > 0f) - calamityGlobalNPC.newAI[3] -= 1f; - } - else - calamityGlobalNPC.newAI[3] = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = calamityGlobalNPC.newAI[3] <= 0f || malice; - - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; - if (biomeEnraged && (!player.ZoneUnderworldHeight || malice)) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1f; - } - if (biomeEnraged && (!modPlayer.ZoneCalamity || malice)) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1f; - } - - npc.Calamity().DR = npc.ai[0] == 4f ? 0.6f : 0.15f; - - // Emit dust - int dustAmt = (npc.ai[0] == 2f) ? 2 : 1; - int size = (npc.ai[0] == 2f) ? 50 : 35; - if (npc.ai[0] != 1f) - { - for (int num1011 = 0; num1011 < 2; num1011++) - { - if (Main.rand.Next(3) < dustAmt) - { - 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; - } - } - } - - // Distance from destination where Brimmy stops moving - float movementDistanceGateValue = 100f; - - // How fast Brimmy moves to the destination - float baseVelocity = (death ? 6f : revenge ? 5.5f : expertMode ? 5f : 4.5f) * (npc.ai[0] == 5f ? 0.05f : npc.ai[0] == 3f ? 1.5f : 1f); - if (expertMode) - baseVelocity += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - baseVelocity += 5f * enrageScale; - - float baseAcceleration = (death ? 0.12f : 0.1f) * (npc.ai[0] == 5f ? 0.5f : npc.ai[0] == 3f ? 1.5f : 1f); - baseAcceleration += 0.1f * enrageScale; - if (expertMode) - { - baseAcceleration += 0.03f * (1f - lifeRatio); - } - if (provy) - { - baseVelocity *= 1.25f; - baseAcceleration *= 1.25f; - } - - // This is where Brimmy should be - Vector2 destination = npc.ai[0] != 3f ? player.Center : new Vector2(player.Center.X, player.Center.Y - 300f); - - // How far Brimmy is from where she's supposed to be - Vector2 distanceFromDestination = destination - npc.Center; - - // Movement - if (npc.ai[0] != 4f) - { - // Inverse lerp returns the percentage of progress between A and B - float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); - - // Min velocity - float minVelocity = distanceFromDestination.Length(); - float minVelocityCap = baseVelocity; - if (minVelocity > minVelocityCap) - minVelocity = minVelocityCap; - - // Max velocity - Vector2 maxVelocity = distanceFromDestination / 24f; - float maxVelocityCap = minVelocityCap * 3f; - if (maxVelocity.Length() > maxVelocityCap) - maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; - - Vector2 desiredVelocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); - npc.SimpleFlyMovement(desiredVelocity, baseAcceleration); - } - - // Rotation and direction - if (npc.ai[0] <= 2f || npc.ai[0] == 5f) - { - npc.rotation = npc.velocity.X * 0.04f; - if (npc.ai[0] != 5 || (npc.ai[1] < 180f && npc.ai[0] == 5f)) - { - float playerLocation = vectorCenter.X - player.Center.X; - npc.direction = playerLocation < 0f ? 1 : -1; - npc.spriteDirection = npc.direction; - } - } - - if (npc.ai[0] == -1f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int phase; - int random = phase2 ? 6 : 5; - do phase = Main.rand.Next(random); - while (phase == npc.ai[1] || (phase == 0 && phase3 && revenge) || phase == 1 || phase == 2 || (phase == 4 && npc.localAI[3] != 0f)); - - npc.ai[0] = phase; - npc.ai[1] = 0f; - - // Cocoon phase cooldown - if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; - else if (phase == 4) - npc.localAI[3] = 3f; - - npc.netUpdate = true; - - // Prevent netUpdate from being blocked by the spam counter. - // A phase switch sync is a critical operation that must be synced. - if (npc.netSpam >= 10) - npc.netSpam = 9; - } - } - - // Pick a location to teleport to - else if (npc.ai[0] == 0f) - { - npc.chaseable = true; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (npc.localAI[1] >= (malice ? 5f : death ? 30f : 180f)) - { - npc.TargetClosest(); - npc.localAI[1] = 0f; - int timer = 0; - int playerPosX; - int playerPosY; - while (true) - { - timer++; - playerPosX = (int)player.Center.X / 16; - playerPosY = (int)player.Center.Y / 16; - - int min = 12; - int max = 16; - - if (Main.rand.NextBool(2)) - playerPosX += Main.rand.Next(min, max); - else - playerPosX -= Main.rand.Next(min, max); - - if (Main.rand.NextBool(2)) - playerPosY += Main.rand.Next(min, max); - else - playerPosY -= Main.rand.Next(min, max); - - if (!WorldGen.SolidTile(playerPosX, playerPosY)) - break; - - if (timer > 100) - return; - } - npc.ai[0] = 1f; - npc.ai[1] = playerPosX; - npc.ai[2] = playerPosY; - npc.netUpdate = true; - } - } - } - - // Teleport to location - else if (npc.ai[0] == 1f) - { - npc.chaseable = true; - 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); - Main.dust[dust].noGravity = true; - Main.dust[dust].fadeIn = 1f; - } - npc.alpha += malice ? 4 : death ? 3 : 2; - if (npc.alpha >= 255) - { - if (Main.netMode != NetmodeID.MultiplayerClient && NPC.CountNPCS(ModContent.NPCType()) < (death ? 1 : 2) && revenge) - { - NPC.NewNPC((int)vectorCenter.X, (int)vectorCenter.Y, ModContent.NPCType()); - } - Main.PlaySound(SoundID.Item8, vectorCenter); - npc.alpha = 255; - npc.position = position; - for (int n = 0; n < 15; n++) - { - int warpDust = Dust.NewDust(npc.position, npc.width, npc.height, 235, 0f, -1f, 90, default, 3f); - Main.dust[warpDust].noGravity = true; - } - npc.ai[0] = 2f; - npc.netUpdate = true; - } - } - - // Either teleport again or go to next AI state - else if (npc.ai[0] == 2f) - { - npc.alpha -= 50; - if (npc.alpha <= 0) - { - npc.chaseable = true; - npc.ai[3] += 1f; - npc.alpha = 0; - if (npc.ai[3] >= 2f || phase2) - { - npc.ai[0] = -1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - else - { - npc.ai[0] = 0f; - } - npc.netUpdate = true; - } - } - - // Float above target and fire projectiles - else if (npc.ai[0] == 3f) - { - npc.chaseable = true; - 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; - float divisor = expertMode ? (death ? 80f : revenge ? 45f : 50f) - (float)Math.Ceiling(10f * (1f - lifeRatio)) : 50f; - divisor -= 5f * enrageScale; - float divisor2 = divisor * 2f; - - if (npc.ai[1] % divisor == divisor - 1f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float num742 = death ? 5f : 4f; - num742 += 2f * enrageScale; - 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; - num744 *= num745; - vectorCenter.X += num743 * 3f; - vectorCenter.Y += num744 * 3f; - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int numProj = death ? 8 : 4; - int spread = death ? 90 : 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 / numProj; - double offsetAngle; - - if (npc.ai[1] % divisor2 == divisor2 - 1f) - { - 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), type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); - } - } - - float projectileSpeed = death ? 6f : 5f; - if (revenge) - projectileSpeed += 1f; - projectileSpeed += 2f * enrageScale; - - if (expertMode) - projectileSpeed += 3f * (1f - lifeRatio); - - vectorCenter = npc.Center; - 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; - vectorCenter.X += relativeSpeedX * 3f; - vectorCenter.Y += relativeSpeedY * 3f; - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - int projectileShot = Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, relativeSpeedX, relativeSpeedY, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, player.Center.X, player.Center.Y); - Main.projectile[projectileShot].timeLeft = 240; - } - } - - if (npc.ai[1] >= divisor * (death ? 5f : 10f)) - { - npc.TargetClosest(); - npc.ai[0] = -1f; - npc.ai[1] = 3f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - - // Cocoon bullet hell - else if (npc.ai[0] == 4f) - { - npc.defense = npc.defDefense * 4; - - npc.chaseable = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] += 1f; - if (expertMode) - npc.localAI[0] += 1f - lifeRatio; - npc.localAI[0] += 1f * enrageScale; - - if (npc.localAI[0] >= 120f) - { - npc.localAI[0] = 0f; - - float projectileSpeed = death ? 9f : revenge ? 8f : 6f; - projectileSpeed += 3f * enrageScale; - - vectorCenter = player.Center - vectorCenter; - - float radialOffset = 0.2f; - float diameter = 80f; - - vectorCenter = Vector2.Normalize(vectorCenter) * projectileSpeed; - - Vector2 velocity = vectorCenter; - velocity.Normalize(); - velocity *= diameter; - - int totalProjectiles = 6; - float offsetAngle = (float)Math.PI * radialOffset; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - for (int j = 0; j < totalProjectiles; j++) - { - float radians = j - (totalProjectiles - 1f) / 2f; - Vector2 offset = velocity.RotatedBy(offsetAngle * radians); - int proj = Projectile.NewProjectile(npc.Center + offset, vectorCenter, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); - Main.projectile[proj].timeLeft = 300; - Main.projectile[proj].tileCollide = false; - } - - totalProjectiles = 12; - float radians2 = MathHelper.TwoPi / totalProjectiles; - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - double angleA = radians2 * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(projectileSpeed * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = npc.localAI[2] % 2f == 0f ? new Vector2(0f, -projectileSpeed) : new Vector2(-velocityX, -projectileSpeed); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k); - Projectile.NewProjectile(npc.Center, vector255, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); - } - - if (death) - { - spinningPoint = npc.localAI[2] % 2f == 0f ? new Vector2(-velocityX, -projectileSpeed) : new Vector2(0f, -projectileSpeed); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k); - Projectile.NewProjectile(npc.Center, vector255 * 0.75f, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); - } - } - - npc.localAI[2] += 1f; - } - } - - npc.velocity *= 0.95f; - 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] >= (death ? 240f : 300f)) - { - npc.TargetClosest(); - npc.ai[0] = -1f; - npc.ai[1] = 4f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.localAI[0] = 0f; - npc.netUpdate = true; - } - } - - // Laser beam attack - else if (npc.ai[0] == 5f) - { - npc.chaseable = true; - - npc.defense = npc.defDefense * 2; - - Vector2 source = new Vector2(vectorCenter.X + (npc.spriteDirection > 0 ? 34f : -34f), vectorCenter.Y - 74f); - Vector2 aimAt = player.Center + player.velocity * 20f; - float aimResponsiveness = malice ? 0.05f : (npc.ai[2] == 1f || death) ? 0.1f : 0.25f; - - Vector2 aimVector = Vector2.Normalize(aimAt - source); - if (aimVector.HasNaNs()) - aimVector = -Vector2.UnitY; - aimVector = Vector2.Normalize(Vector2.Lerp(aimVector, Vector2.Normalize(npc.velocity), aimResponsiveness)); - aimVector *= 6f; - - Vector2 laserVelocity = Vector2.Normalize(aimVector); - if (laserVelocity.HasNaNs()) - laserVelocity = -Vector2.UnitY; - - calamityGlobalNPC.newAI[1] = laserVelocity.X; - calamityGlobalNPC.newAI[2] = laserVelocity.Y; - - // Rev = 190 + 165 = 355 - // Death = 165 - - npc.ai[1] += 1f; - if (npc.ai[1] >= 240f) - { - npc.TargetClosest(); - npc.ai[2] += 1f; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - if (npc.ai[2] >= (death ? 1f : 2f)) - { - npc.ai[0] = -1f; - npc.ai[1] = 5f; - npc.ai[2] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - else - { - npc.ai[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - } - else if (npc.ai[1] >= 180f) - { - npc.velocity *= 0.95f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.ai[1] == 180f) - { - Main.PlaySound(SoundID.Item68, source); - Vector2 laserVelocity2 = new Vector2(npc.localAI[0], npc.localAI[1]); - laserVelocity2.Normalize(); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(source, laserVelocity2, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - else - { - float playSoundTimer = 30f; - if (npc.ai[1] < 150f) - { - switch ((int)npc.ai[2]) - { - case 0: - npc.ai[1] += 0.5f; - break; - case 1: - npc.ai[1] += 1f; - playSoundTimer = 40f; - break; - } - if (death) - { - npc.ai[1] += 0.5f; - playSoundTimer += 10f; - } - } - - if (npc.ai[1] % playSoundTimer == 0f) - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 20); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f) - { - Projectile.NewProjectile(source, laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - calamityGlobalNPC.newAI[0] = 1f; - } - else - { - if (npc.ai[1] == 150f) - { - 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, npc.whoAmI); - } - } - } - } - } - } - #endregion - - #region Calamitas Clone - public static void CalamitasCloneAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Emit light - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1f, 0f, 0f); - - // Variables for increasing difficulty - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Phases - bool phase3 = lifeRatio < 0.7f || death; - bool phase4 = lifeRatio < 0.35f; - bool phase5 = lifeRatio <= 0.1f && revenge; - - // Don't take damage during bullet hells - npc.dontTakeDamage = calamityGlobalNPC.newAI[2] > 0f; - - // Variable for live brothers - bool brotherAlive = false; - - // For seekers - CalamityGlobalNPC.calamitas = npc.whoAmI; - - // Seeker ring - if (calamityGlobalNPC.newAI[1] == 0f && phase4 && expertMode) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 74); - int seekerAmt = death ? 10 : 5; - int seekerSpread = 360 / seekerAmt; - int seekerDistance = death ? 180 : 150; - for (int i = 0; i < seekerAmt; i++) - { - int spawn = NPC.NewNPC((int)(npc.Center.X + (Math.Sin(i * seekerSpread) * seekerDistance)), (int)(npc.Center.Y + (Math.Cos(i * seekerSpread) * seekerDistance)), ModContent.NPCType(), npc.whoAmI, 0, 0, 0, -1); - Main.npc[spawn].ai[0] = i * seekerSpread; - } - } - - string key = "Mods.CalamityMod.CalamitasBossText3"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - - calamityGlobalNPC.newAI[1] = 1f; - } - - // Do bullet hell or spawn brothers - if (calamityGlobalNPC.newAI[0] == 0f && npc.life > 0) - calamityGlobalNPC.newAI[0] = npc.lifeMax; - - // Bullet hells at 70% and 10%, brothers at 40% - if (npc.life > 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num660 = (int)(npc.lifeMax * 0.3); - if ((npc.life + num660) < calamityGlobalNPC.newAI[0]) - { - calamityGlobalNPC.newAI[0] = npc.life; - if (calamityGlobalNPC.newAI[0] <= (float)npc.lifeMax * 0.1) - { - Main.PlaySound(SoundID.Item109, npc.Center); - calamityGlobalNPC.newAI[2] = 2f; - SpawnDust(); - } - else if (calamityGlobalNPC.newAI[0] <= (float)npc.lifeMax * 0.4) - { - NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI); - NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI); - - string key = "Mods.CalamityMod.CalamitasBossText2"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - - SpawnDust(); - } - else - { - Main.PlaySound(SoundID.Item109, npc.Center); - calamityGlobalNPC.newAI[2] = 1f; - SpawnDust(); - } - } - } - } - - // Immunity if brothers are alive - if (CalamityGlobalNPC.cataclysm != -1) - { - if (Main.npc[CalamityGlobalNPC.cataclysm].active) - brotherAlive = true; - } - if (CalamityGlobalNPC.catastrophe != -1) - { - if (Main.npc[CalamityGlobalNPC.catastrophe].active) - brotherAlive = true; - } - - if (brotherAlive) - npc.dontTakeDamage = true; - - void SpawnDust() - { - int dustAmt = 50; - int random = 3; - - for (int j = 0; j < 10; j++) - { - random += j; - int dustAmtSpawned = 0; - int scale = random * 6; - float dustPositionX = npc.Center.X - (scale / 2); - float dustPositionY = npc.Center.Y - (scale / 2); - while (dustAmtSpawned < dustAmt) - { - float dustVelocityX = Main.rand.Next(-random, random); - float dustVelocityY = Main.rand.Next(-random, random); - float dustVelocityScalar = random * 2f; - float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); - dustVelocity = dustVelocityScalar / dustVelocity; - dustVelocityX *= dustVelocity; - dustVelocityY *= dustVelocity; - int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[dust].noGravity = true; - Main.dust[dust].position.X = npc.Center.X; - Main.dust[dust].position.Y = npc.Center.Y; - Main.dust[dust].position.X += Main.rand.Next(-10, 11); - Main.dust[dust].position.Y += Main.rand.Next(-10, 11); - Main.dust[dust].velocity.X = dustVelocityX; - Main.dust[dust].velocity.Y = dustVelocityY; - dustAmtSpawned++; - } - } - } - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - // Target variable - Player player = Main.player[npc.target]; - - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; - if (Main.dayTime || malice) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 2f; - } - - // Rotation - Vector2 npcCenter = new Vector2(npc.Center.X, npc.position.Y + npc.height - 59f); - Vector2 lookAt = new Vector2(player.position.X - (player.width / 2), player.position.Y - (player.height / 2)); - Vector2 rotationVector = npcCenter - lookAt; - - // Malice Mode predictive charge rotation - if (npc.ai[1] == 4f && phase5 && malice) - { - // Velocity - float chargeVelocity = 30f; - chargeVelocity += 5f * enrageScale; - if (provy) - chargeVelocity *= 1.25f; - - lookAt += Main.player[npc.target].velocity * 20f; - rotationVector = Vector2.Normalize(npcCenter - lookAt) * chargeVelocity; - } - - float rotation = (float)Math.Atan2(rotationVector.Y, rotationVector.X) + MathHelper.PiOver2; - if (rotation < 0f) - rotation += MathHelper.TwoPi; - else if (rotation > MathHelper.TwoPi) - rotation -= MathHelper.TwoPi; - - float rotationAmt = 0.1f; - if (npc.rotation < rotation) - { - if ((rotation - npc.rotation) > MathHelper.Pi) - npc.rotation -= rotationAmt; - else - npc.rotation += rotationAmt; - } - else if (npc.rotation > rotation) - { - if ((npc.rotation - rotation) > MathHelper.Pi) - npc.rotation += rotationAmt; - else - npc.rotation -= rotationAmt; - } - - if (npc.rotation > rotation - rotationAmt && npc.rotation < rotation + rotationAmt) - npc.rotation = rotation; - if (npc.rotation < 0f) - npc.rotation += MathHelper.TwoPi; - else if (npc.rotation > MathHelper.TwoPi) - npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > rotation - rotationAmt && npc.rotation < rotation + rotationAmt) - npc.rotation = rotation; - - // Despawn - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[1] != 0f) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.alpha = 0; - npc.netUpdate = true; - } - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - // Reset damage from bullet hell phases - npc.damage = npc.defDamage; - - // Distance from destination where Cal Clone stops moving - float movementDistanceGateValue = 100f; - - // How fast Cal Clone moves to the destination - float baseVelocity = (expertMode ? 10f : 8.5f) * (npc.ai[1] == 4f ? 1.4f : 1f); - float baseAcceleration = (expertMode ? 0.18f : 0.155f) * (npc.ai[1] == 4f ? 1.4f : 1f); - baseVelocity += 4f * enrageScale; - baseAcceleration += 0.1f * enrageScale; - if (death) - { - baseVelocity += 2f * (1f - lifeRatio); - baseAcceleration += 0.04f * (1f - lifeRatio); - } - if (provy) - { - baseVelocity *= 1.25f; - baseAcceleration *= 1.25f; - } - - // Reduce acceleration if target is holding a true melee weapon - Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) - baseAcceleration *= 0.5f; - - // What side Cal Clone should be on, relative to the target - int xPos = 1; - if (npc.Center.X < player.Center.X) - xPos = -1; - - // How far Cal Clone should be from the target - float averageDistance = 500f; - float chargeDistance = phase5 ? 300f : 400f; - - // This is where Cal Clone should be - Vector2 destination = (calamityGlobalNPC.newAI[2] > 0f || npc.ai[1] == 0f) ? new Vector2(player.Center.X, player.Center.Y - averageDistance) : - npc.ai[1] == 1f ? new Vector2(player.Center.X + averageDistance * xPos, player.Center.Y) : - new Vector2(player.Center.X + chargeDistance * xPos, player.Center.Y); - - // Add some random distance to the destination after certain attacks - if (npc.localAI[0] == 1f) - { - npc.localAI[0] = 0f; - npc.localAI[2] = Main.rand.Next(-50, 51); - npc.localAI[3] = Main.rand.Next(-300, 301); - npc.netUpdate = true; - } - - // Add a bit of randomness to the destination - if (death) - { - destination.X += npc.ai[1] == 0f ? npc.localAI[3] : npc.localAI[2]; - destination.Y += npc.ai[1] == 0f ? npc.localAI[2] : npc.localAI[3]; - } - - // How far Cal Clone is from where she's supposed to be - Vector2 distanceFromDestination = destination - npc.Center; - - // Movement - if (npc.ai[1] == 0f || npc.ai[1] == 1f || npc.ai[1] == 4f || calamityGlobalNPC.newAI[2] > 0f) - { - // Inverse lerp returns the percentage of progress between A and B - float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); - - // Min velocity - float minVelocity = distanceFromDestination.Length(); - float minVelocityCap = baseVelocity; - if (minVelocity > minVelocityCap) - minVelocity = minVelocityCap; - - // Max velocity - Vector2 maxVelocity = distanceFromDestination / 24f; - float maxVelocityCap = minVelocityCap * 3f; - if (maxVelocity.Length() > maxVelocityCap) - maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; - - Vector2 desiredVelocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); - npc.SimpleFlyMovement(desiredVelocity, baseAcceleration); - } - - // Bullet hell phase - if (calamityGlobalNPC.newAI[2] > 0f) - { - if (calamityGlobalNPC.newAI[3] < 900f) - { - calamityGlobalNPC.newAI[3] += 1f; - npc.damage = 0; - npc.dontTakeDamage = true; - npc.alpha = 255; - - float rotX = player.Center.X - npc.Center.X; - float rotY = player.Center.Y - npc.Center.Y; - npc.rotation = (float)Math.Atan2(rotY, rotX) - MathHelper.PiOver2; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (calamityGlobalNPC.newAI[2] == 2f) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type) + (provy ? 30 : 0); - float gigaBlastFrequency = (expertMode ? 180f : 240f) - enrageScale * 15f; - float projSpeed = malice ? 6.25f : 5f; - if (calamityGlobalNPC.newAI[3] <= 300f) - { - if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from top - Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer); - } - else if (calamityGlobalNPC.newAI[3] <= 600f && calamityGlobalNPC.newAI[3] > 300f) - { - if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from right - Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -projSpeed, 0f, type, damage, 0f, Main.myPlayer); - } - else if (calamityGlobalNPC.newAI[3] > 600f) - { - if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from top - Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer); - } - } - - npc.ai[0] += 1f; - float hellblastGateValue = (expertMode ? 12f : 16f) - enrageScale; - if (npc.ai[0] >= hellblastGateValue) - { - npc.ai[0] = 0f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type) + (provy ? 30 : 0); - float projSpeed = malice ? 5f : 4f; - if (calamityGlobalNPC.newAI[3] % (hellblastGateValue * 6f) == 0f) - { - float distance = Main.rand.NextBool() ? -1000f : 1000f; - float velocity = distance == -1000f ? projSpeed : -projSpeed; - Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - if (calamityGlobalNPC.newAI[3] < 300f) // Blasts from above - { - Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - else if (calamityGlobalNPC.newAI[3] < 600f) // Blasts from left and right - { - Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 0.5f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - Projectile.NewProjectile(player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 0.5f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - else // Blasts from above, left, and right - { - Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed - 1f, type, damage, 0f, Main.myPlayer, 2f, 0f); - Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 1f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - Projectile.NewProjectile(player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 1f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - } - } - } - else - { - npc.ai[0] = 0f; - npc.ai[3] = 0f; - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - - // Prevent bullshit charge hits when second bullet hell ends. - if (phase5) - { - npc.ai[1] = 4f; - npc.ai[2] = -105f; - npc.TargetClosest(); - } - else - { - if (death) - { - int AIState = Main.rand.Next(3); - switch (AIState) - { - case 0: - npc.ai[1] = 0f; - npc.ai[2] = 0f; - break; - case 1: - npc.ai[1] = 1f; - npc.ai[2] = 0f; - break; - case 2: - npc.ai[1] = 4f; - npc.ai[2] = -105f; - npc.TargetClosest(); - break; - } - } - else - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - if (death) - npc.localAI[0] = 1f; - } - - npc.netUpdate = true; - - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - if (projectile.timeLeft > 60) - projectile.timeLeft = 60; - } - else if (projectile.type == ModContent.ProjectileType()) - { - projectile.ai[1] = 1f; - - if (projectile.timeLeft > 60) - projectile.timeLeft = 60; - } - } - } - } - - return; - } - - npc.alpha = npc.dontTakeDamage ? 255 : 0; - - // Float above target and fire lasers or fireballs - if (npc.ai[1] == 0f) - { - npc.ai[2] += 1f; - float phaseTimer = 400f - (death ? 120f * (1f - lifeRatio) : 0f); - if (npc.ai[2] >= phaseTimer || phase5) - { - if (death && !phase5 && Main.rand.Next(2) == 0 && !brotherAlive) - npc.ai[1] = 4f; - else - npc.ai[1] = 1f; - - npc.ai[2] = 0f; - if (death) - npc.localAI[0] = 1f; - - npc.TargetClosest(); - npc.netUpdate = true; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (!brotherAlive) - { - if (expertMode) - npc.localAI[1] += death ? 2f * (1f - lifeRatio) : 1f - lifeRatio; - if (revenge) - npc.localAI[1] += 0.5f; - } - - if (npc.localAI[1] >= (brotherAlive ? 180f : 120f)) - { - npc.localAI[1] = 0f; - - float projectileVelocity = expertMode ? 14f : 12.5f; - projectileVelocity += 3f * enrageScale; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 fireballVelocity = Vector2.Normalize(player.Center - npc.Center) * projectileVelocity; - Vector2 offset = Vector2.Normalize(fireballVelocity) * 40f; - Projectile.NewProjectile(npc.Center + offset, fireballVelocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, player.Center.X, player.Center.Y); - } - } - } - - // Float to the side of the target and fire - else if (npc.ai[1] == 1f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (!brotherAlive) - { - if (revenge) - npc.localAI[1] += 0.5f; - if (expertMode) - npc.localAI[1] += 0.5f; - } - - if (npc.localAI[1] >= (brotherAlive ? 75f : 50f) && Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - npc.localAI[1] = 0f; - - float projectileVelocity = expertMode ? 12.5f : 11f; - projectileVelocity += 3f * enrageScale; - int type = brotherAlive ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 fireballVelocity = Vector2.Normalize(player.Center - npc.Center) * projectileVelocity; - Vector2 offset = Vector2.Normalize(fireballVelocity) * 40f; - - if (!Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center + offset, fireballVelocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, player.Center.X, player.Center.Y); - } - else - { - float ai0 = type == ModContent.ProjectileType() ? 1f : 0f; - int proj = Projectile.NewProjectile(npc.Center + offset, fireballVelocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, ai0, 0f); - if (type == ModContent.ProjectileType()) - Main.projectile[proj].tileCollide = true; - } - } - } - - npc.ai[2] += 1f; - float phaseTimer = 240f - (death ? 60f * (1f - lifeRatio) : 0f); - if (npc.ai[2] >= phaseTimer || phase5) - { - if (death && !phase5 && Main.rand.Next(2) == 0 && !brotherAlive) - npc.ai[1] = 0f; - else - npc.ai[1] = !brotherAlive && phase3 && revenge ? 4f : 0f; - - npc.ai[2] = 0f; - if (death) - npc.localAI[0] = 1f; - - npc.TargetClosest(); - npc.netUpdate = true; - } - } - else if (npc.ai[1] == 2f) - { - npc.rotation = rotation; - - float chargeVelocity = phase5 ? 30f : (25f + (death ? 4f * (1f - lifeRatio) : 0f)); - chargeVelocity += 5f * enrageScale; - - if (provy) - chargeVelocity *= 1.25f; - - Vector2 vector = Vector2.Normalize(player.Center + (phase5 && malice ? player.velocity * 20f : Vector2.Zero) - npc.Center); - npc.velocity = vector * chargeVelocity; - - npc.ai[1] = 3f; - npc.netUpdate = true; - } - else if (npc.ai[1] == 3f) - { - npc.ai[2] += 1f; - - float chargeTime = phase5 ? 35f : (45f - (death ? 6f * (1f - lifeRatio) : 0f)); - if (npc.ai[2] >= chargeTime) - { - npc.velocity *= 0.9f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - { - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - // Leave behind slow hellblasts in Death Mode - if (Main.netMode != NetmodeID.MultiplayerClient && death && phase4 && npc.ai[2] % (phase5 ? 6f : 10f) == 0f) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 fireballVelocity = npc.velocity * 0.01f; - Projectile.NewProjectile(npc.Center, fireballVelocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); - } - } - - if (npc.ai[2] >= chargeTime + 10f) - { - if (!phase5) - npc.ai[3] += 1f; - - npc.ai[2] = 0f; - - npc.rotation = rotation; - npc.TargetClosest(); - npc.netUpdate = true; - - if (npc.ai[3] >= 2f) - { - npc.ai[1] = 0f; - npc.ai[3] = 0f; - return; - } - - npc.ai[1] = 4f; - } - } - else - { - npc.ai[2] += 1f; - if (npc.ai[2] >= (phase5 ? 15f : 30f)) - { - npc.TargetClosest(); - - npc.ai[1] = 2f; - npc.ai[2] = 0f; - if (death) - npc.localAI[0] = 1f; - - npc.netUpdate = true; - } - } - } - - public static void CataclysmAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Emit light - 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; - - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; - if (Main.dayTime || malice) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 2f; - } - - 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 += MathHelper.TwoPi; - else if (num842 > MathHelper.TwoPi) - num842 -= MathHelper.TwoPi; - - float num843 = 0.15f; - if (npc.rotation < num842) - { - if ((num842 - npc.rotation) > MathHelper.Pi) - npc.rotation -= num843; - else - npc.rotation += num843; - } - else if (npc.rotation > num842) - { - if ((npc.rotation - num842) > MathHelper.Pi) - npc.rotation += num843; - else - npc.rotation -= num843; - } - - if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) - npc.rotation = num842; - if (npc.rotation < 0f) - 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; - - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - calamityGlobalNPC.newAI[0] = 1f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[1] != 0f) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - return; - } - } - else - calamityGlobalNPC.newAI[0] = 0f; - - if (npc.ai[1] == 0f) - { - float num861 = 5f; - float num862 = 0.1f; - num861 += 2f * enrageScale; - num862 += 0.06f * enrageScale; - - if (provy) - { - num861 *= 1.25f; - num862 *= 1.25f; - } - - int num863 = 1; - if (npc.position.X + (npc.width / 2) < player.position.X + player.width) - num863 = -1; - - 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 * 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) - { - if (num866 > 300f) - num861 += 0.5f; - if (num866 > 400f) - num861 += 0.5f; - if (num866 > 500f) - num861 += 0.55f; - if (num866 > 600f) - num861 += 0.55f; - if (num866 > 700f) - num861 += 0.6f; - if (num866 > 800f) - num861 += 0.6f; - } - - num866 = num861 / num866; - num864 *= num866; - num865 *= num866; - - if (npc.velocity.X < num864) - { - npc.velocity.X += num862; - if (npc.velocity.X < 0f && num864 > 0f) - npc.velocity.X += num862; - } - else if (npc.velocity.X > num864) - { - npc.velocity.X -= num862; - if (npc.velocity.X > 0f && num864 < 0f) - npc.velocity.X -= num862; - } - if (npc.velocity.Y < num865) - { - npc.velocity.Y += num862; - if (npc.velocity.Y < 0f && num865 > 0f) - npc.velocity.Y += num862; - } - else if (npc.velocity.Y > num865) - { - npc.velocity.Y -= num862; - if (npc.velocity.Y > 0f && num865 < 0f) - npc.velocity.Y -= num862; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (240f - (death ? 120f * (1f - lifeRatio) : 0f))) - { - npc.TargetClosest(); - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.target = 255; - npc.netUpdate = true; - } - - 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; - if (npc.localAI[2] > 22f) - { - npc.localAI[2] = 0f; - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 34); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (revenge) - npc.localAI[1] += 0.5f; - - if (npc.localAI[1] > 12f) - { - npc.localAI[1] = 0f; - float num867 = NPC.AnyNPCs(ModContent.NPCType()) ? 4f : 6f; - num867 += enrageScale; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - 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; - num865 += npc.velocity.Y * 0.5f; - num864 += npc.velocity.X * 0.5f; - vector86.X -= num864; - vector86.Y -= num865; - Projectile.NewProjectile(vector86.X, vector86.Y, num864, num865, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, 0f); - } - } - } - } - else - { - if (npc.ai[1] == 1f) - { - Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 0); - npc.rotation = num842; - - float num870 = 14f + (death ? 4f * (1f - lifeRatio) : 0f); - num870 += 3f * enrageScale; - if (expertMode) - num870 += 2f; - if (revenge) - num870 += 2f; - if (provy) - num870 *= 1.15f; - - Vector2 vector87 = npc.Center; - float num871 = player.Center.X - vector87.X; - float num872 = player.Center.Y - vector87.Y; - float num873 = (float)Math.Sqrt(num871 * num871 + num872 * num872); - num873 = num870 / num873; - npc.velocity.X = num871 * num873; - npc.velocity.Y = num872 * num873; - npc.ai[1] = 2f; - return; - } - - if (npc.ai[1] == 2f) - { - npc.ai[2] += 1f + (death ? 0.5f * (1f - lifeRatio) : 0f); - if (expertMode) - npc.ai[2] += 0.25f; - if (revenge) - npc.ai[2] += 0.25f; - - if (npc.ai[2] >= 75f) - { - npc.velocity.X *= 0.93f; - npc.velocity.Y *= 0.93f; - - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - if (npc.ai[2] >= 105f) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.target = 255; - npc.rotation = num842; - npc.TargetClosest(); - if (npc.ai[3] >= 3f) - { - npc.ai[1] = 0f; - npc.ai[3] = 0f; - return; - } - npc.ai[1] = 1f; - } - } - } - } - - public static void CatastropheAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Emit light - 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; - - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; - if (Main.dayTime || malice) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 2f; - } - - 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 += MathHelper.TwoPi; - else if (num842 > MathHelper.TwoPi) - num842 -= MathHelper.TwoPi; - - float num843 = 0.15f; - if (npc.rotation < num842) - { - if ((num842 - npc.rotation) > MathHelper.Pi) - npc.rotation -= num843; - else - npc.rotation += num843; - } - else if (npc.rotation > num842) - { - if ((npc.rotation - num842) > MathHelper.Pi) - npc.rotation += num843; - else - npc.rotation -= num843; - } - - if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) - npc.rotation = num842; - if (npc.rotation < 0f) - 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; - - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - calamityGlobalNPC.newAI[0] = 1f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[1] != 0f) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - return; - } - } - else - calamityGlobalNPC.newAI[0] = 0f; - - if (npc.ai[1] == 0f) - { - float num861 = 4.5f; - float num862 = 0.2f; - num861 += 2f * enrageScale; - num862 += 0.1f * enrageScale; - - if (provy) - { - num861 *= 1.25f; - num862 *= 1.25f; - } - - int num863 = 1; - if (npc.Center.X < player.Center.X) - num863 = -1; - - Vector2 vector86 = npc.Center; - float num864 = player.Center.X + (num863 * 180) - vector86.X; - float num865 = player.Center.Y - vector86.Y; - float num866 = (float)Math.Sqrt(num864 * num864 + num865 * num865); - - if (expertMode || provy) - { - if (num866 > 300f) - num861 += 0.5f; - if (num866 > 400f) - num861 += 0.5f; - if (num866 > 500f) - num861 += 0.55f; - if (num866 > 600f) - num861 += 0.55f; - if (num866 > 700f) - num861 += 0.6f; - if (num866 > 800f) - num861 += 0.6f; - } - - num866 = num861 / num866; - num864 *= num866; - num865 *= num866; - - if (npc.velocity.X < num864) - { - npc.velocity.X += num862; - if (npc.velocity.X < 0f && num864 > 0f) - npc.velocity.X += num862; - } - else if (npc.velocity.X > num864) - { - npc.velocity.X -= num862; - if (npc.velocity.X > 0f && num864 < 0f) - npc.velocity.X -= num862; - } - if (npc.velocity.Y < num865) - { - npc.velocity.Y += num862; - if (npc.velocity.Y < 0f && num865 > 0f) - npc.velocity.Y += num862; - } - else if (npc.velocity.Y > num865) - { - npc.velocity.Y -= num862; - if (npc.velocity.Y > 0f && num865 < 0f) - npc.velocity.Y -= num862; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (180f - (death ? 90f * (1f - lifeRatio) : 0f))) - { - npc.TargetClosest(); - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.target = 255; - npc.netUpdate = true; - } - - bool fireDelay = npc.ai[2] > 120f || lifeRatio < 0.9f; - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && fireDelay) - { - npc.localAI[2] += 1f; - if (npc.localAI[2] > 36f) - { - npc.localAI[2] = 0f; - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 34); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (revenge) - npc.localAI[1] += 0.5f; - - if (npc.localAI[1] > 50f) - { - npc.localAI[1] = 0f; - float num867 = death ? 14f : 12f; - num867 += 3f * enrageScale; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - 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; - num865 += npc.velocity.Y * 0.5f; - num864 += npc.velocity.X * 0.5f; - vector86.X -= num864; - vector86.Y -= num865; - Projectile.NewProjectile(vector86.X, vector86.Y, num864, num865, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, 0f); - } - } - } - } - else - { - if (npc.ai[1] == 1f) - { - Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 0); - npc.rotation = num842; - - float num870 = (NPC.AnyNPCs(ModContent.NPCType()) ? 12f : 16f) + (death ? 4f * (1f - lifeRatio) : 0f); - num870 += 4f * enrageScale; - if (expertMode) - num870 += 2f; - if (revenge) - num870 += 2f; - if (provy) - num870 *= 1.15f; - - 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; - npc.ai[1] = 2f; - return; - } - - if (npc.ai[1] == 2f) - { - npc.ai[2] += 1f + (death ? 0.5f * (1f - lifeRatio) : 0f); - if (expertMode) - npc.ai[2] += 0.25f; - if (revenge) - npc.ai[2] += 0.25f; - - if (npc.ai[2] >= 60f) //50 - { - npc.velocity.X *= 0.93f; - npc.velocity.Y *= 0.93f; - - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - if (npc.ai[2] >= 90f) //80 - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.rotation = num842; - if (npc.ai[3] >= 4f) - { - npc.ai[1] = 0f; - npc.ai[3] = 0f; - return; - } - npc.ai[1] = 1f; - } - } - } - } - #endregion - - #region Astrum Aureus - public static void AstrumAureusAI(NPC npc, Mod mod) + #region Aquatic Scourge + public static void AquaticScourgeAI(NPC npc, Mod mod, bool head) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - bool postMoonLordBuff = NPC.downedMoonlord && !BossRushEvent.BossRushActive; - npc.damage = postMoonLordBuff ? npc.defDamage * 2 : npc.defDamage; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Variables - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - float shootTimer = 1f; - if (expertMode) - shootTimer += death ? (float)Math.Round(3f * (1f - lifeRatio)) : (float)Math.Round(2f * (1f - lifeRatio)); + // Adjust hostility and stats + if (npc.justHit || npc.life <= npc.lifeMax * 0.999 || BossRushEvent.BossRushActive) + { + if (calamityGlobalNPC.newAI[0] == 0f) + { + // Kiss my motherfucking ass you piece of shit game + npc.timeLeft *= 20; + CalamityMod.bossKillTimes.TryGetValue(npc.type, out int revKillTime); + calamityGlobalNPC.KillTime = revKillTime; + calamityGlobalNPC.newAI[0] = 1f; + npc.boss = head; + npc.chaseable = true; + npc.netUpdate = true; + } + npc.damage = npc.defDamage; + } + else + npc.damage = 0; - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; - if (Main.dayTime || malice) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 2f; - } + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Phases + bool phase2 = lifeRatio < 0.75f; + bool phase3 = lifeRatio < 0.5f; + bool phase4 = lifeRatio < 0.25f; - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Set worm variable + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - Player player = Main.player[npc.target]; + if (!head) + { + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + } - // Direction + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + Player player = Main.player[npc.target]; + + bool notOcean = player.position.Y < 400f || + player.position.Y > Main.worldSurface * 16.0 || + (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); + + // Enrage + if (head) + { + if (notOcean && !player.Calamity().ZoneSulphur && !BossRushEvent.BossRushActive) + { + if (npc.localAI[2] > 0f) + npc.localAI[2] -= 1f; + } + else + npc.localAI[2] = CalamityGlobalNPC.biomeEnrageTimerMax; + } + + bool biomeEnraged = npc.localAI[2] <= 0f || malice; + + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + if (biomeEnraged) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } + + Vector2 vectorCenter = npc.Center; + + // Circular movement + bool doSpiral = false; + if (head && calamityGlobalNPC.newAI[0] == 1f && calamityGlobalNPC.newAI[2] == 1f && revenge) + { + bool doNotSpiral = !Collision.CanHit(npc.Center, 1, 1, player.position, player.width, player.height); + float ai3 = 660f; + calamityGlobalNPC.newAI[3] += 1f; + doSpiral = calamityGlobalNPC.newAI[1] == 0f && calamityGlobalNPC.newAI[3] >= ai3; + if (doSpiral) + { + // Barf + npc.localAI[3] = 90f; + float barfDivisor = malice ? 30f : expertMode ? 40f : 60f; + if (calamityGlobalNPC.newAI[3] % barfDivisor == 0f) + { + Main.PlaySound(SoundID.NPCKilled, (int)npc.position.X, (int)npc.position.Y, 13); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (phase3) + { + // Circle of toxic clouds + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + int totalProjectiles = (phase4 ? 6 : 9) + (int)((calamityGlobalNPC.newAI[3] - ai3) / barfDivisor) * (phase4 ? 2 : 3); + float radians = MathHelper.TwoPi / totalProjectiles; + float cloudVelocity = 1f + enrageScale; + Vector2 spinningPoint = new Vector2(0f, -cloudVelocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(vectorCenter, vector255, type, damage, 0f, Main.myPlayer); + } + } + else + { + // Spread of directed sand blasts + float num742 = death ? 10f : 8f; + float num743 = player.Center.X - vectorCenter.X; + float num744 = player.Center.Y - vectorCenter.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + + num745 = num742 / num745; + num743 *= num745; + num744 *= num745; + + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + int numProj = death ? 5 : 3; + int spread = death ? 60 : 36; + 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 / numProj; + double offsetAngle; + + for (int i = 0; i < numProj; i++) + { + offsetAngle = startAngle + deltaAngle * i; + int proj = Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[proj].tileCollide = false; + } + } + } + } + + // Velocity boost + if (calamityGlobalNPC.newAI[3] == ai3) + { + npc.velocity.Normalize(); + npc.velocity *= 24f; + } + + // Spin velocity + float velocity = (float)(Math.PI * 2D) / 120f; + 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 + 120f) + { + calamityGlobalNPC.newAI[3] = 0f; + float chargeVelocity = (death ? 16f : 12f) + 3f * enrageScale; + npc.velocity = Vector2.Normalize(player.Center - npc.Center) * chargeVelocity; + npc.TargetClosest(); + } + } + else + { + if (doNotSpiral && calamityGlobalNPC.newAI[3] > 0f) + calamityGlobalNPC.newAI[3] -= 2f; + + if (npc.localAI[3] > 0f) + npc.localAI[3] -= 1f; + + npc.localAI[1] = npc.Center.X - player.Center.X < 0 ? 1f : -1f; + } + } + + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = doSpiral; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (head) + { + // Spawn segments + if (calamityGlobalNPC.newAI[2] == 0f && npc.ai[0] == 0f) + { + int maxLength = death ? 80 : revenge ? 40 : expertMode ? 35 : 30; + int Previous = npc.whoAmI; + for (int num36 = 0; num36 < maxLength; num36++) + { + int lol; + if (num36 >= 0 && num36 < maxLength - 1) + { + if (num36 % 2 == 0) + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + else + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + } + else + 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] = npc.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); + Previous = lol; + } + calamityGlobalNPC.newAI[2] = 1f; + } + + // Big barf attack + if (calamityGlobalNPC.newAI[0] == 1f && !doSpiral && phase2) + { + npc.localAI[0] += 1f; + if (npc.localAI[0] >= (revenge ? 360f : 420f)) + { + if (Vector2.Distance(player.Center, npc.Center) > 320f) + { + npc.localAI[0] = 0f; + npc.netUpdate = true; + Main.PlaySound(SoundID.NPCKilled, (int)npc.position.X, (int)npc.position.Y, 13); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float velocity = death ? 9.5f : revenge ? 7.5f : 6.5f; + int totalProjectiles = malice ? 40 : expertMode ? 30 : 20; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float homing = phase4 ? 1f : 0f; + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 vector255 = new Vector2(0f, -velocity).RotatedBy(radians * i); + Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, homing, 0f); + } + + if (phase3) + { + int num320 = malice ? 21 : expertMode ? 14 : 7; + type = ModContent.ProjectileType(); + damage = npc.GetProjectileDamage(type); + for (int num321 = 0; num321 < num320; num321++) + { + Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + vector15.Normalize(); + vector15 *= Main.rand.Next(death ? 200 : 50, 401) * 0.01f; + + float maximumVelocityMult = death ? 0.35f : 0.25f; + if (expertMode) + vector15 *= 1f + (maximumVelocityMult * (0.5f - lifeRatio) * 2f); + + Projectile.NewProjectile(npc.Center, vector15, type, damage, 0f, Main.myPlayer, 0f, Main.rand.Next(-45, 1)); + } + } + } + } + } + } + } + + // Fire sand blasts or teeth depending on body type + else + { + if (calamityGlobalNPC.newAI[0] == 1f && (!phase3 || phase4)) + { + npc.localAI[0] += 1f; + float shootProjectile = 300; + float timer = npc.ai[0] + 15f; + float divisor = timer + shootProjectile; + + if (npc.type == ModContent.NPCType()) + { + if (npc.localAI[0] % divisor == 0f && (npc.ai[0] % 3f == 0f || !death)) + { + npc.TargetClosest(); + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 17); + 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 type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float num941 = death ? 9f : 8f; + num944 = num941 / num944; + num942 *= num944; + num943 *= num944; + vector104.X += num942 * 5f; + vector104.Y += num943 * 5f; + float accelerate = phase4 ? 1f : 0f; + Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, type, damage, 0f, Main.myPlayer, accelerate, 0f); + npc.netUpdate = true; + } + } + } + else if (npc.type == ModContent.NPCType()) + { + if (npc.localAI[0] % divisor == 0f && (npc.ai[0] % 3f == 0f || !death)) + { + npc.TargetClosest(); + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + 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 type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float num941 = death ? 15f : 12f; + num944 = num941 / num944; + num942 *= num944; + num943 *= num944; + vector104.X += num942 * 5f; + vector104.Y += num943 * 5f; + float homing = phase4 ? 1f : 0f; + Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, type, damage, 0f, Main.myPlayer, homing, 0f); + npc.netUpdate = true; + } + } + } + } + } + } + + // Kill body and tail + if (!head) + { + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } + } + else + { + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; + } + + float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f; + if (player.dead || Vector2.Distance(npc.Center, player.Center) > maxDistance) + { + calamityGlobalNPC.newAI[1] = 1f; + npc.TargetClosest(false); + npc.velocity.Y += 2f; + + if (npc.position.Y > Main.worldSurface * 16.0) + npc.velocity.Y += 2f; + + if (npc.position.Y > Main.worldSurface * 16.0) + { + for (int a = 0; a < Main.npc.Length; a++) + { + int type = Main.npc[a].type; + if (type == ModContent.NPCType() || type == ModContent.NPCType() || + type == ModContent.NPCType() || type == ModContent.NPCType()) + { + Main.npc[a].active = false; + } + } + } + } + else + calamityGlobalNPC.newAI[1] = 0f; + + // Change direction + if (npc.velocity.X < 0f) + npc.spriteDirection = -1; + else if (npc.velocity.X > 0f) + npc.spriteDirection = 1; + + // Alpha changes + if (head || Main.npc[(int)npc.ai[1]].alpha < 128) + { + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } + + // Velocity and movement + float num188 = 5f; + float num189 = 0.08f; + 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); + + if (head && !doSpiral) + { + if (calamityGlobalNPC.newAI[0] != 1f) + { + num192 += 400; + if (Math.Abs(npc.Center.X - player.Center.X) < 500f) + { + if (npc.velocity.X > 0f) + num191 = player.Center.X + 600f; + else + num191 = player.Center.X - 600f; + } + } + + if (calamityGlobalNPC.newAI[0] == 1f) + { + num188 = revenge ? 9f : 7f; + num189 = revenge ? 0.12f : 0.1f; + if (expertMode) + { + num188 += 8f * (1f - lifeRatio); + num189 += 0.06f * (1f - lifeRatio); + } + num188 += 3f * enrageScale; + num189 += 0.06f * enrageScale; + if (death) + { + num188 += 5f; + num189 -= 0.03f; + num188 += Vector2.Distance(player.Center, npc.Center) * 0.0015f; + num189 += Vector2.Distance(player.Center, npc.Center) * 0.00003f; + } + } + + float num48 = num188 * 1.3f; + float num49 = num188 * 0.7f; + float num50 = npc.velocity.Length(); + if (num50 > 0f) + { + if (num50 > num48) + { + npc.velocity.Normalize(); + npc.velocity *= num48; + } + else if (num50 < num49) + { + npc.velocity.Normalize(); + npc.velocity *= num49; + } + } + } + + 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)Math.Sqrt(num191 * num191 + num192 * num192); + + if (!head) + { + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + { + try + { + 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)Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + int num194 = npc.width; + num193 = (num193 - num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; + if (num191 < 0f) + { + npc.spriteDirection = -1; + } + else if (num191 > 0f) + { + npc.spriteDirection = 1; + } + } + } + else if (!doSpiral) + { + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); + float num198 = num188 / num193; + num191 *= num198; + num192 *= num198; + + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + { + npc.velocity.X += num189; + } + else + { + if (npc.velocity.X > num191) + npc.velocity.X -= num189; + } + if (npc.velocity.Y < num192) + { + npc.velocity.Y += num189; + } + else + { + if (npc.velocity.Y > num192) + npc.velocity.Y -= num189; + } + 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 (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; + else + npc.velocity.X -= num189 * 2f; + } + } + else + { + if (num196 > num197) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189 * 1.1f; + else if (npc.velocity.X > num191) + npc.velocity.X -= num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += num189; + else + npc.velocity.Y -= num189; + } + } + else + { + if (npc.velocity.Y < num192) + npc.velocity.Y += num189 * 1.1f; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.X > 0f) + npc.velocity.X += num189; + else + npc.velocity.X -= num189; + } + } + } + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + } + } + #endregion + + #region Brimstone Elemental + public static void BrimstoneElementalAI(NPC npc, Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + // Used for Brimling AI states + CalamityGlobalNPC.brimstoneElemental = npc.whoAmI; + + // Emit light + 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; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + Player player = Main.player[npc.target]; + + bool despawnDistance = Vector2.Distance(player.Center, vectorCenter) > CalamityGlobalNPC.CatchUpDistance350Tiles; + + if (!player.active || player.dead || despawnDistance) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead || despawnDistance) + { + npc.rotation = npc.velocity.X * 0.04f; + + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + npc.velocity.Y -= 0.1f; + if (npc.velocity.Y < -12f) + npc.velocity.Y = -12f; + + if (npc.timeLeft > 60) + npc.timeLeft = 60; + + if (npc.ai[0] != 0f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.netUpdate = true; + } + return; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; + + CalamityPlayer modPlayer = player.Calamity(); + + // Reset defense + npc.defense = npc.defDefense; + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = npc.ai[0] == 4f; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Variables for buffing the AI + bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + bool phase2 = lifeRatio < 0.5f && revenge; + bool phase3 = lifeRatio < 0.33f; + + // Enrage + if ((!player.ZoneUnderworldHeight || !modPlayer.ZoneCalamity) && !BossRushEvent.BossRushActive) + { + if (calamityGlobalNPC.newAI[3] > 0f) + calamityGlobalNPC.newAI[3] -= 1f; + } + else + calamityGlobalNPC.newAI[3] = CalamityGlobalNPC.biomeEnrageTimerMax; + + bool biomeEnraged = calamityGlobalNPC.newAI[3] <= 0f || malice; + + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + if (biomeEnraged && (!player.ZoneUnderworldHeight || malice)) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + if (biomeEnraged && (!modPlayer.ZoneCalamity || malice)) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + + npc.Calamity().DR = npc.ai[0] == 4f ? 0.6f : 0.15f; + + // Emit dust + int dustAmt = (npc.ai[0] == 2f) ? 2 : 1; + int size = (npc.ai[0] == 2f) ? 50 : 35; + if (npc.ai[0] != 1f) + { + for (int num1011 = 0; num1011 < 2; num1011++) + { + if (Main.rand.Next(3) < dustAmt) + { + 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; + } + } + } + + // Distance from destination where Brimmy stops moving + float movementDistanceGateValue = 100f; + + // How fast Brimmy moves to the destination + float baseVelocity = (death ? 6f : revenge ? 5.5f : expertMode ? 5f : 4.5f) * (npc.ai[0] == 5f ? 0.05f : npc.ai[0] == 3f ? 1.5f : 1f); + if (expertMode) + baseVelocity += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + baseVelocity += 5f * enrageScale; + + float baseAcceleration = (death ? 0.12f : 0.1f) * (npc.ai[0] == 5f ? 0.5f : npc.ai[0] == 3f ? 1.5f : 1f); + baseAcceleration += 0.1f * enrageScale; + if (expertMode) + { + baseAcceleration += 0.03f * (1f - lifeRatio); + } + if (provy) + { + baseVelocity *= 1.25f; + baseAcceleration *= 1.25f; + } + + // This is where Brimmy should be + Vector2 destination = npc.ai[0] != 3f ? player.Center : new Vector2(player.Center.X, player.Center.Y - 300f); + + // How far Brimmy is from where she's supposed to be + Vector2 distanceFromDestination = destination - npc.Center; + + // Movement + if (npc.ai[0] != 4f) + { + // Inverse lerp returns the percentage of progress between A and B + float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + + // Min velocity + float minVelocity = distanceFromDestination.Length(); + float minVelocityCap = baseVelocity; + if (minVelocity > minVelocityCap) + minVelocity = minVelocityCap; + + // Max velocity + Vector2 maxVelocity = distanceFromDestination / 24f; + float maxVelocityCap = minVelocityCap * 3f; + if (maxVelocity.Length() > maxVelocityCap) + maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; + + Vector2 desiredVelocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); + npc.SimpleFlyMovement(desiredVelocity, baseAcceleration); + } + + // Rotation and direction + if (npc.ai[0] <= 2f || npc.ai[0] == 5f) + { + npc.rotation = npc.velocity.X * 0.04f; + if (npc.ai[0] != 5 || (npc.ai[1] < 180f && npc.ai[0] == 5f)) + { + float playerLocation = vectorCenter.X - player.Center.X; + npc.direction = playerLocation < 0f ? 1 : -1; + npc.spriteDirection = npc.direction; + } + } + + if (npc.ai[0] == -1f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int phase; + int random = phase2 ? 6 : 5; + do phase = Main.rand.Next(random); + while (phase == npc.ai[1] || (phase == 0 && phase3 && revenge) || phase == 1 || phase == 2 || (phase == 4 && npc.localAI[3] != 0f)); + + npc.ai[0] = phase; + npc.ai[1] = 0f; + + // Cocoon phase cooldown + if (npc.localAI[3] > 0f) + npc.localAI[3] -= 1f; + else if (phase == 4) + npc.localAI[3] = 3f; + + npc.netUpdate = true; + + // Prevent netUpdate from being blocked by the spam counter. + // A phase switch sync is a critical operation that must be synced. + if (npc.netSpam >= 10) + npc.netSpam = 9; + } + } + + // Pick a location to teleport to + else if (npc.ai[0] == 0f) + { + npc.chaseable = true; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[1] += 1f; + if (npc.localAI[1] >= (malice ? 5f : death ? 30f : 180f)) + { + npc.TargetClosest(); + npc.localAI[1] = 0f; + int timer = 0; + int playerPosX; + int playerPosY; + while (true) + { + timer++; + playerPosX = (int)player.Center.X / 16; + playerPosY = (int)player.Center.Y / 16; + + int min = 12; + int max = 16; + + if (Main.rand.NextBool(2)) + playerPosX += Main.rand.Next(min, max); + else + playerPosX -= Main.rand.Next(min, max); + + if (Main.rand.NextBool(2)) + playerPosY += Main.rand.Next(min, max); + else + playerPosY -= Main.rand.Next(min, max); + + if (!WorldGen.SolidTile(playerPosX, playerPosY)) + break; + + if (timer > 100) + return; + } + npc.ai[0] = 1f; + npc.ai[1] = playerPosX; + npc.ai[2] = playerPosY; + npc.netUpdate = true; + } + } + } + + // Teleport to location + else if (npc.ai[0] == 1f) + { + npc.chaseable = true; + 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); + Main.dust[dust].noGravity = true; + Main.dust[dust].fadeIn = 1f; + } + npc.alpha += malice ? 4 : death ? 3 : 2; + if (npc.alpha >= 255) + { + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.CountNPCS(ModContent.NPCType()) < (death ? 1 : 2) && revenge) + { + NPC.NewNPC((int)vectorCenter.X, (int)vectorCenter.Y, ModContent.NPCType()); + } + Main.PlaySound(SoundID.Item8, vectorCenter); + npc.alpha = 255; + npc.position = position; + for (int n = 0; n < 15; n++) + { + int warpDust = Dust.NewDust(npc.position, npc.width, npc.height, 235, 0f, -1f, 90, default, 3f); + Main.dust[warpDust].noGravity = true; + } + npc.ai[0] = 2f; + npc.netUpdate = true; + } + } + + // Either teleport again or go to next AI state + else if (npc.ai[0] == 2f) + { + npc.alpha -= 50; + if (npc.alpha <= 0) + { + npc.chaseable = true; + npc.ai[3] += 1f; + npc.alpha = 0; + if (npc.ai[3] >= 2f || phase2) + { + npc.ai[0] = -1f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + } + else + { + npc.ai[0] = 0f; + } + npc.netUpdate = true; + } + } + + // Float above target and fire projectiles + else if (npc.ai[0] == 3f) + { + npc.chaseable = true; + 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; + float divisor = expertMode ? (death ? 80f : revenge ? 45f : 50f) - (float)Math.Ceiling(10f * (1f - lifeRatio)) : 50f; + divisor -= 5f * enrageScale; + float divisor2 = divisor * 2f; + + if (npc.ai[1] % divisor == divisor - 1f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float num742 = death ? 5f : 4f; + num742 += 2f * enrageScale; + 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; + num744 *= num745; + vectorCenter.X += num743 * 3f; + vectorCenter.Y += num744 * 3f; + + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + int numProj = death ? 8 : 4; + int spread = death ? 90 : 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 / numProj; + double offsetAngle; + + if (npc.ai[1] % divisor2 == divisor2 - 1f) + { + 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), type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); + } + } + + float projectileSpeed = death ? 6f : 5f; + if (revenge) + projectileSpeed += 1f; + projectileSpeed += 2f * enrageScale; + + if (expertMode) + projectileSpeed += 3f * (1f - lifeRatio); + + vectorCenter = npc.Center; + 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; + vectorCenter.X += relativeSpeedX * 3f; + vectorCenter.Y += relativeSpeedY * 3f; + type = ModContent.ProjectileType(); + damage = npc.GetProjectileDamage(type); + int projectileShot = Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, relativeSpeedX, relativeSpeedY, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, player.Center.X, player.Center.Y); + Main.projectile[projectileShot].timeLeft = 240; + } + } + + if (npc.ai[1] >= divisor * (death ? 5f : 10f)) + { + npc.TargetClosest(); + npc.ai[0] = -1f; + npc.ai[1] = 3f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } + } + + // Cocoon bullet hell + else if (npc.ai[0] == 4f) + { + npc.defense = npc.defDefense * 4; + + npc.chaseable = false; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[0] += 1f; + if (expertMode) + npc.localAI[0] += 1f - lifeRatio; + npc.localAI[0] += 1f * enrageScale; + + if (npc.localAI[0] >= 120f) + { + npc.localAI[0] = 0f; + + float projectileSpeed = death ? 9f : revenge ? 8f : 6f; + projectileSpeed += 3f * enrageScale; + + vectorCenter = player.Center - vectorCenter; + + float radialOffset = 0.2f; + float diameter = 80f; + + vectorCenter = Vector2.Normalize(vectorCenter) * projectileSpeed; + + Vector2 velocity = vectorCenter; + velocity.Normalize(); + velocity *= diameter; + + int totalProjectiles = 6; + float offsetAngle = (float)Math.PI * radialOffset; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + for (int j = 0; j < totalProjectiles; j++) + { + float radians = j - (totalProjectiles - 1f) / 2f; + Vector2 offset = velocity.RotatedBy(offsetAngle * radians); + int proj = Projectile.NewProjectile(npc.Center + offset, vectorCenter, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); + Main.projectile[proj].timeLeft = 300; + Main.projectile[proj].tileCollide = false; + } + + totalProjectiles = 12; + float radians2 = MathHelper.TwoPi / totalProjectiles; + type = ModContent.ProjectileType(); + damage = npc.GetProjectileDamage(type); + double angleA = radians2 * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(projectileSpeed * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = npc.localAI[2] % 2f == 0f ? new Vector2(0f, -projectileSpeed) : new Vector2(-velocityX, -projectileSpeed); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k); + Projectile.NewProjectile(npc.Center, vector255, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); + } + + if (death) + { + spinningPoint = npc.localAI[2] % 2f == 0f ? new Vector2(-velocityX, -projectileSpeed) : new Vector2(0f, -projectileSpeed); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k); + Projectile.NewProjectile(npc.Center, vector255 * 0.75f, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); + } + } + + npc.localAI[2] += 1f; + } + } + + npc.velocity *= 0.95f; + 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] >= (death ? 240f : 300f)) + { + npc.TargetClosest(); + npc.ai[0] = -1f; + npc.ai[1] = 4f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.localAI[0] = 0f; + npc.netUpdate = true; + } + } + + // Laser beam attack + else if (npc.ai[0] == 5f) + { + npc.chaseable = true; + + npc.defense = npc.defDefense * 2; + + Vector2 source = new Vector2(vectorCenter.X + (npc.spriteDirection > 0 ? 34f : -34f), vectorCenter.Y - 74f); + Vector2 aimAt = player.Center + player.velocity * 20f; + float aimResponsiveness = malice ? 0.05f : (npc.ai[2] == 1f || death) ? 0.1f : 0.25f; + + Vector2 aimVector = Vector2.Normalize(aimAt - source); + if (aimVector.HasNaNs()) + aimVector = -Vector2.UnitY; + aimVector = Vector2.Normalize(Vector2.Lerp(aimVector, Vector2.Normalize(npc.velocity), aimResponsiveness)); + aimVector *= 6f; + + Vector2 laserVelocity = Vector2.Normalize(aimVector); + if (laserVelocity.HasNaNs()) + laserVelocity = -Vector2.UnitY; + + calamityGlobalNPC.newAI[1] = laserVelocity.X; + calamityGlobalNPC.newAI[2] = laserVelocity.Y; + + // Rev = 190 + 165 = 355 + // Death = 165 + + npc.ai[1] += 1f; + if (npc.ai[1] >= 240f) + { + npc.TargetClosest(); + npc.ai[2] += 1f; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + if (npc.ai[2] >= (death ? 1f : 2f)) + { + npc.ai[0] = -1f; + npc.ai[1] = 5f; + npc.ai[2] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + else + { + npc.ai[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + } + else if (npc.ai[1] >= 180f) + { + npc.velocity *= 0.95f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (npc.ai[1] == 180f) + { + Main.PlaySound(SoundID.Item68, source); + Vector2 laserVelocity2 = new Vector2(npc.localAI[0], npc.localAI[1]); + laserVelocity2.Normalize(); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(source, laserVelocity2, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + else + { + float playSoundTimer = 30f; + if (npc.ai[1] < 150f) + { + switch ((int)npc.ai[2]) + { + case 0: + npc.ai[1] += 0.5f; + break; + case 1: + npc.ai[1] += 1f; + playSoundTimer = 40f; + break; + } + if (death) + { + npc.ai[1] += 0.5f; + playSoundTimer += 10f; + } + } + + if (npc.ai[1] % playSoundTimer == 0f) + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 20); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (npc.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f) + { + Projectile.NewProjectile(source, laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); + calamityGlobalNPC.newAI[0] = 1f; + } + else + { + if (npc.ai[1] == 150f) + { + 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, npc.whoAmI); + } + } + } + } + } + } + #endregion + + #region Calamitas Clone + public static void CalamitasCloneAI(NPC npc, Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + // Emit light + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1f, 0f, 0f); + + // Variables for increasing difficulty + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Phases + bool phase3 = lifeRatio < 0.7f || death; + bool phase4 = lifeRatio < 0.35f; + bool phase5 = lifeRatio <= 0.1f && revenge; + + // Don't take damage during bullet hells + npc.dontTakeDamage = calamityGlobalNPC.newAI[2] > 0f; + + // Variable for live brothers + bool brotherAlive = false; + + // For seekers + CalamityGlobalNPC.calamitas = npc.whoAmI; + + // Seeker ring + if (calamityGlobalNPC.newAI[1] == 0f && phase4 && expertMode) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 74); + int seekerAmt = death ? 10 : 5; + int seekerSpread = 360 / seekerAmt; + int seekerDistance = death ? 180 : 150; + for (int i = 0; i < seekerAmt; i++) + { + int spawn = NPC.NewNPC((int)(npc.Center.X + (Math.Sin(i * seekerSpread) * seekerDistance)), (int)(npc.Center.Y + (Math.Cos(i * seekerSpread) * seekerDistance)), ModContent.NPCType(), npc.whoAmI, 0, 0, 0, -1); + Main.npc[spawn].ai[0] = i * seekerSpread; + } + } + + string key = "Mods.CalamityMod.CalamitasBossText3"; + Color messageColor = Color.Orange; + CalamityUtils.DisplayLocalizedText(key, messageColor); + + calamityGlobalNPC.newAI[1] = 1f; + } + + // Do bullet hell or spawn brothers + if (calamityGlobalNPC.newAI[0] == 0f && npc.life > 0) + calamityGlobalNPC.newAI[0] = npc.lifeMax; + + // Bullet hells at 70% and 10%, brothers at 40% + if (npc.life > 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int num660 = (int)(npc.lifeMax * 0.3); + if ((npc.life + num660) < calamityGlobalNPC.newAI[0]) + { + calamityGlobalNPC.newAI[0] = npc.life; + if (calamityGlobalNPC.newAI[0] <= (float)npc.lifeMax * 0.1) + { + Main.PlaySound(SoundID.Item109, npc.Center); + calamityGlobalNPC.newAI[2] = 2f; + SpawnDust(); + } + else if (calamityGlobalNPC.newAI[0] <= (float)npc.lifeMax * 0.4) + { + NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI); + NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI); + + string key = "Mods.CalamityMod.CalamitasBossText2"; + Color messageColor = Color.Orange; + CalamityUtils.DisplayLocalizedText(key, messageColor); + + SpawnDust(); + } + else + { + Main.PlaySound(SoundID.Item109, npc.Center); + calamityGlobalNPC.newAI[2] = 1f; + SpawnDust(); + } + } + } + } + + // Immunity if brothers are alive + if (CalamityGlobalNPC.cataclysm != -1) + { + if (Main.npc[CalamityGlobalNPC.cataclysm].active) + brotherAlive = true; + } + if (CalamityGlobalNPC.catastrophe != -1) + { + if (Main.npc[CalamityGlobalNPC.catastrophe].active) + brotherAlive = true; + } + + if (brotherAlive) + npc.dontTakeDamage = true; + + void SpawnDust() + { + int dustAmt = 50; + int random = 3; + + for (int j = 0; j < 10; j++) + { + random += j; + int dustAmtSpawned = 0; + int scale = random * 6; + float dustPositionX = npc.Center.X - (scale / 2); + float dustPositionY = npc.Center.Y - (scale / 2); + while (dustAmtSpawned < dustAmt) + { + float dustVelocityX = Main.rand.Next(-random, random); + float dustVelocityY = Main.rand.Next(-random, random); + float dustVelocityScalar = random * 2f; + float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); + dustVelocity = dustVelocityScalar / dustVelocity; + dustVelocityX *= dustVelocity; + dustVelocityY *= dustVelocity; + int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].position.X = npc.Center.X; + Main.dust[dust].position.Y = npc.Center.Y; + Main.dust[dust].position.X += Main.rand.Next(-10, 11); + Main.dust[dust].position.Y += Main.rand.Next(-10, 11); + Main.dust[dust].velocity.X = dustVelocityX; + Main.dust[dust].velocity.Y = dustVelocityY; + dustAmtSpawned++; + } + } + } + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + // Target variable + Player player = Main.player[npc.target]; + + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } + + // Rotation + Vector2 npcCenter = new Vector2(npc.Center.X, npc.position.Y + npc.height - 59f); + Vector2 lookAt = new Vector2(player.position.X - (player.width / 2), player.position.Y - (player.height / 2)); + Vector2 rotationVector = npcCenter - lookAt; + + // Malice Mode predictive charge rotation + if (npc.ai[1] == 4f && phase5 && malice) + { + // Velocity + float chargeVelocity = 30f; + chargeVelocity += 5f * enrageScale; + if (provy) + chargeVelocity *= 1.25f; + + lookAt += Main.player[npc.target].velocity * 20f; + rotationVector = Vector2.Normalize(npcCenter - lookAt) * chargeVelocity; + } + + float rotation = (float)Math.Atan2(rotationVector.Y, rotationVector.X) + MathHelper.PiOver2; + if (rotation < 0f) + rotation += MathHelper.TwoPi; + else if (rotation > MathHelper.TwoPi) + rotation -= MathHelper.TwoPi; + + float rotationAmt = 0.1f; + if (npc.rotation < rotation) + { + if ((rotation - npc.rotation) > MathHelper.Pi) + npc.rotation -= rotationAmt; + else + npc.rotation += rotationAmt; + } + else if (npc.rotation > rotation) + { + if ((npc.rotation - rotation) > MathHelper.Pi) + npc.rotation += rotationAmt; + else + npc.rotation -= rotationAmt; + } + + if (npc.rotation > rotation - rotationAmt && npc.rotation < rotation + rotationAmt) + npc.rotation = rotation; + if (npc.rotation < 0f) + npc.rotation += MathHelper.TwoPi; + else if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; + if (npc.rotation > rotation - rotationAmt && npc.rotation < rotation + rotationAmt) + npc.rotation = rotation; + + // Despawn + if (!player.active || player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead) + { + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + npc.velocity.Y -= 0.1f; + if (npc.velocity.Y < -12f) + npc.velocity.Y = -12f; + + if (npc.timeLeft > 60) + npc.timeLeft = 60; + + if (npc.ai[1] != 0f) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.alpha = 0; + npc.netUpdate = true; + } + return; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; + + // Reset damage from bullet hell phases + npc.damage = npc.defDamage; + + // Distance from destination where Cal Clone stops moving + float movementDistanceGateValue = 100f; + + // How fast Cal Clone moves to the destination + float baseVelocity = (expertMode ? 10f : 8.5f) * (npc.ai[1] == 4f ? 1.4f : 1f); + float baseAcceleration = (expertMode ? 0.18f : 0.155f) * (npc.ai[1] == 4f ? 1.4f : 1f); + baseVelocity += 4f * enrageScale; + baseAcceleration += 0.1f * enrageScale; + if (death) + { + baseVelocity += 2f * (1f - lifeRatio); + baseAcceleration += 0.04f * (1f - lifeRatio); + } + if (provy) + { + baseVelocity *= 1.25f; + baseAcceleration *= 1.25f; + } + + // Reduce acceleration if target is holding a true melee weapon + Item targetSelectedItem = player.inventory[player.selectedItem]; + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) + baseAcceleration *= 0.5f; + + // What side Cal Clone should be on, relative to the target + int xPos = 1; + if (npc.Center.X < player.Center.X) + xPos = -1; + + // How far Cal Clone should be from the target + float averageDistance = 500f; + float chargeDistance = phase5 ? 300f : 400f; + + // This is where Cal Clone should be + Vector2 destination = (calamityGlobalNPC.newAI[2] > 0f || npc.ai[1] == 0f) ? new Vector2(player.Center.X, player.Center.Y - averageDistance) : + npc.ai[1] == 1f ? new Vector2(player.Center.X + averageDistance * xPos, player.Center.Y) : + new Vector2(player.Center.X + chargeDistance * xPos, player.Center.Y); + + // Add some random distance to the destination after certain attacks + if (npc.localAI[0] == 1f) + { + npc.localAI[0] = 0f; + npc.localAI[2] = Main.rand.Next(-50, 51); + npc.localAI[3] = Main.rand.Next(-300, 301); + npc.netUpdate = true; + } + + // Add a bit of randomness to the destination + if (death) + { + destination.X += npc.ai[1] == 0f ? npc.localAI[3] : npc.localAI[2]; + destination.Y += npc.ai[1] == 0f ? npc.localAI[2] : npc.localAI[3]; + } + + // How far Cal Clone is from where she's supposed to be + Vector2 distanceFromDestination = destination - npc.Center; + + // Movement + if (npc.ai[1] == 0f || npc.ai[1] == 1f || npc.ai[1] == 4f || calamityGlobalNPC.newAI[2] > 0f) + { + // Inverse lerp returns the percentage of progress between A and B + float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + + // Min velocity + float minVelocity = distanceFromDestination.Length(); + float minVelocityCap = baseVelocity; + if (minVelocity > minVelocityCap) + minVelocity = minVelocityCap; + + // Max velocity + Vector2 maxVelocity = distanceFromDestination / 24f; + float maxVelocityCap = minVelocityCap * 3f; + if (maxVelocity.Length() > maxVelocityCap) + maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; + + Vector2 desiredVelocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); + npc.SimpleFlyMovement(desiredVelocity, baseAcceleration); + } + + // Bullet hell phase + if (calamityGlobalNPC.newAI[2] > 0f) + { + if (calamityGlobalNPC.newAI[3] < 900f) + { + calamityGlobalNPC.newAI[3] += 1f; + npc.damage = 0; + npc.dontTakeDamage = true; + npc.alpha = 255; + + float rotX = player.Center.X - npc.Center.X; + float rotY = player.Center.Y - npc.Center.Y; + npc.rotation = (float)Math.Atan2(rotY, rotX) - MathHelper.PiOver2; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (calamityGlobalNPC.newAI[2] == 2f) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type) + (provy ? 30 : 0); + float gigaBlastFrequency = (expertMode ? 180f : 240f) - enrageScale * 15f; + float projSpeed = malice ? 6.25f : 5f; + if (calamityGlobalNPC.newAI[3] <= 300f) + { + if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from top + Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer); + } + else if (calamityGlobalNPC.newAI[3] <= 600f && calamityGlobalNPC.newAI[3] > 300f) + { + if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from right + Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -projSpeed, 0f, type, damage, 0f, Main.myPlayer); + } + else if (calamityGlobalNPC.newAI[3] > 600f) + { + if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from top + Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer); + } + } + + npc.ai[0] += 1f; + float hellblastGateValue = (expertMode ? 12f : 16f) - enrageScale; + if (npc.ai[0] >= hellblastGateValue) + { + npc.ai[0] = 0f; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type) + (provy ? 30 : 0); + float projSpeed = malice ? 5f : 4f; + if (calamityGlobalNPC.newAI[3] % (hellblastGateValue * 6f) == 0f) + { + float distance = Main.rand.NextBool() ? -1000f : 1000f; + float velocity = distance == -1000f ? projSpeed : -projSpeed; + Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + if (calamityGlobalNPC.newAI[3] < 300f) // Blasts from above + { + Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + else if (calamityGlobalNPC.newAI[3] < 600f) // Blasts from left and right + { + Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 0.5f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 0.5f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + else // Blasts from above, left, and right + { + Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed - 1f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 1f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 1f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + } + } + } + else + { + npc.ai[0] = 0f; + npc.ai[3] = 0f; + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + + // Prevent bullshit charge hits when second bullet hell ends. + if (phase5) + { + npc.ai[1] = 4f; + npc.ai[2] = -105f; + npc.TargetClosest(); + } + else + { + if (death) + { + int AIState = Main.rand.Next(3); + switch (AIState) + { + case 0: + npc.ai[1] = 0f; + npc.ai[2] = 0f; + break; + case 1: + npc.ai[1] = 1f; + npc.ai[2] = 0f; + break; + case 2: + npc.ai[1] = 4f; + npc.ai[2] = -105f; + npc.TargetClosest(); + break; + } + } + else + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + + if (death) + npc.localAI[0] = 1f; + } + + npc.netUpdate = true; + + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active) + { + if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + { + if (projectile.timeLeft > 60) + projectile.timeLeft = 60; + } + else if (projectile.type == ModContent.ProjectileType()) + { + projectile.ai[1] = 1f; + + if (projectile.timeLeft > 60) + projectile.timeLeft = 60; + } + } + } + } + + return; + } + + npc.alpha = npc.dontTakeDamage ? 255 : 0; + + // Float above target and fire lasers or fireballs + if (npc.ai[1] == 0f) + { + npc.ai[2] += 1f; + float phaseTimer = 400f - (death ? 120f * (1f - lifeRatio) : 0f); + if (npc.ai[2] >= phaseTimer || phase5) + { + if (death && !phase5 && Main.rand.Next(2) == 0 && !brotherAlive) + npc.ai[1] = 4f; + else + npc.ai[1] = 1f; + + npc.ai[2] = 0f; + if (death) + npc.localAI[0] = 1f; + + npc.TargetClosest(); + npc.netUpdate = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[1] += 1f; + if (!brotherAlive) + { + if (expertMode) + npc.localAI[1] += death ? 2f * (1f - lifeRatio) : 1f - lifeRatio; + if (revenge) + npc.localAI[1] += 0.5f; + } + + if (npc.localAI[1] >= (brotherAlive ? 180f : 120f)) + { + npc.localAI[1] = 0f; + + float projectileVelocity = expertMode ? 14f : 12.5f; + projectileVelocity += 3f * enrageScale; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Vector2 fireballVelocity = Vector2.Normalize(player.Center - npc.Center) * projectileVelocity; + Vector2 offset = Vector2.Normalize(fireballVelocity) * 40f; + Projectile.NewProjectile(npc.Center + offset, fireballVelocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, player.Center.X, player.Center.Y); + } + } + } + + // Float to the side of the target and fire + else if (npc.ai[1] == 1f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[1] += 1f; + if (!brotherAlive) + { + if (revenge) + npc.localAI[1] += 0.5f; + if (expertMode) + npc.localAI[1] += 0.5f; + } + + if (npc.localAI[1] >= (brotherAlive ? 75f : 50f) && Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + npc.localAI[1] = 0f; + + float projectileVelocity = expertMode ? 12.5f : 11f; + projectileVelocity += 3f * enrageScale; + int type = brotherAlive ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Vector2 fireballVelocity = Vector2.Normalize(player.Center - npc.Center) * projectileVelocity; + Vector2 offset = Vector2.Normalize(fireballVelocity) * 40f; + + if (!Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + type = ModContent.ProjectileType(); + damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center + offset, fireballVelocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, player.Center.X, player.Center.Y); + } + else + { + float ai0 = type == ModContent.ProjectileType() ? 1f : 0f; + int proj = Projectile.NewProjectile(npc.Center + offset, fireballVelocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, ai0, 0f); + if (type == ModContent.ProjectileType()) + Main.projectile[proj].tileCollide = true; + } + } + } + + npc.ai[2] += 1f; + float phaseTimer = 240f - (death ? 60f * (1f - lifeRatio) : 0f); + if (npc.ai[2] >= phaseTimer || phase5) + { + if (death && !phase5 && Main.rand.Next(2) == 0 && !brotherAlive) + npc.ai[1] = 0f; + else + npc.ai[1] = !brotherAlive && phase3 && revenge ? 4f : 0f; + + npc.ai[2] = 0f; + if (death) + npc.localAI[0] = 1f; + + npc.TargetClosest(); + npc.netUpdate = true; + } + } + else if (npc.ai[1] == 2f) + { + npc.rotation = rotation; + + float chargeVelocity = phase5 ? 30f : (25f + (death ? 4f * (1f - lifeRatio) : 0f)); + chargeVelocity += 5f * enrageScale; + + if (provy) + chargeVelocity *= 1.25f; + + Vector2 vector = Vector2.Normalize(player.Center + (phase5 && malice ? player.velocity * 20f : Vector2.Zero) - npc.Center); + npc.velocity = vector * chargeVelocity; + + npc.ai[1] = 3f; + npc.netUpdate = true; + } + else if (npc.ai[1] == 3f) + { + npc.ai[2] += 1f; + + float chargeTime = phase5 ? 35f : (45f - (death ? 6f * (1f - lifeRatio) : 0f)); + if (npc.ai[2] >= chargeTime) + { + npc.velocity *= 0.9f; + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) + npc.velocity.X = 0f; + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) + npc.velocity.Y = 0f; + } + else + { + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; + + // Leave behind slow hellblasts in Death Mode + if (Main.netMode != NetmodeID.MultiplayerClient && death && phase4 && npc.ai[2] % (phase5 ? 6f : 10f) == 0f) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Vector2 fireballVelocity = npc.velocity * 0.01f; + Projectile.NewProjectile(npc.Center, fireballVelocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); + } + } + + if (npc.ai[2] >= chargeTime + 10f) + { + if (!phase5) + npc.ai[3] += 1f; + + npc.ai[2] = 0f; + + npc.rotation = rotation; + npc.TargetClosest(); + npc.netUpdate = true; + + if (npc.ai[3] >= 2f) + { + npc.ai[1] = 0f; + npc.ai[3] = 0f; + return; + } + + npc.ai[1] = 4f; + } + } + else + { + npc.ai[2] += 1f; + if (npc.ai[2] >= (phase5 ? 15f : 30f)) + { + npc.TargetClosest(); + + npc.ai[1] = 2f; + npc.ai[2] = 0f; + if (death) + npc.localAI[0] = 1f; + + npc.netUpdate = true; + } + } + } + + public static void CataclysmAI(NPC npc, Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Emit light + 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; + + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + Player player = Main.player[npc.target]; + + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } + + 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 += MathHelper.TwoPi; + else if (num842 > MathHelper.TwoPi) + num842 -= MathHelper.TwoPi; + + float num843 = 0.15f; + if (npc.rotation < num842) + { + if ((num842 - npc.rotation) > MathHelper.Pi) + npc.rotation -= num843; + else + npc.rotation += num843; + } + else if (npc.rotation > num842) + { + if ((npc.rotation - num842) > MathHelper.Pi) + npc.rotation += num843; + else + npc.rotation -= num843; + } + + if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) + npc.rotation = num842; + if (npc.rotation < 0f) + 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; + + if (!player.active || player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead) + { + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + npc.velocity.Y -= 0.1f; + if (npc.velocity.Y < -12f) + npc.velocity.Y = -12f; + + calamityGlobalNPC.newAI[0] = 1f; + + if (npc.timeLeft > 60) + npc.timeLeft = 60; + + if (npc.ai[1] != 0f) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } + return; + } + } + else + calamityGlobalNPC.newAI[0] = 0f; + + if (npc.ai[1] == 0f) + { + float num861 = 5f; + float num862 = 0.1f; + num861 += 2f * enrageScale; + num862 += 0.06f * enrageScale; + + if (provy) + { + num861 *= 1.25f; + num862 *= 1.25f; + } + + int num863 = 1; + if (npc.position.X + (npc.width / 2) < player.position.X + player.width) + num863 = -1; + + 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 * 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) + { + if (num866 > 300f) + num861 += 0.5f; + if (num866 > 400f) + num861 += 0.5f; + if (num866 > 500f) + num861 += 0.55f; + if (num866 > 600f) + num861 += 0.55f; + if (num866 > 700f) + num861 += 0.6f; + if (num866 > 800f) + num861 += 0.6f; + } + + num866 = num861 / num866; + num864 *= num866; + num865 *= num866; + + if (npc.velocity.X < num864) + { + npc.velocity.X += num862; + if (npc.velocity.X < 0f && num864 > 0f) + npc.velocity.X += num862; + } + else if (npc.velocity.X > num864) + { + npc.velocity.X -= num862; + if (npc.velocity.X > 0f && num864 < 0f) + npc.velocity.X -= num862; + } + if (npc.velocity.Y < num865) + { + npc.velocity.Y += num862; + if (npc.velocity.Y < 0f && num865 > 0f) + npc.velocity.Y += num862; + } + else if (npc.velocity.Y > num865) + { + npc.velocity.Y -= num862; + if (npc.velocity.Y > 0f && num865 < 0f) + npc.velocity.Y -= num862; + } + + npc.ai[2] += 1f; + if (npc.ai[2] >= (240f - (death ? 120f * (1f - lifeRatio) : 0f))) + { + npc.TargetClosest(); + npc.ai[1] = 1f; + npc.ai[2] = 0f; + npc.target = 255; + npc.netUpdate = true; + } + + 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; + if (npc.localAI[2] > 22f) + { + npc.localAI[2] = 0f; + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 34); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[1] += 1f; + if (revenge) + npc.localAI[1] += 0.5f; + + if (npc.localAI[1] > 12f) + { + npc.localAI[1] = 0f; + float num867 = NPC.AnyNPCs(ModContent.NPCType()) ? 4f : 6f; + num867 += enrageScale; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + 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; + num865 += npc.velocity.Y * 0.5f; + num864 += npc.velocity.X * 0.5f; + vector86.X -= num864; + vector86.Y -= num865; + Projectile.NewProjectile(vector86.X, vector86.Y, num864, num865, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, 0f); + } + } + } + } + else + { + if (npc.ai[1] == 1f) + { + Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 0); + npc.rotation = num842; + + float num870 = 14f + (death ? 4f * (1f - lifeRatio) : 0f); + num870 += 3f * enrageScale; + if (expertMode) + num870 += 2f; + if (revenge) + num870 += 2f; + if (provy) + num870 *= 1.15f; + + Vector2 vector87 = npc.Center; + float num871 = player.Center.X - vector87.X; + float num872 = player.Center.Y - vector87.Y; + float num873 = (float)Math.Sqrt(num871 * num871 + num872 * num872); + num873 = num870 / num873; + npc.velocity.X = num871 * num873; + npc.velocity.Y = num872 * num873; + npc.ai[1] = 2f; + return; + } + + if (npc.ai[1] == 2f) + { + npc.ai[2] += 1f + (death ? 0.5f * (1f - lifeRatio) : 0f); + if (expertMode) + npc.ai[2] += 0.25f; + if (revenge) + npc.ai[2] += 0.25f; + + if (npc.ai[2] >= 75f) + { + npc.velocity.X *= 0.93f; + npc.velocity.Y *= 0.93f; + + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) + npc.velocity.X = 0f; + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) + npc.velocity.Y = 0f; + } + else + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; + + if (npc.ai[2] >= 105f) + { + npc.ai[3] += 1f; + npc.ai[2] = 0f; + npc.target = 255; + npc.rotation = num842; + npc.TargetClosest(); + if (npc.ai[3] >= 3f) + { + npc.ai[1] = 0f; + npc.ai[3] = 0f; + return; + } + npc.ai[1] = 1f; + } + } + } + } + + public static void CatastropheAI(NPC npc, Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Emit light + 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; + + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + Player player = Main.player[npc.target]; + + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } + + 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 += MathHelper.TwoPi; + else if (num842 > MathHelper.TwoPi) + num842 -= MathHelper.TwoPi; + + float num843 = 0.15f; + if (npc.rotation < num842) + { + if ((num842 - npc.rotation) > MathHelper.Pi) + npc.rotation -= num843; + else + npc.rotation += num843; + } + else if (npc.rotation > num842) + { + if ((npc.rotation - num842) > MathHelper.Pi) + npc.rotation += num843; + else + npc.rotation -= num843; + } + + if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) + npc.rotation = num842; + if (npc.rotation < 0f) + 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; + + if (!player.active || player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead) + { + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + npc.velocity.Y -= 0.1f; + if (npc.velocity.Y < -12f) + npc.velocity.Y = -12f; + + calamityGlobalNPC.newAI[0] = 1f; + + if (npc.timeLeft > 60) + npc.timeLeft = 60; + + if (npc.ai[1] != 0f) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } + return; + } + } + else + calamityGlobalNPC.newAI[0] = 0f; + + if (npc.ai[1] == 0f) + { + float num861 = 4.5f; + float num862 = 0.2f; + num861 += 2f * enrageScale; + num862 += 0.1f * enrageScale; + + if (provy) + { + num861 *= 1.25f; + num862 *= 1.25f; + } + + int num863 = 1; + if (npc.Center.X < player.Center.X) + num863 = -1; + + Vector2 vector86 = npc.Center; + float num864 = player.Center.X + (num863 * 180) - vector86.X; + float num865 = player.Center.Y - vector86.Y; + float num866 = (float)Math.Sqrt(num864 * num864 + num865 * num865); + + if (expertMode || provy) + { + if (num866 > 300f) + num861 += 0.5f; + if (num866 > 400f) + num861 += 0.5f; + if (num866 > 500f) + num861 += 0.55f; + if (num866 > 600f) + num861 += 0.55f; + if (num866 > 700f) + num861 += 0.6f; + if (num866 > 800f) + num861 += 0.6f; + } + + num866 = num861 / num866; + num864 *= num866; + num865 *= num866; + + if (npc.velocity.X < num864) + { + npc.velocity.X += num862; + if (npc.velocity.X < 0f && num864 > 0f) + npc.velocity.X += num862; + } + else if (npc.velocity.X > num864) + { + npc.velocity.X -= num862; + if (npc.velocity.X > 0f && num864 < 0f) + npc.velocity.X -= num862; + } + if (npc.velocity.Y < num865) + { + npc.velocity.Y += num862; + if (npc.velocity.Y < 0f && num865 > 0f) + npc.velocity.Y += num862; + } + else if (npc.velocity.Y > num865) + { + npc.velocity.Y -= num862; + if (npc.velocity.Y > 0f && num865 < 0f) + npc.velocity.Y -= num862; + } + + npc.ai[2] += 1f; + if (npc.ai[2] >= (180f - (death ? 90f * (1f - lifeRatio) : 0f))) + { + npc.TargetClosest(); + npc.ai[1] = 1f; + npc.ai[2] = 0f; + npc.target = 255; + npc.netUpdate = true; + } + + bool fireDelay = npc.ai[2] > 120f || lifeRatio < 0.9f; + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && fireDelay) + { + npc.localAI[2] += 1f; + if (npc.localAI[2] > 36f) + { + npc.localAI[2] = 0f; + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 34); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[1] += 1f; + if (revenge) + npc.localAI[1] += 0.5f; + + if (npc.localAI[1] > 50f) + { + npc.localAI[1] = 0f; + float num867 = death ? 14f : 12f; + num867 += 3f * enrageScale; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + 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; + num865 += npc.velocity.Y * 0.5f; + num864 += npc.velocity.X * 0.5f; + vector86.X -= num864; + vector86.Y -= num865; + Projectile.NewProjectile(vector86.X, vector86.Y, num864, num865, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, 0f); + } + } + } + } + else + { + if (npc.ai[1] == 1f) + { + Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 0); + npc.rotation = num842; + + float num870 = (NPC.AnyNPCs(ModContent.NPCType()) ? 12f : 16f) + (death ? 4f * (1f - lifeRatio) : 0f); + num870 += 4f * enrageScale; + if (expertMode) + num870 += 2f; + if (revenge) + num870 += 2f; + if (provy) + num870 *= 1.15f; + + 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; + npc.ai[1] = 2f; + return; + } + + if (npc.ai[1] == 2f) + { + npc.ai[2] += 1f + (death ? 0.5f * (1f - lifeRatio) : 0f); + if (expertMode) + npc.ai[2] += 0.25f; + if (revenge) + npc.ai[2] += 0.25f; + + if (npc.ai[2] >= 60f) //50 + { + npc.velocity.X *= 0.93f; + npc.velocity.Y *= 0.93f; + + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) + npc.velocity.X = 0f; + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) + npc.velocity.Y = 0f; + } + else + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; + + if (npc.ai[2] >= 90f) //80 + { + npc.ai[3] += 1f; + npc.ai[2] = 0f; + npc.TargetClosest(); + npc.rotation = num842; + if (npc.ai[3] >= 4f) + { + npc.ai[1] = 0f; + npc.ai[3] = 0f; + return; + } + npc.ai[1] = 1f; + } + } + } + } + #endregion + + #region Astrum Aureus + public static void AstrumAureusAI(NPC npc, Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + bool postMoonLordBuff = NPC.downedMoonlord && !BossRushEvent.BossRushActive; + npc.damage = postMoonLordBuff ? npc.defDamage * 2 : npc.defDamage; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Variables + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + float shootTimer = 1f; + if (expertMode) + shootTimer += death ? (float)Math.Round(3f * (1f - lifeRatio)) : (float)Math.Round(2f * (1f - lifeRatio)); + + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + Player player = Main.player[npc.target]; + + // Direction npc.spriteDirection = (npc.direction > 0) ? 1 : -1; - // Phases - bool phase2 = lifeRatio < (revenge ? 0.85f : expertMode ? 0.8f : 0.75f); - bool phase3 = lifeRatio < (revenge ? 0.7f : expertMode ? 0.6f : 0.5f); - bool phase4 = lifeRatio < (revenge ? 0.5f : 0.4f) && expertMode; - bool phase5 = lifeRatio < 0.3f && revenge; - bool reduceFallSpeed = npc.velocity.Y > 0f && npc.Bottom.Y > player.Top.Y && npc.ai[0] == 4f; + // Phases + bool phase2 = lifeRatio < (revenge ? 0.85f : expertMode ? 0.8f : 0.75f); + bool phase3 = lifeRatio < (revenge ? 0.7f : expertMode ? 0.6f : 0.5f); + bool phase4 = lifeRatio < (revenge ? 0.5f : 0.4f) && expertMode; + bool phase5 = lifeRatio < 0.3f && revenge; + bool reduceFallSpeed = npc.velocity.Y > 0f && npc.Bottom.Y > player.Top.Y && npc.ai[0] == 4f; - // Despawn - bool despawnDistance = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; - if (!player.active || player.dead || despawnDistance) + // Despawn + bool despawnDistance = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; + if (!player.active || player.dead || despawnDistance) { npc.TargetClosest(false); player = Main.player[npc.target]; @@ -2497,31 +2497,31 @@ namespace CalamityMod.NPCs { npc.noTileCollide = true; - if (npc.velocity.Y < -3f) - npc.velocity.Y = -3f; - npc.velocity.Y += 0.1f; - if (npc.velocity.Y > 12f) - npc.velocity.Y = 12f; + if (npc.velocity.Y < -3f) + npc.velocity.Y = -3f; + npc.velocity.Y += 0.1f; + if (npc.velocity.Y > 12f) + npc.velocity.Y = 12f; - if (npc.timeLeft > 60) + if (npc.timeLeft > 60) npc.timeLeft = 60; - if (npc.ai[0] != 1f) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - return; + if (npc.ai[0] != 1f) + { + npc.ai[0] = 1f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } + return; } } else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + npc.timeLeft = 1800; - // Emit light when not Idle - if (npc.ai[0] != 1f) + // Emit light when not Idle + if (npc.ai[0] != 1f) 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 @@ -2531,64 +2531,64 @@ namespace CalamityMod.NPCs { npc.localAI[0] += npc.ai[0] == 2f ? 4f : shootTimer; - float astralFlameGateValue = phase4 ? 30f : 60f; - if (npc.localAI[0] >= astralFlameGateValue) - { - // Fire astral flames while teleporting - if (npc.ai[0] >= 5f && npc.ai[0] != 7) - { - npc.localAI[0] = 0f; - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 109); + float astralFlameGateValue = phase4 ? 30f : 60f; + if (npc.localAI[0] >= astralFlameGateValue) + { + // Fire astral flames while teleporting + if (npc.ai[0] >= 5f && npc.ai[0] != 7) + { + npc.localAI[0] = 0f; + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 109); - float velocity = death ? (8f + npc.localAI[2] * 0.025f) : 7f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (postMoonLordBuff) - damage *= 2; + float velocity = death ? (8f + npc.localAI[2] * 0.025f) : 7f; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + if (postMoonLordBuff) + damage *= 2; - float spreadLimit = (phase4 ? 100f : 50f) + enrageScale * 50f; - float randomSpread = (Main.rand.NextFloat() - 0.5f) * spreadLimit; - Vector2 spawnVector = new Vector2(npc.Center.X, npc.Center.Y - 80f); - Vector2 destination = new Vector2(spawnVector.X + randomSpread, spawnVector.Y - 100f); - Projectile.NewProjectile(npc.Center, Vector2.Normalize(destination - npc.Center) * velocity, type, damage, 0f, Main.myPlayer); - } + float spreadLimit = (phase4 ? 100f : 50f) + enrageScale * 50f; + float randomSpread = (Main.rand.NextFloat() - 0.5f) * spreadLimit; + Vector2 spawnVector = new Vector2(npc.Center.X, npc.Center.Y - 80f); + Vector2 destination = new Vector2(spawnVector.X + randomSpread, spawnVector.Y - 100f); + Projectile.NewProjectile(npc.Center, Vector2.Normalize(destination - npc.Center) * velocity, type, damage, 0f, Main.myPlayer); + } - npc.netUpdate = true; - } + npc.netUpdate = true; + } if (npc.localAI[0] >= 180f) { // Fire astral lasers while walking if (npc.ai[0] == 2f) { - npc.localAI[0] = 0f; - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 33); + npc.localAI[0] = 0f; + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 33); - float num179 = death ? 20f : 18.5f; - int maxProjectiles = malice ? 8 : death ? 6 : 4; - int spread = malice ? 80 : death ? 60 : 45; + float num179 = death ? 20f : 18.5f; + int maxProjectiles = malice ? 8 : death ? 6 : 4; + int spread = malice ? 80 : death ? 60 : 45; - if (!phase2) - { - maxProjectiles /= 2; - spread /= 2; - } + if (!phase2) + { + maxProjectiles /= 2; + spread /= 2; + } 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 + player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); + float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); num183 = num179 / num183; num180 *= num183; num182 *= num183; - value9.X += num180; - value9.Y += num182; + value9.X += num180; + value9.Y += num182; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (postMoonLordBuff) - damage *= 2; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + if (postMoonLordBuff) + damage *= 2; for (int i = 0; i < maxProjectiles; i++) { @@ -2603,21 +2603,21 @@ namespace CalamityMod.NPCs Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer); } - npc.netUpdate = true; + npc.netUpdate = true; } } } } - else - npc.localAI[0] = 0f; + else + npc.localAI[0] = 0f; - // Start up - if (npc.ai[0] == 0f) + // Start up + if (npc.ai[0] == 0f) { npc.ai[0] = 1f; npc.netUpdate = true; - CustomGravity(); - } + CustomGravity(); + } // Idle else if (npc.ai[0] == 1f) @@ -2629,32 +2629,32 @@ namespace CalamityMod.NPCs npc.ai[1] += 1f; if (npc.ai[1] >= 120f || malice) { - // Stop colliding with tiles - npc.noTileCollide = true; + // Stop colliding with tiles + npc.noTileCollide = true; - // Set AI to next phase (Walk) and reset other AI - npc.TargetClosest(); - npc.ai[0] = 2f; + // Set AI to next phase (Walk) and reset other AI + npc.TargetClosest(); + npc.ai[0] = 2f; npc.ai[1] = 0f; npc.netUpdate = true; } - else - CustomGravity(); - } + else + CustomGravity(); + } // Walk else if (npc.ai[0] == 2f) { - // Set walking speed + // Set walking speed float num823 = 6f; - num823 += 4f * enrageScale; - if (expertMode) - num823 += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - if (revenge) - num823 += Math.Abs(npc.Center.X - player.Center.X) * 0.0025f; + num823 += 4f * enrageScale; + if (expertMode) + num823 += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + if (revenge) + num823 += Math.Abs(npc.Center.X - player.Center.X) * 0.0025f; - // Set walking direction - if (Math.Abs(npc.Center.X - player.Center.X) < 200f) + // Set walking direction + if (Math.Abs(npc.Center.X - player.Center.X) < 200f) { npc.velocity.X *= 0.9f; if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) @@ -2671,51 +2671,51 @@ namespace CalamityMod.NPCs npc.velocity.X = (npc.velocity.X * 20f - num823) / 21f; } - if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height) && player.position.Y <= npc.position.Y + npc.height) - { - CustomGravity(); - npc.noTileCollide = false; - } - else - { - npc.noTileCollide = true; - // 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 - (num854 / 2), npc.position.Y + npc.height - num855); + if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height) && player.position.Y <= npc.position.Y + npc.height) + { + CustomGravity(); + npc.noTileCollide = false; + } + else + { + npc.noTileCollide = true; + // 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 - (num854 / 2), npc.position.Y + npc.height - num855); - bool flag52 = false; - 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; + bool flag52 = false; + 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) - { - npc.velocity.Y += 0.5f; - } - else if (Collision.SolidCollision(position2, num854, num855)) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = 0f; + if (flag52) + { + npc.velocity.Y += 0.5f; + } + else if (Collision.SolidCollision(position2, num854, num855)) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y = 0f; - if (npc.velocity.Y > -0.2) - npc.velocity.Y -= 0.025f; - else - npc.velocity.Y -= 0.2f; + if (npc.velocity.Y > -0.2) + npc.velocity.Y -= 0.025f; + else + npc.velocity.Y -= 0.2f; - if (npc.velocity.Y < -4f) - npc.velocity.Y = -4f; - } - else - { - if (npc.velocity.Y < 0f) - npc.velocity.Y = 0f; + if (npc.velocity.Y < -4f) + npc.velocity.Y = -4f; + } + else + { + if (npc.velocity.Y < 0f) + npc.velocity.Y = 0f; - if (npc.velocity.Y < 0.1) - npc.velocity.Y += 0.025f; - else - npc.velocity.Y += 0.5f; - } - } + if (npc.velocity.Y < 0.1) + npc.velocity.Y += 0.025f; + else + npc.velocity.Y += 0.5f; + } + } // Walk for a maximum of 6 seconds npc.ai[1] += 1f; @@ -2724,9 +2724,9 @@ namespace CalamityMod.NPCs // Collide with tiles again npc.noTileCollide = false; - // Set AI to next phase (Jump) and reset other AI - npc.TargetClosest(); - npc.ai[0] = 3f; + // Set AI to next phase (Jump) and reset other AI + npc.TargetClosest(); + npc.ai[0] = 3f; npc.ai[1] = 0f; npc.netUpdate = true; } @@ -2739,7 +2739,7 @@ namespace CalamityMod.NPCs // Jump else if (npc.ai[0] == 3f) { - npc.noTileCollide = false; + npc.noTileCollide = false; if (npc.velocity.Y == 0f) { @@ -2748,60 +2748,60 @@ namespace CalamityMod.NPCs // Half second delay before jumping npc.ai[1] += 1f; - if (npc.ai[1] >= 30f) - { - npc.ai[1] = -20f; - } - else if (npc.ai[1] == -1f) - { - // Set jump velocity, reset and set AI to next phase (Stomp) - float velocityX = 9f; - velocityX += 6f * enrageScale; - if (expertMode) - velocityX += death ? 4.5f * (1f - lifeRatio) : 3f * (1f - lifeRatio); + if (npc.ai[1] >= 30f) + { + npc.ai[1] = -20f; + } + else if (npc.ai[1] == -1f) + { + // Set jump velocity, reset and set AI to next phase (Stomp) + float velocityX = 9f; + velocityX += 6f * enrageScale; + if (expertMode) + velocityX += death ? 4.5f * (1f - lifeRatio) : 3f * (1f - lifeRatio); - float playerLocation = npc.Center.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; + float playerLocation = npc.Center.X - player.Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; - npc.velocity.X = velocityX * npc.direction; + npc.velocity.X = velocityX * npc.direction; - float distanceBelowTarget = npc.position.Y - (player.position.Y + 80f); + float distanceBelowTarget = npc.position.Y - (player.position.Y + 80f); - if (revenge) - { - float multiplier = 0.001f + 0.0005f * enrageScale; - if (distanceBelowTarget > 0f) - calamityGlobalNPC.newAI[0] = 1f + distanceBelowTarget * multiplier; + if (revenge) + { + float multiplier = 0.001f + 0.0005f * enrageScale; + if (distanceBelowTarget > 0f) + calamityGlobalNPC.newAI[0] = 1f + distanceBelowTarget * multiplier; - float speedMultLimit = 2f + 1f * enrageScale; - if (calamityGlobalNPC.newAI[0] > speedMultLimit) - calamityGlobalNPC.newAI[0] = speedMultLimit; - } + float speedMultLimit = 2f + 1f * enrageScale; + if (calamityGlobalNPC.newAI[0] > speedMultLimit) + calamityGlobalNPC.newAI[0] = speedMultLimit; + } - if (expertMode) - { - if (player.position.Y < npc.Bottom.Y) - npc.velocity.Y = (phase5 && (npc.ai[2] < 2f || npc.ai[2] == 3f)) ? -1f : -14.5f; - else - npc.velocity.Y = 1f; + if (expertMode) + { + if (player.position.Y < npc.Bottom.Y) + npc.velocity.Y = (phase5 && (npc.ai[2] < 2f || npc.ai[2] == 3f)) ? -1f : -14.5f; + else + npc.velocity.Y = 1f; - npc.noTileCollide = true; - } - else - npc.velocity.Y = (phase5 && (npc.ai[2] < 2f || npc.ai[2] == 3f)) ? -1f : -14.5f; + npc.noTileCollide = true; + } + else + npc.velocity.Y = (phase5 && (npc.ai[2] < 2f || npc.ai[2] == 3f)) ? -1f : -14.5f; - if (calamityGlobalNPC.newAI[0] > 1f) - npc.velocity.Y *= calamityGlobalNPC.newAI[0]; + if (calamityGlobalNPC.newAI[0] > 1f) + npc.velocity.Y *= calamityGlobalNPC.newAI[0]; - npc.ai[0] = 4f; - npc.ai[1] = 0f; + npc.ai[0] = 4f; + npc.ai[1] = 0f; - npc.netUpdate = true; - } + npc.netUpdate = true; + } } - CustomGravity(); - } + CustomGravity(); + } // Stomp else if (npc.ai[0] == 4f) @@ -2811,29 +2811,29 @@ namespace CalamityMod.NPCs // Play stomp sound Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LegStomp"), (int)npc.position.X, (int)npc.position.Y); - // Stomp and jump again, if stomped twice then reset and set AI to next phase (Teleport or Idle) - npc.TargetClosest(); - npc.ai[2] += 1f; - float maxStompAmt = phase5 ? 5f : 3f; - if (npc.ai[2] >= maxStompAmt) - { - npc.ai[0] = phase2 ? 5f : 1f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - else - { - float playerLocation = npc.Center.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; + // Stomp and jump again, if stomped twice then reset and set AI to next phase (Teleport or Idle) + npc.TargetClosest(); + npc.ai[2] += 1f; + float maxStompAmt = phase5 ? 5f : 3f; + if (npc.ai[2] >= maxStompAmt) + { + npc.ai[0] = phase2 ? 5f : 1f; + npc.ai[2] = 0f; + npc.netUpdate = true; + } + else + { + float playerLocation = npc.Center.X - player.Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; - npc.ai[0] = 3f; - npc.netUpdate = true; - } + npc.ai[0] = 3f; + npc.netUpdate = true; + } - calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[0] = 0f; - // Spawn dust for visual effect - for (int num622 = (int)npc.position.X - 20; num622 < (int)npc.position.X + npc.width + 40; num622 += 20) + // Spawn dust for visual effect + for (int num622 = (int)npc.position.X - 20; num622 < (int)npc.position.X + npc.width + 40; num622 += 20) { for (int num623 = 0; num623 < 4; num623++) { @@ -2842,93 +2842,93 @@ namespace CalamityMod.NPCs } } - // Fire lasers on stomp - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 33); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float num179 = death ? 20f : 18.5f; - int maxProjectiles = malice ? 12 : death ? 6 : 4; - int spread = malice ? 120 : death ? 60 : 45; - if (phase5) - { - maxProjectiles = (int)(maxProjectiles * 1.5); - spread = (int)Math.Round(spread * 1.5); - } + // Fire lasers on stomp + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 33); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float num179 = death ? 20f : 18.5f; + int maxProjectiles = malice ? 12 : death ? 6 : 4; + int spread = malice ? 120 : death ? 60 : 45; + if (phase5) + { + maxProjectiles = (int)(maxProjectiles * 1.5); + spread = (int)Math.Round(spread * 1.5); + } - 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 + player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (postMoonLordBuff) - damage *= 2; + 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 + player.height * 0.5f - value9.Y - num181; + float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); + num183 = num179 / num183; + num180 *= num183; + num182 *= num183; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + if (postMoonLordBuff) + damage *= 2; - value9.X += num180; - value9.Y += num182; - for (int i = 0; i < maxProjectiles; i++) - { - 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 += Main.rand.Next(-spread, spread + 1); - num182 += Main.rand.Next(-spread, spread + 1); - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); - } + value9.X += num180; + value9.Y += num182; + for (int i = 0; i < maxProjectiles; i++) + { + 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 += Main.rand.Next(-spread, spread + 1); + num182 += Main.rand.Next(-spread, spread + 1); + num180 *= num183; + num182 *= num183; + Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); + } - npc.netUpdate = true; - } + npc.netUpdate = true; + } } else { - // Set velocities while falling, this happens before the stomp - // Fall through - if (!player.dead && expertMode) - { - if ((player.position.Y > npc.Bottom.Y && npc.velocity.Y > 0f) || (player.position.Y < npc.Bottom.Y && npc.velocity.Y < 0f)) - npc.noTileCollide = true; - else if ((npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) || (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height))) - npc.noTileCollide = false; - } + // Set velocities while falling, this happens before the stomp + // Fall through + if (!player.dead && expertMode) + { + if ((player.position.Y > npc.Bottom.Y && npc.velocity.Y > 0f) || (player.position.Y < npc.Bottom.Y && npc.velocity.Y < 0f)) + npc.noTileCollide = true; + else if ((npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) || (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height))) + npc.noTileCollide = false; + } - if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + 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 (npc.Bottom.Y < player.position.Y) - { + if (npc.Bottom.Y < player.position.Y) + { float fallSpeed = 1.2f; - fallSpeed += 0.8f * enrageScale; - if (expertMode) - fallSpeed += death ? 0.6f * (1f - lifeRatio) : 0.4f * (1f - lifeRatio); + fallSpeed += 0.8f * enrageScale; + if (expertMode) + fallSpeed += death ? 0.6f * (1f - lifeRatio) : 0.4f * (1f - lifeRatio); - if (calamityGlobalNPC.newAI[0] > 1f) - fallSpeed *= calamityGlobalNPC.newAI[0]; + if (calamityGlobalNPC.newAI[0] > 1f) + fallSpeed *= calamityGlobalNPC.newAI[0]; - npc.velocity.Y += fallSpeed; - } + npc.velocity.Y += fallSpeed; + } } else { - float velocityXChange = 0.2f + Math.Abs(npc.Center.X - player.Center.X) * 0.0001f; - velocityXChange += 0.1f * enrageScale; + float velocityXChange = 0.2f + Math.Abs(npc.Center.X - player.Center.X) * 0.0001f; + velocityXChange += 0.1f * enrageScale; - if (npc.direction < 0) + if (npc.direction < 0) npc.velocity.X -= velocityXChange; else if (npc.direction > 0) npc.velocity.X += velocityXChange; float num626 = 12f; - num626 += 8f * enrageScale; - if (expertMode) - num626 += death ? 4.5f * (1f - lifeRatio) : 3f * (1f - lifeRatio); + num626 += 8f * enrageScale; + if (expertMode) + num626 += death ? 4.5f * (1f - lifeRatio) : 3f * (1f - lifeRatio); if (npc.velocity.X < -num626) npc.velocity.X = -num626; @@ -2936,32 +2936,32 @@ namespace CalamityMod.NPCs npc.velocity.X = num626; } - CustomGravity(); - } + CustomGravity(); + } } // Teleport else if (npc.ai[0] == 5f) { - // Don't deal damage - npc.damage = 0; + // Don't deal damage + npc.damage = 0; - // Slow down - npc.velocity.X *= 0.9f; + // Slow down + npc.velocity.X *= 0.9f; // Spawn slimes and start teleport if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[1] += 1f; - if (death) - npc.localAI[2] += 1f + 0.33f * (1f - lifeRatio); - - if (phase3) - { - npc.localAI[1] += 1f; - if (death) - npc.localAI[2] += 1f + 0.33f * (1f - lifeRatio); - } + if (death) + npc.localAI[2] += 1f + 0.33f * (1f - lifeRatio); + + if (phase3) + { + npc.localAI[1] += 1f; + if (death) + npc.localAI[2] += 1f + 0.33f * (1f - lifeRatio); + } if (npc.localAI[1] >= ((malice ? 120f : 240f) - (death ? 60f * (1f - lifeRatio) : 0f))) { @@ -2970,25 +2970,25 @@ namespace CalamityMod.NPCs if (NPC.CountNPCS(ModContent.NPCType()) > 1) spawnFlag = false; - if (spawnFlag && Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 25, ModContent.NPCType()); + if (spawnFlag && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 25, ModContent.NPCType()); - if (death) - { - int damageAmt = npc.lifeMax / 100; - npc.life -= damageAmt; - if (npc.life < 1) - npc.life = 1; + if (death) + { + int damageAmt = npc.lifeMax / 100; + npc.life -= damageAmt; + if (npc.life < 1) + npc.life = 1; - npc.HealEffect(-damageAmt, true); - npc.netUpdate = true; - } - } + npc.HealEffect(-damageAmt, true); + npc.netUpdate = true; + } + } - // Reset localAI and find a teleport destination - npc.TargetClosest(); - npc.localAI[1] = 0f; + // Reset localAI and find a teleport destination + npc.TargetClosest(); + npc.localAI[1] = 0f; int num1249 = 0; int num1250; int num1251; @@ -3022,17 +3022,17 @@ namespace CalamityMod.NPCs // Mid-teleport else if (npc.ai[0] == 6f) { - if (death) - npc.localAI[2] += 1f + 0.33f * (1f - lifeRatio); + if (death) + npc.localAI[2] += 1f + 0.33f * (1f - lifeRatio); - if (phase3) - { - if (death) - npc.localAI[2] += 1f + 0.33f * (1f - lifeRatio); - } + if (phase3) + { + if (death) + npc.localAI[2] += 1f + 0.33f * (1f - lifeRatio); + } - // Turn invisible - npc.alpha += 10; + // Turn invisible + npc.alpha += 10; if (npc.alpha >= 255) { // Set position to teleport destination @@ -3042,7 +3042,7 @@ namespace CalamityMod.NPCs // Reset alpha and set AI to next phase (End of teleport) npc.alpha = 255; npc.ai[0] = 7f; - npc.localAI[2] = 0f; + npc.localAI[2] = 0f; npc.netUpdate = true; } @@ -3074,21 +3074,21 @@ namespace CalamityMod.NPCs if (NPC.CountNPCS(ModContent.NPCType()) > 1) spawnFlag = false; - if (spawnFlag && Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 25, ModContent.NPCType()); + if (spawnFlag && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 25, ModContent.NPCType()); - if (death) - { - int damageAmt = npc.lifeMax / 100; - npc.life -= damageAmt; - if (npc.life < 1) - npc.life = 1; + if (death) + { + int damageAmt = npc.lifeMax / 100; + npc.life -= damageAmt; + if (npc.life < 1) + npc.life = 1; - npc.HealEffect(-damageAmt, true); - npc.netUpdate = true; - } - } + npc.HealEffect(-damageAmt, true); + npc.netUpdate = true; + } + } // Reset alpha and set AI to next phase (Idle) npc.alpha = 0; @@ -3113,2041 +3113,2041 @@ namespace CalamityMod.NPCs } } - void CustomGravity() - { - float gravity = 0.36f + 0.12f * enrageScale; - float maxFallSpeed = reduceFallSpeed ? 12f : 12f + 4f * enrageScale; + void CustomGravity() + { + float gravity = 0.36f + 0.12f * enrageScale; + float maxFallSpeed = reduceFallSpeed ? 12f : 12f + 4f * enrageScale; - if (calamityGlobalNPC.newAI[0] > 1f && !reduceFallSpeed) - maxFallSpeed *= calamityGlobalNPC.newAI[0]; + if (calamityGlobalNPC.newAI[0] > 1f && !reduceFallSpeed) + maxFallSpeed *= calamityGlobalNPC.newAI[0]; - npc.velocity.Y += gravity; - if (npc.velocity.Y > maxFallSpeed) - npc.velocity.Y = maxFallSpeed; - } + npc.velocity.Y += gravity; + if (npc.velocity.Y > maxFallSpeed) + npc.velocity.Y = maxFallSpeed; + } } - #endregion - - #region Astrum Deus - public static void AstrumDeusAI(NPC npc, Mod mod, bool head) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Difficulty variables - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - float enrageScale = BossRushEvent.BossRushActive ? 0.5f : 0f; - if (Main.dayTime || malice) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1.5f; - } - - // Deus cannot hit for 3 seconds or while invulnerable - if (calamityGlobalNPC.newAI[1] < 180f || npc.dontTakeDamage) - npc.damage = 0; - else - npc.damage = npc.defDamage; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - bool increaseSpeed = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles; - bool increaseSpeedMore = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; - - // Despawn safety, make sure to target another player if the current player target is too far away - if (increaseSpeedMore && head) - npc.TargetClosest(); - - // Inflict Extreme Gravity to nearby players - if (revenge) - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); - } - } - - // Life - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Phases based on life percentage - bool halfHealth = lifeRatio < 0.5f; - bool doubleWormPhase = calamityGlobalNPC.newAI[0] != 0f; - bool startFlightPhase = lifeRatio < 0.8f || death || doubleWormPhase; - bool phase2 = lifeRatio < 0.5f && doubleWormPhase && expertMode; - bool phase3 = lifeRatio < 0.2f && doubleWormPhase && expertMode; - bool splittingMines = lifeRatio < 0.7f; - bool movingMines = lifeRatio < 0.3f && doubleWormPhase && expertMode; - bool deathModeEnragePhase_Head = calamityGlobalNPC.newAI[0] == 3f; - bool deathModeEnragePhase_BodyAndTail = false; - - // 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing - float resistanceTime = doubleWormPhase ? 300f : 600f; - if (calamityGlobalNPC.newAI[1] < resistanceTime) - calamityGlobalNPC.newAI[1] += 1f; - - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < resistanceTime; - - // Flight timer - float aiSwitchTimer = doubleWormPhase ? 1200f : 1800f; - calamityGlobalNPC.newAI[3] += 1f; - if (calamityGlobalNPC.newAI[3] >= aiSwitchTimer) - calamityGlobalNPC.newAI[3] = 0f; - - // Phase for flying at the player - bool flyAtTarget = calamityGlobalNPC.newAI[3] >= (aiSwitchTimer * 0.5f) && startFlightPhase; - - // Length of worms - int phase1Length = death ? 80 : revenge ? 70 : expertMode ? 60 : 50; - int phase2Length = phase1Length / 2; - int maxLength = doubleWormPhase ? phase2Length : phase1Length; - - // Split into two worms - if (head) - { - float splitAnimationTime = 180f; - bool oneWormAlive = NPC.CountNPCS(ModContent.NPCType()) < 2; - bool deathModeFinalWormEnrage = death && doubleWormPhase && oneWormAlive && calamityGlobalNPC.newAI[1] >= resistanceTime; - if (deathModeFinalWormEnrage) - { - if (calamityGlobalNPC.newAI[0] != 3f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AstrumDeusSplit"), player.Center); - calamityGlobalNPC.newAI[0] = 3f; - npc.defense = 12; - calamityGlobalNPC.DR = 0.075f; - - // Despawns the other deus worm segments - int bodyID = ModContent.NPCType(); - int tailID = ModContent.NPCType(); - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC wormseg = Main.npc[i]; - if (!wormseg.active) - continue; - - if ((wormseg.type == bodyID || wormseg.type == tailID) && Main.npc[(int)wormseg.ai[2]].Calamity().newAI[0] != 3f) - { - wormseg.life = 0; - wormseg.active = false; - } - } - } - - calamityGlobalNPC.newAI[2] += 10f; - if (calamityGlobalNPC.newAI[2] > 162f) - calamityGlobalNPC.newAI[2] = 162f; - - npc.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f); - } - - bool despawnRemainingWorm = doubleWormPhase && oneWormAlive && !death; - if ((halfHealth && calamityGlobalNPC.newAI[0] == 0f) || despawnRemainingWorm) - { - npc.dontTakeDamage = true; - - calamityGlobalNPC.newAI[2] += despawnRemainingWorm ? 10f : 1f; - npc.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f); - - bool despawning = calamityGlobalNPC.newAI[2] == splitAnimationTime; - - // - // CODE TWEAKED BY: OZZATRON - // September 20th, 2020 - // reason: fixing Astrum Deus death mode NPC cap bug - // - - // Despawn the unsplit Astrum Deus and spawn two half-size Astrum Deus worms. - if (despawning) - { - // If this is already a split worm (newAI[0] != 0f) then don't do anything. At all. - if (doubleWormPhase) - return; - - // Mark all existing body and tail segments as inactive. This instantly frees up their NPC slots for the freshly spawned worms. - int bodyID = ModContent.NPCType(); - int tailID = ModContent.NPCType(); - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC wormseg = Main.npc[i]; - if (!wormseg.active) - continue; - if (wormseg.type == bodyID || wormseg.type == tailID) - { - wormseg.life = 0; - wormseg.active = false; - } - } - - // The unsplit Astrum Deus worm head will die next frame. - npc.life = 0; - - // Do not spawn worms client side. The server handles this. - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Now that the original worm doesn't exist, startCount can be zero. - // int startCount = npc.whoAmI + phase1Length + 1; - int startIndexHeadOne = 1; - int headOneID = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, npc.type, startIndexHeadOne); - Main.npc[headOneID].Calamity().newAI[0] = 1f; - Main.npc[headOneID].velocity = Vector2.Normalize(player.Center - Main.npc[headOneID].Center) * 16f; - Main.npc[headOneID].timeLeft *= 20; - Main.npc[headOneID].netUpdate = true; - - // On server, immediately send the correct extra AI of this head to clients. - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.SyncCalamityNPCAIArray); - netMessage.Write((byte)headOneID); - netMessage.Write(Main.npc[headOneID].Calamity().newAI[0]); - netMessage.Write(Main.npc[headOneID].Calamity().newAI[1]); - netMessage.Write(Main.npc[headOneID].Calamity().newAI[2]); - netMessage.Write(Main.npc[headOneID].Calamity().newAI[3]); - netMessage.Send(); - } - - // Make sure the second split worm is also contiguous. - int startIndexHeadTwo = startIndexHeadOne + phase2Length + 1; - int headTwoID = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, npc.type, startIndexHeadTwo); - Main.npc[headTwoID].Calamity().newAI[0] = 2f; - Main.npc[headTwoID].Calamity().newAI[3] = 600f; - Main.npc[headTwoID].velocity = Vector2.Normalize(player.Center - Main.npc[headTwoID].Center) * 16f; - Main.npc[headTwoID].timeLeft *= 20; - Main.npc[headTwoID].netUpdate = true; - - // On server, immediately send the correct extra AI of this head to clients. - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.SyncCalamityNPCAIArray); - netMessage.Write((byte)headTwoID); - netMessage.Write(Main.npc[headTwoID].Calamity().newAI[0]); - netMessage.Write(Main.npc[headTwoID].Calamity().newAI[1]); - netMessage.Write(Main.npc[headTwoID].Calamity().newAI[2]); - netMessage.Write(Main.npc[headTwoID].Calamity().newAI[3]); - netMessage.Send(); - } - - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AstrumDeusSplit"), player.Center); - } - return; - } - } - } - - // Copy dontTakeDamage and Opacity from head - else - { - npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; - npc.Opacity = Main.npc[(int)npc.ai[2]].Opacity; - deathModeEnragePhase_BodyAndTail = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 3f; - - if (deathModeEnragePhase_BodyAndTail) - { - npc.defense = 25; - calamityGlobalNPC.DR = 0.15f; - } - } - - // Set worm variable - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Emit light - 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) && !npc.dontTakeDamage) - { - // Alpha changes - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - - // Check if other segments are still alive, if not, die - if (npc.type != ModContent.NPCType()) - { - bool shouldDespawn = true; - int headType = ModContent.NPCType(); - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].type != headType || !Main.npc[i].active) - continue; - shouldDespawn = false; - break; - } - if (shouldDespawn) - { - if (Main.npc.IndexInRange((int)npc.ai[1]) && Main.npc[(int)npc.ai[1]].active && Main.npc[(int)npc.ai[1]].life > 0) - shouldDespawn = false; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - npc.netUpdate = true; - } - } - - // Direction - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; - else if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - - // Head code - if (head) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.ai[0] == 0f) - { - int Previous = npc.whoAmI; - int bodyType = ModContent.NPCType(); - int tailType = ModContent.NPCType(); - for (int num36 = 0; num36 < maxLength; num36++) - { - int lol; - if (num36 >= 0 && num36 < maxLength - 1) - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), bodyType, npc.whoAmI); - else - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), tailType, npc.whoAmI); - - if (num36 % 2 == 0) - Main.npc[lol].localAI[3] = 1f; - - Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].Calamity().newAI[0] = Main.npc[Previous].Calamity().newAI[0]; - Main.npc[lol].Calamity().newAI[3] = Main.npc[Previous].Calamity().newAI[3]; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.SyncCalamityNPCAIArray); - netMessage.Write((byte)lol); - netMessage.Write(Main.npc[lol].Calamity().newAI[0]); - netMessage.Write(Main.npc[lol].Calamity().newAI[1]); - netMessage.Write(Main.npc[lol].Calamity().newAI[2]); - netMessage.Write(Main.npc[lol].Calamity().newAI[3]); - netMessage.Send(); - } - Main.npc[lol].ai[2] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); - Previous = lol; - } - } - } - } - - if (head) - { - int num12 = (int)(npc.position.X / 16f) - 1; - int num13 = (int)((npc.position.X + npc.width) / 16f) + 2; - int num14 = (int)(npc.position.Y / 16f) - 1; - int num15 = (int)((npc.position.Y + npc.height) / 16f) + 2; - - if (num12 < 0) - num12 = 0; - if (num13 > Main.maxTilesX) - num13 = Main.maxTilesX; - if (num14 < 0) - num14 = 0; - if (num15 > Main.maxTilesY) - num15 = Main.maxTilesY; - - // Fly or not - bool flag2 = flyAtTarget; - if (!flag2) - { - for (int k = num12; k < num13; k++) - { - for (int l = num14; l < num15; l++) - { - 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 = 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; - } - } - } - } - } - - // Start flying if target is not within a certain distance - if (!flag2) - { - npc.localAI[1] = 1f; - - if (head) - { - Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num16 = 200; - int heightReduction = death ? 130 : (int)(130f * (1f - lifeRatio)); - int height = 400 - heightReduction; - bool flag3 = true; - - if (npc.position.Y > player.position.Y) - { - for (int m = 0; m < Main.maxPlayers; m++) - { - if (Main.player[m].active) - { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, height); - if (rectangle.Intersects(rectangle2)) - { - flag3 = false; - break; - } - } - } - if (flag3) - flag2 = true; - } - } - } - else - npc.localAI[1] = 0f; - - // Despawn - float fallSpeed = deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f; - if (player.dead) - { - flag2 = false; - float velocity = 2f; - npc.velocity.Y -= velocity; - if ((double)npc.position.Y < Main.topWorld + 16f) - { - fallSpeed = deathModeEnragePhase_Head ? 38f : death ? 35f : 32f; - npc.velocity.Y -= velocity; - } - - int headType = ModContent.NPCType(); - int bodyType = ModContent.NPCType(); - int tailType = ModContent.NPCType(); - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int num957 = 0; num957 < Main.maxNPCs; num957++) - { - if (Main.npc[num957].type == headType || Main.npc[num957].type == bodyType || Main.npc[num957].type == tailType) - { - Main.npc[num957].active = false; - Main.npc[num957].netUpdate = true; - } - } - } - } - - float fallSpeedBoost = 5f * (1f - lifeRatio); - fallSpeed += fallSpeedBoost; - fallSpeed += 4f * enrageScale; - - // Speed and movement - float speedBoost = death ? (0.1f * (1f - lifeRatio)) : (0.13f * (1f - lifeRatio)); - float turnSpeedBoost = death ? (0.18f * (1f - lifeRatio)) : (0.2f * (1f - lifeRatio)); - float speed = (deathModeEnragePhase_Head ? 0.2f : death ? 0.18f : 0.13f) + speedBoost; - float turnSpeed = (deathModeEnragePhase_Head ? 0.27f : death ? 0.25f : 0.2f) + turnSpeedBoost; - speed += 0.05f * enrageScale; - turnSpeed += 0.08f * enrageScale; - - if (flyAtTarget) - { - float speedMultiplier = deathModeEnragePhase_Head ? 1.25f : doubleWormPhase ? (phase3 ? 1.25f : phase2 ? 1.2f : 1.15f) : 1f; - speed *= speedMultiplier; - } - - if (revenge) - { - float revMultiplier = 1.1f; - speed *= revMultiplier; - turnSpeed *= revMultiplier; - fallSpeed *= revMultiplier; - } - - speed *= increaseSpeedMore ? 4f : increaseSpeed ? 2f : 1f; - turnSpeed *= increaseSpeedMore ? 4f : increaseSpeed ? 2f : 1f; - - 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; - - if (!flag2) - { - npc.velocity.Y += 0.15f; - if (npc.velocity.Y > fallSpeed) - npc.velocity.Y = fallSpeed; - - 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; - else - npc.velocity.X += speed * 1.1f; - } - else if (npc.velocity.Y == fallSpeed) - { - if (npc.velocity.X < num20) - npc.velocity.X += speed; - else if (npc.velocity.X > num20) - npc.velocity.X -= speed; - } - else if (npc.velocity.Y > 4f) - { - if (npc.velocity.X < 0f) - npc.velocity.X += speed * 0.9f; - else - npc.velocity.X -= speed * 0.9f; - } - } - else - { - float num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = fallSpeed / num22; - num20 *= num27; - num21 *= num27; - - bool flag6 = false; - if (flyAtTarget) - { - if (((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f) || (npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > speed / 2f && num22 < 400f) - { - flag6 = true; - - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < fallSpeed) - npc.velocity *= 1.1f; - } - - if (npc.position.Y > player.position.Y) - { - flag6 = true; - - if (Math.Abs(npc.velocity.X) < fallSpeed / 2f) - { - if (npc.velocity.X == 0f) - npc.velocity.X -= npc.direction; - - npc.velocity.X *= 1.1f; - } - else if (npc.velocity.Y > -fallSpeed) - npc.velocity.Y -= speed; - } - } - - if (!flag6) - { - if (!flyAtTarget) - { - if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) - { - if (npc.velocity.X < num20) - npc.velocity.X += turnSpeed; - else if (npc.velocity.X > num20) - npc.velocity.X -= turnSpeed; - if (npc.velocity.Y < num21) - npc.velocity.Y += turnSpeed; - else if (npc.velocity.Y > num21) - npc.velocity.Y -= turnSpeed; - } - } - - if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) - { - if (npc.velocity.X < num20) - npc.velocity.X += speed; - else if (npc.velocity.X > num20) - npc.velocity.X -= speed; - if (npc.velocity.Y < num21) - npc.velocity.Y += speed; - else if (npc.velocity.Y > num21) - npc.velocity.Y -= speed; - - 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 (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; - else - npc.velocity.X -= speed * 2f; - } - } - else if (num25 > num26) - { - if (npc.velocity.X < num20) - npc.velocity.X += speed * 1.1f; - else if (npc.velocity.X > num20) - npc.velocity.X -= speed * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += speed; - else - npc.velocity.Y -= speed; - } - } - else - { - if (npc.velocity.Y < num21) - npc.velocity.Y += speed * 1.1f; - else if (npc.velocity.Y > num21) - npc.velocity.Y -= speed * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X += speed; - else - npc.velocity.X -= speed; - } - } - } - } - - if (flag2) - { - if (npc.localAI[0] != 1f) - npc.netUpdate = true; - - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - npc.netUpdate = true; - - npc.localAI[0] = 0f; - } - - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - } - - // Only the main worm body and tail use this code - else - { - // Shoot lasers - if (npc.type == ModContent.NPCType() && Main.netMode != NetmodeID.MultiplayerClient) - { - int shootTime = (doubleWormPhase && expertMode) ? 2 : 1; - npc.localAI[0] += 1f; - float shootProjectile = 400 / shootTime; - float timer = npc.ai[0] + 15f; - float divisor = timer + shootProjectile; - if (!flyAtTarget || deathModeEnragePhase_BodyAndTail) - { - if (npc.localAI[0] % divisor == 0f && npc.ai[0] % 2f == 0f) - { - npc.TargetClosest(); - - if (deathModeEnragePhase_BodyAndTail) - { - Vector2 velocity = Vector2.Zero; - if (movingMines) - { - Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - vector15.Normalize(); - vector15 *= Main.rand.Next(90, 121) * 0.01f; - velocity = vector15; - } - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float split = (splittingMines && npc.ai[0] % 3f == 0f) ? 1f : 0f; - Projectile.NewProjectile(npc.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f); - } - - if (Vector2.Distance(player.Center, npc.Center) > 80f) - { - Main.PlaySound((phase2 || deathModeEnragePhase_BodyAndTail) ? SoundID.Item91 : SoundID.Item12, npc.Center); - float num941 = (death ? 16f : revenge ? 14f : 13f) + enrageScale * 4f; - 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; - vector104.X += num942 * 5f; - vector104.Y += num943 * 5f; - Vector2 shootDirection = new Vector2(num942, num943).SafeNormalize(Vector2.UnitY); - Vector2 laserVelocity = shootDirection * num941; - int type = (phase2 || deathModeEnragePhase_BodyAndTail) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (phase2 || deathModeEnragePhase_BodyAndTail) - { - // Waving beams need to start offset so they cross each other neatly. - float waveSideOffset = Main.rand.NextFloat(9f, 14f); - Vector2 perp = shootDirection.RotatedBy(-MathHelper.PiOver2) * waveSideOffset; - - for (int i = -1; i <= 1; i += 2) - { - Vector2 laserStartPos = vector104 + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); - Projectile godRay = Projectile.NewProjectileDirect(laserStartPos, laserVelocity * 1.1f, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); - - // Tell this Phased God Ray exactly which way it should be waving. - godRay.localAI[1] = i * 0.5f; - } - } - else - Projectile.NewProjectile(vector104, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); - } - } - } - else - { - if (npc.localAI[0] % divisor == 0f && npc.ai[0] % 2f == 0f) - { - Vector2 velocity = Vector2.Zero; - if (movingMines) - { - Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - vector15.Normalize(); - vector15 *= Main.rand.Next(30, 121) * 0.01f; - velocity = vector15; - } - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float split = (splittingMines && npc.ai[0] % 3f == 0f) ? 1f : 0f; - Projectile.NewProjectile(npc.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f); - } - } - } - - // Follow the head - 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; - - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - 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)Math.Atan2(num192, num191) + MathHelper.PiOver2; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - - if (num191 < 0f) - npc.spriteDirection = -1; - else if (num191 > 0f) - npc.spriteDirection = 1; - } - } - } - #endregion - - #region Ceaseless Void - public static void CeaselessVoidAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - CalamityGlobalNPC.voidBoss = npc.whoAmI; - - Vector2 vector = npc.Center; - - // Percent life remaining - double lifeRatio = npc.life / (double)npc.lifeMax; - - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - // Phases - bool phase2 = lifeRatio <= 0.7; - bool phase3 = lifeRatio <= 0.4; - bool phase4 = lifeRatio <= 0.1; - bool theBigSucc = npc.life / (double)npc.lifeMax <= 0.1; - bool succSoHardThatYouDie = npc.life / (double)npc.lifeMax <= 0.005; - - // Spawn Dark Energies - int darkEnergyAmt = death ? 6 : revenge ? 5 : expertMode ? 4 : 3; - if (phase2) - darkEnergyAmt += 1; - if (phase3) - darkEnergyAmt += 1; - if (phase4) - darkEnergyAmt += 1; - - // Spawn a few Dark Energies as soon as the fight starts - int spacing = 360 / darkEnergyAmt; - int distance2 = 10; - if (npc.ai[2] == 0f) - { - npc.ai[2] = 1f; - for (int i = 0; i < darkEnergyAmt; i++) - { - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 1f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 2f, 0f, 0f); - } - NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 0.5f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 1.5f, 0f, 0f); - } - - // If there are any Dark Energies alive, change AI and don't take damage - bool anyDarkEnergies = NPC.AnyNPCs(ModContent.NPCType()); - bool movingDuringSuccPhase = npc.ai[3] == 0f; - npc.dontTakeDamage = anyDarkEnergies || theBigSucc || movingDuringSuccPhase; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - // Speed enrage - bool moveVeryFast = Vector2.Distance(npc.Center, player.Center) > 960f || (!player.ZoneDungeon && !BossRushEvent.BossRushActive && player.position.Y < Main.worldSurface * 16.0); - - // Despawn - if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) - { - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.timeLeft < 10) - { - CalamityWorld.DoGSecondStageCountdown = 0; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); - netMessage.Write(CalamityWorld.DoGSecondStageCountdown); - netMessage.Send(); - } - } - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - // Scale multiplier based on nearby active tiles - float tileEnrageMult = BossRushEvent.BossRushActive ? 1.375f : malice ? 1.25f : 1f; - npc.Calamity().CurrentlyEnraged = tileEnrageMult > 1f && !BossRushEvent.BossRushActive; - - // Set AI variable to be used by Dark Energies - npc.ai[1] = tileEnrageMult; - - // Increase projectile fire rate based on number of nearby active tiles - float projectileFireRateMultiplier = MathHelper.Lerp(0.5f, 1.5f, 1f - ((tileEnrageMult - 1f) / 0.5f)); - - // Succ attack - if (!anyDarkEnergies) - { - // This is here because it's used in multiple places - float suckDistance = malice ? 1920f : death ? 1600f : revenge ? 1440f : expertMode ? 1280f : 1040f; - - // Move closer to the target before trying to succ - if (movingDuringSuccPhase) - { - if (Vector2.Distance(vector, player.Center) > 320f || !Collision.CanHit(vector, 1, 1, player.Center, 1, 1)) - Movement(true); - else - npc.ai[3] = 1f; - } - else - { - // Use this to generate more and more dust in final phase - float finalPhaseDustRatio = 1f; - if (succSoHardThatYouDie) - { - finalPhaseDustRatio = 5f; - } - else if (theBigSucc) - { - float amount = (10f - (float)(npc.life / (double)npc.lifeMax) * 100f) / 10f; - finalPhaseDustRatio += MathHelper.Lerp(0f, 2f, amount); - } - - // Slow down - if (npc.velocity.Length() > 0.5f) - npc.velocity *= 0.8f; - else - npc.velocity = Vector2.Zero; - - // Move towards target again if they get outside the succ radius - float moveCloserGateValue = suckDistance * 0.75f; - if (Vector2.Distance(vector, player.Center) > moveCloserGateValue) - npc.ai[3] = 0f; - - // Ceaseless Void sucks in dark energy in different patterns - // This attack also sucks in all players that are within reach of the succ - int dustRings = 3; - for (int h = 0; h < dustRings; h++) - { - float distanceDivisor = h + 1f; - float dustDistance = suckDistance / distanceDivisor; - int numDust = (int)(0.1f * MathHelper.TwoPi * dustDistance); - float angleIncrement = MathHelper.TwoPi / (float)numDust; - Vector2 dustOffset = new Vector2(dustDistance, 0f); - dustOffset = dustOffset.RotatedByRandom(MathHelper.TwoPi); - - int var = (int)(dustDistance / finalPhaseDustRatio); - float dustVelocity = 24f / distanceDivisor * finalPhaseDustRatio; - for (int i = 0; i < numDust; i++) - { - if (Main.rand.NextBool(var)) - { - dustOffset = dustOffset.RotatedBy(angleIncrement); - int dust = Dust.NewDust(vector, 1, 1, ModContent.DustType()); - Main.dust[dust].position = vector + dustOffset; - Main.dust[dust].fadeIn = 1f; - Main.dust[dust].velocity = Vector2.Normalize(vector - Main.dust[dust].position) * dustVelocity; - Main.dust[dust].scale = 3f - h; - } - } - } - - float succPower = 0.1f + finalPhaseDustRatio * 0.1f; - for (int i = 0; i < Main.maxPlayers; i++) - { - float distance = Vector2.Distance(Main.player[i].Center, vector); - if (distance < suckDistance && Main.player[i].grappling[0] == -1) - { - if (Collision.CanHit(vector, 1, 1, Main.player[i].Center, 1, 1)) - { - float distanceRatio = distance / suckDistance; - float multiplier = 1f - distanceRatio; - - if (Main.player[i].Center.X < vector.X) - Main.player[i].velocity.X += succPower * multiplier; - else - Main.player[i].velocity.X -= succPower * multiplier; - - if (Main.player[i].Center.Y < vector.Y) - Main.player[i].velocity.Y += succPower * multiplier; - else - Main.player[i].velocity.Y -= succPower * multiplier; - } - } - } - - // Projectiles - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Slowly die in final phase and then implode - // This phase lasts 20 seconds - if (theBigSucc && calamityGlobalNPC.newAI[1] % 60f == 0f) - { - int damageAmt = npc.lifeMax / 200; - npc.life -= damageAmt; - npc.HealEffect(-damageAmt, true); - - if (npc.life <= 0) - { - npc.life = 0; - npc.HitEffect(); - npc.checkDead(); - } - - npc.netUpdate = true; - } - - // Beam Portals - if (calamityGlobalNPC.newAI[1] == 0f) - { - int numBeamPortals = malice ? 3 : revenge ? 2 : 1; - float degrees = 360 / numBeamPortals; - float beamPortalDistance = malice ? 800f : death ? 960f : revenge ? 1000f : expertMode ? 1040f : 1080f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < numBeamPortals; i++) - { - float ai1 = i * degrees; - Projectile.NewProjectile(player.Center.X + (float)(Math.Sin(i * degrees) * beamPortalDistance), player.Center.Y + (float)(Math.Cos(i * degrees) * beamPortalDistance), 0f, 0f, type, damage, 0f, player.whoAmI, ai1, 0f); - } - } - - // Use this timer to lessen Dark Energy projectile rate of fire while Beam Portals are active - float beamPortalTimeLeft = 600f; - bool summonLessDarkEnergies = false; - if (calamityGlobalNPC.newAI[1] < beamPortalTimeLeft) - { - calamityGlobalNPC.newAI[1] += 1f; - summonLessDarkEnergies = true; - } - else if (theBigSucc) - calamityGlobalNPC.newAI[1] += 1f; - - // Suck in Dark Energy projectiles from far away - calamityGlobalNPC.newAI[3] += 1f; - float darkEnergySpiralGateValue = (summonLessDarkEnergies ? 36f : 12f) * projectileFireRateMultiplier; - if (calamityGlobalNPC.newAI[3] >= darkEnergySpiralGateValue) - { - calamityGlobalNPC.newAI[3] = 0f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - bool normalSpread = npc.localAI[0] % 2f == 0f; - float speed = 0.5f; - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(speed * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalSpread ? new Vector2(0f, -speed) : new Vector2(-velocityX, -speed); - float radialOffset = MathHelper.ToRadians(npc.localAI[1]); - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 spawnVector = vector + Vector2.Normalize(spinningPoint.RotatedBy(radians * i + radialOffset)) * suckDistance; - Vector2 velocity = Vector2.Normalize(vector - spawnVector) * speed; - Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - npc.localAI[1] += 10f; - } - - // Summon some extra projectiles in Expert Mode - if (phase2 && expertMode && !summonLessDarkEnergies) - { - npc.localAI[2] += 1f; - if (npc.localAI[2] >= 60f * projectileFireRateMultiplier) - { - npc.localAI[2] = 0f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - bool normalSpread = npc.localAI[0] % 2f != 0f; - float speed = 2f; - int totalProjectiles = 2; - float radians = MathHelper.TwoPi / totalProjectiles; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(speed * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalSpread ? new Vector2(0f, -speed) : new Vector2(-velocityX, -speed); - float radialOffset = MathHelper.ToRadians(npc.localAI[1] * 0.25f); - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 spawnVector = vector + Vector2.Normalize(spinningPoint.RotatedBy(radians * i + radialOffset)) * suckDistance; - Vector2 velocity = Vector2.Normalize(vector - spawnVector) * speed; - Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - } - - // Summon some extra projectiles in Revengeance Mode - if (phase4 && revenge && !summonLessDarkEnergies) - { - npc.localAI[3] += 1f; - if (npc.localAI[3] >= 90f * projectileFireRateMultiplier) - { - npc.localAI[3] = 0f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - bool normalSpread = npc.localAI[0] % 2f == 0f; - float speed = 4f; - int totalProjectiles = 2; - float radians = MathHelper.TwoPi / totalProjectiles; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(speed * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalSpread ? new Vector2(0f, -speed) : new Vector2(-velocityX, -speed); - float radialOffset = MathHelper.ToRadians(npc.localAI[1] * 0.25f); - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 spawnVector = vector + Vector2.Normalize(spinningPoint.RotatedBy(radians * i + radialOffset)) * suckDistance; - Vector2 velocity = Vector2.Normalize(vector - spawnVector) * speed; - Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - } - } - else - { - Movement(false); - - // Count up all Dark Energy HP values - int totalDarkEnergyHP = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC darkEnergy = Main.npc[i]; - if (darkEnergy.active && darkEnergy.type == ModContent.NPCType()) - totalDarkEnergyHP += darkEnergy.life; - } - - // Destroy all Dark Energies if their total HP is below 20% - int darkEnergyMaxHP = BossRushEvent.BossRushActive ? 44000 : (CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel1) ? 12000 : 3000; - int totalDarkEnergiesSpawned = darkEnergyAmt * 3 + 2; - int totalDarkEnergyMaxHP = darkEnergyMaxHP * totalDarkEnergiesSpawned; - int succPhaseGateValue = (int)(totalDarkEnergyMaxHP * 0.2); - if (totalDarkEnergyHP < succPhaseGateValue) - { - Main.PlaySound(SoundID.NPCDeath44, vector); - - // Kill all Dark Energies - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC darkEnergy = Main.npc[i]; - if (darkEnergy.active && darkEnergy.type == ModContent.NPCType()) - { - darkEnergy.HitEffect(); - darkEnergy.active = false; - darkEnergy.netUpdate = true; - } - } - - // Generate a dust explosion - int dustAmt = 30; - int random = 3; - for (int j = 0; j < 10; j++) - { - random += j * 2; - int dustAmtSpawned = 0; - int scale = random * 13; - float dustPositionX = vector.X - (scale / 2); - float dustPositionY = vector.Y - (scale / 2); - while (dustAmtSpawned < dustAmt) - { - float dustVelocityX = Main.rand.Next(-random, random); - float dustVelocityY = Main.rand.Next(-random, random); - float dustVelocityScalar = random * 2f; - float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); - dustVelocity = dustVelocityScalar / dustVelocity; - dustVelocityX *= dustVelocity; - dustVelocityY *= dustVelocity; - int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].position.X = vector.X; - Main.dust[dust].position.Y = vector.Y; - Main.dust[dust].position.X += Main.rand.Next(-10, 11); - Main.dust[dust].position.Y += Main.rand.Next(-10, 11); - Main.dust[dust].velocity.X = dustVelocityX; - Main.dust[dust].velocity.Y = dustVelocityY; - dustAmtSpawned++; - } - } - } - } - - // Basic movement towards a location - void Movement(bool succ) - { - float velocity = moveVeryFast ? 25f : BossRushEvent.BossRushActive ? 15f : ((expertMode ? 7.5f : 6f) + (float)(death ? 2f * (1D - lifeRatio) : 0f)) * tileEnrageMult; - float acceleration = moveVeryFast ? 0.75f : malice ? 0.3f : death ? 0.2f : expertMode ? 0.16f : 0.12f; - - // Increase speed dramatically in succ phase - if (succ) - { - velocity *= 2f; - acceleration *= 2f; - } - - Vector2 moveTo = new Vector2(player.Center.X - vector.X, player.Center.Y - vector.Y); - - // Move between 8 different positions around the player, in order - float maxDistance = 320f; - Vector2 moveToOffset = succ ? Vector2.Zero : new Vector2(0f, -maxDistance); - if (!succ) - { - // Move to a new location every few seconds - calamityGlobalNPC.newAI[2] += 1f; - float newPositionGateValue = malice ? 180f : death ? 270f : revenge ? 300f : expertMode ? 360f : 480f; - if (calamityGlobalNPC.newAI[2] > newPositionGateValue) - { - calamityGlobalNPC.newAI[2] = 0f; - - npc.ai[0] += 1f; - if (npc.ai[0] > 7f) - npc.ai[0] = 0f; - } - - switch ((int)npc.ai[0]) - { - case 0: - break; - case 1: - moveToOffset.X = -maxDistance; - break; - case 2: - moveToOffset.X = -maxDistance; - moveToOffset.Y = 0f; - break; - case 3: - moveToOffset.X = -maxDistance; - moveToOffset.Y = maxDistance; - break; - case 4: - moveToOffset.Y = maxDistance; - break; - case 5: - moveToOffset.X = maxDistance; - moveToOffset.Y = maxDistance; - break; - case 6: - moveToOffset.X = maxDistance; - moveToOffset.Y = 0f; - break; - case 7: - moveToOffset.X = maxDistance; - break; - } - } - - moveTo += moveToOffset; - - float distance = (float)Math.Sqrt(moveTo.X * moveTo.X + moveTo.Y * moveTo.Y); - - distance = velocity / distance; - moveTo.X *= distance; - moveTo.Y *= distance; - - if (npc.velocity.X < moveTo.X) - { - npc.velocity.X += acceleration; - if (npc.velocity.X < 0f && moveTo.X > 0f) - npc.velocity.X += acceleration; - } - else if (npc.velocity.X > moveTo.X) - { - npc.velocity.X -= acceleration; - if (npc.velocity.X > 0f && moveTo.X < 0f) - npc.velocity.X -= acceleration; - } - if (npc.velocity.Y < moveTo.Y) - { - npc.velocity.Y += acceleration; - if (npc.velocity.Y < 0f && moveTo.Y > 0f) - npc.velocity.Y += acceleration; - } - else if (npc.velocity.Y > moveTo.Y) - { - npc.velocity.Y -= acceleration; - if (npc.velocity.Y > 0f && moveTo.Y < 0f) - npc.velocity.Y -= acceleration; - } - } - - // Spawn more Dark Energies as the fight progresses - if (calamityGlobalNPC.newAI[0] == 0f && npc.life > 0) - calamityGlobalNPC.newAI[0] = npc.lifeMax; - - if (npc.life > 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int healthGateValue = (int)(npc.lifeMax * 0.3); - if ((npc.life + healthGateValue) < calamityGlobalNPC.newAI[0]) - { - npc.TargetClosest(); - calamityGlobalNPC.newAI[0] = npc.life; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.ai[3] = 0f; - npc.localAI[0] += 1f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - npc.localAI[3] = 0f; - - if (phase4) - { - for (int i = 0; i < darkEnergyAmt; i++) - { - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 2f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 4f, 0f, 0f); - } - NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 1f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 3f, 0f, 0f); - } - else if (phase3) - { - for (int i = 0; i < darkEnergyAmt; i++) - { - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 1.5f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 3f, 0f, 0f); - } - NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 0.5f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 2f, 0f, 0f); - } - else - { - for (int i = 0; i < darkEnergyAmt; i++) - { - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 1f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 2f, 0f, 0f); - } - NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 1.5f, 0f, 0f); - NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 2.5f, 0f, 0f); - } - - // Despawn potentially hazardous projectiles when entering a new phase - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile projectile = Main.projectile[i]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - if (projectile.timeLeft > 30) - projectile.timeLeft = 30; - } - } - } - } - } - } - } - #endregion - - #region Bumblebirb - public static void BumblebirbAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - // Variables - float rotationMult = 3f; - float rotationAmt = 0.03f; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - Vector2 vector = npc.Center; - - // Adjust slowing debuff immunity - bool immuneToSlowingDebuffs = npc.ai[0] == 3f || npc.ai[0] == 3.1f || npc.ai[0] == 3.2f; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; - - // If target is outside the jungle for more than 5 seconds, enrage - if (!player.ZoneJungle) - { - if (npc.localAI[1] < CalamityGlobalNPC.biomeEnrageTimerMax) - npc.localAI[1] += 1f; - } - else - npc.localAI[1] = 0f; - - // If dragonfolly is off screen, enrage for the next couple attacks - if (Vector2.Distance(player.Center, vector) > 1200f) - npc.localAI[2] = 2f; - - // Enrage scale - float enrageScale = death ? 1.5f : 1f; - if (npc.localAI[1] >= CalamityGlobalNPC.biomeEnrageTimerMax || malice) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1f; - } - if (npc.localAI[2] > 0f || malice) - enrageScale += 1f; - - if (enrageScale > 3f) - enrageScale = 3f; - - // Despawn - if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - - if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) - { - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; - - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.2f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[0] != 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Phases - bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f); - bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f) && expertMode; - - float birbSpawnPhaseTimer = 180f; - float newPhaseTimer = 180f; - bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || - (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); - - calamityGlobalNPC.DR = (phaseSwitchPhase || npc.ai[0] == 5f || (enrageScale == 3f && !malice)) ? 0.55f : 0.1f; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phaseSwitchPhase || npc.ai[0] == 5f || (enrageScale == 3f && !malice); - - if (phaseSwitchPhase) - { - if (npc.velocity.X < 0f) - npc.direction = -1; - else if (npc.velocity.X > 0f) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; - - if (phase3) - { - calamityGlobalNPC.newAI[1] += 1f; - - // Sound - if (calamityGlobalNPC.newAI[1] == newPhaseTimer - 60f) - { - SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_BetsyScream, (int)npc.position.X, (int)npc.position.Y); - if (sound != null) - { - sound.Pitch = 0.25f; - } - } - - if (calamityGlobalNPC.newAI[1] >= newPhaseTimer) - { - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 1f; - calamityGlobalNPC.newAI[3] = 1f; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.SyncExtraAI(); - npc.netUpdate = true; - } - } - else - { - calamityGlobalNPC.newAI[0] += 1f; - - // Sound - if (calamityGlobalNPC.newAI[0] == newPhaseTimer - 60f) - { - SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_BetsyScream, (int)npc.position.X, (int)npc.position.Y); - if (sound != null) - { - sound.Pitch = 0.25f; - } - } - - if (calamityGlobalNPC.newAI[0] >= newPhaseTimer) - { - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[2] = 1f; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.SyncExtraAI(); - npc.netUpdate = true; - } - } - - Vector2 value52 = player.Center - npc.Center; - float scaleFactor16 = 4f + value52.Length() / 100f; - float num1308 = 25f; - value52.Normalize(); - value52 *= scaleFactor16; - npc.velocity = (npc.velocity * (num1308 - 1f) + value52) / num1308; - return; - } - - // Max spawn amount - int maxBirbs = revenge ? 3 : 2; - - // Variable for charging - float chargeDistance = 600f; - if (phase2) - chargeDistance -= 50f; - if (phase3) - chargeDistance -= 50f; - chargeDistance -= (enrageScale - 1f) * 100f; - - // Phase switch - if (npc.ai[0] == 0f) - { - if (npc.Center.X < player.Center.X - 2f) - npc.direction = 1; - if (npc.Center.X > player.Center.X + 2f) - npc.direction = -1; - - // Direction and rotation - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt * 1.25f) / 10f; - - // Fly to target if target is too far away, otherwise get close to target and then slow down - Vector2 value51 = player.Center - npc.Center; - value51.Y -= 200f; - if (value51.Length() > 2800f) - { - npc.TargetClosest(); - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - else if (value51.Length() > 240f) - { - float scaleFactor15 = 12f + (enrageScale - 1f) * 6f; - float num1306 = 30f; - value51.Normalize(); - value51 *= scaleFactor15; - npc.velocity = (npc.velocity * (num1306 - 1f) + value51) / num1306; - } - else if (npc.velocity.Length() > 2f) - npc.velocity *= 0.95f; - else if (npc.velocity.Length() < 1f) - npc.velocity *= 1.05f; - - // Phase switch - npc.ai[1] += 1f; - if (npc.ai[1] >= 30f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - while (npc.ai[0] == 0f) - { - if (phase2) - npc.localAI[0] += 1f; - - bool canHit = Collision.CanHit(npc.Center, 1, 1, player.Center, 1, 1); - - if (npc.localAI[0] >= (phase3 ? 7 : 9) && canHit) - { - npc.TargetClosest(); - npc.ai[0] = 5f; - npc.localAI[0] = 0f; - - // Decrease the feather variable, feathers can be used again if it's at 0 - if (npc.ai[3] > 0f) - npc.ai[3] -= 1f; - - // Decrease enraged attacks by 1 - if (npc.localAI[2] > 0f) - npc.localAI[2] -= 1f; - - // Decrease amount of attacks until able to spawn small birbs again - if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; - } - else - { - int num1307 = phase2 ? Main.rand.Next(2) + 1 : Main.rand.Next(3); - if (phase3) - num1307 = 1; - - float featherVelocity = 2f + (enrageScale - 1f); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - - if (num1307 == 0 && canHit && npc.localAI[3] == 0f) - { - npc.TargetClosest(); - npc.ai[0] = 2f; - - // Decrease the feather variable, feathers can be used again if it's at 0 - if (npc.ai[3] > 0f) - npc.ai[3] -= 1f; - - // Decrease enraged attacks by 1 - if (npc.localAI[2] > 0f) - npc.localAI[2] -= 1f; - - // Birb will do at least 1 different attack before entering this phase again - npc.localAI[3] = 1f; - } - else if (num1307 == 1) - { - npc.TargetClosest(); - npc.ai[0] = 3f; - - // Decrease enraged attacks by 1 - if (npc.localAI[2] > 0f) - npc.localAI[2] -= 1f; - - // Decrease amount of attacks until able to use other attacks again - if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; - - if (phase2 && npc.ai[3] == 0f) - { - npc.ai[3] = 3f; - Main.PlaySound(SoundID.Item102, (int)player.position.X, (int)player.position.Y); - int totalProjectiles = 40; - float radians = MathHelper.TwoPi / totalProjectiles; - int distance = 800; - bool spawnRight = player.velocity.X > 0f; - for (int i = 0; i < totalProjectiles; i++) - { - if (spawnRight) - { - if (i >= (int)(totalProjectiles * 0.125) && i <= (int)(totalProjectiles * 0.375)) - { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - else - { - if (i >= (int)(totalProjectiles * 0.625) && i <= (int)(totalProjectiles * 0.875)) - { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - else - { - // Decrease the feather variable, feathers can be used again if it's at 0 - if (npc.ai[3] > 0f) - npc.ai[3] -= 1f; - } - } - else if (NPC.CountNPCS(ModContent.NPCType()) < maxBirbs && npc.localAI[3] == 0f) - { - npc.TargetClosest(); - npc.ai[0] = 4f; - - // Birb will do at least 2 different attacks before entering this phase again - npc.localAI[3] = 2f; - - // Decrease enraged attacks by 1 - if (npc.localAI[2] > 0f) - npc.localAI[2] -= 1f; - - if (npc.ai[3] == 0f) - { - npc.ai[3] = 3f; - Main.PlaySound(SoundID.Item102, (int)player.position.X, (int)player.position.Y); - int totalProjectiles = phase2 ? 40 : 48; - float radians = MathHelper.TwoPi / totalProjectiles; - int distance = phase2 ? 1200 : 1320; - bool spawnRight = player.velocity.X > 0f; - for (int i = 0; i < totalProjectiles; i++) - { - if (spawnRight) - { - if (i >= totalProjectiles / 2) - break; - - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - else - { - if (i >= totalProjectiles / 2) - { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - else - { - // Decrease the feather variable, feathers can be used again if it's at 0 - if (npc.ai[3] > 0f) - npc.ai[3] -= 1f; - } - } - } - } - - npc.netUpdate = true; - npc.SyncExtraAI(); - } - } - - // Fly to target - else if (npc.ai[0] == 1f) - { - if (npc.velocity.X < 0f) - npc.direction = -1; - else if (npc.velocity.X > 0f) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; - - Vector2 value52 = player.Center - npc.Center; - if (value52.Length() < 800f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.TargetClosest(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - npc.SyncExtraAI(); - } - - float velocity = 14f + (enrageScale - 1f) * 4f; - float scaleFactor16 = velocity + value52.Length() / 100f; - float num1308 = 25f; - value52.Normalize(); - value52 *= scaleFactor16; - npc.velocity = (npc.velocity * (num1308 - 1f) + value52) / num1308; - } - - // Fly towards target quickly - else if (npc.ai[0] == 2f) - { - if (npc.target < 0 || !player.active || player.dead) - { - npc.TargetClosest(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - npc.SyncExtraAI(); - } - - if (player.Center.X - 10f < npc.Center.X) - npc.direction = -1; - else if (player.Center.X + 10f > npc.Center.X) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 1.25f) / 5f; - - Vector2 value53 = player.Center - npc.Center; - value53.Y -= 20f; - npc.ai[2] += 0.0222222228f; - if (expertMode) - npc.ai[2] += 0.0166666675f; - - float velocity = 8f + (enrageScale - 1f) * 2f; - float scaleFactor17 = velocity + npc.ai[2] + value53.Length() / 120f; - float num1309 = 20f; - value53.Normalize(); - value53 *= scaleFactor17; - npc.velocity = (npc.velocity * (num1309 - 1f) + value53) / num1309; - - npc.ai[1] += 1f; - if (npc.ai[1] >= 120f || !Collision.CanHit(npc.Center, 1, 1, player.Center, 1, 1)) - { - npc.TargetClosest(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - npc.SyncExtraAI(); - } - } - - // Line up charge - else if (npc.ai[0] == 3f) - { - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; - - Vector2 value54 = player.Center - npc.Center; - value54.Y -= 12f; - if (npc.Center.X > player.Center.X) - value54.X += chargeDistance; - else - value54.X -= chargeDistance; - - float verticalDistanceGateValue = (phase3 ? 100f : 20f) + (enrageScale - 1f) * 20f; - if (Math.Abs(npc.Center.X - player.Center.X) > chargeDistance - 50f && Math.Abs(npc.Center.Y - player.Center.Y) < verticalDistanceGateValue) - { - npc.ai[0] = 3.1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - npc.SyncExtraAI(); - } - - npc.ai[1] += 0.0333333351f; - float velocity = 16f + (enrageScale - 1f) * 4f; - float scaleFactor18 = velocity + npc.ai[1]; - float num1310 = 4f; - value54.Normalize(); - value54 *= scaleFactor18; - npc.velocity = (npc.velocity * (num1310 - 1f) + value54) / num1310; - } - - // Prepare to charge - else if (npc.ai[0] == 3.1f) - { - npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; - - Vector2 vector206 = player.Center - npc.Center; - vector206.Y -= 12f; - float scaleFactor19 = 28f + (enrageScale - 1f) * 4f; - float num1311 = 8f; - vector206.Normalize(); - vector206 *= scaleFactor19; - npc.velocity = (npc.velocity * (num1311 - 1f) + vector206) / num1311; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - - npc.ai[1] += 1f; - if (npc.ai[1] > 10f) - { - npc.velocity = vector206; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.ai[0] = 3.2f; - npc.ai[1] = npc.direction; - npc.netUpdate = true; - npc.SyncExtraAI(); - } - } - - // Charge - else if (npc.ai[0] == 3.2f) - { - npc.ai[2] += 0.0333333351f; - float velocity = 28f + (enrageScale - 1f) * 4f; - npc.velocity.X = (velocity + npc.ai[2]) * npc.ai[1]; - - if ((npc.ai[1] > 0f && npc.Center.X > player.Center.X + (chargeDistance - 140f)) || (npc.ai[1] < 0f && npc.Center.X < player.Center.X - (chargeDistance - 140f))) - { - if (!Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.TargetClosest(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - else if (Math.Abs(npc.Center.X - player.Center.X) > chargeDistance + 200f) - { - npc.TargetClosest(); - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - } - - npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; - } - - // Birb spawn - else if (npc.ai[0] == 4f) - { - if (npc.ai[1] == 0f) - { - Vector2 destination2 = player.Center + new Vector2(0f, -200f); - Vector2 desiredVelocity2 = npc.SafeDirectionTo(destination2, -Vector2.UnitY) * 18f; - npc.SimpleFlyMovement(desiredVelocity2, 1.5f); - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - - npc.ai[2] += 1f; - if (npc.Distance(player.Center) < 600f || npc.ai[2] >= 180f) - { - npc.ai[1] = 1f; - npc.netUpdate = true; - } - } - else - { - if (npc.ai[1] < 90f) - npc.velocity *= 0.95f; - else - npc.velocity *= 0.98f; - - if (npc.ai[1] == 90f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y /= 3f; - - npc.velocity.Y -= 3f; - } - - // Sound - if (npc.ai[1] == birbSpawnPhaseTimer - 60f) - { - SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_BetsyScream, (int)npc.position.X, (int)npc.position.Y); - if (sound != null) - { - sound.Pitch = 0.25f; - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - bool spawnFlag = NPC.CountNPCS(ModContent.NPCType()) < maxBirbs && (npc.ai[1] == 140f || (revenge && npc.ai[1] == 155f) || npc.ai[1] == 170f); - if (spawnFlag) - { - Vector2 vector7 = npc.Center + (MathHelper.TwoPi * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 50f * (0.6f + Main.rand.NextFloat() * 0.4f); - if (Vector2.Distance(vector7, player.Center) > 150f) - NPC.NewNPC((int)vector7.X, (int)vector7.Y, ModContent.NPCType(), npc.whoAmI); - npc.netUpdate = true; - } - } - - npc.ai[1] += 1f; - } - - if (npc.ai[1] >= birbSpawnPhaseTimer) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Spit homing aura sphere - else if (npc.ai[0] == 5f) - { - // Velocity - npc.velocity *= 0.98f; - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; - - // Play sound - float aiGateValue = 120f; - if (npc.ai[1] == aiGateValue - 30f) - { - Main.PlaySound(SoundID.DD2_BetsyFireballShot, (int)npc.position.X, (int)npc.position.Y); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + vector; - float ai0 = (phase3 ? 2f : 0f) + (enrageScale - 1f); - if (ai0 > 3f) - ai0 = 3f; - Projectile.NewProjectile(vector7.X, vector7.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, ai0, npc.target + 1); - npc.netUpdate = true; - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= aiGateValue) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - } - } - - public static void Bumblebirb2AI(NPC npc, Mod mod, bool bossMinion) - { + #endregion + + #region Astrum Deus + public static void AstrumDeusAI(NPC npc, Mod mod, bool head) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + // Difficulty variables + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + float enrageScale = BossRushEvent.BossRushActive ? 0.5f : 0f; + if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1.5f; + } + + // Deus cannot hit for 3 seconds or while invulnerable + if (calamityGlobalNPC.newAI[1] < 180f || npc.dontTakeDamage) + npc.damage = 0; + else + npc.damage = npc.defDamage; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + Player player = Main.player[npc.target]; + + bool increaseSpeed = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles; + bool increaseSpeedMore = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; + + // Despawn safety, make sure to target another player if the current player target is too far away + if (increaseSpeedMore && head) + npc.TargetClosest(); + + // Inflict Extreme Gravity to nearby players + if (revenge) + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); + } + } + + // Life + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Phases based on life percentage + bool halfHealth = lifeRatio < 0.5f; + bool doubleWormPhase = calamityGlobalNPC.newAI[0] != 0f; + bool startFlightPhase = lifeRatio < 0.8f || death || doubleWormPhase; + bool phase2 = lifeRatio < 0.5f && doubleWormPhase && expertMode; + bool phase3 = lifeRatio < 0.2f && doubleWormPhase && expertMode; + bool splittingMines = lifeRatio < 0.7f; + bool movingMines = lifeRatio < 0.3f && doubleWormPhase && expertMode; + bool deathModeEnragePhase_Head = calamityGlobalNPC.newAI[0] == 3f; + bool deathModeEnragePhase_BodyAndTail = false; + + // 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing + float resistanceTime = doubleWormPhase ? 300f : 600f; + if (calamityGlobalNPC.newAI[1] < resistanceTime) + calamityGlobalNPC.newAI[1] += 1f; + + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < resistanceTime; + + // Flight timer + float aiSwitchTimer = doubleWormPhase ? 1200f : 1800f; + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= aiSwitchTimer) + calamityGlobalNPC.newAI[3] = 0f; + + // Phase for flying at the player + bool flyAtTarget = calamityGlobalNPC.newAI[3] >= (aiSwitchTimer * 0.5f) && startFlightPhase; + + // Length of worms + int phase1Length = death ? 80 : revenge ? 70 : expertMode ? 60 : 50; + int phase2Length = phase1Length / 2; + int maxLength = doubleWormPhase ? phase2Length : phase1Length; + + // Split into two worms + if (head) + { + float splitAnimationTime = 180f; + bool oneWormAlive = NPC.CountNPCS(ModContent.NPCType()) < 2; + bool deathModeFinalWormEnrage = death && doubleWormPhase && oneWormAlive && calamityGlobalNPC.newAI[1] >= resistanceTime; + if (deathModeFinalWormEnrage) + { + if (calamityGlobalNPC.newAI[0] != 3f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AstrumDeusSplit"), player.Center); + calamityGlobalNPC.newAI[0] = 3f; + npc.defense = 12; + calamityGlobalNPC.DR = 0.075f; + + // Despawns the other deus worm segments + int bodyID = ModContent.NPCType(); + int tailID = ModContent.NPCType(); + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC wormseg = Main.npc[i]; + if (!wormseg.active) + continue; + + if ((wormseg.type == bodyID || wormseg.type == tailID) && Main.npc[(int)wormseg.ai[2]].Calamity().newAI[0] != 3f) + { + wormseg.life = 0; + wormseg.active = false; + } + } + } + + calamityGlobalNPC.newAI[2] += 10f; + if (calamityGlobalNPC.newAI[2] > 162f) + calamityGlobalNPC.newAI[2] = 162f; + + npc.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f); + } + + bool despawnRemainingWorm = doubleWormPhase && oneWormAlive && !death; + if ((halfHealth && calamityGlobalNPC.newAI[0] == 0f) || despawnRemainingWorm) + { + npc.dontTakeDamage = true; + + calamityGlobalNPC.newAI[2] += despawnRemainingWorm ? 10f : 1f; + npc.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f); + + bool despawning = calamityGlobalNPC.newAI[2] == splitAnimationTime; + + // + // CODE TWEAKED BY: OZZATRON + // September 20th, 2020 + // reason: fixing Astrum Deus death mode NPC cap bug + // + + // Despawn the unsplit Astrum Deus and spawn two half-size Astrum Deus worms. + if (despawning) + { + // If this is already a split worm (newAI[0] != 0f) then don't do anything. At all. + if (doubleWormPhase) + return; + + // Mark all existing body and tail segments as inactive. This instantly frees up their NPC slots for the freshly spawned worms. + int bodyID = ModContent.NPCType(); + int tailID = ModContent.NPCType(); + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC wormseg = Main.npc[i]; + if (!wormseg.active) + continue; + if (wormseg.type == bodyID || wormseg.type == tailID) + { + wormseg.life = 0; + wormseg.active = false; + } + } + + // The unsplit Astrum Deus worm head will die next frame. + npc.life = 0; + + // Do not spawn worms client side. The server handles this. + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Now that the original worm doesn't exist, startCount can be zero. + // int startCount = npc.whoAmI + phase1Length + 1; + int startIndexHeadOne = 1; + int headOneID = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, npc.type, startIndexHeadOne); + Main.npc[headOneID].Calamity().newAI[0] = 1f; + Main.npc[headOneID].velocity = Vector2.Normalize(player.Center - Main.npc[headOneID].Center) * 16f; + Main.npc[headOneID].timeLeft *= 20; + Main.npc[headOneID].netUpdate = true; + + // On server, immediately send the correct extra AI of this head to clients. + if (Main.netMode == NetmodeID.Server) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.SyncCalamityNPCAIArray); + netMessage.Write((byte)headOneID); + netMessage.Write(Main.npc[headOneID].Calamity().newAI[0]); + netMessage.Write(Main.npc[headOneID].Calamity().newAI[1]); + netMessage.Write(Main.npc[headOneID].Calamity().newAI[2]); + netMessage.Write(Main.npc[headOneID].Calamity().newAI[3]); + netMessage.Send(); + } + + // Make sure the second split worm is also contiguous. + int startIndexHeadTwo = startIndexHeadOne + phase2Length + 1; + int headTwoID = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, npc.type, startIndexHeadTwo); + Main.npc[headTwoID].Calamity().newAI[0] = 2f; + Main.npc[headTwoID].Calamity().newAI[3] = 600f; + Main.npc[headTwoID].velocity = Vector2.Normalize(player.Center - Main.npc[headTwoID].Center) * 16f; + Main.npc[headTwoID].timeLeft *= 20; + Main.npc[headTwoID].netUpdate = true; + + // On server, immediately send the correct extra AI of this head to clients. + if (Main.netMode == NetmodeID.Server) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.SyncCalamityNPCAIArray); + netMessage.Write((byte)headTwoID); + netMessage.Write(Main.npc[headTwoID].Calamity().newAI[0]); + netMessage.Write(Main.npc[headTwoID].Calamity().newAI[1]); + netMessage.Write(Main.npc[headTwoID].Calamity().newAI[2]); + netMessage.Write(Main.npc[headTwoID].Calamity().newAI[3]); + netMessage.Send(); + } + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AstrumDeusSplit"), player.Center); + } + return; + } + } + } + + // Copy dontTakeDamage and Opacity from head + else + { + npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; + npc.Opacity = Main.npc[(int)npc.ai[2]].Opacity; + deathModeEnragePhase_BodyAndTail = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 3f; + + if (deathModeEnragePhase_BodyAndTail) + { + npc.defense = 25; + calamityGlobalNPC.DR = 0.15f; + } + } + + // Set worm variable + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + // Emit light + 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) && !npc.dontTakeDamage) + { + // Alpha changes + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } + + // Check if other segments are still alive, if not, die + if (npc.type != ModContent.NPCType()) + { + bool shouldDespawn = true; + int headType = ModContent.NPCType(); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].type != headType || !Main.npc[i].active) + continue; + shouldDespawn = false; + break; + } + if (shouldDespawn) + { + if (Main.npc.IndexInRange((int)npc.ai[1]) && Main.npc[(int)npc.ai[1]].active && Main.npc[(int)npc.ai[1]].life > 0) + shouldDespawn = false; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + npc.netUpdate = true; + } + } + + // Direction + if (npc.velocity.X < 0f) + npc.spriteDirection = -1; + else if (npc.velocity.X > 0f) + npc.spriteDirection = 1; + + // Head code + if (head) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (npc.ai[0] == 0f) + { + int Previous = npc.whoAmI; + int bodyType = ModContent.NPCType(); + int tailType = ModContent.NPCType(); + for (int num36 = 0; num36 < maxLength; num36++) + { + int lol; + if (num36 >= 0 && num36 < maxLength - 1) + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), bodyType, npc.whoAmI); + else + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), tailType, npc.whoAmI); + + if (num36 % 2 == 0) + Main.npc[lol].localAI[3] = 1f; + + Main.npc[lol].realLife = npc.whoAmI; + Main.npc[lol].Calamity().newAI[0] = Main.npc[Previous].Calamity().newAI[0]; + Main.npc[lol].Calamity().newAI[3] = Main.npc[Previous].Calamity().newAI[3]; + if (Main.netMode == NetmodeID.Server) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.SyncCalamityNPCAIArray); + netMessage.Write((byte)lol); + netMessage.Write(Main.npc[lol].Calamity().newAI[0]); + netMessage.Write(Main.npc[lol].Calamity().newAI[1]); + netMessage.Write(Main.npc[lol].Calamity().newAI[2]); + netMessage.Write(Main.npc[lol].Calamity().newAI[3]); + netMessage.Send(); + } + Main.npc[lol].ai[2] = npc.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); + Previous = lol; + } + } + } + } + + if (head) + { + int num12 = (int)(npc.position.X / 16f) - 1; + int num13 = (int)((npc.position.X + npc.width) / 16f) + 2; + int num14 = (int)(npc.position.Y / 16f) - 1; + int num15 = (int)((npc.position.Y + npc.height) / 16f) + 2; + + if (num12 < 0) + num12 = 0; + if (num13 > Main.maxTilesX) + num13 = Main.maxTilesX; + if (num14 < 0) + num14 = 0; + if (num15 > Main.maxTilesY) + num15 = Main.maxTilesY; + + // Fly or not + bool flag2 = flyAtTarget; + if (!flag2) + { + for (int k = num12; k < num13; k++) + { + for (int l = num14; l < num15; l++) + { + 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 = 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; + } + } + } + } + } + + // Start flying if target is not within a certain distance + if (!flag2) + { + npc.localAI[1] = 1f; + + if (head) + { + Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + int num16 = 200; + int heightReduction = death ? 130 : (int)(130f * (1f - lifeRatio)); + int height = 400 - heightReduction; + bool flag3 = true; + + if (npc.position.Y > player.position.Y) + { + for (int m = 0; m < Main.maxPlayers; m++) + { + if (Main.player[m].active) + { + Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, height); + if (rectangle.Intersects(rectangle2)) + { + flag3 = false; + break; + } + } + } + if (flag3) + flag2 = true; + } + } + } + else + npc.localAI[1] = 0f; + + // Despawn + float fallSpeed = deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f; + if (player.dead) + { + flag2 = false; + float velocity = 2f; + npc.velocity.Y -= velocity; + if ((double)npc.position.Y < Main.topWorld + 16f) + { + fallSpeed = deathModeEnragePhase_Head ? 38f : death ? 35f : 32f; + npc.velocity.Y -= velocity; + } + + int headType = ModContent.NPCType(); + int bodyType = ModContent.NPCType(); + int tailType = ModContent.NPCType(); + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int num957 = 0; num957 < Main.maxNPCs; num957++) + { + if (Main.npc[num957].type == headType || Main.npc[num957].type == bodyType || Main.npc[num957].type == tailType) + { + Main.npc[num957].active = false; + Main.npc[num957].netUpdate = true; + } + } + } + } + + float fallSpeedBoost = 5f * (1f - lifeRatio); + fallSpeed += fallSpeedBoost; + fallSpeed += 4f * enrageScale; + + // Speed and movement + float speedBoost = death ? (0.1f * (1f - lifeRatio)) : (0.13f * (1f - lifeRatio)); + float turnSpeedBoost = death ? (0.18f * (1f - lifeRatio)) : (0.2f * (1f - lifeRatio)); + float speed = (deathModeEnragePhase_Head ? 0.2f : death ? 0.18f : 0.13f) + speedBoost; + float turnSpeed = (deathModeEnragePhase_Head ? 0.27f : death ? 0.25f : 0.2f) + turnSpeedBoost; + speed += 0.05f * enrageScale; + turnSpeed += 0.08f * enrageScale; + + if (flyAtTarget) + { + float speedMultiplier = deathModeEnragePhase_Head ? 1.25f : doubleWormPhase ? (phase3 ? 1.25f : phase2 ? 1.2f : 1.15f) : 1f; + speed *= speedMultiplier; + } + + if (revenge) + { + float revMultiplier = 1.1f; + speed *= revMultiplier; + turnSpeed *= revMultiplier; + fallSpeed *= revMultiplier; + } + + speed *= increaseSpeedMore ? 4f : increaseSpeed ? 2f : 1f; + turnSpeed *= increaseSpeedMore ? 4f : increaseSpeed ? 2f : 1f; + + 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; + + if (!flag2) + { + npc.velocity.Y += 0.15f; + if (npc.velocity.Y > fallSpeed) + npc.velocity.Y = fallSpeed; + + 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; + else + npc.velocity.X += speed * 1.1f; + } + else if (npc.velocity.Y == fallSpeed) + { + if (npc.velocity.X < num20) + npc.velocity.X += speed; + else if (npc.velocity.X > num20) + npc.velocity.X -= speed; + } + else if (npc.velocity.Y > 4f) + { + if (npc.velocity.X < 0f) + npc.velocity.X += speed * 0.9f; + else + npc.velocity.X -= speed * 0.9f; + } + } + else + { + float num22 = (float)Math.Sqrt(num20 * num20 + num21 * num21); + float num25 = Math.Abs(num20); + float num26 = Math.Abs(num21); + float num27 = fallSpeed / num22; + num20 *= num27; + num21 *= num27; + + bool flag6 = false; + if (flyAtTarget) + { + if (((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f) || (npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > speed / 2f && num22 < 400f) + { + flag6 = true; + + if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < fallSpeed) + npc.velocity *= 1.1f; + } + + if (npc.position.Y > player.position.Y) + { + flag6 = true; + + if (Math.Abs(npc.velocity.X) < fallSpeed / 2f) + { + if (npc.velocity.X == 0f) + npc.velocity.X -= npc.direction; + + npc.velocity.X *= 1.1f; + } + else if (npc.velocity.Y > -fallSpeed) + npc.velocity.Y -= speed; + } + } + + if (!flag6) + { + if (!flyAtTarget) + { + if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) + { + if (npc.velocity.X < num20) + npc.velocity.X += turnSpeed; + else if (npc.velocity.X > num20) + npc.velocity.X -= turnSpeed; + if (npc.velocity.Y < num21) + npc.velocity.Y += turnSpeed; + else if (npc.velocity.Y > num21) + npc.velocity.Y -= turnSpeed; + } + } + + if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) + { + if (npc.velocity.X < num20) + npc.velocity.X += speed; + else if (npc.velocity.X > num20) + npc.velocity.X -= speed; + if (npc.velocity.Y < num21) + npc.velocity.Y += speed; + else if (npc.velocity.Y > num21) + npc.velocity.Y -= speed; + + 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 (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; + else + npc.velocity.X -= speed * 2f; + } + } + else if (num25 > num26) + { + if (npc.velocity.X < num20) + npc.velocity.X += speed * 1.1f; + else if (npc.velocity.X > num20) + npc.velocity.X -= speed * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += speed; + else + npc.velocity.Y -= speed; + } + } + else + { + if (npc.velocity.Y < num21) + npc.velocity.Y += speed * 1.1f; + else if (npc.velocity.Y > num21) + npc.velocity.Y -= speed * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) + { + if (npc.velocity.X > 0f) + npc.velocity.X += speed; + else + npc.velocity.X -= speed; + } + } + } + } + + if (flag2) + { + if (npc.localAI[0] != 1f) + npc.netUpdate = true; + + npc.localAI[0] = 1f; + } + else + { + if (npc.localAI[0] != 0f) + npc.netUpdate = true; + + npc.localAI[0] = 0f; + } + + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + npc.netUpdate = true; + + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + } + + // Only the main worm body and tail use this code + else + { + // Shoot lasers + if (npc.type == ModContent.NPCType() && Main.netMode != NetmodeID.MultiplayerClient) + { + int shootTime = (doubleWormPhase && expertMode) ? 2 : 1; + npc.localAI[0] += 1f; + float shootProjectile = 400 / shootTime; + float timer = npc.ai[0] + 15f; + float divisor = timer + shootProjectile; + if (!flyAtTarget || deathModeEnragePhase_BodyAndTail) + { + if (npc.localAI[0] % divisor == 0f && npc.ai[0] % 2f == 0f) + { + npc.TargetClosest(); + + if (deathModeEnragePhase_BodyAndTail) + { + Vector2 velocity = Vector2.Zero; + if (movingMines) + { + Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + vector15.Normalize(); + vector15 *= Main.rand.Next(90, 121) * 0.01f; + velocity = vector15; + } + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float split = (splittingMines && npc.ai[0] % 3f == 0f) ? 1f : 0f; + Projectile.NewProjectile(npc.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f); + } + + if (Vector2.Distance(player.Center, npc.Center) > 80f) + { + Main.PlaySound((phase2 || deathModeEnragePhase_BodyAndTail) ? SoundID.Item91 : SoundID.Item12, npc.Center); + float num941 = (death ? 16f : revenge ? 14f : 13f) + enrageScale * 4f; + 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; + vector104.X += num942 * 5f; + vector104.Y += num943 * 5f; + Vector2 shootDirection = new Vector2(num942, num943).SafeNormalize(Vector2.UnitY); + Vector2 laserVelocity = shootDirection * num941; + int type = (phase2 || deathModeEnragePhase_BodyAndTail) ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + if (phase2 || deathModeEnragePhase_BodyAndTail) + { + // Waving beams need to start offset so they cross each other neatly. + float waveSideOffset = Main.rand.NextFloat(9f, 14f); + Vector2 perp = shootDirection.RotatedBy(-MathHelper.PiOver2) * waveSideOffset; + + for (int i = -1; i <= 1; i += 2) + { + Vector2 laserStartPos = vector104 + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); + Projectile godRay = Projectile.NewProjectileDirect(laserStartPos, laserVelocity * 1.1f, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); + + // Tell this Phased God Ray exactly which way it should be waving. + godRay.localAI[1] = i * 0.5f; + } + } + else + Projectile.NewProjectile(vector104, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); + } + } + } + else + { + if (npc.localAI[0] % divisor == 0f && npc.ai[0] % 2f == 0f) + { + Vector2 velocity = Vector2.Zero; + if (movingMines) + { + Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + vector15.Normalize(); + vector15 *= Main.rand.Next(30, 121) * 0.01f; + velocity = vector15; + } + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float split = (splittingMines && npc.ai[0] % 3f == 0f) ? 1f : 0f; + Projectile.NewProjectile(npc.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f); + } + } + } + + // Follow the head + 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; + + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + { + try + { + 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)Math.Atan2(num192, num191) + MathHelper.PiOver2; + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + int num194 = npc.width; + num193 = (num193 - num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; + + if (num191 < 0f) + npc.spriteDirection = -1; + else if (num191 > 0f) + npc.spriteDirection = 1; + } + } + } + #endregion + + #region Ceaseless Void + public static void CeaselessVoidAI(NPC npc, Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + CalamityGlobalNPC.voidBoss = npc.whoAmI; + + Vector2 vector = npc.Center; + + // Percent life remaining + double lifeRatio = npc.life / (double)npc.lifeMax; + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Phases + bool phase2 = lifeRatio <= 0.7; + bool phase3 = lifeRatio <= 0.4; + bool phase4 = lifeRatio <= 0.1; + bool theBigSucc = npc.life / (double)npc.lifeMax <= 0.1; + bool succSoHardThatYouDie = npc.life / (double)npc.lifeMax <= 0.005; + + // Spawn Dark Energies + int darkEnergyAmt = death ? 6 : revenge ? 5 : expertMode ? 4 : 3; + if (phase2) + darkEnergyAmt += 1; + if (phase3) + darkEnergyAmt += 1; + if (phase4) + darkEnergyAmt += 1; + + // Spawn a few Dark Energies as soon as the fight starts + int spacing = 360 / darkEnergyAmt; + int distance2 = 10; + if (npc.ai[2] == 0f) + { + npc.ai[2] = 1f; + for (int i = 0; i < darkEnergyAmt; i++) + { + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 1f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 2f, 0f, 0f); + } + NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 0.5f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 1.5f, 0f, 0f); + } + + // If there are any Dark Energies alive, change AI and don't take damage + bool anyDarkEnergies = NPC.AnyNPCs(ModContent.NPCType()); + bool movingDuringSuccPhase = npc.ai[3] == 0f; + npc.dontTakeDamage = anyDarkEnergies || theBigSucc || movingDuringSuccPhase; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + Player player = Main.player[npc.target]; + + // Speed enrage + bool moveVeryFast = Vector2.Distance(npc.Center, player.Center) > 960f || (!player.ZoneDungeon && !BossRushEvent.BossRushActive && player.position.Y < Main.worldSurface * 16.0); + + // Despawn + if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) + { + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + npc.velocity.Y -= 0.1f; + if (npc.velocity.Y < -12f) + npc.velocity.Y = -12f; + + if (npc.timeLeft < 10) + { + CalamityWorld.DoGSecondStageCountdown = 0; + if (Main.netMode == NetmodeID.Server) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); + netMessage.Write(CalamityWorld.DoGSecondStageCountdown); + netMessage.Send(); + } + } + + if (npc.timeLeft > 60) + npc.timeLeft = 60; + + return; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; + + // Scale multiplier based on nearby active tiles + float tileEnrageMult = BossRushEvent.BossRushActive ? 1.375f : malice ? 1.25f : 1f; + npc.Calamity().CurrentlyEnraged = tileEnrageMult > 1f && !BossRushEvent.BossRushActive; + + // Set AI variable to be used by Dark Energies + npc.ai[1] = tileEnrageMult; + + // Increase projectile fire rate based on number of nearby active tiles + float projectileFireRateMultiplier = MathHelper.Lerp(0.5f, 1.5f, 1f - ((tileEnrageMult - 1f) / 0.5f)); + + // Succ attack + if (!anyDarkEnergies) + { + // This is here because it's used in multiple places + float suckDistance = malice ? 1920f : death ? 1600f : revenge ? 1440f : expertMode ? 1280f : 1040f; + + // Move closer to the target before trying to succ + if (movingDuringSuccPhase) + { + if (Vector2.Distance(vector, player.Center) > 320f || !Collision.CanHit(vector, 1, 1, player.Center, 1, 1)) + Movement(true); + else + npc.ai[3] = 1f; + } + else + { + // Use this to generate more and more dust in final phase + float finalPhaseDustRatio = 1f; + if (succSoHardThatYouDie) + { + finalPhaseDustRatio = 5f; + } + else if (theBigSucc) + { + float amount = (10f - (float)(npc.life / (double)npc.lifeMax) * 100f) / 10f; + finalPhaseDustRatio += MathHelper.Lerp(0f, 2f, amount); + } + + // Slow down + if (npc.velocity.Length() > 0.5f) + npc.velocity *= 0.8f; + else + npc.velocity = Vector2.Zero; + + // Move towards target again if they get outside the succ radius + float moveCloserGateValue = suckDistance * 0.75f; + if (Vector2.Distance(vector, player.Center) > moveCloserGateValue) + npc.ai[3] = 0f; + + // Ceaseless Void sucks in dark energy in different patterns + // This attack also sucks in all players that are within reach of the succ + int dustRings = 3; + for (int h = 0; h < dustRings; h++) + { + float distanceDivisor = h + 1f; + float dustDistance = suckDistance / distanceDivisor; + int numDust = (int)(0.1f * MathHelper.TwoPi * dustDistance); + float angleIncrement = MathHelper.TwoPi / (float)numDust; + Vector2 dustOffset = new Vector2(dustDistance, 0f); + dustOffset = dustOffset.RotatedByRandom(MathHelper.TwoPi); + + int var = (int)(dustDistance / finalPhaseDustRatio); + float dustVelocity = 24f / distanceDivisor * finalPhaseDustRatio; + for (int i = 0; i < numDust; i++) + { + if (Main.rand.NextBool(var)) + { + dustOffset = dustOffset.RotatedBy(angleIncrement); + int dust = Dust.NewDust(vector, 1, 1, ModContent.DustType()); + Main.dust[dust].position = vector + dustOffset; + Main.dust[dust].fadeIn = 1f; + Main.dust[dust].velocity = Vector2.Normalize(vector - Main.dust[dust].position) * dustVelocity; + Main.dust[dust].scale = 3f - h; + } + } + } + + float succPower = 0.1f + finalPhaseDustRatio * 0.1f; + for (int i = 0; i < Main.maxPlayers; i++) + { + float distance = Vector2.Distance(Main.player[i].Center, vector); + if (distance < suckDistance && Main.player[i].grappling[0] == -1) + { + if (Collision.CanHit(vector, 1, 1, Main.player[i].Center, 1, 1)) + { + float distanceRatio = distance / suckDistance; + float multiplier = 1f - distanceRatio; + + if (Main.player[i].Center.X < vector.X) + Main.player[i].velocity.X += succPower * multiplier; + else + Main.player[i].velocity.X -= succPower * multiplier; + + if (Main.player[i].Center.Y < vector.Y) + Main.player[i].velocity.Y += succPower * multiplier; + else + Main.player[i].velocity.Y -= succPower * multiplier; + } + } + } + + // Projectiles + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Slowly die in final phase and then implode + // This phase lasts 20 seconds + if (theBigSucc && calamityGlobalNPC.newAI[1] % 60f == 0f) + { + int damageAmt = npc.lifeMax / 200; + npc.life -= damageAmt; + npc.HealEffect(-damageAmt, true); + + if (npc.life <= 0) + { + npc.life = 0; + npc.HitEffect(); + npc.checkDead(); + } + + npc.netUpdate = true; + } + + // Beam Portals + if (calamityGlobalNPC.newAI[1] == 0f) + { + int numBeamPortals = malice ? 3 : revenge ? 2 : 1; + float degrees = 360 / numBeamPortals; + float beamPortalDistance = malice ? 800f : death ? 960f : revenge ? 1000f : expertMode ? 1040f : 1080f; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + for (int i = 0; i < numBeamPortals; i++) + { + float ai1 = i * degrees; + Projectile.NewProjectile(player.Center.X + (float)(Math.Sin(i * degrees) * beamPortalDistance), player.Center.Y + (float)(Math.Cos(i * degrees) * beamPortalDistance), 0f, 0f, type, damage, 0f, player.whoAmI, ai1, 0f); + } + } + + // Use this timer to lessen Dark Energy projectile rate of fire while Beam Portals are active + float beamPortalTimeLeft = 600f; + bool summonLessDarkEnergies = false; + if (calamityGlobalNPC.newAI[1] < beamPortalTimeLeft) + { + calamityGlobalNPC.newAI[1] += 1f; + summonLessDarkEnergies = true; + } + else if (theBigSucc) + calamityGlobalNPC.newAI[1] += 1f; + + // Suck in Dark Energy projectiles from far away + calamityGlobalNPC.newAI[3] += 1f; + float darkEnergySpiralGateValue = (summonLessDarkEnergies ? 36f : 12f) * projectileFireRateMultiplier; + if (calamityGlobalNPC.newAI[3] >= darkEnergySpiralGateValue) + { + calamityGlobalNPC.newAI[3] = 0f; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + bool normalSpread = npc.localAI[0] % 2f == 0f; + float speed = 0.5f; + int totalProjectiles = 4; + float radians = MathHelper.TwoPi / totalProjectiles; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(speed * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = normalSpread ? new Vector2(0f, -speed) : new Vector2(-velocityX, -speed); + float radialOffset = MathHelper.ToRadians(npc.localAI[1]); + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 spawnVector = vector + Vector2.Normalize(spinningPoint.RotatedBy(radians * i + radialOffset)) * suckDistance; + Vector2 velocity = Vector2.Normalize(vector - spawnVector) * speed; + Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); + } + npc.localAI[1] += 10f; + } + + // Summon some extra projectiles in Expert Mode + if (phase2 && expertMode && !summonLessDarkEnergies) + { + npc.localAI[2] += 1f; + if (npc.localAI[2] >= 60f * projectileFireRateMultiplier) + { + npc.localAI[2] = 0f; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + bool normalSpread = npc.localAI[0] % 2f != 0f; + float speed = 2f; + int totalProjectiles = 2; + float radians = MathHelper.TwoPi / totalProjectiles; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(speed * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = normalSpread ? new Vector2(0f, -speed) : new Vector2(-velocityX, -speed); + float radialOffset = MathHelper.ToRadians(npc.localAI[1] * 0.25f); + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 spawnVector = vector + Vector2.Normalize(spinningPoint.RotatedBy(radians * i + radialOffset)) * suckDistance; + Vector2 velocity = Vector2.Normalize(vector - spawnVector) * speed; + Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); + } + } + } + + // Summon some extra projectiles in Revengeance Mode + if (phase4 && revenge && !summonLessDarkEnergies) + { + npc.localAI[3] += 1f; + if (npc.localAI[3] >= 90f * projectileFireRateMultiplier) + { + npc.localAI[3] = 0f; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + bool normalSpread = npc.localAI[0] % 2f == 0f; + float speed = 4f; + int totalProjectiles = 2; + float radians = MathHelper.TwoPi / totalProjectiles; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(speed * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = normalSpread ? new Vector2(0f, -speed) : new Vector2(-velocityX, -speed); + float radialOffset = MathHelper.ToRadians(npc.localAI[1] * 0.25f); + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 spawnVector = vector + Vector2.Normalize(spinningPoint.RotatedBy(radians * i + radialOffset)) * suckDistance; + Vector2 velocity = Vector2.Normalize(vector - spawnVector) * speed; + Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); + } + } + } + } + } + } + else + { + Movement(false); + + // Count up all Dark Energy HP values + int totalDarkEnergyHP = 0; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC darkEnergy = Main.npc[i]; + if (darkEnergy.active && darkEnergy.type == ModContent.NPCType()) + totalDarkEnergyHP += darkEnergy.life; + } + + // Destroy all Dark Energies if their total HP is below 20% + int darkEnergyMaxHP = BossRushEvent.BossRushActive ? 44000 : (CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel1) ? 12000 : 3000; + int totalDarkEnergiesSpawned = darkEnergyAmt * 3 + 2; + int totalDarkEnergyMaxHP = darkEnergyMaxHP * totalDarkEnergiesSpawned; + int succPhaseGateValue = (int)(totalDarkEnergyMaxHP * 0.2); + if (totalDarkEnergyHP < succPhaseGateValue) + { + Main.PlaySound(SoundID.NPCDeath44, vector); + + // Kill all Dark Energies + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC darkEnergy = Main.npc[i]; + if (darkEnergy.active && darkEnergy.type == ModContent.NPCType()) + { + darkEnergy.HitEffect(); + darkEnergy.active = false; + darkEnergy.netUpdate = true; + } + } + + // Generate a dust explosion + int dustAmt = 30; + int random = 3; + for (int j = 0; j < 10; j++) + { + random += j * 2; + int dustAmtSpawned = 0; + int scale = random * 13; + float dustPositionX = vector.X - (scale / 2); + float dustPositionY = vector.Y - (scale / 2); + while (dustAmtSpawned < dustAmt) + { + float dustVelocityX = Main.rand.Next(-random, random); + float dustVelocityY = Main.rand.Next(-random, random); + float dustVelocityScalar = random * 2f; + float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); + dustVelocity = dustVelocityScalar / dustVelocity; + dustVelocityX *= dustVelocity; + dustVelocityY *= dustVelocity; + int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].position.X = vector.X; + Main.dust[dust].position.Y = vector.Y; + Main.dust[dust].position.X += Main.rand.Next(-10, 11); + Main.dust[dust].position.Y += Main.rand.Next(-10, 11); + Main.dust[dust].velocity.X = dustVelocityX; + Main.dust[dust].velocity.Y = dustVelocityY; + dustAmtSpawned++; + } + } + } + } + + // Basic movement towards a location + void Movement(bool succ) + { + float velocity = moveVeryFast ? 25f : BossRushEvent.BossRushActive ? 15f : ((expertMode ? 7.5f : 6f) + (float)(death ? 2f * (1D - lifeRatio) : 0f)) * tileEnrageMult; + float acceleration = moveVeryFast ? 0.75f : malice ? 0.3f : death ? 0.2f : expertMode ? 0.16f : 0.12f; + + // Increase speed dramatically in succ phase + if (succ) + { + velocity *= 2f; + acceleration *= 2f; + } + + Vector2 moveTo = new Vector2(player.Center.X - vector.X, player.Center.Y - vector.Y); + + // Move between 8 different positions around the player, in order + float maxDistance = 320f; + Vector2 moveToOffset = succ ? Vector2.Zero : new Vector2(0f, -maxDistance); + if (!succ) + { + // Move to a new location every few seconds + calamityGlobalNPC.newAI[2] += 1f; + float newPositionGateValue = malice ? 180f : death ? 270f : revenge ? 300f : expertMode ? 360f : 480f; + if (calamityGlobalNPC.newAI[2] > newPositionGateValue) + { + calamityGlobalNPC.newAI[2] = 0f; + + npc.ai[0] += 1f; + if (npc.ai[0] > 7f) + npc.ai[0] = 0f; + } + + switch ((int)npc.ai[0]) + { + case 0: + break; + case 1: + moveToOffset.X = -maxDistance; + break; + case 2: + moveToOffset.X = -maxDistance; + moveToOffset.Y = 0f; + break; + case 3: + moveToOffset.X = -maxDistance; + moveToOffset.Y = maxDistance; + break; + case 4: + moveToOffset.Y = maxDistance; + break; + case 5: + moveToOffset.X = maxDistance; + moveToOffset.Y = maxDistance; + break; + case 6: + moveToOffset.X = maxDistance; + moveToOffset.Y = 0f; + break; + case 7: + moveToOffset.X = maxDistance; + break; + } + } + + moveTo += moveToOffset; + + float distance = (float)Math.Sqrt(moveTo.X * moveTo.X + moveTo.Y * moveTo.Y); + + distance = velocity / distance; + moveTo.X *= distance; + moveTo.Y *= distance; + + if (npc.velocity.X < moveTo.X) + { + npc.velocity.X += acceleration; + if (npc.velocity.X < 0f && moveTo.X > 0f) + npc.velocity.X += acceleration; + } + else if (npc.velocity.X > moveTo.X) + { + npc.velocity.X -= acceleration; + if (npc.velocity.X > 0f && moveTo.X < 0f) + npc.velocity.X -= acceleration; + } + if (npc.velocity.Y < moveTo.Y) + { + npc.velocity.Y += acceleration; + if (npc.velocity.Y < 0f && moveTo.Y > 0f) + npc.velocity.Y += acceleration; + } + else if (npc.velocity.Y > moveTo.Y) + { + npc.velocity.Y -= acceleration; + if (npc.velocity.Y > 0f && moveTo.Y < 0f) + npc.velocity.Y -= acceleration; + } + } + + // Spawn more Dark Energies as the fight progresses + if (calamityGlobalNPC.newAI[0] == 0f && npc.life > 0) + calamityGlobalNPC.newAI[0] = npc.lifeMax; + + if (npc.life > 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int healthGateValue = (int)(npc.lifeMax * 0.3); + if ((npc.life + healthGateValue) < calamityGlobalNPC.newAI[0]) + { + npc.TargetClosest(); + calamityGlobalNPC.newAI[0] = npc.life; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.ai[3] = 0f; + npc.localAI[0] += 1f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + npc.localAI[3] = 0f; + + if (phase4) + { + for (int i = 0; i < darkEnergyAmt; i++) + { + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 2f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 4f, 0f, 0f); + } + NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 1f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 3f, 0f, 0f); + } + else if (phase3) + { + for (int i = 0; i < darkEnergyAmt; i++) + { + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 1.5f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 3f, 0f, 0f); + } + NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 0.5f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 2f, 0f, 0f); + } + else + { + for (int i = 0; i < darkEnergyAmt; i++) + { + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 1f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(i * spacing) * distance2)), (int)(vector.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 2f, 0f, 0f); + } + NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 1.5f, 0f, 0f); + NPC.NewNPC((int)(vector.X + (Math.Sin(0) * distance2)), (int)(vector.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 2.5f, 0f, 0f); + } + + // Despawn potentially hazardous projectiles when entering a new phase + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile projectile = Main.projectile[i]; + if (projectile.active) + { + if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + { + if (projectile.timeLeft > 30) + projectile.timeLeft = 30; + } + } + } + } + } + } + } + #endregion + + #region Bumblebirb + public static void BumblebirbAI(NPC npc, Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + Player player = Main.player[npc.target]; + + // Variables + float rotationMult = 3f; + float rotationAmt = 0.03f; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + Vector2 vector = npc.Center; + + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = npc.ai[0] == 3f || npc.ai[0] == 3.1f || npc.ai[0] == 3.2f; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + + // If target is outside the jungle for more than 5 seconds, enrage + if (!player.ZoneJungle) + { + if (npc.localAI[1] < CalamityGlobalNPC.biomeEnrageTimerMax) + npc.localAI[1] += 1f; + } + else + npc.localAI[1] = 0f; + + // If dragonfolly is off screen, enrage for the next couple attacks + if (Vector2.Distance(player.Center, vector) > 1200f) + npc.localAI[2] = 2f; + + // Enrage scale + float enrageScale = death ? 1.5f : 1f; + if (npc.localAI[1] >= CalamityGlobalNPC.biomeEnrageTimerMax || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + if (npc.localAI[2] > 0f || malice) + enrageScale += 1f; + + if (enrageScale > 3f) + enrageScale = 3f; + + // Despawn + if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + + if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) + { + npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; + + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + npc.velocity.Y -= 0.2f; + if (npc.velocity.Y < -12f) + npc.velocity.Y = -12f; + + if (npc.timeLeft > 60) + npc.timeLeft = 60; + + if (npc.ai[0] != 0f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.netUpdate = true; + } + + return; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Phases + bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f); + bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f) && expertMode; + + float birbSpawnPhaseTimer = 180f; + float newPhaseTimer = 180f; + bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || + (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); + + calamityGlobalNPC.DR = (phaseSwitchPhase || npc.ai[0] == 5f || (enrageScale == 3f && !malice)) ? 0.55f : 0.1f; + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phaseSwitchPhase || npc.ai[0] == 5f || (enrageScale == 3f && !malice); + + if (phaseSwitchPhase) + { + if (npc.velocity.X < 0f) + npc.direction = -1; + else if (npc.velocity.X > 0f) + npc.direction = 1; + + npc.spriteDirection = npc.direction; + npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; + + if (phase3) + { + calamityGlobalNPC.newAI[1] += 1f; + + // Sound + if (calamityGlobalNPC.newAI[1] == newPhaseTimer - 60f) + { + SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_BetsyScream, (int)npc.position.X, (int)npc.position.Y); + if (sound != null) + { + sound.Pitch = 0.25f; + } + } + + if (calamityGlobalNPC.newAI[1] >= newPhaseTimer) + { + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 1f; + calamityGlobalNPC.newAI[3] = 1f; + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.SyncExtraAI(); + npc.netUpdate = true; + } + } + else + { + calamityGlobalNPC.newAI[0] += 1f; + + // Sound + if (calamityGlobalNPC.newAI[0] == newPhaseTimer - 60f) + { + SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_BetsyScream, (int)npc.position.X, (int)npc.position.Y); + if (sound != null) + { + sound.Pitch = 0.25f; + } + } + + if (calamityGlobalNPC.newAI[0] >= newPhaseTimer) + { + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[2] = 1f; + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.SyncExtraAI(); + npc.netUpdate = true; + } + } + + Vector2 value52 = player.Center - npc.Center; + float scaleFactor16 = 4f + value52.Length() / 100f; + float num1308 = 25f; + value52.Normalize(); + value52 *= scaleFactor16; + npc.velocity = (npc.velocity * (num1308 - 1f) + value52) / num1308; + return; + } + + // Max spawn amount + int maxBirbs = revenge ? 3 : 2; + + // Variable for charging + float chargeDistance = 600f; + if (phase2) + chargeDistance -= 50f; + if (phase3) + chargeDistance -= 50f; + chargeDistance -= (enrageScale - 1f) * 100f; + + // Phase switch + if (npc.ai[0] == 0f) + { + if (npc.Center.X < player.Center.X - 2f) + npc.direction = 1; + if (npc.Center.X > player.Center.X + 2f) + npc.direction = -1; + + // Direction and rotation + npc.spriteDirection = npc.direction; + npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt * 1.25f) / 10f; + + // Fly to target if target is too far away, otherwise get close to target and then slow down + Vector2 value51 = player.Center - npc.Center; + value51.Y -= 200f; + if (value51.Length() > 2800f) + { + npc.TargetClosest(); + npc.ai[0] = 1f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + else if (value51.Length() > 240f) + { + float scaleFactor15 = 12f + (enrageScale - 1f) * 6f; + float num1306 = 30f; + value51.Normalize(); + value51 *= scaleFactor15; + npc.velocity = (npc.velocity * (num1306 - 1f) + value51) / num1306; + } + else if (npc.velocity.Length() > 2f) + npc.velocity *= 0.95f; + else if (npc.velocity.Length() < 1f) + npc.velocity *= 1.05f; + + // Phase switch + npc.ai[1] += 1f; + if (npc.ai[1] >= 30f && Main.netMode != NetmodeID.MultiplayerClient) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + + while (npc.ai[0] == 0f) + { + if (phase2) + npc.localAI[0] += 1f; + + bool canHit = Collision.CanHit(npc.Center, 1, 1, player.Center, 1, 1); + + if (npc.localAI[0] >= (phase3 ? 7 : 9) && canHit) + { + npc.TargetClosest(); + npc.ai[0] = 5f; + npc.localAI[0] = 0f; + + // Decrease the feather variable, feathers can be used again if it's at 0 + if (npc.ai[3] > 0f) + npc.ai[3] -= 1f; + + // Decrease enraged attacks by 1 + if (npc.localAI[2] > 0f) + npc.localAI[2] -= 1f; + + // Decrease amount of attacks until able to spawn small birbs again + if (npc.localAI[3] > 0f) + npc.localAI[3] -= 1f; + } + else + { + int num1307 = phase2 ? Main.rand.Next(2) + 1 : Main.rand.Next(3); + if (phase3) + num1307 = 1; + + float featherVelocity = 2f + (enrageScale - 1f); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + + if (num1307 == 0 && canHit && npc.localAI[3] == 0f) + { + npc.TargetClosest(); + npc.ai[0] = 2f; + + // Decrease the feather variable, feathers can be used again if it's at 0 + if (npc.ai[3] > 0f) + npc.ai[3] -= 1f; + + // Decrease enraged attacks by 1 + if (npc.localAI[2] > 0f) + npc.localAI[2] -= 1f; + + // Birb will do at least 1 different attack before entering this phase again + npc.localAI[3] = 1f; + } + else if (num1307 == 1) + { + npc.TargetClosest(); + npc.ai[0] = 3f; + + // Decrease enraged attacks by 1 + if (npc.localAI[2] > 0f) + npc.localAI[2] -= 1f; + + // Decrease amount of attacks until able to use other attacks again + if (npc.localAI[3] > 0f) + npc.localAI[3] -= 1f; + + if (phase2 && npc.ai[3] == 0f) + { + npc.ai[3] = 3f; + Main.PlaySound(SoundID.Item102, (int)player.position.X, (int)player.position.Y); + int totalProjectiles = 40; + float radians = MathHelper.TwoPi / totalProjectiles; + int distance = 800; + bool spawnRight = player.velocity.X > 0f; + for (int i = 0; i < totalProjectiles; i++) + { + if (spawnRight) + { + if (i >= (int)(totalProjectiles * 0.125) && i <= (int)(totalProjectiles * 0.375)) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); + } + } + else + { + if (i >= (int)(totalProjectiles * 0.625) && i <= (int)(totalProjectiles * 0.875)) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); + } + } + } + } + else + { + // Decrease the feather variable, feathers can be used again if it's at 0 + if (npc.ai[3] > 0f) + npc.ai[3] -= 1f; + } + } + else if (NPC.CountNPCS(ModContent.NPCType()) < maxBirbs && npc.localAI[3] == 0f) + { + npc.TargetClosest(); + npc.ai[0] = 4f; + + // Birb will do at least 2 different attacks before entering this phase again + npc.localAI[3] = 2f; + + // Decrease enraged attacks by 1 + if (npc.localAI[2] > 0f) + npc.localAI[2] -= 1f; + + if (npc.ai[3] == 0f) + { + npc.ai[3] = 3f; + Main.PlaySound(SoundID.Item102, (int)player.position.X, (int)player.position.Y); + int totalProjectiles = phase2 ? 40 : 48; + float radians = MathHelper.TwoPi / totalProjectiles; + int distance = phase2 ? 1200 : 1320; + bool spawnRight = player.velocity.X > 0f; + for (int i = 0; i < totalProjectiles; i++) + { + if (spawnRight) + { + if (i >= totalProjectiles / 2) + break; + + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); + } + else + { + if (i >= totalProjectiles / 2) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(spawnVector, velocity, type, damage, 0f, Main.myPlayer); + } + } + } + } + else + { + // Decrease the feather variable, feathers can be used again if it's at 0 + if (npc.ai[3] > 0f) + npc.ai[3] -= 1f; + } + } + } + } + + npc.netUpdate = true; + npc.SyncExtraAI(); + } + } + + // Fly to target + else if (npc.ai[0] == 1f) + { + if (npc.velocity.X < 0f) + npc.direction = -1; + else if (npc.velocity.X > 0f) + npc.direction = 1; + + npc.spriteDirection = npc.direction; + npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; + + Vector2 value52 = player.Center - npc.Center; + if (value52.Length() < 800f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + { + npc.TargetClosest(); + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.netUpdate = true; + npc.SyncExtraAI(); + } + + float velocity = 14f + (enrageScale - 1f) * 4f; + float scaleFactor16 = velocity + value52.Length() / 100f; + float num1308 = 25f; + value52.Normalize(); + value52 *= scaleFactor16; + npc.velocity = (npc.velocity * (num1308 - 1f) + value52) / num1308; + } + + // Fly towards target quickly + else if (npc.ai[0] == 2f) + { + if (npc.target < 0 || !player.active || player.dead) + { + npc.TargetClosest(); + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.netUpdate = true; + npc.SyncExtraAI(); + } + + if (player.Center.X - 10f < npc.Center.X) + npc.direction = -1; + else if (player.Center.X + 10f > npc.Center.X) + npc.direction = 1; + + npc.spriteDirection = npc.direction; + npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 1.25f) / 5f; + + Vector2 value53 = player.Center - npc.Center; + value53.Y -= 20f; + npc.ai[2] += 0.0222222228f; + if (expertMode) + npc.ai[2] += 0.0166666675f; + + float velocity = 8f + (enrageScale - 1f) * 2f; + float scaleFactor17 = velocity + npc.ai[2] + value53.Length() / 120f; + float num1309 = 20f; + value53.Normalize(); + value53 *= scaleFactor17; + npc.velocity = (npc.velocity * (num1309 - 1f) + value53) / num1309; + + npc.ai[1] += 1f; + if (npc.ai[1] >= 120f || !Collision.CanHit(npc.Center, 1, 1, player.Center, 1, 1)) + { + npc.TargetClosest(); + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.netUpdate = true; + npc.SyncExtraAI(); + } + } + + // Line up charge + else if (npc.ai[0] == 3f) + { + if (npc.velocity.X < 0f) + npc.direction = -1; + else + npc.direction = 1; + + npc.spriteDirection = npc.direction; + npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; + + Vector2 value54 = player.Center - npc.Center; + value54.Y -= 12f; + if (npc.Center.X > player.Center.X) + value54.X += chargeDistance; + else + value54.X -= chargeDistance; + + float verticalDistanceGateValue = (phase3 ? 100f : 20f) + (enrageScale - 1f) * 20f; + if (Math.Abs(npc.Center.X - player.Center.X) > chargeDistance - 50f && Math.Abs(npc.Center.Y - player.Center.Y) < verticalDistanceGateValue) + { + npc.ai[0] = 3.1f; + npc.ai[1] = 0f; + npc.netUpdate = true; + npc.SyncExtraAI(); + } + + npc.ai[1] += 0.0333333351f; + float velocity = 16f + (enrageScale - 1f) * 4f; + float scaleFactor18 = velocity + npc.ai[1]; + float num1310 = 4f; + value54.Normalize(); + value54 *= scaleFactor18; + npc.velocity = (npc.velocity * (num1310 - 1f) + value54) / num1310; + } + + // Prepare to charge + else if (npc.ai[0] == 3.1f) + { + npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; + + Vector2 vector206 = player.Center - npc.Center; + vector206.Y -= 12f; + float scaleFactor19 = 28f + (enrageScale - 1f) * 4f; + float num1311 = 8f; + vector206.Normalize(); + vector206 *= scaleFactor19; + npc.velocity = (npc.velocity * (num1311 - 1f) + vector206) / num1311; + + if (npc.velocity.X < 0f) + npc.direction = -1; + else + npc.direction = 1; + + npc.spriteDirection = npc.direction; + + npc.ai[1] += 1f; + if (npc.ai[1] > 10f) + { + npc.velocity = vector206; + + if (npc.velocity.X < 0f) + npc.direction = -1; + else + npc.direction = 1; + + npc.ai[0] = 3.2f; + npc.ai[1] = npc.direction; + npc.netUpdate = true; + npc.SyncExtraAI(); + } + } + + // Charge + else if (npc.ai[0] == 3.2f) + { + npc.ai[2] += 0.0333333351f; + float velocity = 28f + (enrageScale - 1f) * 4f; + npc.velocity.X = (velocity + npc.ai[2]) * npc.ai[1]; + + if ((npc.ai[1] > 0f && npc.Center.X > player.Center.X + (chargeDistance - 140f)) || (npc.ai[1] < 0f && npc.Center.X < player.Center.X - (chargeDistance - 140f))) + { + if (!Collision.SolidCollision(npc.position, npc.width, npc.height)) + { + npc.TargetClosest(); + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.netUpdate = true; + } + else if (Math.Abs(npc.Center.X - player.Center.X) > chargeDistance + 200f) + { + npc.TargetClosest(); + npc.ai[0] = 1f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.netUpdate = true; + } + } + + npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; + } + + // Birb spawn + else if (npc.ai[0] == 4f) + { + if (npc.ai[1] == 0f) + { + Vector2 destination2 = player.Center + new Vector2(0f, -200f); + Vector2 desiredVelocity2 = npc.SafeDirectionTo(destination2, -Vector2.UnitY) * 18f; + npc.SimpleFlyMovement(desiredVelocity2, 1.5f); + + if (npc.velocity.X < 0f) + npc.direction = -1; + else + npc.direction = 1; + + npc.spriteDirection = npc.direction; + + npc.ai[2] += 1f; + if (npc.Distance(player.Center) < 600f || npc.ai[2] >= 180f) + { + npc.ai[1] = 1f; + npc.netUpdate = true; + } + } + else + { + if (npc.ai[1] < 90f) + npc.velocity *= 0.95f; + else + npc.velocity *= 0.98f; + + if (npc.ai[1] == 90f) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y /= 3f; + + npc.velocity.Y -= 3f; + } + + // Sound + if (npc.ai[1] == birbSpawnPhaseTimer - 60f) + { + SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_BetsyScream, (int)npc.position.X, (int)npc.position.Y); + if (sound != null) + { + sound.Pitch = 0.25f; + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + bool spawnFlag = NPC.CountNPCS(ModContent.NPCType()) < maxBirbs && (npc.ai[1] == 140f || (revenge && npc.ai[1] == 155f) || npc.ai[1] == 170f); + if (spawnFlag) + { + Vector2 vector7 = npc.Center + (MathHelper.TwoPi * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 50f * (0.6f + Main.rand.NextFloat() * 0.4f); + if (Vector2.Distance(vector7, player.Center) > 150f) + NPC.NewNPC((int)vector7.X, (int)vector7.Y, ModContent.NPCType(), npc.whoAmI); + npc.netUpdate = true; + } + } + + npc.ai[1] += 1f; + } + + if (npc.ai[1] >= birbSpawnPhaseTimer) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Spit homing aura sphere + else if (npc.ai[0] == 5f) + { + // Velocity + npc.velocity *= 0.98f; + npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; + + // Play sound + float aiGateValue = 120f; + if (npc.ai[1] == aiGateValue - 30f) + { + Main.PlaySound(SoundID.DD2_BetsyFireballShot, (int)npc.position.X, (int)npc.position.Y); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 vector7 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + vector; + float ai0 = (phase3 ? 2f : 0f) + (enrageScale - 1f); + if (ai0 > 3f) + ai0 = 3f; + Projectile.NewProjectile(vector7.X, vector7.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, ai0, npc.target + 1); + npc.netUpdate = true; + } + } + + npc.ai[1] += 1f; + if (npc.ai[1] >= aiGateValue) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.netUpdate = true; + } + } + } + + public static void Bumblebirb2AI(NPC npc, Mod mod, bool bossMinion) + { Player player = Main.player[npc.target]; Vector2 vector = npc.Center; - float rotationMult = 4f; - float rotationAmt = 0.04f; + float rotationMult = 4f; + float rotationAmt = 0.04f; - if (Vector2.Distance(player.Center, vector) > 5600f) + if (Vector2.Distance(player.Center, vector) > 5600f) { if (npc.timeLeft > 5) { @@ -5351,1781 +5351,1781 @@ namespace CalamityMod.NPCs } } } - } - #endregion - - #region Old Duke - public static void OldDukeAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - npc.Calamity().canBreakPlayerDefense = true; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Variables - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - bool tired = calamityGlobalNPC.newAI[1] == 1f; - bool phase2 = lifeRatio <= (death ? 0.8f : revenge ? 0.7f : 0.5f); - bool phase3 = lifeRatio <= (death ? 0.5f : (revenge ? 0.35f : 0.2f)) && expertMode; - bool phase2AI = npc.ai[0] > 4f; - bool phase3AI = npc.ai[0] > 9f; - bool charging = npc.ai[3] < 10f; - float pie = (float)Math.PI; - - if (calamityGlobalNPC.newAI[0] >= 300f) - calamityGlobalNPC.newAI[1] = 1f; - - // Adjust stats - calamityGlobalNPC.DR = tired ? 0f : 0.5f; - npc.defense = tired ? 0 : npc.defDefense; - if (phase3AI) - { - npc.damage = (int)(npc.defDamage * 1.2f); - npc.defense = tired ? 0 : npc.defDefense - 40; - } - else if (phase2AI) - { - npc.damage = (int)(npc.defDamage * 1.1f); - npc.defense = tired ? 0 : npc.defDefense - 20; - } - else - { - npc.damage = npc.defDamage; - } - - int idlePhaseTimer = expertMode ? 55 : 60; - float idlePhaseAcceleration = expertMode ? 0.75f : 0.7f; - float idlePhaseVelocity = expertMode ? 14f : 13f; - if (phase3AI) - { - idlePhaseAcceleration = expertMode ? 0.6f : 0.55f; - idlePhaseVelocity = expertMode ? 12f : 11f; - } - else if (phase2AI & charging) - { - idlePhaseAcceleration = expertMode ? 0.8f : 0.75f; - idlePhaseVelocity = expertMode ? 15f : 14f; - } - - int chargeTime = expertMode ? 34 : 36; - float chargeVelocity = expertMode ? 20f : 19f; - if (phase3AI) - { - chargeTime = expertMode ? 28 : 30; - chargeVelocity = expertMode ? 26f : 25f; - } - else if (charging & phase2AI) - { - chargeTime = expertMode ? 31 : 33; - chargeVelocity = expertMode ? 24f : 23f; - } - - if (malice) - { - idlePhaseTimer = 35; - idlePhaseAcceleration *= 1.25f; - idlePhaseVelocity *= 1.2f; - chargeTime -= 3; - chargeVelocity *= 1.25f; - } - else if (death) - { - idlePhaseTimer = 51; - idlePhaseAcceleration *= 1.05f; - idlePhaseVelocity *= 1.05f; - chargeTime -= 2; - chargeVelocity *= 1.1f; - } - else if (revenge) - { - idlePhaseTimer = 53; - idlePhaseAcceleration *= 1.025f; - idlePhaseVelocity *= 1.025f; - chargeTime -= 1; - chargeVelocity *= 1.05f; - } - - if (tired) - idlePhaseVelocity *= 0.25f; - - // Variables - int toothBallBelchPhaseTimer = malice ? 35 : death ? 90 : 120; - int toothBallBelchPhaseDivisor = malice ? 7 : death ? 18 : 24; - float toothBallBelchPhaseAcceleration = malice ? 0.95f : death ? 0.6f : 0.55f; - float toothBallBelchPhaseVelocity = malice ? 14f : death ? 10f : 9f; - float goreVelocityX = death ? 8f : revenge ? 7.5f : expertMode ? 7f : 6f; - float goreVelocityY = death ? 10.5f : revenge ? 10f : expertMode ? 9.5f : 8f; - float sharkronVelocity = malice ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; - int num9 = 120; - int num10 = 180; - int num12 = 30; - int num13 = malice ? 35 : death ? 90 : 120; - int toothBallSpinPhaseDivisor = malice ? 7 : death ? 18 : 24; - float spinTime = num13 / 2; - float toothBallSpinToothBallVelocity = malice ? 14f : death ? 9.5f : 9f; - float scaleFactor4 = 22f; - float num15 = MathHelper.TwoPi / spinTime; - int num16 = 75; - - Vector2 vector = npc.Center; - Player player = Main.player[npc.target]; - - // Get target - if (npc.target < 0 || npc.target == 255 || player.dead || !player.active) - { - npc.TargetClosest(); - player = Main.player[npc.target]; - npc.netUpdate = true; - } - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(player.Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - // Despawn - if (player.dead || Vector2.Distance(player.Center, vector) > 8800f) - { - npc.TargetClosest(); - - npc.velocity.Y -= 0.4f; - - if (npc.timeLeft > 10) - npc.timeLeft = 10; - - if (npc.timeLeft == 1) - { - CalamityWorld.acidRainPoints = 0; - CalamityWorld.triedToSummonOldDuke = false; - AcidRainEvent.UpdateInvasion(false); - npc.timeLeft = 0; - } - - if (npc.ai[0] > 4f) - npc.ai[0] = 5f; - else - npc.ai[0] = 0f; - - npc.ai[2] = 0f; - } - - if (tired) - { - npc.Calamity().canBreakPlayerDefense = false; - - npc.damage /= 4; - - // Play tired sound - if (calamityGlobalNPC.newAI[0] % 60f == 0f) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeHuff"), player.Center); - - calamityGlobalNPC.newAI[0] -= malice ? 1.5f : 1f; - if (calamityGlobalNPC.newAI[0] <= 0f) - calamityGlobalNPC.newAI[1] = 0f; - } - - // Enrage variable - bool enrage = !BossRushEvent.BossRushActive && - (player.position.Y < 300f || player.position.Y > Main.worldSurface * 16.0 || - (player.position.X > 8000f && player.position.X < (Main.maxTilesX * 16 - 8000))); - - // Enrage - if (enrage) - { - if (npc.localAI[1] > 0f) - npc.localAI[1] -= 1f; - } - else - npc.localAI[1] = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = npc.localAI[1] <= 0f; - - npc.Calamity().CurrentlyEnraged = biomeEnraged || malice; - - // Increased DR while transitioning phases and not tired - if (!tired) - calamityGlobalNPC.DR = (npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f) ? 0.75f : 0.5f; - - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f; - - // Enrage - if (biomeEnraged) - { - toothBallBelchPhaseTimer = 30; - toothBallBelchPhaseDivisor = 6; - toothBallBelchPhaseAcceleration = 1f; - toothBallBelchPhaseVelocity = 15f; - goreVelocityX = 12f; - goreVelocityY = 16f; - sharkronVelocity = 20f; - idlePhaseTimer = 20; - idlePhaseAcceleration = 1.2f; - idlePhaseVelocity = 20f; - chargeTime = 25; - chargeVelocity += 8f; - toothBallSpinPhaseDivisor = 6; - toothBallSpinToothBallVelocity = 15f; - npc.damage = npc.defDamage * 2; - npc.defense = npc.defDefense * 3; - } - - // Set variables for spawn effects - if (npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - npc.alpha = 255; - npc.rotation = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[0] = -1f; - npc.netUpdate = true; - } - } - - // Rotation - float rateOfRotation = 0.04f; - if (npc.ai[0] == 1f || npc.ai[0] == 6f || npc.ai[0] == 7f || npc.ai[0] == 14f) - rateOfRotation = 0f; - if (npc.ai[0] == 3f || npc.ai[0] == 4f) - rateOfRotation = 0.01f; - if (npc.ai[0] == 8f || npc.ai[0] == 13f) - rateOfRotation = 0.05f; - - Vector2 rotationVector = player.Center - vector; - if (calamityGlobalNPC.newAI[1] != 1f && !player.dead) - { - // Rotate to show direction of predictive charge - if (npc.ai[0] == 0f && !phase2) - { - if (npc.ai[3] < 6f) - { - rateOfRotation = 0.1f; - rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - vector) * chargeVelocity; - } - } - else if (npc.ai[0] == 5f && !phase3) - { - if (npc.ai[3] < 4f) - { - rateOfRotation = 0.1f; - rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - vector) * chargeVelocity; - } - } - else if (npc.ai[0] == 10f) - { - if (npc.ai[3] < 8f && npc.ai[3] != 1f && npc.ai[3] != 4f) - { - rateOfRotation = 0.1f; - rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - vector) * chargeVelocity; - } - } - } - - float num17 = (float)Math.Atan2(rotationVector.Y, rotationVector.X); - if (npc.spriteDirection == 1) - num17 += pie; - if (num17 < 0f) - num17 += MathHelper.TwoPi; - if (num17 > MathHelper.TwoPi) - num17 -= MathHelper.TwoPi; - if (npc.ai[0] == -1f || npc.ai[0] == 3f || npc.ai[0] == 4f) - num17 = 0f; - if (npc.ai[0] == 8f || npc.ai[0] == 13f) - num17 = pie * 0.1666666667f * npc.spriteDirection; - - if (npc.rotation < num17) - { - if (num17 - npc.rotation > pie) - npc.rotation -= rateOfRotation; - else - npc.rotation += rateOfRotation; - } - if (npc.rotation > num17) - { - if (npc.rotation - num17 > pie) - npc.rotation += rateOfRotation; - else - npc.rotation -= rateOfRotation; - } - - if ((npc.ai[0] != 8f && npc.ai[0] != 13f) || npc.spriteDirection == 1) - { - if (npc.rotation > num17 - rateOfRotation && npc.rotation < num17 + rateOfRotation) - npc.rotation = num17; - if (npc.rotation < 0f) - npc.rotation += MathHelper.TwoPi; - if (npc.rotation > MathHelper.TwoPi) - npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > num17 - rateOfRotation && npc.rotation < num17 + rateOfRotation) - npc.rotation = num17; - } - - // Alpha adjustments - if (npc.ai[0] != -1f && (npc.ai[0] < 9f || npc.ai[0] > 12f)) - { - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.alpha += 15; - else - npc.alpha -= 15; - - if (npc.alpha < 0) - npc.alpha = 0; - if (npc.alpha > 150) - npc.alpha = 150; - } - - // Spawn effects - if (npc.ai[0] == -1f) - { - // Velocity - if (npc.Calamity().newAI[3] == 0f) - npc.velocity *= 0.98f; - - // Direction - int num19 = Math.Sign(player.Center.X - vector.X); - if (num19 != 0) - { - npc.direction = num19; - npc.spriteDirection = -npc.direction; - } - - // Alpha - if (npc.ai[2] > 20f) - { - if (npc.Calamity().newAI[3] == 0f) - npc.velocity.Y = -2f; - - npc.alpha -= 5; - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.alpha += 15; - if (npc.alpha < 0) - npc.alpha = 0; - if (npc.alpha > 150) - npc.alpha = 150; - } - - // Spawn dust and play sound - if (npc.ai[2] == num9 - 30) - { - int num20 = 36; - for (int i = 0; i < num20; i++) - { - 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; - Main.dust[num21].noLight = true; - Main.dust[num21].velocity = Vector2.Normalize(vector2) * 3f; - } - - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= num16) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - } - - // Phase 1 - else if (npc.ai[0] == 0f && !player.dead) - { - // Velocity - if (npc.ai[1] == 0f) - 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) * idlePhaseVelocity; - npc.SimpleFlyMovement(vector3, idlePhaseAcceleration); - - // Rotation and direction - int num22 = Math.Sign(player.Center.X - vector.X); - if (num22 != 0) - { - if (npc.ai[2] == 0f && num22 != npc.direction) - npc.rotation += pie; - - npc.direction = num22; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - // Phase switch - if (calamityGlobalNPC.newAI[1] != 1f || (phase2 && !phase2AI)) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= idlePhaseTimer || (phase2 && !phase2AI)) - { - int num23 = 0; - switch ((int)npc.ai[3]) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - num23 = 1; - break; - case 6: - npc.ai[3] = 1f; - num23 = 2; - break; - case 7: - npc.ai[3] = 0f; - num23 = 3; - break; - } - - if (phase2) - num23 = 4; - - // Set velocity for charge - if (num23 == 1) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - // Velocity - Vector2 distanceVector = player.Center + player.velocity * 20f - vector; - npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (num22 != 0) - { - npc.direction = num22; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - - // Tooth Balls - else if (num23 == 2) - { - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - // Call sharks from the sides of the screen - else if (num23 == 3) - { - npc.ai[0] = 3f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - // Go to phase 2 - else if (num23 == 4) - { - npc.ai[0] = 4f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - npc.netUpdate = true; - } - } - } - - // Charge - else if (npc.ai[0] == 1f) - { - // Accelerate - npc.velocity *= 1.01f; - - // Spawn dust - int num24 = 7; - for (int j = 0; j < num24; j++) - { - 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; - Main.dust[num25].velocity /= 4f; - Main.dust[num25].velocity -= npc.velocity; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime) - { - calamityGlobalNPC.newAI[0] += 30f; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Tooth Ball belch - else if (npc.ai[0] == 2f) - { - // Velocity - if (npc.ai[1] == 0f) - 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) * toothBallBelchPhaseVelocity; - npc.SimpleFlyMovement(vector5, toothBallBelchPhaseAcceleration); - - // Play sounds and spawn Tooth Balls - 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] % toothBallBelchPhaseDivisor == 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) * (npc.width + 20) / 2f + vector; - NPC.NewNPC((int)vector6.X, (int)vector6.Y + 45, ModContent.NPCType()); - } - } - - // Direction - int num26 = Math.Sign(player.Center.X - vector.X); - if (num26 != 0) - { - npc.direction = num26; - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - npc.spriteDirection = -npc.direction; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= toothBallBelchPhaseTimer) - { - calamityGlobalNPC.newAI[0] += 30f; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Call sharks from the sides of the screen - else if (npc.ai[0] == 3f) - { - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Play sound and spawn sharks - 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] >= 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, 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] >= num9) - { - calamityGlobalNPC.newAI[0] += 30f; - calamityGlobalNPC.newAI[2] = 0f; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Transition to phase 2 and call sharks from below - else if (npc.ai[0] == 4f) - { - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Sound - 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] >= num10 - 60) - { - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) - { - calamityGlobalNPC.newAI[2] += 150f; - NPC.NewNPC((int)(vector.X + 50f + calamityGlobalNPC.newAI[2]), (int)(vector.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); - NPC.NewNPC((int)(vector.X - 50f - calamityGlobalNPC.newAI[2]), (int)(vector.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); - } - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= num10) - { - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Phase 2 - else if (npc.ai[0] == 5f && !player.dead) - { - // Velocity - if (npc.ai[1] == 0f) - 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) * idlePhaseVelocity; - npc.SimpleFlyMovement(vector8, idlePhaseAcceleration); - - // Direction and rotation - int num27 = Math.Sign(player.Center.X - vector.X); - if (num27 != 0) - { - if (npc.ai[2] == 0f && num27 != npc.direction) - npc.rotation += pie; - - npc.direction = num27; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - // Phase switch - if (calamityGlobalNPC.newAI[1] != 1f || (phase3 && !phase3AI)) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= idlePhaseTimer || (phase3 && !phase3AI)) - { - int num28 = 0; - switch ((int)npc.ai[3]) - { - case 0: - case 1: - case 2: - case 3: - num28 = 1; - break; - case 4: - npc.ai[3] = 1f; - num28 = 2; - break; - case 5: - npc.ai[3] = 0f; - num28 = 3; - break; - } - - if (phase3) - num28 = 4; - - // Set velocity for charge - if (num28 == 1) - { - npc.ai[0] = 6f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - // Velocity and rotation - Vector2 distanceVector = player.Center + player.velocity * 20f - vector; - npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (num27 != 0) - { - npc.direction = num27; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - - // Set velocity for spin - else if (num28 == 2) - { - // Velocity and rotation - npc.velocity = Vector2.Normalize(player.Center - vector) * scaleFactor4; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (num27 != 0) - { - npc.direction = num27; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - npc.ai[0] = 7f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - else if (num28 == 3) - { - npc.ai[0] = 8f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - // Go to next phase - else if (num28 == 4) - { - npc.ai[0] = 9f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - npc.netUpdate = true; - } - } - } - - // Charge - else if (npc.ai[0] == 6f) - { - // Accelerate - npc.velocity *= 1.01f; - - // Spawn dust - int num29 = 7; - for (int k = 0; k < num29; k++) - { - 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; - Main.dust[num30].velocity /= 4f; - Main.dust[num30].velocity -= npc.velocity; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime) - { - calamityGlobalNPC.newAI[0] += 30f; - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Tooth Ball and Vortex spin - else if (npc.ai[0] == 7f) - { - // Play sounds and spawn Tooth Balls and a Vortex - if (npc.ai[2] == 0f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 vortexSpawn = vector + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(vortexSpawn, Vector2.Zero, type, damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); - } - } - - if (npc.ai[2] % toothBallSpinPhaseDivisor == 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) * (npc.width + 20) / 2f + vector; - int num31 = NPC.NewNPC((int)vector10.X, (int)vector10.Y + 45, ModContent.NPCType()); - Main.npc[num31].target = npc.target; - Main.npc[num31].velocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * toothBallSpinToothBallVelocity; - Main.npc[num31].netUpdate = true; - Main.npc[num31].ai[3] = Main.rand.Next(30, 181); - } - } - - // Velocity and rotation - npc.velocity = npc.velocity.RotatedBy(-(double)num15 * (float)npc.direction); - npc.rotation -= num15 * npc.direction; - - npc.ai[2] += 1f; - if (npc.ai[2] >= num13) - { - calamityGlobalNPC.newAI[0] += 30f; - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Vomit a huge amount of gore into the sky and call sharks from the sides of the screen - else if (npc.ai[0] == 8f) - { - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Play sound - 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 * npc.direction) * (npc.width + 20) / 2f + vector; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < 20; i++) - { - float velocityX = npc.direction * goreVelocityX * (Main.rand.NextFloat() + 0.5f); - float velocityY = goreVelocityY * (Main.rand.NextFloat() + 0.5f); - Projectile.NewProjectile(vector7.X, vector7.Y, velocityX, -velocityY, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - - 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, 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] >= num9) - { - calamityGlobalNPC.newAI[0] += 30f; - calamityGlobalNPC.newAI[2] = 0f; - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Transition to phase 3 and summon sharks from above - else if (npc.ai[0] == 9f) - { - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Sound - 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] >= num10 - 60) - { - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) - { - calamityGlobalNPC.newAI[2] += 200f; - NPC.NewNPC((int)(vector.X + 50f + calamityGlobalNPC.newAI[2]), (int)(vector.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, sharkronVelocity, 255); - NPC.NewNPC((int)(vector.X - 50f - calamityGlobalNPC.newAI[2]), (int)(vector.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, sharkronVelocity, 255); - } - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= num10) - { - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Phase 3 - else if (npc.ai[0] == 10f && !player.dead) - { - // Alpha - npc.alpha -= 25; - if (npc.alpha < 0) - npc.alpha = 0; - - // Movement location - if (npc.ai[1] == 0f) - npc.ai[1] = 500 * Math.Sign((vector - player.Center).X); - - Vector2 desiredVelocity = Vector2.Normalize(player.Center + new Vector2(-npc.ai[1], -300f) - vector - npc.velocity) * idlePhaseVelocity; - npc.SimpleFlyMovement(desiredVelocity, idlePhaseAcceleration); - - // Rotation and direction - int num32 = Math.Sign(player.Center.X - vector.X); - if (num32 != 0) - { - if (npc.ai[2] == 0f && num32 != npc.direction) - { - npc.rotation += pie; - for (int l = 0; l < npc.oldPos.Length; l++) - npc.oldPos[l] = Vector2.Zero; - } - - npc.direction = num32; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - // Phase switch - if (calamityGlobalNPC.newAI[1] != 1f) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= idlePhaseTimer) - { - int num33 = 0; - switch ((int)npc.ai[3]) - { - case 0: - case 2: - case 3: - case 5: - case 6: - case 7: - num33 = 1; - break; - case 1: - case 8: - num33 = 2; - break; - case 4: - npc.ai[3] = 1f; - num33 = 3; - break; - case 9: - npc.ai[3] = 6f; - num33 = 4; - break; - } - - // Set velocity for charge - if (num33 == 1) - { - npc.ai[0] = 11f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - // Velocity and rotation - Vector2 distanceVector = player.Center + player.velocity * 20f - vector; - npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (num32 != 0) - { - npc.direction = num32; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - - // Pause - else if (num33 == 2) - { - npc.ai[0] = 12f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - else if (num33 == 3) - { - npc.ai[0] = 13f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - // Set velocity for spin - else if (num33 == 4) - { - // Velocity and rotation - npc.velocity = Vector2.Normalize(player.Center - vector) * scaleFactor4; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (num32 != 0) - { - npc.direction = num32; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - npc.ai[0] = 14f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - npc.netUpdate = true; - } - } - } - - // Charge - else if (npc.ai[0] == 11f) - { - // Accelerate - npc.velocity *= 1.01f; - - // Spawn dust - int num34 = 7; - for (int m = 0; m < num34; m++) - { - 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; - Main.dust[num35].velocity /= 4f; - Main.dust[num35].velocity -= npc.velocity; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime) - { - calamityGlobalNPC.newAI[0] += 30f; - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Pause before teleport - else if (npc.ai[0] == 12f) - { - // Alpha - if (npc.alpha < 255 && npc.ai[2] >= num12 - 15f) - { - npc.alpha += 17; - if (npc.alpha > 255) - npc.alpha = 255; - } - - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Play sound - 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] == num12 / 2) - { - // Teleport location - if (npc.ai[1] == 0f) - npc.ai[1] = 600 * Math.Sign((vector - player.Center).X); - - // Rotation and direction - Vector2 center = player.Center + new Vector2(npc.ai[1], -300f); - vector = npc.Center = center; - int num36 = Math.Sign(player.Center.X - vector.X); - if (num36 != 0) - { - if (npc.ai[2] == 0f && num36 != npc.direction) - { - npc.rotation += pie; - for (int n = 0; n < npc.oldPos.Length; n++) - npc.oldPos[n] = Vector2.Zero; - } - - npc.direction = num36; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= num12) - { - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - npc.ai[3] += 2f; - if (npc.ai[3] >= 9f) - npc.ai[3] = 0f; - - npc.netUpdate = true; - } - } - - // Vomit a huge amount of gore into the sky and call sharks from the sides of the screen - else if (npc.ai[0] == 13f) - { - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Play sound - 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 * npc.direction) * (npc.width + 20) / 2f + vector; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < 20; i++) - { - float velocityX = npc.direction * goreVelocityX * (Main.rand.NextFloat() + 0.5f); - float velocityY = goreVelocityY * (Main.rand.NextFloat() + 0.5f); - Projectile.NewProjectile(vector7.X, vector7.Y, velocityX, -velocityY, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - - 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, 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] >= num9) - { - calamityGlobalNPC.newAI[0] += 30f; - calamityGlobalNPC.newAI[2] = 0f; - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Tooth Ball and Vortex spin - else if (npc.ai[0] == 14f) - { - // Play sounds and spawn Tooth Balls and a Vortex - if (npc.ai[2] == 0f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 vortexSpawn = vector + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(vortexSpawn, Vector2.Zero, type, damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); - } - } - - if (npc.ai[2] % toothBallSpinPhaseDivisor == 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) * (npc.width + 20) / 2f + vector; - int num31 = NPC.NewNPC((int)vector10.X, (int)vector10.Y + 45, ModContent.NPCType()); - Main.npc[num31].target = npc.target; - Main.npc[num31].velocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * toothBallSpinToothBallVelocity; - Main.npc[num31].netUpdate = true; - Main.npc[num31].ai[3] = Main.rand.Next(30, 361); - } - } - - // Velocity and rotation - npc.velocity = npc.velocity.RotatedBy(-(double)num15 * (float)npc.direction); - npc.rotation -= num15 * npc.direction; - - npc.ai[2] += 1f; - if (npc.ai[2] >= num13) - { - calamityGlobalNPC.newAI[0] += 30f; - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - } - #endregion - - // This AI is for testing purposes, don't remove it - #region Brimstone Elemental2 - public static void BrimstoneElementalAI2(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Used for Brimling AI states - CalamityGlobalNPC.brimstoneElemental = npc.whoAmI; - - // Center - Vector2 vectorCenter = npc.Center; - - // Get a target - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); - - Player player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 5600f) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 5600f) - { - npc.rotation = npc.velocity.X * 0.04f; - - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[0] != 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.netUpdate = true; - } - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - CalamityPlayer modPlayer = player.Calamity(); - - // Reset defense - npc.defense = npc.defDefense; - - // Hide the sprite - npc.alpha = 255; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Variables for buffing the AI - bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool calamity = modPlayer.ZoneCalamity; - bool phase2 = (lifeRatio < 0.5f && revenge) || death; - - // Speed while moving in phase 1 - float speed = expertMode ? 5f : 4.5f; - if (BossRushEvent.BossRushActive) - speed = 12f; - else if (!calamity) - speed = 7f; - else if (death) - speed = 6f; - else if (revenge) - speed = 5.5f; - float speedBoost = death ? 2f : 2f * (1f - lifeRatio); - speed += speedBoost; - - 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(xDistance * xDistance + yDistance * yDistance); - - // Static movement towards target - if (npc.ai[0] == 5f) - { - npc.rotation = npc.velocity.X * 0.04f; - if (npc.ai[1] < 180f) - { - float playerLocation = vectorCenter.X - player.Center.X; - npc.direction = playerLocation < 0f ? 1 : -1; - npc.spriteDirection = npc.direction; - totalDistance = speed * 0.15f / totalDistance; - xDistance *= totalDistance; - yDistance *= totalDistance; - npc.velocity.X = (npc.velocity.X * 50f + xDistance) / 51f; - npc.velocity.Y = (npc.velocity.Y * 50f + yDistance) / 51f; - } - } - - if (npc.ai[0] == 0f) - { - npc.chaseable = true; - 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; - - bool shootProjectile = false; - float fireRate = 60f; - if (npc.ai[1] % fireRate == fireRate - 1f) - shootProjectile = true; - - if (shootProjectile) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - 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; - num744 *= num745; - - vectorCenter.X += num743 * 3f; - vectorCenter.Y += num744 * 3f; - - float radians = MathHelper.TwoPi / 3f; - - 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 / numProj; - double offsetAngle; - - 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, 0f, Main.myPlayer, 10f, 0f); - } - } - } - - if (npc.position.Y > player.position.Y - 150f) //200 - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= 0.98f; - - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.15f : 0.1f; - - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - } - else if (npc.position.Y < player.position.Y - 350f) //500 - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.98f; - - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.15f : 0.1f; - - if (npc.velocity.Y < -3f) - npc.velocity.Y = -3f; - } - 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 -= BossRushEvent.BossRushActive ? 0.15f : 0.1f; - - if (npc.velocity.X > 8f) - npc.velocity.X = 8f; - } - 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 += (BossRushEvent.BossRushActive ? 0.15f : 0.1f); - - if (npc.velocity.X < -8f) - npc.velocity.X = -8f; - } - - if (npc.ai[1] >= 300f) - { - npc.TargetClosest(true); - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - - // Cocoon bullet hell - else if (npc.ai[0] == 1f) - { - npc.defense = 99999; - npc.chaseable = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] += 1f; - - float projectileSpeed = revenge ? 8f : 6f; - if (BossRushEvent.BossRushActive) - projectileSpeed = 12f; - - 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; - - // Offset the arc - Vector2 velocity = targetVector; - velocity.Normalize(); - velocity *= diameter; - - totalProjectiles = 16; - int half = totalProjectiles / 2; - float scalar = 0.2f; - float velocityMult = (totalProjectiles - 1f) / 2f; - offsetAngle = (float)Math.PI * radialOffset; - - 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 *= diameter; - - totalProjectiles = 8; - offsetAngle = (float)Math.PI * radialOffset; - - for (int j = 0; j < totalProjectiles; j++) - { - 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); - } - }*/ - } - - 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] >= 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; - } - } - - // Laser beam attack - else if (npc.ai[0] == 2f) - { - npc.defense = npc.defDefense * 3; - - Vector2 source = new Vector2(vectorCenter.X + (npc.spriteDirection > 0 ? 34f : -34f), vectorCenter.Y - 74f); - Vector2 aimAt = player.Center + player.velocity * 20f; - float aimResponsiveness = 0.4f; - - switch ((int)npc.ai[2]) - { - case 0: - break; - case 1: - aimResponsiveness = 0.25f; - break; - case 2: - aimResponsiveness = 0.1f; - break; - } - - Vector2 aimVector = Vector2.Normalize(aimAt - source); - if (aimVector.HasNaNs()) - aimVector = -Vector2.UnitY; - aimVector = Vector2.Normalize(Vector2.Lerp(aimVector, Vector2.Normalize(npc.velocity), aimResponsiveness)); - aimVector *= 6f; - - Vector2 laserVelocity = Vector2.Normalize(aimVector); - if (laserVelocity.HasNaNs()) - laserVelocity = -Vector2.UnitY; - - calamityGlobalNPC.newAI[1] = laserVelocity.X; - calamityGlobalNPC.newAI[2] = laserVelocity.Y; - - npc.ai[1] += 1f; - if (npc.ai[1] >= 300f) - { - npc.TargetClosest(true); - npc.ai[2] += 1f; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - if (npc.ai[2] >= 3f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - else - { - npc.ai[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - } - else if (npc.ai[1] >= 180f) - { - npc.velocity *= 0.95f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.ai[1] == 180f) - { - Main.PlaySound(SoundID.Zombie, (int)npc.position.X, (int)npc.position.Y, 104); - Vector2 laserVelocity2 = new Vector2(npc.localAI[0], npc.localAI[1]); - laserVelocity2.Normalize(); - - 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 / 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, 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); - } - } - } - } - else - { - float playSoundTimer = 20f; - if (npc.ai[1] < 150f) - { - switch ((int)npc.ai[2]) - { - case 0: - break; - case 1: - npc.ai[1] += 0.5f; - playSoundTimer = 30f; - break; - case 2: - npc.ai[1] += 1f; - playSoundTimer = 40f; - break; - } - } - - if (npc.ai[1] % playSoundTimer == 0f) - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 20); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f) - { - Projectile.NewProjectile(source, laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - calamityGlobalNPC.newAI[0] = 1f; - } - else - { - if (npc.ai[1] == 150f) - { - npc.localAI[0] = laserVelocity.X; - npc.localAI[1] = laserVelocity.Y; - - Vector2 laserVelocity2 = new Vector2(npc.localAI[0], npc.localAI[1]); - laserVelocity2.Normalize(); - - 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 / 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, 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); - } - } - } - } - } - } - } - #endregion - - #region Gem Crawler AI - public static void GemCrawlerAI(NPC npc, Mod mod, float speedDetect, float speedAdditive) + } + #endregion + + #region Old Duke + public static void OldDukeAI(NPC npc, Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + npc.Calamity().canBreakPlayerDefense = true; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Variables + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + bool tired = calamityGlobalNPC.newAI[1] == 1f; + bool phase2 = lifeRatio <= (death ? 0.8f : revenge ? 0.7f : 0.5f); + bool phase3 = lifeRatio <= (death ? 0.5f : (revenge ? 0.35f : 0.2f)) && expertMode; + bool phase2AI = npc.ai[0] > 4f; + bool phase3AI = npc.ai[0] > 9f; + bool charging = npc.ai[3] < 10f; + float pie = (float)Math.PI; + + if (calamityGlobalNPC.newAI[0] >= 300f) + calamityGlobalNPC.newAI[1] = 1f; + + // Adjust stats + calamityGlobalNPC.DR = tired ? 0f : 0.5f; + npc.defense = tired ? 0 : npc.defDefense; + if (phase3AI) + { + npc.damage = (int)(npc.defDamage * 1.2f); + npc.defense = tired ? 0 : npc.defDefense - 40; + } + else if (phase2AI) + { + npc.damage = (int)(npc.defDamage * 1.1f); + npc.defense = tired ? 0 : npc.defDefense - 20; + } + else + { + npc.damage = npc.defDamage; + } + + int idlePhaseTimer = expertMode ? 55 : 60; + float idlePhaseAcceleration = expertMode ? 0.75f : 0.7f; + float idlePhaseVelocity = expertMode ? 14f : 13f; + if (phase3AI) + { + idlePhaseAcceleration = expertMode ? 0.6f : 0.55f; + idlePhaseVelocity = expertMode ? 12f : 11f; + } + else if (phase2AI & charging) + { + idlePhaseAcceleration = expertMode ? 0.8f : 0.75f; + idlePhaseVelocity = expertMode ? 15f : 14f; + } + + int chargeTime = expertMode ? 34 : 36; + float chargeVelocity = expertMode ? 20f : 19f; + if (phase3AI) + { + chargeTime = expertMode ? 28 : 30; + chargeVelocity = expertMode ? 26f : 25f; + } + else if (charging & phase2AI) + { + chargeTime = expertMode ? 31 : 33; + chargeVelocity = expertMode ? 24f : 23f; + } + + if (malice) + { + idlePhaseTimer = 35; + idlePhaseAcceleration *= 1.25f; + idlePhaseVelocity *= 1.2f; + chargeTime -= 3; + chargeVelocity *= 1.25f; + } + else if (death) + { + idlePhaseTimer = 51; + idlePhaseAcceleration *= 1.05f; + idlePhaseVelocity *= 1.05f; + chargeTime -= 2; + chargeVelocity *= 1.1f; + } + else if (revenge) + { + idlePhaseTimer = 53; + idlePhaseAcceleration *= 1.025f; + idlePhaseVelocity *= 1.025f; + chargeTime -= 1; + chargeVelocity *= 1.05f; + } + + if (tired) + idlePhaseVelocity *= 0.25f; + + // Variables + int toothBallBelchPhaseTimer = malice ? 35 : death ? 90 : 120; + int toothBallBelchPhaseDivisor = malice ? 7 : death ? 18 : 24; + float toothBallBelchPhaseAcceleration = malice ? 0.95f : death ? 0.6f : 0.55f; + float toothBallBelchPhaseVelocity = malice ? 14f : death ? 10f : 9f; + float goreVelocityX = death ? 8f : revenge ? 7.5f : expertMode ? 7f : 6f; + float goreVelocityY = death ? 10.5f : revenge ? 10f : expertMode ? 9.5f : 8f; + float sharkronVelocity = malice ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + int num9 = 120; + int num10 = 180; + int num12 = 30; + int num13 = malice ? 35 : death ? 90 : 120; + int toothBallSpinPhaseDivisor = malice ? 7 : death ? 18 : 24; + float spinTime = num13 / 2; + float toothBallSpinToothBallVelocity = malice ? 14f : death ? 9.5f : 9f; + float scaleFactor4 = 22f; + float num15 = MathHelper.TwoPi / spinTime; + int num16 = 75; + + Vector2 vector = npc.Center; + Player player = Main.player[npc.target]; + + // Get target + if (npc.target < 0 || npc.target == 255 || player.dead || !player.active) + { + npc.TargetClosest(); + player = Main.player[npc.target]; + npc.netUpdate = true; + } + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(player.Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + // Despawn + if (player.dead || Vector2.Distance(player.Center, vector) > 8800f) + { + npc.TargetClosest(); + + npc.velocity.Y -= 0.4f; + + if (npc.timeLeft > 10) + npc.timeLeft = 10; + + if (npc.timeLeft == 1) + { + CalamityWorld.acidRainPoints = 0; + CalamityWorld.triedToSummonOldDuke = false; + AcidRainEvent.UpdateInvasion(false); + npc.timeLeft = 0; + } + + if (npc.ai[0] > 4f) + npc.ai[0] = 5f; + else + npc.ai[0] = 0f; + + npc.ai[2] = 0f; + } + + if (tired) + { + npc.Calamity().canBreakPlayerDefense = false; + + npc.damage /= 4; + + // Play tired sound + if (calamityGlobalNPC.newAI[0] % 60f == 0f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeHuff"), player.Center); + + calamityGlobalNPC.newAI[0] -= malice ? 1.5f : 1f; + if (calamityGlobalNPC.newAI[0] <= 0f) + calamityGlobalNPC.newAI[1] = 0f; + } + + // Enrage variable + bool enrage = !BossRushEvent.BossRushActive && + (player.position.Y < 300f || player.position.Y > Main.worldSurface * 16.0 || + (player.position.X > 8000f && player.position.X < (Main.maxTilesX * 16 - 8000))); + + // Enrage + if (enrage) + { + if (npc.localAI[1] > 0f) + npc.localAI[1] -= 1f; + } + else + npc.localAI[1] = CalamityGlobalNPC.biomeEnrageTimerMax; + + bool biomeEnraged = npc.localAI[1] <= 0f; + + npc.Calamity().CurrentlyEnraged = biomeEnraged || malice; + + // Increased DR while transitioning phases and not tired + if (!tired) + calamityGlobalNPC.DR = (npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f) ? 0.75f : 0.5f; + + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f; + + // Enrage + if (biomeEnraged) + { + toothBallBelchPhaseTimer = 30; + toothBallBelchPhaseDivisor = 6; + toothBallBelchPhaseAcceleration = 1f; + toothBallBelchPhaseVelocity = 15f; + goreVelocityX = 12f; + goreVelocityY = 16f; + sharkronVelocity = 20f; + idlePhaseTimer = 20; + idlePhaseAcceleration = 1.2f; + idlePhaseVelocity = 20f; + chargeTime = 25; + chargeVelocity += 8f; + toothBallSpinPhaseDivisor = 6; + toothBallSpinToothBallVelocity = 15f; + npc.damage = npc.defDamage * 2; + npc.defense = npc.defDefense * 3; + } + + // Set variables for spawn effects + if (npc.localAI[0] == 0f) + { + npc.localAI[0] = 1f; + npc.alpha = 255; + npc.rotation = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.ai[0] = -1f; + npc.netUpdate = true; + } + } + + // Rotation + float rateOfRotation = 0.04f; + if (npc.ai[0] == 1f || npc.ai[0] == 6f || npc.ai[0] == 7f || npc.ai[0] == 14f) + rateOfRotation = 0f; + if (npc.ai[0] == 3f || npc.ai[0] == 4f) + rateOfRotation = 0.01f; + if (npc.ai[0] == 8f || npc.ai[0] == 13f) + rateOfRotation = 0.05f; + + Vector2 rotationVector = player.Center - vector; + if (calamityGlobalNPC.newAI[1] != 1f && !player.dead) + { + // Rotate to show direction of predictive charge + if (npc.ai[0] == 0f && !phase2) + { + if (npc.ai[3] < 6f) + { + rateOfRotation = 0.1f; + rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - vector) * chargeVelocity; + } + } + else if (npc.ai[0] == 5f && !phase3) + { + if (npc.ai[3] < 4f) + { + rateOfRotation = 0.1f; + rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - vector) * chargeVelocity; + } + } + else if (npc.ai[0] == 10f) + { + if (npc.ai[3] < 8f && npc.ai[3] != 1f && npc.ai[3] != 4f) + { + rateOfRotation = 0.1f; + rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - vector) * chargeVelocity; + } + } + } + + float num17 = (float)Math.Atan2(rotationVector.Y, rotationVector.X); + if (npc.spriteDirection == 1) + num17 += pie; + if (num17 < 0f) + num17 += MathHelper.TwoPi; + if (num17 > MathHelper.TwoPi) + num17 -= MathHelper.TwoPi; + if (npc.ai[0] == -1f || npc.ai[0] == 3f || npc.ai[0] == 4f) + num17 = 0f; + if (npc.ai[0] == 8f || npc.ai[0] == 13f) + num17 = pie * 0.1666666667f * npc.spriteDirection; + + if (npc.rotation < num17) + { + if (num17 - npc.rotation > pie) + npc.rotation -= rateOfRotation; + else + npc.rotation += rateOfRotation; + } + if (npc.rotation > num17) + { + if (npc.rotation - num17 > pie) + npc.rotation += rateOfRotation; + else + npc.rotation -= rateOfRotation; + } + + if ((npc.ai[0] != 8f && npc.ai[0] != 13f) || npc.spriteDirection == 1) + { + if (npc.rotation > num17 - rateOfRotation && npc.rotation < num17 + rateOfRotation) + npc.rotation = num17; + if (npc.rotation < 0f) + npc.rotation += MathHelper.TwoPi; + if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; + if (npc.rotation > num17 - rateOfRotation && npc.rotation < num17 + rateOfRotation) + npc.rotation = num17; + } + + // Alpha adjustments + if (npc.ai[0] != -1f && (npc.ai[0] < 9f || npc.ai[0] > 12f)) + { + if (Collision.SolidCollision(npc.position, npc.width, npc.height)) + npc.alpha += 15; + else + npc.alpha -= 15; + + if (npc.alpha < 0) + npc.alpha = 0; + if (npc.alpha > 150) + npc.alpha = 150; + } + + // Spawn effects + if (npc.ai[0] == -1f) + { + // Velocity + if (npc.Calamity().newAI[3] == 0f) + npc.velocity *= 0.98f; + + // Direction + int num19 = Math.Sign(player.Center.X - vector.X); + if (num19 != 0) + { + npc.direction = num19; + npc.spriteDirection = -npc.direction; + } + + // Alpha + if (npc.ai[2] > 20f) + { + if (npc.Calamity().newAI[3] == 0f) + npc.velocity.Y = -2f; + + npc.alpha -= 5; + if (Collision.SolidCollision(npc.position, npc.width, npc.height)) + npc.alpha += 15; + if (npc.alpha < 0) + npc.alpha = 0; + if (npc.alpha > 150) + npc.alpha = 150; + } + + // Spawn dust and play sound + if (npc.ai[2] == num9 - 30) + { + int num20 = 36; + for (int i = 0; i < num20; i++) + { + 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; + Main.dust[num21].noLight = true; + Main.dust[num21].velocity = Vector2.Normalize(vector2) * 3f; + } + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); + } + + npc.ai[2] += 1f; + if (npc.ai[2] >= num16) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.netUpdate = true; + } + } + + // Phase 1 + else if (npc.ai[0] == 0f && !player.dead) + { + // Velocity + if (npc.ai[1] == 0f) + 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) * idlePhaseVelocity; + npc.SimpleFlyMovement(vector3, idlePhaseAcceleration); + + // Rotation and direction + int num22 = Math.Sign(player.Center.X - vector.X); + if (num22 != 0) + { + if (npc.ai[2] == 0f && num22 != npc.direction) + npc.rotation += pie; + + npc.direction = num22; + + if (npc.spriteDirection != -npc.direction) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + + // Phase switch + if (calamityGlobalNPC.newAI[1] != 1f || (phase2 && !phase2AI)) + { + npc.ai[2] += 1f; + if (npc.ai[2] >= idlePhaseTimer || (phase2 && !phase2AI)) + { + int num23 = 0; + switch ((int)npc.ai[3]) + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + num23 = 1; + break; + case 6: + npc.ai[3] = 1f; + num23 = 2; + break; + case 7: + npc.ai[3] = 0f; + num23 = 3; + break; + } + + if (phase2) + num23 = 4; + + // Set velocity for charge + if (num23 == 1) + { + npc.ai[0] = 1f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + + // Velocity + Vector2 distanceVector = player.Center + player.velocity * 20f - vector; + npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + + // Direction + if (num22 != 0) + { + npc.direction = num22; + + if (npc.spriteDirection == 1) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + } + + // Tooth Balls + else if (num23 == 2) + { + npc.ai[0] = 2f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + + // Call sharks from the sides of the screen + else if (num23 == 3) + { + npc.ai[0] = 3f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + + // Go to phase 2 + else if (num23 == 4) + { + npc.ai[0] = 4f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + + npc.netUpdate = true; + } + } + } + + // Charge + else if (npc.ai[0] == 1f) + { + // Accelerate + npc.velocity *= 1.01f; + + // Spawn dust + int num24 = 7; + for (int j = 0; j < num24; j++) + { + 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; + Main.dust[num25].velocity /= 4f; + Main.dust[num25].velocity -= npc.velocity; + } + + npc.ai[2] += 1f; + if (npc.ai[2] >= chargeTime) + { + calamityGlobalNPC.newAI[0] += 30f; + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] += 2f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Tooth Ball belch + else if (npc.ai[0] == 2f) + { + // Velocity + if (npc.ai[1] == 0f) + 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) * toothBallBelchPhaseVelocity; + npc.SimpleFlyMovement(vector5, toothBallBelchPhaseAcceleration); + + // Play sounds and spawn Tooth Balls + 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] % toothBallBelchPhaseDivisor == 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) * (npc.width + 20) / 2f + vector; + NPC.NewNPC((int)vector6.X, (int)vector6.Y + 45, ModContent.NPCType()); + } + } + + // Direction + int num26 = Math.Sign(player.Center.X - vector.X); + if (num26 != 0) + { + npc.direction = num26; + if (npc.spriteDirection != -npc.direction) + npc.rotation += pie; + npc.spriteDirection = -npc.direction; + } + + npc.ai[2] += 1f; + if (npc.ai[2] >= toothBallBelchPhaseTimer) + { + calamityGlobalNPC.newAI[0] += 30f; + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Call sharks from the sides of the screen + else if (npc.ai[0] == 3f) + { + // Velocity + npc.velocity *= 0.98f; + npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + + // Play sound and spawn sharks + 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] >= 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, 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] >= num9) + { + calamityGlobalNPC.newAI[0] += 30f; + calamityGlobalNPC.newAI[2] = 0f; + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Transition to phase 2 and call sharks from below + else if (npc.ai[0] == 4f) + { + // Velocity + npc.velocity *= 0.98f; + npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + + // Sound + 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] >= num10 - 60) + { + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) + { + calamityGlobalNPC.newAI[2] += 150f; + NPC.NewNPC((int)(vector.X + 50f + calamityGlobalNPC.newAI[2]), (int)(vector.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); + NPC.NewNPC((int)(vector.X - 50f - calamityGlobalNPC.newAI[2]), (int)(vector.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); + } + } + + npc.ai[2] += 1f; + if (npc.ai[2] >= num10) + { + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.ai[0] = 5f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Phase 2 + else if (npc.ai[0] == 5f && !player.dead) + { + // Velocity + if (npc.ai[1] == 0f) + 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) * idlePhaseVelocity; + npc.SimpleFlyMovement(vector8, idlePhaseAcceleration); + + // Direction and rotation + int num27 = Math.Sign(player.Center.X - vector.X); + if (num27 != 0) + { + if (npc.ai[2] == 0f && num27 != npc.direction) + npc.rotation += pie; + + npc.direction = num27; + + if (npc.spriteDirection != -npc.direction) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + + // Phase switch + if (calamityGlobalNPC.newAI[1] != 1f || (phase3 && !phase3AI)) + { + npc.ai[2] += 1f; + if (npc.ai[2] >= idlePhaseTimer || (phase3 && !phase3AI)) + { + int num28 = 0; + switch ((int)npc.ai[3]) + { + case 0: + case 1: + case 2: + case 3: + num28 = 1; + break; + case 4: + npc.ai[3] = 1f; + num28 = 2; + break; + case 5: + npc.ai[3] = 0f; + num28 = 3; + break; + } + + if (phase3) + num28 = 4; + + // Set velocity for charge + if (num28 == 1) + { + npc.ai[0] = 6f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + + // Velocity and rotation + Vector2 distanceVector = player.Center + player.velocity * 20f - vector; + npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + + // Direction + if (num27 != 0) + { + npc.direction = num27; + + if (npc.spriteDirection == 1) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + } + + // Set velocity for spin + else if (num28 == 2) + { + // Velocity and rotation + npc.velocity = Vector2.Normalize(player.Center - vector) * scaleFactor4; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + + // Direction + if (num27 != 0) + { + npc.direction = num27; + + if (npc.spriteDirection == 1) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + + npc.ai[0] = 7f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + + else if (num28 == 3) + { + npc.ai[0] = 8f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + + // Go to next phase + else if (num28 == 4) + { + npc.ai[0] = 9f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + + npc.netUpdate = true; + } + } + } + + // Charge + else if (npc.ai[0] == 6f) + { + // Accelerate + npc.velocity *= 1.01f; + + // Spawn dust + int num29 = 7; + for (int k = 0; k < num29; k++) + { + 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; + Main.dust[num30].velocity /= 4f; + Main.dust[num30].velocity -= npc.velocity; + } + + npc.ai[2] += 1f; + if (npc.ai[2] >= chargeTime) + { + calamityGlobalNPC.newAI[0] += 30f; + npc.ai[0] = 5f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] += 2f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Tooth Ball and Vortex spin + else if (npc.ai[0] == 7f) + { + // Play sounds and spawn Tooth Balls and a Vortex + if (npc.ai[2] == 0f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); + + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Vector2 vortexSpawn = vector + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(vortexSpawn, Vector2.Zero, type, damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); + } + } + + if (npc.ai[2] % toothBallSpinPhaseDivisor == 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) * (npc.width + 20) / 2f + vector; + int num31 = NPC.NewNPC((int)vector10.X, (int)vector10.Y + 45, ModContent.NPCType()); + Main.npc[num31].target = npc.target; + Main.npc[num31].velocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * toothBallSpinToothBallVelocity; + Main.npc[num31].netUpdate = true; + Main.npc[num31].ai[3] = Main.rand.Next(30, 181); + } + } + + // Velocity and rotation + npc.velocity = npc.velocity.RotatedBy(-(double)num15 * (float)npc.direction); + npc.rotation -= num15 * npc.direction; + + npc.ai[2] += 1f; + if (npc.ai[2] >= num13) + { + calamityGlobalNPC.newAI[0] += 30f; + npc.ai[0] = 5f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Vomit a huge amount of gore into the sky and call sharks from the sides of the screen + else if (npc.ai[0] == 8f) + { + // Velocity + npc.velocity *= 0.98f; + npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + + // Play sound + 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 * npc.direction) * (npc.width + 20) / 2f + vector; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + for (int i = 0; i < 20; i++) + { + float velocityX = npc.direction * goreVelocityX * (Main.rand.NextFloat() + 0.5f); + float velocityY = goreVelocityY * (Main.rand.NextFloat() + 0.5f); + Projectile.NewProjectile(vector7.X, vector7.Y, velocityX, -velocityY, type, damage, 0f, Main.myPlayer, 0f, 0f); + } + } + } + + 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, 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] >= num9) + { + calamityGlobalNPC.newAI[0] += 30f; + calamityGlobalNPC.newAI[2] = 0f; + npc.ai[0] = 5f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Transition to phase 3 and summon sharks from above + else if (npc.ai[0] == 9f) + { + // Velocity + npc.velocity *= 0.98f; + npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + + // Sound + 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] >= num10 - 60) + { + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) + { + calamityGlobalNPC.newAI[2] += 200f; + NPC.NewNPC((int)(vector.X + 50f + calamityGlobalNPC.newAI[2]), (int)(vector.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, sharkronVelocity, 255); + NPC.NewNPC((int)(vector.X - 50f - calamityGlobalNPC.newAI[2]), (int)(vector.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, sharkronVelocity, 255); + } + } + + npc.ai[2] += 1f; + if (npc.ai[2] >= num10) + { + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.ai[0] = 10f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Phase 3 + else if (npc.ai[0] == 10f && !player.dead) + { + // Alpha + npc.alpha -= 25; + if (npc.alpha < 0) + npc.alpha = 0; + + // Movement location + if (npc.ai[1] == 0f) + npc.ai[1] = 500 * Math.Sign((vector - player.Center).X); + + Vector2 desiredVelocity = Vector2.Normalize(player.Center + new Vector2(-npc.ai[1], -300f) - vector - npc.velocity) * idlePhaseVelocity; + npc.SimpleFlyMovement(desiredVelocity, idlePhaseAcceleration); + + // Rotation and direction + int num32 = Math.Sign(player.Center.X - vector.X); + if (num32 != 0) + { + if (npc.ai[2] == 0f && num32 != npc.direction) + { + npc.rotation += pie; + for (int l = 0; l < npc.oldPos.Length; l++) + npc.oldPos[l] = Vector2.Zero; + } + + npc.direction = num32; + + if (npc.spriteDirection != -npc.direction) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + + // Phase switch + if (calamityGlobalNPC.newAI[1] != 1f) + { + npc.ai[2] += 1f; + if (npc.ai[2] >= idlePhaseTimer) + { + int num33 = 0; + switch ((int)npc.ai[3]) + { + case 0: + case 2: + case 3: + case 5: + case 6: + case 7: + num33 = 1; + break; + case 1: + case 8: + num33 = 2; + break; + case 4: + npc.ai[3] = 1f; + num33 = 3; + break; + case 9: + npc.ai[3] = 6f; + num33 = 4; + break; + } + + // Set velocity for charge + if (num33 == 1) + { + npc.ai[0] = 11f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + + // Velocity and rotation + Vector2 distanceVector = player.Center + player.velocity * 20f - vector; + npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + + // Direction + if (num32 != 0) + { + npc.direction = num32; + + if (npc.spriteDirection == 1) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + } + + // Pause + else if (num33 == 2) + { + npc.ai[0] = 12f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + + else if (num33 == 3) + { + npc.ai[0] = 13f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + + // Set velocity for spin + else if (num33 == 4) + { + // Velocity and rotation + npc.velocity = Vector2.Normalize(player.Center - vector) * scaleFactor4; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + + // Direction + if (num32 != 0) + { + npc.direction = num32; + + if (npc.spriteDirection == 1) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + + npc.ai[0] = 14f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + + npc.netUpdate = true; + } + } + } + + // Charge + else if (npc.ai[0] == 11f) + { + // Accelerate + npc.velocity *= 1.01f; + + // Spawn dust + int num34 = 7; + for (int m = 0; m < num34; m++) + { + 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; + Main.dust[num35].velocity /= 4f; + Main.dust[num35].velocity -= npc.velocity; + } + + npc.ai[2] += 1f; + if (npc.ai[2] >= chargeTime) + { + calamityGlobalNPC.newAI[0] += 30f; + npc.ai[0] = 10f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] += 2f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Pause before teleport + else if (npc.ai[0] == 12f) + { + // Alpha + if (npc.alpha < 255 && npc.ai[2] >= num12 - 15f) + { + npc.alpha += 17; + if (npc.alpha > 255) + npc.alpha = 255; + } + + // Velocity + npc.velocity *= 0.98f; + npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + + // Play sound + 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] == num12 / 2) + { + // Teleport location + if (npc.ai[1] == 0f) + npc.ai[1] = 600 * Math.Sign((vector - player.Center).X); + + // Rotation and direction + Vector2 center = player.Center + new Vector2(npc.ai[1], -300f); + vector = npc.Center = center; + int num36 = Math.Sign(player.Center.X - vector.X); + if (num36 != 0) + { + if (npc.ai[2] == 0f && num36 != npc.direction) + { + npc.rotation += pie; + for (int n = 0; n < npc.oldPos.Length; n++) + npc.oldPos[n] = Vector2.Zero; + } + + npc.direction = num36; + + if (npc.spriteDirection != -npc.direction) + npc.rotation += pie; + + npc.spriteDirection = -npc.direction; + } + } + + npc.ai[2] += 1f; + if (npc.ai[2] >= num12) + { + npc.ai[0] = 10f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + + npc.ai[3] += 2f; + if (npc.ai[3] >= 9f) + npc.ai[3] = 0f; + + npc.netUpdate = true; + } + } + + // Vomit a huge amount of gore into the sky and call sharks from the sides of the screen + else if (npc.ai[0] == 13f) + { + // Velocity + npc.velocity *= 0.98f; + npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + + // Play sound + 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 * npc.direction) * (npc.width + 20) / 2f + vector; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + for (int i = 0; i < 20; i++) + { + float velocityX = npc.direction * goreVelocityX * (Main.rand.NextFloat() + 0.5f); + float velocityY = goreVelocityY * (Main.rand.NextFloat() + 0.5f); + Projectile.NewProjectile(vector7.X, vector7.Y, velocityX, -velocityY, type, damage, 0f, Main.myPlayer, 0f, 0f); + } + } + } + + 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, 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] >= num9) + { + calamityGlobalNPC.newAI[0] += 30f; + calamityGlobalNPC.newAI[2] = 0f; + npc.ai[0] = 10f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Tooth Ball and Vortex spin + else if (npc.ai[0] == 14f) + { + // Play sounds and spawn Tooth Balls and a Vortex + if (npc.ai[2] == 0f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeRoar"), (int)npc.position.X, (int)npc.position.Y); + + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Vector2 vortexSpawn = vector + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(vortexSpawn, Vector2.Zero, type, damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); + } + } + + if (npc.ai[2] % toothBallSpinPhaseDivisor == 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) * (npc.width + 20) / 2f + vector; + int num31 = NPC.NewNPC((int)vector10.X, (int)vector10.Y + 45, ModContent.NPCType()); + Main.npc[num31].target = npc.target; + Main.npc[num31].velocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * toothBallSpinToothBallVelocity; + Main.npc[num31].netUpdate = true; + Main.npc[num31].ai[3] = Main.rand.Next(30, 361); + } + } + + // Velocity and rotation + npc.velocity = npc.velocity.RotatedBy(-(double)num15 * (float)npc.direction); + npc.rotation -= num15 * npc.direction; + + npc.ai[2] += 1f; + if (npc.ai[2] >= num13) + { + calamityGlobalNPC.newAI[0] += 30f; + npc.ai[0] = 10f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + } + #endregion + + // This AI is for testing purposes, don't remove it + #region Brimstone Elemental2 + public static void BrimstoneElementalAI2(NPC npc, Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + // Used for Brimling AI states + CalamityGlobalNPC.brimstoneElemental = npc.whoAmI; + + // Center + Vector2 vectorCenter = npc.Center; + + // Get a target + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); + + Player player = Main.player[npc.target]; + if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 5600f) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 5600f) + { + npc.rotation = npc.velocity.X * 0.04f; + + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + npc.velocity.Y -= 0.1f; + if (npc.velocity.Y < -12f) + npc.velocity.Y = -12f; + + if (npc.timeLeft > 60) + npc.timeLeft = 60; + + if (npc.ai[0] != 0f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.netUpdate = true; + } + return; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; + + CalamityPlayer modPlayer = player.Calamity(); + + // Reset defense + npc.defense = npc.defDefense; + + // Hide the sprite + npc.alpha = 255; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Variables for buffing the AI + bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool calamity = modPlayer.ZoneCalamity; + bool phase2 = (lifeRatio < 0.5f && revenge) || death; + + // Speed while moving in phase 1 + float speed = expertMode ? 5f : 4.5f; + if (BossRushEvent.BossRushActive) + speed = 12f; + else if (!calamity) + speed = 7f; + else if (death) + speed = 6f; + else if (revenge) + speed = 5.5f; + float speedBoost = death ? 2f : 2f * (1f - lifeRatio); + speed += speedBoost; + + 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(xDistance * xDistance + yDistance * yDistance); + + // Static movement towards target + if (npc.ai[0] == 5f) + { + npc.rotation = npc.velocity.X * 0.04f; + if (npc.ai[1] < 180f) + { + float playerLocation = vectorCenter.X - player.Center.X; + npc.direction = playerLocation < 0f ? 1 : -1; + npc.spriteDirection = npc.direction; + totalDistance = speed * 0.15f / totalDistance; + xDistance *= totalDistance; + yDistance *= totalDistance; + npc.velocity.X = (npc.velocity.X * 50f + xDistance) / 51f; + npc.velocity.Y = (npc.velocity.Y * 50f + yDistance) / 51f; + } + } + + if (npc.ai[0] == 0f) + { + npc.chaseable = true; + 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; + + bool shootProjectile = false; + float fireRate = 60f; + if (npc.ai[1] % fireRate == fireRate - 1f) + shootProjectile = true; + + if (shootProjectile) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + 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; + num744 *= num745; + + vectorCenter.X += num743 * 3f; + vectorCenter.Y += num744 * 3f; + + float radians = MathHelper.TwoPi / 3f; + + 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 / numProj; + double offsetAngle; + + 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, 0f, Main.myPlayer, 10f, 0f); + } + } + } + + if (npc.position.Y > player.position.Y - 150f) //200 + { + if (npc.velocity.Y > 0f) + npc.velocity.Y *= 0.98f; + + npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.15f : 0.1f; + + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + } + else if (npc.position.Y < player.position.Y - 350f) //500 + { + if (npc.velocity.Y < 0f) + npc.velocity.Y *= 0.98f; + + npc.velocity.Y += BossRushEvent.BossRushActive ? 0.15f : 0.1f; + + if (npc.velocity.Y < -3f) + npc.velocity.Y = -3f; + } + 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 -= BossRushEvent.BossRushActive ? 0.15f : 0.1f; + + if (npc.velocity.X > 8f) + npc.velocity.X = 8f; + } + 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 += (BossRushEvent.BossRushActive ? 0.15f : 0.1f); + + if (npc.velocity.X < -8f) + npc.velocity.X = -8f; + } + + if (npc.ai[1] >= 300f) + { + npc.TargetClosest(true); + npc.ai[0] = 1f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } + } + + // Cocoon bullet hell + else if (npc.ai[0] == 1f) + { + npc.defense = 99999; + npc.chaseable = false; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[0] += 1f; + + float projectileSpeed = revenge ? 8f : 6f; + if (BossRushEvent.BossRushActive) + projectileSpeed = 12f; + + 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; + + // Offset the arc + Vector2 velocity = targetVector; + velocity.Normalize(); + velocity *= diameter; + + totalProjectiles = 16; + int half = totalProjectiles / 2; + float scalar = 0.2f; + float velocityMult = (totalProjectiles - 1f) / 2f; + offsetAngle = (float)Math.PI * radialOffset; + + 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 *= diameter; + + totalProjectiles = 8; + offsetAngle = (float)Math.PI * radialOffset; + + for (int j = 0; j < totalProjectiles; j++) + { + 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); + } + }*/ + } + + 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] >= 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; + } + } + + // Laser beam attack + else if (npc.ai[0] == 2f) + { + npc.defense = npc.defDefense * 3; + + Vector2 source = new Vector2(vectorCenter.X + (npc.spriteDirection > 0 ? 34f : -34f), vectorCenter.Y - 74f); + Vector2 aimAt = player.Center + player.velocity * 20f; + float aimResponsiveness = 0.4f; + + switch ((int)npc.ai[2]) + { + case 0: + break; + case 1: + aimResponsiveness = 0.25f; + break; + case 2: + aimResponsiveness = 0.1f; + break; + } + + Vector2 aimVector = Vector2.Normalize(aimAt - source); + if (aimVector.HasNaNs()) + aimVector = -Vector2.UnitY; + aimVector = Vector2.Normalize(Vector2.Lerp(aimVector, Vector2.Normalize(npc.velocity), aimResponsiveness)); + aimVector *= 6f; + + Vector2 laserVelocity = Vector2.Normalize(aimVector); + if (laserVelocity.HasNaNs()) + laserVelocity = -Vector2.UnitY; + + calamityGlobalNPC.newAI[1] = laserVelocity.X; + calamityGlobalNPC.newAI[2] = laserVelocity.Y; + + npc.ai[1] += 1f; + if (npc.ai[1] >= 300f) + { + npc.TargetClosest(true); + npc.ai[2] += 1f; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + if (npc.ai[2] >= 3f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + else + { + npc.ai[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + } + else if (npc.ai[1] >= 180f) + { + npc.velocity *= 0.95f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (npc.ai[1] == 180f) + { + Main.PlaySound(SoundID.Zombie, (int)npc.position.X, (int)npc.position.Y, 104); + Vector2 laserVelocity2 = new Vector2(npc.localAI[0], npc.localAI[1]); + laserVelocity2.Normalize(); + + 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 / 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, 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); + } + } + } + } + else + { + float playSoundTimer = 20f; + if (npc.ai[1] < 150f) + { + switch ((int)npc.ai[2]) + { + case 0: + break; + case 1: + npc.ai[1] += 0.5f; + playSoundTimer = 30f; + break; + case 2: + npc.ai[1] += 1f; + playSoundTimer = 40f; + break; + } + } + + if (npc.ai[1] % playSoundTimer == 0f) + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 20); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (npc.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f) + { + Projectile.NewProjectile(source, laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); + calamityGlobalNPC.newAI[0] = 1f; + } + else + { + if (npc.ai[1] == 150f) + { + npc.localAI[0] = laserVelocity.X; + npc.localAI[1] = laserVelocity.Y; + + Vector2 laserVelocity2 = new Vector2(npc.localAI[0], npc.localAI[1]); + laserVelocity2.Normalize(); + + 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 / 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, 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); + } + } + } + } + } + } + } + #endregion + + #region Gem Crawler AI + public static void GemCrawlerAI(NPC npc, Mod mod, float speedDetect, float speedAdditive) { int num19 = 30; int num20 = 10; @@ -7288,11 +7288,11 @@ namespace CalamityMod.NPCs } } } - } - #endregion + } + #endregion - #region Dungeon Spirit AI - public static void DungeonSpiritAI(NPC npc, Mod mod, float speed, float rotation, bool lantern = false) + #region Dungeon Spirit AI + public static void DungeonSpiritAI(NPC npc, Mod mod, float speed, float rotation, bool lantern = false) { npc.TargetClosest(true); Vector2 npcPos = new Vector2(npc.Center.X, npc.Center.Y); @@ -7301,22 +7301,22 @@ namespace CalamityMod.NPCs float targetDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); float homingSpeed = speed; - if (lantern) - { - if (npc.localAI[0] < 85f) - { - homingSpeed = 0.1f; - targetDist = homingSpeed / targetDist; - xDist *= targetDist; - yDist *= targetDist; - npc.velocity = (npc.velocity * 100f + new Vector2(xDist, yDist)) / 101f; - npc.localAI[0] += 1f; - return; - } + if (lantern) + { + if (npc.localAI[0] < 85f) + { + homingSpeed = 0.1f; + targetDist = homingSpeed / targetDist; + xDist *= targetDist; + yDist *= targetDist; + npc.velocity = (npc.velocity * 100f + new Vector2(xDist, yDist)) / 101f; + npc.localAI[0] += 1f; + return; + } - npc.dontTakeDamage = false; - npc.chaseable = true; - } + npc.dontTakeDamage = false; + npc.chaseable = true; + } targetDist = homingSpeed / targetDist; xDist *= targetDist; @@ -7324,18 +7324,18 @@ namespace CalamityMod.NPCs npc.velocity.X = (npc.velocity.X * 100f + xDist) / 101f; npc.velocity.Y = (npc.velocity.Y * 100f + yDist) / 101f; - if (lantern) - { - npc.rotation = npc.velocity.X * 0.08f; - npc.spriteDirection = (npc.direction > 0) ? 1 : -1; - } - else - npc.rotation = (float)Math.Atan2((double)yDist, (double)xDist) + rotation; + if (lantern) + { + npc.rotation = npc.velocity.X * 0.08f; + npc.spriteDirection = (npc.direction > 0) ? 1 : -1; + } + else + npc.rotation = (float)Math.Atan2((double)yDist, (double)xDist) + rotation; } - #endregion + #endregion - #region Unicorn AI - public static void UnicornAI(NPC npc, Mod mod, bool spin, float bounciness, float speedDetect, float speedAdditive, float bouncy1 = -8.5f, float bouncy2 = -7.5f, float bouncy3 = -7f, float bouncy4 = -6f, float bouncy5 = -8f) + #region Unicorn AI + public static void UnicornAI(NPC npc, Mod mod, bool spin, float bounciness, float speedDetect, float speedAdditive, float bouncy1 = -8.5f, float bouncy2 = -7.5f, float bouncy3 = -7f, float bouncy4 = -6f, float bouncy5 = -8f) { bool DogPhase1 = npc.type == ModContent.NPCType() && npc.life > npc.lifeMax * (CalamityWorld.death ? 0.9 : 0.5); bool DogPhase2 = npc.type == ModContent.NPCType() && npc.life <= npc.lifeMax * (CalamityWorld.death ? 0.9 : 0.5); @@ -7348,36 +7348,36 @@ namespace CalamityMod.NPCs npc.ai[3] += 1f; } int num2 = DogPhase1 ? 10 : 4; - if (!DogPhase1) - { - bool flag4 = npc.velocity.Y == 0f; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type && Math.Abs(npc.position.X - Main.npc[i].position.X) + Math.Abs(npc.position.Y - Main.npc[i].position.Y) < (float)npc.width) - { - if (npc.position.X < Main.npc[i].position.X) - { - npc.velocity.X -= 0.05f; - } - else - { - npc.velocity.X += 0.05f; - } - if (npc.position.Y < Main.npc[i].position.Y) - { - npc.velocity.Y -= 0.05f; - } - else - { - npc.velocity.Y += 0.05f; - } - } - } - if (flag4) - { - npc.velocity.Y = 0f; - } - } + if (!DogPhase1) + { + bool flag4 = npc.velocity.Y == 0f; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type && Math.Abs(npc.position.X - Main.npc[i].position.X) + Math.Abs(npc.position.Y - Main.npc[i].position.Y) < (float)npc.width) + { + if (npc.position.X < Main.npc[i].position.X) + { + npc.velocity.X -= 0.05f; + } + else + { + npc.velocity.X += 0.05f; + } + if (npc.position.Y < Main.npc[i].position.Y) + { + npc.velocity.Y -= 0.05f; + } + else + { + npc.velocity.Y += 0.05f; + } + } + } + if (flag4) + { + npc.velocity.Y = 0f; + } + } if (npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num || flag2) { npc.ai[3] += 1f; @@ -7407,39 +7407,39 @@ namespace CalamityMod.NPCs { npc.ai[3] = 0f; } - if (!DogPhase1) - { - if (npc.velocity.Y == 0f && Math.Abs(npc.velocity.X) > 3f && ((npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f) || (npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f))) - { - npc.velocity.Y -= bounciness; - if (npc.type == ModContent.NPCType()) - { - Main.PlaySound(SoundID.Item, npc.Center, 14); - for (int k = 0; k < 10; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, -1f, 0, default, 1f); - } - } - if (npc.type == ModContent.NPCType()) - { - Main.PlaySound(SoundID.NPCHit, npc.Center, 7); - } - if (DogPhase2) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 33, 0f, -1f, 0, default, 1f); - } - } - if (npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType()) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 33, 0f, -1f, 0, default, 1f); - } - } - } - } + if (!DogPhase1) + { + if (npc.velocity.Y == 0f && Math.Abs(npc.velocity.X) > 3f && ((npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f) || (npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f))) + { + npc.velocity.Y -= bounciness; + if (npc.type == ModContent.NPCType()) + { + Main.PlaySound(SoundID.Item, npc.Center, 14); + for (int k = 0; k < 10; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, -1f, 0, default, 1f); + } + } + if (npc.type == ModContent.NPCType()) + { + Main.PlaySound(SoundID.NPCHit, npc.Center, 7); + } + if (DogPhase2) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 33, 0f, -1f, 0, default, 1f); + } + } + if (npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType()) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 33, 0f, -1f, 0, default, 1f); + } + } + } + } if (npc.ai[3] < (float)num) { npc.TargetClosest(true); @@ -7643,21 +7643,21 @@ namespace CalamityMod.NPCs } } } - if (spin) - { - npc.rotation += npc.velocity.X * 0.05f; - npc.spriteDirection = -npc.direction; - } - } - #endregion + if (spin) + { + npc.rotation += npc.velocity.X * 0.05f; + npc.spriteDirection = -npc.direction; + } + } + #endregion - #region Swimming AI - public static void PassiveSwimmingAI(NPC npc, Mod mod, int passiveness, float detectRange, float xSpeed, float ySpeed, float speedLimitX, float speedLimitY, float rotation, bool spriteFacesLeft = true) + #region Swimming AI + public static void PassiveSwimmingAI(NPC npc, Mod mod, int passiveness, float detectRange, float xSpeed, float ySpeed, float speedLimitX, float speedLimitY, float rotation, bool spriteFacesLeft = true) { - if (spriteFacesLeft) - npc.spriteDirection = (npc.direction > 0) ? 1 : -1; - else - npc.spriteDirection = (npc.direction > 0) ? -1 : 1; + if (spriteFacesLeft) + npc.spriteDirection = (npc.direction > 0) ? 1 : -1; + else + npc.spriteDirection = (npc.direction > 0) ? -1 : 1; npc.noGravity = true; if (npc.direction == 0) @@ -7672,47 +7672,47 @@ namespace CalamityMod.NPCs { bool flag14 = npc.chaseable; npc.TargetClosest(false); - if (passiveness != 2) - { - if (npc.type == ModContent.NPCType()) - { - if (Main.player[npc.target].wet && !Main.player[npc.target].dead) - { - flag14 = true; - npc.chaseable = true; //once the enemy has detected the player, let minions fuck it up - } - } - if (npc.type == ModContent.NPCType()) - { - if (!Main.player[npc.target].dead) - { - flag14 = true; - npc.chaseable = true; //once the enemy has detected the player, let minions fuck it up - } - } - else if (Main.player[npc.target].wet && !Main.player[npc.target].dead && - (Main.player[npc.target].Center - npc.Center).Length() < detectRange && - Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - flag14 = true; - npc.chaseable = true; //once the enemy has detected the player, let minions fuck it up - } - else - { - if (passiveness == 1) - { - flag14 = false; - } - } - } + if (passiveness != 2) + { + if (npc.type == ModContent.NPCType()) + { + if (Main.player[npc.target].wet && !Main.player[npc.target].dead) + { + flag14 = true; + npc.chaseable = true; //once the enemy has detected the player, let minions fuck it up + } + } + if (npc.type == ModContent.NPCType()) + { + if (!Main.player[npc.target].dead) + { + flag14 = true; + npc.chaseable = true; //once the enemy has detected the player, let minions fuck it up + } + } + else if (Main.player[npc.target].wet && !Main.player[npc.target].dead && + (Main.player[npc.target].Center - npc.Center).Length() < detectRange && + Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + flag14 = true; + npc.chaseable = true; //once the enemy has detected the player, let minions fuck it up + } + else + { + if (passiveness == 1) + { + flag14 = false; + } + } + } if ((Main.player[npc.target].dead || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) && flag14) { flag14 = false; } if (!flag14 || passiveness == 0) { - if (passiveness == 0) - npc.TargetClosest(true); + if (passiveness == 0) + npc.TargetClosest(true); if (npc.collideX) { npc.velocity.X = npc.velocity.X * -1f; @@ -7739,48 +7739,48 @@ namespace CalamityMod.NPCs if (flag14 && passiveness != 2) { npc.TargetClosest(true); - if (passiveness == 3) - { - npc.velocity.X = npc.velocity.X - (float)npc.direction * xSpeed; - npc.velocity.Y = npc.velocity.Y - (float)npc.directionY * ySpeed; - } - else - { - npc.velocity.X = npc.velocity.X + (float)npc.direction * (CalamityWorld.death ? 2f * xSpeed : xSpeed); - npc.velocity.Y = npc.velocity.Y + (float)npc.directionY * (CalamityWorld.death ? 2f * ySpeed : ySpeed); - } - float velocityCapX = CalamityWorld.death && passiveness != 3 ? 2f * speedLimitX : speedLimitX; - float velocityCapY = CalamityWorld.death && passiveness != 3 ? 2f * speedLimitY : speedLimitY; + if (passiveness == 3) + { + npc.velocity.X = npc.velocity.X - (float)npc.direction * xSpeed; + npc.velocity.Y = npc.velocity.Y - (float)npc.directionY * ySpeed; + } + else + { + npc.velocity.X = npc.velocity.X + (float)npc.direction * (CalamityWorld.death ? 2f * xSpeed : xSpeed); + npc.velocity.Y = npc.velocity.Y + (float)npc.directionY * (CalamityWorld.death ? 2f * ySpeed : ySpeed); + } + float velocityCapX = CalamityWorld.death && passiveness != 3 ? 2f * speedLimitX : speedLimitX; + float velocityCapY = CalamityWorld.death && passiveness != 3 ? 2f * speedLimitY : speedLimitY; npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -velocityCapX, velocityCapX); npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -velocityCapY, velocityCapY); - if (npc.type == ModContent.NPCType()) - { - npc.localAI[0] += (CalamityWorld.death ? 2f : 1f); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= 120f) - { - npc.localAI[0] = 0f; - 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(-20, 21); - float num7 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-20, 21); - float num8 = (float)Math.Sqrt((double)(num6 * num6 + num7 * num7)); - num8 = speed / num8; - num6 *= num8; - num7 *= num8; - int damage = 50; - if (Main.expertMode) - { - damage = 40; - } - int beam = Projectile.NewProjectile(npc.Center.X + (npc.spriteDirection == 1 ? 25f : -25f), npc.Center.Y + (Main.player[npc.target].position.Y > npc.Center.Y ? 5f : -5f), num6, num7, ProjectileID.EyeBeam, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[beam].tileCollide = true; - } - } - } - if (npc.type == ModContent.NPCType()) - { + if (npc.type == ModContent.NPCType()) + { + npc.localAI[0] += (CalamityWorld.death ? 2f : 1f); + if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= 120f) + { + npc.localAI[0] = 0f; + 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(-20, 21); + float num7 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-20, 21); + float num8 = (float)Math.Sqrt((double)(num6 * num6 + num7 * num7)); + num8 = speed / num8; + num6 *= num8; + num7 *= num8; + int damage = 50; + if (Main.expertMode) + { + damage = 40; + } + int beam = Projectile.NewProjectile(npc.Center.X + (npc.spriteDirection == 1 ? 25f : -25f), npc.Center.Y + (Main.player[npc.target].position.Y > npc.Center.Y ? 5f : -5f), num6, num7, ProjectileID.EyeBeam, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[beam].tileCollide = true; + } + } + } + if (npc.type == ModContent.NPCType()) + { if ((Main.player[npc.target].Center - npc.Center).Length() < 350f) { npc.localAI[0] += (CalamityWorld.death ? 3f : 1f); @@ -7806,11 +7806,11 @@ namespace CalamityMod.NPCs } } } - } - if (npc.type == ModContent.NPCType()) - { - npc.direction *= -1; - } + } + if (npc.type == ModContent.NPCType()) + { + npc.direction *= -1; + } } else { @@ -7884,9 +7884,9 @@ namespace CalamityMod.NPCs npc.ai[0] = 1f; } npc.rotation = npc.velocity.Y * (float)npc.direction * rotation; - float rotationLimit = 2f * rotation; - npc.rotation = MathHelper.Clamp(npc.rotation, -rotationLimit, rotationLimit); - } - #endregion - } + float rotationLimit = 2f * rotation; + npc.rotation = MathHelper.Clamp(npc.rotation, -rotationLimit, rotationLimit); + } + #endregion + } } diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index 48a0f8c8bb..9d155b31a6 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -16,7 +16,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs { - public partial class CalamityGlobalAI + public partial class CalamityGlobalAI { #region Death Mode NPC AI diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index c89847f14b..59cff5306d 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -66,43 +66,43 @@ using CalamityMod.Balancing; namespace CalamityMod.NPCs { - public partial class CalamityGlobalNPC : GlobalNPC + public partial class CalamityGlobalNPC : GlobalNPC { - #region Variables + #region Variables - public float DR { get; set; } = 0f; + public float DR { get; set; } = 0f; - public int KillTime { get; set; } = 0; + public int KillTime { get; set; } = 0; - public const int DoGPhase1KillTime = 5400; + public const int DoGPhase1KillTime = 5400; - // Debuff Vulnerabilities - // null = neutral, true = vulnerable, false = resistant - // neutral = 100% effective, vulnerable = 400% effective DoT and 200% effective non-DoT effects (within reason, some aren't exactly 200% more effective), resistant = 50% effective - public bool? VulnerableToHeat = null; - public bool? VulnerableToCold = null; - public bool? VulnerableToSickness = null; - public bool? VulnerableToElectricity = null; - public bool? VulnerableToWater = null; + // Debuff Vulnerabilities + // null = neutral, true = vulnerable, false = resistant + // neutral = 100% effective, vulnerable = 400% effective DoT and 200% effective non-DoT effects (within reason, some aren't exactly 200% more effective), resistant = 50% effective + public bool? VulnerableToHeat = null; + public bool? VulnerableToCold = null; + public bool? VulnerableToSickness = null; + public bool? VulnerableToElectricity = null; + public bool? VulnerableToWater = null; - // Eskimo Set effect - public bool IncreasedColdEffects = false; + // Eskimo Set effect + public bool IncreasedColdEffects = false; - // Fireball and Cinnamon Roll effect - public bool IncreasedHeatEffects = false; + // Fireball and Cinnamon Roll effect + public bool IncreasedHeatEffects = false; - // Evergreen Gin effect - public bool IncreasedSicknessAndWaterEffects = false; + // Evergreen Gin effect + public bool IncreasedSicknessAndWaterEffects = false; - // Biome enrage timer max - public const int biomeEnrageTimerMax = 300; + // Biome enrage timer max + public const int biomeEnrageTimerMax = 300; - public bool ShouldFallThroughPlatforms; + public bool ShouldFallThroughPlatforms; - /// - /// 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; + /// + /// 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.

@@ -112,45 +112,45 @@ namespace CalamityMod.NPCs public Dictionary flatDRReductions = new Dictionary(); public Dictionary multDRReductions = new Dictionary(); - /// - /// Allows hostile NPCs to deal damage to the player's defense stat, used mostly for hard-hitting bosses. - /// - public bool canBreakPlayerDefense = false; + /// + /// Allows hostile NPCs to deal damage to the player's defense stat, used mostly for hard-hitting bosses. + /// + public bool canBreakPlayerDefense = false; - // Total defense loss from some true melee hits and other things that reduce defense - public int miscDefenseLoss = 0; + // Total defense loss from some true melee hits and other things that reduce defense + public int miscDefenseLoss = 0; - // Distance values for when bosses increase velocity to catch up to their target - public const float CatchUpDistance200Tiles = 3200f; - public const float CatchUpDistance350Tiles = 5600f; + // Distance values for when bosses increase velocity to catch up to their target + public const float CatchUpDistance200Tiles = 3200f; + public const float CatchUpDistance350Tiles = 5600f; - // Boss Zen distance - private const float BossZenDistance = 6400f; + // Boss Zen distance + private const float BossZenDistance = 6400f; - // Boss contact and projectile damage multiplier in Malice Mode - public const double MaliceModeDamageMultiplier = 1.25; + // Boss contact and projectile damage multiplier in Malice Mode + public const double MaliceModeDamageMultiplier = 1.25; - // Variable used to nerf desert prehardmode enemies pre-Desert Scourge - private const double DesertEnemyStatMultiplier = 0.75; + // Variable used to nerf desert prehardmode enemies pre-Desert Scourge + private const double DesertEnemyStatMultiplier = 0.75; - // Max velocity used in contact damage scaling - public float maxVelocity = 0f; + // Max velocity used in contact damage scaling + public float maxVelocity = 0f; - // Dash damage immunity timer - public const int maxPlayerImmunities = Main.maxPlayers + 1; - public int[] dashImmunityTime = new int[maxPlayerImmunities]; + // Dash damage immunity timer + public const int maxPlayerImmunities = Main.maxPlayers + 1; + public int[] dashImmunityTime = new int[maxPlayerImmunities]; - // Town NPC shop alert animation variables - public int shopAlertAnimTimer = 0; - public int shopAlertAnimFrame = 0; + // Town NPC shop alert animation variables + public int shopAlertAnimTimer = 0; + public int shopAlertAnimFrame = 0; - // Rage interactions - public bool DoesNotGenerateRage = false; + // Rage interactions + public bool DoesNotGenerateRage = false; // NewAI internal const int maxAIMod = 4; public float[] newAI = new float[maxAIMod]; - public int AITimer = 0; + public int AITimer = 0; // Town NPC Patreon public bool setNewName = true; @@ -158,22 +158,22 @@ namespace CalamityMod.NPCs // Draedons Remote public static bool DraedonMayhem = false; - // Stuff used by the Boss Health UI - public bool SplittingWorm = false; - public bool CanHaveBossHealthBar = false; - public bool ShouldCloseHPBar = false; + // Stuff used by the Boss Health UI + public bool SplittingWorm = false; + public bool CanHaveBossHealthBar = false; + public bool ShouldCloseHPBar = false; - // Timer for how long an NPC is immune to certain debuffs - public const int slowingDebuffResistanceMin = 1800; - public int debuffResistanceTimer = 0; + // Timer for how long an NPC is immune to certain debuffs + public const int slowingDebuffResistanceMin = 1800; + public int debuffResistanceTimer = 0; - // If a boss is affected by knockback and a timer for how long that boss is immune to knockback after being knocked back - public bool bossCanBeKnockedBack = false; - public const int knockbackResistanceMin = 180; - public int knockbackResistanceTimer = 0; + // If a boss is affected by knockback and a timer for how long that boss is immune to knockback after being knocked back + public bool bossCanBeKnockedBack = false; + public const int knockbackResistanceMin = 180; + public int knockbackResistanceTimer = 0; - // Debuffs - public int vaporfied = 0; + // Debuffs + public int vaporfied = 0; public int timeSlow = 0; public int gState = 0; public int tesla = 0; @@ -188,19 +188,19 @@ namespace CalamityMod.NPCs public int wCleave = 0; public int bBlood = 0; public int dFlames = 0; - public int marked = 0; + public int marked = 0; public int irradiated = 0; public int bFlames = 0; public int hFlames = 0; public int pFlames = 0; public int aCrunch = 0; - // Soma Prime Shred deals damage with DirectStrikes instead of with direct debuff damage - // It also stacks, scales with ranged damage, and can crit, meaning it needs to know who applied it most recently - public int somaShredStacks = 0; - public int somaShredApplicator = -1; - // Reduced by the number of active stacks every frame. If it hits zero, one stack disappears. - public int somaShredFalloff = Shred.StackFalloffFrames; + // Soma Prime Shred deals damage with DirectStrikes instead of with direct debuff damage + // It also stacks, scales with ranged damage, and can crit, meaning it needs to know who applied it most recently + public int somaShredStacks = 0; + public int somaShredApplicator = -1; + // Reduced by the number of active stacks every frame. If it hits zero, one stack disappears. + public int somaShredFalloff = Shred.StackFalloffFrames; public int cDepth = 0; public int gsInferno = 0; @@ -221,11 +221,11 @@ namespace CalamityMod.NPCs public int sagePoisonDamage = 0; public int vulnerabilityHex = 0; public int banishingFire = 0; - public int wither = 0; - public int RancorBurnTime = 0; + public int wither = 0; + public int RancorBurnTime = 0; - // whoAmI Variables - public static int[] bobbitWormBottom = new int[5]; + // whoAmI Variables + public static int[] bobbitWormBottom = new int[5]; public static int DD2CrystalIndex = -1; public static int hiveMind = -1; public static int perfHive = -1; @@ -247,14 +247,14 @@ namespace CalamityMod.NPCs public static int scavenger = -1; public static int energyFlame = -1; public static int doughnutBoss = -1; - public static int doughnutBossDefender = -1; - public static int doughnutBossHealer = -1; - public static int holyBossAttacker = -1; + public static int doughnutBossDefender = -1; + public static int doughnutBossHealer = -1; + public static int holyBossAttacker = -1; public static int holyBossDefender = -1; public static int holyBossHealer = -1; public static int holyBoss = -1; public static int voidBoss = -1; - public static int signus = -1; + public static int signus = -1; public static int ghostBossClone = -1; public static int ghostBoss = -1; public static int DoGHead = -1; @@ -262,34 +262,34 @@ namespace CalamityMod.NPCs public static int SCalCatastrophe = -1; public static int SCal = -1; public static int SCalWorm = -1; - public static int draedon = -1; - public static int draedonExoMechWorm = -1; - public static int draedonExoMechTwinRed = -1; - public static int draedonExoMechTwinGreen = -1; - public static int draedonExoMechPrime = -1; - public static int draedonExoMechPrimePlasmaCannon = -1; - public static int adultEidolonWyrmHead = -1; + public static int draedon = -1; + public static int draedonExoMechWorm = -1; + public static int draedonExoMechTwinRed = -1; + public static int draedonExoMechTwinGreen = -1; + public static int draedonExoMechPrime = -1; + public static int draedonExoMechPrimePlasmaCannon = -1; + public static int adultEidolonWyrmHead = -1; - // Drawing variables. - public FireParticleSet VulnerabilityHexFireDrawer = null; + // Drawing variables. + public FireParticleSet VulnerabilityHexFireDrawer = null; - // Boss Enrage variable for use with the boss health UI. - // The logic behind this is as follows: - // 1 - For special cases with super-enrages (specifically Yharon/SCal with their arenas), go solely based on whether that enrage is active. That information is most important to the player. - // 2 - Otherwise, check if the demonshade enrage is active. If it is, register this as true. If not, go to step 3. - // 3 - Check if a specific enrage condition (such as Duke Fishron's Ocean check) is met. If it is, and Boss Rush is not active, set this to true. If not, go to step 4. - // 4 - Check if malice is active and Boss Rush isn't. If so, set this to true. - public bool CurrentlyEnraged; + // Boss Enrage variable for use with the boss health UI. + // The logic behind this is as follows: + // 1 - For special cases with super-enrages (specifically Yharon/SCal with their arenas), go solely based on whether that enrage is active. That information is most important to the player. + // 2 - Otherwise, check if the demonshade enrage is active. If it is, register this as true. If not, go to step 3. + // 3 - Check if a specific enrage condition (such as Duke Fishron's Ocean check) is met. If it is, and Boss Rush is not active, set this to true. If not, go to step 4. + // 4 - Check if malice is active and Boss Rush isn't. If so, set this to true. + public bool CurrentlyEnraged; - // Increased defense or DR variable for use with the boss health UI. - // The logic behind this is as follows: - // 1 - When bosses are transitioning phases they gain a massive DR increase. - // 2 - When bosses are using certain attacks that make them particularly vulnerable they gain a massive DR or defense increase. - public bool CurrentlyIncreasingDefenseOrDR; + // Increased defense or DR variable for use with the boss health UI. + // The logic behind this is as follows: + // 1 - When bosses are transitioning phases they gain a massive DR increase. + // 2 - When bosses are using certain attacks that make them particularly vulnerable they gain a massive DR or defense increase. + public bool CurrentlyIncreasingDefenseOrDR; - // Other Boss Rush stuff - public bool DoesNotDisappearInBossRush; - #endregion + // Other Boss Rush stuff + public bool DoesNotDisappearInBossRush; + #endregion #region Instance Per Entity public override bool InstancePerEntity => true; @@ -303,25 +303,25 @@ namespace CalamityMod.NPCs { if (type >= 0) { - if (!Main.npc[type].active) - { - type = -1; - } - else if (type2 == -1) - { - if (Main.npc[type].type != type1) - type = -1; - } - else - { - if (Main.npc[type].type != type1 && Main.npc[type].type != type2) - type = -1; - } + if (!Main.npc[type].active) + { + type = -1; + } + else if (type2 == -1) + { + if (Main.npc[type].type != type1) + type = -1; + } + else + { + if (Main.npc[type].type != type1 && Main.npc[type].type != type2) + type = -1; + } } } - for (int i = 0; i < bobbitWormBottom.Length; i++) - ResetSavedIndex(ref bobbitWormBottom[i], NPCType()); + for (int i = 0; i < bobbitWormBottom.Length; i++) + ResetSavedIndex(ref bobbitWormBottom[i], NPCType()); ResetSavedIndex(ref DD2CrystalIndex, NPCID.DD2EterniaCrystal); ResetSavedIndex(ref hiveMind, NPCType()); @@ -344,14 +344,14 @@ namespace CalamityMod.NPCs ResetSavedIndex(ref scavenger, NPCType()); ResetSavedIndex(ref energyFlame, NPCType()); ResetSavedIndex(ref doughnutBoss, NPCType()); - ResetSavedIndex(ref doughnutBossDefender, NPCType()); - ResetSavedIndex(ref doughnutBossHealer, NPCType()); - ResetSavedIndex(ref holyBossAttacker, NPCType()); + ResetSavedIndex(ref doughnutBossDefender, NPCType()); + ResetSavedIndex(ref doughnutBossHealer, 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 signus, NPCType()); ResetSavedIndex(ref ghostBossClone, NPCType()); ResetSavedIndex(ref ghostBoss, NPCType()); ResetSavedIndex(ref DoGHead, NPCType()); @@ -360,21 +360,21 @@ namespace CalamityMod.NPCs ResetSavedIndex(ref SCal, NPCType()); ResetSavedIndex(ref SCalWorm, NPCType()); - ResetSavedIndex(ref draedon, NPCType()); - ResetSavedIndex(ref draedonExoMechWorm, NPCType()); - ResetSavedIndex(ref draedonExoMechTwinRed, NPCType()); - ResetSavedIndex(ref draedonExoMechTwinGreen, NPCType()); - ResetSavedIndex(ref draedonExoMechPrime, NPCType()); - ResetSavedIndex(ref draedonExoMechPrimePlasmaCannon, NPCType()); + ResetSavedIndex(ref draedon, NPCType()); + ResetSavedIndex(ref draedonExoMechWorm, NPCType()); + ResetSavedIndex(ref draedonExoMechTwinRed, NPCType()); + ResetSavedIndex(ref draedonExoMechTwinGreen, NPCType()); + ResetSavedIndex(ref draedonExoMechPrime, NPCType()); + ResetSavedIndex(ref draedonExoMechPrimePlasmaCannon, NPCType()); - ResetSavedIndex(ref adultEidolonWyrmHead, NPCType()); + ResetSavedIndex(ref adultEidolonWyrmHead, NPCType()); - // Reset the enraged state every frame. The expectation is that bosses will continuously set it back to true if necessary. - CurrentlyEnraged = false; - CurrentlyIncreasingDefenseOrDR = false; - CanHaveBossHealthBar = false; - ShouldCloseHPBar = false; - } + // Reset the enraged state every frame. The expectation is that bosses will continuously set it back to true if necessary. + CurrentlyEnraged = false; + CurrentlyIncreasingDefenseOrDR = false; + CanHaveBossHealthBar = false; + ShouldCloseHPBar = false; + } #endregion #region Life Regen @@ -390,8 +390,8 @@ namespace CalamityMod.NPCs npc.AddBuff(BuffType(), 2); } - // Special venom debuff case for the Lionfish and certain other projectiles. - if (npc.venom) + // Special venom debuff case for the Lionfish and certain other projectiles. + if (npc.venom) { if (npc.lifeRegen > 0) npc.lifeRegen = 0; @@ -443,44 +443,44 @@ namespace CalamityMod.NPCs if (shellfishVore > 0) { int projectileCount = 0; - int owner = 255; + int owner = 255; for (int j = 0; j < Main.maxProjectiles; j++) { if (Main.projectile[j].active && Main.projectile[j].type == ProjectileType() && Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI) { - owner = Main.projectile[j].owner; + owner = Main.projectile[j].owner; projectileCount++; - if (projectileCount >= 5) - { - projectileCount = 5; - break; - } + if (projectileCount >= 5) + { + projectileCount = 5; + break; + } } } - Item heldItem = Main.player[owner].ActiveItem(); - int totalDamage = (int)(150 * Main.player[owner].minionDamage); - bool forbidden = Main.player[owner].head == ArmorIDs.Head.AncientBattleArmor && Main.player[owner].body == ArmorIDs.Body.AncientBattleArmor && Main.player[owner].legs == ArmorIDs.Legs.AncientBattleArmor; - bool reducedNerf = Main.player[owner].Calamity().fearmongerSet || (forbidden && heldItem.magic); + Item heldItem = Main.player[owner].ActiveItem(); + int totalDamage = (int)(150 * Main.player[owner].minionDamage); + bool forbidden = Main.player[owner].head == ArmorIDs.Head.AncientBattleArmor && Main.player[owner].body == ArmorIDs.Body.AncientBattleArmor && Main.player[owner].legs == ArmorIDs.Legs.AncientBattleArmor; + bool reducedNerf = Main.player[owner].Calamity().fearmongerSet || (forbidden && heldItem.magic); - double summonNerfMult = reducedNerf ? 0.75 : 0.5; - if (!Main.player[owner].Calamity().profanedCrystalBuffs) - { - if (heldItem.type > ItemID.None) - { - if (!heldItem.summon && - (heldItem.melee || heldItem.ranged || heldItem.magic || heldItem.Calamity().rogue) && - heldItem.hammer == 0 && heldItem.pick == 0 && heldItem.axe == 0 && heldItem.useStyle != 0 && - !heldItem.accessory && heldItem.ammo == AmmoID.None) - { - totalDamage = (int)(totalDamage * summonNerfMult); - } - } - } + double summonNerfMult = reducedNerf ? 0.75 : 0.5; + if (!Main.player[owner].Calamity().profanedCrystalBuffs) + { + if (heldItem.type > ItemID.None) + { + if (!heldItem.summon && + (heldItem.melee || heldItem.ranged || heldItem.magic || heldItem.Calamity().rogue) && + heldItem.hammer == 0 && heldItem.pick == 0 && heldItem.axe == 0 && heldItem.useStyle != 0 && + !heldItem.accessory && heldItem.ammo == AmmoID.None) + { + totalDamage = (int)(totalDamage * summonNerfMult); + } + } + } - int totalDisplayedDamage = totalDamage / 5; - ApplyDPSDebuff(projectileCount * totalDamage, projectileCount * totalDisplayedDamage, ref npc.lifeRegen, ref damage); + int totalDisplayedDamage = totalDamage / 5; + ApplyDPSDebuff(projectileCount * totalDamage, projectileCount * totalDisplayedDamage, ref npc.lifeRegen, ref damage); } if (clamDebuff > 0) @@ -490,14 +490,14 @@ 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 == ProjectileType()) - projectileCount += 2; - if (Main.projectile[j].type == ProjectileType()) - projectileCount++; + if (Main.projectile[j].type == ProjectileType()) + projectileCount += 2; + if (Main.projectile[j].type == ProjectileType()) + projectileCount++; } } - ApplyDPSDebuff(projectileCount * 15, projectileCount * 3, ref npc.lifeRegen, ref damage); + ApplyDPSDebuff(projectileCount * 15, projectileCount * 3, ref npc.lifeRegen, ref damage); } if (irradiated > 0) @@ -513,367 +513,367 @@ namespace CalamityMod.NPCs } if (projectileCount > 0) - ApplyDPSDebuff(projectileCount * 20, projectileCount * 4, ref npc.lifeRegen, ref damage); - else - ApplyDPSDebuff(20, 4, ref npc.lifeRegen, ref damage); + ApplyDPSDebuff(projectileCount * 20, projectileCount * 4, ref npc.lifeRegen, ref damage); + else + ApplyDPSDebuff(20, 4, ref npc.lifeRegen, ref damage); } - // Exo Freeze, Glacial State and Temporal Sadness don't work on normal/expert Queen Bee. - if (debuffResistanceTimer <= 0 || (debuffResistanceTimer > slowingDebuffResistanceMin)) - { - if (npc.type != NPCID.QueenBee || CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - float baseXVelocityMult = 0.9f; - float baseYVelocityIncrease = 0.05f; - if (VulnerableToCold.HasValue) - { - if (VulnerableToCold.Value) - { - baseXVelocityMult = 0.5f; - baseYVelocityIncrease = 0.2f; - } - else - { - baseXVelocityMult = 0.98f; - baseYVelocityIncrease = 0.01f; - } - } + // Exo Freeze, Glacial State and Temporal Sadness don't work on normal/expert Queen Bee. + if (debuffResistanceTimer <= 0 || (debuffResistanceTimer > slowingDebuffResistanceMin)) + { + if (npc.type != NPCID.QueenBee || CalamityWorld.revenge || BossRushEvent.BossRushActive) + { + float baseXVelocityMult = 0.9f; + float baseYVelocityIncrease = 0.05f; + if (VulnerableToCold.HasValue) + { + if (VulnerableToCold.Value) + { + baseXVelocityMult = 0.5f; + baseYVelocityIncrease = 0.2f; + } + else + { + baseXVelocityMult = 0.98f; + baseYVelocityIncrease = 0.01f; + } + } - if (eFreeze > 0) - { - if (!CalamityPlayer.areThereAnyDamnBosses) - { - npc.velocity.X *= baseXVelocityMult; - npc.velocity.Y += baseYVelocityIncrease; - if (npc.velocity.Y > 15f) - npc.velocity.Y = 15f; - } - else - npc.velocity *= baseXVelocityMult; - } - else if (gState > 0) - { - if (!CalamityPlayer.areThereAnyDamnBosses) - { - npc.velocity.X *= baseXVelocityMult; - npc.velocity.Y += baseYVelocityIncrease * 0.5f; - if (npc.velocity.Y > 15f) - npc.velocity.Y = 15f; - } - else - { - npc.velocity *= baseXVelocityMult; - } - } - else if (tSad > 0) - npc.velocity *= 0.5f; - } - } + if (eFreeze > 0) + { + if (!CalamityPlayer.areThereAnyDamnBosses) + { + npc.velocity.X *= baseXVelocityMult; + npc.velocity.Y += baseYVelocityIncrease; + if (npc.velocity.Y > 15f) + npc.velocity.Y = 15f; + } + else + npc.velocity *= baseXVelocityMult; + } + else if (gState > 0) + { + if (!CalamityPlayer.areThereAnyDamnBosses) + { + npc.velocity.X *= baseXVelocityMult; + npc.velocity.Y += baseYVelocityIncrease * 0.5f; + if (npc.velocity.Y > 15f) + npc.velocity.Y = 15f; + } + else + { + npc.velocity *= baseXVelocityMult; + } + } + else if (tSad > 0) + npc.velocity *= 0.5f; + } + } - // Debuff vulnerabilities and resistances. - // Damage multiplier calcs. - // Worms that are vulnerable to debuffs and Slime God slimes take reduced damage from vulnerabilities. - bool wormBoss = CalamityLists.DesertScourgeIDs.Contains(npc.type) || CalamityLists.EaterofWorldsIDs.Contains(npc.type) || CalamityLists.PerforatorIDs.Contains(npc.type) || - CalamityLists.AquaticScourgeIDs.Contains(npc.type) || CalamityLists.AstrumDeusIDs.Contains(npc.type) || CalamityLists.StormWeaverIDs.Contains(npc.type); - bool slimeGod = CalamityLists.SlimeGodIDs.Contains(npc.type); + // Debuff vulnerabilities and resistances. + // Damage multiplier calcs. + // Worms that are vulnerable to debuffs and Slime God slimes take reduced damage from vulnerabilities. + bool wormBoss = CalamityLists.DesertScourgeIDs.Contains(npc.type) || CalamityLists.EaterofWorldsIDs.Contains(npc.type) || CalamityLists.PerforatorIDs.Contains(npc.type) || + CalamityLists.AquaticScourgeIDs.Contains(npc.type) || CalamityLists.AstrumDeusIDs.Contains(npc.type) || CalamityLists.StormWeaverIDs.Contains(npc.type); + bool slimeGod = CalamityLists.SlimeGodIDs.Contains(npc.type); - double heatDamageMult = npc.drippingSlime ? ((wormBoss || slimeGod) ? 3D : 5D) : 1D; - if (VulnerableToHeat.HasValue) - { - if (VulnerableToHeat.Value) - heatDamageMult *= npc.drippingSlime ? ((wormBoss || slimeGod) ? 1.5 : 2D) : ((wormBoss || slimeGod) ? 3D : 5D); - else - heatDamageMult *= npc.drippingSlime ? 0.2 : 0.5; - } + double heatDamageMult = npc.drippingSlime ? ((wormBoss || slimeGod) ? 3D : 5D) : 1D; + if (VulnerableToHeat.HasValue) + { + if (VulnerableToHeat.Value) + heatDamageMult *= npc.drippingSlime ? ((wormBoss || slimeGod) ? 1.5 : 2D) : ((wormBoss || slimeGod) ? 3D : 5D); + else + heatDamageMult *= npc.drippingSlime ? 0.2 : 0.5; + } - double coldDamageMult = 1D; - if (VulnerableToCold.HasValue) - { - if (VulnerableToCold.Value) - coldDamageMult *= wormBoss ? 3D : 5D; - else - coldDamageMult *= 0.5; - } + double coldDamageMult = 1D; + if (VulnerableToCold.HasValue) + { + if (VulnerableToCold.Value) + coldDamageMult *= wormBoss ? 3D : 5D; + else + coldDamageMult *= 0.5; + } - double sicknessDamageMult = irradiated > 0 ? (wormBoss ? 3D : 5D) : 1D; - if (VulnerableToSickness.HasValue) - { - if (VulnerableToSickness.Value) - sicknessDamageMult *= irradiated > 0 ? (wormBoss ? 1.5 : 2D) : (wormBoss ? 3D : 5D); - else - sicknessDamageMult *= irradiated > 0 ? 0.2 : 0.5; - } + double sicknessDamageMult = irradiated > 0 ? (wormBoss ? 3D : 5D) : 1D; + if (VulnerableToSickness.HasValue) + { + if (VulnerableToSickness.Value) + sicknessDamageMult *= irradiated > 0 ? (wormBoss ? 1.5 : 2D) : (wormBoss ? 3D : 5D); + else + sicknessDamageMult *= irradiated > 0 ? 0.2 : 0.5; + } - bool increasedElectricityDamage = npc.wet || npc.honeyWet || npc.lavaWet || npc.dripping; - double electricityDamageMult = increasedElectricityDamage ? (wormBoss ? 3D : 5D) : 1D; - if (VulnerableToElectricity.HasValue) - { - if (VulnerableToElectricity.Value) - electricityDamageMult *= increasedElectricityDamage ? (wormBoss ? 1.5 : 2D) : (wormBoss ? 3D : 5D); - else - electricityDamageMult *= increasedElectricityDamage ? 0.2 : 0.5; - } + bool increasedElectricityDamage = npc.wet || npc.honeyWet || npc.lavaWet || npc.dripping; + double electricityDamageMult = increasedElectricityDamage ? (wormBoss ? 3D : 5D) : 1D; + if (VulnerableToElectricity.HasValue) + { + if (VulnerableToElectricity.Value) + electricityDamageMult *= increasedElectricityDamage ? (wormBoss ? 1.5 : 2D) : (wormBoss ? 3D : 5D); + else + electricityDamageMult *= increasedElectricityDamage ? 0.2 : 0.5; + } - double waterDamageMult = 1D; - if (VulnerableToWater.HasValue) - { - if (VulnerableToWater.Value) - waterDamageMult *= wormBoss ? 3D : 5D; - else - waterDamageMult *= 0.5; - } + double waterDamageMult = 1D; + if (VulnerableToWater.HasValue) + { + if (VulnerableToWater.Value) + waterDamageMult *= wormBoss ? 3D : 5D; + else + waterDamageMult *= 0.5; + } - if (IncreasedHeatEffects) - heatDamageMult += 0.5; + if (IncreasedHeatEffects) + heatDamageMult += 0.5; - if (IncreasedColdEffects) - coldDamageMult += 0.5; + if (IncreasedColdEffects) + coldDamageMult += 0.5; - if (IncreasedSicknessAndWaterEffects) - { - sicknessDamageMult += 0.5; - waterDamageMult += 0.5; - } + if (IncreasedSicknessAndWaterEffects) + { + sicknessDamageMult += 0.5; + waterDamageMult += 0.5; + } - // Subtract 1 for the vanilla damage multiplier because it's already dealing DoT in the vanilla regen code. - double vanillaHeatDamageMult = heatDamageMult - 1D; - double vanillaColdDamageMult = coldDamageMult - 1D; - double vanillaSicknessDamageMult = sicknessDamageMult - 1D; + // Subtract 1 for the vanilla damage multiplier because it's already dealing DoT in the vanilla regen code. + double vanillaHeatDamageMult = heatDamageMult - 1D; + double vanillaColdDamageMult = coldDamageMult - 1D; + double vanillaSicknessDamageMult = sicknessDamageMult - 1D; - // On Fire - if (npc.onFire) - { - int baseOnFireDoTValue = (int)((npc.oiled ? 28 : 8) * vanillaHeatDamageMult); - npc.lifeRegen -= baseOnFireDoTValue; - if (damage < baseOnFireDoTValue / 4) - damage = baseOnFireDoTValue / 4; - } + // On Fire + if (npc.onFire) + { + int baseOnFireDoTValue = (int)((npc.oiled ? 28 : 8) * vanillaHeatDamageMult); + npc.lifeRegen -= baseOnFireDoTValue; + if (damage < baseOnFireDoTValue / 4) + damage = baseOnFireDoTValue / 4; + } - // Cursed Inferno - if (npc.onFire2) - { - int baseCursedInfernoDoTValue = (int)((npc.oiled ? 36 : 12) * vanillaHeatDamageMult); - npc.lifeRegen -= baseCursedInfernoDoTValue; - if (damage < baseCursedInfernoDoTValue / 4) - damage = baseCursedInfernoDoTValue / 4; - } + // Cursed Inferno + if (npc.onFire2) + { + int baseCursedInfernoDoTValue = (int)((npc.oiled ? 36 : 12) * vanillaHeatDamageMult); + npc.lifeRegen -= baseCursedInfernoDoTValue; + if (damage < baseCursedInfernoDoTValue / 4) + damage = baseCursedInfernoDoTValue / 4; + } - // Shadowflame - if (npc.shadowFlame) - { - int baseShadowFlameDoTValue = (int)((npc.oiled ? 58 : 30) * vanillaHeatDamageMult); - npc.lifeRegen -= baseShadowFlameDoTValue; - if (damage < baseShadowFlameDoTValue / 4) - damage = baseShadowFlameDoTValue / 4; - } + // Shadowflame + if (npc.shadowFlame) + { + int baseShadowFlameDoTValue = (int)((npc.oiled ? 58 : 30) * vanillaHeatDamageMult); + npc.lifeRegen -= baseShadowFlameDoTValue; + if (damage < baseShadowFlameDoTValue / 4) + damage = baseShadowFlameDoTValue / 4; + } - // Brimstone Flames - if (bFlames > 0) - { - int baseBrimstoneFlamesDoTValue = (int)((npc.oiled ? 92 : 40) * heatDamageMult); - ApplyDPSDebuff(baseBrimstoneFlamesDoTValue, baseBrimstoneFlamesDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // Brimstone Flames + if (bFlames > 0) + { + int baseBrimstoneFlamesDoTValue = (int)((npc.oiled ? 92 : 40) * heatDamageMult); + ApplyDPSDebuff(baseBrimstoneFlamesDoTValue, baseBrimstoneFlamesDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // Holy Flames - if (hFlames > 0) - { - int baseHolyFlamesDoTValue = (int)((npc.oiled ? 114 : 50) * heatDamageMult); - ApplyDPSDebuff(baseHolyFlamesDoTValue, baseHolyFlamesDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // Holy Flames + if (hFlames > 0) + { + int baseHolyFlamesDoTValue = (int)((npc.oiled ? 114 : 50) * heatDamageMult); + ApplyDPSDebuff(baseHolyFlamesDoTValue, baseHolyFlamesDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // God Slayer Inferno - if (gsInferno > 0) - { - int baseGodSlayerInfernoDoTValue = (int)((npc.oiled ? 514 : 250) * heatDamageMult); - ApplyDPSDebuff(baseGodSlayerInfernoDoTValue, baseGodSlayerInfernoDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // God Slayer Inferno + if (gsInferno > 0) + { + int baseGodSlayerInfernoDoTValue = (int)((npc.oiled ? 514 : 250) * heatDamageMult); + ApplyDPSDebuff(baseGodSlayerInfernoDoTValue, baseGodSlayerInfernoDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // Abyssal Flames - if (aFlames > 0) - { - int baseAbyssalFlamesDoTValue = (int)((npc.oiled ? 150 : 75) * heatDamageMult); - ApplyDPSDebuff(baseAbyssalFlamesDoTValue, baseAbyssalFlamesDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // Abyssal Flames + if (aFlames > 0) + { + int baseAbyssalFlamesDoTValue = (int)((npc.oiled ? 150 : 75) * heatDamageMult); + ApplyDPSDebuff(baseAbyssalFlamesDoTValue, baseAbyssalFlamesDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // Demon Flames - if (dFlames > 0) - { - int baseDemonFlamesDoTValue = (int)((npc.oiled ? 5012 : 2500) * heatDamageMult); - ApplyDPSDebuff(baseDemonFlamesDoTValue, baseDemonFlamesDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // Demon Flames + if (dFlames > 0) + { + int baseDemonFlamesDoTValue = (int)((npc.oiled ? 5012 : 2500) * heatDamageMult); + ApplyDPSDebuff(baseDemonFlamesDoTValue, baseDemonFlamesDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // Banishing Fire - if (banishingFire > 0) - { - int baseBanishingFireDoTValue = (int)((npc.oiled ? (npc.lifeMax >= 1000000 ? (npc.lifeMax / 500) + 1512 : 5512) : (npc.lifeMax >= 1000000 ? npc.lifeMax / 500 : 4000)) * heatDamageMult); - ApplyDPSDebuff(baseBanishingFireDoTValue, baseBanishingFireDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // Banishing Fire + if (banishingFire > 0) + { + int baseBanishingFireDoTValue = (int)((npc.oiled ? (npc.lifeMax >= 1000000 ? (npc.lifeMax / 500) + 1512 : 5512) : (npc.lifeMax >= 1000000 ? npc.lifeMax / 500 : 4000)) * heatDamageMult); + ApplyDPSDebuff(baseBanishingFireDoTValue, baseBanishingFireDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // Vulnerability Hex - if (vulnerabilityHex > 0) - { - int baseVulnerabilityHexDoTValue = (int)((npc.oiled ? VulnerabilityHex.DPS * 2 : VulnerabilityHex.DPS) * heatDamageMult); - ApplyDPSDebuff(baseVulnerabilityHexDoTValue, VulnerabilityHex.TickNumber, ref npc.lifeRegen, ref damage); - } + // Vulnerability Hex + if (vulnerabilityHex > 0) + { + int baseVulnerabilityHexDoTValue = (int)((npc.oiled ? VulnerabilityHex.DPS * 2 : VulnerabilityHex.DPS) * heatDamageMult); + ApplyDPSDebuff(baseVulnerabilityHexDoTValue, VulnerabilityHex.TickNumber, ref npc.lifeRegen, ref damage); + } - // Frostburn - if (npc.onFrostBurn) - { - int baseFrostBurnDoTValue = (int)((npc.oiled ? 44 : 16) * vanillaColdDamageMult); - npc.lifeRegen -= baseFrostBurnDoTValue; - if (damage < baseFrostBurnDoTValue / 4) - damage = baseFrostBurnDoTValue / 4; - } + // Frostburn + if (npc.onFrostBurn) + { + int baseFrostBurnDoTValue = (int)((npc.oiled ? 44 : 16) * vanillaColdDamageMult); + npc.lifeRegen -= baseFrostBurnDoTValue; + if (damage < baseFrostBurnDoTValue / 4) + damage = baseFrostBurnDoTValue / 4; + } - // Nightwither - if (nightwither > 0) - { - int baseNightwitherDoTValue = (int)(200 * coldDamageMult); - ApplyDPSDebuff(baseNightwitherDoTValue, baseNightwitherDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // Nightwither + if (nightwither > 0) + { + int baseNightwitherDoTValue = (int)(200 * coldDamageMult); + ApplyDPSDebuff(baseNightwitherDoTValue, baseNightwitherDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // Plague - if (pFlames > 0) - { - int basePlagueDoTValue = (int)(100 * sicknessDamageMult); - ApplyDPSDebuff(basePlagueDoTValue, basePlagueDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // Plague + if (pFlames > 0) + { + int basePlagueDoTValue = (int)(100 * sicknessDamageMult); + ApplyDPSDebuff(basePlagueDoTValue, basePlagueDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // Astral Infection - if (astralInfection > 0) - { - int baseAstralInfectionDoTValue = (int)(75 * sicknessDamageMult); - ApplyDPSDebuff(baseAstralInfectionDoTValue, baseAstralInfectionDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // Astral Infection + if (astralInfection > 0) + { + int baseAstralInfectionDoTValue = (int)(75 * sicknessDamageMult); + ApplyDPSDebuff(baseAstralInfectionDoTValue, baseAstralInfectionDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // Sulphuric Poisoning - if (sulphurPoison > 0) - { - int baseSulphurPoisonDoTValue = (int)(180 * sicknessDamageMult); - ApplyDPSDebuff(baseSulphurPoisonDoTValue, baseSulphurPoisonDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // Sulphuric Poisoning + if (sulphurPoison > 0) + { + int baseSulphurPoisonDoTValue = (int)(180 * sicknessDamageMult); + ApplyDPSDebuff(baseSulphurPoisonDoTValue, baseSulphurPoisonDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // Sage Poison - if (sagePoisonTime > 0) - { - int baseSagePoisonDoTValue = (int)(90 * sicknessDamageMult); - ApplyDPSDebuff(baseSagePoisonDoTValue, npc.Calamity().sagePoisonDamage, ref npc.lifeRegen, ref damage); - } + // Sage Poison + if (sagePoisonTime > 0) + { + int baseSagePoisonDoTValue = (int)(90 * sicknessDamageMult); + ApplyDPSDebuff(baseSagePoisonDoTValue, npc.Calamity().sagePoisonDamage, ref npc.lifeRegen, ref damage); + } - // Kami Debuff from Yanmei's Knife - if (kamiFlu > 0) - { - int baseKamiFluDoTValue = (int)(250 * sicknessDamageMult); - ApplyDPSDebuff(baseKamiFluDoTValue, baseKamiFluDoTValue / 10, ref npc.lifeRegen, ref damage); - } + // Kami Debuff from Yanmei's Knife + if (kamiFlu > 0) + { + int baseKamiFluDoTValue = (int)(250 * sicknessDamageMult); + ApplyDPSDebuff(baseKamiFluDoTValue, baseKamiFluDoTValue / 10, ref npc.lifeRegen, ref damage); + } - // Poisoned - if (npc.poisoned) - { - int basePoisonedDoTValue = (int)(4 * vanillaSicknessDamageMult); - npc.lifeRegen -= basePoisonedDoTValue; - if (damage < basePoisonedDoTValue / 4) - damage = basePoisonedDoTValue / 4; - } + // Poisoned + if (npc.poisoned) + { + int basePoisonedDoTValue = (int)(4 * vanillaSicknessDamageMult); + npc.lifeRegen -= basePoisonedDoTValue; + if (damage < basePoisonedDoTValue / 4) + damage = basePoisonedDoTValue / 4; + } - // Venom - if (npc.venom) - { - int baseVenomDoTValue = (int)(12 * vanillaSicknessDamageMult); - npc.lifeRegen -= baseVenomDoTValue; - if (damage < baseVenomDoTValue / 4) - damage = baseVenomDoTValue / 4; - } + // Venom + if (npc.venom) + { + int baseVenomDoTValue = (int)(12 * vanillaSicknessDamageMult); + npc.lifeRegen -= baseVenomDoTValue; + if (damage < baseVenomDoTValue / 4) + damage = baseVenomDoTValue / 4; + } - // Electrified - if (electrified > 0) - { - int baseElectrifiedDoTValue = (int)((CalamityPlayer.areThereAnyDamnBosses ? 5 : 10) * (npc.velocity.X == 0 ? 1 : 4) * electricityDamageMult); - ApplyDPSDebuff(baseElectrifiedDoTValue, baseElectrifiedDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // Electrified + if (electrified > 0) + { + int baseElectrifiedDoTValue = (int)((CalamityPlayer.areThereAnyDamnBosses ? 5 : 10) * (npc.velocity.X == 0 ? 1 : 4) * electricityDamageMult); + ApplyDPSDebuff(baseElectrifiedDoTValue, baseElectrifiedDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // Crush Depth - if (cDepth > 0) - { - int baseCrushDepthDoTValue = (int)(((Main.hardMode ? 36 : 12) - npc.defense) * 5 * waterDamageMult); - if (baseCrushDepthDoTValue > 0) - ApplyDPSDebuff(baseCrushDepthDoTValue, baseCrushDepthDoTValue / 5, ref npc.lifeRegen, ref damage); - } + // Crush Depth + if (cDepth > 0) + { + int baseCrushDepthDoTValue = (int)(((Main.hardMode ? 36 : 12) - npc.defense) * 5 * waterDamageMult); + if (baseCrushDepthDoTValue > 0) + ApplyDPSDebuff(baseCrushDepthDoTValue, baseCrushDepthDoTValue / 5, ref npc.lifeRegen, ref damage); + } - // Debuffs that aren't affected by weaknesses or resistances. - if (vaporfied > 0) - ApplyDPSDebuff(30, 6, ref npc.lifeRegen, ref damage); - if (somaShredStacks > 0) - Shred.TickDebuff(npc, this); - if (bBlood > 0) - ApplyDPSDebuff(50, 10, ref npc.lifeRegen, ref damage); + // Debuffs that aren't affected by weaknesses or resistances. + if (vaporfied > 0) + ApplyDPSDebuff(30, 6, ref npc.lifeRegen, ref damage); + if (somaShredStacks > 0) + Shred.TickDebuff(npc, this); + if (bBlood > 0) + ApplyDPSDebuff(50, 10, ref npc.lifeRegen, ref damage); - // Reduce DoT on worm bosses by 75%. - if (wormBoss && npc.lifeRegen < 0) - { - npc.lifeRegen /= 4; - if (npc.lifeRegen > -1) - npc.lifeRegen = -1; + // Reduce DoT on worm bosses by 75%. + if (wormBoss && npc.lifeRegen < 0) + { + npc.lifeRegen /= 4; + if (npc.lifeRegen > -1) + npc.lifeRegen = -1; - // Every other EoW body segment and the head segments are immune to DoT - if (((npc.ai[2] % 2f == 0f && npc.type == NPCID.EaterofWorldsBody) || npc.type == NPCID.EaterofWorldsHead) && (CalamityWorld.death || BossRushEvent.BossRushActive)) - npc.lifeRegen = 0; - } - } + // Every other EoW body segment and the head segments are immune to DoT + if (((npc.ai[2] % 2f == 0f && npc.type == NPCID.EaterofWorldsBody) || npc.type == NPCID.EaterofWorldsHead) && (CalamityWorld.death || BossRushEvent.BossRushActive)) + npc.lifeRegen = 0; + } + } - public void ApplyDPSDebuff(int lifeRegenValue, int damageValue, ref int lifeRegen, ref int damage) - { - if (lifeRegen > 0) - lifeRegen = 0; + public void ApplyDPSDebuff(int lifeRegenValue, int damageValue, ref int lifeRegen, ref int damage) + { + if (lifeRegen > 0) + lifeRegen = 0; - lifeRegen -= lifeRegenValue; + lifeRegen -= lifeRegenValue; - if (damage < damageValue) - damage = damageValue; - } + if (damage < damageValue) + damage = damageValue; + } #endregion #region Set Defaults public override void SetDefaults(NPC npc) { - ShouldFallThroughPlatforms = false; + ShouldFallThroughPlatforms = false; - for (int i = 0; i < maxPlayerImmunities; i++) - dashImmunityTime[i] = 0; + for (int i = 0; i < maxPlayerImmunities; i++) + dashImmunityTime[i] = 0; - for (int m = 0; m < maxAIMod; m++) + for (int m = 0; m < maxAIMod; m++) newAI[m] = 0f; - // Apply DR to vanilla NPCs. - // This also applies DR to other mods' NPCs who have set up their NPCs to have DR. - if (CalamityMod.DRValues.ContainsKey(npc.type)) - { - CalamityMod.DRValues.TryGetValue(npc.type, out float newDR); - DR = newDR; - } + // Apply DR to vanilla NPCs. + // This also applies DR to other mods' NPCs who have set up their NPCs to have DR. + if (CalamityMod.DRValues.ContainsKey(npc.type)) + { + CalamityMod.DRValues.TryGetValue(npc.type, out float newDR); + DR = newDR; + } - // Aquatic Scourge sets kill time in AI, not here. - if (CalamityMod.bossKillTimes.ContainsKey(npc.type) && !CalamityLists.AquaticScourgeIDs.Contains(npc.type)) - { - CalamityMod.bossKillTimes.TryGetValue(npc.type, out int revKillTime); - KillTime = revKillTime; - } + // Aquatic Scourge sets kill time in AI, not here. + if (CalamityMod.bossKillTimes.ContainsKey(npc.type) && !CalamityLists.AquaticScourgeIDs.Contains(npc.type)) + { + CalamityMod.bossKillTimes.TryGetValue(npc.type, out int revKillTime); + KillTime = revKillTime; + } - // Fixing more red mistakes - if (npc.type == NPCID.WallofFleshEye) - npc.netAlways = true; + // Fixing more red mistakes + if (npc.type == NPCID.WallofFleshEye) + npc.netAlways = true; sagePoisonDamage = 0; - if (npc.type == NPCID.Golem && (CalamityWorld.revenge || BossRushEvent.BossRushActive)) - npc.noGravity = true; + if (npc.type == NPCID.Golem && (CalamityWorld.revenge || BossRushEvent.BossRushActive)) + npc.noGravity = true; - DeclareBossHealthUIVariables(npc); + DeclareBossHealthUIVariables(npc); - DebuffImmunities(npc); + DebuffImmunities(npc); - BaseVanillaBossHPAdjustments(npc); + BaseVanillaBossHPAdjustments(npc); - if (BossRushEvent.BossRushActive) + if (BossRushEvent.BossRushActive) BossRushStatChanges(npc, mod); BossValueChanges(npc); @@ -881,152 +881,152 @@ namespace CalamityMod.NPCs if (DraedonMayhem) DraedonMechaMayhemStatChanges(npc); - if (CalamityWorld.revenge) + if (CalamityWorld.revenge) RevDeathStatChanges(npc, mod); OtherStatChanges(npc); - VulnerabilitiesAndResistances(npc); + VulnerabilitiesAndResistances(npc); - BoundNPCSafety(mod, npc); + BoundNPCSafety(mod, npc); } - #endregion + #endregion - #region Boss Health UI Variable Setting - public void DeclareBossHealthUIVariables(NPC npc) - { - if (npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsTail) - SplittingWorm = true; - } - #endregion - - #region Debuff Immunities - private void DebuffImmunities(NPC npc) + #region Boss Health UI Variable Setting + public void DeclareBossHealthUIVariables(NPC npc) { - // Check out NPCDebuffs.cs as this function sets the debuff immunities for all enemies in Cal bar the ones described below. - npc.SetNPCDebuffImmunities(); + if (npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsTail) + SplittingWorm = true; + } + #endregion - // All bosses and several enemies are automatically immune to Pearl Aura. - if (CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) - npc.buffImmune[BuffType()] = true; + #region Debuff Immunities + private void DebuffImmunities(NPC npc) + { + // Check out NPCDebuffs.cs as this function sets the debuff immunities for all enemies in Cal bar the ones described below. + npc.SetNPCDebuffImmunities(); - // All enemies are automatically immune to the Confused debuff, so we must specifically set them not to be. - // Extra note: Clams are not in this list as they initially immune to Confused, but are no longer immune once aggro'd. This is set in their AI(). - if (CalamityLists.confusionEnemyList.Contains(npc.type)) - npc.buffImmune[BuffID.Confused] = false; + // All bosses and several enemies are automatically immune to Pearl Aura. + if (CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) + npc.buffImmune[BuffType()] = true; - // Any enemy not immune to Venom shouldn't be immune to Sulphuric Poisoning as it is an upgrade. - if (!npc.buffImmune[BuffID.Venom]) - npc.buffImmune[BuffType()] = false; + // All enemies are automatically immune to the Confused debuff, so we must specifically set them not to be. + // Extra note: Clams are not in this list as they initially immune to Confused, but are no longer immune once aggro'd. This is set in their AI(). + if (CalamityLists.confusionEnemyList.Contains(npc.type)) + npc.buffImmune[BuffID.Confused] = false; - // Sets certain vanilla NPCs and all town NPCs to be immune to most debuffs. - if (((CalamityLists.DesertScourgeIDs.Contains(npc.type) || npc.type == NPCID.Creeper || CalamityLists.PerforatorIDs.Contains(npc.type)) && CalamityWorld.malice) || - CalamityLists.DestroyerIDs.Contains(npc.type) || npc.type == NPCID.SkeletronHead || npc.type == NPCID.SpikeBall || npc.type == NPCID.BlazingWheel || - (CalamityLists.EaterofWorldsIDs.Contains(npc.type) && (BossRushEvent.BossRushActive || CalamityWorld.malice)) || - npc.type == NPCID.DD2EterniaCrystal || npc.townNPC) - { - for (int k = 0; k < npc.buffImmune.Length; k++) - { - npc.buffImmune[k] = true; - } + // Any enemy not immune to Venom shouldn't be immune to Sulphuric Poisoning as it is an upgrade. + if (!npc.buffImmune[BuffID.Venom]) + npc.buffImmune[BuffType()] = false; - if (npc.townNPC) - { - npc.buffImmune[BuffID.Wet] = false; - npc.buffImmune[BuffID.Slimed] = false; - npc.buffImmune[BuffID.Lovestruck] = false; - npc.buffImmune[BuffID.Stinky] = false; - } - } + // Sets certain vanilla NPCs and all town NPCs to be immune to most debuffs. + if (((CalamityLists.DesertScourgeIDs.Contains(npc.type) || npc.type == NPCID.Creeper || CalamityLists.PerforatorIDs.Contains(npc.type)) && CalamityWorld.malice) || + CalamityLists.DestroyerIDs.Contains(npc.type) || npc.type == NPCID.SkeletronHead || npc.type == NPCID.SpikeBall || npc.type == NPCID.BlazingWheel || + (CalamityLists.EaterofWorldsIDs.Contains(npc.type) && (BossRushEvent.BossRushActive || CalamityWorld.malice)) || + npc.type == NPCID.DD2EterniaCrystal || npc.townNPC) + { + for (int k = 0; k < npc.buffImmune.Length; k++) + { + npc.buffImmune[k] = true; + } - // Most bosses and boss servants are not immune to Kami Flu. + if (npc.townNPC) + { + npc.buffImmune[BuffID.Wet] = false; + npc.buffImmune[BuffID.Slimed] = false; + npc.buffImmune[BuffID.Lovestruck] = false; + npc.buffImmune[BuffID.Stinky] = false; + } + } + + // Most bosses and boss servants are not immune to Kami Flu. if (YanmeisKnifeSlash.CanRecieveCoolEffectsFrom(npc)) npc.buffImmune[BuffType()] = false; - // Nothing should be immune to Enraged. + // Nothing should be immune to Enraged. npc.buffImmune[BuffType()] = false; // Extra Notes: // Shellfish minions set debuff immunity to Shellfish Claps on enemy hits, so most things are technically not immune. // The Spiteful Candle sets the debuff immunity of Spite to all nearby enemies in the tile file for an enemy with less than 99% DR. } - #endregion + #endregion - #region Base Vanilla Boss HP Adjustments - private void BaseVanillaBossHPAdjustments(NPC npc) - { - switch (npc.type) - { - case NPCID.MoonLordCore: - npc.lifeMax = 92000; - break; + #region Base Vanilla Boss HP Adjustments + private void BaseVanillaBossHPAdjustments(NPC npc) + { + switch (npc.type) + { + case NPCID.MoonLordCore: + npc.lifeMax = 92000; + break; - case NPCID.CultistBoss: - npc.lifeMax = 53500; - break; + case NPCID.CultistBoss: + npc.lifeMax = 53500; + break; - case NPCID.CultistDragonBody1: - case NPCID.CultistDragonBody2: - case NPCID.CultistDragonBody3: - case NPCID.CultistDragonBody4: - case NPCID.CultistDragonHead: - case NPCID.CultistDragonTail: - npc.lifeMax = 41600; - break; + case NPCID.CultistDragonBody1: + case NPCID.CultistDragonBody2: + case NPCID.CultistDragonBody3: + case NPCID.CultistDragonBody4: + case NPCID.CultistDragonHead: + case NPCID.CultistDragonTail: + npc.lifeMax = 41600; + break; - case NPCID.DukeFishron: - npc.lifeMax = 105625; - break; + case NPCID.DukeFishron: + npc.lifeMax = 105625; + break; - case NPCID.Golem: - npc.lifeMax = 30000; - break; + case NPCID.Golem: + npc.lifeMax = 30000; + break; - case NPCID.GolemHead: - npc.lifeMax = 20000; - break; + case NPCID.GolemHead: + npc.lifeMax = 20000; + break; - case NPCID.Plantera: - npc.lifeMax = 75000; - break; + case NPCID.Plantera: + npc.lifeMax = 75000; + break; - case NPCID.Retinazer: - npc.lifeMax = 22000; - break; + case NPCID.Retinazer: + npc.lifeMax = 22000; + break; - case NPCID.Spazmatism: - npc.lifeMax = 26000; - break; + case NPCID.Spazmatism: + npc.lifeMax = 26000; + break; - case NPCID.WallofFlesh: - case NPCID.WallofFleshEye: - npc.lifeMax = 12800; - break; + case NPCID.WallofFlesh: + case NPCID.WallofFleshEye: + npc.lifeMax = 12800; + break; - case NPCID.BrainofCthulhu: - npc.lifeMax = 1400; - break; + case NPCID.BrainofCthulhu: + npc.lifeMax = 1400; + break; - case NPCID.EaterofWorldsBody: - case NPCID.EaterofWorldsHead: - case NPCID.EaterofWorldsTail: - npc.lifeMax = 175; - break; + case NPCID.EaterofWorldsBody: + case NPCID.EaterofWorldsHead: + case NPCID.EaterofWorldsTail: + npc.lifeMax = 175; + break; - case NPCID.EyeofCthulhu: - npc.lifeMax = 3050; - break; - } - } - #endregion + case NPCID.EyeofCthulhu: + npc.lifeMax = 3050; + break; + } + } + #endregion - #region Boss Rush Stat Changes - private void BossRushStatChanges(NPC npc, Mod mod) + #region Boss Rush Stat Changes + private void BossRushStatChanges(NPC npc, Mod mod) { if (!npc.friendly) { - npc.buffImmune[BuffType()] = false; - npc.buffImmune[BuffType()] = true; + npc.buffImmune[BuffType()] = false; + npc.buffImmune[BuffType()] = true; } foreach (KeyValuePair BossRushHPChange in CalamityLists.BossRushHPChanges) @@ -1091,18 +1091,18 @@ namespace CalamityMod.NPCs break; } } - #endregion + #endregion - #region Revengeance and Death Mode Stat Changes - private void RevDeathStatChanges(NPC npc, Mod mod) + #region Revengeance and Death Mode Stat Changes + private void RevDeathStatChanges(NPC npc, Mod mod) { npc.value = (int)(npc.value * 1.5); - if (CalamityLists.DeathModeSplittingWormIDs.Contains(npc.type)) - { - if (CalamityWorld.death) - npc.lifeMax = (int)(npc.lifeMax * 0.25); - } + if (CalamityLists.DeathModeSplittingWormIDs.Contains(npc.type)) + { + if (CalamityWorld.death) + npc.lifeMax = (int)(npc.lifeMax * 0.25); + } if (npc.type == NPCID.Mothron) { @@ -1112,16 +1112,16 @@ namespace CalamityMod.NPCs { npc.lifeMax = (int)(npc.lifeMax * 1.2); - if (npc.type == NPCID.MoonLordCore) - npc.npcSlots = 36f; + if (npc.type == NPCID.MoonLordCore) + npc.npcSlots = 36f; } else if (npc.type == NPCID.CultistBoss || (npc.type >= NPCID.CultistDragonHead && npc.type <= NPCID.CultistDragonTail)) { npc.lifeMax = (int)(npc.lifeMax * 1.2); - if (npc.type == NPCID.CultistBoss) - npc.npcSlots = 20f; - } + if (npc.type == NPCID.CultistBoss) + npc.npcSlots = 20f; + } else if (npc.type == NPCID.DukeFishron) { npc.lifeMax = (int)(npc.lifeMax * 1.4); @@ -1135,14 +1135,14 @@ namespace CalamityMod.NPCs { npc.lifeMax = (int)(npc.lifeMax * 1.2); - if (npc.type == NPCID.Golem) - npc.npcSlots = 64f; + if (npc.type == NPCID.Golem) + npc.npcSlots = 64f; } else if (npc.type == NPCID.GolemHeadFree) { npc.lifeMax = (int)(npc.lifeMax * 1.7); - npc.width = 88; - npc.height = 90; + npc.width = 88; + npc.height = 90; npc.dontTakeDamage = false; } else if (npc.type == NPCID.Plantera) @@ -1159,32 +1159,32 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCID.SkeletronHead) { - if (CalamityWorld.death) - npc.lifeMax = (int)(npc.lifeMax * 0.5); - else - npc.lifeMax = (int)(npc.lifeMax * 0.75); + if (CalamityWorld.death) + npc.lifeMax = (int)(npc.lifeMax * 0.5); + else + npc.lifeMax = (int)(npc.lifeMax * 0.75); - npc.npcSlots = 12f; + npc.npcSlots = 12f; } else if (npc.type == NPCID.SkeletronHand) { - if (CalamityWorld.death) - npc.lifeMax = (int)(npc.lifeMax * 0.65); - else - npc.lifeMax = (int)(npc.lifeMax * 0.9); - } + if (CalamityWorld.death) + npc.lifeMax = (int)(npc.lifeMax * 0.65); + else + npc.lifeMax = (int)(npc.lifeMax * 0.9); + } else if (npc.type == NPCID.QueenBee) { - npc.defense = 14; - npc.defDefense = npc.defense; + npc.defense = 14; + npc.defDefense = npc.defense; npc.lifeMax = (int)(npc.lifeMax * 1.2); npc.npcSlots = 14f; } - else if ((npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall) && CalamityPlayer.areThereAnyDamnBosses) - { - npc.lifeMax = (int)(npc.lifeMax * 1.4); - npc.scale = 1.25f; - } + else if ((npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall) && CalamityPlayer.areThereAnyDamnBosses) + { + npc.lifeMax = (int)(npc.lifeMax * 1.4); + npc.scale = 1.25f; + } else if (npc.type == NPCID.BrainofCthulhu) { npc.lifeMax = (int)(npc.lifeMax * 1.2); @@ -1201,19 +1201,19 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.EaterofWorldsHead) npc.npcSlots = 10f; - if (CalamityWorld.death) - npc.scale = 1.1f; - } + if (CalamityWorld.death) + npc.scale = 1.1f; + } else if (npc.type == NPCID.EyeofCthulhu) { npc.lifeMax = (int)(npc.lifeMax * 1.2); npc.npcSlots = 10f; } - else if (npc.type == NPCID.KingSlime) - { - if (CalamityWorld.death) - npc.scale = 3f; - } + else if (npc.type == NPCID.KingSlime) + { + if (CalamityWorld.death) + npc.scale = 3f; + } else if (npc.type == NPCID.Wraith || npc.type == NPCID.Mimic || npc.type == NPCID.Reaper || npc.type == NPCID.PresentMimic || npc.type == NPCID.SandElemental) { npc.knockBackResist = 0f; @@ -1227,22 +1227,22 @@ namespace CalamityMod.NPCs npc.scale = CalamityWorld.death ? 2.5f : 1.5f; npc.npcSlots = 10f; } - else if (npc.type == NPCID.Probe) - { - if (CalamityWorld.death) - npc.lifeMax = (int)(npc.lifeMax * 2.0); - - npc.scale = CalamityWorld.death ? 2f : 1.2f; - } + else if (npc.type == NPCID.Probe) + { + if (CalamityWorld.death) + npc.lifeMax = (int)(npc.lifeMax * 2.0); + + npc.scale = CalamityWorld.death ? 2f : 1.2f; + } else if (npc.type == NPCID.SkeletronPrime) { - npc.lifeMax = (int)(npc.lifeMax * 1.2); - npc.npcSlots = 12f; + npc.lifeMax = (int)(npc.lifeMax * 1.2); + npc.npcSlots = 12f; + } + else if (npc.type <= NPCID.PrimeLaser && npc.type >= NPCID.PrimeCannon) + { + npc.lifeMax = (int)(npc.lifeMax * 0.65); } - else if (npc.type <= NPCID.PrimeLaser && npc.type >= NPCID.PrimeCannon) - { - npc.lifeMax = (int)(npc.lifeMax * 0.65); - } else if (npc.type == NPCID.Retinazer || npc.type == NPCID.Spazmatism) { npc.lifeMax = (int)(npc.lifeMax * 1.2); @@ -1255,866 +1255,866 @@ namespace CalamityMod.NPCs npc.canGhostHeal = false; } } - #endregion + #endregion - #region Vulnerabilities and Resistances - private void VulnerabilitiesAndResistances(NPC npc) - { - // These enemies are categorized in such a way to make them easy to understand. - // Do not mess with these categories unless you ask me for permission - Fab. - switch (npc.type) - { - // Regular organic desert enemies. - case NPCID.Antlion: - case NPCID.FlyingAntlion: - case NPCID.WalkingAntlion: - case NPCID.TombCrawlerHead: - case NPCID.TombCrawlerBody: - case NPCID.TombCrawlerTail: - case NPCID.DesertBeast: - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - case NPCID.DesertLamiaDark: - case NPCID.DesertLamiaLight: - case NPCID.DesertGhoul: - case NPCID.DesertGhoulCorruption: - case NPCID.DesertGhoulCrimson: - case NPCID.DesertGhoulHallow: - case NPCID.Mummy: - case NPCID.DarkMummy: - case NPCID.LightMummy: - case NPCID.Tumbleweed: - case NPCID.SandShark: - case NPCID.SandsharkCorrupt: - case NPCID.SandsharkCrimson: - case NPCID.SandsharkHallow: - VulnerableToCold = true; - VulnerableToSickness = true; - VulnerableToWater = true; - break; - - // Scorpions and sand elemental. - case NPCID.DesertScorpionWalk: - case NPCID.DesertScorpionWall: - case NPCID.SandElemental: - VulnerableToCold = true; - VulnerableToSickness = false; - VulnerableToWater = true; - break; - - // Desert slimes. - case NPCID.SandSlime: - VulnerableToCold = true; - VulnerableToSickness = false; - VulnerableToWater = true; - VulnerableToHeat = true; - break; - - // Organic undead or other enemies that are covered in slime. - case NPCID.ArmedZombieSlimed: - case NPCID.BigSlimedZombie: - case NPCID.BunnySlimed: - case NPCID.SlimedZombie: - case NPCID.SmallSlimedZombie: - VulnerableToCold = true; - VulnerableToHeat = true; - break; - - // Slimes that use heat-related attacks. - case NPCID.LavaSlime: - VulnerableToCold = true; - VulnerableToSickness = false; - VulnerableToHeat = false; - VulnerableToWater = true; - break; - - // Regular slimes. - case NPCID.DungeonSlime: - case NPCID.BabySlime: - case NPCID.BlackSlime: - case NPCID.BlueSlime: - case NPCID.CorruptSlime: - case NPCID.GreenSlime: - case NPCID.IlluminantSlime: - case NPCID.JungleSlime: - case NPCID.KingSlime: - case NPCID.MotherSlime: - case NPCID.PurpleSlime: - case NPCID.RainbowSlime: - case NPCID.RedSlime: - case NPCID.Slimeling: - case NPCID.SlimeMasked: - case NPCID.Slimer: - case NPCID.Slimer2: - case NPCID.SlimeRibbonGreen: - case NPCID.SlimeRibbonRed: - case NPCID.SlimeRibbonWhite: - case NPCID.SlimeRibbonYellow: - case NPCID.SlimeSpiked: - case NPCID.SpikedJungleSlime: - case NPCID.UmbrellaSlime: - case NPCID.YellowSlime: - case NPCID.ToxicSludge: - case NPCID.Crimslime: - case NPCID.BigCrimslime: - case NPCID.LittleCrimslime: - case NPCID.Gastropod: - case NPCID.Pinky: - VulnerableToSickness = false; - VulnerableToHeat = true; - break; - - // Skeletons and other armored/bone enemies that use heat-related attacks. - case NPCID.HellArmoredBones: - case NPCID.HellArmoredBonesMace: - case NPCID.HellArmoredBonesSpikeShield: - case NPCID.HellArmoredBonesSword: - case NPCID.DiabolistRed: - case NPCID.DiabolistWhite: - VulnerableToHeat = false; - VulnerableToCold = true; - VulnerableToSickness = false; - VulnerableToWater = true; - break; - - // Skeletons and other armored/bone enemies that are dead or undead. - case NPCID.SkeletronHand: - case NPCID.SkeletronHead: - case NPCID.AngryBones: - case NPCID.AngryBonesBig: - case NPCID.AngryBonesBigHelmet: - case NPCID.AngryBonesBigMuscle: - case NPCID.DarkCaster: - case NPCID.CursedSkull: - case NPCID.GiantCursedSkull: - case NPCID.DungeonGuardian: - case NPCID.BigBoned: - case NPCID.BlueArmoredBones: - case NPCID.BlueArmoredBonesMace: - case NPCID.BlueArmoredBonesNoPants: - case NPCID.BlueArmoredBonesSword: - case NPCID.BoneLee: - case NPCID.BoneSerpentBody: - case NPCID.BoneSerpentHead: - case NPCID.BoneSerpentTail: - case NPCID.BoneThrowingSkeleton: - case NPCID.BoneThrowingSkeleton2: - case NPCID.BoneThrowingSkeleton3: - case NPCID.BoneThrowingSkeleton4: - case NPCID.RustyArmoredBonesAxe: - case NPCID.RustyArmoredBonesFlail: - case NPCID.RustyArmoredBonesSword: - case NPCID.RustyArmoredBonesSwordNoArmor: - case NPCID.ShortBones: - case NPCID.Necromancer: - case NPCID.NecromancerArmored: - case NPCID.RaggedCaster: - case NPCID.RaggedCasterOpenCoat: - case NPCID.SkeletonCommando: - case NPCID.ArmoredSkeleton: - case NPCID.BigHeadacheSkeleton: - case NPCID.BigMisassembledSkeleton: - case NPCID.BigPantlessSkeleton: - case NPCID.BigSkeleton: - case NPCID.DD2SkeletonT1: - case NPCID.DD2SkeletonT3: - case NPCID.GreekSkeleton: - case NPCID.HeadacheSkeleton: - case NPCID.HeavySkeleton: - case NPCID.MisassembledSkeleton: - case NPCID.PantlessSkeleton: - case NPCID.Skeleton: - case NPCID.SkeletonAlien: - case NPCID.SkeletonArcher: - case NPCID.SkeletonAstonaut: - case NPCID.SkeletonSniper: - case NPCID.SkeletonTopHat: - case NPCID.SmallHeadacheSkeleton: - case NPCID.SmallMisassembledSkeleton: - case NPCID.SmallPantlessSkeleton: - case NPCID.SmallSkeleton: - case NPCID.TacticalSkeleton: - case NPCID.Tim: - case NPCID.UndeadMiner: - case NPCID.UndeadViking: - case NPCID.ArmoredViking: - case NPCID.GraniteFlyer: - case NPCID.GraniteGolem: - case NPCID.RuneWizard: - case NPCID.Golem: - case NPCID.GolemFistLeft: - case NPCID.GolemFistRight: - case NPCID.GolemHead: - case NPCID.GolemHeadFree: - VulnerableToSickness = false; - VulnerableToWater = true; - break; - - // Metal non-robotic enemies - case NPCID.BigMimicCorruption: - case NPCID.BigMimicCrimson: - case NPCID.BigMimicHallow: - case NPCID.BigMimicJungle: - case NPCID.Paladin: - case NPCID.Mimic: - case NPCID.PresentMimic: - case NPCID.PirateShipCannon: - case NPCID.PossessedArmor: - VulnerableToSickness = false; - break; - - // Robotic enemies. - case NPCID.Probe: - case NPCID.MartianProbe: - case NPCID.DeadlySphere: - case NPCID.MartianDrone: - case NPCID.MartianWalker: - case NPCID.MartianTurret: - case NPCID.ElfCopter: - case NPCID.SkeletronPrime: - case NPCID.PrimeCannon: - case NPCID.PrimeLaser: - case NPCID.PrimeSaw: - case NPCID.PrimeVice: - case NPCID.TheDestroyer: - case NPCID.TheDestroyerBody: - case NPCID.TheDestroyerTail: - case NPCID.SantaNK1: - case NPCID.MartianSaucer: - case NPCID.MartianSaucerCannon: - case NPCID.MartianSaucerCore: - case NPCID.MartianSaucerTurret: - VulnerableToElectricity = true; - VulnerableToSickness = false; - break; - - // Ghostly or ethereal enemies. - case NPCID.DungeonSpirit: - case NPCID.AncientCultistSquidhead: - case NPCID.CultistDragonBody1: - case NPCID.CultistDragonBody2: - case NPCID.CultistDragonBody3: - case NPCID.CultistDragonBody4: - case NPCID.CultistDragonHead: - case NPCID.CultistDragonTail: - case NPCID.Ghost: - case NPCID.ChaosElemental: - case NPCID.CrimsonAxe: - case NPCID.EnchantedSword: - case NPCID.CursedHammer: - case NPCID.DesertDjinn: - case NPCID.Wraith: - case NPCID.ShadowFlameApparition: - case NPCID.Reaper: - case NPCID.Poltergeist: - case NPCID.Pixie: - VulnerableToSickness = false; - break; - - // Organic enemies. - case NPCID.CultistArcherBlue: - case NPCID.CultistArcherWhite: - case NPCID.CultistBoss: - case NPCID.CultistDevote: - case NPCID.BloodCrawler: - case NPCID.BloodCrawlerWall: - case NPCID.CaveBat: - case NPCID.GiantBat: - case NPCID.CochinealBeetle: - case NPCID.CyanBeetle: - case NPCID.LacBeetle: - case NPCID.AnomuraFungus: - case NPCID.GiantFungiBulb: - case NPCID.FungiBulb: - case NPCID.MushiLadybug: - case NPCID.ZombieMushroom: - case NPCID.ZombieMushroomHat: - case NPCID.ManEater: - case NPCID.Snatcher: - case NPCID.AngryTrapper: - case NPCID.HoppinJack: - case NPCID.Splinterling: - case NPCID.MourningWood: - case NPCID.Pumpking: - case NPCID.Everscream: - case NPCID.Crimera: - case NPCID.BigCrimera: - case NPCID.LittleCrimera: - case NPCID.DemonEye: - case NPCID.DemonEye2: - case NPCID.DemonEyeOwl: - case NPCID.DemonEyeSpaceship: - case NPCID.DevourerBody: - case NPCID.DevourerHead: - case NPCID.DevourerTail: - case NPCID.DoctorBones: - case NPCID.EaterofSouls: - case NPCID.BigEater: - case NPCID.LittleEater: - case NPCID.EaterofWorldsBody: - case NPCID.EaterofWorldsHead: - case NPCID.EaterofWorldsTail: - case NPCID.FaceMonster: - case NPCID.GiantShelly: - case NPCID.GiantShelly2: - case NPCID.GiantWormBody: - case NPCID.GiantWormHead: - case NPCID.GiantWormTail: - case NPCID.GoblinScout: - case NPCID.Harpy: - case NPCID.JungleBat: - case NPCID.Nymph: - case NPCID.Raven: - case NPCID.Salamander: - case NPCID.Salamander2: - case NPCID.Salamander3: - case NPCID.Salamander4: - case NPCID.Salamander5: - case NPCID.Salamander6: - case NPCID.Salamander7: - case NPCID.Salamander8: - case NPCID.Salamander9: - case NPCID.Vulture: - case NPCID.WallCreeper: - case NPCID.WallCreeperWall: - case NPCID.ArmedZombie: - case NPCID.ArmedZombieCenx: - case NPCID.ArmedZombiePincussion: - case NPCID.ArmedZombieSwamp: - case NPCID.ArmedZombieTwiggy: - case NPCID.BaldZombie: - case NPCID.BigBaldZombie: - case NPCID.BigFemaleZombie: - case NPCID.BigPincushionZombie: - case NPCID.BigRainZombie: - case NPCID.BigSwampZombie: - case NPCID.BigTwiggyZombie: - case NPCID.BigZombie: - case NPCID.BloodZombie: - case NPCID.FemaleZombie: - case NPCID.PincushionZombie: - case NPCID.SmallBaldZombie: - case NPCID.SmallFemaleZombie: - case NPCID.SmallPincushionZombie: - case NPCID.SmallRainZombie: - case NPCID.SmallSwampZombie: - case NPCID.SmallTwiggyZombie: - case NPCID.SmallZombie: - case NPCID.SwampZombie: - case NPCID.TwiggyZombie: - case NPCID.Zombie: - case NPCID.ZombieDoctor: - case NPCID.ZombiePixie: - case NPCID.ZombieRaincoat: - case NPCID.ZombieSuperman: - case NPCID.ZombieSweater: - case NPCID.ZombieXmas: - case NPCID.Clinger: - case NPCID.Corruptor: - case NPCID.Derpling: - case NPCID.Herpling: - case NPCID.DiggerBody: - case NPCID.DiggerHead: - case NPCID.DiggerTail: - case NPCID.FloatyGross: - case NPCID.FlyingSnake: - case NPCID.Lihzahrd: - case NPCID.LihzahrdCrawler: - case NPCID.GiantFlyingFox: - case NPCID.GiantTortoise: - case NPCID.IchorSticker: - case NPCID.IlluminantBat: - case NPCID.Medusa: - case NPCID.Moth: - case NPCID.Unicorn: - case NPCID.WanderingEye: - case NPCID.Werewolf: - case NPCID.SeekerBody: - case NPCID.SeekerHead: - case NPCID.SeekerTail: - case NPCID.WyvernBody: - case NPCID.WyvernBody2: - case NPCID.WyvernBody3: - case NPCID.WyvernHead: - case NPCID.WyvernLegs: - case NPCID.WyvernTail: - case NPCID.Clown: - case NPCID.CorruptBunny: - case NPCID.CrimsonBunny: - case NPCID.Drippler: - case NPCID.TheGroom: - case NPCID.TheBride: - case NPCID.GoblinArcher: - case NPCID.GoblinPeon: - case NPCID.GoblinSorcerer: - case NPCID.GoblinSummoner: - case NPCID.GoblinThief: - case NPCID.GoblinWarrior: - case NPCID.DD2DarkMageT1: - case NPCID.DD2DarkMageT3: - case NPCID.DD2DrakinT2: - case NPCID.DD2DrakinT3: - case NPCID.DD2GoblinBomberT1: - case NPCID.DD2GoblinBomberT2: - case NPCID.DD2GoblinBomberT3: - case NPCID.DD2GoblinT1: - case NPCID.DD2GoblinT2: - case NPCID.DD2GoblinT3: - case NPCID.DD2JavelinstT1: - case NPCID.DD2JavelinstT2: - case NPCID.DD2JavelinstT3: - case NPCID.DD2KoboldFlyerT2: - case NPCID.DD2KoboldFlyerT3: - case NPCID.DD2KoboldWalkerT2: - case NPCID.DD2KoboldWalkerT3: - case NPCID.DD2OgreT2: - case NPCID.DD2OgreT3: - case NPCID.DD2WitherBeastT2: - case NPCID.DD2WitherBeastT3: - case NPCID.DD2WyvernT1: - case NPCID.DD2WyvernT2: - case NPCID.DD2WyvernT3: - case NPCID.Parrot: - case NPCID.PirateCaptain: - case NPCID.PirateCorsair: - case NPCID.PirateCrossbower: - case NPCID.PirateDeadeye: - case NPCID.PirateDeckhand: - case NPCID.Mothron: - case NPCID.MothronEgg: - case NPCID.MothronSpawn: - case NPCID.Butcher: - case NPCID.DrManFly: - case NPCID.Eyezor: - case NPCID.Frankenstein: - case NPCID.Fritz: - case NPCID.Nailhead: - case NPCID.Psycho: - case NPCID.SwampThing: - case NPCID.ThePossessed: - case NPCID.Vampire: - case NPCID.VampireBat: - case NPCID.BrainScrambler: - case NPCID.GigaZapper: - case NPCID.GrayGrunt: - case NPCID.MartianEngineer: - case NPCID.MartianOfficer: - case NPCID.RayGunner: - case NPCID.Scutlix: - case NPCID.ScutlixRider: - case NPCID.HeadlessHorseman: - case NPCID.Hellhound: - case NPCID.Scarecrow1: - case NPCID.Scarecrow2: - case NPCID.Scarecrow3: - case NPCID.Scarecrow4: - case NPCID.Scarecrow5: - case NPCID.Scarecrow6: - case NPCID.Scarecrow7: - case NPCID.Scarecrow8: - case NPCID.Scarecrow9: - case NPCID.Scarecrow10: - case NPCID.NebulaHeadcrab: - case NPCID.LunarTowerNebula: - case NPCID.NebulaBeast: - case NPCID.NebulaBrain: - case NPCID.NebulaSoldier: - case NPCID.LunarTowerSolar: - case NPCID.SolarCorite: - case NPCID.SolarCrawltipedeTail: - case NPCID.SolarDrakomire: - case NPCID.SolarDrakomireRider: - case NPCID.SolarSolenian: - case NPCID.SolarSpearman: - case NPCID.SolarSroller: - case NPCID.LunarTowerStardust: - case NPCID.StardustCellBig: - case NPCID.StardustCellSmall: - case NPCID.StardustJellyfishBig: - case NPCID.StardustSoldier: - case NPCID.StardustSpiderBig: - case NPCID.StardustSpiderSmall: - case NPCID.StardustWormHead: - case NPCID.LunarTowerVortex: - case NPCID.VortexHornet: - case NPCID.VortexHornetQueen: - case NPCID.VortexLarva: - case NPCID.VortexRifleman: - case NPCID.VortexSoldier: - case NPCID.BrainofCthulhu: - case NPCID.Creeper: - case NPCID.EyeofCthulhu: - case NPCID.ServantofCthulhu: - case NPCID.MoonLordCore: - case NPCID.MoonLordHand: - case NPCID.MoonLordHead: - case NPCID.Spazmatism: // Changes to robotic in phase 2 - case NPCID.Retinazer: // Changes to robotic in phase 2 - VulnerableToCold = true; - VulnerableToHeat = true; - VulnerableToSickness = true; - break; - - // Demons and shit. - case NPCID.WallofFlesh: - case NPCID.WallofFleshEye: - case NPCID.TheHungry: - case NPCID.TheHungryII: - case NPCID.LeechBody: - case NPCID.LeechHead: - case NPCID.LeechTail: - case NPCID.Demon: - case NPCID.VoodooDemon: - case NPCID.RedDevil: - case NPCID.DemonTaxCollector: - VulnerableToCold = true; - VulnerableToHeat = false; - VulnerableToSickness = true; - break; - - // Fire enemies that are also organic. - case NPCID.FireImp: - case NPCID.Hellbat: - case NPCID.Lavabat: - VulnerableToCold = true; - VulnerableToHeat = false; - VulnerableToSickness = true; - VulnerableToWater = true; - break; - - // Fire enemies that aren't organic. - case NPCID.MeteorHead: - VulnerableToCold = true; - VulnerableToHeat = false; - VulnerableToSickness = false; - VulnerableToWater = true; - break; - - // Lightning bug thing. - case NPCID.DD2LightningBugT3: - VulnerableToElectricity = false; - VulnerableToCold = true; - VulnerableToHeat = true; - VulnerableToSickness = true; - break; - - // Betsy. - case NPCID.DD2Betsy: - VulnerableToCold = true; - VulnerableToHeat = false; - VulnerableToSickness = true; - break; - - // Nimbus - case NPCID.AngryNimbus: - VulnerableToCold = true; - VulnerableToElectricity = false; - VulnerableToWater = false; - VulnerableToHeat = false; - VulnerableToSickness = false; - break; - - // Cold-themed enemies - case NPCID.ArmedZombieEskimo: - case NPCID.ZombieEskimo: - case NPCID.IceBat: - case NPCID.SnowFlinx: - case NPCID.IceTortoise: - case NPCID.IcyMerman: - case NPCID.PigronCorruption: - case NPCID.PigronCrimson: - case NPCID.PigronHallow: - case NPCID.Wolf: - case NPCID.CorruptPenguin: - case NPCID.CrimsonPenguin: - case NPCID.ElfArcher: - case NPCID.Krampus: - case NPCID.Yeti: - case NPCID.Nutcracker: - case NPCID.NutcrackerSpinning: - case NPCID.ZombieElf: - case NPCID.ZombieElfBeard: - case NPCID.ZombieElfGirl: - VulnerableToHeat = true; - VulnerableToCold = false; - VulnerableToSickness = true; - break; - - // Cold-themed enemies that aren't organic. - case NPCID.IceElemental: - case NPCID.IceSlime: - case NPCID.SpikedIceSlime: - case NPCID.IceGolem: - case NPCID.MisterStabby: - case NPCID.SnowBalla: - case NPCID.SnowmanGangsta: - case NPCID.Flocko: - case NPCID.IceQueen: - case NPCID.GingerbreadMan: - VulnerableToCold = false; - VulnerableToHeat = true; - VulnerableToSickness = false; - break; - - // Water-themed enemies. - case NPCID.Crawdad: - case NPCID.Crawdad2: - case NPCID.BlueJellyfish: - case NPCID.GreenJellyfish: - case NPCID.PinkJellyfish: - case NPCID.BloodJelly: - case NPCID.FungoFish: - case NPCID.Crab: - case NPCID.Piranha: - case NPCID.SeaSnail: - case NPCID.Squid: - case NPCID.Shark: - case NPCID.AnglerFish: - case NPCID.Arapaima: - case NPCID.BloodFeeder: - case NPCID.CorruptGoldfish: - case NPCID.CrimsonGoldfish: - case NPCID.FlyingFish: - case NPCID.CreatureFromTheDeep: - case NPCID.DukeFishron: - case NPCID.Sharkron: - case NPCID.Sharkron2: - VulnerableToHeat = false; - VulnerableToSickness = true; - VulnerableToElectricity = true; - VulnerableToWater = false; - break; - - // Fucking bees, hornets and poisonous/toxic stuff. - case NPCID.Bee: - case NPCID.BeeSmall: - case NPCID.QueenBee: - case NPCID.BigHornetFatty: - case NPCID.BigHornetHoney: - case NPCID.BigHornetLeafy: - case NPCID.BigHornetSpikey: - case NPCID.BigHornetStingy: - case NPCID.BigMossHornet: - case NPCID.GiantMossHornet: - case NPCID.Hornet: - case NPCID.HornetFatty: - case NPCID.HornetHoney: - case NPCID.HornetLeafy: - case NPCID.HornetSpikey: - case NPCID.HornetStingy: - case NPCID.LittleHornetFatty: - case NPCID.LittleHornetHoney: - case NPCID.LittleHornetLeafy: - case NPCID.LittleHornetSpikey: - case NPCID.LittleHornetStingy: - case NPCID.LittleMossHornet: - case NPCID.MossHornet: - case NPCID.TinyMossHornet: - case NPCID.JungleCreeper: - case NPCID.JungleCreeperWall: - case NPCID.BlackRecluse: - case NPCID.BlackRecluseWall: - case NPCID.Plantera: - case NPCID.PlanterasTentacle: - VulnerableToCold = true; - VulnerableToHeat = true; - VulnerableToSickness = false; - break; - } - } - #endregion - - #region Other Stat Changes - private void OtherStatChanges(NPC npc) + #region Vulnerabilities and Resistances + private void VulnerabilitiesAndResistances(NPC npc) { - switch (npc.type) - { - case NPCID.KingSlime: - case NPCID.EyeofCthulhu: - case NPCID.BrainofCthulhu: - case NPCID.QueenBee: - case NPCID.Corruptor: - case NPCID.Crawdad: - case NPCID.Crawdad2: - case NPCID.ManEater: - case NPCID.AngryTrapper: - case NPCID.Snatcher: - case NPCID.SpikeBall: - case NPCID.DesertBeast: - case NPCID.BoneLee: - case NPCID.Paladin: - case NPCID.BigMimicCorruption: - case NPCID.BigMimicCrimson: - case NPCID.BigMimicHallow: - case NPCID.DiggerHead: - case NPCID.SeekerHead: - case NPCID.DuneSplicerHead: - case NPCID.SolarCrawltipedeHead: - case NPCID.Mimic: - case NPCID.SandShark: - case NPCID.SandsharkCorrupt: - case NPCID.SandsharkCrimson: - case NPCID.SandsharkHallow: - case NPCID.Butcher: - case NPCID.DeadlySphere: - case NPCID.Mothron: - case NPCID.Reaper: - case NPCID.Psycho: - case NPCID.PresentMimic: - case NPCID.Yeti: - case NPCID.NebulaBeast: - case NPCID.SolarCorite: - case NPCID.StardustWormHead: - case NPCID.EaterofWorldsHead: - case NPCID.SkeletronHead: - case NPCID.SkeletronHand: - case NPCID.WallofFlesh: - case NPCID.TheHungry: - case NPCID.TheHungryII: - case NPCID.Spazmatism: - case NPCID.Retinazer: - case NPCID.TheDestroyer: - case NPCID.TheDestroyerBody: - case NPCID.TheDestroyerTail: - case NPCID.SkeletronPrime: - case NPCID.PrimeVice: - case NPCID.PrimeSaw: - case NPCID.Plantera: - case NPCID.PlanterasTentacle: - case NPCID.Golem: - case NPCID.GolemFistLeft: - case NPCID.GolemFistRight: - case NPCID.CultistDragonHead: - case NPCID.AncientCultistSquidhead: - case NPCID.AncientLight: - case NPCID.DD2OgreT2: - case NPCID.DD2OgreT3: - case NPCID.DD2Betsy: - case NPCID.PumpkingBlade: - case NPCID.SantaNK1: - case NPCID.DukeFishron: - canBreakPlayerDefense = true; - break; + // These enemies are categorized in such a way to make them easy to understand. + // Do not mess with these categories unless you ask me for permission - Fab. + switch (npc.type) + { + // Regular organic desert enemies. + case NPCID.Antlion: + case NPCID.FlyingAntlion: + case NPCID.WalkingAntlion: + case NPCID.TombCrawlerHead: + case NPCID.TombCrawlerBody: + case NPCID.TombCrawlerTail: + case NPCID.DesertBeast: + case NPCID.DuneSplicerHead: + case NPCID.DuneSplicerBody: + case NPCID.DuneSplicerTail: + case NPCID.DesertLamiaDark: + case NPCID.DesertLamiaLight: + case NPCID.DesertGhoul: + case NPCID.DesertGhoulCorruption: + case NPCID.DesertGhoulCrimson: + case NPCID.DesertGhoulHallow: + case NPCID.Mummy: + case NPCID.DarkMummy: + case NPCID.LightMummy: + case NPCID.Tumbleweed: + case NPCID.SandShark: + case NPCID.SandsharkCorrupt: + case NPCID.SandsharkCrimson: + case NPCID.SandsharkHallow: + VulnerableToCold = true; + VulnerableToSickness = true; + VulnerableToWater = true; + break; - // Reduce prehardmode desert enemy stats pre-Desert Scourge - case NPCID.WalkingAntlion: + // Scorpions and sand elemental. + case NPCID.DesertScorpionWalk: + case NPCID.DesertScorpionWall: + case NPCID.SandElemental: + VulnerableToCold = true; + VulnerableToSickness = false; + VulnerableToWater = true; + break; - if (!CalamityWorld.downedDesertScourge) - { - npc.lifeMax = (int)(npc.lifeMax * DesertEnemyStatMultiplier); - npc.damage = (int)(npc.damage * DesertEnemyStatMultiplier); - npc.defDamage = npc.damage; - npc.defense /= 2; - npc.defDefense = npc.defense; - } - else - canBreakPlayerDefense = true; + // Desert slimes. + case NPCID.SandSlime: + VulnerableToCold = true; + VulnerableToSickness = false; + VulnerableToWater = true; + VulnerableToHeat = true; + break; - break; + // Organic undead or other enemies that are covered in slime. + case NPCID.ArmedZombieSlimed: + case NPCID.BigSlimedZombie: + case NPCID.BunnySlimed: + case NPCID.SlimedZombie: + case NPCID.SmallSlimedZombie: + VulnerableToCold = true; + VulnerableToHeat = true; + break; - case NPCID.Antlion: - case NPCID.FlyingAntlion: - if (!CalamityWorld.downedDesertScourge) - { - npc.lifeMax = (int)(npc.lifeMax * DesertEnemyStatMultiplier); - npc.damage = (int)(npc.damage * DesertEnemyStatMultiplier); - npc.defDamage = npc.damage; - npc.defense /= 2; - npc.defDefense = npc.defense; - } - break; + // Slimes that use heat-related attacks. + case NPCID.LavaSlime: + VulnerableToCold = true; + VulnerableToSickness = false; + VulnerableToHeat = false; + VulnerableToWater = true; + break; - // Reduce Dungeon Guardian HP - case NPCID.DungeonGuardian: - npc.lifeMax = (int)(npc.lifeMax * 0.1); - canBreakPlayerDefense = true; - break; + // Regular slimes. + case NPCID.DungeonSlime: + case NPCID.BabySlime: + case NPCID.BlackSlime: + case NPCID.BlueSlime: + case NPCID.CorruptSlime: + case NPCID.GreenSlime: + case NPCID.IlluminantSlime: + case NPCID.JungleSlime: + case NPCID.KingSlime: + case NPCID.MotherSlime: + case NPCID.PurpleSlime: + case NPCID.RainbowSlime: + case NPCID.RedSlime: + case NPCID.Slimeling: + case NPCID.SlimeMasked: + case NPCID.Slimer: + case NPCID.Slimer2: + case NPCID.SlimeRibbonGreen: + case NPCID.SlimeRibbonRed: + case NPCID.SlimeRibbonWhite: + case NPCID.SlimeRibbonYellow: + case NPCID.SlimeSpiked: + case NPCID.SpikedJungleSlime: + case NPCID.UmbrellaSlime: + case NPCID.YellowSlime: + case NPCID.ToxicSludge: + case NPCID.Crimslime: + case NPCID.BigCrimslime: + case NPCID.LittleCrimslime: + case NPCID.Gastropod: + case NPCID.Pinky: + VulnerableToSickness = false; + VulnerableToHeat = true; + break; - // Reduce Tomb Crawler stats - case NPCID.TombCrawlerHead: + // Skeletons and other armored/bone enemies that use heat-related attacks. + case NPCID.HellArmoredBones: + case NPCID.HellArmoredBonesMace: + case NPCID.HellArmoredBonesSpikeShield: + case NPCID.HellArmoredBonesSword: + case NPCID.DiabolistRed: + case NPCID.DiabolistWhite: + VulnerableToHeat = false; + VulnerableToCold = true; + VulnerableToSickness = false; + VulnerableToWater = true; + break; - npc.lifeMax = (int)(npc.lifeMax * (CalamityWorld.downedDesertScourge ? 0.6 : 0.45)); - if (!CalamityWorld.downedDesertScourge) - { - npc.damage = (int)(npc.damage * DesertEnemyStatMultiplier); - npc.defDamage = npc.damage; - // Tomb Crawler Head has 0 defense so there is no need to reduce it - } - else - canBreakPlayerDefense = true; + // Skeletons and other armored/bone enemies that are dead or undead. + case NPCID.SkeletronHand: + case NPCID.SkeletronHead: + case NPCID.AngryBones: + case NPCID.AngryBonesBig: + case NPCID.AngryBonesBigHelmet: + case NPCID.AngryBonesBigMuscle: + case NPCID.DarkCaster: + case NPCID.CursedSkull: + case NPCID.GiantCursedSkull: + case NPCID.DungeonGuardian: + case NPCID.BigBoned: + case NPCID.BlueArmoredBones: + case NPCID.BlueArmoredBonesMace: + case NPCID.BlueArmoredBonesNoPants: + case NPCID.BlueArmoredBonesSword: + case NPCID.BoneLee: + case NPCID.BoneSerpentBody: + case NPCID.BoneSerpentHead: + case NPCID.BoneSerpentTail: + case NPCID.BoneThrowingSkeleton: + case NPCID.BoneThrowingSkeleton2: + case NPCID.BoneThrowingSkeleton3: + case NPCID.BoneThrowingSkeleton4: + case NPCID.RustyArmoredBonesAxe: + case NPCID.RustyArmoredBonesFlail: + case NPCID.RustyArmoredBonesSword: + case NPCID.RustyArmoredBonesSwordNoArmor: + case NPCID.ShortBones: + case NPCID.Necromancer: + case NPCID.NecromancerArmored: + case NPCID.RaggedCaster: + case NPCID.RaggedCasterOpenCoat: + case NPCID.SkeletonCommando: + case NPCID.ArmoredSkeleton: + case NPCID.BigHeadacheSkeleton: + case NPCID.BigMisassembledSkeleton: + case NPCID.BigPantlessSkeleton: + case NPCID.BigSkeleton: + case NPCID.DD2SkeletonT1: + case NPCID.DD2SkeletonT3: + case NPCID.GreekSkeleton: + case NPCID.HeadacheSkeleton: + case NPCID.HeavySkeleton: + case NPCID.MisassembledSkeleton: + case NPCID.PantlessSkeleton: + case NPCID.Skeleton: + case NPCID.SkeletonAlien: + case NPCID.SkeletonArcher: + case NPCID.SkeletonAstonaut: + case NPCID.SkeletonSniper: + case NPCID.SkeletonTopHat: + case NPCID.SmallHeadacheSkeleton: + case NPCID.SmallMisassembledSkeleton: + case NPCID.SmallPantlessSkeleton: + case NPCID.SmallSkeleton: + case NPCID.TacticalSkeleton: + case NPCID.Tim: + case NPCID.UndeadMiner: + case NPCID.UndeadViking: + case NPCID.ArmoredViking: + case NPCID.GraniteFlyer: + case NPCID.GraniteGolem: + case NPCID.RuneWizard: + case NPCID.Golem: + case NPCID.GolemFistLeft: + case NPCID.GolemFistRight: + case NPCID.GolemHead: + case NPCID.GolemHeadFree: + VulnerableToSickness = false; + VulnerableToWater = true; + break; - break; + // Metal non-robotic enemies + case NPCID.BigMimicCorruption: + case NPCID.BigMimicCrimson: + case NPCID.BigMimicHallow: + case NPCID.BigMimicJungle: + case NPCID.Paladin: + case NPCID.Mimic: + case NPCID.PresentMimic: + case NPCID.PirateShipCannon: + case NPCID.PossessedArmor: + VulnerableToSickness = false; + break; - case NPCID.TombCrawlerBody: - case NPCID.TombCrawlerTail: + // Robotic enemies. + case NPCID.Probe: + case NPCID.MartianProbe: + case NPCID.DeadlySphere: + case NPCID.MartianDrone: + case NPCID.MartianWalker: + case NPCID.MartianTurret: + case NPCID.ElfCopter: + case NPCID.SkeletronPrime: + case NPCID.PrimeCannon: + case NPCID.PrimeLaser: + case NPCID.PrimeSaw: + case NPCID.PrimeVice: + case NPCID.TheDestroyer: + case NPCID.TheDestroyerBody: + case NPCID.TheDestroyerTail: + case NPCID.SantaNK1: + case NPCID.MartianSaucer: + case NPCID.MartianSaucerCannon: + case NPCID.MartianSaucerCore: + case NPCID.MartianSaucerTurret: + VulnerableToElectricity = true; + VulnerableToSickness = false; + break; - npc.lifeMax = (int)(npc.lifeMax * (CalamityWorld.downedDesertScourge ? 0.6 : 0.45)); - if (!CalamityWorld.downedDesertScourge) - { - npc.damage = (int)(npc.damage * DesertEnemyStatMultiplier); - npc.defDamage = npc.damage; - npc.defense /= 2; - npc.defDefense = npc.defense; - } + // Ghostly or ethereal enemies. + case NPCID.DungeonSpirit: + case NPCID.AncientCultistSquidhead: + case NPCID.CultistDragonBody1: + case NPCID.CultistDragonBody2: + case NPCID.CultistDragonBody3: + case NPCID.CultistDragonBody4: + case NPCID.CultistDragonHead: + case NPCID.CultistDragonTail: + case NPCID.Ghost: + case NPCID.ChaosElemental: + case NPCID.CrimsonAxe: + case NPCID.EnchantedSword: + case NPCID.CursedHammer: + case NPCID.DesertDjinn: + case NPCID.Wraith: + case NPCID.ShadowFlameApparition: + case NPCID.Reaper: + case NPCID.Poltergeist: + case NPCID.Pixie: + VulnerableToSickness = false; + break; - break; + // Organic enemies. + case NPCID.CultistArcherBlue: + case NPCID.CultistArcherWhite: + case NPCID.CultistBoss: + case NPCID.CultistDevote: + case NPCID.BloodCrawler: + case NPCID.BloodCrawlerWall: + case NPCID.CaveBat: + case NPCID.GiantBat: + case NPCID.CochinealBeetle: + case NPCID.CyanBeetle: + case NPCID.LacBeetle: + case NPCID.AnomuraFungus: + case NPCID.GiantFungiBulb: + case NPCID.FungiBulb: + case NPCID.MushiLadybug: + case NPCID.ZombieMushroom: + case NPCID.ZombieMushroomHat: + case NPCID.ManEater: + case NPCID.Snatcher: + case NPCID.AngryTrapper: + case NPCID.HoppinJack: + case NPCID.Splinterling: + case NPCID.MourningWood: + case NPCID.Pumpking: + case NPCID.Everscream: + case NPCID.Crimera: + case NPCID.BigCrimera: + case NPCID.LittleCrimera: + case NPCID.DemonEye: + case NPCID.DemonEye2: + case NPCID.DemonEyeOwl: + case NPCID.DemonEyeSpaceship: + case NPCID.DevourerBody: + case NPCID.DevourerHead: + case NPCID.DevourerTail: + case NPCID.DoctorBones: + case NPCID.EaterofSouls: + case NPCID.BigEater: + case NPCID.LittleEater: + case NPCID.EaterofWorldsBody: + case NPCID.EaterofWorldsHead: + case NPCID.EaterofWorldsTail: + case NPCID.FaceMonster: + case NPCID.GiantShelly: + case NPCID.GiantShelly2: + case NPCID.GiantWormBody: + case NPCID.GiantWormHead: + case NPCID.GiantWormTail: + case NPCID.GoblinScout: + case NPCID.Harpy: + case NPCID.JungleBat: + case NPCID.Nymph: + case NPCID.Raven: + case NPCID.Salamander: + case NPCID.Salamander2: + case NPCID.Salamander3: + case NPCID.Salamander4: + case NPCID.Salamander5: + case NPCID.Salamander6: + case NPCID.Salamander7: + case NPCID.Salamander8: + case NPCID.Salamander9: + case NPCID.Vulture: + case NPCID.WallCreeper: + case NPCID.WallCreeperWall: + case NPCID.ArmedZombie: + case NPCID.ArmedZombieCenx: + case NPCID.ArmedZombiePincussion: + case NPCID.ArmedZombieSwamp: + case NPCID.ArmedZombieTwiggy: + case NPCID.BaldZombie: + case NPCID.BigBaldZombie: + case NPCID.BigFemaleZombie: + case NPCID.BigPincushionZombie: + case NPCID.BigRainZombie: + case NPCID.BigSwampZombie: + case NPCID.BigTwiggyZombie: + case NPCID.BigZombie: + case NPCID.BloodZombie: + case NPCID.FemaleZombie: + case NPCID.PincushionZombie: + case NPCID.SmallBaldZombie: + case NPCID.SmallFemaleZombie: + case NPCID.SmallPincushionZombie: + case NPCID.SmallRainZombie: + case NPCID.SmallSwampZombie: + case NPCID.SmallTwiggyZombie: + case NPCID.SmallZombie: + case NPCID.SwampZombie: + case NPCID.TwiggyZombie: + case NPCID.Zombie: + case NPCID.ZombieDoctor: + case NPCID.ZombiePixie: + case NPCID.ZombieRaincoat: + case NPCID.ZombieSuperman: + case NPCID.ZombieSweater: + case NPCID.ZombieXmas: + case NPCID.Clinger: + case NPCID.Corruptor: + case NPCID.Derpling: + case NPCID.Herpling: + case NPCID.DiggerBody: + case NPCID.DiggerHead: + case NPCID.DiggerTail: + case NPCID.FloatyGross: + case NPCID.FlyingSnake: + case NPCID.Lihzahrd: + case NPCID.LihzahrdCrawler: + case NPCID.GiantFlyingFox: + case NPCID.GiantTortoise: + case NPCID.IchorSticker: + case NPCID.IlluminantBat: + case NPCID.Medusa: + case NPCID.Moth: + case NPCID.Unicorn: + case NPCID.WanderingEye: + case NPCID.Werewolf: + case NPCID.SeekerBody: + case NPCID.SeekerHead: + case NPCID.SeekerTail: + case NPCID.WyvernBody: + case NPCID.WyvernBody2: + case NPCID.WyvernBody3: + case NPCID.WyvernHead: + case NPCID.WyvernLegs: + case NPCID.WyvernTail: + case NPCID.Clown: + case NPCID.CorruptBunny: + case NPCID.CrimsonBunny: + case NPCID.Drippler: + case NPCID.TheGroom: + case NPCID.TheBride: + case NPCID.GoblinArcher: + case NPCID.GoblinPeon: + case NPCID.GoblinSorcerer: + case NPCID.GoblinSummoner: + case NPCID.GoblinThief: + case NPCID.GoblinWarrior: + case NPCID.DD2DarkMageT1: + case NPCID.DD2DarkMageT3: + case NPCID.DD2DrakinT2: + case NPCID.DD2DrakinT3: + case NPCID.DD2GoblinBomberT1: + case NPCID.DD2GoblinBomberT2: + case NPCID.DD2GoblinBomberT3: + case NPCID.DD2GoblinT1: + case NPCID.DD2GoblinT2: + case NPCID.DD2GoblinT3: + case NPCID.DD2JavelinstT1: + case NPCID.DD2JavelinstT2: + case NPCID.DD2JavelinstT3: + case NPCID.DD2KoboldFlyerT2: + case NPCID.DD2KoboldFlyerT3: + case NPCID.DD2KoboldWalkerT2: + case NPCID.DD2KoboldWalkerT3: + case NPCID.DD2OgreT2: + case NPCID.DD2OgreT3: + case NPCID.DD2WitherBeastT2: + case NPCID.DD2WitherBeastT3: + case NPCID.DD2WyvernT1: + case NPCID.DD2WyvernT2: + case NPCID.DD2WyvernT3: + case NPCID.Parrot: + case NPCID.PirateCaptain: + case NPCID.PirateCorsair: + case NPCID.PirateCrossbower: + case NPCID.PirateDeadeye: + case NPCID.PirateDeckhand: + case NPCID.Mothron: + case NPCID.MothronEgg: + case NPCID.MothronSpawn: + case NPCID.Butcher: + case NPCID.DrManFly: + case NPCID.Eyezor: + case NPCID.Frankenstein: + case NPCID.Fritz: + case NPCID.Nailhead: + case NPCID.Psycho: + case NPCID.SwampThing: + case NPCID.ThePossessed: + case NPCID.Vampire: + case NPCID.VampireBat: + case NPCID.BrainScrambler: + case NPCID.GigaZapper: + case NPCID.GrayGrunt: + case NPCID.MartianEngineer: + case NPCID.MartianOfficer: + case NPCID.RayGunner: + case NPCID.Scutlix: + case NPCID.ScutlixRider: + case NPCID.HeadlessHorseman: + case NPCID.Hellhound: + case NPCID.Scarecrow1: + case NPCID.Scarecrow2: + case NPCID.Scarecrow3: + case NPCID.Scarecrow4: + case NPCID.Scarecrow5: + case NPCID.Scarecrow6: + case NPCID.Scarecrow7: + case NPCID.Scarecrow8: + case NPCID.Scarecrow9: + case NPCID.Scarecrow10: + case NPCID.NebulaHeadcrab: + case NPCID.LunarTowerNebula: + case NPCID.NebulaBeast: + case NPCID.NebulaBrain: + case NPCID.NebulaSoldier: + case NPCID.LunarTowerSolar: + case NPCID.SolarCorite: + case NPCID.SolarCrawltipedeTail: + case NPCID.SolarDrakomire: + case NPCID.SolarDrakomireRider: + case NPCID.SolarSolenian: + case NPCID.SolarSpearman: + case NPCID.SolarSroller: + case NPCID.LunarTowerStardust: + case NPCID.StardustCellBig: + case NPCID.StardustCellSmall: + case NPCID.StardustJellyfishBig: + case NPCID.StardustSoldier: + case NPCID.StardustSpiderBig: + case NPCID.StardustSpiderSmall: + case NPCID.StardustWormHead: + case NPCID.LunarTowerVortex: + case NPCID.VortexHornet: + case NPCID.VortexHornetQueen: + case NPCID.VortexLarva: + case NPCID.VortexRifleman: + case NPCID.VortexSoldier: + case NPCID.BrainofCthulhu: + case NPCID.Creeper: + case NPCID.EyeofCthulhu: + case NPCID.ServantofCthulhu: + case NPCID.MoonLordCore: + case NPCID.MoonLordHand: + case NPCID.MoonLordHead: + case NPCID.Spazmatism: // Changes to robotic in phase 2 + case NPCID.Retinazer: // Changes to robotic in phase 2 + VulnerableToCold = true; + VulnerableToHeat = true; + VulnerableToSickness = true; + break; - // Fix Sharkron hitboxes - case NPCID.Sharkron: - case NPCID.Sharkron2: - npc.width = npc.height = 36; - canBreakPlayerDefense = true; - break; + // Demons and shit. + case NPCID.WallofFlesh: + case NPCID.WallofFleshEye: + case NPCID.TheHungry: + case NPCID.TheHungryII: + case NPCID.LeechBody: + case NPCID.LeechHead: + case NPCID.LeechTail: + case NPCID.Demon: + case NPCID.VoodooDemon: + case NPCID.RedDevil: + case NPCID.DemonTaxCollector: + VulnerableToCold = true; + VulnerableToHeat = false; + VulnerableToSickness = true; + break; - // Make Core hitbox bigger - case NPCID.MartianSaucerCore: - npc.width *= 2; - npc.height *= 2; - break; + // Fire enemies that are also organic. + case NPCID.FireImp: + case NPCID.Hellbat: + case NPCID.Lavabat: + VulnerableToCold = true; + VulnerableToHeat = false; + VulnerableToSickness = true; + VulnerableToWater = true; + break; - // Nerf Green Jellyfish because they spawn in prehardmode - case NPCID.GreenJellyfish: - npc.damage = 40; - npc.defDamage = npc.damage; - npc.defense = 4; - npc.defDefense = npc.defense; - break; + // Fire enemies that aren't organic. + case NPCID.MeteorHead: + VulnerableToCold = true; + VulnerableToHeat = false; + VulnerableToSickness = false; + VulnerableToWater = true; + break; - default: - break; - } + // Lightning bug thing. + case NPCID.DD2LightningBugT3: + VulnerableToElectricity = false; + VulnerableToCold = true; + VulnerableToHeat = true; + VulnerableToSickness = true; + break; - // Reduce mech boss HP and damage depending on the new ore progression changes - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - if (!NPC.downedMechBossAny) - { - if (CalamityLists.DestroyerIDs.Contains(npc.type) || npc.type == NPCID.Probe || CalamityLists.SkeletronPrimeIDs.Contains(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8); - npc.damage = (int)(npc.damage * 0.8); - npc.defDamage = npc.damage; - } - } - else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) - { - if (CalamityLists.DestroyerIDs.Contains(npc.type) || npc.type == NPCID.Probe || CalamityLists.SkeletronPrimeIDs.Contains(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) - { - npc.lifeMax = (int)(npc.lifeMax * 0.9); - npc.damage = (int)(npc.damage * 0.9); - npc.defDamage = npc.damage; - } - } - } + // Betsy. + case NPCID.DD2Betsy: + VulnerableToCold = true; + VulnerableToHeat = false; + VulnerableToSickness = true; + break; - if (Main.hardMode && CalamityLists.HardmodeNPCNerfList.Contains(npc.type)) - { - npc.damage = (int)(npc.damage * 0.75); - npc.defDamage = npc.damage; - } + // Nimbus + case NPCID.AngryNimbus: + VulnerableToCold = true; + VulnerableToElectricity = false; + VulnerableToWater = false; + VulnerableToHeat = false; + VulnerableToSickness = false; + break; - if (CalamityWorld.downedDoG) + // Cold-themed enemies + case NPCID.ArmedZombieEskimo: + case NPCID.ZombieEskimo: + case NPCID.IceBat: + case NPCID.SnowFlinx: + case NPCID.IceTortoise: + case NPCID.IcyMerman: + case NPCID.PigronCorruption: + case NPCID.PigronCrimson: + case NPCID.PigronHallow: + case NPCID.Wolf: + case NPCID.CorruptPenguin: + case NPCID.CrimsonPenguin: + case NPCID.ElfArcher: + case NPCID.Krampus: + case NPCID.Yeti: + case NPCID.Nutcracker: + case NPCID.NutcrackerSpinning: + case NPCID.ZombieElf: + case NPCID.ZombieElfBeard: + case NPCID.ZombieElfGirl: + VulnerableToHeat = true; + VulnerableToCold = false; + VulnerableToSickness = true; + break; + + // Cold-themed enemies that aren't organic. + case NPCID.IceElemental: + case NPCID.IceSlime: + case NPCID.SpikedIceSlime: + case NPCID.IceGolem: + case NPCID.MisterStabby: + case NPCID.SnowBalla: + case NPCID.SnowmanGangsta: + case NPCID.Flocko: + case NPCID.IceQueen: + case NPCID.GingerbreadMan: + VulnerableToCold = false; + VulnerableToHeat = true; + VulnerableToSickness = false; + break; + + // Water-themed enemies. + case NPCID.Crawdad: + case NPCID.Crawdad2: + case NPCID.BlueJellyfish: + case NPCID.GreenJellyfish: + case NPCID.PinkJellyfish: + case NPCID.BloodJelly: + case NPCID.FungoFish: + case NPCID.Crab: + case NPCID.Piranha: + case NPCID.SeaSnail: + case NPCID.Squid: + case NPCID.Shark: + case NPCID.AnglerFish: + case NPCID.Arapaima: + case NPCID.BloodFeeder: + case NPCID.CorruptGoldfish: + case NPCID.CrimsonGoldfish: + case NPCID.FlyingFish: + case NPCID.CreatureFromTheDeep: + case NPCID.DukeFishron: + case NPCID.Sharkron: + case NPCID.Sharkron2: + VulnerableToHeat = false; + VulnerableToSickness = true; + VulnerableToElectricity = true; + VulnerableToWater = false; + break; + + // Fucking bees, hornets and poisonous/toxic stuff. + case NPCID.Bee: + case NPCID.BeeSmall: + case NPCID.QueenBee: + case NPCID.BigHornetFatty: + case NPCID.BigHornetHoney: + case NPCID.BigHornetLeafy: + case NPCID.BigHornetSpikey: + case NPCID.BigHornetStingy: + case NPCID.BigMossHornet: + case NPCID.GiantMossHornet: + case NPCID.Hornet: + case NPCID.HornetFatty: + case NPCID.HornetHoney: + case NPCID.HornetLeafy: + case NPCID.HornetSpikey: + case NPCID.HornetStingy: + case NPCID.LittleHornetFatty: + case NPCID.LittleHornetHoney: + case NPCID.LittleHornetLeafy: + case NPCID.LittleHornetSpikey: + case NPCID.LittleHornetStingy: + case NPCID.LittleMossHornet: + case NPCID.MossHornet: + case NPCID.TinyMossHornet: + case NPCID.JungleCreeper: + case NPCID.JungleCreeperWall: + case NPCID.BlackRecluse: + case NPCID.BlackRecluseWall: + case NPCID.Plantera: + case NPCID.PlanterasTentacle: + VulnerableToCold = true; + VulnerableToHeat = true; + VulnerableToSickness = false; + break; + } + } + #endregion + + #region Other Stat Changes + private void OtherStatChanges(NPC npc) + { + switch (npc.type) + { + case NPCID.KingSlime: + case NPCID.EyeofCthulhu: + case NPCID.BrainofCthulhu: + case NPCID.QueenBee: + case NPCID.Corruptor: + case NPCID.Crawdad: + case NPCID.Crawdad2: + case NPCID.ManEater: + case NPCID.AngryTrapper: + case NPCID.Snatcher: + case NPCID.SpikeBall: + case NPCID.DesertBeast: + case NPCID.BoneLee: + case NPCID.Paladin: + case NPCID.BigMimicCorruption: + case NPCID.BigMimicCrimson: + case NPCID.BigMimicHallow: + case NPCID.DiggerHead: + case NPCID.SeekerHead: + case NPCID.DuneSplicerHead: + case NPCID.SolarCrawltipedeHead: + case NPCID.Mimic: + case NPCID.SandShark: + case NPCID.SandsharkCorrupt: + case NPCID.SandsharkCrimson: + case NPCID.SandsharkHallow: + case NPCID.Butcher: + case NPCID.DeadlySphere: + case NPCID.Mothron: + case NPCID.Reaper: + case NPCID.Psycho: + case NPCID.PresentMimic: + case NPCID.Yeti: + case NPCID.NebulaBeast: + case NPCID.SolarCorite: + case NPCID.StardustWormHead: + case NPCID.EaterofWorldsHead: + case NPCID.SkeletronHead: + case NPCID.SkeletronHand: + case NPCID.WallofFlesh: + case NPCID.TheHungry: + case NPCID.TheHungryII: + case NPCID.Spazmatism: + case NPCID.Retinazer: + case NPCID.TheDestroyer: + case NPCID.TheDestroyerBody: + case NPCID.TheDestroyerTail: + case NPCID.SkeletronPrime: + case NPCID.PrimeVice: + case NPCID.PrimeSaw: + case NPCID.Plantera: + case NPCID.PlanterasTentacle: + case NPCID.Golem: + case NPCID.GolemFistLeft: + case NPCID.GolemFistRight: + case NPCID.CultistDragonHead: + case NPCID.AncientCultistSquidhead: + case NPCID.AncientLight: + case NPCID.DD2OgreT2: + case NPCID.DD2OgreT3: + case NPCID.DD2Betsy: + case NPCID.PumpkingBlade: + case NPCID.SantaNK1: + case NPCID.DukeFishron: + canBreakPlayerDefense = true; + break; + + // Reduce prehardmode desert enemy stats pre-Desert Scourge + case NPCID.WalkingAntlion: + + if (!CalamityWorld.downedDesertScourge) + { + npc.lifeMax = (int)(npc.lifeMax * DesertEnemyStatMultiplier); + npc.damage = (int)(npc.damage * DesertEnemyStatMultiplier); + npc.defDamage = npc.damage; + npc.defense /= 2; + npc.defDefense = npc.defense; + } + else + canBreakPlayerDefense = true; + + break; + + case NPCID.Antlion: + case NPCID.FlyingAntlion: + if (!CalamityWorld.downedDesertScourge) + { + npc.lifeMax = (int)(npc.lifeMax * DesertEnemyStatMultiplier); + npc.damage = (int)(npc.damage * DesertEnemyStatMultiplier); + npc.defDamage = npc.damage; + npc.defense /= 2; + npc.defDefense = npc.defense; + } + break; + + // Reduce Dungeon Guardian HP + case NPCID.DungeonGuardian: + npc.lifeMax = (int)(npc.lifeMax * 0.1); + canBreakPlayerDefense = true; + break; + + // Reduce Tomb Crawler stats + case NPCID.TombCrawlerHead: + + npc.lifeMax = (int)(npc.lifeMax * (CalamityWorld.downedDesertScourge ? 0.6 : 0.45)); + if (!CalamityWorld.downedDesertScourge) + { + npc.damage = (int)(npc.damage * DesertEnemyStatMultiplier); + npc.defDamage = npc.damage; + // Tomb Crawler Head has 0 defense so there is no need to reduce it + } + else + canBreakPlayerDefense = true; + + break; + + case NPCID.TombCrawlerBody: + case NPCID.TombCrawlerTail: + + npc.lifeMax = (int)(npc.lifeMax * (CalamityWorld.downedDesertScourge ? 0.6 : 0.45)); + if (!CalamityWorld.downedDesertScourge) + { + npc.damage = (int)(npc.damage * DesertEnemyStatMultiplier); + npc.defDamage = npc.damage; + npc.defense /= 2; + npc.defDefense = npc.defense; + } + + break; + + // Fix Sharkron hitboxes + case NPCID.Sharkron: + case NPCID.Sharkron2: + npc.width = npc.height = 36; + canBreakPlayerDefense = true; + break; + + // Make Core hitbox bigger + case NPCID.MartianSaucerCore: + npc.width *= 2; + npc.height *= 2; + break; + + // Nerf Green Jellyfish because they spawn in prehardmode + case NPCID.GreenJellyfish: + npc.damage = 40; + npc.defDamage = npc.damage; + npc.defense = 4; + npc.defDefense = npc.defense; + break; + + default: + break; + } + + // Reduce mech boss HP and damage depending on the new ore progression changes + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + { + if (!NPC.downedMechBossAny) + { + if (CalamityLists.DestroyerIDs.Contains(npc.type) || npc.type == NPCID.Probe || CalamityLists.SkeletronPrimeIDs.Contains(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8); + npc.damage = (int)(npc.damage * 0.8); + npc.defDamage = npc.damage; + } + } + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) + { + if (CalamityLists.DestroyerIDs.Contains(npc.type) || npc.type == NPCID.Probe || CalamityLists.SkeletronPrimeIDs.Contains(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) + { + npc.lifeMax = (int)(npc.lifeMax * 0.9); + npc.damage = (int)(npc.damage * 0.9); + npc.defDamage = npc.damage; + } + } + } + + if (Main.hardMode && CalamityLists.HardmodeNPCNerfList.Contains(npc.type)) + { + npc.damage = (int)(npc.damage * 0.75); + npc.defDamage = npc.damage; + } + + if (CalamityWorld.downedDoG) { if (CalamityLists.pumpkinMoonBuffList.Contains(npc.type)) { @@ -2130,14 +2130,14 @@ namespace CalamityMod.NPCs npc.life = npc.lifeMax; npc.defDamage = npc.damage; } - else if (CalamityLists.eclipseBuffList.Contains(npc.type)) - { - npc.lifeMax = (int)(npc.lifeMax * 5D); - npc.damage += 30; - npc.life = npc.lifeMax; - npc.defDamage = npc.damage; - } - } + else if (CalamityLists.eclipseBuffList.Contains(npc.type)) + { + npc.lifeMax = (int)(npc.lifeMax * 5D); + npc.damage += 30; + npc.life = npc.lifeMax; + npc.defDamage = npc.damage; + } + } if (NPC.downedMoonlord) { @@ -2152,44 +2152,44 @@ namespace CalamityMod.NPCs if (CalamityWorld.revenge) { - double damageMultiplier = 1D; - bool containsNPC = false; + double damageMultiplier = 1D; + bool containsNPC = false; if (CalamityLists.revengeanceEnemyBuffList25Percent.Contains(npc.type)) { - damageMultiplier += 0.25; - containsNPC = true; + damageMultiplier += 0.25; + containsNPC = true; + } + else if (CalamityLists.revengeanceEnemyBuffList20Percent.Contains(npc.type)) + { + damageMultiplier += 0.2; + containsNPC = true; + } + else if (CalamityLists.revengeanceEnemyBuffList15Percent.Contains(npc.type)) + { + damageMultiplier += 0.15; + containsNPC = true; + } + else if (CalamityLists.revengeanceEnemyBuffList10Percent.Contains(npc.type)) + { + damageMultiplier += 0.1; + containsNPC = true; } - else if (CalamityLists.revengeanceEnemyBuffList20Percent.Contains(npc.type)) - { - damageMultiplier += 0.2; - containsNPC = true; - } - else if (CalamityLists.revengeanceEnemyBuffList15Percent.Contains(npc.type)) - { - damageMultiplier += 0.15; - containsNPC = true; - } - else if (CalamityLists.revengeanceEnemyBuffList10Percent.Contains(npc.type)) - { - damageMultiplier += 0.1; - containsNPC = true; - } - if (containsNPC) - { - if (CalamityWorld.death) - damageMultiplier += (damageMultiplier - 1D) * 0.6; + if (containsNPC) + { + if (CalamityWorld.death) + damageMultiplier += (damageMultiplier - 1D) * 0.6; - npc.damage = (int)(npc.damage * damageMultiplier); - npc.defDamage = npc.damage; - } - } + npc.damage = (int)(npc.damage * damageMultiplier); + npc.defDamage = npc.damage; + } + } - if (npc.type < NPCID.Count && NPCStats.EnemyStats.ContactDamageValues.ContainsKey(npc.type)) - { - npc.GetNPCDamage(); - npc.defDamage = npc.damage; - } + if (npc.type < NPCID.Count && NPCStats.EnemyStats.ContactDamageValues.ContainsKey(npc.type)) + { + npc.GetNPCDamage(); + npc.defDamage = npc.damage; + } if ((npc.boss && npc.type != NPCID.MartianSaucerCore && npc.type < NPCID.Count) || CalamityLists.bossHPScaleList.Contains(npc.type)) { @@ -2319,11 +2319,11 @@ namespace CalamityMod.NPCs #region Can Hit Player public override bool CanHitPlayer(NPC npc, Player target, ref int cooldownSlot) { - if (target.Calamity().prismaticHelmet && !CalamityPlayer.areThereAnyDamnBosses) - { - if (npc.lifeMax < 500) - return false; - } + if (target.Calamity().prismaticHelmet && !CalamityPlayer.areThereAnyDamnBosses) + { + if (npc.lifeMax < 500) + return false; + } return true; } @@ -2359,15 +2359,15 @@ namespace CalamityMod.NPCs // However, armor penetration bonus damage has already been applied, so it's slightly higher than it should be. double yellowCandleDamage = 0.05 * damage; - // Apply modifications to enemy's current defense based on Calamity debuffs. - // As with defense and DR, flat reductions apply first, then multiplicative reductions. - int effectiveDefense = npc.defense - + // Apply modifications to enemy's current defense based on Calamity debuffs. + // As with defense and DR, flat reductions apply first, then multiplicative reductions. + int effectiveDefense = npc.defense - (wCleave > 0 ? WarCleave.DefenseReduction : 0) - (aCrunch > 0 ? ArmorCrunch.DefenseReduction : 0) - (marked > 0 && DR <= 0f ? MarkedforDeath.DefenseReduction : 0) - - (wither > 0 ? WitherDebuff.DefenseReduction : 0) - - Main.LocalPlayer.armorPenetration - - miscDefenseLoss; + (wither > 0 ? WitherDebuff.DefenseReduction : 0) - + Main.LocalPlayer.armorPenetration - + miscDefenseLoss; // Defense can never be negative and has a minimum value of zero. if (effectiveDefense < 0) @@ -2379,31 +2379,31 @@ namespace CalamityMod.NPCs // DR applies after vanilla defense. damage = ApplyDR(npc, damage, yellowCandleDamage); - // Damage reduction on spawn for certain worm bosses. - bool destroyerResist = CalamityLists.DestroyerIDs.Contains(npc.type) && (CalamityWorld.revenge || BossRushEvent.BossRushActive); - bool eaterofWorldsResist = CalamityLists.EaterofWorldsIDs.Contains(npc.type) && BossRushEvent.BossRushActive; - if (destroyerResist || eaterofWorldsResist || CalamityLists.AstrumDeusIDs.Contains(npc.type)) - { - float resistanceGateValue = (CalamityLists.AstrumDeusIDs.Contains(npc.type) && newAI[0] != 0f) ? 300f : 600f; - if (newAI[1] < resistanceGateValue || (newAI[2] > 0f && CalamityLists.DestroyerIDs.Contains(npc.type))) - damage *= 0.01; - } + // Damage reduction on spawn for certain worm bosses. + bool destroyerResist = CalamityLists.DestroyerIDs.Contains(npc.type) && (CalamityWorld.revenge || BossRushEvent.BossRushActive); + bool eaterofWorldsResist = CalamityLists.EaterofWorldsIDs.Contains(npc.type) && BossRushEvent.BossRushActive; + if (destroyerResist || eaterofWorldsResist || CalamityLists.AstrumDeusIDs.Contains(npc.type)) + { + float resistanceGateValue = (CalamityLists.AstrumDeusIDs.Contains(npc.type) && newAI[0] != 0f) ? 300f : 600f; + if (newAI[1] < resistanceGateValue || (newAI[2] > 0f && CalamityLists.DestroyerIDs.Contains(npc.type))) + damage *= 0.01; + } - // Large Deus worm takes reduced damage to last a long enough time. - if (CalamityLists.AstrumDeusIDs.Contains(npc.type) && newAI[0] == 0f) - damage *= 0.8; + // Large Deus worm takes reduced damage to last a long enough time. + if (CalamityLists.AstrumDeusIDs.Contains(npc.type) && newAI[0] == 0f) + damage *= 0.8; - // Inflict 0 damage if it's below 0.5 - damage = damage < 0.5 ? 0D : damage < 1D ? 1D : damage; + // Inflict 0 damage if it's below 0.5 + damage = damage < 0.5 ? 0D : damage < 1D ? 1D : damage; - // Disable vanilla damage method if damage is less than 0.5 - if (damage == 0D) - return false; + // Disable vanilla damage method if damage is less than 0.5 + if (damage == 0D) + return false; - // Cancel out vanilla defense math by reversing the calculation vanilla is about to perform. - // While roundabout, this is safer than returning false to stop vanilla damage calculations entirely. - // Other mods will probably expect the vanilla code to run and may compensate for it themselves. - damage = Main.CalculateDamage((int)damage, -defense); + // Cancel out vanilla defense math by reversing the calculation vanilla is about to perform. + // While roundabout, this is safer than returning false to stop vanilla damage calculations entirely. + // Other mods will probably expect the vanilla code to run and may compensate for it themselves. + damage = Main.CalculateDamage((int)damage, -defense); return true; } @@ -2426,36 +2426,36 @@ namespace CalamityMod.NPCs if (effectiveDR <= 0f) effectiveDR = 0f; - // Add Yellow Candle damage if the NPC isn't supposed to be "near invincible" - if (yellowCandle > 0 && DR < 0.99f && npc.takenDamageMultiplier > 0.05f) - damage += yellowCandleDamage; + // Add Yellow Candle damage if the NPC isn't supposed to be "near invincible" + if (yellowCandle > 0 && DR < 0.99f && npc.takenDamageMultiplier > 0.05f) + damage += yellowCandleDamage; - // Calculate extra DR based on kill time, similar to the Hush boss from The Binding of Isaac - bool nightProvi = npc.type == NPCType() && (!Main.dayTime || CalamityWorld.malice); - if (KillTime > 0 && AITimer < KillTime && !BossRushEvent.BossRushActive && nightProvi) - { - // Set the DR scaling factor - float DRScalar = 10f; + // Calculate extra DR based on kill time, similar to the Hush boss from The Binding of Isaac + bool nightProvi = npc.type == NPCType() && (!Main.dayTime || CalamityWorld.malice); + if (KillTime > 0 && AITimer < KillTime && !BossRushEvent.BossRushActive && nightProvi) + { + // Set the DR scaling factor + float DRScalar = 10f; // The limit for how much extra DR the boss can have float extraDRLimit = (1f - DR) * DRScalar; - // Ranges from 1 to 0 - float currentHPRatio = npc.life / (float)npc.lifeMax; + // Ranges from 1 to 0 + float currentHPRatio = npc.life / (float)npc.lifeMax; - // Ranges from 0 to 1 - float killTimeRatio = AITimer / (float)KillTime; + // 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))); - } - } + // 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; + double newDamage = (1f - effectiveDR) * damage; return newDamage; } @@ -2534,119 +2534,119 @@ namespace CalamityMod.NPCs #region Boss Head Slot public override void BossHeadSlot(NPC npc, ref int index) { - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - if (npc.type == NPCID.BrainofCthulhu) - { - if (npc.life / (float)npc.lifeMax < ((CalamityWorld.death || BossRushEvent.BossRushActive) ? 1f : 0.2f)) - index = -1; - } + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + { + if (npc.type == NPCID.BrainofCthulhu) + { + if (npc.life / (float)npc.lifeMax < ((CalamityWorld.death || BossRushEvent.BossRushActive) ? 1f : 0.2f)) + index = -1; + } - if (npc.type == NPCID.DukeFishron && (CalamityWorld.death || BossRushEvent.BossRushActive)) - { - if (npc.life / (float)npc.lifeMax < 0.4f) - index = -1; - } - } + if (npc.type == NPCID.DukeFishron && (CalamityWorld.death || BossRushEvent.BossRushActive)) + { + if (npc.life / (float)npc.lifeMax < 0.4f) + index = -1; + } + } } #endregion #region Pre AI public override bool PreAI(NPC npc) { - // Change Spaz and Ret weaknesses and resistances when phase 2 starts. - if (npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) - { - if (npc.ai[0] >= 2f) - { - VulnerableToCold = null; - VulnerableToHeat = null; - VulnerableToSickness = false; - VulnerableToElectricity = true; - } - } + // Change Spaz and Ret weaknesses and resistances when phase 2 starts. + if (npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) + { + if (npc.ai[0] >= 2f) + { + VulnerableToCold = null; + VulnerableToHeat = null; + VulnerableToSickness = false; + VulnerableToElectricity = true; + } + } - if (VulnerabilityHexFireDrawer != null) - VulnerabilityHexFireDrawer.Update(); + if (VulnerabilityHexFireDrawer != null) + VulnerabilityHexFireDrawer.Update(); - SetPatreonTownNPCName(npc, mod); + SetPatreonTownNPCName(npc, mod); - // Decrement each immune timer if it's greater than 0. - for (int i = 0; i < maxPlayerImmunities; i++) - { - if (dashImmunityTime[i] > 0) - dashImmunityTime[i]--; - } + // Decrement each immune timer if it's greater than 0. + for (int i = 0; i < maxPlayerImmunities; i++) + { + if (dashImmunityTime[i] > 0) + dashImmunityTime[i]--; + } - if (CalamityPlayer.areThereAnyDamnBosses) - { - if (npc.velocity.Length() > maxVelocity) - maxVelocity = npc.velocity.Length(); - } + if (CalamityPlayer.areThereAnyDamnBosses) + { + if (npc.velocity.Length() > maxVelocity) + maxVelocity = npc.velocity.Length(); + } - if (KillTime > 0 || npc.type == NPCType()) - { - // If any boss NPC is active, apply Zen to nearby players to reduce spawn rate. - if (CalamityConfig.Instance.BossZen) - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < BossZenDistance) - Main.player[Main.myPlayer].AddBuff(BuffType(), 2); - } - } + if (KillTime > 0 || npc.type == NPCType()) + { + // If any boss NPC is active, apply Zen to nearby players to reduce spawn rate. + if (CalamityConfig.Instance.BossZen) + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < BossZenDistance) + Main.player[Main.myPlayer].AddBuff(BuffType(), 2); + } + } - if (npc.type != NPCType()) - { - if (AITimer < KillTime) - AITimer++; - } - } + if (npc.type != NPCType()) + { + if (AITimer < KillTime) + AITimer++; + } + } - if (npc.type == NPCID.TargetDummy || npc.type == NPCType()) + if (npc.type == NPCID.TargetDummy || npc.type == NPCType()) { npc.dontTakeDamage = CalamityPlayer.areThereAnyDamnBosses; - if (draedon != -1) - { - if (Main.npc[draedon].active) - npc.dontTakeDamage = true; - } - } + if (draedon != -1) + { + if (Main.npc[draedon].active) + npc.dontTakeDamage = true; + } + } - // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - if (CalamityLists.ZeroContactDamageNPCList.Contains(npc.type)) - npc.damage = npc.defDamage = 0; + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + if (CalamityLists.ZeroContactDamageNPCList.Contains(npc.type)) + npc.damage = npc.defDamage = 0; - // Don't do damage for 42 frames after spawning in - if (npc.type == NPCID.Sharkron || npc.type == NPCID.Sharkron2) - npc.damage = npc.alpha > 0 ? 0 : npc.defDamage; + // Don't do damage for 42 frames after spawning in + if (npc.type == NPCID.Sharkron || npc.type == NPCID.Sharkron2) + npc.damage = npc.alpha > 0 ? 0 : npc.defDamage; - if (CalamityLists.DestroyerIDs.Contains(npc.type) || CalamityLists.EaterofWorldsIDs.Contains(npc.type)) + if (CalamityLists.DestroyerIDs.Contains(npc.type) || CalamityLists.EaterofWorldsIDs.Contains(npc.type)) npc.buffImmune[BuffType()] = false; if (BossRushEvent.BossRushActive && !npc.friendly && !npc.townNPC && !npc.Calamity().DoesNotDisappearInBossRush) BossRushForceDespawnOtherNPCs(npc, mod); - if (NPC.LunarApocalypseIsUp) - PillarEventProgressionEdit(npc); + if (NPC.LunarApocalypseIsUp) + PillarEventProgressionEdit(npc); - // Adult Wyrm Ancient Doom - if (npc.type == NPCID.AncientDoom) - { - if (Main.npc[(int)npc.ai[0]].type == NPCType()) - return CultistAI.BuffedAncientDoomAI(npc, mod); - } - - // Disable teleports for hardmode dungeon casters if they get hit - if (npc.type >= NPCID.RaggedCaster && npc.type <= NPCID.DiabolistWhite && npc.justHit) - { - npc.ai[0] = 1f; - } - - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + // Adult Wyrm Ancient Doom + if (npc.type == NPCID.AncientDoom) { - switch (npc.type) + if (Main.npc[(int)npc.ai[0]].type == NPCType()) + return CultistAI.BuffedAncientDoomAI(npc, mod); + } + + // Disable teleports for hardmode dungeon casters if they get hit + if (npc.type >= NPCID.RaggedCaster && npc.type <= NPCID.DiabolistWhite && npc.justHit) + { + npc.ai[0] = 1f; + } + + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + { + switch (npc.type) { case NPCID.KingSlime: return KingSlimeAI.BuffedKingSlimeAI(npc, mod); @@ -2681,8 +2681,8 @@ namespace CalamityMod.NPCs case NPCID.TheDestroyerBody: case NPCID.TheDestroyerTail: return DestroyerAI.BuffedDestroyerAI(npc, mod); - case NPCID.Probe: - return DestroyerAI.BuffedProbeAI(npc, mod); + case NPCID.Probe: + return DestroyerAI.BuffedProbeAI(npc, mod); case NPCID.Retinazer: return TwinsAI.BuffedRetinazerAI(npc, mod); @@ -2709,9 +2709,9 @@ namespace CalamityMod.NPCs case NPCID.Golem: return GolemAI.BuffedGolemAI(npc, mod); - case NPCID.GolemFistLeft: - case NPCID.GolemFistRight: - return GolemAI.BuffedGolemFistAI(npc, mod); + case NPCID.GolemFistLeft: + case NPCID.GolemFistRight: + return GolemAI.BuffedGolemFistAI(npc, mod); case NPCID.GolemHead: return GolemAI.BuffedGolemHeadAI(npc, mod); case NPCID.GolemHeadFree: @@ -2755,615 +2755,615 @@ namespace CalamityMod.NPCs case NPCID.CultistBoss: case NPCID.CultistBossClone: return CultistAI.BuffedCultistAI(npc, mod); - case NPCID.AncientLight: - return CultistAI.BuffedAncientLightAI(npc, mod); - case NPCID.AncientDoom: + case NPCID.AncientLight: + return CultistAI.BuffedAncientLightAI(npc, mod); + case NPCID.AncientDoom: return CultistAI.BuffedAncientDoomAI(npc, mod); case NPCID.MoonLordCore: case NPCID.MoonLordHand: case NPCID.MoonLordHead: - case NPCID.MoonLordFreeEye: - case NPCID.MoonLordLeechBlob: + case NPCID.MoonLordFreeEye: + case NPCID.MoonLordLeechBlob: return MoonLordAI.BuffedMoonLordAI(npc, mod); - default: + default: break; } } - else if (npc.type == NPCID.Retinazer) - return TwinsAI.TrueMeleeRetinazerPhase2AI(npc); + else if (npc.type == NPCID.Retinazer) + return TwinsAI.TrueMeleeRetinazerPhase2AI(npc); - if (CalamityWorld.death) - { - switch (npc.aiStyle) - { - case 1: - 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()) - { - return SlimeAI.BuffedSlimeAI(npc, mod); - } - else - { - switch (npc.type) - { - case NPCID.BlueSlime: - case NPCID.MotherSlime: - case NPCID.LavaSlime: - case NPCID.DungeonSlime: - case NPCID.CorruptSlime: - case NPCID.IlluminantSlime: - case NPCID.ToxicSludge: - case NPCID.IceSlime: - case NPCID.Crimslime: - case NPCID.SpikedIceSlime: - case NPCID.SpikedJungleSlime: - case NPCID.UmbrellaSlime: - case NPCID.RainbowSlime: - case NPCID.SlimeMasked: - case NPCID.HoppinJack: - case NPCID.SlimeRibbonWhite: - case NPCID.SlimeRibbonYellow: - case NPCID.SlimeRibbonGreen: - case NPCID.SlimeRibbonRed: - case NPCID.SlimeSpiked: - case NPCID.SandSlime: - return SlimeAI.BuffedSlimeAI(npc, mod); - } - } - break; - case 2: - if (npc.type == NPCType() || npc.type == NPCType()) - { - return DemonEyeAI.BuffedDemonEyeAI(npc, mod); - } - else - { - switch (npc.type) - { - case NPCID.DemonEye: - case NPCID.TheHungryII: - case NPCID.WanderingEye: - case NPCID.PigronCorruption: - case NPCID.PigronHallow: - case NPCID.PigronCrimson: - case NPCID.CataractEye: - case NPCID.SleepyEye: - case NPCID.DialatedEye: - case NPCID.GreenEye: - case NPCID.PurpleEye: - case NPCID.DemonEyeOwl: - case NPCID.DemonEyeSpaceship: - return DemonEyeAI.BuffedDemonEyeAI(npc, mod); - } - } - break; - case 3: - if (npc.type == NPCType() || - npc.type == NPCType() || npc.type == NPCType()) - { - return CalamityGlobalAI.BuffedFighterAI(npc, mod); - } - else - { - switch (npc.type) - { - case NPCID.Zombie: - case NPCID.ArmedZombie: - case NPCID.ArmedZombieEskimo: - case NPCID.ArmedZombiePincussion: - case NPCID.ArmedZombieSlimed: - case NPCID.ArmedZombieSwamp: - case NPCID.ArmedZombieTwiggy: - case NPCID.ArmedZombieCenx: - case NPCID.Skeleton: - case NPCID.AngryBones: - case NPCID.UndeadMiner: - case NPCID.CorruptBunny: - case NPCID.DoctorBones: - case NPCID.TheGroom: - case NPCID.Crab: - case NPCID.GoblinScout: - case NPCID.ArmoredSkeleton: - case NPCID.Mummy: - case NPCID.DarkMummy: - case NPCID.LightMummy: - case NPCID.Werewolf: - case NPCID.Clown: - case NPCID.SkeletonArcher: - case NPCID.ChaosElemental: - case NPCID.BaldZombie: - case NPCID.PossessedArmor: - case NPCID.ZombieEskimo: - case NPCID.BlackRecluse: - case NPCID.WallCreeper: - case NPCID.UndeadViking: - case NPCID.CorruptPenguin: - case NPCID.FaceMonster: - case NPCID.SnowFlinx: - case NPCID.PincushionZombie: - case NPCID.SlimedZombie: - case NPCID.SwampZombie: - case NPCID.TwiggyZombie: - case NPCID.Nymph: - case NPCID.ArmoredViking: - case NPCID.Lihzahrd: - case NPCID.LihzahrdCrawler: - case NPCID.FemaleZombie: - case NPCID.HeadacheSkeleton: - case NPCID.MisassembledSkeleton: - case NPCID.PantlessSkeleton: - case NPCID.IcyMerman: - case NPCID.PirateDeckhand: - case NPCID.PirateCorsair: - case NPCID.PirateDeadeye: - case NPCID.PirateCrossbower: - case NPCID.PirateCaptain: - case NPCID.CochinealBeetle: - case NPCID.CyanBeetle: - case NPCID.LacBeetle: - case NPCID.SeaSnail: - case NPCID.ZombieRaincoat: - case NPCID.JungleCreeper: - case NPCID.BloodCrawler: - case NPCID.IceGolem: - case NPCID.Eyezor: - case NPCID.ZombieMushroom: - case NPCID.ZombieMushroomHat: - case NPCID.AnomuraFungus: - case NPCID.MushiLadybug: - case NPCID.RustyArmoredBonesAxe: - case NPCID.RustyArmoredBonesFlail: - case NPCID.RustyArmoredBonesSword: - case NPCID.RustyArmoredBonesSwordNoArmor: - case NPCID.BlueArmoredBones: - case NPCID.BlueArmoredBonesMace: - case NPCID.BlueArmoredBonesNoPants: - case NPCID.BlueArmoredBonesSword: - case NPCID.HellArmoredBones: - case NPCID.HellArmoredBonesSpikeShield: - case NPCID.HellArmoredBonesMace: - case NPCID.HellArmoredBonesSword: - case NPCID.BoneLee: - case NPCID.Paladin: - case NPCID.SkeletonSniper: - case NPCID.TacticalSkeleton: - case NPCID.SkeletonCommando: - case NPCID.AngryBonesBig: - case NPCID.AngryBonesBigMuscle: - case NPCID.AngryBonesBigHelmet: - case NPCID.Scarecrow1: - case NPCID.Scarecrow2: - case NPCID.Scarecrow3: - case NPCID.Scarecrow4: - case NPCID.Scarecrow5: - case NPCID.Scarecrow6: - case NPCID.Scarecrow7: - case NPCID.Scarecrow8: - case NPCID.Scarecrow9: - case NPCID.Scarecrow10: - case NPCID.ZombieDoctor: - case NPCID.ZombieSuperman: - case NPCID.ZombiePixie: - case NPCID.SkeletonTopHat: - case NPCID.SkeletonAstonaut: - case NPCID.SkeletonAlien: - case NPCID.Splinterling: - case NPCID.ZombieXmas: - case NPCID.ZombieSweater: - case NPCID.ZombieElf: - case NPCID.ZombieElfBeard: - case NPCID.ZombieElfGirl: - case NPCID.GingerbreadMan: - case NPCID.Yeti: - case NPCID.Nutcracker: - case NPCID.NutcrackerSpinning: - case NPCID.ElfArcher: - case NPCID.Krampus: - case NPCID.CultistArcherBlue: - case NPCID.CultistArcherWhite: - case NPCID.BrainScrambler: - case NPCID.RayGunner: - case NPCID.MartianOfficer: - case NPCID.GrayGrunt: - case NPCID.MartianEngineer: - case NPCID.GigaZapper: - case NPCID.Scutlix: - case NPCID.BoneThrowingSkeleton: - case NPCID.BoneThrowingSkeleton2: - case NPCID.BoneThrowingSkeleton3: - case NPCID.BoneThrowingSkeleton4: - case NPCID.CrimsonBunny: - case NPCID.CrimsonPenguin: - case NPCID.Medusa: - case NPCID.GreekSkeleton: - case NPCID.GraniteGolem: - case NPCID.BloodZombie: - case NPCID.Crawdad: - case NPCID.Crawdad2: - case NPCID.Salamander: - case NPCID.Salamander2: - case NPCID.Salamander3: - case NPCID.Salamander4: - case NPCID.Salamander5: - case NPCID.Salamander6: - case NPCID.Salamander7: - case NPCID.Salamander8: - case NPCID.Salamander9: - case NPCID.WalkingAntlion: - case NPCID.DesertGhoul: - case NPCID.DesertGhoulCorruption: - case NPCID.DesertGhoulCrimson: - case NPCID.DesertGhoulHallow: - case NPCID.DesertLamiaLight: - case NPCID.DesertLamiaDark: - case NPCID.DesertScorpionWalk: - case NPCID.DesertBeast: - case NPCID.StardustSoldier: - case NPCID.StardustSpiderBig: - case NPCID.NebulaSoldier: - case NPCID.VortexRifleman: - case NPCID.VortexSoldier: - case NPCID.VortexLarva: - case NPCID.VortexHornet: - case NPCID.VortexHornetQueen: - case NPCID.SolarDrakomire: - case NPCID.SolarSpearman: - case NPCID.SolarSolenian: - case NPCID.Frankenstein: - case NPCID.SwampThing: - case NPCID.Vampire: - case NPCID.Butcher: - case NPCID.CreatureFromTheDeep: - case NPCID.Fritz: - case NPCID.Nailhead: - case NPCID.Psycho: - case NPCID.ThePossessed: - case NPCID.DrManFly: - case NPCID.GoblinPeon: - case NPCID.GoblinThief: - case NPCID.GoblinWarrior: - case NPCID.GoblinArcher: - case NPCID.GoblinSummoner: - case NPCID.MartianWalker: - case NPCID.DemonTaxCollector: - case NPCID.TheBride: - return CalamityGlobalAI.BuffedFighterAI(npc, mod); - } - } - break; - case 5: - switch (npc.type) - { - case NPCID.ServantofCthulhu: - case NPCID.EaterofSouls: - case NPCID.MeteorHead: - case NPCID.Corruptor: - case NPCID.Crimera: - case NPCID.Moth: - case NPCID.Parrot: - return CalamityGlobalAI.BuffedFlyingAI(npc, mod); - } - break; - case 6: - switch (npc.type) - { - case NPCID.DevourerHead: - case NPCID.DevourerBody: - case NPCID.DevourerTail: - case NPCID.GiantWormHead: - case NPCID.GiantWormBody: - case NPCID.GiantWormTail: - case NPCID.BoneSerpentHead: - case NPCID.BoneSerpentBody: - case NPCID.BoneSerpentTail: - case NPCID.WyvernHead: - case NPCID.WyvernLegs: - case NPCID.WyvernBody: - case NPCID.WyvernBody2: - case NPCID.WyvernBody3: - case NPCID.WyvernTail: - case NPCID.DiggerHead: - case NPCID.DiggerBody: - case NPCID.DiggerTail: - case NPCID.SeekerHead: - case NPCID.SeekerBody: - case NPCID.SeekerTail: - case NPCID.LeechHead: - case NPCID.LeechBody: - case NPCID.LeechTail: - case NPCID.TombCrawlerHead: - case NPCID.TombCrawlerBody: - case NPCID.TombCrawlerTail: - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - case NPCID.StardustWormHead: - case NPCID.SolarCrawltipedeHead: - case NPCID.SolarCrawltipedeBody: - case NPCID.SolarCrawltipedeTail: - return CalamityGlobalAI.BuffedWormAI(npc, mod); - } - break; - case 8: - switch (npc.type) - { - case NPCID.FireImp: - case NPCID.DarkCaster: - case NPCID.Tim: - case NPCID.RuneWizard: - case NPCID.RaggedCaster: - case NPCID.RaggedCasterOpenCoat: - case NPCID.Necromancer: - case NPCID.NecromancerArmored: - case NPCID.DiabolistRed: - case NPCID.DiabolistWhite: - case NPCID.DesertDjinn: - case NPCID.GoblinSorcerer: - return CalamityGlobalAI.BuffedCasterAI(npc, mod); - } - break; - case 13: - switch (npc.type) - { - case NPCID.ManEater: - case NPCID.Snatcher: - case NPCID.Clinger: - case NPCID.AngryTrapper: - case NPCID.FungiBulb: - case NPCID.GiantFungiBulb: - return CalamityGlobalAI.BuffedPlantAI(npc, mod); - } - break; - case 14: - if (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType()) - { - return CalamityGlobalAI.BuffedBatAI(npc, mod); - } - else - { - switch (npc.type) - { - case NPCID.Harpy: - case NPCID.CaveBat: - case NPCID.JungleBat: - case NPCID.Hellbat: - case NPCID.Demon: - case NPCID.VoodooDemon: - case NPCID.GiantBat: - case NPCID.Slimer: - case NPCID.IlluminantBat: - case NPCID.IceBat: - case NPCID.Lavabat: - case NPCID.GiantFlyingFox: - case NPCID.RedDevil: - case NPCID.FlyingSnake: - case NPCID.VampireBat: - return CalamityGlobalAI.BuffedBatAI(npc, mod); - } - } - break; - case 16: - switch (npc.type) - { - case NPCID.CorruptGoldfish: - case NPCID.Piranha: - case NPCID.Shark: - case NPCID.AnglerFish: - case NPCID.Arapaima: - case NPCID.BloodFeeder: - case NPCID.CrimsonGoldfish: - return CalamityGlobalAI.BuffedSwimmingAI(npc, mod); - } - break; - case 18: - switch (npc.type) - { - case NPCID.BlueJellyfish: - case NPCID.PinkJellyfish: - case NPCID.GreenJellyfish: - case NPCID.Squid: - case NPCID.BloodJelly: - case NPCID.FungoFish: - return CalamityGlobalAI.BuffedJellyfishAI(npc, mod); - } - break; - case 19: - switch (npc.type) - { - case NPCID.Antlion: - return CalamityGlobalAI.BuffedAntlionAI(npc, mod); - } - break; - case 20: - switch (npc.type) - { - case NPCID.SpikeBall: - return CalamityGlobalAI.BuffedSpikeBallAI(npc, mod); - } - break; - case 21: - switch (npc.type) - { - case NPCID.BlazingWheel: - return CalamityGlobalAI.BuffedBlazingWheelAI(npc, mod); - } - break; - case 22: - switch (npc.type) - { - case NPCID.Pixie: - case NPCID.Wraith: - case NPCID.Gastropod: - case NPCID.IceElemental: - case NPCID.FloatyGross: - case NPCID.IchorSticker: - case NPCID.Ghost: - case NPCID.Poltergeist: - case NPCID.Drippler: - case NPCID.Reaper: - return CalamityGlobalAI.BuffedHoveringAI(npc, mod); - } - break; - case 23: - switch (npc.type) - { - case NPCID.CursedHammer: - case NPCID.EnchantedSword: - case NPCID.CrimsonAxe: - return CalamityGlobalAI.BuffedFlyingWeaponAI(npc, mod); - } - break; - case 25: - switch (npc.type) - { - case NPCID.Mimic: - case NPCID.PresentMimic: - return CalamityGlobalAI.BuffedMimicAI(npc, mod); - } - break; - case 26: - if (npc.type == NPCType()) - { - return CalamityGlobalAI.BuffedUnicornAI(npc, mod); - } - else - { - switch (npc.type) - { - case NPCID.Unicorn: - case NPCID.Wolf: - case NPCID.HeadlessHorseman: - case NPCID.Hellhound: - case NPCID.StardustSpiderSmall: - case NPCID.NebulaBeast: - case NPCID.Tumbleweed: - return CalamityGlobalAI.BuffedUnicornAI(npc, mod); - } - } - break; - case 39: - if (npc.type == NPCType() || npc.type == NPCType()) - { - return CalamityGlobalAI.BuffedTortoiseAI(npc, mod); - } - else - { - switch (npc.type) - { - case NPCID.GiantTortoise: - case NPCID.IceTortoise: - case NPCID.GiantShelly: - case NPCID.GiantShelly2: - case NPCID.SolarSroller: - return CalamityGlobalAI.BuffedTortoiseAI(npc, mod); - } - } - break; - case 40: - switch (npc.type) - { - case NPCID.BlackRecluseWall: - case NPCID.WallCreeperWall: - case NPCID.JungleCreeperWall: - case NPCID.BloodCrawlerWall: - case NPCID.DesertScorpionWall: - return CalamityGlobalAI.BuffedSpiderAI(npc, mod); - } - break; - case 41: - if (npc.type == NPCType()) - { - return CalamityGlobalAI.BuffedHerplingAI(npc, mod); - } - else - { - switch (npc.type) - { - case NPCID.Herpling: - case NPCID.Derpling: - return CalamityGlobalAI.BuffedHerplingAI(npc, mod); - } - } - break; - case 44: - switch (npc.type) - { - case NPCID.FlyingFish: - case NPCID.FlyingAntlion: - return CalamityGlobalAI.BuffedFlyingFishAI(npc, mod); - } - break; - case 49: - switch (npc.type) - { - case NPCID.AngryNimbus: - return CalamityGlobalAI.BuffedAngryNimbusAI(npc, mod); - } - break; - case 50: - switch (npc.type) - { - case NPCID.FungiSpore: - case NPCID.Spore: - return CalamityGlobalAI.BuffedSporeAI(npc, mod); - } - break; - case 73: - switch (npc.type) - { - case NPCID.MartianTurret: - return CalamityGlobalAI.BuffedTeslaTurretAI(npc, mod); - } - break; - case 74: - switch (npc.type) - { - case NPCID.MartianDrone: - case NPCID.SolarCorite: - return CalamityGlobalAI.BuffedCoriteAI(npc, mod); - } - break; - case 80: - switch (npc.type) - { - case NPCID.MartianProbe: - return CalamityGlobalAI.BuffedMartianProbeAI(npc, mod); - } - break; - case 89: - switch (npc.type) - { - case NPCID.MothronEgg: - return CalamityGlobalAI.BuffedMothronEggAI(npc, mod); - } - break; - case 91: - if (npc.type == NPCType()) - { - return CalamityGlobalAI.BuffedGraniteElementalAI(npc, mod); - } - else - { - switch (npc.type) - { - case NPCID.GraniteFlyer: - return CalamityGlobalAI.BuffedGraniteElementalAI(npc, mod); - } - } - break; - default: - break; - } - } - else if (Main.expertMode) - { - if (npc.type == NPCID.FungiSpore || npc.type == NPCID.Spore) - return CalamityGlobalAI.BuffedSporeAI(npc, mod); - } + if (CalamityWorld.death) + { + switch (npc.aiStyle) + { + case 1: + 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()) + { + return SlimeAI.BuffedSlimeAI(npc, mod); + } + else + { + switch (npc.type) + { + case NPCID.BlueSlime: + case NPCID.MotherSlime: + case NPCID.LavaSlime: + case NPCID.DungeonSlime: + case NPCID.CorruptSlime: + case NPCID.IlluminantSlime: + case NPCID.ToxicSludge: + case NPCID.IceSlime: + case NPCID.Crimslime: + case NPCID.SpikedIceSlime: + case NPCID.SpikedJungleSlime: + case NPCID.UmbrellaSlime: + case NPCID.RainbowSlime: + case NPCID.SlimeMasked: + case NPCID.HoppinJack: + case NPCID.SlimeRibbonWhite: + case NPCID.SlimeRibbonYellow: + case NPCID.SlimeRibbonGreen: + case NPCID.SlimeRibbonRed: + case NPCID.SlimeSpiked: + case NPCID.SandSlime: + return SlimeAI.BuffedSlimeAI(npc, mod); + } + } + break; + case 2: + if (npc.type == NPCType() || npc.type == NPCType()) + { + return DemonEyeAI.BuffedDemonEyeAI(npc, mod); + } + else + { + switch (npc.type) + { + case NPCID.DemonEye: + case NPCID.TheHungryII: + case NPCID.WanderingEye: + case NPCID.PigronCorruption: + case NPCID.PigronHallow: + case NPCID.PigronCrimson: + case NPCID.CataractEye: + case NPCID.SleepyEye: + case NPCID.DialatedEye: + case NPCID.GreenEye: + case NPCID.PurpleEye: + case NPCID.DemonEyeOwl: + case NPCID.DemonEyeSpaceship: + return DemonEyeAI.BuffedDemonEyeAI(npc, mod); + } + } + break; + case 3: + if (npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCType()) + { + return CalamityGlobalAI.BuffedFighterAI(npc, mod); + } + else + { + switch (npc.type) + { + case NPCID.Zombie: + case NPCID.ArmedZombie: + case NPCID.ArmedZombieEskimo: + case NPCID.ArmedZombiePincussion: + case NPCID.ArmedZombieSlimed: + case NPCID.ArmedZombieSwamp: + case NPCID.ArmedZombieTwiggy: + case NPCID.ArmedZombieCenx: + case NPCID.Skeleton: + case NPCID.AngryBones: + case NPCID.UndeadMiner: + case NPCID.CorruptBunny: + case NPCID.DoctorBones: + case NPCID.TheGroom: + case NPCID.Crab: + case NPCID.GoblinScout: + case NPCID.ArmoredSkeleton: + case NPCID.Mummy: + case NPCID.DarkMummy: + case NPCID.LightMummy: + case NPCID.Werewolf: + case NPCID.Clown: + case NPCID.SkeletonArcher: + case NPCID.ChaosElemental: + case NPCID.BaldZombie: + case NPCID.PossessedArmor: + case NPCID.ZombieEskimo: + case NPCID.BlackRecluse: + case NPCID.WallCreeper: + case NPCID.UndeadViking: + case NPCID.CorruptPenguin: + case NPCID.FaceMonster: + case NPCID.SnowFlinx: + case NPCID.PincushionZombie: + case NPCID.SlimedZombie: + case NPCID.SwampZombie: + case NPCID.TwiggyZombie: + case NPCID.Nymph: + case NPCID.ArmoredViking: + case NPCID.Lihzahrd: + case NPCID.LihzahrdCrawler: + case NPCID.FemaleZombie: + case NPCID.HeadacheSkeleton: + case NPCID.MisassembledSkeleton: + case NPCID.PantlessSkeleton: + case NPCID.IcyMerman: + case NPCID.PirateDeckhand: + case NPCID.PirateCorsair: + case NPCID.PirateDeadeye: + case NPCID.PirateCrossbower: + case NPCID.PirateCaptain: + case NPCID.CochinealBeetle: + case NPCID.CyanBeetle: + case NPCID.LacBeetle: + case NPCID.SeaSnail: + case NPCID.ZombieRaincoat: + case NPCID.JungleCreeper: + case NPCID.BloodCrawler: + case NPCID.IceGolem: + case NPCID.Eyezor: + case NPCID.ZombieMushroom: + case NPCID.ZombieMushroomHat: + case NPCID.AnomuraFungus: + case NPCID.MushiLadybug: + case NPCID.RustyArmoredBonesAxe: + case NPCID.RustyArmoredBonesFlail: + case NPCID.RustyArmoredBonesSword: + case NPCID.RustyArmoredBonesSwordNoArmor: + case NPCID.BlueArmoredBones: + case NPCID.BlueArmoredBonesMace: + case NPCID.BlueArmoredBonesNoPants: + case NPCID.BlueArmoredBonesSword: + case NPCID.HellArmoredBones: + case NPCID.HellArmoredBonesSpikeShield: + case NPCID.HellArmoredBonesMace: + case NPCID.HellArmoredBonesSword: + case NPCID.BoneLee: + case NPCID.Paladin: + case NPCID.SkeletonSniper: + case NPCID.TacticalSkeleton: + case NPCID.SkeletonCommando: + case NPCID.AngryBonesBig: + case NPCID.AngryBonesBigMuscle: + case NPCID.AngryBonesBigHelmet: + case NPCID.Scarecrow1: + case NPCID.Scarecrow2: + case NPCID.Scarecrow3: + case NPCID.Scarecrow4: + case NPCID.Scarecrow5: + case NPCID.Scarecrow6: + case NPCID.Scarecrow7: + case NPCID.Scarecrow8: + case NPCID.Scarecrow9: + case NPCID.Scarecrow10: + case NPCID.ZombieDoctor: + case NPCID.ZombieSuperman: + case NPCID.ZombiePixie: + case NPCID.SkeletonTopHat: + case NPCID.SkeletonAstonaut: + case NPCID.SkeletonAlien: + case NPCID.Splinterling: + case NPCID.ZombieXmas: + case NPCID.ZombieSweater: + case NPCID.ZombieElf: + case NPCID.ZombieElfBeard: + case NPCID.ZombieElfGirl: + case NPCID.GingerbreadMan: + case NPCID.Yeti: + case NPCID.Nutcracker: + case NPCID.NutcrackerSpinning: + case NPCID.ElfArcher: + case NPCID.Krampus: + case NPCID.CultistArcherBlue: + case NPCID.CultistArcherWhite: + case NPCID.BrainScrambler: + case NPCID.RayGunner: + case NPCID.MartianOfficer: + case NPCID.GrayGrunt: + case NPCID.MartianEngineer: + case NPCID.GigaZapper: + case NPCID.Scutlix: + case NPCID.BoneThrowingSkeleton: + case NPCID.BoneThrowingSkeleton2: + case NPCID.BoneThrowingSkeleton3: + case NPCID.BoneThrowingSkeleton4: + case NPCID.CrimsonBunny: + case NPCID.CrimsonPenguin: + case NPCID.Medusa: + case NPCID.GreekSkeleton: + case NPCID.GraniteGolem: + case NPCID.BloodZombie: + case NPCID.Crawdad: + case NPCID.Crawdad2: + case NPCID.Salamander: + case NPCID.Salamander2: + case NPCID.Salamander3: + case NPCID.Salamander4: + case NPCID.Salamander5: + case NPCID.Salamander6: + case NPCID.Salamander7: + case NPCID.Salamander8: + case NPCID.Salamander9: + case NPCID.WalkingAntlion: + case NPCID.DesertGhoul: + case NPCID.DesertGhoulCorruption: + case NPCID.DesertGhoulCrimson: + case NPCID.DesertGhoulHallow: + case NPCID.DesertLamiaLight: + case NPCID.DesertLamiaDark: + case NPCID.DesertScorpionWalk: + case NPCID.DesertBeast: + case NPCID.StardustSoldier: + case NPCID.StardustSpiderBig: + case NPCID.NebulaSoldier: + case NPCID.VortexRifleman: + case NPCID.VortexSoldier: + case NPCID.VortexLarva: + case NPCID.VortexHornet: + case NPCID.VortexHornetQueen: + case NPCID.SolarDrakomire: + case NPCID.SolarSpearman: + case NPCID.SolarSolenian: + case NPCID.Frankenstein: + case NPCID.SwampThing: + case NPCID.Vampire: + case NPCID.Butcher: + case NPCID.CreatureFromTheDeep: + case NPCID.Fritz: + case NPCID.Nailhead: + case NPCID.Psycho: + case NPCID.ThePossessed: + case NPCID.DrManFly: + case NPCID.GoblinPeon: + case NPCID.GoblinThief: + case NPCID.GoblinWarrior: + case NPCID.GoblinArcher: + case NPCID.GoblinSummoner: + case NPCID.MartianWalker: + case NPCID.DemonTaxCollector: + case NPCID.TheBride: + return CalamityGlobalAI.BuffedFighterAI(npc, mod); + } + } + break; + case 5: + switch (npc.type) + { + case NPCID.ServantofCthulhu: + case NPCID.EaterofSouls: + case NPCID.MeteorHead: + case NPCID.Corruptor: + case NPCID.Crimera: + case NPCID.Moth: + case NPCID.Parrot: + return CalamityGlobalAI.BuffedFlyingAI(npc, mod); + } + break; + case 6: + switch (npc.type) + { + case NPCID.DevourerHead: + case NPCID.DevourerBody: + case NPCID.DevourerTail: + case NPCID.GiantWormHead: + case NPCID.GiantWormBody: + case NPCID.GiantWormTail: + case NPCID.BoneSerpentHead: + case NPCID.BoneSerpentBody: + case NPCID.BoneSerpentTail: + case NPCID.WyvernHead: + case NPCID.WyvernLegs: + case NPCID.WyvernBody: + case NPCID.WyvernBody2: + case NPCID.WyvernBody3: + case NPCID.WyvernTail: + case NPCID.DiggerHead: + case NPCID.DiggerBody: + case NPCID.DiggerTail: + case NPCID.SeekerHead: + case NPCID.SeekerBody: + case NPCID.SeekerTail: + case NPCID.LeechHead: + case NPCID.LeechBody: + case NPCID.LeechTail: + case NPCID.TombCrawlerHead: + case NPCID.TombCrawlerBody: + case NPCID.TombCrawlerTail: + case NPCID.DuneSplicerHead: + case NPCID.DuneSplicerBody: + case NPCID.DuneSplicerTail: + case NPCID.StardustWormHead: + case NPCID.SolarCrawltipedeHead: + case NPCID.SolarCrawltipedeBody: + case NPCID.SolarCrawltipedeTail: + return CalamityGlobalAI.BuffedWormAI(npc, mod); + } + break; + case 8: + switch (npc.type) + { + case NPCID.FireImp: + case NPCID.DarkCaster: + case NPCID.Tim: + case NPCID.RuneWizard: + case NPCID.RaggedCaster: + case NPCID.RaggedCasterOpenCoat: + case NPCID.Necromancer: + case NPCID.NecromancerArmored: + case NPCID.DiabolistRed: + case NPCID.DiabolistWhite: + case NPCID.DesertDjinn: + case NPCID.GoblinSorcerer: + return CalamityGlobalAI.BuffedCasterAI(npc, mod); + } + break; + case 13: + switch (npc.type) + { + case NPCID.ManEater: + case NPCID.Snatcher: + case NPCID.Clinger: + case NPCID.AngryTrapper: + case NPCID.FungiBulb: + case NPCID.GiantFungiBulb: + return CalamityGlobalAI.BuffedPlantAI(npc, mod); + } + break; + case 14: + if (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType()) + { + return CalamityGlobalAI.BuffedBatAI(npc, mod); + } + else + { + switch (npc.type) + { + case NPCID.Harpy: + case NPCID.CaveBat: + case NPCID.JungleBat: + case NPCID.Hellbat: + case NPCID.Demon: + case NPCID.VoodooDemon: + case NPCID.GiantBat: + case NPCID.Slimer: + case NPCID.IlluminantBat: + case NPCID.IceBat: + case NPCID.Lavabat: + case NPCID.GiantFlyingFox: + case NPCID.RedDevil: + case NPCID.FlyingSnake: + case NPCID.VampireBat: + return CalamityGlobalAI.BuffedBatAI(npc, mod); + } + } + break; + case 16: + switch (npc.type) + { + case NPCID.CorruptGoldfish: + case NPCID.Piranha: + case NPCID.Shark: + case NPCID.AnglerFish: + case NPCID.Arapaima: + case NPCID.BloodFeeder: + case NPCID.CrimsonGoldfish: + return CalamityGlobalAI.BuffedSwimmingAI(npc, mod); + } + break; + case 18: + switch (npc.type) + { + case NPCID.BlueJellyfish: + case NPCID.PinkJellyfish: + case NPCID.GreenJellyfish: + case NPCID.Squid: + case NPCID.BloodJelly: + case NPCID.FungoFish: + return CalamityGlobalAI.BuffedJellyfishAI(npc, mod); + } + break; + case 19: + switch (npc.type) + { + case NPCID.Antlion: + return CalamityGlobalAI.BuffedAntlionAI(npc, mod); + } + break; + case 20: + switch (npc.type) + { + case NPCID.SpikeBall: + return CalamityGlobalAI.BuffedSpikeBallAI(npc, mod); + } + break; + case 21: + switch (npc.type) + { + case NPCID.BlazingWheel: + return CalamityGlobalAI.BuffedBlazingWheelAI(npc, mod); + } + break; + case 22: + switch (npc.type) + { + case NPCID.Pixie: + case NPCID.Wraith: + case NPCID.Gastropod: + case NPCID.IceElemental: + case NPCID.FloatyGross: + case NPCID.IchorSticker: + case NPCID.Ghost: + case NPCID.Poltergeist: + case NPCID.Drippler: + case NPCID.Reaper: + return CalamityGlobalAI.BuffedHoveringAI(npc, mod); + } + break; + case 23: + switch (npc.type) + { + case NPCID.CursedHammer: + case NPCID.EnchantedSword: + case NPCID.CrimsonAxe: + return CalamityGlobalAI.BuffedFlyingWeaponAI(npc, mod); + } + break; + case 25: + switch (npc.type) + { + case NPCID.Mimic: + case NPCID.PresentMimic: + return CalamityGlobalAI.BuffedMimicAI(npc, mod); + } + break; + case 26: + if (npc.type == NPCType()) + { + return CalamityGlobalAI.BuffedUnicornAI(npc, mod); + } + else + { + switch (npc.type) + { + case NPCID.Unicorn: + case NPCID.Wolf: + case NPCID.HeadlessHorseman: + case NPCID.Hellhound: + case NPCID.StardustSpiderSmall: + case NPCID.NebulaBeast: + case NPCID.Tumbleweed: + return CalamityGlobalAI.BuffedUnicornAI(npc, mod); + } + } + break; + case 39: + if (npc.type == NPCType() || npc.type == NPCType()) + { + return CalamityGlobalAI.BuffedTortoiseAI(npc, mod); + } + else + { + switch (npc.type) + { + case NPCID.GiantTortoise: + case NPCID.IceTortoise: + case NPCID.GiantShelly: + case NPCID.GiantShelly2: + case NPCID.SolarSroller: + return CalamityGlobalAI.BuffedTortoiseAI(npc, mod); + } + } + break; + case 40: + switch (npc.type) + { + case NPCID.BlackRecluseWall: + case NPCID.WallCreeperWall: + case NPCID.JungleCreeperWall: + case NPCID.BloodCrawlerWall: + case NPCID.DesertScorpionWall: + return CalamityGlobalAI.BuffedSpiderAI(npc, mod); + } + break; + case 41: + if (npc.type == NPCType()) + { + return CalamityGlobalAI.BuffedHerplingAI(npc, mod); + } + else + { + switch (npc.type) + { + case NPCID.Herpling: + case NPCID.Derpling: + return CalamityGlobalAI.BuffedHerplingAI(npc, mod); + } + } + break; + case 44: + switch (npc.type) + { + case NPCID.FlyingFish: + case NPCID.FlyingAntlion: + return CalamityGlobalAI.BuffedFlyingFishAI(npc, mod); + } + break; + case 49: + switch (npc.type) + { + case NPCID.AngryNimbus: + return CalamityGlobalAI.BuffedAngryNimbusAI(npc, mod); + } + break; + case 50: + switch (npc.type) + { + case NPCID.FungiSpore: + case NPCID.Spore: + return CalamityGlobalAI.BuffedSporeAI(npc, mod); + } + break; + case 73: + switch (npc.type) + { + case NPCID.MartianTurret: + return CalamityGlobalAI.BuffedTeslaTurretAI(npc, mod); + } + break; + case 74: + switch (npc.type) + { + case NPCID.MartianDrone: + case NPCID.SolarCorite: + return CalamityGlobalAI.BuffedCoriteAI(npc, mod); + } + break; + case 80: + switch (npc.type) + { + case NPCID.MartianProbe: + return CalamityGlobalAI.BuffedMartianProbeAI(npc, mod); + } + break; + case 89: + switch (npc.type) + { + case NPCID.MothronEgg: + return CalamityGlobalAI.BuffedMothronEggAI(npc, mod); + } + break; + case 91: + if (npc.type == NPCType()) + { + return CalamityGlobalAI.BuffedGraniteElementalAI(npc, mod); + } + else + { + switch (npc.type) + { + case NPCID.GraniteFlyer: + return CalamityGlobalAI.BuffedGraniteElementalAI(npc, mod); + } + } + break; + default: + break; + } + } + else if (Main.expertMode) + { + if (npc.type == NPCID.FungiSpore || npc.type == NPCID.Spore) + return CalamityGlobalAI.BuffedSporeAI(npc, mod); + } if (npc.type == NPCID.DD2LanePortal) { @@ -3378,343 +3378,343 @@ namespace CalamityMod.NPCs #region Boss Rush Force Despawn Other NPCs private void BossRushForceDespawnOtherNPCs(NPC npc, Mod mod) { - if (BossRushEvent.BossRushStage >= BossRushEvent.Bosses.Count) - return; + if (BossRushEvent.BossRushStage >= BossRushEvent.Bosses.Count) + return; - if (!BossRushEvent.Bosses[BossRushEvent.BossRushStage].HostileNPCsToNotDelete.Contains(npc.type)) - { - npc.active = false; - npc.netUpdate = true; - } - } - #endregion - - #region Pillar Event Progression Edit - private void PillarEventProgressionEdit(NPC npc) - { - // Make pillars a bit more fun by forcing more difficult enemies based on progression. - int solarTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerSolar / 25D); - switch (solarTowerShieldStrength) - { - case 4: - // Possible spawns: Drakanian, Drakomire, Drakomire Rider, Sroller - switch (npc.type) - { - case NPCID.SolarCrawltipedeHead: - case NPCID.SolarCrawltipedeBody: - case NPCID.SolarCrawltipedeTail: - case NPCID.SolarSolenian: - case NPCID.SolarCorite: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 3: - // Possible spawns: Drakanian, Drakomire Rider, Sroller - switch (npc.type) - { - case NPCID.SolarCrawltipedeHead: - case NPCID.SolarCrawltipedeBody: - case NPCID.SolarCrawltipedeTail: - case NPCID.SolarDrakomire: - case NPCID.SolarSolenian: - case NPCID.SolarCorite: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 2: - // Possible spawns: Drakanian, Selenian, Sroller - switch (npc.type) - { - case NPCID.SolarDrakomire: - case NPCID.SolarCrawltipedeHead: - case NPCID.SolarCrawltipedeBody: - case NPCID.SolarCrawltipedeTail: - case NPCID.SolarCorite: - case NPCID.SolarDrakomireRider: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 1: - // Possible spawns: Corite, Selenian, Sroller, Crawltipede - switch (npc.type) - { - case NPCID.SolarDrakomire: - case NPCID.SolarSpearman: - case NPCID.SolarDrakomireRider: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 0: - // Possible spawns: Corite, Crawltipede, Selenian - switch (npc.type) - { - case NPCID.SolarDrakomire: - case NPCID.SolarSpearman: - case NPCID.SolarDrakomireRider: - case NPCID.SolarSroller: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - } - - int vortexTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerVortex / 25D); - switch (vortexTowerShieldStrength) - { - case 4: - // Possible spawns: Alien Larva, Alien Hornet, Alien Queen - switch (npc.type) - { - case NPCID.VortexSoldier: - case NPCID.VortexRifleman: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 3: - // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Vortexian - if (npc.type == NPCID.VortexRifleman) - { - npc.active = false; - npc.netUpdate = true; - } - break; - case 2: - // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Storm Diver - if (npc.type == NPCID.VortexSoldier) - { - npc.active = false; - npc.netUpdate = true; - } - break; - case 1: - case 0: - // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Vortexian, Storm Diver - break; - } - - int nebulaTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerNebula / 25D); - switch (nebulaTowerShieldStrength) - { - case 4: - // Possible spawns: Brain Suckler - switch (npc.type) - { - case NPCID.NebulaBeast: - case NPCID.NebulaBrain: - case NPCID.NebulaSoldier: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 3: - // Possible spawns: Brain Suckler, Predictor - switch (npc.type) - { - case NPCID.NebulaBeast: - case NPCID.NebulaBrain: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 2: - // Possible spawns: Brain Suckler, Predictor, Evolution Beast - if (npc.type == NPCID.NebulaBrain) - { - npc.active = false; - npc.netUpdate = true; - } - break; - case 1: - case 0: - // Possible spawns: Predictor, Evolution Beast, Nebula Floater - if (npc.type == NPCID.NebulaHeadcrab) - { - npc.active = false; - npc.netUpdate = true; - } - break; - } - - int stardustTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerStardust / 25D); - switch (stardustTowerShieldStrength) - { - case 4: - // Possible spawns: Milkyway Weaver, Star Cell - switch (npc.type) - { - case NPCID.StardustSpiderBig: - case NPCID.StardustSoldier: - case NPCID.StardustJellyfishBig: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 3: - // Possible spawns: Milkyway Weaver, Stargazer, Twinkle Popper - switch (npc.type) - { - case NPCID.StardustCellBig: - case NPCID.StardustJellyfishBig: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 2: - // Possible spawns: Stargazer, Twinkle Popper, Flow Invader - switch (npc.type) - { - case NPCID.StardustCellBig: - case NPCID.StardustWormHead: - case NPCID.StardustWormBody: - case NPCID.StardustWormTail: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 1: - case 0: - // Possible spawns: Twinkle Popper, Flow Invader - switch (npc.type) - { - case NPCID.StardustCellBig: - case NPCID.StardustWormHead: - case NPCID.StardustWormBody: - case NPCID.StardustWormTail: - case NPCID.StardustSoldier: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - } - } - #endregion - - #region AI - public override void AI(NPC npc) - { - if (CalamityWorld.revenge && npc.type == NPCID.DungeonGuardian) - SkeletronAI.RevengeanceDungeonGuardianAI(npc); + if (!BossRushEvent.Bosses[BossRushEvent.BossRushStage].HostileNPCsToNotDelete.Contains(npc.type)) + { + npc.active = false; + npc.netUpdate = true; + } } - #endregion + #endregion - #region Post AI - public override void PostAI(NPC npc) - { - // Debuff decrements - if (debuffResistanceTimer > 0) - debuffResistanceTimer--; - if (knockbackResistanceTimer > 0) - knockbackResistanceTimer--; + #region Pillar Event Progression Edit + private void PillarEventProgressionEdit(NPC npc) + { + // Make pillars a bit more fun by forcing more difficult enemies based on progression. + int solarTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerSolar / 25D); + switch (solarTowerShieldStrength) + { + case 4: + // Possible spawns: Drakanian, Drakomire, Drakomire Rider, Sroller + switch (npc.type) + { + case NPCID.SolarCrawltipedeHead: + case NPCID.SolarCrawltipedeBody: + case NPCID.SolarCrawltipedeTail: + case NPCID.SolarSolenian: + case NPCID.SolarCorite: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + case 3: + // Possible spawns: Drakanian, Drakomire Rider, Sroller + switch (npc.type) + { + case NPCID.SolarCrawltipedeHead: + case NPCID.SolarCrawltipedeBody: + case NPCID.SolarCrawltipedeTail: + case NPCID.SolarDrakomire: + case NPCID.SolarSolenian: + case NPCID.SolarCorite: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + case 2: + // Possible spawns: Drakanian, Selenian, Sroller + switch (npc.type) + { + case NPCID.SolarDrakomire: + case NPCID.SolarCrawltipedeHead: + case NPCID.SolarCrawltipedeBody: + case NPCID.SolarCrawltipedeTail: + case NPCID.SolarCorite: + case NPCID.SolarDrakomireRider: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + case 1: + // Possible spawns: Corite, Selenian, Sroller, Crawltipede + switch (npc.type) + { + case NPCID.SolarDrakomire: + case NPCID.SolarSpearman: + case NPCID.SolarDrakomireRider: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + case 0: + // Possible spawns: Corite, Crawltipede, Selenian + switch (npc.type) + { + case NPCID.SolarDrakomire: + case NPCID.SolarSpearman: + case NPCID.SolarDrakomireRider: + case NPCID.SolarSroller: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + } - if (timeSlow > 0) - timeSlow--; - if (tesla > 0) - tesla--; - if (gState > 0) - gState--; - if (tSad > 0) - tSad--; - if (eFreeze > 0) - eFreeze--; - if (eutrophication > 0) - eutrophication--; - if (webbed > 0) - webbed--; - if (slowed > 0) - slowed--; - if (kamiFlu > 0) - kamiFlu--; - if (vaporfied > 0) - vaporfied--; + int vortexTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerVortex / 25D); + switch (vortexTowerShieldStrength) + { + case 4: + // Possible spawns: Alien Larva, Alien Hornet, Alien Queen + switch (npc.type) + { + case NPCID.VortexSoldier: + case NPCID.VortexRifleman: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + case 3: + // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Vortexian + if (npc.type == NPCID.VortexRifleman) + { + npc.active = false; + npc.netUpdate = true; + } + break; + case 2: + // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Storm Diver + if (npc.type == NPCID.VortexSoldier) + { + npc.active = false; + npc.netUpdate = true; + } + break; + case 1: + case 0: + // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Vortexian, Storm Diver + break; + } - if (electrified > 0) - electrified--; - if (yellowCandle > 0) - yellowCandle--; - if (pearlAura > 0) - pearlAura--; - if (wCleave > 0) - wCleave--; - if (bBlood > 0) - bBlood--; - if (dFlames > 0) - dFlames--; - if (vulnerabilityHex > 0) - vulnerabilityHex--; - if (marked > 0) - marked--; - if (irradiated > 0) - irradiated--; - if (bFlames > 0) - bFlames--; - if (hFlames > 0) - hFlames--; - if (pFlames > 0) - pFlames--; - if (aFlames > 0) - aFlames--; - // Soma Prime's Shred stacks have a unique falloff mechanic in the debuff's own file. - if (aCrunch > 0) - aCrunch--; - if (cDepth > 0) - cDepth--; - if (gsInferno > 0) - gsInferno--; - if (astralInfection > 0) - astralInfection--; - if (wDeath > 0) - wDeath--; - if (nightwither > 0) - nightwither--; - if (enraged > 0) - enraged--; - if (shellfishVore > 0) - shellfishVore--; - if (clamDebuff > 0) - clamDebuff--; - if (sulphurPoison > 0) - sulphurPoison--; + int nebulaTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerNebula / 25D); + switch (nebulaTowerShieldStrength) + { + case 4: + // Possible spawns: Brain Suckler + switch (npc.type) + { + case NPCID.NebulaBeast: + case NPCID.NebulaBrain: + case NPCID.NebulaSoldier: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + case 3: + // Possible spawns: Brain Suckler, Predictor + switch (npc.type) + { + case NPCID.NebulaBeast: + case NPCID.NebulaBrain: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + case 2: + // Possible spawns: Brain Suckler, Predictor, Evolution Beast + if (npc.type == NPCID.NebulaBrain) + { + npc.active = false; + npc.netUpdate = true; + } + break; + case 1: + case 0: + // Possible spawns: Predictor, Evolution Beast, Nebula Floater + if (npc.type == NPCID.NebulaHeadcrab) + { + npc.active = false; + npc.netUpdate = true; + } + break; + } + + int stardustTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerStardust / 25D); + switch (stardustTowerShieldStrength) + { + case 4: + // Possible spawns: Milkyway Weaver, Star Cell + switch (npc.type) + { + case NPCID.StardustSpiderBig: + case NPCID.StardustSoldier: + case NPCID.StardustJellyfishBig: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + case 3: + // Possible spawns: Milkyway Weaver, Stargazer, Twinkle Popper + switch (npc.type) + { + case NPCID.StardustCellBig: + case NPCID.StardustJellyfishBig: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + case 2: + // Possible spawns: Stargazer, Twinkle Popper, Flow Invader + switch (npc.type) + { + case NPCID.StardustCellBig: + case NPCID.StardustWormHead: + case NPCID.StardustWormBody: + case NPCID.StardustWormTail: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + case 1: + case 0: + // Possible spawns: Twinkle Popper, Flow Invader + switch (npc.type) + { + case NPCID.StardustCellBig: + case NPCID.StardustWormHead: + case NPCID.StardustWormBody: + case NPCID.StardustWormTail: + case NPCID.StardustSoldier: + npc.active = false; + npc.netUpdate = true; + break; + default: + break; + } + break; + } + } + #endregion + + #region AI + public override void AI(NPC npc) + { + if (CalamityWorld.revenge && npc.type == NPCID.DungeonGuardian) + SkeletronAI.RevengeanceDungeonGuardianAI(npc); + } + #endregion + + #region Post AI + public override void PostAI(NPC npc) + { + // Debuff decrements + if (debuffResistanceTimer > 0) + debuffResistanceTimer--; + if (knockbackResistanceTimer > 0) + knockbackResistanceTimer--; + + if (timeSlow > 0) + timeSlow--; + if (tesla > 0) + tesla--; + if (gState > 0) + gState--; + if (tSad > 0) + tSad--; + if (eFreeze > 0) + eFreeze--; + if (eutrophication > 0) + eutrophication--; + if (webbed > 0) + webbed--; + if (slowed > 0) + slowed--; + if (kamiFlu > 0) + kamiFlu--; + if (vaporfied > 0) + vaporfied--; + + if (electrified > 0) + electrified--; + if (yellowCandle > 0) + yellowCandle--; + if (pearlAura > 0) + pearlAura--; + if (wCleave > 0) + wCleave--; + if (bBlood > 0) + bBlood--; + if (dFlames > 0) + dFlames--; + if (vulnerabilityHex > 0) + vulnerabilityHex--; + if (marked > 0) + marked--; + if (irradiated > 0) + irradiated--; + if (bFlames > 0) + bFlames--; + if (hFlames > 0) + hFlames--; + if (pFlames > 0) + pFlames--; + if (aFlames > 0) + aFlames--; + // Soma Prime's Shred stacks have a unique falloff mechanic in the debuff's own file. + if (aCrunch > 0) + aCrunch--; + if (cDepth > 0) + cDepth--; + if (gsInferno > 0) + gsInferno--; + if (astralInfection > 0) + astralInfection--; + if (wDeath > 0) + wDeath--; + if (nightwither > 0) + nightwither--; + if (enraged > 0) + enraged--; + if (shellfishVore > 0) + shellfishVore--; + if (clamDebuff > 0) + clamDebuff--; + if (sulphurPoison > 0) + sulphurPoison--; if (sagePoisonTime > 0) sagePoisonTime--; if (kamiFlu > 0) @@ -3726,75 +3726,75 @@ namespace CalamityMod.NPCs if (GaussFluxTimer > 0) GaussFluxTimer--; if (ladHearts > 0) - ladHearts--; + ladHearts--; if (vulnerabilityHex > 0) vulnerabilityHex--; if (banishingFire > 0) - banishingFire--; + banishingFire--; if (wither > 0) - wither--; - if (RancorBurnTime > 0) - RancorBurnTime--; + wither--; + if (RancorBurnTime > 0) + RancorBurnTime--; - // Queen Bee is completely immune to having her movement impaired if not in a high difficulty mode. - if (npc.type == NPCID.QueenBee && !CalamityWorld.revenge && !BossRushEvent.BossRushActive) - return; + // Queen Bee is completely immune to having her movement impaired if not in a high difficulty mode. + if (npc.type == NPCID.QueenBee && !CalamityWorld.revenge && !BossRushEvent.BossRushActive) + return; - if (debuffResistanceTimer <= 0 || (debuffResistanceTimer > slowingDebuffResistanceMin)) - { - if (eFreeze <= 0 && gState <= 0 && tSad <= 0) - { - if (eutrophication > 0) - { - float velocityMult = 0.95f; - if (VulnerableToWater.HasValue) - { - if (VulnerableToWater.Value) - velocityMult = 0.6f; - else - velocityMult = 0.99f; - } - npc.velocity *= velocityMult; - } - else if (timeSlow > 0 || webbed > 0) - { - npc.velocity *= 0.85f; - } - else if (slowed > 0 || tesla > 0 || vaporfied > 0) - { - float velocityMult = 0.95f; - if (tesla > 0) - { - if (VulnerableToElectricity.HasValue) - { - if (VulnerableToElectricity.Value) - velocityMult = 0.6f; - else - velocityMult = 0.99f; - } - } - npc.velocity *= velocityMult; - } - else if (vulnerabilityHex > 0) - { - npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-Calamity.MaxNPCSpeed), new Vector2(Calamity.MaxNPCSpeed, 10f)); - } - else if (kamiFlu > 420) - { - npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-KamiDebuff.MaxNPCSpeed), new Vector2(KamiDebuff.MaxNPCSpeed)); - } - } - } + if (debuffResistanceTimer <= 0 || (debuffResistanceTimer > slowingDebuffResistanceMin)) + { + if (eFreeze <= 0 && gState <= 0 && tSad <= 0) + { + if (eutrophication > 0) + { + float velocityMult = 0.95f; + if (VulnerableToWater.HasValue) + { + if (VulnerableToWater.Value) + velocityMult = 0.6f; + else + velocityMult = 0.99f; + } + npc.velocity *= velocityMult; + } + else if (timeSlow > 0 || webbed > 0) + { + npc.velocity *= 0.85f; + } + else if (slowed > 0 || tesla > 0 || vaporfied > 0) + { + float velocityMult = 0.95f; + if (tesla > 0) + { + if (VulnerableToElectricity.HasValue) + { + if (VulnerableToElectricity.Value) + velocityMult = 0.6f; + else + velocityMult = 0.99f; + } + } + npc.velocity *= velocityMult; + } + else if (vulnerabilityHex > 0) + { + npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-Calamity.MaxNPCSpeed), new Vector2(Calamity.MaxNPCSpeed, 10f)); + } + else if (kamiFlu > 420) + { + npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-KamiDebuff.MaxNPCSpeed), new Vector2(KamiDebuff.MaxNPCSpeed)); + } + } + } if (!CalamityPlayer.areThereAnyDamnBosses && !CalamityLists.enemyImmunityList.Contains(npc.type)) - { - if (pearlAura > 0) - npc.velocity *= 0.9f; - } + { + if (pearlAura > 0) + npc.velocity *= 0.9f; + } - if (npc.type == NPCID.DD2EterniaCrystal) - CalamityGlobalAI.DD2CrystalExtraAI(npc); - } + if (npc.type == NPCID.DD2EterniaCrystal) + CalamityGlobalAI.DD2CrystalExtraAI(npc); + } #endregion #region On Hit Player @@ -3829,242 +3829,242 @@ namespace CalamityMod.NPCs break; } - if (Main.hardMode) - { - switch (npc.type) - { - case NPCID.BigBoned: - case NPCID.ShortBones: - case NPCID.AngryBones: - case NPCID.AngryBonesBig: - case NPCID.AngryBonesBigMuscle: - case NPCID.AngryBonesBigHelmet: - target.AddBuff(BuffType(), 60); - break; - - default: - break; - } - - if (NPC.downedPlantBoss) - { - switch (npc.type) - { - case NPCID.RustyArmoredBonesAxe: - case NPCID.RustyArmoredBonesFlail: - case NPCID.RustyArmoredBonesSword: - case NPCID.RustyArmoredBonesSwordNoArmor: - case NPCID.BlueArmoredBones: - case NPCID.BlueArmoredBonesMace: - case NPCID.BlueArmoredBonesNoPants: - case NPCID.BlueArmoredBonesSword: - case NPCID.HellArmoredBones: - case NPCID.HellArmoredBonesSpikeShield: - case NPCID.HellArmoredBonesMace: - case NPCID.HellArmoredBonesSword: - target.AddBuff(BuffType(), 120); - break; - - default: - break; - } - } - } - - if (Main.expertMode) - { - switch (npc.type) - { - case NPCID.Hellbat: - target.AddBuff(BuffID.OnFire, 120); - break; - - default: - break; - } - } - } - #endregion - - #region Modify Hit - public override void ModifyHitByItem(NPC npc, Player player, Item item, ref int damage, ref float knockback, ref bool crit) - { - CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.camper && !player.StandingStill()) - damage = (int)(damage * 0.1); - - // True melee resists - if (CalamityLists.DesertScourgeIDs.Contains(npc.type) || CalamityLists.EaterofWorldsIDs.Contains(npc.type) || npc.type == NPCID.Creeper || - CalamityLists.PerforatorIDs.Contains(npc.type) || CalamityLists.AquaticScourgeIDs.Contains(npc.type) || CalamityLists.DestroyerIDs.Contains(npc.type) || - CalamityLists.AstrumDeusIDs.Contains(npc.type) || CalamityLists.StormWeaverIDs.Contains(npc.type) || CalamityLists.ThanatosIDs.Contains(npc.type) || - npc.type == NPCType() || npc.type == NPCType() || CalamityLists.AresIDs.Contains(npc.type) || npc.type == NPCType()) - { - double damageMult = CalamityLists.ThanatosIDs.Contains(npc.type) ? 0.35 : 0.5; - if (item.melee && item.type != ItemType() && item.type != ItemType()) - damage = (int)(damage * damageMult); - } - } - #endregion - - #region Modify Hit By Projectile - public override void ModifyHitByProjectile(NPC npc, Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - - MakeTownNPCsTakeMoreDamage(npc, projectile, mod, ref damage); - - // Supercrits - var cgp = projectile.Calamity(); - if (cgp.canSupercrit) - { - int critOver100 = 0; - if (projectile.melee) - critOver100 = player.meleeCrit - 100; - else if (projectile.ranged) - critOver100 = player.rangedCrit - 100; - else if (projectile.magic) - critOver100 = player.magicCrit - 100; - else if (projectile.thrown) // Also covers rogue - critOver100 = player.thrownCrit - 100; - - // Supercrits can "supercrit" over and over for each extra 100% critical strike chance. - // For example if you have 716% critical strike chance, you are guaranteed +700% damage and then have a 16% chance for +800% damage instead. - if (critOver100 > 0) - { - int supercritLayers = critOver100 / 100; - int lastLayerCritChance = critOver100 - supercritLayers; - // Roll for the remaining crit chance - if (Main.rand.Next(100) <= lastLayerCritChance) - ++supercritLayers; - - // Apply supercrit damage. This projectile is already guaranteed to be a crit, which will double its damage at the end. - // As such, only 50% damage is added per supercrit layer here. - damage = (int)(damage * (1f + 0.5f * supercritLayers)); - } - } - - int bullseyeType = ProjectileType(); - Projectile bullseye = null; - for (int i = 0; i < Main.maxProjectiles; i++) + if (Main.hardMode) { - if (Main.projectile[i].type != bullseyeType || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI) - continue; + switch (npc.type) + { + case NPCID.BigBoned: + case NPCID.ShortBones: + case NPCID.AngryBones: + case NPCID.AngryBonesBig: + case NPCID.AngryBonesBigMuscle: + case NPCID.AngryBonesBigHelmet: + target.AddBuff(BuffType(), 60); + break; - // Only choose a bullseye if it is attached to the NPC that is being hit. - if (npc.whoAmI == (int)Main.projectile[i].ai[0]) - { - bullseye = Main.projectile[i]; - break; - } - } + default: + break; + } - // Don't allow large hitbox projectiles or explosions to "snipe" enemies. - // Hitbox criteria were changed to allow long one dimensional projectiles so that Condemnation would work. - bool hitBullseye = false; - bool acceptableVelocity = projectile.velocity != Vector2.Zero; - bool acceptableHitbox = (projectile.width < 36) || (projectile.height < 36); - if (bullseye != null && projectile.ranged && acceptableVelocity && acceptableHitbox) - { - if (bullseye != null) - { - // Bullseyes are visually different on bosses and thus have larger hitboxes. - float bullseyeRadius = npc.IsABoss() ? DaawnlightSpiritOrigin.BossBullseyeRadius : DaawnlightSpiritOrigin.RegularEnemyBullseyeRadius; + if (NPC.downedPlantBoss) + { + switch (npc.type) + { + case NPCID.RustyArmoredBonesAxe: + case NPCID.RustyArmoredBonesFlail: + case NPCID.RustyArmoredBonesSword: + case NPCID.RustyArmoredBonesSwordNoArmor: + case NPCID.BlueArmoredBones: + case NPCID.BlueArmoredBonesMace: + case NPCID.BlueArmoredBonesNoPants: + case NPCID.BlueArmoredBonesSword: + case NPCID.HellArmoredBones: + case NPCID.HellArmoredBonesSpikeShield: + case NPCID.HellArmoredBonesMace: + case NPCID.HellArmoredBonesSword: + target.AddBuff(BuffType(), 120); + break; - // Do some geometry + trig to determine if the projectile WOULD hit the bullseye, even if it's about to be deleted on-hit. - // This is the equivalent of drawing a laser sight from the projectile along its velocity vector and seeing if it crosses the bullseye's hitbox. - // To do this more reliably, we back the projectile up quite a distance. - Vector2 normVelocity = projectile.velocity.SafeNormalize(Vector2.UnitY); - Vector2 backedUpPosition = projectile.Center - 160f * normVelocity; - Vector2 directionToBullseyeCenter = (bullseye.Center - backedUpPosition).SafeNormalize(Vector2.UnitY); - Vector2 perp = directionToBullseyeCenter.RotatedBy(MathHelper.PiOver2); - // Double the radius is given so that the cosine break-even point is right at the edge of the hitbox. - Vector2 comparisonPointOne = bullseye.Center + perp * 2f * bullseyeRadius; - Vector2 comparisonPointTwo = bullseye.Center - perp * 2f * bullseyeRadius; - Vector2 dirToPointOne = (comparisonPointOne - backedUpPosition).SafeNormalize(-Vector2.UnitX); - Vector2 dirToPointTwo = (comparisonPointTwo - backedUpPosition).SafeNormalize(Vector2.UnitX); + default: + break; + } + } + } - // Law of cosines: (A dot B) = |A| * |B| * cos(theta) - // where theta is the angle between the two vectors A and B. - // cos(theta) approaches one as the angle approaches zero, so an angle is smaller if the cos is bigger. - // If the angle to the bullseye's center is smaller than the angle to both the comparison points, it's a hit. - float dotCenter = Vector2.Dot(normVelocity, directionToBullseyeCenter); - float dotOne = Vector2.Dot(normVelocity, dirToPointOne); - float dotTwo = Vector2.Dot(normVelocity, dirToPointTwo); - bool willStrikeBullseye = dotCenter > dotOne && dotCenter > dotTwo; + if (Main.expertMode) + { + switch (npc.type) + { + case NPCID.Hellbat: + target.AddBuff(BuffID.OnFire, 120); + break; - // If a bullseye is triggered, set it as hit. - if (willStrikeBullseye && bullseye.ai[1] == 0f) - { - crit = true; - hitBullseye = true; - bullseye.ai[1] = 1f; // Make the bullseye disappear immediately. - bullseye.netUpdate = true; - } - } + default: + break; + } + } + } + #endregion - // TODO -- Use the 1.4 spawn context system for this. - // This suffers from the same issues as current crit logic in vanilla, but I have no idea how to do this better without said system. - if (modPlayer.spiritOrigin && crit) - { - // Crits have their damage doubled after ModifyHitNPC, in the StrikeNPC function. - // Here, damage is divded by 2 to compensate for that. - // This means that the bonus provided by Daawnlight Spirit Origin can be computed as a complete replacement to regular crits. - float mult = DaawnlightSpiritOrigin.GetDamageMultiplier(player, modPlayer, hitBullseye) / 2f; - damage = (int)(damage * mult); - } - } + #region Modify Hit + public override void ModifyHitByItem(NPC npc, Player player, Item item, ref int damage, ref float knockback, ref bool crit) + { + CalamityPlayer modPlayer = player.Calamity(); + if (modPlayer.camper && !player.StandingStill()) + damage = (int)(damage * 0.1); - if (!projectile.npcProj && !projectile.trap) - { - if (projectile.ranged && modPlayer.plagueReaper && pFlames > 0) - damage = (int)(damage * 1.1); - } + // True melee resists + if (CalamityLists.DesertScourgeIDs.Contains(npc.type) || CalamityLists.EaterofWorldsIDs.Contains(npc.type) || npc.type == NPCID.Creeper || + CalamityLists.PerforatorIDs.Contains(npc.type) || CalamityLists.AquaticScourgeIDs.Contains(npc.type) || CalamityLists.DestroyerIDs.Contains(npc.type) || + CalamityLists.AstrumDeusIDs.Contains(npc.type) || CalamityLists.StormWeaverIDs.Contains(npc.type) || CalamityLists.ThanatosIDs.Contains(npc.type) || + npc.type == NPCType() || npc.type == NPCType() || CalamityLists.AresIDs.Contains(npc.type) || npc.type == NPCType()) + { + double damageMult = CalamityLists.ThanatosIDs.Contains(npc.type) ? 0.35 : 0.5; + if (item.melee && item.type != ItemType() && item.type != ItemType()) + damage = (int)(damage * damageMult); + } + } + #endregion - // Any weapons that shoot projectiles from anywhere other than the player's center aren't affected by point-blank shot damage boost. - if (!Main.player[projectile.owner].ActiveItem().IsAir && Main.player[projectile.owner].ActiveItem().Calamity().canFirePointBlankShots && projectile.ranged) - { - if (projectile.Calamity().pointBlankShotDuration > 0) - { - projectile.Calamity().pointBlankShotDuration = 0; - damage = (int)(damage * 1.5); - } - } + #region Modify Hit By Projectile + public override void ModifyHitByProjectile(NPC npc, Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); - // Apply balancing resists/vulnerabilities. - BalancingChangesManager.ApplyFromProjectile(npc, ref damage, projectile); + MakeTownNPCsTakeMoreDamage(npc, projectile, mod, ref damage); - if (CalamityLists.pierceResistList.Contains(npc.type)) - PierceResistGlobal(projectile, npc, ref damage); - - if (modPlayer.camper && !player.StandingStill()) - damage = (int)(damage * 0.1); - } + // Supercrits + var cgp = projectile.Calamity(); + if (cgp.canSupercrit) + { + int critOver100 = 0; + if (projectile.melee) + critOver100 = player.meleeCrit - 100; + else if (projectile.ranged) + critOver100 = player.rangedCrit - 100; + else if (projectile.magic) + critOver100 = player.magicCrit - 100; + else if (projectile.thrown) // Also covers rogue + critOver100 = player.thrownCrit - 100; - private void PierceResistGlobal(Projectile projectile, NPC npc, ref int damage) - { - if (CalamityLists.GrenadeResistIDs.Contains(projectile.type)) - { - if (!CalamityLists.EaterofWorldsIDs.Contains(npc.type)) - damage = (int)(damage * 0.2); - else if (!Main.expertMode) - damage = (int)(damage * 0.2); - } + // Supercrits can "supercrit" over and over for each extra 100% critical strike chance. + // For example if you have 716% critical strike chance, you are guaranteed +700% damage and then have a 16% chance for +800% damage instead. + if (critOver100 > 0) + { + int supercritLayers = critOver100 / 100; + int lastLayerCritChance = critOver100 - supercritLayers; + // Roll for the remaining crit chance + if (Main.rand.Next(100) <= lastLayerCritChance) + ++supercritLayers; - // Thanatos segments do not trigger pierce resistance if they are closed - if (CalamityLists.ThanatosIDs.Contains(npc.type) && unbreakableDR) - return; + // Apply supercrit damage. This projectile is already guaranteed to be a crit, which will double its damage at the end. + // As such, only 50% damage is added per supercrit layer here. + damage = (int)(damage * (1f + 0.5f * supercritLayers)); + } + } - float damageReduction = projectile.Calamity().timesPierced * projectile.Calamity().PierceResistHarshness; - if (damageReduction > projectile.Calamity().PierceResistCap) - damageReduction = projectile.Calamity().PierceResistCap; + int bullseyeType = ProjectileType(); + Projectile bullseye = null; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != bullseyeType || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI) + continue; - damage -= (int)(damage * damageReduction); + // Only choose a bullseye if it is attached to the NPC that is being hit. + if (npc.whoAmI == (int)Main.projectile[i].ai[0]) + { + bullseye = Main.projectile[i]; + break; + } + } - if ((projectile.penetrate > 1 || projectile.penetrate == -1) && !CalamityLists.pierceResistExceptionList.Contains(projectile.type) && !projectile.IsSummon() && projectile.aiStyle != 15 && projectile.aiStyle != 39 && projectile.aiStyle != 99) - projectile.Calamity().timesPierced++; - } - #endregion + // Don't allow large hitbox projectiles or explosions to "snipe" enemies. + // Hitbox criteria were changed to allow long one dimensional projectiles so that Condemnation would work. + bool hitBullseye = false; + bool acceptableVelocity = projectile.velocity != Vector2.Zero; + bool acceptableHitbox = (projectile.width < 36) || (projectile.height < 36); + if (bullseye != null && projectile.ranged && acceptableVelocity && acceptableHitbox) + { + if (bullseye != null) + { + // Bullseyes are visually different on bosses and thus have larger hitboxes. + float bullseyeRadius = npc.IsABoss() ? DaawnlightSpiritOrigin.BossBullseyeRadius : DaawnlightSpiritOrigin.RegularEnemyBullseyeRadius; + + // Do some geometry + trig to determine if the projectile WOULD hit the bullseye, even if it's about to be deleted on-hit. + // This is the equivalent of drawing a laser sight from the projectile along its velocity vector and seeing if it crosses the bullseye's hitbox. + // To do this more reliably, we back the projectile up quite a distance. + Vector2 normVelocity = projectile.velocity.SafeNormalize(Vector2.UnitY); + Vector2 backedUpPosition = projectile.Center - 160f * normVelocity; + Vector2 directionToBullseyeCenter = (bullseye.Center - backedUpPosition).SafeNormalize(Vector2.UnitY); + Vector2 perp = directionToBullseyeCenter.RotatedBy(MathHelper.PiOver2); + // Double the radius is given so that the cosine break-even point is right at the edge of the hitbox. + Vector2 comparisonPointOne = bullseye.Center + perp * 2f * bullseyeRadius; + Vector2 comparisonPointTwo = bullseye.Center - perp * 2f * bullseyeRadius; + Vector2 dirToPointOne = (comparisonPointOne - backedUpPosition).SafeNormalize(-Vector2.UnitX); + Vector2 dirToPointTwo = (comparisonPointTwo - backedUpPosition).SafeNormalize(Vector2.UnitX); + + // Law of cosines: (A dot B) = |A| * |B| * cos(theta) + // where theta is the angle between the two vectors A and B. + // cos(theta) approaches one as the angle approaches zero, so an angle is smaller if the cos is bigger. + // If the angle to the bullseye's center is smaller than the angle to both the comparison points, it's a hit. + float dotCenter = Vector2.Dot(normVelocity, directionToBullseyeCenter); + float dotOne = Vector2.Dot(normVelocity, dirToPointOne); + float dotTwo = Vector2.Dot(normVelocity, dirToPointTwo); + bool willStrikeBullseye = dotCenter > dotOne && dotCenter > dotTwo; + + // If a bullseye is triggered, set it as hit. + if (willStrikeBullseye && bullseye.ai[1] == 0f) + { + crit = true; + hitBullseye = true; + bullseye.ai[1] = 1f; // Make the bullseye disappear immediately. + bullseye.netUpdate = true; + } + } + + // TODO -- Use the 1.4 spawn context system for this. + // This suffers from the same issues as current crit logic in vanilla, but I have no idea how to do this better without said system. + if (modPlayer.spiritOrigin && crit) + { + // Crits have their damage doubled after ModifyHitNPC, in the StrikeNPC function. + // Here, damage is divded by 2 to compensate for that. + // This means that the bonus provided by Daawnlight Spirit Origin can be computed as a complete replacement to regular crits. + float mult = DaawnlightSpiritOrigin.GetDamageMultiplier(player, modPlayer, hitBullseye) / 2f; + damage = (int)(damage * mult); + } + } + + if (!projectile.npcProj && !projectile.trap) + { + if (projectile.ranged && modPlayer.plagueReaper && pFlames > 0) + damage = (int)(damage * 1.1); + } + + // Any weapons that shoot projectiles from anywhere other than the player's center aren't affected by point-blank shot damage boost. + if (!Main.player[projectile.owner].ActiveItem().IsAir && Main.player[projectile.owner].ActiveItem().Calamity().canFirePointBlankShots && projectile.ranged) + { + if (projectile.Calamity().pointBlankShotDuration > 0) + { + projectile.Calamity().pointBlankShotDuration = 0; + damage = (int)(damage * 1.5); + } + } + + // Apply balancing resists/vulnerabilities. + BalancingChangesManager.ApplyFromProjectile(npc, ref damage, projectile); + + if (CalamityLists.pierceResistList.Contains(npc.type)) + PierceResistGlobal(projectile, npc, ref damage); + + if (modPlayer.camper && !player.StandingStill()) + damage = (int)(damage * 0.1); + } + + private void PierceResistGlobal(Projectile projectile, NPC npc, ref int damage) + { + if (CalamityLists.GrenadeResistIDs.Contains(projectile.type)) + { + if (!CalamityLists.EaterofWorldsIDs.Contains(npc.type)) + damage = (int)(damage * 0.2); + else if (!Main.expertMode) + damage = (int)(damage * 0.2); + } + + // Thanatos segments do not trigger pierce resistance if they are closed + if (CalamityLists.ThanatosIDs.Contains(npc.type) && unbreakableDR) + return; + + float damageReduction = projectile.Calamity().timesPierced * projectile.Calamity().PierceResistHarshness; + if (damageReduction > projectile.Calamity().PierceResistCap) + damageReduction = projectile.Calamity().PierceResistCap; + + damage -= (int)(damage * damageReduction); + + if ((projectile.penetrate > 1 || projectile.penetrate == -1) && !CalamityLists.pierceResistExceptionList.Contains(projectile.type) && !projectile.IsSummon() && projectile.aiStyle != 15 && projectile.aiStyle != 39 && projectile.aiStyle != 99) + projectile.Calamity().timesPierced++; + } + #endregion #region Check Dead public override bool CheckDead(NPC npc) @@ -4082,13 +4082,13 @@ namespace CalamityMod.NPCs if (Main.rand.NextBool(maxValue) && Main.wallDungeon[Main.tile[(int)npc.Center.X / 16, (int)npc.Center.Y / 16].wall]) { - int randomType = Utils.SelectRandom(Main.rand, new int[] - { - NPCType(), - NPCType(), - NPCType(), - NPCType() - }); + int randomType = Utils.SelectRandom(Main.rand, new int[] + { + NPCType(), + NPCType(), + NPCType(), + NPCType() + }); NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, randomType, 0, 0f, 0f, 0f, 0f, 255); } @@ -4101,10 +4101,10 @@ namespace CalamityMod.NPCs #region Hit Effect public override void HitEffect(NPC npc, int hitDirection, double damage) { - if (npc.life <= 0 && npc.Organic() && RancorBurnTime > 0) - DeathAshParticle.CreateAshesFromNPC(npc); + if (npc.life <= 0 && npc.Organic() && RancorBurnTime > 0) + DeathAshParticle.CreateAshesFromNPC(npc); - if (CalamityWorld.revenge) + if (CalamityWorld.revenge) { switch (npc.type) { @@ -4176,24 +4176,24 @@ namespace CalamityMod.NPCs } } - if (npc.life <= 0 && BossRushEvent.BossRushActive && npc.type == NPCID.WallofFlesh && BossRushEvent.CurrentlyFoughtBoss == npc.type) + if (npc.life <= 0 && BossRushEvent.BossRushActive && npc.type == NPCID.WallofFlesh && BossRushEvent.CurrentlyFoughtBoss == npc.type) { - // Post-Wall of Flesh teleport back to spawn. - // This appears to only work correctly client-side in MP. - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) - { - bool appropriatePlayer = Main.myPlayer == playerIndex; - if (Main.player[playerIndex].active && appropriatePlayer) - Main.player[playerIndex].Spawn(); - } - } + // Post-Wall of Flesh teleport back to spawn. + // This appears to only work correctly client-side in MP. + for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + bool appropriatePlayer = Main.myPlayer == playerIndex; + if (Main.player[playerIndex].active && appropriatePlayer) + Main.player[playerIndex].Spawn(); + } + } } #endregion #region Edit Spawn Rate public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns) { - // Biomes + // Biomes if (player.Calamity().ZoneSulphur) { spawnRate = (int)(spawnRate * 1.1); @@ -4239,95 +4239,95 @@ namespace CalamityMod.NPCs maxSpawns = (int)(maxSpawns * 1.1f); } - // Boosts - if (CalamityWorld.downedDoG && (Main.pumpkinMoon || Main.snowMoon || Main.eclipse)) - { - spawnRate = (int)(spawnRate * 0.75); - maxSpawns = (int)(maxSpawns * 3f); - } + // Boosts + if (CalamityWorld.downedDoG && (Main.pumpkinMoon || Main.snowMoon || Main.eclipse)) + { + spawnRate = (int)(spawnRate * 0.75); + maxSpawns = (int)(maxSpawns * 3f); + } - if (player.Calamity().clamity) - { - spawnRate = (int)(spawnRate * 0.02); - maxSpawns = (int)(maxSpawns * 1.5f); - } + if (player.Calamity().clamity) + { + spawnRate = (int)(spawnRate * 0.02); + maxSpawns = (int)(maxSpawns * 1.5f); + } - if (CalamityWorld.death && Main.bloodMoon) - { - spawnRate = (int)(spawnRate * 0.25); - maxSpawns = (int)(maxSpawns * 10f); - } + if (CalamityWorld.death && Main.bloodMoon) + { + spawnRate = (int)(spawnRate * 0.25); + maxSpawns = (int)(maxSpawns * 10f); + } - if (NPC.LunarApocalypseIsUp) - { - if ((player.ZoneTowerNebula && NPC.ShieldStrengthTowerNebula == 0) || (player.ZoneTowerStardust && NPC.ShieldStrengthTowerStardust == 0) || - (player.ZoneTowerVortex && NPC.ShieldStrengthTowerVortex == 0) || (player.ZoneTowerSolar && NPC.ShieldStrengthTowerSolar == 0)) - { - spawnRate = (int)(spawnRate * 0.85); - maxSpawns = (int)(maxSpawns * 1.25f); - } - } + if (NPC.LunarApocalypseIsUp) + { + if ((player.ZoneTowerNebula && NPC.ShieldStrengthTowerNebula == 0) || (player.ZoneTowerStardust && NPC.ShieldStrengthTowerStardust == 0) || + (player.ZoneTowerVortex && NPC.ShieldStrengthTowerVortex == 0) || (player.ZoneTowerSolar && NPC.ShieldStrengthTowerSolar == 0)) + { + spawnRate = (int)(spawnRate * 0.85); + maxSpawns = (int)(maxSpawns * 1.25f); + } + } - if (CalamityWorld.revenge) - spawnRate = (int)(spawnRate * 0.85); + if (CalamityWorld.revenge) + spawnRate = (int)(spawnRate * 0.85); - if (Main.waterCandles > 0) - { - spawnRate = (int)(spawnRate * 0.9); - maxSpawns = (int)(maxSpawns * 1.1f); - } - if (player.enemySpawns) - { - spawnRate = (int)(spawnRate * 0.8); - maxSpawns = (int)(maxSpawns * 1.2f); - } - if (player.Calamity().chaosCandle) - { - spawnRate = (int)(spawnRate * 0.6); - maxSpawns = (int)(maxSpawns * 2.5f); - } - if (player.Calamity().zerg) + if (Main.waterCandles > 0) + { + spawnRate = (int)(spawnRate * 0.9); + maxSpawns = (int)(maxSpawns * 1.1f); + } + if (player.enemySpawns) + { + spawnRate = (int)(spawnRate * 0.8); + maxSpawns = (int)(maxSpawns * 1.2f); + } + if (player.Calamity().chaosCandle) + { + spawnRate = (int)(spawnRate * 0.6); + maxSpawns = (int)(maxSpawns * 2.5f); + } + if (player.Calamity().zerg) { spawnRate = (int)(spawnRate * 0.2); maxSpawns = (int)(maxSpawns * 5f); } - if (NPC.AnyNPCs(NPCType())) - { - int otherWulfrumEnemies = NPC.CountNPCS(NPCType()) + NPC.CountNPCS(NPCType()) + NPC.CountNPCS(NPCType()) + NPC.CountNPCS(NPCType()); - if (otherWulfrumEnemies < 4) - { - spawnRate = (int)(spawnRate * 0.8); - maxSpawns = (int)(maxSpawns * 1.2f); - } - } + if (NPC.AnyNPCs(NPCType())) + { + int otherWulfrumEnemies = NPC.CountNPCS(NPCType()) + NPC.CountNPCS(NPCType()) + NPC.CountNPCS(NPCType()) + NPC.CountNPCS(NPCType()); + if (otherWulfrumEnemies < 4) + { + spawnRate = (int)(spawnRate * 0.8); + maxSpawns = (int)(maxSpawns * 1.2f); + } + } - // Reductions - if (Main.peaceCandles > 0) - { - spawnRate = (int)(spawnRate * 1.1); - maxSpawns = (int)(maxSpawns * 0.9f); - } - if (player.calmed) - { - spawnRate = (int)(spawnRate * 1.2); - maxSpawns = (int)(maxSpawns * 0.8f); - } + // Reductions + if (Main.peaceCandles > 0) + { + spawnRate = (int)(spawnRate * 1.1); + maxSpawns = (int)(maxSpawns * 0.9f); + } + if (player.calmed) + { + spawnRate = (int)(spawnRate * 1.2); + maxSpawns = (int)(maxSpawns * 0.8f); + } if (player.Calamity().tranquilityCandle) { spawnRate = (int)(spawnRate * 1.4); maxSpawns = (int)(maxSpawns * 0.4f); } - if (player.Calamity().zen || (CalamityConfig.Instance.DisableExpertTownSpawns && player.townNPCs > 1f && Main.expertMode)) - { - spawnRate = (int)(spawnRate * 2.5); - maxSpawns = (int)(maxSpawns * 0.3f); - } - if ((player.Calamity().bossZen || CalamityWorld.DoGSecondStageCountdown > 0) && CalamityConfig.Instance.BossZen) - { - spawnRate *= 5; - maxSpawns = (int)(maxSpawns * 0.001f); - } - } + if (player.Calamity().zen || (CalamityConfig.Instance.DisableExpertTownSpawns && player.townNPCs > 1f && Main.expertMode)) + { + spawnRate = (int)(spawnRate * 2.5); + maxSpawns = (int)(maxSpawns * 0.3f); + } + if ((player.Calamity().bossZen || CalamityWorld.DoGSecondStageCountdown > 0) && CalamityConfig.Instance.BossZen) + { + spawnRate *= 5; + maxSpawns = (int)(maxSpawns * 0.001f); + } + } #endregion #region Edit Spawn Range @@ -4339,85 +4339,85 @@ namespace CalamityMod.NPCs safeRangeX = (int)(1920 / 16 * 0.32); //0.52 } } - #endregion + #endregion - #region Edit Spawn Pool + #region Edit Spawn Pool - internal static readonly FieldInfo MaxSpawnsField = typeof(NPC).GetField("maxSpawns", BindingFlags.NonPublic | BindingFlags.Static); - public static void AttemptToSpawnLabCritters(Player player) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - return; + internal static readonly FieldInfo MaxSpawnsField = typeof(NPC).GetField("maxSpawns", BindingFlags.NonPublic | BindingFlags.Static); + public static void AttemptToSpawnLabCritters(Player player) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + return; - int spawnRate = 400; - int maxSpawnCount = (int)MaxSpawnsField.GetValue(null); - NPCLoader.EditSpawnRate(player, ref spawnRate, ref maxSpawnCount); + int spawnRate = 400; + int maxSpawnCount = (int)MaxSpawnsField.GetValue(null); + NPCLoader.EditSpawnRate(player, ref spawnRate, ref maxSpawnCount); - // Enforce a limit on the amount of enemies that can appear. - if (player.activeNPCs >= maxSpawnCount) - return; + // Enforce a limit on the amount of enemies that can appear. + if (player.activeNPCs >= maxSpawnCount) + return; - for (int i = 0; i < 8; i++) - { - int checkPositionX = (int)(player.Center.X / 16 + Main.rand.Next(30, 54) * Main.rand.NextBool(2).ToDirectionInt()); - int checkPositionY = (int)(player.Center.Y / 16 + Main.rand.Next(24, 45) * Main.rand.NextBool(2).ToDirectionInt()); - Vector2 checkPosition = new Vector2(checkPositionX, checkPositionY); + for (int i = 0; i < 8; i++) + { + int checkPositionX = (int)(player.Center.X / 16 + Main.rand.Next(30, 54) * Main.rand.NextBool(2).ToDirectionInt()); + int checkPositionY = (int)(player.Center.Y / 16 + Main.rand.Next(24, 45) * Main.rand.NextBool(2).ToDirectionInt()); + Vector2 checkPosition = new Vector2(checkPositionX, checkPositionY); - Tile aboveSpawnTile = CalamityUtils.ParanoidTileRetrieval(checkPositionX, checkPositionY - 1); - bool nearLab = CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.SunkenSeaLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.PlanetoidLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.JungleLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.HellLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.IceLabCenter / 16f) < 180f; + Tile aboveSpawnTile = CalamityUtils.ParanoidTileRetrieval(checkPositionX, checkPositionY - 1); + bool nearLab = CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.SunkenSeaLabCenter / 16f) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.PlanetoidLabCenter / 16f) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.JungleLabCenter / 16f) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.HellLabCenter / 16f) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.IceLabCenter / 16f) < 180f; - bool isLabWall = aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType(); - isLabWall |= aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType(); - if (!isLabWall || !nearLab || Collision.SolidCollision((checkPosition - new Vector2(2f, 2f)).ToWorldCoordinates(), 4, 4) || player.activeNPCs >= maxSpawnCount || !Main.rand.NextBool(spawnRate)) - continue; + bool isLabWall = aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType(); + isLabWall |= aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType(); + if (!isLabWall || !nearLab || Collision.SolidCollision((checkPosition - new Vector2(2f, 2f)).ToWorldCoordinates(), 4, 4) || player.activeNPCs >= maxSpawnCount || !Main.rand.NextBool(spawnRate)) + continue; - WeightedRandom pool = new WeightedRandom(); - pool.Add(NPCID.None, 0f); - pool.Add(NPCType(), 0.2f); + WeightedRandom pool = new WeightedRandom(); + pool.Add(NPCID.None, 0f); + pool.Add(NPCType(), 0.2f); - int typeToSpawn = pool.Get(); - if (typeToSpawn != NPCID.None) - { - int spawnedNPC = NPCLoader.SpawnNPC(typeToSpawn, checkPositionX, checkPositionY - 1); - if (Main.netMode == NetmodeID.Server && spawnedNPC < Main.maxNPCs) - { - Main.npc[spawnedNPC].position.Y -= 8f; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, spawnedNPC); - return; - } - } - } - } + int typeToSpawn = pool.Get(); + if (typeToSpawn != NPCID.None) + { + int spawnedNPC = NPCLoader.SpawnNPC(typeToSpawn, checkPositionX, checkPositionY - 1); + if (Main.netMode == NetmodeID.Server && spawnedNPC < Main.maxNPCs) + { + Main.npc[spawnedNPC].position.Y -= 8f; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, spawnedNPC); + return; + } + } + } + } public override void EditSpawnPool(IDictionary pool, NPCSpawnInfo spawnInfo) { - bool calamityBiomeZone = spawnInfo.player.Calamity().ZoneAbyss || - spawnInfo.player.Calamity().ZoneCalamity || - spawnInfo.player.Calamity().ZoneSulphur || - spawnInfo.player.Calamity().ZoneSunkenSea || - (spawnInfo.player.Calamity().ZoneAstral && !NPC.LunarApocalypseIsUp); + bool calamityBiomeZone = spawnInfo.player.Calamity().ZoneAbyss || + spawnInfo.player.Calamity().ZoneCalamity || + spawnInfo.player.Calamity().ZoneSulphur || + spawnInfo.player.Calamity().ZoneSunkenSea || + (spawnInfo.player.Calamity().ZoneAstral && !NPC.LunarApocalypseIsUp); - // Spawn Green Jellyfish in prehm and Blue Jellyfish in hardmode - if (spawnInfo.player.ZoneRockLayerHeight && spawnInfo.water && !calamityBiomeZone) - { - if (!Main.hardMode) - pool[NPCID.GreenJellyfish] = SpawnCondition.CaveJellyfish.Chance * 0.5f; - else - pool[NPCID.BlueJellyfish] = SpawnCondition.CaveJellyfish.Chance; - } + // Spawn Green Jellyfish in prehm and Blue Jellyfish in hardmode + if (spawnInfo.player.ZoneRockLayerHeight && spawnInfo.water && !calamityBiomeZone) + { + if (!Main.hardMode) + pool[NPCID.GreenJellyfish] = SpawnCondition.CaveJellyfish.Chance * 0.5f; + else + pool[NPCID.BlueJellyfish] = SpawnCondition.CaveJellyfish.Chance; + } - // Add Truffle Worm spawns to surface mushroom biome - if (spawnInfo.player.ZoneGlowshroom && Main.hardMode && (spawnInfo.player.ZoneOverworldHeight || spawnInfo.player.ZoneSkyHeight)) - { - if (NPC.CountNPCS(NPCID.TruffleWorm) < 2) - pool[NPCID.TruffleWorm] = SpawnCondition.OverworldMushroom.Chance * 0.5f; - } + // Add Truffle Worm spawns to surface mushroom biome + if (spawnInfo.player.ZoneGlowshroom && Main.hardMode && (spawnInfo.player.ZoneOverworldHeight || spawnInfo.player.ZoneSkyHeight)) + { + if (NPC.CountNPCS(NPCID.TruffleWorm) < 2) + pool[NPCID.TruffleWorm] = SpawnCondition.OverworldMushroom.Chance * 0.5f; + } - if (calamityBiomeZone) + if (calamityBiomeZone) { pool[0] = 0f; } @@ -4495,18 +4495,18 @@ namespace CalamityMod.NPCs } } - if (spawnInfo.playerSafe) - return; + if (spawnInfo.playerSafe) + return; - if (!Main.hardMode && spawnInfo.player.ZoneUnderworldHeight && !calamityBiomeZone) - { - if (!NPC.AnyNPCs(NPCID.VoodooDemon)) - pool[NPCID.VoodooDemon] = SpawnCondition.Underworld.Chance * 0.75f; - } + if (!Main.hardMode && spawnInfo.player.ZoneUnderworldHeight && !calamityBiomeZone) + { + if (!NPC.AnyNPCs(NPCID.VoodooDemon)) + pool[NPCID.VoodooDemon] = SpawnCondition.Underworld.Chance * 0.75f; + } if (spawnInfo.player.Calamity().disableVoodooSpawns && pool.ContainsKey(NPCID.VoodooDemon)) pool.Remove(NPCID.VoodooDemon); - } + } #endregion #region Drawing @@ -4521,34 +4521,34 @@ namespace CalamityMod.NPCs public override void DrawEffects(NPC npc, ref Color drawColor) { - if (vaporfied > 0) - { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 246, - 242, - 229, - 226, - 247, - 187, - 234 - }); + if (vaporfied > 0) + { + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 246, + 242, + 229, + 226, + 247, + 187, + 234 + }); - if (Main.rand.Next(5) < 4) - { - 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, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.8f; - Main.dust[dust].velocity.Y -= 0.5f; - if (Main.rand.NextBool(4)) - { - Main.dust[dust].noGravity = false; - Main.dust[dust].scale *= 0.5f; - } - } - } + if (Main.rand.Next(5) < 4) + { + 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, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.8f; + Main.dust[dust].velocity.Y -= 0.5f; + if (Main.rand.NextBool(4)) + { + Main.dust[dust].noGravity = false; + Main.dust[dust].scale *= 0.5f; + } + } + } - if (bBlood > 0) + if (bBlood > 0) { if (Main.rand.Next(5) < 4) { @@ -4599,46 +4599,46 @@ namespace CalamityMod.NPCs Lighting.AddLight(npc.position, 0.025f, 0f, 0f); } - // Enemies suffering from Soma Prime's Shred spray blood like Violence - if (somaShredStacks > 0 && Main.netMode != NetmodeID.Server) + // Enemies suffering from Soma Prime's Shred spray blood like Violence + if (somaShredStacks > 0 && Main.netMode != NetmodeID.Server) { - // The amount of blood particles spawned by Soma Prime's Shred scales loosely with the number of stacks. - float roughBloodCount = (float)Math.Sqrt(0.8f * somaShredStacks); - int exactBloodCount = (int)roughBloodCount; - // Chance for the final blood particle - if (Main.rand.NextFloat() < roughBloodCount - exactBloodCount) - ++exactBloodCount; + // The amount of blood particles spawned by Soma Prime's Shred scales loosely with the number of stacks. + float roughBloodCount = (float)Math.Sqrt(0.8f * somaShredStacks); + int exactBloodCount = (int)roughBloodCount; + // Chance for the final blood particle + if (Main.rand.NextFloat() < roughBloodCount - exactBloodCount) + ++exactBloodCount; - // Velocity of the spurting blood also slightly increases with stacks. - float velStackMult = 1f + (float)Math.Log(somaShredStacks); + // Velocity of the spurting blood also slightly increases with stacks. + float velStackMult = 1f + (float)Math.Log(somaShredStacks); - // Code copied from Violence. - for (int i = 0; i < exactBloodCount; ++i) - { - int bloodLifetime = Main.rand.Next(22, 36); - float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); - Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat()); - bloodColor = Color.Lerp(bloodColor, new Color(51, 22, 94), Main.rand.NextFloat(0.65f)); + // Code copied from Violence. + for (int i = 0; i < exactBloodCount; ++i) + { + int bloodLifetime = Main.rand.Next(22, 36); + float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); + Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat()); + bloodColor = Color.Lerp(bloodColor, new Color(51, 22, 94), Main.rand.NextFloat(0.65f)); - if (Main.rand.NextBool(20)) - bloodScale *= 2f; + if (Main.rand.NextBool(20)) + bloodScale *= 2f; - float randomSpeedMultiplier = Main.rand.NextFloat(1.25f, 2.25f); - Vector2 bloodVelocity = Main.rand.NextVector2Unit() * velStackMult * randomSpeedMultiplier; - bloodVelocity.Y -= 5f; - BloodParticle blood = new BloodParticle(npc.Center, bloodVelocity, bloodLifetime, bloodScale, bloodColor); - GeneralParticleHandler.SpawnParticle(blood); - } - for (int i = 0; i < exactBloodCount / 3; ++i) - { - float bloodScale = Main.rand.NextFloat(0.2f, 0.33f); - Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat(0.5f, 1f)); - Vector2 bloodVelocity = Main.rand.NextVector2Unit() * velStackMult * Main.rand.NextFloat(1f, 2f); - bloodVelocity.Y -= 2.3f; - BloodParticle2 blood = new BloodParticle2(npc.Center, bloodVelocity, 20, bloodScale, bloodColor); - GeneralParticleHandler.SpawnParticle(blood); - } - } + float randomSpeedMultiplier = Main.rand.NextFloat(1.25f, 2.25f); + Vector2 bloodVelocity = Main.rand.NextVector2Unit() * velStackMult * randomSpeedMultiplier; + bloodVelocity.Y -= 5f; + BloodParticle blood = new BloodParticle(npc.Center, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + for (int i = 0; i < exactBloodCount / 3; ++i) + { + float bloodScale = Main.rand.NextFloat(0.2f, 0.33f); + Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat(0.5f, 1f)); + Vector2 bloodVelocity = Main.rand.NextVector2Unit() * velStackMult * Main.rand.NextFloat(1f, 2f); + bloodVelocity.Y -= 2.3f; + BloodParticle2 blood = new BloodParticle2(npc.Center, bloodVelocity, 20, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + } if (hFlames > 0 || banishingFire > 0) { @@ -4824,17 +4824,17 @@ namespace CalamityMod.NPCs } } } - if (ladHearts > 0 && !npc.loveStruck) - { - if (Main.rand.NextBool(5)) - { - Vector2 velocity = CalamityUtils.RandomVelocity(10f, 1f, 1f, 0.66f); - int heart = Gore.NewGore(npc.position + new Vector2(Main.rand.Next(npc.width + 1), Main.rand.Next(npc.height + 1)), velocity * Main.rand.Next(3, 6) * 0.33f, 331, Main.rand.Next(40, 121) * 0.01f); - Main.gore[heart].sticky = false; - Main.gore[heart].velocity *= 0.4f; - Main.gore[heart].velocity.Y -= 0.6f; - } - } + if (ladHearts > 0 && !npc.loveStruck) + { + if (Main.rand.NextBool(5)) + { + Vector2 velocity = CalamityUtils.RandomVelocity(10f, 1f, 1f, 0.66f); + int heart = Gore.NewGore(npc.position + new Vector2(Main.rand.Next(npc.width + 1), Main.rand.Next(npc.height + 1)), velocity * Main.rand.Next(3, 6) * 0.33f, 331, Main.rand.Next(40, 121) * 0.01f); + Main.gore[heart].sticky = false; + Main.gore[heart].velocity *= 0.4f; + Main.gore[heart].velocity.Y -= 0.6f; + } + } if (gState > 0 || eFreeze > 0) drawColor = Color.Cyan; @@ -4860,208 +4860,208 @@ namespace CalamityMod.NPCs if (npc.Calamity().kamiFlu > 0 && !CalamityLists.kamiDebuffColorImmuneList.Contains(npc.type)) return new Color(51, 197, 108, npc.alpha); - if (npc.type == NPCID.AncientDoom) - return new Color(255, 255, 255, npc.alpha); + if (npc.type == NPCID.AncientDoom) + return new Color(255, 255, 255, npc.alpha); - return null; + return null; } public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor) { - if (npc.type != NPCID.BrainofCthulhu && (npc.type != NPCID.DukeFishron || npc.ai[0] <= 9f) && npc.active) - { - if (CalamityConfig.Instance.DebuffDisplay && (npc.boss || BossHealthBarManager.MinibossHPBarList.Contains(npc.type) || BossHealthBarManager.OneToMany.ContainsKey(npc.type) || CalamityLists.needsDebuffIconDisplayList.Contains(npc.type))) - { - IList buffTextureList = new List(); + if (npc.type != NPCID.BrainofCthulhu && (npc.type != NPCID.DukeFishron || npc.ai[0] <= 9f) && npc.active) + { + if (CalamityConfig.Instance.DebuffDisplay && (npc.boss || BossHealthBarManager.MinibossHPBarList.Contains(npc.type) || BossHealthBarManager.OneToMany.ContainsKey(npc.type) || CalamityLists.needsDebuffIconDisplayList.Contains(npc.type))) + { + IList buffTextureList = new List(); - // Damage over time debuffs - if (aFlames > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/AbyssalFlames")); - if (astralInfection > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/AstralInfectionDebuff")); - if (bFlames > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/BrimstoneFlames")); - if (bBlood > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/BurningBlood")); - if (cDepth > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/CrushDepth")); - if (dFlames > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/DemonFlames")); - if (gsInferno > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno")); - if (hFlames > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/HolyFlames")); - if (nightwither > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Nightwither")); - if (pFlames > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Plague")); - if (shellfishVore > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/ShellfishEating")); - if (somaShredStacks > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Shred")); - if (clamDebuff > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/SnapClamDebuff")); - if (sulphurPoison > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/SulphuricPoisoning")); + // Damage over time debuffs + if (aFlames > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/AbyssalFlames")); + if (astralInfection > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/AstralInfectionDebuff")); + if (bFlames > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/BrimstoneFlames")); + if (bBlood > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/BurningBlood")); + if (cDepth > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/CrushDepth")); + if (dFlames > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/DemonFlames")); + if (gsInferno > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno")); + if (hFlames > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/HolyFlames")); + if (nightwither > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Nightwither")); + if (pFlames > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Plague")); + if (shellfishVore > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/ShellfishEating")); + if (somaShredStacks > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Shred")); + if (clamDebuff > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/SnapClamDebuff")); + if (sulphurPoison > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/SulphuricPoisoning")); if (sagePoisonTime > 0) buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/SagePoison")); if (vaporfied > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Vaporfied")); + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Vaporfied")); - // Stat debuffs - if (aCrunch > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/ArmorCrunch")); - if (enraged > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/Enraged")); - if (eutrophication > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/Eutrophication")); - if (eFreeze > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/ExoFreeze")); - if (gState > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/GlacialState")); - if (irradiated > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/Irradiated")); - if (kamiFlu > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/KamiDebuff")); - if (marked > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/MarkedforDeath")); - if (pearlAura > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/PearlAura")); + // Stat debuffs + if (aCrunch > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/ArmorCrunch")); + if (enraged > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/Enraged")); + if (eutrophication > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/Eutrophication")); + if (eFreeze > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/ExoFreeze")); + if (gState > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/GlacialState")); + if (irradiated > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/Irradiated")); + if (kamiFlu > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/KamiDebuff")); + if (marked > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/MarkedforDeath")); + if (pearlAura > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/PearlAura")); if (relicOfResilienceWeakness > 0) buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/ProfanedWeakness")); - if (tSad > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/TemporalSadness")); - if (tesla > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/TeslaFreeze")); - if (timeSlow > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/TimeSlow")); - if (wCleave > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/WarCleave")); - if (wDeath > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/WhisperingDeath")); - if (wither > 0) - buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/WitherDebuff")); + if (tSad > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/TemporalSadness")); + if (tesla > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/TeslaFreeze")); + if (timeSlow > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/TimeSlow")); + if (wCleave > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/WarCleave")); + if (wDeath > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/WhisperingDeath")); + if (wither > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/StatDebuffs/WitherDebuff")); - // Vanilla damage over time debuffs - if (electrified > 0) - buffTextureList.Add(Main.buffTexture[BuffID.Electrified]); - if (npc.onFire) - buffTextureList.Add(Main.buffTexture[BuffID.OnFire]); - if (npc.poisoned) - buffTextureList.Add(Main.buffTexture[BuffID.Poisoned]); - if (npc.onFire2) - buffTextureList.Add(Main.buffTexture[BuffID.CursedInferno]); - if (npc.onFrostBurn) - buffTextureList.Add(Main.buffTexture[BuffID.Frostburn]); - if (npc.venom) - buffTextureList.Add(Main.buffTexture[BuffID.Venom]); - if (npc.shadowFlame) - buffTextureList.Add(Main.buffTexture[BuffID.ShadowFlame]); - if (npc.oiled) - buffTextureList.Add(Main.buffTexture[BuffID.Oiled]); - if (npc.javelined) - buffTextureList.Add(Main.buffTexture[BuffID.BoneJavelin]); - if (npc.daybreak) - buffTextureList.Add(Main.buffTexture[BuffID.Daybreak]); - if (npc.celled) - buffTextureList.Add(Main.buffTexture[BuffID.StardustMinionBleed]); - if (npc.dryadBane) - buffTextureList.Add(Main.buffTexture[BuffID.DryadsWardDebuff]); - if (npc.dryadWard) - buffTextureList.Add(Main.buffTexture[BuffID.DryadsWard]); - if (npc.soulDrain && npc.realLife == -1) - buffTextureList.Add(Main.buffTexture[BuffID.SoulDrain]); + // Vanilla damage over time debuffs + if (electrified > 0) + buffTextureList.Add(Main.buffTexture[BuffID.Electrified]); + if (npc.onFire) + buffTextureList.Add(Main.buffTexture[BuffID.OnFire]); + if (npc.poisoned) + buffTextureList.Add(Main.buffTexture[BuffID.Poisoned]); + if (npc.onFire2) + buffTextureList.Add(Main.buffTexture[BuffID.CursedInferno]); + if (npc.onFrostBurn) + buffTextureList.Add(Main.buffTexture[BuffID.Frostburn]); + if (npc.venom) + buffTextureList.Add(Main.buffTexture[BuffID.Venom]); + if (npc.shadowFlame) + buffTextureList.Add(Main.buffTexture[BuffID.ShadowFlame]); + if (npc.oiled) + buffTextureList.Add(Main.buffTexture[BuffID.Oiled]); + if (npc.javelined) + buffTextureList.Add(Main.buffTexture[BuffID.BoneJavelin]); + if (npc.daybreak) + buffTextureList.Add(Main.buffTexture[BuffID.Daybreak]); + if (npc.celled) + buffTextureList.Add(Main.buffTexture[BuffID.StardustMinionBleed]); + if (npc.dryadBane) + buffTextureList.Add(Main.buffTexture[BuffID.DryadsWardDebuff]); + if (npc.dryadWard) + buffTextureList.Add(Main.buffTexture[BuffID.DryadsWard]); + if (npc.soulDrain && npc.realLife == -1) + buffTextureList.Add(Main.buffTexture[BuffID.SoulDrain]); - // Vanilla stat debuffs - if (npc.confused) - buffTextureList.Add(Main.buffTexture[BuffID.Confused]); - if (npc.ichor) - buffTextureList.Add(Main.buffTexture[BuffID.Ichor]); - if (slowed > 0) - buffTextureList.Add(Main.buffTexture[BuffID.Slow]); - if (webbed > 0) - buffTextureList.Add(Main.buffTexture[BuffID.Webbed]); - if (npc.midas) - buffTextureList.Add(Main.buffTexture[BuffID.Midas]); - if (npc.loveStruck) - buffTextureList.Add(Main.buffTexture[BuffID.Lovestruck]); - if (npc.stinky) - buffTextureList.Add(Main.buffTexture[BuffID.Stinky]); - if (npc.betsysCurse) - buffTextureList.Add(Main.buffTexture[BuffID.BetsysCurse]); - if (npc.dripping) - buffTextureList.Add(Main.buffTexture[BuffID.Wet]); - if (npc.drippingSlime) - buffTextureList.Add(Main.buffTexture[BuffID.Slimed]); + // Vanilla stat debuffs + if (npc.confused) + buffTextureList.Add(Main.buffTexture[BuffID.Confused]); + if (npc.ichor) + buffTextureList.Add(Main.buffTexture[BuffID.Ichor]); + if (slowed > 0) + buffTextureList.Add(Main.buffTexture[BuffID.Slow]); + if (webbed > 0) + buffTextureList.Add(Main.buffTexture[BuffID.Webbed]); + if (npc.midas) + buffTextureList.Add(Main.buffTexture[BuffID.Midas]); + if (npc.loveStruck) + buffTextureList.Add(Main.buffTexture[BuffID.Lovestruck]); + if (npc.stinky) + buffTextureList.Add(Main.buffTexture[BuffID.Stinky]); + if (npc.betsysCurse) + buffTextureList.Add(Main.buffTexture[BuffID.BetsysCurse]); + if (npc.dripping) + buffTextureList.Add(Main.buffTexture[BuffID.Wet]); + if (npc.drippingSlime) + buffTextureList.Add(Main.buffTexture[BuffID.Slimed]); - // Total amount of elements in the buff list - int buffTextureListLength = buffTextureList.Count; + // Total amount of elements in the buff list + int buffTextureListLength = buffTextureList.Count; - // Total length of a single row in the buff display - int totalLength = buffTextureListLength * 14; + // Total length of a single row in the buff display + int totalLength = buffTextureListLength * 14; - // Max amount of buffs per row - int buffDisplayRowLimit = 5; + // Max amount of buffs per row + int buffDisplayRowLimit = 5; - // The maximum length of a single row in the buff display - // Limited to 80 units, because every buff drawn here is half the size of a normal buff, 16 x 16, 16 * 5 = 80 units - float drawPosX = totalLength >= 80f ? 40f : (float)(totalLength / 2); + // The maximum length of a single row in the buff display + // Limited to 80 units, because every buff drawn here is half the size of a normal buff, 16 x 16, 16 * 5 = 80 units + float drawPosX = totalLength >= 80f ? 40f : (float)(totalLength / 2); - // The height of a single frame of the npc - float npcHeight = (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2) * npc.scale; + // The height of a single frame of the npc + float npcHeight = (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2) * npc.scale; - // Offset the debuff display based on the npc's graphical offset, and 16 units, to create some space between the sprite and the display - float drawPosY = npcHeight + npc.gfxOffY + 16f; + // Offset the debuff display based on the npc's graphical offset, and 16 units, to create some space between the sprite and the display + float drawPosY = npcHeight + npc.gfxOffY + 16f; - // The position where the display is drawn - Vector2 drawPos = npc.Center - Main.screenPosition; + // The position where the display is drawn + Vector2 drawPos = npc.Center - Main.screenPosition; - // Iterate through the buff texture list - for (int i = 0; i < buffTextureList.Count; i++) - { - // Reset the X position of the display every 5th and non-zero iteration, otherwise decrease the X draw position by 16 units - if (i != 0) - { - if (i % buffDisplayRowLimit == 0) - drawPosX = 40f; - else - drawPosX -= 14f; - } + // Iterate through the buff texture list + for (int i = 0; i < buffTextureList.Count; i++) + { + // Reset the X position of the display every 5th and non-zero iteration, otherwise decrease the X draw position by 16 units + if (i != 0) + { + if (i % buffDisplayRowLimit == 0) + drawPosX = 40f; + else + drawPosX -= 14f; + } - // Offset the Y position every row after 5 iterations to limit each displayed row to 5 debuffs - float additionalYOffset = 14f * (float)Math.Floor(i * 0.2); + // Offset the Y position every row after 5 iterations to limit each displayed row to 5 debuffs + float additionalYOffset = 14f * (float)Math.Floor(i * 0.2); - // Draw the display - var tex = buffTextureList.ElementAt(i); - spriteBatch.Draw(tex, drawPos - new Vector2(drawPosX, drawPosY + additionalYOffset), null, Color.White, 0f, default, 0.5f, SpriteEffects.None, 0f); + // Draw the display + var tex = buffTextureList.ElementAt(i); + spriteBatch.Draw(tex, drawPos - new Vector2(drawPosX, drawPosY + additionalYOffset), null, Color.White, 0f, default, 0.5f, SpriteEffects.None, 0f); - // TODO -- Show number of Shred stacks (how?) - } - } - } + // TODO -- Show number of Shred stacks (how?) + } + } + } - TownNPCAlertSystem(npc, mod, spriteBatch); + TownNPCAlertSystem(npc, mod, spriteBatch); - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { if (npc.type == NPCID.SkeletronPrime || CalamityLists.DestroyerIDs.Contains(npc.type)) return false; } - if (npc.type == NPCID.GolemHeadFree) - { - // Draw the head as usual. - Texture2D golemHeadTexture = Main.npcTexture[npc.type]; - Vector2 headDrawPosition = npc.Center + Vector2.UnitY * npc.gfxOffY - Main.screenPosition; - spriteBatch.Draw(golemHeadTexture, headDrawPosition, npc.frame, npc.GetAlpha(drawColor), 0f, npc.frame.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); + if (npc.type == NPCID.GolemHeadFree) + { + // Draw the head as usual. + Texture2D golemHeadTexture = Main.npcTexture[npc.type]; + Vector2 headDrawPosition = npc.Center + Vector2.UnitY * npc.gfxOffY - Main.screenPosition; + spriteBatch.Draw(golemHeadTexture, headDrawPosition, npc.frame, npc.GetAlpha(drawColor), 0f, npc.frame.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); - // Draw the eyes. The way vanilla handles this is hardcoded bullshit that cannot handle different hitboxes and thus requires rewriting. - Color eyeColor = new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, 0); - Vector2 eyesDrawPosition = headDrawPosition - npc.scale * new Vector2(1f, 12f); - Rectangle eyesFrame = new Rectangle(0, 0, Main.golemTexture[1].Width, Main.golemTexture[1].Height / 2); - spriteBatch.Draw(Main.golemTexture[1], eyesDrawPosition, eyesFrame, eyeColor, 0f, eyesFrame.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); - return false; - } + // Draw the eyes. The way vanilla handles this is hardcoded bullshit that cannot handle different hitboxes and thus requires rewriting. + Color eyeColor = new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, 0); + Vector2 eyesDrawPosition = headDrawPosition - npc.scale * new Vector2(1f, 12f); + Rectangle eyesFrame = new Rectangle(0, 0, Main.golemTexture[1].Width, Main.golemTexture[1].Height / 2); + spriteBatch.Draw(Main.golemTexture[1], eyesDrawPosition, eyesFrame, eyeColor, 0f, eyesFrame.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); + return false; + } if (Main.LocalPlayer.Calamity().trippy) { @@ -5111,24 +5111,24 @@ namespace CalamityMod.NPCs Main.spriteBatch.Draw(Main.npcTexture[npc.type], new Vector2(position9.X - Main.screenPosition.X + npc.width / 2 - Main.npcTexture[npc.type].Width * npc.scale / 2f + vector11.X * npc.scale, position9.Y - Main.screenPosition.Y + npc.height - Main.npcTexture[npc.type].Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + vector11.Y * npc.scale + num66 + npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(npc.frame), alpha15, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } - else - { - if (npc.Calamity().vulnerabilityHex > 0) - { - float compactness = npc.width * 0.6f; - if (compactness < 10f) - compactness = 10f; - float power = npc.height / 100f; - if (power > 2.75f) - power = 2.75f; - if (VulnerabilityHexFireDrawer is null || VulnerabilityHexFireDrawer.LocalTimer >= VulnerabilityHexFireDrawer.SetLifetime) - VulnerabilityHexFireDrawer = new FireParticleSet(npc.Calamity().vulnerabilityHex, 1, Color.Red * 1.25f, Color.Red, compactness, power); - else - VulnerabilityHexFireDrawer.DrawSet(npc.Bottom - Vector2.UnitY * (12f - npc.gfxOffY)); - } - else - VulnerabilityHexFireDrawer = null; - } + else + { + if (npc.Calamity().vulnerabilityHex > 0) + { + float compactness = npc.width * 0.6f; + if (compactness < 10f) + compactness = 10f; + float power = npc.height / 100f; + if (power > 2.75f) + power = 2.75f; + if (VulnerabilityHexFireDrawer is null || VulnerabilityHexFireDrawer.LocalTimer >= VulnerabilityHexFireDrawer.SetLifetime) + VulnerabilityHexFireDrawer = new FireParticleSet(npc.Calamity().vulnerabilityHex, 1, Color.Red * 1.25f, Color.Red, compactness, power); + else + VulnerabilityHexFireDrawer.DrawSet(npc.Bottom - Vector2.UnitY * (12f - npc.gfxOffY)); + } + else + VulnerabilityHexFireDrawer = null; + } // Draw a pillar of light and fade the background as an animation when skipping things in the DD2 event. if (npc.type == NPCID.DD2EterniaCrystal) @@ -5158,11 +5158,11 @@ namespace CalamityMod.NPCs } public override void PostDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor) - { - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + { + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { - // His afterimages I can't get to work, so fuck it - if (npc.type == NPCID.SkeletronPrime) + // His afterimages I can't get to work, so fuck it + if (npc.type == NPCID.SkeletronPrime) { Texture2D npcTexture = Main.npcTexture[npc.type]; int frameHeight = npcTexture.Height / Main.npcFrameCount[npc.type]; @@ -5208,294 +5208,294 @@ namespace CalamityMod.NPCs spriteBatch.Draw(Main.BoneEyesTexture, npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), npc.frame, new Color(200, 200, 200, 0), npc.rotation, npc.frame.Size() / 2, npc.scale, spriteEffects, 0f); } - else if (CalamityLists.DestroyerIDs.Contains(npc.type)) - { - if (drawColor != Color.Black) - { - Texture2D npcTexture = Main.npcTexture[npc.type]; - int frameHeight = npcTexture.Height / Main.npcFrameCount[npc.type]; + else if (CalamityLists.DestroyerIDs.Contains(npc.type)) + { + if (drawColor != Color.Black) + { + Texture2D npcTexture = Main.npcTexture[npc.type]; + int frameHeight = npcTexture.Height / Main.npcFrameCount[npc.type]; - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + Vector2 halfSize = npc.frame.Size() / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - if (npc.type == NPCID.TheDestroyerBody) - { - if (npc.ai[2] == 0f) - npc.frame.Y = 0; - else - npc.frame.Y = frameHeight; - } + if (npc.type == NPCID.TheDestroyerBody) + { + if (npc.ai[2] == 0f) + npc.frame.Y = 0; + else + npc.frame.Y = frameHeight; + } - // Draw segments - spriteBatch.Draw(npcTexture, npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), - npc.frame, npc.GetAlpha(drawColor), npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + // Draw segments + spriteBatch.Draw(npcTexture, npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), + npc.frame, npc.GetAlpha(drawColor), npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - // Draw lights - if (npc.ai[2] == 0f) - { - if ((newAI[3] >= 900f && npc.life / (float)npc.lifeMax < 0.5f) || (newAI[1] < 600f && newAI[1] > 60f)) - { - spriteBatch.Draw(Main.destTexture[npc.type - NPCID.TheDestroyer], npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), npc.frame, - new Color(50, 50, 255, 0) * (1f - npc.alpha / 255f), npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - else - { - spriteBatch.Draw(Main.destTexture[npc.type - NPCID.TheDestroyer], npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), npc.frame, - new Color(255, 255, 255, 0) * (1f - npc.alpha / 255f), npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - } - } + // Draw lights + if (npc.ai[2] == 0f) + { + if ((newAI[3] >= 900f && npc.life / (float)npc.lifeMax < 0.5f) || (newAI[1] < 600f && newAI[1] > 60f)) + { + spriteBatch.Draw(Main.destTexture[npc.type - NPCID.TheDestroyer], npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), npc.frame, + new Color(50, 50, 255, 0) * (1f - npc.alpha / 255f), npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + } + else + { + spriteBatch.Draw(Main.destTexture[npc.type - NPCID.TheDestroyer], npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), npc.frame, + new Color(255, 255, 255, 0) * (1f - npc.alpha / 255f), npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + } + } + } + } } - } + } - public override bool? DrawHealthBar(NPC npc, byte hbPosition, ref float scale, ref Vector2 position) - { - if (CalamityWorld.death) - { - switch (npc.type) - { - case NPCID.DiggerHead: - case NPCID.DiggerBody: - case NPCID.DiggerTail: - case NPCID.SeekerHead: - case NPCID.SeekerBody: - case NPCID.SeekerTail: - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - return true; - default: - break; - } - } - return null; - } + public override bool? DrawHealthBar(NPC npc, byte hbPosition, ref float scale, ref Vector2 position) + { + if (CalamityWorld.death) + { + switch (npc.type) + { + case NPCID.DiggerHead: + case NPCID.DiggerBody: + case NPCID.DiggerTail: + case NPCID.SeekerHead: + case NPCID.SeekerBody: + case NPCID.SeekerTail: + case NPCID.DuneSplicerHead: + case NPCID.DuneSplicerBody: + case NPCID.DuneSplicerTail: + return true; + default: + break; + } + } + return null; + } - public static Color buffColor(Color newColor, float R, float G, float B, float A) - { - newColor.R = (byte)((float)newColor.R * R); - newColor.G = (byte)((float)newColor.G * G); - newColor.B = (byte)((float)newColor.B * B); - newColor.A = (byte)((float)newColor.A * A); - return newColor; - } - #endregion + public static Color buffColor(Color newColor, float R, float G, float B, float A) + { + newColor.R = (byte)((float)newColor.R * R); + newColor.G = (byte)((float)newColor.G * G); + newColor.B = (byte)((float)newColor.B * B); + newColor.A = (byte)((float)newColor.A * A); + return newColor; + } + #endregion - #region Any Events - public static bool AnyEvents(Player player) - { - if (Main.invasionType > InvasionID.None) - return true; - if (player.PillarZone()) - return true; - if (DD2Event.Ongoing) - return true; - if ((player.ZoneOverworldHeight || player.ZoneSkyHeight) && (Main.eclipse || Main.bloodMoon || Main.pumpkinMoon || Main.snowMoon)) - return true; - if (CalamityWorld.rainingAcid && player.InSulphur()) - return true; - return false; - } - #endregion + #region Any Events + public static bool AnyEvents(Player player) + { + if (Main.invasionType > InvasionID.None) + return true; + if (player.PillarZone()) + return true; + if (DD2Event.Ongoing) + return true; + if ((player.ZoneOverworldHeight || player.ZoneSkyHeight) && (Main.eclipse || Main.bloodMoon || Main.pumpkinMoon || Main.snowMoon)) + return true; + if (CalamityWorld.rainingAcid && player.InSulphur()) + return true; + return false; + } + #endregion - #region Get Downed Boss Variable - public static bool GetDownedBossVariable(int type) - { - switch (type) - { - case NPCID.KingSlime: - return NPC.downedSlimeKing; + #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.EyeofCthulhu: + return NPC.downedBoss1; - case NPCID.EaterofWorldsHead: - case NPCID.EaterofWorldsBody: - case NPCID.EaterofWorldsTail: - case NPCID.BrainofCthulhu: - case NPCID.Creeper: - return NPC.downedBoss2; + case NPCID.EaterofWorldsHead: + case NPCID.EaterofWorldsBody: + case NPCID.EaterofWorldsTail: + case NPCID.BrainofCthulhu: + case NPCID.Creeper: + return NPC.downedBoss2; - case NPCID.QueenBee: - return NPC.downedQueenBee; + case NPCID.QueenBee: + return NPC.downedQueenBee; - case NPCID.SkeletronHead: - return NPC.downedBoss3; + case NPCID.SkeletronHead: + return NPC.downedBoss3; - case NPCID.WallofFlesh: - case NPCID.WallofFleshEye: - return Main.hardMode; + case NPCID.WallofFlesh: + case NPCID.WallofFleshEye: + return Main.hardMode; - case NPCID.TheDestroyer: - case NPCID.TheDestroyerBody: - case NPCID.TheDestroyerTail: - return NPC.downedMechBoss1; + case NPCID.TheDestroyer: + case NPCID.TheDestroyerBody: + case NPCID.TheDestroyerTail: + return NPC.downedMechBoss1; - case NPCID.Spazmatism: - case NPCID.Retinazer: - return NPC.downedMechBoss2; + case NPCID.Spazmatism: + case NPCID.Retinazer: + return NPC.downedMechBoss2; - case NPCID.SkeletronPrime: - return NPC.downedMechBoss3; + case NPCID.SkeletronPrime: + return NPC.downedMechBoss3; - case NPCID.Plantera: - return NPC.downedPlantBoss; + case NPCID.Plantera: + return NPC.downedPlantBoss; - case NPCID.Golem: - case NPCID.GolemHead: - return NPC.downedGolemBoss; + case NPCID.Golem: + case NPCID.GolemHead: + return NPC.downedGolemBoss; - case NPCID.DukeFishron: - return NPC.downedFishron; + case NPCID.DukeFishron: + return NPC.downedFishron; - case NPCID.CultistBoss: - return NPC.downedAncientCultist; + case NPCID.CultistBoss: + return NPC.downedAncientCultist; - case NPCID.MoonLordCore: - case NPCID.MoonLordHand: - case NPCID.MoonLordHead: - return NPC.downedMoonlord; - } + 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()) - { - 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()) - { - 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()) - { - 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()) - { - 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()) - { - return CalamityWorld.downedDoG; - } - else if (type == NPCType()) - { - return CalamityWorld.downedYharon; - } - else if (type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType()) - { - return CalamityWorld.downedExoMechs; - } - else if (type == NPCType()) - { - return CalamityWorld.downedSCal; - } - else if (type == NPCType()) - { - return CalamityWorld.downedAdultEidolonWyrm; - } + if (type == NPCType() || type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedDesertScourge; + } + else if (type == NPCType()) + { + return CalamityWorld.downedCrabulon; + } + else if (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()) + { + 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()) + { + 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()) + { + 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()) + { + return CalamityWorld.downedDoG; + } + else if (type == NPCType()) + { + return CalamityWorld.downedYharon; + } + else if (type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType()) + { + return CalamityWorld.downedExoMechs; + } + else if (type == NPCType()) + { + return CalamityWorld.downedSCal; + } + else if (type == NPCType()) + { + return CalamityWorld.downedAdultEidolonWyrm; + } - return true; - } - #endregion + return true; + } + #endregion - #region Speedrun Display - public static void SetNewBossJustDowned(NPC npc) - { - if (!GetDownedBossVariable(npc.type)) - { - CalamityLists.bossTypes.TryGetValue(npc.type, out int newBossTypeJustDowned); + #region Speedrun Display + public static void SetNewBossJustDowned(NPC npc) + { + if (!GetDownedBossVariable(npc.type)) + { + CalamityLists.bossTypes.TryGetValue(npc.type, out int newBossTypeJustDowned); - for (int i = 0; i < Main.maxPlayers; i++) - { - Player player = Main.player[i]; - if (!player.active) - continue; + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (!player.active) + continue; - CalamityPlayer mp = player.Calamity(); - mp.lastSplitType = newBossTypeJustDowned; - mp.lastSplit = mp.previousSessionTotal.Add(CalamityMod.SpeedrunTimer.Elapsed); - } - } - } - #endregion + CalamityPlayer mp = player.Calamity(); + mp.lastSplitType = newBossTypeJustDowned; + mp.lastSplit = mp.previousSessionTotal.Add(CalamityMod.SpeedrunTimer.Elapsed); + } + } + } + #endregion - #region Player Counts - public static bool AnyLivingPlayers() + #region Player Counts + public static bool AnyLivingPlayers() { for (int i = 0; i < Main.maxPlayers; i++) { @@ -5507,34 +5507,34 @@ namespace CalamityMod.NPCs return false; } - public static int GetActivePlayerCount() - { - if (Main.netMode == NetmodeID.SinglePlayer) - { - return 1; - } - - int players = 0; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i] != null && Main.player[i].active) - { - players++; - } - } - return players; - } - #endregion - - #region Should Affect NPC - public static bool ShouldAffectNPC(NPC target) + public static int GetActivePlayerCount() { - if (CalamityLists.EaterofWorldsIDs.Contains(target.type) || CalamityLists.DestroyerIDs.Contains(target.type)) - return false; + if (Main.netMode == NetmodeID.SinglePlayer) + { + return 1; + } + + int players = 0; + for (int i = 0; i < Main.maxPlayers; i++) + { + if (Main.player[i] != null && Main.player[i].active) + { + players++; + } + } + return players; + } + #endregion + + #region Should Affect NPC + public static bool ShouldAffectNPC(NPC target) + { + if (CalamityLists.EaterofWorldsIDs.Contains(target.type) || CalamityLists.DestroyerIDs.Contains(target.type)) + return false; if (target.damage > 0 && !target.boss && !target.friendly && !target.dontTakeDamage && target.type != NPCID.Creeper && target.type != NPCType() && target.type != NPCID.MourningWood && target.type != NPCID.Everscream && target.type != NPCID.SantaNK1 && target.type != NPCType() && - target.type != NPCType() && target.type != NPCType() && target.type != NPCType() && target.type != NPCID.GolemFistLeft && target.type != NPCID.GolemFistRight && + target.type != NPCType() && target.type != NPCType() && target.type != NPCType() && target.type != NPCID.GolemFistLeft && target.type != NPCID.GolemFistRight && target.type != NPCType() && target.type != NPCType() && target.type != NPCID.DD2Betsy && !CalamityLists.enemyImmunityList.Contains(target.type) && !AcidRainEvent.AllMinibosses.Contains(target.type)) { return true; @@ -5559,23 +5559,23 @@ namespace CalamityMod.NPCs Projectile projectile = Main.projectile[m]; if (projectile.active && projectile.bobber && projectile.owner == plr) { - if (plr == Main.myPlayer && projectile.ai[0] == 0f) - { - for (int item = 0; item < Main.maxInventory; item++) - { - if (player.inventory[item].type == baitType) - { - player.inventory[item].stack--; - if (player.inventory[item].stack <= 0) - { - player.inventory[item].SetDefaults(0, false); - } - break; - } - } + if (plr == Main.myPlayer && projectile.ai[0] == 0f) + { + for (int item = 0; item < Main.maxInventory; item++) + { + if (player.inventory[item].type == baitType) + { + player.inventory[item].stack--; + if (player.inventory[item].stack <= 0) + { + player.inventory[item].SetDefaults(0, false); + } + break; + } + } - projectile.ai[0] = 2f; - projectile.netUpdate = true; + projectile.ai[0] = 2f; + projectile.netUpdate = true; // The vanilla game uses a special packet for Duke Fishron spawning. // However, this packet doesn't work on modded NPC types, so we must create @@ -5606,7 +5606,7 @@ namespace CalamityMod.NPCs int oldDuke = NPC.NewNPC((int)proj.Center.X, (int)proj.Center.Y + 100, NPCType()); CalamityUtils.BossAwakenMessage(oldDuke); } - else + else { var netMessage = CalamityMod.Instance.GetPacket(); netMessage.Write((byte)CalamityModMessageType.ServersideSpawnOldDuke); @@ -5624,32 +5624,32 @@ namespace CalamityMod.NPCs } } } - #endregion + #endregion - #region Smooth Movement - public static void SmoothMovement(NPC npc, float movementDistanceGateValue, Vector2 distanceFromDestination, float baseVelocity) - { - // Inverse lerp returns the percentage of progress between A and B - float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + #region Smooth Movement + public static void SmoothMovement(NPC npc, float movementDistanceGateValue, Vector2 distanceFromDestination, float baseVelocity) + { + // Inverse lerp returns the percentage of progress between A and B + float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); - // Min velocity - float minVelocity = distanceFromDestination.Length(); - float minVelocityCap = baseVelocity; - if (minVelocity > minVelocityCap) - minVelocity = minVelocityCap; + // Min velocity + float minVelocity = distanceFromDestination.Length(); + float minVelocityCap = baseVelocity; + if (minVelocity > minVelocityCap) + minVelocity = minVelocityCap; - // Max velocity - Vector2 maxVelocity = distanceFromDestination / 24f; - float maxVelocityCap = minVelocityCap * 3f; - if (maxVelocity.Length() > maxVelocityCap) - maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; + // Max velocity + Vector2 maxVelocity = distanceFromDestination / 24f; + float maxVelocityCap = minVelocityCap * 3f; + if (maxVelocity.Length() > maxVelocityCap) + maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; - npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); - } - #endregion + npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); + } + #endregion - #region Astral things - public static void DoHitDust(NPC npc, int hitDirection, int dustType = 5, float xSpeedMult = 1f, int numHitDust = 5, int numDeathDust = 20) + #region Astral things + public static void DoHitDust(NPC npc, int hitDirection, int dustType = 5, float xSpeedMult = 1f, int numHitDust = 5, int numDeathDust = 20) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 75148cf8ca..0a2ea75d99 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -43,16 +43,16 @@ namespace CalamityMod.NPCs if (CalamityWorld.death && !SplittingWormLootBlockWrapper(npc, mod)) return false; - // Do not provide free hearts for certain boss NPCs in Rev+. - if (CalamityWorld.revenge && CalamityLists.heartDropBlockList.Contains(npc.type)) - return false; + // Do not provide free hearts for certain boss NPCs in Rev+. + if (CalamityWorld.revenge && CalamityLists.heartDropBlockList.Contains(npc.type)) + return false; // Block loot from non-boss EoW segments and Creepers, their drops will drop from the Treasure Bag in Rev+. // This is to prevent heart drops until the boss is dead. if (CalamityWorld.revenge) { if (npc.boss && (npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsTail)) - { + { int[] EoWDrops = new int[] { ItemID.DemoniteOre, @@ -92,281 +92,281 @@ namespace CalamityMod.NPCs bool mechLore = !NPC.downedMechBossAny && (lastTwinStanding || npc.type == NPCID.TheDestroyer || npc.type == NPCID.SkeletronPrime); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, mechLore); - if (npc.type == NPCID.KingSlime) - { + if (npc.type == NPCID.KingSlime) + { // Drop a huge spray of Gel items // More gel is not dropped on Expert because he has more minions, which increases the amount of gel provided. int minGel = 72; int maxGel = 100; - DropHelper.DropItemSpray(npc, ItemID.Gel, minGel, maxGel, 4); + DropHelper.DropItemSpray(npc, ItemID.Gel, minGel, maxGel, 4); - DropHelper.DropItemCondition(npc, ItemID.RoyalGel, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); + DropHelper.DropItemCondition(npc, ItemID.RoyalGel, true, !Main.expertMode); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedSlimeKing); - SetNewShopVariable(new int[] { NPCID.Dryad }, NPC.downedSlimeKing); - SetNewBossJustDowned(npc); - } - else if (npc.type == NPCID.EyeofCthulhu) - { - DropHelper.DropItemCondition(npc, ItemID.EoCShield, true, !Main.expertMode); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedSlimeKing); + SetNewShopVariable(new int[] { NPCID.Dryad }, NPC.downedSlimeKing); + SetNewBossJustDowned(npc); + } + else if (npc.type == NPCID.EyeofCthulhu) + { + DropHelper.DropItemCondition(npc, ItemID.EoCShield, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, DropHelper.NormalWeaponDropRateFloat); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, DropHelper.NormalWeaponDropRateFloat); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedBoss1); - SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.Dryad, NPCID.Demolitionist }, NPC.downedBoss1); - SetNewBossJustDowned(npc); - } - else if ((npc.boss && (npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsTail)) || npc.type == NPCID.BrainofCthulhu) - { - DropHelper.DropItemCondition(npc, npc.type == NPCID.BrainofCthulhu ? ItemID.BrainOfConfusion : ItemID.WormScarf, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !WorldGen.crimson && !NPC.downedBoss2); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !WorldGen.crimson && !NPC.downedBoss2); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, WorldGen.crimson && !NPC.downedBoss2); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, WorldGen.crimson && !NPC.downedBoss2); - SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.ArmsDealer, NPCID.Dryad, NPCID.Demolitionist }, NPC.downedBoss2); - SetNewBossJustDowned(npc); - } - else if (npc.type == NPCID.QueenBee) - { - // Drop weapons Calamity style instead of mutually exclusive. - if (!Main.expertMode) - { - int[] queenBeeWeapons = new int[] - { - ItemID.BeeKeeper, - ItemID.BeesKnees, - ItemID.BeeGun - }; - // It's already 33.33% in vanilla normal, so we shouldn't lower the drop rate to 25% - DropHelper.DropEntireSet(npc, DropHelper.BagWeaponDropRateFloat, queenBeeWeapons); - DropHelper.BlockDrops(queenBeeWeapons); - } + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedBoss1); + SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.Dryad, NPCID.Demolitionist }, NPC.downedBoss1); + SetNewBossJustDowned(npc); + } + else if ((npc.boss && (npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsTail)) || npc.type == NPCID.BrainofCthulhu) + { + DropHelper.DropItemCondition(npc, npc.type == NPCID.BrainofCthulhu ? ItemID.BrainOfConfusion : ItemID.WormScarf, true, !Main.expertMode); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !WorldGen.crimson && !NPC.downedBoss2); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !WorldGen.crimson && !NPC.downedBoss2); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, WorldGen.crimson && !NPC.downedBoss2); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, WorldGen.crimson && !NPC.downedBoss2); + SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.ArmsDealer, NPCID.Dryad, NPCID.Demolitionist }, NPC.downedBoss2); + SetNewBossJustDowned(npc); + } + else if (npc.type == NPCID.QueenBee) + { + // Drop weapons Calamity style instead of mutually exclusive. + if (!Main.expertMode) + { + int[] queenBeeWeapons = new int[] + { + ItemID.BeeKeeper, + ItemID.BeesKnees, + ItemID.BeeGun + }; + // It's already 33.33% in vanilla normal, so we shouldn't lower the drop rate to 25% + DropHelper.DropEntireSet(npc, DropHelper.BagWeaponDropRateFloat, queenBeeWeapons); + DropHelper.BlockDrops(queenBeeWeapons); + } - DropHelper.DropItemCondition(npc, ItemID.HiveBackpack, true, !Main.expertMode); + DropHelper.DropItemCondition(npc, ItemID.HiveBackpack, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); - DropHelper.DropItemCondition(npc, ItemID.Stinger, !Main.expertMode, 5, 10); // Extra stingers - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 30, 50); + DropHelper.DropItemCondition(npc, ItemID.Stinger, !Main.expertMode, 5, 10); // Extra stingers + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 30, 50); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedQueenBee); - SetNewShopVariable(new int[] { NPCID.ArmsDealer, NPCID.Dryad }, NPC.downedQueenBee); - SetNewBossJustDowned(npc); - } - else if (npc.type == NPCID.SkeletronHead) - { - DropHelper.DropItemSpray(npc, ItemID.Bone, 70, 100, 5); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedQueenBee); + SetNewShopVariable(new int[] { NPCID.ArmsDealer, NPCID.Dryad }, NPC.downedQueenBee); + SetNewBossJustDowned(npc); + } + else if (npc.type == NPCID.SkeletronHead) + { + DropHelper.DropItemSpray(npc, ItemID.Bone, 70, 100, 5); - DropHelper.DropItemCondition(npc, ItemID.BoneGlove, true, !Main.expertMode); + DropHelper.DropItemCondition(npc, ItemID.BoneGlove, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedBoss3); - SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.Dryad, NPCID.Demolitionist }, NPC.downedBoss3); - SetNewBossJustDowned(npc); - } - else if (npc.type == NPCID.WallofFlesh) - { - if (!Main.expertMode) - { - // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. - int[] wofWeapons = new int[] - { - ItemID.BreakerBlade, - ItemID.ClockworkAssaultRifle, - ModContent.ItemType(), - ItemID.LaserRifle, - ModContent.ItemType(), - ModContent.ItemType() - }; - DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, wofWeapons); - DropHelper.BlockDrops(wofWeapons); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedBoss3); + SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.Dryad, NPCID.Demolitionist }, NPC.downedBoss3); + SetNewBossJustDowned(npc); + } + else if (npc.type == NPCID.WallofFlesh) + { + if (!Main.expertMode) + { + // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. + int[] wofWeapons = new int[] + { + ItemID.BreakerBlade, + ItemID.ClockworkAssaultRifle, + ModContent.ItemType(), + ItemID.LaserRifle, + ModContent.ItemType(), + ModContent.ItemType() + }; + DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, wofWeapons); + DropHelper.BlockDrops(wofWeapons); // Drop emblems Calamity style instead of mutually exclusive -- this includes the Rogue Emblem. int[] emblems = new int[] - { - ItemID.WarriorEmblem, - ItemID.RangerEmblem, - ItemID.SorcererEmblem, - ItemID.SummonerEmblem, - ModContent.ItemType(), - }; - DropHelper.DropEntireSet(npc, 0.25f, emblems); - DropHelper.BlockDrops(emblems); - } + { + ItemID.WarriorEmblem, + ItemID.RangerEmblem, + ItemID.SorcererEmblem, + ItemID.SummonerEmblem, + ModContent.ItemType(), + }; + DropHelper.DropEntireSet(npc, 0.25f, emblems); + DropHelper.BlockDrops(emblems); + } DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); // Drop Hermit's Box directly for EACH player, regardles of Expert or not. 100% chance on first kill, 10% chance afterwards. float hermitBoxChance = Main.hardMode ? 1f : 0.1f; - DropHelper.DropItemChance(npc, ModContent.ItemType(), true, hermitBoxChance); + DropHelper.DropItemChance(npc, ModContent.ItemType(), true, hermitBoxChance); - DropHelper.DropItemFromSetChance(npc, DropHelper.BagWeaponDropRateFloat, ItemID.CorruptionKey, ItemID.CrimsonKey); + DropHelper.DropItemFromSetChance(npc, DropHelper.BagWeaponDropRateFloat, ItemID.CorruptionKey, ItemID.CrimsonKey); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !Main.hardMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !Main.hardMode); - SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.ArmsDealer, NPCID.Dryad, NPCID.Painter, NPCID.WitchDoctor, NPCID.Stylist, NPCID.DyeTrader, NPCID.Demolitionist, NPCID.PartyGirl, NPCID.Clothier, NPCID.SkeletonMerchant, ModContent.NPCType() }, Main.hardMode); - SetNewBossJustDowned(npc); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !Main.hardMode); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !Main.hardMode); + SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.ArmsDealer, NPCID.Dryad, NPCID.Painter, NPCID.WitchDoctor, NPCID.Stylist, NPCID.DyeTrader, NPCID.Demolitionist, NPCID.PartyGirl, NPCID.Clothier, NPCID.SkeletonMerchant, ModContent.NPCType() }, Main.hardMode); + SetNewBossJustDowned(npc); - // First kill text (this is not a loot function) - if (!Main.hardMode) - { - // Increase altar count to allow natural mech boss spawning. - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) - WorldGen.altarCount++; + // First kill text (this is not a loot function) + if (!Main.hardMode) + { + // Increase altar count to allow natural mech boss spawning. + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) + WorldGen.altarCount++; - string key2 = "Mods.CalamityMod.UglyBossText"; - Color messageColor2 = Color.Aquamarine; - CalamityUtils.DisplayLocalizedText(key2, messageColor2); + string key2 = "Mods.CalamityMod.UglyBossText"; + Color messageColor2 = Color.Aquamarine; + CalamityUtils.DisplayLocalizedText(key2, messageColor2); - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) - { - string key3 = "Mods.CalamityMod.HardmodeOreTier1Text"; - Color messageColor3 = new Color(50, 255, 130); + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) + { + string key3 = "Mods.CalamityMod.HardmodeOreTier1Text"; + Color messageColor3 = new Color(50, 255, 130); CalamityUtils.SpawnOre(TileID.Cobalt, 12E-05, 0.4f, 0.6f, 3, 8); - CalamityUtils.SpawnOre(TileID.Palladium, 12E-05, 0.4f, 0.6f, 3, 8); - CalamityUtils.DisplayLocalizedText(key3, messageColor3); - } - } - } - else if (lastTwinStanding) - { - // Only drop hallowed bars after all mechs are down - if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) - DropHelper.BlockDrops(ItemID.HallowedBar); + CalamityUtils.SpawnOre(TileID.Palladium, 12E-05, 0.4f, 0.6f, 3, 8); + CalamityUtils.DisplayLocalizedText(key3, messageColor3); + } + } + } + else if (lastTwinStanding) + { + // Only drop hallowed bars after all mechs are down + if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) + DropHelper.BlockDrops(ItemID.HallowedBar); - DropHelper.DropItemCondition(npc, ItemID.MechanicalWheelPiece, true, !Main.expertMode); + DropHelper.DropItemCondition(npc, ItemID.MechanicalWheelPiece, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedMechBoss2); - SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); - SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || NPC.downedMechBoss2 || !NPC.downedMechBoss3); - SetNewBossJustDowned(npc); + SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); + SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || NPC.downedMechBoss2 || !NPC.downedMechBoss3); + SetNewBossJustDowned(npc); - if (!NPC.downedMechBoss2 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) - SpawnMechBossHardmodeOres(); - } - else if (npc.type == NPCID.TheDestroyer) - { - // Only drop hallowed bars after all mechs are down - if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) - DropHelper.BlockDrops(ItemID.HallowedBar); + if (!NPC.downedMechBoss2 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) + SpawnMechBossHardmodeOres(); + } + else if (npc.type == NPCID.TheDestroyer) + { + // Only drop hallowed bars after all mechs are down + if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) + DropHelper.BlockDrops(ItemID.HallowedBar); - DropHelper.DropItemCondition(npc, ItemID.MechanicalWagonPiece, true, !Main.expertMode); + DropHelper.DropItemCondition(npc, ItemID.MechanicalWagonPiece, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedMechBoss1); - SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); - SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3); - SetNewBossJustDowned(npc); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedMechBoss1); + SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); + SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3); + SetNewBossJustDowned(npc); - if (!NPC.downedMechBoss1 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) - SpawnMechBossHardmodeOres(); - } - else if (npc.type == NPCID.SkeletronPrime) - { - // Only drop hallowed bars after all mechs are down - if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) - DropHelper.BlockDrops(ItemID.HallowedBar); + if (!NPC.downedMechBoss1 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) + SpawnMechBossHardmodeOres(); + } + else if (npc.type == NPCID.SkeletronPrime) + { + // Only drop hallowed bars after all mechs are down + if ((!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3) && CalamityConfig.Instance.EarlyHardmodeProgressionRework) + DropHelper.BlockDrops(ItemID.HallowedBar); - DropHelper.DropItemCondition(npc, ItemID.MechanicalBatteryPiece, true, !Main.expertMode); + DropHelper.DropItemCondition(npc, ItemID.MechanicalBatteryPiece, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, DraedonMayhem, 8, 16); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedMechBoss3); - SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); - SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || !NPC.downedMechBoss2 || NPC.downedMechBoss3); - SetNewBossJustDowned(npc); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedMechBoss3); + SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); + SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || !NPC.downedMechBoss2 || NPC.downedMechBoss3); + SetNewBossJustDowned(npc); - if (!NPC.downedMechBoss3 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) - SpawnMechBossHardmodeOres(); - } - else if (npc.type == NPCID.Plantera) - { - // Drop weapons Calamity style instead of mutually exclusive. - if (!Main.expertMode) - { - int[] planteraWeapons = new int[] - { - ItemID.FlowerPow, - ItemID.Seedler, - ItemID.GrenadeLauncher, - ItemID.VenusMagnum, - ItemID.LeafBlower, - ItemID.NettleBurst, - ItemID.WaspGun, - ModContent.ItemType() - }; - DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, planteraWeapons); - DropHelper.BlockDrops(planteraWeapons); + if (!NPC.downedMechBoss3 && CalamityConfig.Instance.EarlyHardmodeProgressionRework) + SpawnMechBossHardmodeOres(); + } + else if (npc.type == NPCID.Plantera) + { + // Drop weapons Calamity style instead of mutually exclusive. + if (!Main.expertMode) + { + int[] planteraWeapons = new int[] + { + ItemID.FlowerPow, + ItemID.Seedler, + ItemID.GrenadeLauncher, + ItemID.VenusMagnum, + ItemID.LeafBlower, + ItemID.NettleBurst, + ItemID.WaspGun, + ModContent.ItemType() + }; + DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, planteraWeapons); + DropHelper.BlockDrops(planteraWeapons); } DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); DropHelper.DropItemCondition(npc, ItemID.SporeSac, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 12, 18); - DropHelper.DropItemChance(npc, ItemID.JungleKey, 3); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 12, 18); + DropHelper.DropItemChance(npc, ItemID.JungleKey, 3); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedPlantBoss); - SetNewShopVariable(new int[] { NPCID.WitchDoctor, NPCID.Truffle, ModContent.NPCType(), ModContent.NPCType() }, NPC.downedPlantBoss); - SetNewBossJustDowned(npc); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedPlantBoss); + SetNewShopVariable(new int[] { NPCID.WitchDoctor, NPCID.Truffle, ModContent.NPCType(), ModContent.NPCType() }, NPC.downedPlantBoss); + SetNewBossJustDowned(npc); - // Spawn Perennial Ore if Plantera has never been killed - if (!NPC.downedPlantBoss) - { - string key2 = "Mods.CalamityMod.PlantOreText"; - Color messageColor2 = Color.GreenYellow; - string key3 = "Mods.CalamityMod.SandSharkText3"; - Color messageColor3 = Color.Goldenrod; + // Spawn Perennial Ore if Plantera has never been killed + if (!NPC.downedPlantBoss) + { + string key2 = "Mods.CalamityMod.PlantOreText"; + Color messageColor2 = Color.GreenYellow; + string key3 = "Mods.CalamityMod.SandSharkText3"; + Color messageColor3 = Color.Goldenrod; - CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.5f, 0.7f, 3, 8, TileID.Dirt, TileID.Stone); + CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.5f, 0.7f, 3, 8, TileID.Dirt, TileID.Stone); - CalamityUtils.DisplayLocalizedText(key2, messageColor2); - CalamityUtils.DisplayLocalizedText(key3, messageColor3); - } - } + CalamityUtils.DisplayLocalizedText(key2, messageColor2); + CalamityUtils.DisplayLocalizedText(key3, messageColor3); + } + } - // These event enemies set shop variables and since those depend on downed bools they must be done in PreNPCLoot. - else if (npc.type == NPCID.Everscream) - { - SetNewShopVariable(new int[] { ModContent.NPCType() }, NPC.downedChristmasTree || !NPC.downedChristmasSantank || !NPC.downedChristmasIceQueen); - } - else if (npc.type == NPCID.SantaNK1) - { - SetNewShopVariable(new int[] { ModContent.NPCType() }, !NPC.downedChristmasTree || NPC.downedChristmasSantank || !NPC.downedChristmasIceQueen); - } - else if (npc.type == NPCID.IceQueen) - { - SetNewShopVariable(new int[] { ModContent.NPCType() }, !NPC.downedChristmasTree || !NPC.downedChristmasSantank || NPC.downedChristmasIceQueen); - } + // These event enemies set shop variables and since those depend on downed bools they must be done in PreNPCLoot. + else if (npc.type == NPCID.Everscream) + { + SetNewShopVariable(new int[] { ModContent.NPCType() }, NPC.downedChristmasTree || !NPC.downedChristmasSantank || !NPC.downedChristmasIceQueen); + } + else if (npc.type == NPCID.SantaNK1) + { + SetNewShopVariable(new int[] { ModContent.NPCType() }, !NPC.downedChristmasTree || NPC.downedChristmasSantank || !NPC.downedChristmasIceQueen); + } + else if (npc.type == NPCID.IceQueen) + { + SetNewShopVariable(new int[] { ModContent.NPCType() }, !NPC.downedChristmasTree || !NPC.downedChristmasSantank || NPC.downedChristmasIceQueen); + } - else if (npc.type == NPCID.Golem) - { - // Drop loot Calamity style instead of mutually exclusive. - if (!Main.expertMode) - { - int[] golemItems = new int[] - { - ItemID.GolemFist, - ItemID.PossessedHatchet, - ItemID.Stynger, - ItemID.HeatRay, - ItemID.StaffofEarth, - ItemID.EyeoftheGolem, - ItemID.SunStone - }; - DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, golemItems); - DropHelper.BlockDrops(golemItems); - } + else if (npc.type == NPCID.Golem) + { + // Drop loot Calamity style instead of mutually exclusive. + if (!Main.expertMode) + { + int[] golemItems = new int[] + { + ItemID.GolemFist, + ItemID.PossessedHatchet, + ItemID.Stynger, + ItemID.HeatRay, + ItemID.StaffofEarth, + ItemID.EyeoftheGolem, + ItemID.SunStone + }; + DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, golemItems); + DropHelper.BlockDrops(golemItems); + } DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); @@ -374,125 +374,125 @@ namespace CalamityMod.NPCs // The Golem Treasure Bag is guaranteed to provide a Picksaw if one is not yet in the inventory. DropHelper.DropItemCondition(npc, ItemID.Picksaw, true, !Main.expertMode && !NPC.downedGolemBoss); - DropHelper.DropItemCondition(npc, ItemID.ShinyStone, true, !Main.expertMode); + DropHelper.DropItemCondition(npc, ItemID.ShinyStone, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 5, 10); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 5, 10); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedGolemBoss); - SetNewShopVariable(new int[] { NPCID.ArmsDealer, NPCID.Cyborg, NPCID.Steampunker, NPCID.Wizard, NPCID.WitchDoctor, NPCID.DD2Bartender, ModContent.NPCType(), ModContent.NPCType() }, NPC.downedGolemBoss); - SetNewBossJustDowned(npc); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedGolemBoss); + SetNewShopVariable(new int[] { NPCID.ArmsDealer, NPCID.Cyborg, NPCID.Steampunker, NPCID.Wizard, NPCID.WitchDoctor, NPCID.DD2Bartender, ModContent.NPCType(), ModContent.NPCType() }, NPC.downedGolemBoss); + SetNewBossJustDowned(npc); - // If Golem has never been killed, send a message about the Plague. - if (!NPC.downedGolemBoss) - { - string key = "Mods.CalamityMod.BabyBossText"; - Color messageColor = Color.Lime; + // If Golem has never been killed, send a message about the Plague. + if (!NPC.downedGolemBoss) + { + string key = "Mods.CalamityMod.BabyBossText"; + Color messageColor = Color.Lime; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - } - else if (npc.type == NPCID.DD2Betsy && !CalamityWorld.downedBetsy) - { - // Drop weapons Calamity style instead of mutually exclusive. - if (!Main.expertMode) - { - int[] betsyWeapons = new int[] - { - ItemID.DD2SquireBetsySword, // Flying Dragon + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + } + else if (npc.type == NPCID.DD2Betsy && !CalamityWorld.downedBetsy) + { + // Drop weapons Calamity style instead of mutually exclusive. + if (!Main.expertMode) + { + int[] betsyWeapons = new int[] + { + ItemID.DD2SquireBetsySword, // Flying Dragon ItemID.MonkStaffT3, // Sky Dragon's Fury ItemID.DD2BetsyBow, // Aerial Bane ItemID.ApprenticeStaffT3, // Betsy's Wrath }; - DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, betsyWeapons); - DropHelper.BlockDrops(betsyWeapons); - } + DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, betsyWeapons); + DropHelper.BlockDrops(betsyWeapons); + } - // Mark Betsy as dead (Vanilla does not keep track of her) - CalamityWorld.downedBetsy = true; - CalamityNetcode.SyncWorld(); - } - else if (npc.type == NPCID.DukeFishron) - { - // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. - if (!Main.expertMode) - { - int[] dukeWeapons = new int[] - { - ItemID.Flairon, - ItemID.Tsunami, - ItemID.BubbleGun, - ItemID.RazorbladeTyphoon, - ItemID.TempestStaff, - ItemID.FishronWings, - ModContent.ItemType() - }; - DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, dukeWeapons); - DropHelper.BlockDrops(dukeWeapons); - } + // Mark Betsy as dead (Vanilla does not keep track of her) + CalamityWorld.downedBetsy = true; + CalamityNetcode.SyncWorld(); + } + else if (npc.type == NPCID.DukeFishron) + { + // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. + if (!Main.expertMode) + { + int[] dukeWeapons = new int[] + { + ItemID.Flairon, + ItemID.Tsunami, + ItemID.BubbleGun, + ItemID.RazorbladeTyphoon, + ItemID.TempestStaff, + ItemID.FishronWings, + ModContent.ItemType() + }; + DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, dukeWeapons); + DropHelper.BlockDrops(dukeWeapons); + } DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); DropHelper.DropItemCondition(npc, ItemID.ShrimpyTruffle, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedFishron); - SetNewBossJustDowned(npc); - } - else if (npc.type == NPCID.CultistBoss) - { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedAncientCultist); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, Main.bloodMoon); - SetNewBossJustDowned(npc); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedFishron); + SetNewBossJustDowned(npc); + } + else if (npc.type == NPCID.CultistBoss) + { + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedAncientCultist); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, Main.bloodMoon); + SetNewBossJustDowned(npc); - // Deus text (this is not a loot function) - if (!NPC.downedAncientCultist) - { - string key = "Mods.CalamityMod.DeusText"; - Color messageColor = Color.Gold; + // Deus text (this is not a loot function) + if (!NPC.downedAncientCultist) + { + string key = "Mods.CalamityMod.DeusText"; + Color messageColor = Color.Gold; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - } - else if (npc.type == NPCID.MoonLordCore) - { - // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. - if (!Main.expertMode) - { - int[] moonLordWeapons = new int[] - { - ItemID.Meowmere, - ItemID.StarWrath, - ItemID.Terrarian, - ItemID.FireworksLauncher, // Celebration + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + } + else if (npc.type == NPCID.MoonLordCore) + { + // Drop weapons Calamity style instead of mutually exclusive -- this includes Calamity weapons. + if (!Main.expertMode) + { + int[] moonLordWeapons = new int[] + { + ItemID.Meowmere, + ItemID.StarWrath, + ItemID.Terrarian, + ItemID.FireworksLauncher, // Celebration // ItemID.CelebrationMK2, ItemID.SDMG, - ItemID.LastPrism, - ItemID.LunarFlareBook, - ItemID.MoonlordTurretStaff, // Lunar Portal Staff + ItemID.LastPrism, + ItemID.LunarFlareBook, + ItemID.MoonlordTurretStaff, // Lunar Portal Staff ItemID.RainbowCrystalStaff, - ModContent.ItemType(), - }; - DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, moonLordWeapons); - DropHelper.BlockDrops(moonLordWeapons); - } + ModContent.ItemType(), + }; + DropHelper.DropEntireSet(npc, DropHelper.NormalWeaponDropRateFloat, moonLordWeapons); + DropHelper.BlockDrops(moonLordWeapons); + } - DropHelper.DropItemCondition(npc, ItemID.GravityGlobe, true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ItemID.SuspiciousLookingTentacle, true, !Main.expertMode); + DropHelper.DropItemCondition(npc, ItemID.GravityGlobe, true, !Main.expertMode); + DropHelper.DropItemCondition(npc, ItemID.SuspiciousLookingTentacle, true, !Main.expertMode); - // One Celestial Onion is given to each player individually - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !Main.expertMode); + // One Celestial Onion is given to each player individually + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !Main.expertMode); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedMoonlord); - SetNewShopVariable(new int[] { ModContent.NPCType() }, NPC.downedMoonlord); - SetNewBossJustDowned(npc); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !NPC.downedMoonlord); + SetNewShopVariable(new int[] { ModContent.NPCType() }, NPC.downedMoonlord); + SetNewBossJustDowned(npc); - string key = "Mods.CalamityMod.MoonBossText"; - Color messageColor = Color.Orange; - string key2 = "Mods.CalamityMod.MoonBossText2"; - Color messageColor2 = Color.Violet; - string key3 = "Mods.CalamityMod.ProfanedBossText2"; - Color messageColor3 = Color.Cyan; - string key4 = "Mods.CalamityMod.FutureOreText"; - Color messageColor4 = Color.LightGray; + string key = "Mods.CalamityMod.MoonBossText"; + Color messageColor = Color.Orange; + string key2 = "Mods.CalamityMod.MoonBossText2"; + Color messageColor2 = Color.Violet; + string key3 = "Mods.CalamityMod.ProfanedBossText2"; + Color messageColor3 = Color.Cyan; + string key4 = "Mods.CalamityMod.FutureOreText"; + Color messageColor4 = Color.LightGray; if (!CalamityWorld.HasGeneratedLuminitePlanetoids) { @@ -512,142 +512,142 @@ namespace CalamityMod.NPCs // Spawn Exodium planetoids and send messages about Providence, Bloodstone, Phantoplasm, etc. if ML has not been killed yet if (!NPC.downedMoonlord) - { - CalamityUtils.DisplayLocalizedText(key, messageColor); - CalamityUtils.DisplayLocalizedText(key2, messageColor2); - CalamityUtils.DisplayLocalizedText(key3, messageColor3); - CalamityUtils.DisplayLocalizedText(key4, messageColor4); - } - } - else if (npc.type == NPCID.Clothier) - { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode); - } - else if (npc.type == NPCID.RedDevil) - { - DropHelper.DropItemChance(npc, ItemID.FireFeather, 0.1f); - DropHelper.BlockDrops(ItemID.FireFeather); - } - else if (npc.type == NPCID.Vampire || npc.type == NPCID.VampireBat) - { - DropHelper.DropItemChance(npc, ItemID.MoonStone, 0.15f); - DropHelper.BlockDrops(ItemID.MoonStone); - } - else if (npc.type == NPCID.Werewolf) - { - DropHelper.DropItemChance(npc, ItemID.MoonCharm, 0.05f); - DropHelper.BlockDrops(ItemID.MoonCharm); - } - else if (npc.type == NPCID.Mimic && !npc.SpawnedFromStatue) - { - float w = DropHelper.BagWeaponDropRateFloat; - // Change to NPCID.IceMimic in 1.4 TMod - if (npc.ai[3] == 4f) - { - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(ItemID.Frostbrand, w), - DropHelper.WeightStack(ItemID.IceBow, w), - DropHelper.WeightStack(ItemID.FlowerofFrost, w), - DropHelper.WeightStack(ItemID.ToySled, 0.05f) - ); - } - else - { - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(ItemID.StarCloak, w), - DropHelper.WeightStack(ItemID.CrossNecklace, w), - DropHelper.WeightStack(ItemID.TitanGlove, w), - DropHelper.WeightStack(ItemID.DualHook, w), - DropHelper.WeightStack(ItemID.MagicDagger, w), - DropHelper.WeightStack(ItemID.PhilosophersStone, w) - ); - } + { + CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.DisplayLocalizedText(key2, messageColor2); + CalamityUtils.DisplayLocalizedText(key3, messageColor3); + CalamityUtils.DisplayLocalizedText(key4, messageColor4); + } + } + else if (npc.type == NPCID.Clothier) + { + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode); + } + else if (npc.type == NPCID.RedDevil) + { + DropHelper.DropItemChance(npc, ItemID.FireFeather, 0.1f); + DropHelper.BlockDrops(ItemID.FireFeather); + } + else if (npc.type == NPCID.Vampire || npc.type == NPCID.VampireBat) + { + DropHelper.DropItemChance(npc, ItemID.MoonStone, 0.15f); + DropHelper.BlockDrops(ItemID.MoonStone); + } + else if (npc.type == NPCID.Werewolf) + { + DropHelper.DropItemChance(npc, ItemID.MoonCharm, 0.05f); + DropHelper.BlockDrops(ItemID.MoonCharm); + } + else if (npc.type == NPCID.Mimic && !npc.SpawnedFromStatue) + { + float w = DropHelper.BagWeaponDropRateFloat; + // Change to NPCID.IceMimic in 1.4 TMod + if (npc.ai[3] == 4f) + { + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(ItemID.Frostbrand, w), + DropHelper.WeightStack(ItemID.IceBow, w), + DropHelper.WeightStack(ItemID.FlowerofFrost, w), + DropHelper.WeightStack(ItemID.ToySled, 0.05f) + ); + } + else + { + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(ItemID.StarCloak, w), + DropHelper.WeightStack(ItemID.CrossNecklace, w), + DropHelper.WeightStack(ItemID.TitanGlove, w), + DropHelper.WeightStack(ItemID.DualHook, w), + DropHelper.WeightStack(ItemID.MagicDagger, w), + DropHelper.WeightStack(ItemID.PhilosophersStone, w) + ); + } - int[] mimicDrops = new int[] - { - ItemID.StarCloak, - ItemID.CrossNecklace, - ItemID.TitanGlove, - ItemID.DualHook, - ItemID.MagicDagger, - ItemID.PhilosophersStone, - ItemID.Frostbrand, - ItemID.IceBow, - ItemID.FlowerofFrost, - ItemID.ToySled - }; - DropHelper.BlockDrops(mimicDrops); - } - else if (npc.type == NPCID.Moth) - { - DropHelper.DropItem(npc, ItemID.ButterflyDust); - DropHelper.BlockDrops(ItemID.ButterflyDust); - } - else if (npc.type >= NPCID.RustyArmoredBonesAxe && npc.type <= NPCID.HellArmoredBonesSword) - { - DropHelper.DropItemChance(npc, ItemID.WispinaBottle, 0.005f); - DropHelper.BlockDrops(ItemID.WispinaBottle); - } - else if (npc.type == NPCID.Paladin) - { - DropHelper.DropItemChance(npc, ItemID.PaladinsHammer, 0.15f); - DropHelper.DropItemChance(npc, ItemID.PaladinsShield, 0.2f); + int[] mimicDrops = new int[] + { + ItemID.StarCloak, + ItemID.CrossNecklace, + ItemID.TitanGlove, + ItemID.DualHook, + ItemID.MagicDagger, + ItemID.PhilosophersStone, + ItemID.Frostbrand, + ItemID.IceBow, + ItemID.FlowerofFrost, + ItemID.ToySled + }; + DropHelper.BlockDrops(mimicDrops); + } + else if (npc.type == NPCID.Moth) + { + DropHelper.DropItem(npc, ItemID.ButterflyDust); + DropHelper.BlockDrops(ItemID.ButterflyDust); + } + else if (npc.type >= NPCID.RustyArmoredBonesAxe && npc.type <= NPCID.HellArmoredBonesSword) + { + DropHelper.DropItemChance(npc, ItemID.WispinaBottle, 0.005f); + DropHelper.BlockDrops(ItemID.WispinaBottle); + } + else if (npc.type == NPCID.Paladin) + { + DropHelper.DropItemChance(npc, ItemID.PaladinsHammer, 0.15f); + DropHelper.DropItemChance(npc, ItemID.PaladinsShield, 0.2f); - int[] paladinDrops = new int[] - { - ItemID.PaladinsHammer, - ItemID.PaladinsShield - }; - DropHelper.BlockDrops(paladinDrops); - } - else if (npc.type == NPCID.BoneLee) - { - DropHelper.DropItemChance(npc, ItemID.BlackBelt, 0.25f); - DropHelper.DropItemChance(npc, ItemID.Tabi, 0.25f); + int[] paladinDrops = new int[] + { + ItemID.PaladinsHammer, + ItemID.PaladinsShield + }; + DropHelper.BlockDrops(paladinDrops); + } + else if (npc.type == NPCID.BoneLee) + { + DropHelper.DropItemChance(npc, ItemID.BlackBelt, 0.25f); + DropHelper.DropItemChance(npc, ItemID.Tabi, 0.25f); - int[] boneLeeDrops = new int[] - { - ItemID.BlackBelt, - ItemID.Tabi - }; - DropHelper.BlockDrops(boneLeeDrops); - } + int[] boneLeeDrops = new int[] + { + ItemID.BlackBelt, + ItemID.Tabi + }; + DropHelper.BlockDrops(boneLeeDrops); + } - return true; + return true; } - #endregion + #endregion - #region Spawn Mech Boss Hardmode Ores - private void SpawnMechBossHardmodeOres() - { - if (!NPC.downedMechBossAny) - { - string key = "Mods.CalamityMod.HardmodeOreTier2Text"; - Color messageColor = new Color(50, 255, 130); + #region Spawn Mech Boss Hardmode Ores + private void SpawnMechBossHardmodeOres() + { + if (!NPC.downedMechBossAny) + { + string key = "Mods.CalamityMod.HardmodeOreTier2Text"; + Color messageColor = new Color(50, 255, 130); CalamityUtils.SpawnOre(TileID.Mythril, 12E-05, 0.5f, 0.7f, 3, 8); CalamityUtils.SpawnOre(TileID.Orichalcum, 12E-05, 0.5f, 0.7f, 3, 8); - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) - { - string key = "Mods.CalamityMod.HardmodeOreTier3Text"; - Color messageColor = new Color(50, 255, 130); + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) + { + string key = "Mods.CalamityMod.HardmodeOreTier3Text"; + Color messageColor = new Color(50, 255, 130); CalamityUtils.SpawnOre(TileID.Adamantite, 12E-05, 0.6f, 0.8f, 3, 8); CalamityUtils.SpawnOre(TileID.Titanium, 12E-05, 0.6f, 0.8f, 3, 8); - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - else - { - string key = "Mods.CalamityMod.HardmodeOreTier4Text"; - Color messageColor = new Color(50, 255, 130); - CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.45f, 0.8f, 3, 8, TileID.Pearlstone, TileID.HallowHardenedSand, TileID.HallowSandstone, TileID.HallowedIce); - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - } - #endregion + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + else + { + string key = "Mods.CalamityMod.HardmodeOreTier4Text"; + Color messageColor = new Color(50, 255, 130); + CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.45f, 0.8f, 3, 8, TileID.Pearlstone, TileID.HallowHardenedSand, TileID.HallowSandstone, TileID.HallowedIce); + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + } + #endregion - #region Abyss Loot Cancel - private bool AbyssLootCancel(NPC npc, Mod mod) + #region Abyss Loot Cancel + private bool AbyssLootCancel(NPC npc, Mod mod) { int x = Main.maxTilesX; int y = Main.maxTilesY; @@ -730,10 +730,10 @@ namespace CalamityMod.NPCs return true; } - #endregion + #endregion - #region NPCLoot - public override void NPCLoot(NPC npc) + #region NPCLoot + public override void NPCLoot(NPC npc) { // LATER -- keeping bosses alive lets draedon mayhem continue even after killing mechs // Reset Draedon Mayhem to false if no bosses are alive @@ -917,34 +917,34 @@ namespace CalamityMod.NPCs case NPCID.GiantShelly: case NPCID.GiantShelly2: - float shellDropRate = Main.expertMode ? 0.25f : 0.15f; - DropHelper.DropItemChance(npc, ModContent.ItemType(), shellDropRate); + float shellDropRate = Main.expertMode ? 0.25f : 0.15f; + DropHelper.DropItemChance(npc, ModContent.ItemType(), shellDropRate); break; case NPCID.AnomuraFungus: - float fungalShellDropRate = Main.expertMode ? 0.25f : 0.15f; - DropHelper.DropItemChance(npc, ModContent.ItemType(), fungalShellDropRate); + float fungalShellDropRate = Main.expertMode ? 0.25f : 0.15f; + DropHelper.DropItemChance(npc, ModContent.ItemType(), fungalShellDropRate); break; case NPCID.Crawdad: case NPCID.Crawdad2: - float carapaceDropRate = Main.expertMode ? 0.25f : 0.15f; - DropHelper.DropItemChance(npc, ModContent.ItemType(), carapaceDropRate); + float carapaceDropRate = Main.expertMode ? 0.25f : 0.15f; + DropHelper.DropItemChance(npc, ModContent.ItemType(), carapaceDropRate); break; case NPCID.GreenJellyfish: - float vitalJellyDropRate = Main.expertMode ? 0.25f : 0.15f; - DropHelper.DropItemChance(npc, ModContent.ItemType(), vitalJellyDropRate); + float vitalJellyDropRate = Main.expertMode ? 0.25f : 0.15f; + DropHelper.DropItemChance(npc, ModContent.ItemType(), vitalJellyDropRate); break; case NPCID.PinkJellyfish: - float lifeJellyDropRate = Main.expertMode ? 0.125f : 0.075f; - DropHelper.DropItemChance(npc, ModContent.ItemType(), lifeJellyDropRate); + float lifeJellyDropRate = Main.expertMode ? 0.125f : 0.075f; + DropHelper.DropItemChance(npc, ModContent.ItemType(), lifeJellyDropRate); break; case NPCID.BlueJellyfish: - float manaJellyDropRate = Main.expertMode ? 0.25f : 0.15f; - DropHelper.DropItemChance(npc, ModContent.ItemType(), manaJellyDropRate); + float manaJellyDropRate = Main.expertMode ? 0.25f : 0.15f; + DropHelper.DropItemChance(npc, ModContent.ItemType(), manaJellyDropRate); break; case NPCID.DarkCaster: @@ -1326,6 +1326,6 @@ namespace CalamityMod.NPCs } } } - #endregion - } + #endregion + } } diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index a76d9262cb..e6ab48db33 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -26,1295 +26,1295 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.NPCs { public partial class CalamityGlobalNPC : GlobalNPC - { - #region Town NPC Patreon Name Sets - private const int AnglerVanillaNames = 22; - private static readonly string[] AnglerNames = - { - "Dazren", - }; - private const int ArmsDealerVanillaNames = 24; - private static readonly string[] ArmsDealerNames = - { - "Drifter", - "Finchi", - "Heniek", // <@!363404700445442050> (Kazurgundu#3791) - "Fire", // <@!354362326947856384> (fire#0692) - "Barney Calhoun", // <@!634462901431697410> (Potato Power#6578) - "XiaoEn0426", // <@!440448864772816896> (XiaoEn0426#9157) - }; - private const int ClothierVanillaNames = 25; - private static readonly string[] ClothierNames = - { - "Joeseph Jostar", - }; - private const int CyborgVanillaNames = 22; - private static readonly string[] CyborgNames = - { - "Sylux", // <@!331812782183809025> (Gonk#2451) - }; - private const int DemolitionistVanillaNames = 22; - private static readonly string[] DemolitionistNames = null; - private const int DryadVanillaNames = 21; - private static readonly string[] DryadNames = - { - "Rythmi", - "Izuna", - "Jasmine", // <@!430532867479699456> (phantasmagoria#6777) - "Cybil", // <@!486507232666845185> (Captain Doofus#????) - }; - private const int DyeTraderVanillaNames = 16; - private static readonly string[] DyeTraderNames = null; - private const int GoblinTinkererVanillaNames = 25; - private static readonly string[] GoblinTinkererNames = - { - "Verth", - "Gormer", // <@!287651204924833795> (Picasso's Bean#2819 -- RIP) - "TingFlarg", // <@!185605031716847616> (Smug#7160) - "Driser", // <@!121996994406252544> (Driser#8630) - "Eddie Spaghetti", // <@!466397267407011841> (Eddie Spaghetti#0002) - }; - private const int GuideVanillaNames = 34; - private static readonly string[] GuideNames = - { - "Lapp", - "Ben Shapiro", - "StreakistYT", - "Necroplasmic", - "Devin", - "Woffle", // <@!185980979427540992> (Chipbeam#2268) - "Cameron", // <@!340401981711712258> (CammyWammy#8634) - "Wilbur", // <@!295171926324805634> (ChaosChaos#5979) - }; - private const int MechanicVanillaNames = 24; - private static readonly string[] MechanicNames = - { - "Lilly", - "Daawn", // <@!206162323541458944> (Daawnily#3859) - "Robin", // <@!654737510030639112> (Altzeus#8687) - "Curly", // <@!673092101780668416> (Curly~Brace#4830) - }; - private const int MerchantVanillaNames = 23; - private static readonly string[] MerchantNames = null; - private const int NurseVanillaNames = 24; - private static readonly string[] NurseNames = - { - "Farsni", - }; - private const int PainterVanillaNames = 18; - private static readonly string[] PainterNames = - { - "Picasso", // <@!353316526306361347> (SCONICBOOM#2164 -- for the late Picasso's Bean#2819) - }; - private const int PartyGirlVanillaNames = 17; - private static readonly string[] PartyGirlNames = null; - private const int PirateVanillaNames = 11; - private static readonly string[] PirateNames = - { - "Tyler Van Hook", - }; - private const int SkeletonMerchantVanillaNames = 10; - private static readonly string[] SkeletonMerchantNames = - { - "Sans Undertale", // <@!145379091648872450> (Shayy#5257) - "Papyrus Undertale", // <@!262663471189983242> (Nycro#0001) - }; - private const int SteampunkerVanillaNames = 20; - private static readonly string[] SteampunkerNames = - { - "Vorbis", - "Angel", - }; - private const int StylistVanillaNames = 20; - private static readonly string[] StylistNames = - { - "Amber", // <@!114677116473180169> (Mishiro Usui#1295) - "Faith", // <@!509050283871961123> (Toasty#1007) - "Xsiana", // <@!625780237489143839> (xiana.#0015) - }; - private const int TavernkeepVanillaNames = 16; - private static readonly string[] TavernkeepNames = - { - "Tim Lockwood", // <@!605839945483026434> (Deimelo#0001) - "Sir Samuel Winchester Jenkins Kester II", // <@!107659695749070848> (Ryaegos#1661) - }; - private const int TaxCollectorVanillaNames = 19; - private static readonly string[] TaxCollectorNames = - { - "Emmett", - }; - private const int TravelingMerchantVanillaNames = 13; - private static readonly string[] TravelingMerchantNames = - { - "Stan Pines", - }; - private const int TruffleVanillaNames = 12; - private static readonly string[] TruffleNames = - { - "Aldrimil", // <@!413719640238194689> (Thorioum#2475) - }; - private const int WitchDoctorVanillaNames = 10; - private static readonly string[] WitchDoctorNames = - { - "Sok'ar", - "Toxin", // <@!348174404984766465> (Toxin#9598), - "Mixcoatl", // <@!284775927294984203> (SharZz#7777) - "Khatunz", // <@!303022375191183360> (jackshiz#7839) - }; - private const int WizardVanillaNames = 22; - private static readonly string[] WizardNames = - { - "Mage One-Trick", - "Inorim, son of Ivukey", - "Jensen", - "Merasmus", // <@!288066987819663360> (Spider pee pee#3328) - "Habolo", // <@!163028025494077441> (ChristmasGoat#7810) - "Ortho", // <@!264984390910738432> (Worcuus#5225) - "Chris Tallballs", // <@!770211589076418571> (Bewearium#1111) - }; - #endregion - - #region Town NPC Names - public static void ResetTownNPCNameBools() - { - void ResetName(int npcID, ref bool nameBool) - { - if (NPC.FindFirstNPC(npcID) == -1) - nameBool = false; - } - - ResetName(NPCID.Angler, ref CalamityWorld.anglerName); - ResetName(NPCID.ArmsDealer, ref CalamityWorld.armsDealerName); - ResetName(NPCID.Clothier, ref CalamityWorld.clothierName); - ResetName(NPCID.Cyborg, ref CalamityWorld.cyborgName); - ResetName(NPCID.Demolitionist, ref CalamityWorld.demolitionistName); - ResetName(NPCID.Dryad, ref CalamityWorld.dryadName); - ResetName(NPCID.DyeTrader, ref CalamityWorld.dyeTraderName); - ResetName(NPCID.GoblinTinkerer, ref CalamityWorld.goblinTinkererName); - ResetName(NPCID.Guide, ref CalamityWorld.guideName); - ResetName(NPCID.Mechanic, ref CalamityWorld.mechanicName); - ResetName(NPCID.Merchant, ref CalamityWorld.merchantName); - ResetName(NPCID.Nurse, ref CalamityWorld.nurseName); - ResetName(NPCID.Painter, ref CalamityWorld.painterName); - ResetName(NPCID.PartyGirl, ref CalamityWorld.partyGirlName); - ResetName(NPCID.Pirate, ref CalamityWorld.pirateName); - ResetName(NPCID.SkeletonMerchant, ref CalamityWorld.skeletonMerchantName); - ResetName(NPCID.Steampunker, ref CalamityWorld.steampunkerName); - ResetName(NPCID.Stylist, ref CalamityWorld.stylistName); - ResetName(NPCID.DD2Bartender, ref CalamityWorld.tavernkeepName); - ResetName(NPCID.TaxCollector, ref CalamityWorld.taxCollectorName); - ResetName(NPCID.TravellingMerchant, ref CalamityWorld.travelingMerchantName); - ResetName(NPCID.Truffle, ref CalamityWorld.truffleName); - ResetName(NPCID.WitchDoctor, ref CalamityWorld.witchDoctorName); - ResetName(NPCID.Wizard, ref CalamityWorld.wizardName); - } - - // Annoyingly, because npc.GivenName is a property, it can't be passed as a ref parameter. - private string ChooseName(ref bool alreadySet, string currentName, int numVanillaNames, string[] patreonNames) - { - if (alreadySet || patreonNames is null || patreonNames.Length == 0) - { - alreadySet = true; - return currentName; - } - - alreadySet = true; - int index = Main.rand.Next(numVanillaNames + patreonNames.Length); - - // If the roll isn't low enough, then a "vanilla name" was picked, meaning we change nothing. - if (index >= patreonNames.Length) - return currentName; - - // Change the name to be a randomly selected Patreon name if the roll is low enough. - return patreonNames[index]; - } - - public void SetPatreonTownNPCName(NPC npc, Mod mod) - { - if (setNewName) - { - setNewName = false; - switch (npc.type) - { - case NPCID.Angler: - npc.GivenName = ChooseName(ref CalamityWorld.anglerName, npc.GivenName, AnglerVanillaNames, AnglerNames); - break; - case NPCID.ArmsDealer: - npc.GivenName = ChooseName(ref CalamityWorld.armsDealerName, npc.GivenName, ArmsDealerVanillaNames, ArmsDealerNames); - break; - case NPCID.Clothier: - npc.GivenName = ChooseName(ref CalamityWorld.clothierName, npc.GivenName, ClothierVanillaNames, ClothierNames); - break; - case NPCID.Cyborg: - npc.GivenName = ChooseName(ref CalamityWorld.cyborgName, npc.GivenName, CyborgVanillaNames, CyborgNames); - break; - case NPCID.Demolitionist: - npc.GivenName = ChooseName(ref CalamityWorld.demolitionistName, npc.GivenName, DemolitionistVanillaNames, DemolitionistNames); - break; - case NPCID.Dryad: - npc.GivenName = ChooseName(ref CalamityWorld.dryadName, npc.GivenName, DryadVanillaNames, DryadNames); - break; - case NPCID.DyeTrader: - npc.GivenName = ChooseName(ref CalamityWorld.dyeTraderName, npc.GivenName, DyeTraderVanillaNames, DyeTraderNames); - break; - case NPCID.GoblinTinkerer: - npc.GivenName = ChooseName(ref CalamityWorld.goblinTinkererName, npc.GivenName, GoblinTinkererVanillaNames, GoblinTinkererNames); - break; - case NPCID.Guide: - npc.GivenName = ChooseName(ref CalamityWorld.guideName, npc.GivenName, GuideVanillaNames, GuideNames); - break; - case NPCID.Mechanic: - npc.GivenName = ChooseName(ref CalamityWorld.mechanicName, npc.GivenName, MechanicVanillaNames, MechanicNames); - break; - case NPCID.Merchant: - npc.GivenName = ChooseName(ref CalamityWorld.merchantName, npc.GivenName, MerchantVanillaNames, MerchantNames); - break; - case NPCID.Nurse: - npc.GivenName = ChooseName(ref CalamityWorld.nurseName, npc.GivenName, NurseVanillaNames, NurseNames); - break; - case NPCID.Painter: - npc.GivenName = ChooseName(ref CalamityWorld.painterName, npc.GivenName, PainterVanillaNames, PainterNames); - break; - case NPCID.PartyGirl: - npc.GivenName = ChooseName(ref CalamityWorld.partyGirlName, npc.GivenName, PartyGirlVanillaNames, PartyGirlNames); - break; - case NPCID.Pirate: - npc.GivenName = ChooseName(ref CalamityWorld.pirateName, npc.GivenName, PirateVanillaNames, PirateNames); - break; - case NPCID.SkeletonMerchant: - npc.GivenName = ChooseName(ref CalamityWorld.skeletonMerchantName, npc.GivenName, SkeletonMerchantVanillaNames, SkeletonMerchantNames); - break; - case NPCID.Steampunker: - npc.GivenName = ChooseName(ref CalamityWorld.steampunkerName, npc.GivenName, SteampunkerVanillaNames, SteampunkerNames); - break; - case NPCID.Stylist: - npc.GivenName = ChooseName(ref CalamityWorld.stylistName, npc.GivenName, StylistVanillaNames, StylistNames); - break; - case NPCID.DD2Bartender: // Tavernkeep - npc.GivenName = ChooseName(ref CalamityWorld.tavernkeepName, npc.GivenName, TavernkeepVanillaNames, TavernkeepNames); - break; - case NPCID.TaxCollector: - npc.GivenName = ChooseName(ref CalamityWorld.taxCollectorName, npc.GivenName, TaxCollectorVanillaNames, TaxCollectorNames); - break; - case NPCID.TravellingMerchant: - npc.GivenName = ChooseName(ref CalamityWorld.travelingMerchantName, npc.GivenName, TravelingMerchantVanillaNames, TravelingMerchantNames); - break; - case NPCID.Truffle: - npc.GivenName = ChooseName(ref CalamityWorld.truffleName, npc.GivenName, TruffleVanillaNames, TruffleNames); - break; - case NPCID.WitchDoctor: - npc.GivenName = ChooseName(ref CalamityWorld.witchDoctorName, npc.GivenName, WitchDoctorVanillaNames, WitchDoctorNames); - break; - case NPCID.Wizard: - npc.GivenName = ChooseName(ref CalamityWorld.wizardName, npc.GivenName, WizardVanillaNames, WizardNames); - break; - default: - break; - } - } - } - #endregion - - #region NPC New Shop Alert - public void TownNPCAlertSystem(NPC npc, Mod mod, SpriteBatch spriteBatch) - { - if (CalamityConfig.Instance.ShopNewAlert && npc.townNPC) - { - if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newPermafrostInventory) - { - DrawNewInventoryAlert(npc); - } - else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newCirrusInventory) - { - DrawNewInventoryAlert(npc); - } - else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newAmidiasInventory) - { - DrawNewInventoryAlert(npc); - } - else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newBanditInventory) - { - DrawNewInventoryAlert(npc); - } - else - { - switch (npc.type) - { - case NPCID.Merchant: - if (Main.LocalPlayer.Calamity().newMerchantInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Painter: - if (Main.LocalPlayer.Calamity().newPainterInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.DyeTrader: - if (Main.LocalPlayer.Calamity().newDyeTraderInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.PartyGirl: - if (Main.LocalPlayer.Calamity().newPartyGirlInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Stylist: - if (Main.LocalPlayer.Calamity().newStylistInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Demolitionist: - if (Main.LocalPlayer.Calamity().newDemolitionistInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Dryad: - if (Main.LocalPlayer.Calamity().newDryadInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.DD2Bartender: - if (Main.LocalPlayer.Calamity().newTavernkeepInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.ArmsDealer: - if (Main.LocalPlayer.Calamity().newArmsDealerInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.GoblinTinkerer: - if (Main.LocalPlayer.Calamity().newGoblinTinkererInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.WitchDoctor: - if (Main.LocalPlayer.Calamity().newWitchDoctorInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Clothier: - if (Main.LocalPlayer.Calamity().newClothierInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Mechanic: - if (Main.LocalPlayer.Calamity().newMechanicInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Pirate: - if (Main.LocalPlayer.Calamity().newPirateInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Truffle: - if (Main.LocalPlayer.Calamity().newTruffleInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Wizard: - if (Main.LocalPlayer.Calamity().newWizardInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Steampunker: - if (Main.LocalPlayer.Calamity().newSteampunkerInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.Cyborg: - if (Main.LocalPlayer.Calamity().newCyborgInventory) - DrawNewInventoryAlert(npc); - break; - case NPCID.SkeletonMerchant: - if (Main.LocalPlayer.Calamity().newSkeletonMerchantInventory) - DrawNewInventoryAlert(npc); - break; - default: - break; - } - } - - void DrawNewInventoryAlert(NPC npc2) - { - // The position where the display is drawn - Vector2 drawPos = npc2.Center - Main.screenPosition; - - // The height of a single frame of the npc - float npcHeight = (float)(Main.npcTexture[npc2.type].Height / Main.npcFrameCount[npc2.type] / 2) * npc2.scale; - - // Offset the debuff display based on the npc's graphical offset, and 16 units, to create some space between the sprite and the display - float drawPosY = npcHeight + npc.gfxOffY + 36f; - - // Texture animation variables - Texture2D texture = GetTexture("CalamityMod/ExtraTextures/UI/NPCAlertDisplay"); - shopAlertAnimTimer++; - if (shopAlertAnimTimer >= 6) - { - shopAlertAnimTimer = 0; - - shopAlertAnimFrame++; - if (shopAlertAnimFrame > 4) - shopAlertAnimFrame = 0; - } - int frameHeight = texture.Height / 5; - Rectangle animRect = new Rectangle(0, frameHeight * shopAlertAnimFrame, texture.Width, frameHeight); - - spriteBatch.Draw(texture, drawPos - new Vector2(5f, drawPosY), animRect, Color.White, 0f, default, 1f, SpriteEffects.None, 0f); - } - } - } - - public override void OnChatButtonClicked(NPC npc, bool firstButton) - { - if (npc.townNPC) - { - switch (npc.type) - { - case NPCID.Merchant: - Main.LocalPlayer.Calamity().newMerchantInventory = false; - break; - case NPCID.Painter: - Main.LocalPlayer.Calamity().newPainterInventory = false; - break; - case NPCID.DyeTrader: - Main.LocalPlayer.Calamity().newDyeTraderInventory = false; - break; - case NPCID.PartyGirl: - Main.LocalPlayer.Calamity().newPartyGirlInventory = false; - break; - case NPCID.Stylist: - Main.LocalPlayer.Calamity().newStylistInventory = false; - break; - case NPCID.Demolitionist: - Main.LocalPlayer.Calamity().newDemolitionistInventory = false; - break; - case NPCID.Dryad: - Main.LocalPlayer.Calamity().newDryadInventory = false; - break; - case NPCID.DD2Bartender: - Main.LocalPlayer.Calamity().newTavernkeepInventory = false; - break; - case NPCID.ArmsDealer: - Main.LocalPlayer.Calamity().newArmsDealerInventory = false; - break; - case NPCID.GoblinTinkerer: - Main.LocalPlayer.Calamity().newGoblinTinkererInventory = false; - break; - case NPCID.WitchDoctor: - Main.LocalPlayer.Calamity().newWitchDoctorInventory = false; - break; - case NPCID.Clothier: - Main.LocalPlayer.Calamity().newClothierInventory = false; - break; - case NPCID.Mechanic: - Main.LocalPlayer.Calamity().newMechanicInventory = false; - break; - case NPCID.Pirate: - Main.LocalPlayer.Calamity().newPirateInventory = false; - break; - case NPCID.Truffle: - Main.LocalPlayer.Calamity().newTruffleInventory = false; - break; - case NPCID.Wizard: - Main.LocalPlayer.Calamity().newWizardInventory = false; - break; - case NPCID.Steampunker: - Main.LocalPlayer.Calamity().newSteampunkerInventory = false; - break; - case NPCID.Cyborg: - Main.LocalPlayer.Calamity().newCyborgInventory = false; - break; - case NPCID.SkeletonMerchant: - Main.LocalPlayer.Calamity().newSkeletonMerchantInventory = false; - break; - default: - break; - } - } - } - - public static void SetNewShopVariable(int[] types, bool alreadySet) - { - if (!alreadySet) - { - for (int i = 0; i < types.Length; i++) - { - if (types[i] == NPCType()) - { - Main.LocalPlayer.Calamity().newPermafrostInventory = true; - } - else if (types[i] == NPCType()) - { - Main.LocalPlayer.Calamity().newCirrusInventory = true; - } - else if (types[i] == NPCType()) - { - Main.LocalPlayer.Calamity().newAmidiasInventory = true; - } - else if (types[i] == NPCType()) - { - Main.LocalPlayer.Calamity().newBanditInventory = true; - } - else - { - switch (types[i]) - { - case NPCID.Merchant: - Main.LocalPlayer.Calamity().newMerchantInventory = true; - break; - case NPCID.Painter: - Main.LocalPlayer.Calamity().newPainterInventory = true; - break; - case NPCID.DyeTrader: - Main.LocalPlayer.Calamity().newDyeTraderInventory = true; - break; - case NPCID.PartyGirl: - Main.LocalPlayer.Calamity().newPartyGirlInventory = true; - break; - case NPCID.Stylist: - Main.LocalPlayer.Calamity().newStylistInventory = true; - break; - case NPCID.Demolitionist: - Main.LocalPlayer.Calamity().newDemolitionistInventory = true; - break; - case NPCID.Dryad: - Main.LocalPlayer.Calamity().newDryadInventory = true; - break; - case NPCID.DD2Bartender: - Main.LocalPlayer.Calamity().newTavernkeepInventory = true; - break; - case NPCID.ArmsDealer: - Main.LocalPlayer.Calamity().newArmsDealerInventory = true; - break; - case NPCID.GoblinTinkerer: - Main.LocalPlayer.Calamity().newGoblinTinkererInventory = true; - break; - case NPCID.WitchDoctor: - Main.LocalPlayer.Calamity().newWitchDoctorInventory = true; - break; - case NPCID.Clothier: - Main.LocalPlayer.Calamity().newClothierInventory = true; - break; - case NPCID.Mechanic: - Main.LocalPlayer.Calamity().newMechanicInventory = true; - break; - case NPCID.Pirate: - Main.LocalPlayer.Calamity().newPirateInventory = true; - break; - case NPCID.Truffle: - Main.LocalPlayer.Calamity().newTruffleInventory = true; - break; - case NPCID.Wizard: - Main.LocalPlayer.Calamity().newWizardInventory = true; - break; - case NPCID.Steampunker: - Main.LocalPlayer.Calamity().newSteampunkerInventory = true; - break; - case NPCID.Cyborg: - Main.LocalPlayer.Calamity().newCyborgInventory = true; - break; - case NPCID.SkeletonMerchant: - Main.LocalPlayer.Calamity().newSkeletonMerchantInventory = true; - break; - default: - break; - } - } - } - } - } - #endregion - - #region NPC Chat - public override void GetChat(NPC npc, ref string chat) + { + #region Town NPC Patreon Name Sets + private const int AnglerVanillaNames = 22; + private static readonly string[] AnglerNames = { - 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) - { - case NPCID.Guide: - if (Main.hardMode) - { - if (Main.rand.NextBool(20)) - { - chat = "Could you be so kind as to, ah... check hell for me...? I left someone I kind of care about down there."; - } - - if (Main.rand.NextBool(20)) - { - chat = "I have this sudden shiver up my spine, like a meteor just fell and thousands of innocent creatures turned into monsters from the stars."; - } - } - - if (Main.rand.NextBool(20) && NPC.downedMoonlord) - { - chat = "The dungeon seems even more restless than usual, watch out for the powerful abominations stirring up in there."; - } - - if (CalamityWorld.downedProvidence) - { - if (Main.rand.NextBool(20)) - { - chat = "Seems like extinguishing that butterfly caused its life to seep into the hallowed areas, try taking a peek there and see what you can find!"; - } - - if (Main.rand.NextBool(20)) - { - chat = "I've heard there is a portal of antimatter absorbing everything it can see in the dungeon, try using the Rune of Kos there!"; - } - } - - break; - case NPCID.Truffle: - if (Main.rand.NextBool(8)) - { - chat = "I don't feel very safe; I think there's pigs following me around and it frightens me."; - } - - 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."; - } - - break; - - case NPCID.Angler: - 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."; - } - - break; - - case NPCID.TravellingMerchant: - 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."; - } - - break; - - case NPCID.SkeletonMerchant: - if (Main.rand.NextBool(5)) - { - chat = "What'dya buyin'?"; - } - - break; - - case NPCID.WitchDoctor: - if (Main.rand.NextBool(8) && Main.LocalPlayer.ZoneJungle) - { - chat = "My home here has an extensive history and a mysterious past. You'll find out quickly just how extensive it is..."; - } - - if (Main.rand.NextBool(8) && Main.LocalPlayer.ZoneJungle && - Main.hardMode && !NPC.downedPlantBoss) - { - chat = "I have unique items if you show me that you have bested the guardian of this jungle."; - } - - if (Main.rand.NextBool(8) && Main.bloodMoon) - { - chat = "This is as good a time as any to pick up the best ingredients for potions."; - } - - break; - - case NPCID.PartyGirl: - if (Main.rand.NextBool(10) && fapsol != -1) - { - chat = "I have a feeling we're going to have absolutely fantastic parties with " + Main.npc[fapsol].GivenName + " around!"; - } - - if (Main.eclipse) - { - if (Main.rand.NextBool(5)) - { - chat = "I think my light display is turning into an accidental bug zapper. At least the monsters are enjoying it."; - } - - if (Main.rand.NextBool(5)) - { - chat = "Ooh! I love parties where everyone wears a scary costume!"; - } - } - - break; - - case NPCID.Painter: - if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneCorrupt) - { - chat = "A little sickness isn't going to stop me from doing my work as an artist!"; - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneCrimson) - { - chat = "There's a surprising art to this area. A sort of horrifying, eldritch feeling. It inspires me!"; - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneSnow) - { - 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?!"; - } - else - { - chat = "I'm not exactly suited for this cold weather. Still looks pretty, though."; - } - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneDesert) - { - chat = "I hate sand. It's coarse, and rough and gets in my paint."; - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneHoly) - { - chat = "Do you think unicorn blood could be used as a good pigment or resin? No I'm not going to find out myself."; - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneSkyHeight) - { - //chat = "I can't breathe." - chat = "I can't work in this environment. All of my paint just floats off."; - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneJungle) - { - chat = "Painting the tortoises in a still life isn't going so well."; - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.Calamity().ZoneAstral) - { - chat = "I can't paint a still life if the fruit grows legs and walks away."; - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneUnderworldHeight) - { - chat = "On the canvas, things get heated around here all the time. Like the environment!"; - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneUnderworldHeight) - { - chat = "Sorry, I'm all out of watercolors. They keep evaporating."; - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.Calamity().ZoneCalamity) - { - chat = "Roses, really? That's such an overrated thing to paint."; - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.Calamity().ZoneSulphur) - { - chat = "Fun fact! Sulphur was used as pigment once upon a time! Or was it Cinnabar?"; - } - if (Main.rand.NextBool(4) && Main.LocalPlayer.Calamity().ZoneAbyss) - { - chat = "Easiest landscape I've ever painted in my life."; - } - break; - - case NPCID.Wizard: - if (Main.rand.NextBool(10) && Main.hardMode) - { - chat = "Space just got way too close for comfort."; - } - - break; - - case NPCID.Dryad: - if (Main.rand.NextBool(5) && CalamityWorld.downedDoG && Main.eclipse) - { - chat = "There's a dark solar energy emanating from the moths that appear during this time. Ah, the moths as you progress further get more powerful... hmm... what power was Yharon holding back?"; - } - - if (Main.rand.NextBool(5) && Main.hardMode) - { - 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(NPCType()) && Main.LocalPlayer.ZoneGlowshroom) - { - chat = Main.npc[fapsol].GivenName + " put me up to this."; - } - - if (Main.rand.NextBool(5) && Main.LocalPlayer.Calamity().ZoneSulphur) - { - chat = "My ancestor was lost here long ago. I must pay my respects to her."; - } - - if (Main.rand.NextBool(5) && Main.LocalPlayer.ZoneGlowshroom) - { - //high iq drugs iirc - chat = "“I'm not here for any reason! Just picking up mushrooms for uh, later use."; - } - - break; - - case NPCID.Stylist: - string worldEvil = WorldGen.crimson ? "Crimson" : "Corruption"; - if (Main.rand.NextBool(15) && Main.hardMode) - { - chat = "Please don't catch space lice. Or " + worldEvil + " lice. Or just lice in general."; - } - - if (fapsol != -1) - { - if (Main.rand.NextBool(15)) - { - chat = "Sometimes I catch " + Main.npc[fapsol].GivenName + " sneaking up from behind me."; - } - - if (Main.rand.NextBool(15)) - { - chat = Main.npc[fapsol].GivenName + " is always trying to brighten my mood... even if, deep down, I know she's sad..."; - } - } - if ((npc.GivenName == "Amber" ? Main.rand.NextBool(10) : Main.rand.NextBool(15)) && Main.LocalPlayer.Calamity().pArtifact) - { - if (Main.LocalPlayer.Calamity().profanedCrystalBuffs) - { - chat = Main.rand.NextBool(2) ? "They look so cute and yet, I can feel their immense power just by being near them. What are you?" : "I hate to break it to you, but you don't have hair to cut or style, hun."; - } - else if (Main.LocalPlayer.Calamity().gDefense && Main.LocalPlayer.Calamity().gOffense) - { - chat = "Aww, they're so cute, do they have names?"; - } - } - break; - - case NPCID.GoblinTinkerer: - if (Main.rand.NextBool(3) && thief != -1 && CalamityWorld.Reforges >= 1) - { - 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) - { - chat = "You know... we haven't had an invasion in a while..."; - } - - break; - - case NPCID.ArmsDealer: - if (Main.rand.NextBool(5) && Main.eclipse) - { - chat = "That's the biggest moth I've ever seen for sure. You'd need one big gun to take one of those down."; - } - - if (Main.rand.NextBool(10) && CalamityWorld.downedDoG) - { - chat = "Is it me or are your weapons getting bigger and bigger?"; - } - - break; - - case NPCID.Merchant: - if (Main.rand.NextBool(5) && NPC.downedMoonlord) - { - chat = "Each night seems only more foreboding than the last. I feel unthinkable terrors are watching your every move."; - } - - if (Main.rand.NextBool(5) && Main.eclipse) - { - chat = "Are you daft?! Turn off those lamps!"; - } - - if (Main.rand.NextBool(5) && Main.raining && Main.LocalPlayer.Calamity().ZoneSulphur) - { - 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: - if (Main.rand.NextBool(5) && NPC.downedMoonlord) - { - chat = "What do you mean your traps aren't making the cut? Don't look at me!"; - } - - if (Main.rand.NextBool(5) && Main.eclipse) - { - chat = "Um... should my nightlight be on?"; - } - - if (Main.rand.NextBool(5) && fapsol != -1) - { - chat = "Well, I like " + Main.npc[fapsol].GivenName + ", but I, ah... I have my eyes on someone else."; - } - - if (Main.rand.NextBool(5) && CalamityWorld.rainingAcid) - { - chat = "Maybe I should've waterproofed my gadgets... They're starting to corrode."; - } - - break; - - case NPCID.DD2Bartender: - if (Main.rand.NextBool(5) && !Main.dayTime && Main.moonPhase == 0) - { - chat = "Care for a little Moonshine?"; - } - - if (Main.rand.NextBool(10) && fapsol != -1) - { - chat = "Sheesh, " + Main.npc[fapsol].GivenName + " is a little cruel, isn't she? I never claimed to be an expert on anything but ale!"; - } - - break; - - case NPCID.Pirate: - if (Main.rand.NextBool(5) && !CalamityWorld.downedLeviathan) - { - chat = "Aye, I've heard of a mythical creature in the oceans, singing with an alluring voice. Careful when yer fishin out there."; - } - - if (Main.rand.NextBool(5) && CalamityWorld.downedAquaticScourge) - { - 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(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(NPCType())) - { - chat = "Twenty-nine bottles of beer on the wall..."; - } - - if (Main.rand.NextBool(5) && Main.LocalPlayer.Center.ToTileCoordinates().X < 380 && !Main.LocalPlayer.Calamity().ZoneSulphur) - { - chat = "Now this is a scene that I can admire any time! I feel like something is watching me though."; - } - - if (Main.rand.NextBool(5) && Main.LocalPlayer.Calamity().ZoneSulphur) - { - chat = "It ain't much of a sight, but there's still life living in these waters."; - } - - if (Main.rand.NextBool(5) && Main.LocalPlayer.Calamity().ZoneSulphur) - { - chat = "Me ship might just sink from the acid alone."; - } - break; - - case NPCID.Cyborg: - if (Main.rand.NextBool(10) && Main.raining) - { - chat = "All these moments will be lost in time. Like tears... in the rain."; - } - - if (NPC.downedMoonlord) - { - if (Main.rand.NextBool(10)) - { - chat = "Always shoot for the moon! It has clearly worked before."; - } - - if (Main.rand.NextBool(10)) - { - chat = "Draedon? He's... a little 'high octane' if you know what I mean."; - } - } - - if (Main.rand.NextBool(10) && !CalamityWorld.downedPlaguebringer && NPC.downedGolemBoss) - { - chat = "Those oversized bugs terrorizing the jungle... Surely you of all people could shut them down!"; - } - - break; - - case NPCID.Clothier: - if (NPC.downedMoonlord) - { - if (Main.rand.NextBool(10)) - { - chat = "Who you gonna call?"; - } - - if (Main.rand.NextBool(10)) - { - chat = "Those screams... I'm not sure why, but I feel like a nameless fear has awoken in my heart."; - } - - if (Main.rand.NextBool(10)) - { - chat = "I can faintly hear ghostly shrieks from the dungeon... and not ones I'm familiar with at all. Just what is going on in there?"; - } - } - - if (Main.rand.NextBool(10) && CalamityWorld.downedPolterghast) - { - chat = "Whatever that thing was, I'm glad it's gone now."; - } - - if (Main.rand.NextBool(5) && NPC.AnyNPCs(NPCID.MoonLordCore)) - { - chat = "Houston, we've had a problem."; - } - - break; - - case NPCID.Steampunker: - bool hasPortalGun = false; - for (int k = 0; k < Main.maxPlayers; k++) - { - Player player = Main.player[k]; - if (player.active && player.HasItem(ItemID.PortalGun)) - { - hasPortalGun = true; - } - } - - if (Main.rand.NextBool(5) && hasPortalGun) - { - chat = "Just what is that contraption? It makes my Teleporters look like child's play!"; - } - - if (Main.rand.NextBool(5) && NPC.downedMoonlord) - { - chat = "Yep! I'm also considering being a space pirate now."; - } - - if (Main.rand.NextBool(5) && Main.LocalPlayer.Calamity().ZoneAstral) - { - chat = "Some of my machines are starting to go haywire thanks to this Astral Infection. I probably shouldn't have built them here"; - } - - if (Main.rand.NextBool(5) && Main.LocalPlayer.ZoneHoly) - { - chat = "I'm sorry I really don't have any Unicorn proof tech here, you're on your own."; - } - - break; - - case NPCID.DyeTrader: - if (Main.rand.NextBool(5)) - { - chat = "Have you seen those gemstone creatures in the caverns? Their colors are simply breathtaking!"; - } - - if (Main.rand.NextBool(5) && permadong != -1) - { - chat = "Do you think " + Main.npc[permadong].GivenName + " knows how to 'let it go?'"; - } - - break; - - case NPCID.TaxCollector: - int platinumCoins = 0; - for (int k = 0; k < Main.maxPlayers; k++) - { - Player player = Main.player[k]; - if (player.active) - { - for (int j = 0; j < player.inventory.Length; j++) - { - if (player.inventory[j].type == ItemID.PlatinumCoin) - { - platinumCoins += player.inventory[j].stack; - } - } - } - } - - if (Main.rand.NextBool(5) && platinumCoins >= 100) - { - chat = "BAH! Doesn't seem like I'll ever be able to quarrel with the debts of the town again!"; - } - - if (Main.rand.NextBool(5) && platinumCoins >= 500) - { - chat = "Where and how are you getting all of this money?"; - } - - if (Main.rand.NextBool(5) && !CalamityWorld.downedBrimstoneElemental) - { - chat = "Perhaps with all that time you've got you could check those old ruins? Certainly something of value in it for you!"; - } - - if (Main.rand.NextBool(10) && CalamityWorld.downedDoG) - { - 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, ItemType())) - { - chat = "Goodness! That cane has swagger!"; - } - - break; - - case NPCID.Demolitionist: - if (Main.rand.NextBool(5) && CalamityWorld.downedDoG) - { - chat = "God Slayer Dynamite? Boy do I like the sound of that!"; - } - - break; - - default: - break; - } - } - #endregion - - #region NPC Stat Changes - public void BoundNPCSafety(Mod mod, NPC npc) - { - // Make Bound Town NPCs take no damage - if (CalamityLists.BoundNPCIDs.Contains(npc.type)) - { - npc.dontTakeDamageFromHostiles = true; - } - } - - public void MakeTownNPCsTakeMoreDamage(NPC npc, Projectile projectile, Mod mod, ref int damage) - { - if (npc.townNPC && projectile.hostile) - damage *= 2; - } - - public override void BuffTownNPC(ref float damageMult, ref int defense) - { - if (NPC.downedMoonlord) - { - damageMult += 0.6f; - defense += 20; - } - if (CalamityWorld.downedProvidence) - { - damageMult += 0.2f; - defense += 12; - } - if (CalamityWorld.downedPolterghast) - { - damageMult += 0.2f; - defense += 12; - } - if (CalamityWorld.downedDoG) - { - damageMult += 0.2f; - defense += 12; - } - if (CalamityWorld.downedYharon) - { - damageMult += 0.2f; - defense += 12; - } - if (CalamityWorld.downedSCal) - { - damageMult += 0.6f; - defense += 20; - } - } - #endregion - - #region Shop Stuff - public override void SetupShop(int type, Chest shop, ref int nextSlot) + "Dazren", + }; + private const int ArmsDealerVanillaNames = 24; + private static readonly string[] ArmsDealerNames = { - int goldCost = NPC.downedMoonlord ? 8 : Main.hardMode ? 4 : 2; + "Drifter", + "Finchi", + "Heniek", // <@!363404700445442050> (Kazurgundu#3791) + "Fire", // <@!354362326947856384> (fire#0692) + "Barney Calhoun", // <@!634462901431697410> (Potato Power#6578) + "XiaoEn0426", // <@!440448864772816896> (XiaoEn0426#9157) + }; + private const int ClothierVanillaNames = 25; + private static readonly string[] ClothierNames = + { + "Joeseph Jostar", + }; + private const int CyborgVanillaNames = 22; + private static readonly string[] CyborgNames = + { + "Sylux", // <@!331812782183809025> (Gonk#2451) + }; + private const int DemolitionistVanillaNames = 22; + private static readonly string[] DemolitionistNames = null; + private const int DryadVanillaNames = 21; + private static readonly string[] DryadNames = + { + "Rythmi", + "Izuna", + "Jasmine", // <@!430532867479699456> (phantasmagoria#6777) + "Cybil", // <@!486507232666845185> (Captain Doofus#????) + }; + private const int DyeTraderVanillaNames = 16; + private static readonly string[] DyeTraderNames = null; + private const int GoblinTinkererVanillaNames = 25; + private static readonly string[] GoblinTinkererNames = + { + "Verth", + "Gormer", // <@!287651204924833795> (Picasso's Bean#2819 -- RIP) + "TingFlarg", // <@!185605031716847616> (Smug#7160) + "Driser", // <@!121996994406252544> (Driser#8630) + "Eddie Spaghetti", // <@!466397267407011841> (Eddie Spaghetti#0002) + }; + private const int GuideVanillaNames = 34; + private static readonly string[] GuideNames = + { + "Lapp", + "Ben Shapiro", + "StreakistYT", + "Necroplasmic", + "Devin", + "Woffle", // <@!185980979427540992> (Chipbeam#2268) + "Cameron", // <@!340401981711712258> (CammyWammy#8634) + "Wilbur", // <@!295171926324805634> (ChaosChaos#5979) + }; + private const int MechanicVanillaNames = 24; + private static readonly string[] MechanicNames = + { + "Lilly", + "Daawn", // <@!206162323541458944> (Daawnily#3859) + "Robin", // <@!654737510030639112> (Altzeus#8687) + "Curly", // <@!673092101780668416> (Curly~Brace#4830) + }; + private const int MerchantVanillaNames = 23; + private static readonly string[] MerchantNames = null; + private const int NurseVanillaNames = 24; + private static readonly string[] NurseNames = + { + "Farsni", + }; + private const int PainterVanillaNames = 18; + private static readonly string[] PainterNames = + { + "Picasso", // <@!353316526306361347> (SCONICBOOM#2164 -- for the late Picasso's Bean#2819) + }; + private const int PartyGirlVanillaNames = 17; + private static readonly string[] PartyGirlNames = null; + private const int PirateVanillaNames = 11; + private static readonly string[] PirateNames = + { + "Tyler Van Hook", + }; + private const int SkeletonMerchantVanillaNames = 10; + private static readonly string[] SkeletonMerchantNames = + { + "Sans Undertale", // <@!145379091648872450> (Shayy#5257) + "Papyrus Undertale", // <@!262663471189983242> (Nycro#0001) + }; + private const int SteampunkerVanillaNames = 20; + private static readonly string[] SteampunkerNames = + { + "Vorbis", + "Angel", + }; + private const int StylistVanillaNames = 20; + private static readonly string[] StylistNames = + { + "Amber", // <@!114677116473180169> (Mishiro Usui#1295) + "Faith", // <@!509050283871961123> (Toasty#1007) + "Xsiana", // <@!625780237489143839> (xiana.#0015) + }; + private const int TavernkeepVanillaNames = 16; + private static readonly string[] TavernkeepNames = + { + "Tim Lockwood", // <@!605839945483026434> (Deimelo#0001) + "Sir Samuel Winchester Jenkins Kester II", // <@!107659695749070848> (Ryaegos#1661) + }; + private const int TaxCollectorVanillaNames = 19; + private static readonly string[] TaxCollectorNames = + { + "Emmett", + }; + private const int TravelingMerchantVanillaNames = 13; + private static readonly string[] TravelingMerchantNames = + { + "Stan Pines", + }; + private const int TruffleVanillaNames = 12; + private static readonly string[] TruffleNames = + { + "Aldrimil", // <@!413719640238194689> (Thorioum#2475) + }; + private const int WitchDoctorVanillaNames = 10; + private static readonly string[] WitchDoctorNames = + { + "Sok'ar", + "Toxin", // <@!348174404984766465> (Toxin#9598), + "Mixcoatl", // <@!284775927294984203> (SharZz#7777) + "Khatunz", // <@!303022375191183360> (jackshiz#7839) + }; + private const int WizardVanillaNames = 22; + private static readonly string[] WizardNames = + { + "Mage One-Trick", + "Inorim, son of Ivukey", + "Jensen", + "Merasmus", // <@!288066987819663360> (Spider pee pee#3328) + "Habolo", // <@!163028025494077441> (ChristmasGoat#7810) + "Ortho", // <@!264984390910738432> (Worcuus#5225) + "Chris Tallballs", // <@!770211589076418571> (Bewearium#1111) + }; + #endregion - if (type == NPCID.Merchant) - { + #region Town NPC Names + public static void ResetTownNPCNameBools() + { + void ResetName(int npcID, ref bool nameBool) + { + if (NPC.FindFirstNPC(npcID) == -1) + nameBool = false; + } + + ResetName(NPCID.Angler, ref CalamityWorld.anglerName); + ResetName(NPCID.ArmsDealer, ref CalamityWorld.armsDealerName); + ResetName(NPCID.Clothier, ref CalamityWorld.clothierName); + ResetName(NPCID.Cyborg, ref CalamityWorld.cyborgName); + ResetName(NPCID.Demolitionist, ref CalamityWorld.demolitionistName); + ResetName(NPCID.Dryad, ref CalamityWorld.dryadName); + ResetName(NPCID.DyeTrader, ref CalamityWorld.dyeTraderName); + ResetName(NPCID.GoblinTinkerer, ref CalamityWorld.goblinTinkererName); + ResetName(NPCID.Guide, ref CalamityWorld.guideName); + ResetName(NPCID.Mechanic, ref CalamityWorld.mechanicName); + ResetName(NPCID.Merchant, ref CalamityWorld.merchantName); + ResetName(NPCID.Nurse, ref CalamityWorld.nurseName); + ResetName(NPCID.Painter, ref CalamityWorld.painterName); + ResetName(NPCID.PartyGirl, ref CalamityWorld.partyGirlName); + ResetName(NPCID.Pirate, ref CalamityWorld.pirateName); + ResetName(NPCID.SkeletonMerchant, ref CalamityWorld.skeletonMerchantName); + ResetName(NPCID.Steampunker, ref CalamityWorld.steampunkerName); + ResetName(NPCID.Stylist, ref CalamityWorld.stylistName); + ResetName(NPCID.DD2Bartender, ref CalamityWorld.tavernkeepName); + ResetName(NPCID.TaxCollector, ref CalamityWorld.taxCollectorName); + ResetName(NPCID.TravellingMerchant, ref CalamityWorld.travelingMerchantName); + ResetName(NPCID.Truffle, ref CalamityWorld.truffleName); + ResetName(NPCID.WitchDoctor, ref CalamityWorld.witchDoctorName); + ResetName(NPCID.Wizard, ref CalamityWorld.wizardName); + } + + // Annoyingly, because npc.GivenName is a property, it can't be passed as a ref parameter. + private string ChooseName(ref bool alreadySet, string currentName, int numVanillaNames, string[] patreonNames) + { + if (alreadySet || patreonNames is null || patreonNames.Length == 0) + { + alreadySet = true; + return currentName; + } + + alreadySet = true; + int index = Main.rand.Next(numVanillaNames + patreonNames.Length); + + // If the roll isn't low enough, then a "vanilla name" was picked, meaning we change nothing. + if (index >= patreonNames.Length) + return currentName; + + // Change the name to be a randomly selected Patreon name if the roll is low enough. + return patreonNames[index]; + } + + public void SetPatreonTownNPCName(NPC npc, Mod mod) + { + if (setNewName) + { + setNewName = false; + switch (npc.type) + { + case NPCID.Angler: + npc.GivenName = ChooseName(ref CalamityWorld.anglerName, npc.GivenName, AnglerVanillaNames, AnglerNames); + break; + case NPCID.ArmsDealer: + npc.GivenName = ChooseName(ref CalamityWorld.armsDealerName, npc.GivenName, ArmsDealerVanillaNames, ArmsDealerNames); + break; + case NPCID.Clothier: + npc.GivenName = ChooseName(ref CalamityWorld.clothierName, npc.GivenName, ClothierVanillaNames, ClothierNames); + break; + case NPCID.Cyborg: + npc.GivenName = ChooseName(ref CalamityWorld.cyborgName, npc.GivenName, CyborgVanillaNames, CyborgNames); + break; + case NPCID.Demolitionist: + npc.GivenName = ChooseName(ref CalamityWorld.demolitionistName, npc.GivenName, DemolitionistVanillaNames, DemolitionistNames); + break; + case NPCID.Dryad: + npc.GivenName = ChooseName(ref CalamityWorld.dryadName, npc.GivenName, DryadVanillaNames, DryadNames); + break; + case NPCID.DyeTrader: + npc.GivenName = ChooseName(ref CalamityWorld.dyeTraderName, npc.GivenName, DyeTraderVanillaNames, DyeTraderNames); + break; + case NPCID.GoblinTinkerer: + npc.GivenName = ChooseName(ref CalamityWorld.goblinTinkererName, npc.GivenName, GoblinTinkererVanillaNames, GoblinTinkererNames); + break; + case NPCID.Guide: + npc.GivenName = ChooseName(ref CalamityWorld.guideName, npc.GivenName, GuideVanillaNames, GuideNames); + break; + case NPCID.Mechanic: + npc.GivenName = ChooseName(ref CalamityWorld.mechanicName, npc.GivenName, MechanicVanillaNames, MechanicNames); + break; + case NPCID.Merchant: + npc.GivenName = ChooseName(ref CalamityWorld.merchantName, npc.GivenName, MerchantVanillaNames, MerchantNames); + break; + case NPCID.Nurse: + npc.GivenName = ChooseName(ref CalamityWorld.nurseName, npc.GivenName, NurseVanillaNames, NurseNames); + break; + case NPCID.Painter: + npc.GivenName = ChooseName(ref CalamityWorld.painterName, npc.GivenName, PainterVanillaNames, PainterNames); + break; + case NPCID.PartyGirl: + npc.GivenName = ChooseName(ref CalamityWorld.partyGirlName, npc.GivenName, PartyGirlVanillaNames, PartyGirlNames); + break; + case NPCID.Pirate: + npc.GivenName = ChooseName(ref CalamityWorld.pirateName, npc.GivenName, PirateVanillaNames, PirateNames); + break; + case NPCID.SkeletonMerchant: + npc.GivenName = ChooseName(ref CalamityWorld.skeletonMerchantName, npc.GivenName, SkeletonMerchantVanillaNames, SkeletonMerchantNames); + break; + case NPCID.Steampunker: + npc.GivenName = ChooseName(ref CalamityWorld.steampunkerName, npc.GivenName, SteampunkerVanillaNames, SteampunkerNames); + break; + case NPCID.Stylist: + npc.GivenName = ChooseName(ref CalamityWorld.stylistName, npc.GivenName, StylistVanillaNames, StylistNames); + break; + case NPCID.DD2Bartender: // Tavernkeep + npc.GivenName = ChooseName(ref CalamityWorld.tavernkeepName, npc.GivenName, TavernkeepVanillaNames, TavernkeepNames); + break; + case NPCID.TaxCollector: + npc.GivenName = ChooseName(ref CalamityWorld.taxCollectorName, npc.GivenName, TaxCollectorVanillaNames, TaxCollectorNames); + break; + case NPCID.TravellingMerchant: + npc.GivenName = ChooseName(ref CalamityWorld.travelingMerchantName, npc.GivenName, TravelingMerchantVanillaNames, TravelingMerchantNames); + break; + case NPCID.Truffle: + npc.GivenName = ChooseName(ref CalamityWorld.truffleName, npc.GivenName, TruffleVanillaNames, TruffleNames); + break; + case NPCID.WitchDoctor: + npc.GivenName = ChooseName(ref CalamityWorld.witchDoctorName, npc.GivenName, WitchDoctorVanillaNames, WitchDoctorNames); + break; + case NPCID.Wizard: + npc.GivenName = ChooseName(ref CalamityWorld.wizardName, npc.GivenName, WizardVanillaNames, WizardNames); + break; + default: + break; + } + } + } + #endregion + + #region NPC New Shop Alert + public void TownNPCAlertSystem(NPC npc, Mod mod, SpriteBatch spriteBatch) + { + if (CalamityConfig.Instance.ShopNewAlert && npc.townNPC) + { + if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newPermafrostInventory) + { + DrawNewInventoryAlert(npc); + } + else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newCirrusInventory) + { + DrawNewInventoryAlert(npc); + } + else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newAmidiasInventory) + { + DrawNewInventoryAlert(npc); + } + else if (npc.type == NPCType() && Main.LocalPlayer.Calamity().newBanditInventory) + { + DrawNewInventoryAlert(npc); + } + else + { + switch (npc.type) + { + case NPCID.Merchant: + if (Main.LocalPlayer.Calamity().newMerchantInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.Painter: + if (Main.LocalPlayer.Calamity().newPainterInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.DyeTrader: + if (Main.LocalPlayer.Calamity().newDyeTraderInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.PartyGirl: + if (Main.LocalPlayer.Calamity().newPartyGirlInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.Stylist: + if (Main.LocalPlayer.Calamity().newStylistInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.Demolitionist: + if (Main.LocalPlayer.Calamity().newDemolitionistInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.Dryad: + if (Main.LocalPlayer.Calamity().newDryadInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.DD2Bartender: + if (Main.LocalPlayer.Calamity().newTavernkeepInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.ArmsDealer: + if (Main.LocalPlayer.Calamity().newArmsDealerInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.GoblinTinkerer: + if (Main.LocalPlayer.Calamity().newGoblinTinkererInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.WitchDoctor: + if (Main.LocalPlayer.Calamity().newWitchDoctorInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.Clothier: + if (Main.LocalPlayer.Calamity().newClothierInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.Mechanic: + if (Main.LocalPlayer.Calamity().newMechanicInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.Pirate: + if (Main.LocalPlayer.Calamity().newPirateInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.Truffle: + if (Main.LocalPlayer.Calamity().newTruffleInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.Wizard: + if (Main.LocalPlayer.Calamity().newWizardInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.Steampunker: + if (Main.LocalPlayer.Calamity().newSteampunkerInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.Cyborg: + if (Main.LocalPlayer.Calamity().newCyborgInventory) + DrawNewInventoryAlert(npc); + break; + case NPCID.SkeletonMerchant: + if (Main.LocalPlayer.Calamity().newSkeletonMerchantInventory) + DrawNewInventoryAlert(npc); + break; + default: + break; + } + } + + void DrawNewInventoryAlert(NPC npc2) + { + // The position where the display is drawn + Vector2 drawPos = npc2.Center - Main.screenPosition; + + // The height of a single frame of the npc + float npcHeight = (float)(Main.npcTexture[npc2.type].Height / Main.npcFrameCount[npc2.type] / 2) * npc2.scale; + + // Offset the debuff display based on the npc's graphical offset, and 16 units, to create some space between the sprite and the display + float drawPosY = npcHeight + npc.gfxOffY + 36f; + + // Texture animation variables + Texture2D texture = GetTexture("CalamityMod/ExtraTextures/UI/NPCAlertDisplay"); + shopAlertAnimTimer++; + if (shopAlertAnimTimer >= 6) + { + shopAlertAnimTimer = 0; + + shopAlertAnimFrame++; + if (shopAlertAnimFrame > 4) + shopAlertAnimFrame = 0; + } + int frameHeight = texture.Height / 5; + Rectangle animRect = new Rectangle(0, frameHeight * shopAlertAnimFrame, texture.Width, frameHeight); + + spriteBatch.Draw(texture, drawPos - new Vector2(5f, drawPosY), animRect, Color.White, 0f, default, 1f, SpriteEffects.None, 0f); + } + } + } + + public override void OnChatButtonClicked(NPC npc, bool firstButton) + { + if (npc.townNPC) + { + switch (npc.type) + { + case NPCID.Merchant: + Main.LocalPlayer.Calamity().newMerchantInventory = false; + break; + case NPCID.Painter: + Main.LocalPlayer.Calamity().newPainterInventory = false; + break; + case NPCID.DyeTrader: + Main.LocalPlayer.Calamity().newDyeTraderInventory = false; + break; + case NPCID.PartyGirl: + Main.LocalPlayer.Calamity().newPartyGirlInventory = false; + break; + case NPCID.Stylist: + Main.LocalPlayer.Calamity().newStylistInventory = false; + break; + case NPCID.Demolitionist: + Main.LocalPlayer.Calamity().newDemolitionistInventory = false; + break; + case NPCID.Dryad: + Main.LocalPlayer.Calamity().newDryadInventory = false; + break; + case NPCID.DD2Bartender: + Main.LocalPlayer.Calamity().newTavernkeepInventory = false; + break; + case NPCID.ArmsDealer: + Main.LocalPlayer.Calamity().newArmsDealerInventory = false; + break; + case NPCID.GoblinTinkerer: + Main.LocalPlayer.Calamity().newGoblinTinkererInventory = false; + break; + case NPCID.WitchDoctor: + Main.LocalPlayer.Calamity().newWitchDoctorInventory = false; + break; + case NPCID.Clothier: + Main.LocalPlayer.Calamity().newClothierInventory = false; + break; + case NPCID.Mechanic: + Main.LocalPlayer.Calamity().newMechanicInventory = false; + break; + case NPCID.Pirate: + Main.LocalPlayer.Calamity().newPirateInventory = false; + break; + case NPCID.Truffle: + Main.LocalPlayer.Calamity().newTruffleInventory = false; + break; + case NPCID.Wizard: + Main.LocalPlayer.Calamity().newWizardInventory = false; + break; + case NPCID.Steampunker: + Main.LocalPlayer.Calamity().newSteampunkerInventory = false; + break; + case NPCID.Cyborg: + Main.LocalPlayer.Calamity().newCyborgInventory = false; + break; + case NPCID.SkeletonMerchant: + Main.LocalPlayer.Calamity().newSkeletonMerchantInventory = false; + break; + default: + break; + } + } + } + + public static void SetNewShopVariable(int[] types, bool alreadySet) + { + if (!alreadySet) + { + for (int i = 0; i < types.Length; i++) + { + if (types[i] == NPCType()) + { + Main.LocalPlayer.Calamity().newPermafrostInventory = true; + } + else if (types[i] == NPCType()) + { + Main.LocalPlayer.Calamity().newCirrusInventory = true; + } + else if (types[i] == NPCType()) + { + Main.LocalPlayer.Calamity().newAmidiasInventory = true; + } + else if (types[i] == NPCType()) + { + Main.LocalPlayer.Calamity().newBanditInventory = true; + } + else + { + switch (types[i]) + { + case NPCID.Merchant: + Main.LocalPlayer.Calamity().newMerchantInventory = true; + break; + case NPCID.Painter: + Main.LocalPlayer.Calamity().newPainterInventory = true; + break; + case NPCID.DyeTrader: + Main.LocalPlayer.Calamity().newDyeTraderInventory = true; + break; + case NPCID.PartyGirl: + Main.LocalPlayer.Calamity().newPartyGirlInventory = true; + break; + case NPCID.Stylist: + Main.LocalPlayer.Calamity().newStylistInventory = true; + break; + case NPCID.Demolitionist: + Main.LocalPlayer.Calamity().newDemolitionistInventory = true; + break; + case NPCID.Dryad: + Main.LocalPlayer.Calamity().newDryadInventory = true; + break; + case NPCID.DD2Bartender: + Main.LocalPlayer.Calamity().newTavernkeepInventory = true; + break; + case NPCID.ArmsDealer: + Main.LocalPlayer.Calamity().newArmsDealerInventory = true; + break; + case NPCID.GoblinTinkerer: + Main.LocalPlayer.Calamity().newGoblinTinkererInventory = true; + break; + case NPCID.WitchDoctor: + Main.LocalPlayer.Calamity().newWitchDoctorInventory = true; + break; + case NPCID.Clothier: + Main.LocalPlayer.Calamity().newClothierInventory = true; + break; + case NPCID.Mechanic: + Main.LocalPlayer.Calamity().newMechanicInventory = true; + break; + case NPCID.Pirate: + Main.LocalPlayer.Calamity().newPirateInventory = true; + break; + case NPCID.Truffle: + Main.LocalPlayer.Calamity().newTruffleInventory = true; + break; + case NPCID.Wizard: + Main.LocalPlayer.Calamity().newWizardInventory = true; + break; + case NPCID.Steampunker: + Main.LocalPlayer.Calamity().newSteampunkerInventory = true; + break; + case NPCID.Cyborg: + Main.LocalPlayer.Calamity().newCyborgInventory = true; + break; + case NPCID.SkeletonMerchant: + Main.LocalPlayer.Calamity().newSkeletonMerchantInventory = true; + break; + default: + break; + } + } + } + } + } + #endregion + + #region NPC Chat + public override void GetChat(NPC npc, ref string chat) + { + 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) + { + case NPCID.Guide: + if (Main.hardMode) + { + if (Main.rand.NextBool(20)) + { + chat = "Could you be so kind as to, ah... check hell for me...? I left someone I kind of care about down there."; + } + + if (Main.rand.NextBool(20)) + { + chat = "I have this sudden shiver up my spine, like a meteor just fell and thousands of innocent creatures turned into monsters from the stars."; + } + } + + if (Main.rand.NextBool(20) && NPC.downedMoonlord) + { + chat = "The dungeon seems even more restless than usual, watch out for the powerful abominations stirring up in there."; + } + + if (CalamityWorld.downedProvidence) + { + if (Main.rand.NextBool(20)) + { + chat = "Seems like extinguishing that butterfly caused its life to seep into the hallowed areas, try taking a peek there and see what you can find!"; + } + + if (Main.rand.NextBool(20)) + { + chat = "I've heard there is a portal of antimatter absorbing everything it can see in the dungeon, try using the Rune of Kos there!"; + } + } + + break; + case NPCID.Truffle: + if (Main.rand.NextBool(8)) + { + chat = "I don't feel very safe; I think there's pigs following me around and it frightens me."; + } + + 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."; + } + + break; + + case NPCID.Angler: + 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."; + } + + break; + + case NPCID.TravellingMerchant: + 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."; + } + + break; + + case NPCID.SkeletonMerchant: + if (Main.rand.NextBool(5)) + { + chat = "What'dya buyin'?"; + } + + break; + + case NPCID.WitchDoctor: + if (Main.rand.NextBool(8) && Main.LocalPlayer.ZoneJungle) + { + chat = "My home here has an extensive history and a mysterious past. You'll find out quickly just how extensive it is..."; + } + + if (Main.rand.NextBool(8) && Main.LocalPlayer.ZoneJungle && + Main.hardMode && !NPC.downedPlantBoss) + { + chat = "I have unique items if you show me that you have bested the guardian of this jungle."; + } + + if (Main.rand.NextBool(8) && Main.bloodMoon) + { + chat = "This is as good a time as any to pick up the best ingredients for potions."; + } + + break; + + case NPCID.PartyGirl: + if (Main.rand.NextBool(10) && fapsol != -1) + { + chat = "I have a feeling we're going to have absolutely fantastic parties with " + Main.npc[fapsol].GivenName + " around!"; + } + + if (Main.eclipse) + { + if (Main.rand.NextBool(5)) + { + chat = "I think my light display is turning into an accidental bug zapper. At least the monsters are enjoying it."; + } + + if (Main.rand.NextBool(5)) + { + chat = "Ooh! I love parties where everyone wears a scary costume!"; + } + } + + break; + + case NPCID.Painter: + if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneCorrupt) + { + chat = "A little sickness isn't going to stop me from doing my work as an artist!"; + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneCrimson) + { + chat = "There's a surprising art to this area. A sort of horrifying, eldritch feeling. It inspires me!"; + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneSnow) + { + 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?!"; + } + else + { + chat = "I'm not exactly suited for this cold weather. Still looks pretty, though."; + } + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneDesert) + { + chat = "I hate sand. It's coarse, and rough and gets in my paint."; + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneHoly) + { + chat = "Do you think unicorn blood could be used as a good pigment or resin? No I'm not going to find out myself."; + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneSkyHeight) + { + //chat = "I can't breathe." + chat = "I can't work in this environment. All of my paint just floats off."; + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneJungle) + { + chat = "Painting the tortoises in a still life isn't going so well."; + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.Calamity().ZoneAstral) + { + chat = "I can't paint a still life if the fruit grows legs and walks away."; + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneUnderworldHeight) + { + chat = "On the canvas, things get heated around here all the time. Like the environment!"; + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneUnderworldHeight) + { + chat = "Sorry, I'm all out of watercolors. They keep evaporating."; + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.Calamity().ZoneCalamity) + { + chat = "Roses, really? That's such an overrated thing to paint."; + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.Calamity().ZoneSulphur) + { + chat = "Fun fact! Sulphur was used as pigment once upon a time! Or was it Cinnabar?"; + } + if (Main.rand.NextBool(4) && Main.LocalPlayer.Calamity().ZoneAbyss) + { + chat = "Easiest landscape I've ever painted in my life."; + } + break; + + case NPCID.Wizard: + if (Main.rand.NextBool(10) && Main.hardMode) + { + chat = "Space just got way too close for comfort."; + } + + break; + + case NPCID.Dryad: + if (Main.rand.NextBool(5) && CalamityWorld.downedDoG && Main.eclipse) + { + chat = "There's a dark solar energy emanating from the moths that appear during this time. Ah, the moths as you progress further get more powerful... hmm... what power was Yharon holding back?"; + } + + if (Main.rand.NextBool(5) && Main.hardMode) + { + 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(NPCType()) && Main.LocalPlayer.ZoneGlowshroom) + { + chat = Main.npc[fapsol].GivenName + " put me up to this."; + } + + if (Main.rand.NextBool(5) && Main.LocalPlayer.Calamity().ZoneSulphur) + { + chat = "My ancestor was lost here long ago. I must pay my respects to her."; + } + + if (Main.rand.NextBool(5) && Main.LocalPlayer.ZoneGlowshroom) + { + //high iq drugs iirc + chat = "“I'm not here for any reason! Just picking up mushrooms for uh, later use."; + } + + break; + + case NPCID.Stylist: + string worldEvil = WorldGen.crimson ? "Crimson" : "Corruption"; + if (Main.rand.NextBool(15) && Main.hardMode) + { + chat = "Please don't catch space lice. Or " + worldEvil + " lice. Or just lice in general."; + } + + if (fapsol != -1) + { + if (Main.rand.NextBool(15)) + { + chat = "Sometimes I catch " + Main.npc[fapsol].GivenName + " sneaking up from behind me."; + } + + if (Main.rand.NextBool(15)) + { + chat = Main.npc[fapsol].GivenName + " is always trying to brighten my mood... even if, deep down, I know she's sad..."; + } + } + if ((npc.GivenName == "Amber" ? Main.rand.NextBool(10) : Main.rand.NextBool(15)) && Main.LocalPlayer.Calamity().pArtifact) + { + if (Main.LocalPlayer.Calamity().profanedCrystalBuffs) + { + chat = Main.rand.NextBool(2) ? "They look so cute and yet, I can feel their immense power just by being near them. What are you?" : "I hate to break it to you, but you don't have hair to cut or style, hun."; + } + else if (Main.LocalPlayer.Calamity().gDefense && Main.LocalPlayer.Calamity().gOffense) + { + chat = "Aww, they're so cute, do they have names?"; + } + } + break; + + case NPCID.GoblinTinkerer: + if (Main.rand.NextBool(3) && thief != -1 && CalamityWorld.Reforges >= 1) + { + 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) + { + chat = "You know... we haven't had an invasion in a while..."; + } + + break; + + case NPCID.ArmsDealer: + if (Main.rand.NextBool(5) && Main.eclipse) + { + chat = "That's the biggest moth I've ever seen for sure. You'd need one big gun to take one of those down."; + } + + if (Main.rand.NextBool(10) && CalamityWorld.downedDoG) + { + chat = "Is it me or are your weapons getting bigger and bigger?"; + } + + break; + + case NPCID.Merchant: + if (Main.rand.NextBool(5) && NPC.downedMoonlord) + { + chat = "Each night seems only more foreboding than the last. I feel unthinkable terrors are watching your every move."; + } + + if (Main.rand.NextBool(5) && Main.eclipse) + { + chat = "Are you daft?! Turn off those lamps!"; + } + + if (Main.rand.NextBool(5) && Main.raining && Main.LocalPlayer.Calamity().ZoneSulphur) + { + 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: + if (Main.rand.NextBool(5) && NPC.downedMoonlord) + { + chat = "What do you mean your traps aren't making the cut? Don't look at me!"; + } + + if (Main.rand.NextBool(5) && Main.eclipse) + { + chat = "Um... should my nightlight be on?"; + } + + if (Main.rand.NextBool(5) && fapsol != -1) + { + chat = "Well, I like " + Main.npc[fapsol].GivenName + ", but I, ah... I have my eyes on someone else."; + } + + if (Main.rand.NextBool(5) && CalamityWorld.rainingAcid) + { + chat = "Maybe I should've waterproofed my gadgets... They're starting to corrode."; + } + + break; + + case NPCID.DD2Bartender: + if (Main.rand.NextBool(5) && !Main.dayTime && Main.moonPhase == 0) + { + chat = "Care for a little Moonshine?"; + } + + if (Main.rand.NextBool(10) && fapsol != -1) + { + chat = "Sheesh, " + Main.npc[fapsol].GivenName + " is a little cruel, isn't she? I never claimed to be an expert on anything but ale!"; + } + + break; + + case NPCID.Pirate: + if (Main.rand.NextBool(5) && !CalamityWorld.downedLeviathan) + { + chat = "Aye, I've heard of a mythical creature in the oceans, singing with an alluring voice. Careful when yer fishin out there."; + } + + if (Main.rand.NextBool(5) && CalamityWorld.downedAquaticScourge) + { + 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(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(NPCType())) + { + chat = "Twenty-nine bottles of beer on the wall..."; + } + + if (Main.rand.NextBool(5) && Main.LocalPlayer.Center.ToTileCoordinates().X < 380 && !Main.LocalPlayer.Calamity().ZoneSulphur) + { + chat = "Now this is a scene that I can admire any time! I feel like something is watching me though."; + } + + if (Main.rand.NextBool(5) && Main.LocalPlayer.Calamity().ZoneSulphur) + { + chat = "It ain't much of a sight, but there's still life living in these waters."; + } + + if (Main.rand.NextBool(5) && Main.LocalPlayer.Calamity().ZoneSulphur) + { + chat = "Me ship might just sink from the acid alone."; + } + break; + + case NPCID.Cyborg: + if (Main.rand.NextBool(10) && Main.raining) + { + chat = "All these moments will be lost in time. Like tears... in the rain."; + } + + if (NPC.downedMoonlord) + { + if (Main.rand.NextBool(10)) + { + chat = "Always shoot for the moon! It has clearly worked before."; + } + + if (Main.rand.NextBool(10)) + { + chat = "Draedon? He's... a little 'high octane' if you know what I mean."; + } + } + + if (Main.rand.NextBool(10) && !CalamityWorld.downedPlaguebringer && NPC.downedGolemBoss) + { + chat = "Those oversized bugs terrorizing the jungle... Surely you of all people could shut them down!"; + } + + break; + + case NPCID.Clothier: + if (NPC.downedMoonlord) + { + if (Main.rand.NextBool(10)) + { + chat = "Who you gonna call?"; + } + + if (Main.rand.NextBool(10)) + { + chat = "Those screams... I'm not sure why, but I feel like a nameless fear has awoken in my heart."; + } + + if (Main.rand.NextBool(10)) + { + chat = "I can faintly hear ghostly shrieks from the dungeon... and not ones I'm familiar with at all. Just what is going on in there?"; + } + } + + if (Main.rand.NextBool(10) && CalamityWorld.downedPolterghast) + { + chat = "Whatever that thing was, I'm glad it's gone now."; + } + + if (Main.rand.NextBool(5) && NPC.AnyNPCs(NPCID.MoonLordCore)) + { + chat = "Houston, we've had a problem."; + } + + break; + + case NPCID.Steampunker: + bool hasPortalGun = false; + for (int k = 0; k < Main.maxPlayers; k++) + { + Player player = Main.player[k]; + if (player.active && player.HasItem(ItemID.PortalGun)) + { + hasPortalGun = true; + } + } + + if (Main.rand.NextBool(5) && hasPortalGun) + { + chat = "Just what is that contraption? It makes my Teleporters look like child's play!"; + } + + if (Main.rand.NextBool(5) && NPC.downedMoonlord) + { + chat = "Yep! I'm also considering being a space pirate now."; + } + + if (Main.rand.NextBool(5) && Main.LocalPlayer.Calamity().ZoneAstral) + { + chat = "Some of my machines are starting to go haywire thanks to this Astral Infection. I probably shouldn't have built them here"; + } + + if (Main.rand.NextBool(5) && Main.LocalPlayer.ZoneHoly) + { + chat = "I'm sorry I really don't have any Unicorn proof tech here, you're on your own."; + } + + break; + + case NPCID.DyeTrader: + if (Main.rand.NextBool(5)) + { + chat = "Have you seen those gemstone creatures in the caverns? Their colors are simply breathtaking!"; + } + + if (Main.rand.NextBool(5) && permadong != -1) + { + chat = "Do you think " + Main.npc[permadong].GivenName + " knows how to 'let it go?'"; + } + + break; + + case NPCID.TaxCollector: + int platinumCoins = 0; + for (int k = 0; k < Main.maxPlayers; k++) + { + Player player = Main.player[k]; + if (player.active) + { + for (int j = 0; j < player.inventory.Length; j++) + { + if (player.inventory[j].type == ItemID.PlatinumCoin) + { + platinumCoins += player.inventory[j].stack; + } + } + } + } + + if (Main.rand.NextBool(5) && platinumCoins >= 100) + { + chat = "BAH! Doesn't seem like I'll ever be able to quarrel with the debts of the town again!"; + } + + if (Main.rand.NextBool(5) && platinumCoins >= 500) + { + chat = "Where and how are you getting all of this money?"; + } + + if (Main.rand.NextBool(5) && !CalamityWorld.downedBrimstoneElemental) + { + chat = "Perhaps with all that time you've got you could check those old ruins? Certainly something of value in it for you!"; + } + + if (Main.rand.NextBool(10) && CalamityWorld.downedDoG) + { + 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, ItemType())) + { + chat = "Goodness! That cane has swagger!"; + } + + break; + + case NPCID.Demolitionist: + if (Main.rand.NextBool(5) && CalamityWorld.downedDoG) + { + chat = "God Slayer Dynamite? Boy do I like the sound of that!"; + } + + break; + + default: + break; + } + } + #endregion + + #region NPC Stat Changes + public void BoundNPCSafety(Mod mod, NPC npc) + { + // Make Bound Town NPCs take no damage + if (CalamityLists.BoundNPCIDs.Contains(npc.type)) + { + npc.dontTakeDamageFromHostiles = true; + } + } + + public void MakeTownNPCsTakeMoreDamage(NPC npc, Projectile projectile, Mod mod, ref int damage) + { + if (npc.townNPC && projectile.hostile) + damage *= 2; + } + + public override void BuffTownNPC(ref float damageMult, ref int defense) + { + if (NPC.downedMoonlord) + { + damageMult += 0.6f; + defense += 20; + } + if (CalamityWorld.downedProvidence) + { + damageMult += 0.2f; + defense += 12; + } + if (CalamityWorld.downedPolterghast) + { + damageMult += 0.2f; + defense += 12; + } + if (CalamityWorld.downedDoG) + { + damageMult += 0.2f; + defense += 12; + } + if (CalamityWorld.downedYharon) + { + damageMult += 0.2f; + defense += 12; + } + if (CalamityWorld.downedSCal) + { + damageMult += 0.6f; + defense += 20; + } + } + #endregion + + #region Shop Stuff + public override void SetupShop(int type, Chest shop, ref int nextSlot) + { + int goldCost = NPC.downedMoonlord ? 8 : Main.hardMode ? 4 : 2; + + if (type == NPCID.Merchant) + { SetShopItem(ref shop, ref nextSlot, ItemID.Bottle, true, Item.buyPrice(0, 0, 0, 20)); SetShopItem(ref shop, ref nextSlot, ItemID.WormholePotion, true, Item.buyPrice(0, 0, 25, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.ArcheryPotion, NPC.downedBoss1, Item.buyPrice(0, goldCost, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.HealingPotion, NPC.downedBoss2); - SetShopItem(ref shop, ref nextSlot, ItemID.ManaPotion, NPC.downedBoss2); - SetShopItem(ref shop, ref nextSlot, ItemID.TitanPotion, NPC.downedBoss3, Item.buyPrice(0, 2, 0, 0)); - 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.downedBoss3); - 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.downedPlantBoss); - SetShopItem(ref shop, ref nextSlot, ItemID.AngelStatue, NPC.FindFirstNPC(NPCType()) != -1, Item.buyPrice(0, 5)); - } + SetShopItem(ref shop, ref nextSlot, ItemID.ArcheryPotion, NPC.downedBoss1, Item.buyPrice(0, goldCost, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.HealingPotion, NPC.downedBoss2); + SetShopItem(ref shop, ref nextSlot, ItemID.ManaPotion, NPC.downedBoss2); + SetShopItem(ref shop, ref nextSlot, ItemID.TitanPotion, NPC.downedBoss3, Item.buyPrice(0, 2, 0, 0)); + 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.downedBoss3); + 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.downedPlantBoss); + SetShopItem(ref shop, ref nextSlot, ItemID.AngelStatue, NPC.FindFirstNPC(NPCType()) != -1, Item.buyPrice(0, 5)); + } - if (type == NPCID.DyeTrader) - { - SetShopItem(ref shop, ref nextSlot, ItemType(), Main.hardMode, Item.buyPrice(0, 10)); - SetShopItem(ref shop, ref nextSlot, ItemID.DyeTradersScimitar, true, Item.buyPrice(0, 15)); - } + if (type == NPCID.DyeTrader) + { + SetShopItem(ref shop, ref nextSlot, ItemType(), Main.hardMode, Item.buyPrice(0, 10)); + SetShopItem(ref shop, ref nextSlot, ItemID.DyeTradersScimitar, true, Item.buyPrice(0, 15)); + } - if (type == NPCID.Demolitionist) - { - SetShopItem(ref shop, ref nextSlot, ItemID.MiningPotion, NPC.downedBoss1, Item.buyPrice(0, 1, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.IronskinPotion, NPC.downedBoss1, Item.buyPrice(0, 1, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.ShinePotion, NPC.downedBoss1, Item.buyPrice(0, 1, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.SpelunkerPotion, NPC.downedBoss2, Item.buyPrice(0, 2, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.ObsidianSkinPotion, NPC.downedBoss3, Item.buyPrice(0, 2, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.EndurancePotion, NPC.downedBoss3, Item.buyPrice(0, goldCost, 0, 0)); - } + if (type == NPCID.Demolitionist) + { + SetShopItem(ref shop, ref nextSlot, ItemID.MiningPotion, NPC.downedBoss1, Item.buyPrice(0, 1, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.IronskinPotion, NPC.downedBoss1, Item.buyPrice(0, 1, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.ShinePotion, NPC.downedBoss1, Item.buyPrice(0, 1, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.SpelunkerPotion, NPC.downedBoss2, Item.buyPrice(0, 2, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.ObsidianSkinPotion, NPC.downedBoss3, Item.buyPrice(0, 2, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.EndurancePotion, NPC.downedBoss3, Item.buyPrice(0, goldCost, 0, 0)); + } - if (type == NPCID.ArmsDealer) - { - SetShopItem(ref shop, ref nextSlot, ItemType(), Main.hardMode, Item.buyPrice(gold: 25)); - bool hasMagnum = Main.LocalPlayer.HasItem(ItemType()) || Main.LocalPlayer.HasItem(ItemType()) || Main.LocalPlayer.HasItem(ItemType()); - SetShopItem(ref shop, ref nextSlot, ItemType(), hasMagnum, Item.buyPrice(0, 3 * goldCost, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemType(), Main.LocalPlayer.HasItem(ItemType()), Item.buyPrice(0, 5 * goldCost, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemType(), Main.LocalPlayer.HasItem(ItemType()), Item.buyPrice(0, 7 * goldCost, 0, 0)); - 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(gold: 20)); - SetShopItem(ref shop, ref nextSlot, ItemID.TacticalShotgun, NPC.downedGolemBoss, Item.buyPrice(gold: 25)); - SetShopItem(ref shop, ref nextSlot, ItemID.SniperRifle, NPC.downedGolemBoss, Item.buyPrice(gold: 25)); - SetShopItem(ref shop, ref nextSlot, ItemID.RifleScope, NPC.downedGolemBoss, Item.buyPrice(gold: 25)); - SetShopItem(ref shop, ref nextSlot, ItemID.AmmoReservationPotion, true, Item.buyPrice(0, 1, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.HunterPotion, true, Item.buyPrice(0, 2, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.BattlePotion, NPC.downedBoss2, Item.buyPrice(0, 2, 0, 0)); - } + if (type == NPCID.ArmsDealer) + { + SetShopItem(ref shop, ref nextSlot, ItemType(), Main.hardMode, Item.buyPrice(gold: 25)); + bool hasMagnum = Main.LocalPlayer.HasItem(ItemType()) || Main.LocalPlayer.HasItem(ItemType()) || Main.LocalPlayer.HasItem(ItemType()); + SetShopItem(ref shop, ref nextSlot, ItemType(), hasMagnum, Item.buyPrice(0, 3 * goldCost, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemType(), Main.LocalPlayer.HasItem(ItemType()), Item.buyPrice(0, 5 * goldCost, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemType(), Main.LocalPlayer.HasItem(ItemType()), Item.buyPrice(0, 7 * goldCost, 0, 0)); + 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(gold: 20)); + SetShopItem(ref shop, ref nextSlot, ItemID.TacticalShotgun, NPC.downedGolemBoss, Item.buyPrice(gold: 25)); + SetShopItem(ref shop, ref nextSlot, ItemID.SniperRifle, NPC.downedGolemBoss, Item.buyPrice(gold: 25)); + SetShopItem(ref shop, ref nextSlot, ItemID.RifleScope, NPC.downedGolemBoss, Item.buyPrice(gold: 25)); + SetShopItem(ref shop, ref nextSlot, ItemID.AmmoReservationPotion, true, Item.buyPrice(0, 1, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.HunterPotion, true, Item.buyPrice(0, 2, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.BattlePotion, NPC.downedBoss2, Item.buyPrice(0, 2, 0, 0)); + } - if (type == NPCID.Stylist) - { - 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); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.revenge); - SetShopItem(ref shop, ref nextSlot, ItemID.StylistKilLaKillScissorsIWish, true, Item.buyPrice(0, 15)); - SetShopItem(ref shop, ref nextSlot, ItemType(), Main.LocalPlayer.Calamity().alcoholPoisoning && NPC.FindFirstNPC(NPCType()) != -1); - } + if (type == NPCID.Stylist) + { + 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); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.revenge); + SetShopItem(ref shop, ref nextSlot, ItemID.StylistKilLaKillScissorsIWish, true, Item.buyPrice(0, 15)); + SetShopItem(ref shop, ref nextSlot, ItemType(), Main.LocalPlayer.Calamity().alcoholPoisoning && NPC.FindFirstNPC(NPCType()) != -1); + } - if (type == NPCID.Cyborg) - { - SetShopItem(ref shop, ref nextSlot, ItemID.RocketLauncher, NPC.downedGolemBoss, Item.buyPrice(0, 25)); - SetShopItem(ref shop, ref nextSlot, ItemType(), NPC.downedGolemBoss, Item.buyPrice(0, 50)); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedPolterghast); - } + if (type == NPCID.Cyborg) + { + SetShopItem(ref shop, ref nextSlot, ItemID.RocketLauncher, NPC.downedGolemBoss, Item.buyPrice(0, 25)); + SetShopItem(ref shop, ref nextSlot, ItemType(), NPC.downedGolemBoss, Item.buyPrice(0, 50)); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedPolterghast); + } - if (type == NPCID.Dryad) - { - SetShopItem(ref shop, ref nextSlot, ItemID.ThornsPotion, true, Item.buyPrice(0, 1, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.FeatherfallPotion, true, Item.buyPrice(0, 1, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.RegenerationPotion, NPC.downedBoss2, Item.buyPrice(0, 2, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.SwiftnessPotion, NPC.downedBoss2, Item.buyPrice(0, goldCost, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.JungleRose, price: Item.buyPrice(0, 2)); - SetShopItem(ref shop, ref nextSlot, ItemID.NaturesGift, price: Item.buyPrice(0, 10)); - 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, ItemType(), CalamityWorld.downedPerforator && Main.expertMode); - SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedHiveMind && Main.expertMode); - SetShopItem(ref shop, ref nextSlot, ItemType()); - } + if (type == NPCID.Dryad) + { + SetShopItem(ref shop, ref nextSlot, ItemID.ThornsPotion, true, Item.buyPrice(0, 1, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.FeatherfallPotion, true, Item.buyPrice(0, 1, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.RegenerationPotion, NPC.downedBoss2, Item.buyPrice(0, 2, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.SwiftnessPotion, NPC.downedBoss2, Item.buyPrice(0, goldCost, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.JungleRose, price: Item.buyPrice(0, 2)); + SetShopItem(ref shop, ref nextSlot, ItemID.NaturesGift, price: Item.buyPrice(0, 10)); + 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, ItemType(), CalamityWorld.downedPerforator && Main.expertMode); + SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedHiveMind && Main.expertMode); + SetShopItem(ref shop, ref nextSlot, ItemType()); + } - if (type == NPCID.GoblinTinkerer) - { - SetShopItem(ref shop, ref nextSlot, ItemID.StinkPotion, true, Item.buyPrice(0, 1, 0, 0)); - 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(0, 5)); - } + if (type == NPCID.GoblinTinkerer) + { + SetShopItem(ref shop, ref nextSlot, ItemID.StinkPotion, true, Item.buyPrice(0, 1, 0, 0)); + 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(0, 5)); + } - if (type == NPCID.Mechanic) - { - SetShopItem(ref shop, ref nextSlot, ItemID.BuilderPotion, true, Item.buyPrice(0, 1, 0, 0)); - } + if (type == NPCID.Mechanic) + { + SetShopItem(ref shop, ref nextSlot, ItemID.BuilderPotion, true, Item.buyPrice(0, 1, 0, 0)); + } - if (type == NPCID.Clothier) - { - 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, ItemType(), price: Item.buyPrice(gold: 10)); + if (type == NPCID.Clothier) + { + 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, ItemType(), price: Item.buyPrice(gold: 10)); SetShopItem(ref shop, ref nextSlot, ItemID.GoldenKey, Main.hardMode, Item.buyPrice(0, 5)); SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedDoG, price: Item.buyPrice(gold: 8)); SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedDoG, price: Item.buyPrice(gold: 8)); @@ -1323,80 +1323,80 @@ namespace CalamityMod.NPCs SetShopItem(ref shop, ref nextSlot, ItemType(), CalamityWorld.downedDoG, price: Item.buyPrice(gold: 8)); } - if (type == NPCID.Painter) - { - SetShopItem(ref shop, ref nextSlot, ItemID.PainterPaintballGun, price: Item.buyPrice(0, 15)); - } + if (type == NPCID.Painter) + { + SetShopItem(ref shop, ref nextSlot, ItemID.PainterPaintballGun, price: Item.buyPrice(0, 15)); + } - if (type == NPCID.Steampunker) - { - SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(0, 0, 5)); - } + if (type == NPCID.Steampunker) + { + SetShopItem(ref shop, ref nextSlot, ItemType(), price: Item.buyPrice(0, 0, 5)); + } - if (type == NPCID.Wizard) - { - SetShopItem(ref shop, ref nextSlot, ItemID.ManaRegenerationPotion, true, Item.buyPrice(0, goldCost, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.MagicPowerPotion, true, Item.buyPrice(0, goldCost, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.GravitationPotion, true, Item.buyPrice(0, 2, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemType()); - SetShopItem(ref shop, ref nextSlot, ItemID.MagicMissile, price: Item.buyPrice(0, 5)); + if (type == NPCID.Wizard) + { + SetShopItem(ref shop, ref nextSlot, ItemID.ManaRegenerationPotion, true, Item.buyPrice(0, goldCost, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.MagicPowerPotion, true, Item.buyPrice(0, goldCost, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.GravitationPotion, true, Item.buyPrice(0, 2, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemType()); + SetShopItem(ref shop, ref nextSlot, ItemID.MagicMissile, price: Item.buyPrice(0, 5)); SetShopItem(ref shop, ref nextSlot, ItemID.RodofDiscord, Main.hardMode && Main.LocalPlayer.ZoneHoly, price: Item.buyPrice(20), true); 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.MagnetSphere, 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.MagnetSphere, NPC.downedGolemBoss, Item.buyPrice(0, 25)); + } - if (type == NPCID.WitchDoctor) - { + if (type == NPCID.WitchDoctor) + { SetShopItem(ref shop, ref nextSlot, ItemID.SummoningPotion, true, Item.buyPrice(0, goldCost, 0, 0)); SetShopItem(ref shop, ref nextSlot, ItemID.CalmingPotion, true, Item.buyPrice(0, 1, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.RagePotion, true, Item.buyPrice(0, goldCost, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.WrathPotion, true, Item.buyPrice(0, goldCost, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.InfernoPotion, true, Item.buyPrice(0, 2, 0, 0)); - 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.ButterflyDust, NPC.downedGolemBoss, Item.buyPrice(0, 10)); - } + SetShopItem(ref shop, ref nextSlot, ItemID.RagePotion, true, Item.buyPrice(0, goldCost, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.WrathPotion, true, Item.buyPrice(0, goldCost, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.InfernoPotion, true, Item.buyPrice(0, 2, 0, 0)); + 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.ButterflyDust, NPC.downedGolemBoss, Item.buyPrice(0, 10)); + } - if (type == NPCID.PartyGirl) - { - SetShopItem(ref shop, ref nextSlot, ItemID.GenderChangePotion, true, Item.buyPrice(0, 1, 0, 0)); - } + if (type == NPCID.PartyGirl) + { + SetShopItem(ref shop, ref nextSlot, ItemID.GenderChangePotion, true, Item.buyPrice(0, 1, 0, 0)); + } - if (type == NPCID.SkeletonMerchant) - { - SetShopItem(ref shop, ref nextSlot, ItemType(), true, Item.buyPrice(0, 1, 0, 0)); - SetShopItem(ref shop, ref nextSlot, ItemID.Marrow, Main.hardMode, Item.buyPrice(0, 36)); - } - } + if (type == NPCID.SkeletonMerchant) + { + SetShopItem(ref shop, ref nextSlot, ItemType(), true, Item.buyPrice(0, 1, 0, 0)); + SetShopItem(ref shop, ref nextSlot, ItemID.Marrow, Main.hardMode, Item.buyPrice(0, 36)); + } + } public override void SetupTravelShop(int[] shop, ref int nextSlot) { - if (Main.moonPhase == 0) - { - shop[nextSlot] = ItemType(); - nextSlot++; - } - } + if (Main.moonPhase == 0) + { + shop[nextSlot] = ItemType(); + nextSlot++; + } + } - public void SetShopItem(ref Chest shop, ref int nextSlot, int itemID, bool condition = true, int? price = null, bool ignoreDiscount = false) - { - if (condition) - { - shop.item[nextSlot].SetDefaults(itemID); - if (price != null) - { - shop.item[nextSlot].shopCustomPrice = price; - if (Main.LocalPlayer.discount && !ignoreDiscount) - shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); - } + public void SetShopItem(ref Chest shop, ref int nextSlot, int itemID, bool condition = true, int? price = null, bool ignoreDiscount = false) + { + if (condition) + { + shop.item[nextSlot].SetDefaults(itemID); + if (price != null) + { + shop.item[nextSlot].shopCustomPrice = price; + if (Main.LocalPlayer.discount && !ignoreDiscount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); + } - nextSlot++; - } - } - #endregion - } + nextSlot++; + } + } + #endregion + } } diff --git a/NPCs/CalamityVanillaMinibossesAI.cs b/NPCs/CalamityVanillaMinibossesAI.cs index 1121e61b2f..33dd3645a4 100644 --- a/NPCs/CalamityVanillaMinibossesAI.cs +++ b/NPCs/CalamityVanillaMinibossesAI.cs @@ -8,7 +8,7 @@ namespace CalamityMod.NPCs public partial class CalamityGlobalAI { internal enum MothronAIState - { + { DespawnYeet = -1, NewAISelection = 0, FlyTowardsPlayer = 1, @@ -21,8 +21,8 @@ namespace CalamityMod.NPCs LayEgg = 8 } - #region Buffed Mothron AI - public static bool BuffedMothronAI(NPC npc) + #region Buffed Mothron AI + public static bool BuffedMothronAI(NPC npc) { npc.noTileCollide = false; npc.noGravity = true; @@ -58,7 +58,7 @@ namespace CalamityMod.NPCs float chargeSpeed = 32f; Vector2 idealFlyVelocity; switch ((MothronAIState)(int)aiState) - { + { case MothronAIState.DespawnYeet: Vector2 idealVelocity = Vector2.UnitY * -34f; npc.velocity = (npc.velocity * 4f + idealVelocity) / 5f; diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index 729ee1ff7b..d8345bacf9 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -25,22 +25,22 @@ namespace CalamityMod.NPCs.CeaselessVoid { DisplayName.SetDefault("Ceaseless Void"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 36f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 36f; npc.width = 100; npc.height = 100; npc.defense = 80; CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.5f; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel1; - npc.LifeMaxNERB(notDoGFight ? 64400 : 16100, notDoGFight ? 77280 : 19320, 72000); + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel1; + npc.LifeMaxNERB(notDoGFight ? 64400 : 16100, notDoGFight ? 77280 : 19320, 72000); // If fought alone, Ceaseless Void plays its own theme if (notDoGFight) @@ -52,9 +52,9 @@ namespace CalamityMod.NPCs.CeaselessVoid else music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; npc.noGravity = true; @@ -62,32 +62,32 @@ namespace CalamityMod.NPCs.CeaselessVoid npc.boss = true; npc.DeathSound = SoundID.NPCDeath14; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToSickness = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.dontTakeDamage); - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - writer.Write(npc.localAI[3]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.dontTakeDamage); + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + writer.Write(npc.localAI[3]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.dontTakeDamage = reader.ReadBoolean(); - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.dontTakeDamage = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -97,121 +97,121 @@ namespace CalamityMod.NPCs.CeaselessVoid public override void AI() { - CalamityAI.CeaselessVoidAI(npc, mod); + CalamityAI.CeaselessVoidAI(npc, mod); } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; - Rectangle targetHitbox = target.Hitbox; + Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= 50f; - } + return minDist <= 50f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 7; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/CeaselessVoid/CeaselessVoidGlow"); - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/CeaselessVoid/CeaselessVoidGlow"); + Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void NPCLoot() + public override void NPCLoot() { // Only drop items if fought at full strength - bool fullStrength = !CalamityWorld.downedSentinel1 || CalamityWorld.DoGSecondStageCountdown <= 0; + bool fullStrength = !CalamityWorld.downedSentinel1 || CalamityWorld.DoGSecondStageCountdown <= 0; if (fullStrength) { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - bool lastSentinelKilled = !CalamityWorld.downedSentinel1 && CalamityWorld.downedSentinel2 && CalamityWorld.downedSentinel3; - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, lastSentinelKilled); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + bool lastSentinelKilled = !CalamityWorld.downedSentinel1 && CalamityWorld.downedSentinel2 && CalamityWorld.downedSentinel3; + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, lastSentinelKilled); - if (!Main.expertMode) - { - // Materials - DropHelper.DropItem(npc, ModContent.ItemType(), true, 2, 3); + if (!Main.expertMode) + { + // Materials + DropHelper.DropItem(npc, ModContent.ItemType(), true, 2, 3); // Weapons float dropChance = DropHelper.NormalWeaponDropRateFloat; DropHelper.DropItemChance(npc, ModContent.ItemType(), dropChance); DropHelper.DropItemChance(npc, ModContent.ItemType(), dropChance); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - if (Main.rand.NextBool(20)) - { - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - } - } + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + if (Main.rand.NextBool(20)) + { + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + } + } } // If DoG's fight is active, set the timer for the remaining two sentinels @@ -227,25 +227,25 @@ namespace CalamityMod.NPCs.CeaselessVoid } } - // Mark Ceaseless Void as dead - if (fullStrength) - { - CalamityWorld.downedSentinel1 = true; - CalamityNetcode.SyncWorld(); - } + // Mark Ceaseless Void as dead + if (fullStrength) + { + CalamityWorld.downedSentinel1 = true; + CalamityNetcode.SyncWorld(); + } } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref string name, ref int potionType) { potionType = ModContent.ItemType(); } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.soundDelay == 0) { @@ -253,11 +253,11 @@ namespace CalamityMod.NPCs.CeaselessVoid Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); } - for (int k = 0; k < 5; k++) - { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - Main.dust[dust].noGravity = true; - } + for (int k = 0; k < 5; k++) + { + int dust = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); + Main.dust[dust].noGravity = true; + } if (npc.life <= 0) { @@ -271,8 +271,8 @@ namespace CalamityMod.NPCs.CeaselessVoid { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; - if (Main.rand.NextBool(2)) + Main.dust[num622].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; @@ -284,7 +284,7 @@ namespace CalamityMod.NPCs.CeaselessVoid Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].noGravity = true; + Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 2f; } diff --git a/NPCs/CeaselessVoid/DarkEnergy.cs b/NPCs/CeaselessVoid/DarkEnergy.cs index 6fb9713820..d4d4644af8 100644 --- a/NPCs/CeaselessVoid/DarkEnergy.cs +++ b/NPCs/CeaselessVoid/DarkEnergy.cs @@ -11,28 +11,28 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.CeaselessVoid { - public class DarkEnergy : ModNPC + public class DarkEnergy : ModNPC { private int invinceTime = 180; - private bool start = true; - private const double minDistance = 10D; - private double distance = minDistance; - private const double minMaxDistance = 800D; + private bool start = true; + private const double minDistance = 10D; + private double distance = minDistance; + private const double minMaxDistance = 800D; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Dark Energy"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.aiStyle = -1; - aiType = -1; - npc.GetNPCDamage(); - npc.dontTakeDamage = true; + npc.Calamity().canBreakPlayerDefense = true; + npc.aiStyle = -1; + aiType = -1; + npc.GetNPCDamage(); + npc.dontTakeDamage = true; npc.width = 80; npc.height = 80; npc.defense = 50; @@ -47,34 +47,34 @@ namespace CalamityMod.NPCs.CeaselessVoid } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.knockBackResist = 0f; - npc.noGravity = true; + npc.knockBackResist = 0f; + npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit53; npc.DeathSound = SoundID.NPCDeath44; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToSickness = false; + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(invinceTime); - writer.Write(start); - writer.Write(distance); - writer.Write(npc.dontTakeDamage); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + writer.Write(start); + writer.Write(distance); + writer.Write(npc.dontTakeDamage); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { invinceTime = reader.ReadInt32(); - start = reader.ReadBoolean(); - distance = reader.ReadDouble(); - npc.dontTakeDamage = reader.ReadBoolean(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + start = reader.ReadBoolean(); + distance = reader.ReadDouble(); + npc.dontTakeDamage = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void FindFrame(int frameHeight) { @@ -84,19 +84,19 @@ namespace CalamityMod.NPCs.CeaselessVoid npc.frame.Y = frame * frameHeight; } - public override void AI() + public override void AI() { - // Set the degrees used for rotation - if (start) - { - start = false; - npc.ai[3] = npc.ai[0]; - } - - // Stay invincible for 3 seconds to avoid being instantly killed - if (invinceTime > 0) + // Set the degrees used for rotation + if (start) { - npc.damage = 0; + start = false; + npc.ai[3] = npc.ai[0]; + } + + // Stay invincible for 3 seconds to avoid being instantly killed + if (invinceTime > 0) + { + npc.damage = 0; invinceTime--; } else @@ -105,197 +105,197 @@ namespace CalamityMod.NPCs.CeaselessVoid npc.dontTakeDamage = false; } - // Force despawn if Ceaseless Void isn't active - if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) - { - npc.active = false; - npc.netUpdate = true; - return; - } + // Force despawn if Ceaseless Void isn't active + if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) + { + npc.active = false; + npc.netUpdate = true; + return; + } - // Set time left just in case something dumb happens with despawning - if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + // Set time left just in case something dumb happens with despawning + if (npc.timeLeft < 1800) + npc.timeLeft = 1800; - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Gets how enraged Ceaseless Void is - float tileEnrageMult = Main.npc[CalamityGlobalNPC.voidBoss].ai[1]; + // Gets how enraged Ceaseless Void is + float tileEnrageMult = Main.npc[CalamityGlobalNPC.voidBoss].ai[1]; - // Distance from Ceaseless Void - double maxDistance = malice ? 1200D : death ? 1040D : revenge ? 960D : expertMode ? 880D : minMaxDistance; - double rateOfChangeIncrease = (maxDistance / minMaxDistance) - 1D; - double rateOfChange = (npc.ai[1] * 0.5f) + 2D + (tileEnrageMult - 1f) + rateOfChangeIncrease; - if (npc.Calamity().newAI[0] == 0f) - { - distance += rateOfChange; - if (distance >= maxDistance) - { - distance = maxDistance; - npc.Calamity().newAI[0] = 1f; - } - } - else - { - distance -= rateOfChange; - if (distance <= minDistance) - { - distance = minDistance; - npc.Calamity().newAI[0] = 0f; - } - } + // Distance from Ceaseless Void + double maxDistance = malice ? 1200D : death ? 1040D : revenge ? 960D : expertMode ? 880D : minMaxDistance; + double rateOfChangeIncrease = (maxDistance / minMaxDistance) - 1D; + double rateOfChange = (npc.ai[1] * 0.5f) + 2D + (tileEnrageMult - 1f) + rateOfChangeIncrease; + if (npc.Calamity().newAI[0] == 0f) + { + distance += rateOfChange; + if (distance >= maxDistance) + { + distance = maxDistance; + npc.Calamity().newAI[0] = 1f; + } + } + else + { + distance -= rateOfChange; + if (distance <= minDistance) + { + distance = minDistance; + npc.Calamity().newAI[0] = 0f; + } + } - // Rotation velocity - float minRotationVelocity = 0.5f + tileEnrageMult - 1f; - float rotationVelocityIncrease = death ? 0.2f : revenge ? 0.15f : expertMode ? 0.1f : 0f; - rotationVelocityIncrease += rotationVelocityIncrease * (npc.ai[1] * 0.5f); + // Rotation velocity + float minRotationVelocity = 0.5f + tileEnrageMult - 1f; + float rotationVelocityIncrease = death ? 0.2f : revenge ? 0.15f : expertMode ? 0.1f : 0f; + rotationVelocityIncrease += rotationVelocityIncrease * (npc.ai[1] * 0.5f); - // Rotate around Ceaseless Void - NPC parent = Main.npc[NPC.FindFirstNPC(ModContent.NPCType())]; - double degrees = npc.ai[3]; - double radians = degrees * (Math.PI / 180); - npc.position.X = parent.Center.X - (int)(Math.Cos(radians) * distance) - npc.width / 2; - npc.position.Y = parent.Center.Y - (int)(Math.Sin(radians) * distance) - npc.height / 2; - npc.ai[3] += minRotationVelocity + rotationVelocityIncrease; + // Rotate around Ceaseless Void + NPC parent = Main.npc[NPC.FindFirstNPC(ModContent.NPCType())]; + double degrees = npc.ai[3]; + double radians = degrees * (Math.PI / 180); + npc.position.X = parent.Center.X - (int)(Math.Cos(radians) * distance) - npc.width / 2; + npc.position.Y = parent.Center.Y - (int)(Math.Sin(radians) * distance) - npc.height / 2; + npc.ai[3] += minRotationVelocity + rotationVelocityIncrease; - // Flash and pulse effect - if (npc.ai[2] == 0f) - { - npc.scale -= 0.01f; - npc.alpha += 15; - if (npc.alpha >= 125) - { - npc.alpha = 130; - npc.ai[2] = 1f; - } - } - else - { - npc.scale += 0.01f; - npc.alpha -= 15; - if (npc.alpha <= 0) - { - npc.alpha = 0; - npc.ai[2] = 0f; - } - } - } + // Flash and pulse effect + if (npc.ai[2] == 0f) + { + npc.scale -= 0.01f; + npc.alpha += 15; + if (npc.alpha >= 125) + { + npc.alpha = 130; + npc.ai[2] = 1f; + } + } + else + { + npc.scale += 0.01f; + npc.alpha -= 15; + if (npc.alpha <= 0) + { + npc.alpha = 0; + npc.ai[2] = 0f; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/CeaselessVoid/DarkEnergyGlow2"); - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/CeaselessVoid/DarkEnergyGlow2"); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/CeaselessVoid/DarkEnergyGlow"); - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - Color color42 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/CeaselessVoid/DarkEnergyGlow"); + Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color color42 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 = npc.GetAlpha(color43); - color43 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + Color color43 = color42; + color43 = Color.Lerp(color43, color36, amount9); + color43 = npc.GetAlpha(color43); + color43 *= (num153 - num163) / 15f; + spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.5f * bossLifeScale); - } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.5f * bossLifeScale); + } - public override bool CheckActive() => false; + public override bool CheckActive() => false; public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(BuffID.VortexDebuff, 20, true); - } + player.AddBuff(BuffID.VortexDebuff, 20, true); + } public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; - Rectangle targetHitbox = target.Hitbox; + Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= 35f; - } + return minDist <= 35f; + } - public override bool CheckDead() => false; + public override bool CheckDead() => false; - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { - for (int k = 0; k < 20; k++) - { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - Main.dust[dust].noGravity = true; - } + for (int k = 0; k < 20; k++) + { + int dust = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); + Main.dust[dust].noGravity = true; + } } } } diff --git a/NPCs/Crabulon/CrabShroom.cs b/NPCs/Crabulon/CrabShroom.cs index de5bdd5826..e8a7d60218 100644 --- a/NPCs/Crabulon/CrabShroom.cs +++ b/NPCs/Crabulon/CrabShroom.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Crabulon { - public class CrabShroom : ModNPC + public class CrabShroom : ModNPC { public override void SetStaticDefaults() { @@ -19,8 +19,8 @@ namespace CalamityMod.NPCs.Crabulon public override void SetDefaults() { npc.aiStyle = -1; - npc.GetNPCDamage(); - npc.width = 14; + npc.GetNPCDamage(); + npc.width = 14; npc.height = 14; npc.lifeMax = 25; if (BossRushEvent.BossRushActive) @@ -34,10 +34,10 @@ namespace CalamityMod.NPCs.Crabulon npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void FindFrame(int frameHeight) { @@ -50,8 +50,8 @@ namespace CalamityMod.NPCs.Crabulon public override void AI() { Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0f, 0.2f, 0.4f); - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - float xVelocityLimit = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 7.5f : 5f; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + float xVelocityLimit = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 7.5f : 5f; float yVelocityLimit = revenge ? 1.25f : 1f; Player player = Main.player[npc.target]; npc.velocity.Y += 0.02f; @@ -83,41 +83,41 @@ namespace CalamityMod.NPCs.Crabulon npc.rotation = npc.velocity.X * 0.1f; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabShroomGlow"); - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabShroomGlow"); + Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool PreNPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override bool PreNPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - return false; - } + return false; + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { @@ -131,5 +131,5 @@ namespace CalamityMod.NPCs.Crabulon } } } - } + } } diff --git a/NPCs/Crabulon/CrabulonIdle.cs b/NPCs/Crabulon/CrabulonIdle.cs index 1b35d73107..dd3888415f 100644 --- a/NPCs/Crabulon/CrabulonIdle.cs +++ b/NPCs/Crabulon/CrabulonIdle.cs @@ -20,11 +20,11 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.Crabulon { - [AutoloadBossHead] + [AutoloadBossHead] public class CrabulonIdle : ModNPC { - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private int shotSpacing = 1000; + private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + private int shotSpacing = 1000; public override void SetStaticDefaults() { @@ -34,10 +34,10 @@ namespace CalamityMod.NPCs.Crabulon public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 14f; - npc.GetNPCDamage(); - npc.width = 196; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 14f; + npc.GetNPCDamage(); + npc.width = 196; npc.height = 196; npc.defense = 8; npc.LifeMaxNERB(3350, 4000, 1100000); @@ -54,53 +54,53 @@ namespace CalamityMod.NPCs.Crabulon npc.HitSound = SoundID.NPCHit45; npc.DeathSound = SoundID.NPCDeath1; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); - writer.Write(npc.localAI[0]); - writer.Write(shotSpacing); + writer.Write(biomeEnrageTimer); + writer.Write(npc.localAI[0]); + writer.Write(shotSpacing); } public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); - npc.localAI[0] = reader.ReadSingle(); - shotSpacing = reader.ReadInt32(); + biomeEnrageTimer = reader.ReadInt32(); + npc.localAI[0] = reader.ReadSingle(); + shotSpacing = reader.ReadInt32(); } public override void AI() { - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0f, 0.3f, 0.7f); + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0f, 0.3f, 0.7f); - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - npc.spriteDirection = npc.direction; + npc.spriteDirection = npc.direction; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Phases - bool phase2 = lifeRatio < 0.66f && expertMode; - bool phase3 = lifeRatio < 0.33f && expertMode; + // Phases + bool phase2 = lifeRatio < 0.66f && expertMode; + bool phase3 = lifeRatio < 0.33f && expertMode; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; - if (!player.active || player.dead) + Player player = Main.player[npc.target]; + if (!player.active || player.dead) { npc.TargetClosest(false); player = Main.player[npc.target]; @@ -108,42 +108,42 @@ namespace CalamityMod.NPCs.Crabulon { npc.noTileCollide = true; - if (npc.velocity.Y < -3f) - npc.velocity.Y = -3f; - npc.velocity.Y += 0.1f; - if (npc.velocity.Y > 12f) - npc.velocity.Y = 12f; + if (npc.velocity.Y < -3f) + npc.velocity.Y = -3f; + npc.velocity.Y += 0.1f; + if (npc.velocity.Y > 12f) + npc.velocity.Y = 12f; - if (npc.timeLeft > 60) + if (npc.timeLeft > 60) npc.timeLeft = 60; - if (npc.ai[0] != 1f) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - shotSpacing = 1000; - npc.netUpdate = true; - } - return; + if (npc.ai[0] != 1f) + { + npc.ai[0] = 1f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + shotSpacing = 1000; + npc.netUpdate = true; + } + return; } } else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + npc.timeLeft = 1800; - // Enrage - if ((!player.ZoneGlowshroom || (npc.position.Y / 16f) < Main.worldSurface) && !BossRushEvent.BossRushActive) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + // Enrage + if ((!player.ZoneGlowshroom || (npc.position.Y / 16f) < Main.worldSurface) && !BossRushEvent.BossRushActive) + { + if (biomeEnrageTimer > 0) + biomeEnrageTimer--; + } + else + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || malice; + bool biomeEnraged = biomeEnrageTimer <= 0 || malice; - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; if (biomeEnraged && ((npc.position.Y / 16f) < Main.worldSurface || malice)) { npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; @@ -155,7 +155,7 @@ namespace CalamityMod.NPCs.Crabulon enrageScale += 1f; } - if (npc.ai[0] != 0f && npc.ai[0] < 3f) + if (npc.ai[0] != 0f && npc.ai[0] < 3f) { Vector2 vector34 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num349 = player.position.X + (player.width / 2) - vector34.X; @@ -239,8 +239,8 @@ namespace CalamityMod.NPCs.Crabulon npc.ai[1] += 1f; if (npc.ai[1] >= (death ? 5f : revenge ? 10f : 15f)) { - npc.TargetClosest(); - npc.noGravity = true; + npc.TargetClosest(); + npc.noGravity = true; npc.noTileCollide = true; npc.ai[0] = 2f; npc.ai[1] = 0f; @@ -254,12 +254,12 @@ namespace CalamityMod.NPCs.Crabulon num823 = 1.25f; if (phase3) num823 = 1.75f; - if (death) - num823 += 2f * (1f - lifeRatio); - num823 += 4f * enrageScale; + if (death) + num823 += 2f * (1f - lifeRatio); + num823 += 4f * enrageScale; - bool flag51 = false; - if (Math.Abs(npc.Center.X - player.Center.X) < 50f) + bool flag51 = false; + if (Math.Abs(npc.Center.X - player.Center.X) < 50f) flag51 = true; if (flag51) @@ -279,55 +279,55 @@ namespace CalamityMod.NPCs.Crabulon npc.velocity.X = (npc.velocity.X * 20f - num823) / 21f; } - if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height) && player.position.Y <= npc.position.Y + npc.height) - { - npc.noGravity = false; - npc.noTileCollide = false; - } - else - { - npc.noGravity = true; - npc.noTileCollide = true; + if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height) && player.position.Y <= npc.position.Y + npc.height) + { + npc.noGravity = false; + npc.noTileCollide = false; + } + else + { + npc.noGravity = true; + npc.noTileCollide = true; - int num854 = 80; - int num855 = 20; - Vector2 position2 = new Vector2(npc.Center.X - (num854 / 2), npc.position.Y + npc.height - num855); + int num854 = 80; + int num855 = 20; + Vector2 position2 = new Vector2(npc.Center.X - (num854 / 2), npc.position.Y + npc.height - num855); - bool fallDownOnTopOfTarget = 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; - if (fallDownOnTopOfTarget) - { - npc.velocity.Y += 0.5f; - } - else if (Collision.SolidCollision(position2, num854, num855)) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = 0f; + bool fallDownOnTopOfTarget = 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; + if (fallDownOnTopOfTarget) + { + npc.velocity.Y += 0.5f; + } + else if (Collision.SolidCollision(position2, num854, num855)) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y = 0f; - if (npc.velocity.Y > -0.2f) - npc.velocity.Y -= 0.025f; - else - npc.velocity.Y -= 0.2f; + if (npc.velocity.Y > -0.2f) + npc.velocity.Y -= 0.025f; + else + npc.velocity.Y -= 0.2f; - if (npc.velocity.Y < -4f) - npc.velocity.Y = -4f; - } - else - { - if (npc.velocity.Y < 0f) - npc.velocity.Y = 0f; + if (npc.velocity.Y < -4f) + npc.velocity.Y = -4f; + } + else + { + if (npc.velocity.Y < 0f) + npc.velocity.Y = 0f; - if (npc.velocity.Y < 0.1f) - npc.velocity.Y += 0.025f; - else - npc.velocity.Y += 0.5f; - } - } + if (npc.velocity.Y < 0.1f) + npc.velocity.Y += 0.025f; + else + npc.velocity.Y += 0.5f; + } + } npc.ai[1] += 1f; if (npc.ai[1] >= (360f - (death ? 120f * (1f - lifeRatio) : 0f))) { - npc.TargetClosest(); - npc.noGravity = false; + npc.TargetClosest(); + npc.noGravity = false; npc.noTileCollide = false; npc.ai[0] = 3f; npc.ai[1] = 0f; @@ -349,87 +349,87 @@ namespace CalamityMod.NPCs.Crabulon if (npc.ai[1] > 0f) { - if (revenge) - { - switch ((int)npc.ai[3]) - { - case 0: - break; - case 1: - case 2: - npc.ai[1] += 3f; - break; - case 3: - npc.ai[1] += 6f; - break; - default: - break; - } - } + if (revenge) + { + switch ((int)npc.ai[3]) + { + case 0: + break; + case 1: + case 2: + npc.ai[1] += 3f; + break; + case 3: + npc.ai[1] += 6f; + break; + default: + break; + } + } if (phase2) npc.ai[1] += !revenge ? 4f : 1f; if (phase3) npc.ai[1] += !revenge ? 4f : 1f; } - float jumpGateValue = (malice ? 30f : 240f) / (enrageScale + 1f); + float jumpGateValue = (malice ? 30f : 240f) / (enrageScale + 1f); if (npc.ai[1] >= jumpGateValue) { npc.ai[1] = -20f; } else if (npc.ai[1] == -1f) { - int velocityX = 4; - float velocityY = -12f; + int velocityX = 4; + float velocityY = -12f; - float distanceBelowTarget = npc.position.Y - (player.position.Y + 80f); - float speedMult = 1f; + float distanceBelowTarget = npc.position.Y - (player.position.Y + 80f); + float speedMult = 1f; - if (revenge) - { - switch ((int)npc.ai[3]) - { - case 0: // Normal - break; - case 1: // High - velocityY -= 4f; - break; - case 2: // Low - velocityY += 4f; - break; - case 3: // Long and low - velocityX += 4; - velocityY += 4f; - break; - default: - break; - } + if (revenge) + { + switch ((int)npc.ai[3]) + { + case 0: // Normal + break; + case 1: // High + velocityY -= 4f; + break; + case 2: // Low + velocityY += 4f; + break; + case 3: // Long and low + velocityX += 4; + velocityY += 4f; + break; + default: + break; + } - if (distanceBelowTarget > 0f) - speedMult += distanceBelowTarget * 0.001f; + if (distanceBelowTarget > 0f) + speedMult += distanceBelowTarget * 0.001f; - if (speedMult > 2f) - speedMult = 2f; + if (speedMult > 2f) + speedMult = 2f; - velocityY *= speedMult; - } + velocityY *= speedMult; + } - if (expertMode) - { - if (player.position.Y < npc.Bottom.Y) - npc.velocity.Y = velocityY; - else - npc.velocity.Y = 1f; + if (expertMode) + { + if (player.position.Y < npc.Bottom.Y) + npc.velocity.Y = velocityY; + else + npc.velocity.Y = 1f; - npc.noTileCollide = true; - } - else - npc.velocity.Y = velocityY; + npc.noTileCollide = true; + } + else + npc.velocity.Y = velocityY; - float playerLocation = npc.Center.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; + float playerLocation = npc.Center.X - player.Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; - npc.velocity.X = velocityX * npc.direction; + npc.velocity.X = velocityX * npc.direction; npc.ai[0] = 4f; npc.ai[1] = 0f; @@ -443,32 +443,32 @@ namespace CalamityMod.NPCs.Crabulon { Main.PlaySound(SoundID.Item14, npc.position); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); - if (npc.ai[2] % 2f == 0f && phase2 && revenge) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float velocityX = npc.ai[2] == 0f ? -4f : 4f; - int totalMushrooms = malice ? 50 : 20; - int shotSpacingDecrement = malice ? 80 : 100; - if (malice) - shotSpacing = 2000; + if (npc.ai[2] % 2f == 0f && phase2 && revenge) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float velocityX = npc.ai[2] == 0f ? -4f : 4f; + int totalMushrooms = malice ? 50 : 20; + int shotSpacingDecrement = malice ? 80 : 100; + if (malice) + shotSpacing = 2000; - for (int x = 0; x < totalMushrooms; x++) - { - Projectile.NewProjectile(npc.Center.X + shotSpacing, npc.Center.Y - 1000f, velocityX, 0f, type, damage, 0f, Main.myPlayer, 0f, 0f); - shotSpacing -= shotSpacingDecrement; - } + for (int x = 0; x < totalMushrooms; x++) + { + Projectile.NewProjectile(npc.Center.X + shotSpacing, npc.Center.Y - 1000f, velocityX, 0f, type, damage, 0f, Main.myPlayer, 0f, 0f); + shotSpacing -= shotSpacingDecrement; + } - shotSpacing = malice ? 2000 : 1000; - } - } + shotSpacing = malice ? 2000 : 1000; + } + } - npc.TargetClosest(); - npc.ai[2] += 1f; - if (npc.ai[2] >= (phase2 ? 4f : 3f)) + npc.TargetClosest(); + npc.ai[2] += 1f; + if (npc.ai[2] >= (phase2 ? 4f : 3f)) { if (Main.netMode != NetmodeID.MultiplayerClient && revenge && !phase2) { @@ -482,18 +482,18 @@ namespace CalamityMod.NPCs.Crabulon npc.ai[0] = 1f; npc.ai[2] = 0f; - if (revenge) - npc.ai[3] = 0f; + if (revenge) + npc.ai[3] = 0f; npc.netUpdate = true; } else { - float playerLocation = npc.Center.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; + float playerLocation = npc.Center.X - player.Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; - npc.ai[0] = 3f; - if (revenge) - npc.ai[3] += 1f; + npc.ai[0] = 3f; + if (revenge) + npc.ai[3] += 1f; npc.netUpdate = true; } @@ -509,26 +509,26 @@ namespace CalamityMod.NPCs.Crabulon } else { - if (!player.dead && expertMode) - { - if ((player.position.Y > npc.Bottom.Y && npc.velocity.Y > 0f) || (player.position.Y < npc.Bottom.Y && npc.velocity.Y < 0f)) - npc.noTileCollide = true; - else if ((npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) || (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height))) - npc.noTileCollide = false; - } + if (!player.dead && expertMode) + { + if ((player.position.Y > npc.Bottom.Y && npc.velocity.Y > 0f) || (player.position.Y < npc.Bottom.Y && npc.velocity.Y < 0f)) + npc.noTileCollide = true; + else if ((npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) || (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height))) + npc.noTileCollide = false; + } - if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width) + if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width) { npc.velocity.X *= 0.9f; npc.velocity.Y += death ? 0.18f : 0.15f; } else { - float velocityX = 0.11f + - (expertMode ? 0.02f : 0f) + - (revenge ? 0.02f : 0f) + - (death ? 0.02f : 0f); - velocityX += 0.05f * enrageScale; + float velocityX = 0.11f + + (expertMode ? 0.02f : 0f) + + (revenge ? 0.02f : 0f) + + (death ? 0.02f : 0f); + velocityX += 0.05f * enrageScale; if (npc.direction < 0) npc.velocity.X -= velocityX; @@ -536,7 +536,7 @@ namespace CalamityMod.NPCs.Crabulon npc.velocity.X += velocityX; float num626 = 2.5f; - num626 += enrageScale; + num626 += enrageScale; if (revenge) { num626 += 1f; @@ -593,71 +593,71 @@ namespace CalamityMod.NPCs.Crabulon } } - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - Vector2 npcCenter = npc.Center; + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Vector2 npcCenter = npc.Center; - // NOTE: Right and left hitboxes are interchangeable, each hitbox is the same size and is located to the right or left of the center hitbox. - Rectangle leftHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 2f) + 6f), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); - Rectangle bodyHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 4f)), (int)(npcCenter.Y - (npc.height / 2f)), npc.width / 2, npc.height); - Rectangle rightHitbox = new Rectangle((int)(npcCenter.X + (npc.width / 4f) - 6f), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); + // NOTE: Right and left hitboxes are interchangeable, each hitbox is the same size and is located to the right or left of the center hitbox. + Rectangle leftHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 2f) + 6f), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); + Rectangle bodyHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 4f)), (int)(npcCenter.Y - (npc.height / 2f)), npc.width / 2, npc.height); + Rectangle rightHitbox = new Rectangle((int)(npcCenter.X + (npc.width / 4f) - 6f), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); - Vector2 leftHitboxCenter = new Vector2(leftHitbox.X + (leftHitbox.Width / 2), leftHitbox.Y + (leftHitbox.Height / 2)); - Vector2 bodyHitboxCenter = new Vector2(bodyHitbox.X + (bodyHitbox.Width / 2), bodyHitbox.Y + (bodyHitbox.Height / 2)); - Vector2 rightHitboxCenter = new Vector2(rightHitbox.X + (rightHitbox.Width / 2), rightHitbox.Y + (rightHitbox.Height / 2)); + Vector2 leftHitboxCenter = new Vector2(leftHitbox.X + (leftHitbox.Width / 2), leftHitbox.Y + (leftHitbox.Height / 2)); + Vector2 bodyHitboxCenter = new Vector2(bodyHitbox.X + (bodyHitbox.Width / 2), bodyHitbox.Y + (bodyHitbox.Height / 2)); + Vector2 rightHitboxCenter = new Vector2(rightHitbox.X + (rightHitbox.Width / 2), rightHitbox.Y + (rightHitbox.Height / 2)); - Rectangle targetHitbox = target.Hitbox; + Rectangle targetHitbox = target.Hitbox; - float leftDist1 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopLeft()); - float leftDist2 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopRight()); - float leftDist3 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomLeft()); - float leftDist4 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomRight()); + float leftDist1 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopLeft()); + float leftDist2 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopRight()); + float leftDist3 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomLeft()); + float leftDist4 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomRight()); - float minLeftDist = leftDist1; - if (leftDist2 < minLeftDist) - minLeftDist = leftDist2; - if (leftDist3 < minLeftDist) - minLeftDist = leftDist3; - if (leftDist4 < minLeftDist) - minLeftDist = leftDist4; + float minLeftDist = leftDist1; + if (leftDist2 < minLeftDist) + minLeftDist = leftDist2; + if (leftDist3 < minLeftDist) + minLeftDist = leftDist3; + if (leftDist4 < minLeftDist) + minLeftDist = leftDist4; - bool insideLeftHitbox = minLeftDist <= 45f; + bool insideLeftHitbox = minLeftDist <= 45f; - float bodyDist1 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopLeft()); - float bodyDist2 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopRight()); - float bodyDist3 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomLeft()); - float bodyDist4 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomRight()); + float bodyDist1 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopLeft()); + float bodyDist2 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopRight()); + float bodyDist3 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomLeft()); + float bodyDist4 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomRight()); - float minBodyDist = bodyDist1; - if (bodyDist2 < minBodyDist) - minBodyDist = bodyDist2; - if (bodyDist3 < minBodyDist) - minBodyDist = bodyDist3; - if (bodyDist4 < minBodyDist) - minBodyDist = bodyDist4; + float minBodyDist = bodyDist1; + if (bodyDist2 < minBodyDist) + minBodyDist = bodyDist2; + if (bodyDist3 < minBodyDist) + minBodyDist = bodyDist3; + if (bodyDist4 < minBodyDist) + minBodyDist = bodyDist4; - bool insideBodyHitbox = minBodyDist <= 90f; + bool insideBodyHitbox = minBodyDist <= 90f; - float rightDist1 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopLeft()); - float rightDist2 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopRight()); - float rightDist3 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomLeft()); - float rightDist4 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomRight()); + float rightDist1 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopLeft()); + float rightDist2 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopRight()); + float rightDist3 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomLeft()); + float rightDist4 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomRight()); - float minRightDist = rightDist1; - if (rightDist2 < minRightDist) - minRightDist = rightDist2; - if (rightDist3 < minRightDist) - minRightDist = rightDist3; - if (rightDist4 < minRightDist) - minRightDist = rightDist4; + float minRightDist = rightDist1; + if (rightDist2 < minRightDist) + minRightDist = rightDist2; + if (rightDist3 < minRightDist) + minRightDist = rightDist3; + if (rightDist4 < minRightDist) + minRightDist = rightDist4; - bool insideRightHitbox = minRightDist <= 45f; + bool insideRightHitbox = minRightDist <= 45f; - return (insideLeftHitbox || insideBodyHitbox || insideRightHitbox) && npc.ai[0] > 1f; - } + return (insideLeftHitbox || insideBodyHitbox || insideRightHitbox) && npc.ai[0] > 1f; + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -667,65 +667,65 @@ namespace CalamityMod.NPCs.Crabulon public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D glow = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabulonIdleGlow"); - Texture2D texture = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabulonIdleAlt"); - Texture2D textureGlow = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabulonIdleAltGlow"); - Texture2D textureAttack = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabulonAttack"); - Texture2D textureAttackGlow = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabulonAttackGlow"); + Texture2D glow = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabulonIdleGlow"); + Texture2D texture = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabulonIdleAlt"); + Texture2D textureGlow = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabulonIdleAltGlow"); + Texture2D textureAttack = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabulonAttack"); + Texture2D textureAttackGlow = ModContent.GetTexture("CalamityMod/NPCs/Crabulon/CrabulonAttackGlow"); - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(Main.npcTexture[npc.type].Width, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(Main.npcTexture[npc.type].Width, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - if (npc.ai[0] > 2f) - { - vector11 = new Vector2(textureAttack.Width / 2, textureAttack.Height / 2); - vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(textureAttack.Width, textureAttack.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + if (npc.ai[0] > 2f) + { + vector11 = new Vector2(textureAttack.Width / 2, textureAttack.Height / 2); + vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(textureAttack.Width, textureAttack.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(textureAttack, vector43, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(textureAttack, vector43, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - spriteBatch.Draw(textureAttackGlow, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - else if (npc.ai[0] == 2f) - { - vector11 = new Vector2(texture.Width / 2, texture.Height / 2); - vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(textureAttackGlow, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + else if (npc.ai[0] == 2f) + { + vector11 = new Vector2(texture.Width / 2, texture.Height / 2); + vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, vector43, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, vector43, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - spriteBatch.Draw(textureGlow, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - else - { - spriteBatch.Draw(Main.npcTexture[npc.type], vector43, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(textureGlow, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + else + { + spriteBatch.Draw(Main.npcTexture[npc.type], vector43, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - spriteBatch.Draw(glow, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + spriteBatch.Draw(glow, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } - return false; + return false; } public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedCrabulon); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) { // Materials DropHelper.DropItem(npc, ItemID.GlowingMushroom, 20, 30); @@ -741,11 +741,11 @@ namespace CalamityMod.NPCs.Crabulon DropHelper.WeightStack(w) ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); } // Mark Crabulon as dead diff --git a/NPCs/Crags/CalamityEye.cs b/NPCs/Crags/CalamityEye.cs index a630a3b18c..2d6d87dc6c 100644 --- a/NPCs/Crags/CalamityEye.cs +++ b/NPCs/Crags/CalamityEye.cs @@ -8,7 +8,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.Crags { - public class CalamityEye : ModNPC + public class CalamityEye : ModNPC { public override void SetStaticDefaults() { @@ -38,62 +38,62 @@ namespace CalamityMod.NPCs.Crags } banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { - if (npc.life < npc.lifeMax * 0.5) - { - if (npc.direction == -1 && npc.velocity.X > -6f) - { - npc.velocity.X -= 0.1f; - if (npc.velocity.X > 6f) - npc.velocity.X -= 0.1f; - else if (npc.velocity.X > 0f) - npc.velocity.X += 0.05f; - if (npc.velocity.X < -6f) - npc.velocity.X = -6f; - } - else if (npc.direction == 1 && npc.velocity.X < 6f) - { - npc.velocity.X += 0.1f; - if (npc.velocity.X < -6f) - npc.velocity.X += 0.1f; - else if (npc.velocity.X < 0f) - npc.velocity.X -= 0.05f; - if (npc.velocity.X > 6f) - npc.velocity.X = 6f; - } - if (npc.directionY == -1 && npc.velocity.Y > -4f) - { - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y > 4f) - npc.velocity.Y -= 0.1f; - else if (npc.velocity.Y > 0f) - npc.velocity.Y += 0.05f; - if (npc.velocity.Y < -4f) - npc.velocity.Y = -4f; - } - else if (npc.directionY == 1 && npc.velocity.Y < 4f) - { - npc.velocity.Y += 0.1f; - if (npc.velocity.Y < -4f) - npc.velocity.Y += 0.1f; - else if (npc.velocity.Y < 0f) - npc.velocity.Y -= 0.05f; - if (npc.velocity.Y > 4f) - npc.velocity.Y = 4f; - } - } - if (Main.rand.NextBool(40)) - { - int index = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5), DustID.Blood, npc.velocity.X, 2f, 0, new Color(), 1f); - Main.dust[index].velocity.X *= 0.5f; - Main.dust[index].velocity.Y *= 0.1f; - } + if (npc.life < npc.lifeMax * 0.5) + { + if (npc.direction == -1 && npc.velocity.X > -6f) + { + npc.velocity.X -= 0.1f; + if (npc.velocity.X > 6f) + npc.velocity.X -= 0.1f; + else if (npc.velocity.X > 0f) + npc.velocity.X += 0.05f; + if (npc.velocity.X < -6f) + npc.velocity.X = -6f; + } + else if (npc.direction == 1 && npc.velocity.X < 6f) + { + npc.velocity.X += 0.1f; + if (npc.velocity.X < -6f) + npc.velocity.X += 0.1f; + else if (npc.velocity.X < 0f) + npc.velocity.X -= 0.05f; + if (npc.velocity.X > 6f) + npc.velocity.X = 6f; + } + if (npc.directionY == -1 && npc.velocity.Y > -4f) + { + npc.velocity.Y -= 0.1f; + if (npc.velocity.Y > 4f) + npc.velocity.Y -= 0.1f; + else if (npc.velocity.Y > 0f) + npc.velocity.Y += 0.05f; + if (npc.velocity.Y < -4f) + npc.velocity.Y = -4f; + } + else if (npc.directionY == 1 && npc.velocity.Y < 4f) + { + npc.velocity.Y += 0.1f; + if (npc.velocity.Y < -4f) + npc.velocity.Y += 0.1f; + else if (npc.velocity.Y < 0f) + npc.velocity.Y -= 0.05f; + if (npc.velocity.Y > 4f) + npc.velocity.Y = 4f; + } + } + if (Main.rand.NextBool(40)) + { + int index = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5), DustID.Blood, npc.velocity.X, 2f, 0, new Color(), 1f); + Main.dust[index].velocity.X *= 0.5f; + Main.dust[index].velocity.Y *= 0.1f; + } } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/Crags/CharredSlime.cs b/NPCs/Crags/CharredSlime.cs index 556ef2e751..8bbd199ced 100644 --- a/NPCs/Crags/CharredSlime.cs +++ b/NPCs/Crags/CharredSlime.cs @@ -20,7 +20,7 @@ namespace CalamityMod.NPCs.Crags public override void SetDefaults() { npc.aiStyle = 1; - aiType = NPCID.LavaSlime; + aiType = NPCID.LavaSlime; npc.damage = 40; npc.width = 40; npc.height = 30; @@ -43,10 +43,10 @@ namespace CalamityMod.NPCs.Crags } banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { @@ -57,12 +57,12 @@ namespace CalamityMod.NPCs.Crags return spawnInfo.player.Calamity().ZoneCalamity ? 0.08f : 0f; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 120, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 120, true); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/Crags/CultistAssassin.cs b/NPCs/Crags/CultistAssassin.cs index bdefcbf5e5..8dd10b22f1 100644 --- a/NPCs/Crags/CultistAssassin.cs +++ b/NPCs/Crags/CultistAssassin.cs @@ -38,23 +38,23 @@ namespace CalamityMod.NPCs.Crags } banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { return (spawnInfo.player.Calamity().ZoneCalamity || spawnInfo.player.ZoneDungeon) && Main.hardMode ? 0.04f : 0f; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 120, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 120, true); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { @@ -66,9 +66,9 @@ namespace CalamityMod.NPCs.Crags { Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CultistAssassinGores/CultistAssassin"), npc.scale); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CultistAssassinGores/CultistAssassin2"), npc.scale); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CultistAssassinGores/CultistAssassin3"), npc.scale); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CultistAssassinGores/CultistAssassin"), npc.scale); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CultistAssassinGores/CultistAssassin2"), npc.scale); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CultistAssassinGores/CultistAssassin3"), npc.scale); } } diff --git a/NPCs/Crags/DespairStone.cs b/NPCs/Crags/DespairStone.cs index 2faff3028d..2e4d8abed1 100644 --- a/NPCs/Crags/DespairStone.cs +++ b/NPCs/Crags/DespairStone.cs @@ -8,7 +8,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.Crags { - public class DespairStone : ModNPC + public class DespairStone : ModNPC { public override void SetStaticDefaults() { @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.Crags npc.width = 72; npc.height = 72; npc.defense = 38; - npc.DR_NERD(0.35f); + npc.DR_NERD(0.35f); npc.lifeMax = 120; npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 0, 5, 0); @@ -39,10 +39,10 @@ namespace CalamityMod.NPCs.Crags } banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { @@ -60,12 +60,12 @@ namespace CalamityMod.NPCs.Crags DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode, 3, 1, 1); } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 120, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 120, true); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/Crags/HeatSpirit.cs b/NPCs/Crags/HeatSpirit.cs index dcd04ad798..64bf158a0f 100644 --- a/NPCs/Crags/HeatSpirit.cs +++ b/NPCs/Crags/HeatSpirit.cs @@ -30,17 +30,17 @@ namespace CalamityMod.NPCs.Crags npc.DeathSound = SoundID.NPCDeath55; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.player.Calamity().ZoneCalamity ? 0.125f : 0f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return spawnInfo.player.Calamity().ZoneCalamity ? 0.125f : 0f; + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { if (npc.velocity.X < 0f) { @@ -92,7 +92,7 @@ namespace CalamityMod.NPCs.Crags public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode, 4, 1, 1); - } + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode, 4, 1, 1); + } } } diff --git a/NPCs/Crags/Scryllar.cs b/NPCs/Crags/Scryllar.cs index a0a405db5e..30e059fdc7 100644 --- a/NPCs/Crags/Scryllar.cs +++ b/NPCs/Crags/Scryllar.cs @@ -42,10 +42,10 @@ namespace CalamityMod.NPCs.Crags } banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { @@ -257,17 +257,17 @@ namespace CalamityMod.NPCs.Crags public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence, 20, 1, 1); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence, 2, 1, 1); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence, 20, 1, 1); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence, 2, 1, 1); DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode, 3, 1, 1); } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 120, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 120, true); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/Crags/ScryllarRage.cs b/NPCs/Crags/ScryllarRage.cs index db8f0add26..7c6d76f1c9 100644 --- a/NPCs/Crags/ScryllarRage.cs +++ b/NPCs/Crags/ScryllarRage.cs @@ -42,10 +42,10 @@ namespace CalamityMod.NPCs.Crags } banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { @@ -257,17 +257,17 @@ namespace CalamityMod.NPCs.Crags public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence, 20, 1, 1); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence, 2, 1, 1); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence, 20, 1, 1); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence, 2, 1, 1); DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode, 3, 1, 1); } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 120, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 120, true); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/Crags/SoulSlurper.cs b/NPCs/Crags/SoulSlurper.cs index ef6f5f6581..b306014d2d 100644 --- a/NPCs/Crags/SoulSlurper.cs +++ b/NPCs/Crags/SoulSlurper.cs @@ -18,8 +18,8 @@ namespace CalamityMod.NPCs.Crags public override void SetStaticDefaults() { DisplayName.SetDefault("Soul Slurper"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.Crags npc.width = 60; npc.height = 40; npc.defense = 30; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 60; npc.knockBackResist = 0.65f; npc.value = Item.buyPrice(0, 0, 5, 0); @@ -46,10 +46,10 @@ namespace CalamityMod.NPCs.Crags } banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { @@ -59,7 +59,7 @@ namespace CalamityMod.NPCs.Crags public override void AI() { bool provy = CalamityWorld.downedProvidence; - Player target = Main.player[npc.target]; + Player target = Main.player[npc.target]; if (npc.target < 0 || npc.target == 255 || target.dead) { npc.TargetClosest(true); @@ -222,59 +222,59 @@ namespace CalamityMod.NPCs.Crags } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(texture.Width / 2), (float)(texture.Height / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Texture2D texture = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(texture.Width / 2), (float)(texture.Height / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture.Width, (float)(texture.Height)) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture.Width, (float)(texture.Height)) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture.Width, (float)(texture.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture.Width, (float)(texture.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture = ModContent.GetTexture("CalamityMod/NPCs/Crags/SoulSlurperGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + texture = ModContent.GetTexture("CalamityMod/NPCs/Crags/SoulSlurperGlow"); + Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture.Width, (float)(texture.Height)) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, npc.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture.Width, (float)(texture.Height)) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, npc.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); + } + } - spriteBatch.Draw(texture, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, npc.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(texture, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, npc.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); - return false; - } + return false; + } public override void NPCLoot() { @@ -283,12 +283,12 @@ namespace CalamityMod.NPCs.Crags DropHelper.DropItemChance(npc, ModContent.ItemType(), (Main.hardMode ? 30 : 10)); } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 120, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 120, true); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) { diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index 61fe151446..2adc6464d7 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -29,8 +29,8 @@ namespace CalamityMod.NPCs.Cryogen [AutoloadBossHead] public class Cryogen : ModNPC { - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private int time = 0; + private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + private int time = 0; private int iceShard = 0; private int currentPhase = 1; private int teleportLocationX = 0; @@ -44,13 +44,13 @@ namespace CalamityMod.NPCs.Cryogen public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 24f; - npc.GetNPCDamage(); - npc.width = 86; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 24f; + npc.GetNPCDamage(); + npc.width = 86; npc.height = 88; npc.defense = 12; - npc.DR_NERD(0.3f); + npc.DR_NERD(0.3f); npc.LifeMaxNERB(30000, 36000, 300000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -63,95 +63,95 @@ namespace CalamityMod.NPCs.Cryogen npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit5; npc.DeathSound = SoundID.NPCDeath15; - music = CalamityMod.Instance.GetMusicFromMusicMod("Cryogen") ?? MusicID.FrostMoon; + music = CalamityMod.Instance.GetMusicFromMusicMod("Cryogen") ?? MusicID.FrostMoon; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = false; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = false; + npc.Calamity().VulnerableToSickness = false; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); - writer.Write(time); + writer.Write(biomeEnrageTimer); + writer.Write(time); writer.Write(iceShard); writer.Write(teleportLocationX); writer.Write(npc.dontTakeDamage); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); - time = reader.ReadInt32(); + biomeEnrageTimer = reader.ReadInt32(); + time = reader.ReadInt32(); iceShard = reader.ReadInt32(); teleportLocationX = reader.ReadInt32(); npc.dontTakeDamage = reader.ReadBoolean(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0f, 1f, 1f); - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Enrage - if (!player.ZoneSnow && !BossRushEvent.BossRushActive) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + // Enrage + if (!player.ZoneSnow && !BossRushEvent.BossRushActive) + { + if (biomeEnrageTimer > 0) + biomeEnrageTimer--; + } + else + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || malice; + bool biomeEnraged = biomeEnrageTimer <= 0 || malice; - float enrageScale = death ? 0.5f : 0f; - if (biomeEnraged) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 2f; - } + float enrageScale = death ? 0.5f : 0f; + if (biomeEnraged) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } - if (enrageScale > 2f) - enrageScale = 2f; + if (enrageScale > 2f) + enrageScale = 2f; - if (BossRushEvent.BossRushActive) - enrageScale = 3f; + if (BossRushEvent.BossRushActive) + enrageScale = 3f; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Phases - bool phase2 = lifeRatio < (revenge ? 0.85f : 0.8f) || death; - bool phase3 = lifeRatio < (death ? 0.8f : revenge ? 0.7f : 0.6f); - bool phase4 = lifeRatio < (death ? 0.6f : revenge ? 0.55f : 0.4f); - bool phase5 = lifeRatio < (death ? 0.5f : revenge ? 0.45f : 0.3f); - bool phase6 = lifeRatio < (death ? 0.35f : 0.25f) && revenge; - bool phase7 = lifeRatio < (death ? 0.25f : 0.15f) && revenge; + // Phases + bool phase2 = lifeRatio < (revenge ? 0.85f : 0.8f) || death; + bool phase3 = lifeRatio < (death ? 0.8f : revenge ? 0.7f : 0.6f); + bool phase4 = lifeRatio < (death ? 0.6f : revenge ? 0.55f : 0.4f); + bool phase5 = lifeRatio < (death ? 0.5f : revenge ? 0.45f : 0.3f); + bool phase6 = lifeRatio < (death ? 0.35f : 0.25f) && revenge; + bool phase7 = lifeRatio < (death ? 0.25f : 0.15f) && revenge; - if ((int)npc.ai[0] + 1 > currentPhase) + if ((int)npc.ai[0] + 1 > currentPhase) HandlePhaseTransition((int)npc.ai[0] + 1); - if (npc.ai[2] == 0f && npc.localAI[1] == 0f && Main.netMode != NetmodeID.MultiplayerClient && (npc.ai[0] < 3f || BossRushEvent.BossRushActive || (death && npc.ai[0] > 3f))) //spawn shield for phase 0 1 2, not 3 4 5 + if (npc.ai[2] == 0f && npc.localAI[1] == 0f && Main.netMode != NetmodeID.MultiplayerClient && (npc.ai[0] < 3f || BossRushEvent.BossRushActive || (death && npc.ai[0] > 3f))) //spawn shield for phase 0 1 2, not 3 4 5 { int num6 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI); npc.ai[2] = num6 + 1; @@ -177,88 +177,88 @@ namespace CalamityMod.NPCs.Cryogen npc.localAI[1] -= 1f; } - CalamityMod.StopRain(); + CalamityMod.StopRain(); - if (!player.active || player.dead) + if (!player.active || player.dead) { npc.TargetClosest(false); player = Main.player[npc.target]; if (!player.active || player.dead) { - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + npc.velocity.Y -= 0.1f; + if (npc.velocity.Y < -12f) + npc.velocity.Y = -12f; - if (npc.timeLeft > 60) + if (npc.timeLeft > 60) npc.timeLeft = 60; - if (npc.ai[1] != 0f) - { - npc.ai[1] = 0f; - teleportLocationX = 0; - iceShard = 0; - npc.netUpdate = true; - } - return; + if (npc.ai[1] != 0f) + { + npc.ai[1] = 0f; + teleportLocationX = 0; + iceShard = 0; + npc.netUpdate = true; + } + return; } } else if (npc.timeLeft < 1800) npc.timeLeft = 1800; - float chargeGateValue = malice ? 240f : 360f; - bool charging = npc.ai[1] >= chargeGateValue; + float chargeGateValue = malice ? 240f : 360f; + bool charging = npc.ai[1] >= chargeGateValue; - if (Main.netMode != NetmodeID.MultiplayerClient && expertMode && (npc.ai[0] < 5f || !phase6) && !charging) + if (Main.netMode != NetmodeID.MultiplayerClient && expertMode && (npc.ai[0] < 5f || !phase6) && !charging) { time++; if (time >= (malice ? 480 : 600)) { - time = 0; - Main.PlaySound(SoundID.Item28, npc.Center); - int totalProjectiles = 3; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity = 2f + npc.ai[0]; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, npc.ai[0] * 0.5f); - } + time = 0; + Main.PlaySound(SoundID.Item28, npc.Center); + int totalProjectiles = 3; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float velocity = 2f + npc.ai[0]; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, npc.ai[0] * 0.5f); + } } } - if (npc.ai[0] == 0f) + if (npc.ai[0] == 0f) { - npc.rotation = npc.velocity.X * 0.1f; + npc.rotation = npc.velocity.X * 0.1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[0] += 1f; if (npc.localAI[0] >= 120f) { npc.localAI[0] = 0f; - npc.TargetClosest(); + npc.TargetClosest(); if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { - Main.PlaySound(SoundID.Item28, npc.Center); - int totalProjectiles = malice ? 24 : 16; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity = 9f + enrageScale; - Vector2 spinningPoint = new Vector2(0f, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); - } + Main.PlaySound(SoundID.Item28, npc.Center); + int totalProjectiles = malice ? 24 : 16; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float velocity = 9f + enrageScale; + Vector2 spinningPoint = new Vector2(0f, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); + } } } } @@ -269,7 +269,7 @@ namespace CalamityMod.NPCs.Cryogen float num1245 = (float)Math.Sqrt(num1243 * num1243 + num1244 * num1244); float num1246 = revenge ? 5f : 4f; - num1246 += 4f * enrageScale; + num1246 += 4f * enrageScale; num1245 = num1246 / num1245; num1243 *= num1245; @@ -279,303 +279,303 @@ namespace CalamityMod.NPCs.Cryogen if (phase2) { - npc.TargetClosest(); - npc.ai[0] = 1f; + npc.TargetClosest(); + npc.ai[0] = 1f; npc.localAI[0] = 0f; npc.netUpdate = true; } } else if (npc.ai[0] == 1f) { - if (npc.ai[1] < chargeGateValue) - { - npc.ai[1] += 1f; - - npc.rotation = npc.velocity.X * 0.1f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= 120f) - { - npc.localAI[0] = 0f; - npc.TargetClosest(); - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - Main.PlaySound(SoundID.Item28, npc.Center); - int totalProjectiles = malice ? 18 : 12; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity2 = 9f + enrageScale; - Vector2 spinningPoint = new Vector2(0f, -velocity2); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); - } - } - } - } - - float velocity = revenge ? 3.5f : 4f; - float acceleration = 0.15f; - velocity -= enrageScale * 0.8f; - acceleration += 0.07f * enrageScale; - - if (npc.position.Y > player.position.Y - 375f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= 0.98f; - - npc.velocity.Y -= acceleration; - - if (npc.velocity.Y > velocity) - npc.velocity.Y = velocity; - } - else if (npc.position.Y < player.position.Y - 425f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.98f; - - npc.velocity.Y += acceleration; - - if (npc.velocity.Y < -velocity) - npc.velocity.Y = -velocity; - } - - if (npc.position.X + (npc.width / 2) > player.position.X + (player.width / 2) + 300f) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= 0.98f; - - npc.velocity.X -= acceleration; - - if (npc.velocity.X > velocity) - npc.velocity.X = velocity; - } - if (npc.position.X + (npc.width / 2) < player.position.X + (player.width / 2) - 300f) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= 0.98f; - - npc.velocity.X += acceleration; - - if (npc.velocity.X < -velocity) - npc.velocity.X = -velocity; - } - } - else if (npc.ai[1] < chargeGateValue + 30f) - { - npc.ai[1] += 1f; - - calamityGlobalNPC.newAI[0] += 0.025f; - if (calamityGlobalNPC.newAI[0] > 0.5f) - calamityGlobalNPC.newAI[0] = 0.5f; - - npc.rotation += calamityGlobalNPC.newAI[0]; - npc.velocity *= 0.98f; - } - else - { - if (npc.ai[1] == chargeGateValue + 30f) - { - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (18f + enrageScale * 2f); - - npc.ai[1] = chargeGateValue + 90f; - calamityGlobalNPC.newAI[0] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - Main.PlaySound(SoundID.Item28, npc.Center); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity = 9f + enrageScale; - for (int i = 0; i < 2; i++) - { - int totalProjectiles = 10; - float radians = MathHelper.TwoPi / totalProjectiles; - float newVelocity = velocity - (velocity * 0.5f * i); - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = i == 0 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, velocity); - } - } - } - } - } - - npc.ai[1] -= 1f; - if (npc.ai[1] == chargeGateValue + 30f) - { - npc.TargetClosest(); - - npc.ai[1] = 0f; - npc.localAI[0] = 0f; - - npc.rotation = npc.velocity.X * 0.1f; - } - else if (npc.ai[1] <= chargeGateValue + 45f) - { - npc.velocity *= 0.95f; - npc.rotation = npc.velocity.X * 0.15f; - } - else - npc.rotation += npc.direction * 0.5f; - } - - if (phase3) + if (npc.ai[1] < chargeGateValue) { - npc.TargetClosest(); - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.localAI[0] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - iceShard = 0; + npc.ai[1] += 1f; + + npc.rotation = npc.velocity.X * 0.1f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[0] += 1f; + if (npc.localAI[0] >= 120f) + { + npc.localAI[0] = 0f; + npc.TargetClosest(); + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + Main.PlaySound(SoundID.Item28, npc.Center); + int totalProjectiles = malice ? 18 : 12; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float velocity2 = 9f + enrageScale; + Vector2 spinningPoint = new Vector2(0f, -velocity2); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); + } + } + } + } + + float velocity = revenge ? 3.5f : 4f; + float acceleration = 0.15f; + velocity -= enrageScale * 0.8f; + acceleration += 0.07f * enrageScale; + + if (npc.position.Y > player.position.Y - 375f) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y *= 0.98f; + + npc.velocity.Y -= acceleration; + + if (npc.velocity.Y > velocity) + npc.velocity.Y = velocity; + } + else if (npc.position.Y < player.position.Y - 425f) + { + if (npc.velocity.Y < 0f) + npc.velocity.Y *= 0.98f; + + npc.velocity.Y += acceleration; + + if (npc.velocity.Y < -velocity) + npc.velocity.Y = -velocity; + } + + if (npc.position.X + (npc.width / 2) > player.position.X + (player.width / 2) + 300f) + { + if (npc.velocity.X > 0f) + npc.velocity.X *= 0.98f; + + npc.velocity.X -= acceleration; + + if (npc.velocity.X > velocity) + npc.velocity.X = velocity; + } + if (npc.position.X + (npc.width / 2) < player.position.X + (player.width / 2) - 300f) + { + if (npc.velocity.X < 0f) + npc.velocity.X *= 0.98f; + + npc.velocity.X += acceleration; + + if (npc.velocity.X < -velocity) + npc.velocity.X = -velocity; + } + } + else if (npc.ai[1] < chargeGateValue + 30f) + { + npc.ai[1] += 1f; + + calamityGlobalNPC.newAI[0] += 0.025f; + if (calamityGlobalNPC.newAI[0] > 0.5f) + calamityGlobalNPC.newAI[0] = 0.5f; + + npc.rotation += calamityGlobalNPC.newAI[0]; + npc.velocity *= 0.98f; + } + else + { + if (npc.ai[1] == chargeGateValue + 30f) + { + npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (18f + enrageScale * 2f); + + npc.ai[1] = chargeGateValue + 90f; + calamityGlobalNPC.newAI[0] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + Main.PlaySound(SoundID.Item28, npc.Center); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float velocity = 9f + enrageScale; + for (int i = 0; i < 2; i++) + { + int totalProjectiles = 10; + float radians = MathHelper.TwoPi / totalProjectiles; + float newVelocity = velocity - (velocity * 0.5f * i); + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = i == 0 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, velocity); + } + } + } + } + } + + npc.ai[1] -= 1f; + if (npc.ai[1] == chargeGateValue + 30f) + { + npc.TargetClosest(); + + npc.ai[1] = 0f; + npc.localAI[0] = 0f; + + npc.rotation = npc.velocity.X * 0.1f; + } + else if (npc.ai[1] <= chargeGateValue + 45f) + { + npc.velocity *= 0.95f; + npc.rotation = npc.velocity.X * 0.15f; + } + else + npc.rotation += npc.direction * 0.5f; + } + + if (phase3) + { + npc.TargetClosest(); + npc.ai[0] = 2f; + npc.ai[1] = 0f; + npc.localAI[0] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + iceShard = 0; npc.netUpdate = true; } } else if (npc.ai[0] == 2f) { - if (npc.ai[1] < chargeGateValue) - { - npc.ai[1] += 1f; - - npc.rotation = npc.velocity.X * 0.1f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= 120f) - { - npc.localAI[0] = 0f; - npc.TargetClosest(); - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - Main.PlaySound(SoundID.Item28, npc.Center); - int totalProjectiles = malice ? 18 : 12; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity = 9f + enrageScale; - Vector2 spinningPoint = new Vector2(0f, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); - } - } - } - } - - Vector2 vector142 = new Vector2(npc.Center.X, npc.Center.Y); - float num1243 = player.Center.X - vector142.X; - float num1244 = player.Center.Y - vector142.Y; - float num1245 = (float)Math.Sqrt(num1243 * num1243 + num1244 * num1244); - - float num1246 = revenge ? 7f : 6f; - num1246 += 4f * enrageScale; - - num1245 = num1246 / num1245; - num1243 *= num1245; - num1244 *= num1245; - npc.velocity.X = (npc.velocity.X * 50f + num1243) / 51f; - npc.velocity.Y = (npc.velocity.Y * 50f + num1244) / 51f; - } - else if (npc.ai[1] < chargeGateValue + 20f) - { - npc.ai[1] += 1f; - - calamityGlobalNPC.newAI[0] += 0.025f; - if (calamityGlobalNPC.newAI[0] > 0.5f) - calamityGlobalNPC.newAI[0] = 0.5f; - - npc.rotation += calamityGlobalNPC.newAI[0]; - npc.velocity *= 0.98f; - } - else - { - if (npc.ai[1] == chargeGateValue + 20f) - { - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (18f + enrageScale * 2f); - - npc.ai[1] = chargeGateValue + 80f; - calamityGlobalNPC.newAI[0] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - Main.PlaySound(SoundID.Item28, npc.Center); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity = 9f + enrageScale; - for (int i = 0; i < 3; i++) - { - int totalProjectiles = 8; - float radians = MathHelper.TwoPi / totalProjectiles; - float newVelocity = velocity - (velocity * 0.33f * i); - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = i == 1 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, velocity); - } - } - } - } - } - - npc.ai[1] -= 1f; - if (npc.ai[1] == chargeGateValue + 20f) - { - npc.TargetClosest(); - - calamityGlobalNPC.newAI[1] += 1f; - if (calamityGlobalNPC.newAI[1] > 1f) - { - npc.ai[1] = 0f; - npc.localAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - } - - npc.rotation = npc.velocity.X * 0.1f; - } - else if (npc.ai[1] <= chargeGateValue + 35f) - { - npc.velocity *= 0.95f; - npc.rotation = npc.velocity.X * 0.15f; - } - else - npc.rotation += npc.direction * 0.5f; - } - - if (phase4) + if (npc.ai[1] < chargeGateValue) { - npc.TargetClosest(); - npc.ai[0] = 3f; - npc.ai[1] = 0f; + npc.ai[1] += 1f; + + npc.rotation = npc.velocity.X * 0.1f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[0] += 1f; + if (npc.localAI[0] >= 120f) + { + npc.localAI[0] = 0f; + npc.TargetClosest(); + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + Main.PlaySound(SoundID.Item28, npc.Center); + int totalProjectiles = malice ? 18 : 12; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float velocity = 9f + enrageScale; + Vector2 spinningPoint = new Vector2(0f, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); + } + } + } + } + + Vector2 vector142 = new Vector2(npc.Center.X, npc.Center.Y); + float num1243 = player.Center.X - vector142.X; + float num1244 = player.Center.Y - vector142.Y; + float num1245 = (float)Math.Sqrt(num1243 * num1243 + num1244 * num1244); + + float num1246 = revenge ? 7f : 6f; + num1246 += 4f * enrageScale; + + num1245 = num1246 / num1245; + num1243 *= num1245; + num1244 *= num1245; + npc.velocity.X = (npc.velocity.X * 50f + num1243) / 51f; + npc.velocity.Y = (npc.velocity.Y * 50f + num1244) / 51f; + } + else if (npc.ai[1] < chargeGateValue + 20f) + { + npc.ai[1] += 1f; + + calamityGlobalNPC.newAI[0] += 0.025f; + if (calamityGlobalNPC.newAI[0] > 0.5f) + calamityGlobalNPC.newAI[0] = 0.5f; + + npc.rotation += calamityGlobalNPC.newAI[0]; + npc.velocity *= 0.98f; + } + else + { + if (npc.ai[1] == chargeGateValue + 20f) + { + npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (18f + enrageScale * 2f); + + npc.ai[1] = chargeGateValue + 80f; + calamityGlobalNPC.newAI[0] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + Main.PlaySound(SoundID.Item28, npc.Center); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float velocity = 9f + enrageScale; + for (int i = 0; i < 3; i++) + { + int totalProjectiles = 8; + float radians = MathHelper.TwoPi / totalProjectiles; + float newVelocity = velocity - (velocity * 0.33f * i); + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = i == 1 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, velocity); + } + } + } + } + } + + npc.ai[1] -= 1f; + if (npc.ai[1] == chargeGateValue + 20f) + { + npc.TargetClosest(); + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] > 1f) + { + npc.ai[1] = 0f; + npc.localAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + } + + npc.rotation = npc.velocity.X * 0.1f; + } + else if (npc.ai[1] <= chargeGateValue + 35f) + { + npc.velocity *= 0.95f; + npc.rotation = npc.velocity.X * 0.15f; + } + else + npc.rotation += npc.direction * 0.5f; + } + + if (phase4) + { + npc.TargetClosest(); + npc.ai[0] = 3f; + npc.ai[1] = 0f; npc.localAI[0] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - npc.netUpdate = true; + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + npc.netUpdate = true; } } else if (npc.ai[0] == 3f) { - npc.rotation = npc.velocity.X * 0.1f; + npc.rotation = npc.velocity.X * 0.1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[0] += 1f; if (npc.localAI[0] >= 90f && npc.Opacity == 1f) @@ -583,18 +583,18 @@ namespace CalamityMod.NPCs.Cryogen npc.localAI[0] = 0f; if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { - Main.PlaySound(SoundID.Item28, npc.Center); - int totalProjectiles = malice ? 18 : 12; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity = 10f + enrageScale; - Vector2 spinningPoint = new Vector2(0f, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); - } + Main.PlaySound(SoundID.Item28, npc.Center); + int totalProjectiles = malice ? 18 : 12; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float velocity = 10f + enrageScale; + Vector2 spinningPoint = new Vector2(0f, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); + } } } } @@ -605,7 +605,7 @@ namespace CalamityMod.NPCs.Cryogen float num1245 = (float)Math.Sqrt(num1243 * num1243 + num1244 * num1244); float speed = revenge ? 5.5f : 5f; - speed += 3f * enrageScale; + speed += 3f * enrageScale; num1245 = speed / num1245; num1243 *= num1245; @@ -620,8 +620,8 @@ namespace CalamityMod.NPCs.Cryogen npc.localAI[2] += 1f; if (npc.localAI[2] >= 180f) { - npc.TargetClosest(); - npc.localAI[2] = 0f; + npc.TargetClosest(); + npc.localAI[2] = 0f; int num1249 = 0; int num1250; int num1251; @@ -680,38 +680,38 @@ namespace CalamityMod.NPCs.Cryogen Main.dust[num39].noGravity = true; } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - npc.localAI[0] = 0f; - Main.PlaySound(SoundID.Item28, npc.Center); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity = 9f + enrageScale; - for (int i = 0; i < 3; i++) - { - int totalProjectiles = malice ? 9 : 6; - float radians = MathHelper.TwoPi / totalProjectiles; - float newVelocity = velocity - (velocity * 0.33f * i); - float velocityX = 0f; - if (i > 0) - { - double angleA = radians * 0.33 * (3 - i); - double angleB = MathHelper.ToRadians(90f) - angleA; - velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); - } - Vector2 spinningPoint = i == 0 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, velocity); - } - } - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + npc.localAI[0] = 0f; + Main.PlaySound(SoundID.Item28, npc.Center); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float velocity = 9f + enrageScale; + for (int i = 0; i < 3; i++) + { + int totalProjectiles = malice ? 9 : 6; + float radians = MathHelper.TwoPi / totalProjectiles; + float newVelocity = velocity - (velocity * 0.33f * i); + float velocityX = 0f; + if (i > 0) + { + double angleA = radians * 0.33 * (3 - i); + double angleB = MathHelper.ToRadians(90f) - angleA; + velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); + } + Vector2 spinningPoint = i == 0 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, velocity); + } + } + } + } - npc.ai[1] = 2f; + npc.ai[1] = 2f; npc.netUpdate = true; } } @@ -726,106 +726,106 @@ namespace CalamityMod.NPCs.Cryogen } } - if (phase5) + if (phase5) { - npc.TargetClosest(); - npc.ai[0] = 4f; + npc.TargetClosest(); + npc.ai[0] = 4f; npc.ai[1] = 0f; - npc.ai[3] = 0f; + npc.ai[3] = 0f; npc.localAI[0] = 0f; npc.localAI[2] = 0f; - npc.Opacity = 1f; + npc.Opacity = 1f; teleportLocationX = 0; iceShard = 0; npc.netUpdate = true; - int chance = 100; - if (DateTime.Now.Month == 4 && DateTime.Now.Day == 1) - chance = 20; + 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.rand.NextBool(chance)) + { + string key = "Mods.CalamityMod.CryogenBossText"; + Color messageColor = Color.Cyan; CalamityUtils.DisplayLocalizedText(key, messageColor); } } } - else if (npc.ai[0] == 4f) - { + else if (npc.ai[0] == 4f) + { npc.damage = npc.defDamage; - if (phase6) - { - if (npc.ai[1] == 60f) - { - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (18f + enrageScale * 2f); + if (phase6) + { + if (npc.ai[1] == 60f) + { + npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (18f + enrageScale * 2f); - if (phase7) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - Main.PlaySound(SoundID.Item28, npc.Center); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity = 9f + enrageScale; - for (int i = 0; i < 4; i++) - { - int totalProjectiles = malice ? 6 : 4; - float radians = MathHelper.TwoPi / totalProjectiles; - float newVelocity = velocity - (velocity * 0.25f * i); - float velocityX = 0f; - if (i > 0) - { - double angleA = radians * 0.25 * (4 - i); - double angleB = MathHelper.ToRadians(90f) - angleA; - velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); - } - Vector2 spinningPoint = i == 0 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, velocity); - } - } - } - } - } - } + if (phase7) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + Main.PlaySound(SoundID.Item28, npc.Center); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float velocity = 9f + enrageScale; + for (int i = 0; i < 4; i++) + { + int totalProjectiles = malice ? 6 : 4; + float radians = MathHelper.TwoPi / totalProjectiles; + float newVelocity = velocity - (velocity * 0.25f * i); + float velocityX = 0f; + if (i > 0) + { + double angleA = radians * 0.25 * (4 - i); + double angleB = MathHelper.ToRadians(90f) - angleA; + velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); + } + Vector2 spinningPoint = i == 0 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, velocity); + } + } + } + } + } + } - npc.ai[1] -= 1f; - if (npc.ai[1] <= 0f) - { - npc.ai[3] += 1f; - npc.TargetClosest(); - if (npc.ai[3] > 2f) - { - npc.damage = 0; - npc.defense = 0; - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[3] = 0f; - time = 0; - } - else - npc.ai[1] = 60f; + npc.ai[1] -= 1f; + if (npc.ai[1] <= 0f) + { + npc.ai[3] += 1f; + npc.TargetClosest(); + if (npc.ai[3] > 2f) + { + npc.damage = 0; + npc.defense = 0; + npc.ai[0] = 5f; + npc.ai[1] = 0f; + npc.ai[3] = 0f; + time = 0; + } + else + npc.ai[1] = 60f; - npc.rotation = npc.velocity.X * 0.1f; - } - else if (npc.ai[1] <= 15f) - { - npc.velocity *= 0.95f; - npc.rotation = npc.velocity.X * 0.15f; - } - else - npc.rotation += npc.direction * 0.5f; + npc.rotation = npc.velocity.X * 0.1f; + } + else if (npc.ai[1] <= 15f) + { + npc.velocity *= 0.95f; + npc.rotation = npc.velocity.X * 0.15f; + } + else + npc.rotation += npc.direction * 0.5f; - return; - } + return; + } - float num1372 = 16f + enrageScale * 2f; + float num1372 = 16f + enrageScale * 2f; Vector2 vector167 = new Vector2(npc.Center.X + (npc.direction * 20), npc.Center.Y + 6f); float num1373 = player.position.X + player.width * 0.5f - vector167.X; @@ -836,14 +836,14 @@ namespace CalamityMod.NPCs.Cryogen num1374 *= num1376; iceShard--; - if (num1375 < 200f || iceShard > 0) - { - if (num1375 < 200f) - iceShard = 20; + if (num1375 < 200f || iceShard > 0) + { + if (num1375 < 200f) + iceShard = 20; - npc.rotation += npc.direction * 0.3f; - return; - } + npc.rotation += npc.direction * 0.3f; + return; + } npc.velocity.X = (npc.velocity.X * 50f + num1373) / 51f; npc.velocity.Y = (npc.velocity.Y * 50f + num1374) / 51f; @@ -860,119 +860,119 @@ namespace CalamityMod.NPCs.Cryogen npc.rotation = npc.velocity.X * 0.15f; } - else - { - npc.rotation = npc.velocity.X * 0.1f; + else + { + npc.rotation = npc.velocity.X * 0.1f; - time++; - if (time >= (malice ? 50 : 75)) - { - time = 0; - Main.PlaySound(SoundID.Item28, npc.Center); - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity2 = 6f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(velocity2 * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity2) : new Vector2(velocityX, -velocity2); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, 1f); - } - } + time++; + if (time >= (malice ? 50 : 75)) + { + time = 0; + Main.PlaySound(SoundID.Item28, npc.Center); + int totalProjectiles = 4; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float velocity2 = 6f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(velocity2 * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity2) : new Vector2(velocityX, -velocity2); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer, 0f, 1f); + } + } - npc.ai[1] += 1f; - if (npc.ai[1] >= (malice ? 120f : 180f)) - { - npc.TargetClosest(); - npc.ai[0] = 4f; - npc.ai[1] = 60f; - time = 0; - iceShard = 0; - npc.netUpdate = true; - } + npc.ai[1] += 1f; + if (npc.ai[1] >= (malice ? 120f : 180f)) + { + npc.TargetClosest(); + npc.ai[0] = 4f; + npc.ai[1] = 60f; + time = 0; + iceShard = 0; + npc.netUpdate = true; + } - float velocity = revenge ? 5f : 6f; - float acceleration = 0.2f; - velocity -= enrageScale; - acceleration += 0.07f * enrageScale; + float velocity = revenge ? 5f : 6f; + float acceleration = 0.2f; + velocity -= enrageScale; + acceleration += 0.07f * enrageScale; - if (npc.position.Y > player.position.Y - 375f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= 0.98f; + if (npc.position.Y > player.position.Y - 375f) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y *= 0.98f; - npc.velocity.Y -= acceleration; + npc.velocity.Y -= acceleration; - if (npc.velocity.Y > velocity) - npc.velocity.Y = velocity; - } - else if (npc.position.Y < player.position.Y - 400f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.98f; + if (npc.velocity.Y > velocity) + npc.velocity.Y = velocity; + } + else if (npc.position.Y < player.position.Y - 400f) + { + if (npc.velocity.Y < 0f) + npc.velocity.Y *= 0.98f; - npc.velocity.Y += acceleration; + npc.velocity.Y += acceleration; - if (npc.velocity.Y < -velocity) - npc.velocity.Y = -velocity; - } + if (npc.velocity.Y < -velocity) + npc.velocity.Y = -velocity; + } - if (npc.position.X + (npc.width / 2) > player.position.X + (player.width / 2) + 350f) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= 0.98f; + if (npc.position.X + (npc.width / 2) > player.position.X + (player.width / 2) + 350f) + { + if (npc.velocity.X > 0f) + npc.velocity.X *= 0.98f; - npc.velocity.X -= acceleration; + npc.velocity.X -= acceleration; - if (npc.velocity.X > velocity) - npc.velocity.X = velocity; - } - if (npc.position.X + (npc.width / 2) < player.position.X + (player.width / 2) - 350f) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= 0.98f; + if (npc.velocity.X > velocity) + npc.velocity.X = velocity; + } + if (npc.position.X + (npc.width / 2) < player.position.X + (player.width / 2) - 350f) + { + if (npc.velocity.X < 0f) + npc.velocity.X *= 0.98f; - npc.velocity.X += acceleration; + npc.velocity.X += acceleration; - if (npc.velocity.X < -velocity) - npc.velocity.X = -velocity; - } - } + if (npc.velocity.X < -velocity) + npc.velocity.X = -velocity; + } + } } private void HandlePhaseTransition(int newPhase) { - Main.PlaySound(SoundID.NPCDeath15, npc.Center); - int chipGoreAmount = newPhase >= 5 ? 3 : newPhase >= 3 ? 2 : 1; + Main.PlaySound(SoundID.NPCDeath15, npc.Center); + int chipGoreAmount = newPhase >= 5 ? 3 : newPhase >= 3 ? 2 : 1; for (int i = 1; i < chipGoreAmount; i++) Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CryoChipGore" + i), 1f); currentPhase = newPhase; - switch (currentPhase) - { - case 0: - case 1: - break; - case 2: - npc.Calamity().DR = 0.27f; - break; - case 3: - npc.Calamity().DR = 0.21f; - break; - case 4: - npc.Calamity().DR = 0.12f; - break; - case 5: - case 6: - npc.Calamity().DR = 0f; - break; - } + switch (currentPhase) + { + case 0: + case 1: + break; + case 2: + npc.Calamity().DR = 0.27f; + break; + case 3: + npc.Calamity().DR = 0.21f; + break; + case 4: + npc.Calamity().DR = 0.12f; + break; + case 5: + case 6: + npc.Calamity().DR = 0f; + break; + } } public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) //for alt textures @@ -982,16 +982,16 @@ namespace CalamityMod.NPCs.Cryogen string phase = "CalamityMod/NPCs/Cryogen/Cryogen_Phase" + currentPhase; Texture2D texture = ModContent.GetTexture(phase); - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Vector2 origin = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Vector2 drawPos = npc.Center - Main.screenPosition; - drawPos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - drawPos += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, drawPos, npc.frame, npc.GetAlpha(drawColor), npc.rotation, origin, npc.scale, spriteEffects, 0f); - return false; + Vector2 origin = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Vector2 drawPos = npc.Center - Main.screenPosition; + drawPos -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + drawPos += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, drawPos, npc.frame, npc.GetAlpha(drawColor), npc.rotation, origin, npc.scale, spriteEffects, 0f); + return false; } return true; } @@ -1044,11 +1044,11 @@ namespace CalamityMod.NPCs.Cryogen public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedCryogen); if (!Main.expertMode) @@ -1064,24 +1064,24 @@ namespace CalamityMod.NPCs.Cryogen DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); } - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); - // Other - DropHelper.DropItemChance(npc, ItemID.FrozenKey, 3); + // Other + DropHelper.DropItemChance(npc, ItemID.FrozenKey, 3); - // Spawn Permafrost if he isn't in the world - int permafrostNPC = NPC.FindFirstNPC(ModContent.NPCType()); + // Spawn Permafrost if he isn't in the world + int permafrostNPC = NPC.FindFirstNPC(ModContent.NPCType()); if (permafrostNPC == -1 && Main.netMode != NetmodeID.MultiplayerClient) { NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); @@ -1102,28 +1102,28 @@ namespace CalamityMod.NPCs.Cryogen CalamityNetcode.SyncWorld(); } - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - Rectangle targetHitbox = target.Hitbox; + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= 40f; - } + return minDist <= 40f; + } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Frostburn, 120, true); player.AddBuff(BuffID.Chilled, 90, true); diff --git a/NPCs/Cryogen/CryogenIce.cs b/NPCs/Cryogen/CryogenIce.cs index a0e5bb5c48..f2e27337b7 100644 --- a/NPCs/Cryogen/CryogenIce.cs +++ b/NPCs/Cryogen/CryogenIce.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Cryogen { - public class CryogenIce : ModNPC + public class CryogenIce : ModNPC { public override void SetStaticDefaults() { @@ -18,16 +18,16 @@ namespace CalamityMod.NPCs.Cryogen public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.aiStyle = -1; + npc.Calamity().canBreakPlayerDefense = true; + npc.aiStyle = -1; aiType = -1; npc.canGhostHeal = false; npc.noTileCollide = true; - npc.GetNPCDamage(); - npc.width = 216; + npc.GetNPCDamage(); + npc.width = 216; npc.height = 216; npc.scale = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.8f : 1f; - npc.DR_NERD(0.4f); + npc.DR_NERD(0.4f); npc.lifeMax = CalamityWorld.death ? 700 : 1400; if (BossRushEvent.BossRushActive) { @@ -36,14 +36,14 @@ namespace CalamityMod.NPCs.Cryogen npc.alpha = 255; npc.HitSound = SoundID.NPCHit5; npc.DeathSound = SoundID.NPCDeath7; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = false; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = false; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { - npc.alpha -= 3; + npc.alpha -= 3; if (npc.alpha < 0) npc.alpha = 0; @@ -66,28 +66,28 @@ namespace CalamityMod.NPCs.Cryogen } } - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - Rectangle targetHitbox = target.Hitbox; + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= 100f * npc.scale && npc.alpha == 0; - } + return minDist <= 100f * npc.scale && npc.alpha == 0; + } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Frostburn, 90, true); player.AddBuff(BuffID.Chilled, 60, true); @@ -98,9 +98,9 @@ namespace CalamityMod.NPCs.Cryogen npc.lifeMax = (int)(npc.lifeMax * 0.5f * bossLifeScale); } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) { @@ -128,24 +128,24 @@ namespace CalamityMod.NPCs.Cryogen Main.dust[num624].velocity *= 2f; } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int totalProjectiles = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 6 : 4; - double radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int damage2 = npc.GetProjectileDamage(type); - float velocity = 9f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - int proj = Projectile.NewProjectile(npc.Center, vector255, type, damage2, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 300; - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int totalProjectiles = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 6 : 4; + double radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + int damage2 = npc.GetProjectileDamage(type); + float velocity = 9f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + int proj = Projectile.NewProjectile(npc.Center, vector255, type, damage2, 0f, Main.myPlayer); + Main.projectile[proj].timeLeft = 300; + } + } float randomSpread; for (int spike = 0; spike < 4; spike++) diff --git a/NPCs/DesertScourge/DesertNuisanceBody.cs b/NPCs/DesertScourge/DesertNuisanceBody.cs index c900a44b43..31f11058df 100644 --- a/NPCs/DesertScourge/DesertNuisanceBody.cs +++ b/NPCs/DesertScourge/DesertNuisanceBody.cs @@ -6,156 +6,156 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DesertScourge { - public class DesertNuisanceBody : ModNPC - { - public override void SetStaticDefaults() => DisplayName.SetDefault("A Desert Nuisance"); + public class DesertNuisanceBody : ModNPC + { + public override void SetStaticDefaults() => DisplayName.SetDefault("A Desert Nuisance"); - public override void SetDefaults() - { - npc.GetNPCDamage(); - npc.width = 40; - npc.height = 40; - npc.defense = 4; - npc.lifeMax = BossRushEvent.BossRushActive ? 35000 : 800; - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.noTileCollide = true; - npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = SoundID.NPCDeath1; - npc.netAlways = true; - npc.dontCountMe = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + public override void SetDefaults() + { + npc.GetNPCDamage(); + npc.width = 40; + npc.height = 40; + npc.defense = 4; + npc.lifeMax = BossRushEvent.BossRushActive ? 35000 : 800; + npc.aiStyle = -1; + aiType = -1; + npc.knockBackResist = 0f; + npc.alpha = 255; + npc.behindTiles = true; + npc.noGravity = true; + npc.noTileCollide = true; + npc.canGhostHeal = false; + npc.HitSound = SoundID.NPCHit1; + npc.DeathSound = SoundID.NPCDeath1; + npc.netAlways = true; + npc.dontCountMe = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + return false; + } - public override void AI() - { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + public override void AI() + { + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + if (Main.npc[(int)npc.ai[1]].alpha < 128) + { + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } - if (Main.player[npc.target].dead) - npc.TargetClosest(false); + if (Main.player[npc.target].dead) + npc.TargetClosest(false); - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)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; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + if (npc.ai[1] > 0f && npc.ai[1] < (float)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; + } + catch + { + } + npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; + num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + int num194 = npc.width; + num193 = (num193 - (float)num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - npc.spriteDirection = 1; - else if (num191 > 0f) - npc.spriteDirection = -1; - } - } + if (num191 < 0f) + npc.spriteDirection = 1; + else if (num191 > 0f) + npc.spriteDirection = -1; + } + } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() + { + return false; + } - public override bool PreNPCLoot() - { - return false; - } + public override bool PreNPCLoot() + { + return false; + } - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } - if (npc.life <= 0) - { - float randomSpread = (float)(Main.rand.Next(-100, 100) / 100); - Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/ScourgeBody"), 0.65f); - Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/ScourgeBody2"), 0.65f); - Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/ScourgeBody3"), 0.65f); - for (int k = 0; k < 10; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); + } + if (npc.life <= 0) + { + float randomSpread = (float)(Main.rand.Next(-100, 100) / 100); + Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/ScourgeBody"), 0.65f); + Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/ScourgeBody2"), 0.65f); + Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/ScourgeBody3"), 0.65f); + for (int k = 0; k < 10; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); + } + } + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.7f * bossLifeScale); - } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.7f * bossLifeScale); + } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.Bleeding, 60, true); - } - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(BuffID.Bleeding, 60, true); + } + } } diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index 8f55285706..3e3e622917 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -7,401 +7,401 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DesertScourge { - public class DesertNuisanceHead : ModNPC - { - public bool flies = false; - public float speed = 0.085f; - public float turnSpeed = 0.125f; - public int maxLength = 13; - bool TailSpawned = false; + public class DesertNuisanceHead : ModNPC + { + public bool flies = false; + public float speed = 0.085f; + public float turnSpeed = 0.125f; + public int maxLength = 13; + bool TailSpawned = false; - public override void SetStaticDefaults() => DisplayName.SetDefault("A Desert Nuisance"); + public override void SetStaticDefaults() => DisplayName.SetDefault("A Desert Nuisance"); - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.defense = 2; - npc.width = 60; - npc.height = 60; - npc.lifeMax = BossRushEvent.BossRushActive ? 35000 : 800; - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.noTileCollide = true; - npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = SoundID.NPCDeath1; - npc.netAlways = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + public override void SetDefaults() + { + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.defense = 2; + npc.width = 60; + npc.height = 60; + npc.lifeMax = BossRushEvent.BossRushActive ? 35000 : 800; + npc.aiStyle = -1; + aiType = -1; + npc.knockBackResist = 0f; + npc.alpha = 255; + npc.behindTiles = true; + npc.noGravity = true; + npc.noTileCollide = true; + npc.HitSound = SoundID.NPCHit1; + npc.DeathSound = SoundID.NPCDeath1; + npc.netAlways = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } - public override void AI() - { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + public override void AI() + { + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!TailSpawned) - { - npc.ai[2] = (float)npc.whoAmI; - npc.realLife = npc.whoAmI; - int num2 = npc.whoAmI; - int num3 = maxLength; - for (int j = 0; j <= num3; j++) - { - int num4 = ModContent.NPCType(); - if (j == num3) - { - num4 = ModContent.NPCType(); - } - 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[2] = (float)npc.whoAmI; - Main.npc[num5].realLife = npc.whoAmI; - Main.npc[num5].ai[1] = (float)num2; - Main.npc[num2].ai[0] = (float)num5; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num5, 0f, 0f, 0f, 0, 0, 0); - num2 = num5; - } - TailSpawned = true; - } - } - int num12 = (int)(npc.position.X / 16f) - 1; - int num13 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; - int num14 = (int)(npc.position.Y / 16f) - 1; - int num15 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; - if (num12 < 0) - { - num12 = 0; - } - if (num13 > Main.maxTilesX) - { - num13 = Main.maxTilesX; - } - if (num14 < 0) - { - num14 = 0; - } - if (num15 > Main.maxTilesY) - { - num15 = Main.maxTilesY; - } - bool flag2 = false; - if (!flag2) - { - for (int k = num12; k < num13; k++) - { - 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)) - { - 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) - { - flag2 = true; - break; - } - } - } - } - } - if (!flag2) - { - npc.localAI[1] = 1f; - Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num16 = 1000; - bool flag3 = true; - if (npc.position.Y > Main.player[npc.target].position.Y) - { - for (int m = 0; m < 255; m++) - { - if (Main.player[m].active) - { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, num16 * 2); - if (rectangle.Intersects(rectangle2)) - { - flag3 = false; - break; - } - } - } - if (flag3) - { - flag2 = true; - } - } - } - else - { - npc.localAI[1] = 0f; - } - float num17 = 16f; - if (Main.player[npc.target].dead) - { - flag2 = false; - npc.velocity.Y = npc.velocity.Y + 1f; - if ((double)npc.position.Y > Main.worldSurface * 16.0) - { - npc.velocity.Y = npc.velocity.Y + 1f; - num17 = 32f; - } - if ((double)npc.position.Y > Main.rockLayer * 16.0) - { - for (int a = 0; a < 200; a++) - { - if (Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType()) - { - Main.npc[a].active = false; - } - } - } - } - float num18 = speed; - float num19 = turnSpeed; - Vector2 vector3 = 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); - float num21 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - if (!flag2) - { - npc.TargetClosest(true); - npc.velocity.Y = npc.velocity.Y + 0.15f; - if (npc.velocity.Y > num17) - { - npc.velocity.Y = num17; - } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.4) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X - num18 * 1.1f; - } - else - { - npc.velocity.X = npc.velocity.X + num18 * 1.1f; - } - } - else if (npc.velocity.Y == num17) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num18; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num18; - } - } - else if (npc.velocity.Y > 4f) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X + num18 * 0.9f; - } - else - { - npc.velocity.X = npc.velocity.X - num18 * 0.9f; - } - } - } - else - { - if (npc.soundDelay == 0) - { - float num24 = num22 / 40f; - if (num24 < 10f) - { - num24 = 10f; - } - if (num24 > 20f) - { - num24 = 20f; - } - npc.soundDelay = (int)num24; - Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); - } - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = num17 / num22; - num20 *= num27; - num21 *= num27; - if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num19; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num19; - } - if (npc.velocity.Y < num21) - { - npc.velocity.Y = npc.velocity.Y + num19; - } - else if (npc.velocity.Y > num21) - { - npc.velocity.Y = npc.velocity.Y - num19; - } - } - if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num18; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num18; - } - if (npc.velocity.Y < num21) - { - npc.velocity.Y = npc.velocity.Y + num18; - } - else if (npc.velocity.Y > num21) - { - npc.velocity.Y = npc.velocity.Y - num18; - } - if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num18 * 2f; - } - else - { - npc.velocity.Y = npc.velocity.Y - num18 * 2f; - } - } - if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num18 * 2f; - } - else - { - npc.velocity.X = npc.velocity.X - num18 * 2f; - } - } - } - else if (num25 > num26) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num18 * 1.1f; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num18 * 1.1f; - } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num18; - } - else - { - npc.velocity.Y = npc.velocity.Y - num18; - } - } - } - else - { - if (npc.velocity.Y < num21) - { - npc.velocity.Y = npc.velocity.Y + num18 * 1.1f; - } - else if (npc.velocity.Y > num21) - { - npc.velocity.Y = npc.velocity.Y - num18 * 1.1f; - } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num18; - } - else - { - npc.velocity.X = npc.velocity.X - num18; - } - } - } - } - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; - if (flag2) - { - if (npc.localAI[0] != 1f) - { - npc.netUpdate = true; - } - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - { - npc.netUpdate = true; - } - npc.localAI[0] = 0f; - } - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - { - npc.netUpdate = true; - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (!TailSpawned) + { + npc.ai[2] = (float)npc.whoAmI; + npc.realLife = npc.whoAmI; + int num2 = npc.whoAmI; + int num3 = maxLength; + for (int j = 0; j <= num3; j++) + { + int num4 = ModContent.NPCType(); + if (j == num3) + { + num4 = ModContent.NPCType(); + } + 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[2] = (float)npc.whoAmI; + Main.npc[num5].realLife = npc.whoAmI; + Main.npc[num5].ai[1] = (float)num2; + Main.npc[num2].ai[0] = (float)num5; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num5, 0f, 0f, 0f, 0, 0, 0); + num2 = num5; + } + TailSpawned = true; + } + } + int num12 = (int)(npc.position.X / 16f) - 1; + int num13 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; + int num14 = (int)(npc.position.Y / 16f) - 1; + int num15 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; + if (num12 < 0) + { + num12 = 0; + } + if (num13 > Main.maxTilesX) + { + num13 = Main.maxTilesX; + } + if (num14 < 0) + { + num14 = 0; + } + if (num15 > Main.maxTilesY) + { + num15 = Main.maxTilesY; + } + bool flag2 = false; + if (!flag2) + { + for (int k = num12; k < num13; k++) + { + 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)) + { + 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) + { + flag2 = true; + break; + } + } + } + } + } + if (!flag2) + { + npc.localAI[1] = 1f; + Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + int num16 = 1000; + bool flag3 = true; + if (npc.position.Y > Main.player[npc.target].position.Y) + { + for (int m = 0; m < 255; m++) + { + if (Main.player[m].active) + { + Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, num16 * 2); + if (rectangle.Intersects(rectangle2)) + { + flag3 = false; + break; + } + } + } + if (flag3) + { + flag2 = true; + } + } + } + else + { + npc.localAI[1] = 0f; + } + float num17 = 16f; + if (Main.player[npc.target].dead) + { + flag2 = false; + npc.velocity.Y = npc.velocity.Y + 1f; + if ((double)npc.position.Y > Main.worldSurface * 16.0) + { + npc.velocity.Y = npc.velocity.Y + 1f; + num17 = 32f; + } + if ((double)npc.position.Y > Main.rockLayer * 16.0) + { + for (int a = 0; a < 200; a++) + { + if (Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType()) + { + Main.npc[a].active = false; + } + } + } + } + float num18 = speed; + float num19 = turnSpeed; + Vector2 vector3 = 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); + float num21 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); + num20 -= vector3.X; + num21 -= vector3.Y; + float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + if (!flag2) + { + npc.TargetClosest(true); + npc.velocity.Y = npc.velocity.Y + 0.15f; + if (npc.velocity.Y > num17) + { + npc.velocity.Y = num17; + } + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.4) + { + if (npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X - num18 * 1.1f; + } + else + { + npc.velocity.X = npc.velocity.X + num18 * 1.1f; + } + } + else if (npc.velocity.Y == num17) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num18; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num18; + } + } + else if (npc.velocity.Y > 4f) + { + if (npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X + num18 * 0.9f; + } + else + { + npc.velocity.X = npc.velocity.X - num18 * 0.9f; + } + } + } + else + { + if (npc.soundDelay == 0) + { + float num24 = num22 / 40f; + if (num24 < 10f) + { + num24 = 10f; + } + if (num24 > 20f) + { + num24 = 20f; + } + npc.soundDelay = (int)num24; + Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); + } + num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + float num25 = Math.Abs(num20); + float num26 = Math.Abs(num21); + float num27 = num17 / num22; + num20 *= num27; + num21 *= num27; + if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num19; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num19; + } + if (npc.velocity.Y < num21) + { + npc.velocity.Y = npc.velocity.Y + num19; + } + else if (npc.velocity.Y > num21) + { + npc.velocity.Y = npc.velocity.Y - num19; + } + } + if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num18; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num18; + } + if (npc.velocity.Y < num21) + { + npc.velocity.Y = npc.velocity.Y + num18; + } + else if (npc.velocity.Y > num21) + { + npc.velocity.Y = npc.velocity.Y - num18; + } + if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) + { + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y + num18 * 2f; + } + else + { + npc.velocity.Y = npc.velocity.Y - num18 * 2f; + } + } + if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) + { + if (npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X + num18 * 2f; + } + else + { + npc.velocity.X = npc.velocity.X - num18 * 2f; + } + } + } + else if (num25 > num26) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num18 * 1.1f; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num18 * 1.1f; + } + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) + { + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y + num18; + } + else + { + npc.velocity.Y = npc.velocity.Y - num18; + } + } + } + else + { + if (npc.velocity.Y < num21) + { + npc.velocity.Y = npc.velocity.Y + num18 * 1.1f; + } + else if (npc.velocity.Y > num21) + { + npc.velocity.Y = npc.velocity.Y - num18 * 1.1f; + } + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) + { + if (npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X + num18; + } + else + { + npc.velocity.X = npc.velocity.X - num18; + } + } + } + } + npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + if (flag2) + { + if (npc.localAI[0] != 1f) + { + npc.netUpdate = true; + } + npc.localAI[0] = 1f; + } + else + { + if (npc.localAI[0] != 0f) + { + npc.netUpdate = true; + } + npc.localAI[0] = 0f; + } + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + { + npc.netUpdate = true; + } + } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScourgeHead"), 0.65f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScourgeHead2"), 0.65f); - for (int k = 0; k < 10; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); + } + if (npc.life <= 0) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScourgeHead"), 0.65f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScourgeHead2"), 0.65f); + for (int k = 0; k < 10; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); + } + } + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.7f * bossLifeScale); - } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.7f * bossLifeScale); + } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.Bleeding, 180, true); - } - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(BuffID.Bleeding, 180, true); + } + } } diff --git a/NPCs/DesertScourge/DesertNuisanceTail.cs b/NPCs/DesertScourge/DesertNuisanceTail.cs index 6a34da0d07..f8a30b46be 100644 --- a/NPCs/DesertScourge/DesertNuisanceTail.cs +++ b/NPCs/DesertScourge/DesertNuisanceTail.cs @@ -6,153 +6,153 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DesertScourge { - public class DesertNuisanceTail : ModNPC - { - public override void SetStaticDefaults() => DisplayName.SetDefault("A Desert Nuisance"); + public class DesertNuisanceTail : ModNPC + { + public override void SetStaticDefaults() => DisplayName.SetDefault("A Desert Nuisance"); - public override void SetDefaults() - { - npc.GetNPCDamage(); - npc.width = 32; - npc.height = 32; - npc.defense = 7; - npc.lifeMax = BossRushEvent.BossRushActive ? 35000 : 800; - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.noTileCollide = true; - npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = SoundID.NPCDeath1; - npc.netAlways = true; - npc.dontCountMe = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + public override void SetDefaults() + { + npc.GetNPCDamage(); + npc.width = 32; + npc.height = 32; + npc.defense = 7; + npc.lifeMax = BossRushEvent.BossRushActive ? 35000 : 800; + npc.aiStyle = -1; + aiType = -1; + npc.knockBackResist = 0f; + npc.alpha = 255; + npc.behindTiles = true; + npc.noGravity = true; + npc.noTileCollide = true; + npc.canGhostHeal = false; + npc.HitSound = SoundID.NPCHit1; + npc.DeathSound = SoundID.NPCDeath1; + npc.netAlways = true; + npc.dontCountMe = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + return false; + } - public override void AI() - { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + public override void AI() + { + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + if (Main.npc[(int)npc.ai[1]].alpha < 128) + { + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } - if (Main.player[npc.target].dead) - npc.TargetClosest(false); + if (Main.player[npc.target].dead) + npc.TargetClosest(false); - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)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; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + if (npc.ai[1] > 0f && npc.ai[1] < (float)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; + } + catch + { + } + npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; + num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + int num194 = npc.width; + num193 = (num193 - (float)num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - npc.spriteDirection = 1; - else if (num191 > 0f) - npc.spriteDirection = -1; - } - } + if (num191 < 0f) + npc.spriteDirection = 1; + else if (num191 > 0f) + npc.spriteDirection = -1; + } + } - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScourgeTail"), 0.65f); - for (int k = 0; k < 10; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); + } + if (npc.life <= 0) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ScourgeTail"), 0.65f); + for (int k = 0; k < 10; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); + } + } + } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() + { + return false; + } - public override bool PreNPCLoot() - { - return false; - } + public override bool PreNPCLoot() + { + return false; + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.7f * bossLifeScale); - } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.7f * bossLifeScale); + } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.Bleeding, 30, true); - } - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(BuffID.Bleeding, 30, true); + } + } } diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index faf00e7b72..1ce5d1109e 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DesertScourge { - public class DesertScourgeBody : ModNPC + public class DesertScourgeBody : ModNPC { public override void SetStaticDefaults() { @@ -18,11 +18,11 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { - npc.GetNPCDamage(); + npc.GetNPCDamage(); npc.width = 32; npc.height = 36; npc.defense = 6; - npc.DR_NERD(0.05f); + npc.DR_NERD(0.05f); npc.LifeMaxNERB(2500, 3000, 1650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -41,19 +41,19 @@ namespace CalamityMod.NPCs.DesertScourge npc.netAlways = true; npc.dontCountMe = true; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -62,117 +62,117 @@ namespace CalamityMod.NPCs.DesertScourge public override void AI() { - Player player = Main.player[npc.target]; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - float burrowTimeGateValue = death ? 420f : 540f; - bool burrow = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= burrowTimeGateValue; + Player player = Main.player[npc.target]; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + float burrowTimeGateValue = death ? 420f : 540f; + bool burrow = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= burrowTimeGateValue; - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + if (Main.npc[(int)npc.ai[1]].alpha < 128) + { + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } - if (Main.player[npc.target].dead) - npc.TargetClosest(false); + if (Main.player[npc.target].dead) + npc.TargetClosest(false); - if (Main.netMode != NetmodeID.MultiplayerClient && revenge && !burrow) - { - npc.localAI[0] += malice ? 6f : Main.rand.Next(4); - if (npc.localAI[0] >= Main.rand.Next(1400, 26001)) - { - npc.localAI[0] = 0f; - 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)); - int projectileType = ModContent.ProjectileType(); - float num941 = malice ? 9f : 6f; - num944 = num941 / num944; - num942 *= num944; - num943 *= num944; - vector104.X += num942 * 5f; - vector104.Y += num943 * 5f; - if (Main.rand.NextBool(2) || malice) - { - Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, projectileType, npc.GetProjectileDamage(projectileType), 0f, Main.myPlayer, 0f, 0f); - } - npc.netUpdate = true; - } - } - } + if (Main.netMode != NetmodeID.MultiplayerClient && revenge && !burrow) + { + npc.localAI[0] += malice ? 6f : Main.rand.Next(4); + if (npc.localAI[0] >= Main.rand.Next(1400, 26001)) + { + npc.localAI[0] = 0f; + 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)); + int projectileType = ModContent.ProjectileType(); + float num941 = malice ? 9f : 6f; + num944 = num941 / num944; + num942 *= num944; + num943 *= num944; + vector104.X += num942 * 5f; + vector104.Y += num943 * 5f; + if (Main.rand.NextBool(2) || malice) + { + Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, projectileType, npc.GetProjectileDamage(projectileType), 0f, Main.myPlayer, 0f, 0f); + } + npc.netUpdate = true; + } + } + } - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)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; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + if (npc.ai[1] > 0f && npc.ai[1] < (float)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; + } + catch + { + } + npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; + num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + int num194 = npc.width; + num193 = (num193 - (float)num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - npc.spriteDirection = 1; - else if (num191 > 0f) - npc.spriteDirection = -1; - } + if (num191 < 0f) + npc.spriteDirection = 1; + else if (num191 > 0f) + npc.spriteDirection = -1; + } } public override bool CheckActive() diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 2b91cbcc88..7af015611e 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -69,9 +69,9 @@ namespace CalamityMod.NPCs.DesertScourge npc.scale = 1.1f; npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -583,12 +583,12 @@ namespace CalamityMod.NPCs.DesertScourge DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); diff --git a/NPCs/DesertScourge/DesertScourgeTail.cs b/NPCs/DesertScourge/DesertScourgeTail.cs index ac9b51b433..de8b378c04 100644 --- a/NPCs/DesertScourge/DesertScourgeTail.cs +++ b/NPCs/DesertScourge/DesertScourgeTail.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DesertScourge { - public class DesertScourgeTail : ModNPC + public class DesertScourgeTail : ModNPC { public override void SetStaticDefaults() { @@ -16,11 +16,11 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { - npc.GetNPCDamage(); + npc.GetNPCDamage(); npc.width = 32; npc.height = 48; npc.defense = 9; - npc.DR_NERD(0.1f); + npc.DR_NERD(0.1f); npc.LifeMaxNERB(2500, 3000, 1650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -39,19 +39,19 @@ namespace CalamityMod.NPCs.DesertScourge npc.netAlways = true; npc.dontCountMe = true; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -60,83 +60,83 @@ namespace CalamityMod.NPCs.DesertScourge public override void AI() { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + if (Main.npc[(int)npc.ai[1]].alpha < 128) + { + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } - if (Main.player[npc.target].dead) - npc.TargetClosest(false); + if (Main.player[npc.target].dead) + npc.TargetClosest(false); - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)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; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + if (npc.ai[1] > 0f && npc.ai[1] < (float)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; + } + catch + { + } + npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; + num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + int num194 = npc.width; + num193 = (num193 - (float)num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - npc.spriteDirection = 1; - else if (num191 > 0f) - npc.spriteDirection = -1; - } - } + if (num191 < 0f) + npc.spriteDirection = 1; + else if (num191 > 0f) + npc.spriteDirection = -1; + } + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index 143c62fd2e..6da5539912 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -13,41 +13,41 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DevourerofGods { - public class DevourerofGodsBody : ModNPC + public class DevourerofGodsBody : ModNPC { - public static int phase2IconIndex; + public static int phase2IconIndex; - internal static void LoadHeadIcons() - { - string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS_Head_Boss"; + internal static void LoadHeadIcons() + { + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS_Head_Boss"; - CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); - phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); - } + CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); + phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); + } - private int invinceTime = 360; - private bool setOpacity = false; - private bool phase2Started = false; - public int SegmentIndex; + private int invinceTime = 360; + private bool setOpacity = false; + private bool phase2Started = false; + public int SegmentIndex; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("The Devourer of Gods"); } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 56; npc.height = 56; npc.defense = 70; CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.925f; global.unbreakableDR = true; - npc.LifeMaxNERB(888750, 1066500, 1500000); // Phase 1 is 371250, Phase 2 is 517500 - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.LifeMaxNERB(888750, 1066500, 1500000); // Phase 1 is 371250, Phase 2 is 517500 + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -64,91 +64,91 @@ namespace CalamityMod.NPCs.DevourerofGods npc.boss = true; music = CalamityMod.Instance.GetMusicFromMusicMod("DevourerOfGodsP1") ?? MusicID.Boss3; npc.dontCountMe = true; - } + } - public override void BossHeadSlot(ref int index) - { - NPC head = CalamityGlobalNPC.DoGHead >= 0 ? Main.npc[CalamityGlobalNPC.DoGHead] : null; - DevourerofGodsHead modNPC = head?.ModNPC() ?? null; - if (head is null || modNPC.AwaitingPhase2Teleport || !modNPC.Phase2Started) - { - index = -1; - return; - } - index = phase2IconIndex; - } - - public override void BossHeadRotation(ref float rotation) - { - NPC head = CalamityGlobalNPC.DoGHead >= 0 ? Main.npc[CalamityGlobalNPC.DoGHead] : null; - DevourerofGodsHead modNPC = head?.ModNPC() ?? null; - if (head is null || modNPC.AwaitingPhase2Teleport || !modNPC.Phase2Started) - return; - - rotation = npc.rotation; - } - - public override void SendExtraAI(BinaryWriter writer) + public override void BossHeadSlot(ref int index) { - writer.Write(phase2Started); - writer.Write(invinceTime); + NPC head = CalamityGlobalNPC.DoGHead >= 0 ? Main.npc[CalamityGlobalNPC.DoGHead] : null; + DevourerofGodsHead modNPC = head?.ModNPC() ?? null; + if (head is null || modNPC.AwaitingPhase2Teleport || !modNPC.Phase2Started) + { + index = -1; + return; + } + index = phase2IconIndex; + } + + public override void BossHeadRotation(ref float rotation) + { + NPC head = CalamityGlobalNPC.DoGHead >= 0 ? Main.npc[CalamityGlobalNPC.DoGHead] : null; + DevourerofGodsHead modNPC = head?.ModNPC() ?? null; + if (head is null || modNPC.AwaitingPhase2Teleport || !modNPC.Phase2Started) + return; + + rotation = npc.rotation; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(phase2Started); + writer.Write(invinceTime); writer.Write(npc.dontTakeDamage); - writer.Write(setOpacity); - writer.Write(npc.Opacity); - writer.Write(SegmentIndex); - writer.Write(npc.frame.X); - writer.Write(npc.frame.Y); - writer.Write(npc.frame.Width); - writer.Write(npc.frame.Height); - } + writer.Write(setOpacity); + writer.Write(npc.Opacity); + writer.Write(SegmentIndex); + writer.Write(npc.frame.X); + writer.Write(npc.frame.Y); + writer.Write(npc.frame.Width); + writer.Write(npc.frame.Height); + } public override void ReceiveExtraAI(BinaryReader reader) { - phase2Started = reader.ReadBoolean(); - invinceTime = reader.ReadInt32(); + phase2Started = reader.ReadBoolean(); + invinceTime = reader.ReadInt32(); npc.dontTakeDamage = reader.ReadBoolean(); - setOpacity = reader.ReadBoolean(); - npc.Opacity = reader.ReadSingle(); - SegmentIndex = reader.ReadInt32(); - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - npc.frame = frame; - } + setOpacity = reader.ReadBoolean(); + npc.Opacity = reader.ReadSingle(); + SegmentIndex = reader.ReadInt32(); + Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); + if (frame.Width > 0 && frame.Height > 0) + npc.frame = frame; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; } - public override void AI() + public override void AI() { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; - if (npc.life / (float)npc.lifeMax < 0.6f) - { - phase2Started = true; + if (npc.life / (float)npc.lifeMax < 0.6f) + { + phase2Started = true; - // Play music after the transiton BS - if (CalamityWorld.DoGSecondStageCountdown == 530) - music = CalamityMod.Instance.GetMusicFromMusicMod("DevourerOfGodsP2") ?? MusicID.LunarBoss; + // Play music after the transiton BS + if (CalamityWorld.DoGSecondStageCountdown == 530) + music = CalamityMod.Instance.GetMusicFromMusicMod("DevourerOfGodsP2") ?? MusicID.LunarBoss; - // Once before DoG spawns, set new size - if (CalamityWorld.DoGSecondStageCountdown == 60) - { - npc.position = npc.Center; - npc.width = 70; - npc.height = 70; - npc.frame = new Rectangle(0, 0, 114, 88); - npc.position -= npc.Size * 0.5f; - npc.netUpdate = true; - } - } + // Once before DoG spawns, set new size + if (CalamityWorld.DoGSecondStageCountdown == 60) + { + npc.position = npc.Center; + npc.width = 70; + npc.height = 70; + npc.frame = new Rectangle(0, 0, 114, 88); + npc.position -= npc.Size * 0.5f; + npc.netUpdate = true; + } + } - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (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); if (invinceTime > 0) { @@ -158,83 +158,83 @@ namespace CalamityMod.NPCs.DevourerofGods else npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; - if (Main.npc[(int)npc.ai[2]].dontTakeDamage) - invinceTime = 240; + if (Main.npc[(int)npc.ai[2]].dontTakeDamage) + invinceTime = 240; - // Target - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Target + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].Opacity >= 0.5f && (!setOpacity || (CalamityWorld.DoGSecondStageCountdown <= 60 && CalamityWorld.DoGSecondStageCountdown > 0))) - { - npc.Opacity += 0.165f; - if (npc.Opacity >= 1f && invinceTime <= 0) - { - setOpacity = true; - npc.Opacity = 1f; - } - } - else - { - if (Main.npc[(int)npc.ai[2]].ModNPC()?.AttemptingToEnterPortal ?? false) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile portal = Main.projectile[Main.npc[(int)npc.ai[2]].ModNPC().PortalIndex]; - float newOpacity = 1f - Utils.InverseLerp(270f, 100f, npc.Distance(portal.Center), true); - if (newOpacity > 0f && npc.Opacity > newOpacity) - { - npc.Opacity = newOpacity; + if (Main.npc[(int)npc.ai[1]].Opacity >= 0.5f && (!setOpacity || (CalamityWorld.DoGSecondStageCountdown <= 60 && CalamityWorld.DoGSecondStageCountdown > 0))) + { + npc.Opacity += 0.165f; + if (npc.Opacity >= 1f && invinceTime <= 0) + { + setOpacity = true; + npc.Opacity = 1f; + } + } + else + { + if (Main.npc[(int)npc.ai[2]].ModNPC()?.AttemptingToEnterPortal ?? false) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile portal = Main.projectile[Main.npc[(int)npc.ai[2]].ModNPC().PortalIndex]; + float newOpacity = 1f - Utils.InverseLerp(270f, 100f, npc.Distance(portal.Center), true); + if (newOpacity > 0f && npc.Opacity > newOpacity) + { + npc.Opacity = newOpacity; - // Create dust at the portal position. - if (Vector2.Dot((npc.rotation - MathHelper.PiOver2).ToRotationVector2(), Main.npc[(int)npc.ai[2]].velocity) > 0f) - { - for (int i = 0; i < 2; i++) - { - Dust cosmicMagic = Dust.NewDustPerfect(portal.Center, Main.rand.NextBool() ? 180 : 173); - cosmicMagic.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 8f); - cosmicMagic.scale *= Main.rand.NextFloat(1f, 1.8f); - cosmicMagic.noGravity = true; - } - } + // Create dust at the portal position. + if (Vector2.Dot((npc.rotation - MathHelper.PiOver2).ToRotationVector2(), Main.npc[(int)npc.ai[2]].velocity) > 0f) + { + for (int i = 0; i < 2; i++) + { + Dust cosmicMagic = Dust.NewDustPerfect(portal.Center, Main.rand.NextBool() ? 180 : 173); + cosmicMagic.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 8f); + cosmicMagic.scale *= Main.rand.NextFloat(1f, 1.8f); + cosmicMagic.noGravity = true; + } + } - if (npc.Opacity < 0.2f) - npc.Opacity = 0f; + if (npc.Opacity < 0.2f) + npc.Opacity = 0f; - npc.netUpdate = true; - } - } - } - else - npc.Opacity = Main.npc[(int)npc.ai[2]].Opacity; - } + npc.netUpdate = true; + } + } + } + else + npc.Opacity = Main.npc[(int)npc.ai[2]].Opacity; + } 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); @@ -274,103 +274,103 @@ namespace CalamityMod.NPCs.DevourerofGods } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - float disintegrationFactor = Main.npc[npc.realLife].ModNPC().DeathAnimationTimer / 640f; - if (disintegrationFactor > 0f) - { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(npc.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + float disintegrationFactor = Main.npc[npc.realLife].ModNPC().DeathAnimationTimer / 640f; + if (disintegrationFactor > 0f) + { + spriteBatch.EnterShaderRegion(); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(npc.whoAmI); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage("Images/Misc/Perlin"); + GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); + } - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - bool useOtherTextures = phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60; - Texture2D texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS") : Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); + bool useOtherTextures = phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60; + Texture2D texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - if (!npc.dontTakeDamage) - { - if (useOtherTextures) - { - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodySGlow"); - Color color36 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + if (!npc.dontTakeDamage) + { + if (useOtherTextures) + { + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodySGlow"); + Color color36 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color36, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + spriteBatch.Draw(texture2D15, vector43, npc.frame, color36, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } - texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodySGlow2") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyGlow"); - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodySGlow2") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyGlow"); + Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); + if (disintegrationFactor > 0f) + spriteBatch.ExitShaderRegion(); - return false; - } + return false; + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; - Rectangle targetHitbox = target.Hitbox; + Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= (phase2Started ? 55f : 40f) && npc.Opacity >= 1f && invinceTime <= 0; - } + return minDist <= (phase2Started ? 55f : 40f) && npc.Opacity >= 1f && invinceTime <= 0; + } - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) - { - if ((damage * (crit ? 2D : 1D)) >= npc.life || (npc.realLife >= 0 && Main.npc[npc.realLife].ModNPC().Dying)) - { - if (npc.realLife >= 0) - { - damage = 0D; - npc.dontTakeDamage = true; - Main.npc[npc.realLife].dontTakeDamage = true; - Main.npc[npc.realLife].life = 1; + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + { + if ((damage * (crit ? 2D : 1D)) >= npc.life || (npc.realLife >= 0 && Main.npc[npc.realLife].ModNPC().Dying)) + { + if (npc.realLife >= 0) + { + damage = 0D; + npc.dontTakeDamage = true; + Main.npc[npc.realLife].dontTakeDamage = true; + Main.npc[npc.realLife].life = 1; - if (!Main.npc[npc.realLife].ModNPC().Dying) - { - Main.npc[npc.realLife].ModNPC().Dying = true; - Main.npc[npc.realLife].dontTakeDamage = true; - Main.npc[npc.realLife].active = true; - Main.npc[npc.realLife].netUpdate = true; - } - } - return false; - } - return true; + if (!Main.npc[npc.realLife].ModNPC().Dying) + { + Main.npc[npc.realLife].ModNPC().Dying = true; + Main.npc[npc.realLife].dontTakeDamage = true; + Main.npc[npc.realLife].active = true; + Main.npc[npc.realLife].netUpdate = true; + } + } + return false; + } + return true; } public override bool CheckDead() { - if (npc.realLife >= 0) - Main.npc[npc.realLife].checkDead(); + if (npc.realLife >= 0) + Main.npc[npc.realLife].checkDead(); return base.CheckDead(); } @@ -384,40 +384,40 @@ namespace CalamityMod.NPCs.DevourerofGods return false; } - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - float randomSpread = Main.rand.Next(-100, 100) / 100; - Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/DoGS6"), 1f); - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - for (int num621 = 0; num621 < 10; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 20; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + { + float randomSpread = Main.rand.Next(-100, 100) / 100; + Gore.NewGore(npc.position, npc.velocity * randomSpread * Main.rand.NextFloat(), mod.GetGoreSlot("Gores/DoGS6"), 1f); + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); + npc.width = 50; + npc.height = 50; + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 10; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 20; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); diff --git a/NPCs/DevourerofGods/DevourerofGodsBody2.cs b/NPCs/DevourerofGods/DevourerofGodsBody2.cs index 8c77d2a444..ada111c172 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody2.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody2.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.DevourerofGods public override void SetDefaults() { - npc.GetNPCDamage(); + npc.GetNPCDamage(); npc.width = 34; npc.height = 34; npc.defense = 60; @@ -74,35 +74,35 @@ namespace CalamityMod.NPCs.DevourerofGods npc.dontTakeDamage = false; } - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { if (npc.alpha != 0) { @@ -116,62 +116,62 @@ namespace CalamityMod.NPCs.DevourerofGods npc.alpha = 0; } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].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(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - 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(num192, num191) + 1.57f; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - } - } + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].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(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + { + try + { + 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(num192, num191) + 1.57f; + num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + int num194 = npc.width; + num193 = (num193 - num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + 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 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBody2Glow"); - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBody2Glow"); + Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 234ee6076c..28e91e2729 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -36,117 +36,117 @@ namespace CalamityMod.NPCs.DevourerofGods { public class DevourerofGodsHead : ModNPC { - public static int phase1IconIndex; - public static int phase2IconIndex; + public static int phase1IconIndex; + public static int phase2IconIndex; - internal static void LoadHeadIcons() - { - string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_Head_Boss"; - string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadS_Head_Boss"; + internal static void LoadHeadIcons() + { + string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadS_Head_Boss"; - CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); - phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); + CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); + phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); - CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); - phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); - } + CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); + phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); + } - // Laser velocity - private const float laserVelocity = 10f; + // Laser velocity + private const float laserVelocity = 10f; - // Phase 1 variables + // Phase 1 variables - // Enums - private enum LaserWallType - { - DiagonalRight = 0, - DiagonalLeft = 1, - DiagonalHorizontal = 2, - DiagonalCross = 3 - } + // Enums + private enum LaserWallType + { + DiagonalRight = 0, + DiagonalLeft = 1, + DiagonalHorizontal = 2, + DiagonalCross = 3 + } - // Laser spread variables - private const int shotSpacingMax = 1050; - private int shotSpacing = shotSpacingMax; - private const int totalShots = 10; - private const int spacingVar = shotSpacingMax / totalShots * 2; - private int laserWallType = 0; - private const float laserWallSpacingOffset = 16f; + // Laser spread variables + private const int shotSpacingMax = 1050; + private int shotSpacing = shotSpacingMax; + private const int totalShots = 10; + private const int spacingVar = shotSpacingMax / totalShots * 2; + private int laserWallType = 0; + private const float laserWallSpacingOffset = 16f; - // Continuously reset variables - public bool AttemptingToEnterPortal = false; - public int PortalIndex = -1; + // Continuously reset variables + public bool AttemptingToEnterPortal = false; + public int PortalIndex = -1; - // Spawn variables - private bool tail = false; + // Spawn variables + private bool tail = false; private const int minLength = 100; private const int maxLength = 101; - // Phase variables + // Phase variables private bool spawnedGuardians = false; private bool spawnedGuardians2 = false; private int spawnDoGCountdown = 0; - private bool hasCreatedPhase1Portal = false; - public bool Phase2Started = false; - public bool AwaitingPhase2Teleport = true; + private bool hasCreatedPhase1Portal = false; + public bool Phase2Started = false; + public bool AwaitingPhase2Teleport = true; - // Phase 2 variables + // Phase 2 variables - // Enums - private enum LaserWallPhase - { - SetUp = 0, - FireLaserWalls = 1, - End = 2 - } - private enum LaserWallType_Phase2 - { - Normal = 0, - Offset = 1, - DiagonalHorizontal = 2, - MultiLayered = 3, - DiagonalVertical = 4 - } + // Enums + private enum LaserWallPhase + { + SetUp = 0, + FireLaserWalls = 1, + End = 2 + } + private enum LaserWallType_Phase2 + { + Normal = 0, + Offset = 1, + DiagonalHorizontal = 2, + MultiLayered = 3, + DiagonalVertical = 4 + } - // Laser wall variables - private const int shotSpacingMax_Phase2 = 1050; - private int[] shotSpacing_Phase2 = new int[4] { shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2 }; - private const int spacingVar_Phase2 = 105; - private const int totalShots_Phase2 = 20; - private const int totalDiagonalShots = 6; - private const int diagonalSpacingVar = shotSpacingMax_Phase2 / totalDiagonalShots * 2; - private int laserWallType_Phase2 = 0; - public int laserWallPhase = 0; + // Laser wall variables + private const int shotSpacingMax_Phase2 = 1050; + private int[] shotSpacing_Phase2 = new int[4] { shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2 }; + private const int spacingVar_Phase2 = 105; + private const int totalShots_Phase2 = 20; + private const int totalDiagonalShots = 6; + private const int diagonalSpacingVar = shotSpacingMax_Phase2 / totalDiagonalShots * 2; + private int laserWallType_Phase2 = 0; + public int laserWallPhase = 0; - // Phase variables - private const int idleCounterMax = 360; - private int idleCounter = idleCounterMax; - private int postTeleportTimer = 0; - private int teleportTimer = -1; - private bool spawnedGuardians3 = false; - private int preventBullshitHitsAtStartofFinalPhaseTimer = 0; - private const float alphaGateValue = 669f; + // Phase variables + private const int idleCounterMax = 360; + private int idleCounter = idleCounterMax; + private int postTeleportTimer = 0; + private int teleportTimer = -1; + private bool spawnedGuardians3 = false; + private int preventBullshitHitsAtStartofFinalPhaseTimer = 0; + private const float alphaGateValue = 669f; - // Death animation variables - public bool Dying; - public int DeathAnimationTimer; - public int DestroyedSegmentCount; + // Death animation variables + public bool Dying; + public int DeathAnimationTimer; + public int DestroyedSegmentCount; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("The Devourer of Gods"); } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 104; npc.height = 104; npc.defense = 50; - npc.LifeMaxNERB(888750, 1066500, 1500000); // Phase 1 is 371250, Phase 2 is 517500 - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.LifeMaxNERB(888750, 1066500, 1500000); // Phase 1 is 371250, Phase 2 is 517500 + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.takenDamageMultiplier = 1.1f; npc.aiStyle = -1; @@ -158,123 +158,123 @@ namespace CalamityMod.NPCs.DevourerofGods npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; - npc.DeathSound = SoundID.NPCDeath14; + npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; music = CalamityMod.Instance.GetMusicFromMusicMod("DevourerOfGodsP1") ?? MusicID.Boss3; - bossBag = ModContent.ItemType(); - } + bossBag = ModContent.ItemType(); + } - public override void BossHeadSlot(ref int index) - { - if (Phase2Started && (CalamityWorld.DoGSecondStageCountdown > 60 || AwaitingPhase2Teleport)) - index = -1; - else if (Phase2Started && !AwaitingPhase2Teleport) - index = phase2IconIndex; - else - index = phase1IconIndex; - } - - public override void BossHeadRotation(ref float rotation) - { - if (Phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60) - rotation = npc.rotation; - } - - public override void SendExtraAI(BinaryWriter writer) + public override void BossHeadSlot(ref int index) { - bool wasDyingBefore = Dying; + if (Phase2Started && (CalamityWorld.DoGSecondStageCountdown > 60 || AwaitingPhase2Teleport)) + index = -1; + else if (Phase2Started && !AwaitingPhase2Teleport) + index = phase2IconIndex; + else + index = phase1IconIndex; + } - // Phase 1 syncs - writer.Write(npc.dontTakeDamage); - writer.Write(spawnedGuardians); + public override void BossHeadRotation(ref float rotation) + { + if (Phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60) + rotation = npc.rotation; + } + + public override void SendExtraAI(BinaryWriter writer) + { + bool wasDyingBefore = Dying; + + // Phase 1 syncs + writer.Write(npc.dontTakeDamage); + writer.Write(spawnedGuardians); writer.Write(spawnedGuardians2); - writer.Write(spawnedGuardians3); - writer.Write(Phase2Started); - writer.Write(hasCreatedPhase1Portal); - writer.Write(AwaitingPhase2Teleport); - writer.Write(spawnDoGCountdown); - writer.Write(shotSpacing); - writer.Write(laserWallType); - writer.Write(PortalIndex); + writer.Write(spawnedGuardians3); + writer.Write(Phase2Started); + writer.Write(hasCreatedPhase1Portal); + writer.Write(AwaitingPhase2Teleport); + writer.Write(spawnDoGCountdown); + writer.Write(shotSpacing); + writer.Write(laserWallType); + writer.Write(PortalIndex); for (int i = 0; i < 4; i++) writer.Write(npc.Calamity().newAI[i]); - // Phase 2 syncs - writer.Write(shotSpacing_Phase2[0]); - writer.Write(shotSpacing_Phase2[1]); - writer.Write(shotSpacing_Phase2[2]); - writer.Write(shotSpacing_Phase2[3]); - writer.Write(idleCounter); - writer.Write(laserWallPhase); - writer.Write(laserWallType_Phase2); - writer.Write(postTeleportTimer); - writer.Write(preventBullshitHitsAtStartofFinalPhaseTimer); - writer.Write(teleportTimer); - writer.Write(npc.Opacity); + // Phase 2 syncs + writer.Write(shotSpacing_Phase2[0]); + writer.Write(shotSpacing_Phase2[1]); + writer.Write(shotSpacing_Phase2[2]); + writer.Write(shotSpacing_Phase2[3]); + writer.Write(idleCounter); + writer.Write(laserWallPhase); + writer.Write(laserWallType_Phase2); + writer.Write(postTeleportTimer); + writer.Write(preventBullshitHitsAtStartofFinalPhaseTimer); + writer.Write(teleportTimer); + writer.Write(npc.Opacity); - // Death animation syncs - writer.Write(Dying); - writer.Write(DeathAnimationTimer); - writer.Write(DestroyedSegmentCount); + // Death animation syncs + writer.Write(Dying); + writer.Write(DeathAnimationTimer); + writer.Write(DestroyedSegmentCount); - // Frame syncs - writer.Write(npc.frame.X); - writer.Write(npc.frame.Y); - writer.Write(npc.frame.Width); - writer.Write(npc.frame.Height); + // Frame syncs + writer.Write(npc.frame.X); + writer.Write(npc.frame.Y); + writer.Write(npc.frame.Width); + writer.Write(npc.frame.Height); - // Be sure to inform clients of the fact that The Devourer of Gods is dying if only the server recieved this packet. - if (Main.netMode == NetmodeID.Server && !wasDyingBefore && Dying) - { - npc.netSpam = 0; - npc.netUpdate = true; - } - } + // Be sure to inform clients of the fact that The Devourer of Gods is dying if only the server recieved this packet. + if (Main.netMode == NetmodeID.Server && !wasDyingBefore && Dying) + { + npc.netSpam = 0; + npc.netUpdate = true; + } + } public override void ReceiveExtraAI(BinaryReader reader) { - // Phase 1 syncs - npc.dontTakeDamage = reader.ReadBoolean(); - spawnedGuardians = reader.ReadBoolean(); - spawnedGuardians2 = reader.ReadBoolean(); - spawnedGuardians3 = reader.ReadBoolean(); - Phase2Started = reader.ReadBoolean(); - hasCreatedPhase1Portal = reader.ReadBoolean(); - AwaitingPhase2Teleport = reader.ReadBoolean(); - spawnDoGCountdown = reader.ReadInt32(); - shotSpacing = reader.ReadInt32(); - laserWallType = reader.ReadInt32(); - PortalIndex = reader.ReadInt32(); - for (int i = 0; i < 4; i++) + // Phase 1 syncs + npc.dontTakeDamage = reader.ReadBoolean(); + spawnedGuardians = reader.ReadBoolean(); + spawnedGuardians2 = reader.ReadBoolean(); + spawnedGuardians3 = reader.ReadBoolean(); + Phase2Started = reader.ReadBoolean(); + hasCreatedPhase1Portal = reader.ReadBoolean(); + AwaitingPhase2Teleport = reader.ReadBoolean(); + spawnDoGCountdown = reader.ReadInt32(); + shotSpacing = reader.ReadInt32(); + laserWallType = reader.ReadInt32(); + PortalIndex = reader.ReadInt32(); + for (int i = 0; i < 4; i++) npc.Calamity().newAI[i] = reader.ReadSingle(); - // Phase 2 syncs - shotSpacing_Phase2[0] = reader.ReadInt32(); - shotSpacing_Phase2[1] = reader.ReadInt32(); - shotSpacing_Phase2[2] = reader.ReadInt32(); - shotSpacing_Phase2[3] = reader.ReadInt32(); - idleCounter = reader.ReadInt32(); - laserWallPhase = reader.ReadInt32(); - laserWallType_Phase2 = reader.ReadInt32(); - postTeleportTimer = reader.ReadInt32(); - preventBullshitHitsAtStartofFinalPhaseTimer = reader.ReadInt32(); - teleportTimer = reader.ReadInt32(); - npc.Opacity = reader.ReadSingle(); + // Phase 2 syncs + shotSpacing_Phase2[0] = reader.ReadInt32(); + shotSpacing_Phase2[1] = reader.ReadInt32(); + shotSpacing_Phase2[2] = reader.ReadInt32(); + shotSpacing_Phase2[3] = reader.ReadInt32(); + idleCounter = reader.ReadInt32(); + laserWallPhase = reader.ReadInt32(); + laserWallType_Phase2 = reader.ReadInt32(); + postTeleportTimer = reader.ReadInt32(); + preventBullshitHitsAtStartofFinalPhaseTimer = reader.ReadInt32(); + teleportTimer = reader.ReadInt32(); + npc.Opacity = reader.ReadSingle(); - // Death animation syncs - Dying = reader.ReadBoolean(); - DeathAnimationTimer = reader.ReadInt32(); - DestroyedSegmentCount = reader.ReadInt32(); + // Death animation syncs + Dying = reader.ReadBoolean(); + DeathAnimationTimer = reader.ReadInt32(); + DestroyedSegmentCount = reader.ReadInt32(); - // Frame syncs - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - npc.frame = frame; - } + // Frame syncs + Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); + if (frame.Width > 0 && frame.Height > 0) + npc.frame = frame; + } public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); // whoAmI variable CalamityGlobalNPC.DoGHead = npc.whoAmI; @@ -282,2058 +282,2058 @@ namespace CalamityMod.NPCs.DevourerofGods // Stop rain CalamityMod.StopRain(); - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - // Variables - Vector2 vector = npc.Center; + // Variables + Vector2 vector = npc.Center; bool flies = npc.ai[3] == 0f; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Phase 1 phases - bool phase2 = lifeRatio < 0.9f; - bool phase3 = lifeRatio < 0.68f; - bool summonSentinels = lifeRatio < 0.6f; + // Phase 1 phases + bool phase2 = lifeRatio < 0.9f; + bool phase3 = lifeRatio < 0.68f; + bool summonSentinels = lifeRatio < 0.6f; - // Phase 2 phases - bool phase4 = lifeRatio < 0.48f; - bool phase5 = lifeRatio < 0.36f; - bool phase6 = lifeRatio < 0.18f; - bool phase7 = lifeRatio < 0.09f; + // Phase 2 phases + bool phase4 = lifeRatio < 0.48f; + bool phase5 = lifeRatio < 0.36f; + bool phase6 = lifeRatio < 0.18f; + bool phase7 = lifeRatio < 0.09f; - // Velocity variables - float fallSpeed = malice ? 19f : death ? 17.5f : 16f; - if (expertMode) - fallSpeed += 4f * (1f - lifeRatio); + // Velocity variables + float fallSpeed = malice ? 19f : death ? 17.5f : 16f; + if (expertMode) + fallSpeed += 4f * (1f - lifeRatio); - float speed = malice ? 18f : death ? 16.5f : 15f; - float turnSpeed = malice ? 0.36f : death ? 0.33f : 0.3f; - float homingSpeed = malice ? 36f : death ? 30f : 24f; - float homingTurnSpeed = malice ? 0.48f : death ? 0.405f : 0.33f; + float speed = malice ? 18f : death ? 16.5f : 15f; + float turnSpeed = malice ? 0.36f : death ? 0.33f : 0.3f; + float homingSpeed = malice ? 36f : death ? 30f : 24f; + float homingTurnSpeed = malice ? 0.48f : death ? 0.405f : 0.33f; - if (expertMode) - { - speed += 3f * (1f - lifeRatio); - turnSpeed += 0.06f * (1f - lifeRatio); - homingSpeed += 12f * (1f - lifeRatio); - homingTurnSpeed += 0.15f * (1f - lifeRatio); - } + if (expertMode) + { + speed += 3f * (1f - lifeRatio); + turnSpeed += 0.06f * (1f - lifeRatio); + homingSpeed += 12f * (1f - lifeRatio); + homingTurnSpeed += 0.15f * (1f - lifeRatio); + } - float groundPhaseTurnSpeed = malice ? 0.3f : death ? 0.24f : 0.18f; + float groundPhaseTurnSpeed = malice ? 0.3f : death ? 0.24f : 0.18f; - if (expertMode) - groundPhaseTurnSpeed += 0.1f * (1f - lifeRatio); + if (expertMode) + groundPhaseTurnSpeed += 0.1f * (1f - lifeRatio); - groundPhaseTurnSpeed += Vector2.Distance(player.Center, npc.Center) * 0.0002f; + groundPhaseTurnSpeed += Vector2.Distance(player.Center, npc.Center) * 0.0002f; - // How long it takes before swapping phases - int phaseLimit = death ? 600 : 900; - if (expertMode && npc.ai[3] == 0f) - { - phaseLimit /= 1 + (int)((death ? 4f : 5f) * (1f - lifeRatio)); - if (phaseLimit < 180) - phaseLimit = 180; - } + // How long it takes before swapping phases + int phaseLimit = death ? 600 : 900; + if (expertMode && npc.ai[3] == 0f) + { + phaseLimit /= 1 + (int)((death ? 4f : 5f) * (1f - lifeRatio)); + if (phaseLimit < 180) + phaseLimit = 180; + } - // Continuously reset certain things. - AttemptingToEnterPortal = false; + // Continuously reset certain things. + AttemptingToEnterPortal = false; - // Light - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); + // Light + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); // Worm variable if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Despawn - if (player.dead) - { - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - - npc.velocity.Y -= 3f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 3f; - - int bodyType = ModContent.NPCType(); - int tailType = ModContent.NPCType(); - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type != npc.type && Main.npc[a].type != bodyType && Main.npc[a].type != tailType) - continue; - - Main.npc[a].active = false; - Main.npc[a].netUpdate = true; - } - } - } - - float distanceFromTarget = Vector2.Distance(player.Center, vector); - bool increaseSpeed = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance200Tiles; - bool increaseSpeedMore = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance350Tiles; - - float takeLessDamageDistance = 1600f; - if (distanceFromTarget > takeLessDamageDistance) - { - float damageTakenScalar = MathHelper.Clamp(1f - ((distanceFromTarget - takeLessDamageDistance) / takeLessDamageDistance), 0f, 1f); - npc.takenDamageMultiplier = MathHelper.Lerp(1f, 1.1f, damageTakenScalar); - } - else - npc.takenDamageMultiplier = 1.1f; - - // Close DoG's HP bar if busy with sentinels or a P2 transition. - if (CalamityWorld.DoGSecondStageCountdown > 0) - npc.Calamity().ShouldCloseHPBar = true; - - // Teleport after the Phase 2 animation. - if (CalamityWorld.DoGSecondStageCountdown == 61) - Teleport(player, malice, death, revenge, expertMode, phase5, true); - - // Be invincibile until the phase 2 teleport happens. - // This is done to prevent DoG from suddenly and weirdly re-appearing after entering the phase 1 portal. - // Once the teleport happens he will be in position and this effect stops. - if (Phase2Started && AwaitingPhase2Teleport && CalamityWorld.DoGSecondStageCountdown < 60) + // Despawn + if (player.dead) { - npc.Opacity = 0f; - npc.dontTakeDamage = true; + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + + npc.velocity.Y -= 3f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 3f; + + int bodyType = ModContent.NPCType(); + int tailType = ModContent.NPCType(); + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type != npc.type && Main.npc[a].type != bodyType && Main.npc[a].type != tailType) + continue; + + Main.npc[a].active = false; + Main.npc[a].netUpdate = true; + } + } } - // Start sentinel phases, only run things that have to happen once in here - if (summonSentinels) - { - if (!Phase2Started) - { - Phase2Started = true; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Reset important shit - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.netSpam = 0; - npc.netUpdate = true; - } - - // Skip the sentinel phase entirely if DoG has already been killed - CalamityWorld.DoGSecondStageCountdown = (CalamityWorld.downedDoG || CalamityWorld.downedSecondSentinels || BossRushEvent.BossRushActive) ? 600 : 21600; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); - netMessage.Write(CalamityWorld.DoGSecondStageCountdown); - netMessage.Send(); - } - } - - // Play music after the transiton BS - if (CalamityWorld.DoGSecondStageCountdown == 530) - music = CalamityMod.Instance.GetMusicFromMusicMod("DevourerOfGodsP2") ?? MusicID.LunarBoss; - - // Once before DoG spawns, set new size and become visible again. - if (CalamityWorld.DoGSecondStageCountdown == 60) - { - npc.position = npc.Center; - npc.width = 186; - npc.height = 186; - npc.position -= npc.Size * 0.5f; - npc.frame = new Rectangle(0, 0, 134, 196); - npc.netUpdate = true; - } - - // Dialogue the moment the second phase starts - if (CalamityWorld.DoGSecondStageCountdown == 60) - { - string key = "Mods.CalamityMod.EdgyBossText10"; - Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - } - - // Begin phase 2 once all sentinels are down - if (Phase2Started) - { - // Go immune and invisible if sentinels are alive - if (CalamityWorld.DoGSecondStageCountdown > 5) - { - // Don't take damage - npc.dontTakeDamage = true; - - // Adjust movement speed. Direction is unaltered unless DoG is close to the top of the world, in which case he moves horizontally. - // A portal will be created ahead of where DoG is moving that he will enter before Phase 2 begins. - float idealFlySpeed = 14f; - - float oldVelocity = npc.velocity.Length(); - float horizontalInterpolant = Utils.InverseLerp(1200f, 600f, npc.Center.Y, true); - Vector2 idealDirection = npc.velocity.SafeNormalize(-Vector2.UnitY); - idealDirection = Vector2.Lerp(idealDirection, Vector2.UnitX * Math.Sign(idealDirection.X), horizontalInterpolant); - npc.velocity = idealDirection * MathHelper.Lerp(oldVelocity, idealFlySpeed, 0.1f); - npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - - if (PortalIndex != -1) - { - Projectile portal = Main.projectile[PortalIndex]; - float newOpacity = 1f - Utils.InverseLerp(200f, 130f, npc.Distance(portal.Center), true); - if (Main.netMode != NetmodeID.MultiplayerClient && newOpacity > 0f && npc.Opacity > newOpacity) - { - npc.Opacity = newOpacity; - npc.netUpdate = true; - } - - if (npc.Opacity < 0.2f) - npc.Opacity = 0f; - - // Ensure the portal is pointing in the direction of the head at first, to prevent direction offsets. - if (CalamityWorld.DoGSecondStageCountdown > 360) - Main.projectile[PortalIndex].Center = npc.Center + npc.SafeDirectionTo(Main.projectile[PortalIndex].Center) * npc.Distance(Main.projectile[PortalIndex].Center); - } - - if (Main.netMode != NetmodeID.MultiplayerClient && !hasCreatedPhase1Portal) - { - Vector2 portalSpawnPosition = npc.Center + npc.velocity.SafeNormalize(-Vector2.UnitY) * 1000f; - PortalIndex = Projectile.NewProjectile(portalSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); - - hasCreatedPhase1Portal = true; - npc.netUpdate = true; - } - - AttemptingToEnterPortal = true; - } - - // Phase 2 - else - { - // Immunity after teleport and when dying - npc.dontTakeDamage = postTeleportTimer > 0 || preventBullshitHitsAtStartofFinalPhaseTimer > 0 || Dying; - - // Teleport - if (teleportTimer >= 0) - { - teleportTimer--; - if (teleportTimer == 0) - Teleport(player, malice, death, revenge, expertMode, phase5); - } - - // Do the death animation once killed. - if (Dying) - { - teleportTimer = 0; - DoDeathAnimation(); - return; - } - - // Laser walls - if (phase4 && !phase6 && postTeleportTimer <= 0) - { - if (laserWallPhase == (int)LaserWallPhase.SetUp) - { - // Increment next laser wall phase timer - calamityGlobalNPC.newAI[3] += 1f; - - // Set alpha value prior to firing laser walls - if (calamityGlobalNPC.newAI[3] > alphaGateValue) - { - // Disable teleports - if (teleportTimer >= 0) - { - GetRiftLocation(false); - teleportTimer = -1; - } - - npc.Opacity = 1f - (MathHelper.Clamp((calamityGlobalNPC.newAI[3] - alphaGateValue) * 5f, 0f, 255f) / 255f); - } - - // Fire laser walls every 12 seconds after a laser wall phase ends - if (calamityGlobalNPC.newAI[3] >= 720f) - { - npc.Opacity = 0f; - - // Reset laser wall timer to 0 - calamityGlobalNPC.newAI[1] = 0f; - - calamityGlobalNPC.newAI[3] = 0f; - laserWallPhase = (int)LaserWallPhase.FireLaserWalls; - } - } - else if (laserWallPhase == (int)LaserWallPhase.FireLaserWalls) - { - // Remain in laser wall firing phase for 6 seconds - idleCounter--; - if (idleCounter <= 0) - { - SpawnTeleportLocation(player); - laserWallPhase = (int)LaserWallPhase.End; - idleCounter = idleCounterMax; - } - } - else if (laserWallPhase == (int)LaserWallPhase.End) - { - // End laser wall phase after 4.25 seconds - npc.Opacity += 0.004f; - if (npc.Opacity >= 1f) - { - npc.Opacity = 1f; - laserWallPhase = (int)LaserWallPhase.SetUp; - } - } - } - else - { - // Set alpha after teleport - if (postTeleportTimer > 0) - { - postTeleportTimer--; - if (postTeleportTimer < 0) - postTeleportTimer = 0; - - npc.Opacity = 1f - (postTeleportTimer / 255f); - } - else - { - npc.Opacity += 0.024f; - if (npc.Opacity >= 1f) - npc.Opacity = 1f; - } - - // This exists so that DoG doesn't sometimes instantly kill the player when he goes to final phase - if (preventBullshitHitsAtStartofFinalPhaseTimer > 0) - { - preventBullshitHitsAtStartofFinalPhaseTimer--; - - if (npc.Opacity > 0.996f) - npc.Opacity = 0.996f; - } - - // Reset laser wall phase - if (laserWallPhase > (int)LaserWallPhase.SetUp) - laserWallPhase = (int)LaserWallPhase.SetUp; - - // Enter final phase - if (!spawnedGuardians3 && phase6) - { - SpawnTeleportLocation(player); - - preventBullshitHitsAtStartofFinalPhaseTimer = 180; - - // Anger message - string key = "Mods.CalamityMod.EdgyBossText11"; - Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); - - // Summon Thots - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); - - for (int i = 0; i < 3; i++) - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); - } - - spawnedGuardians3 = true; - } - } - - // Spawn segments and fire projectiles - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Fireballs - if (npc.Opacity >= 1f && distanceFromTarget > 500f) - { - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] >= 150f && calamityGlobalNPC.newAI[0] % (phase7 ? 20f : 40f) == 0f) - { - Vector2 vector44 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num427 = player.position.X + (player.width / 2) - vector44.X; - float num428 = player.position.Y + (player.height / 2) - vector44.Y; - float num430 = 8f; - float num429 = (float)Math.Sqrt(num427 * num427 + num428 * num428); - num429 = num430 / num429; - num427 *= num429; - num428 *= num429; - num428 += npc.velocity.Y * 0.5f; - num427 += npc.velocity.X * 0.5f; - vector44.X -= num427; - vector44.Y -= num428; - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(vector44.X, vector44.Y, num427, num428, type, damage, 0f, Main.myPlayer); - } - } - else if (distanceFromTarget < 250f) - calamityGlobalNPC.newAI[0] = 0f; - - // Laser walls - if (!phase6 && laserWallPhase == (int)LaserWallPhase.FireLaserWalls) - { - float spawnOffset = 1500f; - float divisor = malice ? 100f : 120f; - - if (calamityGlobalNPC.newAI[1] % divisor == 0f) - { - Main.PlaySound(SoundID.Item12, player.position); - - // Side walls - float targetPosY = player.position.Y; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int halfTotalDiagonalShots = totalDiagonalShots / 2; - Vector2 start = default; - Vector2 velocity = default; - Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; - - switch (laserWallType_Phase2) - { - case (int)LaserWallType_Phase2.Normal: - - for (int x = 0; x < totalShots_Phase2; x++) - { - Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - shotSpacing_Phase2[0] -= spacingVar_Phase2; - } - - if (expertMode) - { - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType_Phase2.Offset: - - targetPosY += 50f; - for (int x = 0; x < totalShots_Phase2; x++) - { - Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - shotSpacing_Phase2[0] -= spacingVar_Phase2; - } - - if (expertMode) - { - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType_Phase2.DiagonalHorizontal: - - for (int x = 0; x < totalDiagonalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0]); - aim.Y += laserWallSpacingOffset * (x - halfTotalDiagonalShots); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0]); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing_Phase2[0] -= diagonalSpacingVar; - } - - Projectile.NewProjectile(player.Center.X, targetPosY + spawnOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.Center.X, targetPosY - spawnOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer); - - break; - - case (int)LaserWallType_Phase2.MultiLayered: - - for (int x = 0; x < totalShots_Phase2; x++) - { - Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - shotSpacing_Phase2[0] -= spacingVar_Phase2; - } - - int totalBonusLasers = totalShots_Phase2 / 2; - for (int x = 0; x < totalBonusLasers; x++) - { - Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[3], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[3], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - shotSpacing_Phase2[3] -= Main.rand.NextBool(2) ? 180 : 200; - } - - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - - break; - - case (int)LaserWallType_Phase2.DiagonalVertical: - - for (int x = 0; x < totalDiagonalShots + 1; x++) - { - start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY + spawnOffset); - aim.X += laserWallSpacingOffset * (x - halfTotalDiagonalShots); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY - spawnOffset); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing_Phase2[0] -= diagonalSpacingVar; - } - - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - - break; - } - - // Pick a random laser wall phase in expert+ - if (expertMode) - { - int laserWallPhase; - int choices = revenge ? 5 : 3; - do laserWallPhase = Main.rand.Next(choices); - while (laserWallPhase == laserWallType_Phase2); - laserWallType_Phase2 = laserWallPhase; - } - else - laserWallType_Phase2 = laserWallType_Phase2 == (int)LaserWallType_Phase2.Normal ? (int)LaserWallType_Phase2.Offset : (int)LaserWallType_Phase2.Normal; - - // Lower wall - for (int x = 0; x < totalShots_Phase2; x++) - { - Projectile.NewProjectile(player.position.X + shotSpacing_Phase2[1], player.position.Y + spawnOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer); - shotSpacing_Phase2[1] -= spacingVar_Phase2; - } - - // Upper wall - for (int x = 0; x < totalShots_Phase2; x++) - { - Projectile.NewProjectile(player.position.X + shotSpacing_Phase2[2], player.position.Y - spawnOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer); - shotSpacing_Phase2[2] -= spacingVar_Phase2; - } - - for (int i = 0; i < shotSpacing_Phase2.Length; i++) - shotSpacing_Phase2[i] = shotSpacingMax_Phase2; - } - - calamityGlobalNPC.newAI[1] += 1f; - } - } - - // Set flight time to max during laser walls - if (!phase6 && laserWallPhase == (int)LaserWallPhase.FireLaserWalls) - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) - { - if (Main.player[Main.myPlayer].wingTime < Main.player[Main.myPlayer].wingTimeMax) - Main.player[Main.myPlayer].wingTime = Main.player[Main.myPlayer].wingTimeMax; - } - } - } - - // Movement - int num180 = (int)(npc.position.X / 16f) - 1; - int num181 = (int)((npc.position.X + npc.width) / 16f) + 2; - int num182 = (int)(npc.position.Y / 16f) - 1; - int num183 = (int)((npc.position.Y + npc.height) / 16f) + 2; - - if (num180 < 0) - num180 = 0; - if (num181 > Main.maxTilesX) - num181 = Main.maxTilesX; - if (num182 < 0) - num182 = 0; - if (num183 > Main.maxTilesY) - num183 = Main.maxTilesY; - - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; - else if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - - // Flight - if (npc.ai[3] == 0f) - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); - } - - // Charge in a direction for a second until the timer is back at 0 - if (postTeleportTimer > 0) - { - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - return; - } - - calamityGlobalNPC.newAI[2] += 1f; - - npc.localAI[1] = 0f; - - // Go to ground phase sooner - if (increaseSpeedMore) - { - if (laserWallPhase == (int)LaserWallPhase.SetUp && calamityGlobalNPC.newAI[3] <= alphaGateValue) - SpawnTeleportLocation(player); - else - calamityGlobalNPC.newAI[2] += 10f; - } - else - calamityGlobalNPC.newAI[2] += 2f; - - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = npc.Center; - float num191 = player.Center.X; - float num192 = player.Center.Y; - int num42 = -1; - int num43 = (int)(player.Center.X / 16f); - int num44 = (int)(player.Center.Y / 16f); - - // Charge at target for 1.5 seconds - bool flyAtTarget = (!phase4 || phase6) && calamityGlobalNPC.newAI[2] > phaseLimit - 90 && revenge; - - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) - { - for (int num46 = num44; num46 <= num44 + 15; num46++) - { - if (WorldGen.SolidTile2(num45, num46)) - { - num42 = num46; - break; - } - } - if (num42 > 0) - break; - } - - if (!flyAtTarget) - { - if (num42 > 0) - { - num42 *= 16; - float num47 = num42 - 800; - if (player.position.Y > num47) - { - num192 = num47; - if (Math.Abs(npc.Center.X - player.Center.X) < 500f) - { - if (npc.velocity.X > 0f) - num191 = player.Center.X + 600f; - else - num191 = player.Center.X - 600f; - } - } - } - } - else - { - num188 = homingSpeed; - num189 = homingTurnSpeed; - } - - num188 += Vector2.Distance(player.Center, npc.Center) * 0.005f; - num189 += Vector2.Distance(player.Center, npc.Center) * 0.00025f; - - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = npc.velocity.Length(); - if (num50 > 0f) - { - if (num50 > num48) - { - npc.velocity.Normalize(); - npc.velocity *= num48; - } - else if (num50 < num49) - { - npc.velocity.Normalize(); - npc.velocity *= num49; - } - } - - 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)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189; - else - { - if (npc.velocity.X > num191) - npc.velocity.X -= num189; - } - - if (npc.velocity.Y < num192) - npc.velocity.Y += num189; - else - { - if (npc.velocity.Y > num192) - npc.velocity.Y -= num189; - } - - 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 (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; - else - npc.velocity.X -= num189 * 2f; - } - } - else - { - if (num196 > num197) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189 * 1.1f; - else if (npc.velocity.X > num191) - npc.velocity.X -= num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num189; - else - npc.velocity.Y -= num189; - } - } - else - { - if (npc.velocity.Y < num192) - npc.velocity.Y += num189 * 1.1f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num189; - else - npc.velocity.X -= num189; - } - } - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - - if (calamityGlobalNPC.newAI[2] > phaseLimit) - { - npc.ai[3] = 1f; - calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Ground - else - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); - } - - // Charge in a direction for a second until the timer is back at 0 - if (postTeleportTimer > 0) - { - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - return; - } - - calamityGlobalNPC.newAI[2] += 1f; - - // Enrage - if (increaseSpeedMore) - { - if (laserWallPhase == (int)LaserWallPhase.SetUp && calamityGlobalNPC.newAI[3] <= alphaGateValue) - { - SpawnTeleportLocation(player); - } - else - groundPhaseTurnSpeed *= 4f; - } - else if (increaseSpeed) - groundPhaseTurnSpeed *= 2f; - - if (!flies) - { - for (int num952 = num180; num952 < num181; num952++) - { - for (int num953 = num182; num953 < num183; num953++) - { - 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 = 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; - } - } - } - } - } - - if (!flies) - { - npc.localAI[1] = 1f; - - Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - - int num954 = death ? 1125 : 1200; - - if (expertMode) - num954 -= (int)(150f * (1f - lifeRatio)); - - if (num954 < 1050) - num954 = 1050; - - bool flag95 = true; - if (npc.position.Y > player.position.Y) - { - for (int num955 = 0; num955 < Main.maxPlayers; num955++) - { - if (Main.player[num955].active) - { - Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - 1000, (int)Main.player[num955].position.Y - 1000, 2000, num954); - if (rectangle12.Intersects(rectangle13)) - { - flag95 = false; - break; - } - } - } - if (flag95) - flies = true; - } - } - else - npc.localAI[1] = 0f; - - float num189 = groundPhaseTurnSpeed; - Vector2 vector18 = npc.Center; - float num191 = player.Center.X; - float num192 = player.Center.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; - - if (!flies) - { - npc.velocity.Y += groundPhaseTurnSpeed; - if (npc.velocity.Y > fallSpeed) - npc.velocity.Y = fallSpeed; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 2.2) - { - if (npc.velocity.X < 0f) - npc.velocity.X -= num189 * 1.1f; - else - npc.velocity.X += num189 * 1.1f; - } - else if (npc.velocity.Y == fallSpeed) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189; - else if (npc.velocity.X > num191) - npc.velocity.X -= num189; - } - else if (npc.velocity.Y > 4f) - { - if (npc.velocity.X < 0f) - npc.velocity.X += num189 * 0.9f; - else - npc.velocity.X -= num189 * 0.9f; - } - } - else - { - double maximumSpeed1 = malice ? 0.52 : death ? 0.46 : 0.4; - double maximumSpeed2 = malice ? 1.25 : death ? 1.125 : 1D; - - if (expertMode) - { - maximumSpeed1 += 0.1f * (1f - lifeRatio); - maximumSpeed2 += 0.2f * (1f - lifeRatio); - } - - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num25 = Math.Abs(num191); - float num26 = Math.Abs(num192); - float num27 = fallSpeed / num193; - num191 *= num27; - num192 *= num27; - - if (((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f)) && ((npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f))) - { - if (npc.velocity.X < num191) - npc.velocity.X += groundPhaseTurnSpeed * 1.5f; - else if (npc.velocity.X > num191) - npc.velocity.X -= groundPhaseTurnSpeed * 1.5f; - - if (npc.velocity.Y < num192) - npc.velocity.Y += groundPhaseTurnSpeed * 1.5f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= groundPhaseTurnSpeed * 1.5f; - } - - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - npc.velocity.X += groundPhaseTurnSpeed; - else if (npc.velocity.X > num191) - npc.velocity.X -= groundPhaseTurnSpeed; - - if (npc.velocity.Y < num192) - npc.velocity.Y += groundPhaseTurnSpeed; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= groundPhaseTurnSpeed; - - if (Math.Abs(num192) < fallSpeed * maximumSpeed1 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += groundPhaseTurnSpeed * 2f; - else - npc.velocity.Y -= groundPhaseTurnSpeed * 2f; - } - - if (Math.Abs(num191) < fallSpeed * maximumSpeed1 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X += groundPhaseTurnSpeed * 2f; - else - npc.velocity.X -= groundPhaseTurnSpeed * 2f; - } - } - else if (num25 > num26) - { - if (npc.velocity.X < num191) - npc.velocity.X += groundPhaseTurnSpeed * 1.1f; - else if (npc.velocity.X > num191) - npc.velocity.X -= groundPhaseTurnSpeed * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += groundPhaseTurnSpeed; - else - npc.velocity.Y -= groundPhaseTurnSpeed; - } - } - else - { - if (npc.velocity.Y < num192) - npc.velocity.Y += groundPhaseTurnSpeed * 1.1f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= groundPhaseTurnSpeed * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) - { - if (npc.velocity.X > 0f) - npc.velocity.X += groundPhaseTurnSpeed; - else - npc.velocity.X -= groundPhaseTurnSpeed; - } - } - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - - if (flies) - { - if (npc.localAI[0] != 1f) - npc.netUpdate = true; - - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - npc.netUpdate = true; - - npc.localAI[0] = 0f; - } - - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; - - if (calamityGlobalNPC.newAI[2] > phaseLimit) - { - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - } - } - else - { - // Spawn Guardians - if (phase3) - { - if (!spawnedGuardians) - { - if (revenge) - spawnDoGCountdown = 10; - - string key = "Mods.CalamityMod.EdgyBossText"; - Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); - - npc.TargetClosest(); - spawnedGuardians = true; - } - - if (spawnDoGCountdown > 0) - { - spawnDoGCountdown--; - if (spawnDoGCountdown == 0 && Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); - - for (int i = 0; i < 2; i++) - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); - } - } - } - else if (phase2) - { - if (!spawnedGuardians2) - { - if (revenge) - spawnDoGCountdown = 10; - - spawnedGuardians2 = true; - } - - if (spawnDoGCountdown > 0) - { - spawnDoGCountdown--; - if (spawnDoGCountdown == 0 && Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); - - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); - } - } - } - - // Alpha - npc.Opacity += 0.047f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - - // Spawn segments - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!tail && npc.ai[0] == 0f) - { - int Previous = npc.whoAmI; - for (int segmentSpawn = 0; segmentSpawn < maxLength; segmentSpawn++) - { - int segment; - if (segmentSpawn >= 0 && segmentSpawn < minLength) - { - segment = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - Main.npc[segment].ModNPC().SegmentIndex = maxLength - segmentSpawn; - } - else - segment = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - - Main.npc[segment].realLife = npc.whoAmI; - Main.npc[segment].ai[2] = npc.whoAmI; - Main.npc[segment].ai[1] = Previous; - Main.npc[Previous].ai[0] = segment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment, 0f, 0f, 0f, 0); - Previous = segment; - } - tail = true; - } - - if (phase2) - { - float spawnOffset = 1500f; - float divisor = malice ? 240f : death ? 360f : 480f; - - if (calamityGlobalNPC.newAI[1] % divisor == 0f) - { - Main.PlaySound(SoundID.Item12, player.position); - - // Side walls - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 start = default; - Vector2 velocity = default; - Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; - Vector2 aimClone = aim; - - switch (laserWallType) - { - case (int)LaserWallType.DiagonalRight: - - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode) - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - - break; - - case (int)LaserWallType.DiagonalLeft: - - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode) - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - - break; - - case (int)LaserWallType.DiagonalHorizontal: - - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode) - { - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType.DiagonalCross: - - int randomLaserGap = Main.rand.Next(3) + 3; // 3, 4, 5, 6 - for (int x = 0; x < totalShots + 1; x++) - { - if (x != randomLaserGap && x != randomLaserGap + 1) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing, player.position.Y + spawnOffset); - aimClone.X += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aimClone - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing, player.position.Y - spawnOffset); - velocity = Vector2.Normalize(aimClone - start) * laserVelocity; - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); - } - - shotSpacing -= spacingVar; - } - - if (expertMode) - { - Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - } - - // Pick a random laser wall phase in expert+ - if (expertMode) - { - int laserWallPhase; - int choices = revenge ? 4 : 3; - do laserWallPhase = Main.rand.Next(choices); - while (laserWallPhase == laserWallType); - laserWallType = laserWallPhase; - } - else - laserWallType = laserWallType == (int)LaserWallType.DiagonalRight ? (int)LaserWallType.DiagonalLeft : (int)LaserWallType.DiagonalRight; - - shotSpacing = shotSpacingMax; - } - - calamityGlobalNPC.newAI[1] += 1f; - } - else - calamityGlobalNPC.newAI[1] = 0f; - } - - // Movement - int num180 = (int)(npc.position.X / 16f) - 1; - int num181 = (int)((npc.position.X + npc.width) / 16f) + 2; - int num182 = (int)(npc.position.Y / 16f) - 1; - int num183 = (int)((npc.position.Y + npc.height) / 16f) + 2; - - if (num180 < 0) - num180 = 0; - if (num181 > Main.maxTilesX) - num181 = Main.maxTilesX; - if (num182 < 0) - num182 = 0; - if (num183 > Main.maxTilesY) - num183 = Main.maxTilesY; - - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; - else if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - - // Flight - if (npc.ai[3] == 0f) - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); - } - - // Flying movement - npc.localAI[1] = 0f; - - calamityGlobalNPC.newAI[2] += 1f; - - // Go to ground phase sooner - if (increaseSpeedMore) - calamityGlobalNPC.newAI[2] += 10f; - else if (increaseSpeed) - calamityGlobalNPC.newAI[2] += 2f; - - float num188 = speed; - float num189 = turnSpeed; - 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); - - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) - { - for (int num46 = num44; num46 <= num44 + 15; num46++) - { - if (WorldGen.SolidTile2(num45, num46)) - { - num42 = num46; - break; - } - } - if (num42 > 0) - break; - } - - if (num42 > 0) - { - num42 *= 16; - float num47 = num42 - 800; - if (player.position.Y > num47) - { - num192 = num47; - if (Math.Abs(npc.Center.X - player.Center.X) < 500f) - { - if (npc.velocity.X > 0f) - num191 = player.Center.X + 600f; - else - num191 = player.Center.X - 600f; - } - } - } - else - { - num188 = homingSpeed; - num189 = homingTurnSpeed; - } - - if (expertMode) - { - num188 += distanceFromTarget * 0.005f * (1f - lifeRatio); - num189 += distanceFromTarget * 0.0001f * (1f - lifeRatio); - } - - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = npc.velocity.Length(); - if (num50 > 0f) - { - if (num50 > num48) - { - npc.velocity.Normalize(); - npc.velocity *= num48; - } - else if (num50 < num49) - { - npc.velocity.Normalize(); - npc.velocity *= num49; - } - } - - 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)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189; - else - { - if (npc.velocity.X > num191) - npc.velocity.X -= num189; - } - - if (npc.velocity.Y < num192) - npc.velocity.Y += num189; - else - { - if (npc.velocity.Y > num192) - npc.velocity.Y -= num189; - } - - 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 (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; - else - npc.velocity.X -= num189 * 2f; - } - } - else - { - if (num196 > num197) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189 * 1.1f; - else if (npc.velocity.X > num191) - npc.velocity.X -= num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num189; - else - npc.velocity.Y -= num189; - } - } - else - { - if (npc.velocity.Y < num192) - npc.velocity.Y += num189 * 1.1f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num189; - else - npc.velocity.X -= num189; - } - } - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - - if (calamityGlobalNPC.newAI[2] > phaseLimit) - { - npc.ai[3] = 1f; - calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Ground - else - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); - } - - calamityGlobalNPC.newAI[2] += 1f; - - // Enrage - if (increaseSpeedMore) - groundPhaseTurnSpeed *= 4f; - else if (increaseSpeed) - groundPhaseTurnSpeed *= 2f; - - if (!flies) - { - for (int num952 = num180; num952 < num181; num952++) - { - for (int num953 = num182; num953 < num183; num953++) - { - 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 = 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; - } - } - } - } - } - - if (!flies) - { - npc.localAI[1] = 1f; - - Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - - int num954 = death ? 1125 : 1200; - - if (expertMode) - num954 -= (int)(150f * (1f - lifeRatio)); - - if (num954 < 1050) - num954 = 1050; - - bool flag95 = true; - if (npc.position.Y > player.position.Y) - { - for (int num955 = 0; num955 < 255; num955++) - { - if (Main.player[num955].active) - { - Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - 1000, (int)Main.player[num955].position.Y - 1000, 2000, num954); - if (rectangle12.Intersects(rectangle13)) - { - flag95 = false; - break; - } - } - } - if (flag95) - flies = true; - } - } - else - npc.localAI[1] = 0f; - - float num189 = groundPhaseTurnSpeed; - Vector2 vector18 = npc.Center; - float num191 = player.Center.X; - float num192 = player.Center.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; - - if (!flies) - { - npc.velocity.Y += groundPhaseTurnSpeed; - if (npc.velocity.Y > fallSpeed) - npc.velocity.Y = fallSpeed; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 2.2) - { - if (npc.velocity.X < 0f) - npc.velocity.X -= num189 * 1.1f; - else - npc.velocity.X += num189 * 1.1f; - } - else if (npc.velocity.Y == fallSpeed) - { - if (npc.velocity.X < num191) - npc.velocity.X += num189; - else if (npc.velocity.X > num191) - npc.velocity.X -= num189; - } - else if (npc.velocity.Y > 4f) - { - if (npc.velocity.X < 0f) - npc.velocity.X += num189 * 0.9f; - else - npc.velocity.X -= num189 * 0.9f; - } - } - else - { - double maximumSpeed1 = malice ? 0.52 : death ? 0.46 : 0.4; - double maximumSpeed2 = malice ? 1.25 : death ? 1.125 : 1D; - - if (expertMode) - { - maximumSpeed1 += 0.1f * (1f - lifeRatio); - maximumSpeed2 += 0.2f * (1f - lifeRatio); - } - - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num25 = Math.Abs(num191); - float num26 = Math.Abs(num192); - float num27 = fallSpeed / num193; - num191 *= num27; - num192 *= num27; - - if (((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f)) && ((npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f))) - { - if (npc.velocity.X < num191) - npc.velocity.X += groundPhaseTurnSpeed * 1.5f; - else if (npc.velocity.X > num191) - npc.velocity.X -= groundPhaseTurnSpeed * 1.5f; - - if (npc.velocity.Y < num192) - npc.velocity.Y += groundPhaseTurnSpeed * 1.5f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= groundPhaseTurnSpeed * 1.5f; - } - - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - npc.velocity.X += groundPhaseTurnSpeed; - else if (npc.velocity.X > num191) - npc.velocity.X -= groundPhaseTurnSpeed; - - if (npc.velocity.Y < num192) - npc.velocity.Y += groundPhaseTurnSpeed; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= groundPhaseTurnSpeed; - - if (Math.Abs(num192) < fallSpeed * maximumSpeed1 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += groundPhaseTurnSpeed * 2f; - else - npc.velocity.Y -= groundPhaseTurnSpeed * 2f; - } - - if (Math.Abs(num191) < fallSpeed * maximumSpeed1 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X += groundPhaseTurnSpeed * 2f; - else - npc.velocity.X -= groundPhaseTurnSpeed * 2f; - } - } - else if (num25 > num26) - { - if (npc.velocity.X < num191) - npc.velocity.X += groundPhaseTurnSpeed * 1.1f; - else if (npc.velocity.X > num191) - npc.velocity.X -= groundPhaseTurnSpeed * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += groundPhaseTurnSpeed; - else - npc.velocity.Y -= groundPhaseTurnSpeed; - } - } - else - { - if (npc.velocity.Y < num192) - npc.velocity.Y += groundPhaseTurnSpeed * 1.1f; - else if (npc.velocity.Y > num192) - npc.velocity.Y -= groundPhaseTurnSpeed * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) - { - if (npc.velocity.X > 0f) - npc.velocity.X += groundPhaseTurnSpeed; - else - npc.velocity.X -= groundPhaseTurnSpeed; - } - } - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - - if (flies) - { - if (npc.localAI[0] != 1f) - npc.netUpdate = true; - - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - npc.netUpdate = true; - - npc.localAI[0] = 0f; - } - - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; - - if (calamityGlobalNPC.newAI[2] > phaseLimit) - { - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - } - - if (npc.life > Main.npc[(int)npc.ai[0]].life) - npc.life = Main.npc[(int)npc.ai[0]].life; - } - - private void SpawnTeleportLocation(Player player) - { - if (teleportTimer > -1 || player.dead || !player.active) - return; - - teleportTimer = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 120 : CalamityWorld.revenge ? 140 : Main.expertMode ? 160 : 180; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int randomRange = 48; - float distance = 640f; - Vector2 targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1)); - Main.PlaySound(SoundID.Item109, player.Center); - Projectile.NewProjectile(targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, npc.whoAmI); - } - } - - private void Teleport(Player player, bool malice, bool death, bool revenge, bool expertMode, bool phase5, bool phase2Transition = false) - { - if (Main.netMode != NetmodeID.MultiplayerClient && phase2Transition) - { - int randomRange = 48; - float distance = 1080f; - Vector2 targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1)); - Projectile.NewProjectile(targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, npc.whoAmI); - } - - Vector2 newPosition = GetRiftLocation(true); - - if ((!AwaitingPhase2Teleport && (player.dead || !player.active)) || newPosition == default) - return; - - if (phase5) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float finalVelocity = 10f; - int totalSpreads = revenge ? 6 : 3; - float mult = revenge ? 1.5f : 3f; - for (int i = 0; i < totalSpreads; i++) - { - int totalProjectiles = malice ? 18 : 12; - float radians = MathHelper.TwoPi / totalProjectiles; - float newVelocity = finalVelocity - i * mult; - float velocityMult = 1f + ((finalVelocity - newVelocity) / (newVelocity * 2f) / 100f); - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = i < 3 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); - float finalVelocityReduction = (float)Math.Pow(1.25, i) - 1f; - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(newPosition, vector255, type, damage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); - } - } - } - } - - npc.TargetClosest(); - npc.position = newPosition; - float chargeVelocity = malice ? 30f : death ? 26f : revenge ? 24f : expertMode ? 22f : 20f; - float maxChargeDistance = 1600f; - postTeleportTimer = (int)Math.Round(maxChargeDistance / chargeVelocity); - AwaitingPhase2Teleport = false; - npc.Opacity = 1f - (postTeleportTimer / 255f); - npc.velocity = Vector2.Normalize(player.Center + player.velocity * 40f - npc.Center) * chargeVelocity; - npc.netUpdate = true; - - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && (Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType())) - { - Main.npc[i].position = newPosition; - - if (Main.npc[i].type == ModContent.NPCType()) - ((DevourerofGodsTail)Main.npc[i].modNPC).setInvulTime(720); - - Main.npc[i].netUpdate = true; - } - } - - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), player.Center); - } - - public void DoDeathAnimation() - { - // Play a sound at the start. - if (DeathAnimationTimer == 1f) - { - var soundInstance = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), npc.Center); - CalamityUtils.SafeVolumeChange(ref soundInstance, 1.6f); - } - - // Close the health bar, fade in, and stop doing contact damage. - npc.Calamity().CanHaveBossHealthBar = false; - npc.Opacity = MathHelper.Clamp(npc.Opacity + 0.1f, 0f, 1f); - npc.dontTakeDamage = true; - npc.damage = 0; - - void destroySegment(int index, ref int destroyedSegments) - { - if (Main.rand.NextBool(5)) - Main.PlaySound(SoundID.Item94, npc.Center); - - List segments = new List() - { - ModContent.NPCType(), - ModContent.NPCType() - }; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (segments.Contains(Main.npc[i].type) && Main.npc[i].active && - (Main.npc[i].type == segments[1] || Main.npc[i].ModNPC().SegmentIndex == index)) - { - for (int j = 0; j < 20; j++) - { - Dust cosmicBurst = Dust.NewDustPerfect(Main.npc[i].Center + Main.rand.NextVector2Circular(25f, 25f), 234); - cosmicBurst.scale = 1.7f; - cosmicBurst.velocity = Main.rand.NextVector2Circular(9f, 9f); - cosmicBurst.noGravity = true; - } - - Main.npc[i].life = 0; - Main.npc[i].HitEffect(); - Main.npc[i].active = false; - Main.npc[i].netUpdate = true; - destroyedSegments++; - break; - } - } - } - - // Slow down but maintain a specific direction. - float idealSpeed = MathHelper.Lerp(8.4f, 4f, Utils.InverseLerp(15f, 210f, DeathAnimationTimer, true)); - if (npc.velocity.Length() != idealSpeed) - npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY) * MathHelper.Lerp(npc.velocity.Length(), idealSpeed, 0.08f); - - // Stay within the world. - if (npc.Center.X < 300f || npc.Center.X > Main.maxTilesX * 16f - 300f) - npc.velocity.X *= -1f; - if (npc.Center.Y < 300f || npc.Center.Y > Main.maxTilesY * 16f - 300f) - npc.velocity.Y *= -1f; - - if (DeathAnimationTimer >= 120f && DeathAnimationTimer < 370f && DeathAnimationTimer % 3f == 0f) - { - int segmentToDestroy = (int)(Utils.InverseLerp(120f, 370f, DeathAnimationTimer, true) * 60f); - destroySegment(segmentToDestroy, ref DestroyedSegmentCount); - } - - if (DeathAnimationTimer == 452f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); - - if (Main.netMode != NetmodeID.Server) - { - var soundInstance = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), npc.Center); - CalamityUtils.SafeVolumeChange(ref soundInstance, 1.6f); - - for (int i = 0; i < 3; i++) - { - soundInstance = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"), npc.Center); - if (soundInstance != null) - { - soundInstance.Pitch = -MathHelper.Lerp(0.1f, 0.4f, i / 3f); - CalamityUtils.SafeVolumeChange(ref soundInstance, 1.4f); - } - } - } - } - - if (DeathAnimationTimer >= 410f && DeathAnimationTimer < 470f && DeathAnimationTimer % 2f == 0f) - { - int segmentToDestroy = (int)(Utils.InverseLerp(410f, 470f, DeathAnimationTimer, true) * 10f) + 60; - destroySegment(segmentToDestroy, ref DeathAnimationTimer); - } - - float light = Utils.InverseLerp(430f, 465f, DeathAnimationTimer, true); - MoonlordDeathDrama.RequestLight(light, Main.LocalPlayer.Center); - - if (DeathAnimationTimer >= 485f) - { - npc.life = 0; - npc.HitEffect(); - npc.NPCLoot(); - npc.active = false; - npc.netUpdate = true; - } - DeathAnimationTimer++; - } - - private Vector2 GetRiftLocation(bool spawnDust) - { - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].type == ModContent.ProjectileType()) - { - if (!spawnDust) - Main.projectile[i].ai[0] = -1f; - - Main.projectile[i].Kill(); - return Main.projectile[i].Center; - } - } - return default; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - float disintegrationFactor = DeathAnimationTimer / 800f; - if (disintegrationFactor > 0f) - { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(npc.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); - } - - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - bool useOtherTextures = Phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60; - Texture2D texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadS") : Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - if (!npc.dontTakeDamage) - { - texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadSGlow") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadGlow"); - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadSGlow2") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadGlow2"); - color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); - - return false; - } - - public override void BossLoot(ref string name, ref int potionType) - { - potionType = ModContent.ItemType(); - } - - public override bool SpecialNPCLoot() - { - int closestSegmentID = DropHelper.FindClosestWormSegment(npc, - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType()); - npc.position = Main.npc[closestSegmentID].position; - return false; - } - - 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; - - CalamityGlobalNPC.SetNewBossJustDowned(npc); - - DropHelper.DropBags(npc); - - DropHelper.DropItem(npc, ModContent.ItemType(), 5, 15); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedDoG); - - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedDoG); - - // Mount - CalamityPlayer mp = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Calamity(); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, mp.fabsolVodka); - - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - // Materials - DropHelper.DropItem(npc, ModContent.ItemType(), 25, 35); - DropHelper.DropItem(npc, ModContent.ItemType(), 150, 250); - - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); - - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - } - - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); - - // If DoG has not been killed yet, notify players that the holiday moons are buffed - if (!CalamityWorld.downedDoG) - { - string key = "Mods.CalamityMod.DoGBossText"; - Color messageColor = Color.Cyan; - string key2 = "Mods.CalamityMod.DoGBossText2"; - Color messageColor2 = Color.Orange; - string key3 = "Mods.CalamityMod.DargonBossText"; - - CalamityUtils.DisplayLocalizedText(key, messageColor); - CalamityUtils.DisplayLocalizedText(key2, messageColor2); - CalamityUtils.DisplayLocalizedText(key3, messageColor2); - } - - // Mark DoG as dead - CalamityWorld.downedDoG = true; - CalamityNetcode.SyncWorld(); - } - - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - - Rectangle targetHitbox = target.Hitbox; - - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; - - return minDist <= (Phase2Started ? 80f : 55f) && (npc.Opacity >= 1f || postTeleportTimer > 0) && preventBullshitHitsAtStartofFinalPhaseTimer <= 0; - } + float distanceFromTarget = Vector2.Distance(player.Center, vector); + bool increaseSpeed = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance200Tiles; + bool increaseSpeedMore = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance350Tiles; + + float takeLessDamageDistance = 1600f; + if (distanceFromTarget > takeLessDamageDistance) + { + float damageTakenScalar = MathHelper.Clamp(1f - ((distanceFromTarget - takeLessDamageDistance) / takeLessDamageDistance), 0f, 1f); + npc.takenDamageMultiplier = MathHelper.Lerp(1f, 1.1f, damageTakenScalar); + } + else + npc.takenDamageMultiplier = 1.1f; + + // Close DoG's HP bar if busy with sentinels or a P2 transition. + if (CalamityWorld.DoGSecondStageCountdown > 0) + npc.Calamity().ShouldCloseHPBar = true; + + // Teleport after the Phase 2 animation. + if (CalamityWorld.DoGSecondStageCountdown == 61) + Teleport(player, malice, death, revenge, expertMode, phase5, true); + + // Be invincibile until the phase 2 teleport happens. + // This is done to prevent DoG from suddenly and weirdly re-appearing after entering the phase 1 portal. + // Once the teleport happens he will be in position and this effect stops. + if (Phase2Started && AwaitingPhase2Teleport && CalamityWorld.DoGSecondStageCountdown < 60) + { + npc.Opacity = 0f; + npc.dontTakeDamage = true; + } + + // Start sentinel phases, only run things that have to happen once in here + if (summonSentinels) + { + if (!Phase2Started) + { + Phase2Started = true; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Reset important shit + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.netSpam = 0; + npc.netUpdate = true; + } + + // Skip the sentinel phase entirely if DoG has already been killed + CalamityWorld.DoGSecondStageCountdown = (CalamityWorld.downedDoG || CalamityWorld.downedSecondSentinels || BossRushEvent.BossRushActive) ? 600 : 21600; + if (Main.netMode == NetmodeID.Server) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); + netMessage.Write(CalamityWorld.DoGSecondStageCountdown); + netMessage.Send(); + } + } + + // Play music after the transiton BS + if (CalamityWorld.DoGSecondStageCountdown == 530) + music = CalamityMod.Instance.GetMusicFromMusicMod("DevourerOfGodsP2") ?? MusicID.LunarBoss; + + // Once before DoG spawns, set new size and become visible again. + if (CalamityWorld.DoGSecondStageCountdown == 60) + { + npc.position = npc.Center; + npc.width = 186; + npc.height = 186; + npc.position -= npc.Size * 0.5f; + npc.frame = new Rectangle(0, 0, 134, 196); + npc.netUpdate = true; + } + + // Dialogue the moment the second phase starts + if (CalamityWorld.DoGSecondStageCountdown == 60) + { + string key = "Mods.CalamityMod.EdgyBossText10"; + Color messageColor = Color.Cyan; + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + } + + // Begin phase 2 once all sentinels are down + if (Phase2Started) + { + // Go immune and invisible if sentinels are alive + if (CalamityWorld.DoGSecondStageCountdown > 5) + { + // Don't take damage + npc.dontTakeDamage = true; + + // Adjust movement speed. Direction is unaltered unless DoG is close to the top of the world, in which case he moves horizontally. + // A portal will be created ahead of where DoG is moving that he will enter before Phase 2 begins. + float idealFlySpeed = 14f; + + float oldVelocity = npc.velocity.Length(); + float horizontalInterpolant = Utils.InverseLerp(1200f, 600f, npc.Center.Y, true); + Vector2 idealDirection = npc.velocity.SafeNormalize(-Vector2.UnitY); + idealDirection = Vector2.Lerp(idealDirection, Vector2.UnitX * Math.Sign(idealDirection.X), horizontalInterpolant); + npc.velocity = idealDirection * MathHelper.Lerp(oldVelocity, idealFlySpeed, 0.1f); + npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; + + if (PortalIndex != -1) + { + Projectile portal = Main.projectile[PortalIndex]; + float newOpacity = 1f - Utils.InverseLerp(200f, 130f, npc.Distance(portal.Center), true); + if (Main.netMode != NetmodeID.MultiplayerClient && newOpacity > 0f && npc.Opacity > newOpacity) + { + npc.Opacity = newOpacity; + npc.netUpdate = true; + } + + if (npc.Opacity < 0.2f) + npc.Opacity = 0f; + + // Ensure the portal is pointing in the direction of the head at first, to prevent direction offsets. + if (CalamityWorld.DoGSecondStageCountdown > 360) + Main.projectile[PortalIndex].Center = npc.Center + npc.SafeDirectionTo(Main.projectile[PortalIndex].Center) * npc.Distance(Main.projectile[PortalIndex].Center); + } + + if (Main.netMode != NetmodeID.MultiplayerClient && !hasCreatedPhase1Portal) + { + Vector2 portalSpawnPosition = npc.Center + npc.velocity.SafeNormalize(-Vector2.UnitY) * 1000f; + PortalIndex = Projectile.NewProjectile(portalSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); + + hasCreatedPhase1Portal = true; + npc.netUpdate = true; + } + + AttemptingToEnterPortal = true; + } + + // Phase 2 + else + { + // Immunity after teleport and when dying + npc.dontTakeDamage = postTeleportTimer > 0 || preventBullshitHitsAtStartofFinalPhaseTimer > 0 || Dying; + + // Teleport + if (teleportTimer >= 0) + { + teleportTimer--; + if (teleportTimer == 0) + Teleport(player, malice, death, revenge, expertMode, phase5); + } + + // Do the death animation once killed. + if (Dying) + { + teleportTimer = 0; + DoDeathAnimation(); + return; + } + + // Laser walls + if (phase4 && !phase6 && postTeleportTimer <= 0) + { + if (laserWallPhase == (int)LaserWallPhase.SetUp) + { + // Increment next laser wall phase timer + calamityGlobalNPC.newAI[3] += 1f; + + // Set alpha value prior to firing laser walls + if (calamityGlobalNPC.newAI[3] > alphaGateValue) + { + // Disable teleports + if (teleportTimer >= 0) + { + GetRiftLocation(false); + teleportTimer = -1; + } + + npc.Opacity = 1f - (MathHelper.Clamp((calamityGlobalNPC.newAI[3] - alphaGateValue) * 5f, 0f, 255f) / 255f); + } + + // Fire laser walls every 12 seconds after a laser wall phase ends + if (calamityGlobalNPC.newAI[3] >= 720f) + { + npc.Opacity = 0f; + + // Reset laser wall timer to 0 + calamityGlobalNPC.newAI[1] = 0f; + + calamityGlobalNPC.newAI[3] = 0f; + laserWallPhase = (int)LaserWallPhase.FireLaserWalls; + } + } + else if (laserWallPhase == (int)LaserWallPhase.FireLaserWalls) + { + // Remain in laser wall firing phase for 6 seconds + idleCounter--; + if (idleCounter <= 0) + { + SpawnTeleportLocation(player); + laserWallPhase = (int)LaserWallPhase.End; + idleCounter = idleCounterMax; + } + } + else if (laserWallPhase == (int)LaserWallPhase.End) + { + // End laser wall phase after 4.25 seconds + npc.Opacity += 0.004f; + if (npc.Opacity >= 1f) + { + npc.Opacity = 1f; + laserWallPhase = (int)LaserWallPhase.SetUp; + } + } + } + else + { + // Set alpha after teleport + if (postTeleportTimer > 0) + { + postTeleportTimer--; + if (postTeleportTimer < 0) + postTeleportTimer = 0; + + npc.Opacity = 1f - (postTeleportTimer / 255f); + } + else + { + npc.Opacity += 0.024f; + if (npc.Opacity >= 1f) + npc.Opacity = 1f; + } + + // This exists so that DoG doesn't sometimes instantly kill the player when he goes to final phase + if (preventBullshitHitsAtStartofFinalPhaseTimer > 0) + { + preventBullshitHitsAtStartofFinalPhaseTimer--; + + if (npc.Opacity > 0.996f) + npc.Opacity = 0.996f; + } + + // Reset laser wall phase + if (laserWallPhase > (int)LaserWallPhase.SetUp) + laserWallPhase = (int)LaserWallPhase.SetUp; + + // Enter final phase + if (!spawnedGuardians3 && phase6) + { + SpawnTeleportLocation(player); + + preventBullshitHitsAtStartofFinalPhaseTimer = 180; + + // Anger message + string key = "Mods.CalamityMod.EdgyBossText11"; + Color messageColor = Color.Cyan; + CalamityUtils.DisplayLocalizedText(key, messageColor); + + // Summon Thots + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); + + for (int i = 0; i < 3; i++) + NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); + } + + spawnedGuardians3 = true; + } + } + + // Spawn segments and fire projectiles + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Fireballs + if (npc.Opacity >= 1f && distanceFromTarget > 500f) + { + calamityGlobalNPC.newAI[0] += 1f; + if (calamityGlobalNPC.newAI[0] >= 150f && calamityGlobalNPC.newAI[0] % (phase7 ? 20f : 40f) == 0f) + { + Vector2 vector44 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num427 = player.position.X + (player.width / 2) - vector44.X; + float num428 = player.position.Y + (player.height / 2) - vector44.Y; + float num430 = 8f; + float num429 = (float)Math.Sqrt(num427 * num427 + num428 * num428); + num429 = num430 / num429; + num427 *= num429; + num428 *= num429; + num428 += npc.velocity.Y * 0.5f; + num427 += npc.velocity.X * 0.5f; + vector44.X -= num427; + vector44.Y -= num428; + + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(vector44.X, vector44.Y, num427, num428, type, damage, 0f, Main.myPlayer); + } + } + else if (distanceFromTarget < 250f) + calamityGlobalNPC.newAI[0] = 0f; + + // Laser walls + if (!phase6 && laserWallPhase == (int)LaserWallPhase.FireLaserWalls) + { + float spawnOffset = 1500f; + float divisor = malice ? 100f : 120f; + + if (calamityGlobalNPC.newAI[1] % divisor == 0f) + { + Main.PlaySound(SoundID.Item12, player.position); + + // Side walls + float targetPosY = player.position.Y; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + int halfTotalDiagonalShots = totalDiagonalShots / 2; + Vector2 start = default; + Vector2 velocity = default; + Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; + + switch (laserWallType_Phase2) + { + case (int)LaserWallType_Phase2.Normal: + + for (int x = 0; x < totalShots_Phase2; x++) + { + Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[0] -= spacingVar_Phase2; + } + + if (expertMode) + { + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + } + + break; + + case (int)LaserWallType_Phase2.Offset: + + targetPosY += 50f; + for (int x = 0; x < totalShots_Phase2; x++) + { + Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[0] -= spacingVar_Phase2; + } + + if (expertMode) + { + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + } + + break; + + case (int)LaserWallType_Phase2.DiagonalHorizontal: + + for (int x = 0; x < totalDiagonalShots + 1; x++) + { + start = new Vector2(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0]); + aim.Y += laserWallSpacingOffset * (x - halfTotalDiagonalShots); + velocity = Vector2.Normalize(aim - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0]); + velocity = Vector2.Normalize(aim - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + shotSpacing_Phase2[0] -= diagonalSpacingVar; + } + + Projectile.NewProjectile(player.Center.X, targetPosY + spawnOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.Center.X, targetPosY - spawnOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer); + + break; + + case (int)LaserWallType_Phase2.MultiLayered: + + for (int x = 0; x < totalShots_Phase2; x++) + { + Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[0] -= spacingVar_Phase2; + } + + int totalBonusLasers = totalShots_Phase2 / 2; + for (int x = 0; x < totalBonusLasers; x++) + { + Projectile.NewProjectile(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[3], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[3], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[3] -= Main.rand.NextBool(2) ? 180 : 200; + } + + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + + break; + + case (int)LaserWallType_Phase2.DiagonalVertical: + + for (int x = 0; x < totalDiagonalShots + 1; x++) + { + start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY + spawnOffset); + aim.X += laserWallSpacingOffset * (x - halfTotalDiagonalShots); + velocity = Vector2.Normalize(aim - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY - spawnOffset); + velocity = Vector2.Normalize(aim - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + shotSpacing_Phase2[0] -= diagonalSpacingVar; + } + + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + + break; + } + + // Pick a random laser wall phase in expert+ + if (expertMode) + { + int laserWallPhase; + int choices = revenge ? 5 : 3; + do laserWallPhase = Main.rand.Next(choices); + while (laserWallPhase == laserWallType_Phase2); + laserWallType_Phase2 = laserWallPhase; + } + else + laserWallType_Phase2 = laserWallType_Phase2 == (int)LaserWallType_Phase2.Normal ? (int)LaserWallType_Phase2.Offset : (int)LaserWallType_Phase2.Normal; + + // Lower wall + for (int x = 0; x < totalShots_Phase2; x++) + { + Projectile.NewProjectile(player.position.X + shotSpacing_Phase2[1], player.position.Y + spawnOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[1] -= spacingVar_Phase2; + } + + // Upper wall + for (int x = 0; x < totalShots_Phase2; x++) + { + Projectile.NewProjectile(player.position.X + shotSpacing_Phase2[2], player.position.Y - spawnOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer); + shotSpacing_Phase2[2] -= spacingVar_Phase2; + } + + for (int i = 0; i < shotSpacing_Phase2.Length; i++) + shotSpacing_Phase2[i] = shotSpacingMax_Phase2; + } + + calamityGlobalNPC.newAI[1] += 1f; + } + } + + // Set flight time to max during laser walls + if (!phase6 && laserWallPhase == (int)LaserWallPhase.FireLaserWalls) + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) + { + if (Main.player[Main.myPlayer].wingTime < Main.player[Main.myPlayer].wingTimeMax) + Main.player[Main.myPlayer].wingTime = Main.player[Main.myPlayer].wingTimeMax; + } + } + } + + // Movement + int num180 = (int)(npc.position.X / 16f) - 1; + int num181 = (int)((npc.position.X + npc.width) / 16f) + 2; + int num182 = (int)(npc.position.Y / 16f) - 1; + int num183 = (int)((npc.position.Y + npc.height) / 16f) + 2; + + if (num180 < 0) + num180 = 0; + if (num181 > Main.maxTilesX) + num181 = Main.maxTilesX; + if (num182 < 0) + num182 = 0; + if (num183 > Main.maxTilesY) + num183 = Main.maxTilesY; + + if (npc.velocity.X < 0f) + npc.spriteDirection = -1; + else if (npc.velocity.X > 0f) + npc.spriteDirection = 1; + + // Flight + if (npc.ai[3] == 0f) + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); + } + + // Charge in a direction for a second until the timer is back at 0 + if (postTeleportTimer > 0) + { + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + return; + } + + calamityGlobalNPC.newAI[2] += 1f; + + npc.localAI[1] = 0f; + + // Go to ground phase sooner + if (increaseSpeedMore) + { + if (laserWallPhase == (int)LaserWallPhase.SetUp && calamityGlobalNPC.newAI[3] <= alphaGateValue) + SpawnTeleportLocation(player); + else + calamityGlobalNPC.newAI[2] += 10f; + } + else + calamityGlobalNPC.newAI[2] += 2f; + + float num188 = speed; + float num189 = turnSpeed; + Vector2 vector18 = npc.Center; + float num191 = player.Center.X; + float num192 = player.Center.Y; + int num42 = -1; + int num43 = (int)(player.Center.X / 16f); + int num44 = (int)(player.Center.Y / 16f); + + // Charge at target for 1.5 seconds + bool flyAtTarget = (!phase4 || phase6) && calamityGlobalNPC.newAI[2] > phaseLimit - 90 && revenge; + + for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) + { + for (int num46 = num44; num46 <= num44 + 15; num46++) + { + if (WorldGen.SolidTile2(num45, num46)) + { + num42 = num46; + break; + } + } + if (num42 > 0) + break; + } + + if (!flyAtTarget) + { + if (num42 > 0) + { + num42 *= 16; + float num47 = num42 - 800; + if (player.position.Y > num47) + { + num192 = num47; + if (Math.Abs(npc.Center.X - player.Center.X) < 500f) + { + if (npc.velocity.X > 0f) + num191 = player.Center.X + 600f; + else + num191 = player.Center.X - 600f; + } + } + } + } + else + { + num188 = homingSpeed; + num189 = homingTurnSpeed; + } + + num188 += Vector2.Distance(player.Center, npc.Center) * 0.005f; + num189 += Vector2.Distance(player.Center, npc.Center) * 0.00025f; + + float num48 = num188 * 1.3f; + float num49 = num188 * 0.7f; + float num50 = npc.velocity.Length(); + if (num50 > 0f) + { + if (num50 > num48) + { + npc.velocity.Normalize(); + npc.velocity *= num48; + } + else if (num50 < num49) + { + npc.velocity.Normalize(); + npc.velocity *= num49; + } + } + + 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)Math.Sqrt(num191 * num191 + num192 * num192); + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); + float num198 = num188 / num193; + num191 *= num198; + num192 *= num198; + + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189; + else + { + if (npc.velocity.X > num191) + npc.velocity.X -= num189; + } + + if (npc.velocity.Y < num192) + npc.velocity.Y += num189; + else + { + if (npc.velocity.Y > num192) + npc.velocity.Y -= num189; + } + + 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 (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; + else + npc.velocity.X -= num189 * 2f; + } + } + else + { + if (num196 > num197) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189 * 1.1f; + else if (npc.velocity.X > num191) + npc.velocity.X -= num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += num189; + else + npc.velocity.Y -= num189; + } + } + else + { + if (npc.velocity.Y < num192) + npc.velocity.Y += num189 * 1.1f; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.X > 0f) + npc.velocity.X += num189; + else + npc.velocity.X -= num189; + } + } + } + + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + + if (calamityGlobalNPC.newAI[2] > phaseLimit) + { + npc.ai[3] = 1f; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Ground + else + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); + } + + // Charge in a direction for a second until the timer is back at 0 + if (postTeleportTimer > 0) + { + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + return; + } + + calamityGlobalNPC.newAI[2] += 1f; + + // Enrage + if (increaseSpeedMore) + { + if (laserWallPhase == (int)LaserWallPhase.SetUp && calamityGlobalNPC.newAI[3] <= alphaGateValue) + { + SpawnTeleportLocation(player); + } + else + groundPhaseTurnSpeed *= 4f; + } + else if (increaseSpeed) + groundPhaseTurnSpeed *= 2f; + + if (!flies) + { + for (int num952 = num180; num952 < num181; num952++) + { + for (int num953 = num182; num953 < num183; num953++) + { + 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 = 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; + } + } + } + } + } + + if (!flies) + { + npc.localAI[1] = 1f; + + Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + + int num954 = death ? 1125 : 1200; + + if (expertMode) + num954 -= (int)(150f * (1f - lifeRatio)); + + if (num954 < 1050) + num954 = 1050; + + bool flag95 = true; + if (npc.position.Y > player.position.Y) + { + for (int num955 = 0; num955 < Main.maxPlayers; num955++) + { + if (Main.player[num955].active) + { + Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - 1000, (int)Main.player[num955].position.Y - 1000, 2000, num954); + if (rectangle12.Intersects(rectangle13)) + { + flag95 = false; + break; + } + } + } + if (flag95) + flies = true; + } + } + else + npc.localAI[1] = 0f; + + float num189 = groundPhaseTurnSpeed; + Vector2 vector18 = npc.Center; + float num191 = player.Center.X; + float num192 = player.Center.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; + + if (!flies) + { + npc.velocity.Y += groundPhaseTurnSpeed; + if (npc.velocity.Y > fallSpeed) + npc.velocity.Y = fallSpeed; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 2.2) + { + if (npc.velocity.X < 0f) + npc.velocity.X -= num189 * 1.1f; + else + npc.velocity.X += num189 * 1.1f; + } + else if (npc.velocity.Y == fallSpeed) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189; + else if (npc.velocity.X > num191) + npc.velocity.X -= num189; + } + else if (npc.velocity.Y > 4f) + { + if (npc.velocity.X < 0f) + npc.velocity.X += num189 * 0.9f; + else + npc.velocity.X -= num189 * 0.9f; + } + } + else + { + double maximumSpeed1 = malice ? 0.52 : death ? 0.46 : 0.4; + double maximumSpeed2 = malice ? 1.25 : death ? 1.125 : 1D; + + if (expertMode) + { + maximumSpeed1 += 0.1f * (1f - lifeRatio); + maximumSpeed2 += 0.2f * (1f - lifeRatio); + } + + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + float num25 = Math.Abs(num191); + float num26 = Math.Abs(num192); + float num27 = fallSpeed / num193; + num191 *= num27; + num192 *= num27; + + if (((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f)) && ((npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f))) + { + if (npc.velocity.X < num191) + npc.velocity.X += groundPhaseTurnSpeed * 1.5f; + else if (npc.velocity.X > num191) + npc.velocity.X -= groundPhaseTurnSpeed * 1.5f; + + if (npc.velocity.Y < num192) + npc.velocity.Y += groundPhaseTurnSpeed * 1.5f; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= groundPhaseTurnSpeed * 1.5f; + } + + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + npc.velocity.X += groundPhaseTurnSpeed; + else if (npc.velocity.X > num191) + npc.velocity.X -= groundPhaseTurnSpeed; + + if (npc.velocity.Y < num192) + npc.velocity.Y += groundPhaseTurnSpeed; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= groundPhaseTurnSpeed; + + if (Math.Abs(num192) < fallSpeed * maximumSpeed1 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += groundPhaseTurnSpeed * 2f; + else + npc.velocity.Y -= groundPhaseTurnSpeed * 2f; + } + + if (Math.Abs(num191) < fallSpeed * maximumSpeed1 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + { + if (npc.velocity.X > 0f) + npc.velocity.X += groundPhaseTurnSpeed * 2f; + else + npc.velocity.X -= groundPhaseTurnSpeed * 2f; + } + } + else if (num25 > num26) + { + if (npc.velocity.X < num191) + npc.velocity.X += groundPhaseTurnSpeed * 1.1f; + else if (npc.velocity.X > num191) + npc.velocity.X -= groundPhaseTurnSpeed * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += groundPhaseTurnSpeed; + else + npc.velocity.Y -= groundPhaseTurnSpeed; + } + } + else + { + if (npc.velocity.Y < num192) + npc.velocity.Y += groundPhaseTurnSpeed * 1.1f; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= groundPhaseTurnSpeed * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) + { + if (npc.velocity.X > 0f) + npc.velocity.X += groundPhaseTurnSpeed; + else + npc.velocity.X -= groundPhaseTurnSpeed; + } + } + } + + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + + if (flies) + { + if (npc.localAI[0] != 1f) + npc.netUpdate = true; + + npc.localAI[0] = 1f; + } + else + { + if (npc.localAI[0] != 0f) + npc.netUpdate = true; + + npc.localAI[0] = 0f; + } + + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + npc.netUpdate = true; + + if (calamityGlobalNPC.newAI[2] > phaseLimit) + { + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + } + } + else + { + // Spawn Guardians + if (phase3) + { + if (!spawnedGuardians) + { + if (revenge) + spawnDoGCountdown = 10; + + string key = "Mods.CalamityMod.EdgyBossText"; + Color messageColor = Color.Cyan; + CalamityUtils.DisplayLocalizedText(key, messageColor); + + npc.TargetClosest(); + spawnedGuardians = true; + } + + if (spawnDoGCountdown > 0) + { + spawnDoGCountdown--; + if (spawnDoGCountdown == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); + + for (int i = 0; i < 2; i++) + NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); + } + } + } + else if (phase2) + { + if (!spawnedGuardians2) + { + if (revenge) + spawnDoGCountdown = 10; + + spawnedGuardians2 = true; + } + + if (spawnDoGCountdown > 0) + { + spawnDoGCountdown--; + if (spawnDoGCountdown == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), (int)player.position.X, (int)player.position.Y); + + NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); + } + } + } + + // Alpha + npc.Opacity += 0.047f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + + // Spawn segments + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (!tail && npc.ai[0] == 0f) + { + int Previous = npc.whoAmI; + for (int segmentSpawn = 0; segmentSpawn < maxLength; segmentSpawn++) + { + int segment; + if (segmentSpawn >= 0 && segmentSpawn < minLength) + { + segment = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + Main.npc[segment].ModNPC().SegmentIndex = maxLength - segmentSpawn; + } + else + segment = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + + Main.npc[segment].realLife = npc.whoAmI; + Main.npc[segment].ai[2] = npc.whoAmI; + Main.npc[segment].ai[1] = Previous; + Main.npc[Previous].ai[0] = segment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment, 0f, 0f, 0f, 0); + Previous = segment; + } + tail = true; + } + + if (phase2) + { + float spawnOffset = 1500f; + float divisor = malice ? 240f : death ? 360f : 480f; + + if (calamityGlobalNPC.newAI[1] % divisor == 0f) + { + Main.PlaySound(SoundID.Item12, player.position); + + // Side walls + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Vector2 start = default; + Vector2 velocity = default; + Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; + Vector2 aimClone = aim; + + switch (laserWallType) + { + case (int)LaserWallType.DiagonalRight: + + for (int x = 0; x < totalShots + 1; x++) + { + start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); + aim.Y += laserWallSpacingOffset * (x - 3); + velocity = Vector2.Normalize(aim - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + shotSpacing -= spacingVar; + } + + if (expertMode) + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + + break; + + case (int)LaserWallType.DiagonalLeft: + + for (int x = 0; x < totalShots + 1; x++) + { + start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); + aim.Y += laserWallSpacingOffset * (x - 3); + velocity = Vector2.Normalize(aim - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + shotSpacing -= spacingVar; + } + + if (expertMode) + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + + break; + + case (int)LaserWallType.DiagonalHorizontal: + + for (int x = 0; x < totalShots + 1; x++) + { + start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); + aim.Y += laserWallSpacingOffset * (x - 3); + velocity = Vector2.Normalize(aim - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); + velocity = Vector2.Normalize(aim - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + shotSpacing -= spacingVar; + } + + if (expertMode) + { + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + } + + break; + + case (int)LaserWallType.DiagonalCross: + + int randomLaserGap = Main.rand.Next(3) + 3; // 3, 4, 5, 6 + for (int x = 0; x < totalShots + 1; x++) + { + if (x != randomLaserGap && x != randomLaserGap + 1) + { + start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); + aim.Y += laserWallSpacingOffset * (x - 3); + velocity = Vector2.Normalize(aim - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); + velocity = Vector2.Normalize(aim - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X + shotSpacing, player.position.Y + spawnOffset); + aimClone.X += laserWallSpacingOffset * (x - 3); + velocity = Vector2.Normalize(aimClone - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + + start = new Vector2(player.position.X + shotSpacing, player.position.Y - spawnOffset); + velocity = Vector2.Normalize(aimClone - start) * laserVelocity; + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer); + } + + shotSpacing -= spacingVar; + } + + if (expertMode) + { + Projectile.NewProjectile(player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + } + + break; + } + + // Pick a random laser wall phase in expert+ + if (expertMode) + { + int laserWallPhase; + int choices = revenge ? 4 : 3; + do laserWallPhase = Main.rand.Next(choices); + while (laserWallPhase == laserWallType); + laserWallType = laserWallPhase; + } + else + laserWallType = laserWallType == (int)LaserWallType.DiagonalRight ? (int)LaserWallType.DiagonalLeft : (int)LaserWallType.DiagonalRight; + + shotSpacing = shotSpacingMax; + } + + calamityGlobalNPC.newAI[1] += 1f; + } + else + calamityGlobalNPC.newAI[1] = 0f; + } + + // Movement + int num180 = (int)(npc.position.X / 16f) - 1; + int num181 = (int)((npc.position.X + npc.width) / 16f) + 2; + int num182 = (int)(npc.position.Y / 16f) - 1; + int num183 = (int)((npc.position.Y + npc.height) / 16f) + 2; + + if (num180 < 0) + num180 = 0; + if (num181 > Main.maxTilesX) + num181 = Main.maxTilesX; + if (num182 < 0) + num182 = 0; + if (num183 > Main.maxTilesY) + num183 = Main.maxTilesY; + + if (npc.velocity.X < 0f) + npc.spriteDirection = -1; + else if (npc.velocity.X > 0f) + npc.spriteDirection = 1; + + // Flight + if (npc.ai[3] == 0f) + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); + } + + // Flying movement + npc.localAI[1] = 0f; + + calamityGlobalNPC.newAI[2] += 1f; + + // Go to ground phase sooner + if (increaseSpeedMore) + calamityGlobalNPC.newAI[2] += 10f; + else if (increaseSpeed) + calamityGlobalNPC.newAI[2] += 2f; + + float num188 = speed; + float num189 = turnSpeed; + 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); + + for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) + { + for (int num46 = num44; num46 <= num44 + 15; num46++) + { + if (WorldGen.SolidTile2(num45, num46)) + { + num42 = num46; + break; + } + } + if (num42 > 0) + break; + } + + if (num42 > 0) + { + num42 *= 16; + float num47 = num42 - 800; + if (player.position.Y > num47) + { + num192 = num47; + if (Math.Abs(npc.Center.X - player.Center.X) < 500f) + { + if (npc.velocity.X > 0f) + num191 = player.Center.X + 600f; + else + num191 = player.Center.X - 600f; + } + } + } + else + { + num188 = homingSpeed; + num189 = homingTurnSpeed; + } + + if (expertMode) + { + num188 += distanceFromTarget * 0.005f * (1f - lifeRatio); + num189 += distanceFromTarget * 0.0001f * (1f - lifeRatio); + } + + float num48 = num188 * 1.3f; + float num49 = num188 * 0.7f; + float num50 = npc.velocity.Length(); + if (num50 > 0f) + { + if (num50 > num48) + { + npc.velocity.Normalize(); + npc.velocity *= num48; + } + else if (num50 < num49) + { + npc.velocity.Normalize(); + npc.velocity *= num49; + } + } + + 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)Math.Sqrt(num191 * num191 + num192 * num192); + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); + float num198 = num188 / num193; + num191 *= num198; + num192 *= num198; + + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189; + else + { + if (npc.velocity.X > num191) + npc.velocity.X -= num189; + } + + if (npc.velocity.Y < num192) + npc.velocity.Y += num189; + else + { + if (npc.velocity.Y > num192) + npc.velocity.Y -= num189; + } + + 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 (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; + else + npc.velocity.X -= num189 * 2f; + } + } + else + { + if (num196 > num197) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189 * 1.1f; + else if (npc.velocity.X > num191) + npc.velocity.X -= num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += num189; + else + npc.velocity.Y -= num189; + } + } + else + { + if (npc.velocity.Y < num192) + npc.velocity.Y += num189 * 1.1f; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.X > 0f) + npc.velocity.X += num189; + else + npc.velocity.X -= num189; + } + } + } + + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + + if (calamityGlobalNPC.newAI[2] > phaseLimit) + { + npc.ai[3] = 1f; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + // Ground + else + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); + } + + calamityGlobalNPC.newAI[2] += 1f; + + // Enrage + if (increaseSpeedMore) + groundPhaseTurnSpeed *= 4f; + else if (increaseSpeed) + groundPhaseTurnSpeed *= 2f; + + if (!flies) + { + for (int num952 = num180; num952 < num181; num952++) + { + for (int num953 = num182; num953 < num183; num953++) + { + 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 = 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; + } + } + } + } + } + + if (!flies) + { + npc.localAI[1] = 1f; + + Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + + int num954 = death ? 1125 : 1200; + + if (expertMode) + num954 -= (int)(150f * (1f - lifeRatio)); + + if (num954 < 1050) + num954 = 1050; + + bool flag95 = true; + if (npc.position.Y > player.position.Y) + { + for (int num955 = 0; num955 < 255; num955++) + { + if (Main.player[num955].active) + { + Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - 1000, (int)Main.player[num955].position.Y - 1000, 2000, num954); + if (rectangle12.Intersects(rectangle13)) + { + flag95 = false; + break; + } + } + } + if (flag95) + flies = true; + } + } + else + npc.localAI[1] = 0f; + + float num189 = groundPhaseTurnSpeed; + Vector2 vector18 = npc.Center; + float num191 = player.Center.X; + float num192 = player.Center.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; + + if (!flies) + { + npc.velocity.Y += groundPhaseTurnSpeed; + if (npc.velocity.Y > fallSpeed) + npc.velocity.Y = fallSpeed; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 2.2) + { + if (npc.velocity.X < 0f) + npc.velocity.X -= num189 * 1.1f; + else + npc.velocity.X += num189 * 1.1f; + } + else if (npc.velocity.Y == fallSpeed) + { + if (npc.velocity.X < num191) + npc.velocity.X += num189; + else if (npc.velocity.X > num191) + npc.velocity.X -= num189; + } + else if (npc.velocity.Y > 4f) + { + if (npc.velocity.X < 0f) + npc.velocity.X += num189 * 0.9f; + else + npc.velocity.X -= num189 * 0.9f; + } + } + else + { + double maximumSpeed1 = malice ? 0.52 : death ? 0.46 : 0.4; + double maximumSpeed2 = malice ? 1.25 : death ? 1.125 : 1D; + + if (expertMode) + { + maximumSpeed1 += 0.1f * (1f - lifeRatio); + maximumSpeed2 += 0.2f * (1f - lifeRatio); + } + + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + float num25 = Math.Abs(num191); + float num26 = Math.Abs(num192); + float num27 = fallSpeed / num193; + num191 *= num27; + num192 *= num27; + + if (((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f)) && ((npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f))) + { + if (npc.velocity.X < num191) + npc.velocity.X += groundPhaseTurnSpeed * 1.5f; + else if (npc.velocity.X > num191) + npc.velocity.X -= groundPhaseTurnSpeed * 1.5f; + + if (npc.velocity.Y < num192) + npc.velocity.Y += groundPhaseTurnSpeed * 1.5f; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= groundPhaseTurnSpeed * 1.5f; + } + + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + npc.velocity.X += groundPhaseTurnSpeed; + else if (npc.velocity.X > num191) + npc.velocity.X -= groundPhaseTurnSpeed; + + if (npc.velocity.Y < num192) + npc.velocity.Y += groundPhaseTurnSpeed; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= groundPhaseTurnSpeed; + + if (Math.Abs(num192) < fallSpeed * maximumSpeed1 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += groundPhaseTurnSpeed * 2f; + else + npc.velocity.Y -= groundPhaseTurnSpeed * 2f; + } + + if (Math.Abs(num191) < fallSpeed * maximumSpeed1 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + { + if (npc.velocity.X > 0f) + npc.velocity.X += groundPhaseTurnSpeed * 2f; + else + npc.velocity.X -= groundPhaseTurnSpeed * 2f; + } + } + else if (num25 > num26) + { + if (npc.velocity.X < num191) + npc.velocity.X += groundPhaseTurnSpeed * 1.1f; + else if (npc.velocity.X > num191) + npc.velocity.X -= groundPhaseTurnSpeed * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += groundPhaseTurnSpeed; + else + npc.velocity.Y -= groundPhaseTurnSpeed; + } + } + else + { + if (npc.velocity.Y < num192) + npc.velocity.Y += groundPhaseTurnSpeed * 1.1f; + else if (npc.velocity.Y > num192) + npc.velocity.Y -= groundPhaseTurnSpeed * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * maximumSpeed2) + { + if (npc.velocity.X > 0f) + npc.velocity.X += groundPhaseTurnSpeed; + else + npc.velocity.X -= groundPhaseTurnSpeed; + } + } + } + + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + + if (flies) + { + if (npc.localAI[0] != 1f) + npc.netUpdate = true; + + npc.localAI[0] = 1f; + } + else + { + if (npc.localAI[0] != 0f) + npc.netUpdate = true; + + npc.localAI[0] = 0f; + } + + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + npc.netUpdate = true; + + if (calamityGlobalNPC.newAI[2] > phaseLimit) + { + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + } + + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; + } + + private void SpawnTeleportLocation(Player player) + { + if (teleportTimer > -1 || player.dead || !player.active) + return; + + teleportTimer = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 120 : CalamityWorld.revenge ? 140 : Main.expertMode ? 160 : 180; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int randomRange = 48; + float distance = 640f; + Vector2 targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1)); + Main.PlaySound(SoundID.Item109, player.Center); + Projectile.NewProjectile(targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, npc.whoAmI); + } + } + + private void Teleport(Player player, bool malice, bool death, bool revenge, bool expertMode, bool phase5, bool phase2Transition = false) + { + if (Main.netMode != NetmodeID.MultiplayerClient && phase2Transition) + { + int randomRange = 48; + float distance = 1080f; + Vector2 targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1)); + Projectile.NewProjectile(targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, npc.whoAmI); + } + + Vector2 newPosition = GetRiftLocation(true); + + if ((!AwaitingPhase2Teleport && (player.dead || !player.active)) || newPosition == default) + return; + + if (phase5) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float finalVelocity = 10f; + int totalSpreads = revenge ? 6 : 3; + float mult = revenge ? 1.5f : 3f; + for (int i = 0; i < totalSpreads; i++) + { + int totalProjectiles = malice ? 18 : 12; + float radians = MathHelper.TwoPi / totalProjectiles; + float newVelocity = finalVelocity - i * mult; + float velocityMult = 1f + ((finalVelocity - newVelocity) / (newVelocity * 2f) / 100f); + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = i < 3 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); + float finalVelocityReduction = (float)Math.Pow(1.25, i) - 1f; + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(newPosition, vector255, type, damage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); + } + } + } + } + + npc.TargetClosest(); + npc.position = newPosition; + float chargeVelocity = malice ? 30f : death ? 26f : revenge ? 24f : expertMode ? 22f : 20f; + float maxChargeDistance = 1600f; + postTeleportTimer = (int)Math.Round(maxChargeDistance / chargeVelocity); + AwaitingPhase2Teleport = false; + npc.Opacity = 1f - (postTeleportTimer / 255f); + npc.velocity = Vector2.Normalize(player.Center + player.velocity * 40f - npc.Center) * chargeVelocity; + npc.netUpdate = true; + + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && (Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType())) + { + Main.npc[i].position = newPosition; + + if (Main.npc[i].type == ModContent.NPCType()) + ((DevourerofGodsTail)Main.npc[i].modNPC).setInvulTime(720); + + Main.npc[i].netUpdate = true; + } + } + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), player.Center); + } + + public void DoDeathAnimation() + { + // Play a sound at the start. + if (DeathAnimationTimer == 1f) + { + var soundInstance = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), npc.Center); + CalamityUtils.SafeVolumeChange(ref soundInstance, 1.6f); + } + + // Close the health bar, fade in, and stop doing contact damage. + npc.Calamity().CanHaveBossHealthBar = false; + npc.Opacity = MathHelper.Clamp(npc.Opacity + 0.1f, 0f, 1f); + npc.dontTakeDamage = true; + npc.damage = 0; + + void destroySegment(int index, ref int destroyedSegments) + { + if (Main.rand.NextBool(5)) + Main.PlaySound(SoundID.Item94, npc.Center); + + List segments = new List() + { + ModContent.NPCType(), + ModContent.NPCType() + }; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (segments.Contains(Main.npc[i].type) && Main.npc[i].active && + (Main.npc[i].type == segments[1] || Main.npc[i].ModNPC().SegmentIndex == index)) + { + for (int j = 0; j < 20; j++) + { + Dust cosmicBurst = Dust.NewDustPerfect(Main.npc[i].Center + Main.rand.NextVector2Circular(25f, 25f), 234); + cosmicBurst.scale = 1.7f; + cosmicBurst.velocity = Main.rand.NextVector2Circular(9f, 9f); + cosmicBurst.noGravity = true; + } + + Main.npc[i].life = 0; + Main.npc[i].HitEffect(); + Main.npc[i].active = false; + Main.npc[i].netUpdate = true; + destroyedSegments++; + break; + } + } + } + + // Slow down but maintain a specific direction. + float idealSpeed = MathHelper.Lerp(8.4f, 4f, Utils.InverseLerp(15f, 210f, DeathAnimationTimer, true)); + if (npc.velocity.Length() != idealSpeed) + npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY) * MathHelper.Lerp(npc.velocity.Length(), idealSpeed, 0.08f); + + // Stay within the world. + if (npc.Center.X < 300f || npc.Center.X > Main.maxTilesX * 16f - 300f) + npc.velocity.X *= -1f; + if (npc.Center.Y < 300f || npc.Center.Y > Main.maxTilesY * 16f - 300f) + npc.velocity.Y *= -1f; + + if (DeathAnimationTimer >= 120f && DeathAnimationTimer < 370f && DeathAnimationTimer % 3f == 0f) + { + int segmentToDestroy = (int)(Utils.InverseLerp(120f, 370f, DeathAnimationTimer, true) * 60f); + destroySegment(segmentToDestroy, ref DestroyedSegmentCount); + } + + if (DeathAnimationTimer == 452f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); + + if (Main.netMode != NetmodeID.Server) + { + var soundInstance = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/DevourerAttack"), npc.Center); + CalamityUtils.SafeVolumeChange(ref soundInstance, 1.6f); + + for (int i = 0; i < 3; i++) + { + soundInstance = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"), npc.Center); + if (soundInstance != null) + { + soundInstance.Pitch = -MathHelper.Lerp(0.1f, 0.4f, i / 3f); + CalamityUtils.SafeVolumeChange(ref soundInstance, 1.4f); + } + } + } + } + + if (DeathAnimationTimer >= 410f && DeathAnimationTimer < 470f && DeathAnimationTimer % 2f == 0f) + { + int segmentToDestroy = (int)(Utils.InverseLerp(410f, 470f, DeathAnimationTimer, true) * 10f) + 60; + destroySegment(segmentToDestroy, ref DeathAnimationTimer); + } + + float light = Utils.InverseLerp(430f, 465f, DeathAnimationTimer, true); + MoonlordDeathDrama.RequestLight(light, Main.LocalPlayer.Center); + + if (DeathAnimationTimer >= 485f) + { + npc.life = 0; + npc.HitEffect(); + npc.NPCLoot(); + npc.active = false; + npc.netUpdate = true; + } + DeathAnimationTimer++; + } + + private Vector2 GetRiftLocation(bool spawnDust) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type == ModContent.ProjectileType()) + { + if (!spawnDust) + Main.projectile[i].ai[0] = -1f; + + Main.projectile[i].Kill(); + return Main.projectile[i].Center; + } + } + return default; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + float disintegrationFactor = DeathAnimationTimer / 800f; + if (disintegrationFactor > 0f) + { + spriteBatch.EnterShaderRegion(); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(npc.whoAmI); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage("Images/Misc/Perlin"); + GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); + } + + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + bool useOtherTextures = Phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60; + Texture2D texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadS") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (!npc.dontTakeDamage) + { + texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadSGlow") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadGlow"); + Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadSGlow2") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadGlow2"); + color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + + if (disintegrationFactor > 0f) + spriteBatch.ExitShaderRegion(); + + return false; + } + + public override void BossLoot(ref string name, ref int potionType) + { + potionType = ModContent.ItemType(); + } + + public override bool SpecialNPCLoot() + { + int closestSegmentID = DropHelper.FindClosestWormSegment(npc, + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType()); + npc.position = Main.npc[closestSegmentID].position; + return false; + } + + 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; + + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); + + DropHelper.DropItem(npc, ModContent.ItemType(), 5, 15); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedDoG); + + CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedDoG); + + // Mount + CalamityPlayer mp = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Calamity(); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, mp.fabsolVodka); + + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) + { + // Materials + DropHelper.DropItem(npc, ModContent.ItemType(), 25, 35); + DropHelper.DropItem(npc, ModContent.ItemType(), 150, 250); + + // Weapons + float w = DropHelper.NormalWeaponDropRateFloat; + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); + + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); + + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + } + + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); + + // If DoG has not been killed yet, notify players that the holiday moons are buffed + if (!CalamityWorld.downedDoG) + { + string key = "Mods.CalamityMod.DoGBossText"; + Color messageColor = Color.Cyan; + string key2 = "Mods.CalamityMod.DoGBossText2"; + Color messageColor2 = Color.Orange; + string key3 = "Mods.CalamityMod.DargonBossText"; + + CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.DisplayLocalizedText(key2, messageColor2); + CalamityUtils.DisplayLocalizedText(key3, messageColor2); + } + + // Mark DoG as dead + CalamityWorld.downedDoG = true; + CalamityNetcode.SyncWorld(); + } + + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= (Phase2Started ? 80f : 55f) && (npc.Opacity >= 1f || postTeleportTimer > 0) && preventBullshitHitsAtStartofFinalPhaseTimer <= 0; + } public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { - if (!Dying && (damage * (crit ? 2D : 1D)) >= npc.life) - { - damage = 0D; - CheckDead(); - return false; - } + if (!Dying && (damage * (crit ? 2D : 1D)) >= npc.life) + { + damage = 0D; + CheckDead(); + return false; + } - return true; + return true; } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) @@ -2348,82 +2348,82 @@ namespace CalamityMod.NPCs.DevourerofGods } public override bool CheckDead() - { - if (!Dying) - { - Dying = true; - npc.life = 1; - npc.dontTakeDamage = true; - npc.active = true; - npc.netUpdate = true; - } - return false; - } + { + if (!Dying) + { + Dying = true; + npc.life = 1; + npc.dontTakeDamage = true; + npc.active = true; + npc.netUpdate = true; + } + return false; + } public override void HitEffect(int hitDirection, double damage) - { - if (npc.soundDelay == 0) - { - npc.soundDelay = 8; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); - } - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS5"), 1f); - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - for (int num621 = 0; num621 < 15; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 30; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } + { + if (npc.soundDelay == 0) + { + npc.soundDelay = 8; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); + } + if (npc.life <= 0) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS5"), 1f); + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); + npc.width = 50; + npc.height = 50; + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 15; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 30; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 300, true); - player.AddBuff(ModContent.BuffType(), 420, true); + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 300, true); + player.AddBuff(ModContent.BuffType(), 420, true); - if (player.Calamity().dogTextCooldown <= 0) - { - string text = Utils.SelectRandom(Main.rand, new string[] - { - "Mods.CalamityMod.EdgyBossText3", - "Mods.CalamityMod.EdgyBossText4", - "Mods.CalamityMod.EdgyBossText5", - "Mods.CalamityMod.EdgyBossText6", - "Mods.CalamityMod.EdgyBossText7" - }); - Color messageColor = Color.Cyan; - Rectangle location = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); - player.Calamity().dogTextCooldown = 60; - } - } - } + if (player.Calamity().dogTextCooldown <= 0) + { + string text = Utils.SelectRandom(Main.rand, new string[] + { + "Mods.CalamityMod.EdgyBossText3", + "Mods.CalamityMod.EdgyBossText4", + "Mods.CalamityMod.EdgyBossText5", + "Mods.CalamityMod.EdgyBossText6", + "Mods.CalamityMod.EdgyBossText7" + }); + Color messageColor = Color.Cyan; + Rectangle location = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); + player.Calamity().dogTextCooldown = 60; + } + } + } } diff --git a/NPCs/DevourerofGods/DevourerofGodsHead2.cs b/NPCs/DevourerofGods/DevourerofGodsHead2.cs index 54edb76aba..cadac6cd29 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead2.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead2.cs @@ -25,8 +25,8 @@ namespace CalamityMod.NPCs.DevourerofGods public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); npc.width = 64; npc.height = 76; npc.defense = 40; @@ -58,11 +58,11 @@ namespace CalamityMod.NPCs.DevourerofGods public override void AI() { - // Target - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + // Target + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; if (invinceTime > 0) { @@ -78,10 +78,10 @@ namespace CalamityMod.NPCs.DevourerofGods Vector2 vector = npc.Center; - bool increaseSpeed = Vector2.Distance(player.Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles; - bool increaseSpeedMore = Vector2.Distance(player.Center, vector) > CalamityGlobalNPC.CatchUpDistance350Tiles; + bool increaseSpeed = Vector2.Distance(player.Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles; + bool increaseSpeedMore = Vector2.Distance(player.Center, vector) > CalamityGlobalNPC.CatchUpDistance350Tiles; - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (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); if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; @@ -148,196 +148,196 @@ namespace CalamityMod.NPCs.DevourerofGods } } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - float num188 = CalamityWorld.malice ? 18f : CalamityWorld.revenge ? 16f : 14f; - float num189 = CalamityWorld.malice ? 0.17f : CalamityWorld.revenge ? 0.15f : 0.13f; + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + float num188 = CalamityWorld.malice ? 18f : CalamityWorld.revenge ? 16f : 14f; + float num189 = CalamityWorld.malice ? 0.17f : CalamityWorld.revenge ? 0.15f : 0.13f; - if (increaseSpeedMore) - num189 *= 6f; - else if (increaseSpeed) - num189 *= 3f; + if (increaseSpeedMore) + num189 *= 6f; + else if (increaseSpeed) + num189 *= 3f; - 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; - } - } - } + 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; + } + } + } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = npc.velocity.Length(); - if (num50 > 0f) - { - if (num50 > num48) - { - npc.velocity.Normalize(); - npc.velocity *= num48; - } - else if (num50 < num49) - { - npc.velocity.Normalize(); - npc.velocity *= num49; - } - } + float num48 = num188 * 1.3f; + float num49 = num188 * 0.7f; + float num50 = npc.velocity.Length(); + if (num50 > 0f) + { + if (num50 > num48) + { + npc.velocity.Normalize(); + npc.velocity *= num48; + } + else if (num50 < num49) + { + npc.velocity.Normalize(); + npc.velocity *= num49; + } + } - 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)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189; - } - else - { - if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num189; - } - } - if (npc.velocity.Y < num192) - { - npc.velocity.Y = npc.velocity.Y + num189; - } - else - { - if (npc.velocity.Y > num192) - { - npc.velocity.Y = npc.velocity.Y - num189; - } - } - 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 = npc.velocity.Y + num189 * 2f; - } - else - { - npc.velocity.Y = npc.velocity.Y - num189 * 2f; - } - } - 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 = npc.velocity.X + num189 * 2f; //changed from 2 - } - else - { - npc.velocity.X = npc.velocity.X - num189 * 2f; //changed from 2 - } - } - } - else - { - if (num196 > num197) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189 * 1.1f; //changed from 1.1 - } - else if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num189 * 1.1f; //changed from 1.1 - } - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num189; - } - else - { - npc.velocity.Y = npc.velocity.Y - num189; - } - } - } - else - { - if (npc.velocity.Y < num192) - { - npc.velocity.Y = npc.velocity.Y + num189 * 1.1f; - } - else if (npc.velocity.Y > num192) - { - npc.velocity.Y = npc.velocity.Y - num189 * 1.1f; - } - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num189; - } - else - { - npc.velocity.X = npc.velocity.X - num189; - } - } - } - } - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + 1.57f; - } + 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)Math.Sqrt(num191 * num191 + num192 * num192); + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); + float num198 = num188 / num193; + num191 *= num198; + num192 *= num198; + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + { + npc.velocity.X = npc.velocity.X + num189; + } + else + { + if (npc.velocity.X > num191) + { + npc.velocity.X = npc.velocity.X - num189; + } + } + if (npc.velocity.Y < num192) + { + npc.velocity.Y = npc.velocity.Y + num189; + } + else + { + if (npc.velocity.Y > num192) + { + npc.velocity.Y = npc.velocity.Y - num189; + } + } + 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 = npc.velocity.Y + num189 * 2f; + } + else + { + npc.velocity.Y = npc.velocity.Y - num189 * 2f; + } + } + 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 = npc.velocity.X + num189 * 2f; //changed from 2 + } + else + { + npc.velocity.X = npc.velocity.X - num189 * 2f; //changed from 2 + } + } + } + else + { + if (num196 > num197) + { + if (npc.velocity.X < num191) + { + npc.velocity.X = npc.velocity.X + num189 * 1.1f; //changed from 1.1 + } + else if (npc.velocity.X > num191) + { + npc.velocity.X = npc.velocity.X - num189 * 1.1f; //changed from 1.1 + } + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y + num189; + } + else + { + npc.velocity.Y = npc.velocity.Y - num189; + } + } + } + else + { + if (npc.velocity.Y < num192) + { + npc.velocity.Y = npc.velocity.Y + num189 * 1.1f; + } + else if (npc.velocity.Y > num192) + { + npc.velocity.Y = npc.velocity.Y - num189 * 1.1f; + } + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X + num189; + } + else + { + npc.velocity.X = npc.velocity.X - num189; + } + } + } + } + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + 1.57f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + 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 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead2Glow"); - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead2Glow"); + Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead2Glow2"); - color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead2Glow2"); + color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int heartAmt = Main.rand.Next(3) + 3; + for (int i = 0; i < heartAmt; i++) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index 70c052c3b5..dac9fceedb 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -15,45 +15,45 @@ namespace CalamityMod.NPCs.DevourerofGods { public class DevourerofGodsTail : ModNPC { - public static int phase1IconIndex; - public static int phase2IconIndex; + public static int phase1IconIndex; + public static int phase2IconIndex; - internal static void LoadHeadIcons() - { - string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTail_Head_Boss"; - string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS_Head_Boss"; + internal static void LoadHeadIcons() + { + string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTail_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS_Head_Boss"; - CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); - phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); + CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); + phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); - CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); - phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); - } + CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); + phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); + } - private int invinceTime = 720; - private bool setOpacity = false; - private bool phase2Started = false; + private int invinceTime = 720; + private bool setOpacity = false; + private bool phase2Started = false; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("The Devourer of Gods"); } - internal void setInvulTime(int time) - { - invinceTime = time; - } - - public override void SetDefaults() + internal void setInvulTime(int time) { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; + invinceTime = time; + } + + public override void SetDefaults() + { + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 66; npc.height = 66; npc.defense = 50; - npc.LifeMaxNERB(888750, 1066500, 1500000); // Phase 1 is 371250, Phase 2 is 517500 - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.LifeMaxNERB(888750, 1066500, 1500000); // Phase 1 is 371250, Phase 2 is 517500 + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -63,7 +63,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.DeathSound = SoundID.NPCDeath14; + npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.boss = true; npc.takenDamageMultiplier = 1.25f; @@ -71,192 +71,192 @@ namespace CalamityMod.NPCs.DevourerofGods npc.dontCountMe = true; } - public override void BossHeadSlot(ref int index) - { - NPC head = CalamityGlobalNPC.DoGHead >= 0 ? Main.npc[CalamityGlobalNPC.DoGHead] : null; - DevourerofGodsHead modNPC = head?.ModNPC() ?? null; + public override void BossHeadSlot(ref int index) + { + NPC head = CalamityGlobalNPC.DoGHead >= 0 ? Main.npc[CalamityGlobalNPC.DoGHead] : null; + DevourerofGodsHead modNPC = head?.ModNPC() ?? null; - index = -1; - if (head is null) - return; + index = -1; + if (head is null) + return; - if (!modNPC.Phase2Started) - { - index = phase1IconIndex; - return; - } + if (!modNPC.Phase2Started) + { + index = phase1IconIndex; + return; + } - if (!modNPC.AwaitingPhase2Teleport) - index = phase2IconIndex; - } + if (!modNPC.AwaitingPhase2Teleport) + index = phase2IconIndex; + } - public override void BossHeadRotation(ref float rotation) - { - NPC head = CalamityGlobalNPC.DoGHead >= 0 ? Main.npc[CalamityGlobalNPC.DoGHead] : null; - DevourerofGodsHead modNPC = head?.ModNPC() ?? null; - if (head != null || modNPC.AwaitingPhase2Teleport || !modNPC.Phase2Started) - return; + public override void BossHeadRotation(ref float rotation) + { + NPC head = CalamityGlobalNPC.DoGHead >= 0 ? Main.npc[CalamityGlobalNPC.DoGHead] : null; + DevourerofGodsHead modNPC = head?.ModNPC() ?? null; + if (head != null || modNPC.AwaitingPhase2Teleport || !modNPC.Phase2Started) + return; - rotation = npc.rotation; - } + rotation = npc.rotation; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(phase2Started); - writer.Write(invinceTime); - writer.Write(setOpacity); - writer.Write(npc.dontTakeDamage); - writer.Write(npc.Opacity); - writer.Write(npc.frame.X); - writer.Write(npc.frame.Y); - writer.Write(npc.frame.Width); - writer.Write(npc.frame.Height); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(phase2Started); + writer.Write(invinceTime); + writer.Write(setOpacity); + writer.Write(npc.dontTakeDamage); + writer.Write(npc.Opacity); + writer.Write(npc.frame.X); + writer.Write(npc.frame.Y); + writer.Write(npc.frame.Width); + writer.Write(npc.frame.Height); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - phase2Started = reader.ReadBoolean(); - invinceTime = reader.ReadInt32(); - setOpacity = reader.ReadBoolean(); - npc.dontTakeDamage = reader.ReadBoolean(); - npc.Opacity = reader.ReadSingle(); - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - npc.frame = frame; - } + public override void ReceiveExtraAI(BinaryReader reader) + { + phase2Started = reader.ReadBoolean(); + invinceTime = reader.ReadInt32(); + setOpacity = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + npc.Opacity = reader.ReadSingle(); + Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); + if (frame.Width > 0 && frame.Height > 0) + npc.frame = frame; + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; } public override void AI() { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; - if (npc.life / (float)npc.lifeMax < 0.6f) - { - phase2Started = true; + if (npc.life / (float)npc.lifeMax < 0.6f) + { + phase2Started = true; - // Play music after the transiton BS - if (CalamityWorld.DoGSecondStageCountdown == 530) - music = CalamityMod.Instance.GetMusicFromMusicMod("DevourerOfGodsP2") ?? MusicID.LunarBoss; + // Play music after the transiton BS + if (CalamityWorld.DoGSecondStageCountdown == 530) + music = CalamityMod.Instance.GetMusicFromMusicMod("DevourerOfGodsP2") ?? MusicID.LunarBoss; - // Once before DoG spawns, set new size - if (CalamityWorld.DoGSecondStageCountdown == 60) - { - npc.position = npc.Center; - npc.width = 80; - npc.height = 140; - npc.frame = new Rectangle(0, 0, 86, 148); - npc.position -= npc.Size * 0.5f; - npc.netUpdate = true; - } - } + // Once before DoG spawns, set new size + if (CalamityWorld.DoGSecondStageCountdown == 60) + { + npc.position = npc.Center; + npc.width = 80; + npc.height = 140; + npc.frame = new Rectangle(0, 0, 86, 148); + npc.position -= npc.Size * 0.5f; + npc.netUpdate = true; + } + } - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (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); - if (invinceTime > 0) - { - invinceTime--; - npc.dontTakeDamage = true; - } - else - npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; + if (invinceTime > 0) + { + invinceTime--; + npc.dontTakeDamage = true; + } + else + npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; - if (Main.npc[(int)npc.ai[2]].dontTakeDamage) - invinceTime = 240; + if (Main.npc[(int)npc.ai[2]].dontTakeDamage) + invinceTime = 240; - // Target - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Target + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - float distanceFromTarget = Vector2.Distance(player.Center, npc.Center); - float takeLessDamageDistance = 1600f; - if (distanceFromTarget > takeLessDamageDistance) - { - float damageTakenScalar = MathHelper.Clamp(1f - ((distanceFromTarget - takeLessDamageDistance) / takeLessDamageDistance), 0f, 1f); - npc.takenDamageMultiplier = MathHelper.Lerp(1f, 1.25f, damageTakenScalar); - } - else - npc.takenDamageMultiplier = 1.25f; + float distanceFromTarget = Vector2.Distance(player.Center, npc.Center); + float takeLessDamageDistance = 1600f; + if (distanceFromTarget > takeLessDamageDistance) + { + float damageTakenScalar = MathHelper.Clamp(1f - ((distanceFromTarget - takeLessDamageDistance) / takeLessDamageDistance), 0f, 1f); + npc.takenDamageMultiplier = MathHelper.Lerp(1f, 1.25f, damageTakenScalar); + } + else + npc.takenDamageMultiplier = 1.25f; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].Opacity >= 0.5f && (!setOpacity || (CalamityWorld.DoGSecondStageCountdown <= 60 && CalamityWorld.DoGSecondStageCountdown > 0))) - { - npc.Opacity += 0.165f; - if (npc.Opacity >= 1f && invinceTime <= 0) - { - setOpacity = true; - npc.Opacity = 1f; - } - } - else - { - if (Main.npc[(int)npc.ai[2]].ModNPC()?.AttemptingToEnterPortal ?? false) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile portal = Main.projectile[Main.npc[(int)npc.ai[2]].ModNPC().PortalIndex]; - float newOpacity = 1f - Utils.InverseLerp(270f, 100f, npc.Distance(portal.Center), true); - if (newOpacity > 0f && npc.Opacity > newOpacity) - { - npc.Opacity = newOpacity; + if (Main.npc[(int)npc.ai[1]].Opacity >= 0.5f && (!setOpacity || (CalamityWorld.DoGSecondStageCountdown <= 60 && CalamityWorld.DoGSecondStageCountdown > 0))) + { + npc.Opacity += 0.165f; + if (npc.Opacity >= 1f && invinceTime <= 0) + { + setOpacity = true; + npc.Opacity = 1f; + } + } + else + { + if (Main.npc[(int)npc.ai[2]].ModNPC()?.AttemptingToEnterPortal ?? false) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile portal = Main.projectile[Main.npc[(int)npc.ai[2]].ModNPC().PortalIndex]; + float newOpacity = 1f - Utils.InverseLerp(270f, 100f, npc.Distance(portal.Center), true); + if (newOpacity > 0f && npc.Opacity > newOpacity) + { + npc.Opacity = newOpacity; - // Create dust at the portal position. - if (Vector2.Dot((npc.rotation - MathHelper.PiOver2).ToRotationVector2(), Main.npc[(int)npc.ai[2]].velocity) > 0f) - { - for (int i = 0; i < 2; i++) - { - Dust cosmicMagic = Dust.NewDustPerfect(portal.Center, Main.rand.NextBool() ? 180 : 173); - cosmicMagic.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 8f); - cosmicMagic.scale *= Main.rand.NextFloat(1f, 1.8f); - cosmicMagic.noGravity = true; - } - } + // Create dust at the portal position. + if (Vector2.Dot((npc.rotation - MathHelper.PiOver2).ToRotationVector2(), Main.npc[(int)npc.ai[2]].velocity) > 0f) + { + for (int i = 0; i < 2; i++) + { + Dust cosmicMagic = Dust.NewDustPerfect(portal.Center, Main.rand.NextBool() ? 180 : 173); + cosmicMagic.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 8f); + cosmicMagic.scale *= Main.rand.NextFloat(1f, 1.8f); + cosmicMagic.noGravity = true; + } + } - if (npc.Opacity < 0.2f) - npc.Opacity = 0f; + if (npc.Opacity < 0.2f) + npc.Opacity = 0f; - npc.netUpdate = true; - } - } - } - else - npc.Opacity = Main.npc[(int)npc.ai[2]].Opacity; - } + npc.netUpdate = true; + } + } + } + else + npc.Opacity = Main.npc[(int)npc.ai[2]].Opacity; + } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + 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; @@ -293,141 +293,141 @@ namespace CalamityMod.NPCs.DevourerofGods } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - float disintegrationFactor = Main.npc[npc.realLife].ModNPC().DeathAnimationTimer / 640f; - if (disintegrationFactor > 0f) - { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(npc.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + float disintegrationFactor = Main.npc[npc.realLife].ModNPC().DeathAnimationTimer / 640f; + if (disintegrationFactor > 0f) + { + spriteBatch.EnterShaderRegion(); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(npc.whoAmI); + GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage("Images/Misc/Perlin"); + GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); + } - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - bool useOtherTextures = phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60; - Texture2D texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS") : Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); + bool useOtherTextures = phase2Started && CalamityWorld.DoGSecondStageCountdown <= 60; + Texture2D texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - if (!npc.dontTakeDamage) - { - texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailSGlow") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailGlow"); - Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + if (!npc.dontTakeDamage) + { + texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailSGlow") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailGlow"); + Color color37 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailSGlow2") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailGlow2"); - color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + texture2D15 = useOtherTextures ? ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailSGlow2") : ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailGlow2"); + color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); - return false; - } + if (disintegrationFactor > 0f) + spriteBatch.ExitShaderRegion(); + return false; + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; - Rectangle targetHitbox = target.Hitbox; + Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= (phase2Started ? 70f : 35f) && npc.Opacity >= 1f; - } + return minDist <= (phase2Started ? 70f : 35f) && npc.Opacity >= 1f; + } - public override void HitEffect(int hitDirection, double damage) - { - if (npc.soundDelay == 0) - { - npc.soundDelay = 8; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); - } - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS4"), 1f); - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - for (int num621 = 0; num621 < 10; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 20; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + if (npc.soundDelay == 0) + { + npc.soundDelay = 8; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); + } + if (npc.life <= 0) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/DoGS4"), 1f); + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); + npc.width = 50; + npc.height = 50; + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 10; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 20; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + } - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) - { - if ((damage * (crit ? 2D : 1D)) >= npc.life || (npc.realLife >= 0 && Main.npc[npc.realLife].ModNPC().Dying)) - { - if (npc.realLife >= 0) - { - damage = 0D; - npc.dontTakeDamage = true; - Main.npc[npc.realLife].dontTakeDamage = true; - Main.npc[npc.realLife].life = 1; + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + { + if ((damage * (crit ? 2D : 1D)) >= npc.life || (npc.realLife >= 0 && Main.npc[npc.realLife].ModNPC().Dying)) + { + if (npc.realLife >= 0) + { + damage = 0D; + npc.dontTakeDamage = true; + Main.npc[npc.realLife].dontTakeDamage = true; + Main.npc[npc.realLife].life = 1; - if (!Main.npc[npc.realLife].ModNPC().Dying) - { - Main.npc[npc.realLife].ModNPC().Dying = true; - Main.npc[npc.realLife].dontTakeDamage = true; - Main.npc[npc.realLife].active = true; - Main.npc[npc.realLife].netUpdate = true; - } - } - return false; - } - return true; - } + if (!Main.npc[npc.realLife].ModNPC().Dying) + { + Main.npc[npc.realLife].ModNPC().Dying = true; + Main.npc[npc.realLife].dontTakeDamage = true; + Main.npc[npc.realLife].active = true; + Main.npc[npc.realLife].netUpdate = true; + } + } + return false; + } + return true; + } - public override bool CheckDead() - { - if (npc.realLife >= 0) - Main.npc[npc.realLife].checkDead(); - return base.CheckDead(); - } + public override bool CheckDead() + { + if (npc.realLife >= 0) + Main.npc[npc.realLife].checkDead(); + return base.CheckDead(); + } - public override bool CheckActive() + public override bool CheckActive() { return false; } @@ -448,18 +448,18 @@ namespace CalamityMod.NPCs.DevourerofGods player.AddBuff(ModContent.BuffType(), 180, true); player.AddBuff(ModContent.BuffType(), 240, true); - if (player.Calamity().dogTextCooldown <= 0) - { - string text = Utils.SelectRandom(Main.rand, new string[] - { - "Mods.CalamityMod.EdgyBossText8", - "Mods.CalamityMod.EdgyBossText9" - }); - Color messageColor = Color.Cyan; - Rectangle location = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); - player.Calamity().dogTextCooldown = 60; - } + if (player.Calamity().dogTextCooldown <= 0) + { + string text = Utils.SelectRandom(Main.rand, new string[] + { + "Mods.CalamityMod.EdgyBossText8", + "Mods.CalamityMod.EdgyBossText9" + }); + Color messageColor = Color.Cyan; + Rectangle location = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); + player.Calamity().dogTextCooldown = 60; + } } } } diff --git a/NPCs/DevourerofGods/DevourerofGodsTail2.cs b/NPCs/DevourerofGods/DevourerofGodsTail2.cs index 9b8f8a801b..0e8ba6c0cc 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail2.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail2.cs @@ -19,7 +19,7 @@ namespace CalamityMod.NPCs.DevourerofGods public override void SetDefaults() { - npc.GetNPCDamage(); + npc.GetNPCDamage(); npc.width = 30; npc.height = 50; npc.defense = 70; @@ -71,35 +71,35 @@ namespace CalamityMod.NPCs.DevourerofGods npc.dontTakeDamage = false; } - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { if (npc.alpha != 0) { @@ -113,62 +113,62 @@ namespace CalamityMod.NPCs.DevourerofGods npc.alpha = 0; } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].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(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - 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(num192, num191) + 1.57f; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - } - } + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].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(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + { + try + { + 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(num192, num191) + 1.57f; + num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + int num194 = npc.width; + num193 = (num193 - num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + 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 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTail2Glow"); - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTail2Glow"); + Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; diff --git a/NPCs/DevourerofGods/DoGSky.cs b/NPCs/DevourerofGods/DoGSky.cs index 0c9d54dac3..b65627933e 100644 --- a/NPCs/DevourerofGods/DoGSky.cs +++ b/NPCs/DevourerofGods/DoGSky.cs @@ -34,8 +34,8 @@ namespace CalamityMod.NPCs.DevourerofGods if (DoGIndex != -1) x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[DoGIndex].Center); - bool sentinelsPhase = Main.npc[DoGIndex].life / (float)Main.npc[DoGIndex].lifeMax < 0.6f && CalamityWorld.DoGSecondStageCountdown > 720; - float intensityScalar = sentinelsPhase ? 0f : 0.5f; + bool sentinelsPhase = Main.npc[DoGIndex].life / (float)Main.npc[DoGIndex].lifeMax < 0.6f && CalamityWorld.DoGSecondStageCountdown > 720; + float intensityScalar = sentinelsPhase ? 0f : 0.5f; return (1f - Utils.SmoothStep(3000f, 6000f, x)) * intensityScalar; } return 0f; @@ -72,10 +72,10 @@ namespace CalamityMod.NPCs.DevourerofGods { if (Main.npc[DoGIndex].active) { - float intensity = GetIntensity(); - float lifeRatio = Main.npc[DoGIndex].life / (float)Main.npc[DoGIndex].lifeMax; - double blackScreenLife_GateValue = lifeRatio < 0.6f && CalamityWorld.DoGSecondStageCountdown <= 2 ? 0.09 : 0.66; - if (Main.npc[DoGIndex].life < Main.npc[DoGIndex].lifeMax * blackScreenLife_GateValue || CalamityWorld.death || BossRushEvent.BossRushActive) + float intensity = GetIntensity(); + float lifeRatio = Main.npc[DoGIndex].life / (float)Main.npc[DoGIndex].lifeMax; + double blackScreenLife_GateValue = lifeRatio < 0.6f && CalamityWorld.DoGSecondStageCountdown <= 2 ? 0.09 : 0.66; + if (Main.npc[DoGIndex].life < Main.npc[DoGIndex].lifeMax * blackScreenLife_GateValue || CalamityWorld.death || BossRushEvent.BossRushActive) { spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * (intensity + 0.5f)); diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index 9f2de07581..f5e56fb0c8 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DraedonLabThings { - public class RepairUnitCritter : ModNPC + public class RepairUnitCritter : ModNPC { public enum BehaviorState { diff --git a/NPCs/ExoMechs/Apollo/Apollo.cs b/NPCs/ExoMechs/Apollo/Apollo.cs index 17e615ac69..40ab6d7d1e 100644 --- a/NPCs/ExoMechs/Apollo/Apollo.cs +++ b/NPCs/ExoMechs/Apollo/Apollo.cs @@ -18,127 +18,127 @@ using CalamityMod.Skies; namespace CalamityMod.NPCs.ExoMechs.Apollo { - public class Apollo : ModNPC + public class Apollo : ModNPC { - public static int phase1IconIndex; - public static int phase2IconIndex; + public static int phase1IconIndex; + public static int phase2IconIndex; - internal static void LoadHeadIcons() - { - string phase1IconPath = "CalamityMod/NPCs/ExoMechs/Apollo/ApolloHead"; - string phase2IconPath = "CalamityMod/NPCs/ExoMechs/Apollo/ApolloPhase2Head"; + internal static void LoadHeadIcons() + { + string phase1IconPath = "CalamityMod/NPCs/ExoMechs/Apollo/ApolloHead"; + string phase2IconPath = "CalamityMod/NPCs/ExoMechs/Apollo/ApolloPhase2Head"; - CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); - phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); + CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); + phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); - CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); - phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); - } + CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); + phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); + } - public enum Phase - { - Normal = 0, - RocketBarrage = 1, - LineUpChargeCombo = 2, - ChargeCombo = 3, - PhaseTransition = 4 - } + public enum Phase + { + Normal = 0, + RocketBarrage = 1, + LineUpChargeCombo = 2, + ChargeCombo = 3, + PhaseTransition = 4 + } - public float AIState - { - get => npc.Calamity().newAI[0]; - set => npc.Calamity().newAI[0] = value; - } + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } - public enum SecondaryPhase - { - Nothing = 0, - Passive = 1, - PassiveAndImmune = 2 - } + public enum SecondaryPhase + { + Nothing = 0, + Passive = 1, + PassiveAndImmune = 2 + } - public float SecondaryAIState - { - get => npc.Calamity().newAI[1]; - set => npc.Calamity().newAI[1] = value; - } + public float SecondaryAIState + { + get => npc.Calamity().newAI[1]; + set => npc.Calamity().newAI[1] = value; + } - // Variable used to scale up velocity if too far from destination - private float velocityBoostMult = 0f; + // Variable used to scale up velocity if too far from destination + private float velocityBoostMult = 0f; - // Number of frames on the X and Y axis - private const int maxFramesX = 10; - private const int maxFramesY = 9; + // Number of frames on the X and Y axis + private const int maxFramesX = 10; + private const int maxFramesY = 9; - // Counters for frames on the X and Y axis - private int frameX = 0; - private int frameY = 0; + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; - // Frame limit per animation, these are the specific frames where each animation ends - private const int normalFrameLimit_Phase1 = 9; - private const int chargeUpFrameLimit_Phase1 = 19; - private const int attackFrameLimit_Phase1 = 29; - private const int phaseTransitionFrameLimit = 59; // The lens pops off on frame 37 - private const int normalFrameLimit_Phase2 = 69; - private const int chargeUpFrameLimit_Phase2 = 79; - private const int attackFrameLimit_Phase2 = 89; + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit_Phase1 = 9; + private const int chargeUpFrameLimit_Phase1 = 19; + private const int attackFrameLimit_Phase1 = 29; + private const int phaseTransitionFrameLimit = 59; // The lens pops off on frame 37 + private const int normalFrameLimit_Phase2 = 69; + private const int chargeUpFrameLimit_Phase2 = 79; + private const int attackFrameLimit_Phase2 = 89; - // Default life ratio for the other mechs - private const float defaultLifeRatio = 5f; + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; - // Max distance from the target before they are unable to hear sound telegraphs - private const float soundDistance = 2800f; + // Max distance from the target before they are unable to hear sound telegraphs + private const float soundDistance = 2800f; - // Normal animation duration - private const float defaultAnimationDuration = 60f; + // Normal animation duration + private const float defaultAnimationDuration = 60f; - // Total duration of the phase transition - private const float phaseTransitionDuration = 180f; + // Total duration of the phase transition + private const float phaseTransitionDuration = 180f; - // Where the timer should be when the lens pops off - private const float lensPopTime = 48f; + // Where the timer should be when the lens pops off + private const float lensPopTime = 48f; - // Variable to pick a different location after each attack - private bool pickNewLocation = false; + // Variable to pick a different location after each attack + private bool pickNewLocation = false; - // Charge locations during the charge combo - private const int maxCharges = 4; - public Vector2[] chargeLocations = new Vector2[maxCharges] { default, default, default, default }; + // Charge locations during the charge combo + private const int maxCharges = 4; + public Vector2[] chargeLocations = new Vector2[maxCharges] { default, default, default, default }; - // Intensity of flash effects during the charge combo - public float ChargeComboFlash; + // Intensity of flash effects during the charge combo + public float ChargeComboFlash; - // Primitive trail drawers for thrusters when charging - public PrimitiveTrail ChargeFlameTrail = null; - public PrimitiveTrail ChargeFlameTrailBig = null; + // Primitive trail drawers for thrusters when charging + public PrimitiveTrail ChargeFlameTrail = null; + public PrimitiveTrail ChargeFlameTrailBig = null; - // Primitive trail drawer for the ribbon things - public PrimitiveTrail RibbonTrail = null; + // Primitive trail drawer for the ribbon things + public PrimitiveTrail RibbonTrail = null; - public const string NameToDisplay = "XS-03 Apollo"; + public const string NameToDisplay = "XS-03 Apollo"; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault(NameToDisplay); - NPCID.Sets.TrailingMode[npc.type] = 3; - NPCID.Sets.TrailCacheLength[npc.type] = 15; - } + NPCID.Sets.TrailingMode[npc.type] = 3; + NPCID.Sets.TrailCacheLength[npc.type] = 15; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 5f; - npc.GetNPCDamage(); - npc.width = 204; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.width = 204; npc.height = 226; npc.defense = 80; - npc.DR_NERD(0.25f); - npc.LifeMaxNERB(1250000, 1495000, 500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.DR_NERD(0.25f); + npc.LifeMaxNERB(1250000, 1495000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; - npc.Opacity = 0f; + npc.Opacity = 0f; npc.knockBackResist = 0f; npc.value = Item.buyPrice(15, 0, 0, 0); npc.noGravity = true; @@ -146,1553 +146,1553 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; - npc.boss = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; - bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } - - public override void BossHeadSlot(ref int index) - { - if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) - index = -1; - else if (npc.life / (float)npc.lifeMax < 0.6f) - index = phase2IconIndex; - else - index = phase1IconIndex; - } - - public override void SendExtraAI(BinaryWriter writer) + npc.boss = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; + bossBag = ModContent.ItemType(); + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } + + public override void BossHeadSlot(ref int index) { - writer.Write(velocityBoostMult); - writer.Write(frameX); - writer.Write(frameY); - writer.Write(pickNewLocation); + if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) + index = -1; + else if (npc.life / (float)npc.lifeMax < 0.6f) + index = phase2IconIndex; + else + index = phase1IconIndex; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(velocityBoostMult); + writer.Write(frameX); + writer.Write(frameY); + writer.Write(pickNewLocation); writer.Write(npc.dontTakeDamage); - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - writer.Write(npc.localAI[3]); - for (int i = 0; i < 4; i++) - { - writer.Write(npc.Calamity().newAI[i]); - writer.WriteVector2(chargeLocations[i]); - } - } + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + writer.Write(npc.localAI[3]); + for (int i = 0; i < 4; i++) + { + writer.Write(npc.Calamity().newAI[i]); + writer.WriteVector2(chargeLocations[i]); + } + } public override void ReceiveExtraAI(BinaryReader reader) { - velocityBoostMult = reader.ReadSingle(); - frameX = reader.ReadInt32(); - frameY = reader.ReadInt32(); - pickNewLocation = reader.ReadBoolean(); - npc.dontTakeDamage = reader.ReadBoolean(); - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - { - npc.Calamity().newAI[i] = reader.ReadSingle(); - chargeLocations[i] = reader.ReadVector2(); - } - } + velocityBoostMult = reader.ReadSingle(); + frameX = reader.ReadInt32(); + frameY = reader.ReadInt32(); + pickNewLocation = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + { + npc.Calamity().newAI[i] = reader.ReadSingle(); + chargeLocations[i] = reader.ReadVector2(); + } + } public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - CalamityGlobalNPC.draedonExoMechTwinGreen = npc.whoAmI; - - npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - // Target variable - Player player = Main.player[npc.target]; - - // Check if the other exo mechs are alive - int otherExoMechsAlive = 0; - bool exoWormAlive = false; - bool exoPrimeAlive = false; - bool exoMechTwinRedAlive = false; - if (CalamityGlobalNPC.draedonExoMechTwinRed != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].active) - { - exoMechTwinRedAlive = true; - - // Link the HP of both twins - if (npc.life > Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].life) - npc.life = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].life; - } - } - if (CalamityGlobalNPC.draedonExoMechWorm != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) - { - // Set target to Thanatos' target if Thanatos is alive - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; - - otherExoMechsAlive++; - exoWormAlive = true; - } - } - if (CalamityGlobalNPC.draedonExoMechPrime != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - // Set target to Ares' target if Ares is alive - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - - otherExoMechsAlive++; - exoPrimeAlive = true; - } - } - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // These are 5 by default to avoid triggering passive phases after the other mechs are dead - float exoWormLifeRatio = defaultLifeRatio; - float exoPrimeLifeRatio = defaultLifeRatio; - if (exoWormAlive) - exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; - if (exoPrimeAlive) - exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; - float totalOtherExoMechLifeRatio = exoWormLifeRatio + exoPrimeLifeRatio; - - // Check if any of the other mechs are passive - bool exoWormPassive = false; - bool exoPrimePassive = false; - if (exoWormAlive) - exoWormPassive = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive; - if (exoPrimeAlive) - exoPrimePassive = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] == (float)AresBody.SecondaryPhase.Passive; - bool anyOtherExoMechPassive = exoWormPassive || exoPrimePassive; - - // Used to nerf Artemis and Apollo if fighting alongside Ares, because otherwise it's too difficult - bool nerfedAttacks = false; - if (exoWormAlive && !nerfedAttacks) - nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] != (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; - if (exoPrimeAlive && !nerfedAttacks) - nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] != (float)AresBody.SecondaryPhase.PassiveAndImmune; - - // Check if any of the other mechs were spawned first - bool exoWormWasFirst = false; - bool exoPrimeWasFirst = false; - if (exoWormAlive) - exoWormWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].ai[3] == 1f; - if (exoPrimeAlive) - exoPrimeWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] == 1f; - bool otherExoMechWasFirst = exoWormWasFirst || exoPrimeWasFirst; - - // Check for Draedon - bool draedonAlive = false; - if (CalamityGlobalNPC.draedon != -1) - { - if (Main.npc[CalamityGlobalNPC.draedon].active) - draedonAlive = true; - } - - // Prevent mechs from being respawned - if (otherExoMechWasFirst) - { - if (npc.ai[3] < 1f) - npc.ai[3] = 1f; - } - - // Decrement the timer used to stop Artemis from firing lasers - if (npc.ai[3] > 1f) - npc.ai[3] -= 1f; - - // Phases - bool phase2 = lifeRatio < 0.6f; - bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; - - // If Artemis and Apollo don't go berserk - bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoPrimeLifeRatio < 0.4f; - - // Whether Artemis and Apollo should be buffed while in berserk phase - bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - - // Spawn Artemis if it doesn't exist after the first 10 frames have passed - if (npc.ai[0] < 10f) - { - npc.ai[0] += 1f; - if (npc.ai[0] == 10f && !NPC.AnyNPCs(ModContent.NPCType())) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - } - else - { - if (!NPC.AnyNPCs(ModContent.NPCType())) - { - npc.active = false; - npc.netUpdate = true; - } - } - - // General AI pattern - // 0 - Fly to the right of the target and fire plasma when ready - // 1 - Fly to the right of the target and fire homing rockets, the rockets home in until close to the target and then fly off in the direction they were moving in - // 2 - Fly below the target, create several line telegraphs to show the dash pattern and then dash along those lines extremely quickly - // 3 - Go passive and fly to the right of the target while firing less projectiles - // 4 - Go passive, immune and invisible; fly far to the left of the target and do nothing until next phase - - // Attack patterns - // If spawned first - // Phase 1 - 0, 1 - // Phase 2 - 4 - // Phase 3 - 3 - - // If berserk, this is the last phase of Artemis and Apollo - // Phase 4 - 0, 1, 2 - - // If not berserk - // Phase 4 - 4 - // Phase 5 - 0, 1 - - // If berserk, this is the last phase of Artemis and Apollo - // Phase 6 - 0, 1, 2 - - // If not berserk - // Phase 6 - 4 - - // Berserk, final phase of Artemis and Apollo - // Phase 7 - 0, 1, 2 - - // Predictiveness - float predictionAmt = malice ? 14f : death ? 12f : revenge ? 11f : expertMode ? 10f : 8f; - if (nerfedAttacks) - predictionAmt *= 0.5f; - if (SecondaryAIState == (int)SecondaryPhase.Passive) - predictionAmt *= 0.5f; - - // Gate values - float reducedTimeForGateValue = malice ? 48f : death ? 32f : revenge ? 24f : expertMode ? 16f : 0f; - float reducedTimeForGateValue_Berserk = reducedTimeForGateValue * 0.5f; - float normalAttackTime = 360f - reducedTimeForGateValue; - float berserkAttackTime = lastMechAlive ? 225f - reducedTimeForGateValue_Berserk : 270f - reducedTimeForGateValue_Berserk; - float attackPhaseGateValue = shouldGetBuffedByBerserkPhase ? berserkAttackTime : normalAttackTime; - float timeToLineUpAttack = 30f; - float timeToLineUpCharge = malice ? 30f : death ? 40f : revenge ? 45f : expertMode ? 50f : 60f; - - // Distance where Apollo stops moving - float movementDistanceGateValue = 100f; - float chargeLocationDistanceGateValue = 40f; - - // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); - float baseVelocity = (AIState == (int)Phase.LineUpChargeCombo ? 40f : 20f) * baseVelocityMult; - - // Attack gate values - bool lineUpAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f; - bool doBigAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f + timeToLineUpAttack; - - // Charge velocity - float chargeVelocity = malice ? 115f : death ? 105f : revenge ? 101.25f : expertMode ? 97.5f : 90f; - - // Charge phase variables - double chargeDistance = Math.Sqrt(500D * 500D + 800D * 800D); - float chargeTime = (float)chargeDistance / chargeVelocity; - - // Plasma and rocket projectile velocities - float projectileVelocity = 12f; - if (lastMechAlive) - projectileVelocity *= 1.2f; - else if (shouldGetBuffedByBerserkPhase) - projectileVelocity *= 1.1f; - - // Rocket phase variables - float rocketPhaseDuration = lastMechAlive ? 60f : 90f; - int numRockets = nerfedAttacks ? 2 : 3; - - // Default vector to fly to - bool flyRight = npc.ai[0] % 2f == 0f || npc.ai[0] < 10f || !revenge; - float destinationX = flyRight ? 750f : -750f; - float destinationY = player.Center.Y; - float chargeComboXOffset = flyRight ? -500f : 500f; - float chargeComboYOffset = npc.ai[2] % 2f == 0f ? 400f : -400f; - Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X + destinationX * 1.6f, destinationY) : - SecondaryAIState == (float)SecondaryPhase.Passive ? new Vector2(player.Center.X + destinationX, destinationY + 360f) : - AIState == (float)Phase.LineUpChargeCombo ? new Vector2(player.Center.X + destinationX, destinationY + chargeComboYOffset) : - new Vector2(player.Center.X + destinationX, destinationY); - - // Add some random distance to the destination after certain attacks - if (pickNewLocation) - { - pickNewLocation = false; - - npc.localAI[0] = Main.rand.Next(-50, 51); - npc.localAI[1] = Main.rand.Next(-250, 251); - if (AIState == (float)Phase.RocketBarrage || SecondaryAIState == (float)SecondaryPhase.Passive) - { - npc.localAI[0] *= 0.5f; - npc.localAI[1] *= 0.5f; - } - - npc.netUpdate = true; - } - - // Add a bit of randomness to the destination, but only in specific phases where it's necessary - if (AIState == (float)Phase.Normal || AIState == (float)Phase.RocketBarrage || AIState == (float)Phase.PhaseTransition) - { - destination.X += npc.localAI[0]; - destination.Y += npc.localAI[1]; - } - - // Scale up velocity over time if too far from destination - Vector2 distanceFromDestination = destination - npc.Center; - if (distanceFromDestination.Length() > movementDistanceGateValue && AIState != (float)Phase.ChargeCombo) - { - if (velocityBoostMult < 1f) - velocityBoostMult += 0.004f; - } - else - { - if (velocityBoostMult > 0f) - velocityBoostMult -= 0.004f; - } - baseVelocity *= 1f + velocityBoostMult; - - // If Apollo can fire projectiles, cannot fire if too close to the target - bool canFire = Vector2.Distance(npc.Center, player.Center) > 320f; - - // Rotation - Vector2 predictionVector = player.velocity * predictionAmt; - Vector2 aimedVector = player.Center + predictionVector - npc.Center; - float rateOfRotation = 0.1f; - Vector2 rotateTowards = player.Center - npc.Center; - bool readyToCharge = AIState == (float)Phase.LineUpChargeCombo && (Vector2.Distance(npc.Center, destination) <= chargeLocationDistanceGateValue || calamityGlobalNPC.newAI[2] > 0f); - if (AIState == (int)Phase.ChargeCombo) - { - rateOfRotation = 0f; - npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - } - else if (AIState == (float)Phase.LineUpChargeCombo && chargeLocations[1] != default) - { - float x = chargeLocations[1].X - npc.Center.X; - float y = chargeLocations[1].Y - npc.Center.Y; - rotateTowards = Vector2.Normalize(new Vector2(x, y)) * baseVelocity; - } - else - { - float x = player.Center.X + predictionVector.X - npc.Center.X; - float y = player.Center.Y + predictionVector.Y - npc.Center.Y; - rotateTowards = Vector2.Normalize(new Vector2(x, y)) * baseVelocity; - } - - // Do not set this during charge or deathray phases - if (rateOfRotation != 0f) - npc.rotation = npc.rotation.AngleTowards((float)Math.Atan2(rotateTowards.Y, rotateTowards.X) + MathHelper.PiOver2, rateOfRotation); - - // Light - Lighting.AddLight(npc.Center, 0.05f * npc.Opacity, 0.25f * npc.Opacity, 0.15f * npc.Opacity); - - // Despawn if target is dead - if (player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (player.dead) - { - AIState = (float)Phase.Normal; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - for (int i = 0; i < maxCharges; i++) - chargeLocations[i] = default; - - npc.dontTakeDamage = true; - - npc.velocity.Y -= 1f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 1f; - - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - - return; - } - } - - // Cause the charge visual effects to begin while performing or preparing for a combo - if (AIState == (float)Phase.LineUpChargeCombo || AIState == (float)Phase.ChargeCombo) - ChargeComboFlash = MathHelper.Clamp(ChargeComboFlash + 0.08f, 0f, 1f); - - // And have them go away afterwards - else - ChargeComboFlash = MathHelper.Clamp(ChargeComboFlash - 0.1f, 0f, 1f); - - // Set to transition to phase 2 if it hasn't happened yet - if (phase2 && npc.localAI[3] == 0f) - { - AIState = (float)Phase.PhaseTransition; - npc.localAI[3] = 1f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - - // Set frames to phase transition frames, which begin on frame 30 - // Reset the frame counter - npc.frameCounter = 0D; - - // X = 3 sets to frame 27 - frameX = 3; - - // Y = 3 sets to frame 30 - frameY = 3; - } - - // Passive and Immune phases - switch ((int)SecondaryAIState) - { - case (int)SecondaryPhase.Nothing: - - // Spawn the other mechs if Artemis and Apollo are first - if (otherExoMechsAlive == 0) - { - if (spawnOtherExoMechs) - { - // Despawn projectile bullshit - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType()) - { - projectile.Kill(); - projectile.owner = Main.maxPlayers; - } - } - } - - // Set Artemis variables - if (exoMechTwinRedAlive) - { - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[3] < 1f) - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[3] = 1f; - - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.PassiveAndImmune; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; - } - - // Reset everything - if (npc.ai[0] < 10f) - npc.ai[0] = 10f; - npc.ai[0] += 1f; - - if (npc.ai[3] < 1f) - npc.ai[3] = 1f; - - SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - for (int i = 0; i < maxCharges; i++) - chargeLocations[i] = default; - - npc.TargetClosest(); - - // Draedon text for the start of phase 2 - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 1f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Spawn the fuckers - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - } - } - } - else - { - // If not spawned first, go to passive state if any other mech is passive or if Artemis and Apollo are under 70% life - // Do not run this if berserk - // Do not run this if any exo mech is dead - if ((anyOtherExoMechPassive || lifeRatio < 0.7f) && !berserk && totalOtherExoMechLifeRatio < 5f) - { - // Set Artemis variables - if (exoMechTwinRedAlive) - { - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.Passive; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; - } - - // Tells Apollo to return to the battle in passive state and reset everything - SecondaryAIState = (float)SecondaryPhase.Passive; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - for (int i = 0; i < maxCharges; i++) - chargeLocations[i] = default; - - npc.TargetClosest(); - } - - // Go passive and immune if one of the other mechs is berserk - // This is only called if two exo mechs are alive in ideal scenarios - // This is not called if Artemis and Apollo and another one or two mechs are berserk - if (otherMechIsBerserk && !berserk) - { - // Despawn projectile bullshit - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType()) - { - projectile.Kill(); - projectile.owner = Main.maxPlayers; - } - } - } - - // Set Artemis variables - if (exoMechTwinRedAlive) - { - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.PassiveAndImmune; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; - } - - // Reset everything - if (npc.ai[0] < 10f) - npc.ai[0] = 10f; - npc.ai[0] += 1f; - - SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - for (int i = 0; i < maxCharges; i++) - chargeLocations[i] = default; - - npc.TargetClosest(); - - // Phase 6, when 1 mech goes berserk and the other one leaves - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 5f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - } - - break; - - // Fire projectiles less often, this happens when all 3 mechs are present and attacking - case (int)SecondaryPhase.Passive: - - // Artemis fires lasers while passive - if (exoMechTwinRedAlive) - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[0] = (float)Artemis.Artemis.Phase.Normal; - - // Fire plasma while passive - AIState = (float)Phase.Normal; - - // Enter passive and invincible phase if one of the other exo mechs is berserk - if (otherMechIsBerserk) - { - // Despawn projectile bullshit - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType()) - { - projectile.Kill(); - projectile.owner = Main.maxPlayers; - } - } - } - - // Set Artemis variables - if (exoMechTwinRedAlive) - { - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.PassiveAndImmune; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; - } - - // Reset everything - if (npc.ai[0] < 10f) - npc.ai[0] = 10f; - npc.ai[0] += 1f; - - SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - for (int i = 0; i < maxCharges; i++) - chargeLocations[i] = default; - - npc.TargetClosest(); - } - - // If Artemis and Apollo are the first mechs to go berserk - if (berserk) - { - // Set Artemis variables - if (exoMechTwinRedAlive) - { - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.Nothing; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; - } - - // Reset everything - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - for (int i = 0; i < maxCharges; i++) - chargeLocations[i] = default; - - npc.TargetClosest(); - - // Never be passive if berserk - SecondaryAIState = (float)SecondaryPhase.Nothing; - - // Phase 4, when 1 mech goes berserk and the other 2 leave - if (exoWormAlive && exoPrimeAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 3f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - } - - break; - - // Fly above target and become immune - case (int)SecondaryPhase.PassiveAndImmune: - - // Artemis does nothing while immune - if (exoMechTwinRedAlive) - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[0] = (float)Artemis.Artemis.Phase.Normal; - - // Do nothing while immune - AIState = (float)Phase.Normal; - - // Enter the fight again if any of the other exo mechs is below 70% and other mechs aren't berserk - if ((exoWormLifeRatio < 0.7f || exoPrimeLifeRatio < 0.7f) && !otherMechIsBerserk) - { - // Set Artemis variables - if (exoMechTwinRedAlive) - { - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = - totalOtherExoMechLifeRatio > 5f ? (float)Artemis.Artemis.SecondaryPhase.Nothing : (float)Artemis.Artemis.SecondaryPhase.Passive; - - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; - } - - // Tells Artemis and Apollo to return to the battle in passive state and reset everything - // Return to normal phases if one or more mechs have been downed - SecondaryAIState = totalOtherExoMechLifeRatio > 5f ? (float)SecondaryPhase.Nothing : (float)SecondaryPhase.Passive; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - for (int i = 0; i < maxCharges; i++) - chargeLocations[i] = default; - - npc.TargetClosest(); - - // Phase 3, when all 3 mechs attack at the same time - if (exoWormAlive && exoPrimeAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 2f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - } - - // This is here just in case - if (berserk) - { - // Set Artemis variables - if (exoMechTwinRedAlive) - { - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.Nothing; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; - Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; - } - - // Reset everything - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - for (int i = 0; i < maxCharges; i++) - chargeLocations[i] = default; - - npc.TargetClosest(); - - // Never be passive if berserk - SecondaryAIState = (float)SecondaryPhase.Nothing; - } - - break; - } - - // Adjust opacity - bool invisiblePhase = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune; - npc.dontTakeDamage = invisiblePhase || AIState == (float)Phase.PhaseTransition; - if (!invisiblePhase) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } - - // Attacking phases - switch ((int)AIState) - { - // Fly to the right of the target - case (int)Phase.Normal: - - // Smooth movement towards the location Apollo is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - - // Default animation for 60 frames and then go to telegraph animation - // newAI[3] tells Apollo what animation state it's currently in - bool attacking = calamityGlobalNPC.newAI[3] >= 2f; - bool firingPlasma = attacking && calamityGlobalNPC.newAI[3] + 2f < attackPhaseGateValue; - - // Only increase attack timer if not in immune phase - if (SecondaryAIState != (float)SecondaryPhase.PassiveAndImmune) - calamityGlobalNPC.newAI[2] += 1f; - - if (calamityGlobalNPC.newAI[2] >= defaultAnimationDuration || attacking) - { - if (firingPlasma) - { - // Fire plasma - float divisor = nerfedAttacks ? 60f : lastMechAlive ? 40f : 45f; - float plasmaTimer = calamityGlobalNPC.newAI[3] - 2f; - if (plasmaTimer % divisor == 0f && canFire) - { - pickNewLocation = true; - npc.ai[2] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaCasterFire"), npc.Center); - Vector2 plasmaVelocity = Vector2.Normalize(aimedVector) * projectileVelocity; - Vector2 offset = Vector2.Normalize(plasmaVelocity) * 70f; - Projectile.NewProjectile(npc.Center + offset, plasmaVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); - } - } - } - else - calamityGlobalNPC.newAI[2] = 0f; - - // Enter rocket phase after a certain time has passed - // Enter charge phase if in phase 2 and the localAI[2] variable is set to do so - calamityGlobalNPC.newAI[3] += 1f; - if (lineUpAttack) - { - // Return to normal plasma phase if in passive state - if (SecondaryAIState == (float)SecondaryPhase.Passive) - { - pickNewLocation = true; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - for (int i = 0; i < maxCharges; i++) - chargeLocations[i] = default; - - npc.TargetClosest(); - } - else if (doBigAttack) - { - pickNewLocation = npc.localAI[2] == 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - - if (phase2) - AIState = npc.localAI[2] == 1f ? (float)Phase.LineUpChargeCombo : (float)Phase.RocketBarrage; - else - AIState = (float)Phase.RocketBarrage; - } - } - } - - break; - - // Charge - case (int)Phase.RocketBarrage: - - // Smooth movement towards the location Apollo is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] % (rocketPhaseDuration / numRockets) == 0f && canFire) - { - pickNewLocation = true; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Main.PlaySound(SoundID.Item36, npc.Center); - Vector2 rocketVelocity = Vector2.Normalize(aimedVector) * projectileVelocity * 1.2f; - Vector2 offset = Vector2.Normalize(rocketVelocity) * 70f; - Projectile.NewProjectile(npc.Center + offset, rocketVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); - } - } - - // Reset phase and variables - if (calamityGlobalNPC.newAI[2] >= rocketPhaseDuration) - { - // Go back to normal phase - AIState = (float)Phase.Normal; - npc.localAI[2] = shouldGetBuffedByBerserkPhase ? 1f : 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); - } - - break; - - // Get in position for the charge combo, don't do anything else until in position - // Fill up the charge location array with the positions Apollo will charge from - // Create telegraph beams between the charge location array positions - case (int)Phase.LineUpChargeCombo: - - if (!readyToCharge) - { - // Smooth movement towards the location Apollo is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - } - else - { - // Save the charge locations and create telegraph beams - int type = ModContent.ProjectileType(); - - for (int i = 0; i < maxCharges; i++) - { - if (chargeLocations[i] == default) - { - switch (i) - { - case 0: - chargeLocations[i] = npc.Center; - break; - case 1: - chargeLocations[i] = chargeLocations[0] + new Vector2(chargeComboXOffset, -chargeComboYOffset * 2f); - break; - case 2: - chargeLocations[i] = chargeLocations[1] + new Vector2(chargeComboXOffset, chargeComboYOffset * 2f); - break; - case 3: - chargeLocations[i] = chargeLocations[2] + new Vector2(chargeComboXOffset, -chargeComboYOffset * 2f); - break; - default: - break; - } - - if (i == 0) - { - // Draw telegraph beams - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int telegraph = Projectile.NewProjectile(chargeLocations[0], Vector2.Zero, type, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - if (Main.projectile.IndexInRange(telegraph)) - { - Main.projectile[telegraph].ModProjectile().ChargePositions = chargeLocations; - Main.projectile[telegraph].netUpdate = true; - } - } - - // Play a charge sound - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - } - } - } - - // Don't move - npc.velocity = Vector2.Zero; - - // Go to charge phase, create lightning bolts in the sky, and reset - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] >= timeToLineUpCharge) - { - ExoMechsSky.CreateLightningBolt(10); - - AIState = (float)Phase.ChargeCombo; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - } - } - - break; - - // Charge to several locations almost instantly (Apollo doesn't teleport here, he's just moving very fast :D) - case (int)Phase.ChargeCombo: - - // Set charge velocity and fire halos of plasma bolts - if (npc.localAI[2] == 0f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ELRFire"), npc.Center); - npc.velocity = Vector2.Normalize(chargeLocations[(int)calamityGlobalNPC.newAI[2] + 1] - chargeLocations[(int)calamityGlobalNPC.newAI[2]]) * chargeVelocity; - npc.localAI[2] = 1f; - npc.netUpdate = true; - npc.netSpam -= 5; - - // Plasma bolts on charge - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int totalProjectiles = CalamityWorld.malice ? 12 : 8; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int damage = (int)(npc.GetProjectileDamage(ModContent.ProjectileType()) * 0.8); - float velocity = 1f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, velocity2, type, damage, 0f, Main.myPlayer); - } - } - - // Dust rings - for (int i = 0; i < 200; i++) - { - float dustVelocity = 16f; - if (i < 150) - dustVelocity = 12f; - if (i < 100) - dustVelocity = 8f; - if (i < 50) - dustVelocity = 4f; - - int dust1 = Dust.NewDust(npc.Center, 6, 6, Main.rand.NextBool(2) ? 107 : 110, 0f, 0f, 100, default, 1f); - float dustVelX = Main.dust[dust1].velocity.X; - float dustVelY = Main.dust[dust1].velocity.Y; - - if (dustVelX == 0f && dustVelY == 0f) - dustVelX = 1f; - - float dustVelocity2 = (float)Math.Sqrt(dustVelX * dustVelX + dustVelY * dustVelY); - dustVelocity2 = dustVelocity / dustVelocity2; - dustVelX *= dustVelocity2; - dustVelY *= dustVelocity2; - - float scale = 1f; - switch ((int)dustVelocity) - { - case 4: - scale = 1.2f; - break; - case 8: - scale = 1.1f; - break; - case 12: - scale = 1f; - break; - case 16: - scale = 0.9f; - break; - default: - break; - } - - Dust dust2 = Main.dust[dust1]; - dust2.velocity *= 0.5f; - dust2.velocity.X = dust2.velocity.X + dustVelX; - dust2.velocity.Y = dust2.velocity.Y + dustVelY; - dust2.scale = scale; - dust2.noGravity = true; - } - } - - // Initiate next charge if close enough to next charge location - calamityGlobalNPC.newAI[3] += 1f; - if (calamityGlobalNPC.newAI[3] >= chargeTime) - { - // Set Apollo's location to the next charge location - npc.Center = chargeLocations[(int)calamityGlobalNPC.newAI[2] + 1]; - - // Reset velocity to 0 - npc.velocity = Vector2.Zero; - - // Increase newAI[2] whenever a charge ends - calamityGlobalNPC.newAI[2] += 1f; - calamityGlobalNPC.newAI[3] = 0f; - npc.localAI[2] = 0f; - } - - // Reset phase and variables - if (calamityGlobalNPC.newAI[2] >= maxCharges - 1) - { - pickNewLocation = true; - AIState = (float)Phase.Normal; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - for (int i = 0; i < maxCharges; i++) - chargeLocations[i] = default; - ChargeComboFlash = 0f; - - // Tell Apollo and Artemis to swap positions - if (npc.ai[0] < 10f) - npc.ai[0] = 10f; - npc.ai[0] += 1f; - - // Change Y offset for the next charge combo - npc.ai[2] = Main.rand.Next(2); - - // Tell Artemis to not fire lasers for a short time while swapping positions - npc.ai[3] = 61f; - - npc.TargetClosest(); - npc.netUpdate = true; - } - - break; - - // Phase transition animation, that's all this exists for - case (int)Phase.PhaseTransition: - - // Smooth movement towards the location Apollo is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - - // Shoot lens gore at the target at the proper time - if (calamityGlobalNPC.newAI[2] == lensPopTime) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"), npc.Center); - Vector2 lensDirection = Vector2.Normalize(aimedVector); - Vector2 offset = lensDirection * 70f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.Center + offset, lensDirection * 24f, ModContent.ProjectileType(), 0, 0f); - } - - // Reset phase and variables - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] >= phaseTransitionDuration) - { - pickNewLocation = true; - AIState = (float)Phase.Normal; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.TargetClosest(); - } - - break; - } - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - - Rectangle targetHitbox = target.Hitbox; - - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; - - return minDist <= 100f && npc.Opacity == 1f && AIState == (float)Phase.ChargeCombo; - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - scale = 2f; - return null; - } - - public override void FindFrame(int frameHeight) - { - // Use telegraph frames before each attack - bool phase2 = npc.life / (float)npc.lifeMax < 0.6f; - npc.frameCounter += 1D; - if (AIState == (float)Phase.PhaseTransition) - { - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 9 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - } - } - else - { - if (AIState == (float)Phase.Normal) - { - int frameLimit = phase2 ? (npc.Calamity().newAI[3] == 0f ? normalFrameLimit_Phase2 : npc.Calamity().newAI[3] == 1f ? chargeUpFrameLimit_Phase2 : attackFrameLimit_Phase2) : - (npc.Calamity().newAI[3] == 0f ? normalFrameLimit_Phase1 : npc.Calamity().newAI[3] == 1f ? chargeUpFrameLimit_Phase1 : attackFrameLimit_Phase1); - - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 9 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames - int currentFrame = (frameX * maxFramesY) + frameY; - if (currentFrame > frameLimit) - frameX = frameY = phase2 ? (npc.Calamity().newAI[3] == 0f ? 6 : npc.Calamity().newAI[3] == 1f ? 7 : 8) : (npc.Calamity().newAI[3] == 0f ? 0 : npc.Calamity().newAI[3] == 1f ? 1 : 2); - } - } - else if (AIState == (float)Phase.RocketBarrage || AIState == (float)Phase.LineUpChargeCombo || AIState == (float)Phase.ChargeCombo) - { - int frameLimit = phase2 ? attackFrameLimit_Phase2 : attackFrameLimit_Phase1; - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 9 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames - int currentFrame = (frameX * maxFramesY) + frameY; - if (currentFrame > frameLimit) - frameX = frameY = phase2 ? 8 : 2; - } - } - } - } - - public float FlameTrailWidthFunction(float completionRatio) => MathHelper.SmoothStep(21f, 8f, completionRatio) * ChargeComboFlash; - - public float FlameTrailWidthFunctionBig(float completionRatio) => MathHelper.SmoothStep(34f, 12f, completionRatio) * ChargeComboFlash; - - public float RibbonTrailWidthFunction(float completionRatio) - { - float baseWidth = Utils.InverseLerp(1f, 0.54f, completionRatio, true) * 5f; - float endTipWidth = CalamityUtils.Convert01To010(Utils.InverseLerp(0.96f, 0.89f, completionRatio, true)) * 2.4f; - return baseWidth + endTipWidth; - } - - public Color FlameTrailColorFunction(float completionRatio) - { - float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true); - Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.27f); - Color middleColor = Color.Lerp(Color.Orange, Color.ForestGreen, 0.74f); - Color endColor = Color.Lime; - return CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * ChargeComboFlash * trailOpacity; - } - - public Color FlameTrailColorFunctionBig(float completionRatio) - { - float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true) * 0.56f; - Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.25f); - Color middleColor = Color.Lerp(Color.Blue, Color.White, 0.35f); - Color endColor = Color.Lerp(Color.DarkBlue, Color.White, 0.47f); - Color color = CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * ChargeComboFlash * trailOpacity; - color.A = 0; - return color; - } - - public Color RibbonTrailColorFunction(float completionRatio) - { - Color startingColor = new Color(34, 40, 48); - Color endColor = new Color(40, 160, 32); - return Color.Lerp(startingColor, endColor, (float)Math.Pow(completionRatio, 1.5D)) * npc.Opacity; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - // Declare the trail drawers if they have yet to be defined. - if (ChargeFlameTrail is null) - ChargeFlameTrail = new PrimitiveTrail(FlameTrailWidthFunction, FlameTrailColorFunction, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]); - - if (ChargeFlameTrailBig is null) - ChargeFlameTrailBig = new PrimitiveTrail(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]); - - if (RibbonTrail is null) - RibbonTrail = new PrimitiveTrail(RibbonTrailWidthFunction, RibbonTrailColorFunction); - - // Prepare the flame trail shader with its map texture. - GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak")); - - int numAfterimages = ChargeComboFlash > 0f ? 0 : 5; - Texture2D texture = Main.npcTexture[npc.type]; - Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - Vector2 origin = npc.Size * 0.5f; - Vector2 center = npc.Center - Main.screenPosition; - Color afterimageBaseColor = Color.White; - - // Draws a single instance of a regular, non-glowmask based Artemis. - // This is created to allow easy duplication of them when drawing the charge. - void drawInstance(Vector2 drawOffset, Color baseColor) - { - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = baseColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - afterimageCenter += drawOffset; - spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); - } - } - - spriteBatch.Draw(texture, center + drawOffset, frame, npc.GetAlpha(baseColor), npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); - } - - // Draw ribbons near the main thruster - for (int direction = -1; direction <= 1; direction += 2) - { - Vector2 ribbonOffset = -Vector2.UnitY.RotatedBy(npc.rotation) * 14f; - ribbonOffset += Vector2.UnitX.RotatedBy(npc.rotation) * direction * 26f; - - float currentSegmentRotation = npc.rotation; - List ribbonDrawPositions = new List(); - for (int i = 0; i < 12; i++) - { - float ribbonCompletionRatio = i / 12f; - float wrappedAngularOffset = MathHelper.WrapAngle(npc.oldRot[i + 1] - currentSegmentRotation) * 0.3f; - float segmentRotationOffset = MathHelper.Clamp(wrappedAngularOffset, -0.12f, 0.12f); - - // Add a sinusoidal offset that goes based on time and completion ratio to create a waving-flag-like effect. - // This is dampened for the first few points to prevent weird offsets. It is also dampened by high velocity. - float sinusoidalRotationOffset = (float)Math.Sin(ribbonCompletionRatio * 2.22f + Main.GlobalTime * 3.4f) * 1.36f; - float sinusoidalRotationOffsetFactor = Utils.InverseLerp(0f, 0.37f, ribbonCompletionRatio, true) * direction * 24f; - sinusoidalRotationOffsetFactor *= Utils.InverseLerp(24f, 16f, npc.velocity.Length(), true); - - Vector2 sinusoidalOffset = Vector2.UnitY.RotatedBy(npc.rotation + sinusoidalRotationOffset) * sinusoidalRotationOffsetFactor; - Vector2 ribbonSegmentOffset = Vector2.UnitY.RotatedBy(currentSegmentRotation) * ribbonCompletionRatio * 540f + sinusoidalOffset; - ribbonDrawPositions.Add(npc.Center + ribbonSegmentOffset + ribbonOffset); - - currentSegmentRotation += segmentRotationOffset; - } - RibbonTrail.Draw(ribbonDrawPositions, -Main.screenPosition, 66); - } - - int instanceCount = (int)MathHelper.Lerp(1f, 15f, ChargeComboFlash); - Color baseInstanceColor = Color.Lerp(drawColor, Color.White, ChargeComboFlash); - baseInstanceColor.A = (byte)(int)(255f - ChargeComboFlash * 255f); - - spriteBatch.EnterShaderRegion(); - - drawInstance(Vector2.Zero, baseInstanceColor); - if (instanceCount > 1) - { - baseInstanceColor *= 0.04f; - float backAfterimageOffset = MathHelper.SmoothStep(0f, 2f, ChargeComboFlash); - for (int i = 0; i < instanceCount; i++) - { - Vector2 drawOffset = (MathHelper.TwoPi * i / instanceCount + Main.GlobalTime * 0.8f).ToRotationVector2() * backAfterimageOffset; - drawInstance(drawOffset, baseInstanceColor); - } - } - - texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Apollo/ApolloGlow"); - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); - } - } - - spriteBatch.Draw(texture, center, frame, Color.White * npc.Opacity, npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); - - spriteBatch.ExitShaderRegion(); - - // Draw a flame trail on the thrusters if needed. This happens during charges. - if (ChargeComboFlash > 0f) - { - for (int direction = -1; direction <= 1; direction++) - { - Vector2 baseDrawOffset = new Vector2(0f, direction == 0f ? 18f : 60f).RotatedBy(npc.rotation); - baseDrawOffset += new Vector2(direction * 64f, 0f).RotatedBy(npc.rotation); - - float backFlameLength = direction == 0f ? 700f : 190f; - Vector2 drawStart = npc.Center + baseDrawOffset; - Vector2 drawEnd = drawStart - (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * ChargeComboFlash * backFlameLength; - Vector2[] drawPositions = new Vector2[] - { - drawStart, - drawEnd - }; - - if (direction == 0) - { - for (int i = 0; i < 4; i++) - { - Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 8f; - ChargeFlameTrailBig.Draw(drawPositions, drawOffset - Main.screenPosition, 70); - } - } - else - ChargeFlameTrail.Draw(drawPositions, -Main.screenPosition, 70); - } - } - - return false; - } - - public override bool SpecialNPCLoot() - { - int closestSegmentID = DropHelper.FindClosestWormSegment(npc, - ModContent.NPCType(), - ModContent.NPCType()); - npc.position = Main.npc[closestSegmentID].position; - return false; - } - - public override void BossLoot(ref string name, ref int potionType) - { - potionType = ModContent.ItemType(); - } - - public override void NPCLoot() + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + CalamityGlobalNPC.draedonExoMechTwinGreen = npc.whoAmI; + + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + // Target variable + Player player = Main.player[npc.target]; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoWormAlive = false; + bool exoPrimeAlive = false; + bool exoMechTwinRedAlive = false; + if (CalamityGlobalNPC.draedonExoMechTwinRed != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].active) + { + exoMechTwinRedAlive = true; + + // Link the HP of both twins + if (npc.life > Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].life) + npc.life = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].life; + } + } + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + // Set target to Thanatos' target if Thanatos is alive + player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; + + otherExoMechsAlive++; + exoWormAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechPrime != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + // Set target to Ares' target if Ares is alive + player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + + otherExoMechsAlive++; + exoPrimeAlive = true; + } + } + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoPrimeLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoPrimeAlive) + exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + float totalOtherExoMechLifeRatio = exoWormLifeRatio + exoPrimeLifeRatio; + + // Check if any of the other mechs are passive + bool exoWormPassive = false; + bool exoPrimePassive = false; + if (exoWormAlive) + exoWormPassive = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive; + if (exoPrimeAlive) + exoPrimePassive = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] == (float)AresBody.SecondaryPhase.Passive; + bool anyOtherExoMechPassive = exoWormPassive || exoPrimePassive; + + // Used to nerf Artemis and Apollo if fighting alongside Ares, because otherwise it's too difficult + bool nerfedAttacks = false; + if (exoWormAlive && !nerfedAttacks) + nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] != (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; + if (exoPrimeAlive && !nerfedAttacks) + nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] != (float)AresBody.SecondaryPhase.PassiveAndImmune; + + // Check if any of the other mechs were spawned first + bool exoWormWasFirst = false; + bool exoPrimeWasFirst = false; + if (exoWormAlive) + exoWormWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].ai[3] == 1f; + if (exoPrimeAlive) + exoPrimeWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] == 1f; + bool otherExoMechWasFirst = exoWormWasFirst || exoPrimeWasFirst; + + // Check for Draedon + bool draedonAlive = false; + if (CalamityGlobalNPC.draedon != -1) + { + if (Main.npc[CalamityGlobalNPC.draedon].active) + draedonAlive = true; + } + + // Prevent mechs from being respawned + if (otherExoMechWasFirst) + { + if (npc.ai[3] < 1f) + npc.ai[3] = 1f; + } + + // Decrement the timer used to stop Artemis from firing lasers + if (npc.ai[3] > 1f) + npc.ai[3] -= 1f; + + // Phases + bool phase2 = lifeRatio < 0.6f; + bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; + + // If Artemis and Apollo don't go berserk + bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoPrimeLifeRatio < 0.4f; + + // Whether Artemis and Apollo should be buffed while in berserk phase + bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; + + // Spawn Artemis if it doesn't exist after the first 10 frames have passed + if (npc.ai[0] < 10f) + { + npc.ai[0] += 1f; + if (npc.ai[0] == 10f && !NPC.AnyNPCs(ModContent.NPCType())) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + } + else + { + if (!NPC.AnyNPCs(ModContent.NPCType())) + { + npc.active = false; + npc.netUpdate = true; + } + } + + // General AI pattern + // 0 - Fly to the right of the target and fire plasma when ready + // 1 - Fly to the right of the target and fire homing rockets, the rockets home in until close to the target and then fly off in the direction they were moving in + // 2 - Fly below the target, create several line telegraphs to show the dash pattern and then dash along those lines extremely quickly + // 3 - Go passive and fly to the right of the target while firing less projectiles + // 4 - Go passive, immune and invisible; fly far to the left of the target and do nothing until next phase + + // Attack patterns + // If spawned first + // Phase 1 - 0, 1 + // Phase 2 - 4 + // Phase 3 - 3 + + // If berserk, this is the last phase of Artemis and Apollo + // Phase 4 - 0, 1, 2 + + // If not berserk + // Phase 4 - 4 + // Phase 5 - 0, 1 + + // If berserk, this is the last phase of Artemis and Apollo + // Phase 6 - 0, 1, 2 + + // If not berserk + // Phase 6 - 4 + + // Berserk, final phase of Artemis and Apollo + // Phase 7 - 0, 1, 2 + + // Predictiveness + float predictionAmt = malice ? 14f : death ? 12f : revenge ? 11f : expertMode ? 10f : 8f; + if (nerfedAttacks) + predictionAmt *= 0.5f; + if (SecondaryAIState == (int)SecondaryPhase.Passive) + predictionAmt *= 0.5f; + + // Gate values + float reducedTimeForGateValue = malice ? 48f : death ? 32f : revenge ? 24f : expertMode ? 16f : 0f; + float reducedTimeForGateValue_Berserk = reducedTimeForGateValue * 0.5f; + float normalAttackTime = 360f - reducedTimeForGateValue; + float berserkAttackTime = lastMechAlive ? 225f - reducedTimeForGateValue_Berserk : 270f - reducedTimeForGateValue_Berserk; + float attackPhaseGateValue = shouldGetBuffedByBerserkPhase ? berserkAttackTime : normalAttackTime; + float timeToLineUpAttack = 30f; + float timeToLineUpCharge = malice ? 30f : death ? 40f : revenge ? 45f : expertMode ? 50f : 60f; + + // Distance where Apollo stops moving + float movementDistanceGateValue = 100f; + float chargeLocationDistanceGateValue = 40f; + + // Velocity and acceleration values + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocity = (AIState == (int)Phase.LineUpChargeCombo ? 40f : 20f) * baseVelocityMult; + + // Attack gate values + bool lineUpAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f; + bool doBigAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f + timeToLineUpAttack; + + // Charge velocity + float chargeVelocity = malice ? 115f : death ? 105f : revenge ? 101.25f : expertMode ? 97.5f : 90f; + + // Charge phase variables + double chargeDistance = Math.Sqrt(500D * 500D + 800D * 800D); + float chargeTime = (float)chargeDistance / chargeVelocity; + + // Plasma and rocket projectile velocities + float projectileVelocity = 12f; + if (lastMechAlive) + projectileVelocity *= 1.2f; + else if (shouldGetBuffedByBerserkPhase) + projectileVelocity *= 1.1f; + + // Rocket phase variables + float rocketPhaseDuration = lastMechAlive ? 60f : 90f; + int numRockets = nerfedAttacks ? 2 : 3; + + // Default vector to fly to + bool flyRight = npc.ai[0] % 2f == 0f || npc.ai[0] < 10f || !revenge; + float destinationX = flyRight ? 750f : -750f; + float destinationY = player.Center.Y; + float chargeComboXOffset = flyRight ? -500f : 500f; + float chargeComboYOffset = npc.ai[2] % 2f == 0f ? 400f : -400f; + Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X + destinationX * 1.6f, destinationY) : + SecondaryAIState == (float)SecondaryPhase.Passive ? new Vector2(player.Center.X + destinationX, destinationY + 360f) : + AIState == (float)Phase.LineUpChargeCombo ? new Vector2(player.Center.X + destinationX, destinationY + chargeComboYOffset) : + new Vector2(player.Center.X + destinationX, destinationY); + + // Add some random distance to the destination after certain attacks + if (pickNewLocation) + { + pickNewLocation = false; + + npc.localAI[0] = Main.rand.Next(-50, 51); + npc.localAI[1] = Main.rand.Next(-250, 251); + if (AIState == (float)Phase.RocketBarrage || SecondaryAIState == (float)SecondaryPhase.Passive) + { + npc.localAI[0] *= 0.5f; + npc.localAI[1] *= 0.5f; + } + + npc.netUpdate = true; + } + + // Add a bit of randomness to the destination, but only in specific phases where it's necessary + if (AIState == (float)Phase.Normal || AIState == (float)Phase.RocketBarrage || AIState == (float)Phase.PhaseTransition) + { + destination.X += npc.localAI[0]; + destination.Y += npc.localAI[1]; + } + + // Scale up velocity over time if too far from destination + Vector2 distanceFromDestination = destination - npc.Center; + if (distanceFromDestination.Length() > movementDistanceGateValue && AIState != (float)Phase.ChargeCombo) + { + if (velocityBoostMult < 1f) + velocityBoostMult += 0.004f; + } + else + { + if (velocityBoostMult > 0f) + velocityBoostMult -= 0.004f; + } + baseVelocity *= 1f + velocityBoostMult; + + // If Apollo can fire projectiles, cannot fire if too close to the target + bool canFire = Vector2.Distance(npc.Center, player.Center) > 320f; + + // Rotation + Vector2 predictionVector = player.velocity * predictionAmt; + Vector2 aimedVector = player.Center + predictionVector - npc.Center; + float rateOfRotation = 0.1f; + Vector2 rotateTowards = player.Center - npc.Center; + bool readyToCharge = AIState == (float)Phase.LineUpChargeCombo && (Vector2.Distance(npc.Center, destination) <= chargeLocationDistanceGateValue || calamityGlobalNPC.newAI[2] > 0f); + if (AIState == (int)Phase.ChargeCombo) + { + rateOfRotation = 0f; + npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; + } + else if (AIState == (float)Phase.LineUpChargeCombo && chargeLocations[1] != default) + { + float x = chargeLocations[1].X - npc.Center.X; + float y = chargeLocations[1].Y - npc.Center.Y; + rotateTowards = Vector2.Normalize(new Vector2(x, y)) * baseVelocity; + } + else + { + float x = player.Center.X + predictionVector.X - npc.Center.X; + float y = player.Center.Y + predictionVector.Y - npc.Center.Y; + rotateTowards = Vector2.Normalize(new Vector2(x, y)) * baseVelocity; + } + + // Do not set this during charge or deathray phases + if (rateOfRotation != 0f) + npc.rotation = npc.rotation.AngleTowards((float)Math.Atan2(rotateTowards.Y, rotateTowards.X) + MathHelper.PiOver2, rateOfRotation); + + // Light + Lighting.AddLight(npc.Center, 0.05f * npc.Opacity, 0.25f * npc.Opacity, 0.15f * npc.Opacity); + + // Despawn if target is dead + if (player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (player.dead) + { + AIState = (float)Phase.Normal; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + + npc.dontTakeDamage = true; + + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 1f; + + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + } + + return; + } + } + + // Cause the charge visual effects to begin while performing or preparing for a combo + if (AIState == (float)Phase.LineUpChargeCombo || AIState == (float)Phase.ChargeCombo) + ChargeComboFlash = MathHelper.Clamp(ChargeComboFlash + 0.08f, 0f, 1f); + + // And have them go away afterwards + else + ChargeComboFlash = MathHelper.Clamp(ChargeComboFlash - 0.1f, 0f, 1f); + + // Set to transition to phase 2 if it hasn't happened yet + if (phase2 && npc.localAI[3] == 0f) + { + AIState = (float)Phase.PhaseTransition; + npc.localAI[3] = 1f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + + // Set frames to phase transition frames, which begin on frame 30 + // Reset the frame counter + npc.frameCounter = 0D; + + // X = 3 sets to frame 27 + frameX = 3; + + // Y = 3 sets to frame 30 + frameY = 3; + } + + // Passive and Immune phases + switch ((int)SecondaryAIState) + { + case (int)SecondaryPhase.Nothing: + + // Spawn the other mechs if Artemis and Apollo are first + if (otherExoMechsAlive == 0) + { + if (spawnOtherExoMechs) + { + // Despawn projectile bullshit + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active) + { + if (projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType()) + { + projectile.Kill(); + projectile.owner = Main.maxPlayers; + } + } + } + + // Set Artemis variables + if (exoMechTwinRedAlive) + { + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[3] < 1f) + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[3] = 1f; + + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.PassiveAndImmune; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; + } + + // Reset everything + if (npc.ai[0] < 10f) + npc.ai[0] = 10f; + npc.ai[0] += 1f; + + if (npc.ai[3] < 1f) + npc.ai[3] = 1f; + + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + + npc.TargetClosest(); + + // Draedon text for the start of phase 2 + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 1f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Spawn the fuckers + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + } + } + } + else + { + // If not spawned first, go to passive state if any other mech is passive or if Artemis and Apollo are under 70% life + // Do not run this if berserk + // Do not run this if any exo mech is dead + if ((anyOtherExoMechPassive || lifeRatio < 0.7f) && !berserk && totalOtherExoMechLifeRatio < 5f) + { + // Set Artemis variables + if (exoMechTwinRedAlive) + { + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.Passive; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; + } + + // Tells Apollo to return to the battle in passive state and reset everything + SecondaryAIState = (float)SecondaryPhase.Passive; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + + npc.TargetClosest(); + } + + // Go passive and immune if one of the other mechs is berserk + // This is only called if two exo mechs are alive in ideal scenarios + // This is not called if Artemis and Apollo and another one or two mechs are berserk + if (otherMechIsBerserk && !berserk) + { + // Despawn projectile bullshit + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active) + { + if (projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType()) + { + projectile.Kill(); + projectile.owner = Main.maxPlayers; + } + } + } + + // Set Artemis variables + if (exoMechTwinRedAlive) + { + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.PassiveAndImmune; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; + } + + // Reset everything + if (npc.ai[0] < 10f) + npc.ai[0] = 10f; + npc.ai[0] += 1f; + + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + + npc.TargetClosest(); + + // Phase 6, when 1 mech goes berserk and the other one leaves + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 5f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + } + + break; + + // Fire projectiles less often, this happens when all 3 mechs are present and attacking + case (int)SecondaryPhase.Passive: + + // Artemis fires lasers while passive + if (exoMechTwinRedAlive) + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[0] = (float)Artemis.Artemis.Phase.Normal; + + // Fire plasma while passive + AIState = (float)Phase.Normal; + + // Enter passive and invincible phase if one of the other exo mechs is berserk + if (otherMechIsBerserk) + { + // Despawn projectile bullshit + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active) + { + if (projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType()) + { + projectile.Kill(); + projectile.owner = Main.maxPlayers; + } + } + } + + // Set Artemis variables + if (exoMechTwinRedAlive) + { + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.PassiveAndImmune; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; + } + + // Reset everything + if (npc.ai[0] < 10f) + npc.ai[0] = 10f; + npc.ai[0] += 1f; + + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + + npc.TargetClosest(); + } + + // If Artemis and Apollo are the first mechs to go berserk + if (berserk) + { + // Set Artemis variables + if (exoMechTwinRedAlive) + { + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.Nothing; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; + } + + // Reset everything + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + + npc.TargetClosest(); + + // Never be passive if berserk + SecondaryAIState = (float)SecondaryPhase.Nothing; + + // Phase 4, when 1 mech goes berserk and the other 2 leave + if (exoWormAlive && exoPrimeAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 3f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + } + + break; + + // Fly above target and become immune + case (int)SecondaryPhase.PassiveAndImmune: + + // Artemis does nothing while immune + if (exoMechTwinRedAlive) + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[0] = (float)Artemis.Artemis.Phase.Normal; + + // Do nothing while immune + AIState = (float)Phase.Normal; + + // Enter the fight again if any of the other exo mechs is below 70% and other mechs aren't berserk + if ((exoWormLifeRatio < 0.7f || exoPrimeLifeRatio < 0.7f) && !otherMechIsBerserk) + { + // Set Artemis variables + if (exoMechTwinRedAlive) + { + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = + totalOtherExoMechLifeRatio > 5f ? (float)Artemis.Artemis.SecondaryPhase.Nothing : (float)Artemis.Artemis.SecondaryPhase.Passive; + + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; + } + + // Tells Artemis and Apollo to return to the battle in passive state and reset everything + // Return to normal phases if one or more mechs have been downed + SecondaryAIState = totalOtherExoMechLifeRatio > 5f ? (float)SecondaryPhase.Nothing : (float)SecondaryPhase.Passive; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + + npc.TargetClosest(); + + // Phase 3, when all 3 mechs attack at the same time + if (exoWormAlive && exoPrimeAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 2f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + } + + // This is here just in case + if (berserk) + { + // Set Artemis variables + if (exoMechTwinRedAlive) + { + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = (float)Artemis.Artemis.SecondaryPhase.Nothing; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[0] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[1] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].localAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[2] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[3] = 0f; + } + + // Reset everything + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + + npc.TargetClosest(); + + // Never be passive if berserk + SecondaryAIState = (float)SecondaryPhase.Nothing; + } + + break; + } + + // Adjust opacity + bool invisiblePhase = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase || AIState == (float)Phase.PhaseTransition; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Attacking phases + switch ((int)AIState) + { + // Fly to the right of the target + case (int)Phase.Normal: + + // Smooth movement towards the location Apollo is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + + // Default animation for 60 frames and then go to telegraph animation + // newAI[3] tells Apollo what animation state it's currently in + bool attacking = calamityGlobalNPC.newAI[3] >= 2f; + bool firingPlasma = attacking && calamityGlobalNPC.newAI[3] + 2f < attackPhaseGateValue; + + // Only increase attack timer if not in immune phase + if (SecondaryAIState != (float)SecondaryPhase.PassiveAndImmune) + calamityGlobalNPC.newAI[2] += 1f; + + if (calamityGlobalNPC.newAI[2] >= defaultAnimationDuration || attacking) + { + if (firingPlasma) + { + // Fire plasma + float divisor = nerfedAttacks ? 60f : lastMechAlive ? 40f : 45f; + float plasmaTimer = calamityGlobalNPC.newAI[3] - 2f; + if (plasmaTimer % divisor == 0f && canFire) + { + pickNewLocation = true; + npc.ai[2] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaCasterFire"), npc.Center); + Vector2 plasmaVelocity = Vector2.Normalize(aimedVector) * projectileVelocity; + Vector2 offset = Vector2.Normalize(plasmaVelocity) * 70f; + Projectile.NewProjectile(npc.Center + offset, plasmaVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); + } + } + } + else + calamityGlobalNPC.newAI[2] = 0f; + + // Enter rocket phase after a certain time has passed + // Enter charge phase if in phase 2 and the localAI[2] variable is set to do so + calamityGlobalNPC.newAI[3] += 1f; + if (lineUpAttack) + { + // Return to normal plasma phase if in passive state + if (SecondaryAIState == (float)SecondaryPhase.Passive) + { + pickNewLocation = true; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + + npc.TargetClosest(); + } + else if (doBigAttack) + { + pickNewLocation = npc.localAI[2] == 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + + if (phase2) + AIState = npc.localAI[2] == 1f ? (float)Phase.LineUpChargeCombo : (float)Phase.RocketBarrage; + else + AIState = (float)Phase.RocketBarrage; + } + } + } + + break; + + // Charge + case (int)Phase.RocketBarrage: + + // Smooth movement towards the location Apollo is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] % (rocketPhaseDuration / numRockets) == 0f && canFire) + { + pickNewLocation = true; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Main.PlaySound(SoundID.Item36, npc.Center); + Vector2 rocketVelocity = Vector2.Normalize(aimedVector) * projectileVelocity * 1.2f; + Vector2 offset = Vector2.Normalize(rocketVelocity) * 70f; + Projectile.NewProjectile(npc.Center + offset, rocketVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); + } + } + + // Reset phase and variables + if (calamityGlobalNPC.newAI[2] >= rocketPhaseDuration) + { + // Go back to normal phase + AIState = (float)Phase.Normal; + npc.localAI[2] = shouldGetBuffedByBerserkPhase ? 1f : 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + } + + break; + + // Get in position for the charge combo, don't do anything else until in position + // Fill up the charge location array with the positions Apollo will charge from + // Create telegraph beams between the charge location array positions + case (int)Phase.LineUpChargeCombo: + + if (!readyToCharge) + { + // Smooth movement towards the location Apollo is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + } + else + { + // Save the charge locations and create telegraph beams + int type = ModContent.ProjectileType(); + + for (int i = 0; i < maxCharges; i++) + { + if (chargeLocations[i] == default) + { + switch (i) + { + case 0: + chargeLocations[i] = npc.Center; + break; + case 1: + chargeLocations[i] = chargeLocations[0] + new Vector2(chargeComboXOffset, -chargeComboYOffset * 2f); + break; + case 2: + chargeLocations[i] = chargeLocations[1] + new Vector2(chargeComboXOffset, chargeComboYOffset * 2f); + break; + case 3: + chargeLocations[i] = chargeLocations[2] + new Vector2(chargeComboXOffset, -chargeComboYOffset * 2f); + break; + default: + break; + } + + if (i == 0) + { + // Draw telegraph beams + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int telegraph = Projectile.NewProjectile(chargeLocations[0], Vector2.Zero, type, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); + if (Main.projectile.IndexInRange(telegraph)) + { + Main.projectile[telegraph].ModProjectile().ChargePositions = chargeLocations; + Main.projectile[telegraph].netUpdate = true; + } + } + + // Play a charge sound + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + } + } + } + + // Don't move + npc.velocity = Vector2.Zero; + + // Go to charge phase, create lightning bolts in the sky, and reset + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= timeToLineUpCharge) + { + ExoMechsSky.CreateLightningBolt(10); + + AIState = (float)Phase.ChargeCombo; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + } + } + + break; + + // Charge to several locations almost instantly (Apollo doesn't teleport here, he's just moving very fast :D) + case (int)Phase.ChargeCombo: + + // Set charge velocity and fire halos of plasma bolts + if (npc.localAI[2] == 0f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ELRFire"), npc.Center); + npc.velocity = Vector2.Normalize(chargeLocations[(int)calamityGlobalNPC.newAI[2] + 1] - chargeLocations[(int)calamityGlobalNPC.newAI[2]]) * chargeVelocity; + npc.localAI[2] = 1f; + npc.netUpdate = true; + npc.netSpam -= 5; + + // Plasma bolts on charge + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int totalProjectiles = CalamityWorld.malice ? 12 : 8; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + int damage = (int)(npc.GetProjectileDamage(ModContent.ProjectileType()) * 0.8); + float velocity = 1f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, velocity2, type, damage, 0f, Main.myPlayer); + } + } + + // Dust rings + for (int i = 0; i < 200; i++) + { + float dustVelocity = 16f; + if (i < 150) + dustVelocity = 12f; + if (i < 100) + dustVelocity = 8f; + if (i < 50) + dustVelocity = 4f; + + int dust1 = Dust.NewDust(npc.Center, 6, 6, Main.rand.NextBool(2) ? 107 : 110, 0f, 0f, 100, default, 1f); + float dustVelX = Main.dust[dust1].velocity.X; + float dustVelY = Main.dust[dust1].velocity.Y; + + if (dustVelX == 0f && dustVelY == 0f) + dustVelX = 1f; + + float dustVelocity2 = (float)Math.Sqrt(dustVelX * dustVelX + dustVelY * dustVelY); + dustVelocity2 = dustVelocity / dustVelocity2; + dustVelX *= dustVelocity2; + dustVelY *= dustVelocity2; + + float scale = 1f; + switch ((int)dustVelocity) + { + case 4: + scale = 1.2f; + break; + case 8: + scale = 1.1f; + break; + case 12: + scale = 1f; + break; + case 16: + scale = 0.9f; + break; + default: + break; + } + + Dust dust2 = Main.dust[dust1]; + dust2.velocity *= 0.5f; + dust2.velocity.X = dust2.velocity.X + dustVelX; + dust2.velocity.Y = dust2.velocity.Y + dustVelY; + dust2.scale = scale; + dust2.noGravity = true; + } + } + + // Initiate next charge if close enough to next charge location + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= chargeTime) + { + // Set Apollo's location to the next charge location + npc.Center = chargeLocations[(int)calamityGlobalNPC.newAI[2] + 1]; + + // Reset velocity to 0 + npc.velocity = Vector2.Zero; + + // Increase newAI[2] whenever a charge ends + calamityGlobalNPC.newAI[2] += 1f; + calamityGlobalNPC.newAI[3] = 0f; + npc.localAI[2] = 0f; + } + + // Reset phase and variables + if (calamityGlobalNPC.newAI[2] >= maxCharges - 1) + { + pickNewLocation = true; + AIState = (float)Phase.Normal; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + ChargeComboFlash = 0f; + + // Tell Apollo and Artemis to swap positions + if (npc.ai[0] < 10f) + npc.ai[0] = 10f; + npc.ai[0] += 1f; + + // Change Y offset for the next charge combo + npc.ai[2] = Main.rand.Next(2); + + // Tell Artemis to not fire lasers for a short time while swapping positions + npc.ai[3] = 61f; + + npc.TargetClosest(); + npc.netUpdate = true; + } + + break; + + // Phase transition animation, that's all this exists for + case (int)Phase.PhaseTransition: + + // Smooth movement towards the location Apollo is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + + // Shoot lens gore at the target at the proper time + if (calamityGlobalNPC.newAI[2] == lensPopTime) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"), npc.Center); + Vector2 lensDirection = Vector2.Normalize(aimedVector); + Vector2 offset = lensDirection * 70f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(npc.Center + offset, lensDirection * 24f, ModContent.ProjectileType(), 0, 0f); + } + + // Reset phase and variables + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= phaseTransitionDuration) + { + pickNewLocation = true; + AIState = (float)Phase.Normal; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.TargetClosest(); + } + + break; + } + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { - // Check if the other exo mechs are alive - bool exoWormAlive = false; - bool exoPrimeAlive = false; - if (CalamityGlobalNPC.draedonExoMechWorm != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) - exoWormAlive = true; - } - if (CalamityGlobalNPC.draedonExoMechPrime != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - exoPrimeAlive = true; - } + cooldownSlot = 1; - // Check for Draedon - bool draedonAlive = false; - if (CalamityGlobalNPC.draedon != -1) - { - if (Main.npc[CalamityGlobalNPC.draedon].active) - draedonAlive = true; - } + Rectangle targetHitbox = target.Hitbox; - // Phase 5, when 1 mech dies and the other 2 return to fight - if (exoWormAlive && exoPrimeAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 4f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - // Phase 7, when 1 mech dies and the final one returns to the fight - else if (exoWormAlive || exoPrimeAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 6f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - // Mark Exo Mechs as dead and drop loot - else - AresBody.DropExoMechLoot(npc, (int)AresBody.MechType.ArtemisAndApollo); - } + return minDist <= 100f && npc.Opacity == 1f && AIState == (float)Phase.ChargeCombo; + } - // Needs edits - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + scale = 2f; + return null; + } - if (npc.life <= 0) - { - for (int num193 = 0; num193 < 2; num193++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } + public override void FindFrame(int frameHeight) + { + // Use telegraph frames before each attack + bool phase2 = npc.life / (float)npc.lifeMax < 0.6f; + npc.frameCounter += 1D; + if (AIState == (float)Phase.PhaseTransition) + { + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Apollo/Apollo1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Apollo/Apollo2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Apollo/Apollo3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Apollo/Apollo4"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Apollo/Apollo5"), 1f); - } - } + // Increment the Y frame + frameY++; - public override bool CheckDead() - { - // Kill Artemis if he's still alive when Apollo dies - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC nPC = Main.npc[i]; - if (nPC.active && nPC.type == ModContent.NPCType() && nPC.life > 0) - { - nPC.life = 0; - nPC.HitEffect(0, 10.0); - nPC.checkDead(); - nPC.active = false; - } - } - return true; - } + // Reset the Y frame if greater than 9 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + } + } + else + { + if (AIState == (float)Phase.Normal) + { + int frameLimit = phase2 ? (npc.Calamity().newAI[3] == 0f ? normalFrameLimit_Phase2 : npc.Calamity().newAI[3] == 1f ? chargeUpFrameLimit_Phase2 : attackFrameLimit_Phase2) : + (npc.Calamity().newAI[3] == 0f ? normalFrameLimit_Phase1 : npc.Calamity().newAI[3] == 1f ? chargeUpFrameLimit_Phase1 : attackFrameLimit_Phase1); - public override bool CheckActive() => false; + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 9 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames + int currentFrame = (frameX * maxFramesY) + frameY; + if (currentFrame > frameLimit) + frameX = frameY = phase2 ? (npc.Calamity().newAI[3] == 0f ? 6 : npc.Calamity().newAI[3] == 1f ? 7 : 8) : (npc.Calamity().newAI[3] == 0f ? 0 : npc.Calamity().newAI[3] == 1f ? 1 : 2); + } + } + else if (AIState == (float)Phase.RocketBarrage || AIState == (float)Phase.LineUpChargeCombo || AIState == (float)Phase.ChargeCombo) + { + int frameLimit = phase2 ? attackFrameLimit_Phase2 : attackFrameLimit_Phase1; + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 9 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames + int currentFrame = (frameX * maxFramesY) + frameY; + if (currentFrame > frameLimit) + frameX = frameY = phase2 ? 8 : 2; + } + } + } + } + + public float FlameTrailWidthFunction(float completionRatio) => MathHelper.SmoothStep(21f, 8f, completionRatio) * ChargeComboFlash; + + public float FlameTrailWidthFunctionBig(float completionRatio) => MathHelper.SmoothStep(34f, 12f, completionRatio) * ChargeComboFlash; + + public float RibbonTrailWidthFunction(float completionRatio) + { + float baseWidth = Utils.InverseLerp(1f, 0.54f, completionRatio, true) * 5f; + float endTipWidth = CalamityUtils.Convert01To010(Utils.InverseLerp(0.96f, 0.89f, completionRatio, true)) * 2.4f; + return baseWidth + endTipWidth; + } + + public Color FlameTrailColorFunction(float completionRatio) + { + float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true); + Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.27f); + Color middleColor = Color.Lerp(Color.Orange, Color.ForestGreen, 0.74f); + Color endColor = Color.Lime; + return CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * ChargeComboFlash * trailOpacity; + } + + public Color FlameTrailColorFunctionBig(float completionRatio) + { + float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true) * 0.56f; + Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.25f); + Color middleColor = Color.Lerp(Color.Blue, Color.White, 0.35f); + Color endColor = Color.Lerp(Color.DarkBlue, Color.White, 0.47f); + Color color = CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * ChargeComboFlash * trailOpacity; + color.A = 0; + return color; + } + + public Color RibbonTrailColorFunction(float completionRatio) + { + Color startingColor = new Color(34, 40, 48); + Color endColor = new Color(40, 160, 32); + return Color.Lerp(startingColor, endColor, (float)Math.Pow(completionRatio, 1.5D)) * npc.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + // Declare the trail drawers if they have yet to be defined. + if (ChargeFlameTrail is null) + ChargeFlameTrail = new PrimitiveTrail(FlameTrailWidthFunction, FlameTrailColorFunction, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]); + + if (ChargeFlameTrailBig is null) + ChargeFlameTrailBig = new PrimitiveTrail(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]); + + if (RibbonTrail is null) + RibbonTrail = new PrimitiveTrail(RibbonTrailWidthFunction, RibbonTrailColorFunction); + + // Prepare the flame trail shader with its map texture. + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak")); + + int numAfterimages = ChargeComboFlash > 0f ? 0 : 5; + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 origin = npc.Size * 0.5f; + Vector2 center = npc.Center - Main.screenPosition; + Color afterimageBaseColor = Color.White; + + // Draws a single instance of a regular, non-glowmask based Artemis. + // This is created to allow easy duplication of them when drawing the charge. + void drawInstance(Vector2 drawOffset, Color baseColor) + { + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = baseColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + afterimageCenter += drawOffset; + spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); + } + } + + spriteBatch.Draw(texture, center + drawOffset, frame, npc.GetAlpha(baseColor), npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); + } + + // Draw ribbons near the main thruster + for (int direction = -1; direction <= 1; direction += 2) + { + Vector2 ribbonOffset = -Vector2.UnitY.RotatedBy(npc.rotation) * 14f; + ribbonOffset += Vector2.UnitX.RotatedBy(npc.rotation) * direction * 26f; + + float currentSegmentRotation = npc.rotation; + List ribbonDrawPositions = new List(); + for (int i = 0; i < 12; i++) + { + float ribbonCompletionRatio = i / 12f; + float wrappedAngularOffset = MathHelper.WrapAngle(npc.oldRot[i + 1] - currentSegmentRotation) * 0.3f; + float segmentRotationOffset = MathHelper.Clamp(wrappedAngularOffset, -0.12f, 0.12f); + + // Add a sinusoidal offset that goes based on time and completion ratio to create a waving-flag-like effect. + // This is dampened for the first few points to prevent weird offsets. It is also dampened by high velocity. + float sinusoidalRotationOffset = (float)Math.Sin(ribbonCompletionRatio * 2.22f + Main.GlobalTime * 3.4f) * 1.36f; + float sinusoidalRotationOffsetFactor = Utils.InverseLerp(0f, 0.37f, ribbonCompletionRatio, true) * direction * 24f; + sinusoidalRotationOffsetFactor *= Utils.InverseLerp(24f, 16f, npc.velocity.Length(), true); + + Vector2 sinusoidalOffset = Vector2.UnitY.RotatedBy(npc.rotation + sinusoidalRotationOffset) * sinusoidalRotationOffsetFactor; + Vector2 ribbonSegmentOffset = Vector2.UnitY.RotatedBy(currentSegmentRotation) * ribbonCompletionRatio * 540f + sinusoidalOffset; + ribbonDrawPositions.Add(npc.Center + ribbonSegmentOffset + ribbonOffset); + + currentSegmentRotation += segmentRotationOffset; + } + RibbonTrail.Draw(ribbonDrawPositions, -Main.screenPosition, 66); + } + + int instanceCount = (int)MathHelper.Lerp(1f, 15f, ChargeComboFlash); + Color baseInstanceColor = Color.Lerp(drawColor, Color.White, ChargeComboFlash); + baseInstanceColor.A = (byte)(int)(255f - ChargeComboFlash * 255f); + + spriteBatch.EnterShaderRegion(); + + drawInstance(Vector2.Zero, baseInstanceColor); + if (instanceCount > 1) + { + baseInstanceColor *= 0.04f; + float backAfterimageOffset = MathHelper.SmoothStep(0f, 2f, ChargeComboFlash); + for (int i = 0; i < instanceCount; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / instanceCount + Main.GlobalTime * 0.8f).ToRotationVector2() * backAfterimageOffset; + drawInstance(drawOffset, baseInstanceColor); + } + } + + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Apollo/ApolloGlow"); + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); + } + } + + spriteBatch.Draw(texture, center, frame, Color.White * npc.Opacity, npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); + + spriteBatch.ExitShaderRegion(); + + // Draw a flame trail on the thrusters if needed. This happens during charges. + if (ChargeComboFlash > 0f) + { + for (int direction = -1; direction <= 1; direction++) + { + Vector2 baseDrawOffset = new Vector2(0f, direction == 0f ? 18f : 60f).RotatedBy(npc.rotation); + baseDrawOffset += new Vector2(direction * 64f, 0f).RotatedBy(npc.rotation); + + float backFlameLength = direction == 0f ? 700f : 190f; + Vector2 drawStart = npc.Center + baseDrawOffset; + Vector2 drawEnd = drawStart - (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * ChargeComboFlash * backFlameLength; + Vector2[] drawPositions = new Vector2[] + { + drawStart, + drawEnd + }; + + if (direction == 0) + { + for (int i = 0; i < 4; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 8f; + ChargeFlameTrailBig.Draw(drawPositions, drawOffset - Main.screenPosition, 70); + } + } + else + ChargeFlameTrail.Draw(drawPositions, -Main.screenPosition, 70); + } + } + + return false; + } + + public override bool SpecialNPCLoot() + { + int closestSegmentID = DropHelper.FindClosestWormSegment(npc, + ModContent.NPCType(), + ModContent.NPCType()); + npc.position = Main.npc[closestSegmentID].position; + return false; + } + + public override void BossLoot(ref string name, ref int potionType) + { + potionType = ModContent.ItemType(); + } + + public override void NPCLoot() + { + // Check if the other exo mechs are alive + bool exoWormAlive = false; + bool exoPrimeAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + exoWormAlive = true; + } + if (CalamityGlobalNPC.draedonExoMechPrime != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + exoPrimeAlive = true; + } + + // Check for Draedon + bool draedonAlive = false; + if (CalamityGlobalNPC.draedon != -1) + { + if (Main.npc[CalamityGlobalNPC.draedon].active) + draedonAlive = true; + } + + // Phase 5, when 1 mech dies and the other 2 return to fight + if (exoWormAlive && exoPrimeAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 4f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + + // Phase 7, when 1 mech dies and the final one returns to the fight + else if (exoWormAlive || exoPrimeAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 6f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + + // Mark Exo Mechs as dead and drop loot + else + AresBody.DropExoMechLoot(npc, (int)AresBody.MechType.ArtemisAndApollo); + } + + // Needs edits + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Apollo/Apollo1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Apollo/Apollo2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Apollo/Apollo3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Apollo/Apollo4"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Apollo/Apollo5"), 1f); + } + } + + public override bool CheckDead() + { + // Kill Artemis if he's still alive when Apollo dies + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC nPC = Main.npc[i]; + if (nPC.active && nPC.type == ModContent.NPCType() && nPC.life > 0) + { + nPC.life = 0; + nPC.HitEffect(0, 10.0); + nPC.checkDead(); + nPC.active = false; + } + } + return true; + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); + } } } diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index 0e9665d2a2..9b34f391d0 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -26,1371 +26,1371 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Ares { - [AutoloadBossHead] - public class AresBody : ModNPC - { - // Used for loot - public enum MechType - { - Ares = 0, - Thanatos = 1, - ArtemisAndApollo = 2 - } - - public enum Phase - { - Normal = 0, - Deathrays = 1 - } - - public float AIState - { - get => npc.Calamity().newAI[0]; - set => npc.Calamity().newAI[0] = value; - } - - public enum SecondaryPhase - { - Nothing = 0, - Passive = 1, - PassiveAndImmune = 2 - } - - public float SecondaryAIState - { - get => npc.Calamity().newAI[1]; - set => npc.Calamity().newAI[1] = value; - } - - public enum Enraged - { - No = 0, - Yes = 1 - } - - public float EnragedState - { - get => npc.localAI[1]; - set => npc.localAI[1] = value; - } - - public float VelocityBoostMult - { - get => npc.localAI[2]; - set => npc.localAI[2] = value; - } - - public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); - - // Spawn rate for enrage steam - public const int ventCloudSpawnRate = 3; - - // Spawn rate for telegraph particles - public const int telegraphParticlesSpawnRate = 5; - - // Number of frames on the X and Y axis - private const int maxFramesX = 6; - private const int maxFramesY = 8; - - // Counters for frames on the X and Y axis - private int frameX = 0; - private int frameY = 0; - - // Frame limit per animation, these are the specific frames where each animation ends - private const int normalFrameLimit = 11; - private const int firstStageDeathrayChargeFrameLimit = 23; - private const int secondStageDeathrayChargeFrameLimit = 35; - private const int finalStageDeathrayChargeFrameLimit = 47; - - // Default life ratio for the other mechs - private const float defaultLifeRatio = 5f; - - // Variable used to stop the arm spawning loop - private bool armsSpawned = false; - - // Total duration of the deathray telegraph - public const float deathrayTelegraphDuration_Normal = 150f; - public const float deathrayTelegraphDuration_Expert = 120f; - public const float deathrayTelegraphDuration_Rev = 105f; - public const float deathrayTelegraphDuration_Death = 90f; - public const float deathrayTelegraphDuration_Malice = 60f; - - // Total duration of the deathrays - public const float deathrayDuration = 600f; - - // Max distance from the target before they are unable to hear sound telegraphs - private const float soundDistance = 4800f; - - // Timers for the Tesla and Plasma Arms so that they fire at the proper times when they spawn and enter new phases - public const float plasmaArmStartTimer = 260f; - public const float teslaArmStartTimer = 80f; - - // Drawers for arm segments. - public PrimitiveTrail LightningDrawer; - public PrimitiveTrail LightningBackgroundDrawer; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("XF-09 Ares"); - NPCID.Sets.TrailingMode[npc.type] = 3; - NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; - } - - public override void SetDefaults() - { - npc.npcSlots = 5f; - npc.damage = 100; - npc.width = 220; - npc.height = 252; - npc.defense = 100; - npc.DR_NERD(0.35f); - npc.LifeMaxNERB(1250000, 1495000, 500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; - aiType = -1; - npc.Opacity = 0f; - npc.knockBackResist = 0f; - npc.value = Item.buyPrice(15, 0, 0, 0); - npc.noGravity = true; - npc.noTileCollide = true; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; - npc.netAlways = true; - npc.boss = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; - bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } - - public override void BossHeadSlot(ref int index) - { - if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) - index = -1; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(frameX); - writer.Write(frameY); - writer.Write(armsSpawned); - writer.Write(npc.dontTakeDamage); - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - frameX = reader.ReadInt32(); - frameY = reader.ReadInt32(); - armsSpawned = reader.ReadBoolean(); - npc.dontTakeDamage = reader.ReadBoolean(); - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - CalamityGlobalNPC.draedonExoMechPrime = npc.whoAmI; - - npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Spawn arms - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!armsSpawned && npc.ai[0] == 0f) - { - int totalArms = 4; - int Previous = npc.whoAmI; - for (int i = 0; i < totalArms; i++) - { - int lol = 0; - switch (i) - { - case 0: - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - break; - case 1: - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - Main.npc[lol].Calamity().newAI[1] = plasmaArmStartTimer; - break; - case 2: - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - Main.npc[lol].Calamity().newAI[1] = teslaArmStartTimer; - break; - case 3: - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - break; - default: - break; - } - - Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].ai[2] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); - Previous = lol; - } - armsSpawned = true; - } - } - - if (npc.life > Main.npc[(int)npc.ai[0]].life) - npc.life = Main.npc[(int)npc.ai[0]].life; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Check if the other exo mechs are alive - int otherExoMechsAlive = 0; - bool exoWormAlive = false; - bool exoTwinsAlive = false; - if (CalamityGlobalNPC.draedonExoMechWorm != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) - { - otherExoMechsAlive++; - exoWormAlive = true; - } - } - - // There is no point in checking for the other twin because they have linked HP - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - { - otherExoMechsAlive++; - exoTwinsAlive = true; - } - } - - // These are 5 by default to avoid triggering passive phases after the other mechs are dead - float exoWormLifeRatio = defaultLifeRatio; - float exoTwinsLifeRatio = defaultLifeRatio; - if (exoWormAlive) - exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; - if (exoTwinsAlive) - exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; - float totalOtherExoMechLifeRatio = exoWormLifeRatio + exoTwinsLifeRatio; - - // Check if any of the other mechs are passive - bool exoWormPassive = false; - bool exoTwinsPassive = false; - if (exoWormAlive) - exoWormPassive = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive; - if (exoTwinsAlive) - exoTwinsPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] == (float)Apollo.Apollo.SecondaryPhase.Passive; - bool anyOtherExoMechPassive = exoWormPassive || exoTwinsPassive; - - // Check if any of the other mechs were spawned first - bool exoWormWasFirst = false; - bool exoTwinsWereFirst = false; - if (exoWormAlive) - exoWormWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].ai[3] == 1f; - if (exoTwinsAlive) - exoTwinsWereFirst = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ai[3] == 1f; - bool otherExoMechWasFirst = exoWormWasFirst || exoTwinsWereFirst; - - // Check for Draedon - bool draedonAlive = false; - if (CalamityGlobalNPC.draedon != -1) - { - if (Main.npc[CalamityGlobalNPC.draedon].active) - draedonAlive = true; - } - - // Prevent mechs from being respawned - if (otherExoMechWasFirst) - { - if (npc.ai[3] < 1f) - npc.ai[3] = 1f; - } - - // Phases - bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; - - // If Ares doesn't go berserk - bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; - - // Whether Ares should be buffed while in berserk phase - bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - // Target variable - Player player = Main.player[npc.target]; - - // General AI pattern - // 0 - Fly above target - // 1 - Fly towards the target, slow down when close enough - // 2 - Fire deathrays from telegraph locations to avoid cheap hits and rotate them around for 10 seconds while the plasma and tesla arms fire projectiles to make dodging difficult - // 3 - Go passive and fly above the target while firing less projectiles - // 4 - Go passive, immune and invisible; fly above the target and do nothing until next phase - - // Attack patterns - // If spawned first - // Phase 1 - 0 - // Phase 2 - 4 - // Phase 3 - 3 - - // If berserk, this is the last phase of Ares - // Phase 4 - 1, 2 - - // If not berserk - // Phase 4 - 4 - // Phase 5 - 0 - - // If berserk, this is the last phase of Ares - // Phase 6 - 1, 2 - - // If not berserk - // Phase 6 - 4 - - // Berserk, final phase of Ares - // Phase 7 - 1, 2 - - // Rotation - npc.rotation = npc.velocity.X * 0.003f; - - // Light and enrage check - if (EnragedState == (float)Enraged.Yes) - { - Lighting.AddLight(npc.Center, 0.5f * npc.Opacity, 0f, 0f); - npc.Calamity().CurrentlyEnraged = true; - } - else - { - float lightScale = 510f; - Lighting.AddLight(npc.Center, Main.DiscoR / lightScale * npc.Opacity, Main.DiscoG / lightScale * npc.Opacity, Main.DiscoB / lightScale * npc.Opacity); - } - - // Despawn if target is dead - if (player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (player.dead) - { - AIState = (float)Phase.Normal; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.dontTakeDamage = true; - - npc.velocity.Y -= 1f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 1f; - - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - - return; - } - } - - // Default vector to fly to - Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X, player.Center.Y - 800f) : AIState != (float)Phase.Deathrays ? new Vector2(player.Center.X, player.Center.Y - 425f) : player.Center; - - // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); - float baseVelocity = (EnragedState == (float)Enraged.Yes ? 28f : 20f) * baseVelocityMult; - float baseAcceleration = shouldGetBuffedByBerserkPhase ? 1.25f : 1f; - float decelerationVelocityMult = 0.85f; - - // Distance where Ares stops moving - float movementDistanceGateValue = 50f; - - // Scale up velocity over time if too far from destination - Vector2 distanceFromDestination = destination - npc.Center; - if (distanceFromDestination.Length() > movementDistanceGateValue && AIState != (float)Phase.Deathrays) - { - if (VelocityBoostMult < 1f) - VelocityBoostMult += 0.004f; - } - else - { - if (VelocityBoostMult > 0f) - VelocityBoostMult -= 0.004f; - } - baseVelocity *= 1f + VelocityBoostMult; - - // Distance from target - float distanceFromTarget = Vector2.Distance(npc.Center, player.Center); - - // Gate values - float deathrayPhaseGateValue = lastMechAlive ? 420f : 600f; - float deathrayDistanceGateValue = 480f; - - // Enter deathray phase again more quickly if enraged - if (EnragedState == (float)Enraged.Yes) - deathrayPhaseGateValue *= 0.75f; - - // Emit steam while enraged - SmokeDrawer.ParticleSpawnRate = 9999999; - if (EnragedState == (float)Enraged.Yes) - { - SmokeDrawer.ParticleSpawnRate = ventCloudSpawnRate; - SmokeDrawer.BaseMoveRotation = npc.rotation + MathHelper.PiOver2; - SmokeDrawer.SpawnAreaCompactness = 80f; - - // Increase DR during enrage - npc.Calamity().DR = 0.85f; - } - else - npc.Calamity().DR = 0.35f; - - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = EnragedState == (float)Enraged.Yes; - - SmokeDrawer.Update(); - - // Passive and Immune phases - switch ((int)SecondaryAIState) - { - case (int)SecondaryPhase.Nothing: - - // Spawn the other mechs if Ares is first - if (otherExoMechsAlive == 0) - { - if (spawnOtherExoMechs) - { - // Reset everything - if (npc.ai[3] < 1f) - npc.ai[3] = 1f; - - SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; - npc.TargetClosest(); - - // Draedon text for the start of phase 2 - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 1f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Spawn the fuckers - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - } - } - } - else - { - // If not spawned first, go to passive state if any other mech is passive or if Ares is under 70% life - // Do not run this if berserk - // Do not run this if any exo mech is dead - if ((anyOtherExoMechPassive || lifeRatio < 0.7f) && !berserk && totalOtherExoMechLifeRatio < 5f) - { - // Tells Ares to return to the battle in passive state and reset everything - SecondaryAIState = (float)SecondaryPhase.Passive; - npc.TargetClosest(); - } - - // Go passive and immune if one of the other mechs is berserk - // This is only called if two exo mechs are alive in ideal scenarios - // This is not called if Ares and another one or two mechs are berserk - if (otherMechIsBerserk && !berserk) - { - // Reset everything - if (npc.ai[3] < 2f) - npc.ai[3] = 2f; - - SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; - npc.TargetClosest(); - - // Phase 6, when 1 mech goes berserk and the other one leaves - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 5f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - } - - break; - - // Fire projectiles less often, this happens when all 3 mechs are present and attacking - case (int)SecondaryPhase.Passive: - - // Enter passive and invincible phase if one of the other exo mechs is berserk - if (otherMechIsBerserk) - { - // Reset everything - if (npc.ai[3] < 2f) - npc.ai[3] = 2f; - - SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; - npc.TargetClosest(); - } - - // If Ares is the first mech to go berserk - if (berserk) - { - // Reset everything - npc.TargetClosest(); - - // Never be passive if berserk - SecondaryAIState = (float)SecondaryPhase.Nothing; - - // Phase 4, when 1 mech goes berserk and the other 2 leave - if (exoWormAlive && exoTwinsAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 3f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - } - - break; - - // Fly above target and become immune - case (int)SecondaryPhase.PassiveAndImmune: - - // Enter the fight again if any of the other exo mechs is below 70% and other mechs aren't berserk - if ((exoWormLifeRatio < 0.7f || exoTwinsLifeRatio < 0.7f) && !otherMechIsBerserk) - { - // Tells Ares to return to the battle in passive state and reset everything - // Return to normal phases if one or more mechs have been downed - SecondaryAIState = totalOtherExoMechLifeRatio > 5f ? (float)SecondaryPhase.Nothing : (float)SecondaryPhase.Passive; - npc.TargetClosest(); - - // Phase 3, when all 3 mechs attack at the same time - if (exoWormAlive && exoTwinsAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 2f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - } - - // This is here just in case - if (berserk) - { - // Reset everything - npc.TargetClosest(); - - // Never be passive if berserk - SecondaryAIState = (float)SecondaryPhase.Nothing; - } - - break; - } - - // Adjust opacity - bool invisiblePhase = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune; - npc.dontTakeDamage = invisiblePhase; - if (!invisiblePhase) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } - - // Attacking phases - switch ((int)AIState) - { - // Fly above the target - case (int)Phase.Normal: - - // Smooth movement towards the location Ares is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - - if (shouldGetBuffedByBerserkPhase) - { - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] > deathrayPhaseGateValue) - { - // Despawn stupid fucking dog shit to avoid screaming the word "cunt" - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType()) - { - if (projectile.timeLeft > 15) - projectile.timeLeft = 15; - - if (projectile.type == ModContent.ProjectileType()) - { - projectile.ai[0] = -1f; - projectile.ai[1] = -1f; - } - else if (projectile.type == ModContent.ProjectileType()) - projectile.ai[0] = -1f; - } - else if (projectile.type == ModContent.ProjectileType()) - projectile.Kill(); - } - } - - calamityGlobalNPC.newAI[2] = 0f; - AIState = (float)Phase.Deathrays; - - // Cancel enrage state if Ares is enraged - if (EnragedState == (float)Enraged.Yes) - EnragedState = (float)Enraged.No; - } - } - - break; - - // Move close to target, reduce velocity when close enough, create telegraph beams, fire deathrays - case (int)Phase.Deathrays: - - if (distanceFromTarget > deathrayDistanceGateValue && calamityGlobalNPC.newAI[3] == 0f) - { - Vector2 desiredVelocity2 = Vector2.Normalize(distanceFromDestination) * baseVelocity; - npc.SimpleFlyMovement(desiredVelocity2, baseAcceleration); - } - else - { - // Enrage if the target is more than the deathray length away - if (distanceFromTarget > 2480f && EnragedState == (float)Enraged.No) - { - // Play enrage sound - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AresEnraged"), - (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y); - } - - // Draedon comments on how foolish it is to run - if (Main.netMode != NetmodeID.MultiplayerClient) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonAresEnrageText", new Color(155, 255, 255)); - - // Enrage - EnragedState = (float)Enraged.Yes; - } - - calamityGlobalNPC.newAI[3] = 1f; - npc.velocity *= decelerationVelocityMult; - - int totalProjectiles = malice ? 12 : death ? 10 : revenge ? 9 : expertMode ? 8 : 6; - float radians = MathHelper.TwoPi / totalProjectiles; - bool normalLaserRotation = npc.localAI[0] % 2f == 0f; - float velocity = 6f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalLaserRotation ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); - spinningPoint.Normalize(); - - float deathrayTelegraphDuration = malice ? deathrayTelegraphDuration_Malice : death ? deathrayTelegraphDuration_Death : - revenge ? deathrayTelegraphDuration_Rev : expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal; - - calamityGlobalNPC.newAI[2] += (EnragedState == (float)Enraged.Yes && calamityGlobalNPC.newAI[2] % 2f == 0f) ? 2f : 1f; - if (calamityGlobalNPC.newAI[2] < deathrayTelegraphDuration) - { - // Fire deathray telegraph beams - if (calamityGlobalNPC.newAI[2] == 1f) - { - // Despawn stupid fucking dog shit to avoid screaming the word "cunt", again - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType()) - { - if (projectile.timeLeft > 15) - projectile.timeLeft = 15; - - if (projectile.type == ModContent.ProjectileType()) - { - projectile.ai[0] = -1f; - projectile.ai[1] = -1f; - } - else if (projectile.type == ModContent.ProjectileType()) - projectile.ai[0] = -1f; - } - else if (projectile.type == ModContent.ProjectileType()) - projectile.Kill(); - } - } - - // Set frames to deathray charge up frames, which begin on frame 12 - // Reset the frame counter - npc.frameCounter = 0D; - - // X = 1 sets to frame 8 - frameX = 1; - - // Y = 4 sets to frame 12 - frameY = 4; - - // Create a bunch of lightning bolts in the sky - ExoMechsSky.CreateLightningBolt(12); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - int type = ModContent.ProjectileType(); - Vector2 spawnPoint = npc.Center + new Vector2(-1f, 23f); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 laserVelocity = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(spawnPoint + Vector2.Normalize(laserVelocity) * 17f, laserVelocity, type, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - else - { - // Fire deathrays - if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"), npc.Center); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 spawnPoint = npc.Center + new Vector2(-1f, 23f); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 laserVelocity = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(spawnPoint + Vector2.Normalize(laserVelocity) * 35f, laserVelocity, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - - if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) - { - AIState = (float)Phase.Normal; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - - /* Normal positions: Laser = 0, Tesla = 1, Plasma = 2, Gauss = 3 - * 0 = Laser = 0, Tesla = 1, Plasma = 2, Gauss = 3 - * 1 = Laser = 3, Tesla = 1, Plasma = 2, Gauss = 0 - * 2 = Laser = 3, Tesla = 2, Plasma = 1, Gauss = 0 - * 3 = Laser = 0, Tesla = 2, Plasma = 1, Gauss = 3 - * 4 = Laser = 0, Tesla = 1, Plasma = 2, Gauss = 3 - * 5 = Laser = 3, Tesla = 1, Plasma = 2, Gauss = 0 - */ - if (revenge) - { - npc.ai[3] += 1f + Main.rand.Next(2); - if (npc.ai[3] > 5f) - npc.ai[3] -= 4f; - } - else if (expertMode) - { - npc.ai[3] += Main.rand.Next(2); - if (npc.ai[3] > 3f) - npc.ai[3] -= 2f; - } - - npc.localAI[0] += 1f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - break; - } - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - scale = 2f; - return null; - } - - public override void FindFrame(int frameHeight) - { - // Use telegraph frames when using deathrays - npc.frameCounter += 1D; - if (AIState == (float)Phase.Normal || npc.Calamity().newAI[3] == 0f) - { - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 8 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames to frame 0 - if ((frameX * maxFramesY) + frameY > normalFrameLimit) - frameX = frameY = 0; - } - } - else - { - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 8 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames to frame 36, the start of the deathray firing animation loop - if ((frameX * maxFramesY) + frameY > finalStageDeathrayChargeFrameLimit) - frameX = frameY = 4; - } - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - // Draw the enrage smoke behind Ares - SmokeDrawer.DrawSet(npc.Center); - - // Draw arms. - int laserArm = NPC.FindFirstNPC(ModContent.NPCType()); - int gaussArm = NPC.FindFirstNPC(ModContent.NPCType()); - int teslaArm = NPC.FindFirstNPC(ModContent.NPCType()); - int plasmaArm = NPC.FindFirstNPC(ModContent.NPCType()); - Color afterimageBaseColor = EnragedState == (float)Enraged.Yes ? Color.Red : Color.White; - Color armGlowmaskColor = afterimageBaseColor; - armGlowmaskColor.A = 184; - - (int, bool)[] armProperties = new (int, bool)[] - { - // Laser arm. - (-1, true), - - // Gauss arm. - (1, true), - - // Telsa arm. - (-1, false), - - // Plasma arm. - (1, false), - }; - - // Swap out arm positions as necessary. - // Normal Position: Laser, Tesla, Plasma, Laser - switch ((int)npc.ai[3]) - { - case 0: - if (AIState == (int)Phase.Deathrays) - { - CalamityUtils.SwapArrayIndices(ref armProperties, 1, 3); - CalamityUtils.SwapArrayIndices(ref armProperties, 0, 1); - } - break; - case 1: - CalamityUtils.SwapArrayIndices(ref armProperties, 0, 1); - if (AIState == (int)Phase.Deathrays) - CalamityUtils.SwapArrayIndices(ref armProperties, 0, 3); - break; - case 2: - if (AIState != (int)Phase.Deathrays) - { - CalamityUtils.SwapArrayIndices(ref armProperties, 0, 1); - CalamityUtils.SwapArrayIndices(ref armProperties, 2, 3); - } - else - { - CalamityUtils.SwapArrayIndices(ref armProperties, 0, 1); - CalamityUtils.SwapArrayIndices(ref armProperties, 2, 3); - CalamityUtils.SwapArrayIndices(ref armProperties, 0, 2); - } - break; - case 3: - CalamityUtils.SwapArrayIndices(ref armProperties, 2, 3); - break; - case 4: - CalamityUtils.SwapArrayIndices(ref armProperties, 1, 3); - break; - case 5: - if (AIState != (int)Phase.Deathrays) - CalamityUtils.SwapArrayIndices(ref armProperties, 0, 1); - else - { - CalamityUtils.SwapArrayIndices(ref armProperties, 0, 3); - CalamityUtils.SwapArrayIndices(ref armProperties, 1, 3); - } - break; - } - - if (laserArm != -1) - DrawArm(spriteBatch, Main.npc[laserArm].Center, armGlowmaskColor, armProperties[0].Item1, armProperties[0].Item2); - if (gaussArm != -1) - DrawArm(spriteBatch, Main.npc[gaussArm].Center, armGlowmaskColor, armProperties[1].Item1, armProperties[1].Item2); - if (teslaArm != -1) - DrawArm(spriteBatch, Main.npc[teslaArm].Center, armGlowmaskColor, armProperties[2].Item1, armProperties[2].Item2); - if (plasmaArm != -1) - DrawArm(spriteBatch, Main.npc[plasmaArm].Center, armGlowmaskColor, armProperties[3].Item1, armProperties[3].Item2); - - Texture2D texture = Main.npcTexture[npc.type]; - Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); - int numAfterimages = 5; - - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, SpriteEffects.None, 0f); - } - } - - Vector2 center = npc.Center - Main.screenPosition; - spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); - - texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresBodyGlow"); - - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, SpriteEffects.None, 0f); - } - } - - spriteBatch.Draw(texture, center, frame, afterimageBaseColor * npc.Opacity, npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); - - return false; - } - internal float WidthFunction(float completionRatio) - { - return MathHelper.Lerp(0.5f, 1.3f, (float)Math.Sin(MathHelper.Pi * completionRatio)) * npc.scale; - } - - internal Color ColorFunction(float completionRatio) - { - Color baseColor1 = EnragedState == (float)Enraged.Yes ? Color.Red : Color.Cyan; - Color baseColor2 = EnragedState == (float)Enraged.Yes ? Color.IndianRed : Color.Cyan; - - float fadeToWhite = MathHelper.Lerp(0f, 0.65f, (float)Math.Sin(MathHelper.TwoPi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f); - Color baseColor = Color.Lerp(baseColor1, Color.White, fadeToWhite); - Color color = Color.Lerp(baseColor, baseColor2, ((float)Math.Sin(MathHelper.Pi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f) * 0.8f) * 0.65f; - color.A = 84; - if (npc.Opacity <= 0f) - return Color.Transparent; - return color; - } - - internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 4f; - - public Color BackgroundColorFunction(float completionRatio) - { - Color backgroundColor = EnragedState == (float)Enraged.Yes ? Color.Crimson : Color.CornflowerBlue; - Color color = backgroundColor * npc.Opacity * 0.4f; - return color; - } - - public void DrawArm(SpriteBatch spriteBatch, Vector2 handPosition, Color glowmaskColor, int direction, bool backArm) - { - if (LightningDrawer is null) - LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); - if (LightningBackgroundDrawer is null) - LightningBackgroundDrawer = new PrimitiveTrail(BackgroundWidthFunction, BackgroundColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); - - SpriteEffects spriteDirection = direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - float distanceFromHand = npc.Distance(handPosition); - float frameTime = Main.GlobalTime * 0.9f % 1f; - - // Draw back arms. - if (backArm) - { - Texture2D shoulderTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopShoulder"); - Texture2D armTexture1 = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopPart1"); - Texture2D armSegmentTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopSegment"); - Texture2D armTexture2 = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopPart2"); - - Texture2D shoulderGlowmask = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopShoulderGlow"); - Texture2D armSegmentGlowmask = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopSegmentGlow"); - Texture2D armGlowmask2 = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopPart2Glow"); - - Vector2 shoulderDrawPosition = npc.Center + new Vector2(direction * 176f, -100f); - Vector2 arm1DrawPosition = shoulderDrawPosition + new Vector2(direction * (shoulderTexture.Width + 16f), 10f); - Vector2 armSegmentDrawPosition = arm1DrawPosition; - - // Determine frames. - Rectangle shoulderFrame = shoulderTexture.Frame(1, 9, 0, (int)(frameTime * 9f)); - Rectangle armSegmentFrame = armSegmentTexture.Frame(1, 9, 0, (int)(frameTime * 9f)); - Rectangle arm2Frame = armTexture2.Frame(1, 9, 0, (int)(frameTime * 9f)); - - Vector2 arm1Origin = armTexture1.Size() * new Vector2((direction == 1).ToInt(), 0.5f); - Vector2 arm2Origin = arm2Frame.Size() * new Vector2((direction == 1).ToInt(), 0.5f); - - float arm1Rotation = MathHelper.Clamp(distanceFromHand * direction / 1200f, -0.12f, 0.12f); - float arm2Rotation = (handPosition - armSegmentDrawPosition - Vector2.UnitY * 12f).ToRotation(); - if (direction == 1) - arm2Rotation += MathHelper.Pi; - float armSegmentRotation = arm2Rotation; - - // Handle offsets for points. - armSegmentDrawPosition += arm1Rotation.ToRotationVector2() * direction * -14f; - armSegmentDrawPosition -= arm2Rotation.ToRotationVector2() * direction * 20f; - Vector2 arm2DrawPosition = armSegmentDrawPosition; - arm2DrawPosition -= arm2Rotation.ToRotationVector2() * direction * 40f; - arm2DrawPosition += (arm2Rotation - MathHelper.PiOver2).ToRotationVector2() * 14f; - - // Calculate colors. - Color shoulderLightColor = npc.GetAlpha(Lighting.GetColor((int)shoulderDrawPosition.X / 16, (int)shoulderDrawPosition.Y / 16)); - Color arm1LightColor = npc.GetAlpha(Lighting.GetColor((int)arm1DrawPosition.X / 16, (int)arm1DrawPosition.Y / 16)); - Color armSegmentLightColor = npc.GetAlpha(Lighting.GetColor((int)armSegmentDrawPosition.X / 16, (int)armSegmentDrawPosition.Y / 16)); - Color arm2LightColor = npc.GetAlpha(Lighting.GetColor((int)arm2DrawPosition.X / 16, (int)arm2DrawPosition.Y / 16)); - Color glowmaskAlphaColor = npc.GetAlpha(glowmaskColor); - - // Draw electricity between arms. - if (npc.Opacity > 0f) - { - List arm2ElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(armSegmentDrawPosition, arm2DrawPosition + arm2Rotation.ToRotationVector2() * -direction * 20f, 250290787); - LightningBackgroundDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90); - LightningDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90); - - // Draw electricity between the final arm and the hand. - List handElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm2DrawPosition - arm2Rotation.ToRotationVector2() * direction * 100f, handPosition, 27182); - LightningBackgroundDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90); - LightningDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90); - } - - shoulderDrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; - arm1DrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; - armSegmentDrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; - arm2DrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; - - spriteBatch.Draw(armTexture1, arm1DrawPosition, null, arm1LightColor, arm1Rotation, arm1Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); - spriteBatch.Draw(shoulderTexture, shoulderDrawPosition, shoulderFrame, shoulderLightColor, 0f, shoulderFrame.Size() * 0.5f, npc.scale, spriteDirection, 0f); - spriteBatch.Draw(shoulderGlowmask, shoulderDrawPosition, shoulderFrame, glowmaskAlphaColor, 0f, shoulderFrame.Size() * 0.5f, npc.scale, spriteDirection, 0f); - spriteBatch.Draw(armSegmentTexture, armSegmentDrawPosition, armSegmentFrame, armSegmentLightColor, armSegmentRotation, armSegmentFrame.Size() * 0.5f, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); - spriteBatch.Draw(armSegmentGlowmask, armSegmentDrawPosition, armSegmentFrame, glowmaskAlphaColor, armSegmentRotation, armSegmentFrame.Size() * 0.5f, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); - spriteBatch.Draw(armTexture2, arm2DrawPosition, arm2Frame, arm2LightColor, arm2Rotation, arm2Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipVertically, 0f); - spriteBatch.Draw(armGlowmask2, arm2DrawPosition, arm2Frame, glowmaskAlphaColor, arm2Rotation, arm2Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipVertically, 0f); - } - else - { - Texture2D shoulderTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmShoulder"); - Texture2D connectorTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmConnector"); - Texture2D armTexture1 = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmPart1"); - Texture2D armTexture2 = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmPart2"); - - Texture2D shoulderGlowmask = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmShoulderGlow"); - Texture2D armTexture1Glowmask = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmPart1Glow"); - Texture2D armTexture2Glowmask = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmPart2Glow"); - - Vector2 shoulderDrawPosition = npc.Center + new Vector2(direction * 110f, -54f); - Vector2 connectorDrawPosition = shoulderDrawPosition + new Vector2(direction * 20f, 32f); - Vector2 arm1DrawPosition = shoulderDrawPosition + Vector2.UnitX * direction * 20f; - - // Determine frames. - Rectangle arm1Frame = armTexture1.Frame(1, 9, 0, (int)(frameTime * 9f)); - Rectangle shoulderFrame = shoulderTexture.Frame(1, 9, 0, (int)(frameTime * 9f)); - Rectangle arm2Frame = armTexture2.Frame(1, 9, 0, (int)(frameTime * 9f)); - - Vector2 arm1Origin = arm1Frame.Size() * new Vector2((direction == 1).ToInt(), 0.5f); - Vector2 arm2Origin = arm2Frame.Size() * new Vector2((direction == 1).ToInt(), 0.5f); - - float arm1Rotation = CalamityUtils.WrapAngle90Degrees((handPosition - shoulderDrawPosition).ToRotation()) * 0.5f; - connectorDrawPosition += arm1Rotation.ToRotationVector2() * direction * -26f; - arm1DrawPosition += arm1Rotation.ToRotationVector2() * direction * (armTexture1.Width - 14f); - float arm2Rotation = CalamityUtils.WrapAngle90Degrees((handPosition - arm1DrawPosition).ToRotation()); - - Vector2 arm2DrawPosition = arm1DrawPosition + arm2Rotation.ToRotationVector2() * direction * (armTexture2.Width + 16f) - Vector2.UnitY * 16f; - - // Calculate colors. - Color shoulderLightColor = npc.GetAlpha(Lighting.GetColor((int)shoulderDrawPosition.X / 16, (int)shoulderDrawPosition.Y / 16)); - Color arm1LightColor = npc.GetAlpha(Lighting.GetColor((int)arm1DrawPosition.X / 16, (int)arm1DrawPosition.Y / 16)); - Color arm2LightColor = npc.GetAlpha(Lighting.GetColor((int)arm2DrawPosition.X / 16, (int)arm2DrawPosition.Y / 16)); - Color glowmaskAlphaColor = npc.GetAlpha(glowmaskColor); - - // Draw electricity between arms. - if (npc.Opacity > 0f) - { - List arm2ElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm1DrawPosition - arm2Rotation.ToRotationVector2() * direction * 10f, arm1DrawPosition + arm2Rotation.ToRotationVector2() * direction * 20f, 31416); - LightningBackgroundDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90); - LightningDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90); - - // Draw electricity between the final arm and the hand. - List handElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm2DrawPosition - arm2Rotation.ToRotationVector2() * direction * 20f, handPosition, 27182); - LightningBackgroundDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90); - LightningDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90); - } - - shoulderDrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; - connectorDrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; - arm1DrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; - arm2DrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; - - spriteBatch.Draw(shoulderTexture, shoulderDrawPosition, shoulderFrame, shoulderLightColor, arm1Rotation, shoulderFrame.Size() * 0.5f, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); - spriteBatch.Draw(shoulderGlowmask, shoulderDrawPosition, shoulderFrame, glowmaskAlphaColor, arm1Rotation, shoulderFrame.Size() * 0.5f, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); - spriteBatch.Draw(connectorTexture, connectorDrawPosition, null, shoulderLightColor, 0f, connectorTexture.Size() * 0.5f, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); - spriteBatch.Draw(armTexture1, arm1DrawPosition, arm1Frame, arm1LightColor, arm1Rotation, arm1Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); - spriteBatch.Draw(armTexture1Glowmask, arm1DrawPosition, arm1Frame, glowmaskAlphaColor, arm1Rotation, arm1Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); - spriteBatch.Draw(armTexture2, arm2DrawPosition, arm2Frame, arm2LightColor, arm2Rotation, arm2Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); - spriteBatch.Draw(armTexture2Glowmask, arm2DrawPosition, arm2Frame, glowmaskAlphaColor, arm2Rotation, arm2Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); - } - } - - public override void BossLoot(ref string name, ref int potionType) - { - potionType = ModContent.ItemType(); - } - - public override void NPCLoot() - { - // Check if the other exo mechs are alive - bool exoWormAlive = false; - bool exoTwinsAlive = false; - if (CalamityGlobalNPC.draedonExoMechWorm != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) - exoWormAlive = true; - } - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - exoTwinsAlive = true; - } - - // Check for Draedon - bool draedonAlive = false; - if (CalamityGlobalNPC.draedon != -1) - { - if (Main.npc[CalamityGlobalNPC.draedon].active) - draedonAlive = true; - } - - // Phase 5, when 1 mech dies and the other 2 return to fight - if (exoWormAlive && exoTwinsAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 4f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - - // Phase 7, when 1 mech dies and the final one returns to the fight - else if (exoWormAlive || exoTwinsAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 6f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - - // Mark Exo Mechs as dead and drop loot - else - DropExoMechLoot(npc, (int)MechType.Ares); - } - - public static void DropExoMechLoot(NPC npc, int mechType) - { - // Dropped before the downed variable is set to true - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedExoMechs); - - switch (mechType) - { - case (int)MechType.Ares: - - DropHelper.DropItem(npc, ModContent.ItemType()); - - CalamityWorld.downedAres = true; - CalamityWorld.downedExoMechs = true; - CalamityNetcode.SyncWorld(); - - break; - - case (int)MechType.Thanatos: - - DropHelper.DropItem(npc, ModContent.ItemType()); - - CalamityWorld.downedThanatos = true; - CalamityWorld.downedExoMechs = true; - CalamityNetcode.SyncWorld(); - - break; - - case (int)MechType.ArtemisAndApollo: - - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - - CalamityWorld.downedArtemisAndApollo = true; - CalamityWorld.downedExoMechs = true; - CalamityNetcode.SyncWorld(); - - break; - } - - CalamityGlobalNPC.SetNewBossJustDowned(npc); - - DropHelper.DropBags(npc); - - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - // Materials - DropHelper.DropItem(npc, ModContent.ItemType(), true, 24, 32); - - // Weapons - // Higher chance due to how the drops work - float w = DropHelper.NormalWeaponDropRateFloat * 2f; - if (CalamityWorld.downedAres) - { - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - } - if (CalamityWorld.downedThanatos) - { - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - } - if (CalamityWorld.downedArtemisAndApollo) - { - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); - } - - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); - DropHelper.DropItem(npc, ModContent.ItemType()); - - // Vanity - // Higher chance due to how the drops work - float maskDropRate = 1f / 3.5f; - if (CalamityWorld.downedThanatos) - DropHelper.DropItemChance(npc, ModContent.ItemType(), maskDropRate); - - if (CalamityWorld.downedArtemisAndApollo) - { - DropHelper.DropItemChance(npc, ModContent.ItemType(), maskDropRate); - DropHelper.DropItemChance(npc, ModContent.ItemType(), maskDropRate); - } - - if (CalamityWorld.downedAres) - DropHelper.DropItemChance(npc, ModContent.ItemType(), maskDropRate); - - DropHelper.DropItemChance(npc, ModContent.ItemType(), maskDropRate); - } - } - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); - - if (npc.life <= 0) - { - for (int num193 = 0; num193 < 2; num193++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody4"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody5"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody6"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody7"), 1f); - } - } - - public override bool CheckActive() => false; - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * 0.8f); - } - } + [AutoloadBossHead] + public class AresBody : ModNPC + { + // Used for loot + public enum MechType + { + Ares = 0, + Thanatos = 1, + ArtemisAndApollo = 2 + } + + public enum Phase + { + Normal = 0, + Deathrays = 1 + } + + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } + + public enum SecondaryPhase + { + Nothing = 0, + Passive = 1, + PassiveAndImmune = 2 + } + + public float SecondaryAIState + { + get => npc.Calamity().newAI[1]; + set => npc.Calamity().newAI[1] = value; + } + + public enum Enraged + { + No = 0, + Yes = 1 + } + + public float EnragedState + { + get => npc.localAI[1]; + set => npc.localAI[1] = value; + } + + public float VelocityBoostMult + { + get => npc.localAI[2]; + set => npc.localAI[2] = value; + } + + public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); + + // Spawn rate for enrage steam + public const int ventCloudSpawnRate = 3; + + // Spawn rate for telegraph particles + public const int telegraphParticlesSpawnRate = 5; + + // Number of frames on the X and Y axis + private const int maxFramesX = 6; + private const int maxFramesY = 8; + + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; + + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit = 11; + private const int firstStageDeathrayChargeFrameLimit = 23; + private const int secondStageDeathrayChargeFrameLimit = 35; + private const int finalStageDeathrayChargeFrameLimit = 47; + + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; + + // Variable used to stop the arm spawning loop + private bool armsSpawned = false; + + // Total duration of the deathray telegraph + public const float deathrayTelegraphDuration_Normal = 150f; + public const float deathrayTelegraphDuration_Expert = 120f; + public const float deathrayTelegraphDuration_Rev = 105f; + public const float deathrayTelegraphDuration_Death = 90f; + public const float deathrayTelegraphDuration_Malice = 60f; + + // Total duration of the deathrays + public const float deathrayDuration = 600f; + + // Max distance from the target before they are unable to hear sound telegraphs + private const float soundDistance = 4800f; + + // Timers for the Tesla and Plasma Arms so that they fire at the proper times when they spawn and enter new phases + public const float plasmaArmStartTimer = 260f; + public const float teslaArmStartTimer = 80f; + + // Drawers for arm segments. + public PrimitiveTrail LightningDrawer; + public PrimitiveTrail LightningBackgroundDrawer; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("XF-09 Ares"); + NPCID.Sets.TrailingMode[npc.type] = 3; + NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; + } + + public override void SetDefaults() + { + npc.npcSlots = 5f; + npc.damage = 100; + npc.width = 220; + npc.height = 252; + npc.defense = 100; + npc.DR_NERD(0.35f); + npc.LifeMaxNERB(1250000, 1495000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; + aiType = -1; + npc.Opacity = 0f; + npc.knockBackResist = 0f; + npc.value = Item.buyPrice(15, 0, 0, 0); + npc.noGravity = true; + npc.noTileCollide = true; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; + npc.boss = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; + bossBag = ModContent.ItemType(); + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } + + public override void BossHeadSlot(ref int index) + { + if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) + index = -1; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(frameX); + writer.Write(frameY); + writer.Write(armsSpawned); + writer.Write(npc.dontTakeDamage); + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + frameX = reader.ReadInt32(); + frameY = reader.ReadInt32(); + armsSpawned = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + CalamityGlobalNPC.draedonExoMechPrime = npc.whoAmI; + + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + // Spawn arms + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (!armsSpawned && npc.ai[0] == 0f) + { + int totalArms = 4; + int Previous = npc.whoAmI; + for (int i = 0; i < totalArms; i++) + { + int lol = 0; + switch (i) + { + case 0: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + break; + case 1: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + Main.npc[lol].Calamity().newAI[1] = plasmaArmStartTimer; + break; + case 2: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + Main.npc[lol].Calamity().newAI[1] = teslaArmStartTimer; + break; + case 3: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + break; + default: + break; + } + + Main.npc[lol].realLife = npc.whoAmI; + Main.npc[lol].ai[2] = npc.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); + Previous = lol; + } + armsSpawned = true; + } + } + + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoWormAlive = false; + bool exoTwinsAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + otherExoMechsAlive++; + exoWormAlive = true; + } + } + + // There is no point in checking for the other twin because they have linked HP + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoTwinsAlive = true; + } + } + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoTwinsLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoTwinsAlive) + exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + float totalOtherExoMechLifeRatio = exoWormLifeRatio + exoTwinsLifeRatio; + + // Check if any of the other mechs are passive + bool exoWormPassive = false; + bool exoTwinsPassive = false; + if (exoWormAlive) + exoWormPassive = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive; + if (exoTwinsAlive) + exoTwinsPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] == (float)Apollo.Apollo.SecondaryPhase.Passive; + bool anyOtherExoMechPassive = exoWormPassive || exoTwinsPassive; + + // Check if any of the other mechs were spawned first + bool exoWormWasFirst = false; + bool exoTwinsWereFirst = false; + if (exoWormAlive) + exoWormWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].ai[3] == 1f; + if (exoTwinsAlive) + exoTwinsWereFirst = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ai[3] == 1f; + bool otherExoMechWasFirst = exoWormWasFirst || exoTwinsWereFirst; + + // Check for Draedon + bool draedonAlive = false; + if (CalamityGlobalNPC.draedon != -1) + { + if (Main.npc[CalamityGlobalNPC.draedon].active) + draedonAlive = true; + } + + // Prevent mechs from being respawned + if (otherExoMechWasFirst) + { + if (npc.ai[3] < 1f) + npc.ai[3] = 1f; + } + + // Phases + bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; + + // If Ares doesn't go berserk + bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; + + // Whether Ares should be buffed while in berserk phase + bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + // Target variable + Player player = Main.player[npc.target]; + + // General AI pattern + // 0 - Fly above target + // 1 - Fly towards the target, slow down when close enough + // 2 - Fire deathrays from telegraph locations to avoid cheap hits and rotate them around for 10 seconds while the plasma and tesla arms fire projectiles to make dodging difficult + // 3 - Go passive and fly above the target while firing less projectiles + // 4 - Go passive, immune and invisible; fly above the target and do nothing until next phase + + // Attack patterns + // If spawned first + // Phase 1 - 0 + // Phase 2 - 4 + // Phase 3 - 3 + + // If berserk, this is the last phase of Ares + // Phase 4 - 1, 2 + + // If not berserk + // Phase 4 - 4 + // Phase 5 - 0 + + // If berserk, this is the last phase of Ares + // Phase 6 - 1, 2 + + // If not berserk + // Phase 6 - 4 + + // Berserk, final phase of Ares + // Phase 7 - 1, 2 + + // Rotation + npc.rotation = npc.velocity.X * 0.003f; + + // Light and enrage check + if (EnragedState == (float)Enraged.Yes) + { + Lighting.AddLight(npc.Center, 0.5f * npc.Opacity, 0f, 0f); + npc.Calamity().CurrentlyEnraged = true; + } + else + { + float lightScale = 510f; + Lighting.AddLight(npc.Center, Main.DiscoR / lightScale * npc.Opacity, Main.DiscoG / lightScale * npc.Opacity, Main.DiscoB / lightScale * npc.Opacity); + } + + // Despawn if target is dead + if (player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (player.dead) + { + AIState = (float)Phase.Normal; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.dontTakeDamage = true; + + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 1f; + + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + } + + return; + } + } + + // Default vector to fly to + Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X, player.Center.Y - 800f) : AIState != (float)Phase.Deathrays ? new Vector2(player.Center.X, player.Center.Y - 425f) : player.Center; + + // Velocity and acceleration values + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocity = (EnragedState == (float)Enraged.Yes ? 28f : 20f) * baseVelocityMult; + float baseAcceleration = shouldGetBuffedByBerserkPhase ? 1.25f : 1f; + float decelerationVelocityMult = 0.85f; + + // Distance where Ares stops moving + float movementDistanceGateValue = 50f; + + // Scale up velocity over time if too far from destination + Vector2 distanceFromDestination = destination - npc.Center; + if (distanceFromDestination.Length() > movementDistanceGateValue && AIState != (float)Phase.Deathrays) + { + if (VelocityBoostMult < 1f) + VelocityBoostMult += 0.004f; + } + else + { + if (VelocityBoostMult > 0f) + VelocityBoostMult -= 0.004f; + } + baseVelocity *= 1f + VelocityBoostMult; + + // Distance from target + float distanceFromTarget = Vector2.Distance(npc.Center, player.Center); + + // Gate values + float deathrayPhaseGateValue = lastMechAlive ? 420f : 600f; + float deathrayDistanceGateValue = 480f; + + // Enter deathray phase again more quickly if enraged + if (EnragedState == (float)Enraged.Yes) + deathrayPhaseGateValue *= 0.75f; + + // Emit steam while enraged + SmokeDrawer.ParticleSpawnRate = 9999999; + if (EnragedState == (float)Enraged.Yes) + { + SmokeDrawer.ParticleSpawnRate = ventCloudSpawnRate; + SmokeDrawer.BaseMoveRotation = npc.rotation + MathHelper.PiOver2; + SmokeDrawer.SpawnAreaCompactness = 80f; + + // Increase DR during enrage + npc.Calamity().DR = 0.85f; + } + else + npc.Calamity().DR = 0.35f; + + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = EnragedState == (float)Enraged.Yes; + + SmokeDrawer.Update(); + + // Passive and Immune phases + switch ((int)SecondaryAIState) + { + case (int)SecondaryPhase.Nothing: + + // Spawn the other mechs if Ares is first + if (otherExoMechsAlive == 0) + { + if (spawnOtherExoMechs) + { + // Reset everything + if (npc.ai[3] < 1f) + npc.ai[3] = 1f; + + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.TargetClosest(); + + // Draedon text for the start of phase 2 + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 1f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Spawn the fuckers + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + } + } + } + else + { + // If not spawned first, go to passive state if any other mech is passive or if Ares is under 70% life + // Do not run this if berserk + // Do not run this if any exo mech is dead + if ((anyOtherExoMechPassive || lifeRatio < 0.7f) && !berserk && totalOtherExoMechLifeRatio < 5f) + { + // Tells Ares to return to the battle in passive state and reset everything + SecondaryAIState = (float)SecondaryPhase.Passive; + npc.TargetClosest(); + } + + // Go passive and immune if one of the other mechs is berserk + // This is only called if two exo mechs are alive in ideal scenarios + // This is not called if Ares and another one or two mechs are berserk + if (otherMechIsBerserk && !berserk) + { + // Reset everything + if (npc.ai[3] < 2f) + npc.ai[3] = 2f; + + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.TargetClosest(); + + // Phase 6, when 1 mech goes berserk and the other one leaves + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 5f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + } + + break; + + // Fire projectiles less often, this happens when all 3 mechs are present and attacking + case (int)SecondaryPhase.Passive: + + // Enter passive and invincible phase if one of the other exo mechs is berserk + if (otherMechIsBerserk) + { + // Reset everything + if (npc.ai[3] < 2f) + npc.ai[3] = 2f; + + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.TargetClosest(); + } + + // If Ares is the first mech to go berserk + if (berserk) + { + // Reset everything + npc.TargetClosest(); + + // Never be passive if berserk + SecondaryAIState = (float)SecondaryPhase.Nothing; + + // Phase 4, when 1 mech goes berserk and the other 2 leave + if (exoWormAlive && exoTwinsAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 3f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + } + + break; + + // Fly above target and become immune + case (int)SecondaryPhase.PassiveAndImmune: + + // Enter the fight again if any of the other exo mechs is below 70% and other mechs aren't berserk + if ((exoWormLifeRatio < 0.7f || exoTwinsLifeRatio < 0.7f) && !otherMechIsBerserk) + { + // Tells Ares to return to the battle in passive state and reset everything + // Return to normal phases if one or more mechs have been downed + SecondaryAIState = totalOtherExoMechLifeRatio > 5f ? (float)SecondaryPhase.Nothing : (float)SecondaryPhase.Passive; + npc.TargetClosest(); + + // Phase 3, when all 3 mechs attack at the same time + if (exoWormAlive && exoTwinsAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 2f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + } + + // This is here just in case + if (berserk) + { + // Reset everything + npc.TargetClosest(); + + // Never be passive if berserk + SecondaryAIState = (float)SecondaryPhase.Nothing; + } + + break; + } + + // Adjust opacity + bool invisiblePhase = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Attacking phases + switch ((int)AIState) + { + // Fly above the target + case (int)Phase.Normal: + + // Smooth movement towards the location Ares is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + + if (shouldGetBuffedByBerserkPhase) + { + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] > deathrayPhaseGateValue) + { + // Despawn stupid fucking dog shit to avoid screaming the word "cunt" + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active) + { + if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType()) + { + if (projectile.timeLeft > 15) + projectile.timeLeft = 15; + + if (projectile.type == ModContent.ProjectileType()) + { + projectile.ai[0] = -1f; + projectile.ai[1] = -1f; + } + else if (projectile.type == ModContent.ProjectileType()) + projectile.ai[0] = -1f; + } + else if (projectile.type == ModContent.ProjectileType()) + projectile.Kill(); + } + } + + calamityGlobalNPC.newAI[2] = 0f; + AIState = (float)Phase.Deathrays; + + // Cancel enrage state if Ares is enraged + if (EnragedState == (float)Enraged.Yes) + EnragedState = (float)Enraged.No; + } + } + + break; + + // Move close to target, reduce velocity when close enough, create telegraph beams, fire deathrays + case (int)Phase.Deathrays: + + if (distanceFromTarget > deathrayDistanceGateValue && calamityGlobalNPC.newAI[3] == 0f) + { + Vector2 desiredVelocity2 = Vector2.Normalize(distanceFromDestination) * baseVelocity; + npc.SimpleFlyMovement(desiredVelocity2, baseAcceleration); + } + else + { + // Enrage if the target is more than the deathray length away + if (distanceFromTarget > 2480f && EnragedState == (float)Enraged.No) + { + // Play enrage sound + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AresEnraged"), + (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y); + } + + // Draedon comments on how foolish it is to run + if (Main.netMode != NetmodeID.MultiplayerClient) + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonAresEnrageText", new Color(155, 255, 255)); + + // Enrage + EnragedState = (float)Enraged.Yes; + } + + calamityGlobalNPC.newAI[3] = 1f; + npc.velocity *= decelerationVelocityMult; + + int totalProjectiles = malice ? 12 : death ? 10 : revenge ? 9 : expertMode ? 8 : 6; + float radians = MathHelper.TwoPi / totalProjectiles; + bool normalLaserRotation = npc.localAI[0] % 2f == 0f; + float velocity = 6f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = normalLaserRotation ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); + spinningPoint.Normalize(); + + float deathrayTelegraphDuration = malice ? deathrayTelegraphDuration_Malice : death ? deathrayTelegraphDuration_Death : + revenge ? deathrayTelegraphDuration_Rev : expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal; + + calamityGlobalNPC.newAI[2] += (EnragedState == (float)Enraged.Yes && calamityGlobalNPC.newAI[2] % 2f == 0f) ? 2f : 1f; + if (calamityGlobalNPC.newAI[2] < deathrayTelegraphDuration) + { + // Fire deathray telegraph beams + if (calamityGlobalNPC.newAI[2] == 1f) + { + // Despawn stupid fucking dog shit to avoid screaming the word "cunt", again + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active) + { + if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType()) + { + if (projectile.timeLeft > 15) + projectile.timeLeft = 15; + + if (projectile.type == ModContent.ProjectileType()) + { + projectile.ai[0] = -1f; + projectile.ai[1] = -1f; + } + else if (projectile.type == ModContent.ProjectileType()) + projectile.ai[0] = -1f; + } + else if (projectile.type == ModContent.ProjectileType()) + projectile.Kill(); + } + } + + // Set frames to deathray charge up frames, which begin on frame 12 + // Reset the frame counter + npc.frameCounter = 0D; + + // X = 1 sets to frame 8 + frameX = 1; + + // Y = 4 sets to frame 12 + frameY = 4; + + // Create a bunch of lightning bolts in the sky + ExoMechsSky.CreateLightningBolt(12); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + int type = ModContent.ProjectileType(); + Vector2 spawnPoint = npc.Center + new Vector2(-1f, 23f); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 laserVelocity = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(spawnPoint + Vector2.Normalize(laserVelocity) * 17f, laserVelocity, type, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + } + else + { + // Fire deathrays + if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"), npc.Center); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Vector2 spawnPoint = npc.Center + new Vector2(-1f, 23f); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 laserVelocity = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(spawnPoint + Vector2.Normalize(laserVelocity) * 35f, laserVelocity, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + } + + if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) + { + AIState = (float)Phase.Normal; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + + /* Normal positions: Laser = 0, Tesla = 1, Plasma = 2, Gauss = 3 + * 0 = Laser = 0, Tesla = 1, Plasma = 2, Gauss = 3 + * 1 = Laser = 3, Tesla = 1, Plasma = 2, Gauss = 0 + * 2 = Laser = 3, Tesla = 2, Plasma = 1, Gauss = 0 + * 3 = Laser = 0, Tesla = 2, Plasma = 1, Gauss = 3 + * 4 = Laser = 0, Tesla = 1, Plasma = 2, Gauss = 3 + * 5 = Laser = 3, Tesla = 1, Plasma = 2, Gauss = 0 + */ + if (revenge) + { + npc.ai[3] += 1f + Main.rand.Next(2); + if (npc.ai[3] > 5f) + npc.ai[3] -= 4f; + } + else if (expertMode) + { + npc.ai[3] += Main.rand.Next(2); + if (npc.ai[3] > 3f) + npc.ai[3] -= 2f; + } + + npc.localAI[0] += 1f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + + break; + } + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + scale = 2f; + return null; + } + + public override void FindFrame(int frameHeight) + { + // Use telegraph frames when using deathrays + npc.frameCounter += 1D; + if (AIState == (float)Phase.Normal || npc.Calamity().newAI[3] == 0f) + { + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 8 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames to frame 0 + if ((frameX * maxFramesY) + frameY > normalFrameLimit) + frameX = frameY = 0; + } + } + else + { + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 8 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames to frame 36, the start of the deathray firing animation loop + if ((frameX * maxFramesY) + frameY > finalStageDeathrayChargeFrameLimit) + frameX = frameY = 4; + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + // Draw the enrage smoke behind Ares + SmokeDrawer.DrawSet(npc.Center); + + // Draw arms. + int laserArm = NPC.FindFirstNPC(ModContent.NPCType()); + int gaussArm = NPC.FindFirstNPC(ModContent.NPCType()); + int teslaArm = NPC.FindFirstNPC(ModContent.NPCType()); + int plasmaArm = NPC.FindFirstNPC(ModContent.NPCType()); + Color afterimageBaseColor = EnragedState == (float)Enraged.Yes ? Color.Red : Color.White; + Color armGlowmaskColor = afterimageBaseColor; + armGlowmaskColor.A = 184; + + (int, bool)[] armProperties = new (int, bool)[] + { + // Laser arm. + (-1, true), + + // Gauss arm. + (1, true), + + // Telsa arm. + (-1, false), + + // Plasma arm. + (1, false), + }; + + // Swap out arm positions as necessary. + // Normal Position: Laser, Tesla, Plasma, Laser + switch ((int)npc.ai[3]) + { + case 0: + if (AIState == (int)Phase.Deathrays) + { + CalamityUtils.SwapArrayIndices(ref armProperties, 1, 3); + CalamityUtils.SwapArrayIndices(ref armProperties, 0, 1); + } + break; + case 1: + CalamityUtils.SwapArrayIndices(ref armProperties, 0, 1); + if (AIState == (int)Phase.Deathrays) + CalamityUtils.SwapArrayIndices(ref armProperties, 0, 3); + break; + case 2: + if (AIState != (int)Phase.Deathrays) + { + CalamityUtils.SwapArrayIndices(ref armProperties, 0, 1); + CalamityUtils.SwapArrayIndices(ref armProperties, 2, 3); + } + else + { + CalamityUtils.SwapArrayIndices(ref armProperties, 0, 1); + CalamityUtils.SwapArrayIndices(ref armProperties, 2, 3); + CalamityUtils.SwapArrayIndices(ref armProperties, 0, 2); + } + break; + case 3: + CalamityUtils.SwapArrayIndices(ref armProperties, 2, 3); + break; + case 4: + CalamityUtils.SwapArrayIndices(ref armProperties, 1, 3); + break; + case 5: + if (AIState != (int)Phase.Deathrays) + CalamityUtils.SwapArrayIndices(ref armProperties, 0, 1); + else + { + CalamityUtils.SwapArrayIndices(ref armProperties, 0, 3); + CalamityUtils.SwapArrayIndices(ref armProperties, 1, 3); + } + break; + } + + if (laserArm != -1) + DrawArm(spriteBatch, Main.npc[laserArm].Center, armGlowmaskColor, armProperties[0].Item1, armProperties[0].Item2); + if (gaussArm != -1) + DrawArm(spriteBatch, Main.npc[gaussArm].Center, armGlowmaskColor, armProperties[1].Item1, armProperties[1].Item2); + if (teslaArm != -1) + DrawArm(spriteBatch, Main.npc[teslaArm].Center, armGlowmaskColor, armProperties[2].Item1, armProperties[2].Item2); + if (plasmaArm != -1) + DrawArm(spriteBatch, Main.npc[plasmaArm].Center, armGlowmaskColor, armProperties[3].Item1, armProperties[3].Item2); + + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); + int numAfterimages = 5; + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, SpriteEffects.None, 0f); + } + } + + Vector2 center = npc.Center - Main.screenPosition; + spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresBodyGlow"); + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, SpriteEffects.None, 0f); + } + } + + spriteBatch.Draw(texture, center, frame, afterimageBaseColor * npc.Opacity, npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + return false; + } + internal float WidthFunction(float completionRatio) + { + return MathHelper.Lerp(0.5f, 1.3f, (float)Math.Sin(MathHelper.Pi * completionRatio)) * npc.scale; + } + + internal Color ColorFunction(float completionRatio) + { + Color baseColor1 = EnragedState == (float)Enraged.Yes ? Color.Red : Color.Cyan; + Color baseColor2 = EnragedState == (float)Enraged.Yes ? Color.IndianRed : Color.Cyan; + + float fadeToWhite = MathHelper.Lerp(0f, 0.65f, (float)Math.Sin(MathHelper.TwoPi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f); + Color baseColor = Color.Lerp(baseColor1, Color.White, fadeToWhite); + Color color = Color.Lerp(baseColor, baseColor2, ((float)Math.Sin(MathHelper.Pi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f) * 0.8f) * 0.65f; + color.A = 84; + if (npc.Opacity <= 0f) + return Color.Transparent; + return color; + } + + internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 4f; + + public Color BackgroundColorFunction(float completionRatio) + { + Color backgroundColor = EnragedState == (float)Enraged.Yes ? Color.Crimson : Color.CornflowerBlue; + Color color = backgroundColor * npc.Opacity * 0.4f; + return color; + } + + public void DrawArm(SpriteBatch spriteBatch, Vector2 handPosition, Color glowmaskColor, int direction, bool backArm) + { + if (LightningDrawer is null) + LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); + if (LightningBackgroundDrawer is null) + LightningBackgroundDrawer = new PrimitiveTrail(BackgroundWidthFunction, BackgroundColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); + + SpriteEffects spriteDirection = direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + float distanceFromHand = npc.Distance(handPosition); + float frameTime = Main.GlobalTime * 0.9f % 1f; + + // Draw back arms. + if (backArm) + { + Texture2D shoulderTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopShoulder"); + Texture2D armTexture1 = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopPart1"); + Texture2D armSegmentTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopSegment"); + Texture2D armTexture2 = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopPart2"); + + Texture2D shoulderGlowmask = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopShoulderGlow"); + Texture2D armSegmentGlowmask = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopSegmentGlow"); + Texture2D armGlowmask2 = ModContent.GetTexture("CalamityMod/ExtraTextures/AresArmTopPart2Glow"); + + Vector2 shoulderDrawPosition = npc.Center + new Vector2(direction * 176f, -100f); + Vector2 arm1DrawPosition = shoulderDrawPosition + new Vector2(direction * (shoulderTexture.Width + 16f), 10f); + Vector2 armSegmentDrawPosition = arm1DrawPosition; + + // Determine frames. + Rectangle shoulderFrame = shoulderTexture.Frame(1, 9, 0, (int)(frameTime * 9f)); + Rectangle armSegmentFrame = armSegmentTexture.Frame(1, 9, 0, (int)(frameTime * 9f)); + Rectangle arm2Frame = armTexture2.Frame(1, 9, 0, (int)(frameTime * 9f)); + + Vector2 arm1Origin = armTexture1.Size() * new Vector2((direction == 1).ToInt(), 0.5f); + Vector2 arm2Origin = arm2Frame.Size() * new Vector2((direction == 1).ToInt(), 0.5f); + + float arm1Rotation = MathHelper.Clamp(distanceFromHand * direction / 1200f, -0.12f, 0.12f); + float arm2Rotation = (handPosition - armSegmentDrawPosition - Vector2.UnitY * 12f).ToRotation(); + if (direction == 1) + arm2Rotation += MathHelper.Pi; + float armSegmentRotation = arm2Rotation; + + // Handle offsets for points. + armSegmentDrawPosition += arm1Rotation.ToRotationVector2() * direction * -14f; + armSegmentDrawPosition -= arm2Rotation.ToRotationVector2() * direction * 20f; + Vector2 arm2DrawPosition = armSegmentDrawPosition; + arm2DrawPosition -= arm2Rotation.ToRotationVector2() * direction * 40f; + arm2DrawPosition += (arm2Rotation - MathHelper.PiOver2).ToRotationVector2() * 14f; + + // Calculate colors. + Color shoulderLightColor = npc.GetAlpha(Lighting.GetColor((int)shoulderDrawPosition.X / 16, (int)shoulderDrawPosition.Y / 16)); + Color arm1LightColor = npc.GetAlpha(Lighting.GetColor((int)arm1DrawPosition.X / 16, (int)arm1DrawPosition.Y / 16)); + Color armSegmentLightColor = npc.GetAlpha(Lighting.GetColor((int)armSegmentDrawPosition.X / 16, (int)armSegmentDrawPosition.Y / 16)); + Color arm2LightColor = npc.GetAlpha(Lighting.GetColor((int)arm2DrawPosition.X / 16, (int)arm2DrawPosition.Y / 16)); + Color glowmaskAlphaColor = npc.GetAlpha(glowmaskColor); + + // Draw electricity between arms. + if (npc.Opacity > 0f) + { + List arm2ElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(armSegmentDrawPosition, arm2DrawPosition + arm2Rotation.ToRotationVector2() * -direction * 20f, 250290787); + LightningBackgroundDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90); + LightningDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90); + + // Draw electricity between the final arm and the hand. + List handElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm2DrawPosition - arm2Rotation.ToRotationVector2() * direction * 100f, handPosition, 27182); + LightningBackgroundDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90); + LightningDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90); + } + + shoulderDrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; + arm1DrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; + armSegmentDrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; + arm2DrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; + + spriteBatch.Draw(armTexture1, arm1DrawPosition, null, arm1LightColor, arm1Rotation, arm1Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(shoulderTexture, shoulderDrawPosition, shoulderFrame, shoulderLightColor, 0f, shoulderFrame.Size() * 0.5f, npc.scale, spriteDirection, 0f); + spriteBatch.Draw(shoulderGlowmask, shoulderDrawPosition, shoulderFrame, glowmaskAlphaColor, 0f, shoulderFrame.Size() * 0.5f, npc.scale, spriteDirection, 0f); + spriteBatch.Draw(armSegmentTexture, armSegmentDrawPosition, armSegmentFrame, armSegmentLightColor, armSegmentRotation, armSegmentFrame.Size() * 0.5f, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(armSegmentGlowmask, armSegmentDrawPosition, armSegmentFrame, glowmaskAlphaColor, armSegmentRotation, armSegmentFrame.Size() * 0.5f, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(armTexture2, arm2DrawPosition, arm2Frame, arm2LightColor, arm2Rotation, arm2Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipVertically, 0f); + spriteBatch.Draw(armGlowmask2, arm2DrawPosition, arm2Frame, glowmaskAlphaColor, arm2Rotation, arm2Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipVertically, 0f); + } + else + { + Texture2D shoulderTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmShoulder"); + Texture2D connectorTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmConnector"); + Texture2D armTexture1 = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmPart1"); + Texture2D armTexture2 = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmPart2"); + + Texture2D shoulderGlowmask = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmShoulderGlow"); + Texture2D armTexture1Glowmask = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmPart1Glow"); + Texture2D armTexture2Glowmask = ModContent.GetTexture("CalamityMod/ExtraTextures/AresBottomArmPart2Glow"); + + Vector2 shoulderDrawPosition = npc.Center + new Vector2(direction * 110f, -54f); + Vector2 connectorDrawPosition = shoulderDrawPosition + new Vector2(direction * 20f, 32f); + Vector2 arm1DrawPosition = shoulderDrawPosition + Vector2.UnitX * direction * 20f; + + // Determine frames. + Rectangle arm1Frame = armTexture1.Frame(1, 9, 0, (int)(frameTime * 9f)); + Rectangle shoulderFrame = shoulderTexture.Frame(1, 9, 0, (int)(frameTime * 9f)); + Rectangle arm2Frame = armTexture2.Frame(1, 9, 0, (int)(frameTime * 9f)); + + Vector2 arm1Origin = arm1Frame.Size() * new Vector2((direction == 1).ToInt(), 0.5f); + Vector2 arm2Origin = arm2Frame.Size() * new Vector2((direction == 1).ToInt(), 0.5f); + + float arm1Rotation = CalamityUtils.WrapAngle90Degrees((handPosition - shoulderDrawPosition).ToRotation()) * 0.5f; + connectorDrawPosition += arm1Rotation.ToRotationVector2() * direction * -26f; + arm1DrawPosition += arm1Rotation.ToRotationVector2() * direction * (armTexture1.Width - 14f); + float arm2Rotation = CalamityUtils.WrapAngle90Degrees((handPosition - arm1DrawPosition).ToRotation()); + + Vector2 arm2DrawPosition = arm1DrawPosition + arm2Rotation.ToRotationVector2() * direction * (armTexture2.Width + 16f) - Vector2.UnitY * 16f; + + // Calculate colors. + Color shoulderLightColor = npc.GetAlpha(Lighting.GetColor((int)shoulderDrawPosition.X / 16, (int)shoulderDrawPosition.Y / 16)); + Color arm1LightColor = npc.GetAlpha(Lighting.GetColor((int)arm1DrawPosition.X / 16, (int)arm1DrawPosition.Y / 16)); + Color arm2LightColor = npc.GetAlpha(Lighting.GetColor((int)arm2DrawPosition.X / 16, (int)arm2DrawPosition.Y / 16)); + Color glowmaskAlphaColor = npc.GetAlpha(glowmaskColor); + + // Draw electricity between arms. + if (npc.Opacity > 0f) + { + List arm2ElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm1DrawPosition - arm2Rotation.ToRotationVector2() * direction * 10f, arm1DrawPosition + arm2Rotation.ToRotationVector2() * direction * 20f, 31416); + LightningBackgroundDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90); + LightningDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90); + + // Draw electricity between the final arm and the hand. + List handElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm2DrawPosition - arm2Rotation.ToRotationVector2() * direction * 20f, handPosition, 27182); + LightningBackgroundDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90); + LightningDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90); + } + + shoulderDrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; + connectorDrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; + arm1DrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; + arm2DrawPosition += Vector2.UnitY * npc.gfxOffY - Main.screenPosition; + + spriteBatch.Draw(shoulderTexture, shoulderDrawPosition, shoulderFrame, shoulderLightColor, arm1Rotation, shoulderFrame.Size() * 0.5f, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(shoulderGlowmask, shoulderDrawPosition, shoulderFrame, glowmaskAlphaColor, arm1Rotation, shoulderFrame.Size() * 0.5f, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(connectorTexture, connectorDrawPosition, null, shoulderLightColor, 0f, connectorTexture.Size() * 0.5f, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(armTexture1, arm1DrawPosition, arm1Frame, arm1LightColor, arm1Rotation, arm1Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(armTexture1Glowmask, arm1DrawPosition, arm1Frame, glowmaskAlphaColor, arm1Rotation, arm1Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(armTexture2, arm2DrawPosition, arm2Frame, arm2LightColor, arm2Rotation, arm2Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(armTexture2Glowmask, arm2DrawPosition, arm2Frame, glowmaskAlphaColor, arm2Rotation, arm2Origin, npc.scale, spriteDirection ^ SpriteEffects.FlipHorizontally, 0f); + } + } + + public override void BossLoot(ref string name, ref int potionType) + { + potionType = ModContent.ItemType(); + } + + public override void NPCLoot() + { + // Check if the other exo mechs are alive + bool exoWormAlive = false; + bool exoTwinsAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + exoWormAlive = true; + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + exoTwinsAlive = true; + } + + // Check for Draedon + bool draedonAlive = false; + if (CalamityGlobalNPC.draedon != -1) + { + if (Main.npc[CalamityGlobalNPC.draedon].active) + draedonAlive = true; + } + + // Phase 5, when 1 mech dies and the other 2 return to fight + if (exoWormAlive && exoTwinsAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 4f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + + // Phase 7, when 1 mech dies and the final one returns to the fight + else if (exoWormAlive || exoTwinsAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 6f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + + // Mark Exo Mechs as dead and drop loot + else + DropExoMechLoot(npc, (int)MechType.Ares); + } + + public static void DropExoMechLoot(NPC npc, int mechType) + { + // Dropped before the downed variable is set to true + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedExoMechs); + + switch (mechType) + { + case (int)MechType.Ares: + + DropHelper.DropItem(npc, ModContent.ItemType()); + + CalamityWorld.downedAres = true; + CalamityWorld.downedExoMechs = true; + CalamityNetcode.SyncWorld(); + + break; + + case (int)MechType.Thanatos: + + DropHelper.DropItem(npc, ModContent.ItemType()); + + CalamityWorld.downedThanatos = true; + CalamityWorld.downedExoMechs = true; + CalamityNetcode.SyncWorld(); + + break; + + case (int)MechType.ArtemisAndApollo: + + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + + CalamityWorld.downedArtemisAndApollo = true; + CalamityWorld.downedExoMechs = true; + CalamityNetcode.SyncWorld(); + + break; + } + + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); + + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) + { + // Materials + DropHelper.DropItem(npc, ModContent.ItemType(), true, 24, 32); + + // Weapons + // Higher chance due to how the drops work + float w = DropHelper.NormalWeaponDropRateFloat * 2f; + if (CalamityWorld.downedAres) + { + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); + } + if (CalamityWorld.downedThanatos) + { + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); + } + if (CalamityWorld.downedArtemisAndApollo) + { + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); + } + + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); + DropHelper.DropItem(npc, ModContent.ItemType()); + + // Vanity + // Higher chance due to how the drops work + float maskDropRate = 1f / 3.5f; + if (CalamityWorld.downedThanatos) + DropHelper.DropItemChance(npc, ModContent.ItemType(), maskDropRate); + + if (CalamityWorld.downedArtemisAndApollo) + { + DropHelper.DropItemChance(npc, ModContent.ItemType(), maskDropRate); + DropHelper.DropItemChance(npc, ModContent.ItemType(), maskDropRate); + } + + if (CalamityWorld.downedAres) + DropHelper.DropItemChance(npc, ModContent.ItemType(), maskDropRate); + + DropHelper.DropItemChance(npc, ModContent.ItemType(), maskDropRate); + } + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody4"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody5"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody6"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody7"), 1f); + } + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * 0.8f); + } + } } diff --git a/NPCs/ExoMechs/Ares/AresGaussNuke.cs b/NPCs/ExoMechs/Ares/AresGaussNuke.cs index 39e602beaa..5a0e0d0336 100644 --- a/NPCs/ExoMechs/Ares/AresGaussNuke.cs +++ b/NPCs/ExoMechs/Ares/AresGaussNuke.cs @@ -14,647 +14,647 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Ares { - public class AresGaussNuke : ModNPC + public class AresGaussNuke : ModNPC { - public enum Phase - { - Nothing = 0, - GaussNuke = 1, - Reload = 2 - } + public enum Phase + { + Nothing = 0, + GaussNuke = 1, + Reload = 2 + } - public float AIState - { - get => npc.Calamity().newAI[0]; - set => npc.Calamity().newAI[0] = value; - } + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } - public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); - public AresCannonChargeParticleSet EnergyDrawer = new AresCannonChargeParticleSet(-1, 15, 40f, Color.Yellow); - public Vector2 CoreSpritePosition => npc.Center + npc.spriteDirection * npc.rotation.ToRotationVector2() * 35f + (npc.rotation + MathHelper.PiOver2).ToRotationVector2() * 5f; + public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); + public AresCannonChargeParticleSet EnergyDrawer = new AresCannonChargeParticleSet(-1, 15, 40f, Color.Yellow); + public Vector2 CoreSpritePosition => npc.Center + npc.spriteDirection * npc.rotation.ToRotationVector2() * 35f + (npc.rotation + MathHelper.PiOver2).ToRotationVector2() * 5f; - // Number of frames on the X and Y axis - private const int maxFramesX = 9; - private const int maxFramesY = 12; + // Number of frames on the X and Y axis + private const int maxFramesX = 9; + private const int maxFramesY = 12; - // Counters for frames on the X and Y axis - private int frameX = 0; - private int frameY = 0; + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; - // Frame limit per animation, these are the specific frames where each animation ends - private const int normalFrameLimit = 11; - private const int firstStageGaussNukeChargeFrameLimit = 23; - private const int secondStageGaussNukeChargeFrameLimit = 35; - private const int finalStageGaussNukeChargeFrameLimit = 47; - private const int reloadFrameLimit = 107; + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit = 11; + private const int firstStageGaussNukeChargeFrameLimit = 23; + private const int secondStageGaussNukeChargeFrameLimit = 35; + private const int finalStageGaussNukeChargeFrameLimit = 47; + private const int reloadFrameLimit = 107; - // Default life ratio for the other mechs - private const float defaultLifeRatio = 5f; + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; - // Total duration of the gauss nuke telegraph - private const float gaussNukeTelegraphDuration = 216f; + // Total duration of the gauss nuke telegraph + private const float gaussNukeTelegraphDuration = 216f; - // Total duration of the gauss nuke firing phase - private const float gaussNukeReloadDuration = 360f; + // Total duration of the gauss nuke firing phase + private const float gaussNukeReloadDuration = 360f; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("XF-09 Ares Gauss Nuke"); - NPCID.Sets.TrailingMode[npc.type] = 3; - NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; - } + NPCID.Sets.TrailingMode[npc.type] = 3; + NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; + } public override void SetDefaults() { - npc.npcSlots = 5f; - npc.damage = 100; - npc.width = 170; + npc.npcSlots = 5f; + npc.damage = 100; + npc.width = 170; npc.height = 120; npc.defense = 80; - npc.DR_NERD(0.35f); - npc.LifeMaxNERB(1250000, 1495000, 500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.DR_NERD(0.35f); + npc.LifeMaxNERB(1250000, 1495000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; - npc.Opacity = 0f; + npc.Opacity = 0f; npc.knockBackResist = 0f; - npc.canGhostHeal = false; + npc.canGhostHeal = false; npc.noGravity = true; npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; - npc.boss = true; - npc.hide = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.boss = true; + npc.hide = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(frameX); - writer.Write(frameY); + writer.Write(frameX); + writer.Write(frameY); writer.Write(npc.dontTakeDamage); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { - frameX = reader.ReadInt32(); - frameY = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - - if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - return; - } - - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - - // Percent life remaining - float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; - - // Check if the other exo mechs are alive - int otherExoMechsAlive = 0; - bool exoWormAlive = false; - bool exoTwinsAlive = false; - if (CalamityGlobalNPC.draedonExoMechWorm != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) - { - otherExoMechsAlive++; - exoWormAlive = true; - } - } - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - { - otherExoMechsAlive++; - exoTwinsAlive = true; - } - } - - // Used to nerf Ares if fighting alongside Artemis and Apollo, because otherwise it's too difficult - bool nerfedAttacks = false; - if (exoTwinsAlive) - nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] != (float)Apollo.Apollo.SecondaryPhase.PassiveAndImmune; - - // Phases - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; - - // These are 5 by default to avoid triggering passive phases after the other mechs are dead - float exoWormLifeRatio = defaultLifeRatio; - float exoTwinsLifeRatio = defaultLifeRatio; - if (exoWormAlive) - exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; - if (exoTwinsAlive) - exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; - - // If Ares doesn't go berserk - bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; - - // Whether Ares should be buffed while in berserk phase - bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - - // Target variable - Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; - - CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); - - // Passive phase check - bool passivePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.Passive; - - // Enrage check - bool enraged = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes; - - // Adjust opacity - bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; - npc.dontTakeDamage = invisiblePhase; - if (!invisiblePhase) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } - - // Predictiveness - float predictionAmt = malice ? 20f : death ? 15f : revenge ? 13.75f : expertMode ? 12.5f : 10f; - if (nerfedAttacks) - predictionAmt *= 0.5f; - if (passivePhase) - predictionAmt *= 0.5f; - - Vector2 predictionVector = player.velocity * predictionAmt; - Vector2 rotationVector = player.Center + predictionVector - npc.Center; - - float projectileVelocity = passivePhase ? 9.6f : 12f; - if (lastMechAlive) - projectileVelocity *= 1.2f; - else if (shouldGetBuffedByBerserkPhase) - projectileVelocity *= 1.1f; - - float rateOfRotation = AIState == (int)Phase.GaussNuke ? 0.08f : 0.04f; - Vector2 lookAt = Vector2.Normalize(rotationVector) * projectileVelocity; - - float rotation = (float)Math.Atan2(lookAt.Y, lookAt.X); - if (npc.spriteDirection == 1) - rotation += MathHelper.Pi; - if (rotation < 0f) - rotation += MathHelper.TwoPi; - if (rotation > MathHelper.TwoPi) - rotation -= MathHelper.TwoPi; - - npc.rotation = npc.rotation.AngleTowards(rotation, rateOfRotation); - - // Direction - int direction = Math.Sign(player.Center.X - npc.Center.X); - if (direction != 0) - { - npc.direction = direction; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += MathHelper.Pi; - - npc.spriteDirection = -npc.direction; - } - - // Light - if (enraged) - Lighting.AddLight(npc.Center, 0.5f * npc.Opacity, 0f, 0f); - else - Lighting.AddLight(npc.Center, 0.2f * npc.Opacity, 0.25f * npc.Opacity, 0.05f * npc.Opacity); - - // Despawn if target is dead - if (player.dead) - { - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (player.dead) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.dontTakeDamage = true; - - npc.velocity.Y -= 1f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 1f; - - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - - return; - } - } - - // Default vector to fly to - float offsetX = 560f; - float offsetY = 0f; - float offsetX2 = 540f; - float offsetY2 = 540f; - switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) - { - case 0: - case 3: - case 4: - break; - - case 1: - case 2: - case 5: - offsetX *= -1f; - offsetX2 *= -1f; - offsetY2 *= -1f; - break; - } - Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); - - // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); - float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; - baseVelocity *= 1f + Main.npc[(int)npc.ai[2]].localAI[2]; - - Vector2 distanceFromDestination = destination - npc.Center; - - // Distance where Ares Nuke Arm stops moving - float movementDistanceGateValue = 50f; - - // Gate values - float gaussNukePhaseGateValue = 750f; - if (enraged) - gaussNukePhaseGateValue *= 0.05f; - else if (lastMechAlive) - gaussNukePhaseGateValue *= 0.1f; - else if (shouldGetBuffedByBerserkPhase) - gaussNukePhaseGateValue *= 0.15f; - - // Variable to disable deathray firing - bool doNotFire = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays || calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; - if (doNotFire && AIState != (float)Phase.Reload) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - } - - // Emit steam while enraged - SmokeDrawer.ParticleSpawnRate = 9999999; - if (enraged) - { - SmokeDrawer.ParticleSpawnRate = AresBody.ventCloudSpawnRate; - SmokeDrawer.BaseMoveRotation = npc.rotation + MathHelper.Pi; - SmokeDrawer.SpawnAreaCompactness = 40f; - - // Increase DR during enrage - npc.Calamity().DR = 0.85f; - } - else - npc.Calamity().DR = 0.35f; - - SmokeDrawer.Update(); - - EnergyDrawer.ParticleSpawnRate = 9999999; - // Attacking phases - switch ((int)AIState) - { - // Do nothing and fly in place - case (int)Phase.Nothing: - - calamityGlobalNPC.newAI[1] += 1f; - if (calamityGlobalNPC.newAI[1] >= gaussNukePhaseGateValue) - { - AIState = (float)Phase.GaussNuke; - calamityGlobalNPC.newAI[1] = 0f; - } - - break; - - // Fire gauss nuke that emits a wave pounder stealth strike-size explosion on death - case (int)Phase.GaussNuke: - - calamityGlobalNPC.newAI[2] += 1f; - float telegraphDuration = enraged ? (gaussNukeTelegraphDuration * 0.5f) : gaussNukeTelegraphDuration; - if (calamityGlobalNPC.newAI[2] < telegraphDuration) - { - // Set frames to gauss nuke charge up frames, which begin on frame 12 - if (calamityGlobalNPC.newAI[2] == 1f) - { - // Reset the frame counter - npc.frameCounter = 0D; - - // X = 1 sets to frame 12 - frameX = 1; - - // Y = 0 sets to frame 12 - frameY = 0; - } - - // Fire gauss nuke on frame 41 - if ((frameX * maxFramesY) + frameY == 41 && calamityGlobalNPC.newAI[1] == 0f) - { - calamityGlobalNPC.newAI[1] = 1f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"), npc.Center); - Vector2 gaussNukeVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float offset = 40f; - Projectile.NewProjectile(npc.Center + Vector2.Normalize(gaussNukeVelocity) * offset, gaussNukeVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); - - // Recoil - npc.velocity -= gaussNukeVelocity; - } - } - - EnergyDrawer.ParticleSpawnRate = AresBody.telegraphParticlesSpawnRate; - EnergyDrawer.SpawnAreaCompactness = 100f; - EnergyDrawer.chargeProgress = calamityGlobalNPC.newAI[2] / telegraphDuration; - } - else - { - // Set frames to gauss nuke reload frames, which begin on frame 48 - AIState = (float)Phase.Reload; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - - // Reset the frame counter - npc.frameCounter = 0D; - - // X = 1 sets to frame 48 - frameX = 4; - - // Y = 0 sets to frame 48 - frameY = 0; - } - - if (calamityGlobalNPC.newAI[2] % (float)Math.Floor(telegraphDuration / 5f) == (float)Math.Floor(telegraphDuration / 5f) - 1 && calamityGlobalNPC.newAI[2] <= telegraphDuration) - { - float pulseCounter = (float)Math.Floor(calamityGlobalNPC.newAI[2] / (telegraphDuration / 5f)) + 1; - EnergyDrawer.AddPulse(pulseCounter); - } - - break; - - case (int)Phase.Reload: - - calamityGlobalNPC.newAI[2] += 1f; - float reloadDuration = enraged ? (gaussNukeReloadDuration * 0.5f) : gaussNukeReloadDuration; - if (calamityGlobalNPC.newAI[2] >= reloadDuration) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[2] = 0f; - } - - break; - } - - EnergyDrawer.Update(); - - // Smooth movement towards the location Ares Gauss Nuke is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; - - public override void FindFrame(int frameHeight) - { - // Use telegraph frames when using gauss nuke - npc.frameCounter += 1D; - double frameTime = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? 3D : 6D; - if (AIState == (float)Phase.Nothing) - { - if (npc.frameCounter >= frameTime) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 12 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames - if ((frameX * maxFramesY) + frameY > normalFrameLimit) - frameX = frameY = 0; - } - } - else - { - if (npc.frameCounter >= frameTime) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 12 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames to frame 0 - if ((frameX * maxFramesY) + frameY > reloadFrameLimit) - frameX = frameY = 0; - } - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - // Draw the enrage smoke behind Ares - SmokeDrawer.DrawSet(npc.Center); - - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture = Main.npcTexture[npc.type]; - Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); - Color afterimageBaseColor = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? Color.Red : Color.White; - int numAfterimages = 5; - - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); - } - } - - Vector2 center = npc.Center - Main.screenPosition; - - float telegraphDuration = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? (gaussNukeTelegraphDuration * 0.5f) : gaussNukeTelegraphDuration; - //Draw an outline to the arm when it charges up - if ((npc.Calamity().newAI[2] < telegraphDuration) && AIState == (float)Phase.GaussNuke) - { - CalamityUtils.EnterShaderRegion(spriteBatch); - Color outlineColor = Color.Lerp(Color.Yellow, Color.White, npc.Calamity().newAI[2] / telegraphDuration); - Vector3 outlineHSL = Main.rgbToHsl(outlineColor); //BasicTint uses the opposite hue i guess? or smth is fucked with the way shaders get their colors. anyways, we invert it - float outlineThickness = MathHelper.Clamp(npc.Calamity().newAI[2] / telegraphDuration * 4f, 0f, 3f); - - GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(1f); - GameShaders.Misc["CalamityMod:BasicTint"].UseColor(Main.hslToRgb(1 - outlineHSL.X, outlineHSL.Y, outlineHSL.Z)); - GameShaders.Misc["CalamityMod:BasicTint"].Apply(); - - for (float i = 0; i < 1; i += 0.125f) - { - spriteBatch.Draw(texture, center + (i * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * outlineThickness, frame, outlineColor, npc.rotation, vector, npc.scale, spriteEffects, 0f); - } - CalamityUtils.ExitShaderRegion(spriteBatch); - } - - spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); - - Texture2D glowTexture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresGaussNukeGlow"); - - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(glowTexture.Width, glowTexture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(glowTexture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(texture, center, frame, afterimageBaseColor * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); - - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - //Update the parameters - - //Draw a pulsing version of the cannon above the real one - if ((npc.Calamity().newAI[2] < telegraphDuration) && AIState == (float)Phase.GaussNuke) - { - - float pulseRatio = (npc.Calamity().newAI[2] % (telegraphDuration / 5f)) / (telegraphDuration / 5f); - float pulseSize = MathHelper.Lerp(0.1f, 0.6f, (float)Math.Floor(npc.Calamity().newAI[2] / (telegraphDuration / 5f)) / 4f); - float pulseOpacity = MathHelper.Clamp((float)Math.Floor(npc.Calamity().newAI[2] / (telegraphDuration / 5f)) * 0.3f, 1f, 2f); - spriteBatch.Draw(texture, center, frame, Color.Yellow * MathHelper.Lerp(1f, 0f, pulseRatio) * pulseOpacity, npc.rotation, vector, npc.scale + pulseRatio * pulseSize, spriteEffects, 0f); - - //Draw the bloom - EnergyDrawer.DrawBloom(CoreSpritePosition); - } - - EnergyDrawer.DrawPulses(CoreSpritePosition); - EnergyDrawer.DrawSet(CoreSpritePosition); - - //Back to normal - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - - return false; - } - - public override void DrawBehind(int index) - { - Main.instance.DrawCacheNPCProjectiles.Add(index); - } - - public override bool PreNPCLoot() => false; - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); - - if (npc.life <= 0) - { - for (int num193 = 0; num193 < 2; num193++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); - } - } - - public override bool CheckActive() => false; - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * 0.8f); - } + frameX = reader.ReadInt32(); + frameY = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + // Percent life remaining + float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoWormAlive = false; + bool exoTwinsAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + otherExoMechsAlive++; + exoWormAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoTwinsAlive = true; + } + } + + // Used to nerf Ares if fighting alongside Artemis and Apollo, because otherwise it's too difficult + bool nerfedAttacks = false; + if (exoTwinsAlive) + nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] != (float)Apollo.Apollo.SecondaryPhase.PassiveAndImmune; + + // Phases + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoTwinsLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoTwinsAlive) + exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + + // If Ares doesn't go berserk + bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; + + // Whether Ares should be buffed while in berserk phase + bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; + + // Target variable + Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); + + // Passive phase check + bool passivePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.Passive; + + // Enrage check + bool enraged = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes; + + // Adjust opacity + bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Predictiveness + float predictionAmt = malice ? 20f : death ? 15f : revenge ? 13.75f : expertMode ? 12.5f : 10f; + if (nerfedAttacks) + predictionAmt *= 0.5f; + if (passivePhase) + predictionAmt *= 0.5f; + + Vector2 predictionVector = player.velocity * predictionAmt; + Vector2 rotationVector = player.Center + predictionVector - npc.Center; + + float projectileVelocity = passivePhase ? 9.6f : 12f; + if (lastMechAlive) + projectileVelocity *= 1.2f; + else if (shouldGetBuffedByBerserkPhase) + projectileVelocity *= 1.1f; + + float rateOfRotation = AIState == (int)Phase.GaussNuke ? 0.08f : 0.04f; + Vector2 lookAt = Vector2.Normalize(rotationVector) * projectileVelocity; + + float rotation = (float)Math.Atan2(lookAt.Y, lookAt.X); + if (npc.spriteDirection == 1) + rotation += MathHelper.Pi; + if (rotation < 0f) + rotation += MathHelper.TwoPi; + if (rotation > MathHelper.TwoPi) + rotation -= MathHelper.TwoPi; + + npc.rotation = npc.rotation.AngleTowards(rotation, rateOfRotation); + + // Direction + int direction = Math.Sign(player.Center.X - npc.Center.X); + if (direction != 0) + { + npc.direction = direction; + + if (npc.spriteDirection != -npc.direction) + npc.rotation += MathHelper.Pi; + + npc.spriteDirection = -npc.direction; + } + + // Light + if (enraged) + Lighting.AddLight(npc.Center, 0.5f * npc.Opacity, 0f, 0f); + else + Lighting.AddLight(npc.Center, 0.2f * npc.Opacity, 0.25f * npc.Opacity, 0.05f * npc.Opacity); + + // Despawn if target is dead + if (player.dead) + { + player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + if (player.dead) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.dontTakeDamage = true; + + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 1f; + + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + } + + return; + } + } + + // Default vector to fly to + float offsetX = 560f; + float offsetY = 0f; + float offsetX2 = 540f; + float offsetY2 = 540f; + switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) + { + case 0: + case 3: + case 4: + break; + + case 1: + case 2: + case 5: + offsetX *= -1f; + offsetX2 *= -1f; + offsetY2 *= -1f; + break; + } + Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); + + // Velocity and acceleration values + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; + baseVelocity *= 1f + Main.npc[(int)npc.ai[2]].localAI[2]; + + Vector2 distanceFromDestination = destination - npc.Center; + + // Distance where Ares Nuke Arm stops moving + float movementDistanceGateValue = 50f; + + // Gate values + float gaussNukePhaseGateValue = 750f; + if (enraged) + gaussNukePhaseGateValue *= 0.05f; + else if (lastMechAlive) + gaussNukePhaseGateValue *= 0.1f; + else if (shouldGetBuffedByBerserkPhase) + gaussNukePhaseGateValue *= 0.15f; + + // Variable to disable deathray firing + bool doNotFire = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays || calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + if (doNotFire && AIState != (float)Phase.Reload) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + } + + // Emit steam while enraged + SmokeDrawer.ParticleSpawnRate = 9999999; + if (enraged) + { + SmokeDrawer.ParticleSpawnRate = AresBody.ventCloudSpawnRate; + SmokeDrawer.BaseMoveRotation = npc.rotation + MathHelper.Pi; + SmokeDrawer.SpawnAreaCompactness = 40f; + + // Increase DR during enrage + npc.Calamity().DR = 0.85f; + } + else + npc.Calamity().DR = 0.35f; + + SmokeDrawer.Update(); + + EnergyDrawer.ParticleSpawnRate = 9999999; + // Attacking phases + switch ((int)AIState) + { + // Do nothing and fly in place + case (int)Phase.Nothing: + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] >= gaussNukePhaseGateValue) + { + AIState = (float)Phase.GaussNuke; + calamityGlobalNPC.newAI[1] = 0f; + } + + break; + + // Fire gauss nuke that emits a wave pounder stealth strike-size explosion on death + case (int)Phase.GaussNuke: + + calamityGlobalNPC.newAI[2] += 1f; + float telegraphDuration = enraged ? (gaussNukeTelegraphDuration * 0.5f) : gaussNukeTelegraphDuration; + if (calamityGlobalNPC.newAI[2] < telegraphDuration) + { + // Set frames to gauss nuke charge up frames, which begin on frame 12 + if (calamityGlobalNPC.newAI[2] == 1f) + { + // Reset the frame counter + npc.frameCounter = 0D; + + // X = 1 sets to frame 12 + frameX = 1; + + // Y = 0 sets to frame 12 + frameY = 0; + } + + // Fire gauss nuke on frame 41 + if ((frameX * maxFramesY) + frameY == 41 && calamityGlobalNPC.newAI[1] == 0f) + { + calamityGlobalNPC.newAI[1] = 1f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"), npc.Center); + Vector2 gaussNukeVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float offset = 40f; + Projectile.NewProjectile(npc.Center + Vector2.Normalize(gaussNukeVelocity) * offset, gaussNukeVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); + + // Recoil + npc.velocity -= gaussNukeVelocity; + } + } + + EnergyDrawer.ParticleSpawnRate = AresBody.telegraphParticlesSpawnRate; + EnergyDrawer.SpawnAreaCompactness = 100f; + EnergyDrawer.chargeProgress = calamityGlobalNPC.newAI[2] / telegraphDuration; + } + else + { + // Set frames to gauss nuke reload frames, which begin on frame 48 + AIState = (float)Phase.Reload; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + + // Reset the frame counter + npc.frameCounter = 0D; + + // X = 1 sets to frame 48 + frameX = 4; + + // Y = 0 sets to frame 48 + frameY = 0; + } + + if (calamityGlobalNPC.newAI[2] % (float)Math.Floor(telegraphDuration / 5f) == (float)Math.Floor(telegraphDuration / 5f) - 1 && calamityGlobalNPC.newAI[2] <= telegraphDuration) + { + float pulseCounter = (float)Math.Floor(calamityGlobalNPC.newAI[2] / (telegraphDuration / 5f)) + 1; + EnergyDrawer.AddPulse(pulseCounter); + } + + break; + + case (int)Phase.Reload: + + calamityGlobalNPC.newAI[2] += 1f; + float reloadDuration = enraged ? (gaussNukeReloadDuration * 0.5f) : gaussNukeReloadDuration; + if (calamityGlobalNPC.newAI[2] >= reloadDuration) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[2] = 0f; + } + + break; + } + + EnergyDrawer.Update(); + + // Smooth movement towards the location Ares Gauss Nuke is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public override void FindFrame(int frameHeight) + { + // Use telegraph frames when using gauss nuke + npc.frameCounter += 1D; + double frameTime = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? 3D : 6D; + if (AIState == (float)Phase.Nothing) + { + if (npc.frameCounter >= frameTime) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 12 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames + if ((frameX * maxFramesY) + frameY > normalFrameLimit) + frameX = frameY = 0; + } + } + else + { + if (npc.frameCounter >= frameTime) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 12 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames to frame 0 + if ((frameX * maxFramesY) + frameY > reloadFrameLimit) + frameX = frameY = 0; + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + // Draw the enrage smoke behind Ares + SmokeDrawer.DrawSet(npc.Center); + + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); + Color afterimageBaseColor = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? Color.Red : Color.White; + int numAfterimages = 5; + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); + } + } + + Vector2 center = npc.Center - Main.screenPosition; + + float telegraphDuration = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? (gaussNukeTelegraphDuration * 0.5f) : gaussNukeTelegraphDuration; + //Draw an outline to the arm when it charges up + if ((npc.Calamity().newAI[2] < telegraphDuration) && AIState == (float)Phase.GaussNuke) + { + CalamityUtils.EnterShaderRegion(spriteBatch); + Color outlineColor = Color.Lerp(Color.Yellow, Color.White, npc.Calamity().newAI[2] / telegraphDuration); + Vector3 outlineHSL = Main.rgbToHsl(outlineColor); //BasicTint uses the opposite hue i guess? or smth is fucked with the way shaders get their colors. anyways, we invert it + float outlineThickness = MathHelper.Clamp(npc.Calamity().newAI[2] / telegraphDuration * 4f, 0f, 3f); + + GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(1f); + GameShaders.Misc["CalamityMod:BasicTint"].UseColor(Main.hslToRgb(1 - outlineHSL.X, outlineHSL.Y, outlineHSL.Z)); + GameShaders.Misc["CalamityMod:BasicTint"].Apply(); + + for (float i = 0; i < 1; i += 0.125f) + { + spriteBatch.Draw(texture, center + (i * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * outlineThickness, frame, outlineColor, npc.rotation, vector, npc.scale, spriteEffects, 0f); + } + CalamityUtils.ExitShaderRegion(spriteBatch); + } + + spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); + + Texture2D glowTexture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresGaussNukeGlow"); + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(glowTexture.Width, glowTexture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(glowTexture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(texture, center, frame, afterimageBaseColor * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + //Update the parameters + + //Draw a pulsing version of the cannon above the real one + if ((npc.Calamity().newAI[2] < telegraphDuration) && AIState == (float)Phase.GaussNuke) + { + + float pulseRatio = (npc.Calamity().newAI[2] % (telegraphDuration / 5f)) / (telegraphDuration / 5f); + float pulseSize = MathHelper.Lerp(0.1f, 0.6f, (float)Math.Floor(npc.Calamity().newAI[2] / (telegraphDuration / 5f)) / 4f); + float pulseOpacity = MathHelper.Clamp((float)Math.Floor(npc.Calamity().newAI[2] / (telegraphDuration / 5f)) * 0.3f, 1f, 2f); + spriteBatch.Draw(texture, center, frame, Color.Yellow * MathHelper.Lerp(1f, 0f, pulseRatio) * pulseOpacity, npc.rotation, vector, npc.scale + pulseRatio * pulseSize, spriteEffects, 0f); + + //Draw the bloom + EnergyDrawer.DrawBloom(CoreSpritePosition); + } + + EnergyDrawer.DrawPulses(CoreSpritePosition); + EnergyDrawer.DrawSet(CoreSpritePosition); + + //Back to normal + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + return false; + } + + public override void DrawBehind(int index) + { + Main.instance.DrawCacheNPCProjectiles.Add(index); + } + + public override bool PreNPCLoot() => false; + + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); + } + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * 0.8f); + } } } diff --git a/NPCs/ExoMechs/Ares/AresLaserCannon.cs b/NPCs/ExoMechs/Ares/AresLaserCannon.cs index 4e911ee407..cae3f83555 100644 --- a/NPCs/ExoMechs/Ares/AresLaserCannon.cs +++ b/NPCs/ExoMechs/Ares/AresLaserCannon.cs @@ -14,694 +14,694 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Ares { - public class AresLaserCannon : ModNPC + public class AresLaserCannon : ModNPC { - public enum Phase - { - Nothing = 0, - Deathray = 1 - } + public enum Phase + { + Nothing = 0, + Deathray = 1 + } - public float AIState - { - get => npc.Calamity().newAI[0]; - set => npc.Calamity().newAI[0] = value; - } + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } - public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); - public AresCannonChargeParticleSet EnergyDrawer = new AresCannonChargeParticleSet(-1, 15, 40f, Color.OrangeRed); - public Vector2 CoreSpritePosition => npc.Center + npc.spriteDirection * npc.rotation.ToRotationVector2() * 30f + (npc.rotation + MathHelper.PiOver2).ToRotationVector2() * 15f; + public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); + public AresCannonChargeParticleSet EnergyDrawer = new AresCannonChargeParticleSet(-1, 15, 40f, Color.OrangeRed); + public Vector2 CoreSpritePosition => npc.Center + npc.spriteDirection * npc.rotation.ToRotationVector2() * 30f + (npc.rotation + MathHelper.PiOver2).ToRotationVector2() * 15f; - // Number of frames on the X and Y axis - private const int maxFramesX = 6; - private const int maxFramesY = 8; + // Number of frames on the X and Y axis + private const int maxFramesX = 6; + private const int maxFramesY = 8; - // Counters for frames on the X and Y axis - private int frameX = 0; - private int frameY = 0; + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; - // Frame limit per animation, these are the specific frames where each animation ends - private const int normalFrameLimit = 11; - private const int firstStageDeathrayChargeFrameLimit = 23; - private const int secondStageDeathrayChargeFrameLimit = 35; - private const int finalStageDeathrayChargeFrameLimit = 47; + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit = 11; + private const int firstStageDeathrayChargeFrameLimit = 23; + private const int secondStageDeathrayChargeFrameLimit = 35; + private const int finalStageDeathrayChargeFrameLimit = 47; - // Default life ratio for the other mechs - private const float defaultLifeRatio = 5f; + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; - // Total duration of the deathray telegraph - private const float deathrayTelegraphDuration = 144f; + // Total duration of the deathray telegraph + private const float deathrayTelegraphDuration = 144f; - // Total duration of the deathray - private const float deathrayDuration = 60f; + // Total duration of the deathray + private const float deathrayDuration = 60f; public override void SetStaticDefaults() { DisplayName.SetDefault("XF-09 Ares Laser Cannon"); - NPCID.Sets.TrailingMode[npc.type] = 3; - NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; - } + NPCID.Sets.TrailingMode[npc.type] = 3; + NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; + } public override void SetDefaults() { - npc.npcSlots = 5f; - npc.damage = 100; - npc.width = 154; + npc.npcSlots = 5f; + npc.damage = 100; + npc.width = 154; npc.height = 90; npc.defense = 80; - npc.DR_NERD(0.35f); - npc.LifeMaxNERB(1250000, 1495000, 500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.DR_NERD(0.35f); + npc.LifeMaxNERB(1250000, 1495000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; - npc.Opacity = 0f; + npc.Opacity = 0f; npc.knockBackResist = 0f; - npc.canGhostHeal = false; - npc.noGravity = true; + npc.canGhostHeal = false; + npc.noGravity = true; npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; - npc.boss = true; - npc.hide = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.boss = true; + npc.hide = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(frameX); - writer.Write(frameY); + writer.Write(frameX); + writer.Write(frameY); writer.Write(npc.dontTakeDamage); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { - frameX = reader.ReadInt32(); - frameY = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + frameX = reader.ReadInt32(); + frameY = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - - if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - return; - } - - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - - // Percent life remaining - float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; - - // Check if the other exo mechs are alive - int otherExoMechsAlive = 0; - bool exoWormAlive = false; - bool exoTwinsAlive = false; - if (CalamityGlobalNPC.draedonExoMechWorm != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) - { - otherExoMechsAlive++; - exoWormAlive = true; - } - } - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - { - otherExoMechsAlive++; - exoTwinsAlive = true; - } - } - - // Used to nerf Ares if fighting alongside Artemis and Apollo, because otherwise it's too difficult - bool nerfedAttacks = false; - if (exoTwinsAlive) - nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] != (float)Apollo.Apollo.SecondaryPhase.PassiveAndImmune; - - // Phases - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; - - // These are 5 by default to avoid triggering passive phases after the other mechs are dead - float exoWormLifeRatio = defaultLifeRatio; - float exoTwinsLifeRatio = defaultLifeRatio; - if (exoWormAlive) - exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; - if (exoTwinsAlive) - exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; - - // If Ares doesn't go berserk - bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; - - // Whether Ares should be buffed while in berserk phase - bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - - // Target variable - Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; - - CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); - - // Passive phase check - bool passivePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.Passive; - - // Enrage check - bool enraged = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes; - - // Adjust opacity - bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; - npc.dontTakeDamage = invisiblePhase; - if (!invisiblePhase) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } - - // Variable to fire normal lasers - bool fireNormalLasers = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays; - - // Default vector to fly to - float offsetX = -560f; - float offsetY = 0f; - float offsetX2 = -540f; - float offsetY2 = -540f; - bool flyLeft = true; - switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) - { - case 0: - case 3: - case 4: - break; - - case 1: - case 2: - case 5: - offsetX *= -1f; - offsetX2 *= -1f; - offsetY2 *= -1f; - flyLeft = false; - break; - } - Vector2 destination = fireNormalLasers ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); - - // Rotate the cannon to look at the target while not firing the beam - // Rotate the cannon to look in the direction it will fire only while it's charging or while it's firing - // Rotation - bool horizontalLaserSweep = calamityGlobalNPC.newAI[3] == 0f; - float rateOfRotation = AIState == (int)Phase.Deathray ? 0.08f : 0.04f; - float lookAtX = flyLeft ? 1000f : -1000f; - Vector2 lookAt = AIState == (int)Phase.Deathray && !fireNormalLasers ? (horizontalLaserSweep ? new Vector2(npc.Center.X, npc.Center.Y + 1000f) : new Vector2(npc.Center.X + lookAtX, npc.Center.Y)) : player.Center; - - float rotation = (float)Math.Atan2(lookAt.Y - npc.Center.Y, lookAt.X - npc.Center.X); - if (npc.spriteDirection == 1) - rotation += MathHelper.Pi; - if (rotation < 0f) - rotation += MathHelper.TwoPi; - if (rotation > MathHelper.TwoPi) - rotation -= MathHelper.TwoPi; - - npc.rotation = npc.rotation.AngleTowards(rotation, rateOfRotation); - - // Direction - int direction = Math.Sign(((AIState == (int)Phase.Deathray && !horizontalLaserSweep) || fireNormalLasers ? lookAt.X : player.Center.X) - npc.Center.X); - if (direction != 0) - { - npc.direction = direction; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += MathHelper.Pi; - - npc.spriteDirection = -npc.direction; - } - - // Light - if (enraged) - Lighting.AddLight(npc.Center, 0.5f * npc.Opacity, 0f, 0f); - else - Lighting.AddLight(npc.Center, 0.25f * npc.Opacity, 0.1f * npc.Opacity, 0.1f * npc.Opacity); - - // Despawn if target is dead - if (player.dead) - { - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (player.dead) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.dontTakeDamage = true; - - npc.velocity.Y -= 1f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 1f; - - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - - return; - } - } - - // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); - float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; - baseVelocity *= 1f + Main.npc[(int)npc.ai[2]].localAI[2]; - float baseAcceleration = shouldGetBuffedByBerserkPhase ? 1.25f : 1f; - - Vector2 distanceFromDestination = destination - npc.Center; - Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination) * baseVelocity; - - // Whether Ares Laser Arm should move to its spot or not - float movementDistanceGateValue = 50f; - bool moveToLocation = Vector2.Distance(npc.Center, destination) > movementDistanceGateValue; - - // Gate values - float deathrayPhaseGateValue = 450f; - if (enraged) - deathrayPhaseGateValue *= 0.1f; - else if (lastMechAlive) - deathrayPhaseGateValue *= 0.3f; - else if (shouldGetBuffedByBerserkPhase) - deathrayPhaseGateValue *= 0.5f; - - float deathrayPhaseVelocity = (nerfedAttacks ? 6f : passivePhase ? 9f : 12f) * baseVelocityMult; - if (lastMechAlive) - deathrayPhaseVelocity *= 1.2f; - else if (shouldGetBuffedByBerserkPhase) - deathrayPhaseVelocity *= 1.1f; - - // If Laser Cannon can fire normal lasers, cannot fire if too close to the target and in deathray spiral phase - bool canFire = Vector2.Distance(npc.Center, player.Center) > 320f || !fireNormalLasers; - - // Telegraph duration for deathray spiral - float deathraySpiralTelegraphDuration = malice ? AresBody.deathrayTelegraphDuration_Malice : death ? AresBody.deathrayTelegraphDuration_Death : - revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; - - // Variable to disable deathray firing - bool doNotFire = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune || - (calamityGlobalNPC_Body.newAI[2] >= deathraySpiralTelegraphDuration + AresBody.deathrayDuration - 10 && fireNormalLasers) || - (calamityGlobalNPC_Body.newAI[3] == 0f && fireNormalLasers); - - if (doNotFire) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - } - - // Emit steam while enraged - SmokeDrawer.ParticleSpawnRate = 9999999; - if (enraged) - { - SmokeDrawer.ParticleSpawnRate = AresBody.ventCloudSpawnRate; - SmokeDrawer.BaseMoveRotation = npc.rotation + MathHelper.Pi; - SmokeDrawer.SpawnAreaCompactness = 40f; - - // Increase DR during enrage - npc.Calamity().DR = 0.85f; - } - else - npc.Calamity().DR = 0.35f; - - SmokeDrawer.Update(); - - EnergyDrawer.ParticleSpawnRate = 9999999; - // Attacking phases - switch ((int)AIState) - { - // Do nothing, rotate to aim at the target and fly in place - case (int)Phase.Nothing: - - // Smooth movement towards the location Ares Laser Cannon is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - - calamityGlobalNPC.newAI[1] += 1f; - if (calamityGlobalNPC.newAI[1] >= deathrayPhaseGateValue) - { - AIState = (float)Phase.Deathray; - calamityGlobalNPC.newAI[1] = 0f; - } - - break; - - // Move close to target, reduce velocity when close enough, create telegraph beams, fire deathrays - case (int)Phase.Deathray: - - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] < deathrayTelegraphDuration) - { - // Play a charge up sound so that the player knows when it's about to fire the deathray - if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration - 100f && !fireNormalLasers) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/CrystylCharge"), npc.Center); - - // Smooth movement towards the location Ares Laser Cannon is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - - // Set frames to deathray charge up frames, which begin on frame 12 - if (calamityGlobalNPC.newAI[2] == 1f) - { - // Reset the frame counter - npc.frameCounter = 0D; - - // X = 1 sets to frame 8 - frameX = 1; - - // Y = 4 sets to frame 12 - frameY = 4; - } - - EnergyDrawer.ParticleSpawnRate = AresBody.telegraphParticlesSpawnRate; - EnergyDrawer.SpawnAreaCompactness = 100f; - EnergyDrawer.chargeProgress = calamityGlobalNPC.newAI[2] / deathrayTelegraphDuration; - } - else - { - // Fire regular Thanatos lasers if Ares is in deathray phase, otherwise, fire deathray - if (fireNormalLasers) - { - // Smooth movement towards the location Ares Laser Cannon is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - - // Fire Thanatos lasers - int numLasers = enraged ? 9 : lastMechAlive ? 3 : 2; - float divisor = deathrayDuration / numLasers; - - if (calamityGlobalNPC.newAI[2] % divisor == 0f && canFire) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - Vector2 laserVelocity = Vector2.Normalize(player.Center - npc.Center); - Vector2 offset = laserVelocity * 70f + Vector2.UnitY * 16f; - Projectile.NewProjectile(npc.Center + offset, player.Center, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - else - { - // Two possible variants: 1 - Horizontal, 2 - Vertical - - // Movement while firing deathray - if (horizontalLaserSweep) - desiredVelocity.X = 0f; - else - desiredVelocity.Y = 0f; - - npc.SimpleFlyMovement(desiredVelocity, baseAcceleration); - float velocityX = flyLeft ? deathrayPhaseVelocity : -deathrayPhaseVelocity; - npc.velocity = horizontalLaserSweep ? new Vector2(velocityX, npc.velocity.Y) : new Vector2(npc.velocity.X, deathrayPhaseVelocity * 0.75f); - - npc.netUpdate = true; - npc.netSpam -= 5; - - // Fire deathray - if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float offset = 84f; - float offset2 = 16f; - Vector2 source = horizontalLaserSweep ? new Vector2(npc.Center.X - offset2 * npc.direction, npc.Center.Y + offset) : new Vector2(npc.Center.X + offset * npc.direction, npc.Center.Y + offset2); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), source); - Vector2 laserVelocity = Vector2.Normalize(lookAt - source); - if (laserVelocity.HasNaNs()) - laserVelocity = -Vector2.UnitY; - - Projectile.NewProjectile(source, laserVelocity, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - - if (calamityGlobalNPC.newAI[2] % (float)Math.Floor(deathrayTelegraphDuration / 5f) == (float)Math.Floor(deathrayTelegraphDuration / 5f) - 1 && calamityGlobalNPC.newAI[2] <= deathrayTelegraphDuration) - { - float pulseCounter = (float)Math.Floor(calamityGlobalNPC.newAI[2] / (deathrayTelegraphDuration / 5f)) + 1; - EnergyDrawer.AddPulse(pulseCounter); - } - - if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) - { - // Reset - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[2] = 0f; - - // Change deathray sweep type for next deathray phase - calamityGlobalNPC.newAI[3] += 1f; - if (calamityGlobalNPC.newAI[3] > 1f) - calamityGlobalNPC.newAI[3] = 0f; - } - - break; - } - - EnergyDrawer.Update(); - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; - - public override void FindFrame(int frameHeight) - { - // Use telegraph frames when using deathrays - npc.frameCounter += 1D; - if (AIState == (float)Phase.Nothing) - { - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 8 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames - if ((frameX * maxFramesY) + frameY > normalFrameLimit) - frameX = frameY = 0; - } - } - else - { - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 8 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames to frame 36, the start of the deathray firing animation loop - if ((frameX * maxFramesY) + frameY > finalStageDeathrayChargeFrameLimit) - frameX = frameY = 4; - } - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - // Draw the enrage smoke behind Ares - SmokeDrawer.DrawSet(npc.Center); - - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture = Main.npcTexture[npc.type]; - Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); - Color afterimageBaseColor = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? Color.Red : Color.White; - int numAfterimages = 5; - - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); - } - } - - Vector2 center = npc.Center - Main.screenPosition; - - //Draw an outline to the arm when it charges up - if ((npc.Calamity().newAI[2] < deathrayTelegraphDuration) && AIState == (float)Phase.Deathray) - { - CalamityUtils.EnterShaderRegion(spriteBatch); - Color outlineColor = Color.Lerp(Color.OrangeRed, Color.White, npc.Calamity().newAI[2] / deathrayTelegraphDuration); - Vector3 outlineHSL = Main.rgbToHsl(outlineColor); //BasicTint uses the opposite hue i guess? or smth is fucked with the way shaders get their colors. anyways, we invert it - float outlineThickness = MathHelper.Clamp(npc.Calamity().newAI[2] / deathrayTelegraphDuration * 4f, 0f, 3f); - - GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(1f); - GameShaders.Misc["CalamityMod:BasicTint"].UseColor(Main.hslToRgb(1 - outlineHSL.X, outlineHSL.Y, outlineHSL.Z)); - GameShaders.Misc["CalamityMod:BasicTint"].Apply(); - - for (float i = 0; i < 1; i += 0.125f) - { - spriteBatch.Draw(texture, center + (i * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * outlineThickness, frame, outlineColor, npc.rotation, vector, npc.scale, spriteEffects, 0f); - } - CalamityUtils.ExitShaderRegion(spriteBatch); - } - - spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); - - Texture2D glowTexture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresLaserCannonGlow"); - - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(glowTexture.Width, glowTexture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(glowTexture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(glowTexture, center, frame, afterimageBaseColor * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); - - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - //Update the parameters - - - - //Draw a pulsing version of the cannon above the real one. - if ((npc.Calamity().newAI[2] < deathrayTelegraphDuration) && AIState == (float)Phase.Deathray) - { - //Also draw a telegraph line aha - Texture2D lineTex = ModContent.GetTexture("CalamityMod/Particles/BloomLine"); - Color outlineColor = Color.Lerp(Color.OrangeRed, Color.White, npc.Calamity().newAI[2] / deathrayTelegraphDuration); - spriteBatch.Draw(lineTex, CoreSpritePosition - npc.rotation.ToRotationVector2() * npc.spriteDirection * 104 - Main.screenPosition, null, outlineColor, npc.rotation - MathHelper.PiOver2 * npc.spriteDirection, new Vector2(lineTex.Width / 2f, lineTex.Height), new Vector2(1f * npc.Calamity().newAI[2] / deathrayTelegraphDuration, 2000f), spriteEffects, 0f); - - float pulseRatio = (npc.Calamity().newAI[2] % (deathrayTelegraphDuration / 5f)) / (deathrayTelegraphDuration / 5f); - float pulseSize = MathHelper.Lerp(0.1f, 0.6f, (float)Math.Floor(npc.Calamity().newAI[2] / (deathrayTelegraphDuration / 5f)) / 4f); - float pulseOpacity = MathHelper.Clamp((float)Math.Floor(npc.Calamity().newAI[2] / (deathrayTelegraphDuration / 5f)) * 0.3f, 1f, 2f); - spriteBatch.Draw(texture, center, frame, Color.OrangeRed * MathHelper.Lerp(1f, 0f, pulseRatio) * pulseOpacity, npc.rotation, vector, npc.scale + pulseRatio * pulseSize, spriteEffects, 0f); - - //Draw the bloom - EnergyDrawer.DrawBloom(CoreSpritePosition); - } - - EnergyDrawer.DrawPulses(CoreSpritePosition); - EnergyDrawer.DrawSet(CoreSpritePosition); - - //Back to normal - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - - return false; - } - - public override void DrawBehind(int index) - { - Main.instance.DrawCacheNPCProjectiles.Add(index); - } - - public override bool PreNPCLoot() => false; - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); - - if (npc.life <= 0) - { - for (int num193 = 0; num193 < 2; num193++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresLaserCannon1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresLaserCannon2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); - } - } - - public override bool CheckActive() => false; - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * 0.8f); - } + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + // Percent life remaining + float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoWormAlive = false; + bool exoTwinsAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + otherExoMechsAlive++; + exoWormAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoTwinsAlive = true; + } + } + + // Used to nerf Ares if fighting alongside Artemis and Apollo, because otherwise it's too difficult + bool nerfedAttacks = false; + if (exoTwinsAlive) + nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] != (float)Apollo.Apollo.SecondaryPhase.PassiveAndImmune; + + // Phases + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoTwinsLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoTwinsAlive) + exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + + // If Ares doesn't go berserk + bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; + + // Whether Ares should be buffed while in berserk phase + bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; + + // Target variable + Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); + + // Passive phase check + bool passivePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.Passive; + + // Enrage check + bool enraged = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes; + + // Adjust opacity + bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Variable to fire normal lasers + bool fireNormalLasers = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays; + + // Default vector to fly to + float offsetX = -560f; + float offsetY = 0f; + float offsetX2 = -540f; + float offsetY2 = -540f; + bool flyLeft = true; + switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) + { + case 0: + case 3: + case 4: + break; + + case 1: + case 2: + case 5: + offsetX *= -1f; + offsetX2 *= -1f; + offsetY2 *= -1f; + flyLeft = false; + break; + } + Vector2 destination = fireNormalLasers ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); + + // Rotate the cannon to look at the target while not firing the beam + // Rotate the cannon to look in the direction it will fire only while it's charging or while it's firing + // Rotation + bool horizontalLaserSweep = calamityGlobalNPC.newAI[3] == 0f; + float rateOfRotation = AIState == (int)Phase.Deathray ? 0.08f : 0.04f; + float lookAtX = flyLeft ? 1000f : -1000f; + Vector2 lookAt = AIState == (int)Phase.Deathray && !fireNormalLasers ? (horizontalLaserSweep ? new Vector2(npc.Center.X, npc.Center.Y + 1000f) : new Vector2(npc.Center.X + lookAtX, npc.Center.Y)) : player.Center; + + float rotation = (float)Math.Atan2(lookAt.Y - npc.Center.Y, lookAt.X - npc.Center.X); + if (npc.spriteDirection == 1) + rotation += MathHelper.Pi; + if (rotation < 0f) + rotation += MathHelper.TwoPi; + if (rotation > MathHelper.TwoPi) + rotation -= MathHelper.TwoPi; + + npc.rotation = npc.rotation.AngleTowards(rotation, rateOfRotation); + + // Direction + int direction = Math.Sign(((AIState == (int)Phase.Deathray && !horizontalLaserSweep) || fireNormalLasers ? lookAt.X : player.Center.X) - npc.Center.X); + if (direction != 0) + { + npc.direction = direction; + + if (npc.spriteDirection != -npc.direction) + npc.rotation += MathHelper.Pi; + + npc.spriteDirection = -npc.direction; + } + + // Light + if (enraged) + Lighting.AddLight(npc.Center, 0.5f * npc.Opacity, 0f, 0f); + else + Lighting.AddLight(npc.Center, 0.25f * npc.Opacity, 0.1f * npc.Opacity, 0.1f * npc.Opacity); + + // Despawn if target is dead + if (player.dead) + { + player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + if (player.dead) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.dontTakeDamage = true; + + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 1f; + + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + } + + return; + } + } + + // Velocity and acceleration values + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; + baseVelocity *= 1f + Main.npc[(int)npc.ai[2]].localAI[2]; + float baseAcceleration = shouldGetBuffedByBerserkPhase ? 1.25f : 1f; + + Vector2 distanceFromDestination = destination - npc.Center; + Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination) * baseVelocity; + + // Whether Ares Laser Arm should move to its spot or not + float movementDistanceGateValue = 50f; + bool moveToLocation = Vector2.Distance(npc.Center, destination) > movementDistanceGateValue; + + // Gate values + float deathrayPhaseGateValue = 450f; + if (enraged) + deathrayPhaseGateValue *= 0.1f; + else if (lastMechAlive) + deathrayPhaseGateValue *= 0.3f; + else if (shouldGetBuffedByBerserkPhase) + deathrayPhaseGateValue *= 0.5f; + + float deathrayPhaseVelocity = (nerfedAttacks ? 6f : passivePhase ? 9f : 12f) * baseVelocityMult; + if (lastMechAlive) + deathrayPhaseVelocity *= 1.2f; + else if (shouldGetBuffedByBerserkPhase) + deathrayPhaseVelocity *= 1.1f; + + // If Laser Cannon can fire normal lasers, cannot fire if too close to the target and in deathray spiral phase + bool canFire = Vector2.Distance(npc.Center, player.Center) > 320f || !fireNormalLasers; + + // Telegraph duration for deathray spiral + float deathraySpiralTelegraphDuration = malice ? AresBody.deathrayTelegraphDuration_Malice : death ? AresBody.deathrayTelegraphDuration_Death : + revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; + + // Variable to disable deathray firing + bool doNotFire = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune || + (calamityGlobalNPC_Body.newAI[2] >= deathraySpiralTelegraphDuration + AresBody.deathrayDuration - 10 && fireNormalLasers) || + (calamityGlobalNPC_Body.newAI[3] == 0f && fireNormalLasers); + + if (doNotFire) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + } + + // Emit steam while enraged + SmokeDrawer.ParticleSpawnRate = 9999999; + if (enraged) + { + SmokeDrawer.ParticleSpawnRate = AresBody.ventCloudSpawnRate; + SmokeDrawer.BaseMoveRotation = npc.rotation + MathHelper.Pi; + SmokeDrawer.SpawnAreaCompactness = 40f; + + // Increase DR during enrage + npc.Calamity().DR = 0.85f; + } + else + npc.Calamity().DR = 0.35f; + + SmokeDrawer.Update(); + + EnergyDrawer.ParticleSpawnRate = 9999999; + // Attacking phases + switch ((int)AIState) + { + // Do nothing, rotate to aim at the target and fly in place + case (int)Phase.Nothing: + + // Smooth movement towards the location Ares Laser Cannon is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] >= deathrayPhaseGateValue) + { + AIState = (float)Phase.Deathray; + calamityGlobalNPC.newAI[1] = 0f; + } + + break; + + // Move close to target, reduce velocity when close enough, create telegraph beams, fire deathrays + case (int)Phase.Deathray: + + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] < deathrayTelegraphDuration) + { + // Play a charge up sound so that the player knows when it's about to fire the deathray + if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration - 100f && !fireNormalLasers) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/CrystylCharge"), npc.Center); + + // Smooth movement towards the location Ares Laser Cannon is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + + // Set frames to deathray charge up frames, which begin on frame 12 + if (calamityGlobalNPC.newAI[2] == 1f) + { + // Reset the frame counter + npc.frameCounter = 0D; + + // X = 1 sets to frame 8 + frameX = 1; + + // Y = 4 sets to frame 12 + frameY = 4; + } + + EnergyDrawer.ParticleSpawnRate = AresBody.telegraphParticlesSpawnRate; + EnergyDrawer.SpawnAreaCompactness = 100f; + EnergyDrawer.chargeProgress = calamityGlobalNPC.newAI[2] / deathrayTelegraphDuration; + } + else + { + // Fire regular Thanatos lasers if Ares is in deathray phase, otherwise, fire deathray + if (fireNormalLasers) + { + // Smooth movement towards the location Ares Laser Cannon is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + + // Fire Thanatos lasers + int numLasers = enraged ? 9 : lastMechAlive ? 3 : 2; + float divisor = deathrayDuration / numLasers; + + if (calamityGlobalNPC.newAI[2] % divisor == 0f && canFire) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + Vector2 laserVelocity = Vector2.Normalize(player.Center - npc.Center); + Vector2 offset = laserVelocity * 70f + Vector2.UnitY * 16f; + Projectile.NewProjectile(npc.Center + offset, player.Center, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + else + { + // Two possible variants: 1 - Horizontal, 2 - Vertical + + // Movement while firing deathray + if (horizontalLaserSweep) + desiredVelocity.X = 0f; + else + desiredVelocity.Y = 0f; + + npc.SimpleFlyMovement(desiredVelocity, baseAcceleration); + float velocityX = flyLeft ? deathrayPhaseVelocity : -deathrayPhaseVelocity; + npc.velocity = horizontalLaserSweep ? new Vector2(velocityX, npc.velocity.Y) : new Vector2(npc.velocity.X, deathrayPhaseVelocity * 0.75f); + + npc.netUpdate = true; + npc.netSpam -= 5; + + // Fire deathray + if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float offset = 84f; + float offset2 = 16f; + Vector2 source = horizontalLaserSweep ? new Vector2(npc.Center.X - offset2 * npc.direction, npc.Center.Y + offset) : new Vector2(npc.Center.X + offset * npc.direction, npc.Center.Y + offset2); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), source); + Vector2 laserVelocity = Vector2.Normalize(lookAt - source); + if (laserVelocity.HasNaNs()) + laserVelocity = -Vector2.UnitY; + + Projectile.NewProjectile(source, laserVelocity, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + } + + if (calamityGlobalNPC.newAI[2] % (float)Math.Floor(deathrayTelegraphDuration / 5f) == (float)Math.Floor(deathrayTelegraphDuration / 5f) - 1 && calamityGlobalNPC.newAI[2] <= deathrayTelegraphDuration) + { + float pulseCounter = (float)Math.Floor(calamityGlobalNPC.newAI[2] / (deathrayTelegraphDuration / 5f)) + 1; + EnergyDrawer.AddPulse(pulseCounter); + } + + if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) + { + // Reset + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[2] = 0f; + + // Change deathray sweep type for next deathray phase + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] > 1f) + calamityGlobalNPC.newAI[3] = 0f; + } + + break; + } + + EnergyDrawer.Update(); + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public override void FindFrame(int frameHeight) + { + // Use telegraph frames when using deathrays + npc.frameCounter += 1D; + if (AIState == (float)Phase.Nothing) + { + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 8 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames + if ((frameX * maxFramesY) + frameY > normalFrameLimit) + frameX = frameY = 0; + } + } + else + { + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 8 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames to frame 36, the start of the deathray firing animation loop + if ((frameX * maxFramesY) + frameY > finalStageDeathrayChargeFrameLimit) + frameX = frameY = 4; + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + // Draw the enrage smoke behind Ares + SmokeDrawer.DrawSet(npc.Center); + + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); + Color afterimageBaseColor = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? Color.Red : Color.White; + int numAfterimages = 5; + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); + } + } + + Vector2 center = npc.Center - Main.screenPosition; + + //Draw an outline to the arm when it charges up + if ((npc.Calamity().newAI[2] < deathrayTelegraphDuration) && AIState == (float)Phase.Deathray) + { + CalamityUtils.EnterShaderRegion(spriteBatch); + Color outlineColor = Color.Lerp(Color.OrangeRed, Color.White, npc.Calamity().newAI[2] / deathrayTelegraphDuration); + Vector3 outlineHSL = Main.rgbToHsl(outlineColor); //BasicTint uses the opposite hue i guess? or smth is fucked with the way shaders get their colors. anyways, we invert it + float outlineThickness = MathHelper.Clamp(npc.Calamity().newAI[2] / deathrayTelegraphDuration * 4f, 0f, 3f); + + GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(1f); + GameShaders.Misc["CalamityMod:BasicTint"].UseColor(Main.hslToRgb(1 - outlineHSL.X, outlineHSL.Y, outlineHSL.Z)); + GameShaders.Misc["CalamityMod:BasicTint"].Apply(); + + for (float i = 0; i < 1; i += 0.125f) + { + spriteBatch.Draw(texture, center + (i * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * outlineThickness, frame, outlineColor, npc.rotation, vector, npc.scale, spriteEffects, 0f); + } + CalamityUtils.ExitShaderRegion(spriteBatch); + } + + spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); + + Texture2D glowTexture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresLaserCannonGlow"); + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(glowTexture.Width, glowTexture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(glowTexture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(glowTexture, center, frame, afterimageBaseColor * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + //Update the parameters + + + + //Draw a pulsing version of the cannon above the real one. + if ((npc.Calamity().newAI[2] < deathrayTelegraphDuration) && AIState == (float)Phase.Deathray) + { + //Also draw a telegraph line aha + Texture2D lineTex = ModContent.GetTexture("CalamityMod/Particles/BloomLine"); + Color outlineColor = Color.Lerp(Color.OrangeRed, Color.White, npc.Calamity().newAI[2] / deathrayTelegraphDuration); + spriteBatch.Draw(lineTex, CoreSpritePosition - npc.rotation.ToRotationVector2() * npc.spriteDirection * 104 - Main.screenPosition, null, outlineColor, npc.rotation - MathHelper.PiOver2 * npc.spriteDirection, new Vector2(lineTex.Width / 2f, lineTex.Height), new Vector2(1f * npc.Calamity().newAI[2] / deathrayTelegraphDuration, 2000f), spriteEffects, 0f); + + float pulseRatio = (npc.Calamity().newAI[2] % (deathrayTelegraphDuration / 5f)) / (deathrayTelegraphDuration / 5f); + float pulseSize = MathHelper.Lerp(0.1f, 0.6f, (float)Math.Floor(npc.Calamity().newAI[2] / (deathrayTelegraphDuration / 5f)) / 4f); + float pulseOpacity = MathHelper.Clamp((float)Math.Floor(npc.Calamity().newAI[2] / (deathrayTelegraphDuration / 5f)) * 0.3f, 1f, 2f); + spriteBatch.Draw(texture, center, frame, Color.OrangeRed * MathHelper.Lerp(1f, 0f, pulseRatio) * pulseOpacity, npc.rotation, vector, npc.scale + pulseRatio * pulseSize, spriteEffects, 0f); + + //Draw the bloom + EnergyDrawer.DrawBloom(CoreSpritePosition); + } + + EnergyDrawer.DrawPulses(CoreSpritePosition); + EnergyDrawer.DrawSet(CoreSpritePosition); + + //Back to normal + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + return false; + } + + public override void DrawBehind(int index) + { + Main.instance.DrawCacheNPCProjectiles.Add(index); + } + + public override bool PreNPCLoot() => false; + + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresLaserCannon1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresLaserCannon2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); + } + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * 0.8f); + } } } diff --git a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs index 3ff4fa6418..681151d7ed 100644 --- a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs +++ b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs @@ -14,645 +14,645 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Ares { - public class AresPlasmaFlamethrower : ModNPC + public class AresPlasmaFlamethrower : ModNPC { - public enum Phase - { - Nothing = 0, - PlasmaBolts = 1 - } + public enum Phase + { + Nothing = 0, + PlasmaBolts = 1 + } - public float AIState - { - get => npc.Calamity().newAI[0]; - set => npc.Calamity().newAI[0] = value; - } + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } - public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); - public AresCannonChargeParticleSet EnergyDrawer = new AresCannonChargeParticleSet(-1, 15, 40f, Color.GreenYellow); - public Vector2 CoreSpritePosition => npc.Center + npc.spriteDirection * npc.rotation.ToRotationVector2() * 30f + (npc.rotation + MathHelper.PiOver2).ToRotationVector2() * 15f; + public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); + public AresCannonChargeParticleSet EnergyDrawer = new AresCannonChargeParticleSet(-1, 15, 40f, Color.GreenYellow); + public Vector2 CoreSpritePosition => npc.Center + npc.spriteDirection * npc.rotation.ToRotationVector2() * 30f + (npc.rotation + MathHelper.PiOver2).ToRotationVector2() * 15f; - // Number of frames on the X and Y axis - private const int maxFramesX = 6; - private const int maxFramesY = 8; + // Number of frames on the X and Y axis + private const int maxFramesX = 6; + private const int maxFramesY = 8; - // Counters for frames on the X and Y axis - private int frameX = 0; - private int frameY = 0; + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; - // Frame limit per animation, these are the specific frames where each animation ends - private const int normalFrameLimit = 11; - private const int firstStagePlasmaBoltChargeFrameLimit = 23; - private const int secondStagePlasmaBoltChargeFrameLimit = 35; - private const int finalStagePlasmaBoltChargeFrameLimit = 47; + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit = 11; + private const int firstStagePlasmaBoltChargeFrameLimit = 23; + private const int secondStagePlasmaBoltChargeFrameLimit = 35; + private const int finalStagePlasmaBoltChargeFrameLimit = 47; - // Default life ratio for the other mechs - private const float defaultLifeRatio = 5f; + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; - // Total duration of the plasma bolt telegraph - private const float plasmaBoltTelegraphDuration = 144f; + // Total duration of the plasma bolt telegraph + private const float plasmaBoltTelegraphDuration = 144f; - // Total duration of the plasma bolt firing phase - private const float plasmaBoltDuration = 120f; + // Total duration of the plasma bolt firing phase + private const float plasmaBoltDuration = 120f; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("XF-09 Ares Plasma Cannon"); - NPCID.Sets.TrailingMode[npc.type] = 3; - NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; - } + NPCID.Sets.TrailingMode[npc.type] = 3; + NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; + } public override void SetDefaults() { - npc.npcSlots = 5f; - npc.damage = 100; - npc.width = 152; + npc.npcSlots = 5f; + npc.damage = 100; + npc.width = 152; npc.height = 90; npc.defense = 80; - npc.DR_NERD(0.35f); - npc.LifeMaxNERB(1250000, 1495000, 500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.DR_NERD(0.35f); + npc.LifeMaxNERB(1250000, 1495000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; - npc.Opacity = 0f; + npc.Opacity = 0f; npc.knockBackResist = 0f; - npc.canGhostHeal = false; - npc.noGravity = true; + npc.canGhostHeal = false; + npc.noGravity = true; npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; - npc.boss = true; - npc.hide = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.boss = true; + npc.hide = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(frameX); - writer.Write(frameY); + writer.Write(frameX); + writer.Write(frameY); writer.Write(npc.dontTakeDamage); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { - frameX = reader.ReadInt32(); - frameY = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - CalamityGlobalNPC.draedonExoMechPrimePlasmaCannon = npc.whoAmI; - - npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - - if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - return; - } - - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - - // Percent life remaining - float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; - - // Check if the other exo mechs are alive - int otherExoMechsAlive = 0; - bool exoWormAlive = false; - bool exoTwinsAlive = false; - if (CalamityGlobalNPC.draedonExoMechWorm != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) - { - otherExoMechsAlive++; - exoWormAlive = true; - } - } - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - { - otherExoMechsAlive++; - exoTwinsAlive = true; - } - } - - // Used to nerf Ares if fighting alongside Artemis and Apollo, because otherwise it's too difficult - bool nerfedAttacks = false; - if (exoTwinsAlive) - nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] != (float)Apollo.Apollo.SecondaryPhase.PassiveAndImmune; - - // Phases - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; - - // These are 5 by default to avoid triggering passive phases after the other mechs are dead - float exoWormLifeRatio = defaultLifeRatio; - float exoTwinsLifeRatio = defaultLifeRatio; - if (exoWormAlive) - exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; - if (exoTwinsAlive) - exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; - - // If Ares doesn't go berserk - bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; - - // Whether Ares should be buffed while in berserk phase - bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - - // Target variable - Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; - - CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); - - // Passive phase check - bool passivePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.Passive; - - // Enrage check - bool enraged = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes; - - // Adjust opacity - bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; - npc.dontTakeDamage = invisiblePhase; - if (!invisiblePhase) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } - - // Predictiveness - float predictionAmt = malice ? 20f : death ? 15f : revenge ? 13.75f : expertMode ? 12.5f : 10f; - if (nerfedAttacks) - predictionAmt *= 0.5f; - if (passivePhase) - predictionAmt *= 0.5f; - - Vector2 predictionVector = player.velocity * predictionAmt; - Vector2 rotationVector = player.Center + predictionVector - npc.Center; - - float projectileVelocity = passivePhase ? 9.6f : 12f; - if (lastMechAlive) - projectileVelocity *= 1.2f; - else if (shouldGetBuffedByBerserkPhase) - projectileVelocity *= 1.1f; - - float rateOfRotation = AIState == (int)Phase.PlasmaBolts ? 0.08f : 0.04f; - Vector2 lookAt = Vector2.Normalize(rotationVector) * projectileVelocity; - - float rotation = (float)Math.Atan2(lookAt.Y, lookAt.X); - if (npc.spriteDirection == 1) - rotation += MathHelper.Pi; - if (rotation < 0f) - rotation += MathHelper.TwoPi; - if (rotation > MathHelper.TwoPi) - rotation -= MathHelper.TwoPi; - - npc.rotation = npc.rotation.AngleTowards(rotation, rateOfRotation); - - // Direction - int direction = Math.Sign(player.Center.X - npc.Center.X); - if (direction != 0) - { - npc.direction = direction; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += MathHelper.Pi; - - npc.spriteDirection = -npc.direction; - } - - // Light - if (enraged) - Lighting.AddLight(npc.Center, 0.5f * npc.Opacity, 0f, 0f); - else - Lighting.AddLight(npc.Center, 0.1f * npc.Opacity, 0.25f * npc.Opacity, 0.05f * npc.Opacity); - - // Gate values - bool fireMoreBolts = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays; - float plasmaBoltPhaseGateValue = fireMoreBolts ? 120f : 270f; - if (enraged) - plasmaBoltPhaseGateValue *= 0.1f; - else if (lastMechAlive) - plasmaBoltPhaseGateValue *= 0.4f; - else if (shouldGetBuffedByBerserkPhase) - plasmaBoltPhaseGateValue *= 0.7f; - - // Set attack timer to this when despawning or when Ares is coming out of deathray phase - float setTimerTo = (int)(plasmaBoltPhaseGateValue * 0.95f) - 1; - - // Despawn if target is dead - if (player.dead) - { - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (player.dead) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = setTimerTo; - calamityGlobalNPC.newAI[2] = 0f; - npc.dontTakeDamage = true; - - npc.velocity.Y -= 1f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 1f; - - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - - return; - } - } - - // Default vector to fly to - float offsetX = 375f; - float offsetY = 160f; - float offsetX2 = 540f; - float offsetY2 = -540f; - switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) - { - case 0: - case 1: - case 4: - case 5: - break; - - case 2: - case 3: - offsetX *= -1f; - offsetX2 *= -1f; - offsetY2 *= -1f; - break; - } - Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); - - // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); - float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; - baseVelocity *= 1f + Main.npc[(int)npc.ai[2]].localAI[2]; - - Vector2 distanceFromDestination = destination - npc.Center; - - // Distance where Ares Plasma Arm stops moving - float movementDistanceGateValue = 50f; - - // Make plasma bolts split less if in deathray spiral phase and not the last mech alive, but fire more if in deathray spiral phase - bool boltsSplitLess = fireMoreBolts && !lastMechAlive; - - // If Plasma Cannon can fire projectiles, cannot fire if too close to the target and in deathray spiral phase - bool canFire = Vector2.Distance(npc.Center, player.Center) > 320f || calamityGlobalNPC_Body.newAI[0] != (float)AresBody.Phase.Deathrays; - - // Telegraph duration for deathray spiral - float deathrayTelegraphDuration = malice ? AresBody.deathrayTelegraphDuration_Malice : death ? AresBody.deathrayTelegraphDuration_Death : - revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; - - // Variable to cancel plasma bolt firing - bool doNotFire = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune || - (calamityGlobalNPC_Body.newAI[2] >= deathrayTelegraphDuration + AresBody.deathrayDuration - 10 && calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays) || - (calamityGlobalNPC_Body.newAI[3] == 0f && calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays); - - if (doNotFire) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = setTimerTo; - calamityGlobalNPC.newAI[2] = 0f; - } - - // Emit steam while enraged - SmokeDrawer.ParticleSpawnRate = 9999999; - if (enraged) - { - SmokeDrawer.ParticleSpawnRate = AresBody.ventCloudSpawnRate; - SmokeDrawer.BaseMoveRotation = npc.rotation + MathHelper.Pi; - SmokeDrawer.SpawnAreaCompactness = 40f; - - // Increase DR during enrage - npc.Calamity().DR = 0.85f; - } - else - npc.Calamity().DR = 0.35f; - - SmokeDrawer.Update(); - - - EnergyDrawer.ParticleSpawnRate = 9999999; - // Attacking phases - switch ((int)AIState) - { - // Do nothing and fly in place - case (int)Phase.Nothing: - - calamityGlobalNPC.newAI[1] += 1f; - if (calamityGlobalNPC.newAI[1] >= plasmaBoltPhaseGateValue) - { - AIState = (float)Phase.PlasmaBolts; - calamityGlobalNPC.newAI[1] = 0f; - } - - break; - - // Fire plasma bolts in a double burst that burst into a halo of smaller bolts - case (int)Phase.PlasmaBolts: - - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] < plasmaBoltTelegraphDuration) - { - // Set frames to plasma orb charge up frames, which begin on frame 12 - if (calamityGlobalNPC.newAI[2] == 1f) - { - // Reset the frame counter - npc.frameCounter = 0D; - - // X = 1 sets to frame 8 - frameX = 1; - - // Y = 4 sets to frame 12 - frameY = 4; - } - - EnergyDrawer.ParticleSpawnRate = AresBody.telegraphParticlesSpawnRate; - EnergyDrawer.SpawnAreaCompactness = 100f; - EnergyDrawer.chargeProgress = calamityGlobalNPC.newAI[2] / plasmaBoltTelegraphDuration; - } - else if (calamityGlobalNPC.newAI[2] < plasmaBoltTelegraphDuration + plasmaBoltDuration) - { - // Fire plasma bolts - int numPlasmaBolts = lastMechAlive ? 3 : 2; - float divisor = plasmaBoltDuration / numPlasmaBolts; - - if ((calamityGlobalNPC.newAI[2] - plasmaBoltTelegraphDuration) % divisor == 0f && canFire) - { - npc.ai[3] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaCasterFire"), npc.Center); - Vector2 plasmaBoltVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 offset = Vector2.Normalize(plasmaBoltVelocity) * 40f + Vector2.UnitY * 16f; - - if (boltsSplitLess) - Projectile.NewProjectile(npc.Center + offset, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, -1f); - else - Projectile.NewProjectile(npc.Center + offset, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); - } - } - } - - if (calamityGlobalNPC.newAI[2] % (float)Math.Floor(plasmaBoltTelegraphDuration / 5f) == (float)Math.Floor(plasmaBoltTelegraphDuration / 5f) - 1 && calamityGlobalNPC.newAI[2] <= plasmaBoltTelegraphDuration) - { - float pulseCounter = (float)Math.Floor(calamityGlobalNPC.newAI[2] / (plasmaBoltTelegraphDuration / 5f)) + 1; - EnergyDrawer.AddPulse(pulseCounter); - } - - if (calamityGlobalNPC.newAI[2] >= plasmaBoltTelegraphDuration + plasmaBoltDuration) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[2] = 0f; - } - - break; - } - - EnergyDrawer.Update(); - - // Smooth movement towards the location Ares Plasma Flamethrower is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; - - public override void FindFrame(int frameHeight) - { - // Use telegraph frames when using plasma bolts - npc.frameCounter += 1D; - if (AIState == (float)Phase.Nothing) - { - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 8 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames - if ((frameX * maxFramesY) + frameY > normalFrameLimit) - frameX = frameY = 0; - } - } - else - { - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 8 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames to frame 36, the start of the plasma bolt firing animation loop - if ((frameX * maxFramesY) + frameY > finalStagePlasmaBoltChargeFrameLimit) - frameX = frameY = 4; - } - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - // Draw the enrage smoke behind Ares - SmokeDrawer.DrawSet(npc.Center); - - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture = Main.npcTexture[npc.type]; - Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); - Color afterimageBaseColor = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? Color.Red : Color.White; - int numAfterimages = 5; - - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); - } - } - - Vector2 center = npc.Center - Main.screenPosition; - - //Draw an outline to the arm when it charges up - if ((npc.Calamity().newAI[2] < plasmaBoltTelegraphDuration) && AIState == (float)Phase.PlasmaBolts) - { - CalamityUtils.EnterShaderRegion(spriteBatch); - Color outlineColor = Color.Lerp(Color.GreenYellow, Color.White, npc.Calamity().newAI[2] / plasmaBoltTelegraphDuration); - Vector3 outlineHSL = Main.rgbToHsl(outlineColor); //BasicTint uses the opposite hue i guess? or smth is fucked with the way shaders get their colors. anyways, we invert it - float outlineThickness = MathHelper.Clamp(npc.Calamity().newAI[2] / plasmaBoltTelegraphDuration * 4f, 0f, 3f); - - GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(1f); - GameShaders.Misc["CalamityMod:BasicTint"].UseColor(Main.hslToRgb(1 - outlineHSL.X, outlineHSL.Y, outlineHSL.Z)); - GameShaders.Misc["CalamityMod:BasicTint"].Apply(); - - for (float i = 0; i < 1; i += 0.125f) - { - spriteBatch.Draw(texture, center + (i * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * outlineThickness, frame, outlineColor, npc.rotation, vector, npc.scale, spriteEffects, 0f); - } - CalamityUtils.ExitShaderRegion(spriteBatch); - } - - spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); - - Texture2D glowTexture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresPlasmaFlamethrowerGlow"); - - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(glowTexture.Width, glowTexture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(glowTexture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(glowTexture, center, frame, afterimageBaseColor * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); - - - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - //Update the parameters - - //Draw a pulsing version of the cannon above the real one - if ((npc.Calamity().newAI[2] < plasmaBoltTelegraphDuration) && AIState == (float)Phase.PlasmaBolts) - { - - float pulseRatio = (npc.Calamity().newAI[2] % (plasmaBoltTelegraphDuration / 5f)) / (plasmaBoltTelegraphDuration / 5f); - float pulseSize = MathHelper.Lerp(0.1f, 0.6f, (float)Math.Floor(npc.Calamity().newAI[2] / (plasmaBoltTelegraphDuration / 5f)) / 4f); - float pulseOpacity = MathHelper.Clamp((float)Math.Floor(npc.Calamity().newAI[2] / (plasmaBoltTelegraphDuration / 5f)) * 0.3f, 1f, 2f); - spriteBatch.Draw(texture, center, frame, Color.GreenYellow * MathHelper.Lerp(1f, 0f, pulseRatio) * pulseOpacity, npc.rotation, vector, npc.scale + pulseRatio * pulseSize, spriteEffects, 0f); - - //Draw the bloom - EnergyDrawer.DrawBloom(CoreSpritePosition); - } - - EnergyDrawer.DrawPulses(CoreSpritePosition); - EnergyDrawer.DrawSet(CoreSpritePosition); - - //Back to normal - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - - return false; - } - - public override void DrawBehind(int index) - { - Main.instance.DrawCacheNPCProjectiles.Add(index); - } - - public override bool PreNPCLoot() => false; - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); - - if (npc.life <= 0) - { - for (int num193 = 0; num193 < 2; num193++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresPlasmaFlamethrower1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresPlasmaFlamethrower2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); - } - } - - public override bool CheckActive() => false; - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * 0.8f); - } + frameX = reader.ReadInt32(); + frameY = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + CalamityGlobalNPC.draedonExoMechPrimePlasmaCannon = npc.whoAmI; + + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + // Percent life remaining + float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoWormAlive = false; + bool exoTwinsAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + otherExoMechsAlive++; + exoWormAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoTwinsAlive = true; + } + } + + // Used to nerf Ares if fighting alongside Artemis and Apollo, because otherwise it's too difficult + bool nerfedAttacks = false; + if (exoTwinsAlive) + nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] != (float)Apollo.Apollo.SecondaryPhase.PassiveAndImmune; + + // Phases + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoTwinsLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoTwinsAlive) + exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + + // If Ares doesn't go berserk + bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; + + // Whether Ares should be buffed while in berserk phase + bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; + + // Target variable + Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); + + // Passive phase check + bool passivePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.Passive; + + // Enrage check + bool enraged = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes; + + // Adjust opacity + bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Predictiveness + float predictionAmt = malice ? 20f : death ? 15f : revenge ? 13.75f : expertMode ? 12.5f : 10f; + if (nerfedAttacks) + predictionAmt *= 0.5f; + if (passivePhase) + predictionAmt *= 0.5f; + + Vector2 predictionVector = player.velocity * predictionAmt; + Vector2 rotationVector = player.Center + predictionVector - npc.Center; + + float projectileVelocity = passivePhase ? 9.6f : 12f; + if (lastMechAlive) + projectileVelocity *= 1.2f; + else if (shouldGetBuffedByBerserkPhase) + projectileVelocity *= 1.1f; + + float rateOfRotation = AIState == (int)Phase.PlasmaBolts ? 0.08f : 0.04f; + Vector2 lookAt = Vector2.Normalize(rotationVector) * projectileVelocity; + + float rotation = (float)Math.Atan2(lookAt.Y, lookAt.X); + if (npc.spriteDirection == 1) + rotation += MathHelper.Pi; + if (rotation < 0f) + rotation += MathHelper.TwoPi; + if (rotation > MathHelper.TwoPi) + rotation -= MathHelper.TwoPi; + + npc.rotation = npc.rotation.AngleTowards(rotation, rateOfRotation); + + // Direction + int direction = Math.Sign(player.Center.X - npc.Center.X); + if (direction != 0) + { + npc.direction = direction; + + if (npc.spriteDirection != -npc.direction) + npc.rotation += MathHelper.Pi; + + npc.spriteDirection = -npc.direction; + } + + // Light + if (enraged) + Lighting.AddLight(npc.Center, 0.5f * npc.Opacity, 0f, 0f); + else + Lighting.AddLight(npc.Center, 0.1f * npc.Opacity, 0.25f * npc.Opacity, 0.05f * npc.Opacity); + + // Gate values + bool fireMoreBolts = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays; + float plasmaBoltPhaseGateValue = fireMoreBolts ? 120f : 270f; + if (enraged) + plasmaBoltPhaseGateValue *= 0.1f; + else if (lastMechAlive) + plasmaBoltPhaseGateValue *= 0.4f; + else if (shouldGetBuffedByBerserkPhase) + plasmaBoltPhaseGateValue *= 0.7f; + + // Set attack timer to this when despawning or when Ares is coming out of deathray phase + float setTimerTo = (int)(plasmaBoltPhaseGateValue * 0.95f) - 1; + + // Despawn if target is dead + if (player.dead) + { + player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + if (player.dead) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = setTimerTo; + calamityGlobalNPC.newAI[2] = 0f; + npc.dontTakeDamage = true; + + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 1f; + + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + } + + return; + } + } + + // Default vector to fly to + float offsetX = 375f; + float offsetY = 160f; + float offsetX2 = 540f; + float offsetY2 = -540f; + switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) + { + case 0: + case 1: + case 4: + case 5: + break; + + case 2: + case 3: + offsetX *= -1f; + offsetX2 *= -1f; + offsetY2 *= -1f; + break; + } + Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); + + // Velocity and acceleration values + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; + baseVelocity *= 1f + Main.npc[(int)npc.ai[2]].localAI[2]; + + Vector2 distanceFromDestination = destination - npc.Center; + + // Distance where Ares Plasma Arm stops moving + float movementDistanceGateValue = 50f; + + // Make plasma bolts split less if in deathray spiral phase and not the last mech alive, but fire more if in deathray spiral phase + bool boltsSplitLess = fireMoreBolts && !lastMechAlive; + + // If Plasma Cannon can fire projectiles, cannot fire if too close to the target and in deathray spiral phase + bool canFire = Vector2.Distance(npc.Center, player.Center) > 320f || calamityGlobalNPC_Body.newAI[0] != (float)AresBody.Phase.Deathrays; + + // Telegraph duration for deathray spiral + float deathrayTelegraphDuration = malice ? AresBody.deathrayTelegraphDuration_Malice : death ? AresBody.deathrayTelegraphDuration_Death : + revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; + + // Variable to cancel plasma bolt firing + bool doNotFire = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune || + (calamityGlobalNPC_Body.newAI[2] >= deathrayTelegraphDuration + AresBody.deathrayDuration - 10 && calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays) || + (calamityGlobalNPC_Body.newAI[3] == 0f && calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays); + + if (doNotFire) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = setTimerTo; + calamityGlobalNPC.newAI[2] = 0f; + } + + // Emit steam while enraged + SmokeDrawer.ParticleSpawnRate = 9999999; + if (enraged) + { + SmokeDrawer.ParticleSpawnRate = AresBody.ventCloudSpawnRate; + SmokeDrawer.BaseMoveRotation = npc.rotation + MathHelper.Pi; + SmokeDrawer.SpawnAreaCompactness = 40f; + + // Increase DR during enrage + npc.Calamity().DR = 0.85f; + } + else + npc.Calamity().DR = 0.35f; + + SmokeDrawer.Update(); + + + EnergyDrawer.ParticleSpawnRate = 9999999; + // Attacking phases + switch ((int)AIState) + { + // Do nothing and fly in place + case (int)Phase.Nothing: + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] >= plasmaBoltPhaseGateValue) + { + AIState = (float)Phase.PlasmaBolts; + calamityGlobalNPC.newAI[1] = 0f; + } + + break; + + // Fire plasma bolts in a double burst that burst into a halo of smaller bolts + case (int)Phase.PlasmaBolts: + + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] < plasmaBoltTelegraphDuration) + { + // Set frames to plasma orb charge up frames, which begin on frame 12 + if (calamityGlobalNPC.newAI[2] == 1f) + { + // Reset the frame counter + npc.frameCounter = 0D; + + // X = 1 sets to frame 8 + frameX = 1; + + // Y = 4 sets to frame 12 + frameY = 4; + } + + EnergyDrawer.ParticleSpawnRate = AresBody.telegraphParticlesSpawnRate; + EnergyDrawer.SpawnAreaCompactness = 100f; + EnergyDrawer.chargeProgress = calamityGlobalNPC.newAI[2] / plasmaBoltTelegraphDuration; + } + else if (calamityGlobalNPC.newAI[2] < plasmaBoltTelegraphDuration + plasmaBoltDuration) + { + // Fire plasma bolts + int numPlasmaBolts = lastMechAlive ? 3 : 2; + float divisor = plasmaBoltDuration / numPlasmaBolts; + + if ((calamityGlobalNPC.newAI[2] - plasmaBoltTelegraphDuration) % divisor == 0f && canFire) + { + npc.ai[3] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaCasterFire"), npc.Center); + Vector2 plasmaBoltVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Vector2 offset = Vector2.Normalize(plasmaBoltVelocity) * 40f + Vector2.UnitY * 16f; + + if (boltsSplitLess) + Projectile.NewProjectile(npc.Center + offset, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, -1f); + else + Projectile.NewProjectile(npc.Center + offset, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); + } + } + } + + if (calamityGlobalNPC.newAI[2] % (float)Math.Floor(plasmaBoltTelegraphDuration / 5f) == (float)Math.Floor(plasmaBoltTelegraphDuration / 5f) - 1 && calamityGlobalNPC.newAI[2] <= plasmaBoltTelegraphDuration) + { + float pulseCounter = (float)Math.Floor(calamityGlobalNPC.newAI[2] / (plasmaBoltTelegraphDuration / 5f)) + 1; + EnergyDrawer.AddPulse(pulseCounter); + } + + if (calamityGlobalNPC.newAI[2] >= plasmaBoltTelegraphDuration + plasmaBoltDuration) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[2] = 0f; + } + + break; + } + + EnergyDrawer.Update(); + + // Smooth movement towards the location Ares Plasma Flamethrower is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public override void FindFrame(int frameHeight) + { + // Use telegraph frames when using plasma bolts + npc.frameCounter += 1D; + if (AIState == (float)Phase.Nothing) + { + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 8 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames + if ((frameX * maxFramesY) + frameY > normalFrameLimit) + frameX = frameY = 0; + } + } + else + { + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 8 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames to frame 36, the start of the plasma bolt firing animation loop + if ((frameX * maxFramesY) + frameY > finalStagePlasmaBoltChargeFrameLimit) + frameX = frameY = 4; + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + // Draw the enrage smoke behind Ares + SmokeDrawer.DrawSet(npc.Center); + + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); + Color afterimageBaseColor = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? Color.Red : Color.White; + int numAfterimages = 5; + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); + } + } + + Vector2 center = npc.Center - Main.screenPosition; + + //Draw an outline to the arm when it charges up + if ((npc.Calamity().newAI[2] < plasmaBoltTelegraphDuration) && AIState == (float)Phase.PlasmaBolts) + { + CalamityUtils.EnterShaderRegion(spriteBatch); + Color outlineColor = Color.Lerp(Color.GreenYellow, Color.White, npc.Calamity().newAI[2] / plasmaBoltTelegraphDuration); + Vector3 outlineHSL = Main.rgbToHsl(outlineColor); //BasicTint uses the opposite hue i guess? or smth is fucked with the way shaders get their colors. anyways, we invert it + float outlineThickness = MathHelper.Clamp(npc.Calamity().newAI[2] / plasmaBoltTelegraphDuration * 4f, 0f, 3f); + + GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(1f); + GameShaders.Misc["CalamityMod:BasicTint"].UseColor(Main.hslToRgb(1 - outlineHSL.X, outlineHSL.Y, outlineHSL.Z)); + GameShaders.Misc["CalamityMod:BasicTint"].Apply(); + + for (float i = 0; i < 1; i += 0.125f) + { + spriteBatch.Draw(texture, center + (i * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * outlineThickness, frame, outlineColor, npc.rotation, vector, npc.scale, spriteEffects, 0f); + } + CalamityUtils.ExitShaderRegion(spriteBatch); + } + + spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); + + Texture2D glowTexture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresPlasmaFlamethrowerGlow"); + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(glowTexture.Width, glowTexture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(glowTexture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(glowTexture, center, frame, afterimageBaseColor * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); + + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + //Update the parameters + + //Draw a pulsing version of the cannon above the real one + if ((npc.Calamity().newAI[2] < plasmaBoltTelegraphDuration) && AIState == (float)Phase.PlasmaBolts) + { + + float pulseRatio = (npc.Calamity().newAI[2] % (plasmaBoltTelegraphDuration / 5f)) / (plasmaBoltTelegraphDuration / 5f); + float pulseSize = MathHelper.Lerp(0.1f, 0.6f, (float)Math.Floor(npc.Calamity().newAI[2] / (plasmaBoltTelegraphDuration / 5f)) / 4f); + float pulseOpacity = MathHelper.Clamp((float)Math.Floor(npc.Calamity().newAI[2] / (plasmaBoltTelegraphDuration / 5f)) * 0.3f, 1f, 2f); + spriteBatch.Draw(texture, center, frame, Color.GreenYellow * MathHelper.Lerp(1f, 0f, pulseRatio) * pulseOpacity, npc.rotation, vector, npc.scale + pulseRatio * pulseSize, spriteEffects, 0f); + + //Draw the bloom + EnergyDrawer.DrawBloom(CoreSpritePosition); + } + + EnergyDrawer.DrawPulses(CoreSpritePosition); + EnergyDrawer.DrawSet(CoreSpritePosition); + + //Back to normal + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + return false; + } + + public override void DrawBehind(int index) + { + Main.instance.DrawCacheNPCProjectiles.Add(index); + } + + public override bool PreNPCLoot() => false; + + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresPlasmaFlamethrower1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresPlasmaFlamethrower2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); + } + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * 0.8f); + } } } diff --git a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs index 632dd005a6..b185e72892 100644 --- a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs +++ b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs @@ -14,638 +14,638 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Ares { - public class AresTeslaCannon : ModNPC + public class AresTeslaCannon : ModNPC { - public enum Phase - { - Nothing = 0, - TeslaOrbs = 1 - } + public enum Phase + { + Nothing = 0, + TeslaOrbs = 1 + } - public float AIState - { - get => npc.Calamity().newAI[0]; - set => npc.Calamity().newAI[0] = value; - } + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } - public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); - public AresCannonChargeParticleSet EnergyDrawer = new AresCannonChargeParticleSet(-1, 15, 40f, Color.Aqua); - public Vector2 CoreSpritePosition => npc.Center + npc.spriteDirection * npc.rotation.ToRotationVector2() * 35f + (npc.rotation + MathHelper.PiOver2).ToRotationVector2() * 5f; + public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); + public AresCannonChargeParticleSet EnergyDrawer = new AresCannonChargeParticleSet(-1, 15, 40f, Color.Aqua); + public Vector2 CoreSpritePosition => npc.Center + npc.spriteDirection * npc.rotation.ToRotationVector2() * 35f + (npc.rotation + MathHelper.PiOver2).ToRotationVector2() * 5f; - // Number of frames on the X and Y axis - private const int maxFramesX = 6; - private const int maxFramesY = 8; + // Number of frames on the X and Y axis + private const int maxFramesX = 6; + private const int maxFramesY = 8; - // Counters for frames on the X and Y axis - private int frameX = 0; - private int frameY = 0; + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; - // Frame limit per animation, these are the specific frames where each animation ends - private const int normalFrameLimit = 11; - private const int firstStageTeslaOrbChargeFrameLimit = 23; - private const int secondStageTeslaOrbChargeFrameLimit = 35; - private const int finalStageTeslaOrbChargeFrameLimit = 47; + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit = 11; + private const int firstStageTeslaOrbChargeFrameLimit = 23; + private const int secondStageTeslaOrbChargeFrameLimit = 35; + private const int finalStageTeslaOrbChargeFrameLimit = 47; - // Default life ratio for the other mechs - private const float defaultLifeRatio = 5f; + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; - // Total duration of the tesla orb telegraph - private const float teslaOrbTelegraphDuration = 144f; + // Total duration of the tesla orb telegraph + private const float teslaOrbTelegraphDuration = 144f; - // Total duration of the tesla orb firing phase - private const float teslaOrbDuration = 120f; + // Total duration of the tesla orb firing phase + private const float teslaOrbDuration = 120f; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("XF-09 Ares Tesla Cannon"); - NPCID.Sets.TrailingMode[npc.type] = 3; - NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; - } + NPCID.Sets.TrailingMode[npc.type] = 3; + NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; + } public override void SetDefaults() { - npc.npcSlots = 5f; - npc.damage = 100; - npc.width = 172; + npc.npcSlots = 5f; + npc.damage = 100; + npc.width = 172; npc.height = 108; npc.defense = 80; - npc.DR_NERD(0.35f); - npc.LifeMaxNERB(1250000, 1495000, 500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.DR_NERD(0.35f); + npc.LifeMaxNERB(1250000, 1495000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; - npc.Opacity = 0f; + npc.Opacity = 0f; npc.knockBackResist = 0f; - npc.canGhostHeal = false; - npc.noGravity = true; + npc.canGhostHeal = false; + npc.noGravity = true; npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; - npc.boss = true; - npc.hide = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.boss = true; + npc.hide = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(frameX); - writer.Write(frameY); + writer.Write(frameX); + writer.Write(frameY); writer.Write(npc.dontTakeDamage); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { - frameX = reader.ReadInt32(); - frameY = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + frameX = reader.ReadInt32(); + frameY = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } - public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - return; - } + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - // Percent life remaining - float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + // Percent life remaining + float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; - // Check if the other exo mechs are alive - int otherExoMechsAlive = 0; - bool exoWormAlive = false; - bool exoTwinsAlive = false; - if (CalamityGlobalNPC.draedonExoMechWorm != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) - { - otherExoMechsAlive++; - exoWormAlive = true; - } - } - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - { - otherExoMechsAlive++; - exoTwinsAlive = true; - } - } + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoWormAlive = false; + bool exoTwinsAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + otherExoMechsAlive++; + exoWormAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoTwinsAlive = true; + } + } - // Used to nerf Ares if fighting alongside Artemis and Apollo, because otherwise it's too difficult - bool nerfedAttacks = false; - if (exoTwinsAlive) - nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] != (float)Apollo.Apollo.SecondaryPhase.PassiveAndImmune; + // Used to nerf Ares if fighting alongside Artemis and Apollo, because otherwise it's too difficult + bool nerfedAttacks = false; + if (exoTwinsAlive) + nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] != (float)Apollo.Apollo.SecondaryPhase.PassiveAndImmune; - // Phases - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; + // Phases + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; - // These are 5 by default to avoid triggering passive phases after the other mechs are dead - float exoWormLifeRatio = defaultLifeRatio; - float exoTwinsLifeRatio = defaultLifeRatio; - if (exoWormAlive) - exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; - if (exoTwinsAlive) - exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoTwinsLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoTwinsAlive) + exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; - // If Ares doesn't go berserk - bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; + // If Ares doesn't go berserk + bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; - // Whether Ares should be buffed while in berserk phase - bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; + // Whether Ares should be buffed while in berserk phase + bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - // Target variable - Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + // Target variable + Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; - CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); - // Passive phase check - bool passivePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.Passive; + // Passive phase check + bool passivePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.Passive; - // Enrage check - bool enraged = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes; + // Enrage check + bool enraged = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes; - // Adjust opacity - bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; - npc.dontTakeDamage = invisiblePhase; - if (!invisiblePhase) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } + // Adjust opacity + bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } - // Predictiveness - float predictionAmt = malice ? 40f : death ? 30f : revenge ? 27.5f : expertMode ? 25f : 20f; - if (nerfedAttacks) - predictionAmt *= 0.5f; - if (passivePhase) - predictionAmt *= 0.5f; - if (lastMechAlive) - predictionAmt *= 1.5f; + // Predictiveness + float predictionAmt = malice ? 40f : death ? 30f : revenge ? 27.5f : expertMode ? 25f : 20f; + if (nerfedAttacks) + predictionAmt *= 0.5f; + if (passivePhase) + predictionAmt *= 0.5f; + if (lastMechAlive) + predictionAmt *= 1.5f; - Vector2 predictionVector = player.velocity * predictionAmt; - Vector2 rotationVector = player.Center + predictionVector - npc.Center; + Vector2 predictionVector = player.velocity * predictionAmt; + Vector2 rotationVector = player.Center + predictionVector - npc.Center; - bool fireMoreOrbs = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays; - float projectileVelocity = (passivePhase || fireMoreOrbs) ? 5.2f : 7.8f; - if (lastMechAlive) - projectileVelocity *= 1.2f; - else if (shouldGetBuffedByBerserkPhase) - projectileVelocity *= 1.1f; + bool fireMoreOrbs = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays; + float projectileVelocity = (passivePhase || fireMoreOrbs) ? 5.2f : 7.8f; + if (lastMechAlive) + projectileVelocity *= 1.2f; + else if (shouldGetBuffedByBerserkPhase) + projectileVelocity *= 1.1f; - float rateOfRotation = AIState == (int)Phase.TeslaOrbs ? 0.08f : 0.04f; - Vector2 lookAt = Vector2.Normalize(rotationVector) * projectileVelocity; + float rateOfRotation = AIState == (int)Phase.TeslaOrbs ? 0.08f : 0.04f; + Vector2 lookAt = Vector2.Normalize(rotationVector) * projectileVelocity; - float rotation = (float)Math.Atan2(lookAt.Y, lookAt.X); - if (npc.spriteDirection == 1) - rotation += MathHelper.Pi; - if (rotation < 0f) - rotation += MathHelper.TwoPi; - if (rotation > MathHelper.TwoPi) - rotation -= MathHelper.TwoPi; + float rotation = (float)Math.Atan2(lookAt.Y, lookAt.X); + if (npc.spriteDirection == 1) + rotation += MathHelper.Pi; + if (rotation < 0f) + rotation += MathHelper.TwoPi; + if (rotation > MathHelper.TwoPi) + rotation -= MathHelper.TwoPi; - npc.rotation = npc.rotation.AngleTowards(rotation, rateOfRotation); + npc.rotation = npc.rotation.AngleTowards(rotation, rateOfRotation); - // Direction - int direction = Math.Sign(player.Center.X - npc.Center.X); - if (direction != 0) - { - npc.direction = direction; + // Direction + int direction = Math.Sign(player.Center.X - npc.Center.X); + if (direction != 0) + { + npc.direction = direction; - if (npc.spriteDirection != -npc.direction) - npc.rotation += MathHelper.Pi; + if (npc.spriteDirection != -npc.direction) + npc.rotation += MathHelper.Pi; - npc.spriteDirection = -npc.direction; - } + npc.spriteDirection = -npc.direction; + } - // Light - if (enraged) - Lighting.AddLight(npc.Center, 0.5f * npc.Opacity, 0f, 0f); - else - Lighting.AddLight(npc.Center, 0.1f * npc.Opacity, 0.25f * npc.Opacity, 0.25f * npc.Opacity); + // Light + if (enraged) + Lighting.AddLight(npc.Center, 0.5f * npc.Opacity, 0f, 0f); + else + Lighting.AddLight(npc.Center, 0.1f * npc.Opacity, 0.25f * npc.Opacity, 0.25f * npc.Opacity); - // Gate values - float teslaOrbPhaseGateValue = fireMoreOrbs ? 120f : 270f; - if (enraged) - teslaOrbPhaseGateValue *= 0.1f; - else if (lastMechAlive) - teslaOrbPhaseGateValue *= 0.4f; - else if (shouldGetBuffedByBerserkPhase) - teslaOrbPhaseGateValue *= 0.7f; + // Gate values + float teslaOrbPhaseGateValue = fireMoreOrbs ? 120f : 270f; + if (enraged) + teslaOrbPhaseGateValue *= 0.1f; + else if (lastMechAlive) + teslaOrbPhaseGateValue *= 0.4f; + else if (shouldGetBuffedByBerserkPhase) + teslaOrbPhaseGateValue *= 0.7f; - // Set attack timer to this when despawning or when Ares is coming out of deathray phase - float setTimerTo = (int)(teslaOrbPhaseGateValue * 0.3f) - 1; + // Set attack timer to this when despawning or when Ares is coming out of deathray phase + float setTimerTo = (int)(teslaOrbPhaseGateValue * 0.3f) - 1; - // Despawn if target is dead - if (player.dead) - { - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (player.dead) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = setTimerTo; - calamityGlobalNPC.newAI[2] = 0f; - npc.dontTakeDamage = true; + // Despawn if target is dead + if (player.dead) + { + player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + if (player.dead) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = setTimerTo; + calamityGlobalNPC.newAI[2] = 0f; + npc.dontTakeDamage = true; - npc.velocity.Y -= 1f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 1f; + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 1f; - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - - return; - } - } - - // Default vector to fly to - float offsetX = -375f; - float offsetY = 160f; - float offsetX2 = -540f; - float offsetY2 = 540f; - switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) - { - case 0: - case 1: - case 4: - case 5: - break; - - case 2: - case 3: - offsetX *= -1f; - offsetX2 *= -1f; - offsetY2 *= -1f; - break; - } - Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); - - // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); - float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; - baseVelocity *= 1f + Main.npc[(int)npc.ai[2]].localAI[2]; - - Vector2 distanceFromDestination = destination - npc.Center; - - // Distance where Ares Tesla Arm stops moving - float movementDistanceGateValue = 50f; - - // If Tesla Cannon can fire projectiles, cannot fire if too close to the target and in deathray spiral phase - bool canFire = Vector2.Distance(npc.Center, player.Center) > 320f || calamityGlobalNPC_Body.newAI[0] != (float)AresBody.Phase.Deathrays; - - // Telegraph duration for deathray spiral - float deathrayTelegraphDuration = malice ? AresBody.deathrayTelegraphDuration_Malice : death ? AresBody.deathrayTelegraphDuration_Death : - revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; - - // Variable to cancel tesla orb firing - bool doNotFire = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune || - (calamityGlobalNPC_Body.newAI[2] >= deathrayTelegraphDuration + AresBody.deathrayDuration - 10 && calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays) || - (calamityGlobalNPC_Body.newAI[3] == 0f && calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays); - - if (doNotFire) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = setTimerTo; - calamityGlobalNPC.newAI[2] = 0f; - } - - // Emit steam while enraged - SmokeDrawer.ParticleSpawnRate = 9999999; - if (enraged) - { - SmokeDrawer.ParticleSpawnRate = AresBody.ventCloudSpawnRate; - SmokeDrawer.BaseMoveRotation = npc.rotation + MathHelper.Pi; - SmokeDrawer.SpawnAreaCompactness = 40f; - - // Increase DR during enrage - npc.Calamity().DR = 0.85f; - } - else - npc.Calamity().DR = 0.35f; - - SmokeDrawer.Update(); - - EnergyDrawer.ParticleSpawnRate = 9999999; - // Attacking phases - switch ((int)AIState) - { - // Do nothing and fly in place - case (int)Phase.Nothing: - - calamityGlobalNPC.newAI[1] += 1f; - if (calamityGlobalNPC.newAI[1] >= teslaOrbPhaseGateValue) - { - AIState = (float)Phase.TeslaOrbs; - calamityGlobalNPC.newAI[1] = 0f; - } - - break; - - // Fire tesla orbs in a quadruple burst that arc electricity between them - case (int)Phase.TeslaOrbs: - - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] < teslaOrbTelegraphDuration) - { - // Set frames to tesla orb charge up frames, which begin on frame 12 - if (calamityGlobalNPC.newAI[2] == 1f) - { - // Reset the frame counter - npc.frameCounter = 0D; - - // X = 1 sets to frame 8 - frameX = 1; - - // Y = 4 sets to frame 12 - frameY = 4; - } - - EnergyDrawer.ParticleSpawnRate = AresBody.telegraphParticlesSpawnRate; - EnergyDrawer.SpawnAreaCompactness = 100f; - EnergyDrawer.chargeProgress = calamityGlobalNPC.newAI[2] / teslaOrbTelegraphDuration; - - } - else if (calamityGlobalNPC.newAI[2] < teslaOrbTelegraphDuration + teslaOrbDuration) - { - // Fire tesla orbs - int numTeslaOrbs = lastMechAlive ? 6 : shouldGetBuffedByBerserkPhase ? 5 : nerfedAttacks ? 3 : 4; - float divisor = teslaOrbDuration / numTeslaOrbs; - - if ((calamityGlobalNPC.newAI[2] - teslaOrbTelegraphDuration) % divisor == 0f && canFire) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBolt"), npc.Center); - Vector2 teslaOrbVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 offset = Vector2.Normalize(teslaOrbVelocity) * 40f + Vector2.UnitY * 8f; - float identity = fireMoreOrbs ? -2f : calamityGlobalNPC.newAI[3] + (calamityGlobalNPC.newAI[2] - teslaOrbTelegraphDuration) / divisor; - Projectile.NewProjectile(npc.Center + offset, teslaOrbVelocity, type, damage, 0f, Main.myPlayer, identity); - } - } - } - - if (calamityGlobalNPC.newAI[2] % (float)Math.Floor(teslaOrbTelegraphDuration / 5f) == (float)Math.Floor(teslaOrbTelegraphDuration / 5f) - 1 && calamityGlobalNPC.newAI[2] <= teslaOrbTelegraphDuration) + if ((double)npc.position.Y < Main.topWorld + 16f) { - float pulseCounter = (float)Math.Floor(calamityGlobalNPC.newAI[2] / (teslaOrbTelegraphDuration / 5f)) + 1; - EnergyDrawer.AddPulse(pulseCounter); + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } } - if (calamityGlobalNPC.newAI[2] >= teslaOrbTelegraphDuration + teslaOrbDuration) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] += 10f; - } + return; + } + } - break; - } + // Default vector to fly to + float offsetX = -375f; + float offsetY = 160f; + float offsetX2 = -540f; + float offsetY2 = 540f; + switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) + { + case 0: + case 1: + case 4: + case 5: + break; - EnergyDrawer.Update(); + case 2: + case 3: + offsetX *= -1f; + offsetX2 *= -1f; + offsetY2 *= -1f; + break; + } + Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); - // Smooth movement towards the location Ares Tesla Cannon is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - } + // Velocity and acceleration values + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; + baseVelocity *= 1f + Main.npc[(int)npc.ai[2]].localAI[2]; - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + Vector2 distanceFromDestination = destination - npc.Center; - public override void FindFrame(int frameHeight) - { - // Use telegraph frames when using tesla orbs - npc.frameCounter += 1D; - if (AIState == (float)Phase.Nothing) - { - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; + // Distance where Ares Tesla Arm stops moving + float movementDistanceGateValue = 50f; - // Increment the Y frame - frameY++; + // If Tesla Cannon can fire projectiles, cannot fire if too close to the target and in deathray spiral phase + bool canFire = Vector2.Distance(npc.Center, player.Center) > 320f || calamityGlobalNPC_Body.newAI[0] != (float)AresBody.Phase.Deathrays; - // Reset the Y frame if greater than 8 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } + // Telegraph duration for deathray spiral + float deathrayTelegraphDuration = malice ? AresBody.deathrayTelegraphDuration_Malice : death ? AresBody.deathrayTelegraphDuration_Death : + revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; - // Reset the frames - if ((frameX * maxFramesY) + frameY > normalFrameLimit) - frameX = frameY = 0; - } - } - else - { - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; + // Variable to cancel tesla orb firing + bool doNotFire = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune || + (calamityGlobalNPC_Body.newAI[2] >= deathrayTelegraphDuration + AresBody.deathrayDuration - 10 && calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays) || + (calamityGlobalNPC_Body.newAI[3] == 0f && calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays); - // Increment the Y frame - frameY++; + if (doNotFire) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = setTimerTo; + calamityGlobalNPC.newAI[2] = 0f; + } - // Reset the Y frame if greater than 8 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } + // Emit steam while enraged + SmokeDrawer.ParticleSpawnRate = 9999999; + if (enraged) + { + SmokeDrawer.ParticleSpawnRate = AresBody.ventCloudSpawnRate; + SmokeDrawer.BaseMoveRotation = npc.rotation + MathHelper.Pi; + SmokeDrawer.SpawnAreaCompactness = 40f; - // Reset the frames to frame 36, the start of the tesla orb firing animation loop - if ((frameX * maxFramesY) + frameY > finalStageTeslaOrbChargeFrameLimit) - frameX = frameY = 4; - } - } - } + // Increase DR during enrage + npc.Calamity().DR = 0.85f; + } + else + npc.Calamity().DR = 0.35f; - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - // Draw the enrage smoke behind Ares - SmokeDrawer.DrawSet(npc.Center); + SmokeDrawer.Update(); - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + EnergyDrawer.ParticleSpawnRate = 9999999; + // Attacking phases + switch ((int)AIState) + { + // Do nothing and fly in place + case (int)Phase.Nothing: - Texture2D texture = Main.npcTexture[npc.type]; - Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); - Color afterimageBaseColor = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? Color.Red : Color.White; - int numAfterimages = 5; + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] >= teslaOrbPhaseGateValue) + { + AIState = (float)Phase.TeslaOrbs; + calamityGlobalNPC.newAI[1] = 0f; + } - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); - } - } + break; - Vector2 center = npc.Center - Main.screenPosition; + // Fire tesla orbs in a quadruple burst that arc electricity between them + case (int)Phase.TeslaOrbs: - //Draw an outline to the arm when it charges up - if ((npc.Calamity().newAI[2] < teslaOrbTelegraphDuration) && AIState == (float)Phase.TeslaOrbs) - { - CalamityUtils.EnterShaderRegion(spriteBatch); - Color outlineColor = Color.Lerp(Color.Aqua, Color.White, npc.Calamity().newAI[2] / teslaOrbTelegraphDuration); - float outlineThickness = MathHelper.Clamp(npc.Calamity().newAI[2] / teslaOrbTelegraphDuration * 4f, 0f, 3f); + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] < teslaOrbTelegraphDuration) + { + // Set frames to tesla orb charge up frames, which begin on frame 12 + if (calamityGlobalNPC.newAI[2] == 1f) + { + // Reset the frame counter + npc.frameCounter = 0D; - GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(1f); - GameShaders.Misc["CalamityMod:BasicTint"].UseColor(outlineColor); - GameShaders.Misc["CalamityMod:BasicTint"].Apply(); + // X = 1 sets to frame 8 + frameX = 1; - for (float i = 0; i < 1; i += 0.125f) - { - spriteBatch.Draw(texture, center + (i * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * outlineThickness, frame, outlineColor, npc.rotation, vector, npc.scale, spriteEffects, 0f); - } - CalamityUtils.ExitShaderRegion(spriteBatch); - } + // Y = 4 sets to frame 12 + frameY = 4; + } - spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); + EnergyDrawer.ParticleSpawnRate = AresBody.telegraphParticlesSpawnRate; + EnergyDrawer.SpawnAreaCompactness = 100f; + EnergyDrawer.chargeProgress = calamityGlobalNPC.newAI[2] / teslaOrbTelegraphDuration; - Texture2D glowTexture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresTeslaCannonGlow"); + } + else if (calamityGlobalNPC.newAI[2] < teslaOrbTelegraphDuration + teslaOrbDuration) + { + // Fire tesla orbs + int numTeslaOrbs = lastMechAlive ? 6 : shouldGetBuffedByBerserkPhase ? 5 : nerfedAttacks ? 3 : 4; + float divisor = teslaOrbDuration / numTeslaOrbs; - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(glowTexture.Width, glowTexture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(glowTexture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); - } - } + if ((calamityGlobalNPC.newAI[2] - teslaOrbTelegraphDuration) % divisor == 0f && canFire) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBolt"), npc.Center); + Vector2 teslaOrbVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Vector2 offset = Vector2.Normalize(teslaOrbVelocity) * 40f + Vector2.UnitY * 8f; + float identity = fireMoreOrbs ? -2f : calamityGlobalNPC.newAI[3] + (calamityGlobalNPC.newAI[2] - teslaOrbTelegraphDuration) / divisor; + Projectile.NewProjectile(npc.Center + offset, teslaOrbVelocity, type, damage, 0f, Main.myPlayer, identity); + } + } + } - spriteBatch.Draw(glowTexture, center, frame, afterimageBaseColor * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); + if (calamityGlobalNPC.newAI[2] % (float)Math.Floor(teslaOrbTelegraphDuration / 5f) == (float)Math.Floor(teslaOrbTelegraphDuration / 5f) - 1 && calamityGlobalNPC.newAI[2] <= teslaOrbTelegraphDuration) + { + float pulseCounter = (float)Math.Floor(calamityGlobalNPC.newAI[2] / (teslaOrbTelegraphDuration / 5f)) + 1; + EnergyDrawer.AddPulse(pulseCounter); + } - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - //Update the parameters + if (calamityGlobalNPC.newAI[2] >= teslaOrbTelegraphDuration + teslaOrbDuration) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] += 10f; + } - //Draw a pulsing version of the thing above the arm - if ((npc.Calamity().newAI[2] < teslaOrbTelegraphDuration) && AIState == (float)Phase.TeslaOrbs) - { + break; + } - float pulseRatio = (npc.Calamity().newAI[2] % (teslaOrbTelegraphDuration / 5f)) / (teslaOrbTelegraphDuration / 5f); - float pulseSize = MathHelper.Lerp(0.1f, 0.6f, (float)Math.Floor(npc.Calamity().newAI[2] / (teslaOrbTelegraphDuration / 5f)) / 4f); - float pulseOpacity = MathHelper.Clamp((float)Math.Floor(npc.Calamity().newAI[2] / (teslaOrbTelegraphDuration / 5f)) * 0.3f, 1f, 2f); - spriteBatch.Draw(texture, center, frame, Color.Aqua * MathHelper.Lerp(1f, 0f, pulseRatio) * pulseOpacity, npc.rotation, vector, npc.scale + pulseRatio * pulseSize, spriteEffects, 0f); + EnergyDrawer.Update(); - //Draw the bloom - EnergyDrawer.DrawBloom(CoreSpritePosition); - } + // Smooth movement towards the location Ares Tesla Cannon is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + } - EnergyDrawer.DrawPulses(CoreSpritePosition); - EnergyDrawer.DrawSet(CoreSpritePosition); + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public override void FindFrame(int frameHeight) + { + // Use telegraph frames when using tesla orbs + npc.frameCounter += 1D; + if (AIState == (float)Phase.Nothing) + { + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 8 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames + if ((frameX * maxFramesY) + frameY > normalFrameLimit) + frameX = frameY = 0; + } + } + else + { + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 8 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames to frame 36, the start of the tesla orb firing animation loop + if ((frameX * maxFramesY) + frameY > finalStageTeslaOrbChargeFrameLimit) + frameX = frameY = 4; + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + // Draw the enrage smoke behind Ares + SmokeDrawer.DrawSet(npc.Center); + + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); + Color afterimageBaseColor = Main.npc[(int)npc.ai[2]].localAI[1] == (float)AresBody.Enraged.Yes ? Color.Red : Color.White; + int numAfterimages = 5; + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); + } + } + + Vector2 center = npc.Center - Main.screenPosition; + + //Draw an outline to the arm when it charges up + if ((npc.Calamity().newAI[2] < teslaOrbTelegraphDuration) && AIState == (float)Phase.TeslaOrbs) + { + CalamityUtils.EnterShaderRegion(spriteBatch); + Color outlineColor = Color.Lerp(Color.Aqua, Color.White, npc.Calamity().newAI[2] / teslaOrbTelegraphDuration); + float outlineThickness = MathHelper.Clamp(npc.Calamity().newAI[2] / teslaOrbTelegraphDuration * 4f, 0f, 3f); + + GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(1f); + GameShaders.Misc["CalamityMod:BasicTint"].UseColor(outlineColor); + GameShaders.Misc["CalamityMod:BasicTint"].Apply(); + + for (float i = 0; i < 1; i += 0.125f) + { + spriteBatch.Draw(texture, center + (i * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * outlineThickness, frame, outlineColor, npc.rotation, vector, npc.scale, spriteEffects, 0f); + } + CalamityUtils.ExitShaderRegion(spriteBatch); + } + + spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); + + Texture2D glowTexture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresTeslaCannonGlow"); + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(glowTexture.Width, glowTexture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(glowTexture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(glowTexture, center, frame, afterimageBaseColor * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + //Update the parameters + + //Draw a pulsing version of the thing above the arm + if ((npc.Calamity().newAI[2] < teslaOrbTelegraphDuration) && AIState == (float)Phase.TeslaOrbs) + { + + float pulseRatio = (npc.Calamity().newAI[2] % (teslaOrbTelegraphDuration / 5f)) / (teslaOrbTelegraphDuration / 5f); + float pulseSize = MathHelper.Lerp(0.1f, 0.6f, (float)Math.Floor(npc.Calamity().newAI[2] / (teslaOrbTelegraphDuration / 5f)) / 4f); + float pulseOpacity = MathHelper.Clamp((float)Math.Floor(npc.Calamity().newAI[2] / (teslaOrbTelegraphDuration / 5f)) * 0.3f, 1f, 2f); + spriteBatch.Draw(texture, center, frame, Color.Aqua * MathHelper.Lerp(1f, 0f, pulseRatio) * pulseOpacity, npc.rotation, vector, npc.scale + pulseRatio * pulseSize, spriteEffects, 0f); + + //Draw the bloom + EnergyDrawer.DrawBloom(CoreSpritePosition); + } + + EnergyDrawer.DrawPulses(CoreSpritePosition); + EnergyDrawer.DrawSet(CoreSpritePosition); - //Back to normal - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + //Back to normal + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - return false; - } + return false; + } - public override void DrawBehind(int index) - { - Main.instance.DrawCacheNPCProjectiles.Add(index); - } + public override void DrawBehind(int index) + { + Main.instance.DrawCacheNPCProjectiles.Add(index); + } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); - if (npc.life <= 0) - { - for (int num193 = 0; num193 < 2; num193++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresTeslaCannon1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresTeslaCannon2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); - } - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresTeslaCannon1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresTeslaCannon2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); + } + } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * 0.8f); - } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * 0.8f); + } } } diff --git a/NPCs/ExoMechs/Artemis/Artemis.cs b/NPCs/ExoMechs/Artemis/Artemis.cs index 328fb75d29..7a4d7a8705 100644 --- a/NPCs/ExoMechs/Artemis/Artemis.cs +++ b/NPCs/ExoMechs/Artemis/Artemis.cs @@ -16,1428 +16,1428 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Artemis { - public class Artemis : ModNPC + public class Artemis : ModNPC { - public static int phase1IconIndex; - public static int phase2IconIndex; + public static int phase1IconIndex; + public static int phase2IconIndex; - internal static void LoadHeadIcons() - { - string phase1IconPath = "CalamityMod/NPCs/ExoMechs/Artemis/ArtemisHead"; - string phase2IconPath = "CalamityMod/NPCs/ExoMechs/Artemis/ArtemisPhase2Head"; + internal static void LoadHeadIcons() + { + string phase1IconPath = "CalamityMod/NPCs/ExoMechs/Artemis/ArtemisHead"; + string phase2IconPath = "CalamityMod/NPCs/ExoMechs/Artemis/ArtemisPhase2Head"; - CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); - phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); + CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); + phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); - CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); - phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); - } + CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); + phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); + } - public enum Phase - { - Normal = 0, - Charge = 1, - LaserShotgun = 2, - Deathray = 3, - PhaseTransition = 4 - } + public enum Phase + { + Normal = 0, + Charge = 1, + LaserShotgun = 2, + Deathray = 3, + PhaseTransition = 4 + } - public float AIState - { - get => npc.Calamity().newAI[0]; - set => npc.Calamity().newAI[0] = value; - } + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } - public enum SecondaryPhase - { - Nothing = 0, - Passive = 1, - PassiveAndImmune = 2 - } + public enum SecondaryPhase + { + Nothing = 0, + Passive = 1, + PassiveAndImmune = 2 + } - public float SecondaryAIState - { - get => npc.Calamity().newAI[1]; - set => npc.Calamity().newAI[1] = value; - } + public float SecondaryAIState + { + get => npc.Calamity().newAI[1]; + set => npc.Calamity().newAI[1] = value; + } - // Variable used to scale up velocity if too far from destination - private float velocityBoostMult = 0f; + // Variable used to scale up velocity if too far from destination + private float velocityBoostMult = 0f; - // The vector used for charging - private Vector2 chargeVelocityNormalized = default; + // The vector used for charging + private Vector2 chargeVelocityNormalized = default; - // Number of frames on the X and Y axis - private const int maxFramesX = 10; - private const int maxFramesY = 9; + // Number of frames on the X and Y axis + private const int maxFramesX = 10; + private const int maxFramesY = 9; - // Counters for frames on the X and Y axis - private int frameX = 0; - private int frameY = 0; + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; - // Frame limit per animation, these are the specific frames where each animation ends - private const int normalFrameLimit_Phase1 = 9; - private const int chargeUpFrameLimit_Phase1 = 19; - private const int attackFrameLimit_Phase1 = 29; - private const int phaseTransitionFrameLimit = 59; // The lens pops off on frame 37 - private const int normalFrameLimit_Phase2 = 69; - private const int chargeUpFrameLimit_Phase2 = 79; - private const int attackFrameLimit_Phase2 = 89; + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit_Phase1 = 9; + private const int chargeUpFrameLimit_Phase1 = 19; + private const int attackFrameLimit_Phase1 = 29; + private const int phaseTransitionFrameLimit = 59; // The lens pops off on frame 37 + private const int normalFrameLimit_Phase2 = 69; + private const int chargeUpFrameLimit_Phase2 = 79; + private const int attackFrameLimit_Phase2 = 89; - // Default life ratio for the other mechs - private const float defaultLifeRatio = 5f; + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; - // Max distance from the target before they are unable to hear sound telegraphs - private const float soundDistance = 2800f; + // Max distance from the target before they are unable to hear sound telegraphs + private const float soundDistance = 2800f; - // Normal animation duration - private const float defaultAnimationDuration = 60f; + // Normal animation duration + private const float defaultAnimationDuration = 60f; - // Total duration of the phase transition - private const float phaseTransitionDuration = 180f; + // Total duration of the phase transition + private const float phaseTransitionDuration = 180f; - // Where the timer should be when the lens pops off - private const float lensPopTime = 48f; + // Where the timer should be when the lens pops off + private const float lensPopTime = 48f; - // Total duration of the deathray telegraph - private const float deathrayTelegraphDuration = 60f; + // Total duration of the deathray telegraph + private const float deathrayTelegraphDuration = 60f; - // Total duration of the deathray - private const float deathrayDuration = 180f; + // Total duration of the deathray + private const float deathrayDuration = 180f; - // Variable to pick a different location after each attack - private bool pickNewLocation = false; + // Variable to pick a different location after each attack + private bool pickNewLocation = false; - // The direction to spin in during spin phases - private int rotationDirection = 0; + // The direction to spin in during spin phases + private int rotationDirection = 0; - // The point to spin around - private Vector2 spinningPoint = default; + // The point to spin around + private Vector2 spinningPoint = default; - // Velocity for the spin - private Vector2 spinVelocity = default; + // Velocity for the spin + private Vector2 spinVelocity = default; - // Intensity of flash effects during the charge combo - public float ChargeFlash; + // Intensity of flash effects during the charge combo + public float ChargeFlash; - // Primitive trail drawers for thrusters when charging - public PrimitiveTrail ChargeFlameTrail = null; - public PrimitiveTrail ChargeFlameTrailBig = null; + // Primitive trail drawers for thrusters when charging + public PrimitiveTrail ChargeFlameTrail = null; + public PrimitiveTrail ChargeFlameTrailBig = null; - // Primitive trail drawer for the ribbon things - public PrimitiveTrail RibbonTrail = null; + // Primitive trail drawer for the ribbon things + public PrimitiveTrail RibbonTrail = null; - public const string NameToDisplay = "XS-01 Artemis"; + public const string NameToDisplay = "XS-01 Artemis"; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault(NameToDisplay); - NPCID.Sets.TrailingMode[npc.type] = 3; - NPCID.Sets.TrailCacheLength[npc.type] = 15; - } + NPCID.Sets.TrailingMode[npc.type] = 3; + NPCID.Sets.TrailCacheLength[npc.type] = 15; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 5f; - npc.GetNPCDamage(); - npc.width = 204; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.width = 204; npc.height = 226; npc.defense = 80; - npc.DR_NERD(0.25f); - npc.LifeMaxNERB(1250000, 1495000, 500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.DR_NERD(0.25f); + npc.LifeMaxNERB(1250000, 1495000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; - npc.Opacity = 0f; + npc.Opacity = 0f; npc.knockBackResist = 0f; npc.noGravity = true; npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; - npc.boss = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.boss = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } - public override void BossHeadSlot(ref int index) - { - if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) - index = -1; - else if (npc.life / (float)npc.lifeMax < 0.6f) - index = phase2IconIndex; - else - index = phase1IconIndex; - } - - public override void SendExtraAI(BinaryWriter writer) + public override void BossHeadSlot(ref int index) { - writer.Write(velocityBoostMult); - writer.WriteVector2(spinVelocity); - writer.WriteVector2(chargeVelocityNormalized); - writer.Write(frameX); - writer.Write(frameY); - writer.Write(pickNewLocation); - writer.Write(rotationDirection); - writer.WriteVector2(spinningPoint); + if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) + index = -1; + else if (npc.life / (float)npc.lifeMax < 0.6f) + index = phase2IconIndex; + else + index = phase1IconIndex; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(velocityBoostMult); + writer.WriteVector2(spinVelocity); + writer.WriteVector2(chargeVelocityNormalized); + writer.Write(frameX); + writer.Write(frameY); + writer.Write(pickNewLocation); + writer.Write(rotationDirection); + writer.WriteVector2(spinningPoint); writer.Write(npc.dontTakeDamage); - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - writer.Write(npc.localAI[3]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + writer.Write(npc.localAI[3]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { - velocityBoostMult = reader.ReadSingle(); - spinVelocity = reader.ReadVector2(); - chargeVelocityNormalized = reader.ReadVector2(); - frameX = reader.ReadInt32(); - frameY = reader.ReadInt32(); - pickNewLocation = reader.ReadBoolean(); - rotationDirection = reader.ReadInt32(); - spinningPoint = reader.ReadVector2(); - npc.dontTakeDamage = reader.ReadBoolean(); - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + velocityBoostMult = reader.ReadSingle(); + spinVelocity = reader.ReadVector2(); + chargeVelocityNormalized = reader.ReadVector2(); + frameX = reader.ReadInt32(); + frameY = reader.ReadInt32(); + pickNewLocation = reader.ReadBoolean(); + rotationDirection = reader.ReadInt32(); + spinningPoint = reader.ReadVector2(); + npc.dontTakeDamage = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - CalamityGlobalNPC.draedonExoMechTwinRed = npc.whoAmI; - - npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - // Target variable - Player player = Main.player[npc.target]; - - // Check if the other exo mechs are alive - int otherExoMechsAlive = 0; - bool exoTwinGreenAlive = false; - bool exoWormAlive = false; - bool exoPrimeAlive = false; - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - { - // Set target to Apollo's target if Apollo is alive - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].target]; - - // Link the HP of both twins - if (npc.life > Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life) - npc.life = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life; - - exoTwinGreenAlive = true; - } - } - if (CalamityGlobalNPC.draedonExoMechWorm != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) - { - // Set target to Thanatos' target if Thanatos is alive - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; - - otherExoMechsAlive++; - exoWormAlive = true; - } - } - if (CalamityGlobalNPC.draedonExoMechPrime != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - // Set target to Ares' target if Ares is alive - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - - otherExoMechsAlive++; - exoPrimeAlive = true; - } - } - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // These are 5 by default to avoid triggering passive phases after the other mechs are dead - float exoWormLifeRatio = defaultLifeRatio; - float exoPrimeLifeRatio = defaultLifeRatio; - if (exoWormAlive) - exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; - if (exoPrimeAlive) - exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; - float totalOtherExoMechLifeRatio = exoWormLifeRatio + exoPrimeLifeRatio; - - // Check if any of the other mechs are passive - bool exoWormPassive = false; - bool exoPrimePassive = false; - if (exoWormAlive) - exoWormPassive = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive; - if (exoPrimeAlive) - exoPrimePassive = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] == (float)AresBody.SecondaryPhase.Passive; - bool anyOtherExoMechPassive = exoWormPassive || exoPrimePassive; - - // Used to nerf Artemis and Apollo if fighting alongside Ares, because otherwise it's too difficult - bool nerfedAttacks = false; - if (exoWormAlive && !nerfedAttacks) - nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] != (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; - if (exoPrimeAlive && !nerfedAttacks) - nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] != (float)AresBody.SecondaryPhase.PassiveAndImmune; - - // Used to nerf Artemis laser shotgun if Apollo is in charging phase - bool nerfedLaserShotgun = false; - bool canFireLasers = true; - if (exoTwinGreenAlive) - { - nerfedLaserShotgun = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[0] == (float)Apollo.Apollo.Phase.LineUpChargeCombo || - Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[0] == (float)Apollo.Apollo.Phase.ChargeCombo; - - // Can only fire lasers if cooldown is less than or equal to 1 - canFireLasers = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ai[3] <= 1f; - - // Set movement according to Apollo - if (npc.ai[0] >= 10f) - npc.ai[0] = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ai[0]; - } - - // Check if any of the other mechs were spawned first - bool exoWormWasFirst = false; - bool exoPrimeWasFirst = false; - if (exoWormAlive) - exoWormWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].ai[3] == 1f; - if (exoPrimeAlive) - exoPrimeWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] == 1f; - bool otherExoMechWasFirst = exoWormWasFirst || exoPrimeWasFirst; - - // Prevent mechs from being respawned - if (otherExoMechWasFirst) - { - if (npc.ai[3] < 1f) - npc.ai[3] = 1f; - } - - // Phases - bool phase2 = lifeRatio < 0.6f; - bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; - - // If Artemis and Apollo don't go berserk - bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoPrimeLifeRatio < 0.4f; - - // Whether Artemis and Apollo should be buffed while in berserk phase - bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - - // Spawn Apollo if it doesn't exist after the first 10 frames have passed - if (npc.ai[0] < 10f) - { - npc.ai[0] += 1f; - if (npc.ai[0] == 10f && !NPC.AnyNPCs(ModContent.NPCType())) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - } - else - { - if (!NPC.AnyNPCs(ModContent.NPCType())) - { - npc.active = false; - npc.netUpdate = true; - } - } - - // General AI pattern - // 0 - Fly to the left of the target and fire lasers when ready - // 1 - Create a laser telegraph and charge extremely fast, this attack is replaced by a spread pattern of lasers in phase 2 - // 2 - Fly above the target, charge up and fire a deathray while moving in a clockwise or counterclockwise circle around the target's original position when the attack started - // 3 - Go passive and fly to the left of the target while firing less projectiles - // 4 - Go passive, immune and invisible; fly far to the left of the target and do nothing until next phase - - // Attack patterns - // If spawned first - // Phase 1 - 0, 1 - // Phase 2 - 4 - // Phase 3 - 3 - - // If berserk, this is the last phase of Artemis and Apollo - // Phase 4 - 0, 1, 2 - - // If not berserk - // Phase 4 - 4 - // Phase 5 - 0, 1 - - // If berserk, this is the last phase of Artemis and Apollo - // Phase 6 - 0, 1, 2 - - // If not berserk - // Phase 6 - 4 - - // Berserk, final phase of Artemis and Apollo - // Phase 7 - 0, 1, 2 - - // Predictiveness - float predictionAmt = malice ? 21f : death ? 18f : revenge ? 16.5f : expertMode ? 15f : 12f; - if (AIState == (float)Phase.LaserShotgun) - predictionAmt *= 1.5f; - if (nerfedAttacks) - predictionAmt *= 0.5f; - if (SecondaryAIState == (float)SecondaryPhase.Passive) - predictionAmt *= 0.5f; - - // Gate values - float reducedTimeForGateValue = malice ? 48f : death ? 32f : revenge ? 24f : expertMode ? 16f : 0f; - float reducedTimeForGateValue_Berserk = reducedTimeForGateValue * 0.5f; - float normalAttackTime = 360f - reducedTimeForGateValue; - float berserkAttackTime = lastMechAlive ? 225f - reducedTimeForGateValue_Berserk : 270f - reducedTimeForGateValue_Berserk; - float attackPhaseGateValue = shouldGetBuffedByBerserkPhase ? berserkAttackTime : normalAttackTime; - float timeToLineUpAttack = phase2 ? 30f : 45f; - - // Spin variables - float spinRadius = 500f; - float spinLocationDistance = 50f; - Vector2 spinLocation = player.Center; - switch ((int)npc.ai[3]) - { - // Laser from top - case 0: - case 1: - spinLocation.Y -= spinRadius; - break; - - // Laser from bottom - case 2: - spinLocation.Y += spinRadius; - break; - - // Laser from left - case 3: - spinRadius *= 1.7f; - spinLocation.X -= spinRadius; - break; - - // Laser from right - case 4: - spinRadius *= 1.7f; - spinLocation.X += spinRadius; - break; - } - - // Distance where Artemis stops moving - float movementDistanceGateValue = 100f; - - // Charge variables - float chargeVelocity = nerfedAttacks ? 75f : malice ? 100f : death ? 90f : revenge ? 86.25f : expertMode ? 82.5f : 75f; - float chargeDistance = 2000f; - float chargeDuration = chargeDistance / chargeVelocity; - bool lineUpAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f; - bool doBigAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f + timeToLineUpAttack; - - // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); - float baseVelocity = ((AIState == (int)Phase.Deathray || lineUpAttack || AIState == (int)Phase.LaserShotgun) ? 40f : 20f) * baseVelocityMult; - float decelerationVelocityMult = 0.85f; - - // Laser shotgun variables - float laserShotgunDuration = lastMechAlive ? 120f : 90f; - - // If Artemis can fire projectiles, cannot fire if too close to the target - bool canFire = Vector2.Distance(npc.Center, player.Center) > 320f && canFireLasers; - - // Add some random distance to the destination after certain attacks - if (pickNewLocation) - { - pickNewLocation = false; - - npc.localAI[0] = Main.rand.Next(-50, 51); - npc.localAI[1] = Main.rand.Next(-250, 251); - if (SecondaryAIState == (float)SecondaryPhase.Passive) - { - npc.localAI[0] *= 0.5f; - npc.localAI[1] *= 0.5f; - } - - npc.netUpdate = true; - } - - // Default vector to fly to - bool flyLeft = npc.ai[0] % 2f == 0f || npc.ai[0] < 10f || !revenge; - float destinationX = flyLeft ? -750f : 750f; - float destinationY = player.Center.Y; - Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X + destinationX * 1.6f, destinationY) : - SecondaryAIState == (float)SecondaryPhase.Passive ? new Vector2(player.Center.X + destinationX, destinationY + 360f) : - AIState == (float)Phase.Deathray ? spinLocation : - new Vector2(player.Center.X + destinationX, destinationY); - - // Add a bit of randomness to the destination, but only in specific phases where it's necessary - if (AIState == (float)Phase.Normal || AIState == (float)Phase.LaserShotgun || AIState == (float)Phase.PhaseTransition) - { - destination.X += npc.localAI[0]; - destination.Y += npc.localAI[1]; - } - - // Scale up velocity over time if too far from destination - Vector2 distanceFromDestination = destination - npc.Center; - if (distanceFromDestination.Length() > movementDistanceGateValue && AIState != (float)Phase.Charge) - { - if (velocityBoostMult < 1f) - velocityBoostMult += 0.004f; - } - else - { - if (velocityBoostMult > 0f) - velocityBoostMult -= 0.004f; - } - baseVelocity *= 1f + velocityBoostMult; - - // Rotation - Vector2 predictionVector = AIState == (float)Phase.Deathray ? Vector2.Zero : player.velocity * predictionAmt; - Vector2 aimedVector = player.Center + predictionVector - npc.Center; - float rateOfRotation = 0.1f; - Vector2 rotateTowards = player.Center - npc.Center; - bool stopRotatingAndSlowDown = !phase2 && AIState == (float)Phase.Normal && lineUpAttack; - if (!stopRotatingAndSlowDown) - { - if (AIState == (int)Phase.Charge) - { - rateOfRotation = 0f; - npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - } - else if (spinningPoint != default) - { - rateOfRotation = 0f; - float x = spinningPoint.X - npc.Center.X; - float y = spinningPoint.Y - npc.Center.Y; - npc.rotation = (float)Math.Atan2(y, x) + MathHelper.PiOver2; - } - else - { - float x = player.Center.X + predictionVector.X - npc.Center.X; - float y = player.Center.Y + predictionVector.Y - npc.Center.Y; - rotateTowards = Vector2.Normalize(new Vector2(x, y)) * baseVelocity; - } - - // Do not set this during charge or deathray phases - if (rateOfRotation != 0f) - npc.rotation = npc.rotation.AngleTowards((float)Math.Atan2(rotateTowards.Y, rotateTowards.X) + MathHelper.PiOver2, rateOfRotation); - } - - // Light - Lighting.AddLight(npc.Center, 0.25f * npc.Opacity, 0.15f * npc.Opacity, 0.05f * npc.Opacity); - - // Despawn if target is dead - if (player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (player.dead) - { - AIState = (float)Phase.Normal; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - rotationDirection = 0; - chargeVelocityNormalized = default; - spinningPoint = default; - spinVelocity = default; - npc.dontTakeDamage = true; - - npc.velocity.Y -= 1f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 1f; - - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - - return; - } - } - - // Duration of deathray spin to do a full circle - // Normal = 120, Expert = 104, Rev = 96, Death = 88, Malice = 72 - float spinTime = 120f - 320f * (baseVelocityMult - 1.25f); - - // Set to transition to phase 2 if it hasn't happened yet - if (phase2 && npc.localAI[3] == 0f) - { - AIState = (float)Phase.PhaseTransition; - npc.localAI[3] = 1f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - - // Set frames to phase transition frames, which begin on frame 30 - // Reset the frame counter - npc.frameCounter = 0D; - - // X = 3 sets to frame 27 - frameX = 3; - - // Y = 3 sets to frame 30 - frameY = 3; - } - - // Variable for charge flash. Changed in parts of the AI below - bool shouldDoChargeFlash = false; - - // Passive and Immune phases - switch ((int)SecondaryAIState) - { - case (int)SecondaryPhase.Nothing: - break; - - // Fire projectiles less often - case (int)SecondaryPhase.Passive: - break; - - // Fly above target and become immune - case (int)SecondaryPhase.PassiveAndImmune: - break; - } - - // Adjust opacity - bool invisiblePhase = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune; - npc.dontTakeDamage = invisiblePhase || AIState == (float)Phase.PhaseTransition; - if (!invisiblePhase) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } - - // Attacking phases - switch ((int)AIState) - { - // Fly to the left of the target - case (int)Phase.Normal: - - if (!stopRotatingAndSlowDown) - { - // Set charge variable to default - chargeVelocityNormalized = default; - - // Smooth movement towards the location Artemis is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - } - else - { - // Save the normalized charge velocity for use in the charge phase - if (chargeVelocityNormalized == default) - chargeVelocityNormalized = Vector2.Normalize(aimedVector); - - // Decelerate - npc.velocity *= decelerationVelocityMult; - } - - // Default animation for 60 frames and then go to telegraph animation - // newAI[3] tells Artemis what animation state it's currently in - bool attacking = calamityGlobalNPC.newAI[3] >= 2f; - bool firingLasers = attacking && calamityGlobalNPC.newAI[3] + 2f < attackPhaseGateValue; - - // Only increase attack timer if not in immune phase - if (SecondaryAIState != (float)SecondaryPhase.PassiveAndImmune) - calamityGlobalNPC.newAI[2] += 1f; - - if (calamityGlobalNPC.newAI[2] >= defaultAnimationDuration || attacking) - { - if (firingLasers) - { - // Fire lasers - float divisor = nerfedAttacks ? 60f : lastMechAlive ? 35f : 45f; - float laserTimer = calamityGlobalNPC.newAI[3] - 2f; - if (laserTimer % divisor == 0f && canFire) - { - pickNewLocation = true; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - Vector2 laserVelocity = Vector2.Normalize(aimedVector); - Vector2 projectileDestination = player.Center + predictionVector; - Vector2 offset = laserVelocity * 70f; - float setVelocityInAI = 6.5f; - Projectile.NewProjectile(npc.Center + offset, projectileDestination, type, damage, 0f, Main.myPlayer, setVelocityInAI, npc.whoAmI); - } - } - } - else - calamityGlobalNPC.newAI[2] = 0f; - - // Enter charge phase after a certain time has passed - // This is replaced by a laser shotgun in phase 2 - // Enter deathray phase if in phase 2 and the localAI[2] variable is set to do so - calamityGlobalNPC.newAI[3] += 1f; - if (lineUpAttack) - { - // Return to normal laser phase if in passive state - if (SecondaryAIState == (float)SecondaryPhase.Passive) - { - pickNewLocation = true; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityNormalized = default; - } - else - { - // Draw a large laser telegraph for the charge - if (!phase2 && calamityGlobalNPC.newAI[3] == attackPhaseGateValue + 5f) - { - // And allow the charge flash effect - shouldDoChargeFlash = true; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - Vector2 laserVelocity = Vector2.Normalize(aimedVector); - Vector2 offset = laserVelocity * 50f; - Projectile.NewProjectile(npc.Center + offset, laserVelocity, type, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - - // Fire a spread of projectiles in the direction of the charge - if (!phase2 && calamityGlobalNPC.newAI[3] == attackPhaseGateValue + 2f + (timeToLineUpAttack - 30f)) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 laserVelocity = chargeVelocityNormalized * 10f; - int numLasersPerSpread = malice ? 10 : death ? 8 : expertMode ? 6 : 4; - int spread = malice ? 30 : death ? 26 : expertMode ? 21 : 15; - float rotation = MathHelper.ToRadians(spread); - float distanceFromTarget = Vector2.Distance(npc.Center, npc.Center + chargeVelocityNormalized * chargeDistance); - float setVelocityInAI = 6.5f; - - for (int i = 0; i < numLasersPerSpread + 1; i++) - { - Vector2 perturbedSpeed = laserVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numLasersPerSpread - 1))); - Vector2 normalizedPerturbedSpeed = Vector2.Normalize(perturbedSpeed); - - Vector2 offset = normalizedPerturbedSpeed * 70f; - Vector2 newCenter = npc.Center + offset; - - Projectile.NewProjectile(newCenter, newCenter + normalizedPerturbedSpeed * distanceFromTarget, type, damage, 0f, Main.myPlayer, setVelocityInAI, npc.whoAmI); - } - } - } - - if (doBigAttack) - { - calamityGlobalNPC.newAI[3] = 0f; - if (phase2) - { - AIState = npc.localAI[2] == 1f ? (float)Phase.Deathray : (float)Phase.LaserShotgun; - } - else - { - // Charge until a certain distance is reached and then return to normal phase - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ELRFire"), npc.Center); - AIState = (float)Phase.Charge; - - // Set charge velocity - npc.velocity = chargeVelocityNormalized * chargeVelocity; - chargeVelocityNormalized = default; - } - } - } - } - } - - break; - - // Charge - case (int)Phase.Charge: - - // Allow the charge flash to happen - shouldDoChargeFlash = true; - - // Reset phase and variables - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] >= chargeDuration) - { - // Decelerate - npc.velocity *= decelerationVelocityMult; - - // Go back to normal phase - if (calamityGlobalNPC.newAI[2] >= chargeDuration + 10f) - { - pickNewLocation = true; - AIState = (float)Phase.Normal; - calamityGlobalNPC.newAI[2] = 0f; - } - } - - break; - - // Laser shotgun barrage - case (int)Phase.LaserShotgun: - - // Smooth movement towards the location Artemis is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - - // Fire lasers - int numSpreads = lastMechAlive ? 3 : 2; - float divisor2 = laserShotgunDuration / numSpreads; - if (calamityGlobalNPC.newAI[2] % divisor2 == 0f && canFire) - { - pickNewLocation = true; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - - Vector2 laserVelocity = Vector2.Normalize(aimedVector) * 10f; - /* Spread: - * lastMechAlive = 20, 25, 30 - * normal = 16, 20, 24 - * nerfedAttacks = 12, 15, 18 - */ - int numLasersAddedByDifficulty = malice ? 3 : death ? 2 : expertMode ? 1 : 0; - int numLasersPerSpread = ((nerfedAttacks || nerfedLaserShotgun) ? 3 : lastMechAlive ? 7 : 5) + numLasersAddedByDifficulty; - int baseSpread = ((nerfedAttacks || nerfedLaserShotgun) ? 9 : lastMechAlive ? 20 : 15) + numLasersAddedByDifficulty * 2; - int spread = baseSpread + (int)(calamityGlobalNPC.newAI[2] / divisor2) * (baseSpread / 4); - float rotation = MathHelper.ToRadians(spread); - float distanceFromTarget = Vector2.Distance(npc.Center, player.Center + predictionVector); - float setVelocityInAI = 6.5f; - - for (int i = 0; i < numLasersPerSpread + 1; i++) - { - Vector2 perturbedSpeed = laserVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numLasersPerSpread - 1))); - Vector2 normalizedPerturbedSpeed = Vector2.Normalize(perturbedSpeed); - - Vector2 offset = normalizedPerturbedSpeed * 70f; - Vector2 newCenter = npc.Center + offset; - - Projectile.NewProjectile(newCenter, newCenter + normalizedPerturbedSpeed * distanceFromTarget, type, damage, 0f, Main.myPlayer, setVelocityInAI, npc.whoAmI); - } - } - } - - // Reset phase and variables - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] >= laserShotgunDuration) - { - pickNewLocation = true; - AIState = (float)Phase.Normal; - npc.localAI[2] = shouldGetBuffedByBerserkPhase ? 1f : 0f; - calamityGlobalNPC.newAI[2] = 0f; - } - - break; - - // Fly above target, fire deathray and move in a circle around the target - case (int)Phase.Deathray: - - // Fly above, stop doing this if in the proper position - // Stop rotating and spin around a target point - if ((destination - npc.Center).Length() < spinLocationDistance || calamityGlobalNPC.newAI[2] > 0f) - { - // Draw telegraph for deathray - if (calamityGlobalNPC.newAI[2] == 0f) - { - npc.velocity = Vector2.Zero; - - switch ((int)npc.ai[3]) - { - // Laser from top - case 0: - case 1: - spinningPoint = npc.Center + Vector2.UnitY * spinRadius; - break; - - // Laser from bottom - case 2: - spinningPoint = npc.Center - Vector2.UnitY * spinRadius; - break; - - // Laser from left - case 3: - spinningPoint = npc.Center + Vector2.UnitX * spinRadius; - break; - - // Laser from right - case 4: - spinningPoint = npc.Center - Vector2.UnitX * spinRadius; - break; - } - - npc.ai[1] = spinningPoint.X; - npc.ai[2] = spinningPoint.Y; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - Vector2 laserVelocity = Vector2.Normalize(spinningPoint - npc.Center); - Vector2 offset = laserVelocity * 70f; - Projectile.NewProjectile(npc.Center + offset, laserVelocity, type, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - - npc.netUpdate = true; - } - - // Fire deathray and spin - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration) - { - if (rotationDirection == 0) - { - // Set spin velocity - spinVelocity.X = MathHelper.Pi * spinRadius / spinTime; - - // Set spin direction - switch ((int)npc.ai[3]) - { - // Laser from top - case 0: - case 1: - if (player.Center.X >= npc.Center.X) - rotationDirection = 1; - else - rotationDirection = -1; - break; - - // Laser from bottom - case 2: - if (player.Center.X >= npc.Center.X) - rotationDirection = -1; - else - rotationDirection = 1; - spinVelocity = -spinVelocity; - break; - - // Laser from left - case 3: - if (player.Center.Y >= npc.Center.Y) - rotationDirection = -1; - else - rotationDirection = 1; - spinVelocity = spinVelocity.RotatedBy(-MathHelper.PiOver2); - break; - - // Laser from right - case 4: - if (player.Center.Y >= npc.Center.Y) - rotationDirection = 1; - else - rotationDirection = -1; - spinVelocity = spinVelocity.RotatedBy(MathHelper.PiOver2); - break; - } - - spinVelocity *= -rotationDirection; - npc.netUpdate = true; - - // Create a bunch of lightning bolts in the sky - ExoMechsSky.CreateLightningBolt(12); - - // Fire deathray - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - Main.PlaySound(29, (int)npc.Center.X, (int)npc.Center.Y, 104); - int damage = npc.GetProjectileDamage(type); - int laser = Projectile.NewProjectile(npc.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, npc.whoAmI); - if (Main.projectile.IndexInRange(laser)) - { - Main.projectile[laser].ai[0] = npc.whoAmI; - Main.projectile[laser].ai[1] = rotationDirection; - } - } - } - else - { - // This is used to adjust both the radians and the velocity of the spin moved per frame - float rotationMult = (calamityGlobalNPC.newAI[2] - deathrayTelegraphDuration) / deathrayDuration * 4f; - if (rotationMult > 1f) - { - // The radians moved per frame during the spin - double radiansOfRotation = MathHelper.Pi / spinTime * -rotationDirection; - npc.velocity = npc.velocity.RotatedBy(radiansOfRotation); - } - else - { - // The radians moved per frame during the spin - // The radians moved are reduced early on to avoid spinning too fucking fast - float decelerationMult = rotationMult * rotationMult; - double radiansOfRotation = MathHelper.Pi / spinTime * -rotationDirection * decelerationMult; - npc.velocity = (spinVelocity * decelerationMult).RotatedBy(radiansOfRotation); - } - } - } - } - else - { - // Smooth movement towards the location Artemis is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - } - - // Reset phase and variables - if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) - { - spinVelocity = default; - rotationDirection = 0; - spinningPoint = default; - pickNewLocation = true; - AIState = (float)Phase.Normal; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - if (revenge) - { - // Can use all 4 types of lasers in rev+ - switch ((int)npc.ai[3]) - { - case 0: - case 1: - npc.ai[3] = 3f + Main.rand.Next(2); - break; - case 2: - npc.ai[3] = 3f + Main.rand.Next(2); - break; - case 3: - npc.ai[3] = 1f + Main.rand.Next(2); - break; - case 4: - npc.ai[3] = 1f + Main.rand.Next(2); - break; - } - } - else if (expertMode) - { - // Can only use the top and bottom lasers in expert - npc.ai[3] += 1f; - if (npc.ai[3] > 2f) - npc.ai[3] = 1f; - } - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.netUpdate = true; - } - - break; - - // Phase transition animation, that's all this exists for - case (int)Phase.PhaseTransition: - - // Smooth movement towards the location Artemis is meant to be at - CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); - - // Shoot lens gore at the target at the proper time - if (calamityGlobalNPC.newAI[2] == lensPopTime) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"), npc.Center); - Vector2 lensDirection = Vector2.Normalize(aimedVector); - Vector2 offset = lensDirection * 70f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.Center + offset, lensDirection * 24f, ModContent.ProjectileType(), 0, 0f); - } - - // Reset phase and variables - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] >= phaseTransitionDuration) - { - pickNewLocation = true; - AIState = (float)Phase.Normal; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityNormalized = default; - } - - break; - } - - // Update the charge flash variable - ChargeFlash = MathHelper.Clamp(ChargeFlash + shouldDoChargeFlash.ToDirectionInt() * 0.08f, 0f, 1f); - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - - Rectangle targetHitbox = target.Hitbox; - - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; - - return minDist <= 100f && npc.Opacity == 1f && AIState == (float)Phase.Charge; - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - scale = 2f; - return null; - } - - public override void FindFrame(int frameHeight) - { - // Use telegraph frames before each attack - bool phase2 = npc.life / (float)npc.lifeMax < 0.6f; - npc.frameCounter += 1D; - if (AIState == (float)Phase.PhaseTransition) - { - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 9 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - } - } - else - { - if (AIState == (float)Phase.Normal) - { - int frameLimit = phase2 ? (npc.Calamity().newAI[3] == 0f ? normalFrameLimit_Phase2 : npc.Calamity().newAI[3] == 1f ? chargeUpFrameLimit_Phase2 : attackFrameLimit_Phase2) : - (npc.Calamity().newAI[3] == 0f ? normalFrameLimit_Phase1 : npc.Calamity().newAI[3] == 1f ? chargeUpFrameLimit_Phase1 : attackFrameLimit_Phase1); - - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 9 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames - int currentFrame = (frameX * maxFramesY) + frameY; - if (currentFrame > frameLimit) - frameX = frameY = phase2 ? (npc.Calamity().newAI[3] == 0f ? 6 : npc.Calamity().newAI[3] == 1f ? 7 : 8) : (npc.Calamity().newAI[3] == 0f ? 0 : npc.Calamity().newAI[3] == 1f ? 1 : 2); - } - } - else if (AIState == (float)Phase.Charge || AIState == (float)Phase.LaserShotgun || AIState == (float)Phase.Deathray) - { - int frameLimit = phase2 ? attackFrameLimit_Phase2 : attackFrameLimit_Phase1; - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; - - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 9 - if (frameY == maxFramesY) - { - frameX++; - frameY = 0; - } - - // Reset the frames - int currentFrame = (frameX * maxFramesY) + frameY; - if (currentFrame > frameLimit) - frameX = frameY = phase2 ? 8 : 2; - } - } - } - } - - public float FlameTrailWidthFunction(float completionRatio) => MathHelper.SmoothStep(21f, 8f, completionRatio) * ChargeFlash; - - public float FlameTrailWidthFunctionBig(float completionRatio) => MathHelper.SmoothStep(34f, 12f, completionRatio) * ChargeFlash; - - public float RibbonTrailWidthFunction(float completionRatio) - { - float baseWidth = Utils.InverseLerp(1f, 0.54f, completionRatio, true) * 5f; - float endTipWidth = CalamityUtils.Convert01To010(Utils.InverseLerp(0.96f, 0.89f, completionRatio, true)) * 2.4f; - return baseWidth + endTipWidth; - } - - public Color FlameTrailColorFunction(float completionRatio) - { - float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true); - Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.27f); - Color middleColor = Color.Lerp(Color.Orange, Color.Yellow, 0.31f); - Color endColor = Color.OrangeRed; - return CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * ChargeFlash * trailOpacity; - } - - public Color FlameTrailColorFunctionBig(float completionRatio) - { - float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true) * 0.56f; - Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.25f); - Color middleColor = Color.Lerp(Color.Blue, Color.White, 0.35f); - Color endColor = Color.Lerp(Color.DarkBlue, Color.White, 0.47f); - Color color = CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * ChargeFlash * trailOpacity; - color.A = 0; - return color; - } - - public Color RibbonTrailColorFunction(float completionRatio) - { - Color startingColor = new Color(34, 40, 48); - Color endColor = new Color(219, 82, 28); - return Color.Lerp(startingColor, endColor, (float)Math.Pow(completionRatio, 1.5D)) * npc.Opacity; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - // Declare the trail drawers if they have yet to be defined. - if (ChargeFlameTrail is null) - ChargeFlameTrail = new PrimitiveTrail(FlameTrailWidthFunction, FlameTrailColorFunction, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]); - - if (ChargeFlameTrailBig is null) - ChargeFlameTrailBig = new PrimitiveTrail(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]); - - if (RibbonTrail is null) - RibbonTrail = new PrimitiveTrail(RibbonTrailWidthFunction, RibbonTrailColorFunction); - - // Prepare the flame trail shader with its map texture. - GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak")); - - int numAfterimages = ChargeFlash > 0f ? 0 : 5; - Texture2D texture = Main.npcTexture[npc.type]; - Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - Vector2 origin = npc.Size * 0.5f; - Vector2 center = npc.Center - Main.screenPosition; - Color afterimageBaseColor = Color.White; - - // Draws a single instance of a regular, non-glowmask based Artemis. - // This is created to allow easy duplication of them when drawing the charge. - void drawInstance(Vector2 drawOffset, Color baseColor) - { - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = baseColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - afterimageCenter += drawOffset; - spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], origin, npc.scale, SpriteEffects.None, 0f); - } - } - - spriteBatch.Draw(texture, center + drawOffset, frame, npc.GetAlpha(baseColor), npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); - } - - // Draw ribbons near the main thruster - for (int direction = -1; direction <= 1; direction += 2) - { - Vector2 ribbonOffset = -Vector2.UnitY.RotatedBy(npc.rotation) * 14f; - ribbonOffset += Vector2.UnitX.RotatedBy(npc.rotation) * direction * 26f; - - float currentSegmentRotation = npc.rotation; - List ribbonDrawPositions = new List(); - for (int i = 0; i < 12; i++) - { - float ribbonCompletionRatio = i / 12f; - float wrappedAngularOffset = MathHelper.WrapAngle(npc.oldRot[i + 1] - currentSegmentRotation) * 0.3f; - float segmentRotationOffset = MathHelper.Clamp(wrappedAngularOffset, -0.12f, 0.12f); - - // Add a sinusoidal offset that goes based on time and completion ratio to create a waving-flag-like effect. - // This is dampened for the first few points to prevent weird offsets. It is also dampened by high velocity. - float sinusoidalRotationOffset = (float)Math.Sin(ribbonCompletionRatio * 2.22f + Main.GlobalTime * 3.4f) * 1.36f; - float sinusoidalRotationOffsetFactor = Utils.InverseLerp(0f, 0.37f, ribbonCompletionRatio, true) * direction * 24f; - sinusoidalRotationOffsetFactor *= Utils.InverseLerp(24f, 16f, npc.velocity.Length(), true); - - Vector2 sinusoidalOffset = Vector2.UnitY.RotatedBy(npc.rotation + sinusoidalRotationOffset) * sinusoidalRotationOffsetFactor; - Vector2 ribbonSegmentOffset = Vector2.UnitY.RotatedBy(currentSegmentRotation) * ribbonCompletionRatio * 540f + sinusoidalOffset; - ribbonDrawPositions.Add(npc.Center + ribbonSegmentOffset + ribbonOffset); - - currentSegmentRotation += segmentRotationOffset; - } - RibbonTrail.Draw(ribbonDrawPositions, -Main.screenPosition, 66); - } - - int instanceCount = (int)MathHelper.Lerp(1f, 15f, ChargeFlash); - Color baseInstanceColor = Color.Lerp(drawColor, Color.White, ChargeFlash); - baseInstanceColor.A = (byte)(int)(255f - ChargeFlash * 255f); - - spriteBatch.EnterShaderRegion(); - - drawInstance(Vector2.Zero, baseInstanceColor); - if (instanceCount > 1) - { - baseInstanceColor *= 0.04f; - float backAfterimageOffset = MathHelper.SmoothStep(0f, 2f, ChargeFlash); - for (int i = 0; i < instanceCount; i++) - { - Vector2 drawOffset = (MathHelper.TwoPi * i / instanceCount + Main.GlobalTime * 0.8f).ToRotationVector2() * backAfterimageOffset; - drawInstance(drawOffset, baseInstanceColor); - } - } - - texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Artemis/ArtemisGlow"); - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; - afterimageCenter += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], origin, npc.scale, SpriteEffects.None, 0f); - } - } - - spriteBatch.Draw(texture, center, frame, Color.White * npc.Opacity, npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); - - spriteBatch.ExitShaderRegion(); - - // Draw a flame trail on the thrusters if needed. This happens during charges. - if (ChargeFlash > 0f) - { - for (int direction = -1; direction <= 1; direction++) - { - Vector2 baseDrawOffset = new Vector2(0f, direction == 0f ? 18f : 60f).RotatedBy(npc.rotation); - baseDrawOffset += new Vector2(direction * 64f, 0f).RotatedBy(npc.rotation); - - float backFlameLength = direction == 0f ? 700f : 190f; - Vector2 drawStart = npc.Center + baseDrawOffset; - Vector2 drawEnd = drawStart - (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * ChargeFlash * backFlameLength; - Vector2[] drawPositions = new Vector2[] - { - drawStart, - drawEnd - }; - - if (direction == 0) - { - for (int i = 0; i < 4; i++) - { - Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 8f; - ChargeFlameTrailBig.Draw(drawPositions, drawOffset - Main.screenPosition, 70); - } - } - else - ChargeFlameTrail.Draw(drawPositions, -Main.screenPosition, 70); - } - } - - return false; - } - - public override bool PreNPCLoot() => false; - - // Needs edits - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); - - if (npc.life <= 0) - { - for (int num193 = 0; num193 < 2; num193++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Artemis/Artemis1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Artemis/Artemis2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Artemis/Artemis3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Artemis/Artemis4"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Artemis/Artemis5"), 1f); - } - } - - public override bool CheckDead() - { - // Kill Apollo if he's still alive when Artemis dies - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC nPC = Main.npc[i]; - if (nPC.active && nPC.type == ModContent.NPCType() && nPC.life > 0) - { - nPC.life = 0; - nPC.HitEffect(0, 10.0); - nPC.checkDead(); - nPC.active = false; - } - } - return true; - } - - public override bool CheckActive() => false; - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + CalamityGlobalNPC.draedonExoMechTwinRed = npc.whoAmI; + + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + // Target variable + Player player = Main.player[npc.target]; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoTwinGreenAlive = false; + bool exoWormAlive = false; + bool exoPrimeAlive = false; + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + // Set target to Apollo's target if Apollo is alive + player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].target]; + + // Link the HP of both twins + if (npc.life > Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life) + npc.life = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life; + + exoTwinGreenAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + // Set target to Thanatos' target if Thanatos is alive + player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; + + otherExoMechsAlive++; + exoWormAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechPrime != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + // Set target to Ares' target if Ares is alive + player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + + otherExoMechsAlive++; + exoPrimeAlive = true; + } + } + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoPrimeLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoPrimeAlive) + exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + float totalOtherExoMechLifeRatio = exoWormLifeRatio + exoPrimeLifeRatio; + + // Check if any of the other mechs are passive + bool exoWormPassive = false; + bool exoPrimePassive = false; + if (exoWormAlive) + exoWormPassive = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive; + if (exoPrimeAlive) + exoPrimePassive = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] == (float)AresBody.SecondaryPhase.Passive; + bool anyOtherExoMechPassive = exoWormPassive || exoPrimePassive; + + // Used to nerf Artemis and Apollo if fighting alongside Ares, because otherwise it's too difficult + bool nerfedAttacks = false; + if (exoWormAlive && !nerfedAttacks) + nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] != (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; + if (exoPrimeAlive && !nerfedAttacks) + nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] != (float)AresBody.SecondaryPhase.PassiveAndImmune; + + // Used to nerf Artemis laser shotgun if Apollo is in charging phase + bool nerfedLaserShotgun = false; + bool canFireLasers = true; + if (exoTwinGreenAlive) + { + nerfedLaserShotgun = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[0] == (float)Apollo.Apollo.Phase.LineUpChargeCombo || + Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[0] == (float)Apollo.Apollo.Phase.ChargeCombo; + + // Can only fire lasers if cooldown is less than or equal to 1 + canFireLasers = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ai[3] <= 1f; + + // Set movement according to Apollo + if (npc.ai[0] >= 10f) + npc.ai[0] = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ai[0]; + } + + // Check if any of the other mechs were spawned first + bool exoWormWasFirst = false; + bool exoPrimeWasFirst = false; + if (exoWormAlive) + exoWormWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].ai[3] == 1f; + if (exoPrimeAlive) + exoPrimeWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] == 1f; + bool otherExoMechWasFirst = exoWormWasFirst || exoPrimeWasFirst; + + // Prevent mechs from being respawned + if (otherExoMechWasFirst) + { + if (npc.ai[3] < 1f) + npc.ai[3] = 1f; + } + + // Phases + bool phase2 = lifeRatio < 0.6f; + bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; + + // If Artemis and Apollo don't go berserk + bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoPrimeLifeRatio < 0.4f; + + // Whether Artemis and Apollo should be buffed while in berserk phase + bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; + + // Spawn Apollo if it doesn't exist after the first 10 frames have passed + if (npc.ai[0] < 10f) + { + npc.ai[0] += 1f; + if (npc.ai[0] == 10f && !NPC.AnyNPCs(ModContent.NPCType())) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + } + else + { + if (!NPC.AnyNPCs(ModContent.NPCType())) + { + npc.active = false; + npc.netUpdate = true; + } + } + + // General AI pattern + // 0 - Fly to the left of the target and fire lasers when ready + // 1 - Create a laser telegraph and charge extremely fast, this attack is replaced by a spread pattern of lasers in phase 2 + // 2 - Fly above the target, charge up and fire a deathray while moving in a clockwise or counterclockwise circle around the target's original position when the attack started + // 3 - Go passive and fly to the left of the target while firing less projectiles + // 4 - Go passive, immune and invisible; fly far to the left of the target and do nothing until next phase + + // Attack patterns + // If spawned first + // Phase 1 - 0, 1 + // Phase 2 - 4 + // Phase 3 - 3 + + // If berserk, this is the last phase of Artemis and Apollo + // Phase 4 - 0, 1, 2 + + // If not berserk + // Phase 4 - 4 + // Phase 5 - 0, 1 + + // If berserk, this is the last phase of Artemis and Apollo + // Phase 6 - 0, 1, 2 + + // If not berserk + // Phase 6 - 4 + + // Berserk, final phase of Artemis and Apollo + // Phase 7 - 0, 1, 2 + + // Predictiveness + float predictionAmt = malice ? 21f : death ? 18f : revenge ? 16.5f : expertMode ? 15f : 12f; + if (AIState == (float)Phase.LaserShotgun) + predictionAmt *= 1.5f; + if (nerfedAttacks) + predictionAmt *= 0.5f; + if (SecondaryAIState == (float)SecondaryPhase.Passive) + predictionAmt *= 0.5f; + + // Gate values + float reducedTimeForGateValue = malice ? 48f : death ? 32f : revenge ? 24f : expertMode ? 16f : 0f; + float reducedTimeForGateValue_Berserk = reducedTimeForGateValue * 0.5f; + float normalAttackTime = 360f - reducedTimeForGateValue; + float berserkAttackTime = lastMechAlive ? 225f - reducedTimeForGateValue_Berserk : 270f - reducedTimeForGateValue_Berserk; + float attackPhaseGateValue = shouldGetBuffedByBerserkPhase ? berserkAttackTime : normalAttackTime; + float timeToLineUpAttack = phase2 ? 30f : 45f; + + // Spin variables + float spinRadius = 500f; + float spinLocationDistance = 50f; + Vector2 spinLocation = player.Center; + switch ((int)npc.ai[3]) + { + // Laser from top + case 0: + case 1: + spinLocation.Y -= spinRadius; + break; + + // Laser from bottom + case 2: + spinLocation.Y += spinRadius; + break; + + // Laser from left + case 3: + spinRadius *= 1.7f; + spinLocation.X -= spinRadius; + break; + + // Laser from right + case 4: + spinRadius *= 1.7f; + spinLocation.X += spinRadius; + break; + } + + // Distance where Artemis stops moving + float movementDistanceGateValue = 100f; + + // Charge variables + float chargeVelocity = nerfedAttacks ? 75f : malice ? 100f : death ? 90f : revenge ? 86.25f : expertMode ? 82.5f : 75f; + float chargeDistance = 2000f; + float chargeDuration = chargeDistance / chargeVelocity; + bool lineUpAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f; + bool doBigAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f + timeToLineUpAttack; + + // Velocity and acceleration values + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocity = ((AIState == (int)Phase.Deathray || lineUpAttack || AIState == (int)Phase.LaserShotgun) ? 40f : 20f) * baseVelocityMult; + float decelerationVelocityMult = 0.85f; + + // Laser shotgun variables + float laserShotgunDuration = lastMechAlive ? 120f : 90f; + + // If Artemis can fire projectiles, cannot fire if too close to the target + bool canFire = Vector2.Distance(npc.Center, player.Center) > 320f && canFireLasers; + + // Add some random distance to the destination after certain attacks + if (pickNewLocation) + { + pickNewLocation = false; + + npc.localAI[0] = Main.rand.Next(-50, 51); + npc.localAI[1] = Main.rand.Next(-250, 251); + if (SecondaryAIState == (float)SecondaryPhase.Passive) + { + npc.localAI[0] *= 0.5f; + npc.localAI[1] *= 0.5f; + } + + npc.netUpdate = true; + } + + // Default vector to fly to + bool flyLeft = npc.ai[0] % 2f == 0f || npc.ai[0] < 10f || !revenge; + float destinationX = flyLeft ? -750f : 750f; + float destinationY = player.Center.Y; + Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X + destinationX * 1.6f, destinationY) : + SecondaryAIState == (float)SecondaryPhase.Passive ? new Vector2(player.Center.X + destinationX, destinationY + 360f) : + AIState == (float)Phase.Deathray ? spinLocation : + new Vector2(player.Center.X + destinationX, destinationY); + + // Add a bit of randomness to the destination, but only in specific phases where it's necessary + if (AIState == (float)Phase.Normal || AIState == (float)Phase.LaserShotgun || AIState == (float)Phase.PhaseTransition) + { + destination.X += npc.localAI[0]; + destination.Y += npc.localAI[1]; + } + + // Scale up velocity over time if too far from destination + Vector2 distanceFromDestination = destination - npc.Center; + if (distanceFromDestination.Length() > movementDistanceGateValue && AIState != (float)Phase.Charge) + { + if (velocityBoostMult < 1f) + velocityBoostMult += 0.004f; + } + else + { + if (velocityBoostMult > 0f) + velocityBoostMult -= 0.004f; + } + baseVelocity *= 1f + velocityBoostMult; + + // Rotation + Vector2 predictionVector = AIState == (float)Phase.Deathray ? Vector2.Zero : player.velocity * predictionAmt; + Vector2 aimedVector = player.Center + predictionVector - npc.Center; + float rateOfRotation = 0.1f; + Vector2 rotateTowards = player.Center - npc.Center; + bool stopRotatingAndSlowDown = !phase2 && AIState == (float)Phase.Normal && lineUpAttack; + if (!stopRotatingAndSlowDown) + { + if (AIState == (int)Phase.Charge) + { + rateOfRotation = 0f; + npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; + } + else if (spinningPoint != default) + { + rateOfRotation = 0f; + float x = spinningPoint.X - npc.Center.X; + float y = spinningPoint.Y - npc.Center.Y; + npc.rotation = (float)Math.Atan2(y, x) + MathHelper.PiOver2; + } + else + { + float x = player.Center.X + predictionVector.X - npc.Center.X; + float y = player.Center.Y + predictionVector.Y - npc.Center.Y; + rotateTowards = Vector2.Normalize(new Vector2(x, y)) * baseVelocity; + } + + // Do not set this during charge or deathray phases + if (rateOfRotation != 0f) + npc.rotation = npc.rotation.AngleTowards((float)Math.Atan2(rotateTowards.Y, rotateTowards.X) + MathHelper.PiOver2, rateOfRotation); + } + + // Light + Lighting.AddLight(npc.Center, 0.25f * npc.Opacity, 0.15f * npc.Opacity, 0.05f * npc.Opacity); + + // Despawn if target is dead + if (player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (player.dead) + { + AIState = (float)Phase.Normal; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + rotationDirection = 0; + chargeVelocityNormalized = default; + spinningPoint = default; + spinVelocity = default; + npc.dontTakeDamage = true; + + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 1f; + + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + } + + return; + } + } + + // Duration of deathray spin to do a full circle + // Normal = 120, Expert = 104, Rev = 96, Death = 88, Malice = 72 + float spinTime = 120f - 320f * (baseVelocityMult - 1.25f); + + // Set to transition to phase 2 if it hasn't happened yet + if (phase2 && npc.localAI[3] == 0f) + { + AIState = (float)Phase.PhaseTransition; + npc.localAI[3] = 1f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + + // Set frames to phase transition frames, which begin on frame 30 + // Reset the frame counter + npc.frameCounter = 0D; + + // X = 3 sets to frame 27 + frameX = 3; + + // Y = 3 sets to frame 30 + frameY = 3; + } + + // Variable for charge flash. Changed in parts of the AI below + bool shouldDoChargeFlash = false; + + // Passive and Immune phases + switch ((int)SecondaryAIState) + { + case (int)SecondaryPhase.Nothing: + break; + + // Fire projectiles less often + case (int)SecondaryPhase.Passive: + break; + + // Fly above target and become immune + case (int)SecondaryPhase.PassiveAndImmune: + break; + } + + // Adjust opacity + bool invisiblePhase = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase || AIState == (float)Phase.PhaseTransition; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Attacking phases + switch ((int)AIState) + { + // Fly to the left of the target + case (int)Phase.Normal: + + if (!stopRotatingAndSlowDown) + { + // Set charge variable to default + chargeVelocityNormalized = default; + + // Smooth movement towards the location Artemis is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + } + else + { + // Save the normalized charge velocity for use in the charge phase + if (chargeVelocityNormalized == default) + chargeVelocityNormalized = Vector2.Normalize(aimedVector); + + // Decelerate + npc.velocity *= decelerationVelocityMult; + } + + // Default animation for 60 frames and then go to telegraph animation + // newAI[3] tells Artemis what animation state it's currently in + bool attacking = calamityGlobalNPC.newAI[3] >= 2f; + bool firingLasers = attacking && calamityGlobalNPC.newAI[3] + 2f < attackPhaseGateValue; + + // Only increase attack timer if not in immune phase + if (SecondaryAIState != (float)SecondaryPhase.PassiveAndImmune) + calamityGlobalNPC.newAI[2] += 1f; + + if (calamityGlobalNPC.newAI[2] >= defaultAnimationDuration || attacking) + { + if (firingLasers) + { + // Fire lasers + float divisor = nerfedAttacks ? 60f : lastMechAlive ? 35f : 45f; + float laserTimer = calamityGlobalNPC.newAI[3] - 2f; + if (laserTimer % divisor == 0f && canFire) + { + pickNewLocation = true; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + Vector2 laserVelocity = Vector2.Normalize(aimedVector); + Vector2 projectileDestination = player.Center + predictionVector; + Vector2 offset = laserVelocity * 70f; + float setVelocityInAI = 6.5f; + Projectile.NewProjectile(npc.Center + offset, projectileDestination, type, damage, 0f, Main.myPlayer, setVelocityInAI, npc.whoAmI); + } + } + } + else + calamityGlobalNPC.newAI[2] = 0f; + + // Enter charge phase after a certain time has passed + // This is replaced by a laser shotgun in phase 2 + // Enter deathray phase if in phase 2 and the localAI[2] variable is set to do so + calamityGlobalNPC.newAI[3] += 1f; + if (lineUpAttack) + { + // Return to normal laser phase if in passive state + if (SecondaryAIState == (float)SecondaryPhase.Passive) + { + pickNewLocation = true; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityNormalized = default; + } + else + { + // Draw a large laser telegraph for the charge + if (!phase2 && calamityGlobalNPC.newAI[3] == attackPhaseGateValue + 5f) + { + // And allow the charge flash effect + shouldDoChargeFlash = true; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + Vector2 laserVelocity = Vector2.Normalize(aimedVector); + Vector2 offset = laserVelocity * 50f; + Projectile.NewProjectile(npc.Center + offset, laserVelocity, type, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + + // Fire a spread of projectiles in the direction of the charge + if (!phase2 && calamityGlobalNPC.newAI[3] == attackPhaseGateValue + 2f + (timeToLineUpAttack - 30f)) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Vector2 laserVelocity = chargeVelocityNormalized * 10f; + int numLasersPerSpread = malice ? 10 : death ? 8 : expertMode ? 6 : 4; + int spread = malice ? 30 : death ? 26 : expertMode ? 21 : 15; + float rotation = MathHelper.ToRadians(spread); + float distanceFromTarget = Vector2.Distance(npc.Center, npc.Center + chargeVelocityNormalized * chargeDistance); + float setVelocityInAI = 6.5f; + + for (int i = 0; i < numLasersPerSpread + 1; i++) + { + Vector2 perturbedSpeed = laserVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numLasersPerSpread - 1))); + Vector2 normalizedPerturbedSpeed = Vector2.Normalize(perturbedSpeed); + + Vector2 offset = normalizedPerturbedSpeed * 70f; + Vector2 newCenter = npc.Center + offset; + + Projectile.NewProjectile(newCenter, newCenter + normalizedPerturbedSpeed * distanceFromTarget, type, damage, 0f, Main.myPlayer, setVelocityInAI, npc.whoAmI); + } + } + } + + if (doBigAttack) + { + calamityGlobalNPC.newAI[3] = 0f; + if (phase2) + { + AIState = npc.localAI[2] == 1f ? (float)Phase.Deathray : (float)Phase.LaserShotgun; + } + else + { + // Charge until a certain distance is reached and then return to normal phase + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ELRFire"), npc.Center); + AIState = (float)Phase.Charge; + + // Set charge velocity + npc.velocity = chargeVelocityNormalized * chargeVelocity; + chargeVelocityNormalized = default; + } + } + } + } + } + + break; + + // Charge + case (int)Phase.Charge: + + // Allow the charge flash to happen + shouldDoChargeFlash = true; + + // Reset phase and variables + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= chargeDuration) + { + // Decelerate + npc.velocity *= decelerationVelocityMult; + + // Go back to normal phase + if (calamityGlobalNPC.newAI[2] >= chargeDuration + 10f) + { + pickNewLocation = true; + AIState = (float)Phase.Normal; + calamityGlobalNPC.newAI[2] = 0f; + } + } + + break; + + // Laser shotgun barrage + case (int)Phase.LaserShotgun: + + // Smooth movement towards the location Artemis is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + + // Fire lasers + int numSpreads = lastMechAlive ? 3 : 2; + float divisor2 = laserShotgunDuration / numSpreads; + if (calamityGlobalNPC.newAI[2] % divisor2 == 0f && canFire) + { + pickNewLocation = true; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + + Vector2 laserVelocity = Vector2.Normalize(aimedVector) * 10f; + /* Spread: + * lastMechAlive = 20, 25, 30 + * normal = 16, 20, 24 + * nerfedAttacks = 12, 15, 18 + */ + int numLasersAddedByDifficulty = malice ? 3 : death ? 2 : expertMode ? 1 : 0; + int numLasersPerSpread = ((nerfedAttacks || nerfedLaserShotgun) ? 3 : lastMechAlive ? 7 : 5) + numLasersAddedByDifficulty; + int baseSpread = ((nerfedAttacks || nerfedLaserShotgun) ? 9 : lastMechAlive ? 20 : 15) + numLasersAddedByDifficulty * 2; + int spread = baseSpread + (int)(calamityGlobalNPC.newAI[2] / divisor2) * (baseSpread / 4); + float rotation = MathHelper.ToRadians(spread); + float distanceFromTarget = Vector2.Distance(npc.Center, player.Center + predictionVector); + float setVelocityInAI = 6.5f; + + for (int i = 0; i < numLasersPerSpread + 1; i++) + { + Vector2 perturbedSpeed = laserVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numLasersPerSpread - 1))); + Vector2 normalizedPerturbedSpeed = Vector2.Normalize(perturbedSpeed); + + Vector2 offset = normalizedPerturbedSpeed * 70f; + Vector2 newCenter = npc.Center + offset; + + Projectile.NewProjectile(newCenter, newCenter + normalizedPerturbedSpeed * distanceFromTarget, type, damage, 0f, Main.myPlayer, setVelocityInAI, npc.whoAmI); + } + } + } + + // Reset phase and variables + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= laserShotgunDuration) + { + pickNewLocation = true; + AIState = (float)Phase.Normal; + npc.localAI[2] = shouldGetBuffedByBerserkPhase ? 1f : 0f; + calamityGlobalNPC.newAI[2] = 0f; + } + + break; + + // Fly above target, fire deathray and move in a circle around the target + case (int)Phase.Deathray: + + // Fly above, stop doing this if in the proper position + // Stop rotating and spin around a target point + if ((destination - npc.Center).Length() < spinLocationDistance || calamityGlobalNPC.newAI[2] > 0f) + { + // Draw telegraph for deathray + if (calamityGlobalNPC.newAI[2] == 0f) + { + npc.velocity = Vector2.Zero; + + switch ((int)npc.ai[3]) + { + // Laser from top + case 0: + case 1: + spinningPoint = npc.Center + Vector2.UnitY * spinRadius; + break; + + // Laser from bottom + case 2: + spinningPoint = npc.Center - Vector2.UnitY * spinRadius; + break; + + // Laser from left + case 3: + spinningPoint = npc.Center + Vector2.UnitX * spinRadius; + break; + + // Laser from right + case 4: + spinningPoint = npc.Center - Vector2.UnitX * spinRadius; + break; + } + + npc.ai[1] = spinningPoint.X; + npc.ai[2] = spinningPoint.Y; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + Vector2 laserVelocity = Vector2.Normalize(spinningPoint - npc.Center); + Vector2 offset = laserVelocity * 70f; + Projectile.NewProjectile(npc.Center + offset, laserVelocity, type, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + + npc.netUpdate = true; + } + + // Fire deathray and spin + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration) + { + if (rotationDirection == 0) + { + // Set spin velocity + spinVelocity.X = MathHelper.Pi * spinRadius / spinTime; + + // Set spin direction + switch ((int)npc.ai[3]) + { + // Laser from top + case 0: + case 1: + if (player.Center.X >= npc.Center.X) + rotationDirection = 1; + else + rotationDirection = -1; + break; + + // Laser from bottom + case 2: + if (player.Center.X >= npc.Center.X) + rotationDirection = -1; + else + rotationDirection = 1; + spinVelocity = -spinVelocity; + break; + + // Laser from left + case 3: + if (player.Center.Y >= npc.Center.Y) + rotationDirection = -1; + else + rotationDirection = 1; + spinVelocity = spinVelocity.RotatedBy(-MathHelper.PiOver2); + break; + + // Laser from right + case 4: + if (player.Center.Y >= npc.Center.Y) + rotationDirection = 1; + else + rotationDirection = -1; + spinVelocity = spinVelocity.RotatedBy(MathHelper.PiOver2); + break; + } + + spinVelocity *= -rotationDirection; + npc.netUpdate = true; + + // Create a bunch of lightning bolts in the sky + ExoMechsSky.CreateLightningBolt(12); + + // Fire deathray + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + Main.PlaySound(29, (int)npc.Center.X, (int)npc.Center.Y, 104); + int damage = npc.GetProjectileDamage(type); + int laser = Projectile.NewProjectile(npc.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, npc.whoAmI); + if (Main.projectile.IndexInRange(laser)) + { + Main.projectile[laser].ai[0] = npc.whoAmI; + Main.projectile[laser].ai[1] = rotationDirection; + } + } + } + else + { + // This is used to adjust both the radians and the velocity of the spin moved per frame + float rotationMult = (calamityGlobalNPC.newAI[2] - deathrayTelegraphDuration) / deathrayDuration * 4f; + if (rotationMult > 1f) + { + // The radians moved per frame during the spin + double radiansOfRotation = MathHelper.Pi / spinTime * -rotationDirection; + npc.velocity = npc.velocity.RotatedBy(radiansOfRotation); + } + else + { + // The radians moved per frame during the spin + // The radians moved are reduced early on to avoid spinning too fucking fast + float decelerationMult = rotationMult * rotationMult; + double radiansOfRotation = MathHelper.Pi / spinTime * -rotationDirection * decelerationMult; + npc.velocity = (spinVelocity * decelerationMult).RotatedBy(radiansOfRotation); + } + } + } + } + else + { + // Smooth movement towards the location Artemis is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + } + + // Reset phase and variables + if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) + { + spinVelocity = default; + rotationDirection = 0; + spinningPoint = default; + pickNewLocation = true; + AIState = (float)Phase.Normal; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + if (revenge) + { + // Can use all 4 types of lasers in rev+ + switch ((int)npc.ai[3]) + { + case 0: + case 1: + npc.ai[3] = 3f + Main.rand.Next(2); + break; + case 2: + npc.ai[3] = 3f + Main.rand.Next(2); + break; + case 3: + npc.ai[3] = 1f + Main.rand.Next(2); + break; + case 4: + npc.ai[3] = 1f + Main.rand.Next(2); + break; + } + } + else if (expertMode) + { + // Can only use the top and bottom lasers in expert + npc.ai[3] += 1f; + if (npc.ai[3] > 2f) + npc.ai[3] = 1f; + } + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.netUpdate = true; + } + + break; + + // Phase transition animation, that's all this exists for + case (int)Phase.PhaseTransition: + + // Smooth movement towards the location Artemis is meant to be at + CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity); + + // Shoot lens gore at the target at the proper time + if (calamityGlobalNPC.newAI[2] == lensPopTime) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"), npc.Center); + Vector2 lensDirection = Vector2.Normalize(aimedVector); + Vector2 offset = lensDirection * 70f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(npc.Center + offset, lensDirection * 24f, ModContent.ProjectileType(), 0, 0f); + } + + // Reset phase and variables + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= phaseTransitionDuration) + { + pickNewLocation = true; + AIState = (float)Phase.Normal; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityNormalized = default; + } + + break; + } + + // Update the charge flash variable + ChargeFlash = MathHelper.Clamp(ChargeFlash + shouldDoChargeFlash.ToDirectionInt() * 0.08f, 0f, 1f); + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= 100f && npc.Opacity == 1f && AIState == (float)Phase.Charge; + } + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + scale = 2f; + return null; + } + + public override void FindFrame(int frameHeight) + { + // Use telegraph frames before each attack + bool phase2 = npc.life / (float)npc.lifeMax < 0.6f; + npc.frameCounter += 1D; + if (AIState == (float)Phase.PhaseTransition) + { + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 9 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + } + } + else + { + if (AIState == (float)Phase.Normal) + { + int frameLimit = phase2 ? (npc.Calamity().newAI[3] == 0f ? normalFrameLimit_Phase2 : npc.Calamity().newAI[3] == 1f ? chargeUpFrameLimit_Phase2 : attackFrameLimit_Phase2) : + (npc.Calamity().newAI[3] == 0f ? normalFrameLimit_Phase1 : npc.Calamity().newAI[3] == 1f ? chargeUpFrameLimit_Phase1 : attackFrameLimit_Phase1); + + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 9 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames + int currentFrame = (frameX * maxFramesY) + frameY; + if (currentFrame > frameLimit) + frameX = frameY = phase2 ? (npc.Calamity().newAI[3] == 0f ? 6 : npc.Calamity().newAI[3] == 1f ? 7 : 8) : (npc.Calamity().newAI[3] == 0f ? 0 : npc.Calamity().newAI[3] == 1f ? 1 : 2); + } + } + else if (AIState == (float)Phase.Charge || AIState == (float)Phase.LaserShotgun || AIState == (float)Phase.Deathray) + { + int frameLimit = phase2 ? attackFrameLimit_Phase2 : attackFrameLimit_Phase1; + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 9 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames + int currentFrame = (frameX * maxFramesY) + frameY; + if (currentFrame > frameLimit) + frameX = frameY = phase2 ? 8 : 2; + } + } + } + } + + public float FlameTrailWidthFunction(float completionRatio) => MathHelper.SmoothStep(21f, 8f, completionRatio) * ChargeFlash; + + public float FlameTrailWidthFunctionBig(float completionRatio) => MathHelper.SmoothStep(34f, 12f, completionRatio) * ChargeFlash; + + public float RibbonTrailWidthFunction(float completionRatio) + { + float baseWidth = Utils.InverseLerp(1f, 0.54f, completionRatio, true) * 5f; + float endTipWidth = CalamityUtils.Convert01To010(Utils.InverseLerp(0.96f, 0.89f, completionRatio, true)) * 2.4f; + return baseWidth + endTipWidth; + } + + public Color FlameTrailColorFunction(float completionRatio) + { + float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true); + Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.27f); + Color middleColor = Color.Lerp(Color.Orange, Color.Yellow, 0.31f); + Color endColor = Color.OrangeRed; + return CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * ChargeFlash * trailOpacity; + } + + public Color FlameTrailColorFunctionBig(float completionRatio) + { + float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true) * 0.56f; + Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.25f); + Color middleColor = Color.Lerp(Color.Blue, Color.White, 0.35f); + Color endColor = Color.Lerp(Color.DarkBlue, Color.White, 0.47f); + Color color = CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * ChargeFlash * trailOpacity; + color.A = 0; + return color; + } + + public Color RibbonTrailColorFunction(float completionRatio) + { + Color startingColor = new Color(34, 40, 48); + Color endColor = new Color(219, 82, 28); + return Color.Lerp(startingColor, endColor, (float)Math.Pow(completionRatio, 1.5D)) * npc.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + // Declare the trail drawers if they have yet to be defined. + if (ChargeFlameTrail is null) + ChargeFlameTrail = new PrimitiveTrail(FlameTrailWidthFunction, FlameTrailColorFunction, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]); + + if (ChargeFlameTrailBig is null) + ChargeFlameTrailBig = new PrimitiveTrail(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]); + + if (RibbonTrail is null) + RibbonTrail = new PrimitiveTrail(RibbonTrailWidthFunction, RibbonTrailColorFunction); + + // Prepare the flame trail shader with its map texture. + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak")); + + int numAfterimages = ChargeFlash > 0f ? 0 : 5; + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 origin = npc.Size * 0.5f; + Vector2 center = npc.Center - Main.screenPosition; + Color afterimageBaseColor = Color.White; + + // Draws a single instance of a regular, non-glowmask based Artemis. + // This is created to allow easy duplication of them when drawing the charge. + void drawInstance(Vector2 drawOffset, Color baseColor) + { + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = baseColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + afterimageCenter += drawOffset; + spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], origin, npc.scale, SpriteEffects.None, 0f); + } + } + + spriteBatch.Draw(texture, center + drawOffset, frame, npc.GetAlpha(baseColor), npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); + } + + // Draw ribbons near the main thruster + for (int direction = -1; direction <= 1; direction += 2) + { + Vector2 ribbonOffset = -Vector2.UnitY.RotatedBy(npc.rotation) * 14f; + ribbonOffset += Vector2.UnitX.RotatedBy(npc.rotation) * direction * 26f; + + float currentSegmentRotation = npc.rotation; + List ribbonDrawPositions = new List(); + for (int i = 0; i < 12; i++) + { + float ribbonCompletionRatio = i / 12f; + float wrappedAngularOffset = MathHelper.WrapAngle(npc.oldRot[i + 1] - currentSegmentRotation) * 0.3f; + float segmentRotationOffset = MathHelper.Clamp(wrappedAngularOffset, -0.12f, 0.12f); + + // Add a sinusoidal offset that goes based on time and completion ratio to create a waving-flag-like effect. + // This is dampened for the first few points to prevent weird offsets. It is also dampened by high velocity. + float sinusoidalRotationOffset = (float)Math.Sin(ribbonCompletionRatio * 2.22f + Main.GlobalTime * 3.4f) * 1.36f; + float sinusoidalRotationOffsetFactor = Utils.InverseLerp(0f, 0.37f, ribbonCompletionRatio, true) * direction * 24f; + sinusoidalRotationOffsetFactor *= Utils.InverseLerp(24f, 16f, npc.velocity.Length(), true); + + Vector2 sinusoidalOffset = Vector2.UnitY.RotatedBy(npc.rotation + sinusoidalRotationOffset) * sinusoidalRotationOffsetFactor; + Vector2 ribbonSegmentOffset = Vector2.UnitY.RotatedBy(currentSegmentRotation) * ribbonCompletionRatio * 540f + sinusoidalOffset; + ribbonDrawPositions.Add(npc.Center + ribbonSegmentOffset + ribbonOffset); + + currentSegmentRotation += segmentRotationOffset; + } + RibbonTrail.Draw(ribbonDrawPositions, -Main.screenPosition, 66); + } + + int instanceCount = (int)MathHelper.Lerp(1f, 15f, ChargeFlash); + Color baseInstanceColor = Color.Lerp(drawColor, Color.White, ChargeFlash); + baseInstanceColor.A = (byte)(int)(255f - ChargeFlash * 255f); + + spriteBatch.EnterShaderRegion(); + + drawInstance(Vector2.Zero, baseInstanceColor); + if (instanceCount > 1) + { + baseInstanceColor *= 0.04f; + float backAfterimageOffset = MathHelper.SmoothStep(0f, 2f, ChargeFlash); + for (int i = 0; i < instanceCount; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / instanceCount + Main.GlobalTime * 0.8f).ToRotationVector2() * backAfterimageOffset; + drawInstance(drawOffset, baseInstanceColor); + } + } + + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Artemis/ArtemisGlow"); + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX, maxFramesY) * npc.scale / 2f; + afterimageCenter += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], origin, npc.scale, SpriteEffects.None, 0f); + } + } + + spriteBatch.Draw(texture, center, frame, Color.White * npc.Opacity, npc.rotation, origin, npc.scale, SpriteEffects.None, 0f); + + spriteBatch.ExitShaderRegion(); + + // Draw a flame trail on the thrusters if needed. This happens during charges. + if (ChargeFlash > 0f) + { + for (int direction = -1; direction <= 1; direction++) + { + Vector2 baseDrawOffset = new Vector2(0f, direction == 0f ? 18f : 60f).RotatedBy(npc.rotation); + baseDrawOffset += new Vector2(direction * 64f, 0f).RotatedBy(npc.rotation); + + float backFlameLength = direction == 0f ? 700f : 190f; + Vector2 drawStart = npc.Center + baseDrawOffset; + Vector2 drawEnd = drawStart - (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * ChargeFlash * backFlameLength; + Vector2[] drawPositions = new Vector2[] + { + drawStart, + drawEnd + }; + + if (direction == 0) + { + for (int i = 0; i < 4; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 8f; + ChargeFlameTrailBig.Draw(drawPositions, drawOffset - Main.screenPosition, 70); + } + } + else + ChargeFlameTrail.Draw(drawPositions, -Main.screenPosition, 70); + } + } + + return false; + } + + public override bool PreNPCLoot() => false; + + // Needs edits + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Artemis/Artemis1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Artemis/Artemis2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Artemis/Artemis3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Artemis/Artemis4"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Artemis/Artemis5"), 1f); + } + } + + public override bool CheckDead() + { + // Kill Apollo if he's still alive when Artemis dies + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC nPC = Main.npc[i]; + if (nPC.active && nPC.type == ModContent.NPCType() && nPC.life > 0) + { + nPC.life = 0; + nPC.HitEffect(0, 10.0); + nPC.checkDead(); + nPC.active = false; + } + } + return true; + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); + } } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs index 9f6c702e6f..f0d61452fb 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs @@ -13,507 +13,507 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Thanatos { - public class ThanatosBody1 : ModNPC + public class ThanatosBody1 : ModNPC { - public static int normalIconIndex; - public static int vulnerableIconIndex; + public static int normalIconIndex; + public static int vulnerableIconIndex; - internal static void LoadHeadIcons() - { - string normalIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosNormalBody"; - string vulnerableIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosVulnerableBody"; + internal static void LoadHeadIcons() + { + string normalIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosNormalBody"; + string vulnerableIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosVulnerableBody"; - CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); - normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); + CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); + normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); - CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); - vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); - } + CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); + vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); + } - // Whether the body is venting heat or not, it is vulnerable to damage during venting - private bool vulnerable = false; + // Whether the body is venting heat or not, it is vulnerable to damage during venting + private bool vulnerable = false; - public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); + public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); - // Default life ratio for the other mechs - private const float defaultLifeRatio = 5f; + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; - // Timer to prevent Thanatos from dealing contact damage for a bit - private int noContactDamageTimer = 0; + // Timer to prevent Thanatos from dealing contact damage for a bit + private int noContactDamageTimer = 0; - private const float timeToOpenAndFireLasers = 36f; + private const float timeToOpenAndFireLasers = 36f; - private const float segmentCloseTimerDecrement = 0.2f; + private const float segmentCloseTimerDecrement = 0.2f; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("XM-05 Thanatos"); - Main.npcFrameCount[npc.type] = 5; - } + Main.npcFrameCount[npc.type] = 5; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 5f; - npc.GetNPCDamage(); - npc.width = 88; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.width = 88; npc.height = 88; npc.defense = 100; - npc.DR_NERD(0.9999f); - npc.Calamity().unbreakableDR = true; - npc.LifeMaxNERB(960000, 1150000, 500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.DR_NERD(0.9999f); + npc.Calamity().unbreakableDR = true; + npc.LifeMaxNERB(960000, 1150000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; - npc.Opacity = 0f; - npc.canGhostHeal = false; - npc.behindTiles = true; + npc.Opacity = 0f; + npc.canGhostHeal = false; + npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.dontCountMe = true; npc.chaseable = false; - npc.boss = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.boss = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } - public override void BossHeadSlot(ref int index) - { - if (Main.npc[(int)npc.ai[2]].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune) - index = -1; - else if (vulnerable) - index = vulnerableIconIndex; - else - index = normalIconIndex; - } + public override void BossHeadSlot(ref int index) + { + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune) + index = -1; + else if (vulnerable) + index = vulnerableIconIndex; + else + index = normalIconIndex; + } - public override void BossHeadRotation(ref float rotation) - { - rotation = npc.rotation; - } + public override void BossHeadRotation(ref float rotation) + { + rotation = npc.rotation; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.chaseable); - writer.Write(npc.dontTakeDamage); - writer.Write(noContactDamageTimer); - writer.Write(vulnerable); - writer.Write(npc.localAI[0]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + writer.Write(noContactDamageTimer); + writer.Write(vulnerable); + writer.Write(npc.localAI[0]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.chaseable = reader.ReadBoolean(); - npc.dontTakeDamage = reader.ReadBoolean(); - noContactDamageTimer = reader.ReadInt32(); - vulnerable = reader.ReadBoolean(); - npc.localAI[0] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + noContactDamageTimer = reader.ReadInt32(); + vulnerable = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - return; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } - // Set vulnerable to false by default - vulnerable = false; + // Set vulnerable to false by default + vulnerable = false; - CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; - npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; - if (!invisiblePhase) - { - if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) - { - if (noContactDamageTimer > 0) - noContactDamageTimer--; + bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; + if (!invisiblePhase) + { + if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) + { + if (noContactDamageTimer > 0) + noContactDamageTimer--; - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - // Deal no contact damage for 3 seconds after becoming visible - noContactDamageTimer = 185; - } - } - else - { - // Deal no contact damage for 3 seconds after becoming visible - noContactDamageTimer = 185; + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + // Deal no contact damage for 3 seconds after becoming visible + noContactDamageTimer = 185; + } + } + else + { + // Deal no contact damage for 3 seconds after becoming visible + noContactDamageTimer = 185; - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } - // Number of body segments - int numSegments = ThanatosHead.minLength; + // Number of body segments + int numSegments = ThanatosHead.minLength; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Check if the other exo mechs are alive - int otherExoMechsAlive = 0; - bool exoPrimeAlive = false; - bool exoTwinsAlive = false; - if (CalamityGlobalNPC.draedonExoMechPrime != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - otherExoMechsAlive++; - exoPrimeAlive = true; - } - } - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - { - otherExoMechsAlive++; - exoTwinsAlive = true; - } - } + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoPrimeAlive = false; + bool exoTwinsAlive = false; + if (CalamityGlobalNPC.draedonExoMechPrime != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + otherExoMechsAlive++; + exoPrimeAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoTwinsAlive = true; + } + } - // Set the AI to become more aggressive if head is berserk - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; + // Set the AI to become more aggressive if head is berserk + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; - // These are 5 by default to avoid triggering passive phases after the other mechs are dead - float exoPrimeLifeRatio = defaultLifeRatio; - float exoTwinsLifeRatio = defaultLifeRatio; - if (exoPrimeAlive) - exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; - if (exoTwinsAlive) - exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoPrimeLifeRatio = defaultLifeRatio; + float exoTwinsLifeRatio = defaultLifeRatio; + if (exoPrimeAlive) + exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + if (exoTwinsAlive) + exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; - // If Thanatos doesn't go berserk - bool otherMechIsBerserk = exoPrimeLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; + // If Thanatos doesn't go berserk + bool otherMechIsBerserk = exoPrimeLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; - // Whether Thanatos should be buffed while in berserk phase - bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; + // Whether Thanatos should be buffed while in berserk phase + bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - // Use to close the segments quicker in later phases - float fasterSegmentClosingVar = lastMechAlive ? 0.2f : shouldGetBuffedByBerserkPhase ? 0.1f : 0f; + // Use to close the segments quicker in later phases + float fasterSegmentClosingVar = lastMechAlive ? 0.2f : shouldGetBuffedByBerserkPhase ? 0.1f : 0f; - bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; - if (shootLasers && !invisiblePhase) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Only charge up lasers if not venting or firing lasers - if (npc.Calamity().newAI[0] == 0f) - npc.ai[3] += 1f; + bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + if (shootLasers && !invisiblePhase) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Only charge up lasers if not venting or firing lasers + if (npc.Calamity().newAI[0] == 0f) + npc.ai[3] += 1f; - double numSegmentsAbleToFire = malice ? 35D : death ? 30D : revenge ? 28D : expertMode ? 25D : 20D; - if (shouldGetBuffedByBerserkPhase) - numSegmentsAbleToFire *= 1.5; + double numSegmentsAbleToFire = malice ? 35D : death ? 30D : revenge ? 28D : expertMode ? 25D : 20D; + if (shouldGetBuffedByBerserkPhase) + numSegmentsAbleToFire *= 1.5; - float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); - if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) - { - float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 90f; - if ((npc.ai[3] % divisor == 0f && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) - { - // Body is vulnerable while firing lasers - vulnerable = true; + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + { + float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 90f; + if ((npc.ai[3] % divisor == 0f && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) + { + // Body is vulnerable while firing lasers + vulnerable = true; - if (npc.Calamity().newAI[1] == 0f) - { - npc.Calamity().newAI[0] += 1f; - if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) - { - npc.ai[3] = 0f; - npc.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; + if (npc.Calamity().newAI[1] == 0f) + { + npc.Calamity().newAI[0] += 1f; + if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) + { + npc.ai[3] = 0f; + npc.Calamity().newAI[1] = 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (!Main.player[i].active || Main.player[i].dead) - continue; + for (int i = 0; i < Main.maxPlayers; i++) + { + if (!Main.player[i].active || Main.player[i].dead) + continue; - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, npc.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, npc.Center); + if (distance < maxDistance) + { + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; + } + } - SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - if (sound != null) - sound.Volume *= 0.1f; + SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + if (sound != null) + sound.Volume *= 0.1f; - for (int i = 0; i < numProjectiles; i++) - { - // Normal laser - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - else - { - npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (npc.Calamity().newAI[0] <= 0f) - { - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - } - } - } - } - else - { - float divisor = npc.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 - if ((npc.ai[3] == divisor && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) - { - // Body is vulnerable while firing lasers - vulnerable = true; + for (int i = 0; i < numProjectiles; i++) + { + // Normal laser + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + } + else + { + npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + else + { + float divisor = npc.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 + if ((npc.ai[3] == divisor && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) + { + // Body is vulnerable while firing lasers + vulnerable = true; - if (npc.Calamity().newAI[1] == 0f) - { - npc.Calamity().newAI[0] += 1f; - if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) - { - npc.ai[3] = 0f; - npc.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; + if (npc.Calamity().newAI[1] == 0f) + { + npc.Calamity().newAI[0] += 1f; + if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) + { + npc.ai[3] = 0f; + npc.Calamity().newAI[1] = 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (!Main.player[i].active || Main.player[i].dead) - continue; + for (int i = 0; i < Main.maxPlayers; i++) + { + if (!Main.player[i].active || Main.player[i].dead) + continue; - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, npc.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, npc.Center); + if (distance < maxDistance) + { + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; + } + } - float predictionAmt = malice ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; - if (npc.ai[0] % 3f == 0f) - predictionAmt *= 0.5f; + float predictionAmt = malice ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; + if (npc.ai[0] % 3f == 0f) + predictionAmt *= 0.5f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - for (int i = 0; i < numProjectiles; i++) - { - // Fire normal lasers if head is in passive state - if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) - { - // Normal laser - Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - else - { - // Normal laser - if (shouldGetBuffedByBerserkPhase && npc.ai[0] % 3f == 0f) - Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + for (int i = 0; i < numProjectiles; i++) + { + // Fire normal lasers if head is in passive state + if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) + { + // Normal laser + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + else + { + // Normal laser + if (shouldGetBuffedByBerserkPhase && npc.ai[0] % 3f == 0f) + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - // Predictive laser - Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + // Predictive laser + Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; + Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - // Opposite laser - projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - } - else - { - npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (npc.Calamity().newAI[0] <= 0f) - { - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - } - } - } - } - } - } - else - { - if (npc.ai[3] > 0f) - npc.ai[3] = 0f; + // Opposite laser + projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; + Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + } + } + else + { + npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + } + } + else + { + if (npc.ai[3] > 0f) + npc.ai[3] = 0f; - npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (npc.Calamity().newAI[0] <= 0f) - { - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - } - else - { - // Body is vulnerable while venting - vulnerable = true; - } - } + npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + else + { + // Body is vulnerable while venting + vulnerable = true; + } + } - // Do not deal contact damage for 5 seconds after spawning - if (npc.Calamity().newAI[2] == 0f) - noContactDamageTimer = 300; + // Do not deal contact damage for 5 seconds after spawning + if (npc.Calamity().newAI[2] == 0f) + noContactDamageTimer = 300; - if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) - npc.Calamity().newAI[2] += 1f; + if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) + npc.Calamity().newAI[2] += 1f; - // Homing only works if vulnerable is true - npc.chaseable = vulnerable; + // Homing only works if vulnerable is true + npc.chaseable = vulnerable; - // Adjust DR based on vulnerable - npc.Calamity().DR = vulnerable ? 0f : 0.9999f; - npc.Calamity().unbreakableDR = !vulnerable; + // Adjust DR based on vulnerable + npc.Calamity().DR = vulnerable ? 0f : 0.9999f; + npc.Calamity().unbreakableDR = !vulnerable; - // Increase overall damage taken while vulnerable - float damageMult = malice ? 1.1f : death ? 1.2f : revenge ? 1.25f : expertMode ? 1.3f : 1.4f; - if (shouldGetBuffedByBerserkPhase) - damageMult -= malice ? 0.1f : death ? 0.175f : revenge ? 0.2f : expertMode ? 0.225f : 0.3f; + // Increase overall damage taken while vulnerable + float damageMult = malice ? 1.1f : death ? 1.2f : revenge ? 1.25f : expertMode ? 1.3f : 1.4f; + if (shouldGetBuffedByBerserkPhase) + damageMult -= malice ? 0.1f : death ? 0.175f : revenge ? 0.2f : expertMode ? 0.225f : 0.3f; - npc.takenDamageMultiplier = vulnerable ? damageMult : 1f; + npc.takenDamageMultiplier = vulnerable ? damageMult : 1f; - // Vent noise and steam - SmokeDrawer.ParticleSpawnRate = 9999999; - if (vulnerable) - { - // Light - Lighting.AddLight(npc.Center, 0.35f * npc.Opacity, 0.05f * npc.Opacity, 0.05f * npc.Opacity); + // Vent noise and steam + SmokeDrawer.ParticleSpawnRate = 9999999; + if (vulnerable) + { + // Light + Lighting.AddLight(npc.Center, 0.35f * npc.Opacity, 0.05f * npc.Opacity, 0.05f * npc.Opacity); - // Noise - float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.1f : 1f; - if (npc.localAI[0] == 0f) - { - SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent"), npc.Center); - if (sound != null) - sound.Volume *= volume; - } + // Noise + float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.1f : 1f; + if (npc.localAI[0] == 0f) + { + SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent"), npc.Center); + if (sound != null) + sound.Volume *= volume; + } - // Steam - npc.localAI[0] += 1f; - float actualVentDuration = lastMechAlive ? 90f : shouldGetBuffedByBerserkPhase ? 120f : ThanatosHead.ventDuration; - if (npc.localAI[0] < actualVentDuration) - { - SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; - SmokeDrawer.ParticleSpawnRate = ThanatosHead.ventCloudSpawnRate; - } - } - else - { - // Light - Lighting.AddLight(npc.Center, 0.05f * npc.Opacity, 0.2f * npc.Opacity, 0.2f * npc.Opacity); + // Steam + npc.localAI[0] += 1f; + float actualVentDuration = lastMechAlive ? 90f : shouldGetBuffedByBerserkPhase ? 120f : ThanatosHead.ventDuration; + if (npc.localAI[0] < actualVentDuration) + { + SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; + SmokeDrawer.ParticleSpawnRate = ThanatosHead.ventCloudSpawnRate; + } + } + else + { + // Light + Lighting.AddLight(npc.Center, 0.05f * npc.Opacity, 0.2f * npc.Opacity, 0.2f * npc.Opacity); - npc.localAI[0] = 0f; - } + npc.localAI[0] = 0f; + } - SmokeDrawer.Update(); + SmokeDrawer.Update(); - Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; + Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; - Vector2 npcCenter = npc.Center; + Vector2 npcCenter = npc.Center; float targetCenterX = player.Center.X; float targetCenterY = player.Center.Y; - targetCenterX = (int)(targetCenterX / 16f) * 16; - targetCenterY = (int)(targetCenterY / 16f) * 16; - npcCenter.X = (int)(npcCenter.X / 16f) * 16; - npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; - targetCenterX -= npcCenter.X; - targetCenterY -= npcCenter.Y; + targetCenterX = (int)(targetCenterX / 16f) * 16; + targetCenterY = (int)(targetCenterY / 16f) * 16; + npcCenter.X = (int)(npcCenter.X / 16f) * 16; + npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; + targetCenterX -= npcCenter.X; + targetCenterY -= npcCenter.Y; float distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - targetCenterX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X; - targetCenterY = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y; + npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + targetCenterX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X; + targetCenterY = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y; } catch { } npc.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2; - distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); - distanceFromTarget = (distanceFromTarget - npc.width) / distanceFromTarget; - targetCenterX *= distanceFromTarget; - targetCenterY *= distanceFromTarget; + distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); + distanceFromTarget = (distanceFromTarget - npc.width) / distanceFromTarget; + targetCenterX *= distanceFromTarget; + targetCenterY *= distanceFromTarget; npc.velocity = Vector2.Zero; npc.position.X = npc.position.X + targetCenterX; npc.position.Y = npc.position.Y + targetCenterY; @@ -525,137 +525,137 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; - Rectangle targetHitbox = target.Hitbox; + Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= 50f && npc.Opacity == 1f && noContactDamageTimer <= 0; - } + return minDist <= 50f && npc.Opacity == 1f && noContactDamageTimer <= 0; + } - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) - { - if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) - damage *= 0.01; + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + { + if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) + damage *= 0.01; - return true; - } + return true; + } - public override void FindFrame(int frameHeight) // 5 total frames - { - if (!Main.npc[(int)npc.ai[2]].active || Main.npc[(int)npc.ai[2]].life <= 0) - return; + public override void FindFrame(int frameHeight) // 5 total frames + { + if (!Main.npc[(int)npc.ai[2]].active || Main.npc[(int)npc.ai[2]].life <= 0) + return; - // Swap between venting and non-venting frames - CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; - bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; - npc.frameCounter += 1D; - if (npc.Calamity().newAI[0] > 0f) - { - if (npc.frameCounter >= 6D) - { - npc.frame.Y += frameHeight; - npc.frameCounter = 0D; - } - int finalFrame = Main.npcFrameCount[npc.type] - 1; - if (npc.frame.Y > frameHeight * finalFrame) - npc.frame.Y = frameHeight * finalFrame; - } - else - { - if (npc.frameCounter >= 6D) - { - npc.frame.Y -= frameHeight; - npc.frameCounter = 0D; - } - if (npc.frame.Y < 0) - npc.frame.Y = 0; - } - } + // Swap between venting and non-venting frames + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; + bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + npc.frameCounter += 1D; + if (npc.Calamity().newAI[0] > 0f) + { + if (npc.frameCounter >= 6D) + { + npc.frame.Y += frameHeight; + npc.frameCounter = 0D; + } + int finalFrame = Main.npcFrameCount[npc.type] - 1; + if (npc.frame.Y > frameHeight * finalFrame) + npc.frame.Y = frameHeight * finalFrame; + } + else + { + if (npc.frameCounter >= 6D) + { + npc.frame.Y -= frameHeight; + npc.frameCounter = 0D; + } + if (npc.frame.Y < 0) + npc.frame.Y = 0; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture = Main.npcTexture[npc.type]; - Vector2 vector = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Texture2D texture = Main.npcTexture[npc.type]; + Vector2 vector = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Vector2 center = npc.Center - Main.screenPosition; - center -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - center += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, center, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); + Vector2 center = npc.Center - Main.screenPosition; + center -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + center += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, center, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); - texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosBody1Glow"); - spriteBatch.Draw(texture, center, npc.frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosBody1Glow"); + spriteBatch.Draw(texture, center, npc.frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); - SmokeDrawer.DrawSet(npc.Center); + SmokeDrawer.DrawSet(npc.Center); - return false; - } + return false; + } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) - { - if (npc.soundDelay == 0) - { - npc.soundDelay = 8; + public override void HitEffect(int hitDirection, double damage) + { + if (npc.soundDelay == 0) + { + npc.soundDelay = 8; - if (vulnerable) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); - else - Main.PlaySound(SoundID.NPCHit4, npc.Center); - } + if (vulnerable) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); + else + Main.PlaySound(SoundID.NPCHit4, npc.Center); + } - int baseDust = vulnerable ? 3 : 1; - for (int k = 0; k < baseDust; k++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + int baseDust = vulnerable ? 3 : 1; + for (int k = 0; k < baseDust; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); - if (npc.life <= 0) - { - for (int num193 = 0; num193 < 2; num193++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody1_2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody1_3"), 1f); - } - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody1_2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody1_3"), 1f); + } + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); + } + } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs index 5f31f54bb5..3144d6392c 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs @@ -13,650 +13,650 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Thanatos { - public class ThanatosBody2 : ModNPC + public class ThanatosBody2 : ModNPC { - public static int normalIconIndex; - public static int vulnerableIconIndex; + public static int normalIconIndex; + public static int vulnerableIconIndex; - internal static void LoadHeadIcons() - { - string normalIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosNormalBody2"; - string vulnerableIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosVulnerableBody2"; + internal static void LoadHeadIcons() + { + string normalIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosNormalBody2"; + string vulnerableIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosVulnerableBody2"; - CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); - normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); + CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); + normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); - CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); - vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); - } + CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); + vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); + } - // Whether the body is venting heat or not, it is vulnerable to damage during venting - private bool vulnerable = false; + // Whether the body is venting heat or not, it is vulnerable to damage during venting + private bool vulnerable = false; - public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); + public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); - // Default life ratio for the other mechs - private const float defaultLifeRatio = 5f; + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; - // Timer to prevent Thanatos from dealing contact damage for a bit - private int noContactDamageTimer = 0; + // Timer to prevent Thanatos from dealing contact damage for a bit + private int noContactDamageTimer = 0; - private const float timeToOpenAndFireLasers = 36f; + private const float timeToOpenAndFireLasers = 36f; - private const float segmentCloseTimerDecrement = 0.2f; + private const float segmentCloseTimerDecrement = 0.2f; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("XM-05 Thanatos"); - Main.npcFrameCount[npc.type] = 5; - } + Main.npcFrameCount[npc.type] = 5; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 5f; - npc.GetNPCDamage(); - npc.width = 90; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.width = 90; npc.height = 90; npc.defense = 100; - npc.DR_NERD(0.9999f); - npc.Calamity().unbreakableDR = true; - npc.LifeMaxNERB(960000, 1150000, 500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.DR_NERD(0.9999f); + npc.Calamity().unbreakableDR = true; + npc.LifeMaxNERB(960000, 1150000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; - npc.Opacity = 0f; - npc.canGhostHeal = false; - npc.behindTiles = true; + npc.Opacity = 0f; + npc.canGhostHeal = false; + npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.dontCountMe = true; npc.chaseable = false; - npc.boss = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.boss = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } - public override void BossHeadSlot(ref int index) - { - if (Main.npc[(int)npc.ai[2]].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune) - index = -1; - else if (vulnerable) - index = vulnerableIconIndex; - else - index = normalIconIndex; - } + public override void BossHeadSlot(ref int index) + { + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune) + index = -1; + else if (vulnerable) + index = vulnerableIconIndex; + else + index = normalIconIndex; + } - public override void BossHeadRotation(ref float rotation) - { - rotation = npc.rotation; - } + public override void BossHeadRotation(ref float rotation) + { + rotation = npc.rotation; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.chaseable); - writer.Write(npc.dontTakeDamage); - writer.Write(noContactDamageTimer); - writer.Write(vulnerable); - writer.Write(npc.localAI[0]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + writer.Write(noContactDamageTimer); + writer.Write(vulnerable); + writer.Write(npc.localAI[0]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.chaseable = reader.ReadBoolean(); - npc.dontTakeDamage = reader.ReadBoolean(); - noContactDamageTimer = reader.ReadInt32(); - vulnerable = reader.ReadBoolean(); - npc.localAI[0] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + noContactDamageTimer = reader.ReadInt32(); + vulnerable = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; - - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - return; - } - - // Set vulnerable to false by default - vulnerable = false; - - CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - - bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; - npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; - if (!invisiblePhase) - { - if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) - { - if (noContactDamageTimer > 0) - noContactDamageTimer--; - - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - // Deal no contact damage for 3 seconds after becoming visible - noContactDamageTimer = 185; - } - } - else - { - // Deal no contact damage for 3 seconds after becoming visible - noContactDamageTimer = 185; - - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } - - // Number of body segments - int numSegments = ThanatosHead.minLength; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Check if the other exo mechs are alive - int otherExoMechsAlive = 0; - bool exoPrimeAlive = false; - bool exoTwinsAlive = false; - if (CalamityGlobalNPC.draedonExoMechPrime != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - otherExoMechsAlive++; - exoPrimeAlive = true; - } - } - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - { - otherExoMechsAlive++; - exoTwinsAlive = true; - } - } - - // Set the AI to become more aggressive if head is berserk - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; - - // These are 5 by default to avoid triggering passive phases after the other mechs are dead - float exoPrimeLifeRatio = defaultLifeRatio; - float exoTwinsLifeRatio = defaultLifeRatio; - if (exoPrimeAlive) - exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; - if (exoTwinsAlive) - exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; - - // If Thanatos doesn't go berserk - bool otherMechIsBerserk = exoPrimeLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; - - // Whether Thanatos should be buffed while in berserk phase - bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - - // Use to close the segments quicker in later phases - float fasterSegmentClosingVar = lastMechAlive ? 0.2f : shouldGetBuffedByBerserkPhase ? 0.1f : 0f; - - bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; - if (shootLasers && !invisiblePhase) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Only charge up lasers if not venting or firing lasers - if (npc.Calamity().newAI[0] == 0f) - npc.ai[3] += 1f; - - double numSegmentsAbleToFire = malice ? 35D : death ? 30D : revenge ? 28D : expertMode ? 25D : 20D; - if (shouldGetBuffedByBerserkPhase) - numSegmentsAbleToFire *= 1.5; - - float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); - - if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) - { - float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 90f; - if ((npc.ai[3] % divisor == 0f && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) - { - // Body is vulnerable while firing lasers - vulnerable = true; - - if (npc.Calamity().newAI[1] == 0f) - { - npc.Calamity().newAI[0] += 1f; - if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) - { - npc.ai[3] = 0f; - npc.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; - - for (int i = 0; i < Main.maxPlayers; i++) - { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, npc.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - if (sound != null) - sound.Volume *= 0.1f; - - for (int i = 0; i < numProjectiles; i++) - { - // Normal laser - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - else - { - npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (npc.Calamity().newAI[0] <= 0f) - { - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - } - } - } - } - else - { - float divisor = npc.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 - if ((npc.ai[3] == divisor && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) - { - // Body is vulnerable while firing lasers - vulnerable = true; - - if (npc.Calamity().newAI[1] == 0f) - { - npc.Calamity().newAI[0] += 1f; - if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) - { - npc.ai[3] = 0f; - npc.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; - - for (int i = 0; i < Main.maxPlayers; i++) - { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, npc.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - float predictionAmt = malice ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; - if (npc.ai[0] % 3f == 0f) - predictionAmt *= 0.5f; - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - for (int i = 0; i < numProjectiles; i++) - { - // Fire normal lasers if head is in passive state - if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) - { - // Normal laser - Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - else - { - // Normal laser - if (shouldGetBuffedByBerserkPhase && npc.ai[0] % 3f == 0f) - Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - - // Predictive laser - Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - - // Opposite laser - projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - } - else - { - npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (npc.Calamity().newAI[0] <= 0f) - { - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - } - } - } - } - } - } - else - { - if (npc.ai[3] > 0f) - npc.ai[3] = 0f; - - npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (npc.Calamity().newAI[0] <= 0f) - { - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - } - else - { - // Body is vulnerable while venting - vulnerable = true; - } - } - - // Do not deal contact damage for 5 seconds after spawning - if (npc.Calamity().newAI[2] == 0f) - noContactDamageTimer = 300; - - if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) - npc.Calamity().newAI[2] += 1f; - - // Homing only works if vulnerable is true - npc.chaseable = vulnerable; - - // Adjust DR based on vulnerable - npc.Calamity().DR = vulnerable ? 0f : 0.9999f; - npc.Calamity().unbreakableDR = !vulnerable; - - // Increase overall damage taken while vulnerable - float damageMult = malice ? 1.1f : death ? 1.2f : revenge ? 1.25f : expertMode ? 1.3f : 1.4f; - if (shouldGetBuffedByBerserkPhase) - damageMult -= malice ? 0.1f : death ? 0.175f : revenge ? 0.2f : expertMode ? 0.225f : 0.3f; - - npc.takenDamageMultiplier = vulnerable ? damageMult : 1f; - - // Vent noise and steam - SmokeDrawer.ParticleSpawnRate = 9999999; - if (vulnerable) - { - // Light - Lighting.AddLight(npc.Center, 0.35f * npc.Opacity, 0.05f * npc.Opacity, 0.05f * npc.Opacity); - - // Noise - float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.1f : 1f; - if (npc.localAI[0] == 0f) - { - SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent"), npc.Center); - if (sound != null) - sound.Volume *= volume; - } - - // Steam - npc.localAI[0] += 1f; - float actualVentDuration = lastMechAlive ? 90f : shouldGetBuffedByBerserkPhase ? 120f : ThanatosHead.ventDuration; - if (npc.localAI[0] < actualVentDuration) - { - SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; - SmokeDrawer.ParticleSpawnRate = ThanatosHead.ventCloudSpawnRate; - } - } - else - { - // Light - Lighting.AddLight(npc.Center, 0.05f * npc.Opacity, 0.2f * npc.Opacity, 0.2f * npc.Opacity); - - npc.localAI[0] = 0f; - } - - SmokeDrawer.Update(); - - Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; - - Vector2 npcCenter = npc.Center; - float targetCenterX = player.Center.X; - float targetCenterY = player.Center.Y; - targetCenterX = (int)(targetCenterX / 16f) * 16; - targetCenterY = (int)(targetCenterY / 16f) * 16; - npcCenter.X = (int)(npcCenter.X / 16f) * 16; - npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; - targetCenterX -= npcCenter.X; - targetCenterY -= npcCenter.Y; - - float distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - targetCenterX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X; - targetCenterY = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y; - } - catch - { - } - - npc.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2; - distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); - distanceFromTarget = (distanceFromTarget - npc.width) / distanceFromTarget; - targetCenterX *= distanceFromTarget; - targetCenterY *= distanceFromTarget; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + targetCenterX; - npc.position.Y = npc.position.Y + targetCenterY; - - if (targetCenterX < 0f) - npc.spriteDirection = -1; - else if (targetCenterX > 0f) - npc.spriteDirection = 1; - } - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - - Rectangle targetHitbox = target.Hitbox; - - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; - - return minDist <= 50f && npc.Opacity == 1f && noContactDamageTimer <= 0; - } - - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) - { - if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) - damage *= 0.01; - - return true; - } - - public override void FindFrame(int frameHeight) // 5 total frames - { - if (!Main.npc[(int)npc.ai[2]].active || Main.npc[(int)npc.ai[2]].life <= 0) - return; - - // Swap between venting and non-venting frames - CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; - bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; - npc.frameCounter += 1D; - if (npc.Calamity().newAI[0] > 0f) - { - if (npc.frameCounter >= 6D) - { - npc.frame.Y += frameHeight; - npc.frameCounter = 0D; - } - int finalFrame = Main.npcFrameCount[npc.type] - 1; - if (npc.frame.Y > frameHeight * finalFrame) - npc.frame.Y = frameHeight * finalFrame; - } - else - { - if (npc.frameCounter >= 6D) - { - npc.frame.Y -= frameHeight; - npc.frameCounter = 0D; - } - if (npc.frame.Y < 0) - npc.frame.Y = 0; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture = Main.npcTexture[npc.type]; - Vector2 vector = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - - Vector2 center = npc.Center - Main.screenPosition; - center -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - center += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, center, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); - - texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosBody2Glow"); - spriteBatch.Draw(texture, center, npc.frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); - - SmokeDrawer.DrawSet(npc.Center); - - return false; - } - - public override bool CheckActive() => false; - - public override bool PreNPCLoot() => false; - - public override void HitEffect(int hitDirection, double damage) - { - if (npc.soundDelay == 0) - { - npc.soundDelay = 8; - - if (vulnerable) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); - else - Main.PlaySound(SoundID.NPCHit4, npc.Center); - } - - int baseDust = vulnerable ? 3 : 1; - for (int k = 0; k < baseDust; k++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); - - if (npc.life <= 0) - { - for (int num193 = 0; num193 < 2; num193++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody2_2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody2_3"), 1f); - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - } + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } + + // Set vulnerable to false by default + vulnerable = false; + + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + + bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; + if (!invisiblePhase) + { + if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) + { + if (noContactDamageTimer > 0) + noContactDamageTimer--; + + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + // Deal no contact damage for 3 seconds after becoming visible + noContactDamageTimer = 185; + } + } + else + { + // Deal no contact damage for 3 seconds after becoming visible + noContactDamageTimer = 185; + + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Number of body segments + int numSegments = ThanatosHead.minLength; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoPrimeAlive = false; + bool exoTwinsAlive = false; + if (CalamityGlobalNPC.draedonExoMechPrime != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + otherExoMechsAlive++; + exoPrimeAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoTwinsAlive = true; + } + } + + // Set the AI to become more aggressive if head is berserk + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoPrimeLifeRatio = defaultLifeRatio; + float exoTwinsLifeRatio = defaultLifeRatio; + if (exoPrimeAlive) + exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + if (exoTwinsAlive) + exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + + // If Thanatos doesn't go berserk + bool otherMechIsBerserk = exoPrimeLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; + + // Whether Thanatos should be buffed while in berserk phase + bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; + + // Use to close the segments quicker in later phases + float fasterSegmentClosingVar = lastMechAlive ? 0.2f : shouldGetBuffedByBerserkPhase ? 0.1f : 0f; + + bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + if (shootLasers && !invisiblePhase) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Only charge up lasers if not venting or firing lasers + if (npc.Calamity().newAI[0] == 0f) + npc.ai[3] += 1f; + + double numSegmentsAbleToFire = malice ? 35D : death ? 30D : revenge ? 28D : expertMode ? 25D : 20D; + if (shouldGetBuffedByBerserkPhase) + numSegmentsAbleToFire *= 1.5; + + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + { + float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 90f; + if ((npc.ai[3] % divisor == 0f && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) + { + // Body is vulnerable while firing lasers + vulnerable = true; + + if (npc.Calamity().newAI[1] == 0f) + { + npc.Calamity().newAI[0] += 1f; + if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) + { + npc.ai[3] = 0f; + npc.Calamity().newAI[1] = 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) + { + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, npc.Center); + if (distance < maxDistance) + { + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; + } + } + + SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + if (sound != null) + sound.Volume *= 0.1f; + + for (int i = 0; i < numProjectiles; i++) + { + // Normal laser + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + } + else + { + npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + else + { + float divisor = npc.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 + if ((npc.ai[3] == divisor && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) + { + // Body is vulnerable while firing lasers + vulnerable = true; + + if (npc.Calamity().newAI[1] == 0f) + { + npc.Calamity().newAI[0] += 1f; + if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) + { + npc.ai[3] = 0f; + npc.Calamity().newAI[1] = 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) + { + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, npc.Center); + if (distance < maxDistance) + { + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; + } + } + + float predictionAmt = malice ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; + if (npc.ai[0] % 3f == 0f) + predictionAmt *= 0.5f; + + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + for (int i = 0; i < numProjectiles; i++) + { + // Fire normal lasers if head is in passive state + if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) + { + // Normal laser + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + else + { + // Normal laser + if (shouldGetBuffedByBerserkPhase && npc.ai[0] % 3f == 0f) + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + + // Predictive laser + Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; + Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + + // Opposite laser + projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; + Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + } + } + else + { + npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + } + } + else + { + if (npc.ai[3] > 0f) + npc.ai[3] = 0f; + + npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + else + { + // Body is vulnerable while venting + vulnerable = true; + } + } + + // Do not deal contact damage for 5 seconds after spawning + if (npc.Calamity().newAI[2] == 0f) + noContactDamageTimer = 300; + + if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) + npc.Calamity().newAI[2] += 1f; + + // Homing only works if vulnerable is true + npc.chaseable = vulnerable; + + // Adjust DR based on vulnerable + npc.Calamity().DR = vulnerable ? 0f : 0.9999f; + npc.Calamity().unbreakableDR = !vulnerable; + + // Increase overall damage taken while vulnerable + float damageMult = malice ? 1.1f : death ? 1.2f : revenge ? 1.25f : expertMode ? 1.3f : 1.4f; + if (shouldGetBuffedByBerserkPhase) + damageMult -= malice ? 0.1f : death ? 0.175f : revenge ? 0.2f : expertMode ? 0.225f : 0.3f; + + npc.takenDamageMultiplier = vulnerable ? damageMult : 1f; + + // Vent noise and steam + SmokeDrawer.ParticleSpawnRate = 9999999; + if (vulnerable) + { + // Light + Lighting.AddLight(npc.Center, 0.35f * npc.Opacity, 0.05f * npc.Opacity, 0.05f * npc.Opacity); + + // Noise + float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.1f : 1f; + if (npc.localAI[0] == 0f) + { + SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent"), npc.Center); + if (sound != null) + sound.Volume *= volume; + } + + // Steam + npc.localAI[0] += 1f; + float actualVentDuration = lastMechAlive ? 90f : shouldGetBuffedByBerserkPhase ? 120f : ThanatosHead.ventDuration; + if (npc.localAI[0] < actualVentDuration) + { + SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; + SmokeDrawer.ParticleSpawnRate = ThanatosHead.ventCloudSpawnRate; + } + } + else + { + // Light + Lighting.AddLight(npc.Center, 0.05f * npc.Opacity, 0.2f * npc.Opacity, 0.2f * npc.Opacity); + + npc.localAI[0] = 0f; + } + + SmokeDrawer.Update(); + + Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; + + Vector2 npcCenter = npc.Center; + float targetCenterX = player.Center.X; + float targetCenterY = player.Center.Y; + targetCenterX = (int)(targetCenterX / 16f) * 16; + targetCenterY = (int)(targetCenterY / 16f) * 16; + npcCenter.X = (int)(npcCenter.X / 16f) * 16; + npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; + targetCenterX -= npcCenter.X; + targetCenterY -= npcCenter.Y; + + float distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + { + try + { + npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + targetCenterX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X; + targetCenterY = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y; + } + catch + { + } + + npc.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2; + distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); + distanceFromTarget = (distanceFromTarget - npc.width) / distanceFromTarget; + targetCenterX *= distanceFromTarget; + targetCenterY *= distanceFromTarget; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + targetCenterX; + npc.position.Y = npc.position.Y + targetCenterY; + + if (targetCenterX < 0f) + npc.spriteDirection = -1; + else if (targetCenterX > 0f) + npc.spriteDirection = 1; + } + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= 50f && npc.Opacity == 1f && noContactDamageTimer <= 0; + } + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + { + if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) + damage *= 0.01; + + return true; + } + + public override void FindFrame(int frameHeight) // 5 total frames + { + if (!Main.npc[(int)npc.ai[2]].active || Main.npc[(int)npc.ai[2]].life <= 0) + return; + + // Swap between venting and non-venting frames + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; + bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + npc.frameCounter += 1D; + if (npc.Calamity().newAI[0] > 0f) + { + if (npc.frameCounter >= 6D) + { + npc.frame.Y += frameHeight; + npc.frameCounter = 0D; + } + int finalFrame = Main.npcFrameCount[npc.type] - 1; + if (npc.frame.Y > frameHeight * finalFrame) + npc.frame.Y = frameHeight * finalFrame; + } + else + { + if (npc.frameCounter >= 6D) + { + npc.frame.Y -= frameHeight; + npc.frameCounter = 0D; + } + if (npc.frame.Y < 0) + npc.frame.Y = 0; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture = Main.npcTexture[npc.type]; + Vector2 vector = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + + Vector2 center = npc.Center - Main.screenPosition; + center -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + center += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, center, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); + + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosBody2Glow"); + spriteBatch.Draw(texture, center, npc.frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); + + SmokeDrawer.DrawSet(npc.Center); + + return false; + } + + public override bool CheckActive() => false; + + public override bool PreNPCLoot() => false; + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.soundDelay == 0) + { + npc.soundDelay = 8; + + if (vulnerable) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); + else + Main.PlaySound(SoundID.NPCHit4, npc.Center); + } + + int baseDust = vulnerable ? 3 : 1; + for (int k = 0; k < baseDust; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody2_2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosBody2_3"), 1f); + } + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); + } + } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs index b777eee1e9..498db632fa 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs @@ -16,1210 +16,1210 @@ using CalamityMod.Skies; namespace CalamityMod.NPCs.ExoMechs.Thanatos { - public class ThanatosHead : ModNPC - { - public static int normalIconIndex; - public static int vulnerableIconIndex; - - internal static void LoadHeadIcons() - { - string normalIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosNormalHead"; - string vulnerableIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosVulnerableHead"; - - CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); - normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); - - CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); - vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); - } - - public enum Phase - { - Charge = 0, - UndergroundLaserBarrage = 1, - Deathray = 2 - } - - public float AIState - { - get => npc.Calamity().newAI[0]; - set => npc.Calamity().newAI[0] = value; - } - - public enum SecondaryPhase - { - Nothing = 0, - Passive = 1, - PassiveAndImmune = 2 - } - - public float SecondaryAIState - { - get => npc.Calamity().newAI[1]; - set => npc.Calamity().newAI[1] = value; - } - - public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); - - // Timer to prevent Thanatos from dealing contact damage for a bit - private int noContactDamageTimer = 0; - - // Invincibility time for the first 10 seconds - public const float immunityTime = 600f; - - // Whether the head is venting heat or not, it is vulnerable to damage during venting - private bool vulnerable = false; - - // Max time in vent phase - public const float ventDuration = 180f; - - // Spawn rate for vent clouds - public const int ventCloudSpawnRate = 5; - - // Default life ratio for the other mechs - private const float defaultLifeRatio = 5f; - - // Base distance from the target for most attacks - private const float baseDistance = 400f; - - // Base distance from target location in order to continue turning - private const float baseTurnDistance = 160f; - - // Max distance from the target before they are unable to hear sound telegraphs - private const float soundDistance = 2800f; - - // Length variables - public const int minLength = 100; - private const int maxLength = 101; - - // Variable used to stop the segment spawning loop - private bool tailSpawned = false; - - // Used in the lerp to smoothly scale velocity up and down - private float chargeVelocityScalar = 0f; - - // Total duration of the deathray telegraph - private const float deathrayTelegraphDuration = 180f; - - // Total duration of the deathray - private const float deathrayDuration = 180f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("XM-05 Thanatos"); - Main.npcFrameCount[npc.type] = 5; - - // Ensure that the reticle is not culled due to the player being very far from Thanatos. - NPCID.Sets.MustAlwaysDraw[npc.type] = true; - } - - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 5f; - npc.GetNPCDamage(); - npc.width = 164; - npc.height = 164; - npc.defense = 80; - npc.DR_NERD(0.9999f); - npc.Calamity().unbreakableDR = true; - npc.LifeMaxNERB(960000, 1150000, 500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; - aiType = -1; - npc.Opacity = 0f; - npc.knockBackResist = 0f; - npc.value = Item.buyPrice(15, 0, 0, 0); - npc.behindTiles = true; - npc.noGravity = true; - npc.noTileCollide = true; - npc.DeathSound = SoundID.NPCDeath14; - npc.netAlways = true; - npc.boss = true; - npc.chaseable = false; - music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; - bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } - - public override void BossHeadSlot(ref int index) - { - if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) - index = -1; - else if (vulnerable) - index = vulnerableIconIndex; - else - index = normalIconIndex; - } - - public override void BossHeadRotation(ref float rotation) - { - rotation = npc.rotation; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.chaseable); - writer.Write(npc.dontTakeDamage); - writer.Write(noContactDamageTimer); - writer.Write(chargeVelocityScalar); - writer.Write(vulnerable); - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - writer.Write(npc.localAI[3]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.chaseable = reader.ReadBoolean(); - npc.dontTakeDamage = reader.ReadBoolean(); - noContactDamageTimer = reader.ReadInt32(); - chargeVelocityScalar = reader.ReadSingle(); - vulnerable = reader.ReadBoolean(); - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } - - public float GetSlowdownAreaEdgeRadius(bool lastMechAlive) => - ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 400f : CalamityWorld.death ? 600f : CalamityWorld.revenge ? 700f : Main.expertMode ? 800f : 1000f) * (lastMechAlive ? 0.6f : 1f); - - public int CheckForOtherMechs(ref Player target, out bool exoPrimeAlive, out bool exoTwinsAlive) - { - exoPrimeAlive = false; - exoTwinsAlive = false; - int otherExoMechsAlive = 0; - if (CalamityGlobalNPC.draedonExoMechPrime != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - // Set target to Ares' target if Ares is alive. - target = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - - otherExoMechsAlive++; - exoPrimeAlive = true; - } - } - - // There is no need in checking for the other twin because they have linked HP. - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - { - otherExoMechsAlive++; - exoTwinsAlive = true; - } - } - return otherExoMechsAlive; - } - - public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - CalamityGlobalNPC.draedonExoMechWorm = npc.whoAmI; - - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - // Target variable - Player player = Main.player[npc.target]; - - // Check if the other exo mechs are alive - int otherExoMechsAlive = CheckForOtherMechs(ref player, out bool exoPrimeAlive, out bool exoTwinsAlive); - - // These are 5 by default to avoid triggering passive phases after the other mechs are dead - float exoPrimeLifeRatio = defaultLifeRatio; - float exoTwinsLifeRatio = defaultLifeRatio; - if (exoPrimeAlive) - exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; - if (exoTwinsAlive) - exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; - float totalOtherExoMechLifeRatio = exoPrimeLifeRatio + exoTwinsLifeRatio; - - // Check if any of the other mechs are passive - bool exoPrimePassive = false; - bool exoTwinsPassive = false; - if (exoPrimeAlive) - exoPrimePassive = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] == (float)AresBody.SecondaryPhase.Passive; - if (exoTwinsAlive) - exoTwinsPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] == (float)Apollo.Apollo.SecondaryPhase.Passive; - bool anyOtherExoMechPassive = exoPrimePassive || exoTwinsPassive; - - // Check if any of the other mechs were spawned first - bool exoPrimeWasFirst = false; - bool exoTwinsWereFirst = false; - if (exoPrimeAlive) - exoPrimeWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] == 1f; - if (exoTwinsAlive) - exoTwinsWereFirst = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ai[3] == 1f; - bool otherExoMechWasFirst = exoPrimeWasFirst || exoTwinsWereFirst; - - // Check for Draedon - bool draedonAlive = false; - if (CalamityGlobalNPC.draedon != -1) - { - if (Main.npc[CalamityGlobalNPC.draedon].active) - draedonAlive = true; - } - - // Prevent mechs from being respawned - if (otherExoMechWasFirst) - { - if (npc.ai[3] < 1f) - npc.ai[3] = 1f; - } - - // Phases - bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; - - // Set vulnerable to false by default - vulnerable = false; - - // If Thanatos doesn't go berserk - bool otherMechIsBerserk = exoPrimeLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; - - // Whether Thanatos should be buffed while in berserk phase - bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Spawn segments - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!tailSpawned && npc.ai[0] == 0f) - { - int Previous = npc.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) - { - int lol; - if (num36 >= 0 && num36 < minLength) - { - if (num36 % 2 == 0) - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - else - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - else - 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] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); - Previous = lol; - } - tailSpawned = true; - } - } - - if (npc.life > Main.npc[(int)npc.ai[0]].life) - npc.life = Main.npc[(int)npc.ai[0]].life; - - // General AI pattern - // 0 - Fly towards the target for 7 seconds, gradually speeding up for the first 5 seconds and slowing down for the last 2 seconds, fire lasers from segments that are venting - // 1 - Fly underneath the target and fire barrages of lasers - // 2 - Fire deathray from mouth with a telegraph similar to the railgun from enter the gungeon, turn speed is very low during this to avoid cheap hits - // 3 - Go passive and fly underneath the target while firing lasers - // 4 - Go passive, immune and invisible; fly far underneath the target and do nothing until next phase - - // Attack patterns - // If spawned first - // Phase 1 - 0, 1, 0, 2 - // Phase 2 - 4 - // Phase 3 - 3 - - // If berserk, this is the last phase of thanatos - // Phase 4 - 0, 1, 0, 2 - - // If not berserk - // Phase 4 - 4 - // Phase 5 - 0, 1, 0, 2 - - // If berserk, this is the last phase of thanatos - // Phase 6 - 0, 1, 0, 2 - - // If not berserk - // Phase 6 - 4 - - // Berserk, final phase of Thanatos - // Phase 7 - 0, 1, 0, 2 - - // Phase gate values - float velocityAdjustTime = 20f; - float speedUpTime = lastMechAlive ? 180f : shouldGetBuffedByBerserkPhase ? 240f : 360f; - float slowDownTime = lastMechAlive ? 30f : shouldGetBuffedByBerserkPhase ? 40f : 60f; - float chargePhaseGateValue = speedUpTime + slowDownTime; - float laserBarrageDuration = lastMechAlive ? 270f : shouldGetBuffedByBerserkPhase ? 300f : 360f; - - // Despawn if target is dead - bool targetDead = false; - if (player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (player.dead) - { - targetDead = true; - AIState = (float)Phase.Charge; - npc.localAI[0] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - npc.dontTakeDamage = true; - - npc.velocity.Y -= 1f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 1f; - - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - } - } - - // Rotation and direction - npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - int direction = npc.direction; - npc.direction = npc.spriteDirection = (npc.velocity.X > 0f) ? 1 : (-1); - if (direction != npc.direction) - npc.netUpdate = true; - - // Default vector to fly to - Vector2 destination = player.Center; - - // Move destination to somewhere far below the target for the first 3 seconds so that Thanatos can fully uncoil quickly - bool speedUp = false; - if (npc.localAI[3] < 180f) - { - speedUp = true; - destination += new Vector2(0f, 2400f); - } - - // Distance from target - float distanceFromTarget = Vector2.Distance(npc.Center, destination); - - // Increase speed if too far from target - float increaseSpeedMult = 1f; - float increaseSpeedGateValue = 500f; - if (distanceFromTarget > increaseSpeedGateValue) - { - float distanceAmount = MathHelper.Clamp((distanceFromTarget - increaseSpeedGateValue) / (CalamityGlobalNPC.CatchUpDistance350Tiles - increaseSpeedGateValue), 0f, 1f); - increaseSpeedMult = MathHelper.Lerp(1f, 3.5f, distanceAmount); - } - - // Charge variables - float turnDistance = baseTurnDistance; - float chargeLocationDistance = turnDistance * 0.2f; - - // Laser Barrage variables - float laserBarrageLocationBaseDistance = SecondaryAIState == (int)SecondaryPhase.PassiveAndImmune ? baseDistance * 2f : baseDistance; - Vector2 laserBarrageLocation = new Vector2(0f, npc.ai[1] % 2f == 0f ? laserBarrageLocationBaseDistance : -laserBarrageLocationBaseDistance); - float laserBarrageLocationDistance = turnDistance * 3f; - - // Velocity and turn speed values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); - float baseVelocity = 11.1f * baseVelocityMult; - - // Increase top velocity if target is dead or if Thanatos is uncoiling - if (targetDead || speedUp) - baseVelocity *= 4f; - else - baseVelocity *= increaseSpeedMult; - - float turnDegrees = baseVelocity * 0.11f * (shouldGetBuffedByBerserkPhase ? 1.25f : 1f); - - float turnSpeed = MathHelper.ToRadians(turnDegrees); - float chargeVelocityMult = MathHelper.Lerp(1f, 1.5f, chargeVelocityScalar); - float chargeTurnSpeedMult = MathHelper.Lerp(1f, 1.5f, chargeVelocityScalar); - float laserBarragePhaseVelocityMult = MathHelper.Lerp(1f, 1.5f, chargeVelocityScalar); - float laserBarragePhaseTurnSpeedMult = MathHelper.Lerp(1f, 3f, chargeVelocityScalar); - float deathrayVelocityMult = MathHelper.Lerp(0.5f, 3f, chargeVelocityScalar); - float deathrayTurnSpeedMult = MathHelper.Lerp(0.5f, 3f, chargeVelocityScalar); - - // Base scale on total time spent in phase - float chargeVelocityScalarIncrement = 1f / speedUpTime; - float chargeVelocityScalarDecrement = 1f / slowDownTime; - - // Scalar to use during deathray phase - float deathrayVelocityScalarIncrement = 1f / deathrayDuration; - - // Scalar to use during laser barrage, passive and immune phases - float laserBarrageVelocityScalarIncrement = lastMechAlive ? 0.025f : shouldGetBuffedByBerserkPhase ? 0.02f : 0.015f; - float laserBarrageVelocityScalarDecrement = 1f / velocityAdjustTime; - - // Passive and Immune phases - switch ((int)SecondaryAIState) - { - case (int)SecondaryPhase.Nothing: - - // Spawn the other mechs if Thanatos is first - if (otherExoMechsAlive == 0) - { - if (spawnOtherExoMechs) - { - // Reset everything - if (npc.ai[3] < 1f) - npc.ai[3] = 1f; - - SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; - npc.localAI[0] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - npc.TargetClosest(); - - // Draedon text for the start of phase 2 - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 1f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Spawn the fuckers - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - } - } - } - else - { - // If not spawned first, go to passive state if any other mech is passive or if Thanatos is under 70% life - // Do not run this if berserk - // Do not run this if any exo mech is dead - if ((anyOtherExoMechPassive || lifeRatio < 0.7f) && !berserk && totalOtherExoMechLifeRatio < 5f) - { - // Tells Thanatos to return to the battle in passive state and reset everything - SecondaryAIState = (float)SecondaryPhase.Passive; - npc.localAI[0] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - npc.TargetClosest(); - } - - // Go passive and immune if one of the other mechs is berserk - // This is only called if two exo mechs are alive in ideal scenarios - // This is not called if Thanatos and another one or two mechs are berserk - if (otherMechIsBerserk && !berserk) - { - // Reset everything - SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; - npc.localAI[0] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - npc.TargetClosest(); - - // Phase 6, when 1 mech goes berserk and the other one leaves - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 5f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - } - - break; - - // Fly underneath target and fire lasers, this happens when all 3 mechs are present and attacking - case (int)SecondaryPhase.Passive: - - // Fire lasers while passive - AIState = (float)Phase.UndergroundLaserBarrage; - - // Enter passive and invincible phase if one of the other exo mechs is berserk - if (otherMechIsBerserk) - { - // Reset everything - SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; - npc.localAI[0] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - npc.TargetClosest(); - } - - // If Thanatos is the first mech to go berserk - if (berserk) - { - // Reset everything - AIState = (float)Phase.Charge; - npc.localAI[0] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - npc.TargetClosest(); - - // Never be passive if berserk - SecondaryAIState = (float)SecondaryPhase.Nothing; - - // Phase 4, when 1 mech goes berserk and the other 2 leave - if (exoTwinsAlive && exoPrimeAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 3f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - } - - break; - - // Fly underneath target and become immune - case (int)SecondaryPhase.PassiveAndImmune: - - // Do nothing while immune - AIState = (float)Phase.UndergroundLaserBarrage; - - // Enter the fight again if any of the other exo mechs is below 70% and other mechs aren't berserk - if ((exoPrimeLifeRatio < 0.7f || exoTwinsLifeRatio < 0.7f) && !otherMechIsBerserk) - { - // Tells Thanatos to return to the battle in passive state and reset everything - // Return to normal phases if one or more mechs have been downed - SecondaryAIState = totalOtherExoMechLifeRatio > 5f ? (float)SecondaryPhase.Nothing : (float)SecondaryPhase.Passive; - npc.localAI[0] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - npc.TargetClosest(); - - // Phase 3, when all 3 mechs attack at the same time - if (exoPrimeAlive && exoTwinsAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 2f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - } - - // This is here just in case - if (berserk) - { - // Reset everything - AIState = (float)Phase.Charge; - npc.localAI[0] = 0f; - npc.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - npc.TargetClosest(); - - // Never be passive if berserk - SecondaryAIState = (float)SecondaryPhase.Nothing; - } - - break; - } - - // Adjust opacity - bool invisiblePhase = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune; - npc.dontTakeDamage = invisiblePhase; - if (!invisiblePhase) - { - if (noContactDamageTimer > 0) - noContactDamageTimer--; - - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - // Deal no contact damage for 3 seconds after becoming visible - noContactDamageTimer = 185; - - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } - - // Attacking phases - switch ((int)AIState) - { - // Fly towards target and gain velocity over time - case (int)Phase.Charge: - - // Use a lerp to smoothly scale up velocity and turn speed - if (calamityGlobalNPC.newAI[3] == 0f) - { - chargeVelocityScalar += chargeVelocityScalarIncrement; - if (chargeVelocityScalar >= 1f) - { - chargeVelocityScalar = 1f; - calamityGlobalNPC.newAI[3] = 1f; - } - } - else - { - chargeVelocityScalar -= chargeVelocityScalarDecrement; - if (chargeVelocityScalar < 0f) - chargeVelocityScalar = 0f; - } - - baseVelocity *= chargeVelocityMult; - turnSpeed *= chargeTurnSpeedMult; - turnDistance = chargeLocationDistance; - - // Gradually turn slower if within 20 tiles of the target - float turnSlowerDistanceGateValue = lastMechAlive ? 160f : 240f; - if (distanceFromTarget < turnSlowerDistanceGateValue) - turnSpeed *= distanceFromTarget / turnSlowerDistanceGateValue; - - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] >= chargePhaseGateValue) - { - AIState = npc.localAI[0] == 1f ? (float)Phase.Deathray : (float)Phase.UndergroundLaserBarrage; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - npc.TargetClosest(); - } - - break; - - // Fly below and summon barrages of lasers - case (int)Phase.UndergroundLaserBarrage: - - // Fly down - destination += laserBarrageLocation; - turnDistance = laserBarrageLocationDistance; - - // Use a lerp to smoothly scale up velocity and turn speed - if (calamityGlobalNPC.newAI[3] == 0f) - { - chargeVelocityScalar += laserBarrageVelocityScalarIncrement; - if (chargeVelocityScalar > 1f) - chargeVelocityScalar = 1f; - } - - baseVelocity *= laserBarragePhaseVelocityMult; - turnSpeed *= laserBarragePhaseTurnSpeedMult; - - if ((destination - npc.Center).Length() < laserBarrageLocationDistance || calamityGlobalNPC.newAI[2] > 0f) - { - calamityGlobalNPC.newAI[2] += 1f; - - if (SecondaryAIState != (float)SecondaryPhase.Passive && SecondaryAIState != (float)SecondaryPhase.PassiveAndImmune) - { - if (calamityGlobalNPC.newAI[2] >= laserBarrageDuration) - { - // Use a lerp to smoothly scale down velocity and turn speed - chargeVelocityScalar -= laserBarrageVelocityScalarDecrement; - if (chargeVelocityScalar < 0f) - chargeVelocityScalar = 0f; - - calamityGlobalNPC.newAI[3] += 1f; - if (calamityGlobalNPC.newAI[3] >= velocityAdjustTime) - { - npc.ai[1] += (shouldGetBuffedByBerserkPhase && revenge) ? 1f : 0f; - npc.localAI[0] = shouldGetBuffedByBerserkPhase ? 1f : 0f; - AIState = (float)Phase.Charge; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - npc.TargetClosest(); - } - } - } - } - - break; - - // Move close to target, reduce velocity and turn speed when close enough, create telegraph beams, reduce turn speed, fire deathray - case (int)Phase.Deathray: - - // Head is vulnerable while charging and firing deathray - vulnerable = true; - - // If close enough to the target, prepare to fire deathray - float slowDownDistance = GetSlowdownAreaEdgeRadius(lastMechAlive); - bool readyToFireDeathray = distanceFromTarget < slowDownDistance; - if (readyToFireDeathray) - npc.localAI[2] = 1f; - - // Use a lerp to smoothly scale up velocity and turn speed - if (calamityGlobalNPC.newAI[3] == 0f) - { - chargeVelocityScalar += deathrayVelocityScalarIncrement; - if (chargeVelocityScalar >= 1f) - { - chargeVelocityScalar = 1f; - - // If ready to fire deathray, start reducing the velocity scalar - if (npc.localAI[2] == 1f) - calamityGlobalNPC.newAI[3] = 1f; - } - } - else - { - // Reduce velocity scalar very quickly - chargeVelocityScalar -= deathrayVelocityScalarIncrement * 5f; - if (chargeVelocityScalar < 0f) - chargeVelocityScalar = 0f; - } - - baseVelocity *= deathrayVelocityMult; - turnSpeed *= deathrayTurnSpeedMult; - turnDistance = chargeLocationDistance; - - // Gradually turn and move slower if within 50 tiles of the target - if (npc.localAI[2] == 1f) - { - // Exponentially scale down velocity if close to the target - float velocityScale = distanceFromTarget / slowDownDistance; - if (velocityScale < 1f) - velocityScale *= velocityScale; - - baseVelocity *= velocityScale; - turnSpeed *= velocityScale; - - calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] < deathrayTelegraphDuration) - { - // Fire deathray telegraph beams - if (calamityGlobalNPC.newAI[2] == 1f) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/THanosLaser"), - (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y); - } - - // Create a bunch of lightning bolts in the sky - ExoMechsSky.CreateLightningBolt(12); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - for (int b = 0; b < 6; b++) - { - int beam = Projectile.NewProjectile(npc.Center, Vector2.Zero, type, 0, 0f, 255, npc.whoAmI); - - // Determine the initial offset angle of telegraph. It will be smoothened to give a "stretch" effect. - if (Main.projectile.IndexInRange(beam)) - { - float squishedRatio = (float)Math.Pow((float)Math.Sin(MathHelper.Pi * b / 6f), 2D); - float smoothenedRatio = MathHelper.SmoothStep(0f, 1f, squishedRatio); - Main.projectile[beam].ai[0] = npc.whoAmI; - Main.projectile[beam].ai[1] = MathHelper.Lerp(-0.74f, 0.74f, smoothenedRatio); - } - } - int beam2 = Projectile.NewProjectile(npc.Center, Vector2.Zero, type, 0, 0f, 255, npc.whoAmI); - if (Main.projectile.IndexInRange(beam2)) - Main.projectile[beam2].ai[0] = npc.whoAmI; - } - } - } - else - { - // Fire deathray - if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - - if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) - { - npc.localAI[0] = 0f; - npc.localAI[2] = 0f; - AIState = (float)Phase.Charge; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - npc.TargetClosest(); - } - } - - break; - } - - // Do not deal contact damage for 5 seconds after spawning - if (npc.localAI[3] == 0f) - noContactDamageTimer = 300; - - if (npc.localAI[3] < immunityTime) - npc.localAI[3] += 1f; - - // Homing only works if vulnerable is true - npc.chaseable = vulnerable; - - // Adjust DR based on vulnerable - npc.Calamity().DR = vulnerable ? 0f : 0.9999f; - npc.Calamity().unbreakableDR = !vulnerable; - - // Increase overall damage taken while vulnerable - npc.takenDamageMultiplier = vulnerable ? 1.1f : 1f; - - // Vent noise and steam - SmokeDrawer.ParticleSpawnRate = 9999999; - if (vulnerable) - { - // Light - Lighting.AddLight(npc.Center, 0.35f * npc.Opacity, 0.05f * npc.Opacity, 0.05f * npc.Opacity); - - // Noise - if (npc.localAI[1] == 0f) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent"), npc.Center); - - // Steam - npc.localAI[1] += 1f; - if (npc.localAI[1] < ventDuration) - { - SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; - SmokeDrawer.ParticleSpawnRate = ventCloudSpawnRate; - } - } - else - { - // Light - Lighting.AddLight(npc.Center, 0.05f * npc.Opacity, 0.2f * npc.Opacity, 0.2f * npc.Opacity); - - npc.localAI[1] = 0f; - } - - SmokeDrawer.Update(); - - if (!targetDead) - { - // Increase velocity if velocity is ever zero - if (npc.velocity == Vector2.Zero) - npc.velocity = Vector2.Normalize(player.Center - npc.Center).SafeNormalize(Vector2.Zero) * baseVelocity; - - // Acceleration - if (!((destination - npc.Center).Length() < turnDistance)) - { - float targetAngle = npc.AngleTo(destination); - float f = npc.velocity.ToRotation().AngleTowards(targetAngle, turnSpeed); - npc.velocity = f.ToRotationVector2() * baseVelocity; - } - } - - // Velocity upper limit - if (npc.velocity.Length() > baseVelocity) - npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero) * baseVelocity; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - - Rectangle targetHitbox = target.Hitbox; - - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; - - return minDist <= 50f && npc.Opacity == 1f && noContactDamageTimer <= 0; - } - - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) - { - if (npc.localAI[3] < immunityTime) - damage *= 0.01; - - return true; - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - scale = 1.5f; - return null; - } - - public override void FindFrame(int frameHeight) // 5 total frames - { - // Swap between venting and non-venting frames - npc.frameCounter += 1D; - if (AIState == (float)Phase.Charge || AIState == (float)Phase.UndergroundLaserBarrage) - { - if (npc.frameCounter >= 6D) - { - npc.frame.Y -= frameHeight; - npc.frameCounter = 0D; - } - if (npc.frame.Y < 0) - npc.frame.Y = 0; - } - else - { - if (npc.frameCounter >= 6D) - { - npc.frame.Y += frameHeight; - npc.frameCounter = 0D; - } - int finalFrame = Main.npcFrameCount[npc.type] - 1; - if (npc.frame.Y >= frameHeight * finalFrame) - npc.frame.Y = frameHeight * finalFrame; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture = Main.npcTexture[npc.type]; - Vector2 vector = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - - Vector2 center = npc.Center - Main.screenPosition; - center -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - center += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, center, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); - - texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosHeadGlow"); - spriteBatch.Draw(texture, center, npc.frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); - - SmokeDrawer.DrawSet(npc.Center); - - // Draw a white indicator aura and reticle before and while a death ray is being fired. - // This is done to give a visual indicator that players should move near the head (which results in slower movement and thus easier dodging capabilities). - if (AIState == (int)Phase.Deathray && SecondaryAIState != (int)SecondaryPhase.PassiveAndImmune) - { - spriteBatch.SetBlendState(BlendState.Additive); - - // A large, faded circle. Is rescaled to fit the radius of the slowdown area. - Texture2D auraTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/THanosAura"); - - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Yes, this is bizarre as fuck. - Player completelyUseless = null; - int otherExoMechsAlive = CheckForOtherMechs(ref completelyUseless, out _, out _); - - // A general factor for the aura. - // Used to cause fade-ins/outs as the attack starts/stops. - float auraGeneralPower = Utils.InverseLerp(0f, deathrayTelegraphDuration * 0.333f, npc.Calamity().newAI[2], true); - auraGeneralPower *= Utils.InverseLerp(deathrayTelegraphDuration + deathrayDuration, deathrayTelegraphDuration + deathrayDuration, npc.Calamity().newAI[2], true); - - // Determine the characteristics of the aura. This requires intermediate computations to determine if Thanatos is in its final phase as well as for pulsing. - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; - float pulse = Main.GlobalTime * 0.72f % 1f; - float auraRadius = GetSlowdownAreaEdgeRadius(lastMechAlive) * auraGeneralPower * 1.25f; - Vector2 outerAuraScale = Vector2.One * auraRadius / auraTexture.Size(); - Vector2 innerAuraScale = outerAuraScale * pulse * 1.2f; - Color outerAuraColor = Color.White * auraGeneralPower * 0.6f; - Color innerAuraColor = outerAuraColor * (float)Math.Sqrt(1f - pulse); - - // Draw the aura. - spriteBatch.Draw(auraTexture, center, null, outerAuraColor, 0f, auraTexture.Size() * 0.5f, outerAuraScale, SpriteEffects.None, 0f); - spriteBatch.Draw(auraTexture, center, null, innerAuraColor, 0f, auraTexture.Size() * 0.5f, innerAuraScale, SpriteEffects.None, 0f); - - spriteBatch.SetBlendState(BlendState.AlphaBlend); - - // Draw the reticle depending on how close the player is. This drawcode terminates early if Thanatos has no target. - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - return false; - - Player target = Main.player[npc.target]; - - Texture2D leftReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleLeft"); - Texture2D rightReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleRight"); - Texture2D topReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleTop"); - Texture2D bottomReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleHead"); - Texture2D leftReticleProngTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleProngLeft"); - Texture2D rightReticleProngTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleProngRight"); - - // The reticle fades away and moves farther away from the target the closer they are to the aura. - // Once far away, the reticle will flash between red and white as an indicator. - float targetHeadDistance = npc.Distance(target.Center); - float reticleOpacity = Utils.InverseLerp(auraRadius * 0.5f - 40f, auraRadius * 0.5f + 100f, targetHeadDistance, true); - float reticleOffsetDistance = MathHelper.SmoothStep(300f, 0f, reticleOpacity); - float reticleFadeToWhite = ((float)Math.Cos(Main.GlobalTime * 6.8f) * 0.5f + 0.5f) * reticleOpacity * 0.67f; - Color reticleBaseColor = new Color(255, 0, 0, 127) * reticleOpacity; - Color reticleFlashBaseColor = Color.Lerp(reticleBaseColor, new Color(255, 255, 255, 0), reticleFadeToWhite) * reticleOpacity; - Vector2 origin = leftReticleTexture.Size() * 0.5f; - - Vector2 playerDrawPosition = target.Center - Main.screenPosition; - spriteBatch.Draw(leftReticleTexture, playerDrawPosition - Vector2.UnitX * reticleOffsetDistance, null, reticleBaseColor, 0f, origin, 1f, SpriteEffects.None, 0f); - spriteBatch.Draw(rightReticleTexture, playerDrawPosition + Vector2.UnitX * reticleOffsetDistance, null, reticleBaseColor, 0f, origin, 1f, SpriteEffects.None, 0f); - - for (int i = 0; i < 3; i++) - { - float scale = 1f + i * 0.125f; - spriteBatch.Draw(leftReticleProngTexture, playerDrawPosition - Vector2.UnitX * reticleOffsetDistance, null, reticleFlashBaseColor, 0f, origin, scale, SpriteEffects.None, 0f); - spriteBatch.Draw(rightReticleProngTexture, playerDrawPosition + Vector2.UnitX * reticleOffsetDistance, null, reticleFlashBaseColor, 0f, origin, scale, SpriteEffects.None, 0f); - spriteBatch.Draw(bottomReticleTexture, playerDrawPosition + Vector2.UnitY * reticleOffsetDistance, null, reticleFlashBaseColor, 0f, origin, scale, SpriteEffects.None, 0f); - } - spriteBatch.Draw(topReticleTexture, playerDrawPosition - Vector2.UnitY * reticleOffsetDistance, null, reticleBaseColor, 0f, origin, 1f, SpriteEffects.None, 0f); - } - - return false; - } - - public override void BossLoot(ref string name, ref int potionType) - { - potionType = ModContent.ItemType(); - } - - public override bool SpecialNPCLoot() - { - int closestSegmentID = DropHelper.FindClosestWormSegment(npc, - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType()); - npc.position = Main.npc[closestSegmentID].position; - return false; - } - - public override void NPCLoot() - { - // Check if the other exo mechs are alive - bool exoTwinsAlive = false; - bool exoPrimeAlive = false; - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - exoTwinsAlive = true; - } - if (CalamityGlobalNPC.draedonExoMechPrime != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - exoPrimeAlive = true; - } - - // Check for Draedon - bool draedonAlive = false; - if (CalamityGlobalNPC.draedon != -1) - { - if (Main.npc[CalamityGlobalNPC.draedon].active) - draedonAlive = true; - } - - // Phase 5, when 1 mech dies and the other 2 return to fight - if (exoTwinsAlive && exoPrimeAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 4f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - - // Phase 7, when 1 mech dies and the final one returns to the fight - else if (exoTwinsAlive || exoPrimeAlive) - { - if (draedonAlive) - { - Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 6f; - Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; - } - } - - // Mark Exo Mechs as dead and drop loot - else - AresBody.DropExoMechLoot(npc, (int)AresBody.MechType.Thanatos); - } - - public override void HitEffect(int hitDirection, double damage) - { - if (npc.soundDelay == 0) - { - npc.soundDelay = 8; - - if (vulnerable) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); - else - Main.PlaySound(SoundID.NPCHit4, npc.Center); - } - - for (int k = 0; k < 3; k++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); - - if (npc.life <= 0) - { - for (int num193 = 0; num193 < 2; num193++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosHead"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosHead2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosHead3"), 1f); - } - } - - public override bool CheckActive() => false; - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - } + public class ThanatosHead : ModNPC + { + public static int normalIconIndex; + public static int vulnerableIconIndex; + + internal static void LoadHeadIcons() + { + string normalIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosNormalHead"; + string vulnerableIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosVulnerableHead"; + + CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); + normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); + + CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); + vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); + } + + public enum Phase + { + Charge = 0, + UndergroundLaserBarrage = 1, + Deathray = 2 + } + + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } + + public enum SecondaryPhase + { + Nothing = 0, + Passive = 1, + PassiveAndImmune = 2 + } + + public float SecondaryAIState + { + get => npc.Calamity().newAI[1]; + set => npc.Calamity().newAI[1] = value; + } + + public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); + + // Timer to prevent Thanatos from dealing contact damage for a bit + private int noContactDamageTimer = 0; + + // Invincibility time for the first 10 seconds + public const float immunityTime = 600f; + + // Whether the head is venting heat or not, it is vulnerable to damage during venting + private bool vulnerable = false; + + // Max time in vent phase + public const float ventDuration = 180f; + + // Spawn rate for vent clouds + public const int ventCloudSpawnRate = 5; + + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; + + // Base distance from the target for most attacks + private const float baseDistance = 400f; + + // Base distance from target location in order to continue turning + private const float baseTurnDistance = 160f; + + // Max distance from the target before they are unable to hear sound telegraphs + private const float soundDistance = 2800f; + + // Length variables + public const int minLength = 100; + private const int maxLength = 101; + + // Variable used to stop the segment spawning loop + private bool tailSpawned = false; + + // Used in the lerp to smoothly scale velocity up and down + private float chargeVelocityScalar = 0f; + + // Total duration of the deathray telegraph + private const float deathrayTelegraphDuration = 180f; + + // Total duration of the deathray + private const float deathrayDuration = 180f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("XM-05 Thanatos"); + Main.npcFrameCount[npc.type] = 5; + + // Ensure that the reticle is not culled due to the player being very far from Thanatos. + NPCID.Sets.MustAlwaysDraw[npc.type] = true; + } + + public override void SetDefaults() + { + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.width = 164; + npc.height = 164; + npc.defense = 80; + npc.DR_NERD(0.9999f); + npc.Calamity().unbreakableDR = true; + npc.LifeMaxNERB(960000, 1150000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; + aiType = -1; + npc.Opacity = 0f; + npc.knockBackResist = 0f; + npc.value = Item.buyPrice(15, 0, 0, 0); + npc.behindTiles = true; + npc.noGravity = true; + npc.noTileCollide = true; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; + npc.boss = true; + npc.chaseable = false; + music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; + bossBag = ModContent.ItemType(); + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } + + public override void BossHeadSlot(ref int index) + { + if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) + index = -1; + else if (vulnerable) + index = vulnerableIconIndex; + else + index = normalIconIndex; + } + + public override void BossHeadRotation(ref float rotation) + { + rotation = npc.rotation; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + writer.Write(noContactDamageTimer); + writer.Write(chargeVelocityScalar); + writer.Write(vulnerable); + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + writer.Write(npc.localAI[3]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + noContactDamageTimer = reader.ReadInt32(); + chargeVelocityScalar = reader.ReadSingle(); + vulnerable = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public float GetSlowdownAreaEdgeRadius(bool lastMechAlive) => + ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 400f : CalamityWorld.death ? 600f : CalamityWorld.revenge ? 700f : Main.expertMode ? 800f : 1000f) * (lastMechAlive ? 0.6f : 1f); + + public int CheckForOtherMechs(ref Player target, out bool exoPrimeAlive, out bool exoTwinsAlive) + { + exoPrimeAlive = false; + exoTwinsAlive = false; + int otherExoMechsAlive = 0; + if (CalamityGlobalNPC.draedonExoMechPrime != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + // Set target to Ares' target if Ares is alive. + target = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + + otherExoMechsAlive++; + exoPrimeAlive = true; + } + } + + // There is no need in checking for the other twin because they have linked HP. + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoTwinsAlive = true; + } + } + return otherExoMechsAlive; + } + + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + CalamityGlobalNPC.draedonExoMechWorm = npc.whoAmI; + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + // Target variable + Player player = Main.player[npc.target]; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = CheckForOtherMechs(ref player, out bool exoPrimeAlive, out bool exoTwinsAlive); + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoPrimeLifeRatio = defaultLifeRatio; + float exoTwinsLifeRatio = defaultLifeRatio; + if (exoPrimeAlive) + exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + if (exoTwinsAlive) + exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + float totalOtherExoMechLifeRatio = exoPrimeLifeRatio + exoTwinsLifeRatio; + + // Check if any of the other mechs are passive + bool exoPrimePassive = false; + bool exoTwinsPassive = false; + if (exoPrimeAlive) + exoPrimePassive = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] == (float)AresBody.SecondaryPhase.Passive; + if (exoTwinsAlive) + exoTwinsPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] == (float)Apollo.Apollo.SecondaryPhase.Passive; + bool anyOtherExoMechPassive = exoPrimePassive || exoTwinsPassive; + + // Check if any of the other mechs were spawned first + bool exoPrimeWasFirst = false; + bool exoTwinsWereFirst = false; + if (exoPrimeAlive) + exoPrimeWasFirst = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] == 1f; + if (exoTwinsAlive) + exoTwinsWereFirst = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ai[3] == 1f; + bool otherExoMechWasFirst = exoPrimeWasFirst || exoTwinsWereFirst; + + // Check for Draedon + bool draedonAlive = false; + if (CalamityGlobalNPC.draedon != -1) + { + if (Main.npc[CalamityGlobalNPC.draedon].active) + draedonAlive = true; + } + + // Prevent mechs from being respawned + if (otherExoMechWasFirst) + { + if (npc.ai[3] < 1f) + npc.ai[3] = 1f; + } + + // Phases + bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; + + // Set vulnerable to false by default + vulnerable = false; + + // If Thanatos doesn't go berserk + bool otherMechIsBerserk = exoPrimeLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; + + // Whether Thanatos should be buffed while in berserk phase + bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; + + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + // Spawn segments + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (!tailSpawned && npc.ai[0] == 0f) + { + int Previous = npc.whoAmI; + for (int num36 = 0; num36 < maxLength; num36++) + { + int lol; + if (num36 >= 0 && num36 < minLength) + { + if (num36 % 2 == 0) + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + else + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + } + else + 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] = npc.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); + Previous = lol; + } + tailSpawned = true; + } + } + + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; + + // General AI pattern + // 0 - Fly towards the target for 7 seconds, gradually speeding up for the first 5 seconds and slowing down for the last 2 seconds, fire lasers from segments that are venting + // 1 - Fly underneath the target and fire barrages of lasers + // 2 - Fire deathray from mouth with a telegraph similar to the railgun from enter the gungeon, turn speed is very low during this to avoid cheap hits + // 3 - Go passive and fly underneath the target while firing lasers + // 4 - Go passive, immune and invisible; fly far underneath the target and do nothing until next phase + + // Attack patterns + // If spawned first + // Phase 1 - 0, 1, 0, 2 + // Phase 2 - 4 + // Phase 3 - 3 + + // If berserk, this is the last phase of thanatos + // Phase 4 - 0, 1, 0, 2 + + // If not berserk + // Phase 4 - 4 + // Phase 5 - 0, 1, 0, 2 + + // If berserk, this is the last phase of thanatos + // Phase 6 - 0, 1, 0, 2 + + // If not berserk + // Phase 6 - 4 + + // Berserk, final phase of Thanatos + // Phase 7 - 0, 1, 0, 2 + + // Phase gate values + float velocityAdjustTime = 20f; + float speedUpTime = lastMechAlive ? 180f : shouldGetBuffedByBerserkPhase ? 240f : 360f; + float slowDownTime = lastMechAlive ? 30f : shouldGetBuffedByBerserkPhase ? 40f : 60f; + float chargePhaseGateValue = speedUpTime + slowDownTime; + float laserBarrageDuration = lastMechAlive ? 270f : shouldGetBuffedByBerserkPhase ? 300f : 360f; + + // Despawn if target is dead + bool targetDead = false; + if (player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (player.dead) + { + targetDead = true; + AIState = (float)Phase.Charge; + npc.localAI[0] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + npc.dontTakeDamage = true; + + npc.velocity.Y -= 1f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 1f; + + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + } + } + } + + // Rotation and direction + npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; + int direction = npc.direction; + npc.direction = npc.spriteDirection = (npc.velocity.X > 0f) ? 1 : (-1); + if (direction != npc.direction) + npc.netUpdate = true; + + // Default vector to fly to + Vector2 destination = player.Center; + + // Move destination to somewhere far below the target for the first 3 seconds so that Thanatos can fully uncoil quickly + bool speedUp = false; + if (npc.localAI[3] < 180f) + { + speedUp = true; + destination += new Vector2(0f, 2400f); + } + + // Distance from target + float distanceFromTarget = Vector2.Distance(npc.Center, destination); + + // Increase speed if too far from target + float increaseSpeedMult = 1f; + float increaseSpeedGateValue = 500f; + if (distanceFromTarget > increaseSpeedGateValue) + { + float distanceAmount = MathHelper.Clamp((distanceFromTarget - increaseSpeedGateValue) / (CalamityGlobalNPC.CatchUpDistance350Tiles - increaseSpeedGateValue), 0f, 1f); + increaseSpeedMult = MathHelper.Lerp(1f, 3.5f, distanceAmount); + } + + // Charge variables + float turnDistance = baseTurnDistance; + float chargeLocationDistance = turnDistance * 0.2f; + + // Laser Barrage variables + float laserBarrageLocationBaseDistance = SecondaryAIState == (int)SecondaryPhase.PassiveAndImmune ? baseDistance * 2f : baseDistance; + Vector2 laserBarrageLocation = new Vector2(0f, npc.ai[1] % 2f == 0f ? laserBarrageLocationBaseDistance : -laserBarrageLocationBaseDistance); + float laserBarrageLocationDistance = turnDistance * 3f; + + // Velocity and turn speed values + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (malice ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocity = 11.1f * baseVelocityMult; + + // Increase top velocity if target is dead or if Thanatos is uncoiling + if (targetDead || speedUp) + baseVelocity *= 4f; + else + baseVelocity *= increaseSpeedMult; + + float turnDegrees = baseVelocity * 0.11f * (shouldGetBuffedByBerserkPhase ? 1.25f : 1f); + + float turnSpeed = MathHelper.ToRadians(turnDegrees); + float chargeVelocityMult = MathHelper.Lerp(1f, 1.5f, chargeVelocityScalar); + float chargeTurnSpeedMult = MathHelper.Lerp(1f, 1.5f, chargeVelocityScalar); + float laserBarragePhaseVelocityMult = MathHelper.Lerp(1f, 1.5f, chargeVelocityScalar); + float laserBarragePhaseTurnSpeedMult = MathHelper.Lerp(1f, 3f, chargeVelocityScalar); + float deathrayVelocityMult = MathHelper.Lerp(0.5f, 3f, chargeVelocityScalar); + float deathrayTurnSpeedMult = MathHelper.Lerp(0.5f, 3f, chargeVelocityScalar); + + // Base scale on total time spent in phase + float chargeVelocityScalarIncrement = 1f / speedUpTime; + float chargeVelocityScalarDecrement = 1f / slowDownTime; + + // Scalar to use during deathray phase + float deathrayVelocityScalarIncrement = 1f / deathrayDuration; + + // Scalar to use during laser barrage, passive and immune phases + float laserBarrageVelocityScalarIncrement = lastMechAlive ? 0.025f : shouldGetBuffedByBerserkPhase ? 0.02f : 0.015f; + float laserBarrageVelocityScalarDecrement = 1f / velocityAdjustTime; + + // Passive and Immune phases + switch ((int)SecondaryAIState) + { + case (int)SecondaryPhase.Nothing: + + // Spawn the other mechs if Thanatos is first + if (otherExoMechsAlive == 0) + { + if (spawnOtherExoMechs) + { + // Reset everything + if (npc.ai[3] < 1f) + npc.ai[3] = 1f; + + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.localAI[0] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + npc.TargetClosest(); + + // Draedon text for the start of phase 2 + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 1f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Spawn the fuckers + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + } + } + } + else + { + // If not spawned first, go to passive state if any other mech is passive or if Thanatos is under 70% life + // Do not run this if berserk + // Do not run this if any exo mech is dead + if ((anyOtherExoMechPassive || lifeRatio < 0.7f) && !berserk && totalOtherExoMechLifeRatio < 5f) + { + // Tells Thanatos to return to the battle in passive state and reset everything + SecondaryAIState = (float)SecondaryPhase.Passive; + npc.localAI[0] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + npc.TargetClosest(); + } + + // Go passive and immune if one of the other mechs is berserk + // This is only called if two exo mechs are alive in ideal scenarios + // This is not called if Thanatos and another one or two mechs are berserk + if (otherMechIsBerserk && !berserk) + { + // Reset everything + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.localAI[0] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + npc.TargetClosest(); + + // Phase 6, when 1 mech goes berserk and the other one leaves + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 5f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + } + + break; + + // Fly underneath target and fire lasers, this happens when all 3 mechs are present and attacking + case (int)SecondaryPhase.Passive: + + // Fire lasers while passive + AIState = (float)Phase.UndergroundLaserBarrage; + + // Enter passive and invincible phase if one of the other exo mechs is berserk + if (otherMechIsBerserk) + { + // Reset everything + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.localAI[0] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + npc.TargetClosest(); + } + + // If Thanatos is the first mech to go berserk + if (berserk) + { + // Reset everything + AIState = (float)Phase.Charge; + npc.localAI[0] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + npc.TargetClosest(); + + // Never be passive if berserk + SecondaryAIState = (float)SecondaryPhase.Nothing; + + // Phase 4, when 1 mech goes berserk and the other 2 leave + if (exoTwinsAlive && exoPrimeAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 3f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + } + + break; + + // Fly underneath target and become immune + case (int)SecondaryPhase.PassiveAndImmune: + + // Do nothing while immune + AIState = (float)Phase.UndergroundLaserBarrage; + + // Enter the fight again if any of the other exo mechs is below 70% and other mechs aren't berserk + if ((exoPrimeLifeRatio < 0.7f || exoTwinsLifeRatio < 0.7f) && !otherMechIsBerserk) + { + // Tells Thanatos to return to the battle in passive state and reset everything + // Return to normal phases if one or more mechs have been downed + SecondaryAIState = totalOtherExoMechLifeRatio > 5f ? (float)SecondaryPhase.Nothing : (float)SecondaryPhase.Passive; + npc.localAI[0] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + npc.TargetClosest(); + + // Phase 3, when all 3 mechs attack at the same time + if (exoPrimeAlive && exoTwinsAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 2f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + } + + // This is here just in case + if (berserk) + { + // Reset everything + AIState = (float)Phase.Charge; + npc.localAI[0] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + npc.TargetClosest(); + + // Never be passive if berserk + SecondaryAIState = (float)SecondaryPhase.Nothing; + } + + break; + } + + // Adjust opacity + bool invisiblePhase = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase; + if (!invisiblePhase) + { + if (noContactDamageTimer > 0) + noContactDamageTimer--; + + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + // Deal no contact damage for 3 seconds after becoming visible + noContactDamageTimer = 185; + + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Attacking phases + switch ((int)AIState) + { + // Fly towards target and gain velocity over time + case (int)Phase.Charge: + + // Use a lerp to smoothly scale up velocity and turn speed + if (calamityGlobalNPC.newAI[3] == 0f) + { + chargeVelocityScalar += chargeVelocityScalarIncrement; + if (chargeVelocityScalar >= 1f) + { + chargeVelocityScalar = 1f; + calamityGlobalNPC.newAI[3] = 1f; + } + } + else + { + chargeVelocityScalar -= chargeVelocityScalarDecrement; + if (chargeVelocityScalar < 0f) + chargeVelocityScalar = 0f; + } + + baseVelocity *= chargeVelocityMult; + turnSpeed *= chargeTurnSpeedMult; + turnDistance = chargeLocationDistance; + + // Gradually turn slower if within 20 tiles of the target + float turnSlowerDistanceGateValue = lastMechAlive ? 160f : 240f; + if (distanceFromTarget < turnSlowerDistanceGateValue) + turnSpeed *= distanceFromTarget / turnSlowerDistanceGateValue; + + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= chargePhaseGateValue) + { + AIState = npc.localAI[0] == 1f ? (float)Phase.Deathray : (float)Phase.UndergroundLaserBarrage; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + npc.TargetClosest(); + } + + break; + + // Fly below and summon barrages of lasers + case (int)Phase.UndergroundLaserBarrage: + + // Fly down + destination += laserBarrageLocation; + turnDistance = laserBarrageLocationDistance; + + // Use a lerp to smoothly scale up velocity and turn speed + if (calamityGlobalNPC.newAI[3] == 0f) + { + chargeVelocityScalar += laserBarrageVelocityScalarIncrement; + if (chargeVelocityScalar > 1f) + chargeVelocityScalar = 1f; + } + + baseVelocity *= laserBarragePhaseVelocityMult; + turnSpeed *= laserBarragePhaseTurnSpeedMult; + + if ((destination - npc.Center).Length() < laserBarrageLocationDistance || calamityGlobalNPC.newAI[2] > 0f) + { + calamityGlobalNPC.newAI[2] += 1f; + + if (SecondaryAIState != (float)SecondaryPhase.Passive && SecondaryAIState != (float)SecondaryPhase.PassiveAndImmune) + { + if (calamityGlobalNPC.newAI[2] >= laserBarrageDuration) + { + // Use a lerp to smoothly scale down velocity and turn speed + chargeVelocityScalar -= laserBarrageVelocityScalarDecrement; + if (chargeVelocityScalar < 0f) + chargeVelocityScalar = 0f; + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= velocityAdjustTime) + { + npc.ai[1] += (shouldGetBuffedByBerserkPhase && revenge) ? 1f : 0f; + npc.localAI[0] = shouldGetBuffedByBerserkPhase ? 1f : 0f; + AIState = (float)Phase.Charge; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + npc.TargetClosest(); + } + } + } + } + + break; + + // Move close to target, reduce velocity and turn speed when close enough, create telegraph beams, reduce turn speed, fire deathray + case (int)Phase.Deathray: + + // Head is vulnerable while charging and firing deathray + vulnerable = true; + + // If close enough to the target, prepare to fire deathray + float slowDownDistance = GetSlowdownAreaEdgeRadius(lastMechAlive); + bool readyToFireDeathray = distanceFromTarget < slowDownDistance; + if (readyToFireDeathray) + npc.localAI[2] = 1f; + + // Use a lerp to smoothly scale up velocity and turn speed + if (calamityGlobalNPC.newAI[3] == 0f) + { + chargeVelocityScalar += deathrayVelocityScalarIncrement; + if (chargeVelocityScalar >= 1f) + { + chargeVelocityScalar = 1f; + + // If ready to fire deathray, start reducing the velocity scalar + if (npc.localAI[2] == 1f) + calamityGlobalNPC.newAI[3] = 1f; + } + } + else + { + // Reduce velocity scalar very quickly + chargeVelocityScalar -= deathrayVelocityScalarIncrement * 5f; + if (chargeVelocityScalar < 0f) + chargeVelocityScalar = 0f; + } + + baseVelocity *= deathrayVelocityMult; + turnSpeed *= deathrayTurnSpeedMult; + turnDistance = chargeLocationDistance; + + // Gradually turn and move slower if within 50 tiles of the target + if (npc.localAI[2] == 1f) + { + // Exponentially scale down velocity if close to the target + float velocityScale = distanceFromTarget / slowDownDistance; + if (velocityScale < 1f) + velocityScale *= velocityScale; + + baseVelocity *= velocityScale; + turnSpeed *= velocityScale; + + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] < deathrayTelegraphDuration) + { + // Fire deathray telegraph beams + if (calamityGlobalNPC.newAI[2] == 1f) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < soundDistance) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/THanosLaser"), + (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y); + } + + // Create a bunch of lightning bolts in the sky + ExoMechsSky.CreateLightningBolt(12); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + for (int b = 0; b < 6; b++) + { + int beam = Projectile.NewProjectile(npc.Center, Vector2.Zero, type, 0, 0f, 255, npc.whoAmI); + + // Determine the initial offset angle of telegraph. It will be smoothened to give a "stretch" effect. + if (Main.projectile.IndexInRange(beam)) + { + float squishedRatio = (float)Math.Pow((float)Math.Sin(MathHelper.Pi * b / 6f), 2D); + float smoothenedRatio = MathHelper.SmoothStep(0f, 1f, squishedRatio); + Main.projectile[beam].ai[0] = npc.whoAmI; + Main.projectile[beam].ai[1] = MathHelper.Lerp(-0.74f, 0.74f, smoothenedRatio); + } + } + int beam2 = Projectile.NewProjectile(npc.Center, Vector2.Zero, type, 0, 0f, 255, npc.whoAmI); + if (Main.projectile.IndexInRange(beam2)) + Main.projectile[beam2].ai[0] = npc.whoAmI; + } + } + } + else + { + // Fire deathray + if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + + if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) + { + npc.localAI[0] = 0f; + npc.localAI[2] = 0f; + AIState = (float)Phase.Charge; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + npc.TargetClosest(); + } + } + + break; + } + + // Do not deal contact damage for 5 seconds after spawning + if (npc.localAI[3] == 0f) + noContactDamageTimer = 300; + + if (npc.localAI[3] < immunityTime) + npc.localAI[3] += 1f; + + // Homing only works if vulnerable is true + npc.chaseable = vulnerable; + + // Adjust DR based on vulnerable + npc.Calamity().DR = vulnerable ? 0f : 0.9999f; + npc.Calamity().unbreakableDR = !vulnerable; + + // Increase overall damage taken while vulnerable + npc.takenDamageMultiplier = vulnerable ? 1.1f : 1f; + + // Vent noise and steam + SmokeDrawer.ParticleSpawnRate = 9999999; + if (vulnerable) + { + // Light + Lighting.AddLight(npc.Center, 0.35f * npc.Opacity, 0.05f * npc.Opacity, 0.05f * npc.Opacity); + + // Noise + if (npc.localAI[1] == 0f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent"), npc.Center); + + // Steam + npc.localAI[1] += 1f; + if (npc.localAI[1] < ventDuration) + { + SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; + SmokeDrawer.ParticleSpawnRate = ventCloudSpawnRate; + } + } + else + { + // Light + Lighting.AddLight(npc.Center, 0.05f * npc.Opacity, 0.2f * npc.Opacity, 0.2f * npc.Opacity); + + npc.localAI[1] = 0f; + } + + SmokeDrawer.Update(); + + if (!targetDead) + { + // Increase velocity if velocity is ever zero + if (npc.velocity == Vector2.Zero) + npc.velocity = Vector2.Normalize(player.Center - npc.Center).SafeNormalize(Vector2.Zero) * baseVelocity; + + // Acceleration + if (!((destination - npc.Center).Length() < turnDistance)) + { + float targetAngle = npc.AngleTo(destination); + float f = npc.velocity.ToRotation().AngleTowards(targetAngle, turnSpeed); + npc.velocity = f.ToRotationVector2() * baseVelocity; + } + } + + // Velocity upper limit + if (npc.velocity.Length() > baseVelocity) + npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero) * baseVelocity; + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= 50f && npc.Opacity == 1f && noContactDamageTimer <= 0; + } + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + { + if (npc.localAI[3] < immunityTime) + damage *= 0.01; + + return true; + } + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + scale = 1.5f; + return null; + } + + public override void FindFrame(int frameHeight) // 5 total frames + { + // Swap between venting and non-venting frames + npc.frameCounter += 1D; + if (AIState == (float)Phase.Charge || AIState == (float)Phase.UndergroundLaserBarrage) + { + if (npc.frameCounter >= 6D) + { + npc.frame.Y -= frameHeight; + npc.frameCounter = 0D; + } + if (npc.frame.Y < 0) + npc.frame.Y = 0; + } + else + { + if (npc.frameCounter >= 6D) + { + npc.frame.Y += frameHeight; + npc.frameCounter = 0D; + } + int finalFrame = Main.npcFrameCount[npc.type] - 1; + if (npc.frame.Y >= frameHeight * finalFrame) + npc.frame.Y = frameHeight * finalFrame; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture = Main.npcTexture[npc.type]; + Vector2 vector = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + + Vector2 center = npc.Center - Main.screenPosition; + center -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + center += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, center, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); + + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosHeadGlow"); + spriteBatch.Draw(texture, center, npc.frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); + + SmokeDrawer.DrawSet(npc.Center); + + // Draw a white indicator aura and reticle before and while a death ray is being fired. + // This is done to give a visual indicator that players should move near the head (which results in slower movement and thus easier dodging capabilities). + if (AIState == (int)Phase.Deathray && SecondaryAIState != (int)SecondaryPhase.PassiveAndImmune) + { + spriteBatch.SetBlendState(BlendState.Additive); + + // A large, faded circle. Is rescaled to fit the radius of the slowdown area. + Texture2D auraTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/THanosAura"); + + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Yes, this is bizarre as fuck. + Player completelyUseless = null; + int otherExoMechsAlive = CheckForOtherMechs(ref completelyUseless, out _, out _); + + // A general factor for the aura. + // Used to cause fade-ins/outs as the attack starts/stops. + float auraGeneralPower = Utils.InverseLerp(0f, deathrayTelegraphDuration * 0.333f, npc.Calamity().newAI[2], true); + auraGeneralPower *= Utils.InverseLerp(deathrayTelegraphDuration + deathrayDuration, deathrayTelegraphDuration + deathrayDuration, npc.Calamity().newAI[2], true); + + // Determine the characteristics of the aura. This requires intermediate computations to determine if Thanatos is in its final phase as well as for pulsing. + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; + float pulse = Main.GlobalTime * 0.72f % 1f; + float auraRadius = GetSlowdownAreaEdgeRadius(lastMechAlive) * auraGeneralPower * 1.25f; + Vector2 outerAuraScale = Vector2.One * auraRadius / auraTexture.Size(); + Vector2 innerAuraScale = outerAuraScale * pulse * 1.2f; + Color outerAuraColor = Color.White * auraGeneralPower * 0.6f; + Color innerAuraColor = outerAuraColor * (float)Math.Sqrt(1f - pulse); + + // Draw the aura. + spriteBatch.Draw(auraTexture, center, null, outerAuraColor, 0f, auraTexture.Size() * 0.5f, outerAuraScale, SpriteEffects.None, 0f); + spriteBatch.Draw(auraTexture, center, null, innerAuraColor, 0f, auraTexture.Size() * 0.5f, innerAuraScale, SpriteEffects.None, 0f); + + spriteBatch.SetBlendState(BlendState.AlphaBlend); + + // Draw the reticle depending on how close the player is. This drawcode terminates early if Thanatos has no target. + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + return false; + + Player target = Main.player[npc.target]; + + Texture2D leftReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleLeft"); + Texture2D rightReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleRight"); + Texture2D topReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleTop"); + Texture2D bottomReticleTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleHead"); + Texture2D leftReticleProngTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleProngLeft"); + Texture2D rightReticleProngTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosReticleProngRight"); + + // The reticle fades away and moves farther away from the target the closer they are to the aura. + // Once far away, the reticle will flash between red and white as an indicator. + float targetHeadDistance = npc.Distance(target.Center); + float reticleOpacity = Utils.InverseLerp(auraRadius * 0.5f - 40f, auraRadius * 0.5f + 100f, targetHeadDistance, true); + float reticleOffsetDistance = MathHelper.SmoothStep(300f, 0f, reticleOpacity); + float reticleFadeToWhite = ((float)Math.Cos(Main.GlobalTime * 6.8f) * 0.5f + 0.5f) * reticleOpacity * 0.67f; + Color reticleBaseColor = new Color(255, 0, 0, 127) * reticleOpacity; + Color reticleFlashBaseColor = Color.Lerp(reticleBaseColor, new Color(255, 255, 255, 0), reticleFadeToWhite) * reticleOpacity; + Vector2 origin = leftReticleTexture.Size() * 0.5f; + + Vector2 playerDrawPosition = target.Center - Main.screenPosition; + spriteBatch.Draw(leftReticleTexture, playerDrawPosition - Vector2.UnitX * reticleOffsetDistance, null, reticleBaseColor, 0f, origin, 1f, SpriteEffects.None, 0f); + spriteBatch.Draw(rightReticleTexture, playerDrawPosition + Vector2.UnitX * reticleOffsetDistance, null, reticleBaseColor, 0f, origin, 1f, SpriteEffects.None, 0f); + + for (int i = 0; i < 3; i++) + { + float scale = 1f + i * 0.125f; + spriteBatch.Draw(leftReticleProngTexture, playerDrawPosition - Vector2.UnitX * reticleOffsetDistance, null, reticleFlashBaseColor, 0f, origin, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(rightReticleProngTexture, playerDrawPosition + Vector2.UnitX * reticleOffsetDistance, null, reticleFlashBaseColor, 0f, origin, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(bottomReticleTexture, playerDrawPosition + Vector2.UnitY * reticleOffsetDistance, null, reticleFlashBaseColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + spriteBatch.Draw(topReticleTexture, playerDrawPosition - Vector2.UnitY * reticleOffsetDistance, null, reticleBaseColor, 0f, origin, 1f, SpriteEffects.None, 0f); + } + + return false; + } + + public override void BossLoot(ref string name, ref int potionType) + { + potionType = ModContent.ItemType(); + } + + public override bool SpecialNPCLoot() + { + int closestSegmentID = DropHelper.FindClosestWormSegment(npc, + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType()); + npc.position = Main.npc[closestSegmentID].position; + return false; + } + + public override void NPCLoot() + { + // Check if the other exo mechs are alive + bool exoTwinsAlive = false; + bool exoPrimeAlive = false; + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + exoTwinsAlive = true; + } + if (CalamityGlobalNPC.draedonExoMechPrime != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + exoPrimeAlive = true; + } + + // Check for Draedon + bool draedonAlive = false; + if (CalamityGlobalNPC.draedon != -1) + { + if (Main.npc[CalamityGlobalNPC.draedon].active) + draedonAlive = true; + } + + // Phase 5, when 1 mech dies and the other 2 return to fight + if (exoTwinsAlive && exoPrimeAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 4f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + + // Phase 7, when 1 mech dies and the final one returns to the fight + else if (exoTwinsAlive || exoPrimeAlive) + { + if (draedonAlive) + { + Main.npc[CalamityGlobalNPC.draedon].localAI[0] = 6f; + Main.npc[CalamityGlobalNPC.draedon].ai[0] = Draedon.ExoMechPhaseDialogueTime; + } + } + + // Mark Exo Mechs as dead and drop loot + else + AresBody.DropExoMechLoot(npc, (int)AresBody.MechType.Thanatos); + } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.soundDelay == 0) + { + npc.soundDelay = 8; + + if (vulnerable) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); + else + Main.PlaySound(SoundID.NPCHit4, npc.Center); + } + + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosHead"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosHead2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosHead3"), 1f); + } + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); + } + } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs index f21f0d38d6..ad3962e99e 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs @@ -13,651 +13,651 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Thanatos { - public class ThanatosTail : ModNPC + public class ThanatosTail : ModNPC { - public static int normalIconIndex; - public static int vulnerableIconIndex; + public static int normalIconIndex; + public static int vulnerableIconIndex; - internal static void LoadHeadIcons() - { - string normalIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosNormalTail"; - string vulnerableIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosVulnerableTail"; + internal static void LoadHeadIcons() + { + string normalIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosNormalTail"; + string vulnerableIconPath = "CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosVulnerableTail"; - CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); - normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); + CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); + normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); - CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); - vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); - } + CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); + vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); + } - // Whether the tail is venting heat or not, it is vulnerable to damage during venting - private bool vulnerable = false; + // Whether the tail is venting heat or not, it is vulnerable to damage during venting + private bool vulnerable = false; - public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); + public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f); - // Default life ratio for the other mechs - private const float defaultLifeRatio = 5f; + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; - // Timer to prevent Thanatos from dealing contact damage for a bit - private int noContactDamageTimer = 0; + // Timer to prevent Thanatos from dealing contact damage for a bit + private int noContactDamageTimer = 0; - private const float timeToOpenAndFireLasers = 36f; + private const float timeToOpenAndFireLasers = 36f; - private const float segmentCloseTimerDecrement = 0.2f; + private const float segmentCloseTimerDecrement = 0.2f; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("XM-05 Thanatos"); - Main.npcFrameCount[npc.type] = 5; - } + Main.npcFrameCount[npc.type] = 5; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 5f; - npc.GetNPCDamage(); - npc.width = 76; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.width = 76; npc.height = 110; npc.defense = 120; - npc.DR_NERD(0.9999f); - npc.Calamity().unbreakableDR = true; - npc.LifeMaxNERB(960000, 1150000, 500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; + npc.DR_NERD(0.9999f); + npc.Calamity().unbreakableDR = true; + npc.LifeMaxNERB(960000, 1150000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; - npc.Opacity = 0f; - npc.canGhostHeal = false; - npc.behindTiles = true; + npc.Opacity = 0f; + npc.canGhostHeal = false; + npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.dontCountMe = true; npc.chaseable = false; - npc.boss = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.boss = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("ExoMechs") ?? MusicID.Boss3; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } - public override void BossHeadSlot(ref int index) - { - if (Main.npc[(int)npc.ai[2]].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune) - index = -1; - else if (vulnerable) - index = vulnerableIconIndex; - else - index = normalIconIndex; - } + public override void BossHeadSlot(ref int index) + { + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune) + index = -1; + else if (vulnerable) + index = vulnerableIconIndex; + else + index = normalIconIndex; + } - public override void BossHeadRotation(ref float rotation) - { - rotation = npc.rotation; - } + public override void BossHeadRotation(ref float rotation) + { + rotation = npc.rotation; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.chaseable); - writer.Write(npc.dontTakeDamage); - writer.Write(noContactDamageTimer); - writer.Write(vulnerable); - writer.Write(npc.localAI[0]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + writer.Write(noContactDamageTimer); + writer.Write(vulnerable); + writer.Write(npc.localAI[0]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.chaseable = reader.ReadBoolean(); - npc.dontTakeDamage = reader.ReadBoolean(); - noContactDamageTimer = reader.ReadInt32(); - vulnerable = reader.ReadBoolean(); - npc.localAI[0] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + noContactDamageTimer = reader.ReadInt32(); + vulnerable = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; - - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - return; - } - - // Set vulnerable to false by default - vulnerable = false; - - CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - - bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; - npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; - if (!invisiblePhase) - { - if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) - { - if (noContactDamageTimer > 0) - noContactDamageTimer--; - - npc.Opacity += 0.2f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; - } - else - { - // Deal no contact damage for 3 seconds after becoming visible - noContactDamageTimer = 185; - } - } - else - { - // Deal no contact damage for 3 seconds after becoming visible - noContactDamageTimer = 185; - - npc.Opacity -= 0.05f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } - - // Number of body segments - int numSegments = ThanatosHead.minLength; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Check if the other exo mechs are alive - int otherExoMechsAlive = 0; - bool exoPrimeAlive = false; - bool exoTwinsAlive = false; - if (CalamityGlobalNPC.draedonExoMechPrime != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - otherExoMechsAlive++; - exoPrimeAlive = true; - } - } - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - { - otherExoMechsAlive++; - exoTwinsAlive = true; - } - } - - // Set the AI to become more aggressive if head is berserk - bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); - bool lastMechAlive = berserk && otherExoMechsAlive == 0; - - // These are 5 by default to avoid triggering passive phases after the other mechs are dead - float exoPrimeLifeRatio = defaultLifeRatio; - float exoTwinsLifeRatio = defaultLifeRatio; - if (exoPrimeAlive) - exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; - if (exoTwinsAlive) - exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; - - // If Thanatos doesn't go berserk - bool otherMechIsBerserk = exoPrimeLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; - - // Whether Thanatos should be buffed while in berserk phase - bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - - // Use to close the segments quicker in later phases - float fasterSegmentClosingVar = lastMechAlive ? 0.2f : shouldGetBuffedByBerserkPhase ? 0.1f : 0f; - - bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; - if (shootLasers && !invisiblePhase) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Only charge up lasers if not venting or firing lasers - if (npc.Calamity().newAI[0] == 0f) - npc.ai[3] += 1f; - - double numSegmentsAbleToFire = malice ? 35D : death ? 30D : revenge ? 28D : expertMode ? 25D : 20D; - if (shouldGetBuffedByBerserkPhase) - numSegmentsAbleToFire *= 1.5; - - float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); - - if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) - { - float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 90f; - if ((npc.ai[3] % divisor == 0f && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) - { - // Body is vulnerable while firing lasers - vulnerable = true; - - if (npc.Calamity().newAI[1] == 0f) - { - npc.Calamity().newAI[0] += 1f; - if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) - { - npc.ai[3] = 0f; - npc.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; - - for (int i = 0; i < Main.maxPlayers; i++) - { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, npc.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - if (sound != null) - sound.Volume *= 0.1f; - - for (int i = 0; i < numProjectiles; i++) - { - // Normal laser - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - else - { - npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (npc.Calamity().newAI[0] <= 0f) - { - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - } - } - } - } - else - { - float divisor = npc.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 - if ((npc.ai[3] == divisor && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) - { - // Body is vulnerable while firing lasers - vulnerable = true; - - if (npc.Calamity().newAI[1] == 0f) - { - npc.Calamity().newAI[0] += 1f; - if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) - { - npc.ai[3] = 0f; - npc.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; - - for (int i = 0; i < Main.maxPlayers; i++) - { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, npc.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - float predictionAmt = malice ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; - if (npc.ai[0] % 3f == 0f) - predictionAmt *= 0.5f; - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - for (int i = 0; i < numProjectiles; i++) - { - // Fire normal lasers if head is in passive state - if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) - { - // Normal laser - Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - else - { - // Normal laser - if (shouldGetBuffedByBerserkPhase && npc.ai[0] % 3f == 0f) - Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - - // Predictive laser - Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - - // Opposite laser - projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - } - else - { - npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (npc.Calamity().newAI[0] <= 0f) - { - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - } - } - } - } - } - } - else - { - if (npc.ai[3] > 0f) - npc.ai[3] = 0f; - - npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (npc.Calamity().newAI[0] <= 0f) - { - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - } - else - { - // Body is vulnerable while venting - vulnerable = true; - } - } - - // Do not deal contact damage for 5 seconds after spawning - if (npc.Calamity().newAI[2] == 0f) - noContactDamageTimer = 300; - - if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) - npc.Calamity().newAI[2] += 1f; - - // Homing only works if vulnerable is true - npc.chaseable = vulnerable; - - // Adjust DR based on vulnerable - npc.Calamity().DR = vulnerable ? 0f : 0.9999f; - npc.Calamity().unbreakableDR = !vulnerable; - - // Increase overall damage taken while vulnerable - float damageMult = malice ? 1.1f : death ? 1.2f : revenge ? 1.25f : expertMode ? 1.3f : 1.4f; - if (shouldGetBuffedByBerserkPhase) - damageMult -= malice ? 0.1f : death ? 0.175f : revenge ? 0.2f : expertMode ? 0.225f : 0.3f; - - npc.takenDamageMultiplier = vulnerable ? damageMult : 1f; - - // Vent noise and steam - SmokeDrawer.ParticleSpawnRate = 9999999; - if (vulnerable) - { - // Light - Lighting.AddLight(npc.Center, 0.35f * npc.Opacity, 0.05f * npc.Opacity, 0.05f * npc.Opacity); - - // Noise - float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.1f : 1f; - if (npc.localAI[0] == 0f) - { - SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent"), npc.Center); - if (sound != null) - sound.Volume *= volume; - } - - // Steam - npc.localAI[0] += 1f; - float actualVentDuration = lastMechAlive ? 90f : shouldGetBuffedByBerserkPhase ? 120f : ThanatosHead.ventDuration; - if (npc.localAI[0] < actualVentDuration) - { - SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; - SmokeDrawer.ParticleSpawnRate = ThanatosHead.ventCloudSpawnRate; - } - } - else - { - // Light - Lighting.AddLight(npc.Center, 0.05f * npc.Opacity, 0.2f * npc.Opacity, 0.2f * npc.Opacity); - - npc.localAI[0] = 0f; - } - - SmokeDrawer.Update(); - - Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; - - Vector2 npcCenter = npc.Center; - float targetCenterX = player.Center.X; - float targetCenterY = player.Center.Y; - targetCenterX = (int)(targetCenterX / 16f) * 16; - targetCenterY = (int)(targetCenterY / 16f) * 16; - npcCenter.X = (int)(npcCenter.X / 16f) * 16; - npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; - targetCenterX -= npcCenter.X; - targetCenterY -= npcCenter.Y; - - float distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - targetCenterX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X; - targetCenterY = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y; - } - catch - { - } - - npc.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2; - distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); - distanceFromTarget = (distanceFromTarget - npc.width) / distanceFromTarget; - targetCenterX *= distanceFromTarget; - targetCenterY *= distanceFromTarget; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + targetCenterX; - npc.position.Y = npc.position.Y + targetCenterY; - - if (targetCenterX < 0f) - npc.spriteDirection = -1; - else if (targetCenterX > 0f) - npc.spriteDirection = 1; - } - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - - Rectangle targetHitbox = target.Hitbox; - - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; - - return minDist <= 45f && npc.Opacity == 1f && noContactDamageTimer <= 0; - } - - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) - { - if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) - damage *= 0.01; - - return true; - } - - public override void FindFrame(int frameHeight) // 5 total frames - { - if (!Main.npc[(int)npc.ai[2]].active || Main.npc[(int)npc.ai[2]].life <= 0) - return; - - // Swap between venting and non-venting frames - CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; - bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; - npc.frameCounter += 1D; - if (npc.Calamity().newAI[0] > 0f) - { - if (npc.frameCounter >= 6D) - { - npc.frame.Y += frameHeight; - npc.frameCounter = 0D; - } - int finalFrame = Main.npcFrameCount[npc.type] - 1; - if (npc.frame.Y > frameHeight * finalFrame) - npc.frame.Y = frameHeight * finalFrame; - } - else - { - if (npc.frameCounter >= 6D) - { - npc.frame.Y -= frameHeight; - npc.frameCounter = 0D; - } - if (npc.frame.Y < 0) - npc.frame.Y = 0; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture = Main.npcTexture[npc.type]; - Vector2 vector = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - - Vector2 center = npc.Center - Main.screenPosition; - center -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - center += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, center, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); - - texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosTailGlow"); - spriteBatch.Draw(texture, center, npc.frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); - - SmokeDrawer.DrawSet(npc.Center); - - return false; - } - - public override bool CheckActive() => false; - - public override bool PreNPCLoot() => false; - - public override void HitEffect(int hitDirection, double damage) - { - if (npc.soundDelay == 0) - { - npc.soundDelay = 8; - - if (vulnerable) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); - else - Main.PlaySound(SoundID.NPCHit4, npc.Center); - } - - int baseDust = vulnerable ? 3 : 1; - for (int k = 0; k < baseDust; k++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); - - if (npc.life <= 0) - { - for (int num193 = 0; num193 < 2; num193++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosTail"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosTail2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosTail3"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosTail4"), 1f); - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - } + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } + + // Set vulnerable to false by default + vulnerable = false; + + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + + bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; + if (!invisiblePhase) + { + if (Main.npc[(int)npc.ai[1]].Opacity > 0.5f) + { + if (noContactDamageTimer > 0) + noContactDamageTimer--; + + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + // Deal no contact damage for 3 seconds after becoming visible + noContactDamageTimer = 185; + } + } + else + { + // Deal no contact damage for 3 seconds after becoming visible + noContactDamageTimer = 185; + + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Number of body segments + int numSegments = ThanatosHead.minLength; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoPrimeAlive = false; + bool exoTwinsAlive = false; + if (CalamityGlobalNPC.draedonExoMechPrime != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + otherExoMechsAlive++; + exoPrimeAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoTwinsAlive = true; + } + } + + // Set the AI to become more aggressive if head is berserk + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool lastMechAlive = berserk && otherExoMechsAlive == 0; + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoPrimeLifeRatio = defaultLifeRatio; + float exoTwinsLifeRatio = defaultLifeRatio; + if (exoPrimeAlive) + exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + if (exoTwinsAlive) + exoTwinsLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + + // If Thanatos doesn't go berserk + bool otherMechIsBerserk = exoPrimeLifeRatio < 0.4f || exoTwinsLifeRatio < 0.4f; + + // Whether Thanatos should be buffed while in berserk phase + bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; + + // Use to close the segments quicker in later phases + float fasterSegmentClosingVar = lastMechAlive ? 0.2f : shouldGetBuffedByBerserkPhase ? 0.1f : 0f; + + bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + if (shootLasers && !invisiblePhase) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Only charge up lasers if not venting or firing lasers + if (npc.Calamity().newAI[0] == 0f) + npc.ai[3] += 1f; + + double numSegmentsAbleToFire = malice ? 35D : death ? 30D : revenge ? 28D : expertMode ? 25D : 20D; + if (shouldGetBuffedByBerserkPhase) + numSegmentsAbleToFire *= 1.5; + + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + { + float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 90f; + if ((npc.ai[3] % divisor == 0f && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) + { + // Body is vulnerable while firing lasers + vulnerable = true; + + if (npc.Calamity().newAI[1] == 0f) + { + npc.Calamity().newAI[0] += 1f; + if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) + { + npc.ai[3] = 0f; + npc.Calamity().newAI[1] = 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) + { + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, npc.Center); + if (distance < maxDistance) + { + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; + } + } + + SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + if (sound != null) + sound.Volume *= 0.1f; + + for (int i = 0; i < numProjectiles; i++) + { + // Normal laser + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + } + else + { + npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + else + { + float divisor = npc.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 + if ((npc.ai[3] == divisor && npc.ai[0] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) + { + // Body is vulnerable while firing lasers + vulnerable = true; + + if (npc.Calamity().newAI[1] == 0f) + { + npc.Calamity().newAI[0] += 1f; + if (npc.Calamity().newAI[0] >= timeToOpenAndFireLasers) + { + npc.ai[3] = 0f; + npc.Calamity().newAI[1] = 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) + { + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, npc.Center); + if (distance < maxDistance) + { + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; + } + } + + float predictionAmt = malice ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; + if (npc.ai[0] % 3f == 0f) + predictionAmt *= 0.5f; + + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + for (int i = 0; i < numProjectiles; i++) + { + // Fire normal lasers if head is in passive state + if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) + { + // Normal laser + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + else + { + // Normal laser + if (shouldGetBuffedByBerserkPhase && npc.ai[0] % 3f == 0f) + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + + // Predictive laser + Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; + Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + + // Opposite laser + projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; + Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + } + } + } + } + } + else + { + npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + } + } + else + { + if (npc.ai[3] > 0f) + npc.ai[3] = 0f; + + npc.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + else + { + // Body is vulnerable while venting + vulnerable = true; + } + } + + // Do not deal contact damage for 5 seconds after spawning + if (npc.Calamity().newAI[2] == 0f) + noContactDamageTimer = 300; + + if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) + npc.Calamity().newAI[2] += 1f; + + // Homing only works if vulnerable is true + npc.chaseable = vulnerable; + + // Adjust DR based on vulnerable + npc.Calamity().DR = vulnerable ? 0f : 0.9999f; + npc.Calamity().unbreakableDR = !vulnerable; + + // Increase overall damage taken while vulnerable + float damageMult = malice ? 1.1f : death ? 1.2f : revenge ? 1.25f : expertMode ? 1.3f : 1.4f; + if (shouldGetBuffedByBerserkPhase) + damageMult -= malice ? 0.1f : death ? 0.175f : revenge ? 0.2f : expertMode ? 0.225f : 0.3f; + + npc.takenDamageMultiplier = vulnerable ? damageMult : 1f; + + // Vent noise and steam + SmokeDrawer.ParticleSpawnRate = 9999999; + if (vulnerable) + { + // Light + Lighting.AddLight(npc.Center, 0.35f * npc.Opacity, 0.05f * npc.Opacity, 0.05f * npc.Opacity); + + // Noise + float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.1f : 1f; + if (npc.localAI[0] == 0f) + { + SoundEffectInstance sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent"), npc.Center); + if (sound != null) + sound.Volume *= volume; + } + + // Steam + npc.localAI[0] += 1f; + float actualVentDuration = lastMechAlive ? 90f : shouldGetBuffedByBerserkPhase ? 120f : ThanatosHead.ventDuration; + if (npc.localAI[0] < actualVentDuration) + { + SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; + SmokeDrawer.ParticleSpawnRate = ThanatosHead.ventCloudSpawnRate; + } + } + else + { + // Light + Lighting.AddLight(npc.Center, 0.05f * npc.Opacity, 0.2f * npc.Opacity, 0.2f * npc.Opacity); + + npc.localAI[0] = 0f; + } + + SmokeDrawer.Update(); + + Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; + + Vector2 npcCenter = npc.Center; + float targetCenterX = player.Center.X; + float targetCenterY = player.Center.Y; + targetCenterX = (int)(targetCenterX / 16f) * 16; + targetCenterY = (int)(targetCenterY / 16f) * 16; + npcCenter.X = (int)(npcCenter.X / 16f) * 16; + npcCenter.Y = (int)(npcCenter.Y / 16f) * 16; + targetCenterX -= npcCenter.X; + targetCenterY -= npcCenter.Y; + + float distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + { + try + { + npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + targetCenterX = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X; + targetCenterY = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y; + } + catch + { + } + + npc.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2; + distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); + distanceFromTarget = (distanceFromTarget - npc.width) / distanceFromTarget; + targetCenterX *= distanceFromTarget; + targetCenterY *= distanceFromTarget; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + targetCenterX; + npc.position.Y = npc.position.Y + targetCenterY; + + if (targetCenterX < 0f) + npc.spriteDirection = -1; + else if (targetCenterX > 0f) + npc.spriteDirection = 1; + } + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= 45f && npc.Opacity == 1f && noContactDamageTimer <= 0; + } + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + { + if (npc.Calamity().newAI[2] < ThanatosHead.immunityTime) + damage *= 0.01; + + return true; + } + + public override void FindFrame(int frameHeight) // 5 total frames + { + if (!Main.npc[(int)npc.ai[2]].active || Main.npc[(int)npc.ai[2]].life <= 0) + return; + + // Swap between venting and non-venting frames + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; + bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + npc.frameCounter += 1D; + if (npc.Calamity().newAI[0] > 0f) + { + if (npc.frameCounter >= 6D) + { + npc.frame.Y += frameHeight; + npc.frameCounter = 0D; + } + int finalFrame = Main.npcFrameCount[npc.type] - 1; + if (npc.frame.Y > frameHeight * finalFrame) + npc.frame.Y = frameHeight * finalFrame; + } + else + { + if (npc.frameCounter >= 6D) + { + npc.frame.Y -= frameHeight; + npc.frameCounter = 0D; + } + if (npc.frame.Y < 0) + npc.frame.Y = 0; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture = Main.npcTexture[npc.type]; + Vector2 vector = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + + Vector2 center = npc.Center - Main.screenPosition; + center -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + center += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, center, npc.frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); + + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Thanatos/ThanatosTailGlow"); + spriteBatch.Draw(texture, center, npc.frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, spriteEffects, 0f); + + SmokeDrawer.DrawSet(npc.Center); + + return false; + } + + public override bool CheckActive() => false; + + public override bool PreNPCLoot() => false; + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.soundDelay == 0) + { + npc.soundDelay = 8; + + if (vulnerable) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/OtherworldlyHit"), npc.Center); + else + Main.PlaySound(SoundID.NPCHit4, npc.Center); + } + + int baseDust = vulnerable ? 3 : 1; + for (int k = 0; k < baseDust; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosTail"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosTail2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosTail3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Thanatos/ThanatosTail4"), 1f); + } + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); + } + } } diff --git a/NPCs/GreatSandShark/GreatSandShark.cs b/NPCs/GreatSandShark/GreatSandShark.cs index 9ea69b0256..af8a63f847 100644 --- a/NPCs/GreatSandShark/GreatSandShark.cs +++ b/NPCs/GreatSandShark/GreatSandShark.cs @@ -11,7 +11,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.GreatSandShark { - [AutoloadBossHead] + [AutoloadBossHead] public class GreatSandShark : ModNPC { private bool resetAI = false; @@ -24,16 +24,16 @@ namespace CalamityMod.NPCs.GreatSandShark public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.noGravity = true; + npc.Calamity().canBreakPlayerDefense = true; + npc.noGravity = true; npc.noTileCollide = true; npc.npcSlots = 15f; npc.damage = 100; npc.width = 300; npc.height = 120; npc.defense = 40; - npc.DR_NERD(0.25f); - npc.LifeMaxNERB(9200, 11000); + npc.DR_NERD(0.25f); + npc.LifeMaxNERB(9200, 11000); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; @@ -47,10 +47,10 @@ namespace CalamityMod.NPCs.GreatSandShark npc.timeLeft = NPC.activeTime * 30; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -79,11 +79,11 @@ namespace CalamityMod.NPCs.GreatSandShark bool lowerLife = npc.life <= npc.lifeMax * (expertMode ? 0.35 : 0.2); bool youMustDie = !Main.player[npc.target].ZoneDesert; - if (!Terraria.GameContent.Events.Sandstorm.Happening) - { - CalamityUtils.StartSandstorm(); - CalamityNetcode.SyncWorld(); - } + if (!Terraria.GameContent.Events.Sandstorm.Happening) + { + CalamityUtils.StartSandstorm(); + CalamityNetcode.SyncWorld(); + } if (npc.soundDelay <= 0) { @@ -377,8 +377,8 @@ namespace CalamityMod.NPCs.GreatSandShark velocityX *= 1.5f; velocityY *= 1.5f; } - npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -velocityX, velocityX); - npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -velocityY, velocityY); + npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -velocityX, velocityX); + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -velocityY, velocityY); Vector2 vec4 = npc.Center + npc.velocity.SafeNormalize(Vector2.Zero) * npc.Size.Length() / 2f + npc.velocity; point15 = vec4.ToTileCoordinates(); tileSafely = Framing.GetTileSafely(point15); @@ -505,7 +505,7 @@ namespace CalamityMod.NPCs.GreatSandShark npc.ai[0] = 1f; } npc.rotation = npc.velocity.Y * npc.direction * 0.1f; - npc.rotation = MathHelper.Clamp(npc.rotation, -0.1f, 0.1f); + npc.rotation = MathHelper.Clamp(npc.rotation, -0.1f, 0.1f); } } diff --git a/NPCs/HiveMind/DankCreeper.cs b/NPCs/HiveMind/DankCreeper.cs index 90f9a5808f..59c41a9110 100644 --- a/NPCs/HiveMind/DankCreeper.cs +++ b/NPCs/HiveMind/DankCreeper.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.HiveMind { - public class DankCreeper : ModNPC + public class DankCreeper : ModNPC { public override void SetStaticDefaults() { @@ -18,9 +18,9 @@ namespace CalamityMod.NPCs.HiveMind public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.width = 70; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.width = 70; npc.height = 70; npc.defense = 6; npc.lifeMax = 90; @@ -36,10 +36,10 @@ namespace CalamityMod.NPCs.HiveMind npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void AI() { @@ -49,9 +49,9 @@ namespace CalamityMod.NPCs.HiveMind if (BossRushEvent.BossRushActive || CalamityWorld.malice) speed = 18f; - if (npc.ai[1] < 90f) - npc.ai[1] += 1f; - speed = MathHelper.Lerp(3f, speed, npc.ai[1] / 90f); + if (npc.ai[1] < 90f) + npc.ai[1] += 1f; + speed = MathHelper.Lerp(3f, speed, npc.ai[1] / 90f); Vector2 vector167 = new Vector2(npc.Center.X + (npc.direction * 20), npc.Center.Y + 6f); float num1373 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector167.X; @@ -109,23 +109,23 @@ namespace CalamityMod.NPCs.HiveMind } } - public override bool PreNPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override bool PreNPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - if ((Main.expertMode || BossRushEvent.BossRushActive) && Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer); - } + if ((Main.expertMode || BossRushEvent.BossRushActive) && Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer); + } - return false; - } + return false; + } } } diff --git a/NPCs/HiveMind/DarkHeart.cs b/NPCs/HiveMind/DarkHeart.cs index 92f9aa471d..fa58bbc2ec 100644 --- a/NPCs/HiveMind/DarkHeart.cs +++ b/NPCs/HiveMind/DarkHeart.cs @@ -36,10 +36,10 @@ namespace CalamityMod.NPCs.HiveMind npc.chaseable = false; npc.HitSound = SoundID.NPCHit13; npc.DeathSound = SoundID.NPCDeath21; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void FindFrame(int frameHeight) { @@ -116,24 +116,24 @@ namespace CalamityMod.NPCs.HiveMind npc.ai[0] = 0f; int num1169 = (int)(npc.position.X + 10f + Main.rand.Next(npc.width - 20)); int num1170 = (int)(npc.position.Y + npc.height + 4f); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(num1169, num1170, 0f, 4f, type, damage, 0f, Main.myPlayer, 0f, 0f); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(num1169, num1170, 0f, 4f, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) { diff --git a/NPCs/HiveMind/HiveBlob.cs b/NPCs/HiveMind/HiveBlob.cs index a84e8bde11..4171dc09f6 100644 --- a/NPCs/HiveMind/HiveBlob.cs +++ b/NPCs/HiveMind/HiveBlob.cs @@ -28,40 +28,40 @@ namespace CalamityMod.NPCs.HiveMind { npc.lifeMax = 1300; } - npc.knockBackResist = 0f; - aiType = -1; + npc.knockBackResist = 0f; + aiType = -1; npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; npc.chaseable = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void AI() { bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - int num750 = CalamityGlobalNPC.hiveMind; - if (num750 < 0 || !Main.npc[num750].active) - { - npc.active = false; - npc.netUpdate = true; - return; - } + int num750 = CalamityGlobalNPC.hiveMind; + if (num750 < 0 || !Main.npc[num750].active) + { + npc.active = false; + npc.netUpdate = true; + return; + } - if (npc.ai[3] > 0f) + if (npc.ai[3] > 0f) num750 = (int)npc.ai[3] - 1; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] -= 1f; - if (npc.localAI[0] <= 0f) + npc.localAI[0] -= 1f; + if (npc.localAI[0] <= 0f) { npc.localAI[0] = Main.rand.Next(180, 361); npc.ai[0] = Main.rand.Next(-100, 101); @@ -114,17 +114,17 @@ namespace CalamityMod.NPCs.HiveMind npc.velocity.Y = npc.velocity.Y * 0.8f; } - float velocityLimit = 8f; - if (npc.velocity.X > velocityLimit) - npc.velocity.X = velocityLimit; - if (npc.velocity.X < -velocityLimit) - npc.velocity.X = -velocityLimit; - if (npc.velocity.Y > velocityLimit) - npc.velocity.Y = velocityLimit; - if (npc.velocity.Y < -velocityLimit) - npc.velocity.Y = -velocityLimit; + float velocityLimit = 8f; + if (npc.velocity.X > velocityLimit) + npc.velocity.X = velocityLimit; + if (npc.velocity.X < -velocityLimit) + npc.velocity.X = -velocityLimit; + if (npc.velocity.Y > velocityLimit) + npc.velocity.Y = velocityLimit; + if (npc.velocity.Y < -velocityLimit) + npc.velocity.Y = -velocityLimit; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) npc.localAI[1] = 180f; @@ -144,26 +144,26 @@ namespace CalamityMod.NPCs.HiveMind num944 = num941 / num944; num942 *= num944; num943 *= num944; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, type, damage, 0f, Main.myPlayer, 0f, 0f); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, type, damage, 0f, Main.myPlayer, 0f, 0f); npc.netUpdate = true; } } } } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } - public override bool CheckActive() + public override bool CheckActive() { return false; } diff --git a/NPCs/HiveMind/HiveBlob2.cs b/NPCs/HiveMind/HiveBlob2.cs index ec02b33f57..467e5249cc 100644 --- a/NPCs/HiveMind/HiveBlob2.cs +++ b/NPCs/HiveMind/HiveBlob2.cs @@ -28,52 +28,52 @@ namespace CalamityMod.NPCs.HiveMind { npc.lifeMax = 1300; } - npc.knockBackResist = 0f; - aiType = -1; + npc.knockBackResist = 0f; + aiType = -1; npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; npc.chaseable = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void AI() { - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - int num750 = CalamityGlobalNPC.hiveMind; - if (num750 < 0 || !Main.npc[num750].active) - { - npc.active = false; - npc.netUpdate = true; - return; - } + int num750 = CalamityGlobalNPC.hiveMind; + if (num750 < 0 || !Main.npc[num750].active) + { + npc.active = false; + npc.netUpdate = true; + return; + } - if (npc.ai[3] > 0f) + if (npc.ai[3] > 0f) num750 = (int)npc.ai[3] - 1; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] -= 1f; - if (npc.localAI[0] <= 0f) - { - npc.localAI[0] = Main.rand.Next(180, 361); - npc.ai[0] = Main.rand.Next(-100, 101); - npc.ai[1] = Main.rand.Next(-100, 101); - npc.netUpdate = true; - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[0] -= 1f; + if (npc.localAI[0] <= 0f) + { + npc.localAI[0] = Main.rand.Next(180, 361); + npc.ai[0] = Main.rand.Next(-100, 101); + npc.ai[1] = Main.rand.Next(-100, 101); + npc.netUpdate = true; + } + } - npc.TargetClosest(true); + npc.TargetClosest(true); - float num751 = death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; - float num752 = 96f; + float num751 = death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; + float num752 = 96f; Vector2 vector22 = new Vector2(npc.ai[0] * 16f + 8f, npc.ai[1] * 16f + 8f); float num189 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - (npc.width / 2) - vector22.X; float num190 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - (npc.height / 2) - vector22.Y; @@ -114,17 +114,17 @@ namespace CalamityMod.NPCs.HiveMind npc.velocity.Y = npc.velocity.Y * 0.8f; } - float velocityLimit = 8f; - if (npc.velocity.X > velocityLimit) - npc.velocity.X = velocityLimit; - if (npc.velocity.X < -velocityLimit) - npc.velocity.X = -velocityLimit; - if (npc.velocity.Y > velocityLimit) - npc.velocity.Y = velocityLimit; - if (npc.velocity.Y < -velocityLimit) - npc.velocity.Y = -velocityLimit; + float velocityLimit = 8f; + if (npc.velocity.X > velocityLimit) + npc.velocity.X = velocityLimit; + if (npc.velocity.X < -velocityLimit) + npc.velocity.X = -velocityLimit; + if (npc.velocity.Y > velocityLimit) + npc.velocity.Y = velocityLimit; + if (npc.velocity.Y < -velocityLimit) + npc.velocity.Y = -velocityLimit; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) npc.localAI[1] = 180f; @@ -136,34 +136,34 @@ namespace CalamityMod.NPCs.HiveMind npc.TargetClosest(true); 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 num941 = death ? 5f : revenge ? 4.5f : expertMode ? 4f : 3.5f; - Vector2 vector104 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + (npc.height / 2)); + float num941 = death ? 5f : revenge ? 4.5f : expertMode ? 4f : 3.5f; + Vector2 vector104 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + (npc.height / 2)); float num942 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector104.X; float num943 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector104.Y; float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); num944 = num941 / num944; num942 *= num944; num943 *= num944; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, type, damage, 0f, Main.myPlayer, 0f, 0f); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, type, damage, 0f, Main.myPlayer, 0f, 0f); npc.netUpdate = true; } } } } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } - public override bool CheckActive() + public override bool CheckActive() { return false; } diff --git a/NPCs/HiveMind/HiveCyst.cs b/NPCs/HiveMind/HiveCyst.cs index bba9f30513..6ae83db4e5 100644 --- a/NPCs/HiveMind/HiveCyst.cs +++ b/NPCs/HiveMind/HiveCyst.cs @@ -28,10 +28,10 @@ namespace CalamityMod.NPCs.HiveMind npc.chaseable = false; npc.HitSound = SoundID.NPCHit1; npc.rarity = 2; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void FindFrame(int frameHeight) { diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 9ba48ade69..748e91192e 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -34,65 +34,65 @@ namespace CalamityMod.NPCs.HiveMind { public class HiveMind : ModNPC { - public static int normalIconIndex; - public static int phase2IconIndex; + public static int normalIconIndex; + public static int phase2IconIndex; - internal static void LoadHeadIcons() - { - string normalIconPath = "CalamityMod/NPCs/HiveMind/HiveMind_Head_Boss"; - string phase2IconPath = "CalamityMod/NPCs/HiveMind/HiveMindP2_Head_Boss"; + internal static void LoadHeadIcons() + { + string normalIconPath = "CalamityMod/NPCs/HiveMind/HiveMind_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/HiveMind/HiveMindP2_Head_Boss"; - CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); - normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); + CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); + normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); - CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); - phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); - } + CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); + phase2IconIndex = ModContent.GetModBossHeadSlot(phase2IconPath); + } - // This block of values can be modified in SetDefaults() based on difficulty mode or something - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private int burrowTimer = 420; - private int minimumDriftTime = 300; - private int teleportRadius = 300; - private int decelerationTime = 30; - private int reelbackFade = 2; // Divide 255 by this for duration of reelback in ticks - private float arcTime = 45f; // Ticks needed to complete movement for spawn and rain attacks (DEATH ONLY) - private float driftSpeed = 1f; // Default speed when slowly floating at player - private float driftBoost = 1f; // Max speed added as health decreases - private int lungeDelay = 90; // # of ticks long hive mind spends sliding to a stop before lunging - private int lungeTime = 33; - private int lungeFade = 15; // Divide 255 by this for duration of hive mind spin before slowing for lunge - private double lungeRots = 0.2; // Number of revolutions made while spinning/fading in for lunge - private bool dashStarted = false; - private int phase2timer = 360; - private int rotationDirection; - private double rotation; - private double rotationIncrement; - private int state = 0; - private int previousState = 0; - private int nextState = 0; - private int reelCount = 0; - private Vector2 deceleration; - private int frameX = 0; - private int frameY = 0; - private const int maxFramesX_Phase2 = 2; - private const int maxFramesY_Phase2 = 8; - private const int height_Phase2 = 142; + // This block of values can be modified in SetDefaults() based on difficulty mode or something + private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + private int burrowTimer = 420; + private int minimumDriftTime = 300; + private int teleportRadius = 300; + private int decelerationTime = 30; + private int reelbackFade = 2; // Divide 255 by this for duration of reelback in ticks + private float arcTime = 45f; // Ticks needed to complete movement for spawn and rain attacks (DEATH ONLY) + private float driftSpeed = 1f; // Default speed when slowly floating at player + private float driftBoost = 1f; // Max speed added as health decreases + private int lungeDelay = 90; // # of ticks long hive mind spends sliding to a stop before lunging + private int lungeTime = 33; + private int lungeFade = 15; // Divide 255 by this for duration of hive mind spin before slowing for lunge + private double lungeRots = 0.2; // Number of revolutions made while spinning/fading in for lunge + private bool dashStarted = false; + private int phase2timer = 360; + private int rotationDirection; + private double rotation; + private double rotationIncrement; + private int state = 0; + private int previousState = 0; + private int nextState = 0; + private int reelCount = 0; + private Vector2 deceleration; + private int frameX = 0; + private int frameY = 0; + private const int maxFramesX_Phase2 = 2; + private const int maxFramesY_Phase2 = 8; + private const int height_Phase2 = 142; public override void SetStaticDefaults() { DisplayName.SetDefault("The Hive Mind"); Main.npcFrameCount[npc.type] = 16; - NPCID.Sets.TrailingMode[npc.type] = 1; - NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + NPCID.Sets.TrailCacheLength[npc.type] = npc.oldPos.Length; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 5f; - npc.GetNPCDamage(); - npc.width = 178; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.width = 178; npc.height = 122; npc.defense = 8; npc.LifeMaxNERB(8500, 10200, 350000); @@ -134,42 +134,42 @@ namespace CalamityMod.NPCs.HiveMind driftBoost = 1f; } - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - { - lungeRots = 0.4; - minimumDriftTime = 40; - reelbackFade = 10; - lungeTime = 16; - driftSpeed = 6f; - driftBoost = 1f; - } + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + { + lungeRots = 0.4; + minimumDriftTime = 40; + reelbackFade = 10; + lungeTime = 16; + driftSpeed = 6f; + driftBoost = 1f; + } phase2timer = minimumDriftTime; rotationIncrement = 0.0246399424 * lungeRots * lungeFade; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } - public override void BossHeadSlot(ref int index) - { - if (npc.life / (float)npc.lifeMax < 0.8f) - index = phase2IconIndex; - else - index = normalIconIndex; - } - - public override void SendExtraAI(BinaryWriter writer) + public override void BossHeadSlot(ref int index) { - writer.Write(biomeEnrageTimer); - writer.Write(npc.dontTakeDamage); - writer.Write(npc.noTileCollide); - writer.Write(npc.noGravity); - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[3]); - writer.Write(burrowTimer); - writer.Write(state); + if (npc.life / (float)npc.lifeMax < 0.8f) + index = phase2IconIndex; + else + index = normalIconIndex; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(biomeEnrageTimer); + writer.Write(npc.dontTakeDamage); + writer.Write(npc.noTileCollide); + writer.Write(npc.noGravity); + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[3]); + writer.Write(burrowTimer); + writer.Write(state); writer.Write(nextState); writer.Write(phase2timer); writer.Write(dashStarted); @@ -178,20 +178,20 @@ namespace CalamityMod.NPCs.HiveMind writer.Write(previousState); writer.Write(reelCount); writer.Write(frameX); - writer.Write(frameY); + writer.Write(frameY); } public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - npc.noTileCollide = reader.ReadBoolean(); - npc.noGravity = reader.ReadBoolean(); - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - burrowTimer = reader.ReadInt32(); - state = reader.ReadInt32(); + biomeEnrageTimer = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); + npc.noTileCollide = reader.ReadBoolean(); + npc.noGravity = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + burrowTimer = reader.ReadInt32(); + state = reader.ReadInt32(); nextState = reader.ReadInt32(); phase2timer = reader.ReadInt32(); dashStarted = reader.ReadBoolean(); @@ -200,116 +200,116 @@ namespace CalamityMod.NPCs.HiveMind previousState = reader.ReadInt32(); reelCount = reader.ReadInt32(); frameX = reader.ReadInt32(); - frameY = reader.ReadInt32(); + frameY = reader.ReadInt32(); } public override void FindFrame(int frameHeight) { - // When Hive Mind starts flying around - bool phase2 = npc.life / (float)npc.lifeMax < 0.8f; + // When Hive Mind starts flying around + bool phase2 = npc.life / (float)npc.lifeMax < 0.8f; - if (phase2) - { - npc.frameCounter++; - if (npc.frameCounter >= 6D) - { - // Reset frame counter - npc.frameCounter = 0D; + if (phase2) + { + npc.frameCounter++; + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; - // Increment the Y frame - frameY++; + // Increment the Y frame + frameY++; - // Reset the Y frame if greater than 8 - if (frameY == maxFramesY_Phase2) - { - frameX++; - frameY = 0; - } + // Reset the Y frame if greater than 8 + if (frameY == maxFramesY_Phase2) + { + frameX++; + frameY = 0; + } - // Reset the frames to frame 0 - if ((frameX * maxFramesY_Phase2) + frameY > 15) - frameX = frameY = 0; - } - } - else - { - npc.frameCounter += 1f / 6f; - npc.frameCounter %= Main.npcFrameCount[npc.type]; - int frame = (int)npc.frameCounter; - npc.frame.Y = frame * frameHeight; - } + // Reset the frames to frame 0 + if ((frameX * maxFramesY_Phase2) + frameY > 15) + frameX = frameY = 0; + } + } + else + { + npc.frameCounter += 1f / 6f; + npc.frameCounter %= Main.npcFrameCount[npc.type]; + int frame = (int)npc.frameCounter; + npc.frame.Y = frame * frameHeight; + } } public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { - // When Hive Mind starts flying around - bool phase2 = npc.life / (float)npc.lifeMax < 0.8f; + // When Hive Mind starts flying around + bool phase2 = npc.life / (float)npc.lifeMax < 0.8f; - if (phase2) - { - SpriteEffects spriteEffects = npc.direction == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D texture = ModContent.GetTexture("CalamityMod/NPCs/HiveMind/HiveMindP2"); - Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); - Color afterimageBaseColor = Color.White; - int numAfterimages = 5; + if (phase2) + { + SpriteEffects spriteEffects = npc.direction == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D texture = ModContent.GetTexture("CalamityMod/NPCs/HiveMind/HiveMindP2"); + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); + Color afterimageBaseColor = Color.White; + int numAfterimages = 5; - if (CalamityConfig.Instance.Afterimages && state != 0) - { - for (int i = 1; i < numAfterimages; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); - afterimageColor = npc.GetAlpha(afterimageColor); - afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX_Phase2, maxFramesY_Phase2) * npc.scale / 2f; - afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages && state != 0) + { + for (int i = 1; i < numAfterimages; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); + afterimageColor = npc.GetAlpha(afterimageColor); + afterimageColor *= (numAfterimages - i) / 15f; + Vector2 afterimageCenter = npc.oldPos[i] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX_Phase2, maxFramesY_Phase2) * npc.scale / 2f; + afterimageCenter += vector * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, afterimageCenter, npc.frame, afterimageColor, npc.oldRot[i], vector, npc.scale, spriteEffects, 0f); + } + } - Vector2 center = npc.Center - Main.screenPosition; - spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); - - return false; - } + Vector2 center = npc.Center - Main.screenPosition; + spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, spriteEffects, 0f); + + return false; + } - return true; + return true; } private void SpawnStuff() { - int maxSpawns = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 5 : CalamityWorld.revenge ? 4 : Main.expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); - for (int i = 0; i < maxSpawns; i++) - { - int type = NPCID.EaterofSouls; - int choice = -1; - do - { - choice++; - switch (choice) - { - case 0: - case 1: - type = NPCID.EaterofSouls; - break; - case 2: - type = NPCID.DevourerHead; - break; - case 3: - case 4: - type = ModContent.NPCType(); - break; - default: - break; - } - } - while (NPC.AnyNPCs(type) && choice < 5); + int maxSpawns = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 5 : CalamityWorld.revenge ? 4 : Main.expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); + for (int i = 0; i < maxSpawns; i++) + { + int type = NPCID.EaterofSouls; + int choice = -1; + do + { + choice++; + switch (choice) + { + case 0: + case 1: + type = NPCID.EaterofSouls; + break; + case 2: + type = NPCID.DevourerHead; + break; + case 3: + case 4: + type = ModContent.NPCType(); + break; + default: + break; + } + } + while (NPC.AnyNPCs(type) && choice < 5); - if (choice < 5) - NPC.NewNPC((int)npc.position.X + Main.rand.Next(npc.width), (int)npc.position.Y + Main.rand.Next(npc.height), type); - } + if (choice < 5) + NPC.NewNPC((int)npc.position.X + Main.rand.Next(npc.width), (int)npc.position.Y + Main.rand.Next(npc.height), type); + } } private void ReelBack() @@ -340,264 +340,264 @@ namespace CalamityMod.NPCs.HiveMind public override void AI() { - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Enrage - if ((!player.ZoneCorrupt || (npc.position.Y / 16f) < Main.worldSurface) && !BossRushEvent.BossRushActive) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + // Enrage + if ((!player.ZoneCorrupt || (npc.position.Y / 16f) < Main.worldSurface) && !BossRushEvent.BossRushActive) + { + if (biomeEnrageTimer > 0) + biomeEnrageTimer--; + } + else + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || malice; + bool biomeEnraged = biomeEnrageTimer <= 0 || malice; - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; - if (biomeEnraged && (!player.ZoneCorrupt || malice)) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1f; - } - if (biomeEnraged && ((npc.position.Y / 16f) < Main.worldSurface || malice)) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1f; - } + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + if (biomeEnraged && (!player.ZoneCorrupt || malice)) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + if (biomeEnraged && ((npc.position.Y / 16f) < Main.worldSurface || malice)) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } - // When Hive Mind starts flying around - bool phase2 = lifeRatio < 0.8f; + // When Hive Mind starts flying around + bool phase2 = lifeRatio < 0.8f; - // Phase 2 settings - if (phase2) - { - // Spawn gores, play sound and reset every crucial variable at the start - if (npc.localAI[1] == 0f) - { - npc.localAI[1] = 1f; + // Phase 2 settings + if (phase2) + { + // Spawn gores, play sound and reset every crucial variable at the start + if (npc.localAI[1] == 0f) + { + npc.localAI[1] = 1f; - int goreAmount = 7; - for (int i = 1; i <= goreAmount; i++) - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HiveMindGores/HiveMindGore" + i), 1f); + int goreAmount = 7; + for (int i = 1; i <= goreAmount; i++) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/HiveMindGores/HiveMindGore" + i), 1f); - Main.PlaySound(SoundID.NPCDeath1, (int)npc.Center.X, (int)npc.Center.Y); + Main.PlaySound(SoundID.NPCDeath1, (int)npc.Center.X, (int)npc.Center.Y); - npc.position = npc.Center; - npc.height = height_Phase2; - npc.position -= npc.Size * 0.5f; + npc.position = npc.Center; + npc.height = height_Phase2; + npc.position -= npc.Size * 0.5f; - npc.frame.Y = 0; - npc.noGravity = true; - npc.noTileCollide = true; - npc.scale = 1f; - npc.alpha = 0; - npc.dontTakeDamage = false; - npc.damage = npc.defDamage; - } + npc.frame.Y = 0; + npc.noGravity = true; + npc.noTileCollide = true; + npc.scale = 1f; + npc.alpha = 0; + npc.dontTakeDamage = false; + npc.damage = npc.defDamage; + } - npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); - } - else - { - CalamityGlobalNPC.hiveMind = npc.whoAmI; + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + } + else + { + CalamityGlobalNPC.hiveMind = npc.whoAmI; - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - if (npc.timeLeft > 60) - npc.timeLeft = 60; + if (!player.active || player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead) + { + if (npc.timeLeft > 60) + npc.timeLeft = 60; - if (npc.localAI[3] < 120f) - npc.localAI[3] += 1f; + if (npc.localAI[3] < 120f) + npc.localAI[3] += 1f; - if (npc.localAI[3] > 60f) - { - npc.velocity.Y += (npc.localAI[3] - 60f) * 0.5f; + if (npc.localAI[3] > 60f) + { + npc.velocity.Y += (npc.localAI[3] - 60f) * 0.5f; - npc.noGravity = true; - npc.noTileCollide = true; + npc.noGravity = true; + npc.noTileCollide = true; - if (burrowTimer > 30) - burrowTimer = 30; - } + if (burrowTimer > 30) + burrowTimer = 30; + } - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + return; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; - if (npc.localAI[3] > 0f) - { - npc.localAI[3] -= 1f; - return; - } + if (npc.localAI[3] > 0f) + { + npc.localAI[3] -= 1f; + return; + } - npc.noGravity = false; - npc.noTileCollide = false; + npc.noGravity = false; + npc.noTileCollide = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - int maxBlobs = death ? 15 : revenge ? 7 : expertMode ? 6 : 5; - for (int i = 0; i < maxBlobs; i++) - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI); - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (npc.localAI[0] == 0f) + { + npc.localAI[0] = 1f; + int maxBlobs = death ? 15 : revenge ? 7 : expertMode ? 6 : 5; + for (int i = 0; i < maxBlobs; i++) + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI); + } + } - if (npc.ai[3] == 0f && npc.life > 0) - npc.ai[3] = npc.lifeMax; + if (npc.ai[3] == 0f && npc.life > 0) + npc.ai[3] = npc.lifeMax; - if (npc.life > 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num660 = (int)(npc.lifeMax * 0.05); - if ((npc.life + num660) < npc.ai[3]) - { - npc.ai[3] = npc.life; + if (npc.life > 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int num660 = (int)(npc.lifeMax * 0.05); + if ((npc.life + num660) < npc.ai[3]) + { + npc.ai[3] = npc.life; - int maxSpawns = malice ? 10 : death ? 5 : revenge ? 4 : expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); - int maxDankSpawns = malice ? 4 : death ? Main.rand.Next(2, 4) : revenge ? 2 : expertMode ? Main.rand.Next(1, 3) : 1; + int maxSpawns = malice ? 10 : death ? 5 : revenge ? 4 : expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); + int maxDankSpawns = malice ? 4 : death ? Main.rand.Next(2, 4) : revenge ? 2 : expertMode ? Main.rand.Next(1, 3) : 1; - for (int num662 = 0; num662 < maxSpawns; num662++) - { - int x = (int)(npc.position.X + Main.rand.Next(npc.width - 32)); - int y = (int)(npc.position.Y + Main.rand.Next(npc.height - 32)); + for (int num662 = 0; num662 < maxSpawns; num662++) + { + 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 type = ModContent.NPCType(); - if (NPC.CountNPCS(ModContent.NPCType()) < maxDankSpawns) - type = ModContent.NPCType(); + int type = ModContent.NPCType(); + if (NPC.CountNPCS(ModContent.NPCType()) < maxDankSpawns) + type = ModContent.NPCType(); - int num664 = NPC.NewNPC(x, y, type); - Main.npc[num664].SetDefaults(type); - if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); - } + int num664 = NPC.NewNPC(x, y, type); + Main.npc[num664].SetDefaults(type); + if (Main.netMode == NetmodeID.Server && num664 < Main.maxNPCs) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + } - return; - } - } - } + return; + } + } + } - burrowTimer--; - if (burrowTimer < -120) - { - burrowTimer = (death ? 180 : revenge ? 300 : expertMode ? 360 : 420) - (int)enrageScale * 55; - if (burrowTimer < 30) - burrowTimer = 30; + burrowTimer--; + if (burrowTimer < -120) + { + burrowTimer = (death ? 180 : revenge ? 300 : expertMode ? 360 : 420) - (int)enrageScale * 55; + if (burrowTimer < 30) + burrowTimer = 30; - npc.scale = 1f; - npc.alpha = 0; - npc.dontTakeDamage = false; - npc.damage = npc.defDamage; - } - else if (burrowTimer < -60) - { - npc.scale += 0.0165f; - npc.alpha -= 4; + npc.scale = 1f; + npc.alpha = 0; + npc.dontTakeDamage = false; + npc.damage = npc.defDamage; + } + else if (burrowTimer < -60) + { + npc.scale += 0.0165f; + npc.alpha -= 4; - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); - Main.dust[num622].velocity *= 2f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); + Main.dust[num622].velocity *= 2f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } - for (int i = 0; i < 2; i++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 3.5f * npc.scale); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 3.5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); - Main.dust[num624].velocity *= 1f; - } - } - else if (burrowTimer == -60) - { - npc.scale = 0.01f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.Center = player.Center; - npc.position.Y = player.position.Y - npc.height; - int tilePosX = (int)npc.Center.X / 16; - int tilePosY = (int)(npc.position.Y + npc.height) / 16 + 1; + for (int i = 0; i < 2; i++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 3.5f * npc.scale); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 3.5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); + Main.dust[num624].velocity *= 1f; + } + } + else if (burrowTimer == -60) + { + npc.scale = 0.01f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.Center = player.Center; + npc.position.Y = player.position.Y - npc.height; + int tilePosX = (int)npc.Center.X / 16; + int tilePosY = (int)(npc.position.Y + npc.height) / 16 + 1; - if (Main.tile[tilePosX, tilePosY] == null) - Main.tile[tilePosX, tilePosY] = new Tile(); + if (Main.tile[tilePosX, tilePosY] == null) + Main.tile[tilePosX, tilePosY] = new Tile(); - while (!(Main.tile[tilePosX, tilePosY].nactive() && Main.tileSolid[Main.tile[tilePosX, tilePosY].type])) - { - tilePosY++; - npc.position.Y += 16; - if (Main.tile[tilePosX, tilePosY] == null) - Main.tile[tilePosX, tilePosY] = new Tile(); - } - } - npc.netUpdate = true; - } - else if (burrowTimer < 0) - { - npc.scale -= 0.0165f; - npc.alpha += 4; + while (!(Main.tile[tilePosX, tilePosY].nactive() && Main.tileSolid[Main.tile[tilePosX, tilePosY].type])) + { + tilePosY++; + npc.position.Y += 16; + if (Main.tile[tilePosX, tilePosY] == null) + Main.tile[tilePosX, tilePosY] = new Tile(); + } + } + npc.netUpdate = true; + } + else if (burrowTimer < 0) + { + npc.scale -= 0.0165f; + npc.alpha += 4; - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); - Main.dust[num622].velocity *= 2f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); + Main.dust[num622].velocity *= 2f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } - for (int i = 0; i < 2; i++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 3.5f * npc.scale); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 3.5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); - Main.dust[num624].velocity *= 1f; - } - } - else if (burrowTimer == 0) - { - if (!player.active || player.dead) - { - burrowTimer = 30; - } - else - { - npc.TargetClosest(); - npc.dontTakeDamage = true; - npc.damage = 0; - } - } + for (int i = 0; i < 2; i++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 3.5f * npc.scale); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 3.5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.Center.Y), npc.width, npc.height / 2, 14, 0f, -3f, 100, default, 2.5f * npc.scale); + Main.dust[num624].velocity *= 1f; + } + } + else if (burrowTimer == 0) + { + if (!player.active || player.dead) + { + burrowTimer = 30; + } + else + { + npc.TargetClosest(); + npc.dontTakeDamage = true; + npc.damage = 0; + } + } - return; - } + return; + } - if (npc.alpha != 0) + if (npc.alpha != 0) { if (npc.damage != 0) npc.damage = 0; @@ -614,30 +614,30 @@ namespace CalamityMod.NPCs.HiveMind if (nextState == 0) { - npc.TargetClosest(); - if (revenge && lifeRatio < 0.53f) + npc.TargetClosest(); + if (revenge && lifeRatio < 0.53f) { - if (death) - { - do - nextState = Main.rand.Next(3, 6); - while (nextState == previousState); - previousState = nextState; - } - else if (lifeRatio < 0.27f) - { - do - nextState = Main.rand.Next(3, 6); - while (nextState == previousState); - previousState = nextState; - } - else - { - do - nextState = Main.rand.Next(3, 5); - while (nextState == previousState); - previousState = nextState; - } + if (death) + { + do + nextState = Main.rand.Next(3, 6); + while (nextState == previousState); + previousState = nextState; + } + else if (lifeRatio < 0.27f) + { + do + nextState = Main.rand.Next(3, 6); + while (nextState == previousState); + previousState = nextState; + } + else + { + do + nextState = Main.rand.Next(3, 5); + while (nextState == previousState); + previousState = nextState; + } } else { @@ -649,13 +649,13 @@ namespace CalamityMod.NPCs.HiveMind else { reelCount++; - if (Main.expertMode && reelCount == 2) - { - reelCount = 0; - nextState = 2; - } - else - nextState = 1; + if (Main.expertMode && reelCount == 2) + { + reelCount = 0; + nextState = 2; + } + else + nextState = 1; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -671,27 +671,27 @@ namespace CalamityMod.NPCs.HiveMind if (!player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 5000f) { npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 5000f) - { - if (npc.timeLeft > 60) - npc.timeLeft = 60; + player = Main.player[npc.target]; + if (!player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 5000f) + { + if (npc.timeLeft > 60) + npc.timeLeft = 60; - if (npc.localAI[3] < 120f) - npc.localAI[3] += 1f; + if (npc.localAI[3] < 120f) + npc.localAI[3] += 1f; - if (npc.localAI[3] > 60f) - npc.velocity.Y += (npc.localAI[3] - 60f) * 0.5f; + if (npc.localAI[3] > 60f) + npc.velocity.Y += (npc.localAI[3] - 60f) * 0.5f; - return; - } + return; + } } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; - if (npc.localAI[3] > 0f) + if (npc.localAI[3] > 0f) { - npc.localAI[3] -= 1f; + npc.localAI[3] -= 1f; return; } @@ -707,7 +707,7 @@ namespace CalamityMod.NPCs.HiveMind else { npc.velocity.Normalize(); - if (expertMode) // Variable velocity in expert and up + if (expertMode) // Variable velocity in expert and up npc.velocity *= driftSpeed + enrageScale + driftBoost * lifeRatio; else npc.velocity *= driftSpeed + enrageScale; @@ -766,7 +766,7 @@ namespace CalamityMod.NPCs.HiveMind if (revenge && lifeRatio < 0.53f) { - state = nextState; + state = nextState; nextState = 0; previousState = state; } @@ -868,7 +868,7 @@ namespace CalamityMod.NPCs.HiveMind { if (expertMode && !NPC.AnyNPCs(ModContent.NPCType())) NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType()); - } + } else if (!NPC.AnyNPCs(NPCID.EaterofSouls)) NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, NPCID.EaterofSouls); } @@ -919,9 +919,9 @@ namespace CalamityMod.NPCs.HiveMind npc.ai[0]++; if (Main.netMode != NetmodeID.MultiplayerClient) { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.position.X + Main.rand.Next(npc.width), npc.position.Y + Main.rand.Next(npc.height), 0, 0, type, damage, 0, Main.myPlayer, 11, 0); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.position.X + Main.rand.Next(npc.width), npc.position.Y + Main.rand.Next(npc.height), 0, 0, type, damage, 0, Main.myPlayer, 11, 0); } if (npc.ai[0] == 10) @@ -951,32 +951,32 @@ namespace CalamityMod.NPCs.HiveMind } } - public override bool? CanHitNPC(NPC target) => npc.alpha == 0; // Can only be hit while fully visible + public override bool? CanHitNPC(NPC target) => npc.alpha == 0; // Can only be hit while fully visible - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - Rectangle targetHitbox = target.Hitbox; + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= 60f && npc.alpha == 0 && npc.scale == 1f; // No damage while not fully visible or shrunk - } + return minDist <= 60f && npc.alpha == 0 && npc.scale == 1f; // No damage while not fully visible or shrunk + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => npc.scale == 1f; // Only draw HP bar while at full size + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => npc.scale == 1f; // Only draw HP bar while at full size - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { if (phase2timer < 0 && damage > 1) { @@ -998,34 +998,34 @@ namespace CalamityMod.NPCs.HiveMind for (int k = 0; k < damage / npc.lifeMax * 100.0; k++) Dust.NewDust(npc.position, npc.width, npc.height, 14, hitDirection, -1f, 0, default, 1f); - // When Hive Mind starts flying around - bool phase2 = npc.life / (float)npc.lifeMax < 0.8f; + // When Hive Mind starts flying around + bool phase2 = npc.life / (float)npc.lifeMax < 0.8f; - if (phase2) - { - if (Main.netMode != NetmodeID.MultiplayerClient && Main.rand.NextBool(15) && NPC.CountNPCS(ModContent.NPCType()) < 2) - { - Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); - NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); - } - } - else - { - if (NPC.CountNPCS(NPCID.EaterofSouls) < 3 && NPC.CountNPCS(NPCID.DevourerHead) < 1) - { - if (Main.rand.NextBool(60) && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); - NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, NPCID.EaterofSouls); - } + if (phase2) + { + if (Main.netMode != NetmodeID.MultiplayerClient && Main.rand.NextBool(15) && NPC.CountNPCS(ModContent.NPCType()) < 2) + { + Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); + NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); + } + } + else + { + if (NPC.CountNPCS(NPCID.EaterofSouls) < 3 && NPC.CountNPCS(NPCID.DevourerHead) < 1) + { + if (Main.rand.NextBool(60) && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); + NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, NPCID.EaterofSouls); + } - if (Main.rand.NextBool(150) && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); - NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, NPCID.DevourerHead); - } - } - } + if (Main.rand.NextBool(150) && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 spawnAt = npc.Center + new Vector2(0f, npc.height / 2f); + NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, NPCID.DevourerHead); + } + } + } if (npc.life <= 0) { @@ -1067,17 +1067,17 @@ namespace CalamityMod.NPCs.HiveMind public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedHiveMind); - CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Dryad }, CalamityWorld.downedHiveMind); + CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Dryad }, CalamityWorld.downedHiveMind); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) { // Materials DropHelper.DropItemSpray(npc, ModContent.ItemType(), 25, 30, 5); @@ -1097,11 +1097,11 @@ namespace CalamityMod.NPCs.HiveMind DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w, 30, 50), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); diff --git a/NPCs/Leviathan/AquaticAberration.cs b/NPCs/Leviathan/AquaticAberration.cs index 1bf6ecdec6..efc5eb654e 100644 --- a/NPCs/Leviathan/AquaticAberration.cs +++ b/NPCs/Leviathan/AquaticAberration.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Leviathan { - public class AquaticAberration : ModNPC + public class AquaticAberration : ModNPC { public override void SetStaticDefaults() { @@ -19,10 +19,10 @@ namespace CalamityMod.NPCs.Leviathan public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.aiStyle = -1; - npc.GetNPCDamage(); - npc.width = 50; + npc.Calamity().canBreakPlayerDefense = true; + npc.aiStyle = -1; + npc.GetNPCDamage(); + npc.width = 50; npc.height = 50; npc.defense = 14; npc.lifeMax = 800; @@ -39,11 +39,11 @@ namespace CalamityMod.NPCs.Leviathan npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void FindFrame(int frameHeight) { @@ -55,19 +55,19 @@ namespace CalamityMod.NPCs.Leviathan public override void AI() { - if (CalamityGlobalNPC.leviathan < 0 || !Main.npc[CalamityGlobalNPC.leviathan].active) - { - npc.active = false; - npc.netUpdate = true; - return; - } + if (CalamityGlobalNPC.leviathan < 0 || !Main.npc[CalamityGlobalNPC.leviathan].active) + { + npc.active = false; + npc.netUpdate = true; + return; + } - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - npc.TargetClosest(false); + npc.TargetClosest(false); npc.rotation = npc.velocity.ToRotation(); if (Math.Sign(npc.velocity.X) != 0) @@ -78,35 +78,35 @@ namespace CalamityMod.NPCs.Leviathan npc.rotation -= MathHelper.Pi; npc.spriteDirection = Math.Sign(npc.velocity.X); - // Percent life remaining - float lifeRatio = Main.npc[CalamityGlobalNPC.leviathan].life / (float)Main.npc[CalamityGlobalNPC.leviathan].lifeMax; + // Percent life remaining + float lifeRatio = Main.npc[CalamityGlobalNPC.leviathan].life / (float)Main.npc[CalamityGlobalNPC.leviathan].lifeMax; - // Phases - bool leviathanInPhase4 = lifeRatio < 0.2f; + // Phases + bool leviathanInPhase4 = lifeRatio < 0.2f; - bool sirenAlive = false; - if (CalamityGlobalNPC.siren != -1) - sirenAlive = Main.npc[CalamityGlobalNPC.siren].active; + bool sirenAlive = false; + if (CalamityGlobalNPC.siren != -1) + sirenAlive = Main.npc[CalamityGlobalNPC.siren].active; - if (CalamityGlobalNPC.siren != -1) - { - if (Main.npc[CalamityGlobalNPC.siren].active) - { - if (Main.npc[CalamityGlobalNPC.siren].damage == 0) - sirenAlive = false; - } - } + if (CalamityGlobalNPC.siren != -1) + { + if (Main.npc[CalamityGlobalNPC.siren].active) + { + if (Main.npc[CalamityGlobalNPC.siren].damage == 0) + sirenAlive = false; + } + } - float inertia = malice ? 24f : death ? 26f : revenge ? 27f : expertMode ? 28f : 30f; - if (!sirenAlive || leviathanInPhase4) - inertia *= 0.75f; + float inertia = malice ? 24f : death ? 26f : revenge ? 27f : expertMode ? 28f : 30f; + if (!sirenAlive || leviathanInPhase4) + inertia *= 0.75f; float num1006 = 0.111111117f * inertia; if (npc.ai[0] == 0f) { float scaleFactor6 = malice ? 14f : death ? 12f : revenge ? 11f : expertMode ? 10f : 8f; - if (!sirenAlive || leviathanInPhase4) - scaleFactor6 *= 1.25f; + if (!sirenAlive || leviathanInPhase4) + scaleFactor6 *= 1.25f; Vector2 center4 = npc.Center; Vector2 center5 = Main.player[npc.target].Center; @@ -165,11 +165,11 @@ namespace CalamityMod.NPCs.Leviathan else if (npc.ai[0] == 2f) { npc.ai[1] += 1f; - bool flag65 = npc.Center.Y + 50f > Main.player[npc.target].Center.Y; - if ((npc.ai[1] >= 90f && flag65) || npc.velocity.Length() < ((!sirenAlive || leviathanInPhase4) ? 10f : 8f)) + bool flag65 = npc.Center.Y + 50f > Main.player[npc.target].Center.Y; + if ((npc.ai[1] >= 90f && flag65) || npc.velocity.Length() < ((!sirenAlive || leviathanInPhase4) ? 10f : 8f)) { - npc.ai[0] = 3f; - npc.ai[1] = 45f; + npc.ai[0] = 3f; + npc.ai[1] = 45f; npc.ai[2] = 0f; npc.ai[3] = 0f; npc.velocity /= 2f; @@ -227,28 +227,28 @@ namespace CalamityMod.NPCs.Leviathan } } - public override bool PreNPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override bool PreNPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - return false; - } + return false; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur || (!NPC.downedPlantBoss && !CalamityWorld.downedCalamitas)) - { - return 0f; - } - return SpawnCondition.OceanMonster.Chance * 0.02f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur || (!NPC.downedPlantBoss && !CalamityWorld.downedCalamitas)) + { + return 0f; + } + return SpawnCondition.OceanMonster.Chance * 0.02f; + } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Bleeding, 120, true); } diff --git a/NPCs/Leviathan/LevSky.cs b/NPCs/Leviathan/LevSky.cs index 60f6000283..cd5a84f2de 100644 --- a/NPCs/Leviathan/LevSky.cs +++ b/NPCs/Leviathan/LevSky.cs @@ -34,12 +34,12 @@ namespace CalamityMod.NPCs.Leviathan x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[LevIndex].Center); } - float spawnAnimationTimer = 180f; - float intensityScalar = 1f; - if (Main.npc[LevIndex].Calamity().newAI[3] < spawnAnimationTimer) - intensityScalar = MathHelper.Lerp(0f, intensityScalar, Main.npc[LevIndex].Calamity().newAI[3] / spawnAnimationTimer); + float spawnAnimationTimer = 180f; + float intensityScalar = 1f; + if (Main.npc[LevIndex].Calamity().newAI[3] < spawnAnimationTimer) + intensityScalar = MathHelper.Lerp(0f, intensityScalar, Main.npc[LevIndex].Calamity().newAI[3] / spawnAnimationTimer); - return (1f - Utils.SmoothStep(3000f, 6000f, x)) * intensityScalar; + return (1f - Utils.SmoothStep(3000f, 6000f, x)) * intensityScalar; } return 0f; } diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index 89b61581aa..e227cee4a8 100644 --- a/NPCs/Leviathan/Leviathan.cs +++ b/NPCs/Leviathan/Leviathan.cs @@ -26,10 +26,10 @@ namespace CalamityMod.NPCs.Leviathan [AutoloadBossHead] public class Leviathan : ModNPC { - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private int counter = 0; + private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + private int counter = 0; private bool initialised = false; - private int soundDelay = 0; + private int soundDelay = 0; public static Texture2D AttackTexture = null; public override void SetStaticDefaults() @@ -42,21 +42,21 @@ namespace CalamityMod.NPCs.Leviathan public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 20f; - npc.GetNPCDamage(); - npc.width = 900; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 20f; + npc.GetNPCDamage(); + npc.width = 900; npc.height = 450; npc.defense = 40; - npc.DR_NERD(0.35f); + npc.DR_NERD(0.35f); npc.LifeMaxNERB(60500, 72560, 600000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; npc.aiStyle = -1; aiType = -1; - npc.Opacity = 0f; - npc.value = Item.buyPrice(0, 60, 0, 0); + npc.Opacity = 0f; + npc.value = Item.buyPrice(0, 60, 0, 0); npc.HitSound = SoundID.NPCHit56; npc.DeathSound = SoundID.NPCDeath60; npc.noTileCollide = true; @@ -65,142 +65,142 @@ namespace CalamityMod.NPCs.Leviathan npc.netAlways = true; music = CalamityMod.Instance.GetMusicFromMusicMod("LeviathanAndAnahita") ?? MusicID.Boss3; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); - writer.Write(npc.dontTakeDamage); + writer.Write(biomeEnrageTimer); + writer.Write(npc.dontTakeDamage); writer.Write(soundDelay); writer.Write(npc.Calamity().newAI[3]); } public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); + biomeEnrageTimer = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); soundDelay = reader.ReadInt32(); npc.Calamity().newAI[3] = reader.ReadSingle(); } public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); CalamityGlobalNPC.leviathan = npc.whoAmI; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; Vector2 vector = npc.Center; - // Is in spawning animation - float spawnAnimationTime = 180f; - bool spawnAnimation = calamityGlobalNPC.newAI[3] < spawnAnimationTime; + // Is in spawning animation + float spawnAnimationTime = 180f; + bool spawnAnimation = calamityGlobalNPC.newAI[3] < spawnAnimationTime; - // Don't do damage during spawn animation - npc.damage = npc.defDamage; - if (spawnAnimation) - npc.damage = 0; + // Don't do damage during spawn animation + npc.damage = npc.defDamage; + if (spawnAnimation) + npc.damage = 0; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Phases - bool phase2 = (lifeRatio < 0.7f || death) && expertMode; - bool phase3 = lifeRatio < (death ? 0.7f : 0.4f); - bool phase4 = lifeRatio < (death ? 0.4f : 0.2f); + // Phases + bool phase2 = (lifeRatio < 0.7f || death) && expertMode; + bool phase3 = lifeRatio < (death ? 0.7f : 0.4f); + bool phase4 = lifeRatio < (death ? 0.4f : 0.2f); bool sirenAlive = false; if (CalamityGlobalNPC.siren != -1) sirenAlive = Main.npc[CalamityGlobalNPC.siren].active; - if (CalamityGlobalNPC.siren != -1) - { - if (Main.npc[CalamityGlobalNPC.siren].active) - { - if (Main.npc[CalamityGlobalNPC.siren].damage == 0) - sirenAlive = false; - } - } + if (CalamityGlobalNPC.siren != -1) + { + if (Main.npc[CalamityGlobalNPC.siren].active) + { + if (Main.npc[CalamityGlobalNPC.siren].damage == 0) + sirenAlive = false; + } + } - int soundChoiceRage = 92; - int soundChoice = Utils.SelectRandom(Main.rand, new int[] - { - 38, - 39, - 40 - }); + int soundChoiceRage = 92; + int soundChoice = Utils.SelectRandom(Main.rand, new int[] + { + 38, + 39, + 40 + }); - if (soundDelay > 0) - soundDelay--; + if (soundDelay > 0) + soundDelay--; if (Main.rand.NextBool(600) && !spawnAnimation) Main.PlaySound(SoundID.Zombie, (int)vector.X, (int)vector.Y, (sirenAlive && !death) ? soundChoice : soundChoiceRage); - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; bool notOcean = player.position.Y < 800f || player.position.Y > Main.worldSurface * 16.0 || (player.position.X > 6400f && player.position.X < (Main.maxTilesX * 16 - 6400)); - // Enrage - if (notOcean && !BossRushEvent.BossRushActive) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + // Enrage + if (notOcean && !BossRushEvent.BossRushActive) + { + if (biomeEnrageTimer > 0) + biomeEnrageTimer--; + } + else + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || malice; + bool biomeEnraged = biomeEnrageTimer <= 0 || malice; - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; if (biomeEnraged) { npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 2f; } - npc.dontTakeDamage = spawnAnimation; + npc.dontTakeDamage = spawnAnimation; - // Adjust slowing debuff immunity - bool immuneToSlowingDebuffs = npc.ai[0] == 2f; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = npc.ai[0] == 2f; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; - if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) + if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) { npc.TargetClosest(false); player = Main.player[npc.target]; if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) { - if (npc.velocity.Y < -3f) - npc.velocity.Y = -3f; - npc.velocity.Y += 0.2f; - if (npc.velocity.Y > 16f) - npc.velocity.Y = 16f; + if (npc.velocity.Y < -3f) + npc.velocity.Y = -3f; + npc.velocity.Y += 0.2f; + if (npc.velocity.Y > 16f) + npc.velocity.Y = 16f; - if (npc.position.Y > Main.worldSurface * 16.0) + if (npc.position.Y > Main.worldSurface * 16.0) { for (int x = 0; x < Main.maxNPCs; x++) { @@ -214,49 +214,49 @@ namespace CalamityMod.NPCs.Leviathan npc.netUpdate = true; } - if (npc.ai[0] != 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } + if (npc.ai[0] != 0f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.netUpdate = true; + } - return; + return; } } else { - // Slowly drift up when spawning - if (spawnAnimation) - { - float minSpawnVelocity = 0.4f; - float maxSpawnVelocity = 4f; - float velocityY = maxSpawnVelocity - MathHelper.Lerp(minSpawnVelocity, maxSpawnVelocity, calamityGlobalNPC.newAI[3] / spawnAnimationTime); - npc.velocity = new Vector2(0f, -velocityY); + // Slowly drift up when spawning + if (spawnAnimation) + { + float minSpawnVelocity = 0.4f; + float maxSpawnVelocity = 4f; + float velocityY = maxSpawnVelocity - MathHelper.Lerp(minSpawnVelocity, maxSpawnVelocity, calamityGlobalNPC.newAI[3] / spawnAnimationTime); + npc.velocity = new Vector2(0f, -velocityY); - if (calamityGlobalNPC.newAI[3] == 10f) - Main.PlaySound(SoundID.Zombie, (int)vector.X, (int)vector.Y, soundChoiceRage); + if (calamityGlobalNPC.newAI[3] == 10f) + Main.PlaySound(SoundID.Zombie, (int)vector.X, (int)vector.Y, soundChoiceRage); - npc.Opacity = MathHelper.Clamp(calamityGlobalNPC.newAI[3] / spawnAnimationTime, 0f, 1f); + npc.Opacity = MathHelper.Clamp(calamityGlobalNPC.newAI[3] / spawnAnimationTime, 0f, 1f); - calamityGlobalNPC.newAI[3] += 1f; + calamityGlobalNPC.newAI[3] += 1f; - return; - } + return; + } - if (npc.ai[0] == 0f) + if (npc.ai[0] == 0f) { float num412 = (sirenAlive && !phase4) ? 3.5f : 7f; float num413 = (sirenAlive && !phase4) ? 0.1f : 0.2f; - num412 += 2f * enrageScale; - num413 += 0.05f * enrageScale; + num412 += 2f * enrageScale; + num413 += 0.05f * enrageScale; - if (expertMode && (!sirenAlive || phase4)) - { - num412 += death ? 6f * (1f - lifeRatio) : 3.5f * (1f - lifeRatio); - num413 += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); - } + if (expertMode && (!sirenAlive || phase4)) + { + num412 += death ? 6f * (1f - lifeRatio) : 3.5f * (1f - lifeRatio); + num413 += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); + } int num414 = 1; if (vector.X < player.position.X + player.width) @@ -296,21 +296,21 @@ namespace CalamityMod.NPCs.Leviathan npc.velocity.Y -= num413; } - float playerLocation = vector.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = vector.X - player.Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; - npc.ai[1] += 1f; - float phaseTimer = 240f; - if (!sirenAlive || phase4) - phaseTimer -= 120f * (1f - lifeRatio); + npc.ai[1] += 1f; + float phaseTimer = 240f; + if (!sirenAlive || phase4) + phaseTimer -= 120f * (1f - lifeRatio); - if (npc.ai[1] >= phaseTimer) + if (npc.ai[1] >= phaseTimer) { npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); + npc.TargetClosest(); npc.netUpdate = true; } else @@ -333,15 +333,15 @@ namespace CalamityMod.NPCs.Leviathan { float speed = (sirenAlive && !phase4 && !death) ? 13.5f : 16f; int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + int damage = npc.GetProjectileDamage(type); - if (expertMode) + if (expertMode) speed = (sirenAlive && !phase4 && !death) ? 14f : 17f; - speed += 2f * enrageScale; + speed += 2f * enrageScale; - if (!sirenAlive || phase4) - speed += 3f * (1f - lifeRatio); + if (!sirenAlive || phase4) + speed += 3f * (1f - lifeRatio); num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); num417 = speed / num417; @@ -350,11 +350,11 @@ namespace CalamityMod.NPCs.Leviathan vector40.X += num415 * 4f; vector40.Y += num416 * 4f; Projectile.NewProjectile(vector40.X, vector40.Y, num415, num416, type, damage, 0f, Main.myPlayer); - if (soundDelay <= 0) - { - soundDelay = 120; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LeviathanRoarMeteor"), vector); - } + if (soundDelay <= 0) + { + soundDelay = 120; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LeviathanRoarMeteor"), vector); + } } } } @@ -368,38 +368,38 @@ namespace CalamityMod.NPCs.Leviathan float num1060 = (float)Math.Sqrt(num1058 * num1058 + num1059 * num1059); npc.ai[1] += 1f; - int num638 = 0; - for (int num639 = 0; num639 < Main.maxPlayers; num639++) - { - if (Main.player[num639].active && !Main.player[num639].dead && (vector - Main.player[num639].Center).Length() < 1000f) - num638++; - } - npc.ai[1] += num638 / 2; + int num638 = 0; + for (int num639 = 0; num639 < Main.maxPlayers; num639++) + { + if (Main.player[num639].active && !Main.player[num639].dead && (vector - Main.player[num639].Center).Length() < 1000f) + num638++; + } + npc.ai[1] += num638 / 2; bool flag103 = false; - float num640 = (!sirenAlive || phase4) ? 30f : 60f; - if (npc.ai[1] > num640) + float num640 = (!sirenAlive || phase4) ? 30f : 60f; + if (npc.ai[1] > num640) { npc.ai[1] = 0f; npc.ai[2] += 1f; flag103 = true; } - int spawnLimit = (sirenAlive && !phase4) ? 2 : (death ? 3 : 4); - if (flag103 && NPC.CountNPCS(ModContent.NPCType()) < spawnLimit) + int spawnLimit = (sirenAlive && !phase4) ? 2 : (death ? 3 : 4); + if (flag103 && NPC.CountNPCS(ModContent.NPCType()) < spawnLimit) { Main.PlaySound(SoundID.Zombie, (int)vector.X, (int)vector.Y, soundChoice); if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.NewNPC((int)vector119.X, (int)vector119.Y, ModContent.NPCType()); + NPC.NewNPC((int)vector119.X, (int)vector119.Y, ModContent.NPCType()); } if (num1060 > ((sirenAlive && !phase4) ? 1000f : 800f)) { float num1064 = (sirenAlive && !phase4) ? 0.05f : 0.065f; - num1064 += 0.04f * enrageScale; + num1064 += 0.04f * enrageScale; - if (expertMode && (!sirenAlive || phase4)) - num1064 += death ? 0.05f * (1f - lifeRatio) : 0.03f * (1f - lifeRatio); + if (expertMode && (!sirenAlive || phase4)) + num1064 += death ? 0.05f * (1f - lifeRatio) : 0.03f * (1f - lifeRatio); vector120 = vector119; num1058 = player.Center.X - vector120.X; @@ -433,39 +433,39 @@ namespace CalamityMod.NPCs.Leviathan else npc.velocity *= 0.9f; - float playerLocation = vector.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = vector.X - player.Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; - if (npc.ai[2] > ((sirenAlive && !phase4) ? 2f : 4f)) + if (npc.ai[2] > ((sirenAlive && !phase4) ? 2f : 4f)) { npc.ai[0] = (((phase2 || phase3) && !sirenAlive) || phase4 || death) ? 2f : 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); + npc.TargetClosest(); npc.netUpdate = true; } } else if (npc.ai[0] == 2f) { Vector2 distFromPlayer = player.Center - vector; - float chargeAmt = death ? (phase4 ? 3f : phase3 ? 2f : 1f) : 1f; + float chargeAmt = death ? (phase4 ? 3f : phase3 ? 2f : 1f) : 1f; if (npc.ai[1] >= chargeAmt * 2f || distFromPlayer.Length() > 2400f) { npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); + npc.TargetClosest(); npc.netUpdate = true; return; } - float chargeDistance = (sirenAlive && !phase4) ? 1100f : 900f; - chargeDistance -= 50f * enrageScale; - if (!sirenAlive || phase4) - chargeDistance -= 250f * (1f - lifeRatio); + float chargeDistance = (sirenAlive && !phase4) ? 1100f : 900f; + chargeDistance -= 50f * enrageScale; + if (!sirenAlive || phase4) + chargeDistance -= 250f * (1f - lifeRatio); - if (npc.ai[1] % 2f == 0f) + if (npc.ai[1] % 2f == 0f) { int num24 = 7; for (int j = 0; j < num24; j++) @@ -485,10 +485,10 @@ namespace CalamityMod.NPCs.Leviathan npc.ai[2] = 0f; float num1044 = revenge ? 20f : 18f; - num1044 += 2f * enrageScale; + num1044 += 2f * enrageScale; - if (revenge && (!sirenAlive || phase4)) - num1044 += death ? 9f * (1f - lifeRatio) : 6f * (1f - lifeRatio); + if (revenge && (!sirenAlive || phase4)) + num1044 += death ? 9f * (1f - lifeRatio) : 6f * (1f - lifeRatio); Vector2 vector117 = vector; float num1045 = player.Center.X - vector117.X; @@ -498,25 +498,25 @@ namespace CalamityMod.NPCs.Leviathan npc.velocity.X = num1045 * num1047; npc.velocity.Y = num1046 * num1047; - float playerLocation = vector.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = vector.X - player.Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LeviathanRoarCharge"), vector); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LeviathanRoarCharge"), vector); return; } float num1048 = revenge ? 7.5f : 6.5f; float num1049 = revenge ? 0.12f : 0.11f; - num1048 += 2f * enrageScale; - num1049 += 0.04f * enrageScale; + num1048 += 2f * enrageScale; + num1049 += 0.04f * enrageScale; - if (revenge && (!sirenAlive || phase4)) - { - num1048 += death ? 9f * (1f - lifeRatio) : 6f * (1f - lifeRatio); - num1049 += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); - } + if (revenge && (!sirenAlive || phase4)) + { + num1048 += death ? 9f * (1f - lifeRatio) : 6f * (1f - lifeRatio); + num1049 += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); + } if (vector.Y < player.Center.Y) npc.velocity.Y += num1049; @@ -540,10 +540,10 @@ namespace CalamityMod.NPCs.Leviathan if (npc.velocity.X > num1048) npc.velocity.X = num1048; - float playerLocation2 = vector.X - player.Center.X; - npc.direction = playerLocation2 < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; - } + float playerLocation2 = vector.X - player.Center.X; + npc.direction = playerLocation2 < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; + } else { if (npc.velocity.X < 0f) @@ -562,99 +562,99 @@ namespace CalamityMod.NPCs.Leviathan if (npc.ai[2] != 1f) return; - float playerLocation = vector.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = vector.X - player.Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; - npc.velocity *= 0.9f; + npc.velocity *= 0.9f; float num1052 = revenge ? 0.11f : 0.1f; - num1052 += 0.02f * enrageScale; + num1052 += 0.02f * enrageScale; - if (revenge && (!sirenAlive || phase4)) - { - npc.velocity *= death ? MathHelper.Lerp(0.75f, 1f, lifeRatio) : MathHelper.Lerp(0.81f, 1f, lifeRatio); - num1052 += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); - } + if (revenge && (!sirenAlive || phase4)) + { + npc.velocity *= death ? MathHelper.Lerp(0.75f, 1f, lifeRatio) : MathHelper.Lerp(0.81f, 1f, lifeRatio); + num1052 += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); + } if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < num1052) { npc.ai[2] = 0f; npc.ai[1] += 1f; - npc.TargetClosest(); + npc.TargetClosest(); } } } } } - // Can only hit the target if within certain distance. - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - Vector2 npcCenter = npc.Center; + // Can only hit the target if within certain distance. + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Vector2 npcCenter = npc.Center; - // NOTE: Tail and mouth hitboxes are interchangeable, each hitbox is the same size and is located to the right or left of the body hitbox. - // Width = 225, Height = 225 - Rectangle mouthHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 2f)), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); - // Width = 450, Height = 450 - Rectangle bodyHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 4f)), (int)(npcCenter.Y - (npc.height / 2f)), npc.width / 2, npc.height); - // Width = 225, Height = 225 - Rectangle tailHitbox = new Rectangle((int)(npcCenter.X + (npc.width / 4f)), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); + // NOTE: Tail and mouth hitboxes are interchangeable, each hitbox is the same size and is located to the right or left of the body hitbox. + // Width = 225, Height = 225 + Rectangle mouthHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 2f)), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); + // Width = 450, Height = 450 + Rectangle bodyHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 4f)), (int)(npcCenter.Y - (npc.height / 2f)), npc.width / 2, npc.height); + // Width = 225, Height = 225 + Rectangle tailHitbox = new Rectangle((int)(npcCenter.X + (npc.width / 4f)), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); - Vector2 mouthHitboxCenter = new Vector2(mouthHitbox.X + (mouthHitbox.Width / 2), mouthHitbox.Y + (mouthHitbox.Height / 2)); - Vector2 bodyHitboxCenter = new Vector2(bodyHitbox.X + (bodyHitbox.Width / 2), bodyHitbox.Y + (bodyHitbox.Height / 2)); - Vector2 tailHitboxCenter = new Vector2(tailHitbox.X + (tailHitbox.Width / 2), tailHitbox.Y + (tailHitbox.Height / 2)); + Vector2 mouthHitboxCenter = new Vector2(mouthHitbox.X + (mouthHitbox.Width / 2), mouthHitbox.Y + (mouthHitbox.Height / 2)); + Vector2 bodyHitboxCenter = new Vector2(bodyHitbox.X + (bodyHitbox.Width / 2), bodyHitbox.Y + (bodyHitbox.Height / 2)); + Vector2 tailHitboxCenter = new Vector2(tailHitbox.X + (tailHitbox.Width / 2), tailHitbox.Y + (tailHitbox.Height / 2)); - Rectangle targetHitbox = target.Hitbox; + Rectangle targetHitbox = target.Hitbox; - float mouthDist1 = Vector2.Distance(mouthHitboxCenter, targetHitbox.TopLeft()); - float mouthDist2 = Vector2.Distance(mouthHitboxCenter, targetHitbox.TopRight()); - float mouthDist3 = Vector2.Distance(mouthHitboxCenter, targetHitbox.BottomLeft()); - float mouthDist4 = Vector2.Distance(mouthHitboxCenter, targetHitbox.BottomRight()); + float mouthDist1 = Vector2.Distance(mouthHitboxCenter, targetHitbox.TopLeft()); + float mouthDist2 = Vector2.Distance(mouthHitboxCenter, targetHitbox.TopRight()); + float mouthDist3 = Vector2.Distance(mouthHitboxCenter, targetHitbox.BottomLeft()); + float mouthDist4 = Vector2.Distance(mouthHitboxCenter, targetHitbox.BottomRight()); - float minMouthDist = mouthDist1; - if (mouthDist2 < minMouthDist) - minMouthDist = mouthDist2; - if (mouthDist3 < minMouthDist) - minMouthDist = mouthDist3; - if (mouthDist4 < minMouthDist) - minMouthDist = mouthDist4; + float minMouthDist = mouthDist1; + if (mouthDist2 < minMouthDist) + minMouthDist = mouthDist2; + if (mouthDist3 < minMouthDist) + minMouthDist = mouthDist3; + if (mouthDist4 < minMouthDist) + minMouthDist = mouthDist4; - bool insideMouthHitbox = minMouthDist <= 115f; + bool insideMouthHitbox = minMouthDist <= 115f; - float bodyDist1 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopLeft()); - float bodyDist2 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopRight()); - float bodyDist3 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomLeft()); - float bodyDist4 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomRight()); + float bodyDist1 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopLeft()); + float bodyDist2 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopRight()); + float bodyDist3 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomLeft()); + float bodyDist4 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomRight()); - float minBodyDist = bodyDist1; - if (bodyDist2 < minBodyDist) - minBodyDist = bodyDist2; - if (bodyDist3 < minBodyDist) - minBodyDist = bodyDist3; - if (bodyDist4 < minBodyDist) - minBodyDist = bodyDist4; + float minBodyDist = bodyDist1; + if (bodyDist2 < minBodyDist) + minBodyDist = bodyDist2; + if (bodyDist3 < minBodyDist) + minBodyDist = bodyDist3; + if (bodyDist4 < minBodyDist) + minBodyDist = bodyDist4; - bool insideBodyHitbox = minBodyDist <= 230f; + bool insideBodyHitbox = minBodyDist <= 230f; - float tailDist1 = Vector2.Distance(tailHitboxCenter, targetHitbox.TopLeft()); - float tailDist2 = Vector2.Distance(tailHitboxCenter, targetHitbox.TopRight()); - float tailDist3 = Vector2.Distance(tailHitboxCenter, targetHitbox.BottomLeft()); - float tailDist4 = Vector2.Distance(tailHitboxCenter, targetHitbox.BottomRight()); + float tailDist1 = Vector2.Distance(tailHitboxCenter, targetHitbox.TopLeft()); + float tailDist2 = Vector2.Distance(tailHitboxCenter, targetHitbox.TopRight()); + float tailDist3 = Vector2.Distance(tailHitboxCenter, targetHitbox.BottomLeft()); + float tailDist4 = Vector2.Distance(tailHitboxCenter, targetHitbox.BottomRight()); - float minTailDist = tailDist1; - if (tailDist2 < minTailDist) - minTailDist = tailDist2; - if (tailDist3 < minTailDist) - minTailDist = tailDist3; - if (tailDist4 < minTailDist) - minTailDist = tailDist4; + float minTailDist = tailDist1; + if (tailDist2 < minTailDist) + minTailDist = tailDist2; + if (tailDist3 < minTailDist) + minTailDist = tailDist3; + if (tailDist4 < minTailDist) + minTailDist = tailDist4; - bool insideTailHitbox = minTailDist <= 115f; + bool insideTailHitbox = minTailDist <= 115f; - return insideMouthHitbox || insideBodyHitbox || insideTailHitbox; - } + return insideMouthHitbox || insideBodyHitbox || insideTailHitbox; + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { @@ -700,7 +700,7 @@ namespace CalamityMod.NPCs.Leviathan // The Leviathan runs the same loot code as Anahita, but only if she dies last. public override void NPCLoot() { - //Trophy dropped regardless of Anahita, precedent of Twins + //Trophy dropped regardless of Anahita, precedent of Twins DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); if (!NPC.AnyNPCs(ModContent.NPCType())) @@ -710,11 +710,11 @@ namespace CalamityMod.NPCs.Leviathan // This loot code is shared with Anahita. public static void DropSirenLeviLoot(NPC npc) { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedLeviathan); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedLeviathan); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedLeviathan); // All other drops are contained in the bag, so they only drop directly on Normal @@ -730,11 +730,11 @@ namespace CalamityMod.NPCs.Leviathan DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); @@ -769,27 +769,27 @@ namespace CalamityMod.NPCs.Leviathan public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { Texture2D texture = AttackTexture; - if (npc.ai[0] == 1f || npc.Calamity().newAI[3] < 180f) + if (npc.ai[0] == 1f || npc.Calamity().newAI[3] < 180f) { - texture = Main.npcTexture[npc.type]; + texture = Main.npcTexture[npc.type]; } - SpriteEffects spriteEffects = SpriteEffects.FlipHorizontally; - float xOffset = -50f; - if (npc.spriteDirection == -1) - { - spriteEffects = SpriteEffects.None; - xOffset *= -1f; - } - Rectangle rectangle = new Rectangle(npc.frame.X, npc.frame.Y, texture.Width / 2, texture.Height / 3); - Vector2 origin = rectangle.Size() / 2f; - spriteBatch.Draw(texture, npc.Center - Main.screenPosition + new Vector2(xOffset, npc.gfxOffY), rectangle, npc.GetAlpha(drawColor), npc.rotation, origin, npc.scale, spriteEffects, 0f); + SpriteEffects spriteEffects = SpriteEffects.FlipHorizontally; + float xOffset = -50f; + if (npc.spriteDirection == -1) + { + spriteEffects = SpriteEffects.None; + xOffset *= -1f; + } + Rectangle rectangle = new Rectangle(npc.frame.X, npc.frame.Y, texture.Width / 2, texture.Height / 3); + Vector2 origin = rectangle.Size() / 2f; + spriteBatch.Draw(texture, npc.Center - Main.screenPosition + new Vector2(xOffset, npc.gfxOffY), rectangle, npc.GetAlpha(drawColor), npc.rotation, origin, npc.scale, spriteEffects, 0f); return false; } public override void FindFrame(int frameHeight) { - int width = 1011; - int height = 486; + int width = 1011; + int height = 486; if (!initialised) { @@ -798,18 +798,18 @@ namespace CalamityMod.NPCs.Leviathan initialised = true; } - npc.frameCounter += 1D; - if (npc.frameCounter >= 8D) - { - npc.frameCounter = 0D; - counter++; - npc.frame.X = counter >= 3 ? width + 3 : 0; + npc.frameCounter += 1D; + if (npc.frameCounter >= 8D) + { + npc.frameCounter = 0D; + counter++; + npc.frame.X = counter >= 3 ? width + 3 : 0; - if (counter == 3) - npc.frame.Y = 0; - else - npc.frame.Y += height; - } + if (counter == 3) + npc.frame.Y = 0; + else + npc.frame.Y += height; + } if (counter == 6) { diff --git a/NPCs/Leviathan/LeviathanStart.cs b/NPCs/Leviathan/LeviathanStart.cs index 0e282244ef..3168ee25c2 100644 --- a/NPCs/Leviathan/LeviathanStart.cs +++ b/NPCs/Leviathan/LeviathanStart.cs @@ -27,31 +27,31 @@ namespace CalamityMod.NPCs.Leviathan npc.defense = 0; npc.lifeMax = 1000; npc.knockBackResist = 0f; - npc.Opacity = 0f; + npc.Opacity = 0f; npc.noGravity = true; - npc.dontTakeDamage = true; + npc.dontTakeDamage = true; npc.chaseable = false; npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = null; - npc.rarity = 2; + npc.DeathSound = null; + npc.rarity = 2; music = CalamityMod.Instance.GetMusicFromMusicMod("AnahitaPreboss") ?? -1; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.dontTakeDamage); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.dontTakeDamage); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.dontTakeDamage = reader.ReadBoolean(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.dontTakeDamage = reader.ReadBoolean(); + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.1f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -63,50 +63,50 @@ namespace CalamityMod.NPCs.Leviathan { npc.TargetClosest(true); - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0f ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; + npc.direction = playerLocation < 0f ? 1 : -1; + npc.spriteDirection = npc.direction; - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 560f) - { - if (npc.ai[0] < 90f) - npc.ai[0] += 1f; - } - else if (npc.ai[0] > 0f) - npc.ai[0] -= 1f; + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 560f) + { + if (npc.ai[0] < 90f) + npc.ai[0] += 1f; + } + else if (npc.ai[0] > 0f) + npc.ai[0] -= 1f; - npc.dontTakeDamage = npc.ai[0] != 90f; + npc.dontTakeDamage = npc.ai[0] != 90f; - npc.Opacity = MathHelper.Clamp(npc.ai[0] / 90f, 0f, 1f); + npc.Opacity = MathHelper.Clamp(npc.ai[0] / 90f, 0f, 1f); - Lighting.AddLight((int)npc.Center.X / 16, (int)npc.Center.Y / 16, 0f, 0f, 0.8f * npc.Opacity); + Lighting.AddLight((int)npc.Center.X / 16, (int)npc.Center.Y / 16, 0f, 0f, 0.8f * npc.Opacity); if (CalamityPlayer.areThereAnyDamnBosses) npc.active = false; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D drawTex = Main.npcTexture[npc.type]; - Vector2 origin = new Vector2(drawTex.Width / 2, drawTex.Height / 2); + Texture2D drawTex = Main.npcTexture[npc.type]; + Vector2 origin = new Vector2(drawTex.Width / 2, drawTex.Height / 2); - Vector2 drawPos = npc.Center - Main.screenPosition; - drawPos -= new Vector2(drawTex.Width, drawTex.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - drawPos += origin * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(drawTex, drawPos, npc.frame, npc.GetAlpha(lightColor), npc.rotation, origin, npc.scale, spriteEffects, 0f); + Vector2 drawPos = npc.Center - Main.screenPosition; + drawPos -= new Vector2(drawTex.Width, drawTex.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + drawPos += origin * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(drawTex, drawPos, npc.frame, npc.GetAlpha(lightColor), npc.rotation, origin, npc.scale, spriteEffects, 0f); - drawTex = ModContent.GetTexture("CalamityMod/NPCs/Leviathan/LeviathanStartGlow"); + drawTex = ModContent.GetTexture("CalamityMod/NPCs/Leviathan/LeviathanStartGlow"); - spriteBatch.Draw(drawTex, drawPos, npc.frame, Color.White, npc.rotation, origin, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(drawTex, drawPos, npc.frame, Color.White, npc.rotation, origin, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (spawnInfo.player.Calamity().disableAnahitaSpawns) return 0f; @@ -117,7 +117,7 @@ namespace CalamityMod.NPCs.Leviathan NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || spawnInfo.player.Calamity().ZoneSulphur || - NPC.LunarApocalypseIsUp) + NPC.LunarApocalypseIsUp) { return 0f; } @@ -138,18 +138,18 @@ namespace CalamityMod.NPCs.Leviathan public override void HitEffect(int hitDirection, double damage) { - if (npc.life > 0) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } - } - else if (Main.netMode != NetmodeID.MultiplayerClient) - { - int siren = NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI); - CalamityUtils.BossAwakenMessage(siren); - } + if (npc.life > 0) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); + } + } + else if (Main.netMode != NetmodeID.MultiplayerClient) + { + int siren = NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI); + CalamityUtils.BossAwakenMessage(siren); + } } } } diff --git a/NPCs/Leviathan/Siren.cs b/NPCs/Leviathan/Siren.cs index b4f9366b58..9f6e6572ec 100644 --- a/NPCs/Leviathan/Siren.cs +++ b/NPCs/Leviathan/Siren.cs @@ -16,23 +16,23 @@ namespace CalamityMod.NPCs.Leviathan [AutoloadBossHead] public class Siren : ModNPC { - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private bool spawnedLevi = false; + private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + private bool spawnedLevi = false; private bool forceChargeFrames = false; private int frameUsed = 0; - public bool HasBegunSummoningLeviathan = false; - public bool WaitingForLeviathan + public bool HasBegunSummoningLeviathan = false; + public bool WaitingForLeviathan { get { - if (Main.npc.IndexInRange(CalamityGlobalNPC.leviathan) && Main.npc[CalamityGlobalNPC.leviathan].life / (float)Main.npc[CalamityGlobalNPC.leviathan].lifeMax >= ((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.7f : 0.4f)) - return true; + if (Main.npc.IndexInRange(CalamityGlobalNPC.leviathan) && Main.npc[CalamityGlobalNPC.leviathan].life / (float)Main.npc[CalamityGlobalNPC.leviathan].lifeMax >= ((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.7f : 0.4f)) + return true; - return CalamityUtils.FindFirstProjectile(ModContent.ProjectileType()) != -1; + return CalamityUtils.FindFirstProjectile(ModContent.ProjectileType()) != -1; } } - //IMPORTANT: Do NOT remove the empty space on the sprites. This is intentional for framing. The sprite is centered and hitbox is fine already. + //IMPORTANT: Do NOT remove the empty space on the sprites. This is intentional for framing. The sprite is centered and hitbox is fine already. public override void SetStaticDefaults() { @@ -42,12 +42,12 @@ namespace CalamityMod.NPCs.Leviathan public override void SetDefaults() { - npc.GetNPCDamage(); - npc.npcSlots = 16f; + npc.GetNPCDamage(); + npc.npcSlots = 16f; npc.width = 100; npc.height = 100; npc.defense = 20; - npc.DR_NERD(0.2f); + npc.DR_NERD(0.2f); npc.LifeMaxNERB(34700, 41600, 260000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -60,251 +60,251 @@ namespace CalamityMod.NPCs.Leviathan npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - music = CalamityMod.Instance.GetMusicFromMusicMod("Anahita") ?? MusicID.Boss3; + music = CalamityMod.Instance.GetMusicFromMusicMod("Anahita") ?? MusicID.Boss3; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); - writer.Write(spawnedLevi); + writer.Write(biomeEnrageTimer); + writer.Write(spawnedLevi); writer.Write(forceChargeFrames); writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[2]); - writer.Write(npc.localAI[3]); - writer.Write(frameUsed); + writer.Write(npc.localAI[2]); + writer.Write(npc.localAI[3]); + writer.Write(frameUsed); writer.Write(npc.dontTakeDamage); - writer.Write(npc.Calamity().newAI[0]); - writer.Write(HasBegunSummoningLeviathan); - } + writer.Write(npc.Calamity().newAI[0]); + writer.Write(HasBegunSummoningLeviathan); + } public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); - spawnedLevi = reader.ReadBoolean(); + biomeEnrageTimer = reader.ReadInt32(); + spawnedLevi = reader.ReadBoolean(); forceChargeFrames = reader.ReadBoolean(); npc.localAI[0] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - frameUsed = reader.ReadInt32(); + npc.localAI[2] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + frameUsed = reader.ReadInt32(); npc.dontTakeDamage = reader.ReadBoolean(); - npc.Calamity().newAI[0] = reader.ReadSingle(); - HasBegunSummoningLeviathan = reader.ReadBoolean(); - } + npc.Calamity().newAI[0] = reader.ReadSingle(); + HasBegunSummoningLeviathan = reader.ReadBoolean(); + } - public override void AI() + public override void AI() { // whoAmI variable CalamityGlobalNPC.siren = npc.whoAmI; - // Set to false so she doesn't do it constantly - npc.Calamity().canBreakPlayerDefense = false; + // Set to false so she doesn't do it constantly + npc.Calamity().canBreakPlayerDefense = false; - // Light - Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0f, 0.5f, 0.3f); + // Light + Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0f, 0.5f, 0.3f); - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - // Check for Leviathan - bool leviAlive = false; - if (CalamityGlobalNPC.leviathan != -1) - leviAlive = Main.npc[CalamityGlobalNPC.leviathan].active; + // Check for Leviathan + bool leviAlive = false; + if (CalamityGlobalNPC.leviathan != -1) + leviAlive = Main.npc[CalamityGlobalNPC.leviathan].active; - // Variables - Player player = Main.player[npc.target]; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + // Variables + Player player = Main.player[npc.target]; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool notOcean = player.position.Y < 800f || player.position.Y > Main.worldSurface * 16.0 || (player.position.X > 6400f && player.position.X < (Main.maxTilesX * 16 - 6400)); + bool notOcean = player.position.Y < 800f || player.position.Y > Main.worldSurface * 16.0 || (player.position.X > 6400f && player.position.X < (Main.maxTilesX * 16 - 6400)); - // Enrage - if (notOcean && !BossRushEvent.BossRushActive) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + // Enrage + if (notOcean && !BossRushEvent.BossRushActive) + { + if (biomeEnrageTimer > 0) + biomeEnrageTimer--; + } + else + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || malice; + bool biomeEnraged = biomeEnrageTimer <= 0 || malice; - float enrageScale = BossRushEvent.BossRushActive ? 0.5f : 0f; - if (biomeEnraged) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1.5f; - } + float enrageScale = BossRushEvent.BossRushActive ? 0.5f : 0f; + if (biomeEnraged) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1.5f; + } - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; - float bubbleVelocity = death ? 9f : revenge ? 7f : expertMode ? 6f : 5f; - bubbleVelocity += 4f * enrageScale; - if (!leviAlive) - bubbleVelocity += 2f * (1f - lifeRatio); + float bubbleVelocity = death ? 9f : revenge ? 7f : expertMode ? 6f : 5f; + bubbleVelocity += 4f * enrageScale; + if (!leviAlive) + bubbleVelocity += 2f * (1f - lifeRatio); - npc.damage = npc.defDamage; + npc.damage = npc.defDamage; - Vector2 vector = npc.Center; + Vector2 vector = npc.Center; - // Phases - bool phase2 = lifeRatio < 0.7f; + // Phases + bool phase2 = lifeRatio < 0.7f; bool phase3 = lifeRatio < 0.4f; - bool phase4 = lifeRatio < (death ? 0.4f : 0.2f); + bool phase4 = lifeRatio < (death ? 0.4f : 0.2f); - // Spawn Leviathan and change music - if (phase3 || death) - { - if (!HasBegunSummoningLeviathan) - { - // Use charging frames. - npc.ai[0] = 3f; + // Spawn Leviathan and change music + if (phase3 || death) + { + if (!HasBegunSummoningLeviathan) + { + // Use charging frames. + npc.ai[0] = 3f; - // Look towards the ocean. - npc.direction = (npc.Center.X < Main.maxTilesX * 8f).ToDirectionInt(); + // Look towards the ocean. + npc.direction = (npc.Center.X < Main.maxTilesX * 8f).ToDirectionInt(); - // Prevent Anahita from leaving the world when doing her dive. - // If she leaves the world entity summons will fail and Levi will simply not spawn. - npc.position.X = MathHelper.Clamp(npc.position.X, 150f, Main.maxTilesX * 16f - 150f); + // Prevent Anahita from leaving the world when doing her dive. + // If she leaves the world entity summons will fail and Levi will simply not spawn. + npc.position.X = MathHelper.Clamp(npc.position.X, 150f, Main.maxTilesX * 16f - 150f); - if (npc.alpha <= 0) - { - float moveDirection = 1f; - if (Math.Abs(npc.Center.X - Main.maxTilesX * 16f) > Math.Abs(npc.Center.X)) - moveDirection = -1f; - npc.velocity.X = moveDirection * 6f; - npc.spriteDirection = (int)-moveDirection; - npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y + 0.2f, -3f, 16f); - } + if (npc.alpha <= 0) + { + float moveDirection = 1f; + if (Math.Abs(npc.Center.X - Main.maxTilesX * 16f) > Math.Abs(npc.Center.X)) + moveDirection = -1f; + npc.velocity.X = moveDirection * 6f; + npc.spriteDirection = (int)-moveDirection; + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y + 0.2f, -3f, 16f); + } - float idealRotation = npc.velocity.ToRotation(); - if (npc.spriteDirection == 1) - idealRotation += MathHelper.Pi; + float idealRotation = npc.velocity.ToRotation(); + if (npc.spriteDirection == 1) + idealRotation += MathHelper.Pi; - npc.rotation = npc.rotation.AngleTowards(idealRotation, 0.08f); + npc.rotation = npc.rotation.AngleTowards(idealRotation, 0.08f); - if (BossRushEvent.BossRushActive || Collision.WetCollision(npc.position, npc.width, npc.height) || npc.position.Y > (Main.worldSurface - 125f) * 16f) - { - int oldAlpha = npc.alpha; - npc.alpha = Utils.Clamp(npc.alpha + 9, 0, 255); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.alpha >= 255 && oldAlpha < 255) - { - Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); - HasBegunSummoningLeviathan = true; - npc.netUpdate = true; - } + if (BossRushEvent.BossRushActive || Collision.WetCollision(npc.position, npc.width, npc.height) || npc.position.Y > (Main.worldSurface - 125f) * 16f) + { + int oldAlpha = npc.alpha; + npc.alpha = Utils.Clamp(npc.alpha + 9, 0, 255); + if (Main.netMode != NetmodeID.MultiplayerClient && npc.alpha >= 255 && oldAlpha < 255) + { + Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); + HasBegunSummoningLeviathan = true; + npc.netUpdate = true; + } - npc.velocity *= 0.9f; - } - npc.dontTakeDamage = true; - return; - } - } + npc.velocity *= 0.9f; + } + npc.dontTakeDamage = true; + return; + } + } - // Change music. - if (leviAlive) - music = CalamityMod.Instance.GetMusicFromMusicMod("LeviathanAndAnahita") ?? MusicID.Boss3; + // Change music. + if (leviAlive) + music = CalamityMod.Instance.GetMusicFromMusicMod("LeviathanAndAnahita") ?? MusicID.Boss3; - // Ice Shield - if (npc.localAI[2] < 3f) - { - if (npc.ai[3] == 0f && npc.localAI[1] == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - int num6 = NPC.NewNPC((int)vector.X, (int)vector.Y, ModContent.NPCType(), npc.whoAmI); - npc.ai[3] = num6 + 1; - npc.localAI[1] = -1f; - npc.localAI[2] += 1f; - npc.netUpdate = true; - Main.npc[num6].ai[0] = npc.whoAmI; - Main.npc[num6].netUpdate = true; - } + // Ice Shield + if (npc.localAI[2] < 3f) + { + if (npc.ai[3] == 0f && npc.localAI[1] == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + int num6 = NPC.NewNPC((int)vector.X, (int)vector.Y, ModContent.NPCType(), npc.whoAmI); + npc.ai[3] = num6 + 1; + npc.localAI[1] = -1f; + npc.localAI[2] += 1f; + npc.netUpdate = true; + Main.npc[num6].ai[0] = npc.whoAmI; + Main.npc[num6].netUpdate = true; + } - int num7 = (int)npc.ai[3] - 1; - if (num7 != -1 && Main.npc[num7].active && Main.npc[num7].type == ModContent.NPCType()) - npc.dontTakeDamage = true; - else - { - npc.dontTakeDamage = false; - npc.ai[3] = 0f; + int num7 = (int)npc.ai[3] - 1; + if (num7 != -1 && Main.npc[num7].active && Main.npc[num7].type == ModContent.NPCType()) + npc.dontTakeDamage = true; + else + { + npc.dontTakeDamage = false; + npc.ai[3] = 0f; - if (npc.localAI[1] == -1f) - npc.localAI[1] = 1f; - else - { - switch ((int)npc.localAI[2]) - { - case 1: - if (phase2) - npc.localAI[1] = 0f; - break; - case 2: - if (phase3) - npc.localAI[1] = 0f; - break; - } - } - } - } - else - { - npc.dontTakeDamage = false; + if (npc.localAI[1] == -1f) + npc.localAI[1] = 1f; + else + { + switch ((int)npc.localAI[2]) + { + case 1: + if (phase2) + npc.localAI[1] = 0f; + break; + case 2: + if (phase3) + npc.localAI[1] = 0f; + break; + } + } + } + } + else + { + npc.dontTakeDamage = false; - int num7 = (int)npc.ai[3] - 1; - if (num7 != -1 && Main.npc[num7].active && Main.npc[num7].type == ModContent.NPCType()) - npc.dontTakeDamage = true; - } + int num7 = (int)npc.ai[3] - 1; + if (num7 != -1 && Main.npc[num7].active && Main.npc[num7].type == ModContent.NPCType()) + npc.dontTakeDamage = true; + } - // Hover near the target, invisible if the Leviathan is present and not sufficiently injured. - if ((phase3 || death) && WaitingForLeviathan) - { - ChargeRotation(player, vector); - ChargeLocation(player, vector, false, true); + // Hover near the target, invisible if the Leviathan is present and not sufficiently injured. + if ((phase3 || death) && WaitingForLeviathan) + { + ChargeRotation(player, vector); + ChargeLocation(player, vector, false, true); - npc.alpha += 3; - if (npc.alpha >= 255) - npc.alpha = 255; - else - { - for (int k = 0; k < 3; k++) - { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, 172, 0f, 0f, 100, default, 2f); - Main.dust[dust].noGravity = true; - Main.dust[dust].noLight = true; - } - } + npc.alpha += 3; + if (npc.alpha >= 255) + npc.alpha = 255; + else + { + for (int k = 0; k < 3; k++) + { + int dust = Dust.NewDust(npc.position, npc.width, npc.height, 172, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } - npc.dontTakeDamage = true; - npc.damage = 0; + npc.dontTakeDamage = true; + npc.damage = 0; - if (npc.ai[0] != -1f) - { - npc.ai[0] = -1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.localAI[0] = 0f; - npc.netUpdate = true; - } + if (npc.ai[0] != -1f) + { + npc.ai[0] = -1f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.localAI[0] = 0f; + npc.netUpdate = true; + } - return; - } + return; + } - // Alpha - if (npc.damage != 0) - { - npc.alpha -= 5; - if (npc.alpha <= 0) - npc.alpha = 0; - } + // Alpha + if (npc.damage != 0) + { + npc.alpha -= 5; + if (npc.alpha <= 0) + npc.alpha = 0; + } // Play sound if (Main.rand.NextBool(300)) @@ -314,61 +314,61 @@ namespace CalamityMod.NPCs.Leviathan if (npc.timeLeft < 1800) npc.timeLeft = 1800; - // Despawn - if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) - { - npc.rotation = npc.velocity.X * 0.02f; + // Despawn + if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) + { + npc.rotation = npc.velocity.X * 0.02f; - if (npc.velocity.Y < -3f) - npc.velocity.Y = -3f; - npc.velocity.Y += 0.2f; - if (npc.velocity.Y > 16f) - npc.velocity.Y = 16f; + if (npc.velocity.Y < -3f) + npc.velocity.Y = -3f; + npc.velocity.Y += 0.2f; + if (npc.velocity.Y > 16f) + npc.velocity.Y = 16f; - if (npc.position.Y > Main.worldSurface * 16.0) - { - for (int x = 0; x < Main.maxNPCs; x++) - { - if (Main.npc[x].type == ModContent.NPCType()) - { - Main.npc[x].active = false; - Main.npc[x].netUpdate = true; - } - } - npc.active = false; - npc.netUpdate = true; - } + if (npc.position.Y > Main.worldSurface * 16.0) + { + for (int x = 0; x < Main.maxNPCs; x++) + { + if (Main.npc[x].type == ModContent.NPCType()) + { + Main.npc[x].active = false; + Main.npc[x].netUpdate = true; + } + } + npc.active = false; + npc.netUpdate = true; + } - if (npc.ai[0] != -1f) - { - npc.ai[0] = -1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.localAI[0] = 0f; - npc.netUpdate = true; - } + if (npc.ai[0] != -1f) + { + npc.ai[0] = -1f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.localAI[0] = 0f; + npc.netUpdate = true; + } - return; - } - } + return; + } + } - // Rotation when charging - if (npc.ai[0] > 2f) + // Rotation when charging + if (npc.ai[0] > 2f) ChargeRotation(player, vector); // Phase switch if (npc.ai[0] == -1f) { int random = ((phase2 && expertMode && !leviAlive) || phase4 || death) ? 4 : 3; - int num618; - do num618 = Main.rand.Next(random); - while (num618 == npc.ai[1] || num618 == 1); + int num618; + do num618 = Main.rand.Next(random); + while (num618 == npc.ai[1] || num618 == 1); - npc.ai[0] = num618; + npc.ai[0] = num618; if (npc.ai[0] != 3f) { @@ -380,7 +380,7 @@ namespace CalamityMod.NPCs.Leviathan else ChargeRotation(player, vector); - npc.TargetClosest(); + npc.TargetClosest(); npc.ai[1] = 0f; npc.ai[2] = 0f; } @@ -396,22 +396,22 @@ namespace CalamityMod.NPCs.Leviathan float num1056 = player.position.Y + (player.height / 2) - 200f - vector118.Y; float num1057 = (float)Math.Sqrt(num1055 * num1055 + num1056 * num1056); - npc.Calamity().newAI[0] += 1f; + npc.Calamity().newAI[0] += 1f; if (num1057 < 600f || npc.Calamity().newAI[0] >= 180f) { npc.ai[0] = 1f; npc.ai[1] = 0f; - npc.Calamity().newAI[0] = 0f; - npc.netUpdate = true; + npc.Calamity().newAI[0] = 0f; + npc.netUpdate = true; return; } - float maxVelocityY = death ? 3f : 4f; - float maxVelocityX = death ? 7f : 8f; - maxVelocityY -= enrageScale; - maxVelocityX -= 2f * enrageScale; + float maxVelocityY = death ? 3f : 4f; + float maxVelocityX = death ? 7f : 8f; + maxVelocityY -= enrageScale; + maxVelocityX -= 2f * enrageScale; - if (npc.position.Y > player.position.Y - 350f) + if (npc.position.Y > player.position.Y - 350f) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.98f; @@ -458,20 +458,20 @@ namespace CalamityMod.NPCs.Leviathan float num1060 = (float)Math.Sqrt(num1058 * num1058 + num1059 * num1059); npc.ai[1] += 1f; - int num638 = 0; - for (int num639 = 0; num639 < 255; num639++) - { - if (Main.player[num639].active && !Main.player[num639].dead && (vector - Main.player[num639].Center).Length() < 1000f) - num638++; - } - npc.ai[1] += num638 / 2; + int num638 = 0; + for (int num639 = 0; num639 < 255; num639++) + { + if (Main.player[num639].active && !Main.player[num639].dead && (vector - Main.player[num639].Center).Length() < 1000f) + num638++; + } + npc.ai[1] += num638 / 2; bool flag103 = false; - float num640 = 20f; - if (!leviAlive || phase4) - num640 -= death ? 15f * (1f - lifeRatio) : 12f * (1f - lifeRatio); + float num640 = 20f; + if (!leviAlive || phase4) + num640 -= death ? 15f * (1f - lifeRatio) : 12f * (1f - lifeRatio); - if (npc.ai[1] > num640) + if (npc.ai[1] > num640) { npc.ai[1] = 0f; npc.ai[2] += 1f; @@ -484,63 +484,63 @@ namespace CalamityMod.NPCs.Leviathan if (Main.netMode != NetmodeID.MultiplayerClient) { int spawn = NPC.NewNPC((int)vector119.X, (int)vector119.Y, NPCID.DetonatingBubble); - Main.npc[spawn].target = npc.target; - Main.npc[spawn].velocity = player.Center - vector119; - Main.npc[spawn].velocity.Normalize(); - Main.npc[spawn].velocity *= bubbleVelocity; - Main.npc[spawn].netUpdate = true; - Main.npc[spawn].ai[3] = Main.rand.Next(80, 121) / 100f; - } + Main.npc[spawn].target = npc.target; + Main.npc[spawn].velocity = player.Center - vector119; + Main.npc[spawn].velocity.Normalize(); + Main.npc[spawn].velocity *= bubbleVelocity; + Main.npc[spawn].netUpdate = true; + Main.npc[spawn].ai[3] = Main.rand.Next(80, 121) / 100f; + } } if (num1060 > 600f) { - float maxVelocityY = death ? 3f : 4f; - float maxVelocityX = death ? 7f : 8f; - maxVelocityY -= enrageScale; - maxVelocityX -= 2f * enrageScale; + float maxVelocityY = death ? 3f : 4f; + float maxVelocityX = death ? 7f : 8f; + maxVelocityY -= enrageScale; + maxVelocityX -= 2f * enrageScale; - if (npc.position.Y > player.position.Y - 350f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= 0.98f; - npc.velocity.Y -= death ? 0.12f : 0.1f; - if (npc.velocity.Y > maxVelocityY) - npc.velocity.Y = maxVelocityY; - } - else if (npc.position.Y < player.position.Y - 450f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.98f; - npc.velocity.Y += death ? 0.12f : 0.1f; - if (npc.velocity.Y < -maxVelocityY) - npc.velocity.Y = -maxVelocityY; - } + if (npc.position.Y > player.position.Y - 350f) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y *= 0.98f; + npc.velocity.Y -= death ? 0.12f : 0.1f; + if (npc.velocity.Y > maxVelocityY) + npc.velocity.Y = maxVelocityY; + } + else if (npc.position.Y < player.position.Y - 450f) + { + if (npc.velocity.Y < 0f) + npc.velocity.Y *= 0.98f; + npc.velocity.Y += death ? 0.12f : 0.1f; + if (npc.velocity.Y < -maxVelocityY) + npc.velocity.Y = -maxVelocityY; + } - if (npc.position.X + (npc.width / 2) > player.position.X + (player.width / 2) + 100f) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= 0.98f; - npc.velocity.X -= death ? 0.12f : 0.1f; - if (npc.velocity.X > maxVelocityX) - npc.velocity.X = maxVelocityX; - } + if (npc.position.X + (npc.width / 2) > player.position.X + (player.width / 2) + 100f) + { + if (npc.velocity.X > 0f) + npc.velocity.X *= 0.98f; + npc.velocity.X -= death ? 0.12f : 0.1f; + if (npc.velocity.X > maxVelocityX) + npc.velocity.X = maxVelocityX; + } - if (npc.position.X + (npc.width / 2) < player.position.X + (player.width / 2) - 100f) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= 0.98f; - npc.velocity.X += death ? 0.12f : 0.1f; - if (npc.velocity.X < -maxVelocityX) - npc.velocity.X = -maxVelocityX; - } - } + if (npc.position.X + (npc.width / 2) < player.position.X + (player.width / 2) - 100f) + { + if (npc.velocity.X < 0f) + npc.velocity.X *= 0.98f; + npc.velocity.X += death ? 0.12f : 0.1f; + if (npc.velocity.X < -maxVelocityX) + npc.velocity.X = -maxVelocityX; + } + } else npc.velocity *= 0.9f; npc.spriteDirection = npc.direction; - float maxBubbleSpawn = death ? 3f : 4f; + float maxBubbleSpawn = death ? 3f : 4f; if (npc.ai[2] > maxBubbleSpawn) { npc.ai[0] = -1f; @@ -555,82 +555,82 @@ namespace CalamityMod.NPCs.Leviathan { npc.rotation = npc.velocity.X * 0.02f; - Vector2 targetVector = player.Center + new Vector2(0f, -350f); - float velocity = death ? 13.5f : 12f; - velocity += 6f * enrageScale; - Vector2 vector3 = Vector2.Normalize(targetVector - vector - npc.velocity) * velocity; - float acceleration = death ? 0.28f : 0.25f; - acceleration += 0.2f * enrageScale; + Vector2 targetVector = player.Center + new Vector2(0f, -350f); + float velocity = death ? 13.5f : 12f; + velocity += 6f * enrageScale; + Vector2 vector3 = Vector2.Normalize(targetVector - vector - npc.velocity) * velocity; + float acceleration = death ? 0.28f : 0.25f; + acceleration += 0.2f * enrageScale; - if (Math.Abs(npc.Center.Y - targetVector.Y) > 50f || Math.Abs(npc.Center.X - player.Center.X) > 350f) - npc.SimpleFlyMovement(vector3, acceleration); + if (Math.Abs(npc.Center.Y - targetVector.Y) > 50f || Math.Abs(npc.Center.X - player.Center.X) > 350f) + npc.SimpleFlyMovement(vector3, acceleration); - npc.ai[1] += 1f; + npc.ai[1] += 1f; - float divisor = 140f; - divisor -= (int)(30f * enrageScale); - if (!leviAlive || phase4) - divisor -= (float)Math.Ceiling(50f * (1f - lifeRatio)); + float divisor = 140f; + divisor -= (int)(30f * enrageScale); + if (!leviAlive || phase4) + divisor -= (float)Math.Ceiling(50f * (1f - lifeRatio)); - bool shootProjectiles = npc.ai[1] % divisor == 0f; - if (Main.netMode != NetmodeID.MultiplayerClient && shootProjectiles) - { - float projectileVelocity = expertMode ? 3f : 2f; - projectileVelocity += enrageScale; - if (!leviAlive || phase4) - projectileVelocity += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + bool shootProjectiles = npc.ai[1] % divisor == 0f; + if (Main.netMode != NetmodeID.MultiplayerClient && shootProjectiles) + { + float projectileVelocity = expertMode ? 3f : 2f; + projectileVelocity += enrageScale; + if (!leviAlive || phase4) + projectileVelocity += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - int totalProjectiles = 8; - int projectileDistance = 600; - int type = ModContent.ProjectileType(); - switch ((int)npc.localAI[3]) - { - case 0: - Main.PlaySound(SoundID.Item21, player.position); - break; - case 1: - totalProjectiles = 3; - type = ModContent.ProjectileType(); - Main.PlaySound(SoundID.Item30, player.position); - break; - case 2: - totalProjectiles = 6; - type = ModContent.ProjectileType(); - float soundPitch = (Main.rand.NextFloat() - 0.5f) * 0.5f; - Main.harpNote = soundPitch; - Main.PlaySound(SoundID.Item26, player.position); - break; - } - npc.localAI[3] += 1f; - if (npc.localAI[3] > 2f) - npc.localAI[3] = 0f; + int totalProjectiles = 8; + int projectileDistance = 600; + int type = ModContent.ProjectileType(); + switch ((int)npc.localAI[3]) + { + case 0: + Main.PlaySound(SoundID.Item21, player.position); + break; + case 1: + totalProjectiles = 3; + type = ModContent.ProjectileType(); + Main.PlaySound(SoundID.Item30, player.position); + break; + case 2: + totalProjectiles = 6; + type = ModContent.ProjectileType(); + float soundPitch = (Main.rand.NextFloat() - 0.5f) * 0.5f; + Main.harpNote = soundPitch; + Main.PlaySound(SoundID.Item26, player.position); + break; + } + npc.localAI[3] += 1f; + if (npc.localAI[3] > 2f) + npc.localAI[3] = 0f; - if ((phase2 && !leviAlive) || phase4) - totalProjectiles += totalProjectiles / 2; + if ((phase2 && !leviAlive) || phase4) + totalProjectiles += totalProjectiles / 2; - float radians = MathHelper.TwoPi / totalProjectiles; - int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -projectileVelocity).RotatedBy(radians * i)) * projectileDistance; - Vector2 projVelocity = Vector2.Normalize(player.Center - spawnVector) * projectileVelocity; - Projectile.NewProjectile(spawnVector, projVelocity, type, damage, 0f, Main.myPlayer); - } - } + float radians = MathHelper.TwoPi / totalProjectiles; + int damage = npc.GetProjectileDamage(type); + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -projectileVelocity).RotatedBy(radians * i)) * projectileDistance; + Vector2 projVelocity = Vector2.Normalize(player.Center - spawnVector) * projectileVelocity; + Projectile.NewProjectile(spawnVector, projVelocity, type, damage, 0f, Main.myPlayer); + } + } - if (Math.Abs(npc.Center.X - player.Center.X) > 10f) - { - float playerLocation = vector.X - player.Center.X; - npc.direction = playerLocation < 0f ? 1 : -1; - npc.spriteDirection = npc.direction; - } + if (Math.Abs(npc.Center.X - player.Center.X) > 10f) + { + float playerLocation = vector.X - player.Center.X; + npc.direction = playerLocation < 0f ? 1 : -1; + npc.spriteDirection = npc.direction; + } - float phaseTimer = 300f; - phaseTimer -= 50f * enrageScale; - if (!leviAlive || phase4) - phaseTimer -= 150f * (1f - lifeRatio); + float phaseTimer = 300f; + phaseTimer -= 50f * enrageScale; + if (!leviAlive || phase4) + phaseTimer -= 150f * (1f - lifeRatio); - if (npc.ai[1] >= phaseTimer) + if (npc.ai[1] >= phaseTimer) { npc.ai[0] = -1f; npc.ai[1] = 2f; @@ -648,17 +648,17 @@ namespace CalamityMod.NPCs.Leviathan if (npc.ai[1] >= (revenge ? 45f : 60f)) { forceChargeFrames = true; - float aiInterval = (leviAlive && !phase4) ? 2f : 3f; - npc.ai[0] = (npc.ai[2] >= aiInterval) ? -1f : 4f; + float aiInterval = (leviAlive && !phase4) ? 2f : 3f; + npc.ai[0] = (npc.ai[2] >= aiInterval) ? -1f : 4f; npc.ai[1] = (npc.ai[2] >= aiInterval) ? 3f : 0f; npc.localAI[0] = 0f; // Velocity and rotation float chargeVelocity = (leviAlive && !phase4) ? 21f : 26f; - chargeVelocity += 8f * enrageScale; + chargeVelocity += 8f * enrageScale; - if (revenge) - chargeVelocity += 2f + (death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio)); + if (revenge) + chargeVelocity += 2f + (death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio)); npc.velocity = Vector2.Normalize(player.Center - vector) * chargeVelocity; npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); @@ -680,11 +680,11 @@ namespace CalamityMod.NPCs.Leviathan // Charge else if (npc.ai[0] == 4f) { - npc.Calamity().canBreakPlayerDefense = true; - npc.damage = (int)(npc.defDamage * 1.5); + npc.Calamity().canBreakPlayerDefense = true; + npc.damage = (int)(npc.defDamage * 1.5); - // Spawn dust - int num24 = 7; + // Spawn dust + int num24 = 7; for (int j = 0; j < num24; j++) { 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) + vector; @@ -722,9 +722,9 @@ namespace CalamityMod.NPCs.Leviathan if (npc.ai[0] == 4f) num18 = 0f; - if (num18 != 0f) - npc.rotation = npc.rotation.AngleTowards(num17, num18); - } + if (num18 != 0f) + npc.rotation = npc.rotation.AngleTowards(num17, num18); + } // Move to charge location private void ChargeLocation(Player player, Vector2 vector, bool leviAlive, bool revenge) @@ -737,10 +737,10 @@ namespace CalamityMod.NPCs.Leviathan Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(npc.localAI[0], -distance) - vector - npc.velocity) * 12f; float acceleration = revenge ? 0.75f : 0.5f; - npc.SimpleFlyMovement(vector3, acceleration); + npc.SimpleFlyMovement(vector3, acceleration); - // Rotation - int num22 = Math.Sign(player.Center.X - vector.X); + // Rotation + int num22 = Math.Sign(player.Center.X - vector.X); if (num22 != 0) { if (npc.ai[1] == 0f && num22 != npc.direction) @@ -770,22 +770,22 @@ namespace CalamityMod.NPCs.Leviathan public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { Texture2D texture = Main.npcTexture[npc.type]; - switch (frameUsed) - { - case 0: - texture = Main.npcTexture[npc.type]; - break; - case 1: - texture = ModContent.GetTexture("CalamityMod/NPCs/Leviathan/SirenStabbing"); - break; - } + switch (frameUsed) + { + case 0: + texture = Main.npcTexture[npc.type]; + break; + case 1: + texture = ModContent.GetTexture("CalamityMod/NPCs/Leviathan/SirenStabbing"); + break; + } - bool charging = npc.ai[0] > 2f || forceChargeFrames; + bool charging = npc.ai[0] > 2f || forceChargeFrames; int height = texture.Height / Main.npcFrameCount[npc.type]; int width = texture.Width; - SpriteEffects spriteEffects = charging ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - if (npc.spriteDirection == -1) - spriteEffects = charging ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + SpriteEffects spriteEffects = charging ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + if (npc.spriteDirection == -1) + spriteEffects = charging ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Main.spriteBatch.Draw(texture, npc.Center - Main.screenPosition + new Vector2(0f, npc.gfxOffY), npc.frame, npc.GetAlpha(drawColor), npc.rotation, new Vector2((float)width / 2f, (float)height / 2f), npc.scale, spriteEffects, 0f); return false; } @@ -797,17 +797,17 @@ namespace CalamityMod.NPCs.Leviathan else frameUsed = 0; - int timeBetweenFrames = 8; + int timeBetweenFrames = 8; npc.frameCounter++; - if (npc.frameCounter > timeBetweenFrames * Main.npcFrameCount[npc.type]) - npc.frameCounter = 0; + if (npc.frameCounter > timeBetweenFrames * Main.npcFrameCount[npc.type]) + npc.frameCounter = 0; - npc.frame.Y = frameHeight * (int)(npc.frameCounter / timeBetweenFrames); - if (npc.frame.Y >= frameHeight * Main.npcFrameCount[npc.type]) - npc.frame.Y = 0; + npc.frame.Y = frameHeight * (int)(npc.frameCounter / timeBetweenFrames); + if (npc.frame.Y >= frameHeight * Main.npcFrameCount[npc.type]) + npc.frame.Y = 0; - //100x1140 - //200x636 + //100x1140 + //200x636 } public override void BossLoot(ref string name, ref int potionType) @@ -818,7 +818,7 @@ namespace CalamityMod.NPCs.Leviathan // Anahita runs the same loot code as the Leviathan, but only if she dies last. public override void NPCLoot() { - //Trophy dropped regardless of Levi, precedent of Twins + //Trophy dropped regardless of Levi, precedent of Twins DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); if (!NPC.AnyNPCs(ModContent.NPCType())) diff --git a/NPCs/Leviathan/SirenIce.cs b/NPCs/Leviathan/SirenIce.cs index 4bbd5c61f4..e42f528175 100644 --- a/NPCs/Leviathan/SirenIce.cs +++ b/NPCs/Leviathan/SirenIce.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Leviathan { - public class SirenIce : ModNPC + public class SirenIce : ModNPC { public override void SetStaticDefaults() { @@ -20,11 +20,11 @@ namespace CalamityMod.NPCs.Leviathan aiType = -1; npc.canGhostHeal = false; npc.noTileCollide = true; - npc.GetNPCDamage(); - npc.width = 100; + npc.GetNPCDamage(); + npc.width = 100; npc.height = 100; npc.defense = 10; - npc.DR_NERD(0.5f); + npc.DR_NERD(0.5f); npc.lifeMax = 650; if (BossRushEvent.BossRushActive) { @@ -33,39 +33,39 @@ namespace CalamityMod.NPCs.Leviathan npc.alpha = 255; npc.HitSound = SoundID.NPCHit5; npc.DeathSound = SoundID.NPCDeath7; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = false; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = false; + npc.Calamity().VulnerableToSickness = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.dontTakeDamage = reader.ReadBoolean(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - int num989 = (int)npc.ai[0]; - if (Main.npc[num989].active && Main.npc[num989].type == ModContent.NPCType()) + writer.Write(npc.dontTakeDamage); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.dontTakeDamage = reader.ReadBoolean(); + } + + public override void AI() + { + int num989 = (int)npc.ai[0]; + if (Main.npc[num989].active && Main.npc[num989].type == ModContent.NPCType()) { - if (npc.alpha > 100 && npc.ai[1] == 0f) - npc.alpha -= 2; + if (npc.alpha > 100 && npc.ai[1] == 0f) + npc.alpha -= 2; - if (Main.npc[num989].damage == 0) - npc.ai[1] = 1f; - else - npc.ai[1] = 0f; + if (Main.npc[num989].damage == 0) + npc.ai[1] = 1f; + else + npc.ai[1] = 0f; - if (npc.ai[1] == 1f) - npc.alpha = Main.npc[num989].alpha; + if (npc.ai[1] == 1f) + npc.alpha = Main.npc[num989].alpha; - npc.dontTakeDamage = Main.npc[num989].damage == 0; - npc.rotation = Main.npc[num989].rotation; + npc.dontTakeDamage = Main.npc[num989].damage == 0; + npc.rotation = Main.npc[num989].rotation; npc.spriteDirection = Main.npc[num989].direction; npc.velocity = Vector2.Zero; npc.position = Main.npc[num989].Center; @@ -76,7 +76,7 @@ namespace CalamityMod.NPCs.Leviathan return; } - npc.dontTakeDamage = false; + npc.dontTakeDamage = false; npc.life = 0; npc.HitEffect(0, 10.0); npc.active = false; @@ -97,27 +97,27 @@ namespace CalamityMod.NPCs.Leviathan } } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => npc.ai[1] == 0f; + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => npc.ai[1] == 0f; - public override Color? GetAlpha(Color drawColor) + public override Color? GetAlpha(Color drawColor) { - if (npc.ai[1] == 1f) - return Color.Transparent; + if (npc.ai[1] == 1f) + return Color.Transparent; - return new Color(200, 200, 200, npc.alpha); + return new Color(200, 200, 200, npc.alpha); } public override void OnHitPlayer(Player player, int damage, bool crit) { - if (npc.ai[1] == 1f) - return; + if (npc.ai[1] == 1f) + return; - player.AddBuff(BuffID.Frostburn, 240, true); + player.AddBuff(BuffID.Frostburn, 240, true); } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/NormalNPCs/AeroSlime.cs b/NPCs/NormalNPCs/AeroSlime.cs index 8d0620229e..f18a5ab29c 100644 --- a/NPCs/NormalNPCs/AeroSlime.cs +++ b/NPCs/NormalNPCs/AeroSlime.cs @@ -33,9 +33,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { diff --git a/NPCs/NormalNPCs/AngryDog.cs b/NPCs/NormalNPCs/AngryDog.cs index a619227c4a..43824507c0 100644 --- a/NPCs/NormalNPCs/AngryDog.cs +++ b/NPCs/NormalNPCs/AngryDog.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class AngryDog : ModNPC + public class AngryDog : ModNPC { private bool reset = false; @@ -39,11 +39,11 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath5; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.coldDamage = true; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = false; - npc.Calamity().VulnerableToSickness = true; - } + npc.coldDamage = true; + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = false; + npc.Calamity().VulnerableToSickness = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -75,10 +75,10 @@ namespace CalamityMod.NPCs.NormalNPCs { npc.ai[1] += 1f; } - CalamityAI.UnicornAI(npc, mod, true, CalamityWorld.death ? 6f : 4f, 5f, 0.2f); + CalamityAI.UnicornAI(npc, mod, true, CalamityWorld.death ? 6f : 4f, 5f, 0.2f); return; } - CalamityAI.UnicornAI(npc, mod, false, CalamityWorld.death ? 6f : 4f, 6f, CalamityWorld.death ? 0.1f : 0.07f); + CalamityAI.UnicornAI(npc, mod, false, CalamityWorld.death ? 6f : 4f, 6f, CalamityWorld.death ? 0.1f : 0.07f); } public override void FindFrame(int frameHeight) diff --git a/NPCs/NormalNPCs/ArmoredDiggerBody.cs b/NPCs/NormalNPCs/ArmoredDiggerBody.cs index db98dd16fd..aa8d56285d 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerBody.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerBody.cs @@ -20,9 +20,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.width = 38; npc.height = 38; npc.defense = 20; - npc.DR_NERD(0.2f); - npc.lifeMax = 20000; - npc.knockBackResist = 0f; + npc.DR_NERD(0.2f); + npc.lifeMax = 20000; + npc.knockBackResist = 0f; npc.aiStyle = -1; aiType = -1; npc.behindTiles = true; @@ -34,9 +34,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.dontCountMe = true; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { diff --git a/NPCs/NormalNPCs/ArmoredDiggerHead.cs b/NPCs/NormalNPCs/ArmoredDiggerHead.cs index 5a29b10a22..5f0fc073dd 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerHead.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerHead.cs @@ -21,13 +21,13 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.damage = 90; + npc.Calamity().canBreakPlayerDefense = true; + npc.damage = 90; npc.npcSlots = 10f; npc.width = 54; npc.height = 54; npc.defense = 10; - npc.DR_NERD(0.1f); + npc.DR_NERD(0.1f); npc.lifeMax = 20000; npc.knockBackResist = 0f; npc.aiStyle = -1; @@ -41,13 +41,13 @@ namespace CalamityMod.NPCs.NormalNPCs npc.netAlways = true; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void AI() { - bool death = CalamityWorld.death; + bool death = CalamityWorld.death; if (npc.ai[3] > 0f) { npc.realLife = (int)npc.ai[3]; diff --git a/NPCs/NormalNPCs/ArmoredDiggerTail.cs b/NPCs/NormalNPCs/ArmoredDiggerTail.cs index c9940e3571..f19c6946ea 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerTail.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerTail.cs @@ -20,9 +20,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.width = 34; npc.height = 34; npc.defense = 30; - npc.DR_NERD(0.3f); - npc.lifeMax = 20000; - npc.knockBackResist = 0f; + npc.DR_NERD(0.3f); + npc.lifeMax = 20000; + npc.knockBackResist = 0f; npc.aiStyle = -1; aiType = -1; npc.behindTiles = true; @@ -34,9 +34,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.dontCountMe = true; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { diff --git a/NPCs/NormalNPCs/BlightedEye.cs b/NPCs/NormalNPCs/BlightedEye.cs index db89251098..ea77f392ce 100644 --- a/NPCs/NormalNPCs/BlightedEye.cs +++ b/NPCs/NormalNPCs/BlightedEye.cs @@ -16,7 +16,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { npc.aiStyle = 2; - aiType = NPCID.TheHungryII; + aiType = NPCID.TheHungryII; npc.damage = 32; npc.width = 30; npc.height = 32; @@ -29,10 +29,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void HitEffect(int hitDirection, double damage) { @@ -65,7 +65,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.5f); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.5f); } } } diff --git a/NPCs/NormalNPCs/BloomSlime.cs b/NPCs/NormalNPCs/BloomSlime.cs index 07280ded3a..e858d61bfa 100644 --- a/NPCs/NormalNPCs/BloomSlime.cs +++ b/NPCs/NormalNPCs/BloomSlime.cs @@ -18,8 +18,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { npc.aiStyle = 1; - aiType = NPCID.ToxicSludge; - npc.damage = 80; + aiType = NPCID.ToxicSludge; + npc.damage = 80; npc.width = 40; npc.height = 30; npc.defense = 25; @@ -35,9 +35,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { diff --git a/NPCs/NormalNPCs/Bohldohr.cs b/NPCs/NormalNPCs/Bohldohr.cs index 594b491189..274a0081d7 100644 --- a/NPCs/NormalNPCs/Bohldohr.cs +++ b/NPCs/NormalNPCs/Bohldohr.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class Bohldohr : ModNPC + public class Bohldohr : ModNPC { public override void SetStaticDefaults() { @@ -14,8 +14,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.aiStyle = -1; + npc.Calamity().canBreakPlayerDefense = true; + npc.aiStyle = -1; aiType = -1; npc.damage = 80; npc.width = 40; @@ -29,9 +29,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.behindTiles = true; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { diff --git a/NPCs/NormalNPCs/Cnidrion.cs b/NPCs/NormalNPCs/Cnidrion.cs index 7c8bc5a977..13d3a261a3 100644 --- a/NPCs/NormalNPCs/Cnidrion.cs +++ b/NPCs/NormalNPCs/Cnidrion.cs @@ -26,9 +26,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.width = 160; npc.height = 80; npc.defense = 6; - npc.noGravity = true; - npc.noTileCollide = true; - npc.DR_NERD(0.05f); + npc.noGravity = true; + npc.noTileCollide = true; + npc.DR_NERD(0.05f); npc.lifeMax = 280; npc.knockBackResist = 0.05f; aiType = -1; @@ -38,26 +38,26 @@ namespace CalamityMod.NPCs.NormalNPCs npc.rarity = 2; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (spawnInfo.player.PillarZone() || - spawnInfo.player.InAstral() || - spawnInfo.player.ZoneCorrupt || - spawnInfo.player.ZoneCrimson || - spawnInfo.player.ZoneOldOneArmy || - spawnInfo.player.ZoneSkyHeight || - spawnInfo.playerSafe || - !spawnInfo.player.ZoneDesert || - !spawnInfo.player.ZoneOverworldHeight || - Main.eclipse || - Main.snowMoon || - Main.pumpkinMoon || - NPC.AnyNPCs(ModContent.NPCType())) + spawnInfo.player.InAstral() || + spawnInfo.player.ZoneCorrupt || + spawnInfo.player.ZoneCrimson || + spawnInfo.player.ZoneOldOneArmy || + spawnInfo.player.ZoneSkyHeight || + spawnInfo.playerSafe || + !spawnInfo.player.ZoneDesert || + !spawnInfo.player.ZoneOverworldHeight || + Main.eclipse || + Main.snowMoon || + Main.pumpkinMoon || + NPC.AnyNPCs(ModContent.NPCType())) { return 0f; } @@ -81,8 +81,8 @@ namespace CalamityMod.NPCs.NormalNPCs npc.TargetClosest(true); bool flag51 = false; int offsetX = 80; - int projectileDamage = expertMode ? 9 : 12; - if (npc.life < npc.lifeMax * 0.33 || (CalamityWorld.death && npc.life < npc.lifeMax * 0.6)) + int projectileDamage = expertMode ? 9 : 12; + if (npc.life < npc.lifeMax * 0.33 || (CalamityWorld.death && npc.life < npc.lifeMax * 0.6)) { num823 = 2f; } @@ -248,9 +248,9 @@ namespace CalamityMod.NPCs.NormalNPCs if (flag52) { npc.velocity.Y += 0.5f; - if (npc.velocity.Y > 10f) - npc.velocity.Y = 10f; - } + if (npc.velocity.Y > 10f) + npc.velocity.Y = 10f; + } else if (Collision.SolidCollision(position2, num854, num855)) { if (npc.velocity.Y > 0f) @@ -274,9 +274,9 @@ namespace CalamityMod.NPCs.NormalNPCs else npc.velocity.Y += 0.25f; - if (npc.velocity.Y > 2f) - npc.velocity.Y = 2f; - } + if (npc.velocity.Y > 2f) + npc.velocity.Y = 2f; + } } public override void HitEffect(int hitDirection, double damage) @@ -296,7 +296,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); } } } diff --git a/NPCs/NormalNPCs/CosmicElemental.cs b/NPCs/NormalNPCs/CosmicElemental.cs index 0c63b5f4ef..b8811b3f40 100644 --- a/NPCs/NormalNPCs/CosmicElemental.cs +++ b/NPCs/NormalNPCs/CosmicElemental.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class CosmicElemental : ModNPC + public class CosmicElemental : ModNPC { public override void SetStaticDefaults() { diff --git a/NPCs/NormalNPCs/CrawlerAmber.cs b/NPCs/NormalNPCs/CrawlerAmber.cs index 3ac8646753..9003015d91 100644 --- a/NPCs/NormalNPCs/CrawlerAmber.cs +++ b/NPCs/NormalNPCs/CrawlerAmber.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class CrawlerAmber : ModNPC + public class CrawlerAmber : ModNPC { private bool detected = false; @@ -32,10 +32,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath36; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/NormalNPCs/CrawlerAmethyst.cs b/NPCs/NormalNPCs/CrawlerAmethyst.cs index 02cca5df94..3e9a6a869c 100644 --- a/NPCs/NormalNPCs/CrawlerAmethyst.cs +++ b/NPCs/NormalNPCs/CrawlerAmethyst.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class CrawlerAmethyst : ModNPC + public class CrawlerAmethyst : ModNPC { private bool detected = false; @@ -32,10 +32,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath36; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/NormalNPCs/CrawlerCrystal.cs b/NPCs/NormalNPCs/CrawlerCrystal.cs index 720dffb7f2..41c88d4b52 100644 --- a/NPCs/NormalNPCs/CrawlerCrystal.cs +++ b/NPCs/NormalNPCs/CrawlerCrystal.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class CrawlerCrystal : ModNPC + public class CrawlerCrystal : ModNPC { private bool detected = false; @@ -33,10 +33,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath36; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/NormalNPCs/CrawlerDiamond.cs b/NPCs/NormalNPCs/CrawlerDiamond.cs index f8a9ed6aa2..6ada901a35 100644 --- a/NPCs/NormalNPCs/CrawlerDiamond.cs +++ b/NPCs/NormalNPCs/CrawlerDiamond.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class CrawlerDiamond : ModNPC + public class CrawlerDiamond : ModNPC { private bool detected = false; @@ -32,10 +32,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath36; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/NormalNPCs/CrawlerEmerald.cs b/NPCs/NormalNPCs/CrawlerEmerald.cs index c09e767734..6032f8650d 100644 --- a/NPCs/NormalNPCs/CrawlerEmerald.cs +++ b/NPCs/NormalNPCs/CrawlerEmerald.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class CrawlerEmerald : ModNPC + public class CrawlerEmerald : ModNPC { private bool detected = false; @@ -32,10 +32,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath36; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/NormalNPCs/CrawlerRuby.cs b/NPCs/NormalNPCs/CrawlerRuby.cs index 2e3a7422e3..3f59e7bcb4 100644 --- a/NPCs/NormalNPCs/CrawlerRuby.cs +++ b/NPCs/NormalNPCs/CrawlerRuby.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class CrawlerRuby : ModNPC + public class CrawlerRuby : ModNPC { private bool detected = false; @@ -32,10 +32,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath36; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/NormalNPCs/CrawlerSapphire.cs b/NPCs/NormalNPCs/CrawlerSapphire.cs index bed72a1067..f93b7e5595 100644 --- a/NPCs/NormalNPCs/CrawlerSapphire.cs +++ b/NPCs/NormalNPCs/CrawlerSapphire.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class CrawlerSapphire : ModNPC + public class CrawlerSapphire : ModNPC { private bool detected = false; @@ -32,10 +32,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath36; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/NormalNPCs/CrawlerTopaz.cs b/NPCs/NormalNPCs/CrawlerTopaz.cs index aa35d5570d..e4f25645e4 100644 --- a/NPCs/NormalNPCs/CrawlerTopaz.cs +++ b/NPCs/NormalNPCs/CrawlerTopaz.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class CrawlerTopaz : ModNPC + public class CrawlerTopaz : ModNPC { private bool detected = false; @@ -32,10 +32,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath36; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/NormalNPCs/CrimulanBlightSlime.cs b/NPCs/NormalNPCs/CrimulanBlightSlime.cs index 003cedbc81..6e93895428 100644 --- a/NPCs/NormalNPCs/CrimulanBlightSlime.cs +++ b/NPCs/NormalNPCs/CrimulanBlightSlime.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class CrimulanBlightSlime : ModNPC + public class CrimulanBlightSlime : ModNPC { public override void SetStaticDefaults() { @@ -16,8 +16,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { npc.aiStyle = 1; - aiType = NPCID.DungeonSlime; - npc.damage = 30; + aiType = NPCID.DungeonSlime; + npc.damage = 30; npc.width = 60; npc.height = 42; npc.defense = 8; @@ -33,9 +33,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { diff --git a/NPCs/NormalNPCs/CryoSlime.cs b/NPCs/NormalNPCs/CryoSlime.cs index daeb1de197..55d9482e53 100644 --- a/NPCs/NormalNPCs/CryoSlime.cs +++ b/NPCs/NormalNPCs/CryoSlime.cs @@ -17,8 +17,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { npc.aiStyle = 1; - aiType = NPCID.DungeonSlime; - npc.damage = 30; + aiType = NPCID.DungeonSlime; + npc.damage = 30; npc.width = 40; npc.height = 30; npc.defense = 8; @@ -34,10 +34,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = false; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = false; + npc.Calamity().VulnerableToSickness = false; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { @@ -49,13 +49,13 @@ namespace CalamityMod.NPCs.NormalNPCs return SpawnCondition.Cavern.Chance * 0.08f; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.Frostburn, 120, true); - player.AddBuff(BuffID.Chilled, 90, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(BuffID.Frostburn, 120, true); + player.AddBuff(BuffID.Chilled, 90, true); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { // TODO -- This dust was an invalid dust. Replaced with a random dust. int dustType = 91; diff --git a/NPCs/NormalNPCs/Cryocore.cs b/NPCs/NormalNPCs/Cryocore.cs index a4ee621b13..7d0bde08d9 100644 --- a/NPCs/NormalNPCs/Cryocore.cs +++ b/NPCs/NormalNPCs/Cryocore.cs @@ -17,22 +17,22 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { - npc.damage = 35; - npc.width = 40; + npc.damage = 35; + npc.width = 40; npc.height = 40; npc.defense = 6; npc.lifeMax = 220; npc.aiStyle = -1; aiType = -1; - npc.value = Item.buyPrice(0, 0, 3, 50); - npc.knockBackResist = 0.75f; + npc.value = Item.buyPrice(0, 0, 3, 50); + npc.knockBackResist = 0.75f; npc.noGravity = true; npc.HitSound = SoundID.NPCHit5; npc.DeathSound = SoundID.NPCDeath15; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = false; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = false; + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { @@ -87,17 +87,17 @@ namespace CalamityMod.NPCs.NormalNPCs npc.rotation = npc.velocity.X * 0.15f; } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.player.ZoneSnow && - spawnInfo.player.ZoneOverworldHeight && - !spawnInfo.player.PillarZone() && - !spawnInfo.player.ZoneDungeon && - !spawnInfo.player.InSunkenSea() && - Main.hardMode && !spawnInfo.playerInTown && !spawnInfo.player.ZoneOldOneArmy && !Main.snowMoon && !Main.pumpkinMoon ? 0.01f : 0f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return spawnInfo.player.ZoneSnow && + spawnInfo.player.ZoneOverworldHeight && + !spawnInfo.player.PillarZone() && + !spawnInfo.player.ZoneDungeon && + !spawnInfo.player.InSunkenSea() && + Main.hardMode && !spawnInfo.playerInTown && !spawnInfo.player.ZoneOldOneArmy && !Main.snowMoon && !Main.pumpkinMoon ? 0.01f : 0f; + } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Frostburn, 90, true); player.AddBuff(BuffID.Chilled, 60, true); @@ -119,9 +119,9 @@ namespace CalamityMod.NPCs.NormalNPCs } } - public override void NPCLoot() - { - DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.33f); - } - } + public override void NPCLoot() + { + DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.33f); + } + } } diff --git a/NPCs/NormalNPCs/Cryocore2.cs b/NPCs/NormalNPCs/Cryocore2.cs index 64601d51f7..d2d7cf467f 100644 --- a/NPCs/NormalNPCs/Cryocore2.cs +++ b/NPCs/NormalNPCs/Cryocore2.cs @@ -17,22 +17,22 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { - npc.damage = 40; - npc.width = 66; + npc.damage = 40; + npc.width = 66; npc.height = 66; npc.defense = 10; npc.lifeMax = 300; npc.aiStyle = -1; aiType = -1; - npc.value = Item.buyPrice(0, 0, 5, 0); - npc.knockBackResist = 0.5f; + npc.value = Item.buyPrice(0, 0, 5, 0); + npc.knockBackResist = 0.5f; npc.noGravity = true; npc.HitSound = SoundID.NPCHit5; npc.DeathSound = SoundID.NPCDeath15; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = false; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = false; + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { @@ -87,17 +87,17 @@ namespace CalamityMod.NPCs.NormalNPCs npc.rotation = npc.velocity.X * 0.15f; } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.player.ZoneSnow && - spawnInfo.player.ZoneOverworldHeight && - !spawnInfo.player.PillarZone() && - !spawnInfo.player.ZoneDungeon && - !spawnInfo.player.InSunkenSea() && - Main.hardMode && !spawnInfo.playerInTown && !spawnInfo.player.ZoneOldOneArmy && !Main.snowMoon && !Main.pumpkinMoon ? 0.01f : 0f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return spawnInfo.player.ZoneSnow && + spawnInfo.player.ZoneOverworldHeight && + !spawnInfo.player.PillarZone() && + !spawnInfo.player.ZoneDungeon && + !spawnInfo.player.InSunkenSea() && + Main.hardMode && !spawnInfo.playerInTown && !spawnInfo.player.ZoneOldOneArmy && !Main.snowMoon && !Main.pumpkinMoon ? 0.01f : 0f; + } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Frostburn, 90, true); player.AddBuff(BuffID.Chilled, 60, true); @@ -119,9 +119,9 @@ namespace CalamityMod.NPCs.NormalNPCs } } - public override void NPCLoot() - { - DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.5f); - } - } + public override void NPCLoot() + { + DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.5f); + } + } } diff --git a/NPCs/NormalNPCs/Cryon.cs b/NPCs/NormalNPCs/Cryon.cs index 44043cde70..98849c42cf 100644 --- a/NPCs/NormalNPCs/Cryon.cs +++ b/NPCs/NormalNPCs/Cryon.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class Cryon : ModNPC + public class Cryon : ModNPC { public override void SetStaticDefaults() { @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.NormalNPCs npc.width = 50; npc.height = 64; npc.defense = 10; - npc.DR_NERD(0.1f); + npc.DR_NERD(0.1f); npc.lifeMax = 300; npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 0, 5, 0); @@ -31,11 +31,11 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath7; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.coldDamage = true; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = false; - npc.Calamity().VulnerableToSickness = false; - } + npc.coldDamage = true; + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = false; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { @@ -78,8 +78,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Frostburn, 120, true); - player.AddBuff(BuffID.Chilled, 90, true); - } + player.AddBuff(BuffID.Chilled, 90, true); + } public override void HitEffect(int hitDirection, double damage) { @@ -98,7 +98,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.5f); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.5f); } } } diff --git a/NPCs/NormalNPCs/EbonianBlightSlime.cs b/NPCs/NormalNPCs/EbonianBlightSlime.cs index 35acc77bc1..c7ce9bf318 100644 --- a/NPCs/NormalNPCs/EbonianBlightSlime.cs +++ b/NPCs/NormalNPCs/EbonianBlightSlime.cs @@ -16,8 +16,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { npc.aiStyle = 1; - aiType = NPCID.DungeonSlime; - npc.damage = 30; + aiType = NPCID.DungeonSlime; + npc.damage = 30; npc.width = 60; npc.height = 42; npc.defense = 8; @@ -33,9 +33,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/NormalNPCs/Eidolist.cs b/NPCs/NormalNPCs/Eidolist.cs index 4cefbade13..02d28289e6 100644 --- a/NPCs/NormalNPCs/Eidolist.cs +++ b/NPCs/NormalNPCs/Eidolist.cs @@ -39,11 +39,11 @@ namespace CalamityMod.NPCs.NormalNPCs npc.timeLeft = NPC.activeTime * 2; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -59,18 +59,18 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - bool adultWyrmAlive = false; - if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) - { - if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) - adultWyrmAlive = true; - } + bool adultWyrmAlive = false; + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) + { + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + adultWyrmAlive = true; + } - npc.Opacity += 0.15f; - if (npc.Opacity > 1f) - npc.Opacity = 1f; + npc.Opacity += 0.15f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; - Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 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 || adultWyrmAlive) { hasBeenHit = true; @@ -148,7 +148,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= Main.rand.Next(90, 601)) { npc.localAI[0] = -90f; - npc.netUpdate = true; + npc.netUpdate = true; 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 = adultWyrmAlive ? 10f : 5f; @@ -156,7 +156,7 @@ namespace CalamityMod.NPCs.NormalNPCs 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(); + float targetDist = targetVec.Length(); targetDist = speed / targetDist; targetVec.X *= targetDist; targetVec.Y *= targetDist; @@ -292,7 +292,7 @@ namespace CalamityMod.NPCs.NormalNPCs { return 0.05f; } - return 0f; + return 0f; } public override void HitEffect(int hitDirection, double damage) @@ -314,25 +314,25 @@ namespace CalamityMod.NPCs.NormalNPCs } } - public override bool PreNPCLoot() - { - bool adultWyrmAlive = false; - if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) - { - if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) - adultWyrmAlive = true; - } - - return !adultWyrmAlive; - } - - public override void NPCLoot() + public override bool PreNPCLoot() { - if (Main.rand.NextBool(10)) - { - DropHelper.DropItem(npc, ItemID.BlueLunaticHood); - DropHelper.DropItem(npc, ItemID.BlueLunaticRobe); - } + bool adultWyrmAlive = false; + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) + { + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + adultWyrmAlive = true; + } + + return !adultWyrmAlive; + } + + public override void NPCLoot() + { + if (Main.rand.NextBool(10)) + { + DropHelper.DropItem(npc, ItemID.BlueLunaticHood); + DropHelper.DropItem(npc, ItemID.BlueLunaticRobe); + } DropHelper.DropItemCondition(npc, ModContent.ItemType(), !NPC.LunarApocalypseIsUp, 0.25f); int minLumenyl = Main.expertMode ? 10 : 8; int maxLumenyl = Main.expertMode ? 14 : 10; diff --git a/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs b/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs index bc159e4111..b5245f1d8d 100644 --- a/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs +++ b/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs @@ -33,11 +33,11 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { @@ -115,11 +115,11 @@ namespace CalamityMod.NPCs.NormalNPCs } float num65 = CalamityWorld.death ? 3f : 1f; float num66 = CalamityWorld.death ? 0.28f : 0.08f; - if (!CalamityWorld.death) - { - num65 += (1f - (float)npc.life / (float)npc.lifeMax) * 2f; - num66 += (1f - (float)npc.life / (float)npc.lifeMax) * 0.2f; - } + if (!CalamityWorld.death) + { + num65 += (1f - (float)npc.life / (float)npc.lifeMax) * 2f; + num66 += (1f - (float)npc.life / (float)npc.lifeMax) * 0.2f; + } if (npc.velocity.X < -num65 || npc.velocity.X > num65) { if (npc.velocity.Y == 0f) @@ -461,8 +461,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItem(npc, ItemID.TinHelmet); - DropHelper.DropItemCondition(npc, ItemID.MagicDagger, Main.hardMode); + DropHelper.DropItem(npc, ItemID.TinHelmet); + DropHelper.DropItemCondition(npc, ItemID.MagicDagger, Main.hardMode); } } } diff --git a/NPCs/NormalNPCs/Frogfish.cs b/NPCs/NormalNPCs/Frogfish.cs index eb80105156..fe5d9be700 100644 --- a/NPCs/NormalNPCs/Frogfish.cs +++ b/NPCs/NormalNPCs/Frogfish.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class Frogfish : ModNPC + public class Frogfish : ModNPC { public override void SetStaticDefaults() { @@ -31,11 +31,11 @@ namespace CalamityMod.NPCs.NormalNPCs banner = npc.type; bannerItem = ModContent.ItemType(); npc.chaseable = false; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { @@ -78,7 +78,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (npc.ai[2] == 1f) { npc.chaseable = true; - CalamityAI.PassiveSwimmingAI(npc, mod, 0, 0f, 0.15f, 0.15f, 3.5f, 1.5f, 0.1f); + CalamityAI.PassiveSwimmingAI(npc, mod, 0, 0f, 0.15f, 0.15f, 3.5f, 1.5f, 0.1f); } } diff --git a/NPCs/NormalNPCs/Horse.cs b/NPCs/NormalNPCs/Horse.cs index a400717e45..4f1c96d07e 100644 --- a/NPCs/NormalNPCs/Horse.cs +++ b/NPCs/NormalNPCs/Horse.cs @@ -11,7 +11,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class Horse : ModNPC + public class Horse : ModNPC { public override void SetStaticDefaults() { @@ -21,40 +21,40 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 3f; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 3f; npc.damage = 50; npc.width = 230; npc.height = 230; npc.defense = 20; - npc.DR_NERD(0.1f); + npc.DR_NERD(0.1f); npc.lifeMax = 3800; npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 1, 50, 0); - npc.dontTakeDamage = true; + npc.dontTakeDamage = true; npc.noGravity = true; npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; npc.rarity = 2; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.dontTakeDamage); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.dontTakeDamage); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.dontTakeDamage = reader.ReadBoolean(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.dontTakeDamage = reader.ReadBoolean(); + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (spawnInfo.playerSafe || !Main.hardMode || spawnInfo.player.Calamity().ZoneAbyss || spawnInfo.player.Calamity().ZoneSunkenSea || NPC.AnyNPCs(npc.type)) @@ -66,10 +66,10 @@ namespace CalamityMod.NPCs.NormalNPCs public override void FindFrame(int frameHeight) { - if (npc.ai[0] == 0f) - return; + if (npc.ai[0] == 0f) + return; - npc.frameCounter++; + npc.frameCounter++; if (npc.frameCounter >= 8) { npc.frame.Y = (npc.frame.Y + frameHeight) % (Main.npcFrameCount[npc.type] * frameHeight); @@ -79,13 +79,13 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - // Weapons - float w = DropHelper.BagWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + // Weapons + float w = DropHelper.BagWeaponDropRateFloat; + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); } public override void HitEffect(int hitDirection, double damage) @@ -121,43 +121,43 @@ namespace CalamityMod.NPCs.NormalNPCs num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Fire, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(npc.Center, 3); + CalamityUtils.ExplosionGores(npc.Center, 3); } } public override bool PreAI() { - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - if (Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 480f) - { - if (npc.ai[0] == 0f) - { - npc.ai[0] = 1f; - npc.dontTakeDamage = false; - } - } - else - npc.TargetClosest(); + if (Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 480f) + { + if (npc.ai[0] == 0f) + { + npc.ai[0] = 1f; + npc.dontTakeDamage = false; + } + } + else + npc.TargetClosest(); - if (npc.ai[0] == 0f) - return false; + if (npc.ai[0] == 0f) + return false; - if (Main.player[npc.target].dead || !Main.player[npc.target].active) - { - if (npc.velocity.Y < -2f) - npc.velocity.Y = -2f; - npc.velocity.Y += 0.1f; - if (npc.velocity.Y > 12f) - npc.velocity.Y = 12f; + if (Main.player[npc.target].dead || !Main.player[npc.target].active) + { + if (npc.velocity.Y < -2f) + npc.velocity.Y = -2f; + npc.velocity.Y += 0.1f; + if (npc.velocity.Y > 12f) + npc.velocity.Y = 12f; - if (npc.timeLeft > 60) - npc.timeLeft = 60; - } + if (npc.timeLeft > 60) + npc.timeLeft = 60; + } - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[0] += 1f; if (npc.localAI[0] >= 300f) @@ -197,19 +197,19 @@ namespace CalamityMod.NPCs.NormalNPCs } } - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; - Vector2 direction = Main.player[npc.target].Center - npc.Center; + Vector2 direction = Main.player[npc.target].Center - npc.Center; direction.Normalize(); npc.ai[1] += Main.expertMode ? 2f : 1f; - if (npc.ai[1] >= 600f) - { - direction *= 6f; - npc.velocity = direction; - npc.ai[1] = 0f; - } + if (npc.ai[1] >= 600f) + { + direction *= 6f; + npc.velocity = direction; + npc.ai[1] = 0f; + } if (Math.Sqrt((npc.velocity.X * npc.velocity.X) + (npc.velocity.Y * npc.velocity.Y)) > 1) npc.velocity *= 0.985f; diff --git a/NPCs/NormalNPCs/IceClasper.cs b/NPCs/NormalNPCs/IceClasper.cs index c52bf28914..fdbb32acfd 100644 --- a/NPCs/NormalNPCs/IceClasper.cs +++ b/NPCs/NormalNPCs/IceClasper.cs @@ -10,7 +10,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class IceClasper : ModNPC + public class IceClasper : ModNPC { public override void SetStaticDefaults() { @@ -37,11 +37,11 @@ namespace CalamityMod.NPCs.NormalNPCs npc.rarity = 2; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.coldDamage = true; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = false; - npc.Calamity().VulnerableToSickness = false; - } + npc.coldDamage = true; + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = false; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { @@ -52,11 +52,11 @@ namespace CalamityMod.NPCs.NormalNPCs } float num = revenge ? 7f : 6f; float num2 = revenge ? 0.07f : 0.06f; - if (CalamityWorld.death) - { - num *= 1.5f; - num2 *= 1.5f; - } + if (CalamityWorld.death) + { + num *= 1.5f; + num2 *= 1.5f; + } Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num4 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); float num5 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); @@ -269,9 +269,9 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); } } } diff --git a/NPCs/NormalNPCs/IceMass.cs b/NPCs/NormalNPCs/IceMass.cs index c70afb4fda..8760dc4ae1 100644 --- a/NPCs/NormalNPCs/IceMass.cs +++ b/NPCs/NormalNPCs/IceMass.cs @@ -17,60 +17,60 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { npc.aiStyle = 86; - npc.damage = 40; - npc.width = 40; + npc.damage = 40; + npc.width = 40; npc.height = 24; npc.defense = 8; npc.alpha = 100; npc.lifeMax = 50; - npc.value = Item.buyPrice(0, 0, 1, 0); - npc.knockBackResist = 0f; + npc.value = Item.buyPrice(0, 0, 1, 0); + npc.knockBackResist = 0f; npc.HitSound = SoundID.NPCHit5; npc.DeathSound = SoundID.NPCDeath15; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = false; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = false; + npc.Calamity().VulnerableToSickness = false; + } 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; + 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 float SpawnChance(NPCSpawnInfo spawnInfo) - { - return spawnInfo.player.ZoneSnow && - spawnInfo.player.ZoneOverworldHeight && - !spawnInfo.player.PillarZone() && - !spawnInfo.player.ZoneDungeon && - !spawnInfo.player.InSunkenSea() && - Main.hardMode && !spawnInfo.playerInTown && !spawnInfo.player.ZoneOldOneArmy && !Main.snowMoon && !Main.pumpkinMoon ? 0.01f : 0f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return spawnInfo.player.ZoneSnow && + spawnInfo.player.ZoneOverworldHeight && + !spawnInfo.player.PillarZone() && + !spawnInfo.player.ZoneDungeon && + !spawnInfo.player.InSunkenSea() && + Main.hardMode && !spawnInfo.playerInTown && !spawnInfo.player.ZoneOldOneArmy && !Main.snowMoon && !Main.pumpkinMoon ? 0.01f : 0f; + } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Frostburn, 90, true); player.AddBuff(BuffID.Chilled, 60, true); @@ -97,9 +97,9 @@ namespace CalamityMod.NPCs.NormalNPCs } } - public override void NPCLoot() - { - DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.25f); - } - } + public override void NPCLoot() + { + DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.25f); + } + } } diff --git a/NPCs/NormalNPCs/ImpiousImmolator.cs b/NPCs/NormalNPCs/ImpiousImmolator.cs index e8ce4c0082..799b650f2e 100644 --- a/NPCs/NormalNPCs/ImpiousImmolator.cs +++ b/NPCs/NormalNPCs/ImpiousImmolator.cs @@ -12,7 +12,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class ImpiousImmolator : ModNPC + public class ImpiousImmolator : ModNPC { public bool hasBeenHit = false; @@ -39,11 +39,11 @@ namespace CalamityMod.NPCs.NormalNPCs npc.knockBackResist = 0.2f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -108,8 +108,8 @@ namespace CalamityMod.NPCs.NormalNPCs npc.TargetClosest(true); npc.velocity.X = npc.velocity.X + (float)npc.direction * 0.2f; npc.velocity.Y = npc.velocity.Y + (float)npc.directionY * 0.2f; - float velocityMax = CalamityWorld.death ? 16f : 12f; - if (npc.velocity.X > velocityMax) + float velocityMax = CalamityWorld.death ? 16f : 12f; + if (npc.velocity.X > velocityMax) { npc.velocity.X = velocityMax; } @@ -263,8 +263,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 2, 4); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 15); + DropHelper.DropItem(npc, ModContent.ItemType(), 2, 4); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 15); } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/NormalNPCs/KingSlimeJewel.cs b/NPCs/NormalNPCs/KingSlimeJewel.cs index a3e8c7b4b3..6bdce03ce5 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel.cs +++ b/NPCs/NormalNPCs/KingSlimeJewel.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class KingSlimeJewel : ModNPC + public class KingSlimeJewel : ModNPC { public override void SetStaticDefaults() { @@ -22,17 +22,17 @@ namespace CalamityMod.NPCs.NormalNPCs npc.damage = 0; npc.width = 22; npc.height = 22; - npc.defense = 10; - npc.DR_NERD(0.1f); - npc.lifeMax = 280; + npc.defense = 10; + npc.DR_NERD(0.1f); + npc.lifeMax = 280; npc.knockBackResist = 0f; npc.noGravity = true; npc.noTileCollide = true; - npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit5; - npc.DeathSound = SoundID.NPCDeath15; - npc.Calamity().VulnerableToSickness = false; - } + npc.canGhostHeal = false; + npc.HitSound = SoundID.NPCHit5; + npc.DeathSound = SoundID.NPCDeath15; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { @@ -110,10 +110,10 @@ namespace CalamityMod.NPCs.NormalNPCs 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 projLength = projVector.Length(); float speed = 9f; - int type = ModContent.ProjectileType(); + int type = ModContent.ProjectileType(); projLength = speed / projLength; projVector.X *= projLength; @@ -136,19 +136,19 @@ namespace CalamityMod.NPCs.NormalNPCs } Main.PlaySound(SoundID.Item8, npc.position); - int damage = npc.GetProjectileDamage(type); - if (CalamityWorld.death || BossRushEvent.BossRushActive) - { - int numProj = 2; - float rotation = MathHelper.ToRadians(9); - for (int i = 0; i < numProj + 1; i++) - { - Vector2 perturbedSpeed = projVector.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - Projectile.NewProjectile(npcPos, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - else - Projectile.NewProjectile(npcPos, projVector, type, damage, 0f, Main.myPlayer, 0f, 0f); + int damage = npc.GetProjectileDamage(type); + if (CalamityWorld.death || BossRushEvent.BossRushActive) + { + int numProj = 2; + float rotation = MathHelper.ToRadians(9); + for (int i = 0; i < numProj + 1; i++) + { + Vector2 perturbedSpeed = projVector.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); + Projectile.NewProjectile(npcPos, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, 0f); + } + } + else + Projectile.NewProjectile(npcPos, projVector, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } @@ -158,41 +158,41 @@ namespace CalamityMod.NPCs.NormalNPCs return new Color(255, 50, 50, 0); } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() + { + return false; + } - public override void HitEffect(int hitDirection, double damage) - { - Dust.NewDust(npc.position, npc.width, npc.height, 90, hitDirection, -1f, 0, default, 1f); - if (npc.life <= 0) - { - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 45; - npc.height = 45; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - for (int num621 = 0; num621 < 2; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 90, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 10; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 90, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 90, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + Dust.NewDust(npc.position, npc.width, npc.height, 90, hitDirection, -1f, 0, default, 1f); + if (npc.life <= 0) + { + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); + npc.width = 45; + npc.height = 45; + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 2; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 90, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 10; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 90, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 90, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + } + } } diff --git a/NPCs/NormalNPCs/MantisShrimp.cs b/NPCs/NormalNPCs/MantisShrimp.cs index a6a6a2c8f7..642ea37d44 100644 --- a/NPCs/NormalNPCs/MantisShrimp.cs +++ b/NPCs/NormalNPCs/MantisShrimp.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.NormalNPCs npc.width = 40; npc.height = 24; npc.defense = 10; - npc.DR_NERD(0.1f); + npc.DR_NERD(0.1f); npc.lifeMax = 30; npc.aiStyle = 3; aiType = NPCID.Crab; @@ -31,11 +31,11 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { @@ -105,7 +105,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedPlantBoss, 0.2f); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedPlantBoss, 0.2f); } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/NormalNPCs/OverloadedSoldier.cs b/NPCs/NormalNPCs/OverloadedSoldier.cs index 3fb807767d..37b7cff803 100644 --- a/NPCs/NormalNPCs/OverloadedSoldier.cs +++ b/NPCs/NormalNPCs/OverloadedSoldier.cs @@ -22,12 +22,12 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { npc.aiStyle = -1; - aiType = -1; + aiType = -1; npc.damage = NPC.downedMoonlord ? 84 : 42; npc.width = 18; npc.height = 40; npc.defense = 18; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = NPC.downedMoonlord ? 1350 : 135; npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 0, 2, 0); @@ -35,370 +35,370 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath2; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } - public override void FindFrame(int frameHeight) - { - npc.frameCounter += (double)Math.Abs(npc.velocity.X); - if (npc.frameCounter > 6.0) - { - npc.frameCounter = 0.0; - npc.frame.Y = npc.frame.Y + frameHeight; - } - if (npc.velocity.Y == 0f) - { - if (npc.direction == 1) - npc.spriteDirection = 1; - if (npc.direction == -1) - npc.spriteDirection = -1; - } - else - { - npc.frameCounter = 0.0; - npc.frame.Y = 0; - return; - } - if (npc.velocity.X == 0f) - { - npc.frameCounter = 0.0; - npc.frame.Y = 0; - } - else - { - if (npc.frame.Y < frameHeight) - npc.frame.Y = frameHeight; - if (npc.frame.Y > frameHeight * 13) - npc.frame.Y = frameHeight; - } - } - - public override void AI() + public override void FindFrame(int frameHeight) { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.35f, 0f, 0.15f); - bool flag3 = false; - if (npc.velocity.X == 0f) - { - flag3 = true; - } - if (npc.justHit) - { - flag3 = false; - } - bool flag4 = false; - bool flag5 = false; - int num35 = 60; - if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) - { - flag4 = true; - } - if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num35) | flag4) - { - npc.ai[3] += 1f; - } - else if ((double)Math.Abs(npc.velocity.X) > 0.9 && npc.ai[3] > 0f) - { - npc.ai[3] -= 1f; - } - if (npc.ai[3] > (float)(num35 * 10)) - { - npc.ai[3] = 0f; - } - if (npc.justHit) - { - npc.ai[3] = 0f; - } - if (npc.ai[3] == (float)num35) - { - npc.netUpdate = true; - } - if (npc.ai[3] < (float)num35) - { - npc.TargetClosest(true); - } - else if (npc.ai[2] <= 0f) - { - if (npc.velocity.X == 0f) - { - if (npc.velocity.Y == 0f) - { - npc.ai[0] += 1f; - if (npc.ai[0] >= 2f) - { - npc.direction *= -1; - npc.spriteDirection = npc.direction; - npc.ai[0] = 0f; - } - } - } - else - { - npc.ai[0] = 0f; - } - if (npc.direction == 0) - { - npc.direction = 1; - } - } - float num65 = 1.5f; - float num66 = 0.1f; - if (CalamityWorld.death) - { - num65 *= 1.5f; - num66 *= 1.5f; - } - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 400f) - { - num65 += (CalamityWorld.death ? 6f : 4f) - ((Main.player[npc.target].Center - npc.Center).Length() * 0.01f); - } - if (npc.velocity.X < -num65 || npc.velocity.X > num65) - { - if (npc.velocity.Y == 0f) - npc.velocity *= 0.7f; - } - else if (npc.velocity.X < num65 && npc.direction == 1) - { - npc.velocity.X = npc.velocity.X + num66; - if (npc.velocity.X > num65) - npc.velocity.X = num65; - } - else if (npc.velocity.X > -num65 && npc.direction == -1) - { - npc.velocity.X = npc.velocity.X - num66; - if (npc.velocity.X < -num65) - npc.velocity.X = -num65; - } - bool flag22 = false; - if (npc.velocity.Y == 0f) - { - int num161 = (int)(npc.position.Y + (float)npc.height + 7f) / 16; - int arg_A8FB_0 = (int)npc.position.X / 16; - int num162 = (int)(npc.position.X + (float)npc.width) / 16; - for (int num163 = arg_A8FB_0; num163 <= num162; num163++) - { - if (Main.tile[num163, num161] == null) - { - return; - } - if (Main.tile[num163, num161].nactive() && Main.tileSolid[(int)Main.tile[num163, num161].type]) - { - flag22 = true; - break; - } - } - } - if (npc.velocity.Y >= 0f) - { - int num164 = 0; - if (npc.velocity.X < 0f) - { - num164 = -1; - } - if (npc.velocity.X > 0f) - { - num164 = 1; - } - Vector2 position2 = npc.position; - position2.X += npc.velocity.X; - int num165 = (int)((position2.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num164)) / 16f); - int num166 = (int)((position2.Y + (float)npc.height - 1f) / 16f); - if (Main.tile[num165, num166] == null) - { - Main.tile[num165, num166] = new Tile(); - } - if (Main.tile[num165, num166 - 1] == null) - { - Main.tile[num165, num166 - 1] = new Tile(); - } - if (Main.tile[num165, num166 - 2] == null) - { - Main.tile[num165, num166 - 2] = new Tile(); - } - if (Main.tile[num165, num166 - 3] == null) - { - Main.tile[num165, num166 - 3] = new Tile(); - } - if (Main.tile[num165, num166 + 1] == null) - { - Main.tile[num165, num166 + 1] = new Tile(); - } - if (Main.tile[num165 - num164, num166 - 3] == null) - { - Main.tile[num165 - num164, num166 - 3] = new Tile(); - } - if ((float)(num165 * 16) < position2.X + (float)npc.width && (float)(num165 * 16 + 16) > position2.X && ((Main.tile[num165, num166].nactive() && !Main.tile[num165, num166].topSlope() && !Main.tile[num165, num166 - 1].topSlope() && Main.tileSolid[(int)Main.tile[num165, num166].type] && !Main.tileSolidTop[(int)Main.tile[num165, num166].type]) || (Main.tile[num165, num166 - 1].halfBrick() && Main.tile[num165, num166 - 1].nactive())) && (!Main.tile[num165, num166 - 1].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 1].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 1].type] || (Main.tile[num165, num166 - 1].halfBrick() && (!Main.tile[num165, num166 - 4].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 4].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 4].type]))) && (!Main.tile[num165, num166 - 2].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 2].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 2].type]) && (!Main.tile[num165, num166 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 3].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 3].type]) && (!Main.tile[num165 - num164, num166 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num165 - num164, num166 - 3].type])) - { - float num167 = (float)(num166 * 16); - if (Main.tile[num165, num166].halfBrick()) - { - num167 += 8f; - } - if (Main.tile[num165, num166 - 1].halfBrick()) - { - num167 -= 8f; - } - if (num167 < position2.Y + (float)npc.height) - { - float num168 = position2.Y + (float)npc.height - num167; - float num169 = 16.1f; - if (num168 <= num169) - { - npc.gfxOffY += npc.position.Y + (float)npc.height - num167; - npc.position.Y = num167 - (float)npc.height; - if (num168 < 9f) - { - npc.stepSpeed = 1f; - } - else - { - npc.stepSpeed = 2f; - } - } - } - } - } - if (flag22) - { - int num170 = (int)((npc.position.X + (float)(npc.width / 2) + (float)(15 * npc.direction)) / 16f); - int num171 = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); - if (Main.tile[num170, num171] == null) - { - Main.tile[num170, num171] = new Tile(); - } - if (Main.tile[num170, num171 - 1] == null) - { - Main.tile[num170, num171 - 1] = new Tile(); - } - if (Main.tile[num170, num171 - 2] == null) - { - Main.tile[num170, num171 - 2] = new Tile(); - } - if (Main.tile[num170, num171 - 3] == null) - { - Main.tile[num170, num171 - 3] = new Tile(); - } - if (Main.tile[num170, num171 + 1] == null) - { - Main.tile[num170, num171 + 1] = new Tile(); - } - if (Main.tile[num170 + npc.direction, num171 - 1] == null) - { - Main.tile[num170 + npc.direction, num171 - 1] = new Tile(); - } - if (Main.tile[num170 + npc.direction, num171 + 1] == null) - { - Main.tile[num170 + npc.direction, num171 + 1] = new Tile(); - } - if (Main.tile[num170 - npc.direction, num171 + 1] == null) - { - Main.tile[num170 - npc.direction, num171 + 1] = new Tile(); - } - Main.tile[num170, num171 + 1].halfBrick(); - if ((Main.tile[num170, num171 - 1].nactive() && (Main.tile[num170, num171 - 1].type == 10 || Main.tile[num170, num171 - 1].type == 388)) & flag5) - { - npc.ai[2] += 1f; - npc.ai[3] = 0f; - if (npc.ai[2] >= 60f) - { - npc.velocity.X = 0.5f * (float)-(float)npc.direction; - int num172 = 5; - if (Main.tile[num170, num171 - 1].type == 388) - { - num172 = 2; - } - npc.ai[1] += (float)num172; - npc.ai[2] = 0f; - bool flag23 = false; - if (npc.ai[1] >= 10f) - { - flag23 = true; - npc.ai[1] = 10f; - } - WorldGen.KillTile(num170, num171 - 1, true, false, false); - if ((Main.netMode != NetmodeID.MultiplayerClient || !flag23) && flag23 && Main.netMode != NetmodeID.MultiplayerClient) - { - if (Main.tile[num170, num171 - 1].type == 10) - { - bool flag24 = WorldGen.OpenDoor(num170, num171 - 1, npc.direction); - if (!flag24) - { - npc.ai[3] = (float)num35; - npc.netUpdate = true; - } - if (Main.netMode == NetmodeID.Server & flag24) - { - NetMessage.SendData(MessageID.ChangeDoor, -1, -1, null, 0, (float)num170, (float)(num171 - 1), (float)npc.direction, 0, 0, 0); - } - } - if (Main.tile[num170, num171 - 1].type == 388) - { - bool flag25 = WorldGen.ShiftTallGate(num170, num171 - 1, false); - if (!flag25) - { - npc.ai[3] = (float)num35; - npc.netUpdate = true; - } - if (Main.netMode == NetmodeID.Server & flag25) - { - NetMessage.SendData(MessageID.ChangeDoor, -1, -1, null, 4, (float)num170, (float)(num171 - 1), 0f, 0, 0, 0); - } - } - } - } - } - else - { - int num173 = npc.spriteDirection; - if ((npc.velocity.X < 0f && num173 == -1) || (npc.velocity.X > 0f && num173 == 1)) - { - if (npc.height >= 32 && Main.tile[num170, num171 - 2].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 2].type]) - { - if (Main.tile[num170, num171 - 3].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 3].type]) - { - npc.velocity.Y = -8f; - npc.netUpdate = true; - } - else - { - npc.velocity.Y = -7f; - npc.netUpdate = true; - } - } - else if (Main.tile[num170, num171 - 1].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 1].type]) - { - npc.velocity.Y = -6f; - npc.netUpdate = true; - } - else if (npc.position.Y + (float)npc.height - (float)(num171 * 16) > 20f && Main.tile[num170, num171].nactive() && !Main.tile[num170, num171].topSlope() && Main.tileSolid[(int)Main.tile[num170, num171].type]) - { - npc.velocity.Y = -5f; - npc.netUpdate = true; - } - else if (npc.directionY < 0 && (!Main.tile[num170, num171 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num170, num171 + 1].type]) && (!Main.tile[num170 + npc.direction, num171 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num170 + npc.direction, num171 + 1].type])) - { - npc.velocity.Y = -8f; - npc.velocity.X = npc.velocity.X * 1.5f; - npc.netUpdate = true; - } - else if (flag5) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - if ((npc.velocity.Y == 0f & flag3) && npc.ai[3] == 1f) - { - npc.velocity.Y = -5f; - } - } - } - } - else if (flag5) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - } + npc.frameCounter += (double)Math.Abs(npc.velocity.X); + if (npc.frameCounter > 6.0) + { + npc.frameCounter = 0.0; + npc.frame.Y = npc.frame.Y + frameHeight; + } + if (npc.velocity.Y == 0f) + { + if (npc.direction == 1) + npc.spriteDirection = 1; + if (npc.direction == -1) + npc.spriteDirection = -1; + } + else + { + npc.frameCounter = 0.0; + npc.frame.Y = 0; + return; + } + if (npc.velocity.X == 0f) + { + npc.frameCounter = 0.0; + npc.frame.Y = 0; + } + else + { + if (npc.frame.Y < frameHeight) + npc.frame.Y = frameHeight; + if (npc.frame.Y > frameHeight * 13) + npc.frame.Y = frameHeight; + } + } + + public override void AI() + { + Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.35f, 0f, 0.15f); + bool flag3 = false; + if (npc.velocity.X == 0f) + { + flag3 = true; + } + if (npc.justHit) + { + flag3 = false; + } + bool flag4 = false; + bool flag5 = false; + int num35 = 60; + if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) + { + flag4 = true; + } + if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num35) | flag4) + { + npc.ai[3] += 1f; + } + else if ((double)Math.Abs(npc.velocity.X) > 0.9 && npc.ai[3] > 0f) + { + npc.ai[3] -= 1f; + } + if (npc.ai[3] > (float)(num35 * 10)) + { + npc.ai[3] = 0f; + } + if (npc.justHit) + { + npc.ai[3] = 0f; + } + if (npc.ai[3] == (float)num35) + { + npc.netUpdate = true; + } + if (npc.ai[3] < (float)num35) + { + npc.TargetClosest(true); + } + else if (npc.ai[2] <= 0f) + { + if (npc.velocity.X == 0f) + { + if (npc.velocity.Y == 0f) + { + npc.ai[0] += 1f; + if (npc.ai[0] >= 2f) + { + npc.direction *= -1; + npc.spriteDirection = npc.direction; + npc.ai[0] = 0f; + } + } + } + else + { + npc.ai[0] = 0f; + } + if (npc.direction == 0) + { + npc.direction = 1; + } + } + float num65 = 1.5f; + float num66 = 0.1f; + if (CalamityWorld.death) + { + num65 *= 1.5f; + num66 *= 1.5f; + } + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 400f) + { + num65 += (CalamityWorld.death ? 6f : 4f) - ((Main.player[npc.target].Center - npc.Center).Length() * 0.01f); + } + if (npc.velocity.X < -num65 || npc.velocity.X > num65) + { + if (npc.velocity.Y == 0f) + npc.velocity *= 0.7f; + } + else if (npc.velocity.X < num65 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + num66; + if (npc.velocity.X > num65) + npc.velocity.X = num65; + } + else if (npc.velocity.X > -num65 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - num66; + if (npc.velocity.X < -num65) + npc.velocity.X = -num65; + } + bool flag22 = false; + if (npc.velocity.Y == 0f) + { + int num161 = (int)(npc.position.Y + (float)npc.height + 7f) / 16; + int arg_A8FB_0 = (int)npc.position.X / 16; + int num162 = (int)(npc.position.X + (float)npc.width) / 16; + for (int num163 = arg_A8FB_0; num163 <= num162; num163++) + { + if (Main.tile[num163, num161] == null) + { + return; + } + if (Main.tile[num163, num161].nactive() && Main.tileSolid[(int)Main.tile[num163, num161].type]) + { + flag22 = true; + break; + } + } + } + if (npc.velocity.Y >= 0f) + { + int num164 = 0; + if (npc.velocity.X < 0f) + { + num164 = -1; + } + if (npc.velocity.X > 0f) + { + num164 = 1; + } + Vector2 position2 = npc.position; + position2.X += npc.velocity.X; + int num165 = (int)((position2.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num164)) / 16f); + int num166 = (int)((position2.Y + (float)npc.height - 1f) / 16f); + if (Main.tile[num165, num166] == null) + { + Main.tile[num165, num166] = new Tile(); + } + if (Main.tile[num165, num166 - 1] == null) + { + Main.tile[num165, num166 - 1] = new Tile(); + } + if (Main.tile[num165, num166 - 2] == null) + { + Main.tile[num165, num166 - 2] = new Tile(); + } + if (Main.tile[num165, num166 - 3] == null) + { + Main.tile[num165, num166 - 3] = new Tile(); + } + if (Main.tile[num165, num166 + 1] == null) + { + Main.tile[num165, num166 + 1] = new Tile(); + } + if (Main.tile[num165 - num164, num166 - 3] == null) + { + Main.tile[num165 - num164, num166 - 3] = new Tile(); + } + if ((float)(num165 * 16) < position2.X + (float)npc.width && (float)(num165 * 16 + 16) > position2.X && ((Main.tile[num165, num166].nactive() && !Main.tile[num165, num166].topSlope() && !Main.tile[num165, num166 - 1].topSlope() && Main.tileSolid[(int)Main.tile[num165, num166].type] && !Main.tileSolidTop[(int)Main.tile[num165, num166].type]) || (Main.tile[num165, num166 - 1].halfBrick() && Main.tile[num165, num166 - 1].nactive())) && (!Main.tile[num165, num166 - 1].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 1].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 1].type] || (Main.tile[num165, num166 - 1].halfBrick() && (!Main.tile[num165, num166 - 4].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 4].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 4].type]))) && (!Main.tile[num165, num166 - 2].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 2].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 2].type]) && (!Main.tile[num165, num166 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 3].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 3].type]) && (!Main.tile[num165 - num164, num166 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num165 - num164, num166 - 3].type])) + { + float num167 = (float)(num166 * 16); + if (Main.tile[num165, num166].halfBrick()) + { + num167 += 8f; + } + if (Main.tile[num165, num166 - 1].halfBrick()) + { + num167 -= 8f; + } + if (num167 < position2.Y + (float)npc.height) + { + float num168 = position2.Y + (float)npc.height - num167; + float num169 = 16.1f; + if (num168 <= num169) + { + npc.gfxOffY += npc.position.Y + (float)npc.height - num167; + npc.position.Y = num167 - (float)npc.height; + if (num168 < 9f) + { + npc.stepSpeed = 1f; + } + else + { + npc.stepSpeed = 2f; + } + } + } + } + } + if (flag22) + { + int num170 = (int)((npc.position.X + (float)(npc.width / 2) + (float)(15 * npc.direction)) / 16f); + int num171 = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); + if (Main.tile[num170, num171] == null) + { + Main.tile[num170, num171] = new Tile(); + } + if (Main.tile[num170, num171 - 1] == null) + { + Main.tile[num170, num171 - 1] = new Tile(); + } + if (Main.tile[num170, num171 - 2] == null) + { + Main.tile[num170, num171 - 2] = new Tile(); + } + if (Main.tile[num170, num171 - 3] == null) + { + Main.tile[num170, num171 - 3] = new Tile(); + } + if (Main.tile[num170, num171 + 1] == null) + { + Main.tile[num170, num171 + 1] = new Tile(); + } + if (Main.tile[num170 + npc.direction, num171 - 1] == null) + { + Main.tile[num170 + npc.direction, num171 - 1] = new Tile(); + } + if (Main.tile[num170 + npc.direction, num171 + 1] == null) + { + Main.tile[num170 + npc.direction, num171 + 1] = new Tile(); + } + if (Main.tile[num170 - npc.direction, num171 + 1] == null) + { + Main.tile[num170 - npc.direction, num171 + 1] = new Tile(); + } + Main.tile[num170, num171 + 1].halfBrick(); + if ((Main.tile[num170, num171 - 1].nactive() && (Main.tile[num170, num171 - 1].type == 10 || Main.tile[num170, num171 - 1].type == 388)) & flag5) + { + npc.ai[2] += 1f; + npc.ai[3] = 0f; + if (npc.ai[2] >= 60f) + { + npc.velocity.X = 0.5f * (float)-(float)npc.direction; + int num172 = 5; + if (Main.tile[num170, num171 - 1].type == 388) + { + num172 = 2; + } + npc.ai[1] += (float)num172; + npc.ai[2] = 0f; + bool flag23 = false; + if (npc.ai[1] >= 10f) + { + flag23 = true; + npc.ai[1] = 10f; + } + WorldGen.KillTile(num170, num171 - 1, true, false, false); + if ((Main.netMode != NetmodeID.MultiplayerClient || !flag23) && flag23 && Main.netMode != NetmodeID.MultiplayerClient) + { + if (Main.tile[num170, num171 - 1].type == 10) + { + bool flag24 = WorldGen.OpenDoor(num170, num171 - 1, npc.direction); + if (!flag24) + { + npc.ai[3] = (float)num35; + npc.netUpdate = true; + } + if (Main.netMode == NetmodeID.Server & flag24) + { + NetMessage.SendData(MessageID.ChangeDoor, -1, -1, null, 0, (float)num170, (float)(num171 - 1), (float)npc.direction, 0, 0, 0); + } + } + if (Main.tile[num170, num171 - 1].type == 388) + { + bool flag25 = WorldGen.ShiftTallGate(num170, num171 - 1, false); + if (!flag25) + { + npc.ai[3] = (float)num35; + npc.netUpdate = true; + } + if (Main.netMode == NetmodeID.Server & flag25) + { + NetMessage.SendData(MessageID.ChangeDoor, -1, -1, null, 4, (float)num170, (float)(num171 - 1), 0f, 0, 0, 0); + } + } + } + } + } + else + { + int num173 = npc.spriteDirection; + if ((npc.velocity.X < 0f && num173 == -1) || (npc.velocity.X > 0f && num173 == 1)) + { + if (npc.height >= 32 && Main.tile[num170, num171 - 2].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 2].type]) + { + if (Main.tile[num170, num171 - 3].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 3].type]) + { + npc.velocity.Y = -8f; + npc.netUpdate = true; + } + else + { + npc.velocity.Y = -7f; + npc.netUpdate = true; + } + } + else if (Main.tile[num170, num171 - 1].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 1].type]) + { + npc.velocity.Y = -6f; + npc.netUpdate = true; + } + else if (npc.position.Y + (float)npc.height - (float)(num171 * 16) > 20f && Main.tile[num170, num171].nactive() && !Main.tile[num170, num171].topSlope() && Main.tileSolid[(int)Main.tile[num170, num171].type]) + { + npc.velocity.Y = -5f; + npc.netUpdate = true; + } + else if (npc.directionY < 0 && (!Main.tile[num170, num171 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num170, num171 + 1].type]) && (!Main.tile[num170 + npc.direction, num171 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num170 + npc.direction, num171 + 1].type])) + { + npc.velocity.Y = -8f; + npc.velocity.X = npc.velocity.X * 1.5f; + npc.netUpdate = true; + } + else if (flag5) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + if ((npc.velocity.Y == 0f & flag3) && npc.ai[3] == 1f) + { + npc.velocity.Y = -5f; + } + } + } + } + else if (flag5) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { @@ -432,8 +432,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedMoonlord); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedMoonlord); } } } diff --git a/NPCs/NormalNPCs/Parasea.cs b/NPCs/NormalNPCs/Parasea.cs index ea431e0479..a763e7e72d 100644 --- a/NPCs/NormalNPCs/Parasea.cs +++ b/NPCs/NormalNPCs/Parasea.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class Parasea : ModNPC + public class Parasea : ModNPC { public override void SetStaticDefaults() { @@ -21,21 +21,21 @@ namespace CalamityMod.NPCs.NormalNPCs npc.aiStyle = -1; aiType = -1; npc.noGravity = true; - npc.damage = 50; - npc.width = npc.height = 30; + npc.damage = 50; + npc.width = npc.height = 30; npc.defense = 8; npc.lifeMax = 400; npc.knockBackResist = 0f; - npc.value = Item.buyPrice(0, 0, 6, 0); - npc.HitSound = SoundID.NPCHit1; + npc.value = Item.buyPrice(0, 0, 6, 0); + npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { @@ -44,16 +44,16 @@ namespace CalamityMod.NPCs.NormalNPCs CalamityAI.DungeonSpiritAI(npc, mod, speed, MathHelper.Pi); } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur || (!NPC.downedPlantBoss && !CalamityWorld.downedCalamitas)) - { - return 0f; - } - return SpawnCondition.OceanMonster.Chance * 0.06f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur || (!NPC.downedPlantBoss && !CalamityWorld.downedCalamitas)) + { + return 0f; + } + return SpawnCondition.OceanMonster.Chance * 0.06f; + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -66,14 +66,14 @@ namespace CalamityMod.NPCs.NormalNPCs Texture2D texture = Main.npcTexture[npc.type]; int height = texture.Height / Main.npcFrameCount[npc.type]; int width = texture.Width; - SpriteEffects spriteEffects = SpriteEffects.FlipHorizontally; - if (npc.spriteDirection == -1) - spriteEffects = SpriteEffects.None; + SpriteEffects spriteEffects = SpriteEffects.FlipHorizontally; + if (npc.spriteDirection == -1) + spriteEffects = SpriteEffects.None; Main.spriteBatch.Draw(texture, npc.Center - Main.screenPosition + new Vector2(0f, npc.gfxOffY), npc.frame, npc.GetAlpha(drawColor), npc.rotation, new Vector2((float)width / 2f, (float)height / 2f), npc.scale, spriteEffects, 0f); return false; } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Bleeding, 60, true); } diff --git a/NPCs/NormalNPCs/PerennialSlime.cs b/NPCs/NormalNPCs/PerennialSlime.cs index 0798b79c03..3391d2dd0c 100644 --- a/NPCs/NormalNPCs/PerennialSlime.cs +++ b/NPCs/NormalNPCs/PerennialSlime.cs @@ -16,8 +16,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { npc.aiStyle = 1; - aiType = NPCID.ToxicSludge; - npc.damage = 35; + aiType = NPCID.ToxicSludge; + npc.damage = 35; npc.width = 40; npc.height = 30; npc.defense = 12; @@ -33,9 +33,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { diff --git a/NPCs/NormalNPCs/PhantomDebris.cs b/NPCs/NormalNPCs/PhantomDebris.cs index e6de916898..a636b61611 100644 --- a/NPCs/NormalNPCs/PhantomDebris.cs +++ b/NPCs/NormalNPCs/PhantomDebris.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.NormalNPCs npc.width = 44; npc.height = 22; npc.defense = 20; - npc.DR_NERD(0.1f); + npc.DR_NERD(0.1f); npc.lifeMax = NPC.downedMoonlord ? 1200 : 120; npc.aiStyle = -1; aiType = -1; @@ -35,364 +35,364 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath36; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void FindFrame(int frameHeight) { - npc.frameCounter += (double)Math.Abs(npc.velocity.X); - if (npc.frameCounter > 6.0) - { - npc.frameCounter = 0.0; - npc.frame.Y = npc.frame.Y + frameHeight; - } - if (npc.velocity.Y == 0f) - { - if (npc.direction == 1) - npc.spriteDirection = 1; - if (npc.direction == -1) - npc.spriteDirection = -1; - } - else - { - npc.frameCounter = 0.0; - npc.frame.Y = 0; - return; - } - if (npc.velocity.X == 0f) - { - npc.frameCounter = 0.0; - npc.frame.Y = 0; - } - else - { - if (npc.frame.Y > frameHeight * 3) - npc.frame.Y = 0; - } - } + npc.frameCounter += (double)Math.Abs(npc.velocity.X); + if (npc.frameCounter > 6.0) + { + npc.frameCounter = 0.0; + npc.frame.Y = npc.frame.Y + frameHeight; + } + if (npc.velocity.Y == 0f) + { + if (npc.direction == 1) + npc.spriteDirection = 1; + if (npc.direction == -1) + npc.spriteDirection = -1; + } + else + { + npc.frameCounter = 0.0; + npc.frame.Y = 0; + return; + } + if (npc.velocity.X == 0f) + { + npc.frameCounter = 0.0; + npc.frame.Y = 0; + } + else + { + if (npc.frame.Y > frameHeight * 3) + npc.frame.Y = 0; + } + } public override void AI() { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.35f, 0f, 0.15f); - bool flag3 = false; - if (npc.velocity.X == 0f) - { - flag3 = true; - } - if (npc.justHit) - { - flag3 = false; - } - bool flag4 = false; - bool flag5 = false; - int num35 = 60; - if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) - { - flag4 = true; - } - if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num35) | flag4) - { - npc.ai[3] += 1f; - } - else if ((double)Math.Abs(npc.velocity.X) > 0.9 && npc.ai[3] > 0f) - { - npc.ai[3] -= 1f; - } - if (npc.ai[3] > (float)(num35 * 10)) - { - npc.ai[3] = 0f; - } - if (npc.justHit) - { - npc.ai[3] = 0f; - } - if (npc.ai[3] == (float)num35) - { - npc.netUpdate = true; - } - if (npc.ai[3] < (float)num35) - { - npc.TargetClosest(true); - } - else if (npc.ai[2] <= 0f) - { - if (npc.velocity.X == 0f) - { - if (npc.velocity.Y == 0f) - { - npc.ai[0] += 1f; - if (npc.ai[0] >= 2f) - { - npc.direction *= -1; - npc.spriteDirection = npc.direction; - npc.ai[0] = 0f; - } - } - } - else - { - npc.ai[0] = 0f; - } - if (npc.direction == 0) - { - npc.direction = 1; - } - } - float num65 = 1.2f + ((Main.player[npc.target].Center - npc.Center).Length() * 0.005f); - float num66 = 0.12f + ((Main.player[npc.target].Center - npc.Center).Length() * 0.0005f); - if (CalamityWorld.death) - { - num65 *= 1.5f; - num66 *= 1.5f; - } - if (npc.velocity.X < -num65 || npc.velocity.X > num65) - { - if (npc.velocity.Y == 0f) - npc.velocity *= 0.7f; - } - else if (npc.velocity.X < num65 && npc.direction == 1) - { - npc.velocity.X = npc.velocity.X + num66; - if (npc.velocity.X > num65) - npc.velocity.X = num65; - } - else if (npc.velocity.X > -num65 && npc.direction == -1) - { - npc.velocity.X = npc.velocity.X - num66; - if (npc.velocity.X < -num65) - npc.velocity.X = -num65; - } - bool flag22 = false; - if (npc.velocity.Y == 0f) - { - int num161 = (int)(npc.position.Y + (float)npc.height + 7f) / 16; - int arg_A8FB_0 = (int)npc.position.X / 16; - int num162 = (int)(npc.position.X + (float)npc.width) / 16; - for (int num163 = arg_A8FB_0; num163 <= num162; num163++) - { - if (Main.tile[num163, num161] == null) - { - return; - } - if (Main.tile[num163, num161].nactive() && Main.tileSolid[(int)Main.tile[num163, num161].type]) - { - flag22 = true; - break; - } - } - } - if (npc.velocity.Y >= 0f) - { - int num164 = 0; - if (npc.velocity.X < 0f) - { - num164 = -1; - } - if (npc.velocity.X > 0f) - { - num164 = 1; - } - Vector2 position2 = npc.position; - position2.X += npc.velocity.X; - int num165 = (int)((position2.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num164)) / 16f); - int num166 = (int)((position2.Y + (float)npc.height - 1f) / 16f); - if (Main.tile[num165, num166] == null) - { - Main.tile[num165, num166] = new Tile(); - } - if (Main.tile[num165, num166 - 1] == null) - { - Main.tile[num165, num166 - 1] = new Tile(); - } - if (Main.tile[num165, num166 - 2] == null) - { - Main.tile[num165, num166 - 2] = new Tile(); - } - if (Main.tile[num165, num166 - 3] == null) - { - Main.tile[num165, num166 - 3] = new Tile(); - } - if (Main.tile[num165, num166 + 1] == null) - { - Main.tile[num165, num166 + 1] = new Tile(); - } - if (Main.tile[num165 - num164, num166 - 3] == null) - { - Main.tile[num165 - num164, num166 - 3] = new Tile(); - } - if ((float)(num165 * 16) < position2.X + (float)npc.width && (float)(num165 * 16 + 16) > position2.X && ((Main.tile[num165, num166].nactive() && !Main.tile[num165, num166].topSlope() && !Main.tile[num165, num166 - 1].topSlope() && Main.tileSolid[(int)Main.tile[num165, num166].type] && !Main.tileSolidTop[(int)Main.tile[num165, num166].type]) || (Main.tile[num165, num166 - 1].halfBrick() && Main.tile[num165, num166 - 1].nactive())) && (!Main.tile[num165, num166 - 1].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 1].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 1].type] || (Main.tile[num165, num166 - 1].halfBrick() && (!Main.tile[num165, num166 - 4].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 4].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 4].type]))) && (!Main.tile[num165, num166 - 2].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 2].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 2].type]) && (!Main.tile[num165, num166 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 3].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 3].type]) && (!Main.tile[num165 - num164, num166 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num165 - num164, num166 - 3].type])) - { - float num167 = (float)(num166 * 16); - if (Main.tile[num165, num166].halfBrick()) - { - num167 += 8f; - } - if (Main.tile[num165, num166 - 1].halfBrick()) - { - num167 -= 8f; - } - if (num167 < position2.Y + (float)npc.height) - { - float num168 = position2.Y + (float)npc.height - num167; - float num169 = 16.1f; - if (num168 <= num169) - { - npc.gfxOffY += npc.position.Y + (float)npc.height - num167; - npc.position.Y = num167 - (float)npc.height; - if (num168 < 9f) - { - npc.stepSpeed = 1f; - } - else - { - npc.stepSpeed = 2f; - } - } - } - } - } - if (flag22) - { - int num170 = (int)((npc.position.X + (float)(npc.width / 2) + (float)(15 * npc.direction)) / 16f); - int num171 = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); - if (Main.tile[num170, num171] == null) - { - Main.tile[num170, num171] = new Tile(); - } - if (Main.tile[num170, num171 - 1] == null) - { - Main.tile[num170, num171 - 1] = new Tile(); - } - if (Main.tile[num170, num171 - 2] == null) - { - Main.tile[num170, num171 - 2] = new Tile(); - } - if (Main.tile[num170, num171 - 3] == null) - { - Main.tile[num170, num171 - 3] = new Tile(); - } - if (Main.tile[num170, num171 + 1] == null) - { - Main.tile[num170, num171 + 1] = new Tile(); - } - if (Main.tile[num170 + npc.direction, num171 - 1] == null) - { - Main.tile[num170 + npc.direction, num171 - 1] = new Tile(); - } - if (Main.tile[num170 + npc.direction, num171 + 1] == null) - { - Main.tile[num170 + npc.direction, num171 + 1] = new Tile(); - } - if (Main.tile[num170 - npc.direction, num171 + 1] == null) - { - Main.tile[num170 - npc.direction, num171 + 1] = new Tile(); - } - Main.tile[num170, num171 + 1].halfBrick(); - if ((Main.tile[num170, num171 - 1].nactive() && (Main.tile[num170, num171 - 1].type == 10 || Main.tile[num170, num171 - 1].type == 388)) & flag5) - { - npc.ai[2] += 1f; - npc.ai[3] = 0f; - if (npc.ai[2] >= 60f) - { - npc.velocity.X = 0.5f * (float)-(float)npc.direction; - int num172 = 5; - if (Main.tile[num170, num171 - 1].type == 388) - { - num172 = 2; - } - npc.ai[1] += (float)num172; - npc.ai[2] = 0f; - bool flag23 = false; - if (npc.ai[1] >= 10f) - { - flag23 = true; - npc.ai[1] = 10f; - } - WorldGen.KillTile(num170, num171 - 1, true, false, false); - if ((Main.netMode != NetmodeID.MultiplayerClient || !flag23) && flag23 && Main.netMode != NetmodeID.MultiplayerClient) - { - if (Main.tile[num170, num171 - 1].type == 10) - { - bool flag24 = WorldGen.OpenDoor(num170, num171 - 1, npc.direction); - if (!flag24) - { - npc.ai[3] = (float)num35; - npc.netUpdate = true; - } - if (Main.netMode == NetmodeID.Server & flag24) - { - NetMessage.SendData(MessageID.ChangeDoor, -1, -1, null, 0, (float)num170, (float)(num171 - 1), (float)npc.direction, 0, 0, 0); - } - } - if (Main.tile[num170, num171 - 1].type == 388) - { - bool flag25 = WorldGen.ShiftTallGate(num170, num171 - 1, false); - if (!flag25) - { - npc.ai[3] = (float)num35; - npc.netUpdate = true; - } - if (Main.netMode == NetmodeID.Server & flag25) - { - NetMessage.SendData(MessageID.ChangeDoor, -1, -1, null, 4, (float)num170, (float)(num171 - 1), 0f, 0, 0, 0); - } - } - } - } - } - else - { - int num173 = npc.spriteDirection; - if ((npc.velocity.X < 0f && num173 == -1) || (npc.velocity.X > 0f && num173 == 1)) - { - if (npc.height >= 32 && Main.tile[num170, num171 - 2].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 2].type]) - { - if (Main.tile[num170, num171 - 3].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 3].type]) - { - npc.velocity.Y = -8f; - npc.netUpdate = true; - } - else - { - npc.velocity.Y = -7f; - npc.netUpdate = true; - } - } - else if (Main.tile[num170, num171 - 1].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 1].type]) - { - npc.velocity.Y = -6f; - npc.netUpdate = true; - } - else if (npc.position.Y + (float)npc.height - (float)(num171 * 16) > 20f && Main.tile[num170, num171].nactive() && !Main.tile[num170, num171].topSlope() && Main.tileSolid[(int)Main.tile[num170, num171].type]) - { - npc.velocity.Y = -5f; - npc.netUpdate = true; - } - else if (npc.directionY < 0 && (!Main.tile[num170, num171 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num170, num171 + 1].type]) && (!Main.tile[num170 + npc.direction, num171 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num170 + npc.direction, num171 + 1].type])) - { - npc.velocity.Y = -8f; - npc.velocity.X = npc.velocity.X * 1.5f; - npc.netUpdate = true; - } - else if (flag5) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - if ((npc.velocity.Y == 0f & flag3) && npc.ai[3] == 1f) - { - npc.velocity.Y = -5f; - } - } - } - } - else if (flag5) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - } + Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.35f, 0f, 0.15f); + bool flag3 = false; + if (npc.velocity.X == 0f) + { + flag3 = true; + } + if (npc.justHit) + { + flag3 = false; + } + bool flag4 = false; + bool flag5 = false; + int num35 = 60; + if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) + { + flag4 = true; + } + if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num35) | flag4) + { + npc.ai[3] += 1f; + } + else if ((double)Math.Abs(npc.velocity.X) > 0.9 && npc.ai[3] > 0f) + { + npc.ai[3] -= 1f; + } + if (npc.ai[3] > (float)(num35 * 10)) + { + npc.ai[3] = 0f; + } + if (npc.justHit) + { + npc.ai[3] = 0f; + } + if (npc.ai[3] == (float)num35) + { + npc.netUpdate = true; + } + if (npc.ai[3] < (float)num35) + { + npc.TargetClosest(true); + } + else if (npc.ai[2] <= 0f) + { + if (npc.velocity.X == 0f) + { + if (npc.velocity.Y == 0f) + { + npc.ai[0] += 1f; + if (npc.ai[0] >= 2f) + { + npc.direction *= -1; + npc.spriteDirection = npc.direction; + npc.ai[0] = 0f; + } + } + } + else + { + npc.ai[0] = 0f; + } + if (npc.direction == 0) + { + npc.direction = 1; + } + } + float num65 = 1.2f + ((Main.player[npc.target].Center - npc.Center).Length() * 0.005f); + float num66 = 0.12f + ((Main.player[npc.target].Center - npc.Center).Length() * 0.0005f); + if (CalamityWorld.death) + { + num65 *= 1.5f; + num66 *= 1.5f; + } + if (npc.velocity.X < -num65 || npc.velocity.X > num65) + { + if (npc.velocity.Y == 0f) + npc.velocity *= 0.7f; + } + else if (npc.velocity.X < num65 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + num66; + if (npc.velocity.X > num65) + npc.velocity.X = num65; + } + else if (npc.velocity.X > -num65 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - num66; + if (npc.velocity.X < -num65) + npc.velocity.X = -num65; + } + bool flag22 = false; + if (npc.velocity.Y == 0f) + { + int num161 = (int)(npc.position.Y + (float)npc.height + 7f) / 16; + int arg_A8FB_0 = (int)npc.position.X / 16; + int num162 = (int)(npc.position.X + (float)npc.width) / 16; + for (int num163 = arg_A8FB_0; num163 <= num162; num163++) + { + if (Main.tile[num163, num161] == null) + { + return; + } + if (Main.tile[num163, num161].nactive() && Main.tileSolid[(int)Main.tile[num163, num161].type]) + { + flag22 = true; + break; + } + } + } + if (npc.velocity.Y >= 0f) + { + int num164 = 0; + if (npc.velocity.X < 0f) + { + num164 = -1; + } + if (npc.velocity.X > 0f) + { + num164 = 1; + } + Vector2 position2 = npc.position; + position2.X += npc.velocity.X; + int num165 = (int)((position2.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num164)) / 16f); + int num166 = (int)((position2.Y + (float)npc.height - 1f) / 16f); + if (Main.tile[num165, num166] == null) + { + Main.tile[num165, num166] = new Tile(); + } + if (Main.tile[num165, num166 - 1] == null) + { + Main.tile[num165, num166 - 1] = new Tile(); + } + if (Main.tile[num165, num166 - 2] == null) + { + Main.tile[num165, num166 - 2] = new Tile(); + } + if (Main.tile[num165, num166 - 3] == null) + { + Main.tile[num165, num166 - 3] = new Tile(); + } + if (Main.tile[num165, num166 + 1] == null) + { + Main.tile[num165, num166 + 1] = new Tile(); + } + if (Main.tile[num165 - num164, num166 - 3] == null) + { + Main.tile[num165 - num164, num166 - 3] = new Tile(); + } + if ((float)(num165 * 16) < position2.X + (float)npc.width && (float)(num165 * 16 + 16) > position2.X && ((Main.tile[num165, num166].nactive() && !Main.tile[num165, num166].topSlope() && !Main.tile[num165, num166 - 1].topSlope() && Main.tileSolid[(int)Main.tile[num165, num166].type] && !Main.tileSolidTop[(int)Main.tile[num165, num166].type]) || (Main.tile[num165, num166 - 1].halfBrick() && Main.tile[num165, num166 - 1].nactive())) && (!Main.tile[num165, num166 - 1].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 1].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 1].type] || (Main.tile[num165, num166 - 1].halfBrick() && (!Main.tile[num165, num166 - 4].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 4].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 4].type]))) && (!Main.tile[num165, num166 - 2].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 2].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 2].type]) && (!Main.tile[num165, num166 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 3].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 3].type]) && (!Main.tile[num165 - num164, num166 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num165 - num164, num166 - 3].type])) + { + float num167 = (float)(num166 * 16); + if (Main.tile[num165, num166].halfBrick()) + { + num167 += 8f; + } + if (Main.tile[num165, num166 - 1].halfBrick()) + { + num167 -= 8f; + } + if (num167 < position2.Y + (float)npc.height) + { + float num168 = position2.Y + (float)npc.height - num167; + float num169 = 16.1f; + if (num168 <= num169) + { + npc.gfxOffY += npc.position.Y + (float)npc.height - num167; + npc.position.Y = num167 - (float)npc.height; + if (num168 < 9f) + { + npc.stepSpeed = 1f; + } + else + { + npc.stepSpeed = 2f; + } + } + } + } + } + if (flag22) + { + int num170 = (int)((npc.position.X + (float)(npc.width / 2) + (float)(15 * npc.direction)) / 16f); + int num171 = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); + if (Main.tile[num170, num171] == null) + { + Main.tile[num170, num171] = new Tile(); + } + if (Main.tile[num170, num171 - 1] == null) + { + Main.tile[num170, num171 - 1] = new Tile(); + } + if (Main.tile[num170, num171 - 2] == null) + { + Main.tile[num170, num171 - 2] = new Tile(); + } + if (Main.tile[num170, num171 - 3] == null) + { + Main.tile[num170, num171 - 3] = new Tile(); + } + if (Main.tile[num170, num171 + 1] == null) + { + Main.tile[num170, num171 + 1] = new Tile(); + } + if (Main.tile[num170 + npc.direction, num171 - 1] == null) + { + Main.tile[num170 + npc.direction, num171 - 1] = new Tile(); + } + if (Main.tile[num170 + npc.direction, num171 + 1] == null) + { + Main.tile[num170 + npc.direction, num171 + 1] = new Tile(); + } + if (Main.tile[num170 - npc.direction, num171 + 1] == null) + { + Main.tile[num170 - npc.direction, num171 + 1] = new Tile(); + } + Main.tile[num170, num171 + 1].halfBrick(); + if ((Main.tile[num170, num171 - 1].nactive() && (Main.tile[num170, num171 - 1].type == 10 || Main.tile[num170, num171 - 1].type == 388)) & flag5) + { + npc.ai[2] += 1f; + npc.ai[3] = 0f; + if (npc.ai[2] >= 60f) + { + npc.velocity.X = 0.5f * (float)-(float)npc.direction; + int num172 = 5; + if (Main.tile[num170, num171 - 1].type == 388) + { + num172 = 2; + } + npc.ai[1] += (float)num172; + npc.ai[2] = 0f; + bool flag23 = false; + if (npc.ai[1] >= 10f) + { + flag23 = true; + npc.ai[1] = 10f; + } + WorldGen.KillTile(num170, num171 - 1, true, false, false); + if ((Main.netMode != NetmodeID.MultiplayerClient || !flag23) && flag23 && Main.netMode != NetmodeID.MultiplayerClient) + { + if (Main.tile[num170, num171 - 1].type == 10) + { + bool flag24 = WorldGen.OpenDoor(num170, num171 - 1, npc.direction); + if (!flag24) + { + npc.ai[3] = (float)num35; + npc.netUpdate = true; + } + if (Main.netMode == NetmodeID.Server & flag24) + { + NetMessage.SendData(MessageID.ChangeDoor, -1, -1, null, 0, (float)num170, (float)(num171 - 1), (float)npc.direction, 0, 0, 0); + } + } + if (Main.tile[num170, num171 - 1].type == 388) + { + bool flag25 = WorldGen.ShiftTallGate(num170, num171 - 1, false); + if (!flag25) + { + npc.ai[3] = (float)num35; + npc.netUpdate = true; + } + if (Main.netMode == NetmodeID.Server & flag25) + { + NetMessage.SendData(MessageID.ChangeDoor, -1, -1, null, 4, (float)num170, (float)(num171 - 1), 0f, 0, 0, 0); + } + } + } + } + } + else + { + int num173 = npc.spriteDirection; + if ((npc.velocity.X < 0f && num173 == -1) || (npc.velocity.X > 0f && num173 == 1)) + { + if (npc.height >= 32 && Main.tile[num170, num171 - 2].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 2].type]) + { + if (Main.tile[num170, num171 - 3].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 3].type]) + { + npc.velocity.Y = -8f; + npc.netUpdate = true; + } + else + { + npc.velocity.Y = -7f; + npc.netUpdate = true; + } + } + else if (Main.tile[num170, num171 - 1].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 1].type]) + { + npc.velocity.Y = -6f; + npc.netUpdate = true; + } + else if (npc.position.Y + (float)npc.height - (float)(num171 * 16) > 20f && Main.tile[num170, num171].nactive() && !Main.tile[num170, num171].topSlope() && Main.tileSolid[(int)Main.tile[num170, num171].type]) + { + npc.velocity.Y = -5f; + npc.netUpdate = true; + } + else if (npc.directionY < 0 && (!Main.tile[num170, num171 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num170, num171 + 1].type]) && (!Main.tile[num170 + npc.direction, num171 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num170 + npc.direction, num171 + 1].type])) + { + npc.velocity.Y = -8f; + npc.velocity.X = npc.velocity.X * 1.5f; + npc.netUpdate = true; + } + else if (flag5) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + if ((npc.velocity.Y == 0f & flag3) && npc.ai[3] == 1f) + { + npc.velocity.Y = -5f; + } + } + } + } + else if (flag5) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { @@ -426,8 +426,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedMoonlord); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedMoonlord); } } } diff --git a/NPCs/NormalNPCs/PhantomSpirit.cs b/NPCs/NormalNPCs/PhantomSpirit.cs index ba5abd35a6..190c4dc6fa 100644 --- a/NPCs/NormalNPCs/PhantomSpirit.cs +++ b/NPCs/NormalNPCs/PhantomSpirit.cs @@ -8,7 +8,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class PhantomSpirit : ModNPC + public class PhantomSpirit : ModNPC { public override void SetStaticDefaults() { @@ -34,8 +34,8 @@ namespace CalamityMod.NPCs.NormalNPCs npc.noTileCollide = true; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { diff --git a/NPCs/NormalNPCs/PhantomSpiritL.cs b/NPCs/NormalNPCs/PhantomSpiritL.cs index f89bff63ec..af0b8339b9 100644 --- a/NPCs/NormalNPCs/PhantomSpiritL.cs +++ b/NPCs/NormalNPCs/PhantomSpiritL.cs @@ -38,8 +38,8 @@ namespace CalamityMod.NPCs.NormalNPCs npc.noTileCollide = true; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { @@ -88,9 +88,9 @@ namespace CalamityMod.NPCs.NormalNPCs if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == 20f) { float num151 = 10f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - num149 = num151 / num149; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + num149 = num151 / num149; num147 *= num149; num148 *= num149; Projectile.NewProjectile(vector17.X, vector17.Y, num147, num148, type, damage, 0f, Main.myPlayer, 0f, 0f); @@ -124,7 +124,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 2, 4); + DropHelper.DropItem(npc, ModContent.ItemType(), 2, 4); } } } diff --git a/NPCs/NormalNPCs/PhantomSpiritM.cs b/NPCs/NormalNPCs/PhantomSpiritM.cs index 01cc9b95eb..b607b950f4 100644 --- a/NPCs/NormalNPCs/PhantomSpiritM.cs +++ b/NPCs/NormalNPCs/PhantomSpiritM.cs @@ -8,7 +8,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class PhantomSpiritM : ModNPC + public class PhantomSpiritM : ModNPC { public override void SetStaticDefaults() { @@ -34,8 +34,8 @@ namespace CalamityMod.NPCs.NormalNPCs npc.noTileCollide = true; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { @@ -83,7 +83,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 1, 3); + DropHelper.DropItem(npc, ModContent.ItemType(), 1, 3); } } } diff --git a/NPCs/NormalNPCs/PhantomSpiritS.cs b/NPCs/NormalNPCs/PhantomSpiritS.cs index 3f29fdee4f..0fddf1bfc7 100644 --- a/NPCs/NormalNPCs/PhantomSpiritS.cs +++ b/NPCs/NormalNPCs/PhantomSpiritS.cs @@ -8,7 +8,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class PhantomSpiritS : ModNPC + public class PhantomSpiritS : ModNPC { public override void SetStaticDefaults() { @@ -33,8 +33,8 @@ namespace CalamityMod.NPCs.NormalNPCs npc.noTileCollide = true; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { @@ -81,7 +81,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); + DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); } } } diff --git a/NPCs/NormalNPCs/Piggy.cs b/NPCs/NormalNPCs/Piggy.cs index a29826f8fb..53879f6307 100644 --- a/NPCs/NormalNPCs/Piggy.cs +++ b/NPCs/NormalNPCs/Piggy.cs @@ -31,10 +31,10 @@ namespace CalamityMod.NPCs.NormalNPCs banner = npc.type; bannerItem = ModContent.ItemType(); npc.catchItem = (short)ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { diff --git a/NPCs/NormalNPCs/ProfanedEnergyBody.cs b/NPCs/NormalNPCs/ProfanedEnergyBody.cs index 95bd397907..03d3717a28 100644 --- a/NPCs/NormalNPCs/ProfanedEnergyBody.cs +++ b/NPCs/NormalNPCs/ProfanedEnergyBody.cs @@ -21,7 +21,7 @@ namespace CalamityMod.NPCs.NormalNPCs npc.width = 72; npc.height = 36; npc.defense = 50; - npc.DR_NERD(0.1f); + npc.DR_NERD(0.1f); npc.lifeMax = 4500; npc.knockBackResist = 0f; aiType = -1; @@ -32,11 +32,11 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath55; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { @@ -84,7 +84,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 2, 4); + DropHelper.DropItem(npc, ModContent.ItemType(), 2, 4); } } } diff --git a/NPCs/NormalNPCs/ProfanedEnergyLantern.cs b/NPCs/NormalNPCs/ProfanedEnergyLantern.cs index dbcf6d2d7a..6d485f8fd4 100644 --- a/NPCs/NormalNPCs/ProfanedEnergyLantern.cs +++ b/NPCs/NormalNPCs/ProfanedEnergyLantern.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class ProfanedEnergyLantern : ModNPC + public class ProfanedEnergyLantern : ModNPC { public override void SetStaticDefaults() { @@ -212,7 +212,7 @@ 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)); - Texture2D chain = ModContent.GetTexture("CalamityMod/NPCs/NormalNPCs/ProfanedEnergySegment"); + 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); @@ -222,7 +222,7 @@ namespace CalamityMod.NPCs.NormalNPCs return true; } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { diff --git a/NPCs/NormalNPCs/Rotdog.cs b/NPCs/NormalNPCs/Rotdog.cs index 70ae99d5c4..890ed7aca9 100644 --- a/NPCs/NormalNPCs/Rotdog.cs +++ b/NPCs/NormalNPCs/Rotdog.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class Rotdog : ModNPC + public class Rotdog : ModNPC { public override void SetStaticDefaults() { @@ -29,10 +29,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath5; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { diff --git a/NPCs/NormalNPCs/SandTortoise.cs b/NPCs/NormalNPCs/SandTortoise.cs index ab42b3e807..7cd11e77a2 100644 --- a/NPCs/NormalNPCs/SandTortoise.cs +++ b/NPCs/NormalNPCs/SandTortoise.cs @@ -20,7 +20,7 @@ namespace CalamityMod.NPCs.NormalNPCs npc.width = 46; npc.height = 32; npc.defense = 30; - npc.DR_NERD(0.25f); + npc.DR_NERD(0.25f); npc.scale = 1.5f; npc.lifeMax = 580; npc.knockBackResist = 0.2f; @@ -31,10 +31,10 @@ namespace CalamityMod.NPCs.NormalNPCs npc.noGravity = false; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } public override void HitEffect(int hitDirection, double damage) { @@ -62,7 +62,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItemChance(npc, ItemID.TurtleShell, 0.1f); + DropHelper.DropItemChance(npc, ItemID.TurtleShell, 0.1f); } } } diff --git a/NPCs/NormalNPCs/ScornEater.cs b/NPCs/NormalNPCs/ScornEater.cs index 3f39c088ba..95874fdd22 100644 --- a/NPCs/NormalNPCs/ScornEater.cs +++ b/NPCs/NormalNPCs/ScornEater.cs @@ -8,7 +8,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class ScornEater : ModNPC + public class ScornEater : ModNPC { public override void SetStaticDefaults() { @@ -18,14 +18,14 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 3f; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 3f; npc.aiStyle = -1; npc.damage = 90; npc.width = 160; npc.height = 160; npc.defense = 38; - npc.DR_NERD(0.05f); + npc.DR_NERD(0.05f); npc.lifeMax = 9000; npc.knockBackResist = 0f; aiType = -1; @@ -34,21 +34,21 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/ScornDeath"); banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { - npc.TargetClosest(true); - if ((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)) - npc.noTileCollide = true; - else - npc.noTileCollide = false; + npc.TargetClosest(true); + if ((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)) + npc.noTileCollide = true; + else + npc.noTileCollide = false; - if (npc.velocity.Y == 0f) + if (npc.velocity.Y == 0f) { npc.ai[2] += 1f; int num321 = 20; @@ -56,10 +56,10 @@ namespace CalamityMod.NPCs.NormalNPCs { num321 = 12; } - if (CalamityWorld.death) - { - num321 /= 4; - } + if (CalamityWorld.death) + { + num321 /= 4; + } if (npc.ai[2] < (float)num321) { npc.velocity.X = npc.velocity.X * 0.9f; @@ -76,15 +76,15 @@ namespace CalamityMod.NPCs.NormalNPCs if (npc.ai[3] >= 4f) { npc.ai[3] = 0f; - npc.noTileCollide = true; - if (npc.ai[1] == 2f) + npc.noTileCollide = true; + if (npc.ai[1] == 2f) { npc.velocity.X = (float)npc.direction * 15f; - if (Main.player[npc.target].position.Y < npc.position.Y + (float)npc.height) - npc.velocity.Y = -12f; - else - npc.velocity.Y = 12f; + if (Main.player[npc.target].position.Y < npc.position.Y + (float)npc.height) + npc.velocity.Y = -12f; + else + npc.velocity.Y = 12f; npc.ai[1] = 0f; } @@ -92,13 +92,13 @@ namespace CalamityMod.NPCs.NormalNPCs { npc.velocity.X = (float)npc.direction * 21f; - if (Main.player[npc.target].position.Y < npc.position.Y + (float)npc.height) - npc.velocity.Y = -6f; - else - npc.velocity.Y = 12f; + if (Main.player[npc.target].position.Y < npc.position.Y + (float)npc.height) + npc.velocity.Y = -6f; + else + npc.velocity.Y = 12f; } - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ScornJump"), (int)npc.Center.X, (int)npc.Center.Y); - } + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ScornJump"), (int)npc.Center.X, (int)npc.Center.Y); + } npc.netUpdate = true; } else @@ -161,12 +161,12 @@ namespace CalamityMod.NPCs.NormalNPCs return SpawnCondition.OverworldHallow.Chance / 4f; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 180, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 180, true); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.soundDelay == 0) { @@ -194,7 +194,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 2, 4); + DropHelper.DropItem(npc, ModContent.ItemType(), 2, 4); } } } diff --git a/NPCs/NormalNPCs/SeaUrchin.cs b/NPCs/NormalNPCs/SeaUrchin.cs index a75974092f..8f2cc29309 100644 --- a/NPCs/NormalNPCs/SeaUrchin.cs +++ b/NPCs/NormalNPCs/SeaUrchin.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class SeaUrchin : ModNPC + public class SeaUrchin : ModNPC { public override void SetStaticDefaults() { @@ -29,11 +29,11 @@ namespace CalamityMod.NPCs.NormalNPCs npc.behindTiles = true; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { diff --git a/NPCs/NormalNPCs/ShockstormShuttle.cs b/NPCs/NormalNPCs/ShockstormShuttle.cs index 86d2984e19..54ea70557a 100644 --- a/NPCs/NormalNPCs/ShockstormShuttle.cs +++ b/NPCs/NormalNPCs/ShockstormShuttle.cs @@ -9,392 +9,392 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class ShockstormShuttle : ModNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shockstorm Shuttle"); - Main.npcFrameCount[npc.type] = 4; - } + public class ShockstormShuttle : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shockstorm Shuttle"); + Main.npcFrameCount[npc.type] = 4; + } - public override void SetDefaults() - { - npc.npcSlots = 3f; - npc.damage = 30; - npc.width = 64; - npc.height = 38; - npc.defense = 15; - npc.DR_NERD(0.15f); - npc.lifeMax = 150; - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.value = Item.buyPrice(0, 0, 5, 0); - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; - npc.noGravity = true; - npc.noTileCollide = true; - banner = npc.type; - bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + public override void SetDefaults() + { + npc.npcSlots = 3f; + npc.damage = 30; + npc.width = 64; + npc.height = 38; + npc.defense = 15; + npc.DR_NERD(0.15f); + npc.lifeMax = 150; + npc.aiStyle = -1; + aiType = -1; + npc.knockBackResist = 0f; + npc.value = Item.buyPrice(0, 0, 5, 0); + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.noGravity = true; + npc.noTileCollide = true; + banner = npc.type; + bannerItem = ModContent.ItemType(); + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } - public override void AI() - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= 60f) - { - npc.localAI[0] = 0f; - 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 projSpeed = 12f; - Vector2 npcPos = npc.Center; - float targetX = Main.player[npc.target].Center.X - npcPos.X; - float YAdjust = Math.Abs(targetX) * 0.1f; - float targetY = Main.player[npc.target].Center.Y - npcPos.Y - YAdjust; - Vector2 velocity = new Vector2(targetX, targetY); - float targetDist = velocity.Length(); - targetDist = projSpeed / targetDist; - velocity.X *= targetDist; - velocity.Y *= targetDist; - int projDmg = 30; - if (Main.expertMode) - { - projDmg = 22; - } - int projType = ProjectileID.MartianTurretBolt; - if (Main.rand.NextBool(8)) - { - projType = ProjectileID.SaucerLaser; - } - npcPos.X += velocity.X; - npcPos.Y += velocity.Y; - for (int num186 = 0; num186 < 2; num186++) - { - velocity = Main.player[npc.target].Center - npcPos; - targetDist = velocity.Length(); - targetDist = projSpeed / targetDist; - velocity.X += Main.rand.Next(-20, 21); - velocity.Y += Main.rand.Next(-20, 21); - velocity.X *= targetDist; - velocity.Y *= targetDist; - Projectile.NewProjectile(npcPos, velocity, projType, projDmg, 0f, Main.myPlayer, 0f, 0f); - } - } - } - } - if (npc.localAI[3] == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[3] = 1f; - } - Vector2 center16 = npc.Center; - Player player8 = Main.player[npc.target]; - if (npc.target < 0 || npc.target == Main.maxPlayers || player8.dead || !player8.active) - { - npc.TargetClosest(); - player8 = Main.player[npc.target]; - npc.netUpdate = true; - } - if ((player8.dead || Vector2.Distance(player8.Center, center16) > 3200f) && npc.ai[0] != 1f) - { - npc.ai[0] = -1f; - npc.netUpdate = true; - } - if (npc.ai[0] == -1f) - { - npc.velocity.Y = npc.velocity.Y - 0.4f; - if (npc.timeLeft > 10) - { - npc.timeLeft = 10; - } - if (!player8.dead) - { - npc.timeLeft = 300; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - return; - } - } - else if (npc.ai[0] == 0f) - { - int num1580 = 0; - if (npc.ai[3] >= 580f) - { - num1580 = 0; - } - else if (npc.ai[3] >= 440f) - { - num1580 = 5; - } - else if (npc.ai[3] >= 420f) - { - num1580 = 4; - } - else if (npc.ai[3] >= 280f) - { - num1580 = 3; - } - else if (npc.ai[3] >= 260f) - { - num1580 = 2; - } - else if (npc.ai[3] >= 20f) - { - num1580 = 1; - } - npc.ai[3] += 1f; - if (npc.ai[3] >= 600f) - { - npc.ai[3] = 0f; - } - int num1581 = num1580; - if (npc.ai[3] >= 580f) - { - num1580 = 0; - } - else if (npc.ai[3] >= 440f) - { - num1580 = 5; - } - else if (npc.ai[3] >= 420f) - { - num1580 = 4; - } - else if (npc.ai[3] >= 280f) - { - num1580 = 3; - } - else if (npc.ai[3] >= 260f) - { - num1580 = 2; - } - else if (npc.ai[3] >= 20f) - { - num1580 = 1; - } - if (num1580 != num1581) - { - if (num1580 == 0) - { - npc.ai[2] = 0f; - } - if (num1580 == 1) - { - npc.ai[2] = (float)((Math.Sign((player8.Center - center16).X) == 1) ? 1 : -1); - } - if (num1580 == 2) - { - npc.ai[2] = 0f; - } - npc.netUpdate = true; - } - if (num1580 == 0) - { - if (npc.ai[2] == 0f) - { - npc.ai[2] = (float)(-600 * Math.Sign((center16 - player8.Center).X)); - } - Vector2 vector196 = player8.Center + new Vector2(npc.ai[2], -250f) - center16; - if (vector196.Length() < 50f) - { - npc.ai[3] = 19f; - } - else - { - vector196.Normalize(); - npc.velocity = Vector2.Lerp(npc.velocity, vector196 * 16f, 0.1f); - } - } - if (num1580 == 1) - { - int num1582 = (int)npc.Center.X / 16; - int num1583 = (int)(npc.position.Y + (float)npc.height) / 16; - int num1584 = 0; - bool flag149 = Main.tile[num1582, num1583].nactive() && Main.tileSolid[(int)Main.tile[num1582, num1583].type] && !Main.tileSolidTop[(int)Main.tile[num1582, num1583].type]; - if (flag149) - { - num1584 = 1; - } - else - { - while (num1584 < 150 && num1583 + num1584 < Main.maxTilesY) - { - int num1585 = num1583 + num1584; - bool flag150 = Main.tile[num1582, num1585].nactive() && Main.tileSolid[(int)Main.tile[num1582, num1585].type] && !Main.tileSolidTop[(int)Main.tile[num1582, num1585].type]; - if (flag150) - { - num1584--; - break; - } - num1584++; - } - } - float num1586 = (float)(num1584 * 16); - float num1587 = 250f; - if (num1586 < num1587) - { - float num1588 = -4f; - if (-num1588 > num1586) - { - num1588 = -num1586; - } - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, num1588, 0.05f); - } - else - { - npc.velocity.Y = npc.velocity.Y * 0.95f; - } - npc.velocity.X = 3.5f * npc.ai[2]; - } - if (num1580 == 2) - { - if (npc.ai[2] == 0f) - { - npc.ai[2] = (float)(300 * Math.Sign((center16 - player8.Center).X)); - } - Vector2 vector197 = player8.Center + new Vector2(npc.ai[2], -170f) - center16; - int num1589 = (int)npc.Center.X / 16; - int num1590 = (int)(npc.position.Y + (float)npc.height) / 16; - int num1591 = 0; - bool flag151 = Main.tile[num1589, num1590].nactive() && Main.tileSolid[(int)Main.tile[num1589, num1590].type] && !Main.tileSolidTop[(int)Main.tile[num1589, num1590].type]; - if (flag151) - { - num1591 = 1; - } - else - { - while (num1591 < 150 && num1590 + num1591 < Main.maxTilesY) - { - int num1592 = num1590 + num1591; - bool flag152 = Main.tile[num1589, num1592].nactive() && Main.tileSolid[(int)Main.tile[num1589, num1592].type] && !Main.tileSolidTop[(int)Main.tile[num1589, num1592].type]; - if (flag152) - { - num1591--; - break; - } - num1591++; - } - } - float num1593 = (float)(num1591 * 16); - float num1594 = 170f; - if (num1593 < num1594) - { - vector197.Y -= num1594 - num1593; - } - if (vector197.Length() < 70f) - { - npc.ai[3] = 279f; - } - else - { - vector197.Normalize(); - npc.velocity = Vector2.Lerp(npc.velocity, vector197 * 20f, 0.1f); - } - } - else if (num1580 == 3) - { - float num1595 = 0.85f; - int num1596 = (int)npc.Center.X / 16; - int num1597 = (int)(npc.position.Y + (float)npc.height) / 16; - int num1598 = 0; - bool flag153 = Main.tile[num1596, num1597].nactive() && Main.tileSolid[(int)Main.tile[num1596, num1597].type] && !Main.tileSolidTop[(int)Main.tile[num1596, num1597].type]; - if (flag153) - { - num1598 = 1; - } - else - { - while (num1598 < 150 && num1597 + num1598 < Main.maxTilesY) - { - int num1599 = num1597 + num1598; - bool flag154 = Main.tile[num1596, num1599].nactive() && Main.tileSolid[(int)Main.tile[num1596, num1599].type] && !Main.tileSolidTop[(int)Main.tile[num1596, num1599].type]; - if (flag154) - { - num1598--; - break; - } - num1598++; - } - } - float num1600 = (float)(num1598 * 16); - float num1601 = 170f; - if (num1600 < num1601) - { - float num1602 = -4f; - if (-num1602 > num1600) - { - num1602 = -num1600; - } - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, num1602, 0.05f); - } - else - { - npc.velocity.Y = npc.velocity.Y * num1595; - } - npc.velocity.X = npc.velocity.X * num1595; - } - if (num1580 == 4) - { - Vector2 vector198 = player8.Center + new Vector2(0f, -250f) - center16; - if (vector198.Length() < 50f) - { - npc.ai[3] = 439f; - return; - } - vector198.Normalize(); - npc.velocity = Vector2.Lerp(npc.velocity, vector198 * 16f, 0.1f); - return; - } - else if (num1580 == 5) - { - npc.velocity *= 0.85f; - return; - } - } - } + public override void AI() + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[0] += 1f; + if (npc.localAI[0] >= 60f) + { + npc.localAI[0] = 0f; + 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 projSpeed = 12f; + Vector2 npcPos = npc.Center; + float targetX = Main.player[npc.target].Center.X - npcPos.X; + float YAdjust = Math.Abs(targetX) * 0.1f; + float targetY = Main.player[npc.target].Center.Y - npcPos.Y - YAdjust; + Vector2 velocity = new Vector2(targetX, targetY); + float targetDist = velocity.Length(); + targetDist = projSpeed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; + int projDmg = 30; + if (Main.expertMode) + { + projDmg = 22; + } + int projType = ProjectileID.MartianTurretBolt; + if (Main.rand.NextBool(8)) + { + projType = ProjectileID.SaucerLaser; + } + npcPos.X += velocity.X; + npcPos.Y += velocity.Y; + for (int num186 = 0; num186 < 2; num186++) + { + velocity = Main.player[npc.target].Center - npcPos; + targetDist = velocity.Length(); + targetDist = projSpeed / targetDist; + velocity.X += Main.rand.Next(-20, 21); + velocity.Y += Main.rand.Next(-20, 21); + velocity.X *= targetDist; + velocity.Y *= targetDist; + Projectile.NewProjectile(npcPos, velocity, projType, projDmg, 0f, Main.myPlayer, 0f, 0f); + } + } + } + } + if (npc.localAI[3] == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[3] = 1f; + } + Vector2 center16 = npc.Center; + Player player8 = Main.player[npc.target]; + if (npc.target < 0 || npc.target == Main.maxPlayers || player8.dead || !player8.active) + { + npc.TargetClosest(); + player8 = Main.player[npc.target]; + npc.netUpdate = true; + } + if ((player8.dead || Vector2.Distance(player8.Center, center16) > 3200f) && npc.ai[0] != 1f) + { + npc.ai[0] = -1f; + npc.netUpdate = true; + } + if (npc.ai[0] == -1f) + { + npc.velocity.Y = npc.velocity.Y - 0.4f; + if (npc.timeLeft > 10) + { + npc.timeLeft = 10; + } + if (!player8.dead) + { + npc.timeLeft = 300; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + return; + } + } + else if (npc.ai[0] == 0f) + { + int num1580 = 0; + if (npc.ai[3] >= 580f) + { + num1580 = 0; + } + else if (npc.ai[3] >= 440f) + { + num1580 = 5; + } + else if (npc.ai[3] >= 420f) + { + num1580 = 4; + } + else if (npc.ai[3] >= 280f) + { + num1580 = 3; + } + else if (npc.ai[3] >= 260f) + { + num1580 = 2; + } + else if (npc.ai[3] >= 20f) + { + num1580 = 1; + } + npc.ai[3] += 1f; + if (npc.ai[3] >= 600f) + { + npc.ai[3] = 0f; + } + int num1581 = num1580; + if (npc.ai[3] >= 580f) + { + num1580 = 0; + } + else if (npc.ai[3] >= 440f) + { + num1580 = 5; + } + else if (npc.ai[3] >= 420f) + { + num1580 = 4; + } + else if (npc.ai[3] >= 280f) + { + num1580 = 3; + } + else if (npc.ai[3] >= 260f) + { + num1580 = 2; + } + else if (npc.ai[3] >= 20f) + { + num1580 = 1; + } + if (num1580 != num1581) + { + if (num1580 == 0) + { + npc.ai[2] = 0f; + } + if (num1580 == 1) + { + npc.ai[2] = (float)((Math.Sign((player8.Center - center16).X) == 1) ? 1 : -1); + } + if (num1580 == 2) + { + npc.ai[2] = 0f; + } + npc.netUpdate = true; + } + if (num1580 == 0) + { + if (npc.ai[2] == 0f) + { + npc.ai[2] = (float)(-600 * Math.Sign((center16 - player8.Center).X)); + } + Vector2 vector196 = player8.Center + new Vector2(npc.ai[2], -250f) - center16; + if (vector196.Length() < 50f) + { + npc.ai[3] = 19f; + } + else + { + vector196.Normalize(); + npc.velocity = Vector2.Lerp(npc.velocity, vector196 * 16f, 0.1f); + } + } + if (num1580 == 1) + { + int num1582 = (int)npc.Center.X / 16; + int num1583 = (int)(npc.position.Y + (float)npc.height) / 16; + int num1584 = 0; + bool flag149 = Main.tile[num1582, num1583].nactive() && Main.tileSolid[(int)Main.tile[num1582, num1583].type] && !Main.tileSolidTop[(int)Main.tile[num1582, num1583].type]; + if (flag149) + { + num1584 = 1; + } + else + { + while (num1584 < 150 && num1583 + num1584 < Main.maxTilesY) + { + int num1585 = num1583 + num1584; + bool flag150 = Main.tile[num1582, num1585].nactive() && Main.tileSolid[(int)Main.tile[num1582, num1585].type] && !Main.tileSolidTop[(int)Main.tile[num1582, num1585].type]; + if (flag150) + { + num1584--; + break; + } + num1584++; + } + } + float num1586 = (float)(num1584 * 16); + float num1587 = 250f; + if (num1586 < num1587) + { + float num1588 = -4f; + if (-num1588 > num1586) + { + num1588 = -num1586; + } + npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, num1588, 0.05f); + } + else + { + npc.velocity.Y = npc.velocity.Y * 0.95f; + } + npc.velocity.X = 3.5f * npc.ai[2]; + } + if (num1580 == 2) + { + if (npc.ai[2] == 0f) + { + npc.ai[2] = (float)(300 * Math.Sign((center16 - player8.Center).X)); + } + Vector2 vector197 = player8.Center + new Vector2(npc.ai[2], -170f) - center16; + int num1589 = (int)npc.Center.X / 16; + int num1590 = (int)(npc.position.Y + (float)npc.height) / 16; + int num1591 = 0; + bool flag151 = Main.tile[num1589, num1590].nactive() && Main.tileSolid[(int)Main.tile[num1589, num1590].type] && !Main.tileSolidTop[(int)Main.tile[num1589, num1590].type]; + if (flag151) + { + num1591 = 1; + } + else + { + while (num1591 < 150 && num1590 + num1591 < Main.maxTilesY) + { + int num1592 = num1590 + num1591; + bool flag152 = Main.tile[num1589, num1592].nactive() && Main.tileSolid[(int)Main.tile[num1589, num1592].type] && !Main.tileSolidTop[(int)Main.tile[num1589, num1592].type]; + if (flag152) + { + num1591--; + break; + } + num1591++; + } + } + float num1593 = (float)(num1591 * 16); + float num1594 = 170f; + if (num1593 < num1594) + { + vector197.Y -= num1594 - num1593; + } + if (vector197.Length() < 70f) + { + npc.ai[3] = 279f; + } + else + { + vector197.Normalize(); + npc.velocity = Vector2.Lerp(npc.velocity, vector197 * 20f, 0.1f); + } + } + else if (num1580 == 3) + { + float num1595 = 0.85f; + int num1596 = (int)npc.Center.X / 16; + int num1597 = (int)(npc.position.Y + (float)npc.height) / 16; + int num1598 = 0; + bool flag153 = Main.tile[num1596, num1597].nactive() && Main.tileSolid[(int)Main.tile[num1596, num1597].type] && !Main.tileSolidTop[(int)Main.tile[num1596, num1597].type]; + if (flag153) + { + num1598 = 1; + } + else + { + while (num1598 < 150 && num1597 + num1598 < Main.maxTilesY) + { + int num1599 = num1597 + num1598; + bool flag154 = Main.tile[num1596, num1599].nactive() && Main.tileSolid[(int)Main.tile[num1596, num1599].type] && !Main.tileSolidTop[(int)Main.tile[num1596, num1599].type]; + if (flag154) + { + num1598--; + break; + } + num1598++; + } + } + float num1600 = (float)(num1598 * 16); + float num1601 = 170f; + if (num1600 < num1601) + { + float num1602 = -4f; + if (-num1602 > num1600) + { + num1602 = -num1600; + } + npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, num1602, 0.05f); + } + else + { + npc.velocity.Y = npc.velocity.Y * num1595; + } + npc.velocity.X = npc.velocity.X * num1595; + } + if (num1580 == 4) + { + Vector2 vector198 = player8.Center + new Vector2(0f, -250f) - center16; + if (vector198.Length() < 50f) + { + npc.ai[3] = 439f; + return; + } + vector198.Normalize(); + npc.velocity = Vector2.Lerp(npc.velocity, vector198 * 16f, 0.1f); + return; + } + else if (num1580 == 5) + { + npc.velocity *= 0.85f; + return; + } + } + } - public override void FindFrame(int frameHeight) - { - npc.frameCounter += 0.15f; - npc.frameCounter %= Main.npcFrameCount[npc.type]; - int frame = (int)npc.frameCounter; - npc.frame.Y = frame * frameHeight; - } + public override void FindFrame(int frameHeight) + { + npc.frameCounter += 0.15f; + npc.frameCounter %= Main.npcFrameCount[npc.type]; + int frame = (int)npc.frameCounter; + npc.frame.Y = frame * frameHeight; + } - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 234, hitDirection, -1f, 0, default, 1f); - } - if (npc.life <= 0) - { - for (int k = 0; k < 20; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 234, hitDirection, -1f, 0, default, 1f); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 234, hitDirection, -1f, 0, default, 1f); + } + if (npc.life <= 0) + { + for (int k = 0; k < 20; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 234, hitDirection, -1f, 0, default, 1f); + } + } + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (spawnInfo.playerSafe || !Main.hardMode) - { - return 0f; - } - return SpawnCondition.Sky.Chance * 0.1f; - } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.playerSafe || !Main.hardMode) + { + return 0f; + } + return SpawnCondition.Sky.Chance * 0.1f; + } - public override void NPCLoot() - { - DropHelper.DropItemCondition(npc, ItemID.MartianConduitPlating, NPC.downedGolemBoss, 1, 10, 30); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - } - } + public override void NPCLoot() + { + DropHelper.DropItemCondition(npc, ItemID.MartianConduitPlating, NPC.downedGolemBoss, 1, 10, 30); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + } + } } diff --git a/NPCs/NormalNPCs/StormlionCharger.cs b/NPCs/NormalNPCs/StormlionCharger.cs index ecfde81d31..19970b6109 100644 --- a/NPCs/NormalNPCs/StormlionCharger.cs +++ b/NPCs/NormalNPCs/StormlionCharger.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class StormlionCharger : ModNPC + public class StormlionCharger : ModNPC { public override void SetStaticDefaults() { @@ -29,11 +29,11 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath34; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = false; + npc.Calamity().VulnerableToWater = true; + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/NormalNPCs/SunBat.cs b/NPCs/NormalNPCs/SunBat.cs index acf486652b..8ef4c9db44 100644 --- a/NPCs/NormalNPCs/SunBat.cs +++ b/NPCs/NormalNPCs/SunBat.cs @@ -30,27 +30,27 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath4; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } - public override void AI() - { - CalamityGlobalAI.BuffedBatAI(npc, mod); - } - - public override void FindFrame(int frameHeight) + public override void AI() { - if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; + CalamityGlobalAI.BuffedBatAI(npc, mod); + } - npc.rotation = npc.velocity.X * 0.1f; + public override void FindFrame(int frameHeight) + { + if (npc.velocity.X > 0f) + npc.spriteDirection = 1; + if (npc.velocity.X < 0f) + npc.spriteDirection = -1; - npc.frameCounter += 0.15f; + npc.rotation = npc.velocity.X * 0.1f; + + npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; int frame = (int)npc.frameCounter; npc.frame.Y = frame * frameHeight; @@ -88,7 +88,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); } } } diff --git a/NPCs/NormalNPCs/Sunskater.cs b/NPCs/NormalNPCs/Sunskater.cs index 23ca3e43df..4fca8e71bf 100644 --- a/NPCs/NormalNPCs/Sunskater.cs +++ b/NPCs/NormalNPCs/Sunskater.cs @@ -36,11 +36,11 @@ namespace CalamityMod.NPCs.NormalNPCs npc.knockBackResist = 0.7f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -105,8 +105,8 @@ namespace CalamityMod.NPCs.NormalNPCs npc.TargetClosest(true); npc.velocity.X = npc.velocity.X + (float)npc.direction * 0.15f; npc.velocity.Y = npc.velocity.Y + (float)npc.directionY * 0.15f; - npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -10f, 10f); - npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -10f, 10f); + npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -10f, 10f); + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -10f, 10f); } else { @@ -224,7 +224,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode, 3, 1, 1); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode, 3, 1, 1); } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/NormalNPCs/SuperDummyNPC.cs b/NPCs/NormalNPCs/SuperDummyNPC.cs index 6c3660dc0e..34ae1fb189 100644 --- a/NPCs/NormalNPCs/SuperDummyNPC.cs +++ b/NPCs/NormalNPCs/SuperDummyNPC.cs @@ -3,46 +3,46 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class SuperDummyNPC : ModNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Super Dummy"); - } + public class SuperDummyNPC : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Super Dummy"); + } - public override void SetDefaults() - { - npc.width = 18; - npc.height = 48; - npc.damage = 0; - npc.defense = 0; - npc.lifeMax = 9999999; - npc.HitSound = SoundID.NPCHit15; - npc.DeathSound = SoundID.NPCDeath2; - npc.value = 0f; - npc.knockBackResist = 0f; - npc.netAlways = true; - npc.aiStyle = 0; - } + public override void SetDefaults() + { + npc.width = 18; + npc.height = 48; + npc.damage = 0; + npc.defense = 0; + npc.lifeMax = 9999999; + npc.HitSound = SoundID.NPCHit15; + npc.DeathSound = SoundID.NPCDeath2; + npc.value = 0f; + npc.knockBackResist = 0f; + npc.netAlways = true; + npc.aiStyle = 0; + } - public override void UpdateLifeRegen(ref int damage) - { - npc.lifeRegen += 2000000; - } + public override void UpdateLifeRegen(ref int damage) + { + npc.lifeRegen += 2000000; + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + return false; + } - public override bool CheckDead() - { - if (npc.lifeRegen < 0) - { - npc.life = npc.lifeMax; - return false; - } - return true; - } - } + public override bool CheckDead() + { + if (npc.lifeRegen < 0) + { + npc.life = npc.lifeMax; + return false; + } + return true; + } + } } diff --git a/NPCs/NormalNPCs/WildBumblefuck.cs b/NPCs/NormalNPCs/WildBumblefuck.cs index 39f5a34685..2e61ec12db 100644 --- a/NPCs/NormalNPCs/WildBumblefuck.cs +++ b/NPCs/NormalNPCs/WildBumblefuck.cs @@ -7,14 +7,14 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class WildBumblefuck : ModNPC + public class WildBumblefuck : ModNPC { public override void SetStaticDefaults() { DisplayName.SetDefault("Draconic Swarmer"); Main.npcFrameCount[npc.type] = 5; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override string Texture => "CalamityMod/NPCs/Bumblebirb/BumbleFolly"; @@ -23,99 +23,99 @@ namespace CalamityMod.NPCs.NormalNPCs npc.npcSlots = 1f; npc.aiStyle = -1; aiType = -1; - npc.damage = 90; - npc.width = 120; + npc.damage = 90; + npc.width = 120; npc.height = 80; npc.defense = 20; npc.LifeMaxNERB(9375, 11250, 5000); // Old HP - 12000, 15000 npc.knockBackResist = 0f; npc.lavaImmune = true; - npc.noTileCollide = true; + npc.noTileCollide = true; npc.noGravity = true; npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit51; npc.DeathSound = SoundID.NPCDeath46; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (spawnInfo.playerSafe || !NPC.downedMoonlord || spawnInfo.player.Calamity().ZoneSunkenSea || NPC.AnyNPCs(npc.type)) - { - return 0f; - } - return SpawnCondition.SurfaceJungle.Chance * 0.14f; - } - - public override void AI() - { - CalamityAI.Bumblebirb2AI(npc, mod, false); + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; } - public override bool PreNPCLoot() - { - DropHelper.DropItemSpray(npc, ModContent.ItemType(), 2, 4); - return false; - } - - public override void FindFrame(int frameHeight) + public override float SpawnChance(NPCSpawnInfo spawnInfo) { - npc.frameCounter += npc.ai[0] == 2.1f ? 1.5 : 1D; - if (npc.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base - { - npc.frameCounter = 0D; - npc.frame.Y += frameHeight; - } - if (npc.frame.Y >= frameHeight * 4) - { - npc.frame.Y = 0; - } - } + if (spawnInfo.playerSafe || !NPC.downedMoonlord || spawnInfo.player.Calamity().ZoneSunkenSea || NPC.AnyNPCs(npc.type)) + { + return 0f; + } + return SpawnCondition.SurfaceJungle.Chance * 0.14f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override void AI() + { + CalamityAI.Bumblebirb2AI(npc, mod, false); + } - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Color color36 = Color.Gold; - float amount9 = 0.5f; - int num153 = npc.ai[0] == 2.1f ? 7 : 0; + public override bool PreNPCLoot() + { + DropHelper.DropItemSpray(npc, ModContent.ItemType(), 2, 4); + return false; + } - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + public override void FindFrame(int frameHeight) + { + npc.frameCounter += npc.ai[0] == 2.1f ? 1.5 : 1D; + if (npc.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base + { + npc.frameCounter = 0D; + npc.frame.Y += frameHeight; + } + if (npc.frame.Y >= frameHeight * 4) + { + npc.frame.Y = 0; + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - return false; - } + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Color color36 = Color.Gold; + float amount9 = 0.5f; + int num153 = npc.ai[0] == 2.1f ? 7 : 0; - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - public override void HitEffect(int hitDirection, double damage) + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + return true; + } + + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/NormalNPCs/WulfrumDrone.cs b/NPCs/NormalNPCs/WulfrumDrone.cs index c7b79f9929..47a505aac6 100644 --- a/NPCs/NormalNPCs/WulfrumDrone.cs +++ b/NPCs/NormalNPCs/WulfrumDrone.cs @@ -68,9 +68,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath14; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void SendExtraAI(BinaryWriter writer) => writer.Write(FlyAwayTimer); @@ -95,7 +95,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (player.dead || !player.active || farFromPlayer || obstanceInFrontOfPlayer) { if (FlyAwayTimer > 360) - { + { npc.velocity = Vector2.Lerp(npc.velocity, Vector2.UnitY * -8f, 0.1f); npc.rotation = npc.rotation.AngleTowards(0f, MathHelper.ToRadians(15f)); npc.noTileCollide = true; @@ -179,7 +179,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) return 0f; @@ -206,7 +206,7 @@ namespace CalamityMod.NPCs.NormalNPCs DropHelper.DropItem(npc, ModContent.ItemType(), 1, 3); DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode); DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.07f); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); } } } diff --git a/NPCs/NormalNPCs/WulfrumGyrator.cs b/NPCs/NormalNPCs/WulfrumGyrator.cs index 3190b0ae51..7210cd45b6 100644 --- a/NPCs/NormalNPCs/WulfrumGyrator.cs +++ b/NPCs/NormalNPCs/WulfrumGyrator.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class WulfrumGyrator : ModNPC + public class WulfrumGyrator : ModNPC { public float TimeSpentStuck { @@ -53,9 +53,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath14; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void FindFrame(int frameHeight) { @@ -157,7 +157,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) return 0f; return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.020f : 0.115f) * pylonMult; @@ -184,7 +184,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.07f); } } diff --git a/NPCs/NormalNPCs/WulfrumHovercraft.cs b/NPCs/NormalNPCs/WulfrumHovercraft.cs index ed1da85d81..e2b2301755 100644 --- a/NPCs/NormalNPCs/WulfrumHovercraft.cs +++ b/NPCs/NormalNPCs/WulfrumHovercraft.cs @@ -75,9 +75,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.noTileCollide = true; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -247,7 +247,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) return 0f; @@ -281,7 +281,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { DropHelper.DropItem(npc, ModContent.ItemType(), 2, 3); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.07f); } } diff --git a/NPCs/NormalNPCs/WulfrumPylon.cs b/NPCs/NormalNPCs/WulfrumPylon.cs index 2e7a44c638..473c426c21 100644 --- a/NPCs/NormalNPCs/WulfrumPylon.cs +++ b/NPCs/NormalNPCs/WulfrumPylon.cs @@ -53,9 +53,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath14; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void AI() { @@ -152,7 +152,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - float pylonMult = !NPC.AnyNPCs(ModContent.NPCType()) ? 1.3f : 1f; + float pylonMult = !NPC.AnyNPCs(ModContent.NPCType()) ? 1.3f : 1f; if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) return 0f; diff --git a/NPCs/NormalNPCs/WulfrumRover.cs b/NPCs/NormalNPCs/WulfrumRover.cs index e00cbde270..ad37416066 100644 --- a/NPCs/NormalNPCs/WulfrumRover.cs +++ b/NPCs/NormalNPCs/WulfrumRover.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class WulfrumRover : ModNPC + public class WulfrumRover : ModNPC { public float TimeSpentStuck { @@ -52,9 +52,9 @@ namespace CalamityMod.NPCs.NormalNPCs npc.DeathSound = SoundID.NPCDeath14; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void FindFrame(int frameHeight) { @@ -117,7 +117,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) return 0f; return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.010f : 0.135f) * pylonMult; @@ -162,8 +162,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.07f); } } diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index faac839cf8..6f06582e7b 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -23,69 +23,69 @@ using CalamityMod.World; namespace CalamityMod.NPCs.OldDuke { - [AutoloadBossHead] + [AutoloadBossHead] public class OldDuke : ModNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Old Duke"); + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("The Old Duke"); Main.npcFrameCount[npc.type] = 7; - NPCID.Sets.TrailingMode[npc.type] = 1; - } - - public override void SetDefaults() - { - npc.width = 150; + NPCID.Sets.TrailingMode[npc.type] = 1; + } + + public override void SetDefaults() + { + npc.width = 150; npc.height = 100; npc.aiStyle = -1; - aiType = -1; - npc.GetNPCDamage(); - npc.defense = 90; - npc.DR_NERD(0.5f, null, null, null, true); - npc.LifeMaxNERB(495000, 594000, 400000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.knockBackResist = 0f; + aiType = -1; + npc.GetNPCDamage(); + npc.defense = 90; + npc.DR_NERD(0.5f, null, null, null, true); + npc.LifeMaxNERB(495000, 594000, 400000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.knockBackResist = 0f; npc.noTileCollide = true; npc.noGravity = true; npc.npcSlots = 15f; npc.HitSound = SoundID.NPCHit14; npc.DeathSound = SoundID.NPCDeath20; - npc.value = Item.buyPrice(4, 0, 0, 0); - npc.boss = true; + npc.value = Item.buyPrice(4, 0, 0, 0); + npc.boss = true; npc.netAlways = true; npc.timeLeft = NPC.activeTime * 30; - music = CalamityMod.Instance.GetMusicFromMusicMod("BoomerDuke") ?? MusicID.Boss1; + music = CalamityMod.Instance.GetMusicFromMusicMod("BoomerDuke") ?? MusicID.Boss1; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.rotation); - writer.Write(npc.spriteDirection); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.rotation = reader.ReadSingle(); - npc.spriteDirection = reader.ReadInt32(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - CalamityAI.OldDukeAI(npc, mod); + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.rotation); + writer.Write(npc.spriteDirection); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.rotation = reader.ReadSingle(); + npc.spriteDirection = reader.ReadInt32(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityAI.OldDukeAI(npc, mod); } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) @@ -96,8 +96,8 @@ namespace CalamityMod.NPCs.OldDuke public override void FindFrame(int frameHeight) { - bool tired = npc.Calamity().newAI[1] == 1f; - if (npc.ai[0] == 0f || npc.ai[0] == 5f || npc.ai[0] == 10f || npc.ai[0] == 12f) + bool tired = npc.Calamity().newAI[1] == 1f; + if (npc.ai[0] == 0f || npc.ai[0] == 5f || npc.ai[0] == 10f || npc.ai[0] == 12f) { int num114 = tired ? 14 : 7; if (npc.ai[0] == 5f || npc.ai[0] == 12f) @@ -115,15 +115,15 @@ namespace CalamityMod.NPCs.OldDuke npc.frame.Y = 0; } } - if (npc.ai[0] == 1f || npc.ai[0] == 6f || npc.ai[0] == 11f) - { - npc.frame.Y = frameHeight * 2; - } - if (npc.ai[0] == 2f || npc.ai[0] == 7f || npc.ai[0] == 14f) - { - npc.frame.Y = frameHeight * 6; - } - if (npc.ai[0] == 3f || npc.ai[0] == 8f || npc.ai[0] == 13f || npc.ai[0] == -1f) + if (npc.ai[0] == 1f || npc.ai[0] == 6f || npc.ai[0] == 11f) + { + npc.frame.Y = frameHeight * 2; + } + if (npc.ai[0] == 2f || npc.ai[0] == 7f || npc.ai[0] == 14f) + { + npc.frame.Y = frameHeight * 6; + } + if (npc.ai[0] == 3f || npc.ai[0] == 8f || npc.ai[0] == 13f || npc.ai[0] == -1f) { int num115 = 120; if (npc.ai[2] < (num115 - 50) || npc.ai[2] > (num115 - 10)) @@ -175,280 +175,280 @@ namespace CalamityMod.NPCs.OldDuke } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / Main.npcFrameCount[npc.type] / 2); - Color color = lightColor; - Color color36 = Color.White; - float amount9 = 0f; - bool flag8 = npc.ai[0] > 4f; - bool flag9 = npc.ai[0] > 9f && npc.ai[0] <= 12f; - int num150 = 120; - int num151 = 60; - if (flag9) - { - color = CalamityGlobalNPC.buffColor(color, 0.4f, 0.8f, 0.4f, 1f); - } - else if (flag8) - { - color = CalamityGlobalNPC.buffColor(color, 0.5f, 0.7f, 0.5f, 1f); - } - else if (npc.ai[0] == 4f && npc.ai[2] > num150) - { - float num152 = npc.ai[2] - num150; - num152 /= num151; - color = CalamityGlobalNPC.buffColor(color, 1f - 0.5f * num152, 1f - 0.3f * num152, 1f - 0.5f * num152, 1f); - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + { + spriteEffects = SpriteEffects.FlipHorizontally; + } + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / Main.npcFrameCount[npc.type] / 2); + Color color = lightColor; + Color color36 = Color.White; + float amount9 = 0f; + bool flag8 = npc.ai[0] > 4f; + bool flag9 = npc.ai[0] > 9f && npc.ai[0] <= 12f; + int num150 = 120; + int num151 = 60; + if (flag9) + { + color = CalamityGlobalNPC.buffColor(color, 0.4f, 0.8f, 0.4f, 1f); + } + else if (flag8) + { + color = CalamityGlobalNPC.buffColor(color, 0.5f, 0.7f, 0.5f, 1f); + } + else if (npc.ai[0] == 4f && npc.ai[2] > num150) + { + float num152 = npc.ai[2] - num150; + num152 /= num151; + color = CalamityGlobalNPC.buffColor(color, 1f - 0.5f * num152, 1f - 0.3f * num152, 1f - 0.5f * num152, 1f); + } - int num153 = 10; - int num154 = 2; - if (npc.ai[0] == -1f) - { - num153 = 0; - } - if (npc.ai[0] == 0f || npc.ai[0] == 5f || npc.ai[0] == 10f || npc.ai[0] == 12f) - { - num153 = 7; - } - if (npc.ai[0] == 1f || npc.ai[0] == 6f || npc.ai[0] > 9f) - { - color36 = Color.Lime; - amount9 = 0.5f; - } - else - { - color = lightColor; - } + int num153 = 10; + int num154 = 2; + if (npc.ai[0] == -1f) + { + num153 = 0; + } + if (npc.ai[0] == 0f || npc.ai[0] == 5f || npc.ai[0] == 10f || npc.ai[0] == 12f) + { + num153 = 7; + } + if (npc.ai[0] == 1f || npc.ai[0] == 6f || npc.ai[0] > 9f) + { + color36 = Color.Lime; + amount9 = 0.5f; + } + else + { + color = lightColor; + } - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += num154) - { - Color color38 = color; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += num154) + { + Color color38 = color; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - int num156 = 0; - float num157 = 0f; - float scaleFactor9 = 0f; + int num156 = 0; + float num157 = 0f; + float scaleFactor9 = 0f; - if (npc.ai[0] == -1f) - { - num156 = 0; - } + if (npc.ai[0] == -1f) + { + num156 = 0; + } - if (npc.ai[0] == 3f || npc.ai[0] == 8f || npc.ai[0] == 13f) - { - int num158 = 60; - int num159 = 30; - if (npc.ai[2] > num158) - { - num156 = 6; - num157 = 1f - (float)Math.Cos((npc.ai[2] - num158) / num159 * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 40f; - } - } + if (npc.ai[0] == 3f || npc.ai[0] == 8f || npc.ai[0] == 13f) + { + int num158 = 60; + int num159 = 30; + if (npc.ai[2] > num158) + { + num156 = 6; + num157 = 1f - (float)Math.Cos((npc.ai[2] - num158) / num159 * MathHelper.TwoPi); + num157 /= 3f; + scaleFactor9 = 40f; + } + } - if ((npc.ai[0] == 4f || npc.ai[0] == 9f) && npc.ai[2] > num150) - { - num156 = 6; - num157 = 1f - (float)Math.Cos((npc.ai[2] - num150) / num151 * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 60f; - } + if ((npc.ai[0] == 4f || npc.ai[0] == 9f) && npc.ai[2] > num150) + { + num156 = 6; + num157 = 1f - (float)Math.Cos((npc.ai[2] - num150) / num151 * MathHelper.TwoPi); + num157 /= 3f; + scaleFactor9 = 60f; + } - if (npc.ai[0] == 12f) - { - num156 = 6; - num157 = 1f - (float)Math.Cos(npc.ai[2] / 30f * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 20f; - } + if (npc.ai[0] == 12f) + { + num156 = 6; + num157 = 1f - (float)Math.Cos(npc.ai[2] / 30f * MathHelper.TwoPi); + num157 /= 3f; + scaleFactor9 = 20f; + } - if (CalamityConfig.Instance.Afterimages) - { - for (int num160 = 0; num160 < num156; num160++) - { - Color color39 = lightColor; - color39 = Color.Lerp(color39, color36, amount9); - color39 = npc.GetAlpha(color39); - color39 *= 1f - num157; - Vector2 vector42 = npc.Center + (num160 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; - vector42 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector42 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector42, npc.frame, color39, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num160 = 0; num160 < num156; num160++) + { + Color color39 = lightColor; + color39 = Color.Lerp(color39, color36, amount9); + color39 = npc.GetAlpha(color39); + color39 *= 1f - num157; + Vector2 vector42 = npc.Center + (num160 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; + vector42 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector42 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector42, npc.frame, color39, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Color color2 = lightColor; - color2 = Color.Lerp(color2, color36, amount9); - color2 = npc.GetAlpha(color2); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, (npc.ai[0] > 9f ? color2 : npc.GetAlpha(lightColor)), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Color color2 = lightColor; + color2 = Color.Lerp(color2, color36, amount9); + color2 = npc.GetAlpha(color2); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, (npc.ai[0] > 9f ? color2 : npc.GetAlpha(lightColor)), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - if (npc.ai[0] >= 4f && npc.Calamity().newAI[1] != 1f) - { - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/OldDuke/OldDukeGlow"); - Color color40 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - color36 = Color.Yellow; + if (npc.ai[0] >= 4f && npc.Calamity().newAI[1] != 1f) + { + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/OldDuke/OldDukeGlow"); + Color color40 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + color36 = Color.Yellow; - amount9 = 1f; - num157 = 0.5f; - scaleFactor9 = 10f; - num154 = 1; + amount9 = 1f; + num157 = 0.5f; + scaleFactor9 = 10f; + num154 = 1; - if (npc.ai[0] == 4f || npc.ai[0] == 9f) - { - float num161 = npc.ai[2] - num150; - num161 /= num151; - color36 *= num161; - color40 *= num161; - } + if (npc.ai[0] == 4f || npc.ai[0] == 9f) + { + float num161 = npc.ai[2] - num150; + num161 /= num151; + color36 *= num161; + color40 *= num161; + } - if (npc.ai[0] == 12f) - { - float num162 = npc.ai[2]; - num162 /= 30f; - if (num162 > 0.5f) - { - num162 = 1f - num162; - } - num162 *= 2f; - num162 = 1f - num162; - color36 *= num162; - color40 *= num162; - } + if (npc.ai[0] == 12f) + { + float num162 = npc.ai[2]; + num162 /= 30f; + if (num162 > 0.5f) + { + num162 = 1f - num162; + } + num162 *= 2f; + num162 = 1f - num162; + color36 *= num162; + color40 *= num162; + } - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163 += num154) - { - Color color41 = color40; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163 += num154) + { + Color color41 = color40; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } - for (int num164 = 1; num164 < num156; num164++) - { - Color color42 = color40; - color42 = Color.Lerp(color42, color36, amount9); - color42 = npc.GetAlpha(color42); - color42 *= 1f - num157; - Vector2 vector45 = npc.Center + (num164 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; - vector45 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector45 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector45, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + for (int num164 = 1; num164 < num156; num164++) + { + Color color42 = color40; + color42 = Color.Lerp(color42, color36, amount9); + color42 = npc.GetAlpha(color42); + color42 *= 1f - num157; + Vector2 vector45 = npc.Center + (num164 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; + vector45 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector45 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector45, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color40, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + spriteBatch.Draw(texture2D15, vector43, npc.frame, color40, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } - return false; - } + return false; + } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref string name, ref int potionType) { potionType = ModContent.ItemType(); } public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedBoomerDuke); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedBoomerDuke); + CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedBoomerDuke); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) { - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + // Weapons + float w = DropHelper.NormalWeaponDropRateFloat; + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); } - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); - // Mark Old Duke as dead - CalamityWorld.downedBoomerDuke = true; + // Mark Old Duke as dead + CalamityWorld.downedBoomerDuke = true; - // Mark first acid rain encounter as true even if he wasn't fought in the acid rain, because it makes sense - CalamityWorld.encounteredOldDuke = true; + // Mark first acid rain encounter as true even if he wasn't fought in the acid rain, because it makes sense + CalamityWorld.encounteredOldDuke = true; CalamityNetcode.SyncWorld(); } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + return true; + } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 480); - } - - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life > 0) - { - int num211 = 0; - while (num211 < damage / npc.lifeMax * 100.0) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - num211++; - } - } - else - { - for (int num212 = 0; num212 < 150; num212++) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, 2 * hitDirection, -2f, 0, default, 1f); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 480); + } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life > 0) + { + int num211 = 0; + while (num211 < damage / npc.lifeMax * 100.0) + { + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); + num211++; + } + } + else + { + for (int num212 = 0; num212 < 150; num212++) + { + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, 2 * hitDirection, -2f, 0, default, 1f); + } - Gore.NewGore(npc.Center + Vector2.UnitX * 20f * npc.direction, npc.velocity, mod.GetGoreSlot("Gores/OldDuke/OldDukeGore"), npc.scale); - Gore.NewGore(npc.Center + Vector2.UnitX * 20f * npc.direction, npc.velocity, mod.GetGoreSlot("Gores/OldDuke/OldDukeGore2"), npc.scale); - Gore.NewGore(npc.Center - Vector2.UnitX * 20f * npc.direction, npc.velocity, mod.GetGoreSlot("Gores/OldDuke/OldDukeGore3"), npc.scale); - Gore.NewGore(npc.Center - Vector2.UnitX * 20f * npc.direction, npc.velocity, mod.GetGoreSlot("Gores/OldDuke/OldDukeGore4"), npc.scale); - } - } - } + Gore.NewGore(npc.Center + Vector2.UnitX * 20f * npc.direction, npc.velocity, mod.GetGoreSlot("Gores/OldDuke/OldDukeGore"), npc.scale); + Gore.NewGore(npc.Center + Vector2.UnitX * 20f * npc.direction, npc.velocity, mod.GetGoreSlot("Gores/OldDuke/OldDukeGore2"), npc.scale); + Gore.NewGore(npc.Center - Vector2.UnitX * 20f * npc.direction, npc.velocity, mod.GetGoreSlot("Gores/OldDuke/OldDukeGore3"), npc.scale); + Gore.NewGore(npc.Center - Vector2.UnitX * 20f * npc.direction, npc.velocity, mod.GetGoreSlot("Gores/OldDuke/OldDukeGore4"), npc.scale); + } + } + } } diff --git a/NPCs/OldDuke/OldDukeSharkron.cs b/NPCs/OldDuke/OldDukeSharkron.cs index 4bf1b40e04..f0673d5b3a 100644 --- a/NPCs/OldDuke/OldDukeSharkron.cs +++ b/NPCs/OldDuke/OldDukeSharkron.cs @@ -13,297 +13,297 @@ using CalamityMod.World; namespace CalamityMod.NPCs.OldDuke { - public class OldDukeSharkron : ModNPC - { - bool spawnedProjectiles = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Sulphurous Sharkron"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } - - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.aiStyle = -1; - aiType = -1; - npc.width = 44; - npc.height = 44; - npc.GetNPCDamage(); - npc.defense = 100; - npc.lifeMax = 6000; - if (BossRushEvent.BossRushActive) - { - npc.lifeMax = 10000; - } - npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = SoundID.NPCDeath1; - npc.knockBackResist = 0f; - npc.alpha = 255; - npc.noGravity = true; - npc.dontTakeDamage = true; - npc.noTileCollide = true; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + public class OldDukeSharkron : ModNPC + { + bool spawnedProjectiles = false; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sulphurous Sharkron"); + NPCID.Sets.TrailingMode[npc.type] = 1; + } + + public override void SetDefaults() + { + npc.Calamity().canBreakPlayerDefense = true; + npc.aiStyle = -1; + aiType = -1; + npc.width = 44; + npc.height = 44; + npc.GetNPCDamage(); + npc.defense = 100; + npc.lifeMax = 6000; + if (BossRushEvent.BossRushActive) + { + npc.lifeMax = 10000; + } + npc.HitSound = SoundID.NPCHit1; + npc.DeathSound = SoundID.NPCDeath1; + npc.knockBackResist = 0f; + npc.alpha = 255; + npc.noGravity = true; + npc.dontTakeDamage = true; + npc.noTileCollide = true; + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.dontTakeDamage); - writer.Write(npc.noGravity); - writer.Write(spawnedProjectiles); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.dontTakeDamage); + writer.Write(npc.noGravity); + writer.Write(spawnedProjectiles); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.dontTakeDamage = reader.ReadBoolean(); - npc.noGravity = reader.ReadBoolean(); - spawnedProjectiles = reader.ReadBoolean(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.dontTakeDamage = reader.ReadBoolean(); + npc.noGravity = reader.ReadBoolean(); + spawnedProjectiles = reader.ReadBoolean(); + } - public override void AI() - { - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + public override void AI() + { + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(false); - npc.netUpdate = true; - } + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) + { + npc.TargetClosest(false); + npc.netUpdate = true; + } - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2(-npc.velocity.Y, -npc.velocity.X); - } - else - { - npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - } + if (npc.velocity.X < 0f) + { + npc.spriteDirection = -1; + npc.rotation = (float)Math.Atan2(-npc.velocity.Y, -npc.velocity.X); + } + else + { + npc.spriteDirection = 1; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + } - npc.alpha -= 6; - if (npc.alpha < 0) - npc.alpha = 0; + npc.alpha -= 6; + if (npc.alpha < 0) + npc.alpha = 0; - // Fly towards Old Duke - bool normalAI = npc.ai[3] == 0f; + // Fly towards Old Duke + bool normalAI = npc.ai[3] == 0f; - // Fly up - bool upwardAI = npc.ai[3] < 0f; + // Fly up + bool upwardAI = npc.ai[3] < 0f; - // Fly down - bool downwardAI = npc.ai[3] > 0f; + // Fly down + bool downwardAI = npc.ai[3] > 0f; - float flyTowardTargetGateValue = malice ? 60f : death ? 70f : revenge ? 75f : expertMode ? 80f : 90f; - float extraTime = malice ? 90f : death ? 100f : revenge ? 105f : expertMode ? 110f : 120f; - float aiGateValue = flyTowardTargetGateValue + extraTime; - if (!normalAI) - aiGateValue -= extraTime * 0.3f; - float explodeIntoGoreGateValue = aiGateValue + extraTime; - float fallDownGateValue = aiGateValue + extraTime * 0.5f; - float maxVelocity = malice ? 24f : death ? 22f : revenge ? 21f : expertMode ? 20f : 18f; + float flyTowardTargetGateValue = malice ? 60f : death ? 70f : revenge ? 75f : expertMode ? 80f : 90f; + float extraTime = malice ? 90f : death ? 100f : revenge ? 105f : expertMode ? 110f : 120f; + float aiGateValue = flyTowardTargetGateValue + extraTime; + if (!normalAI) + aiGateValue -= extraTime * 0.3f; + float explodeIntoGoreGateValue = aiGateValue + extraTime; + float fallDownGateValue = aiGateValue + extraTime * 0.5f; + float maxVelocity = malice ? 24f : death ? 22f : revenge ? 21f : expertMode ? 20f : 18f; - if (npc.ai[0] == 0f) - { - // Set velocity to fly towards a specified location on the first frame - if (npc.ai[1] == 0f) - { - if (normalAI) - npc.velocity = Vector2.Normalize(Main.npc[(int)npc.ai[2]].Center - npc.Center) * (maxVelocity - 6f); - else - npc.velocity = new Vector2(npc.ai[2], npc.ai[3]); + if (npc.ai[0] == 0f) + { + // Set velocity to fly towards a specified location on the first frame + if (npc.ai[1] == 0f) + { + if (normalAI) + npc.velocity = Vector2.Normalize(Main.npc[(int)npc.ai[2]].Center - npc.Center) * (maxVelocity - 6f); + else + npc.velocity = new Vector2(npc.ai[2], npc.ai[3]); - Main.PlaySound(SoundID.NPCDeath19, npc.position); - } + Main.PlaySound(SoundID.NPCDeath19, npc.position); + } - // Fly towards a target after a certain time has passed - npc.ai[1] += 1f; - if (npc.ai[1] >= flyTowardTargetGateValue) - { - // Start second part of AI if not inside tiles and a certain time has passed - if (!Collision.SolidCollision(npc.position, npc.width, npc.height) && npc.ai[1] >= aiGateValue) - npc.ai[0] = 1f; + // Fly towards a target after a certain time has passed + npc.ai[1] += 1f; + if (npc.ai[1] >= flyTowardTargetGateValue) + { + // Start second part of AI if not inside tiles and a certain time has passed + if (!Collision.SolidCollision(npc.position, npc.width, npc.height) && npc.ai[1] >= aiGateValue) + npc.ai[0] = 1f; - // If not set to fly towards Old Duke from the start, accelerate - if (!normalAI) - { - if (npc.velocity.Length() < maxVelocity) - npc.velocity *= 1.01f; - } + // If not set to fly towards Old Duke from the start, accelerate + if (!normalAI) + { + if (npc.velocity.Length() < maxVelocity) + npc.velocity *= 1.01f; + } - // Fly towards the target - float scaleFactor2 = npc.velocity.Length(); - Vector2 vector17 = Main.player[npc.target].Center - npc.Center; - vector17.Normalize(); - vector17 *= scaleFactor2; - float inertia = malice ? 16f : death ? 18f : revenge ? 20f : expertMode ? 22f : 25f; - npc.velocity = (npc.velocity * (inertia - 1f) + vector17) / inertia; - npc.velocity.Normalize(); - npc.velocity *= scaleFactor2; - } - } - else if (npc.ai[0] == 1f) - { - // Move slower if set to fly upward from the start - if (upwardAI) - maxVelocity -= 6f; + // Fly towards the target + float scaleFactor2 = npc.velocity.Length(); + Vector2 vector17 = Main.player[npc.target].Center - npc.Center; + vector17.Normalize(); + vector17 *= scaleFactor2; + float inertia = malice ? 16f : death ? 18f : revenge ? 20f : expertMode ? 22f : 25f; + npc.velocity = (npc.velocity * (inertia - 1f) + vector17) / inertia; + npc.velocity.Normalize(); + npc.velocity *= scaleFactor2; + } + } + else if (npc.ai[0] == 1f) + { + // Move slower if set to fly upward from the start + if (upwardAI) + maxVelocity -= 6f; - // Decrease velocity if moving faster than max - if (npc.velocity.Length() > maxVelocity) - npc.velocity *= 0.99f; + // Decrease velocity if moving faster than max + if (npc.velocity.Length() > maxVelocity) + npc.velocity *= 0.99f; - npc.dontTakeDamage = false; + npc.dontTakeDamage = false; - // Explode into gores if colliding with tiles or after a certain time has passed - npc.ai[1] += 1f; - if (Collision.SolidCollision(npc.position, npc.width, npc.height) || npc.ai[1] >= explodeIntoGoreGateValue) - { - if (npc.DeathSound != null) - Main.PlaySound(npc.DeathSound, npc.position); + // Explode into gores if colliding with tiles or after a certain time has passed + npc.ai[1] += 1f; + if (Collision.SolidCollision(npc.position, npc.width, npc.height) || npc.ai[1] >= explodeIntoGoreGateValue) + { + if (npc.DeathSound != null) + Main.PlaySound(npc.DeathSound, npc.position); - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - return; - } + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } - // Fall down after a certain time has passed - if (npc.ai[1] >= fallDownGateValue) - { - npc.noGravity = false; - npc.velocity.Y += 0.3f; - } - } - } + // Fall down after a certain time has passed + if (npc.ai[1] >= fallDownGateValue) + { + npc.noGravity = false; + npc.velocity.Y += 0.3f; + } + } + } - public override bool PreNPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override bool PreNPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - return false; - } + return false; + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.FlipHorizontally; - if (npc.spriteDirection == -1) - spriteEffects = SpriteEffects.None; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.FlipHorizontally; + if (npc.spriteDirection == -1) + spriteEffects = SpriteEffects.None; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Color color36 = Color.Lime; - float amount9 = 0.5f; - int num153 = 10; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Color color36 = Color.Lime; + float amount9 = 0.5f; + int num153 = 10; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return npc.alpha == 0; - } + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + return npc.alpha == 0; + } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 240); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 240); + } public override bool CheckDead() - { - Main.PlaySound(SoundID.NPCDeath12, npc.position); + { + Main.PlaySound(SoundID.NPCDeath12, npc.position); - npc.position.X = npc.position.X + (npc.width / 2); + npc.position.X = npc.position.X + (npc.width / 2); npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = npc.height = 96; npc.position.X = npc.position.X - (npc.width / 2); npc.position.Y = npc.position.Y - (npc.height / 2); - for (int num621 = 0; num621 < 15; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity.Y *= 6f; - Main.dust[num622].velocity.X *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } + for (int num621 = 0; num621 < 15; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity.Y *= 6f; + Main.dust[num622].velocity.X *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } - for (int num623 = 0; num623 < 30; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Blood, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity.Y *= 10f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Blood, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity.X *= 2f; - } + for (int num623 = 0; num623 < 30; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Blood, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity.Y *= 10f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity.X *= 2f; + } - if (Main.netMode != NetmodeID.MultiplayerClient && !spawnedProjectiles) - { - spawnedProjectiles = true; - int spawnX = npc.width / 2; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < 2; i++) - Projectile.NewProjectile(npc.Center.X + Main.rand.Next(-spawnX, spawnX), npc.Center.Y, - Main.rand.Next(-3, 4), Main.rand.Next(-12, -6), type, damage, 0f, Main.myPlayer); - } + if (Main.netMode != NetmodeID.MultiplayerClient && !spawnedProjectiles) + { + spawnedProjectiles = true; + int spawnX = npc.width / 2; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + for (int i = 0; i < 2; i++) + Projectile.NewProjectile(npc.Center.X + Main.rand.Next(-spawnX, spawnX), npc.Center.Y, + Main.rand.Next(-3, 4), Main.rand.Next(-12, -6), type, damage, 0f, Main.myPlayer); + } - return true; + return true; } public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } - if (npc.life <= 0) - { - for (int k = 0; k < 20; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } - } - } - } + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); + } + if (npc.life <= 0) + { + for (int k = 0; k < 20; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); + } + } + } + } } \ No newline at end of file diff --git a/NPCs/OldDuke/OldDukeToothBall.cs b/NPCs/OldDuke/OldDukeToothBall.cs index 621b364bd8..871f938250 100644 --- a/NPCs/OldDuke/OldDukeToothBall.cs +++ b/NPCs/OldDuke/OldDukeToothBall.cs @@ -12,67 +12,67 @@ using CalamityMod.Events; namespace CalamityMod.NPCs.OldDuke { - public class OldDukeToothBall : ModNPC - { - bool spawnedProjectiles = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tooth Ball"); - } - - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.aiStyle = -1; - aiType = -1; - npc.GetNPCDamage(); - npc.width = 40; - npc.height = 40; - npc.defense = 0; - npc.lifeMax = 3750; - if (BossRushEvent.BossRushActive) - { - npc.lifeMax = 7500; - } - npc.alpha = 255; + public class OldDukeToothBall : ModNPC + { + bool spawnedProjectiles = false; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tooth Ball"); + } + + public override void SetDefaults() + { + npc.Calamity().canBreakPlayerDefense = true; + npc.aiStyle = -1; + aiType = -1; + npc.GetNPCDamage(); + npc.width = 40; + npc.height = 40; + npc.defense = 0; + npc.lifeMax = 3750; + if (BossRushEvent.BossRushActive) + { + npc.lifeMax = 7500; + } + npc.alpha = 255; npc.knockBackResist = 0f; - npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = SoundID.NPCDeath11; + npc.HitSound = SoundID.NPCHit1; + npc.DeathSound = SoundID.NPCDeath11; npc.noGravity = true; npc.noTileCollide = true; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.dontTakeDamage); - writer.Write(spawnedProjectiles); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.dontTakeDamage); + writer.Write(spawnedProjectiles); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.dontTakeDamage = reader.ReadBoolean(); - spawnedProjectiles = reader.ReadBoolean(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.dontTakeDamage = reader.ReadBoolean(); + spawnedProjectiles = reader.ReadBoolean(); + } - public override void AI() - { - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + public override void AI() + { + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - npc.rotation += npc.velocity.X * 0.05f; + npc.rotation += npc.velocity.X * 0.05f; if (npc.alpha > 0) npc.alpha -= 15; - npc.TargetClosest(false); - Player player = Main.player[npc.target]; - if (!player.active || player.dead) + npc.TargetClosest(false); + Player player = Main.player[npc.target]; + if (!player.active || player.dead) { npc.TargetClosest(false); player = Main.player[npc.target]; @@ -92,10 +92,10 @@ namespace CalamityMod.NPCs.OldDuke { npc.dontTakeDamage = false; npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - return; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; } npc.ai[3] += 1f; @@ -107,13 +107,13 @@ namespace CalamityMod.NPCs.OldDuke } float num1372 = death ? 14f : revenge ? 13f : 12f; - if (expertMode) - { - float speedUpMult = BossRushEvent.BossRushActive ? 0.015f : CalamityWorld.malice ? 0.0125f : 0.01f; - num1372 += Vector2.Distance(player.Center, npc.Center) * speedUpMult; - } + if (expertMode) + { + float speedUpMult = BossRushEvent.BossRushActive ? 0.015f : CalamityWorld.malice ? 0.0125f : 0.01f; + num1372 += Vector2.Distance(player.Center, npc.Center) * speedUpMult; + } - Vector2 vector167 = new Vector2(npc.Center.X + npc.direction * 20, npc.Center.Y + 6f); + Vector2 vector167 = new Vector2(npc.Center.X + npc.direction * 20, npc.Center.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(num1373 * num1373 + num1374 * num1374); @@ -151,57 +151,57 @@ namespace CalamityMod.NPCs.OldDuke npc.velocity.Y = (npc.velocity.Y * 7f + num1374) / 8f; } - float num1247 = CalamityWorld.malice ? 0.65f : 0.5f; - for (int num1248 = 0; num1248 < Main.maxNPCs; num1248++) - { - if (Main.npc[num1248].active) - { - if (num1248 != npc.whoAmI && Main.npc[num1248].type == npc.type) - { - if (Vector2.Distance(npc.Center, Main.npc[num1248].Center) < 48f) - { - if (npc.position.X < Main.npc[num1248].position.X) - npc.velocity.X -= num1247; - else - npc.velocity.X += num1247; + float num1247 = CalamityWorld.malice ? 0.65f : 0.5f; + for (int num1248 = 0; num1248 < Main.maxNPCs; num1248++) + { + if (Main.npc[num1248].active) + { + if (num1248 != npc.whoAmI && Main.npc[num1248].type == npc.type) + { + if (Vector2.Distance(npc.Center, Main.npc[num1248].Center) < 48f) + { + if (npc.position.X < Main.npc[num1248].position.X) + npc.velocity.X -= num1247; + else + npc.velocity.X += num1247; - if (npc.position.Y < Main.npc[num1248].position.Y) - npc.velocity.Y -= num1247; - else - npc.velocity.Y += num1247; - } - } - } - } - } + if (npc.position.Y < Main.npc[num1248].position.Y) + npc.velocity.Y -= num1247; + else + npc.velocity.Y += num1247; + } + } + } + } + } - public override bool PreNPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override bool PreNPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - return false; - } + return false; + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return npc.alpha == 0; - } + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; + return npc.alpha == 0; + } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 240); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 240); + } public override bool CheckDead() { @@ -237,40 +237,40 @@ namespace CalamityMod.NPCs.OldDuke if (Main.netMode != NetmodeID.MultiplayerClient && !spawnedProjectiles) { - spawnedProjectiles = true; - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - for (int k = 0; k < totalProjectiles; k++) - { - float velocity = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? Main.rand.Next(6, 10) : Main.rand.Next(7, 11); - Vector2 vector255 = new Vector2(0f, -velocity).RotatedBy(radians * k); - int proj = Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 360; - } + spawnedProjectiles = true; + int totalProjectiles = 4; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + for (int k = 0; k < totalProjectiles; k++) + { + float velocity = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? Main.rand.Next(6, 10) : Main.rand.Next(7, 11); + Vector2 vector255 = new Vector2(0f, -velocity).RotatedBy(radians * k); + int proj = Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); + Main.projectile[proj].timeLeft = 360; + } - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer); + type = ModContent.ProjectileType(); + damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer); } return true; } public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } - if (npc.life <= 0) - { - for (int k = 0; k < 15; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } - } - } - } + { + for (int k = 0; k < 3; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); + } + if (npc.life <= 0) + { + for (int k = 0; k < 15; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); + } + } + } + } } \ No newline at end of file diff --git a/NPCs/Other/CalamitasEnchantDemon.cs b/NPCs/Other/CalamitasEnchantDemon.cs index 9e5c790243..4e829be630 100644 --- a/NPCs/Other/CalamitasEnchantDemon.cs +++ b/NPCs/Other/CalamitasEnchantDemon.cs @@ -6,160 +6,160 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Other { - public class CalamitasEnchantDemon : ModNPC - { - public Player Target => Main.player[npc.target]; - public ref float AttackTimer => ref npc.ai[0]; - public ref float FadeAwayTimer => ref npc.ai[1]; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Demon"); - Main.npcFrameCount[npc.type] = 5; - } + public class CalamitasEnchantDemon : ModNPC + { + public Player Target => Main.player[npc.target]; + public ref float AttackTimer => ref npc.ai[0]; + public ref float FadeAwayTimer => ref npc.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Demon"); + Main.npcFrameCount[npc.type] = 5; + } - public override void SetDefaults() - { - npc.width = 68; - npc.height = 68; - npc.damage = 270; - npc.defense = 0; + public override void SetDefaults() + { + npc.width = 68; + npc.height = 68; + npc.damage = 270; + npc.defense = 0; - // This is meant to be created after SCal is defeated and should be at least a little challenging. - npc.lifeMax = 101010; - npc.HitSound = SoundID.NPCHit47; - npc.DeathSound = SoundID.NPCDeath18; - npc.noGravity = true; - npc.noTileCollide = true; - npc.value = 0f; - npc.knockBackResist = 0f; - npc.netAlways = true; - npc.aiStyle = 0; - npc.Calamity().DoesNotDisappearInBossRush = true; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + // This is meant to be created after SCal is defeated and should be at least a little challenging. + npc.lifeMax = 101010; + npc.HitSound = SoundID.NPCHit47; + npc.DeathSound = SoundID.NPCDeath18; + npc.noGravity = true; + npc.noTileCollide = true; + npc.value = 0f; + npc.knockBackResist = 0f; + npc.netAlways = true; + npc.aiStyle = 0; + npc.Calamity().DoesNotDisappearInBossRush = true; + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 101010; + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 101010; - public override void AI() - { - FadeAwayTimer++; + public override void AI() + { + FadeAwayTimer++; - // This npc should not attempt to locate other targets. The only one it will accept is the - // player who summoned it in the first place. - if (!Main.projectile.IndexInRange(npc.target) || Target.dead || !Target.active) - { - FadeAway(); - return; - } + // This npc should not attempt to locate other targets. The only one it will accept is the + // player who summoned it in the first place. + if (!Main.projectile.IndexInRange(npc.target) || Target.dead || !Target.active) + { + FadeAway(); + return; + } - if (FadeAwayTimer < 15f) - { - DoInitializationAI(); - return; - } + if (FadeAwayTimer < 15f) + { + DoInitializationAI(); + return; + } - AttackTarget(); - } + AttackTarget(); + } - public void FadeAway() - { - npc.dontTakeDamage = true; - npc.Opacity = Utils.InverseLerp(50f, 0f, FadeAwayTimer, true); + public void FadeAway() + { + npc.dontTakeDamage = true; + npc.Opacity = Utils.InverseLerp(50f, 0f, FadeAwayTimer, true); - // Become inactive after fading away completely. - if (npc.Opacity <= 0f) - { - npc.active = false; - npc.netUpdate = true; - } + // Become inactive after fading away completely. + if (npc.Opacity <= 0f) + { + npc.active = false; + npc.netUpdate = true; + } - // Slow down and fade away. - npc.velocity = Vector2.Lerp(npc.velocity, Vector2.UnitY * npc.Opacity * -2f, 0.125f); + // Slow down and fade away. + npc.velocity = Vector2.Lerp(npc.velocity, Vector2.UnitY * npc.Opacity * -2f, 0.125f); - FadeAwayTimer++; + FadeAwayTimer++; - if (Main.dedServ) - return; + if (Main.dedServ) + return; - // Create some fade dust. - for (int i = 0; i < 3; i++) - { - Dust magic = Dust.NewDustDirect(npc.position, npc.width, npc.height, 223); - magic.velocity = -Vector2.UnitY * Main.rand.NextFloat(2.8f, 3.5f); - magic.scale = Main.rand.NextFloat(1f, 1.125f); - magic.fadeIn = 0.4f; - magic.noGravity = true; - magic.noLight = true; - } - } + // Create some fade dust. + for (int i = 0; i < 3; i++) + { + Dust magic = Dust.NewDustDirect(npc.position, npc.width, npc.height, 223); + magic.velocity = -Vector2.UnitY * Main.rand.NextFloat(2.8f, 3.5f); + magic.scale = Main.rand.NextFloat(1f, 1.125f); + magic.fadeIn = 0.4f; + magic.noGravity = true; + magic.noLight = true; + } + } - public void DoInitializationAI() - { - // Create a burst of magic on the first frame. - if (!Main.dedServ && FadeAwayTimer == 1f) - { - for (int i = 0; i < 50; i++) - { - Dust magic = Dust.NewDustDirect(npc.position, npc.width, npc.height, 223); - magic.velocity = -Vector2.UnitY * Main.rand.NextFloat(2.8f, 3.5f); - magic.scale = Main.rand.NextFloat(1f, 1.125f); - magic.fadeIn = 0.7f; - magic.noGravity = true; - magic.noLight = true; - } - } + public void DoInitializationAI() + { + // Create a burst of magic on the first frame. + if (!Main.dedServ && FadeAwayTimer == 1f) + { + for (int i = 0; i < 50; i++) + { + Dust magic = Dust.NewDustDirect(npc.position, npc.width, npc.height, 223); + magic.velocity = -Vector2.UnitY * Main.rand.NextFloat(2.8f, 3.5f); + magic.scale = Main.rand.NextFloat(1f, 1.125f); + magic.fadeIn = 0.7f; + magic.noGravity = true; + magic.noLight = true; + } + } - // Rise upward. - npc.velocity = Vector2.UnitX * MathHelper.Lerp(-0.1f, -3.5f, FadeAwayTimer / 15f); - } + // Rise upward. + npc.velocity = Vector2.UnitX * MathHelper.Lerp(-0.1f, -3.5f, FadeAwayTimer / 15f); + } - public void AttackTarget() - { - // Slow down prior to a charge. - if (AttackTimer % 120f > 90f) - npc.velocity *= 0.94f; + public void AttackTarget() + { + // Slow down prior to a charge. + if (AttackTimer % 120f > 90f) + npc.velocity *= 0.94f; - // Otherwise attempt to move towards the player. - else if (!npc.WithinRange(Target.Center, 150f)) - { - Vector2 idealVelocity = npc.SafeDirectionTo(Target.Center) * 16f; - npc.velocity = (npc.velocity * 29f + idealVelocity) / 30f; - npc.velocity = Vector2.Lerp(npc.velocity, idealVelocity, 0.025f); - } + // Otherwise attempt to move towards the player. + else if (!npc.WithinRange(Target.Center, 150f)) + { + Vector2 idealVelocity = npc.SafeDirectionTo(Target.Center) * 16f; + npc.velocity = (npc.velocity * 29f + idealVelocity) / 30f; + npc.velocity = Vector2.Lerp(npc.velocity, idealVelocity, 0.025f); + } - // Charge. - if (AttackTimer % 120f == 119f) - npc.velocity = npc.SafeDirectionTo(Target.Center) * 23.5f; + // Charge. + if (AttackTimer % 120f == 119f) + npc.velocity = npc.SafeDirectionTo(Target.Center) * 23.5f; - npc.spriteDirection = (npc.velocity.X < 0f).ToDirectionInt(); - } + npc.spriteDirection = (npc.velocity.X < 0f).ToDirectionInt(); + } - public override void FindFrame(int frameHeight) - { - npc.frameCounter++; - if (npc.frameCounter % 5f == 4f) - npc.frame.Y += frameHeight; + public override void FindFrame(int frameHeight) + { + npc.frameCounter++; + if (npc.frameCounter % 5f == 4f) + npc.frame.Y += frameHeight; - if (npc.frame.Y >= frameHeight * Main.npcFrameCount[npc.type]) - npc.frame.Y = 0; - } + if (npc.frame.Y >= frameHeight * Main.npcFrameCount[npc.type]) + npc.frame.Y = 0; + } - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - Utils.PoofOfSmoke(npc.Center); - } + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + Utils.PoofOfSmoke(npc.Center); + } - public override void NPCLoot() - { - // Release 4 healing projectiles towards the target. - for (int i = 0; i < 4; i++) - { - Vector2 shootVelocity = npc.SafeDirectionTo(Target.Center).RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 14f); - Projectile.NewProjectile(npc.Center, shootVelocity, ModContent.ProjectileType(), 0, 0f, npc.target); - } - } - } + public override void NPCLoot() + { + // Release 4 healing projectiles towards the target. + for (int i = 0; i < 4; i++) + { + Vector2 shootVelocity = npc.SafeDirectionTo(Target.Center).RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 14f); + Projectile.NewProjectile(npc.Center, shootVelocity, ModContent.ProjectileType(), 0, 0f, npc.target); + } + } + } } diff --git a/NPCs/Other/DemonPortal.cs b/NPCs/Other/DemonPortal.cs index 538d937e39..f23f4c2050 100644 --- a/NPCs/Other/DemonPortal.cs +++ b/NPCs/Other/DemonPortal.cs @@ -26,10 +26,10 @@ namespace CalamityMod.NPCs.Other npc.aiStyle = -1; npc.Calamity().DoesNotGenerateRage = true; npc.Calamity().DoesNotDisappearInBossRush = true; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 24660; diff --git a/NPCs/Other/ExhumedHeart.cs b/NPCs/Other/ExhumedHeart.cs index ba83c55f6e..a21b97f5ce 100644 --- a/NPCs/Other/ExhumedHeart.cs +++ b/NPCs/Other/ExhumedHeart.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Other { - public class ExhumedHeart : ModNPC + public class ExhumedHeart : ModNPC { public ref float Time => ref npc.ai[0]; public Player Owner @@ -41,10 +41,10 @@ namespace CalamityMod.NPCs.Other npc.aiStyle = -1; npc.Calamity().DoesNotGenerateRage = true; npc.Calamity().DoesNotDisappearInBossRush = true; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 51740; diff --git a/NPCs/Other/LecherousOrb.cs b/NPCs/Other/LecherousOrb.cs index 38b9680e75..bd2068bd8d 100644 --- a/NPCs/Other/LecherousOrb.cs +++ b/NPCs/Other/LecherousOrb.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Other { - public class LecherousOrb : ModNPC + public class LecherousOrb : ModNPC { public ref float Time => ref npc.ai[0]; public ref float Frame => ref npc.localAI[0]; @@ -38,10 +38,10 @@ namespace CalamityMod.NPCs.Other npc.canGhostHeal = false; npc.Calamity().DoesNotGenerateRage = true; npc.Calamity().DoesNotDisappearInBossRush = true; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToWater = true; + } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 181445; diff --git a/NPCs/Perforator/PerforatorBodyLarge.cs b/NPCs/Perforator/PerforatorBodyLarge.cs index 59ddf66339..db934428d6 100644 --- a/NPCs/Perforator/PerforatorBodyLarge.cs +++ b/NPCs/Perforator/PerforatorBodyLarge.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { - public class PerforatorBodyLarge : ModNPC + public class PerforatorBodyLarge : ModNPC { public override void SetStaticDefaults() { @@ -18,11 +18,11 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - npc.GetNPCDamage(); + npc.GetNPCDamage(); npc.width = 60; npc.height = 60; npc.defense = 8; - npc.LifeMaxNERB(2250, 2700, 80000); + npc.LifeMaxNERB(2250, 2700, 80000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -38,19 +38,19 @@ namespace CalamityMod.NPCs.Perforator npc.netAlways = true; npc.dontCountMe = true; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -59,107 +59,107 @@ namespace CalamityMod.NPCs.Perforator public override void AI() { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + if (Main.npc[(int)npc.ai[1]].alpha < 128) + { + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } - if (Main.player[npc.target].dead) - npc.TargetClosest(false); + if (Main.player[npc.target].dead) + npc.TargetClosest(false); - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)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; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + if (npc.ai[1] > 0f && npc.ai[1] < (float)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; + } + catch + { + } + npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; + num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + int num194 = npc.width; + num193 = (num193 - (float)num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - npc.spriteDirection = 1; - else if (num191 > 0f) - npc.spriteDirection = -1; - } - } + if (num191 < 0f) + npc.spriteDirection = 1; + else if (num191 > 0f) + npc.spriteDirection = -1; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = npc.localAI[3] == 1f ? ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodyLargeAlt") : Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + Texture2D texture2D15 = npc.localAI[3] == 1f ? ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodyLargeAlt") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = npc.localAI[3] == 1f ? ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodyLargeAltGlow") : ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodyLargeGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = npc.localAI[3] == 1f ? ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodyLargeAltGlow") : ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodyLargeGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CheckActive() + public override bool CheckActive() { return false; } diff --git a/NPCs/Perforator/PerforatorBodyMedium.cs b/NPCs/Perforator/PerforatorBodyMedium.cs index 92cb075c0e..6832b77066 100644 --- a/NPCs/Perforator/PerforatorBodyMedium.cs +++ b/NPCs/Perforator/PerforatorBodyMedium.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { - public class PerforatorBodyMedium : ModNPC + public class PerforatorBodyMedium : ModNPC { public override void SetStaticDefaults() { @@ -19,12 +19,12 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 40; npc.height = 40; npc.defense = 6; - npc.LifeMaxNERB(150, 180, 7000); + npc.LifeMaxNERB(150, 180, 7000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -40,168 +40,168 @@ namespace CalamityMod.NPCs.Perforator npc.netAlways = true; npc.dontCountMe = true; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().SplittingWorm = true; + npc.Calamity().SplittingWorm = true; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void AI() { - npc.realLife = -1; + npc.realLife = -1; - // Target - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + // Target + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - if (Main.player[npc.target].dead) - npc.TargetClosest(false); + if (Main.player[npc.target].dead) + npc.TargetClosest(false); - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + if (Main.npc[(int)npc.ai[1]].alpha < 128) + { + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.ai[0] == 0f) - { - if (npc.ai[2] > 0f) - 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 - npc.ai[0] = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (npc.ai[0] == 0f) + { + if (npc.ai[2] > 0f) + 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 + npc.ai[0] = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); - 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; - } + 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; + } - // Splitting effect - if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != npc.aiStyle) - { - npc.type = ModContent.NPCType(); - int whoAmI = npc.whoAmI; - float num25 = npc.life / (float)npc.lifeMax; - float num26 = npc.ai[0]; - npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)(npc.lifeMax * num25); - npc.ai[0] = num26; - npc.TargetClosest(true); - npc.netUpdate = true; - npc.whoAmI = whoAmI; - } - if (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle) - { - int whoAmI2 = npc.whoAmI; - float num27 = npc.life / (float)npc.lifeMax; - float num28 = npc.ai[1]; - npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)(npc.lifeMax * num27); - npc.ai[1] = num28; - npc.TargetClosest(true); - npc.netUpdate = true; - npc.whoAmI = whoAmI2; - } + // Splitting effect + if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); + } + if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != npc.aiStyle) + { + npc.type = ModContent.NPCType(); + int whoAmI = npc.whoAmI; + float num25 = npc.life / (float)npc.lifeMax; + float num26 = npc.ai[0]; + npc.SetDefaultsKeepPlayerInteraction(npc.type); + npc.life = (int)(npc.lifeMax * num25); + npc.ai[0] = num26; + npc.TargetClosest(true); + npc.netUpdate = true; + npc.whoAmI = whoAmI; + } + if (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle) + { + int whoAmI2 = npc.whoAmI; + float num27 = npc.life / (float)npc.lifeMax; + float num28 = npc.ai[1]; + npc.SetDefaultsKeepPlayerInteraction(npc.type); + npc.life = (int)(npc.lifeMax * num27); + npc.ai[1] = num28; + npc.TargetClosest(true); + npc.netUpdate = true; + npc.whoAmI = whoAmI2; + } - if (!npc.active && Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } + if (!npc.active && Main.netMode == NetmodeID.Server) + NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); + } - 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); + 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 = (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(num39 * num39 + num40 * num40); + 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(num39 * num39 + num40 * num40); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - 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 - { - } + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + { + try + { + 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(num40, num39) + MathHelper.PiOver2; - num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); - int num53 = npc.width; - num53 = (int)(num53 * npc.scale); - num52 = (num52 - num53) / num52; - num39 *= num52; - num40 *= num52; - npc.velocity = Vector2.Zero; - npc.position.X += num39; - npc.position.Y += num40; - } - } + npc.rotation = (float)Math.Atan2(num40, num39) + MathHelper.PiOver2; + num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); + int num53 = npc.width; + num53 = (int)(num53 * npc.scale); + num52 = (num52 - num53) / num52; + num39 *= num52; + num40 *= num52; + npc.velocity = Vector2.Zero; + npc.position.X += num39; + npc.position.Y += num40; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + 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 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodyMediumGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodyMediumGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CheckActive() + public override bool CheckActive() { return false; } - public override bool PreNPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override bool PreNPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - return false; - } + return false; + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/Perforator/PerforatorBodySmall.cs b/NPCs/Perforator/PerforatorBodySmall.cs index 709fa5bcf6..868803bfce 100644 --- a/NPCs/Perforator/PerforatorBodySmall.cs +++ b/NPCs/Perforator/PerforatorBodySmall.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { - public class PerforatorBodySmall : ModNPC + public class PerforatorBodySmall : ModNPC { public override void SetStaticDefaults() { @@ -18,11 +18,11 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - npc.GetNPCDamage(); + npc.GetNPCDamage(); npc.width = 42; npc.height = 42; npc.defense = 4; - npc.LifeMaxNERB(1000, 1200, 50000); + npc.LifeMaxNERB(1000, 1200, 50000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -38,19 +38,19 @@ namespace CalamityMod.NPCs.Perforator npc.netAlways = true; npc.dontCountMe = true; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -59,107 +59,107 @@ namespace CalamityMod.NPCs.Perforator public override void AI() { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + if (Main.npc[(int)npc.ai[1]].alpha < 128) + { + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } - if (Main.player[npc.target].dead) - npc.TargetClosest(false); + if (Main.player[npc.target].dead) + npc.TargetClosest(false); - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)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; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + if (npc.ai[1] > 0f && npc.ai[1] < (float)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; + } + catch + { + } + npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; + num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + int num194 = npc.width; + num193 = (num193 - (float)num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - npc.spriteDirection = 1; - else if (num191 > 0f) - npc.spriteDirection = -1; - } - } + if (num191 < 0f) + npc.spriteDirection = 1; + else if (num191 > 0f) + npc.spriteDirection = -1; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + 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 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodySmallGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorBodySmallGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CheckActive() + public override bool CheckActive() { return false; } diff --git a/NPCs/Perforator/PerforatorCyst.cs b/NPCs/Perforator/PerforatorCyst.cs index 275df24d31..b0a93d1221 100644 --- a/NPCs/Perforator/PerforatorCyst.cs +++ b/NPCs/Perforator/PerforatorCyst.cs @@ -29,10 +29,10 @@ namespace CalamityMod.NPCs.Perforator npc.chaseable = false; npc.HitSound = SoundID.NPCHit13; npc.rarity = 2; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void FindFrame(int frameHeight) { @@ -42,29 +42,29 @@ namespace CalamityMod.NPCs.Perforator npc.frame.Y = frame * frameHeight; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorCystGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorCystGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) return 0f; diff --git a/NPCs/Perforator/PerforatorHeadLarge.cs b/NPCs/Perforator/PerforatorHeadLarge.cs index 9512d49267..8e615fbcf9 100644 --- a/NPCs/Perforator/PerforatorHeadLarge.cs +++ b/NPCs/Perforator/PerforatorHeadLarge.cs @@ -11,11 +11,11 @@ using System.IO; namespace CalamityMod.NPCs.Perforator { - [AutoloadBossHead] + [AutoloadBossHead] public class PerforatorHeadLarge : ModNPC { - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private bool TailSpawned = false; + private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + private bool TailSpawned = false; public override void SetStaticDefaults() { @@ -24,14 +24,14 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 70; npc.height = 84; npc.defense = 4; - npc.LifeMaxNERB(2250, 2700, 80000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.LifeMaxNERB(2250, 2700, 80000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -44,491 +44,491 @@ namespace CalamityMod.NPCs.Perforator npc.DeathSound = SoundID.NPCDeath1; npc.netAlways = true; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(biomeEnrageTimer); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - biomeEnrageTimer = reader.ReadInt32(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + writer.Write(biomeEnrageTimer); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } - // Enrage - if ((!Main.player[npc.target].ZoneCrimson || (npc.position.Y / 16f) < Main.worldSurface) && !BossRushEvent.BossRushActive) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + public override void ReceiveExtraAI(BinaryReader reader) + { + biomeEnrageTimer = reader.ReadInt32(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } - bool biomeEnraged = biomeEnrageTimer <= 0 || malice; + public override void AI() + { + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; - if (biomeEnraged && (!Main.player[npc.target].ZoneCrimson || malice)) - enrageScale += 1f; - if (biomeEnraged && ((npc.position.Y / 16f) < Main.worldSurface || malice)) - enrageScale += 1f; + // Enrage + if ((!Main.player[npc.target].ZoneCrimson || (npc.position.Y / 16f) < Main.worldSurface) && !BossRushEvent.BossRushActive) + { + if (biomeEnrageTimer > 0) + biomeEnrageTimer--; + } + else + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + bool biomeEnraged = biomeEnrageTimer <= 0 || malice; - if (revenge || lifeRatio < (expertMode ? 0.75f : 0.5f)) - npc.Calamity().newAI[0] += 1f; + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + if (biomeEnraged && (!Main.player[npc.target].ZoneCrimson || malice)) + enrageScale += 1f; + if (biomeEnraged && ((npc.position.Y / 16f) < Main.worldSurface || malice)) + enrageScale += 1f; - float burrowTimeGateValue = death ? 480f : 600f; - bool burrow = npc.Calamity().newAI[0] >= burrowTimeGateValue; - bool resetTime = npc.Calamity().newAI[0] >= burrowTimeGateValue + 600f; - bool lungeUpward = burrow && npc.Calamity().newAI[1] == 1f; - bool quickFall = npc.Calamity().newAI[1] == 2f; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - float speed = 0.09f; - float turnSpeed = 0.06f; + if (revenge || lifeRatio < (expertMode ? 0.75f : 0.5f)) + npc.Calamity().newAI[0] += 1f; - if (expertMode) - { - float velocityScale = (death ? 0.12f : 0.1f) * enrageScale; - speed += velocityScale * (1f - lifeRatio); - float accelerationScale = (death ? 0.12f : 0.1f) * enrageScale; - turnSpeed += accelerationScale * (1f - lifeRatio); - } + float burrowTimeGateValue = death ? 480f : 600f; + bool burrow = npc.Calamity().newAI[0] >= burrowTimeGateValue; + bool resetTime = npc.Calamity().newAI[0] >= burrowTimeGateValue + 600f; + bool lungeUpward = burrow && npc.Calamity().newAI[1] == 1f; + bool quickFall = npc.Calamity().newAI[1] == 2f; - if (lungeUpward) - { - speed *= 1.25f; - turnSpeed *= 1.5f; - } + float speed = 0.09f; + float turnSpeed = 0.06f; - if (npc.ai[2] > 0f) + if (expertMode) + { + float velocityScale = (death ? 0.12f : 0.1f) * enrageScale; + speed += velocityScale * (1f - lifeRatio); + float accelerationScale = (death ? 0.12f : 0.1f) * enrageScale; + turnSpeed += accelerationScale * (1f - lifeRatio); + } + + if (lungeUpward) + { + speed *= 1.25f; + turnSpeed *= 1.5f; + } + + if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; npc.alpha -= 42; if (npc.alpha < 0) npc.alpha = 0; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!TailSpawned) - { - int Previous = npc.whoAmI; - int maxLength = death ? 27 : revenge ? 24 : expertMode ? 21 : 15; - for (int num36 = 0; num36 < maxLength; num36++) - { - int lol; - if (num36 >= 0 && num36 < maxLength - 1) - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - else - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - if (num36 % 2 == 0) - { - Main.npc[lol].localAI[3] = 1f; - } - Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].ai[2] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); - Previous = lol; - } - TailSpawned = true; - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (!TailSpawned) + { + int Previous = npc.whoAmI; + int maxLength = death ? 27 : revenge ? 24 : expertMode ? 21 : 15; + for (int num36 = 0; num36 < maxLength; num36++) + { + int lol; + if (num36 >= 0 && num36 < maxLength - 1) + { + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + } + else + { + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + } + if (num36 % 2 == 0) + { + Main.npc[lol].localAI[3] = 1f; + } + Main.npc[lol].realLife = npc.whoAmI; + Main.npc[lol].ai[2] = npc.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); + Previous = lol; + } + TailSpawned = true; + } + } - int num12 = (int)(npc.position.X / 16f) - 1; - int num13 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; - int num14 = (int)(npc.position.Y / 16f) - 1; - int num15 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; - if (num12 < 0) - { - num12 = 0; - } - if (num13 > Main.maxTilesX) - { - num13 = Main.maxTilesX; - } - if (num14 < 0) - { - num14 = 0; - } - if (num15 > Main.maxTilesY) - { - num15 = Main.maxTilesY; - } - bool flag2 = lungeUpward; - if (!flag2) - { - for (int k = num12; k < num13; k++) - { - 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)) - { - 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) - { - flag2 = true; - break; - } - } - } - } - } - if (!flag2) - { - npc.localAI[1] = 1f; - Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num16 = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; - bool flag3 = true; - if (npc.position.Y > player.position.Y) - { - for (int m = 0; m < 255; m++) - { - if (Main.player[m].active) - { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, num16 * 2); - if (rectangle.Intersects(rectangle2)) - { - flag3 = false; - break; - } - } - } - if (flag3) - { - flag2 = true; - } - } - } - else - { - npc.localAI[1] = 0f; - } + int num12 = (int)(npc.position.X / 16f) - 1; + int num13 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; + int num14 = (int)(npc.position.Y / 16f) - 1; + int num15 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; + if (num12 < 0) + { + num12 = 0; + } + if (num13 > Main.maxTilesX) + { + num13 = Main.maxTilesX; + } + if (num14 < 0) + { + num14 = 0; + } + if (num15 > Main.maxTilesY) + { + num15 = Main.maxTilesY; + } + bool flag2 = lungeUpward; + if (!flag2) + { + for (int k = num12; k < num13; k++) + { + 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)) + { + 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) + { + flag2 = true; + break; + } + } + } + } + } + if (!flag2) + { + npc.localAI[1] = 1f; + Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + int num16 = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; + bool flag3 = true; + if (npc.position.Y > player.position.Y) + { + for (int m = 0; m < 255; m++) + { + if (Main.player[m].active) + { + Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, num16 * 2); + if (rectangle.Intersects(rectangle2)) + { + flag3 = false; + break; + } + } + } + if (flag3) + { + flag2 = true; + } + } + } + else + { + npc.localAI[1] = 0f; + } - float num17 = 16f; - if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active) - { - flag2 = false; - npc.velocity.Y += 1f; - if ((double)npc.position.Y > Main.worldSurface * 16.0) - { - npc.velocity.Y += 1f; - num17 = 32f; - } - if ((double)npc.position.Y > Main.rockLayer * 16.0) - { - for (int a = 0; a < 200; a++) - { - if (Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType()) - { - Main.npc[a].active = false; - } - } - } - } + float num17 = 16f; + if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active) + { + flag2 = false; + npc.velocity.Y += 1f; + if ((double)npc.position.Y > Main.worldSurface * 16.0) + { + npc.velocity.Y += 1f; + num17 = 32f; + } + if ((double)npc.position.Y > Main.rockLayer * 16.0) + { + for (int a = 0; a < 200; a++) + { + if (Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType()) + { + Main.npc[a].active = false; + } + } + } + } - float num18 = speed; - float num19 = turnSpeed; - float burrowDistance = malice ? 500f : 800f; - float burrowTarget = player.Center.Y + burrowDistance; - float lungeTarget = player.Center.Y - 600f; - Vector2 vector3 = npc.Center; - float num20 = player.Center.X; - float num21 = lungeUpward ? lungeTarget : burrow ? burrowTarget : player.Center.Y; - 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); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + float num18 = speed; + float num19 = turnSpeed; + float burrowDistance = malice ? 500f : 800f; + float burrowTarget = player.Center.Y + burrowDistance; + float lungeTarget = player.Center.Y - 600f; + Vector2 vector3 = npc.Center; + float num20 = player.Center.X; + float num21 = lungeUpward ? lungeTarget : burrow ? burrowTarget : player.Center.Y; + 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); + num20 -= vector3.X; + num21 -= vector3.Y; + float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - // Lunge up towards target - if (burrow && npc.Center.Y >= burrowTarget - 16f) - npc.Calamity().newAI[1] = 1f; + // Lunge up towards target + if (burrow && npc.Center.Y >= burrowTarget - 16f) + npc.Calamity().newAI[1] = 1f; - // Quickly fall back down once above target - if (lungeUpward && npc.Center.Y <= player.Center.Y - 420f) - { - npc.TargetClosest(); - npc.Calamity().newAI[1] = 2f; - } + // Quickly fall back down once above target + if (lungeUpward && npc.Center.Y <= player.Center.Y - 420f) + { + npc.TargetClosest(); + npc.Calamity().newAI[1] = 2f; + } - // Quickly fall and reset variables once at target's Y position - if (quickFall) - { - npc.velocity.Y += 0.5f; - if (npc.Center.Y >= player.Center.Y) - { - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - } - } + // Quickly fall and reset variables once at target's Y position + if (quickFall) + { + npc.velocity.Y += 0.5f; + if (npc.Center.Y >= player.Center.Y) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } - // Reset variables if the burrow and lunge attack is taking too long - if (resetTime) - { - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - } + // Reset variables if the burrow and lunge attack is taking too long + if (resetTime) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } - if (!flag2) - { - npc.TargetClosest(true); - npc.velocity.Y = npc.velocity.Y + 0.15f; - if (npc.velocity.Y > num17) - { - npc.velocity.Y = num17; - } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.4) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X - num18 * 1.1f; - } - else - { - npc.velocity.X = npc.velocity.X + num18 * 1.1f; - } - } - else if (npc.velocity.Y == num17) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num18; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num18; - } - } - else if (npc.velocity.Y > 4f) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X + num18 * 0.9f; - } - else - { - npc.velocity.X = npc.velocity.X - num18 * 0.9f; - } - } - } - else - { - if (npc.soundDelay == 0) - { - float num24 = num22 / 40f; - if (num24 < 10f) - { - num24 = 10f; - } - if (num24 > 20f) - { - num24 = 20f; - } - npc.soundDelay = (int)num24; - Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); - } - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = num17 / num22; - num20 *= num27; - num21 *= num27; - if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num19; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num19; - } - if (npc.velocity.Y < num21) - { - npc.velocity.Y = npc.velocity.Y + num19; - } - else if (npc.velocity.Y > num21) - { - npc.velocity.Y = npc.velocity.Y - num19; - } - } - if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num18; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num18; - } - if (npc.velocity.Y < num21) - { - npc.velocity.Y = npc.velocity.Y + num18; - } - else if (npc.velocity.Y > num21) - { - npc.velocity.Y = npc.velocity.Y - num18; - } - if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num18 * 2f; - } - else - { - npc.velocity.Y = npc.velocity.Y - num18 * 2f; - } - } - if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num18 * 2f; - } - else - { - npc.velocity.X = npc.velocity.X - num18 * 2f; - } - } - } - else if (num25 > num26) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num18 * 1.1f; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num18 * 1.1f; - } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num18; - } - else - { - npc.velocity.Y = npc.velocity.Y - num18; - } - } - } - else - { - if (npc.velocity.Y < num21) - { - npc.velocity.Y = npc.velocity.Y + num18 * 1.1f; - } - else if (npc.velocity.Y > num21) - { - npc.velocity.Y = npc.velocity.Y - num18 * 1.1f; - } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num18; - } - else - { - npc.velocity.X = npc.velocity.X - num18; - } - } - } - } - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; - if (flag2) - { - if (npc.localAI[0] != 1f) - { - npc.netUpdate = true; - } - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - { - npc.netUpdate = true; - } - npc.localAI[0] = 0f; - } - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - { - npc.netUpdate = true; - } + if (!flag2) + { + npc.TargetClosest(true); + npc.velocity.Y = npc.velocity.Y + 0.15f; + if (npc.velocity.Y > num17) + { + npc.velocity.Y = num17; + } + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.4) + { + if (npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X - num18 * 1.1f; + } + else + { + npc.velocity.X = npc.velocity.X + num18 * 1.1f; + } + } + else if (npc.velocity.Y == num17) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num18; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num18; + } + } + else if (npc.velocity.Y > 4f) + { + if (npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X + num18 * 0.9f; + } + else + { + npc.velocity.X = npc.velocity.X - num18 * 0.9f; + } + } + } + else + { + if (npc.soundDelay == 0) + { + float num24 = num22 / 40f; + if (num24 < 10f) + { + num24 = 10f; + } + if (num24 > 20f) + { + num24 = 20f; + } + npc.soundDelay = (int)num24; + Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); + } + num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + float num25 = Math.Abs(num20); + float num26 = Math.Abs(num21); + float num27 = num17 / num22; + num20 *= num27; + num21 *= num27; + if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num19; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num19; + } + if (npc.velocity.Y < num21) + { + npc.velocity.Y = npc.velocity.Y + num19; + } + else if (npc.velocity.Y > num21) + { + npc.velocity.Y = npc.velocity.Y - num19; + } + } + if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num18; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num18; + } + if (npc.velocity.Y < num21) + { + npc.velocity.Y = npc.velocity.Y + num18; + } + else if (npc.velocity.Y > num21) + { + npc.velocity.Y = npc.velocity.Y - num18; + } + if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) + { + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y + num18 * 2f; + } + else + { + npc.velocity.Y = npc.velocity.Y - num18 * 2f; + } + } + if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) + { + if (npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X + num18 * 2f; + } + else + { + npc.velocity.X = npc.velocity.X - num18 * 2f; + } + } + } + else if (num25 > num26) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num18 * 1.1f; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num18 * 1.1f; + } + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) + { + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y + num18; + } + else + { + npc.velocity.Y = npc.velocity.Y - num18; + } + } + } + else + { + if (npc.velocity.Y < num21) + { + npc.velocity.Y = npc.velocity.Y + num18 * 1.1f; + } + else if (npc.velocity.Y > num21) + { + npc.velocity.Y = npc.velocity.Y - num18 * 1.1f; + } + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) + { + if (npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X + num18; + } + else + { + npc.velocity.X = npc.velocity.X - num18; + } + } + } + } + npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + if (flag2) + { + if (npc.localAI[0] != 1f) + { + npc.netUpdate = true; + } + npc.localAI[0] = 1f; + } + else + { + if (npc.localAI[0] != 0f) + { + npc.netUpdate = true; + } + npc.localAI[0] = 0f; + } + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + { + npc.netUpdate = true; + } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + 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 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorHeadLargeGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorHeadLargeGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CheckActive() + public override bool CheckActive() { return false; } @@ -568,13 +568,13 @@ namespace CalamityMod.NPCs.Perforator public override void NPCLoot() { - if (!CalamityWorld.revenge) - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + if (!CalamityWorld.revenge) + { + int heartAmt = Main.rand.Next(3) + 3; + for (int i = 0; i < heartAmt; i++) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } public override void OnHitPlayer(Player player, int damage, bool crit) { diff --git a/NPCs/Perforator/PerforatorHeadMedium.cs b/NPCs/Perforator/PerforatorHeadMedium.cs index 9546b385c7..622238bef7 100644 --- a/NPCs/Perforator/PerforatorHeadMedium.cs +++ b/NPCs/Perforator/PerforatorHeadMedium.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { - [AutoloadBossHead] + [AutoloadBossHead] public class PerforatorHeadMedium : ModNPC { public override void SetStaticDefaults() @@ -20,14 +20,14 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 58; npc.height = 68; npc.defense = 2; - npc.LifeMaxNERB(150, 180, 7000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.LifeMaxNERB(150, 180, 7000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -40,373 +40,373 @@ namespace CalamityMod.NPCs.Perforator npc.DeathSound = SoundID.NPCDeath1; npc.netAlways = true; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().SplittingWorm = true; + npc.Calamity().SplittingWorm = true; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } - public override void AI() - { - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + public override void AI() + { + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; - if ((npc.position.Y / 16f) < Main.worldSurface || malice) - enrageScale += 1f; - if (!Main.player[npc.target].ZoneCrimson || malice) - enrageScale += 1f; + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + if ((npc.position.Y / 16f) < Main.worldSurface || malice) + enrageScale += 1f; + if (!Main.player[npc.target].ZoneCrimson || malice) + enrageScale += 1f; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - float speed = 0.08f; - float turnSpeed = 0.06f; + float speed = 0.08f; + float turnSpeed = 0.06f; - if (expertMode) - { - float velocityScale = (death ? 0.08f : 0.07f) * enrageScale; - speed += velocityScale * (1f - lifeRatio); - float accelerationScale = (death ? 0.08f : 0.07f) * enrageScale; - turnSpeed += accelerationScale * (1f - lifeRatio); - } + if (expertMode) + { + float velocityScale = (death ? 0.08f : 0.07f) * enrageScale; + speed += velocityScale * (1f - lifeRatio); + float accelerationScale = (death ? 0.08f : 0.07f) * enrageScale; + turnSpeed += accelerationScale * (1f - lifeRatio); + } - npc.realLife = -1; + npc.realLife = -1; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.ai[0] == 0f) - { - int totalSegments = death ? 14 : revenge ? 13 : expertMode ? 12 : 10; - npc.ai[2] = totalSegments; - npc.ai[0] = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); - 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; - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (npc.ai[0] == 0f) + { + int totalSegments = death ? 14 : revenge ? 13 : expertMode ? 12 : 10; + npc.ai[2] = totalSegments; + npc.ai[0] = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); + 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; + } - // Splitting effect - if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - if (!Main.npc[(int)npc.ai[0]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } + // Splitting effect + if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); + } + if (!Main.npc[(int)npc.ai[0]].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); + } - if (!npc.active && Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } + if (!npc.active && Main.netMode == NetmodeID.Server) + NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); + } - // Movement - int num29 = (int)(npc.position.X / 16f) - 1; - int num30 = (int)((npc.position.X + npc.width) / 16f) + 2; - int num31 = (int)(npc.position.Y / 16f) - 1; - int num32 = (int)((npc.position.Y + npc.height) / 16f) + 2; - if (num29 < 0) - num29 = 0; - if (num30 > Main.maxTilesX) - num30 = Main.maxTilesX; - if (num31 < 0) - num31 = 0; - if (num32 > Main.maxTilesY) - num32 = Main.maxTilesY; + // Movement + int num29 = (int)(npc.position.X / 16f) - 1; + int num30 = (int)((npc.position.X + npc.width) / 16f) + 2; + int num31 = (int)(npc.position.Y / 16f) - 1; + int num32 = (int)((npc.position.Y + npc.height) / 16f) + 2; + if (num29 < 0) + num29 = 0; + if (num30 > Main.maxTilesX) + num30 = Main.maxTilesX; + if (num31 < 0) + num31 = 0; + if (num32 > Main.maxTilesY) + num32 = Main.maxTilesY; - // Fly or not - bool flag2 = false; - if (!flag2) - { - for (int num33 = num29; num33 < num30; num33++) - { - for (int num34 = num31; num34 < num32; num34++) - { - 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 = 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()) - { - WorldGen.KillTile(num33, num34, true, true, false); - } - } - } - } - } - } - if (!flag2) - { - Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num35 = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; - bool flag3 = true; - for (int num36 = 0; num36 < Main.maxPlayers; num36++) - { - if (Main.player[num36].active) - { - Rectangle rectangle2 = new Rectangle((int)Main.player[num36].position.X - num35, (int)Main.player[num36].position.Y - num35, num35 * 2, num35 * 2); - if (rectangle.Intersects(rectangle2)) - { - flag3 = false; - break; - } - } - } - if (flag3) - flag2 = true; - } + // Fly or not + bool flag2 = false; + if (!flag2) + { + for (int num33 = num29; num33 < num30; num33++) + { + for (int num34 = num31; num34 < num32; num34++) + { + 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 = 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()) + { + WorldGen.KillTile(num33, num34, true, true, false); + } + } + } + } + } + } + if (!flag2) + { + Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + int num35 = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; + bool flag3 = true; + for (int num36 = 0; num36 < Main.maxPlayers; num36++) + { + if (Main.player[num36].active) + { + Rectangle rectangle2 = new Rectangle((int)Main.player[num36].position.X - num35, (int)Main.player[num36].position.Y - num35, num35 * 2, num35 * 2); + if (rectangle.Intersects(rectangle2)) + { + flag3 = false; + break; + } + } + } + if (flag3) + flag2 = true; + } - float fallSpeed = 16f; - if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active) - { - npc.TargetClosest(false); - flag2 = false; - npc.velocity.Y += 1f; - if (npc.position.Y > Main.worldSurface * 16.0) - { - npc.velocity.Y += 1f; - fallSpeed = 32f; - } - if (npc.position.Y > Main.rockLayer * 16.0) - { - for (int num957 = 0; num957 < Main.maxNPCs; num957++) - { - if (Main.npc[num957].type == npc.type || Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType()) - { - Main.npc[num957].active = false; - } - } - } - } + float fallSpeed = 16f; + if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active) + { + npc.TargetClosest(false); + flag2 = false; + npc.velocity.Y += 1f; + if (npc.position.Y > Main.worldSurface * 16.0) + { + npc.velocity.Y += 1f; + fallSpeed = 32f; + } + if (npc.position.Y > Main.rockLayer * 16.0) + { + for (int num957 = 0; num957 < Main.maxNPCs; num957++) + { + if (Main.npc[num957].type == npc.type || Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType()) + { + Main.npc[num957].active = false; + } + } + } + } - // Velocity and acceleration - float num37 = speed; - float num38 = turnSpeed; + // Velocity and acceleration + float num37 = speed; + float num38 = turnSpeed; - Vector2 vector2 = npc.Center; - float num39 = player.Center.X; - float num40 = player.Center.Y; + Vector2 vector2 = npc.Center; + float num39 = player.Center.X; + float num40 = player.Center.Y; - 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(num39 * num39 + num40 * num40); + 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(num39 * num39 + num40 * num40); - // Prevent new heads from being slowed when they spawn - if (npc.Calamity().newAI[1] < 3f) - { - npc.Calamity().newAI[1] += 1f; + // Prevent new heads from being slowed when they spawn + if (npc.Calamity().newAI[1] < 3f) + { + npc.Calamity().newAI[1] += 1f; - // Set velocity for when a new head spawns - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (num37 * (death ? 0.3f : 0.2f)); - } + // Set velocity for when a new head spawns + npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (num37 * (death ? 0.3f : 0.2f)); + } - if (!flag2) - { - npc.velocity.Y += 0.15f; - if (npc.velocity.Y > fallSpeed) - npc.velocity.Y = fallSpeed; + if (!flag2) + { + npc.velocity.Y += 0.15f; + if (npc.velocity.Y > fallSpeed) + npc.velocity.Y = fallSpeed; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.4) - { - if (npc.velocity.X < 0f) - npc.velocity.X -= num38 * 1.1f; - else - npc.velocity.X += num38 * 1.1f; - } - else if (npc.velocity.Y == fallSpeed) - { - if (npc.velocity.X < num39) - npc.velocity.X += num38; - else if (npc.velocity.X > num39) - npc.velocity.X -= num38; - } - else if (npc.velocity.Y > 4f) - { - if (npc.velocity.X < 0f) - npc.velocity.X += num38 * 0.9f; - else - npc.velocity.X -= num38 * 0.9f; - } - } - else - { - // Sound - if (npc.soundDelay == 0) - { - float num54 = num52 / 40f; - if (num54 < 10f) - num54 = 10f; - if (num54 > 20f) - num54 = 20f; + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.4) + { + if (npc.velocity.X < 0f) + npc.velocity.X -= num38 * 1.1f; + else + npc.velocity.X += num38 * 1.1f; + } + else if (npc.velocity.Y == fallSpeed) + { + if (npc.velocity.X < num39) + npc.velocity.X += num38; + else if (npc.velocity.X > num39) + npc.velocity.X -= num38; + } + else if (npc.velocity.Y > 4f) + { + if (npc.velocity.X < 0f) + npc.velocity.X += num38 * 0.9f; + else + npc.velocity.X -= num38 * 0.9f; + } + } + else + { + // Sound + if (npc.soundDelay == 0) + { + float num54 = num52 / 40f; + if (num54 < 10f) + num54 = 10f; + if (num54 > 20f) + num54 = 20f; - npc.soundDelay = (int)num54; - Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); - } + npc.soundDelay = (int)num54; + Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); + } - num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); - float num55 = Math.Abs(num39); - float num56 = Math.Abs(num40); - float num57 = fallSpeed / num52; - num39 *= num57; - num40 *= num57; + num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); + float num55 = Math.Abs(num39); + float num56 = Math.Abs(num40); + float num57 = fallSpeed / num52; + num39 *= num57; + num40 *= num57; - if (((npc.velocity.X > 0f && num39 > 0f) || (npc.velocity.X < 0f && num39 < 0f)) && ((npc.velocity.Y > 0f && num40 > 0f) || (npc.velocity.Y < 0f && num40 < 0f))) - { - if (npc.velocity.X < num39) - npc.velocity.X += num38; - else if (npc.velocity.X > num39) - npc.velocity.X -= num38; + if (((npc.velocity.X > 0f && num39 > 0f) || (npc.velocity.X < 0f && num39 < 0f)) && ((npc.velocity.Y > 0f && num40 > 0f) || (npc.velocity.Y < 0f && num40 < 0f))) + { + if (npc.velocity.X < num39) + npc.velocity.X += num38; + else if (npc.velocity.X > num39) + npc.velocity.X -= num38; - if (npc.velocity.Y < num40) - npc.velocity.Y += num38; - else if (npc.velocity.Y > num40) - npc.velocity.Y -= num38; - } + if (npc.velocity.Y < num40) + npc.velocity.Y += num38; + else if (npc.velocity.Y > num40) + npc.velocity.Y -= num38; + } - if ((npc.velocity.X > 0f && num39 > 0f) || (npc.velocity.X < 0f && num39 < 0f) || (npc.velocity.Y > 0f && num40 > 0f) || (npc.velocity.Y < 0f && num40 < 0f)) - { - if (npc.velocity.X < num39) - npc.velocity.X += num37; - else if (npc.velocity.X > num39) - npc.velocity.X -= num37; + if ((npc.velocity.X > 0f && num39 > 0f) || (npc.velocity.X < 0f && num39 < 0f) || (npc.velocity.Y > 0f && num40 > 0f) || (npc.velocity.Y < 0f && num40 < 0f)) + { + if (npc.velocity.X < num39) + npc.velocity.X += num37; + else if (npc.velocity.X > num39) + npc.velocity.X -= num37; - if (npc.velocity.Y < num40) - npc.velocity.Y += num37; - else if (npc.velocity.Y > num40) - npc.velocity.Y -= num37; + if (npc.velocity.Y < num40) + npc.velocity.Y += num37; + else if (npc.velocity.Y > num40) + npc.velocity.Y -= num37; - if (Math.Abs(num40) < fallSpeed * 0.2 && ((npc.velocity.X > 0f && num39 < 0f) || (npc.velocity.X < 0f && num39 > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num37 * 2f; - else - npc.velocity.Y -= num37 * 2f; - } + if (Math.Abs(num40) < fallSpeed * 0.2 && ((npc.velocity.X > 0f && num39 < 0f) || (npc.velocity.X < 0f && num39 > 0f))) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += num37 * 2f; + else + npc.velocity.Y -= num37 * 2f; + } - if (Math.Abs(num39) < fallSpeed * 0.2 && ((npc.velocity.Y > 0f && num40 < 0f) || (npc.velocity.Y < 0f && num40 > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num37 * 2f; - else - npc.velocity.X -= num37 * 2f; - } - } - else if (num55 > num56) - { - if (npc.velocity.X < num39) - npc.velocity.X += num37 * 1.1f; - else if (npc.velocity.X > num39) - npc.velocity.X -= num37 * 1.1f; + if (Math.Abs(num39) < fallSpeed * 0.2 && ((npc.velocity.Y > 0f && num40 < 0f) || (npc.velocity.Y < 0f && num40 > 0f))) + { + if (npc.velocity.X > 0f) + npc.velocity.X += num37 * 2f; + else + npc.velocity.X -= num37 * 2f; + } + } + else if (num55 > num56) + { + if (npc.velocity.X < num39) + npc.velocity.X += num37 * 1.1f; + else if (npc.velocity.X > num39) + npc.velocity.X -= num37 * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num37; - else - npc.velocity.Y -= num37; - } - } - else - { - if (npc.velocity.Y < num40) - npc.velocity.Y += num37 * 1.1f; - else if (npc.velocity.Y > num40) - npc.velocity.Y -= num37 * 1.1f; + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y += num37; + else + npc.velocity.Y -= num37; + } + } + else + { + if (npc.velocity.Y < num40) + npc.velocity.Y += num37 * 1.1f; + else if (npc.velocity.Y > num40) + npc.velocity.Y -= num37 * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num37; - else - npc.velocity.X -= num37; - } - } - } + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) + { + if (npc.velocity.X > 0f) + npc.velocity.X += num37; + else + npc.velocity.X -= num37; + } + } + } - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - if (flag2) - { - if (npc.localAI[0] != 1f) - npc.netUpdate = true; + if (flag2) + { + if (npc.localAI[0] != 1f) + npc.netUpdate = true; - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - npc.netUpdate = true; + npc.localAI[0] = 1f; + } + else + { + if (npc.localAI[0] != 0f) + npc.netUpdate = true; - npc.localAI[0] = 0f; - } - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; - } + npc.localAI[0] = 0f; + } + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + npc.netUpdate = true; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + 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 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorHeadMediumGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorHeadMediumGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CheckActive() + public override bool CheckActive() { return false; } @@ -428,25 +428,25 @@ namespace CalamityMod.NPCs.Perforator } } - public override bool PreNPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override bool PreNPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - for (int i = 0; i < Main.maxNPCs; i++) - { - if (i != npc.whoAmI && Main.npc[i].active && (Main.npc[i].type == npc.type || Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType())) - return false; - } + for (int i = 0; i < Main.maxNPCs; i++) + { + if (i != npc.whoAmI && Main.npc[i].active && (Main.npc[i].type == npc.type || Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType())) + return false; + } - return true; - } + return true; + } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref string name, ref int potionType) { name = "The Medium Perforator"; potionType = ItemID.HealingPotion; diff --git a/NPCs/Perforator/PerforatorHeadSmall.cs b/NPCs/Perforator/PerforatorHeadSmall.cs index e17fe9fc1f..d1078daca1 100644 --- a/NPCs/Perforator/PerforatorHeadSmall.cs +++ b/NPCs/Perforator/PerforatorHeadSmall.cs @@ -11,27 +11,27 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { - [AutoloadBossHead] + [AutoloadBossHead] public class PerforatorHeadSmall : ModNPC { - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private const int MsgType = 23; - private bool TailSpawned = false; + private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + private const int MsgType = 23; + private bool TailSpawned = false; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("The Perforator"); } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 42; npc.height = 62; - npc.LifeMaxNERB(1000, 1200, 50000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.LifeMaxNERB(1000, 1200, 50000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -44,433 +44,433 @@ namespace CalamityMod.NPCs.Perforator npc.DeathSound = SoundID.NPCDeath1; npc.netAlways = true; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(biomeEnrageTimer); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - biomeEnrageTimer = reader.ReadInt32(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + writer.Write(biomeEnrageTimer); + } - // Enrage - if ((!Main.player[npc.target].ZoneCrimson || (npc.position.Y / 16f) < Main.worldSurface) && !BossRushEvent.BossRushActive) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + public override void ReceiveExtraAI(BinaryReader reader) + { + biomeEnrageTimer = reader.ReadInt32(); + } - bool biomeEnraged = biomeEnrageTimer <= 0 || malice; + public override void AI() + { + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; - if (biomeEnraged && (!Main.player[npc.target].ZoneCrimson || malice)) - enrageScale += 1f; - if (biomeEnraged && ((npc.position.Y / 16f) < Main.worldSurface || malice)) - enrageScale += 1f; + // Enrage + if ((!Main.player[npc.target].ZoneCrimson || (npc.position.Y / 16f) < Main.worldSurface) && !BossRushEvent.BossRushActive) + { + if (biomeEnrageTimer > 0) + biomeEnrageTimer--; + } + else + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + bool biomeEnraged = biomeEnrageTimer <= 0 || malice; - float speed = 0.15f; - float turnSpeed = 0.1f; + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + if (biomeEnraged && (!Main.player[npc.target].ZoneCrimson || malice)) + enrageScale += 1f; + if (biomeEnraged && ((npc.position.Y / 16f) < Main.worldSurface || malice)) + enrageScale += 1f; - if (expertMode) - { - float velocityScale = (death ? 0.15f : 0.1f) * enrageScale; - speed += velocityScale * (1f - lifeRatio); - float accelerationScale = (death ? 0.12f : 0.1f) * enrageScale; - turnSpeed += accelerationScale * (1f - lifeRatio); - } + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - if (npc.ai[2] > 0f) + float speed = 0.15f; + float turnSpeed = 0.1f; + + if (expertMode) + { + float velocityScale = (death ? 0.15f : 0.1f) * enrageScale; + speed += velocityScale * (1f - lifeRatio); + float accelerationScale = (death ? 0.12f : 0.1f) * enrageScale; + turnSpeed += accelerationScale * (1f - lifeRatio); + } + + if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; npc.alpha -= 42; if (npc.alpha < 0) npc.alpha = 0; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!TailSpawned) - { - int Previous = npc.whoAmI; - int maxLength = death ? 9 : revenge ? 8 : expertMode ? 7 : 5; - for (int num36 = 0; num36 < maxLength; num36++) - { - int lol; - if (num36 >= 0 && num36 < maxLength - 1) - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - else - { - 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] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - NetMessage.SendData(MsgType, -1, -1, null, lol, 0f, 0f, 0f, 0); - Previous = lol; - } - TailSpawned = true; - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (!TailSpawned) + { + int Previous = npc.whoAmI; + int maxLength = death ? 9 : revenge ? 8 : expertMode ? 7 : 5; + for (int num36 = 0; num36 < maxLength; num36++) + { + int lol; + if (num36 >= 0 && num36 < maxLength - 1) + { + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + } + else + { + 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] = npc.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; + NetMessage.SendData(MsgType, -1, -1, null, lol, 0f, 0f, 0f, 0); + Previous = lol; + } + TailSpawned = true; + } + } - int num12 = (int)(npc.position.X / 16f) - 1; - int num13 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; - int num14 = (int)(npc.position.Y / 16f) - 1; - int num15 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; - if (num12 < 0) - { - num12 = 0; - } - if (num13 > Main.maxTilesX) - { - num13 = Main.maxTilesX; - } - if (num14 < 0) - { - num14 = 0; - } - if (num15 > Main.maxTilesY) - { - num15 = Main.maxTilesY; - } - bool flag2 = false; - if (!flag2) - { - for (int k = num12; k < num13; k++) - { - 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)) - { - 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) - { - flag2 = true; - break; - } - } - } - } - } - if (!flag2) - { - npc.localAI[1] = 1f; - Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num16 = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; - bool flag3 = true; - if (npc.position.Y > player.position.Y) - { - for (int m = 0; m < 255; m++) - { - if (Main.player[m].active) - { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, num16 * 2); - if (rectangle.Intersects(rectangle2)) - { - flag3 = false; - break; - } - } - } - if (flag3) - { - flag2 = true; - } - } - } - else - { - npc.localAI[1] = 0f; - } - float num17 = 16f; - if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active) - { - flag2 = false; - npc.velocity.Y += 1f; - if ((double)npc.position.Y > Main.worldSurface * 16.0) - { - npc.velocity.Y += 1f; - num17 = 32f; - } - if ((double)npc.position.Y > Main.rockLayer * 16.0) - { - for (int a = 0; a < 200; a++) - { - if (Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType()) - { - Main.npc[a].active = false; - } - } - } - } - float num18 = speed; - float num19 = turnSpeed; - 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); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - if (!flag2) - { - npc.TargetClosest(true); - npc.velocity.Y = npc.velocity.Y + 0.15f; - if (npc.velocity.Y > num17) - { - npc.velocity.Y = num17; - } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.4) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X - num18 * 1.1f; - } - else - { - npc.velocity.X = npc.velocity.X + num18 * 1.1f; - } - } - else if (npc.velocity.Y == num17) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num18; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num18; - } - } - else if (npc.velocity.Y > 4f) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X + num18 * 0.9f; - } - else - { - npc.velocity.X = npc.velocity.X - num18 * 0.9f; - } - } - } - else - { - if (npc.soundDelay == 0) - { - float num24 = num22 / 40f; - if (num24 < 10f) - { - num24 = 10f; - } - if (num24 > 20f) - { - num24 = 20f; - } - npc.soundDelay = (int)num24; - Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); - } - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = num17 / num22; - num20 *= num27; - num21 *= num27; - if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num19; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num19; - } - if (npc.velocity.Y < num21) - { - npc.velocity.Y = npc.velocity.Y + num19; - } - else if (npc.velocity.Y > num21) - { - npc.velocity.Y = npc.velocity.Y - num19; - } - } - if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num18; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num18; - } - if (npc.velocity.Y < num21) - { - npc.velocity.Y = npc.velocity.Y + num18; - } - else if (npc.velocity.Y > num21) - { - npc.velocity.Y = npc.velocity.Y - num18; - } - if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num18 * 2f; - } - else - { - npc.velocity.Y = npc.velocity.Y - num18 * 2f; - } - } - if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num18 * 2f; - } - else - { - npc.velocity.X = npc.velocity.X - num18 * 2f; - } - } - } - else if (num25 > num26) - { - if (npc.velocity.X < num20) - { - npc.velocity.X = npc.velocity.X + num18 * 1.1f; - } - else if (npc.velocity.X > num20) - { - npc.velocity.X = npc.velocity.X - num18 * 1.1f; - } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num18; - } - else - { - npc.velocity.Y = npc.velocity.Y - num18; - } - } - } - else - { - if (npc.velocity.Y < num21) - { - npc.velocity.Y = npc.velocity.Y + num18 * 1.1f; - } - else if (npc.velocity.Y > num21) - { - npc.velocity.Y = npc.velocity.Y - num18 * 1.1f; - } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num18; - } - else - { - npc.velocity.X = npc.velocity.X - num18; - } - } - } - } - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; - if (flag2) - { - if (npc.localAI[0] != 1f) - { - npc.netUpdate = true; - } - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - { - npc.netUpdate = true; - } - npc.localAI[0] = 0f; - } - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - { - npc.netUpdate = true; - } - } + int num12 = (int)(npc.position.X / 16f) - 1; + int num13 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; + int num14 = (int)(npc.position.Y / 16f) - 1; + int num15 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; + if (num12 < 0) + { + num12 = 0; + } + if (num13 > Main.maxTilesX) + { + num13 = Main.maxTilesX; + } + if (num14 < 0) + { + num14 = 0; + } + if (num15 > Main.maxTilesY) + { + num15 = Main.maxTilesY; + } + bool flag2 = false; + if (!flag2) + { + for (int k = num12; k < num13; k++) + { + 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)) + { + 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) + { + flag2 = true; + break; + } + } + } + } + } + if (!flag2) + { + npc.localAI[1] = 1f; + Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + int num16 = death ? 160 : revenge ? 200 : expertMode ? 240 : 300; + bool flag3 = true; + if (npc.position.Y > player.position.Y) + { + for (int m = 0; m < 255; m++) + { + if (Main.player[m].active) + { + Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, num16 * 2); + if (rectangle.Intersects(rectangle2)) + { + flag3 = false; + break; + } + } + } + if (flag3) + { + flag2 = true; + } + } + } + else + { + npc.localAI[1] = 0f; + } + float num17 = 16f; + if (player.dead || CalamityGlobalNPC.perfHive < 0 || !Main.npc[CalamityGlobalNPC.perfHive].active) + { + flag2 = false; + npc.velocity.Y += 1f; + if ((double)npc.position.Y > Main.worldSurface * 16.0) + { + npc.velocity.Y += 1f; + num17 = 32f; + } + if ((double)npc.position.Y > Main.rockLayer * 16.0) + { + for (int a = 0; a < 200; a++) + { + if (Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType()) + { + Main.npc[a].active = false; + } + } + } + } + float num18 = speed; + float num19 = turnSpeed; + 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); + num20 -= vector3.X; + num21 -= vector3.Y; + float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + if (!flag2) + { + npc.TargetClosest(true); + npc.velocity.Y = npc.velocity.Y + 0.15f; + if (npc.velocity.Y > num17) + { + npc.velocity.Y = num17; + } + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.4) + { + if (npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X - num18 * 1.1f; + } + else + { + npc.velocity.X = npc.velocity.X + num18 * 1.1f; + } + } + else if (npc.velocity.Y == num17) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num18; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num18; + } + } + else if (npc.velocity.Y > 4f) + { + if (npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X + num18 * 0.9f; + } + else + { + npc.velocity.X = npc.velocity.X - num18 * 0.9f; + } + } + } + else + { + if (npc.soundDelay == 0) + { + float num24 = num22 / 40f; + if (num24 < 10f) + { + num24 = 10f; + } + if (num24 > 20f) + { + num24 = 20f; + } + npc.soundDelay = (int)num24; + Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); + } + num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + float num25 = Math.Abs(num20); + float num26 = Math.Abs(num21); + float num27 = num17 / num22; + num20 *= num27; + num21 *= num27; + if (((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f)) && ((npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f))) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num19; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num19; + } + if (npc.velocity.Y < num21) + { + npc.velocity.Y = npc.velocity.Y + num19; + } + else if (npc.velocity.Y > num21) + { + npc.velocity.Y = npc.velocity.Y - num19; + } + } + if ((npc.velocity.X > 0f && num20 > 0f) || (npc.velocity.X < 0f && num20 < 0f) || (npc.velocity.Y > 0f && num21 > 0f) || (npc.velocity.Y < 0f && num21 < 0f)) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num18; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num18; + } + if (npc.velocity.Y < num21) + { + npc.velocity.Y = npc.velocity.Y + num18; + } + else if (npc.velocity.Y > num21) + { + npc.velocity.Y = npc.velocity.Y - num18; + } + if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((npc.velocity.X > 0f && num20 < 0f) || (npc.velocity.X < 0f && num20 > 0f))) + { + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y + num18 * 2f; + } + else + { + npc.velocity.Y = npc.velocity.Y - num18 * 2f; + } + } + if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((npc.velocity.Y > 0f && num21 < 0f) || (npc.velocity.Y < 0f && num21 > 0f))) + { + if (npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X + num18 * 2f; + } + else + { + npc.velocity.X = npc.velocity.X - num18 * 2f; + } + } + } + else if (num25 > num26) + { + if (npc.velocity.X < num20) + { + npc.velocity.X = npc.velocity.X + num18 * 1.1f; + } + else if (npc.velocity.X > num20) + { + npc.velocity.X = npc.velocity.X - num18 * 1.1f; + } + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) + { + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y + num18; + } + else + { + npc.velocity.Y = npc.velocity.Y - num18; + } + } + } + else + { + if (npc.velocity.Y < num21) + { + npc.velocity.Y = npc.velocity.Y + num18 * 1.1f; + } + else if (npc.velocity.Y > num21) + { + npc.velocity.Y = npc.velocity.Y - num18 * 1.1f; + } + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num17 * 0.5) + { + if (npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X + num18; + } + else + { + npc.velocity.X = npc.velocity.X - num18; + } + } + } + } + npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + if (flag2) + { + if (npc.localAI[0] != 1f) + { + npc.netUpdate = true; + } + npc.localAI[0] = 1f; + } + else + { + if (npc.localAI[0] != 0f) + { + npc.netUpdate = true; + } + npc.localAI[0] = 0f; + } + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + { + npc.netUpdate = true; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + 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 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorHeadSmallGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorHeadSmallGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CheckActive() + public override bool CheckActive() { return false; } @@ -509,12 +509,12 @@ namespace CalamityMod.NPCs.Perforator public override void NPCLoot() { - if (!CalamityWorld.revenge) - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + if (!CalamityWorld.revenge) + { + int heartAmt = Main.rand.Next(3) + 3; + for (int i = 0; i < heartAmt; i++) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index 1267bf7a31..f65437882e 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -28,8 +28,8 @@ namespace CalamityMod.NPCs.Perforator [AutoloadBossHead] public class PerforatorHive : ModNPC { - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private bool small = false; + private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + private bool small = false; private bool medium = false; private bool large = false; @@ -41,10 +41,10 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 18f; - npc.GetNPCDamage(); - npc.width = 110; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 18f; + npc.GetNPCDamage(); + npc.width = 110; npc.height = 100; npc.defense = 4; npc.LifeMaxNERB(5000, 6000, 270000); @@ -59,12 +59,12 @@ namespace CalamityMod.NPCs.Perforator npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit13; npc.DeathSound = SoundID.NPCDeath19; - music = CalamityMod.Instance.GetMusicFromMusicMod("Perforators") ?? MusicID.Boss2; + music = CalamityMod.Instance.GetMusicFromMusicMod("Perforators") ?? MusicID.Boss2; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void FindFrame(int frameHeight) { @@ -74,364 +74,364 @@ namespace CalamityMod.NPCs.Perforator npc.frame.Y = frame * frameHeight; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(biomeEnrageTimer); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(biomeEnrageTimer); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - biomeEnrageTimer = reader.ReadInt32(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + biomeEnrageTimer = reader.ReadInt32(); + } - public override void AI() - { - CalamityGlobalNPC.perfHive = npc.whoAmI; + public override void AI() + { + CalamityGlobalNPC.perfHive = npc.whoAmI; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Variables for ichor spore phase - float sporePhaseGateValue = malice ? 450f : 600f; - bool floatAboveToFireBlobs = npc.ai[2] >= sporePhaseGateValue - 120f; + // Variables for ichor spore phase + float sporePhaseGateValue = malice ? 450f : 600f; + bool floatAboveToFireBlobs = npc.ai[2] >= sporePhaseGateValue - 120f; - // Don't deal damage for 3 seconds after spawning or while firing blobs - npc.damage = npc.defDamage; - if (npc.ai[1] < 180f || floatAboveToFireBlobs) - { - if (npc.ai[1] < 180f) - npc.ai[1] += 1f; + // Don't deal damage for 3 seconds after spawning or while firing blobs + npc.damage = npc.defDamage; + if (npc.ai[1] < 180f || floatAboveToFireBlobs) + { + if (npc.ai[1] < 180f) + npc.ai[1] += 1f; - npc.damage = 0; - } + npc.damage = 0; + } - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Phases based on life percentage - bool phase2 = lifeRatio < 0.7f; + // Phases based on life percentage + bool phase2 = lifeRatio < 0.7f; - // Enrage - if ((!player.ZoneCrimson || (npc.position.Y / 16f) < Main.worldSurface) && !BossRushEvent.BossRushActive) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + // Enrage + if ((!player.ZoneCrimson || (npc.position.Y / 16f) < Main.worldSurface) && !BossRushEvent.BossRushActive) + { + if (biomeEnrageTimer > 0) + biomeEnrageTimer--; + } + else + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || malice; + bool biomeEnraged = biomeEnrageTimer <= 0 || malice; - float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; - if (biomeEnraged && (!player.ZoneCrimson || malice)) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1f; - } - if (biomeEnraged && ((npc.position.Y / 16f) < Main.worldSurface || malice)) - { - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; - enrageScale += 1f; - } + float enrageScale = BossRushEvent.BossRushActive ? 1f : 0f; + if (biomeEnraged && (!player.ZoneCrimson || malice)) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + if (biomeEnraged && ((npc.position.Y / 16f) < Main.worldSurface || malice)) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } - if (!player.active || player.dead || Vector2.Distance(player.Center, npc.Center) > 5600f) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, npc.Center) > 5600f) - { - npc.rotation = npc.velocity.X * 0.04f; + if (!player.active || player.dead || Vector2.Distance(player.Center, npc.Center) > 5600f) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead || Vector2.Distance(player.Center, npc.Center) > 5600f) + { + npc.rotation = npc.velocity.X * 0.04f; - if (npc.velocity.Y < -3f) - npc.velocity.Y = -3f; - npc.velocity.Y += 0.1f; - if (npc.velocity.Y > 12f) - npc.velocity.Y = 12f; + if (npc.velocity.Y < -3f) + npc.velocity.Y = -3f; + npc.velocity.Y += 0.1f; + if (npc.velocity.Y > 12f) + npc.velocity.Y = 12f; - if (npc.timeLeft > 60) - npc.timeLeft = 60; + if (npc.timeLeft > 60) + npc.timeLeft = 60; - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + return; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; - int wormsAlive = 0; - if (NPC.AnyNPCs(ModContent.NPCType())) - wormsAlive++; - if (NPC.AnyNPCs(ModContent.NPCType())) - wormsAlive++; - if (NPC.AnyNPCs(ModContent.NPCType())) - wormsAlive++; + int wormsAlive = 0; + if (NPC.AnyNPCs(ModContent.NPCType())) + wormsAlive++; + if (NPC.AnyNPCs(ModContent.NPCType())) + wormsAlive++; + if (NPC.AnyNPCs(ModContent.NPCType())) + wormsAlive++; - if (npc.ai[3] == 0f && npc.life > 0) - npc.ai[3] = npc.lifeMax; + if (npc.ai[3] == 0f && npc.life > 0) + npc.ai[3] = npc.lifeMax; - bool canSpawnWorms = !small || !medium || !large; - if (npc.life > 0 && canSpawnWorms) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num660 = (int)(npc.lifeMax * 0.25); - if ((npc.life + num660) < npc.ai[3]) - { - npc.ai[3] = npc.life; - int wormType = ModContent.NPCType(); - if (!small) - { - small = true; - } - else if (!medium) - { - medium = true; - wormType = ModContent.NPCType(); - } - else if (!large) - { - large = true; - wormType = ModContent.NPCType(); - } - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, wormType, 1); - npc.TargetClosest(); + bool canSpawnWorms = !small || !medium || !large; + if (npc.life > 0 && canSpawnWorms) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int num660 = (int)(npc.lifeMax * 0.25); + if ((npc.life + num660) < npc.ai[3]) + { + npc.ai[3] = npc.life; + int wormType = ModContent.NPCType(); + if (!small) + { + small = true; + } + else if (!medium) + { + medium = true; + wormType = ModContent.NPCType(); + } + else if (!large) + { + large = true; + wormType = ModContent.NPCType(); + } + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, wormType, 1); + npc.TargetClosest(); - Main.PlaySound(SoundID.NPCDeath23, npc.position); + Main.PlaySound(SoundID.NPCDeath23, npc.position); - for (int num621 = 0; num621 < 16; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 170, 0f, 0f, 100, default, 1f); - Main.dust[num622].velocity *= 2f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.25f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } + for (int num621 = 0; num621 < 16; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 170, 0f, 0f, 100, default, 1f); + Main.dust[num622].velocity *= 2f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.25f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } - for (int num623 = 0; num623 < 32; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 5, 0f, 0f, 100, default, 1.5f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 3f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 5, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; - } - } - } - } + for (int num623 = 0; num623 < 32; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 5, 0f, 0f, 100, default, 1.5f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 3f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 5, 0f, 0f, 100, default, 1f); + Main.dust[num624].velocity *= 2f; + } + } + } + } - if (Math.Abs(npc.Center.X - player.Center.X) > 10f) - { - float playerLocation = npc.Center.X - player.Center.X; - npc.direction = playerLocation < 0f ? 1 : -1; - npc.spriteDirection = npc.direction; - } + if (Math.Abs(npc.Center.X - player.Center.X) > 10f) + { + float playerLocation = npc.Center.X - player.Center.X; + npc.direction = playerLocation < 0f ? 1 : -1; + npc.spriteDirection = npc.direction; + } - npc.rotation = npc.velocity.X * 0.04f; + npc.rotation = npc.velocity.X * 0.04f; - // Emit ichor blobs - if (phase2) - { - if (wormsAlive == 0 || malice || floatAboveToFireBlobs) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= sporePhaseGateValue) - { - if (npc.ai[2] < sporePhaseGateValue + 300f) - { - if (npc.velocity.Length() > 0.5f) - npc.velocity *= malice ? 0.94f : 0.96f; - else - npc.ai[2] = sporePhaseGateValue + 300f; - } - else - { - npc.ai[2] = 0f; + // Emit ichor blobs + if (phase2) + { + if (wormsAlive == 0 || malice || floatAboveToFireBlobs) + { + npc.ai[2] += 1f; + if (npc.ai[2] >= sporePhaseGateValue) + { + if (npc.ai[2] < sporePhaseGateValue + 300f) + { + if (npc.velocity.Length() > 0.5f) + npc.velocity *= malice ? 0.94f : 0.96f; + else + npc.ai[2] = sporePhaseGateValue + 300f; + } + else + { + npc.ai[2] = 0f; - Main.PlaySound(SoundID.NPCDeath23, npc.position); + Main.PlaySound(SoundID.NPCDeath23, npc.position); - for (int num621 = 0; num621 < 32; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 170, 0f, 0f, 100, default, 1f); - float dustVelocityYAdd = Math.Abs(Main.dust[num622].velocity.Y) * 0.5f; - if (Main.dust[num622].velocity.Y < 0f) - Main.dust[num622].velocity.Y = 2f + dustVelocityYAdd; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.25f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } + for (int num621 = 0; num621 < 32; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 170, 0f, 0f, 100, default, 1f); + float dustVelocityYAdd = Math.Abs(Main.dust[num622].velocity.Y) * 0.5f; + if (Main.dust[num622].velocity.Y < 0f) + Main.dust[num622].velocity.Y = 2f + dustVelocityYAdd; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.25f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } - int numBlobs = expertMode ? 6 : 3; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + int numBlobs = expertMode ? 6 : 3; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < numBlobs; i++) - { - Vector2 blobVelocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - blobVelocity.Normalize(); - blobVelocity *= Main.rand.Next(200, 401) * (malice ? 0.02f : 0.01f); + for (int i = 0; i < numBlobs; i++) + { + Vector2 blobVelocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + blobVelocity.Normalize(); + blobVelocity *= Main.rand.Next(200, 401) * (malice ? 0.02f : 0.01f); - float sporeVelocityYAdd = Math.Abs(blobVelocity.Y) * 0.5f; - if (blobVelocity.Y < 2f) - blobVelocity.Y = 2f + sporeVelocityYAdd; + float sporeVelocityYAdd = Math.Abs(blobVelocity.Y) * 0.5f; + if (blobVelocity.Y < 2f) + blobVelocity.Y = 2f + sporeVelocityYAdd; - Projectile.NewProjectile(npc.Center, blobVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); - } - } + Projectile.NewProjectile(npc.Center, blobVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); + } + } - return; - } - } - } + return; + } + } + } - // Movement velocities, increased while enraged - float velocityEnrageIncrease = enrageScale; + // Movement velocities, increased while enraged + float velocityEnrageIncrease = enrageScale; - // When firing blobs, float above the target and don't call any other projectile firing or movement code - if (floatAboveToFireBlobs) - { - if (revenge) - Movement(player, 6f + velocityEnrageIncrease, 0.3f, 450f); - else - Movement(player, 5f + velocityEnrageIncrease, 0.2f, 450f); + // When firing blobs, float above the target and don't call any other projectile firing or movement code + if (floatAboveToFireBlobs) + { + if (revenge) + Movement(player, 6f + velocityEnrageIncrease, 0.3f, 450f); + else + Movement(player, 5f + velocityEnrageIncrease, 0.2f, 450f); - return; - } + return; + } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int shoot = (revenge ? 6 : 4) - wormsAlive; - npc.localAI[0] += Main.rand.Next(shoot); - if (npc.localAI[0] >= Main.rand.Next(300, 901) && npc.position.Y + npc.height < player.position.Y && Vector2.Distance(player.Center, npc.Center) > 80f) - { - npc.localAI[0] = 0f; - Main.PlaySound(SoundID.NPCHit20, npc.position); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int shoot = (revenge ? 6 : 4) - wormsAlive; + npc.localAI[0] += Main.rand.Next(shoot); + if (npc.localAI[0] >= Main.rand.Next(300, 901) && npc.position.Y + npc.height < player.position.Y && Vector2.Distance(player.Center, npc.Center) > 80f) + { + npc.localAI[0] = 0f; + Main.PlaySound(SoundID.NPCHit20, npc.position); - for (int num621 = 0; num621 < 8; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 170, 0f, 0f, 100, default, 1f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.25f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } + for (int num621 = 0; num621 < 8; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 170, 0f, 0f, 100, default, 1f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.25f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } - for (int num623 = 0; num623 < 16; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 5, 0f, 0f, 100, default, 1.5f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 5, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; - } + for (int num623 = 0; num623 < 16; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 5, 0f, 0f, 100, default, 1.5f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 5, 0f, 0f, 100, default, 1f); + Main.dust[num624].velocity *= 2f; + } - int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int totalProjectiles = death ? 16 : revenge ? 14 : expertMode ? 12 : 10; - float maxVelocity = 8f; - float velocityAdjustment = maxVelocity * 1.5f / totalProjectiles; - Vector2 start = new Vector2(npc.Center.X, npc.Center.Y + 30f); - Vector2 destination = wormsAlive > 0 ? new Vector2(Vector2.Normalize(player.Center - start).X, 0f) * maxVelocity * 0.4f : Vector2.Zero; - Vector2 velocity = destination + Vector2.UnitY * -maxVelocity; - for (int i = 0; i < totalProjectiles + 1; i++) - { - Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); - velocity.X += velocityAdjustment * npc.direction; - } - } - } + int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + int totalProjectiles = death ? 16 : revenge ? 14 : expertMode ? 12 : 10; + float maxVelocity = 8f; + float velocityAdjustment = maxVelocity * 1.5f / totalProjectiles; + Vector2 start = new Vector2(npc.Center.X, npc.Center.Y + 30f); + Vector2 destination = wormsAlive > 0 ? new Vector2(Vector2.Normalize(player.Center - start).X, 0f) * maxVelocity * 0.4f : Vector2.Zero; + Vector2 velocity = destination + Vector2.UnitY * -maxVelocity; + for (int i = 0; i < totalProjectiles + 1; i++) + { + Projectile.NewProjectile(start, velocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); + velocity.X += velocityAdjustment * npc.direction; + } + } + } - if (revenge) - { - if (wormsAlive == 1) - { - Movement(player, 4f + velocityEnrageIncrease, 0.1f, 350f); - } - else - { - if (large || death) - Movement(player, 5.5f + velocityEnrageIncrease, death ? 0.075f : 0.065f, 20f); - else if (medium) - Movement(player, 5f + velocityEnrageIncrease, death ? 0.07f : 0.06f, 30f); - else if (small) - Movement(player, 4.5f + velocityEnrageIncrease, death ? 0.065f : 0.055f, 40f); - else - Movement(player, 4f + velocityEnrageIncrease, death ? 0.06f : 0.05f, 50f); - } - } - else - Movement(player, 4f + velocityEnrageIncrease, 0.05f, 350f); - } + if (revenge) + { + if (wormsAlive == 1) + { + Movement(player, 4f + velocityEnrageIncrease, 0.1f, 350f); + } + else + { + if (large || death) + Movement(player, 5.5f + velocityEnrageIncrease, death ? 0.075f : 0.065f, 20f); + else if (medium) + Movement(player, 5f + velocityEnrageIncrease, death ? 0.07f : 0.06f, 30f); + else if (small) + Movement(player, 4.5f + velocityEnrageIncrease, death ? 0.065f : 0.055f, 40f); + else + Movement(player, 4f + velocityEnrageIncrease, death ? 0.06f : 0.05f, 50f); + } + } + else + Movement(player, 4f + velocityEnrageIncrease, 0.05f, 350f); + } - private void Movement(Player target, float velocity, float acceleration, float y) - { - // Distance from destination where Perf Hive stops moving - float movementDistanceGateValue = 100f; + private void Movement(Player target, float velocity, float acceleration, float y) + { + // Distance from destination where Perf Hive stops moving + float movementDistanceGateValue = 100f; - // This is where Perf Hive should be - Vector2 destination = new Vector2(target.Center.X, target.Center.Y - y); + // This is where Perf Hive should be + Vector2 destination = new Vector2(target.Center.X, target.Center.Y - y); - // How far Perf Hive is from where it's supposed to be - Vector2 distanceFromDestination = destination - npc.Center; + // How far Perf Hive is from where it's supposed to be + Vector2 distanceFromDestination = destination - npc.Center; - // Inverse lerp returns the percentage of progress between A and B - float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + // Inverse lerp returns the percentage of progress between A and B + float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); - // Min velocity - float minVelocity = distanceFromDestination.Length(); - float minVelocityCap = velocity; - if (minVelocity > minVelocityCap) - minVelocity = minVelocityCap; + // Min velocity + float minVelocity = distanceFromDestination.Length(); + float minVelocityCap = velocity; + if (minVelocity > minVelocityCap) + minVelocity = minVelocityCap; - // Max velocity - Vector2 maxVelocity = distanceFromDestination / 24f; - float maxVelocityCap = minVelocityCap * 3f; - if (maxVelocity.Length() > maxVelocityCap) - maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; + // Max velocity + Vector2 maxVelocity = distanceFromDestination / 24f; + float maxVelocityCap = minVelocityCap * 3f; + if (maxVelocity.Length() > maxVelocityCap) + maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; - Vector2 desiredVelocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); - npc.SimpleFlyMovement(desiredVelocity, acceleration); - } + Vector2 desiredVelocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); + npc.SimpleFlyMovement(desiredVelocity, acceleration); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorHiveGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorHiveGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CheckDead() + public override bool CheckDead() { if (NPC.AnyNPCs(ModContent.NPCType())) { @@ -453,42 +453,42 @@ namespace CalamityMod.NPCs.Perforator public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedPerforator); - CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Dryad }, CalamityWorld.downedPerforator); + CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Dryad }, CalamityWorld.downedPerforator); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) { - // Materials - DropHelper.DropItemSpray(npc, ModContent.ItemType(), 35, 45, 5); - DropHelper.DropItemSpray(npc, ItemID.CrimtaneBar, 12, 15); - DropHelper.DropItemSpray(npc, ItemID.Vertebrae, 12, 15); - if (Main.hardMode) + // Materials + DropHelper.DropItemSpray(npc, ModContent.ItemType(), 35, 45, 5); + DropHelper.DropItemSpray(npc, ItemID.CrimtaneBar, 12, 15); + DropHelper.DropItemSpray(npc, ItemID.Vertebrae, 12, 15); + if (Main.hardMode) DropHelper.DropItemSpray(npc, ItemID.Ichor, 10, 20, 2); DropHelper.DropItem(npc, ItemID.CrimsonSeeds, 10, 15); - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w, 30, 50), - DropHelper.WeightStack(w) - ); + // Weapons + float w = DropHelper.NormalWeaponDropRateFloat; + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w, 30, 50), + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); @@ -500,22 +500,22 @@ namespace CalamityMod.NPCs.Perforator { string key = "Mods.CalamityMod.SkyOreText"; Color messageColor = Color.Cyan; - CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.4f, 0.6f, 3, 8); + CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.4f, 0.6f, 3, 8); - CalamityUtils.DisplayLocalizedText(key, messageColor); - } + CalamityUtils.DisplayLocalizedText(key, messageColor); + } // Mark The Perforator Hive as dead CalamityWorld.downedPerforator = true; CalamityNetcode.SyncWorld(); } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 180, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 180, true); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < damage / npc.lifeMax * 100.0; k++) { diff --git a/NPCs/Perforator/PerforatorTailLarge.cs b/NPCs/Perforator/PerforatorTailLarge.cs index f9714c44d4..9580b42e94 100644 --- a/NPCs/Perforator/PerforatorTailLarge.cs +++ b/NPCs/Perforator/PerforatorTailLarge.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { - public class PerforatorTailLarge : ModNPC + public class PerforatorTailLarge : ModNPC { public override void SetStaticDefaults() { @@ -18,12 +18,12 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - npc.GetNPCDamage(); + npc.GetNPCDamage(); npc.width = 60; npc.height = 78; npc.defense = 12; - npc.LifeMaxNERB(2250, 2700, 80000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.LifeMaxNERB(2250, 2700, 80000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -38,19 +38,19 @@ namespace CalamityMod.NPCs.Perforator npc.netAlways = true; npc.dontCountMe = true; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -59,107 +59,107 @@ namespace CalamityMod.NPCs.Perforator public override void AI() { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + if (Main.npc[(int)npc.ai[1]].alpha < 128) + { + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } - if (Main.player[npc.target].dead) - npc.TargetClosest(false); + if (Main.player[npc.target].dead) + npc.TargetClosest(false); - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)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; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + if (npc.ai[1] > 0f && npc.ai[1] < (float)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; + } + catch + { + } + npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; + num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + int num194 = npc.width; + num193 = (num193 - (float)num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - npc.spriteDirection = 1; - else if (num191 > 0f) - npc.spriteDirection = -1; - } - } + if (num191 < 0f) + npc.spriteDirection = 1; + else if (num191 > 0f) + npc.spriteDirection = -1; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + 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 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorTailLargeGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorTailLargeGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/Perforator/PerforatorTailMedium.cs b/NPCs/Perforator/PerforatorTailMedium.cs index cddfa50af6..5ea93c28e6 100644 --- a/NPCs/Perforator/PerforatorTailMedium.cs +++ b/NPCs/Perforator/PerforatorTailMedium.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { - public class PerforatorTailMedium : ModNPC + public class PerforatorTailMedium : ModNPC { public override void SetStaticDefaults() { @@ -19,13 +19,13 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 40; npc.height = 50; npc.defense = 10; - npc.LifeMaxNERB(150, 180, 7000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.LifeMaxNERB(150, 180, 7000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -40,124 +40,124 @@ namespace CalamityMod.NPCs.Perforator npc.netAlways = true; npc.dontCountMe = true; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().SplittingWorm = true; + npc.Calamity().SplittingWorm = true; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void AI() { - npc.realLife = -1; + npc.realLife = -1; - // Target - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + // Target + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - if (Main.player[npc.target].dead) - npc.TargetClosest(false); + if (Main.player[npc.target].dead) + npc.TargetClosest(false); - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + if (Main.npc[(int)npc.ai[1]].alpha < 128) + { + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Splitting effect - if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - if (!Main.npc[(int)npc.ai[1]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Splitting effect + if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); + } + if (!Main.npc[(int)npc.ai[1]].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); + } - if (!npc.active && Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } + if (!npc.active && Main.netMode == NetmodeID.Server) + NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); + } - 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); + 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 = (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(num39 * num39 + num40 * num40); + 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(num39 * num39 + num40 * num40); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - 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 - { - } + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + { + try + { + 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(num40, num39) + MathHelper.PiOver2; - num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); - int num53 = npc.width; - num53 = (int)(num53 * npc.scale); - num52 = (num52 - num53) / num52; - num39 *= num52; - num40 *= num52; - npc.velocity = Vector2.Zero; - npc.position.X += num39; - npc.position.Y += num40; - } - } + npc.rotation = (float)Math.Atan2(num40, num39) + MathHelper.PiOver2; + num52 = (float)Math.Sqrt(num39 * num39 + num40 * num40); + int num53 = npc.width; + num53 = (int)(num53 * npc.scale); + num52 = (num52 - num53) / num52; + num39 *= num52; + num40 *= num52; + npc.velocity = Vector2.Zero; + npc.position.X += num39; + npc.position.Y += num40; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + 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 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorTailMediumGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorTailMediumGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { @@ -181,14 +181,14 @@ namespace CalamityMod.NPCs.Perforator public override bool PreNPCLoot() { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - return false; + return false; } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/Perforator/PerforatorTailSmall.cs b/NPCs/Perforator/PerforatorTailSmall.cs index 0c744a9a07..f9ad162ef0 100644 --- a/NPCs/Perforator/PerforatorTailSmall.cs +++ b/NPCs/Perforator/PerforatorTailSmall.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { - public class PerforatorTailSmall : ModNPC + public class PerforatorTailSmall : ModNPC { public override void SetStaticDefaults() { @@ -18,12 +18,12 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - npc.GetNPCDamage(); + npc.GetNPCDamage(); npc.width = 40; npc.height = 34; npc.defense = 8; - npc.LifeMaxNERB(1000, 1200, 50000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.LifeMaxNERB(1000, 1200, 50000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -38,19 +38,19 @@ namespace CalamityMod.NPCs.Perforator npc.netAlways = true; npc.dontCountMe = true; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -59,107 +59,107 @@ namespace CalamityMod.NPCs.Perforator public override void AI() { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(true); + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } + if (Main.npc[(int)npc.ai[1]].alpha < 128) + { + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } - if (Main.player[npc.target].dead) - npc.TargetClosest(false); + if (Main.player[npc.target].dead) + npc.TargetClosest(false); - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)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; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].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); + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + if (npc.ai[1] > 0f && npc.ai[1] < (float)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; + } + catch + { + } + npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; + num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + int num194 = npc.width; + num193 = (num193 - (float)num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - npc.spriteDirection = 1; - else if (num191 > 0f) - npc.spriteDirection = -1; - } - } + if (num191 < 0f) + npc.spriteDirection = 1; + else if (num191 > 0f) + npc.spriteDirection = -1; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + 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 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorTailSmallGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Perforator/PerforatorTailSmallGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/PlagueEnemies/PlagueBee.cs b/NPCs/PlagueEnemies/PlagueBee.cs index 54314edc90..999c6c944f 100644 --- a/NPCs/PlagueEnemies/PlagueBee.cs +++ b/NPCs/PlagueEnemies/PlagueBee.cs @@ -16,8 +16,8 @@ namespace CalamityMod.NPCs.PlagueEnemies { DisplayName.SetDefault("Plague Charger"); Main.npcFrameCount[npc.type] = 4; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -37,68 +37,68 @@ namespace CalamityMod.NPCs.PlagueEnemies npc.noTileCollide = false; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; - - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlagueEnemies/PlagueBeeGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override void NPCLoot() + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - DropHelper.DropItemChance(npc, ItemID.Stinger, Main.expertMode ? 0.5f : 0.25f); - DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; + + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlagueEnemies/PlagueBeeGlow"); + Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; + } + + public override void NPCLoot() + { + 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/PlagueEnemies/PlagueBeeLarge.cs b/NPCs/PlagueEnemies/PlagueBeeLarge.cs index 3d335d41ab..4e3a37a8b1 100644 --- a/NPCs/PlagueEnemies/PlagueBeeLarge.cs +++ b/NPCs/PlagueEnemies/PlagueBeeLarge.cs @@ -16,8 +16,8 @@ namespace CalamityMod.NPCs.PlagueEnemies { DisplayName.SetDefault("Plague Charger"); Main.npcFrameCount[npc.type] = 4; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -37,68 +37,68 @@ namespace CalamityMod.NPCs.PlagueEnemies npc.noTileCollide = false; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; - - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlagueEnemies/PlagueBeeGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override void NPCLoot() + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - DropHelper.DropItemChance(npc, ItemID.Stinger, Main.expertMode ? 0.5f : 0.25f); - DropHelper.DropItem(npc, ModContent.ItemType(), 2, 3); + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; + + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlagueEnemies/PlagueBeeGlow"); + Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; + } + + public override void NPCLoot() + { + 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/PlagueEnemies/PlaguebringerShade.cs b/NPCs/PlagueEnemies/PlaguebringerShade.cs index 5509ed390a..a53b3d8e77 100644 --- a/NPCs/PlagueEnemies/PlaguebringerShade.cs +++ b/NPCs/PlagueEnemies/PlaguebringerShade.cs @@ -21,18 +21,18 @@ namespace CalamityMod.NPCs.PlagueEnemies { DisplayName.SetDefault("Plaguebringer"); Main.npcFrameCount[npc.type] = 12; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.damage = 70; - npc.npcSlots = 8f; + npc.Calamity().canBreakPlayerDefense = true; + npc.damage = 70; + npc.npcSlots = 8f; npc.width = 66; npc.height = 66; npc.defense = 24; - npc.DR_NERD(0.2f); + npc.DR_NERD(0.2f); npc.lifeMax = 3000; npc.value = Item.buyPrice(0, 1, 50, 0); npc.knockBackResist = 0f; @@ -45,9 +45,9 @@ namespace CalamityMod.NPCs.PlagueEnemies npc.DeathSound = SoundID.NPCDeath14; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void AI() { @@ -441,13 +441,13 @@ namespace CalamityMod.NPCs.PlagueEnemies num1073 = num1070 / num1073; num1071 *= num1073; num1072 *= num1073; - bool fireRocket = Main.rand.NextBool(15); + bool fireRocket = Main.rand.NextBool(15); int type = fireRocket ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = fireRocket ? 72 : 52; + int damage = fireRocket ? 72 : 52; if (Main.expertMode) damage = fireRocket ? 50 : 35; - Projectile.NewProjectile(vector121.X, vector121.Y, num1071, num1072, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(vector121.X, vector121.Y, num1071, num1072, type, damage, 0f, Main.myPlayer, 0f, 0f); } } if (!Collision.CanHit(new Vector2(vector121.X, vector121.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) @@ -541,44 +541,44 @@ namespace CalamityMod.NPCs.PlagueEnemies } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; - if (npc.ai[0] != 0f) - num153 = 5; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 7; + if (npc.ai[0] != 0f) + num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (spawnInfo.playerSafe || !NPC.downedGolemBoss || NPC.AnyNPCs(ModContent.NPCType())) { @@ -629,17 +629,17 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void NPCLoot() { - if (!CalamityWorld.revenge) - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + if (!CalamityWorld.revenge) + { + int heartAmt = Main.rand.Next(3) + 3; + for (int i = 0; i < heartAmt; i++) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - 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); + 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); } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/PlagueEnemies/PlaguedDerpling.cs b/NPCs/PlagueEnemies/PlaguedDerpling.cs index 398625a03e..f29112573f 100644 --- a/NPCs/PlagueEnemies/PlaguedDerpling.cs +++ b/NPCs/PlagueEnemies/PlaguedDerpling.cs @@ -34,10 +34,10 @@ namespace CalamityMod.NPCs.PlagueEnemies npc.HitSound = SoundID.NPCHit22; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { @@ -55,11 +55,11 @@ namespace CalamityMod.NPCs.PlagueEnemies } float num = 6f; //2 float num2 = 0.05f; - if (CalamityWorld.death) - { - num *= 1.5f; - num2 *= 1.5f; - } + if (CalamityWorld.death) + { + num *= 1.5f; + num2 *= 1.5f; + } Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num4 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); float num5 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); @@ -185,7 +185,7 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); + DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); } } } diff --git a/NPCs/PlagueEnemies/PlaguedFlyingFox.cs b/NPCs/PlagueEnemies/PlaguedFlyingFox.cs index 8c9c775261..860cf13547 100644 --- a/NPCs/PlagueEnemies/PlaguedFlyingFox.cs +++ b/NPCs/PlagueEnemies/PlaguedFlyingFox.cs @@ -32,10 +32,10 @@ namespace CalamityMod.NPCs.PlagueEnemies npc.HitSound = SoundID.NPCHit1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { @@ -69,7 +69,7 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); + DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); } } } diff --git a/NPCs/PlagueEnemies/PlaguedJungleSlime.cs b/NPCs/PlagueEnemies/PlaguedJungleSlime.cs index 9327efdf6b..cd0ac05daf 100644 --- a/NPCs/PlagueEnemies/PlaguedJungleSlime.cs +++ b/NPCs/PlagueEnemies/PlaguedJungleSlime.cs @@ -39,9 +39,9 @@ namespace CalamityMod.NPCs.PlagueEnemies npc.HitSound = SoundID.NPCHit1; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void AI() { @@ -126,8 +126,8 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void NPCLoot() { - DropHelper.DropItemChance(npc, ItemID.Stinger, Main.expertMode ? 0.5f : 0.25f); - DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); + 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/PlagueEnemies/PlaguedTortoise.cs b/NPCs/PlagueEnemies/PlaguedTortoise.cs index fe10f7a873..87e6e303ba 100644 --- a/NPCs/PlagueEnemies/PlaguedTortoise.cs +++ b/NPCs/PlagueEnemies/PlaguedTortoise.cs @@ -32,10 +32,10 @@ namespace CalamityMod.NPCs.PlagueEnemies npc.noGravity = false; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + } public override void HitEffect(int hitDirection, double damage) { @@ -69,7 +69,7 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 3, 4); + DropHelper.DropItem(npc, ModContent.ItemType(), 3, 4); } } } diff --git a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs index 3f05b6b02a..d79d49209e 100644 --- a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs +++ b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs @@ -17,14 +17,14 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { DisplayName.SetDefault("Plague Homing Missile"); Main.npcFrameCount[npc.type] = 4; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.width = 22; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.width = 22; npc.height = 22; npc.defense = 20; npc.lifeMax = BossRushEvent.BossRushActive ? 5000 : 500; @@ -36,18 +36,18 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.noGravity = true; npc.canGhostHeal = false; npc.noTileCollide = true; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void AI() { - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - Lighting.AddLight(npc.Center, 0.015f, 0.1f, 0f); + Lighting.AddLight(npc.Center, 0.015f, 0.1f, 0f); if (Math.Abs(npc.velocity.X) >= 3f || Math.Abs(npc.velocity.Y) >= 3f) { @@ -82,7 +82,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - float timeBeforeHoming = 120f - npc.ai[3] * 0.5f; + float timeBeforeHoming = 120f - npc.ai[3] * 0.5f; if (npc.ai[2] < timeBeforeHoming) { npc.ai[2] += 1f; @@ -115,27 +115,27 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath Vector2 v3 = Main.player[(int)npc.ai[1]].Center - npc.Center; float num760 = npc.velocity.ToRotation(); float num761 = v3.ToRotation(); - float angle = num761 - num760; - angle = MathHelper.WrapAngle(angle); + float angle = num761 - num760; + angle = MathHelper.WrapAngle(angle); npc.velocity = npc.velocity.RotatedBy(angle * 0.2); } else { npc.noTileCollide = false; - if (npc.velocity.Length() < (malice ? 25f : 20f)) - npc.velocity *= 1.01f; + if (npc.velocity.Length() < (malice ? 25f : 20f)) + npc.velocity *= 1.01f; - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - CheckDead(); - npc.life = 0; - return; - } + if (Collision.SolidCollision(npc.position, npc.width, npc.height)) + { + CheckDead(); + npc.life = 0; + return; + } } } - float distanceBeforeExploding = 42f; + float distanceBeforeExploding = 42f; for (int i = 0; i < Main.maxPlayers; i++) { Player player = Main.player[i]; @@ -148,61 +148,61 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlaguebringerGoliath/PlagueHomingMissileGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlaguebringerGoliath/PlagueHomingMissileGlow"); + Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -241,9 +241,9 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath return true; } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 180, true); } diff --git a/NPCs/PlaguebringerGoliath/PlagueMine.cs b/NPCs/PlaguebringerGoliath/PlagueMine.cs index 766b19261d..d0c1b7c128 100644 --- a/NPCs/PlaguebringerGoliath/PlagueMine.cs +++ b/NPCs/PlaguebringerGoliath/PlagueMine.cs @@ -20,8 +20,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); npc.width = 42; npc.height = 42; npc.defense = 20; @@ -34,19 +34,19 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void AI() { - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - Lighting.AddLight(npc.Center, 0.03f, 0.2f, 0f); + Lighting.AddLight(npc.Center, 0.03f, 0.2f, 0f); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; if (!player.active || player.dead) { npc.TargetClosest(false); @@ -63,8 +63,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.timeLeft = 600; Vector2 vector = Main.player[npc.target].Center - npc.Center; - float distanceRequiredForExplosion = 90f; - float timeBeforeExplosion = (malice ? 1000f : death ? 740f : revenge ? 520f : 400f) + npc.ai[3] * 4f; + float distanceRequiredForExplosion = 90f; + float timeBeforeExplosion = (malice ? 1000f : death ? 740f : revenge ? 520f : 400f) + npc.ai[3] * 4f; if (vector.Length() < distanceRequiredForExplosion || npc.ai[0] >= timeBeforeExplosion) { CheckDead(); @@ -88,7 +88,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath float num1376 = velocity / num1375; num1373 *= num1376; num1374 *= num1376; - float inertia = (malice ? 35f : death ? 40f : revenge ? 45f : 50f) - npc.ai[3] * 0.25f; + float inertia = (malice ? 35f : death ? 40f : revenge ? 45f : 50f) - npc.ai[3] * 0.25f; npc.velocity.X = (npc.velocity.X * inertia + num1373) / (inertia + 1f); npc.velocity.Y = (npc.velocity.Y * inertia + num1374) / (inertia + 1f); } @@ -104,35 +104,35 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - 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(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Texture2D texture2D15 = Main.npcTexture[npc.type]; + 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(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlaguebringerGoliath/PlagueMineGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlaguebringerGoliath/PlagueMineGlow"); + Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 240, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 240, true); + } - public override bool CheckDead() + public override bool CheckDead() { Main.PlaySound(SoundID.Item14, npc.position); npc.position.X = npc.position.X + (float)(npc.width / 2); diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index 31ef854a90..c629a84267 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -29,8 +29,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath [AutoloadBossHead] public class PlaguebringerGoliath : ModNPC { - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private const float MissileAngleSpread = 60; + private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + private const float MissileAngleSpread = 60; private const int MissileProjectiles = 8; private int MissileCountdown = 0; private int despawnTimer = 120; @@ -45,19 +45,19 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { DisplayName.SetDefault("The Plaguebringer Goliath"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 64f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 64f; npc.width = 198; npc.height = 198; npc.defense = 50; - npc.DR_NERD(0.3f); - npc.LifeMaxNERB(88750, 106500, 370000); + npc.DR_NERD(0.3f); + npc.LifeMaxNERB(88750, 106500, 370000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -71,14 +71,14 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.DeathSound = SoundID.NPCDeath14; music = CalamityMod.Instance.GetMusicFromMusicMod("PlaguebringerGoliath") ?? MusicID.Boss3; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); - writer.Write(halfLife); + writer.Write(biomeEnrageTimer); + writer.Write(halfLife); writer.Write(canDespawn); writer.Write(flyingFrame2); writer.Write(MissileCountdown); @@ -91,8 +91,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); - halfLife = reader.ReadBoolean(); + biomeEnrageTimer = reader.ReadInt32(); + halfLife = reader.ReadBoolean(); canDespawn = reader.ReadBoolean(); flyingFrame2 = reader.ReadBoolean(); MissileCountdown = reader.ReadInt32(); @@ -105,47 +105,47 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); //drawcode adjustments for the new sprite npc.gfxOffY = charging ? -40 : -50; npc.width = npc.frame.Width / 2; npc.height = (int)(npc.frame.Height * (charging ? 1.5f : 1.8f)); - // Mode variables - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Mode variables + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Phases - bool phase2 = lifeRatio < 0.75f; - bool phase3 = lifeRatio < 0.5f; - bool phase4 = lifeRatio < 0.25f; - bool phase5 = lifeRatio < 0.1f; + // Phases + bool phase2 = lifeRatio < 0.75f; + bool phase3 = lifeRatio < 0.5f; + bool phase4 = lifeRatio < 0.25f; + bool phase5 = lifeRatio < 0.1f; - // Adjusts how 'challenging' the projectiles and enemies are to deal with - float challengeAmt = (1f - lifeRatio) * 100f; - float nukeBarrageChallengeAmt = (0.5f - lifeRatio) * 200f; + // Adjusts how 'challenging' the projectiles and enemies are to deal with + float challengeAmt = (1f - lifeRatio) * 100f; + float nukeBarrageChallengeAmt = (0.5f - lifeRatio) * 200f; - // Adjust slowing debuff immunity - bool immuneToSlowingDebuffs = npc.ai[0] == 0f || npc.ai[0] == 4f; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = npc.ai[0] == 0f || npc.ai[0] == 4f; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; - // Light - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.3f, 0.7f, 0f); + // Light + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.3f, 0.7f, 0f); // Show message if (!halfLife && phase3 && expertMode) @@ -164,7 +164,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (MissileCountdown > 1) MissileCountdown--; - Vector2 vectorCenter = npc.Center; + Vector2 vectorCenter = npc.Center; // Count nearby players int num1038 = 0; @@ -174,58 +174,58 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath num1038++; } - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; // Distance from target Vector2 distFromPlayer = player.Center - vectorCenter; - // Enrage - if (!player.ZoneJungle && !BossRushEvent.BossRushActive) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + // Enrage + if (!player.ZoneJungle && !BossRushEvent.BossRushActive) + { + if (biomeEnrageTimer > 0) + biomeEnrageTimer--; + } + else + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || malice; + bool biomeEnraged = biomeEnrageTimer <= 0 || malice; - float enrageScale = death ? 0.5f : 0f; + float enrageScale = death ? 0.5f : 0f; if (biomeEnraged) { npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 1.5f; } - if (enrageScale > 1.5f) - enrageScale = 1.5f; + if (enrageScale > 1.5f) + enrageScale = 1.5f; - if (BossRushEvent.BossRushActive) - enrageScale = 2f; + if (BossRushEvent.BossRushActive) + enrageScale = 2f; - bool diagonalDash = (revenge && phase2) || malice; + bool diagonalDash = (revenge && phase2) || malice; - if (npc.ai[0] != 0f && npc.ai[0] != 4f) - npc.rotation = npc.velocity.X * 0.02f; + if (npc.ai[0] != 0f && npc.ai[0] != 4f) + npc.rotation = npc.velocity.X * 0.02f; - // Despawn - if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 5600f) + // Despawn + if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 5600f) { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 5600f) - { - if (despawnTimer > 0) - despawnTimer--; - } + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 5600f) + { + if (despawnTimer > 0) + despawnTimer--; + } } else despawnTimer = 120; @@ -233,34 +233,34 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath canDespawn = despawnTimer <= 0; if (canDespawn) { - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.2f; - if (npc.velocity.Y < -16f) - npc.velocity.Y = -16f; + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + npc.velocity.Y -= 0.2f; + if (npc.velocity.Y < -16f) + npc.velocity.Y = -16f; - if (npc.timeLeft > 60) + if (npc.timeLeft > 60) npc.timeLeft = 60; - if (npc.ai[0] != -1f) - { - npc.ai[0] = -1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - MissileCountdown = 0; - chargeDistance = 0; - npc.netUpdate = true; - } - return; + if (npc.ai[0] != -1f) + { + npc.ai[0] = -1f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + MissileCountdown = 0; + chargeDistance = 0; + npc.netUpdate = true; + } + return; } - // Always start in enemy spawning phase - if (calamityGlobalNPC.newAI[3] == 0f) - { - calamityGlobalNPC.newAI[3] = 1f; - npc.ai[0] = 2f; - npc.netUpdate = true; - } + // Always start in enemy spawning phase + if (calamityGlobalNPC.newAI[3] == 0f) + { + calamityGlobalNPC.newAI[3] = 1f; + npc.ai[0] = 2f; + npc.netUpdate = true; + } // Phase switch if (npc.ai[0] == -1f) @@ -271,31 +271,31 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath do num596 = MissileCountdown == 1 ? 4 : Main.rand.Next(4); while (num596 == npc.ai[1] || num596 == 1); - if (num596 == 0 && diagonalDash && distFromPlayer.Length() < 1800f) - { - do - { - switch (Main.rand.Next(3)) - { - case 0: - chargeDistance = 0; - break; - case 1: - chargeDistance = 400; - break; - case 2: - chargeDistance = -400; - break; - } - } - while (chargeDistance == npc.ai[3]); + if (num596 == 0 && diagonalDash && distFromPlayer.Length() < 1800f) + { + do + { + switch (Main.rand.Next(3)) + { + case 0: + chargeDistance = 0; + break; + case 1: + chargeDistance = 400; + break; + case 2: + chargeDistance = -400; + break; + } + } + while (chargeDistance == npc.ai[3]); - npc.ai[3] = -chargeDistance; - } + npc.ai[3] = -chargeDistance; + } npc.ai[0] = num596; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); + npc.TargetClosest(); npc.netUpdate = true; // Prevent netUpdate from being blocked by the spam counter. @@ -310,19 +310,19 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // Charge phase else if (npc.ai[0] == 0f) { - float num1044 = revenge ? 28f : 26f; - if (phase2) - num1044 += 1f; - if (phase3) - num1044 += 1f; - if (phase4) - num1044 += 1f; - if (phase5) - num1044 += 1f; + float num1044 = revenge ? 28f : 26f; + if (phase2) + num1044 += 1f; + if (phase3) + num1044 += 1f; + if (phase4) + num1044 += 1f; + if (phase5) + num1044 += 1f; - num1044 += 2f * enrageScale; + num1044 += 2f * enrageScale; - int num1043 = (int)Math.Ceiling(2f + enrageScale); + int num1043 = (int)Math.Ceiling(2f + enrageScale); if ((npc.ai[1] > (2 * num1043) && npc.ai[1] % 2f == 0f) || distFromPlayer.Length() > 1800f) { npc.ai[0] = -1f; @@ -343,28 +343,28 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // Charge if (npc.ai[1] % 2f == 0f) { - float playerLocation = vectorCenter.X - player.Center.X; + float playerLocation = vectorCenter.X - player.Center.X; - float num620 = 20f; - num620 += 20f * enrageScale; + float num620 = 20f; + num620 += 20f * enrageScale; - if (Math.Abs(npc.Center.Y - (player.Center.Y - chargeDistance)) < num620) + if (Math.Abs(npc.Center.Y - (player.Center.Y - chargeDistance)) < num620) { - if (diagonalDash) - { - switch (Main.rand.Next(3)) - { - case 0: - chargeDistance = 0; - break; - case 1: - chargeDistance = 400; - break; - case 2: - chargeDistance = -400; - break; - } - } + if (diagonalDash) + { + switch (Main.rand.Next(3)) + { + case 0: + chargeDistance = 0; + break; + case 1: + chargeDistance = 400; + break; + case 2: + chargeDistance = -400; + break; + } + } charging = true; npc.frameCounter = 4; @@ -379,15 +379,15 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath num1047 = num1044 / num1047; npc.velocity.X = num1045 * num1047; npc.velocity.Y = num1046 * num1047; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - calamityGlobalNPC.newAI[1] = npc.velocity.X; - calamityGlobalNPC.newAI[2] = npc.velocity.Y; + calamityGlobalNPC.newAI[1] = npc.velocity.X; + calamityGlobalNPC.newAI[2] = npc.velocity.Y; - npc.direction = playerLocation < 0 ? 1 : -1; + npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; - if (npc.spriteDirection != 1) - npc.rotation += (float)Math.PI; + if (npc.spriteDirection != 1) + npc.rotation += (float)Math.PI; npc.netUpdate = true; npc.netSpam -= 5; @@ -396,8 +396,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath return; } - npc.rotation = npc.velocity.X * 0.02f; - charging = false; + npc.rotation = npc.velocity.X * 0.02f; + charging = false; float num1048 = revenge ? 14f : 12f; float num1049 = revenge ? 0.25f : 0.22f; @@ -411,10 +411,10 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath num1048 += 1f; num1049 += 0.05f; } - num1048 += 1.5f * enrageScale; - num1049 += 0.25f * enrageScale; + num1048 += 1.5f * enrageScale; + num1049 += 0.25f * enrageScale; - if (vectorCenter.Y < (player.Center.Y - chargeDistance)) + if (vectorCenter.Y < (player.Center.Y - chargeDistance)) npc.velocity.Y += num1049; else npc.velocity.Y -= num1049; @@ -455,46 +455,46 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath int num1050 = revenge ? 525 : 550; if (phase4) - num1050 = revenge ? 450 : 475; - else if (phase3) + num1050 = revenge ? 450 : 475; + else if (phase3) num1050 = revenge ? 475 : 500; else if (phase2) num1050 = revenge ? 500 : 525; - num1050 -= (int)(25f * enrageScale); + num1050 -= (int)(25f * enrageScale); - int num1051 = 1; + int num1051 = 1; if (vectorCenter.X < player.Center.X) num1051 = -1; - if (npc.direction == num1051 && (Math.Abs(vectorCenter.X - player.Center.X) > num1050 || Math.Abs(vectorCenter.Y - player.Center.Y) > num1050)) - npc.ai[2] = 1f; + if (npc.direction == num1051 && (Math.Abs(vectorCenter.X - player.Center.X) > num1050 || Math.Abs(vectorCenter.Y - player.Center.Y) > num1050)) + npc.ai[2] = 1f; - if (enrageScale > 0 && npc.ai[2] == 1f) - npc.velocity *= 0.95f; + if (enrageScale > 0 && npc.ai[2] == 1f) + npc.velocity *= 0.95f; - if (npc.ai[2] != 1f) + if (npc.ai[2] != 1f) { charging = true; npc.frameCounter = 4; // Velocity fix if PBG slowed if (npc.velocity.Length() < num1044) - npc.velocity = new Vector2(calamityGlobalNPC.newAI[1], calamityGlobalNPC.newAI[2]); + npc.velocity = new Vector2(calamityGlobalNPC.newAI[1], calamityGlobalNPC.newAI[2]); - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] > 90f) - npc.velocity *= 1.01f; + calamityGlobalNPC.newAI[0] += 1f; + if (calamityGlobalNPC.newAI[0] > 90f) + npc.velocity *= 1.01f; npc.netUpdate = true; - return; + return; } - float playerLocation = vectorCenter.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = vectorCenter.X - player.Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; - npc.rotation = npc.velocity.X * 0.02f; - charging = false; + npc.rotation = npc.velocity.X * 0.02f; + charging = false; npc.velocity *= 0.9f; float num1052 = revenge ? 0.12f : 0.1f; @@ -513,16 +513,16 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.velocity *= 0.98f; num1052 += 0.05f; } - if (enrageScale > 0) - npc.velocity *= 0.95f; + if (enrageScale > 0) + npc.velocity *= 0.95f; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < num1052) + if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < num1052) { npc.ai[2] = 0f; npc.ai[1] += 1f; - calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[0] = 0f; } - } + } } // Move closer if too far away @@ -536,13 +536,13 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath float num1056 = player.position.Y + (player.height / 2) - 200f - vectorCenter.Y; float num1057 = (float)Math.Sqrt(num1055 * num1055 + num1056 * num1056); - calamityGlobalNPC.newAI[0] += 1f; - if (num1057 < 600f || calamityGlobalNPC.newAI[0] >= 180f) + calamityGlobalNPC.newAI[0] += 1f; + if (num1057 < 600f || calamityGlobalNPC.newAI[0] >= 180f) { npc.ai[0] = (phase3 || malice) ? 5f : 1f; npc.ai[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - npc.netUpdate = true; + calamityGlobalNPC.newAI[0] = 0f; + npc.netUpdate = true; // Prevent netUpdate from being blocked by the spam counter. // A phase switch sync is a critical operation that must be synced. @@ -585,27 +585,27 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { Main.PlaySound(SoundID.NPCHit, (int)npc.position.X, (int)npc.position.Y, 8); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (expertMode && NPC.CountNPCS(ModContent.NPCType()) < 2) - NPC.NewNPC((int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (expertMode && NPC.CountNPCS(ModContent.NPCType()) < 2) + NPC.NewNPC((int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); - float npcSpeed = (revenge ? 9f : 7f) + enrageScale * 2f; + float npcSpeed = (revenge ? 9f : 7f) + enrageScale * 2f; - float num1071 = player.position.X + player.width * 0.5f - vector119.X; - float num1072 = player.position.Y + player.height * 0.5f - vector119.Y; - float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); + float num1071 = player.position.X + player.width * 0.5f - vector119.X; + float num1072 = player.position.Y + player.height * 0.5f - vector119.Y; + float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); - num1073 = npcSpeed / num1073; - num1071 *= num1073; - num1072 *= num1073; + num1073 = npcSpeed / num1073; + num1071 *= num1073; + num1072 *= num1073; - int num1062 = NPC.NewNPC((int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); - Main.npc[num1062].velocity.X = num1071; - Main.npc[num1062].velocity.Y = num1072; - Main.npc[num1062].netUpdate = true; - } - } + int num1062 = NPC.NewNPC((int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); + Main.npc[num1062].velocity.X = num1071; + Main.npc[num1062].velocity.Y = num1072; + Main.npc[num1062].netUpdate = true; + } + } // Move closer if too far away if (num1060 > 600f) @@ -621,8 +621,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { npc.ai[0] = -1f; npc.ai[1] = 2f; - npc.ai[2] = 0f; - npc.netUpdate = true; + npc.ai[2] = 0f; + npc.netUpdate = true; // Prevent netUpdate from being blocked by the spam counter. // A phase switch sync is a critical operation that must be synced. @@ -665,28 +665,28 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 88); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (expertMode && NPC.CountNPCS(ModContent.NPCType()) < 3) - NPC.NewNPC((int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (expertMode && NPC.CountNPCS(ModContent.NPCType()) < 3) + NPC.NewNPC((int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); - float npcSpeed = (revenge ? 11f : 9f) + enrageScale * 2f; + float npcSpeed = (revenge ? 11f : 9f) + enrageScale * 2f; - float num1071 = player.position.X + player.width * 0.5f - vector119.X; - float num1072 = player.position.Y + player.height * 0.5f - vector119.Y; - float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); + float num1071 = player.position.X + player.width * 0.5f - vector119.X; + float num1072 = player.position.Y + player.height * 0.5f - vector119.Y; + float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); - num1073 = npcSpeed / num1073; - num1071 *= num1073; - num1072 *= num1073; - num1071 += Main.rand.Next(-20, 21) * 0.05f; - num1072 += Main.rand.Next(-20, 21) * 0.05f; + num1073 = npcSpeed / num1073; + num1071 *= num1073; + num1072 *= num1073; + num1071 += Main.rand.Next(-20, 21) * 0.05f; + num1072 += Main.rand.Next(-20, 21) * 0.05f; - int num1062 = NPC.NewNPC((int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); - Main.npc[num1062].velocity.X = num1071; - Main.npc[num1062].velocity.Y = num1072; - Main.npc[num1062].netUpdate = true; - } + int num1062 = NPC.NewNPC((int)vector119.X, (int)vector119.Y, ModContent.NPCType(), 0, 0f, 0f, 0f, challengeAmt); + Main.npc[num1062].velocity.X = num1071; + Main.npc[num1062].velocity.Y = num1072; + Main.npc[num1062].netUpdate = true; + } } // Move closer if too far away @@ -703,8 +703,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { npc.ai[0] = -1f; npc.ai[1] = 2f; - npc.ai[2] = 0f; - npc.netUpdate = true; + npc.ai[2] = 0f; + npc.netUpdate = true; // Prevent netUpdate from being blocked by the spam counter. // A phase switch sync is a critical operation that must be synced. @@ -721,18 +721,18 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath Vector2 vector121 = new Vector2(npc.direction == 1 ? npc.getRect().BottomLeft().X : npc.getRect().BottomRight().X, npc.getRect().Bottom().Y + 20f); vector121.X += npc.direction * 120; - npc.ai[1] += 1f; - int num650 = phase5 ? 20 : (phase3 ? 25 : 30); - num650 -= (int)Math.Ceiling(5f * enrageScale); + npc.ai[1] += 1f; + int num650 = phase5 ? 20 : (phase3 ? 25 : 30); + num650 -= (int)Math.Ceiling(5f * enrageScale); - if (npc.ai[1] % num650 == (num650 - 1) && vectorCenter.Y < player.position.Y) + if (npc.ai[1] % num650 == (num650 - 1) && vectorCenter.Y < player.position.Y) { Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 42); if (Main.netMode != NetmodeID.MultiplayerClient) { float projectileSpeed = revenge ? 6f : 5f; - projectileSpeed += 2f * enrageScale; + projectileSpeed += 2f * enrageScale; float num1071 = player.position.X + player.width * 0.5f - vector121.X; float num1072 = player.position.Y + player.height * 0.5f - vector121.Y; @@ -742,30 +742,30 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath num1072 *= num1073; int type = ModContent.ProjectileType(); - switch ((int)npc.ai[2]) - { - case 0: - case 1: - break; - case 2: - case 3: - if (expertMode) - type = ModContent.ProjectileType(); - break; - case 4: - type = ModContent.ProjectileType(); - break; - } + switch ((int)npc.ai[2]) + { + case 0: + case 1: + break; + case 2: + case 3: + if (expertMode) + type = ModContent.ProjectileType(); + break; + case 4: + type = ModContent.ProjectileType(); + break; + } - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(vector121.X, vector121.Y, num1071, num1072, type, damage, 0f, Main.myPlayer, challengeAmt, player.position.Y); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(vector121.X, vector121.Y, num1071, num1072, type, damage, 0f, Main.myPlayer, challengeAmt, player.position.Y); npc.netUpdate = true; } - npc.ai[2] += 1f; - if (npc.ai[2] > 4f) - npc.ai[2] = 0f; - } + npc.ai[2] += 1f; + if (npc.ai[2] > 4f) + npc.ai[2] = 0f; + } Movement(100f, 400f, 500f, player, enrageScale); @@ -773,12 +773,12 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; - if (npc.ai[1] > num650 * 10f) - { + if (npc.ai[1] > num650 * 10f) + { npc.ai[0] = -1f; npc.ai[1] = 3f; - npc.ai[2] = 0f; - npc.netUpdate = true; + npc.ai[2] = 0f; + npc.netUpdate = true; // Prevent netUpdate from being blocked by the spam counter. // A phase switch sync is a critical operation that must be synced. @@ -792,11 +792,11 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // Missile charge else if (npc.ai[0] == 4f) { - float num1044 = revenge ? 28f : 26f; + float num1044 = revenge ? 28f : 26f; - num1044 += 3f * enrageScale; + num1044 += 3f * enrageScale; - int num1043 = (int)Math.Ceiling(2f + enrageScale); + int num1043 = (int)Math.Ceiling(2f + enrageScale); if (npc.ai[1] > (2 * num1043) && npc.ai[1] % 2f == 0f) { MissileCountdown = 0; @@ -818,10 +818,10 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { float playerLocation = vectorCenter.X - player.Center.X; - float num620 = 20f; - num620 += 20 * enrageScale; + float num620 = 20f; + num620 += 20 * enrageScale; - if (Math.Abs(vectorCenter.Y - (player.Center.Y - 500f)) < num620) + if (Math.Abs(vectorCenter.Y - (player.Center.Y - 500f)) < num620) { if (MissileCountdown == 1) { @@ -830,17 +830,17 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (Main.netMode != NetmodeID.MultiplayerClient) { float speed = revenge ? 6f : 5f; - speed += 2f * enrageScale; + speed += 2f * enrageScale; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); - Vector2 baseVelocity = player.Center - vectorCenter; + Vector2 baseVelocity = player.Center - vectorCenter; baseVelocity.Normalize(); baseVelocity *= speed; - int missiles = malice ? 16 : MissileProjectiles; - int spread = malice ? 18 : 24; + int missiles = malice ? 16 : MissileProjectiles; + int spread = malice ? 18 : 24; for (int i = 0; i < missiles; i++) { Vector2 spawn = vectorCenter; // Normal = 96, Malice = 144 @@ -863,25 +863,25 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath num1047 = num1044 / num1047; npc.velocity.X = num1045 * num1047; npc.velocity.Y = num1046 * num1047; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - npc.direction = playerLocation < 0 ? 1 : -1; + npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; - if (npc.spriteDirection != 1) - npc.rotation += (float)Math.PI; + if (npc.spriteDirection != 1) + npc.rotation += (float)Math.PI; npc.netUpdate = true; - return; + return; } - npc.rotation = npc.velocity.X * 0.02f; - charging = false; + npc.rotation = npc.velocity.X * 0.02f; + charging = false; float num1048 = revenge ? 16f : 14f; float num1049 = revenge ? 0.2f : 0.18f; - num1048 += 1.5f * enrageScale; - num1049 += 0.25f * enrageScale; + num1048 += 1.5f * enrageScale; + num1049 += 0.25f * enrageScale; if (vectorCenter.Y < player.Center.Y - 500f) npc.velocity.Y += num1049; @@ -907,7 +907,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; - } + } // Slow down after charge else @@ -926,26 +926,26 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath num1051 = -1; if (npc.direction == num1051 && Math.Abs(vectorCenter.X - player.Center.X) > num1050) npc.ai[2] = 1f; - if (enrageScale > 0 && npc.ai[2] == 1f) - npc.velocity *= 0.95f; + if (enrageScale > 0 && npc.ai[2] == 1f) + npc.velocity *= 0.95f; - if (npc.ai[2] != 1f) + if (npc.ai[2] != 1f) { charging = true; // Velocity fix if PBG slowed if (npc.velocity.Length() < num1044) - npc.velocity.X = num1044 * npc.direction; + npc.velocity.X = num1044 * npc.direction; - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] > 90f) - npc.velocity.X *= 1.01f; + calamityGlobalNPC.newAI[0] += 1f; + if (calamityGlobalNPC.newAI[0] > 90f) + npc.velocity.X *= 1.01f; - return; + return; } - npc.rotation = npc.velocity.X * 0.02f; - charging = false; + npc.rotation = npc.velocity.X * 0.02f; + charging = false; npc.velocity *= 0.9f; float num1052 = revenge ? 0.12f : 0.1f; @@ -964,32 +964,32 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.velocity *= 0.9f; num1052 += 0.05f; } - if (enrageScale > 0) - npc.velocity *= 0.95f; + if (enrageScale > 0) + npc.velocity *= 0.95f; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < num1052) + if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < num1052) { npc.ai[2] = 0f; npc.ai[1] += 1f; - calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[0] = 0f; } - } + } } } private void Movement(float xPos, float yPos, float yPos2, Player player, float enrageScale) { - Vector2 acceleration = new Vector2(0.1f, 0.15f); - Vector2 velocity = new Vector2(8f, 5f); - float deceleration = 0.98f; + Vector2 acceleration = new Vector2(0.1f, 0.15f); + Vector2 velocity = new Vector2(8f, 5f); + float deceleration = 0.98f; - acceleration *= 0.1f * enrageScale + 1f; - velocity *= 1f - enrageScale * 0.1f; - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - velocity *= 0.5f; - deceleration *= 1f - enrageScale * 0.1f; + acceleration *= 0.1f * enrageScale + 1f; + velocity *= 1f - enrageScale * 0.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + velocity *= 0.5f; + deceleration *= 1f - enrageScale * 0.1f; - if (npc.position.Y > player.position.Y - yPos) + if (npc.position.Y > player.position.Y - yPos) { if (npc.velocity.Y > 0f) npc.velocity.Y *= deceleration; @@ -1026,28 +1026,28 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath public override bool CheckActive() => canDespawn; - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - Rectangle targetHitbox = target.Hitbox; + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= 100f; - } + return minDist <= 100f; + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 2; k++) { @@ -1087,8 +1087,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.npcTexture[npc.type]; - Texture2D glowTexture = ModContent.GetTexture("CalamityMod/NPCs/PlaguebringerGoliath/PlaguebringerGoliathGlow"); - if (curTex != (charging ? 2 : 1)) + Texture2D glowTexture = ModContent.GetTexture("CalamityMod/NPCs/PlaguebringerGoliath/PlaguebringerGoliathGlow"); + if (curTex != (charging ? 2 : 1)) { npc.frame.X = 0; npc.frame.Y = 0; @@ -1097,8 +1097,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { curTex = 2; texture = ModContent.GetTexture("CalamityMod/NPCs/PlaguebringerGoliath/PlaguebringerGoliathChargeTex"); - glowTexture = ModContent.GetTexture("CalamityMod/NPCs/PlaguebringerGoliath/PlaguebringerGoliathChargeTexGlow"); - } + glowTexture = ModContent.GetTexture("CalamityMod/NPCs/PlaguebringerGoliath/PlaguebringerGoliathChargeTexGlow"); + } else { curTex = 1; @@ -1108,55 +1108,55 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - int frameCount = 3; - Rectangle rectangle = new Rectangle(npc.frame.X, npc.frame.Y, texture.Width / 2, texture.Height / frameCount); - Vector2 vector11 = rectangle.Size() / 2f; - Vector2 posOffset = new Vector2(charging ? 175 : 125, 0); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 10; - if (npc.ai[0] != 0f && npc.ai[0] != 4f) - num153 = 7; + int frameCount = 3; + Rectangle rectangle = new Rectangle(npc.frame.X, npc.frame.Y, texture.Width / 2, texture.Height / frameCount); + Vector2 vector11 = rectangle.Size() / 2f; + Vector2 posOffset = new Vector2(charging ? 175 : 125, 0); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 10; + if (npc.ai[0] != 0f && npc.ai[0] != 4f) + num153 = 7; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture.Width, texture.Height / frameCount) * npc.scale / 2f; - vector41 += vector11 * npc.scale + posOffset; - spriteBatch.Draw(texture, vector41, new Rectangle?(rectangle), color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture.Width, texture.Height / frameCount) * npc.scale / 2f; + vector41 += vector11 * npc.scale + posOffset; + spriteBatch.Draw(texture, vector41, new Rectangle?(rectangle), color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture.Width, texture.Height / frameCount) * npc.scale / 2f; - vector43 += vector11 * npc.scale + posOffset; - spriteBatch.Draw(texture, vector43, new Rectangle?(rectangle), npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture.Width, texture.Height / frameCount) * npc.scale / 2f; + vector43 += vector11 * npc.scale + posOffset; + spriteBatch.Draw(texture, vector43, new Rectangle?(rectangle), npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(glowTexture.Width, glowTexture.Height / frameCount) * npc.scale / 2f; - vector44 += vector11 * npc.scale + posOffset; - spriteBatch.Draw(glowTexture, vector44, new Rectangle?(rectangle), color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(glowTexture.Width, glowTexture.Height / frameCount) * npc.scale / 2f; + vector44 += vector11 * npc.scale + posOffset; + spriteBatch.Draw(glowTexture, vector44, new Rectangle?(rectangle), color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(glowTexture, vector43, new Rectangle?(rectangle), color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(glowTexture, vector43, new Rectangle?(rectangle), color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; + return false; } public override void FindFrame(int frameHeight) @@ -1188,15 +1188,15 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedPlaguebringer); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) { // Materials DropHelper.DropItemSpray(npc, ModContent.ItemType(), 10, 14); @@ -1217,10 +1217,10 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w) - ); + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); diff --git a/NPCs/Polterghast/PhantomFuckYou.cs b/NPCs/Polterghast/PhantomFuckYou.cs index 7222f1488a..35e84818e8 100644 --- a/NPCs/Polterghast/PhantomFuckYou.cs +++ b/NPCs/Polterghast/PhantomFuckYou.cs @@ -11,186 +11,186 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Polterghast { - public class PhantomFuckYou : ModNPC - { - private bool start = true; + public class PhantomFuckYou : ModNPC + { + private bool start = true; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Phantom"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Phantom"); + NPCID.Sets.TrailingMode[npc.type] = 1; + } - public override void SetDefaults() - { - npc.aiStyle = -1; - aiType = -1; - npc.width = 30; - npc.height = 30; - npc.defense = 45; - npc.DR_NERD(0.1f); - npc.noGravity = true; - npc.noTileCollide = true; - npc.canGhostHeal = false; - npc.damage = 0; - npc.LifeMaxNERB(Main.expertMode ? 11250 : 8750, CalamityWorld.death ? 22500 : 18750, 15000); - npc.HitSound = SoundID.NPCHit36; - npc.DeathSound = SoundID.NPCDeath39; - npc.Calamity().VulnerableToSickness = false; - } + public override void SetDefaults() + { + npc.aiStyle = -1; + aiType = -1; + npc.width = 30; + npc.height = 30; + npc.defense = 45; + npc.DR_NERD(0.1f); + npc.noGravity = true; + npc.noTileCollide = true; + npc.canGhostHeal = false; + npc.damage = 0; + npc.LifeMaxNERB(Main.expertMode ? 11250 : 8750, CalamityWorld.death ? 22500 : 18750, 15000); + npc.HitSound = SoundID.NPCHit36; + npc.DeathSound = SoundID.NPCDeath39; + npc.Calamity().VulnerableToSickness = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(start); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(start); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - start = reader.ReadBoolean(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + start = reader.ReadBoolean(); + } - public override bool PreAI() - { - if (start) - { - start = false; + public override bool PreAI() + { + if (start) + { + start = false; - for (int i = 0; i < 10; i++) - { - int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 2f); - Main.dust[dust].noGravity = true; - } + for (int i = 0; i < 10; i++) + { + int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + } - npc.ai[1] = npc.ai[0]; - } + npc.ai[1] = npc.ai[0]; + } - if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active) - { - npc.active = false; - npc.netUpdate = true; - return false; - } + if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active) + { + npc.active = false; + npc.netUpdate = true; + return false; + } - bool chargePhase = Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] >= 420f; + bool chargePhase = Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] >= 420f; - // Percent life remaining, Polter - float lifeRatio = Main.npc[CalamityGlobalNPC.ghostBoss].life / Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax; + // Percent life remaining, Polter + float lifeRatio = Main.npc[CalamityGlobalNPC.ghostBoss].life / Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax; - // Scale multiplier based on nearby active tiles - float tileEnrageMult = Main.npc[CalamityGlobalNPC.ghostBoss].ai[3]; + // Scale multiplier based on nearby active tiles + float tileEnrageMult = Main.npc[CalamityGlobalNPC.ghostBoss].ai[3]; - npc.TargetClosest(true); + npc.TargetClosest(true); - Vector2 direction = Main.player[npc.target].Center - npc.Center; - direction.Normalize(); - direction *= 0.05f; - npc.rotation = direction.ToRotation(); + Vector2 direction = Main.player[npc.target].Center - npc.Center; + direction.Normalize(); + direction *= 0.05f; + npc.rotation = direction.ToRotation(); - if (!chargePhase) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= 150f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float maxVelocity = 8f * tileEnrageMult; - float acceleration = 1.15f + (tileEnrageMult - 1f) * 0.15f; - Projectile.NewProjectile(npc.Center, direction, type, damage, 1f, npc.target, maxVelocity, acceleration); - } - npc.ai[2] = 0f; - } - } + if (!chargePhase) + { + npc.ai[2] += 1f; + if (npc.ai[2] >= 150f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float maxVelocity = 8f * tileEnrageMult; + float acceleration = 1.15f + (tileEnrageMult - 1f) * 0.15f; + Projectile.NewProjectile(npc.Center, direction, type, damage, 1f, npc.target, maxVelocity, acceleration); + } + npc.ai[2] = 0f; + } + } - NPC parent = Main.npc[NPC.FindFirstNPC(ModContent.NPCType())]; - double deg = npc.ai[1]; - double rad = deg * (Math.PI / 180); - double dist = 500; - npc.position.X = parent.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; - npc.position.Y = parent.Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; - float SPEEN = 1f - lifeRatio * 2f; - if (SPEEN < 0f) - SPEEN = 0f; - npc.ai[1] += 0.5f + SPEEN; - return false; - } + NPC parent = Main.npc[NPC.FindFirstNPC(ModContent.NPCType())]; + double deg = npc.ai[1]; + double rad = deg * (Math.PI / 180); + double dist = 500; + npc.position.X = parent.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; + npc.position.Y = parent.Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; + float SPEEN = 1f - lifeRatio * 2f; + if (SPEEN < 0f) + SPEEN = 0f; + npc.ai[1] += 0.5f + SPEEN; + return false; + } - public override Color? GetAlpha(Color drawColor) - { - return new Color(200, 200, 200, 0); - } + public override Color? GetAlpha(Color drawColor) + { + return new Color(200, 200, 200, 0); + } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() + { + return false; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void HitEffect(int hitDirection, double damage) - { - Dust.NewDust(npc.position, npc.width, npc.height, 180, hitDirection, -1f, 0, default, 1f); - if (npc.life <= 0) - { - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 45; - npc.height = 45; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - for (int num621 = 0; num621 < 2; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Phantoplasm, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 10; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + Dust.NewDust(npc.position, npc.width, npc.height, 180, hitDirection, -1f, 0, default, 1f); + if (npc.life <= 0) + { + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); + npc.width = 45; + npc.height = 45; + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 2; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Phantoplasm, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 10; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + } + } } diff --git a/NPCs/Polterghast/PolterPhantom.cs b/NPCs/Polterghast/PolterPhantom.cs index c2c51f9260..174daae7a7 100644 --- a/NPCs/Polterghast/PolterPhantom.cs +++ b/NPCs/Polterghast/PolterPhantom.cs @@ -11,28 +11,28 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Polterghast { - [AutoloadBossHead] - public class PolterPhantom : ModNPC + [AutoloadBossHead] + public class PolterPhantom : ModNPC { private int despawnTimer = 600; - private bool reachedChargingPoint = false; + private bool reachedChargingPoint = false; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Polterghast"); Main.npcFrameCount[npc.type] = 4; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.width = 90; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.width = 90; npc.height = 120; - npc.defense = 45; - npc.DR_NERD(0.1f); - npc.LifeMaxNERB(Main.expertMode ? 45000 : 35000, CalamityWorld.death ? 90000 : 75000, 60000); + npc.defense = 45; + npc.DR_NERD(0.1f); + npc.LifeMaxNERB(Main.expertMode ? 45000 : 35000, CalamityWorld.death ? 90000 : 75000, 60000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -45,50 +45,50 @@ namespace CalamityMod.NPCs.Polterghast npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit36; npc.DeathSound = SoundID.NPCDeath39; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToSickness = false; + } - public override void BossHeadRotation(ref float rotation) - { - bool polterHasTarget = CalamityGlobalNPC.ghostBoss.WithinBounds(Main.maxNPCs) && Main.npc[CalamityGlobalNPC.ghostBoss].active && Main.npc[CalamityGlobalNPC.ghostBoss].HasValidTarget; - if (polterHasTarget && npc.Calamity().newAI[3] == 0f) - rotation = (Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center - npc.Center).ToRotation() + MathHelper.PiOver2; - else - rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - } + public override void BossHeadRotation(ref float rotation) + { + bool polterHasTarget = CalamityGlobalNPC.ghostBoss.WithinBounds(Main.maxNPCs) && Main.npc[CalamityGlobalNPC.ghostBoss].active && Main.npc[CalamityGlobalNPC.ghostBoss].HasValidTarget; + if (polterHasTarget && npc.Calamity().newAI[3] == 0f) + rotation = (Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target].Center - npc.Center).ToRotation() + MathHelper.PiOver2; + else + rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(despawnTimer); - writer.Write(reachedChargingPoint); - CalamityGlobalNPC cgn = npc.Calamity(); - writer.Write(cgn.newAI[0]); - writer.Write(cgn.newAI[1]); - writer.Write(cgn.newAI[2]); - writer.Write(cgn.newAI[3]); - } + writer.Write(reachedChargingPoint); + CalamityGlobalNPC cgn = npc.Calamity(); + writer.Write(cgn.newAI[0]); + writer.Write(cgn.newAI[1]); + writer.Write(cgn.newAI[2]); + writer.Write(cgn.newAI[3]); + } public override void ReceiveExtraAI(BinaryReader reader) { despawnTimer = reader.ReadInt32(); - reachedChargingPoint = reader.ReadBoolean(); - CalamityGlobalNPC cgn = npc.Calamity(); - cgn.newAI[0] = reader.ReadSingle(); - cgn.newAI[1] = reader.ReadSingle(); - cgn.newAI[2] = reader.ReadSingle(); - cgn.newAI[3] = reader.ReadSingle(); - } + reachedChargingPoint = reader.ReadBoolean(); + CalamityGlobalNPC cgn = npc.Calamity(); + cgn.newAI[0] = reader.ReadSingle(); + cgn.newAI[1] = reader.ReadSingle(); + cgn.newAI[2] = reader.ReadSingle(); + cgn.newAI[3] = reader.ReadSingle(); + } public override void AI() { CalamityGlobalNPC.ghostBossClone = npc.whoAmI; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active) + if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active) { npc.active = false; npc.netUpdate = true; @@ -97,21 +97,21 @@ namespace CalamityMod.NPCs.Polterghast Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.5f, 0.25f, 0.75f); - Player player = Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target]; + Player player = Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target]; - // Percent life remaining, Polter - float lifeRatio = Main.npc[CalamityGlobalNPC.ghostBoss].life / Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax; + // Percent life remaining, Polter + float lifeRatio = Main.npc[CalamityGlobalNPC.ghostBoss].life / Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax; - Vector2 vector = npc.Center; + Vector2 vector = npc.Center; - // Scale multiplier based on nearby active tiles - float tileEnrageMult = Main.npc[CalamityGlobalNPC.ghostBoss].ai[3]; - bool chargePhase = Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] >= 420f || npc.Calamity().newAI[3] == 1f; - float chargeVelocity = 24f; - float chargeAcceleration = 0.6f; - float chargeDistance = 480f; + // Scale multiplier based on nearby active tiles + float tileEnrageMult = Main.npc[CalamityGlobalNPC.ghostBoss].ai[3]; + bool chargePhase = Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] >= 420f || npc.Calamity().newAI[3] == 1f; + float chargeVelocity = 24f; + float chargeAcceleration = 0.6f; + float chargeDistance = 480f; - bool speedBoost = false; + bool speedBoost = false; bool despawnBoost = false; if (npc.timeLeft < 1500) @@ -122,283 +122,283 @@ namespace CalamityMod.NPCs.Polterghast if (!player.ZoneDungeon && !BossRushEvent.BossRushActive && player.position.Y < Main.worldSurface * 16.0) { despawnTimer--; - if (despawnTimer <= 0) - { - despawnBoost = true; - npc.ai[1] = 0f; - npc.Calamity().newAI[0] = 0f; - npc.Calamity().newAI[1] = 0f; - npc.Calamity().newAI[2] = 0f; - npc.Calamity().newAI[3] = 0f; - } + if (despawnTimer <= 0) + { + despawnBoost = true; + npc.ai[1] = 0f; + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + npc.Calamity().newAI[2] = 0f; + npc.Calamity().newAI[3] = 0f; + } speedBoost = true; - velocity += 8f; - acceleration = 0.15f; + velocity += 8f; + acceleration = 0.15f; } else despawnTimer++; - if (Main.npc[CalamityGlobalNPC.ghostBoss].ai[2] < 300f) + if (Main.npc[CalamityGlobalNPC.ghostBoss].ai[2] < 300f) { - velocity = 21f; - acceleration = 0.13f; + velocity = 21f; + acceleration = 0.13f; } - if (expertMode) - { - chargeVelocity += revenge ? 4f : 2f; - velocity += revenge ? 5f : 3.5f; - acceleration += revenge ? 0.035f : 0.025f; - } + if (expertMode) + { + chargeVelocity += revenge ? 4f : 2f; + velocity += revenge ? 5f : 3.5f; + acceleration += revenge ? 0.035f : 0.025f; + } - // Predictiveness - Vector2 predictionVector = chargePhase && malice ? player.velocity * 20f : Vector2.Zero; - Vector2 lookAt = player.Center + predictionVector; - Vector2 rotationVector = lookAt - vector; + // Predictiveness + Vector2 predictionVector = chargePhase && malice ? player.velocity * 20f : Vector2.Zero; + Vector2 lookAt = player.Center + predictionVector; + Vector2 rotationVector = lookAt - vector; - // Rotation - if (npc.Calamity().newAI[3] == 0f) - { - float num740 = player.Center.X + predictionVector.X - vector.X; - float num741 = player.Center.Y + predictionVector.Y - vector.Y; - npc.rotation = (float)Math.Atan2(num741, num740) + MathHelper.PiOver2; - } - else - npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; + // Rotation + if (npc.Calamity().newAI[3] == 0f) + { + float num740 = player.Center.X + predictionVector.X - vector.X; + float num741 = player.Center.Y + predictionVector.Y - vector.Y; + npc.rotation = (float)Math.Atan2(num741, num740) + MathHelper.PiOver2; + } + else + npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - npc.damage = npc.defDamage; + npc.damage = npc.defDamage; - if (!chargePhase) - { - // Set this here to avoid despawn issues - reachedChargingPoint = false; + if (!chargePhase) + { + // Set this here to avoid despawn issues + reachedChargingPoint = false; - npc.ai[0] = 0f; + npc.ai[0] = 0f; - npc.Opacity += 0.02f; - if (npc.Opacity > 0.8f) - npc.Opacity = 0.8f; + npc.Opacity += 0.02f; + if (npc.Opacity > 0.8f) + npc.Opacity = 0.8f; - float movementLimitX = 0f; - float movementLimitY = 0f; - int numHooks = 4; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - movementLimitX += Main.npc[i].Center.X; - movementLimitY += Main.npc[i].Center.Y; - } - } - movementLimitX /= numHooks; - movementLimitY /= numHooks; + float movementLimitX = 0f; + float movementLimitY = 0f; + int numHooks = 4; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + movementLimitX += Main.npc[i].Center.X; + movementLimitY += Main.npc[i].Center.Y; + } + } + movementLimitX /= numHooks; + movementLimitY /= numHooks; - Vector2 vector91 = new Vector2(movementLimitX, movementLimitY); - float num736 = player.Center.X - vector91.X; - float num737 = player.Center.Y - vector91.Y; + Vector2 vector91 = new Vector2(movementLimitX, movementLimitY); + float num736 = player.Center.X - vector91.X; + float num737 = player.Center.Y - vector91.Y; - if (despawnBoost) - { - num737 *= -1f; - num736 *= -1f; - velocity += 8f; - } + if (despawnBoost) + { + num737 *= -1f; + num736 *= -1f; + velocity += 8f; + } - float num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); - float maxDistanceFromHooks = expertMode ? 650f : 500f; - if (speedBoost || malice) - maxDistanceFromHooks += 250f; - if (death) - maxDistanceFromHooks += maxDistanceFromHooks * 0.1f * (1f - lifeRatio); + float num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); + float maxDistanceFromHooks = expertMode ? 650f : 500f; + if (speedBoost || malice) + maxDistanceFromHooks += 250f; + if (death) + maxDistanceFromHooks += maxDistanceFromHooks * 0.1f * (1f - lifeRatio); - // Increase speed based on nearby active tiles - velocity *= tileEnrageMult; - acceleration *= tileEnrageMult; + // Increase speed based on nearby active tiles + velocity *= tileEnrageMult; + acceleration *= tileEnrageMult; - if (death) - { - velocity += velocity * 0.15f * (1f - lifeRatio); - acceleration += acceleration * 0.15f * (1f - lifeRatio); - } + if (death) + { + velocity += velocity * 0.15f * (1f - lifeRatio); + acceleration += acceleration * 0.15f * (1f - lifeRatio); + } - if (num738 >= maxDistanceFromHooks) - { - num738 = maxDistanceFromHooks / num738; - num736 *= num738; - num737 *= num738; - } + if (num738 >= maxDistanceFromHooks) + { + num738 = maxDistanceFromHooks / num738; + num736 *= num738; + num737 *= num738; + } - movementLimitX += num736; - movementLimitY += num737; - vector91 = vector; - num736 = movementLimitX - vector91.X; - num737 = movementLimitY - vector91.Y; - num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); + movementLimitX += num736; + movementLimitY += num737; + vector91 = vector; + num736 = movementLimitX - vector91.X; + num737 = movementLimitY - vector91.Y; + num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); - if (num738 < velocity) - { - num736 = npc.velocity.X; - num737 = npc.velocity.Y; - } - else - { - num738 = velocity / num738; - num736 *= num738; - num737 *= num738; - } + if (num738 < velocity) + { + num736 = npc.velocity.X; + num737 = npc.velocity.Y; + } + else + { + num738 = velocity / num738; + num736 *= num738; + num737 *= num738; + } - if (npc.velocity.X < num736) - { - npc.velocity.X += acceleration; - if (npc.velocity.X < 0f && num736 > 0f) - npc.velocity.X += acceleration * 2f; - } - else if (npc.velocity.X > num736) - { - npc.velocity.X -= acceleration; - if (npc.velocity.X > 0f && num736 < 0f) - npc.velocity.X -= acceleration * 2f; - } - if (npc.velocity.Y < num737) - { - npc.velocity.Y += acceleration; - if (npc.velocity.Y < 0f && num737 > 0f) - npc.velocity.Y += acceleration * 2f; - } - else if (npc.velocity.Y > num737) - { - npc.velocity.Y -= acceleration; - if (npc.velocity.Y > 0f && num737 < 0f) - npc.velocity.Y -= acceleration * 2f; - } - } - else - { - // Charge - if (npc.Calamity().newAI[3] == 1f) - { - reachedChargingPoint = false; + if (npc.velocity.X < num736) + { + npc.velocity.X += acceleration; + if (npc.velocity.X < 0f && num736 > 0f) + npc.velocity.X += acceleration * 2f; + } + else if (npc.velocity.X > num736) + { + npc.velocity.X -= acceleration; + if (npc.velocity.X > 0f && num736 < 0f) + npc.velocity.X -= acceleration * 2f; + } + if (npc.velocity.Y < num737) + { + npc.velocity.Y += acceleration; + if (npc.velocity.Y < 0f && num737 > 0f) + npc.velocity.Y += acceleration * 2f; + } + else if (npc.velocity.Y > num737) + { + npc.velocity.Y -= acceleration; + if (npc.velocity.Y > 0f && num737 < 0f) + npc.velocity.Y -= acceleration * 2f; + } + } + else + { + // Charge + if (npc.Calamity().newAI[3] == 1f) + { + reachedChargingPoint = false; - npc.Opacity += 0.06f; - if (npc.Opacity > 0.8f) - npc.Opacity = 0.8f; + npc.Opacity += 0.06f; + if (npc.Opacity > 0.8f) + npc.Opacity = 0.8f; - if (npc.Calamity().newAI[1] == 0f) - { - npc.velocity = Vector2.Normalize(rotationVector) * chargeVelocity; - npc.Calamity().newAI[1] = 1f; - } - else - { - npc.Calamity().newAI[2] += 1f; + if (npc.Calamity().newAI[1] == 0f) + { + npc.velocity = Vector2.Normalize(rotationVector) * chargeVelocity; + npc.Calamity().newAI[1] = 1f; + } + else + { + npc.Calamity().newAI[2] += 1f; - // Slow down for a few frames - float totalChargeTime = chargeDistance * 4f / chargeVelocity; - float slowDownTime = chargeVelocity; - if (npc.Calamity().newAI[2] >= totalChargeTime - slowDownTime) - npc.velocity *= 0.9f; + // Slow down for a few frames + float totalChargeTime = chargeDistance * 4f / chargeVelocity; + float slowDownTime = chargeVelocity; + if (npc.Calamity().newAI[2] >= totalChargeTime - slowDownTime) + npc.velocity *= 0.9f; - // Reset and either go back to normal or charge again - if (npc.Calamity().newAI[2] >= totalChargeTime) - { - npc.Calamity().newAI[1] = 0f; - npc.Calamity().newAI[2] = 0f; - npc.Calamity().newAI[3] = 0f; - npc.ai[0] = 0f; - npc.ai[1] += 1f; + // Reset and either go back to normal or charge again + if (npc.Calamity().newAI[2] >= totalChargeTime) + { + npc.Calamity().newAI[1] = 0f; + npc.Calamity().newAI[2] = 0f; + npc.Calamity().newAI[3] = 0f; + npc.ai[0] = 0f; + npc.ai[1] += 1f; - if (npc.ai[1] >= 3f) - { - // Reset and return to normal movement - npc.Calamity().newAI[0] = 0f; - npc.ai[1] = 0f; - } - } - } - } - else - { - // Random location choice - if (npc.ai[0] == 0f) - { - npc.velocity = Vector2.Zero; - npc.ai[0] = Main.rand.Next(2) + 1; - npc.netUpdate = true; - } + if (npc.ai[1] >= 3f) + { + // Reset and return to normal movement + npc.Calamity().newAI[0] = 0f; + npc.ai[1] = 0f; + } + } + } + } + else + { + // Random location choice + if (npc.ai[0] == 0f) + { + npc.velocity = Vector2.Zero; + npc.ai[0] = Main.rand.Next(2) + 1; + npc.netUpdate = true; + } - // Pick a charging location - // Set charge locations X - if (Main.npc[CalamityGlobalNPC.ghostBoss].Center.X >= player.Center.X) - npc.Calamity().newAI[1] = npc.ai[0] == 1f ? player.Center.X - chargeDistance : Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[1]; - else - npc.Calamity().newAI[1] = npc.ai[0] == 1f ? player.Center.X + chargeDistance : Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[1]; + // Pick a charging location + // Set charge locations X + if (Main.npc[CalamityGlobalNPC.ghostBoss].Center.X >= player.Center.X) + npc.Calamity().newAI[1] = npc.ai[0] == 1f ? player.Center.X - chargeDistance : Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[1]; + else + npc.Calamity().newAI[1] = npc.ai[0] == 1f ? player.Center.X + chargeDistance : Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[1]; - // Set charge locations Y - if (Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y >= player.Center.Y) - npc.Calamity().newAI[2] = npc.ai[0] == 2f ? player.Center.Y - chargeDistance : Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[2]; - else - npc.Calamity().newAI[2] = npc.ai[0] == 2f ? player.Center.Y + chargeDistance : Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[2]; + // Set charge locations Y + if (Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y >= player.Center.Y) + npc.Calamity().newAI[2] = npc.ai[0] == 2f ? player.Center.Y - chargeDistance : Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[2]; + else + npc.Calamity().newAI[2] = npc.ai[0] == 2f ? player.Center.Y + chargeDistance : Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[2]; - // Do not deal damage during movement to avoid cheap bullshit hits - npc.damage = 0; + // Do not deal damage during movement to avoid cheap bullshit hits + npc.damage = 0; - // Charge location - Vector2 chargeVector = new Vector2(npc.Calamity().newAI[1], npc.Calamity().newAI[2]); - Vector2 chargeLocationVelocity = Vector2.Normalize(chargeVector - vector) * chargeVelocity; + // Charge location + Vector2 chargeVector = new Vector2(npc.Calamity().newAI[1], npc.Calamity().newAI[2]); + Vector2 chargeLocationVelocity = Vector2.Normalize(chargeVector - vector) * chargeVelocity; - // Line up a charge - float chargeDistanceGateValue = 32f; + // Line up a charge + float chargeDistanceGateValue = 32f; - if (Vector2.Distance(vector, chargeVector) <= chargeDistanceGateValue * 3f) - { - npc.Opacity += 0.06f; - if (npc.Opacity > 0.8f) - npc.Opacity = 0.8f; - } - else - { - npc.Opacity -= 0.06f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } + if (Vector2.Distance(vector, chargeVector) <= chargeDistanceGateValue * 3f) + { + npc.Opacity += 0.06f; + if (npc.Opacity > 0.8f) + npc.Opacity = 0.8f; + } + else + { + npc.Opacity -= 0.06f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } - if (Vector2.Distance(vector, chargeVector) <= chargeDistanceGateValue || reachedChargingPoint) - { - // Emit dust - if (!reachedChargingPoint) - { - Main.PlaySound(SoundID.Item125, npc.position); - for (int i = 0; i < 30; i++) - { - int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 5f; - } - } + if (Vector2.Distance(vector, chargeVector) <= chargeDistanceGateValue || reachedChargingPoint) + { + // Emit dust + if (!reachedChargingPoint) + { + Main.PlaySound(SoundID.Item125, npc.position); + for (int i = 0; i < 30; i++) + { + int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 5f; + } + } - reachedChargingPoint = true; - npc.velocity = Vector2.Zero; - npc.Center = chargeVector; - } - else - { - // Reduce velocity and acceleration to allow for smoother movement inside this loop - if (Vector2.Distance(vector, chargeVector) > 1200f) - npc.velocity = chargeLocationVelocity; - else - npc.SimpleFlyMovement(chargeLocationVelocity, chargeAcceleration); - } - } + reachedChargingPoint = true; + npc.velocity = Vector2.Zero; + npc.Center = chargeVector; + } + else + { + // Reduce velocity and acceleration to allow for smoother movement inside this loop + if (Vector2.Distance(vector, chargeVector) > 1200f) + npc.velocity = chargeLocationVelocity; + else + npc.SimpleFlyMovement(chargeLocationVelocity, chargeAcceleration); + } + } - npc.netUpdate = true; + npc.netUpdate = true; - if (npc.netSpam > 10) - npc.netSpam = 10; + if (npc.netSpam > 10) + npc.netSpam = 10; - if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); - } + if (Main.netMode == NetmodeID.Server) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); + } } public override Color? GetAlpha(Color drawColor) @@ -406,72 +406,72 @@ namespace CalamityMod.NPCs.Polterghast return new Color(200, 150, 255) * npc.Opacity; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Color color36 = Color.White; - Color lightRed = new Color(255, 100, 100, 255) * npc.Opacity; - float amount9 = 0.5f; - int num153 = 7; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Color color36 = Color.White; + Color lightRed = new Color(255, 100, 100, 255) * npc.Opacity; + float amount9 = 0.5f; + int num153 = 7; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; - if (Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > 300f) - color38 = Color.Lerp(color38, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - 300f) / 120f, 0f, 1f)); + if (Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > 300f) + color38 = Color.Lerp(color38, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - 300f) / 120f, 0f, 1f)); - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Color color = npc.GetAlpha(lightColor); + Color color = npc.GetAlpha(lightColor); - if (Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > 300f) - color = Color.Lerp(color, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - 300f) / 120f, 0f, 1f)); + if (Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > 300f) + color = Color.Lerp(color, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - 300f) / 120f, 0f, 1f)); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterPhantomGlow"); - Color color42 = Color.Lerp(Color.White, (Main.npc[CalamityGlobalNPC.ghostBoss].ai[2] < 300f || Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > 300f) ? Color.Red : Color.Black, 0.5f); + Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterPhantomGlow"); + Color color42 = Color.Lerp(Color.White, (Main.npc[CalamityGlobalNPC.ghostBoss].ai[2] < 300f || Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > 300f) ? Color.Red : Color.Black, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 = npc.GetAlpha(color43); - color43 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color43 = color42; + color43 = Color.Lerp(color43, color36, amount9); + color43 = npc.GetAlpha(color43); + color43 *= (num153 - num163) / 15f; + spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 1.0; if (npc.frameCounter > 6.0) @@ -485,15 +485,15 @@ namespace CalamityMod.NPCs.Polterghast } } - public override bool CheckActive() - { - return false; - } - - public override void OnHitPlayer(Player player, int damage, bool crit) + public override bool CheckActive() { - player.AddBuff(BuffID.MoonLeech, 360, true); - } + return false; + } + + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(BuffID.MoonLeech, 360, true); + } public override bool CanHitPlayer(Player target, ref int cooldownSlot) { diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index 5c0021af31..5e5c7e36a7 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -27,40 +27,40 @@ namespace CalamityMod.NPCs.Polterghast { public class Polterghast : ModNPC { - public static int phase1IconIndex; - public static int phase3IconIndex; + public static int phase1IconIndex; + public static int phase3IconIndex; - internal static void LoadHeadIcons() - { - string phase1IconPath = "CalamityMod/NPCs/Polterghast/Polterghast_Head_Boss"; - string phase3IconPath = "CalamityMod/NPCs/Polterghast/Necroplasm_Head_Boss"; + internal static void LoadHeadIcons() + { + string phase1IconPath = "CalamityMod/NPCs/Polterghast/Polterghast_Head_Boss"; + string phase3IconPath = "CalamityMod/NPCs/Polterghast/Necroplasm_Head_Boss"; - CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); - phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); + CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); + phase1IconIndex = ModContent.GetModBossHeadSlot(phase1IconPath); - CalamityMod.Instance.AddBossHeadTexture(phase3IconPath, -1); - phase3IconIndex = ModContent.GetModBossHeadSlot(phase3IconPath); - } + CalamityMod.Instance.AddBossHeadTexture(phase3IconPath, -1); + phase3IconIndex = ModContent.GetModBossHeadSlot(phase3IconPath); + } - private int despawnTimer = 600; - private bool reachedChargingPoint = false; + private int despawnTimer = 600; + private bool reachedChargingPoint = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Polterghast"); Main.npcFrameCount[npc.type] = 12; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; + npc.Calamity().canBreakPlayerDefense = true; npc.npcSlots = 50f; - npc.GetNPCDamage(); - npc.width = 90; + npc.GetNPCDamage(); + npc.width = 90; npc.height = 120; npc.defense = 90; - npc.DR_NERD(0.2f); + npc.DR_NERD(0.2f); npc.LifeMaxNERB(350000, 420000, 325000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -72,146 +72,146 @@ namespace CalamityMod.NPCs.Polterghast npc.noGravity = true; npc.noTileCollide = true; npc.netAlways = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("Polterghast") ?? MusicID.Plantera; + music = CalamityMod.Instance.GetMusicFromMusicMod("Polterghast") ?? MusicID.Plantera; npc.HitSound = SoundID.NPCHit7; npc.DeathSound = SoundID.NPCDeath39; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToSickness = false; + } - public override void BossHeadSlot(ref int index) - { - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + public override void BossHeadSlot(ref int index) + { + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool phase3 = npc.life / (float)npc.lifeMax < (death ? 0.6f : revenge ? 0.5f : expertMode ? 0.35f : 0.2f); - if (phase3) - index = phase3IconIndex; - else - index = phase1IconIndex; - } + bool phase3 = npc.life / (float)npc.lifeMax < (death ? 0.6f : revenge ? 0.5f : expertMode ? 0.35f : 0.2f); + if (phase3) + index = phase3IconIndex; + else + index = phase1IconIndex; + } - public override void BossHeadRotation(ref float rotation) - { - if (npc.HasValidTarget && npc.Calamity().newAI[3] == 0f) - rotation = (Main.player[npc.TranslatedTargetIndex].Center - npc.Center).ToRotation() + MathHelper.PiOver2; - else - rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - } + public override void BossHeadRotation(ref float rotation) + { + if (npc.HasValidTarget && npc.Calamity().newAI[3] == 0f) + rotation = (Main.player[npc.TranslatedTargetIndex].Center - npc.Center).ToRotation() + MathHelper.PiOver2; + else + rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; + } - public override void SendExtraAI(BinaryWriter writer) + public override void SendExtraAI(BinaryWriter writer) { writer.Write(despawnTimer); - writer.Write(reachedChargingPoint); - CalamityGlobalNPC cgn = npc.Calamity(); - writer.Write(cgn.newAI[0]); - writer.Write(cgn.newAI[1]); - writer.Write(cgn.newAI[2]); - writer.Write(cgn.newAI[3]); + writer.Write(reachedChargingPoint); + CalamityGlobalNPC cgn = npc.Calamity(); + writer.Write(cgn.newAI[0]); + writer.Write(cgn.newAI[1]); + writer.Write(cgn.newAI[2]); + writer.Write(cgn.newAI[3]); } public override void ReceiveExtraAI(BinaryReader reader) { despawnTimer = reader.ReadInt32(); - reachedChargingPoint = reader.ReadBoolean(); - CalamityGlobalNPC cgn = npc.Calamity(); - cgn.newAI[0] = reader.ReadSingle(); - cgn.newAI[1] = reader.ReadSingle(); - cgn.newAI[2] = reader.ReadSingle(); - cgn.newAI[3] = reader.ReadSingle(); + reachedChargingPoint = reader.ReadBoolean(); + CalamityGlobalNPC cgn = npc.Calamity(); + cgn.newAI[0] = reader.ReadSingle(); + cgn.newAI[1] = reader.ReadSingle(); + cgn.newAI[2] = reader.ReadSingle(); + cgn.newAI[3] = reader.ReadSingle(); } public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); // Emit light 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; + // whoAmI variable + CalamityGlobalNPC.ghostBoss = npc.whoAmI; // Detect clone bool cloneAlive = false; if (CalamityGlobalNPC.ghostBossClone != -1) cloneAlive = Main.npc[CalamityGlobalNPC.ghostBossClone].active; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Variables - Vector2 vector = npc.Center; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool speedBoost = false; + // Variables + Vector2 vector = npc.Center; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool speedBoost = false; bool despawnBoost = false; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - // Phases - bool phase2 = lifeRatio < (death ? 0.9f : revenge ? 0.8f : expertMode ? 0.65f : 0.5f); + // Phases + bool phase2 = lifeRatio < (death ? 0.9f : revenge ? 0.8f : expertMode ? 0.65f : 0.5f); bool phase3 = lifeRatio < (death ? 0.6f : revenge ? 0.5f : expertMode ? 0.35f : 0.2f); bool phase4 = lifeRatio < (death ? 0.45f : revenge ? 0.35f : expertMode ? 0.2f : 0.1f); bool phase5 = lifeRatio < (death ? 0.2f : revenge ? 0.15f : expertMode ? 0.1f : 0.05f); - // Get angry if the clone is dead and in phase 3 - bool getPissed = !cloneAlive && phase3; + // Get angry if the clone is dead and in phase 3 + bool getPissed = !cloneAlive && phase3; - // Velocity and acceleration - calamityGlobalNPC.newAI[0] += 1f; - bool chargePhase = calamityGlobalNPC.newAI[0] >= 480f; - int chargeAmt = getPissed ? 4 : phase3 ? 3 : phase2 ? 2 : 1; - float chargeVelocity = getPissed ? 28f : phase3 ? 24f : phase2 ? 22f : 20f; - float chargeAcceleration = getPissed ? 0.7f : phase3 ? 0.6f : phase2 ? 0.55f : 0.5f; - float chargeDistance = 480f; - bool charging = npc.ai[2] >= 300f; - bool reset = npc.ai[2] >= 600f; - float speedUpDistance = 480f - 360f * (1f - lifeRatio); + // Velocity and acceleration + calamityGlobalNPC.newAI[0] += 1f; + bool chargePhase = calamityGlobalNPC.newAI[0] >= 480f; + int chargeAmt = getPissed ? 4 : phase3 ? 3 : phase2 ? 2 : 1; + float chargeVelocity = getPissed ? 28f : phase3 ? 24f : phase2 ? 22f : 20f; + float chargeAcceleration = getPissed ? 0.7f : phase3 ? 0.6f : phase2 ? 0.55f : 0.5f; + float chargeDistance = 480f; + bool charging = npc.ai[2] >= 300f; + bool reset = npc.ai[2] >= 600f; + float speedUpDistance = 480f - 360f * (1f - lifeRatio); - // Only get a new target while not charging - if (!chargePhase) - { - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Only get a new target while not charging + if (!chargePhase) + { + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - } + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + } - Player player = Main.player[npc.target]; - bool speedUp = Vector2.Distance(player.Center, vector) > speedUpDistance; // 30 or 40 tile distance - float velocity = 10f; // Max should be 21 - float acceleration = 0.05f; // Max should be 0.13 + Player player = Main.player[npc.target]; + bool speedUp = Vector2.Distance(player.Center, vector) > speedUpDistance; // 30 or 40 tile distance + float velocity = 10f; // Max should be 21 + float acceleration = 0.05f; // Max should be 0.13 - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - speedBoost = true; - despawnBoost = true; - reachedChargingPoint = false; - npc.ai[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; + if (!player.active || player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead) + { + speedBoost = true; + despawnBoost = true; + reachedChargingPoint = false; + npc.ai[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; - if (cloneAlive) - { - Main.npc[CalamityGlobalNPC.ghostBossClone].ai[0] = 0f; - Main.npc[CalamityGlobalNPC.ghostBossClone].ai[1] = 0f; - Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[0] = 0f; - Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[1] = 0f; - Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[2] = 0f; - Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[3] = 0f; - } - } - } + if (cloneAlive) + { + Main.npc[CalamityGlobalNPC.ghostBossClone].ai[0] = 0f; + Main.npc[CalamityGlobalNPC.ghostBossClone].ai[1] = 0f; + Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[0] = 0f; + Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[1] = 0f; + Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[2] = 0f; + Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[3] = 0f; + } + } + } // Stop rain CalamityMod.StopRain(); @@ -226,386 +226,386 @@ namespace CalamityMod.NPCs.Polterghast npc.localAI[0] = 1f; NPC.NewNPC((int)vector.X, (int)vector.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); NPC.NewNPC((int)vector.X, (int)vector.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); - NPC.NewNPC((int)vector.X, (int)vector.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); + NPC.NewNPC((int)vector.X, (int)vector.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); NPC.NewNPC((int)vector.X, (int)vector.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); } if (!player.ZoneDungeon && !BossRushEvent.BossRushActive && player.position.Y < Main.worldSurface * 16.0) { despawnTimer--; - if (despawnTimer <= 0) - { - despawnBoost = true; - npc.ai[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - } + if (despawnTimer <= 0) + { + despawnBoost = true; + npc.ai[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + } speedBoost = true; - velocity += 5f; - acceleration += 0.05f; + velocity += 5f; + acceleration += 0.05f; } else despawnTimer++; // Despawn if (Vector2.Distance(player.Center, vector) > (despawnBoost ? 1500f : 6000f)) - { - npc.active = false; - npc.netUpdate = true; - return; - } - - if (phase2) { - velocity += 2.5f; - acceleration += 0.02f; - } + npc.active = false; + npc.netUpdate = true; + return; + } - if (!phase3) - { - if (charging) - { - velocity += phase2 ? 4.5f : 3.5f; - acceleration += phase2 ? 0.03f : 0.025f; - } - } - else - { - if (charging) - { - velocity += phase5 ? 8.5f : 4.5f; - acceleration += phase5 ? 0.06f : 0.03f; - } - else - { - if (phase5) - { - velocity += 1.5f; - acceleration += 0.015f; - } - else if (phase4) - { - velocity += 1f; - acceleration += 0.01f; - } - else - { - velocity += 0.5f; - acceleration += 0.005f; - } - } - } + if (phase2) + { + velocity += 2.5f; + acceleration += 0.02f; + } - if (expertMode) - { - chargeVelocity += revenge ? 4f : 2f; - velocity += revenge ? 5f : 3.5f; - acceleration += revenge ? 0.035f : 0.025f; - } + if (!phase3) + { + if (charging) + { + velocity += phase2 ? 4.5f : 3.5f; + acceleration += phase2 ? 0.03f : 0.025f; + } + } + else + { + if (charging) + { + velocity += phase5 ? 8.5f : 4.5f; + acceleration += phase5 ? 0.06f : 0.03f; + } + else + { + if (phase5) + { + velocity += 1.5f; + acceleration += 0.015f; + } + else if (phase4) + { + velocity += 1f; + acceleration += 0.01f; + } + else + { + velocity += 0.5f; + acceleration += 0.005f; + } + } + } - // Slow down if close to target and not inside tiles - if (!speedUp && !Collision.SolidCollision(npc.position, npc.width, npc.height) && Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && !charging && !chargePhase) - { - velocity = 8f; - acceleration = 0.035f; - } + if (expertMode) + { + chargeVelocity += revenge ? 4f : 2f; + velocity += revenge ? 5f : 3.5f; + acceleration += revenge ? 0.035f : 0.025f; + } - // Detect active tiles around Polterghast - int radius = 30; // 30 tile radius - int diameter = radius * 2; - int npcCenterX = (int)(vector.X / 16f); - int npcCenterY = (int)(vector.Y / 16f); - Rectangle area = new Rectangle(npcCenterX - radius, npcCenterY - radius, diameter, diameter); - int nearbyActiveTiles = 0; // 0 to 3600 - for (int x = area.Left; x < area.Right; x++) - { - for (int y = area.Top; y < area.Bottom; y++) - { - if (Main.tile[x, y] != null) - { - if (Main.tile[x, y].nactive() && Main.tileSolid[Main.tile[x, y].type] && !Main.tileSolidTop[Main.tile[x, y].type] && !TileID.Sets.Platforms[Main.tile[x, y].type]) - nearbyActiveTiles++; - } - } - } + // Slow down if close to target and not inside tiles + if (!speedUp && !Collision.SolidCollision(npc.position, npc.width, npc.height) && Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && !charging && !chargePhase) + { + velocity = 8f; + acceleration = 0.035f; + } - // Scale multiplier based on nearby active tiles - float tileEnrageMult = 1f; - if (nearbyActiveTiles < 1000) - tileEnrageMult += (1000 - nearbyActiveTiles) * 0.00075f; // Ranges from 1f to 1.75f + // Detect active tiles around Polterghast + int radius = 30; // 30 tile radius + int diameter = radius * 2; + int npcCenterX = (int)(vector.X / 16f); + int npcCenterY = (int)(vector.Y / 16f); + Rectangle area = new Rectangle(npcCenterX - radius, npcCenterY - radius, diameter, diameter); + int nearbyActiveTiles = 0; // 0 to 3600 + for (int x = area.Left; x < area.Right; x++) + { + for (int y = area.Top; y < area.Bottom; y++) + { + if (Main.tile[x, y] != null) + { + if (Main.tile[x, y].nactive() && Main.tileSolid[Main.tile[x, y].type] && !Main.tileSolidTop[Main.tile[x, y].type] && !TileID.Sets.Platforms[Main.tile[x, y].type]) + nearbyActiveTiles++; + } + } + } - if (malice) - tileEnrageMult = 1.75f; + // Scale multiplier based on nearby active tiles + float tileEnrageMult = 1f; + if (nearbyActiveTiles < 1000) + tileEnrageMult += (1000 - nearbyActiveTiles) * 0.00075f; // Ranges from 1f to 1.75f - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && tileEnrageMult >= 1.6f; + if (malice) + tileEnrageMult = 1.75f; - // Used to inform clone and hooks about number of active tiles nearby - npc.ai[3] = tileEnrageMult; + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && tileEnrageMult >= 1.6f; - // Increase projectile fire rate based on number of nearby active tiles - float amount = 1f - ((tileEnrageMult - 1f) / 0.75f); - if (amount < 0f) - amount = 0f; - float projectileFireRateMultiplier = MathHelper.Lerp(1f, 2f, amount); + // Used to inform clone and hooks about number of active tiles nearby + npc.ai[3] = tileEnrageMult; - // Increase projectile stats based on number of nearby active tiles - int baseProjectileTimeLeft = (int)(1200f * tileEnrageMult); - int baseProjectileAmt = (int)(4f * tileEnrageMult); - int baseProjectileSpread = (int)(45f * tileEnrageMult); - float baseProjectileVelocity = 5f * tileEnrageMult; - if (speedBoost) - baseProjectileVelocity *= 1.25f; + // Increase projectile fire rate based on number of nearby active tiles + float amount = 1f - ((tileEnrageMult - 1f) / 0.75f); + if (amount < 0f) + amount = 0f; + float projectileFireRateMultiplier = MathHelper.Lerp(1f, 2f, amount); - // Predictiveness - Vector2 predictionVector = chargePhase && malice ? player.velocity * 20f : Vector2.Zero; - Vector2 lookAt = player.Center + predictionVector; - Vector2 rotationVector = lookAt - vector; + // Increase projectile stats based on number of nearby active tiles + int baseProjectileTimeLeft = (int)(1200f * tileEnrageMult); + int baseProjectileAmt = (int)(4f * tileEnrageMult); + int baseProjectileSpread = (int)(45f * tileEnrageMult); + float baseProjectileVelocity = 5f * tileEnrageMult; + if (speedBoost) + baseProjectileVelocity *= 1.25f; - // Rotation - if (calamityGlobalNPC.newAI[3] == 0f) - { - float num740 = player.Center.X + predictionVector.X - vector.X; - float num741 = player.Center.Y + predictionVector.Y - vector.Y; - npc.rotation = (float)Math.Atan2(num741, num740) + MathHelper.PiOver2; - } - else - npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; + // Predictiveness + Vector2 predictionVector = chargePhase && malice ? player.velocity * 20f : Vector2.Zero; + Vector2 lookAt = player.Center + predictionVector; + Vector2 rotationVector = lookAt - vector; - if (!chargePhase) - { - npc.ai[2] += 1f; - if (reset) - { - npc.ai[2] = 0f; - npc.netUpdate = true; - } + // Rotation + if (calamityGlobalNPC.newAI[3] == 0f) + { + float num740 = player.Center.X + predictionVector.X - vector.X; + float num741 = player.Center.Y + predictionVector.Y - vector.Y; + npc.rotation = (float)Math.Atan2(num741, num740) + MathHelper.PiOver2; + } + else + npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - float movementLimitX = 0f; - float movementLimitY = 0f; - int numHooks = 4; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - movementLimitX += Main.npc[i].Center.X; - movementLimitY += Main.npc[i].Center.Y; - } - } - movementLimitX /= numHooks; - movementLimitY /= numHooks; + if (!chargePhase) + { + npc.ai[2] += 1f; + if (reset) + { + npc.ai[2] = 0f; + npc.netUpdate = true; + } - Vector2 vector91 = new Vector2(movementLimitX, movementLimitY); - float num736 = player.Center.X - vector91.X; - float num737 = player.Center.Y - vector91.Y; + float movementLimitX = 0f; + float movementLimitY = 0f; + int numHooks = 4; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + movementLimitX += Main.npc[i].Center.X; + movementLimitY += Main.npc[i].Center.Y; + } + } + movementLimitX /= numHooks; + movementLimitY /= numHooks; - if (despawnBoost) - { - num737 *= -1f; - num736 *= -1f; - velocity += 10f; - } + Vector2 vector91 = new Vector2(movementLimitX, movementLimitY); + float num736 = player.Center.X - vector91.X; + float num737 = player.Center.Y - vector91.Y; - float num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); - float maxDistanceFromHooks = expertMode ? 650f : 500f; - if (speedBoost || malice) - maxDistanceFromHooks += 250f; - if (death) - maxDistanceFromHooks += maxDistanceFromHooks * 0.1f * (1f - lifeRatio); + if (despawnBoost) + { + num737 *= -1f; + num736 *= -1f; + velocity += 10f; + } - // Increase speed based on nearby active tiles - velocity *= tileEnrageMult; - acceleration *= tileEnrageMult; + float num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); + float maxDistanceFromHooks = expertMode ? 650f : 500f; + if (speedBoost || malice) + maxDistanceFromHooks += 250f; + if (death) + maxDistanceFromHooks += maxDistanceFromHooks * 0.1f * (1f - lifeRatio); - if (death) - { - velocity += velocity * 0.15f * (1f - lifeRatio); - acceleration += acceleration * 0.15f * (1f - lifeRatio); - } + // Increase speed based on nearby active tiles + velocity *= tileEnrageMult; + acceleration *= tileEnrageMult; - if (num738 >= maxDistanceFromHooks) - { - num738 = maxDistanceFromHooks / num738; - num736 *= num738; - num737 *= num738; - } + if (death) + { + velocity += velocity * 0.15f * (1f - lifeRatio); + acceleration += acceleration * 0.15f * (1f - lifeRatio); + } - movementLimitX += num736; - movementLimitY += num737; - num736 = movementLimitX - vector.X; - num737 = movementLimitY - vector.Y; - num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); + if (num738 >= maxDistanceFromHooks) + { + num738 = maxDistanceFromHooks / num738; + num736 *= num738; + num737 *= num738; + } - if (num738 < velocity) - { - num736 = npc.velocity.X; - num737 = npc.velocity.Y; - } - else - { - num738 = velocity / num738; - num736 *= num738; - num737 *= num738; - } + movementLimitX += num736; + movementLimitY += num737; + num736 = movementLimitX - vector.X; + num737 = movementLimitY - vector.Y; + num738 = (float)Math.Sqrt(num736 * num736 + num737 * num737); - if (npc.velocity.X < num736) - { - npc.velocity.X += acceleration; - if (npc.velocity.X < 0f && num736 > 0f) - npc.velocity.X += acceleration * 2f; - } - else if (npc.velocity.X > num736) - { - npc.velocity.X -= acceleration; - if (npc.velocity.X > 0f && num736 < 0f) - npc.velocity.X -= acceleration * 2f; - } - if (npc.velocity.Y < num737) - { - npc.velocity.Y += acceleration; - if (npc.velocity.Y < 0f && num737 > 0f) - npc.velocity.Y += acceleration * 2f; - } - else if (npc.velocity.Y > num737) - { - npc.velocity.Y -= acceleration; - if (npc.velocity.Y > 0f && num737 < 0f) - npc.velocity.Y -= acceleration * 2f; - } + if (num738 < velocity) + { + num736 = npc.velocity.X; + num737 = npc.velocity.Y; + } + else + { + num738 = velocity / num738; + num736 *= num738; + num737 *= num738; + } - // Slow down considerably if near player - if (!speedUp && nearbyActiveTiles > 1000 && !Collision.SolidCollision(npc.position, npc.width, npc.height) && Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && !charging) - { - if (npc.velocity.Length() > velocity) - npc.velocity *= 0.97f; - } - } - else - { - // Charge - if (calamityGlobalNPC.newAI[3] == 1f) - { - reachedChargingPoint = false; + if (npc.velocity.X < num736) + { + npc.velocity.X += acceleration; + if (npc.velocity.X < 0f && num736 > 0f) + npc.velocity.X += acceleration * 2f; + } + else if (npc.velocity.X > num736) + { + npc.velocity.X -= acceleration; + if (npc.velocity.X > 0f && num736 < 0f) + npc.velocity.X -= acceleration * 2f; + } + if (npc.velocity.Y < num737) + { + npc.velocity.Y += acceleration; + if (npc.velocity.Y < 0f && num737 > 0f) + npc.velocity.Y += acceleration * 2f; + } + else if (npc.velocity.Y > num737) + { + npc.velocity.Y -= acceleration; + if (npc.velocity.Y > 0f && num737 < 0f) + npc.velocity.Y -= acceleration * 2f; + } - if (calamityGlobalNPC.newAI[1] == 0f) - { - npc.velocity = Vector2.Normalize(rotationVector) * chargeVelocity; - calamityGlobalNPC.newAI[1] = 1f; - } - else - { - calamityGlobalNPC.newAI[2] += 1f; + // Slow down considerably if near player + if (!speedUp && nearbyActiveTiles > 1000 && !Collision.SolidCollision(npc.position, npc.width, npc.height) && Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && !charging) + { + if (npc.velocity.Length() > velocity) + npc.velocity *= 0.97f; + } + } + else + { + // Charge + if (calamityGlobalNPC.newAI[3] == 1f) + { + reachedChargingPoint = false; - // Slow down for a few frames - float totalChargeTime = chargeDistance * 4f / chargeVelocity; - float slowDownTime = chargeVelocity; - if (calamityGlobalNPC.newAI[2] >= totalChargeTime - slowDownTime) - npc.velocity *= 0.9f; + if (calamityGlobalNPC.newAI[1] == 0f) + { + npc.velocity = Vector2.Normalize(rotationVector) * chargeVelocity; + calamityGlobalNPC.newAI[1] = 1f; + } + else + { + calamityGlobalNPC.newAI[2] += 1f; - // Reset and either go back to normal or charge again - if (calamityGlobalNPC.newAI[2] >= totalChargeTime) - { - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.ai[1] += 1f; + // Slow down for a few frames + float totalChargeTime = chargeDistance * 4f / chargeVelocity; + float slowDownTime = chargeVelocity; + if (calamityGlobalNPC.newAI[2] >= totalChargeTime - slowDownTime) + npc.velocity *= 0.9f; - if (npc.ai[1] >= chargeAmt) - { - // Reset and return to normal movement - calamityGlobalNPC.newAI[0] = 0f; - npc.ai[1] = 0f; - } - else - { - // Get a new target and charge again - npc.TargetClosest(); - } - } - } - } - else - { - // Pick a charging location - // Set charge locations X - if (vector.X >= player.Center.X) - calamityGlobalNPC.newAI[1] = player.Center.X + chargeDistance; - else - calamityGlobalNPC.newAI[1] = player.Center.X - chargeDistance; + // Reset and either go back to normal or charge again + if (calamityGlobalNPC.newAI[2] >= totalChargeTime) + { + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.ai[1] += 1f; - // Set charge locations Y - if (vector.Y >= player.Center.Y) - calamityGlobalNPC.newAI[2] = player.Center.Y + chargeDistance; - else - calamityGlobalNPC.newAI[2] = player.Center.Y - chargeDistance; + if (npc.ai[1] >= chargeAmt) + { + // Reset and return to normal movement + calamityGlobalNPC.newAI[0] = 0f; + npc.ai[1] = 0f; + } + else + { + // Get a new target and charge again + npc.TargetClosest(); + } + } + } + } + else + { + // Pick a charging location + // Set charge locations X + if (vector.X >= player.Center.X) + calamityGlobalNPC.newAI[1] = player.Center.X + chargeDistance; + else + calamityGlobalNPC.newAI[1] = player.Center.X - chargeDistance; - Vector2 chargeVector = new Vector2(calamityGlobalNPC.newAI[1], calamityGlobalNPC.newAI[2]); - Vector2 chargeLocationVelocity = Vector2.Normalize(chargeVector - vector) * chargeVelocity; - Vector2 cloneChargeVector = cloneAlive ? new Vector2(Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[1], Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[2]) : default; + // Set charge locations Y + if (vector.Y >= player.Center.Y) + calamityGlobalNPC.newAI[2] = player.Center.Y + chargeDistance; + else + calamityGlobalNPC.newAI[2] = player.Center.Y - chargeDistance; - // If clone is alive and not at proper location then keep trying to line up until it gets into position - float chargeDistanceGateValue = 40f; - bool clonePositionCheck = cloneAlive ? Vector2.Distance(Main.npc[CalamityGlobalNPC.ghostBossClone].Center, cloneChargeVector) <= chargeDistanceGateValue : true; + Vector2 chargeVector = new Vector2(calamityGlobalNPC.newAI[1], calamityGlobalNPC.newAI[2]); + Vector2 chargeLocationVelocity = Vector2.Normalize(chargeVector - vector) * chargeVelocity; + Vector2 cloneChargeVector = cloneAlive ? new Vector2(Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[1], Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[2]) : default; - // Line up a charge - if (Vector2.Distance(vector, chargeVector) <= chargeDistanceGateValue || reachedChargingPoint) - { - // Emit dust - if (!reachedChargingPoint) - { - Main.PlaySound(SoundID.Item125, npc.position); - for (int i = 0; i < 30; i++) - { - int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 5f; - } - } + // If clone is alive and not at proper location then keep trying to line up until it gets into position + float chargeDistanceGateValue = 40f; + bool clonePositionCheck = cloneAlive ? Vector2.Distance(Main.npc[CalamityGlobalNPC.ghostBossClone].Center, cloneChargeVector) <= chargeDistanceGateValue : true; - reachedChargingPoint = true; - npc.velocity = Vector2.Zero; - npc.Center = chargeVector; + // Line up a charge + if (Vector2.Distance(vector, chargeVector) <= chargeDistanceGateValue || reachedChargingPoint) + { + // Emit dust + if (!reachedChargingPoint) + { + Main.PlaySound(SoundID.Item125, npc.position); + for (int i = 0; i < 30; i++) + { + int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 5f; + } + } - if (clonePositionCheck) - { - // Initiate charge - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 1f; + reachedChargingPoint = true; + npc.velocity = Vector2.Zero; + npc.Center = chargeVector; - // Tell clone to charge - if (cloneAlive) - { - Main.npc[CalamityGlobalNPC.ghostBossClone].ai[0] = 0f; - Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[1] = 0f; - Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[2] = 0f; - Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[3] = 1f; + if (clonePositionCheck) + { + // Initiate charge + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 1f; - // - // CODE TWEAKED BY: OZZATRON - // September 21st, 2020 - // reason: fixing Polter charge MP desync bug - // - // removed Polter syncing the clone's newAI array. The clone now auto syncs its own newAI every frame. - } - } - } - else - npc.SimpleFlyMovement(chargeLocationVelocity, chargeAcceleration); - } + // Tell clone to charge + if (cloneAlive) + { + Main.npc[CalamityGlobalNPC.ghostBossClone].ai[0] = 0f; + Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[1] = 0f; + Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[2] = 0f; + Main.npc[CalamityGlobalNPC.ghostBossClone].Calamity().newAI[3] = 1f; - npc.netUpdate = true; + // + // CODE TWEAKED BY: OZZATRON + // September 21st, 2020 + // reason: fixing Polter charge MP desync bug + // + // removed Polter syncing the clone's newAI array. The clone now auto syncs its own newAI every frame. + } + } + } + else + npc.SimpleFlyMovement(chargeLocationVelocity, chargeAcceleration); + } - if (npc.netSpam > 10) - npc.netSpam = 10; + npc.netUpdate = true; - if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); - } + if (npc.netSpam > 10) + npc.netSpam = 10; - if (!phase2 && !phase3) + if (Main.netMode == NetmodeID.Server) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); + } + + if (!phase2 && !phase3) { npc.damage = npc.defDamage; npc.defense = npc.defDefense; @@ -636,59 +636,59 @@ namespace CalamityMod.NPCs.Polterghast type = ModContent.ProjectileType(); } - int damage = npc.GetProjectileDamage(type); + int damage = npc.GetProjectileDamage(type); - Vector2 vector93 = vector; - float num743 = player.Center.X - vector93.X; - float num744 = player.Center.Y - vector93.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + Vector2 vector93 = vector; + float num743 = player.Center.X - vector93.X; + float num744 = player.Center.Y - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); - num745 = baseProjectileVelocity / num745; - num743 *= num745; - num744 *= num745; - vector93.X += num743 * 3f; - vector93.Y += num744 * 3f; + num745 = baseProjectileVelocity / num745; + num743 *= num745; + num744 *= num745; + vector93.X += num743 * 3f; + vector93.Y += num744 * 3f; - float rotation = MathHelper.ToRadians(baseProjectileSpread); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; - double deltaAngle = rotation / baseProjectileAmt; - double offsetAngle; - for (int i = 0; i < baseProjectileAmt; i++) - { - offsetAngle = startAngle + deltaAngle * i; - int proj = Projectile.NewProjectile(vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[proj].timeLeft = type == ModContent.ProjectileType() ? baseProjectileTimeLeft / 4 : baseProjectileTimeLeft; - } - } + float rotation = MathHelper.ToRadians(baseProjectileSpread); + float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); + double startAngle = Math.Atan2(num743, num744) - rotation / 2; + double deltaAngle = rotation / baseProjectileAmt; + double offsetAngle; + for (int i = 0; i < baseProjectileAmt; i++) + { + offsetAngle = startAngle + deltaAngle * i; + int proj = Projectile.NewProjectile(vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[proj].timeLeft = type == ModContent.ProjectileType() ? baseProjectileTimeLeft / 4 : baseProjectileTimeLeft; + } + } else { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); - Vector2 vector93 = vector; - float num743 = player.Center.X - vector93.X; - float num744 = player.Center.Y - vector93.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + Vector2 vector93 = vector; + float num743 = player.Center.X - vector93.X; + float num744 = player.Center.Y - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); - num745 = (baseProjectileVelocity + 5f) / num745; - num743 *= num745; - num744 *= num745; - vector93.X += num743 * 3f; - vector93.Y += num744 * 3f; + num745 = (baseProjectileVelocity + 5f) / num745; + num743 *= num745; + num744 *= num745; + vector93.X += num743 * 3f; + vector93.Y += num744 * 3f; - float rotation = MathHelper.ToRadians(baseProjectileSpread + 15); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; - double deltaAngle = rotation / baseProjectileAmt; - double offsetAngle; - for (int i = 0; i < baseProjectileAmt; i++) - { - offsetAngle = startAngle + deltaAngle * i; - int proj = Projectile.NewProjectile(vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[proj].timeLeft = baseProjectileTimeLeft / 4; - } - } + float rotation = MathHelper.ToRadians(baseProjectileSpread + 15); + float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); + double startAngle = Math.Atan2(num743, num744) - rotation / 2; + double deltaAngle = rotation / baseProjectileAmt; + double offsetAngle; + for (int i = 0; i < baseProjectileAmt; i++) + { + offsetAngle = startAngle + deltaAngle * i; + int proj = Projectile.NewProjectile(vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[proj].timeLeft = baseProjectileTimeLeft / 4; + } + } } } } @@ -698,14 +698,14 @@ namespace CalamityMod.NPCs.Polterghast { npc.ai[0] = 1f; - // Reset charge attack arrays to prevent problems - npc.ai[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; + // Reset charge attack arrays to prevent problems + npc.ai[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; - Main.PlaySound(SoundID.Item122, npc.Center); + Main.PlaySound(SoundID.Item122, npc.Center); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Polt"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Polt2"), 1f); @@ -758,68 +758,68 @@ namespace CalamityMod.NPCs.Polterghast if (flag47) { - int type = ModContent.ProjectileType(); - if (Main.rand.NextBool(3)) - { - npc.localAI[1] = -30f; - type = ModContent.ProjectileType(); - } + int type = ModContent.ProjectileType(); + if (Main.rand.NextBool(3)) + { + npc.localAI[1] = -30f; + type = ModContent.ProjectileType(); + } - int damage = npc.GetProjectileDamage(type); + int damage = npc.GetProjectileDamage(type); - Vector2 vector93 = vector; - float num743 = player.Center.X - vector93.X; - float num744 = player.Center.Y - vector93.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + Vector2 vector93 = vector; + float num743 = player.Center.X - vector93.X; + float num744 = player.Center.Y - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); - num745 = (baseProjectileVelocity + 1f) / num745; - num743 *= num745; - num744 *= num745; - vector93.X += num743 * 3f; - vector93.Y += num744 * 3f; + num745 = (baseProjectileVelocity + 1f) / num745; + num743 *= num745; + num744 *= num745; + vector93.X += num743 * 3f; + vector93.Y += num744 * 3f; - int numProj = baseProjectileAmt + 1; - float rotation = MathHelper.ToRadians(baseProjectileSpread + 15); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; - double deltaAngle = rotation / numProj; - double offsetAngle; - for (int i = 0; i < numProj; i++) - { - offsetAngle = startAngle + deltaAngle * i; - int proj = Projectile.NewProjectile(vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[proj].timeLeft = type == ModContent.ProjectileType() ? baseProjectileTimeLeft / 4 : baseProjectileTimeLeft; - } - } + int numProj = baseProjectileAmt + 1; + float rotation = MathHelper.ToRadians(baseProjectileSpread + 15); + float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); + double startAngle = Math.Atan2(num743, num744) - rotation / 2; + double deltaAngle = rotation / numProj; + double offsetAngle; + for (int i = 0; i < numProj; i++) + { + offsetAngle = startAngle + deltaAngle * i; + int proj = Projectile.NewProjectile(vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[proj].timeLeft = type == ModContent.ProjectileType() ? baseProjectileTimeLeft / 4 : baseProjectileTimeLeft; + } + } else { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); - Vector2 vector93 = vector; - float num743 = player.Center.X - vector93.X; - float num744 = player.Center.Y - vector93.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + Vector2 vector93 = vector; + float num743 = player.Center.X - vector93.X; + float num744 = player.Center.Y - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); - num745 = (baseProjectileVelocity + 5f) / num745; - num743 *= num745; - num744 *= num745; - vector93.X += num743 * 3f; - vector93.Y += num744 * 3f; + num745 = (baseProjectileVelocity + 5f) / num745; + num743 *= num745; + num744 *= num745; + vector93.X += num743 * 3f; + vector93.Y += num744 * 3f; - int numProj = baseProjectileAmt + 1; - float rotation = MathHelper.ToRadians(baseProjectileSpread + 35); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; - double deltaAngle = rotation / numProj; - double offsetAngle; - for (int i = 0; i < numProj; i++) - { - offsetAngle = startAngle + deltaAngle * i; - int proj = Projectile.NewProjectile(vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[proj].timeLeft = baseProjectileTimeLeft / 4; - } - } + int numProj = baseProjectileAmt + 1; + float rotation = MathHelper.ToRadians(baseProjectileSpread + 35); + float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); + double startAngle = Math.Atan2(num743, num744) - rotation / 2; + double deltaAngle = rotation / numProj; + double offsetAngle; + for (int i = 0; i < numProj; i++) + { + offsetAngle = startAngle + deltaAngle * i; + int proj = Projectile.NewProjectile(vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[proj].timeLeft = baseProjectileTimeLeft / 4; + } + } } } } @@ -831,26 +831,26 @@ namespace CalamityMod.NPCs.Polterghast { npc.ai[0] = 2f; - // Reset charge attack arrays to prevent problems - npc.ai[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; + // Reset charge attack arrays to prevent problems + npc.ai[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) { NPC.NewNPC((int)vector.X, (int)vector.Y, ModContent.NPCType()); - if (expertMode) - { - for (int I = 0; I < 3; I++) - { - int spawn = NPC.NewNPC((int)(vector.X + (Math.Sin(I * 120) * 500)), (int)(vector.Y + (Math.Cos(I * 120) * 500)), ModContent.NPCType(), npc.whoAmI, 0, 0, 0, -1); - NPC npc2 = Main.npc[spawn]; - npc2.ai[0] = I * 120; - } - } + if (expertMode) + { + for (int I = 0; I < 3; I++) + { + int spawn = NPC.NewNPC((int)(vector.X + (Math.Sin(I * 120) * 500)), (int)(vector.Y + (Math.Cos(I * 120) * 500)), ModContent.NPCType(), npc.whoAmI, 0, 0, 0, -1); + NPC npc2 = Main.npc[spawn]; + npc2.ai[0] = I * 120; + } + } } Main.PlaySound(SoundID.Item122, npc.Center); @@ -887,42 +887,42 @@ namespace CalamityMod.NPCs.Polterghast npc.damage = (int)(npc.defDamage * 1.4f); npc.defense = (int)(npc.defDefense * 0.5f); - npc.localAI[1] += 1f; - if (npc.localAI[1] >= (getPissed ? 150f : 210f) * projectileFireRateMultiplier && Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - npc.localAI[1] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient && !charging && !chargePhase) - { - Vector2 vector93 = vector; - float num743 = player.Center.X - vector93.X; - float num744 = player.Center.Y - vector93.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); + npc.localAI[1] += 1f; + if (npc.localAI[1] >= (getPissed ? 150f : 210f) * projectileFireRateMultiplier && Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + npc.localAI[1] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient && !charging && !chargePhase) + { + Vector2 vector93 = vector; + float num743 = player.Center.X - vector93.X; + float num744 = player.Center.Y - vector93.Y; + float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); - num745 = baseProjectileVelocity / num745; - num743 *= num745; - num744 *= num745; - vector93.X += num743 * 3f; - vector93.Y += num744 * 3f; + num745 = baseProjectileVelocity / num745; + num743 *= num745; + num744 *= num745; + vector93.X += num743 * 3f; + vector93.Y += num744 * 3f; - int numProj = baseProjectileAmt + (getPissed ? 4 : 2); - float rotation = MathHelper.ToRadians(baseProjectileSpread + (getPissed ? 60 : 45)); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; - double deltaAngle = rotation / numProj; - double offsetAngle; + int numProj = baseProjectileAmt + (getPissed ? 4 : 2); + float rotation = MathHelper.ToRadians(baseProjectileSpread + (getPissed ? 60 : 45)); + float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); + double startAngle = Math.Atan2(num743, num744) - rotation / 2; + double deltaAngle = rotation / numProj; + double offsetAngle; - int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < numProj; i++) - { - offsetAngle = startAngle + deltaAngle * i; - Projectile.NewProjectile(vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } + for (int i = 0; i < numProj; i++) + { + offsetAngle = startAngle + deltaAngle * i; + Projectile.NewProjectile(vector93.X, vector93.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 0f, 0f); + } + } + } - if (phase4) + if (phase4) { npc.localAI[2] += 1f; if (npc.localAI[2] >= (getPissed ? 300f : 420f)) @@ -937,10 +937,10 @@ namespace CalamityMod.NPCs.Polterghast num761 = num757 / num761; num758 *= num761; num760 *= num761; - vector94.X += num758 * 3f; - vector94.Y += num760 * 3f; + vector94.X += num758 * 3f; + vector94.Y += num760 * 3f; - if (NPC.CountNPCS(ModContent.NPCType()) < 2 && Main.netMode != NetmodeID.MultiplayerClient && !charging && !chargePhase) + if (NPC.CountNPCS(ModContent.NPCType()) < 2 && Main.netMode != NetmodeID.MultiplayerClient && !charging && !chargePhase) { int num762 = NPC.NewNPC((int)vector.X, (int)vector.Y, ModContent.NPCType()); Main.npc[num762].velocity.X = num758; @@ -959,14 +959,14 @@ namespace CalamityMod.NPCs.Polterghast public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedPolterghast); - CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Cyborg }, CalamityWorld.downedPolterghast); + CalamityGlobalNPC.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) @@ -990,9 +990,9 @@ namespace CalamityMod.NPCs.Polterghast DropHelper.WeightStack(w) ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); - } + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); + } // If Polterghast has not been killed, notify players about the Abyss minibosses now dropping items if (!CalamityWorld.downedPolterghast) @@ -1005,101 +1005,101 @@ namespace CalamityMod.NPCs.Polterghast string sulfSeaBoostMessage = "Mods.CalamityMod.GhostBossText4"; Color sulfSeaBoostColor = AcidRainEvent.TextColor; - if (Main.rand.NextBool(20) && DateTime.Now.Month == 4 && DateTime.Now.Day == 1) - { - sulfSeaBoostMessage = "Mods.CalamityMod.AprilFools2"; // Goddamn boomer duke moments - } + if (Main.rand.NextBool(20) && DateTime.Now.Month == 4 && DateTime.Now.Day == 1) + { + sulfSeaBoostMessage = "Mods.CalamityMod.AprilFools2"; // Goddamn boomer duke moments + } - CalamityUtils.DisplayLocalizedText(key, messageColor); - CalamityUtils.DisplayLocalizedText(sulfSeaBoostMessage, sulfSeaBoostColor); - } + CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.DisplayLocalizedText(sulfSeaBoostMessage, sulfSeaBoostColor); + } // Mark Polterghast as dead CalamityWorld.downedPolterghast = true; - CalamityNetcode.SyncWorld(); - } + CalamityNetcode.SyncWorld(); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastGlow2"); - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; - - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastGlow"); - - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - Color lightRed = new Color(255, 100, 100, 255); - if (npc.Calamity().newAI[0] > 300f) - color37 = Color.Lerp(color37, lightRed, MathHelper.Clamp((npc.Calamity().newAI[0] - 300f) / 120f, 0f, 1f)); - - Color color42 = Color.Lerp(Color.White, (npc.ai[2] >= 300f || npc.Calamity().newAI[0] > 300f) ? Color.Red : Color.Black, 0.5f); - - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 = npc.GetAlpha(color43); - color43 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override void FindFrame(int frameHeight) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastGlow2"); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 7; - bool phase2 = lifeRatio < (death ? 0.9f : revenge ? 0.8f : expertMode ? 0.65f : 0.5f); - bool phase3 = lifeRatio < (death ? 0.6f : revenge ? 0.5f : expertMode ? 0.35f : 0.2f); + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastGlow"); + + Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + Color lightRed = new Color(255, 100, 100, 255); + if (npc.Calamity().newAI[0] > 300f) + color37 = Color.Lerp(color37, lightRed, MathHelper.Clamp((npc.Calamity().newAI[0] - 300f) / 120f, 0f, 1f)); + + Color color42 = Color.Lerp(Color.White, (npc.ai[2] >= 300f || npc.Calamity().newAI[0] > 300f) ? Color.Red : Color.Black, 0.5f); + + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + Color color43 = color42; + color43 = Color.Lerp(color43, color36, amount9); + color43 = npc.GetAlpha(color43); + color43 *= (num153 - num163) / 15f; + spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; + } + + public override void FindFrame(int frameHeight) + { + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + bool phase2 = lifeRatio < (death ? 0.9f : revenge ? 0.8f : expertMode ? 0.65f : 0.5f); + bool phase3 = lifeRatio < (death ? 0.6f : revenge ? 0.5f : expertMode ? 0.35f : 0.2f); npc.frameCounter += 1D; if (npc.frameCounter > 6D) @@ -1109,14 +1109,14 @@ namespace CalamityMod.NPCs.Polterghast } if (phase3) { - if (npc.frame.Y < frameHeight * 8) - { - npc.frame.Y = frameHeight * 8; - } - if (npc.frame.Y > frameHeight * 11) - { - npc.frame.Y = frameHeight * 8; - } + if (npc.frame.Y < frameHeight * 8) + { + npc.frame.Y = frameHeight * 8; + } + if (npc.frame.Y > frameHeight * 11) + { + npc.frame.Y = frameHeight * 8; + } } else if (phase2) { @@ -1131,17 +1131,17 @@ namespace CalamityMod.NPCs.Polterghast } else { - if (npc.frame.Y > frameHeight * 3) - { - npc.frame.Y = 0; - } - } + if (npc.frame.Y > frameHeight * 3) + { + npc.frame.Y = 0; + } + } } public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(BuffID.MoonLeech, 900, true); - } + player.AddBuff(BuffID.MoonLeech, 900, true); + } public override bool CanHitPlayer(Player target, ref int cooldownSlot) { diff --git a/NPCs/Polterghast/PolterghastHook.cs b/NPCs/Polterghast/PolterghastHook.cs index b432e5b26a..fab966e77b 100644 --- a/NPCs/Polterghast/PolterghastHook.cs +++ b/NPCs/Polterghast/PolterghastHook.cs @@ -10,7 +10,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.Polterghast { - public class PolterghastHook : ModNPC + public class PolterghastHook : ModNPC { private int despawnTimer = 300; private bool phase2 = false; @@ -19,8 +19,8 @@ namespace CalamityMod.NPCs.Polterghast { DisplayName.SetDefault("Polterghast Hook"); Main.npcFrameCount[npc.type] = 2; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -41,17 +41,17 @@ namespace CalamityMod.NPCs.Polterghast { writer.Write(phase2); writer.Write(despawnTimer); - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - } + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + } public override void ReceiveExtraAI(BinaryReader reader) { phase2 = reader.ReadBoolean(); despawnTimer = reader.ReadInt32(); - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - } + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + } public override void AI() { @@ -61,36 +61,36 @@ namespace CalamityMod.NPCs.Polterghast // Bools bool speedBoost = false; bool despawnBoost = false; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - // Despawn if Polter is gone - if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active) + // Despawn if Polter is gone + if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active) { npc.active = false; npc.netUpdate = true; return; } - Player player = Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target]; + Player player = Main.player[Main.npc[CalamityGlobalNPC.ghostBoss].target]; - if (!player.active || player.dead) - { - speedBoost = true; - despawnBoost = true; - } + if (!player.active || player.dead) + { + speedBoost = true; + despawnBoost = true; + } - bool chargePhase = Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] >= 420f; + bool chargePhase = Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] >= 420f; - // Percent life remaining, Polter - float lifeRatio = Main.npc[CalamityGlobalNPC.ghostBoss].life / (float)Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax; + // Percent life remaining, Polter + float lifeRatio = Main.npc[CalamityGlobalNPC.ghostBoss].life / (float)Main.npc[CalamityGlobalNPC.ghostBoss].lifeMax; - // Scale multiplier based on nearby active tiles - float tileEnrageMult = Main.npc[CalamityGlobalNPC.ghostBoss].ai[3]; + // Scale multiplier based on nearby active tiles + float tileEnrageMult = Main.npc[CalamityGlobalNPC.ghostBoss].ai[3]; - // Despawn - if (CalamityGlobalNPC.ghostBoss != -1 && !player.ZoneDungeon && + // Despawn + if (CalamityGlobalNPC.ghostBoss != -1 && !player.ZoneDungeon && player.position.Y < Main.worldSurface * 16.0 && !BossRushEvent.BossRushActive) { despawnTimer--; @@ -103,20 +103,20 @@ namespace CalamityMod.NPCs.Polterghast else despawnTimer++; - // Phase 2 - bool phase3 = lifeRatio < (death ? 0.6f : revenge ? 0.5f : expertMode ? 0.35f : 0.2f); - phase2 = lifeRatio < (death ? 0.9f : revenge ? 0.8f : expertMode ? 0.65f : 0.5f) && !phase3; - if (phase2) + // Phase 2 + bool phase3 = lifeRatio < (death ? 0.6f : revenge ? 0.5f : expertMode ? 0.35f : 0.2f); + phase2 = lifeRatio < (death ? 0.9f : revenge ? 0.8f : expertMode ? 0.65f : 0.5f) && !phase3; + if (phase2) { - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Movement(phase2, expertMode, revenge, death, speedBoost, despawnBoost, lifeRatio, tileEnrageMult, player); + Movement(phase2, expertMode, revenge, death, speedBoost, despawnBoost, lifeRatio, tileEnrageMult, player); // Fire projectiles Vector2 vector17 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); @@ -149,9 +149,9 @@ namespace CalamityMod.NPCs.Polterghast if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == 20f) { float num151 = 10f * tileEnrageMult; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - num149 = num151 / num149; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + num149 = num151 / num149; num147 *= num149; num148 *= num149; int proj = Projectile.NewProjectile(vector17.X, vector17.Y, num147, num148, type, damage, 0f, Main.myPlayer, 0f, 0f); @@ -166,9 +166,9 @@ namespace CalamityMod.NPCs.Polterghast private void Movement(bool phase2, bool expertMode, bool revenge, bool death, bool speedBoost, bool despawnBoost, float lifeRatio, float tileEnrageMult, Player player) { - bool chargePhase = Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] >= 420f; + bool chargePhase = Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] >= 420f; - if (phase2) + if (phase2) { float num740 = Main.player[npc.target].Center.X - npc.Center.X; float num741 = Main.player[npc.target].Center.Y - npc.Center.Y; @@ -188,21 +188,21 @@ namespace CalamityMod.NPCs.Polterghast if (npc.ai[0] == 0f || npc.ai[1] == 0f) npc.localAI[0] = 0f; - if (chargePhase) - { - npc.localAI[0] -= 10f; - } - else - { - float shootBoost = death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - npc.localAI[0] -= 1f + shootBoost * tileEnrageMult; - if (expertMode) - npc.localAI[0] -= Vector2.Distance(npc.Center, player.Center) * 0.002f; - if (Main.npc[CalamityGlobalNPC.ghostBoss].ai[2] >= 300f) - npc.localAI[0] -= 3f; - if (speedBoost) - npc.localAI[0] -= 6f; - } + if (chargePhase) + { + npc.localAI[0] -= 10f; + } + else + { + float shootBoost = death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + npc.localAI[0] -= 1f + shootBoost * tileEnrageMult; + if (expertMode) + npc.localAI[0] -= Vector2.Distance(npc.Center, player.Center) * 0.002f; + if (Main.npc[CalamityGlobalNPC.ghostBoss].ai[2] >= 300f) + npc.localAI[0] -= 3f; + if (speedBoost) + npc.localAI[0] -= 6f; + } if (!despawnBoost && npc.localAI[0] <= 0f && npc.ai[0] != 0f) { @@ -244,8 +244,8 @@ namespace CalamityMod.NPCs.Polterghast flag50 = true; npc.ai[0] = num768; npc.ai[1] = num769; - npc.localAI[1] = Vector2.Distance(npc.Center, player.Center) * 0.01f; - npc.netUpdate = true; + npc.localAI[1] = Vector2.Distance(npc.Center, player.Center) * 0.01f; + npc.netUpdate = true; } } catch { @@ -256,7 +256,7 @@ namespace CalamityMod.NPCs.Polterghast if (npc.ai[0] > 0f && npc.ai[1] > 0f) { - float velocityBoost = death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + float velocityBoost = death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); float velocity = (8f + velocityBoost) * tileEnrageMult; if (expertMode) velocity += npc.localAI[1]; @@ -293,101 +293,101 @@ namespace CalamityMod.NPCs.Polterghast } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color lightRed = new Color(255, 100, 100, 255); - if (Main.npc[CalamityGlobalNPC.ghostBoss].active && !phase2) - { - Vector2 center = npc.Center; - float bossCenterX = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - center.X; - float bossCenterY = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - center.Y; - float rotation2 = (float)Math.Atan2(bossCenterY, bossCenterX) - 1.57f; - bool draw = true; - while (draw) - { - int chainWidth = 20; //16 24 - int chainHeight = 52; //32 16 - float num10 = (float)Math.Sqrt(bossCenterX * bossCenterX + bossCenterY * bossCenterY); - if (num10 < chainHeight) - { - chainWidth = (int)num10 - chainHeight + chainWidth; - draw = false; - } - num10 = chainWidth / num10; - bossCenterX *= num10; - bossCenterY *= num10; - center.X += bossCenterX; - center.Y += bossCenterY; - bossCenterX = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - center.X; - bossCenterY = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - center.Y; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Color lightRed = new Color(255, 100, 100, 255); + if (Main.npc[CalamityGlobalNPC.ghostBoss].active && !phase2) + { + Vector2 center = npc.Center; + float bossCenterX = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - center.X; + float bossCenterY = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - center.Y; + float rotation2 = (float)Math.Atan2(bossCenterY, bossCenterX) - 1.57f; + bool draw = true; + while (draw) + { + int chainWidth = 20; //16 24 + int chainHeight = 52; //32 16 + float num10 = (float)Math.Sqrt(bossCenterX * bossCenterX + bossCenterY * bossCenterY); + if (num10 < chainHeight) + { + chainWidth = (int)num10 - chainHeight + chainWidth; + draw = false; + } + num10 = chainWidth / num10; + bossCenterX *= num10; + bossCenterY *= num10; + center.X += bossCenterX; + center.Y += bossCenterY; + bossCenterX = Main.npc[CalamityGlobalNPC.ghostBoss].Center.X - center.X; + bossCenterY = Main.npc[CalamityGlobalNPC.ghostBoss].Center.Y - center.Y; - Color color2 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - if (Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > 300f) - color2 = Color.Lerp(color2, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - 300f) / 120f, 0f, 1f)); + Color color2 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + if (Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > 300f) + color2 = Color.Lerp(color2, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - 300f) / 120f, 0f, 1f)); - Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastChain"), 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/Polterghast/PolterghastChain").Width, chainWidth)), color2, rotation2, - new Vector2(ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastChain").Width * 0.5f, ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastChain").Height * 0.5f), 1f, SpriteEffects.None, 0f); - } - } + Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastChain"), 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/Polterghast/PolterghastChain").Width, chainWidth)), color2, rotation2, + new Vector2(ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastChain").Width * 0.5f, ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastChain").Height * 0.5f), 1f, SpriteEffects.None, 0f); + } + } - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastHookGlow"); - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Polterghast/PolterghastHookGlow"); + Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - if (Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > 300f) - color37 = Color.Lerp(color37, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - 300f) / 120f, 0f, 1f)); + if (Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] > 300f) + color37 = Color.Lerp(color37, lightRed, MathHelper.Clamp((Main.npc[CalamityGlobalNPC.ghostBoss].Calamity().newAI[0] - 300f) / 120f, 0f, 1f)); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { if (phase2) { diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs index 56476e1ba0..ff28bc3ac2 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs @@ -26,23 +26,23 @@ namespace CalamityMod.NPCs.ProfanedGuardians private int healTimer = 0; private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Guardian Commander"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 20f; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 20f; npc.aiStyle = -1; - npc.GetNPCDamage(); - npc.width = 100; + npc.GetNPCDamage(); + npc.width = 100; npc.height = 80; npc.defense = 40; - npc.DR_NERD(0.3f); + npc.DR_NERD(0.3f); npc.LifeMaxNERB(56250, 67500, 165000); // Old HP - 102500, 112500 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -55,11 +55,11 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.value = Item.buyPrice(1, 0, 0, 0); npc.HitSound = SoundID.NPCHit52; npc.DeathSound = SoundID.NPCDeath55; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -87,16 +87,16 @@ namespace CalamityMod.NPCs.ProfanedGuardians { CalamityGlobalNPC.doughnutBoss = npc.whoAmI; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - Vector2 vectorCenter = npc.Center; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[1] == 0f) + Vector2 vectorCenter = npc.Center; + if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[1] == 0f) { npc.localAI[1] = 1f; NPC.NewNPC((int)vectorCenter.X, (int)vectorCenter.Y, ModContent.NPCType()); @@ -156,59 +156,59 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - if (!Main.dayTime || !player.active || player.dead) + if (!Main.dayTime || !player.active || player.dead) { npc.TargetClosest(false); player = Main.player[npc.target]; if (!Main.dayTime || !player.active || player.dead) { - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + npc.velocity.Y -= 0.1f; + if (npc.velocity.Y < -12f) + npc.velocity.Y = -12f; - if (npc.timeLeft > 60) + if (npc.timeLeft > 60) npc.timeLeft = 60; - if (npc.ai[0] != 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - return; + if (npc.ai[0] != 0f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } + return; } } else if (npc.timeLeft < 1800) npc.timeLeft = 1800; - // Become immune over time if target isn't in hell or hallow - bool isHoly = player.ZoneHoly; - bool isHell = player.ZoneUnderworldHeight; - if (!isHoly && !isHell && !BossRushEvent.BossRushActive) + // Become immune over time if target isn't in hell or hallow + bool isHoly = player.ZoneHoly; + bool isHell = player.ZoneUnderworldHeight; + if (!isHoly && !isHell && !BossRushEvent.BossRushActive) { if (biomeEnrageTimer > 0) - biomeEnrageTimer--; + biomeEnrageTimer--; else npc.Calamity().CurrentlyEnraged = true; } else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; bool biomeEnraged = biomeEnrageTimer <= 0; - bool phase1 = false; + bool phase1 = false; for (int num569 = 0; num569 < Main.maxNPCs; num569++) { if ((Main.npc[num569].active && Main.npc[num569].type == ModContent.NPCType()) || (Main.npc[num569].active && Main.npc[num569].type == ModContent.NPCType())) @@ -393,7 +393,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { npc.ai[0] = 0f; npc.ai[1] = 0f; - npc.TargetClosest(); + npc.TargetClosest(); npc.netUpdate = true; } @@ -401,64 +401,64 @@ namespace CalamityMod.NPCs.ProfanedGuardians } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; - if (npc.ai[0] == 2f) - num153 = 10; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; + if (npc.ai[0] == 2f) + num153 = 10; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBossGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBossGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; @@ -472,18 +472,18 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - // Profaned Guardians have no actual drops and no treasure bag - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + // Profaned Guardians have no actual drops and no treasure bag + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItem(npc, ModContent.ItemType()); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedGuardians); - // Mark the Profaned Guardians as dead - CalamityWorld.downedGuardians = true; + // Mark the Profaned Guardians as dead + CalamityWorld.downedGuardians = true; CalamityNetcode.SyncWorld(); } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs index d7e2f2b227..7ce6ad9e28 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs @@ -20,23 +20,23 @@ namespace CalamityMod.NPCs.ProfanedGuardians private int healTimer = 0; private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Guardian Defender"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 3f; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 3f; npc.aiStyle = -1; - npc.GetNPCDamage(); - npc.width = 100; + npc.GetNPCDamage(); + npc.width = 100; npc.height = 80; npc.defense = 50; - npc.DR_NERD(0.4f); + npc.DR_NERD(0.4f); npc.LifeMaxNERB(43750, 52500, 30000); // Old HP - 40000, 50000 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -47,11 +47,11 @@ namespace CalamityMod.NPCs.ProfanedGuardians aiType = -1; npc.HitSound = SoundID.NPCHit52; npc.DeathSound = SoundID.NPCDeath55; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -117,19 +117,19 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[Main.npc[CalamityGlobalNPC.doughnutBoss].target]; + Player player = Main.player[Main.npc[CalamityGlobalNPC.doughnutBoss].target]; - if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + if (npc.timeLeft < 1800) + npc.timeLeft = 1800; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; bool isHoly = player.ZoneHoly; @@ -139,12 +139,12 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (!isHoly && !isHell && !BossRushEvent.BossRushActive) { if (biomeEnrageTimer > 0) - biomeEnrageTimer--; + biomeEnrageTimer--; else npc.Calamity().CurrentlyEnraged = true; } else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; bool biomeEnraged = biomeEnrageTimer <= 0; @@ -291,64 +291,64 @@ namespace CalamityMod.NPCs.ProfanedGuardians } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; if (npc.ai[0] == 2f) num153 = 10; if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss2Glow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss2Glow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; @@ -365,10 +365,10 @@ namespace CalamityMod.NPCs.ProfanedGuardians potionType = ItemID.GreaterHealingPotion; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 240, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 240, true); + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs index f9709b672b..88617ee7df 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs @@ -15,25 +15,25 @@ namespace CalamityMod.NPCs.ProfanedGuardians [AutoloadBossHead] public class ProfanedGuardianBoss3 : ModNPC { - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Guardian Healer"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 3f; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 3f; npc.aiStyle = -1; - npc.GetNPCDamage(); - npc.width = 100; + npc.GetNPCDamage(); + npc.width = 100; npc.height = 80; npc.defense = 30; - npc.DR_NERD(0.2f); + npc.DR_NERD(0.2f); npc.LifeMaxNERB(25000, 30000, 20000); // Old HP - 25000, 35000 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -44,11 +44,11 @@ namespace CalamityMod.NPCs.ProfanedGuardians aiType = -1; npc.HitSound = SoundID.NPCHit52; npc.DeathSound = SoundID.NPCDeath55; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -57,7 +57,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); + biomeEnrageTimer = reader.ReadInt32(); } public override void FindFrame(int frameHeight) @@ -132,72 +132,72 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.velocity *= 1.1f; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss3Glow2"); - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss3Glow2"); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss3Glow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - Color color42 = Color.Lerp(Color.White, Color.Violet, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss3Glow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color color42 = Color.Lerp(Color.White, Color.Violet, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 = npc.GetAlpha(color43); - color43 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + Color color43 = color42; + color43 = Color.Lerp(color43, color36, amount9); + color43 = npc.GetAlpha(color43); + color43 *= (num153 - num163) / 15f; + spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; @@ -214,10 +214,10 @@ namespace CalamityMod.NPCs.ProfanedGuardians potionType = ItemID.GreaterHealingPotion; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 180, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 180, true); + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/Providence/ProvSky.cs b/NPCs/Providence/ProvSky.cs index 3d6d53ff69..006bc9237d 100644 --- a/NPCs/Providence/ProvSky.cs +++ b/NPCs/Providence/ProvSky.cs @@ -32,10 +32,10 @@ namespace CalamityMod.NPCs.Providence if (ProvIndex != -1) x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[ProvIndex].Center); - float spawnAnimationTimer = 180f; - float intensityScalar = 0.25f; - if (Main.npc[ProvIndex].Calamity().newAI[3] < spawnAnimationTimer) - intensityScalar = MathHelper.Lerp(0f, intensityScalar, Main.npc[ProvIndex].Calamity().newAI[3] / spawnAnimationTimer); + float spawnAnimationTimer = 180f; + float intensityScalar = 0.25f; + if (Main.npc[ProvIndex].Calamity().newAI[3] < spawnAnimationTimer) + intensityScalar = MathHelper.Lerp(0f, intensityScalar, Main.npc[ProvIndex].Calamity().newAI[3] / spawnAnimationTimer); return (1f - Utils.SmoothStep(3000f, 6000f, x)) * intensityScalar; } @@ -72,7 +72,7 @@ namespace CalamityMod.NPCs.Providence if (maxDepth >= 0 && minDepth < 0) { float intensity = GetIntensity(); - Color color = Main.dayTime ? new Color(255, 200, 100) : new Color(100, 150, 255); + Color color = Main.dayTime ? new Color(255, 200, 100) : new Color(100, 150, 255); spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), color * intensity); } } diff --git a/NPCs/Providence/ProvSpawnDefense.cs b/NPCs/Providence/ProvSpawnDefense.cs index 0b9b624647..648ac0ea15 100644 --- a/NPCs/Providence/ProvSpawnDefense.cs +++ b/NPCs/Providence/ProvSpawnDefense.cs @@ -10,28 +10,28 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Providence { - [AutoloadBossHead] - public class ProvSpawnDefense : ModNPC + [AutoloadBossHead] + public class ProvSpawnDefense : ModNPC { - private bool start = true; + private bool start = true; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Providence Defender"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 1f; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 1f; npc.aiStyle = -1; - npc.GetNPCDamage(); - npc.width = 100; + npc.GetNPCDamage(); + npc.width = 100; npc.height = 80; npc.defense = 50; - npc.DR_NERD(0.4f); + npc.DR_NERD(0.4f); npc.lifeMax = 18750; if (BossRushEvent.BossRushActive) { @@ -45,13 +45,13 @@ namespace CalamityMod.NPCs.Providence aiType = -1; npc.HitSound = SoundID.NPCHit52; npc.DeathSound = SoundID.NPCDeath55; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -61,108 +61,108 @@ namespace CalamityMod.NPCs.Providence public override void AI() { - // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - npc.damage = 0; + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + npc.damage = 0; - CalamityGlobalNPC.holyBossDefender = npc.whoAmI; + CalamityGlobalNPC.holyBossDefender = npc.whoAmI; - if (CalamityGlobalNPC.holyBoss < 0 || !Main.npc[CalamityGlobalNPC.holyBoss].active) + if (CalamityGlobalNPC.holyBoss < 0 || !Main.npc[CalamityGlobalNPC.holyBoss].active) { npc.active = false; npc.netUpdate = true; return; } - NPC parent = Main.npc[CalamityGlobalNPC.holyBoss]; - if (start) - { - for (int d = 0; d < 30; d++) - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); + NPC parent = Main.npc[CalamityGlobalNPC.holyBoss]; + if (start) + { + for (int d = 0; d < 30; d++) + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); - npc.ai[1] = npc.ai[0]; - start = false; - } + npc.ai[1] = npc.ai[0]; + start = false; + } - float playerLocation = npc.Center.X - Main.player[Main.npc[CalamityGlobalNPC.holyBoss].target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = npc.Center.X - Main.player[Main.npc[CalamityGlobalNPC.holyBoss].target].Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; - double deg = npc.ai[1]; - double rad = deg * (Math.PI / 180); - double dist = 400; - npc.position.X = parent.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; - npc.position.Y = parent.Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; - npc.ai[1] += 1f; - } + double deg = npc.ai[1]; + double rad = deg * (Math.PI / 180); + double dist = 400; + npc.position.X = parent.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; + npc.position.Y = parent.Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; + npc.ai[1] += 1f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss2Glow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss2Glow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int heartAmt = Main.rand.Next(3) + 3; + for (int i = 0; i < heartAmt; i++) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.ProfanedFire, hitDirection, -1f, 0, default, 1f); diff --git a/NPCs/Providence/ProvSpawnHealer.cs b/NPCs/Providence/ProvSpawnHealer.cs index 21bfe9ed13..4ab259ab37 100644 --- a/NPCs/Providence/ProvSpawnHealer.cs +++ b/NPCs/Providence/ProvSpawnHealer.cs @@ -10,17 +10,17 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Providence { - [AutoloadBossHead] - public class ProvSpawnHealer : ModNPC + [AutoloadBossHead] + public class ProvSpawnHealer : ModNPC { - private bool start = true; + private bool start = true; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Providence Healer"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.Providence npc.width = 100; npc.height = 80; npc.defense = 30; - npc.DR_NERD(0.2f); + npc.DR_NERD(0.2f); npc.lifeMax = 15000; if (BossRushEvent.BossRushActive) { @@ -44,13 +44,13 @@ namespace CalamityMod.NPCs.Providence aiType = -1; npc.HitSound = SoundID.NPCHit52; npc.DeathSound = SoundID.NPCDeath55; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -58,118 +58,118 @@ namespace CalamityMod.NPCs.Providence npc.frame.Y = frame * frameHeight; } - public override void AI() - { - // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - npc.damage = 0; + public override void AI() + { + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + npc.damage = 0; - CalamityGlobalNPC.holyBossHealer = npc.whoAmI; + CalamityGlobalNPC.holyBossHealer = npc.whoAmI; - if (CalamityGlobalNPC.holyBoss < 0 || !Main.npc[CalamityGlobalNPC.holyBoss].active) - { - npc.active = false; - npc.netUpdate = true; - return; - } + if (CalamityGlobalNPC.holyBoss < 0 || !Main.npc[CalamityGlobalNPC.holyBoss].active) + { + npc.active = false; + npc.netUpdate = true; + return; + } - NPC parent = Main.npc[CalamityGlobalNPC.holyBoss]; - if (start) - { - for (int d = 0; d < 30; d++) - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); + NPC parent = Main.npc[CalamityGlobalNPC.holyBoss]; + if (start) + { + for (int d = 0; d < 30; d++) + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); - npc.ai[1] = npc.ai[0]; - start = false; - } + npc.ai[1] = npc.ai[0]; + start = false; + } - float playerLocation = npc.Center.X - Main.player[Main.npc[CalamityGlobalNPC.holyBoss].target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = npc.Center.X - Main.player[Main.npc[CalamityGlobalNPC.holyBoss].target].Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; - double deg = npc.ai[1]; - double rad = deg * (Math.PI / 180); - double dist = 400; - npc.position.X = parent.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; - npc.position.Y = parent.Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; - npc.ai[1] += 1f; - } + double deg = npc.ai[1]; + double rad = deg * (Math.PI / 180); + double dist = 400; + npc.position.X = parent.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; + npc.position.Y = parent.Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; + npc.ai[1] += 1f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss3Glow2"); - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss3Glow2"); + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss3Glow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - Color color42 = Color.Lerp(Color.White, Color.Violet, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBoss3Glow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + Color color42 = Color.Lerp(Color.White, Color.Violet, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 = npc.GetAlpha(color43); - color43 *= (float)(num153 - num163) / 15f; - spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + Color color43 = color42; + color43 = Color.Lerp(color43, color36, amount9); + color43 = npc.GetAlpha(color43); + color43 *= (float)(num153 - num163) / 15f; + spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int heartAmt = Main.rand.Next(3) + 3; + for (int i = 0; i < heartAmt; i++) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } - public override bool CheckActive() => false; + public override bool CheckActive() => false; public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/Providence/ProvSpawnOffense.cs b/NPCs/Providence/ProvSpawnOffense.cs index b99d1d559e..a763c45727 100644 --- a/NPCs/Providence/ProvSpawnOffense.cs +++ b/NPCs/Providence/ProvSpawnOffense.cs @@ -10,28 +10,28 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Providence { - [AutoloadBossHead] - public class ProvSpawnOffense : ModNPC + [AutoloadBossHead] + public class ProvSpawnOffense : ModNPC { - private bool start = true; + private bool start = true; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Providence Offense"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 1f; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 1f; npc.aiStyle = -1; - npc.GetNPCDamage(); - npc.width = 100; + npc.GetNPCDamage(); + npc.width = 100; npc.height = 80; npc.defense = 40; - npc.DR_NERD(0.3f); + npc.DR_NERD(0.3f); npc.lifeMax = 31875; if (BossRushEvent.BossRushActive) { @@ -45,13 +45,13 @@ namespace CalamityMod.NPCs.Providence aiType = -1; npc.HitSound = SoundID.NPCHit52; npc.DeathSound = SoundID.NPCDeath55; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; @@ -61,10 +61,10 @@ namespace CalamityMod.NPCs.Providence public override void AI() { - // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - npc.damage = 0; + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + npc.damage = 0; - CalamityGlobalNPC.holyBossAttacker = npc.whoAmI; + CalamityGlobalNPC.holyBossAttacker = npc.whoAmI; if (CalamityGlobalNPC.holyBoss < 0 || !Main.npc[CalamityGlobalNPC.holyBoss].active) { @@ -73,98 +73,98 @@ namespace CalamityMod.NPCs.Providence return; } - NPC parent = Main.npc[CalamityGlobalNPC.holyBoss]; - if (start) - { - for (int d = 0; d < 30; d++) - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); + NPC parent = Main.npc[CalamityGlobalNPC.holyBoss]; + if (start) + { + for (int d = 0; d < 30; d++) + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); - npc.ai[1] = npc.ai[0]; - start = false; - } + npc.ai[1] = npc.ai[0]; + start = false; + } - float playerLocation = npc.Center.X - Main.player[Main.npc[CalamityGlobalNPC.holyBoss].target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = npc.Center.X - Main.player[Main.npc[CalamityGlobalNPC.holyBoss].target].Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; - double deg = npc.ai[1]; - double rad = deg * (Math.PI / 180); - double dist = 400; - npc.position.X = parent.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; - npc.position.Y = parent.Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; - npc.ai[1] += 1f; - } + double deg = npc.ai[1]; + double rad = deg * (Math.PI / 180); + double dist = 400; + npc.position.X = parent.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; + npc.position.Y = parent.Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; + npc.ai[1] += 1f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; - if (npc.ai[0] == 2f) - num153 = 10; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; + if (npc.ai[0] == 2f) + num153 = 10; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBossGlow"); - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianBossGlow"); + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int heartAmt = Main.rand.Next(3) + 3; + for (int i = 0; i < heartAmt; i++) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.ProfanedFire, hitDirection, -1f, 0, default, 1f); diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 877b2bc5df..8b1b57f177 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -36,29 +36,29 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Providence { - [AutoloadBossHead] - public class Providence : ModNPC - { - private enum Phase - { - PhaseChange = -1, - HolyBlast = 0, - HolyFire = 1, - FlameCocoon = 2, - MoltenBlobs = 3, - HolyBomb = 4, - SpearCocoon = 5, - Crystal = 6, - Laser = 7 - } + [AutoloadBossHead] + public class Providence : ModNPC + { + private enum Phase + { + PhaseChange = -1, + HolyBlast = 0, + HolyFire = 1, + FlameCocoon = 2, + MoltenBlobs = 3, + HolyBomb = 4, + SpearCocoon = 5, + Crystal = 6, + Laser = 7 + } - private float AIState - { - get => npc.ai[0]; - set => npc.ai[0] = value; - } + private float AIState + { + get => npc.ai[0]; + set => npc.ai[0] = value; + } - private bool text = false; + private bool text = false; private bool useDefenseFrames = false; private float bossLife; private int biomeType = 0; @@ -68,19 +68,19 @@ namespace CalamityMod.NPCs.Providence private int frameUsed = 0; private int healTimer = 0; internal bool challenge = Main.expertMode/* && Main.netMode == NetmodeID.SinglePlayer*/; //Used to determine if Profaned Soul Crystal should drop, couldn't figure out mp mems always dropping it so challenge is singleplayer only. - internal bool hasTakenDaytimeDamage = false; - public bool Dying = false; - public int DeathAnimationTimer; + internal bool hasTakenDaytimeDamage = false; + public bool Dying = false; + public int DeathAnimationTimer; - public static float normalDR = 0.3f; + public static float normalDR = 0.3f; public static float cocoonDR = 0.9f; public override void SetStaticDefaults() { DisplayName.SetDefault("Providence, the Profaned Goddess"); Main.npcFrameCount[npc.type] = 3; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -89,7 +89,7 @@ namespace CalamityMod.NPCs.Providence npc.width = 600; npc.height = 450; npc.defense = 50; - npc.DR_NERD(normalDR); + npc.DR_NERD(normalDR); npc.LifeMaxNERB(312500, 375000, 1250000); // Old HP - 440000, 500000 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -98,18 +98,18 @@ namespace CalamityMod.NPCs.Providence aiType = -1; npc.value = Item.buyPrice(3, 0, 0, 0); npc.boss = true; - npc.Opacity = 0f; + npc.Opacity = 0f; npc.noGravity = true; npc.noTileCollide = true; npc.netAlways = true; - music = CalamityMod.Instance.GetMusicFromMusicMod("Providence") ?? MusicID.LunarBoss; + music = CalamityMod.Instance.GetMusicFromMusicMod("Providence") ?? MusicID.LunarBoss; npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/ProvidenceDeath"); bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -124,40 +124,40 @@ namespace CalamityMod.NPCs.Providence writer.Write(npc.dontTakeDamage); writer.Write(npc.chaseable); writer.Write(npc.canGhostHeal); - writer.Write(npc.localAI[2]); - writer.Write(Dying); - writer.Write(DeathAnimationTimer); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); + writer.Write(npc.localAI[2]); + writer.Write(Dying); + writer.Write(DeathAnimationTimer); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); } public override void ReceiveExtraAI(BinaryReader reader) { - bool wasDyingBefore = Dying; + bool wasDyingBefore = Dying; text = reader.ReadBoolean(); useDefenseFrames = reader.ReadBoolean(); biomeType = reader.ReadInt32(); phaseChange = reader.ReadInt32(); - biomeEnrageTimer = reader.ReadInt32(); + biomeEnrageTimer = reader.ReadInt32(); frameUsed = reader.ReadInt32(); healTimer = reader.ReadInt32(); flightPath = reader.ReadInt32(); npc.dontTakeDamage = reader.ReadBoolean(); npc.chaseable = reader.ReadBoolean(); npc.canGhostHeal = reader.ReadBoolean(); - npc.localAI[2] = reader.ReadSingle(); - Dying = reader.ReadBoolean(); - DeathAnimationTimer = reader.ReadInt32(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + Dying = reader.ReadBoolean(); + DeathAnimationTimer = reader.ReadInt32(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); - // Be sure to inform clients of the fact that Providence is dying if only the server recieved this packet. - if (Main.netMode == NetmodeID.Server && !wasDyingBefore && Dying) - { - npc.netSpam = 0; - npc.netUpdate = true; - } - } + // Be sure to inform clients of the fact that Providence is dying if only the server recieved this packet. + if (Main.netMode == NetmodeID.Server && !wasDyingBefore && Dying) + { + npc.netSpam = 0; + npc.netUpdate = true; + } + } public override void AI() { @@ -169,142 +169,142 @@ namespace CalamityMod.NPCs.Providence // Rotation npc.rotation = npc.velocity.X * 0.004f; - Vector2 vector = npc.Center; + Vector2 vector = npc.Center; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - // Target variable and boss center - Player player = Main.player[npc.target]; + // Target variable and boss center + Player player = Main.player[npc.target]; - // Night bool - bool malice = CalamityWorld.malice; - bool nightTime = !Main.dayTime || malice; + // Night bool + bool malice = CalamityWorld.malice; + bool nightTime = !Main.dayTime || malice; - // Difficulty bools - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || nightTime; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || nightTime; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || nightTime; + // Difficulty bools + bool death = CalamityWorld.death || BossRushEvent.BossRushActive || nightTime; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || nightTime; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || nightTime; - // Target's current biome - bool isHoly = player.ZoneHoly; + // Target's current biome + bool isHoly = player.ZoneHoly; bool isHell = player.ZoneUnderworldHeight; // Fire projectiles at normal rate or not bool normalAttackRate = true; - // Is in spawning animation - float spawnAnimationTime = 180f; - bool spawnAnimation = calamityGlobalNPC.newAI[3] < spawnAnimationTime; + // Is in spawning animation + float spawnAnimationTime = 180f; + bool spawnAnimation = calamityGlobalNPC.newAI[3] < spawnAnimationTime; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Play enrage animation if night starts - if (nightTime && calamityGlobalNPC.newAI[3] == spawnAnimationTime) - { - AIState = (int)Phase.HolyBlast; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.netUpdate = true; - } - - // Increase all projectile damage at night - int projectileDamageMult = 1; - if (nightTime) - projectileDamageMult = 2; - - npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && (nightTime || malice)) || biomeEnrageTimer <= 0; - - // Projectile damage values - int holyLaserDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int crystalDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int holySpearDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int holyBombDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int moltenBlastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int holyFireDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int holyBlastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int holyStarDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - - // Change dust type at night - int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; - - // Phase times - float phaseTime = nightTime ? (240f - 60f * (1f - lifeRatio)) : 300f; - float crystalPhaseTime = nightTime ? (float)Math.Round(60f * lifeRatio) : death ? 60f : 120f; - int nightCrystalTime = 210; - float attackDelayAfterCocoon = phaseTime * 0.3f; - - // Phases - bool ignoreGuardianAmt = lifeRatio < (death ? 0.2f : 0.15f); - bool phase2 = lifeRatio < 0.75f && !nightTime; - bool delayAttacks = npc.localAI[2] > 0f; - - // Spear phase - float spearRateIncrease = 1f - lifeRatio; - float bossRushSpearRateIncrease = 0.25f; - float baseSpearRate = 18f; - float spearRate = 1f + spearRateIncrease; - - if (BossRushEvent.BossRushActive) - spearRate += bossRushSpearRateIncrease; - - // Projectile fire rate multiplier - double attackRateMult = 1D; - - // Where projectiles are fired from during cocoon phases - Vector2 fireFrom = new Vector2(vector.X, vector.Y + 20f); - - // Cocoon projectile initial velocity - float cocoonProjVelocity = 3f + (death ? 2f * (1f - lifeRatio) : 0f); - - // Distance X needed from target in order to fire holy or molten blasts - float distanceNeededToShoot = death ? 300f : revenge ? 360f : 420f; - - // X distance from target - float distanceX = Math.Abs(vector.X - player.Center.X); - - // Inflict Holy Inferno if target is too far away - float baseDistance = 2800f; - float shorterFlameCocoonDistance = (CalamityWorld.death || BossRushEvent.BossRushActive || nightTime) ? 2200f : CalamityWorld.revenge ? 2400f : Main.expertMode ? 2600f : baseDistance; - float shorterSpearCocoonDistance = (CalamityWorld.death || BossRushEvent.BossRushActive || nightTime) ? 1800f : CalamityWorld.revenge ? 2150f : Main.expertMode ? 2500f : baseDistance; - float shorterDistance = AIState == (int)Phase.FlameCocoon ? shorterFlameCocoonDistance : shorterSpearCocoonDistance; - float maxDistance = (AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon) ? shorterDistance : baseDistance; - if (Vector2.Distance(player.Center, vector) > maxDistance) + // Play enrage animation if night starts + if (nightTime && calamityGlobalNPC.newAI[3] == spawnAnimationTime) { - if (!player.dead && player.active) - player.AddBuff(ModContent.BuffType(), 2); - } + AIState = (int)Phase.HolyBlast; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.netUpdate = true; + } - // Count the remaining Guardians, healer especially because it allows the boss to heal - int guardianAmt = 0; - bool attackerAlive = false; - bool defenderAlive = false; + // Increase all projectile damage at night + int projectileDamageMult = 1; + if (nightTime) + projectileDamageMult = 2; + + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && (nightTime || malice)) || biomeEnrageTimer <= 0; + + // Projectile damage values + int holyLaserDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; + int crystalDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; + int holySpearDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; + int holyBombDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; + int moltenBlastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; + int holyFireDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; + int holyBlastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; + int holyStarDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; + + // Change dust type at night + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + + // Phase times + float phaseTime = nightTime ? (240f - 60f * (1f - lifeRatio)) : 300f; + float crystalPhaseTime = nightTime ? (float)Math.Round(60f * lifeRatio) : death ? 60f : 120f; + int nightCrystalTime = 210; + float attackDelayAfterCocoon = phaseTime * 0.3f; + + // Phases + bool ignoreGuardianAmt = lifeRatio < (death ? 0.2f : 0.15f); + bool phase2 = lifeRatio < 0.75f && !nightTime; + bool delayAttacks = npc.localAI[2] > 0f; + + // Spear phase + float spearRateIncrease = 1f - lifeRatio; + float bossRushSpearRateIncrease = 0.25f; + float baseSpearRate = 18f; + float spearRate = 1f + spearRateIncrease; + + if (BossRushEvent.BossRushActive) + spearRate += bossRushSpearRateIncrease; + + // Projectile fire rate multiplier + double attackRateMult = 1D; + + // Where projectiles are fired from during cocoon phases + Vector2 fireFrom = new Vector2(vector.X, vector.Y + 20f); + + // Cocoon projectile initial velocity + float cocoonProjVelocity = 3f + (death ? 2f * (1f - lifeRatio) : 0f); + + // Distance X needed from target in order to fire holy or molten blasts + float distanceNeededToShoot = death ? 300f : revenge ? 360f : 420f; + + // X distance from target + float distanceX = Math.Abs(vector.X - player.Center.X); + + // Inflict Holy Inferno if target is too far away + float baseDistance = 2800f; + float shorterFlameCocoonDistance = (CalamityWorld.death || BossRushEvent.BossRushActive || nightTime) ? 2200f : CalamityWorld.revenge ? 2400f : Main.expertMode ? 2600f : baseDistance; + float shorterSpearCocoonDistance = (CalamityWorld.death || BossRushEvent.BossRushActive || nightTime) ? 1800f : CalamityWorld.revenge ? 2150f : Main.expertMode ? 2500f : baseDistance; + float shorterDistance = AIState == (int)Phase.FlameCocoon ? shorterFlameCocoonDistance : shorterSpearCocoonDistance; + float maxDistance = (AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon) ? shorterDistance : baseDistance; + if (Vector2.Distance(player.Center, vector) > maxDistance) + { + if (!player.dead && player.active) + player.AddBuff(ModContent.BuffType(), 2); + } + + // Count the remaining Guardians, healer especially because it allows the boss to heal + int guardianAmt = 0; + bool attackerAlive = false; + bool defenderAlive = false; bool healerAlive = false; if (CalamityGlobalNPC.holyBossAttacker != -1) { - if (Main.npc[CalamityGlobalNPC.holyBossAttacker].active) - { - guardianAmt++; - attackerAlive = true; - } + if (Main.npc[CalamityGlobalNPC.holyBossAttacker].active) + { + guardianAmt++; + attackerAlive = true; + } } if (CalamityGlobalNPC.holyBossDefender != -1) { - if (Main.npc[CalamityGlobalNPC.holyBossDefender].active) - { - guardianAmt++; - defenderAlive = true; - } + if (Main.npc[CalamityGlobalNPC.holyBossDefender].active) + { + guardianAmt++; + defenderAlive = true; + } } if (CalamityGlobalNPC.holyBossHealer != -1) { @@ -358,41 +358,41 @@ namespace CalamityMod.NPCs.Providence if (!isHoly && !isHell && !BossRushEvent.BossRushActive) { if (biomeEnrageTimer > 0) - biomeEnrageTimer--; + biomeEnrageTimer--; } else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - // Take damage or not - bool biomeEnraged = biomeEnrageTimer <= 0 || malice; - npc.dontTakeDamage = Dying; + // Take damage or not + bool biomeEnraged = biomeEnrageTimer <= 0 || malice; + npc.dontTakeDamage = Dying; - // Do the death animation once killed. - if (Dying) + // Do the death animation once killed. + if (Dying) { - DoDeathAnimation(); - return; + DoDeathAnimation(); + return; } - // Damage - if (attackerAlive) - { - double damageMult = 1.25; - holyLaserDamage = (int)(holyLaserDamage * damageMult); - crystalDamage = (int)(crystalDamage * damageMult); - holySpearDamage = (int)(holySpearDamage * damageMult); - holyBombDamage = (int)(holyBombDamage * damageMult); - moltenBlastDamage = (int)(moltenBlastDamage * damageMult); - holyFireDamage = (int)(holyFireDamage * damageMult); - holyBlastDamage = (int)(holyBlastDamage * damageMult); - holyStarDamage = (int)(holyStarDamage * damageMult); - } + // Damage + if (attackerAlive) + { + double damageMult = 1.25; + holyLaserDamage = (int)(holyLaserDamage * damageMult); + crystalDamage = (int)(crystalDamage * damageMult); + holySpearDamage = (int)(holySpearDamage * damageMult); + holyBombDamage = (int)(holyBombDamage * damageMult); + moltenBlastDamage = (int)(moltenBlastDamage * damageMult); + holyFireDamage = (int)(holyFireDamage * damageMult); + holyBlastDamage = (int)(holyBlastDamage * damageMult); + holyStarDamage = (int)(holyStarDamage * damageMult); + } - // Defense - if (defenderAlive) - npc.defense = npc.defDefense * 2; - else - npc.defense = npc.defDefense; + // Defense + if (defenderAlive) + npc.defense = npc.defDefense * 2; + else + npc.defense = npc.defDefense; // Healing if (healerAlive) @@ -418,71 +418,71 @@ namespace CalamityMod.NPCs.Providence } } - // Despawn - bool targetDead = false; + // Despawn + bool targetDead = false; if (!player.active || player.dead) { - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - } - if (!player.active || player.dead) - { - targetDead = true; + if (!player.active || player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + } + if (!player.active || player.dead) + { + targetDead = true; - if (npc.timeLeft > 60) - npc.timeLeft = 60; + if (npc.timeLeft > 60) + npc.timeLeft = 60; - if (npc.velocity.X > 0f) - npc.velocity.X += 0.2f; - else - npc.velocity.X -= 0.2f; + if (npc.velocity.X > 0f) + npc.velocity.X += 0.2f; + else + npc.velocity.X -= 0.2f; - npc.velocity.Y -= 0.2f; - } + npc.velocity.Y -= 0.2f; + } } else if (npc.timeLeft < 1800) npc.timeLeft = 1800; - // Guardian spawn - if (!nightTime) - { - if (bossLife == 0f && npc.life > 0) - bossLife = npc.lifeMax; + // Guardian spawn + if (!nightTime) + { + if (bossLife == 0f && npc.life > 0) + bossLife = npc.lifeMax; - if (npc.life > 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num660 = (int)(npc.lifeMax * 0.66); - if ((npc.life + num660) < bossLife) - { - bossLife = npc.life; - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 74); - int guardianRingAmt = 3; - int guardianSpread = 360 / guardianRingAmt; - int guardianDistance = 400; - for (int i = 0; i < guardianRingAmt; i++) - { - int type = i == 0 ? ModContent.NPCType() : i == 1 ? ModContent.NPCType() : ModContent.NPCType(); - int spawn = NPC.NewNPC((int)(npc.Center.X + (Math.Sin(i * guardianSpread) * guardianDistance)), (int)(npc.Center.Y + (Math.Cos(i * guardianSpread) * guardianDistance)), type, npc.whoAmI, 0, 0, 0, -1); - Main.npc[spawn].ai[0] = i * guardianSpread; - } - } - } - } - } + if (npc.life > 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int num660 = (int)(npc.lifeMax * 0.66); + if ((npc.life + num660) < bossLife) + { + bossLife = npc.life; + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 74); + int guardianRingAmt = 3; + int guardianSpread = 360 / guardianRingAmt; + int guardianDistance = 400; + for (int i = 0; i < guardianRingAmt; i++) + { + int type = i == 0 ? ModContent.NPCType() : i == 1 ? ModContent.NPCType() : ModContent.NPCType(); + int spawn = NPC.NewNPC((int)(npc.Center.X + (Math.Sin(i * guardianSpread) * guardianDistance)), (int)(npc.Center.Y + (Math.Cos(i * guardianSpread) * guardianDistance)), type, npc.whoAmI, 0, 0, 0, -1); + Main.npc[spawn].ai[0] = i * guardianSpread; + } + } + } + } + } // Set DR based on current attack phase npc.Calamity().DR = (AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon || AIState == (int)Phase.Laser || spawnAnimation) ? - cocoonDR : delayAttacks ? - MathHelper.Lerp(normalDR, cocoonDR, npc.localAI[2] / attackDelayAfterCocoon) : normalDR; + cocoonDR : delayAttacks ? + MathHelper.Lerp(normalDR, cocoonDR, npc.localAI[2] / attackDelayAfterCocoon) : normalDR; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon || AIState == (int)Phase.Laser || spawnAnimation; + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon || AIState == (int)Phase.Laser || spawnAnimation; - // Movement - if (AIState != (int)Phase.FlameCocoon && AIState != (int)Phase.SpearCocoon) + // Movement + if (AIState != (int)Phase.FlameCocoon && AIState != (int)Phase.SpearCocoon) { // Firing holy ray or not bool firingLaser = AIState == (int)Phase.Laser; @@ -520,11 +520,11 @@ namespace CalamityMod.NPCs.Providence if (vector.X > player.Center.X && flightPath > 0 && distanceX > num851) flightPath = 0; - // Velocity and acceleration - float speedIncreaseTimer = nightTime ? 75f : death ? 120f : 150f; + // Velocity and acceleration + float speedIncreaseTimer = nightTime ? 75f : death ? 120f : 150f; bool increaseSpeed = calamityGlobalNPC.newAI[0] > speedIncreaseTimer || biomeEnraged; - float accelerationBoost = death ? 0.3f * (1f - lifeRatio) : 0.2f * (1f - lifeRatio); - float velocityBoost = death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); + float accelerationBoost = death ? 0.3f * (1f - lifeRatio) : 0.2f * (1f - lifeRatio); + float velocityBoost = death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); float acceleration = (expertMode ? 1.1f : 1.05f) + accelerationBoost; float velocity = (expertMode ? 16f : 15f) + velocityBoost; if (BossRushEvent.BossRushActive || nightTime) @@ -542,924 +542,924 @@ namespace CalamityMod.NPCs.Providence velocity += (calamityGlobalNPC.newAI[0] - speedIncreaseTimer) * 0.04f; if (velocity > 30f || biomeEnraged) velocity = 30f; - if (biomeEnraged) - acceleration = 2f; + if (biomeEnraged) + acceleration = 2f; } - if (!targetDead) - { - 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 + npc.height); - if (num855 < (firingLaser ? 150f : 200f)) // 150 - npc.velocity.Y -= 0.2f; - if (num855 > (firingLaser ? 200f : 250f)) // 200 - npc.velocity.Y += 0.2f; - - float speedVariance = 2f; - if (npc.velocity.Y > (firingLaser ? speedVariance : 6f)) - npc.velocity.Y = firingLaser ? speedVariance : 6f; - if (npc.velocity.Y < (firingLaser ? -speedVariance : -6f)) - npc.velocity.Y = firingLaser ? -speedVariance : -6f; - } - - // Slowly drift down when spawning - if (spawnAnimation) - { - float minSpawnVelocity = 0.4f; - float maxSpawnVelocity = 4f; - float velocityY = maxSpawnVelocity - MathHelper.Lerp(minSpawnVelocity, maxSpawnVelocity, calamityGlobalNPC.newAI[3] / spawnAnimationTime); - npc.velocity = new Vector2(0f, velocityY); - } - } - - // Phase switch - switch ((int)AIState) - { - case (int)Phase.PhaseChange: - - phaseChange++; - if (phaseChange > 14) - phaseChange = 0; - - int phase = 0; - - // Holy ray in hallow, Crystal in hell - bool useLaser = (phase2 && biomeType == 1) || BossRushEvent.BossRushActive; - bool useCrystal = (phase2 && biomeType == 2) || BossRushEvent.BossRushActive; - - // Unique pattern for Death Mode and Boss Rush - if (death) - { - switch (phaseChange) - { - case 0: - phase = (int)Phase.MoltenBlobs; - break; - case 1: - phase = (int)Phase.SpearCocoon; - break; - case 2: - phase = (int)Phase.HolyBlast; - break; - case 3: - phase = (useCrystal || nightTime) ? (int)Phase.Crystal : (int)Phase.MoltenBlobs; - break; - case 4: - phase = useCrystal ? (int)Phase.MoltenBlobs : (int)Phase.FlameCocoon; - break; - case 5: - phase = useCrystal ? (int)Phase.FlameCocoon : (int)Phase.HolyFire; - break; - case 6: - phase = (useLaser || nightTime) ? (int)Phase.Laser : (int)Phase.HolyBomb; - break; - case 7: - phase = (useLaser || nightTime) ? (int)Phase.HolyBomb : (int)Phase.MoltenBlobs; - break; - case 8: - phase = (useLaser || nightTime) ? (int)Phase.MoltenBlobs : (int)Phase.SpearCocoon; - break; - case 9: - phase = (int)Phase.HolyBlast; - break; - case 10: - phase = (useCrystal || nightTime) ? (int)Phase.Crystal : (int)Phase.FlameCocoon; - break; - case 11: - phase = nightTime ? (int)Phase.FlameCocoon : (int)Phase.MoltenBlobs; - break; - case 12: - phase = (useLaser || nightTime) ? (int)Phase.Laser : (int)Phase.HolyBomb; - break; - case 13: - phase = (int)Phase.SpearCocoon; - break; - case 14: - phase = (useLaser || nightTime) ? (int)Phase.HolyBomb : (int)Phase.HolyBlast; - break; - default: - break; - } - } - else - { - switch (phaseChange) - { - case 0: - phase = (int)Phase.HolyBlast; - break; - case 1: - phase = useLaser ? (int)Phase.Laser : (int)Phase.HolyFire; - break; - case 2: - phase = (int)Phase.HolyBomb; - break; - case 3: - phase = (int)Phase.MoltenBlobs; - break; - case 4: - phase = (int)Phase.SpearCocoon; - break; - case 5: - phase = useCrystal ? (int)Phase.Crystal : (int)Phase.HolyBomb; - break; - case 6: - phase = (int)Phase.HolyFire; - break; - case 7: - phase = (int)Phase.HolyBlast; - break; - case 8: - phase = (int)Phase.MoltenBlobs; - break; - case 9: - phase = (int)Phase.FlameCocoon; - break; - case 10: - phase = (int)Phase.HolyBomb; - break; - case 11: - phase = useLaser ? (int)Phase.Laser : (int)Phase.HolyBlast; - break; - case 12: - phase = (int)Phase.HolyFire; - break; - case 13: - phase = (int)Phase.MoltenBlobs; - break; - case 14: - phase = (int)Phase.SpearCocoon; - break; - default: - break; - } - } - - // If too far from target, set phase to 0 - if (Math.Abs(vector.X - player.Center.X) > 5600f) - phase = (int)Phase.HolyBlast; - - // Reset attack delay for laser - if (phase == (int)Phase.Laser) - npc.localAI[2] = 0f; - - // Reset arrays - AIState = phase; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.netUpdate = true; - break; - - case (int)Phase.HolyBlast: - - if (spawnAnimation) - { - if (Main.netMode != NetmodeID.MultiplayerClient && calamityGlobalNPC.newAI[3] == 0f) - Projectile.NewProjectile(vector + new Vector2(0f, -80f), Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, biomeType, 0f); - - if (calamityGlobalNPC.newAI[3] == 10f && nightTime) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceHolyRay"), (int)npc.position.X, (int)npc.position.Y); - - if (calamityGlobalNPC.newAI[3] > 10f && calamityGlobalNPC.newAI[3] < 150f) - { - int dustAmt = (int)MathHelper.Lerp(4f, 8f, calamityGlobalNPC.newAI[3] / spawnAnimationTime); - for (int m = 0; m < dustAmt; m++) - { - float fade = MathHelper.Lerp(1.3f, 0.7f, npc.Opacity) * Utils.InverseLerp(0f, 120f, calamityGlobalNPC.newAI[3], clamped: true); - Color newColor = Main.hslToRgb(calamityGlobalNPC.newAI[3] / 180f, 1f, 0.5f); - - if (!nightTime) - { - newColor.R = 255; - if (biomeType == 2) - newColor.B = 0; - } - else - { - newColor.B = 255; - if (biomeType == 2) - newColor.G = 0; - else - newColor.R = 0; - } - - int dust = Dust.NewDust(npc.position, npc.width, npc.height, 267, 0f, 0f, 0, newColor); - Main.dust[dust].position = npc.Center + Main.rand.NextVector2Circular(npc.width * 2f, npc.height * 2f) + new Vector2(0f, -150f); - Main.dust[dust].velocity *= Main.rand.NextFloat() * 0.8f; - Main.dust[dust].noGravity = true; - Main.dust[dust].fadeIn = 0.6f + Main.rand.NextFloat() * 0.7f * fade; - Main.dust[dust].velocity += Vector2.UnitY * 3f; - Main.dust[dust].scale = 1.2f; - - if (dust != 6000) - { - Dust dust2 = Dust.CloneDust(dust); - dust2.scale /= 2f; - dust2.fadeIn *= 0.85f; - dust2.color = new Color(255, 255, 0, 255); - } - } - } - - npc.Opacity = MathHelper.Clamp(calamityGlobalNPC.newAI[3] / spawnAnimationTime, 0f, 1f); - - calamityGlobalNPC.newAI[3] += 1f; - - if (nightTime && calamityGlobalNPC.newAI[3] >= spawnAnimationTime) - calamityGlobalNPC.newAI[3] += 1f; - - return; - } - - // Attack delay after cocoon phase - if (delayAttacks) - { - npc.localAI[2] -= 1f; - return; - } - - if (distanceX > distanceNeededToShoot && npc.position.Y < player.position.Y) - { - npc.ai[3] += 1f; - - int shootBoost = death ? (int)Math.Round(5f * (1f - lifeRatio)) : (int)Math.Round(4f * (1f - lifeRatio)); - int num856 = (biomeEnraged ? 18 : expertMode ? 24 : 26) - shootBoost; - - num856 = (int)(num856 * attackRateMult); - - 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 + player.width * 0.5f - vector.X; - float num858 = player.Center.Y - vector.Y; - float num859 = (float)Math.Sqrt(num857 * num857 + num858 * num858); - - float velocityBoost = death ? 4f * (1f - lifeRatio) : 2.5f * (1f - lifeRatio); - float num860 = (expertMode ? 10.25f : 9f) + velocityBoost; - - if (revenge) - num860 *= 1.15f; - - num859 = num860 / num859; - num857 *= num859; - num858 *= num859; - - Projectile.NewProjectile(vector.X, vector.Y, num857, num858, ModContent.ProjectileType(), holyBlastDamage, 0f, Main.myPlayer, 0f, 0f); - } - } - else if (npc.ai[3] < 0f) - npc.ai[3] += 1f; - - npc.ai[1] += 1f; - if (npc.ai[1] >= phaseTime) - { - AIState = (int)Phase.PhaseChange; - npc.TargetClosest(); - } - - break; - - case (int)Phase.HolyFire: - - // Attack delay after cocoon phase - if (delayAttacks) - { - npc.localAI[2] -= 1f; - return; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[3] += 1f; - - int shootBoost = death ? (int)Math.Round(6f * (1f - lifeRatio)) : (int)Math.Round(5f * (1f - lifeRatio)); - int num864 = (expertMode ? 36 : 39) - shootBoost; - if (BossRushEvent.BossRushActive || biomeEnraged) - num864 = 27; - - num864 = (int)(num864 * attackRateMult); - - if (npc.ai[3] >= num864) - { - npc.ai[3] = 0f; - - Vector2 vector113 = new Vector2(vector.X, npc.position.Y + npc.height - 14f); - - float num865 = npc.velocity.Y; - if (num865 < 0f) - num865 = 0f; - - num865 += expertMode ? 4f : 3f; - - if (nightTime) - num865 *= 2f; - - Projectile.NewProjectile(vector113.X, vector113.Y, npc.velocity.X * 0.25f, num865, ModContent.ProjectileType(), holyFireDamage, 0f, Main.myPlayer, 0f, 0f); - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= phaseTime) - { - AIState = (int)Phase.PhaseChange; - npc.TargetClosest(); - } - - break; - - case (int)Phase.FlameCocoon: - - if (!targetDead) - { - if (npc.velocity.Length() <= 2f) - npc.velocity = Vector2.Zero; - if (npc.velocity.Length() > 2f) - { - npc.velocity *= 0.9f; - return; - } - } - - float divisor = (expertMode ? 2f : 3f) + (float)Math.Floor(3f * lifeRatio) + (attackRateMult > 1D ? (float)Math.Ceiling(attackRateMult * 1.6) : 0f); - int totalFlameProjectiles = biomeEnraged ? 45 : 36; - int chains = 4; - float interval = totalFlameProjectiles / chains * divisor; - double patternInterval = Math.Floor(npc.ai[3] / interval); - int healingStarChance = revenge ? 8 : expertMode ? 6 : 4; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (patternInterval % 2 == 0) - { - if (npc.ai[3] % divisor == 0f) - { - Main.PlaySound(SoundID.Item20, npc.Center); - bool normalSpread = calamityGlobalNPC.newAI[1] % 2f == 0f; - double radians = MathHelper.TwoPi / chains; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(cocoonProjVelocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalSpread ? new Vector2(0f, -cocoonProjVelocity) : new Vector2(-velocityX, -cocoonProjVelocity); - for (int i = 0; i < chains; i++) - { - Vector2 vector2 = spinningPoint.RotatedBy(radians * i + MathHelper.ToRadians(npc.ai[2])); - - int projectileType = ModContent.ProjectileType(); - int dmgAmt = holyStarDamage; - if (Main.rand.NextBool(healingStarChance) && !death) - { - projectileType = ModContent.ProjectileType(); - dmgAmt = npc.GetProjectileDamageNoScaling(projectileType); - Projectile.NewProjectile(fireFrom, vector2, projectileType, 0, 0f, Main.myPlayer, 0f, dmgAmt); - } - else - Projectile.NewProjectile(fireFrom, vector2, projectileType, dmgAmt, 0f, Main.myPlayer); - } - - // Radial offset - npc.ai[2] += 10f; - } - npc.netUpdate = true; - } - else - { - npc.ai[2] = 0f; - - totalFlameProjectiles = biomeEnraged ? 20 : 16; - if (npc.ai[3] % (divisor * totalFlameProjectiles) == 0f) - { - calamityGlobalNPC.newAI[1] += 1f; - double radians = MathHelper.TwoPi / totalFlameProjectiles; - Main.PlaySound(SoundID.Item20, npc.position); - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(cocoonProjVelocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = npc.ai[3] % (divisor * totalFlameProjectiles * 2f) == 0f ? new Vector2(-velocityX, -cocoonProjVelocity) : new Vector2(0f, -cocoonProjVelocity); - for (int i = 0; i < totalFlameProjectiles; i++) - { - Vector2 vector2 = spinningPoint.RotatedBy(radians * i); - - int projectileType = ModContent.ProjectileType(); - int dmgAmt = holyStarDamage; - if (Main.rand.NextBool(healingStarChance) && !death) - { - projectileType = ModContent.ProjectileType(); - dmgAmt = npc.GetProjectileDamageNoScaling(projectileType); - Projectile.NewProjectile(fireFrom, vector2, projectileType, 0, 0f, Main.myPlayer, 0f, dmgAmt); - } - else - Projectile.NewProjectile(fireFrom, vector2, projectileType, dmgAmt, 0f, Main.myPlayer); - } - } - } - - // Fire a flame towards every player, with a limit of 5 - if (npc.ai[3] % 60f == 0f && expertMode) - { - List targets = new List(); - for (int p = 0; p < Main.maxPlayers; p++) - { - if (Main.player[p].active && !Main.player[p].dead) - targets.Add(p); - - if (targets.Count > 4) - break; - } - foreach (int t in targets) - { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - fireFrom) * cocoonProjVelocity * 1.5f; - int type = ModContent.ProjectileType(); - Projectile.NewProjectile(fireFrom, velocity2, type, holyStarDamage, 0f, Main.myPlayer); - } - } - } - - if (npc.ai[3] == 0f) - DespawnSpecificProjectiles(); - - // Air is burning text - npc.ai[3] += 1f; - if (npc.ai[3] >= (phaseTime * 1.5f) && !text) - { - text = true; - string key = "Mods.CalamityMod.ProfanedBossText"; - Color messageColor = Color.Orange; - - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - - // Inflict Icarus Folly - if (npc.ai[3] >= (phaseTime * 2f)) - { - if (Main.netMode != NetmodeID.Server) - { - Player player2 = Main.player[Main.myPlayer]; - bool inLiquid = (player2.wet || player2.honeyWet) && !player2.lavaWet; - - if (!player2.dead && player2.active && Vector2.Distance(player2.Center, vector) < 2800f && !inLiquid) - { - Main.PlaySound(SoundID.Item20, player2.position); - player2.AddBuff(ModContent.BuffType(), 3000, true); - - for (int num621 = 0; num621 < 40; num621++) - { - int num622 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), - player2.width, player2.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - for (int num623 = 0; num623 < 60; num623++) - { - int num624 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), - player2.width, player2.height, dustType, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), - player2.width, player2.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - - text = false; - AIState = (int)Phase.PhaseChange; - npc.localAI[2] = attackDelayAfterCocoon; - npc.TargetClosest(); - } - - break; - - case (int)Phase.MoltenBlobs: - - // Attack delay after cocoon phase - if (delayAttacks) - { - npc.localAI[2] -= 1f; - return; - } - - if (distanceX > distanceNeededToShoot && npc.position.Y < player.position.Y) - { - npc.ai[3] += 1f; - - int shootBoost = death ? (int)Math.Round(5f * (1f - lifeRatio)) : (int)Math.Round(4f * (1f - lifeRatio)); - int num856 = (expertMode ? 24 : 26) - shootBoost; - if (BossRushEvent.BossRushActive || biomeEnraged) - num856 = 18; - - num856 = (int)(num856 * attackRateMult); - - 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 + player.width * 0.5f - vector.X; - float num858 = player.Center.Y - vector.Y; - float num859 = (float)Math.Sqrt(num857 * num857 + num858 * num858); - - float shootBoost2 = death ? 4f * (1f - lifeRatio) : 2.5f * (1f - lifeRatio); - float num860 = (expertMode ? 10.25f : 9f) + shootBoost2; - if (BossRushEvent.BossRushActive) - num860 = 12.75f; - - if (revenge) - num860 *= 1.15f; - - num859 = num860 / num859; - num857 *= num859; - num858 *= num859; - - Projectile.NewProjectile(vector.X, vector.Y, num857 * 0.1f, num858, ModContent.ProjectileType(), moltenBlastDamage, 0f, Main.myPlayer, 0f, 0f); - } - } - else if (npc.ai[3] < 0f) - npc.ai[3] += 1f; - - npc.ai[1] += 1f; - if (npc.ai[1] >= phaseTime) - { - AIState = (int)Phase.PhaseChange; - npc.TargetClosest(); - } - - break; - - case (int)Phase.HolyBomb: - - // Attack delay after cocoon phase - if (delayAttacks) - { - npc.localAI[2] -= 1f; - return; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[3] += 1f; - - int shootBoost = death ? (int)Math.Round(12f * (1f - lifeRatio)) : (int)Math.Round(10f * (1f - lifeRatio)); - int num864 = (biomeEnraged ? 54 : expertMode ? 73 : 77) - shootBoost; - - num864 = (int)(num864 * attackRateMult); - - if (npc.ai[3] >= num864) - { - npc.ai[3] = 0f; - - Vector2 vector113 = new Vector2(vector.X, npc.position.Y + npc.height - 14f); - - float num865 = npc.velocity.Y; - if (num865 < 0f) - num865 = 0f; - - num865 += expertMode ? 4f : 3f; - - Projectile.NewProjectile(vector113.X, vector113.Y, npc.velocity.X * 0.25f, num865, ModContent.ProjectileType(), holyBombDamage, 0f, Main.myPlayer, 0f, 0f); - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= phaseTime) - { - AIState = (int)Phase.PhaseChange; - npc.TargetClosest(); - } + if (!targetDead) + { + 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 + npc.height); + if (num855 < (firingLaser ? 150f : 200f)) // 150 + npc.velocity.Y -= 0.2f; + if (num855 > (firingLaser ? 200f : 250f)) // 200 + npc.velocity.Y += 0.2f; + + float speedVariance = 2f; + if (npc.velocity.Y > (firingLaser ? speedVariance : 6f)) + npc.velocity.Y = firingLaser ? speedVariance : 6f; + if (npc.velocity.Y < (firingLaser ? -speedVariance : -6f)) + npc.velocity.Y = firingLaser ? -speedVariance : -6f; + } + + // Slowly drift down when spawning + if (spawnAnimation) + { + float minSpawnVelocity = 0.4f; + float maxSpawnVelocity = 4f; + float velocityY = maxSpawnVelocity - MathHelper.Lerp(minSpawnVelocity, maxSpawnVelocity, calamityGlobalNPC.newAI[3] / spawnAnimationTime); + npc.velocity = new Vector2(0f, velocityY); + } + } + + // Phase switch + switch ((int)AIState) + { + case (int)Phase.PhaseChange: + + phaseChange++; + if (phaseChange > 14) + phaseChange = 0; + + int phase = 0; + + // Holy ray in hallow, Crystal in hell + bool useLaser = (phase2 && biomeType == 1) || BossRushEvent.BossRushActive; + bool useCrystal = (phase2 && biomeType == 2) || BossRushEvent.BossRushActive; + + // Unique pattern for Death Mode and Boss Rush + if (death) + { + switch (phaseChange) + { + case 0: + phase = (int)Phase.MoltenBlobs; + break; + case 1: + phase = (int)Phase.SpearCocoon; + break; + case 2: + phase = (int)Phase.HolyBlast; + break; + case 3: + phase = (useCrystal || nightTime) ? (int)Phase.Crystal : (int)Phase.MoltenBlobs; + break; + case 4: + phase = useCrystal ? (int)Phase.MoltenBlobs : (int)Phase.FlameCocoon; + break; + case 5: + phase = useCrystal ? (int)Phase.FlameCocoon : (int)Phase.HolyFire; + break; + case 6: + phase = (useLaser || nightTime) ? (int)Phase.Laser : (int)Phase.HolyBomb; + break; + case 7: + phase = (useLaser || nightTime) ? (int)Phase.HolyBomb : (int)Phase.MoltenBlobs; + break; + case 8: + phase = (useLaser || nightTime) ? (int)Phase.MoltenBlobs : (int)Phase.SpearCocoon; + break; + case 9: + phase = (int)Phase.HolyBlast; + break; + case 10: + phase = (useCrystal || nightTime) ? (int)Phase.Crystal : (int)Phase.FlameCocoon; + break; + case 11: + phase = nightTime ? (int)Phase.FlameCocoon : (int)Phase.MoltenBlobs; + break; + case 12: + phase = (useLaser || nightTime) ? (int)Phase.Laser : (int)Phase.HolyBomb; + break; + case 13: + phase = (int)Phase.SpearCocoon; + break; + case 14: + phase = (useLaser || nightTime) ? (int)Phase.HolyBomb : (int)Phase.HolyBlast; + break; + default: + break; + } + } + else + { + switch (phaseChange) + { + case 0: + phase = (int)Phase.HolyBlast; + break; + case 1: + phase = useLaser ? (int)Phase.Laser : (int)Phase.HolyFire; + break; + case 2: + phase = (int)Phase.HolyBomb; + break; + case 3: + phase = (int)Phase.MoltenBlobs; + break; + case 4: + phase = (int)Phase.SpearCocoon; + break; + case 5: + phase = useCrystal ? (int)Phase.Crystal : (int)Phase.HolyBomb; + break; + case 6: + phase = (int)Phase.HolyFire; + break; + case 7: + phase = (int)Phase.HolyBlast; + break; + case 8: + phase = (int)Phase.MoltenBlobs; + break; + case 9: + phase = (int)Phase.FlameCocoon; + break; + case 10: + phase = (int)Phase.HolyBomb; + break; + case 11: + phase = useLaser ? (int)Phase.Laser : (int)Phase.HolyBlast; + break; + case 12: + phase = (int)Phase.HolyFire; + break; + case 13: + phase = (int)Phase.MoltenBlobs; + break; + case 14: + phase = (int)Phase.SpearCocoon; + break; + default: + break; + } + } + + // If too far from target, set phase to 0 + if (Math.Abs(vector.X - player.Center.X) > 5600f) + phase = (int)Phase.HolyBlast; + + // Reset attack delay for laser + if (phase == (int)Phase.Laser) + npc.localAI[2] = 0f; + + // Reset arrays + AIState = phase; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.netUpdate = true; + break; + + case (int)Phase.HolyBlast: + + if (spawnAnimation) + { + if (Main.netMode != NetmodeID.MultiplayerClient && calamityGlobalNPC.newAI[3] == 0f) + Projectile.NewProjectile(vector + new Vector2(0f, -80f), Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, biomeType, 0f); + + if (calamityGlobalNPC.newAI[3] == 10f && nightTime) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceHolyRay"), (int)npc.position.X, (int)npc.position.Y); + + if (calamityGlobalNPC.newAI[3] > 10f && calamityGlobalNPC.newAI[3] < 150f) + { + int dustAmt = (int)MathHelper.Lerp(4f, 8f, calamityGlobalNPC.newAI[3] / spawnAnimationTime); + for (int m = 0; m < dustAmt; m++) + { + float fade = MathHelper.Lerp(1.3f, 0.7f, npc.Opacity) * Utils.InverseLerp(0f, 120f, calamityGlobalNPC.newAI[3], clamped: true); + Color newColor = Main.hslToRgb(calamityGlobalNPC.newAI[3] / 180f, 1f, 0.5f); + + if (!nightTime) + { + newColor.R = 255; + if (biomeType == 2) + newColor.B = 0; + } + else + { + newColor.B = 255; + if (biomeType == 2) + newColor.G = 0; + else + newColor.R = 0; + } + + int dust = Dust.NewDust(npc.position, npc.width, npc.height, 267, 0f, 0f, 0, newColor); + Main.dust[dust].position = npc.Center + Main.rand.NextVector2Circular(npc.width * 2f, npc.height * 2f) + new Vector2(0f, -150f); + Main.dust[dust].velocity *= Main.rand.NextFloat() * 0.8f; + Main.dust[dust].noGravity = true; + Main.dust[dust].fadeIn = 0.6f + Main.rand.NextFloat() * 0.7f * fade; + Main.dust[dust].velocity += Vector2.UnitY * 3f; + Main.dust[dust].scale = 1.2f; + + if (dust != 6000) + { + Dust dust2 = Dust.CloneDust(dust); + dust2.scale /= 2f; + dust2.fadeIn *= 0.85f; + dust2.color = new Color(255, 255, 0, 255); + } + } + } + + npc.Opacity = MathHelper.Clamp(calamityGlobalNPC.newAI[3] / spawnAnimationTime, 0f, 1f); + + calamityGlobalNPC.newAI[3] += 1f; + + if (nightTime && calamityGlobalNPC.newAI[3] >= spawnAnimationTime) + calamityGlobalNPC.newAI[3] += 1f; + + return; + } + + // Attack delay after cocoon phase + if (delayAttacks) + { + npc.localAI[2] -= 1f; + return; + } + + if (distanceX > distanceNeededToShoot && npc.position.Y < player.position.Y) + { + npc.ai[3] += 1f; + + int shootBoost = death ? (int)Math.Round(5f * (1f - lifeRatio)) : (int)Math.Round(4f * (1f - lifeRatio)); + int num856 = (biomeEnraged ? 18 : expertMode ? 24 : 26) - shootBoost; + + num856 = (int)(num856 * attackRateMult); + + 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 + player.width * 0.5f - vector.X; + float num858 = player.Center.Y - vector.Y; + float num859 = (float)Math.Sqrt(num857 * num857 + num858 * num858); + + float velocityBoost = death ? 4f * (1f - lifeRatio) : 2.5f * (1f - lifeRatio); + float num860 = (expertMode ? 10.25f : 9f) + velocityBoost; + + if (revenge) + num860 *= 1.15f; + + num859 = num860 / num859; + num857 *= num859; + num858 *= num859; + + Projectile.NewProjectile(vector.X, vector.Y, num857, num858, ModContent.ProjectileType(), holyBlastDamage, 0f, Main.myPlayer, 0f, 0f); + } + } + else if (npc.ai[3] < 0f) + npc.ai[3] += 1f; + + npc.ai[1] += 1f; + if (npc.ai[1] >= phaseTime) + { + AIState = (int)Phase.PhaseChange; + npc.TargetClosest(); + } + + break; + + case (int)Phase.HolyFire: + + // Attack delay after cocoon phase + if (delayAttacks) + { + npc.localAI[2] -= 1f; + return; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.ai[3] += 1f; + + int shootBoost = death ? (int)Math.Round(6f * (1f - lifeRatio)) : (int)Math.Round(5f * (1f - lifeRatio)); + int num864 = (expertMode ? 36 : 39) - shootBoost; + if (BossRushEvent.BossRushActive || biomeEnraged) + num864 = 27; + + num864 = (int)(num864 * attackRateMult); + + if (npc.ai[3] >= num864) + { + npc.ai[3] = 0f; + + Vector2 vector113 = new Vector2(vector.X, npc.position.Y + npc.height - 14f); + + float num865 = npc.velocity.Y; + if (num865 < 0f) + num865 = 0f; + + num865 += expertMode ? 4f : 3f; + + if (nightTime) + num865 *= 2f; + + Projectile.NewProjectile(vector113.X, vector113.Y, npc.velocity.X * 0.25f, num865, ModContent.ProjectileType(), holyFireDamage, 0f, Main.myPlayer, 0f, 0f); + } + } + + npc.ai[1] += 1f; + if (npc.ai[1] >= phaseTime) + { + AIState = (int)Phase.PhaseChange; + npc.TargetClosest(); + } + + break; + + case (int)Phase.FlameCocoon: + + if (!targetDead) + { + if (npc.velocity.Length() <= 2f) + npc.velocity = Vector2.Zero; + if (npc.velocity.Length() > 2f) + { + npc.velocity *= 0.9f; + return; + } + } + + float divisor = (expertMode ? 2f : 3f) + (float)Math.Floor(3f * lifeRatio) + (attackRateMult > 1D ? (float)Math.Ceiling(attackRateMult * 1.6) : 0f); + int totalFlameProjectiles = biomeEnraged ? 45 : 36; + int chains = 4; + float interval = totalFlameProjectiles / chains * divisor; + double patternInterval = Math.Floor(npc.ai[3] / interval); + int healingStarChance = revenge ? 8 : expertMode ? 6 : 4; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (patternInterval % 2 == 0) + { + if (npc.ai[3] % divisor == 0f) + { + Main.PlaySound(SoundID.Item20, npc.Center); + bool normalSpread = calamityGlobalNPC.newAI[1] % 2f == 0f; + double radians = MathHelper.TwoPi / chains; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(cocoonProjVelocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = normalSpread ? new Vector2(0f, -cocoonProjVelocity) : new Vector2(-velocityX, -cocoonProjVelocity); + for (int i = 0; i < chains; i++) + { + Vector2 vector2 = spinningPoint.RotatedBy(radians * i + MathHelper.ToRadians(npc.ai[2])); + + int projectileType = ModContent.ProjectileType(); + int dmgAmt = holyStarDamage; + if (Main.rand.NextBool(healingStarChance) && !death) + { + projectileType = ModContent.ProjectileType(); + dmgAmt = npc.GetProjectileDamageNoScaling(projectileType); + Projectile.NewProjectile(fireFrom, vector2, projectileType, 0, 0f, Main.myPlayer, 0f, dmgAmt); + } + else + Projectile.NewProjectile(fireFrom, vector2, projectileType, dmgAmt, 0f, Main.myPlayer); + } + + // Radial offset + npc.ai[2] += 10f; + } + npc.netUpdate = true; + } + else + { + npc.ai[2] = 0f; + + totalFlameProjectiles = biomeEnraged ? 20 : 16; + if (npc.ai[3] % (divisor * totalFlameProjectiles) == 0f) + { + calamityGlobalNPC.newAI[1] += 1f; + double radians = MathHelper.TwoPi / totalFlameProjectiles; + Main.PlaySound(SoundID.Item20, npc.position); + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(cocoonProjVelocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = npc.ai[3] % (divisor * totalFlameProjectiles * 2f) == 0f ? new Vector2(-velocityX, -cocoonProjVelocity) : new Vector2(0f, -cocoonProjVelocity); + for (int i = 0; i < totalFlameProjectiles; i++) + { + Vector2 vector2 = spinningPoint.RotatedBy(radians * i); + + int projectileType = ModContent.ProjectileType(); + int dmgAmt = holyStarDamage; + if (Main.rand.NextBool(healingStarChance) && !death) + { + projectileType = ModContent.ProjectileType(); + dmgAmt = npc.GetProjectileDamageNoScaling(projectileType); + Projectile.NewProjectile(fireFrom, vector2, projectileType, 0, 0f, Main.myPlayer, 0f, dmgAmt); + } + else + Projectile.NewProjectile(fireFrom, vector2, projectileType, dmgAmt, 0f, Main.myPlayer); + } + } + } + + // Fire a flame towards every player, with a limit of 5 + if (npc.ai[3] % 60f == 0f && expertMode) + { + List targets = new List(); + for (int p = 0; p < Main.maxPlayers; p++) + { + if (Main.player[p].active && !Main.player[p].dead) + targets.Add(p); + + if (targets.Count > 4) + break; + } + foreach (int t in targets) + { + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - fireFrom) * cocoonProjVelocity * 1.5f; + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(fireFrom, velocity2, type, holyStarDamage, 0f, Main.myPlayer); + } + } + } + + if (npc.ai[3] == 0f) + DespawnSpecificProjectiles(); + + // Air is burning text + npc.ai[3] += 1f; + if (npc.ai[3] >= (phaseTime * 1.5f) && !text) + { + text = true; + string key = "Mods.CalamityMod.ProfanedBossText"; + Color messageColor = Color.Orange; + + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + + // Inflict Icarus Folly + if (npc.ai[3] >= (phaseTime * 2f)) + { + if (Main.netMode != NetmodeID.Server) + { + Player player2 = Main.player[Main.myPlayer]; + bool inLiquid = (player2.wet || player2.honeyWet) && !player2.lavaWet; + + if (!player2.dead && player2.active && Vector2.Distance(player2.Center, vector) < 2800f && !inLiquid) + { + Main.PlaySound(SoundID.Item20, player2.position); + player2.AddBuff(ModContent.BuffType(), 3000, true); + + for (int num621 = 0; num621 < 40; num621++) + { + int num622 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), + player2.width, player2.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + for (int num623 = 0; num623 < 60; num623++) + { + int num624 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), + player2.width, player2.height, dustType, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(player2.position.X, player2.position.Y), + player2.width, player2.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + } + + text = false; + AIState = (int)Phase.PhaseChange; + npc.localAI[2] = attackDelayAfterCocoon; + npc.TargetClosest(); + } + + break; + + case (int)Phase.MoltenBlobs: + + // Attack delay after cocoon phase + if (delayAttacks) + { + npc.localAI[2] -= 1f; + return; + } + + if (distanceX > distanceNeededToShoot && npc.position.Y < player.position.Y) + { + npc.ai[3] += 1f; + + int shootBoost = death ? (int)Math.Round(5f * (1f - lifeRatio)) : (int)Math.Round(4f * (1f - lifeRatio)); + int num856 = (expertMode ? 24 : 26) - shootBoost; + if (BossRushEvent.BossRushActive || biomeEnraged) + num856 = 18; + + num856 = (int)(num856 * attackRateMult); + + 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 + player.width * 0.5f - vector.X; + float num858 = player.Center.Y - vector.Y; + float num859 = (float)Math.Sqrt(num857 * num857 + num858 * num858); + + float shootBoost2 = death ? 4f * (1f - lifeRatio) : 2.5f * (1f - lifeRatio); + float num860 = (expertMode ? 10.25f : 9f) + shootBoost2; + if (BossRushEvent.BossRushActive) + num860 = 12.75f; + + if (revenge) + num860 *= 1.15f; + + num859 = num860 / num859; + num857 *= num859; + num858 *= num859; + + Projectile.NewProjectile(vector.X, vector.Y, num857 * 0.1f, num858, ModContent.ProjectileType(), moltenBlastDamage, 0f, Main.myPlayer, 0f, 0f); + } + } + else if (npc.ai[3] < 0f) + npc.ai[3] += 1f; + + npc.ai[1] += 1f; + if (npc.ai[1] >= phaseTime) + { + AIState = (int)Phase.PhaseChange; + npc.TargetClosest(); + } + + break; + + case (int)Phase.HolyBomb: + + // Attack delay after cocoon phase + if (delayAttacks) + { + npc.localAI[2] -= 1f; + return; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.ai[3] += 1f; + + int shootBoost = death ? (int)Math.Round(12f * (1f - lifeRatio)) : (int)Math.Round(10f * (1f - lifeRatio)); + int num864 = (biomeEnraged ? 54 : expertMode ? 73 : 77) - shootBoost; + + num864 = (int)(num864 * attackRateMult); + + if (npc.ai[3] >= num864) + { + npc.ai[3] = 0f; + + Vector2 vector113 = new Vector2(vector.X, npc.position.Y + npc.height - 14f); + + float num865 = npc.velocity.Y; + if (num865 < 0f) + num865 = 0f; + + num865 += expertMode ? 4f : 3f; + + Projectile.NewProjectile(vector113.X, vector113.Y, npc.velocity.X * 0.25f, num865, ModContent.ProjectileType(), holyBombDamage, 0f, Main.myPlayer, 0f, 0f); + } + } + + npc.ai[1] += 1f; + if (npc.ai[1] >= phaseTime) + { + AIState = (int)Phase.PhaseChange; + npc.TargetClosest(); + } - break; - - case (int)Phase.SpearCocoon: - - if (!targetDead) - { - if (npc.velocity.Length() <= 2f) - npc.velocity = Vector2.Zero; - if (npc.velocity.Length() > 2f) - { - npc.velocity *= 0.9f; - return; - } - } - - if (npc.ai[1] == 0f) - DespawnSpecificProjectiles(); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[2] += spearRate; - if (npc.ai[2] >= (float)(baseSpearRate * attackRateMult)) - { - npc.ai[2] = 0f; - - Main.PlayTrackedSound(SoundID.DD2_BetsyFireballShot, fireFrom); - - int projectileType = ModContent.ProjectileType(); - - if (calamityGlobalNPC.newAI[2] % 2f == 0f) - { - int totalSpearProjectiles = biomeEnraged ? 15 : 12; - double radians = MathHelper.TwoPi / totalSpearProjectiles; - Vector2 spinningPoint = Vector2.Normalize(new Vector2(-calamityGlobalNPC.newAI[1], -cocoonProjVelocity)); - - for (int i = 0; i < totalSpearProjectiles; i++) - { - Vector2 vector2 = spinningPoint.RotatedBy(radians * i) * cocoonProjVelocity; - Projectile.NewProjectile(fireFrom, vector2, projectileType, holySpearDamage, 0f, Main.myPlayer); - } - - if (spearRateIncrease > 1f) - spearRateIncrease = 1f; - - float radialOffset = MathHelper.Lerp(0.2f, 0.4f, spearRateIncrease); - calamityGlobalNPC.newAI[1] += radialOffset; - } - - calamityGlobalNPC.newAI[2] += 1f; - - cocoonProjVelocity = death ? 14f : revenge ? 13f : expertMode ? 12f : 10f; - Vector2 velocity2 = Vector2.Normalize(player.Center - fireFrom) * cocoonProjVelocity; - Projectile.NewProjectile(fireFrom, velocity2, projectileType, holySpearDamage, 0f, Main.myPlayer, 1f, 0f); - } - } - - npc.ai[3] += 1f; - if (npc.ai[3] >= phaseTime) - { - AIState = (int)Phase.PhaseChange; - npc.localAI[2] = attackDelayAfterCocoon; - npc.TargetClosest(); - } - - break; - - case (int)Phase.Crystal: - - if (!targetDead) - npc.velocity *= 0.9f; - - npc.ai[1] += 1f; - if (npc.ai[1] >= crystalPhaseTime) - { - if (npc.ai[1] == crystalPhaseTime && Main.netMode != NetmodeID.MultiplayerClient) - { - int proj = Projectile.NewProjectile(player.Center.X, player.Center.Y - 360f, 0f, 0f, ModContent.ProjectileType(), crystalDamage, 0f, player.whoAmI, lifeRatio, 0f); - - if (nightTime) - Main.projectile[proj].timeLeft = nightCrystalTime; - } - - if (npc.ai[1] >= crystalPhaseTime + nightCrystalTime || !nightTime) - { - AIState = (int)Phase.PhaseChange; - npc.TargetClosest(); - } - } - - break; - - case (int)Phase.Laser: - - Vector2 value19 = new Vector2(27f, 59f); - - float rotation = (nightTime ? 435f : 450f) + (guardianAmt * 5); - - npc.ai[2] += 1f; - if (npc.ai[2] < 120f) - { - if (npc.ai[2] >= 40f) - { - int num1220 = 0; - if (npc.ai[2] >= 80f) - num1220 = 1; - - for (int d = 0; d < 1 + num1220; d++) - { - float scalar = 1.2f; - if (d % 2 == 1) - scalar = 2.8f; - - Vector2 vector199 = new Vector2(vector.X, vector.Y + 32f) + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * value19 / 2f; - int index = Dust.NewDust(vector199 - Vector2.One * 8f, 16, 16, dustType, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); - Main.dust[index].velocity = Vector2.Normalize(vector - vector199) * 3.5f * (10f - num1220 * 2f) / 10f; - Main.dust[index].noGravity = true; - Main.dust[index].scale = scalar; - } - } - } - else if (npc.ai[2] < (revenge ? 220f : 300f)) - { - if (npc.ai[2] == 120f) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < 2800f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceHolyRay"), - (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 velocity = player.Center - vector; - velocity.Normalize(); - - float num1225 = -1f; - if (velocity.X < 0f) - num1225 = 1f; - - // 60 degrees offset - velocity = velocity.RotatedBy(-(double)num1225 * MathHelper.TwoPi / 6f); - Projectile.NewProjectile(vector.X, vector.Y + 32f, velocity.X, velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); - - // -60 degrees offset - if (revenge) - Projectile.NewProjectile(vector.X, vector.Y + 32f, -velocity.X, -velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, -num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); - - if (nightTime && lifeRatio < 0.5f) - { - rotation *= 0.33f; - velocity = velocity.RotatedBy(-(double)num1225 * MathHelper.TwoPi / 2f); - Projectile.NewProjectile(vector.X, vector.Y + 32f, velocity.X, velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); - - if (revenge) - Projectile.NewProjectile(vector.X, vector.Y + 32f, -velocity.X, -velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, -num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); - } - - npc.netUpdate = true; - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= (revenge ? 235f : 315f)) - { - AIState = (int)Phase.PhaseChange; - npc.TargetClosest(); - } - - break; - } + break; + + case (int)Phase.SpearCocoon: + + if (!targetDead) + { + if (npc.velocity.Length() <= 2f) + npc.velocity = Vector2.Zero; + if (npc.velocity.Length() > 2f) + { + npc.velocity *= 0.9f; + return; + } + } + + if (npc.ai[1] == 0f) + DespawnSpecificProjectiles(); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.ai[2] += spearRate; + if (npc.ai[2] >= (float)(baseSpearRate * attackRateMult)) + { + npc.ai[2] = 0f; + + Main.PlayTrackedSound(SoundID.DD2_BetsyFireballShot, fireFrom); + + int projectileType = ModContent.ProjectileType(); + + if (calamityGlobalNPC.newAI[2] % 2f == 0f) + { + int totalSpearProjectiles = biomeEnraged ? 15 : 12; + double radians = MathHelper.TwoPi / totalSpearProjectiles; + Vector2 spinningPoint = Vector2.Normalize(new Vector2(-calamityGlobalNPC.newAI[1], -cocoonProjVelocity)); + + for (int i = 0; i < totalSpearProjectiles; i++) + { + Vector2 vector2 = spinningPoint.RotatedBy(radians * i) * cocoonProjVelocity; + Projectile.NewProjectile(fireFrom, vector2, projectileType, holySpearDamage, 0f, Main.myPlayer); + } + + if (spearRateIncrease > 1f) + spearRateIncrease = 1f; + + float radialOffset = MathHelper.Lerp(0.2f, 0.4f, spearRateIncrease); + calamityGlobalNPC.newAI[1] += radialOffset; + } + + calamityGlobalNPC.newAI[2] += 1f; + + cocoonProjVelocity = death ? 14f : revenge ? 13f : expertMode ? 12f : 10f; + Vector2 velocity2 = Vector2.Normalize(player.Center - fireFrom) * cocoonProjVelocity; + Projectile.NewProjectile(fireFrom, velocity2, projectileType, holySpearDamage, 0f, Main.myPlayer, 1f, 0f); + } + } + + npc.ai[3] += 1f; + if (npc.ai[3] >= phaseTime) + { + AIState = (int)Phase.PhaseChange; + npc.localAI[2] = attackDelayAfterCocoon; + npc.TargetClosest(); + } + + break; + + case (int)Phase.Crystal: + + if (!targetDead) + npc.velocity *= 0.9f; + + npc.ai[1] += 1f; + if (npc.ai[1] >= crystalPhaseTime) + { + if (npc.ai[1] == crystalPhaseTime && Main.netMode != NetmodeID.MultiplayerClient) + { + int proj = Projectile.NewProjectile(player.Center.X, player.Center.Y - 360f, 0f, 0f, ModContent.ProjectileType(), crystalDamage, 0f, player.whoAmI, lifeRatio, 0f); + + if (nightTime) + Main.projectile[proj].timeLeft = nightCrystalTime; + } + + if (npc.ai[1] >= crystalPhaseTime + nightCrystalTime || !nightTime) + { + AIState = (int)Phase.PhaseChange; + npc.TargetClosest(); + } + } + + break; + + case (int)Phase.Laser: + + Vector2 value19 = new Vector2(27f, 59f); + + float rotation = (nightTime ? 435f : 450f) + (guardianAmt * 5); + + npc.ai[2] += 1f; + if (npc.ai[2] < 120f) + { + if (npc.ai[2] >= 40f) + { + int num1220 = 0; + if (npc.ai[2] >= 80f) + num1220 = 1; + + for (int d = 0; d < 1 + num1220; d++) + { + float scalar = 1.2f; + if (d % 2 == 1) + scalar = 2.8f; + + Vector2 vector199 = new Vector2(vector.X, vector.Y + 32f) + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * value19 / 2f; + int index = Dust.NewDust(vector199 - Vector2.One * 8f, 16, 16, dustType, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); + Main.dust[index].velocity = Vector2.Normalize(vector - vector199) * 3.5f * (10f - num1220 * 2f) / 10f; + Main.dust[index].noGravity = true; + Main.dust[index].scale = scalar; + } + } + } + else if (npc.ai[2] < (revenge ? 220f : 300f)) + { + if (npc.ai[2] == 120f) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, vector) < 2800f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceHolyRay"), + (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 velocity = player.Center - vector; + velocity.Normalize(); + + float num1225 = -1f; + if (velocity.X < 0f) + num1225 = 1f; + + // 60 degrees offset + velocity = velocity.RotatedBy(-(double)num1225 * MathHelper.TwoPi / 6f); + Projectile.NewProjectile(vector.X, vector.Y + 32f, velocity.X, velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); + + // -60 degrees offset + if (revenge) + Projectile.NewProjectile(vector.X, vector.Y + 32f, -velocity.X, -velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, -num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); + + if (nightTime && lifeRatio < 0.5f) + { + rotation *= 0.33f; + velocity = velocity.RotatedBy(-(double)num1225 * MathHelper.TwoPi / 2f); + Projectile.NewProjectile(vector.X, vector.Y + 32f, velocity.X, velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); + + if (revenge) + Projectile.NewProjectile(vector.X, vector.Y + 32f, -velocity.X, -velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, -num1225 * MathHelper.TwoPi / rotation, npc.whoAmI); + } + + npc.netUpdate = true; + } + } + } + + npc.ai[1] += 1f; + if (npc.ai[1] >= (revenge ? 235f : 315f)) + { + AIState = (int)Phase.PhaseChange; + npc.TargetClosest(); + } + + break; + } } - public void DoDeathAnimation() + public void DoDeathAnimation() { - AIState = (int)Phase.HolyFire; - useDefenseFrames = false; - DeathAnimationTimer++; + AIState = (int)Phase.HolyFire; + useDefenseFrames = false; + DeathAnimationTimer++; - // Slow down to a halt and define rotation based off of that. - npc.velocity *= 0.9f; - npc.rotation = npc.velocity.X * 0.004f; + // Slow down to a halt and define rotation based off of that. + npc.velocity *= 0.9f; + npc.rotation = npc.velocity.X * 0.004f; - // Play an animation sound immediately. Also delete various projectiles. - if (DeathAnimationTimer == 1f) - { - if (Main.netMode != NetmodeID.Server && Main.LocalPlayer.WithinRange(npc.Center, 4800f)) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceDeathAnimation").WithVolume(1.65f), Main.LocalPlayer.Center); + // Play an animation sound immediately. Also delete various projectiles. + if (DeathAnimationTimer == 1f) + { + if (Main.netMode != NetmodeID.Server && Main.LocalPlayer.WithinRange(npc.Center, 4800f)) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceDeathAnimation").WithVolume(1.65f), Main.LocalPlayer.Center); - DespawnSpecificProjectiles(); + DespawnSpecificProjectiles(); - int laserType = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (!Main.projectile[i].active || Main.projectile[i].type != laserType) - continue; - Main.projectile[i].Kill(); - } - } + int laserType = ModContent.ProjectileType(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (!Main.projectile[i].active || Main.projectile[i].type != laserType) + continue; + Main.projectile[i].Kill(); + } + } - // Begin fading out before the exploding sun animation happens. - if (DeathAnimationTimer >= 370f) - npc.Opacity *= 0.97f; + // Begin fading out before the exploding sun animation happens. + if (DeathAnimationTimer >= 370f) + npc.Opacity *= 0.97f; - // Create an explosive wave shortly after the death animation begins. - // The temporal offset coincides with the point at which the crystal shatter sound happens in the - // above defeat scene sound. - if (DeathAnimationTimer == 92f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceHolyBlastImpact"), npc.Center); - Main.PlaySound(npc.DeathSound, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); - } + // Create an explosive wave shortly after the death animation begins. + // The temporal offset coincides with the point at which the crystal shatter sound happens in the + // above defeat scene sound. + if (DeathAnimationTimer == 92f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceHolyBlastImpact"), npc.Center); + Main.PlaySound(npc.DeathSound, npc.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); + } - // Explode as an enormous holy star before dying and dropping loot. - if (Main.netMode != NetmodeID.MultiplayerClient && DeathAnimationTimer == 310f) - { - for (int i = 0; i < 80; i++) - { - Vector2 sparkleVelocity = Main.rand.NextVector2Circular(23f, 23f); - Projectile.NewProjectile(npc.Center, sparkleVelocity, ModContent.ProjectileType(), 0, 0f); - } - Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, 255); - } + // Explode as an enormous holy star before dying and dropping loot. + if (Main.netMode != NetmodeID.MultiplayerClient && DeathAnimationTimer == 310f) + { + for (int i = 0; i < 80; i++) + { + Vector2 sparkleVelocity = Main.rand.NextVector2Circular(23f, 23f); + Projectile.NewProjectile(npc.Center, sparkleVelocity, ModContent.ProjectileType(), 0, 0f); + } + Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, 255); + } - // Idly release harmless cindiers. - int shootRate = (int)MathHelper.Lerp(12f, 5f, Utils.InverseLerp(0f, 250f, DeathAnimationTimer, true)); - if (DeathAnimationTimer % shootRate == shootRate - 1f) - { - for (int i = 0; i < 3; i++) - { - Vector2 shootVelocity = Main.rand.NextVector2CircularEdge(13f, 13f) * Main.rand.NextFloat(0.7f, 1.3f); - Projectile.NewProjectile(npc.Center, shootVelocity, ModContent.ProjectileType(), 0, 0f, 255); - } - } + // Idly release harmless cindiers. + int shootRate = (int)MathHelper.Lerp(12f, 5f, Utils.InverseLerp(0f, 250f, DeathAnimationTimer, true)); + if (DeathAnimationTimer % shootRate == shootRate - 1f) + { + for (int i = 0; i < 3; i++) + { + Vector2 shootVelocity = Main.rand.NextVector2CircularEdge(13f, 13f) * Main.rand.NextFloat(0.7f, 1.3f); + Projectile.NewProjectile(npc.Center, shootVelocity, ModContent.ProjectileType(), 0, 0f, 255); + } + } - // Do periodic syncs. - if (Main.netMode == NetmodeID.Server && DeathAnimationTimer % 45f == 44f) - npc.netUpdate = true; + // Do periodic syncs. + if (Main.netMode == NetmodeID.Server && DeathAnimationTimer % 45f == 44f) + npc.netUpdate = true; - // Die and create drops after the star is gone. - if (DeathAnimationTimer >= 345f) - { - npc.active = false; - npc.HitEffect(); - npc.NPCLoot(); - npc.netUpdate = true; - } - } + // Die and create drops after the star is gone. + if (DeathAnimationTimer >= 345f) + { + npc.active = false; + npc.HitEffect(); + npc.NPCLoot(); + npc.netUpdate = true; + } + } - public float CalculateBurnIntensity() + public float CalculateBurnIntensity() { - float distanceToTarget = Vector2.Distance(Main.player[npc.target].Center, npc.Center); - float aiTimer = npc.ai[3]; + float distanceToTarget = Vector2.Distance(Main.player[npc.target].Center, npc.Center); + float aiTimer = npc.ai[3]; - // Night bool - bool malice = CalamityWorld.malice; - bool nightTime = !Main.dayTime || malice; + // Night bool + bool malice = CalamityWorld.malice; + bool nightTime = !Main.dayTime || malice; - float baseDistance = 2800f; - float shorterFlameCocoonDistance = (CalamityWorld.death || BossRushEvent.BossRushActive || nightTime) ? 600f : CalamityWorld.revenge ? 400f : Main.expertMode ? 200f : 0f; - float shorterSpearCocoonDistance = (CalamityWorld.death || BossRushEvent.BossRushActive || nightTime) ? 1000f : CalamityWorld.revenge ? 650f : Main.expertMode ? 300f : 0f; - float shorterDistance = AIState == (int)Phase.FlameCocoon ? shorterFlameCocoonDistance : shorterSpearCocoonDistance; + float baseDistance = 2800f; + float shorterFlameCocoonDistance = (CalamityWorld.death || BossRushEvent.BossRushActive || nightTime) ? 600f : CalamityWorld.revenge ? 400f : Main.expertMode ? 200f : 0f; + float shorterSpearCocoonDistance = (CalamityWorld.death || BossRushEvent.BossRushActive || nightTime) ? 1000f : CalamityWorld.revenge ? 650f : Main.expertMode ? 300f : 0f; + float shorterDistance = AIState == (int)Phase.FlameCocoon ? shorterFlameCocoonDistance : shorterSpearCocoonDistance; - bool guardianAlive = false; - if (CalamityGlobalNPC.holyBossAttacker != -1 && Main.npc[CalamityGlobalNPC.holyBossAttacker].active) - guardianAlive = true; + bool guardianAlive = false; + if (CalamityGlobalNPC.holyBossAttacker != -1 && Main.npc[CalamityGlobalNPC.holyBossAttacker].active) + guardianAlive = true; - if (CalamityGlobalNPC.holyBossDefender != -1 && Main.npc[CalamityGlobalNPC.holyBossDefender].active) - guardianAlive = true; + if (CalamityGlobalNPC.holyBossDefender != -1 && Main.npc[CalamityGlobalNPC.holyBossDefender].active) + guardianAlive = true; - if (CalamityGlobalNPC.holyBossHealer != -1 && Main.npc[CalamityGlobalNPC.holyBossHealer].active) - guardianAlive = true; + if (CalamityGlobalNPC.holyBossHealer != -1 && Main.npc[CalamityGlobalNPC.holyBossHealer].active) + guardianAlive = true; - float maxDistance = baseDistance; + float maxDistance = baseDistance; - // A factor which measures how much of the distance shortening shave-off should be taken into account. - // It is determined based on how much time has elapsed during the attack thus far, specifically for the two cocoon attacks. - // This shave-off does not happen when guardians are present. - float shorterDistanceFade = Utils.InverseLerp(0f, 120f, aiTimer, true); + // A factor which measures how much of the distance shortening shave-off should be taken into account. + // It is determined based on how much time has elapsed during the attack thus far, specifically for the two cocoon attacks. + // This shave-off does not happen when guardians are present. + float shorterDistanceFade = Utils.InverseLerp(0f, 120f, aiTimer, true); if (!guardianAlive) { maxDistance = baseDistance; - if (AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon) - maxDistance -= shorterDistance * shorterDistanceFade; + if (AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon) + maxDistance -= shorterDistance * shorterDistanceFade; } - float drawFireDistanceStart = maxDistance - 800f; - return Utils.InverseLerp(drawFireDistanceStart, maxDistance, distanceToTarget, true); - } + float drawFireDistanceStart = maxDistance - 800f; + return Utils.InverseLerp(drawFireDistanceStart, maxDistance, distanceToTarget, true); + } - private void DespawnSpecificProjectiles(bool dying = false) - { - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - projectile.Kill(); - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - projectile.active = false; + private void DespawnSpecificProjectiles(bool dying = false) + { + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active) + { + if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + projectile.Kill(); + else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + projectile.active = false; - if (dying) - { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - projectile.Kill(); - else if (projectile.type == ModContent.ProjectileType()) - projectile.active = false; - } - } - } - } + if (dying) + { + if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + projectile.Kill(); + else if (projectile.type == ModContent.ProjectileType()) + projectile.active = false; + } + } + } + } public override bool CanHitPlayer(Player target, ref int cooldownSlot) { @@ -1468,57 +1468,57 @@ namespace CalamityMod.NPCs.Providence public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedProvidence); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedProvidence); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedProvidence); + CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedProvidence); - // Accessories clientside only in Expert. Both drop if she is defeated at night. - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, biomeType != 2 || !hasTakenDaytimeDamage); + // Accessories clientside only in Expert. Both drop if she is defeated at night. + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, biomeType != 2 || !hasTakenDaytimeDamage); DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, biomeType == 2 || !hasTakenDaytimeDamage); - // Drops pre-scal, cannot be sold, does nothing aka purely vanity. Requires at least expert for consistency with other post scal dev items. - bool shouldDrop = challenge/* || (Main.expertMode && Main.rand.NextBool(CalamityWorld.downedSCal ? 10 : 200))*/; - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, shouldDrop); + // Drops pre-scal, cannot be sold, does nothing aka purely vanity. Requires at least expert for consistency with other post scal dev items. + bool shouldDrop = challenge/* || (Main.expertMode && Main.rand.NextBool(CalamityWorld.downedSCal ? 10 : 200))*/; + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, shouldDrop); - // Special drop for defeating her at night - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice || !hasTakenDaytimeDamage, 3, 4); + // Special drop for defeating her at night + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice || !hasTakenDaytimeDamage, 3, 4); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) { // Materials DropHelper.DropItemSpray(npc, ModContent.ItemType(), 20, 30); DropHelper.DropItemSpray(npc, ModContent.ItemType(), 15, 20); - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + // Weapons + float w = DropHelper.NormalWeaponDropRateFloat; + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); } - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 0.1f); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.Top.Y >= (Main.maxTilesY - 240f) * 16f) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.Top.Y >= (Main.maxTilesY - 240f) * 16f) SpawnLootBox(); // If Providence has not been killed, notify players of Uelibloom Ore @@ -1531,17 +1531,17 @@ namespace CalamityMod.NPCs.Providence CalamityUtils.SpawnOre(ModContent.TileType(), 15E-05, 0.4f, 0.8f, 3, 8, TileID.Mud); - CalamityUtils.DisplayLocalizedText(key2, messageColor2); - CalamityUtils.DisplayLocalizedText(key3, messageColor3); - } + CalamityUtils.DisplayLocalizedText(key2, messageColor2); + CalamityUtils.DisplayLocalizedText(key3, messageColor3); + } - if (challenge) - { - if (Main.netMode == NetmodeID.SinglePlayer) - { - Main.NewText(Language.GetTextValue("Mods.CalamityMod.ProfanedBossText4"), Color.DarkOrange); - } - } + if (challenge) + { + if (Main.netMode == NetmodeID.SinglePlayer) + { + Main.NewText(Language.GetTextValue("Mods.CalamityMod.ProfanedBossText4"), Color.DarkOrange); + } + } // Mark Providence as dead CalamityWorld.downedProvidence = true; @@ -1581,158 +1581,158 @@ namespace CalamityMod.NPCs.Providence public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - void drawProvidenceInstance(Vector2 drawOffset, Color? colorOverride) - { - bool malice = CalamityWorld.malice; - bool nightTime = !Main.dayTime || malice; + void drawProvidenceInstance(Vector2 drawOffset, Color? colorOverride) + { + bool malice = CalamityWorld.malice; + bool nightTime = !Main.dayTime || malice; - string baseTextureString = "CalamityMod/NPCs/Providence/"; - string baseGlowTextureString = baseTextureString + "Glowmasks/"; + string baseTextureString = "CalamityMod/NPCs/Providence/"; + string baseGlowTextureString = baseTextureString + "Glowmasks/"; - string getTextureString = baseTextureString + "Providence"; - string getTextureGlowString = baseGlowTextureString + "ProvidenceGlow"; - string getTextureGlow2String = baseGlowTextureString + "ProvidenceGlow2"; + string getTextureString = baseTextureString + "Providence"; + string getTextureGlowString = baseGlowTextureString + "ProvidenceGlow"; + string getTextureGlow2String = baseGlowTextureString + "ProvidenceGlow2"; - if (AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon) - { - if (!useDefenseFrames) - { - getTextureString = baseTextureString + "ProvidenceDefense"; - getTextureGlowString = baseGlowTextureString + "ProvidenceDefenseGlow"; - getTextureGlow2String = baseGlowTextureString + "ProvidenceDefenseGlow2"; - } - else - { - getTextureString = baseTextureString + "ProvidenceDefenseAlt"; - getTextureGlowString = baseGlowTextureString + "ProvidenceDefenseAltGlow"; - getTextureGlow2String = baseGlowTextureString + "ProvidenceDefenseAltGlow2"; - } - } - else - { - if (frameUsed == 0) - { - getTextureGlowString = baseGlowTextureString + "ProvidenceGlow"; - getTextureGlow2String = baseGlowTextureString + "ProvidenceGlow2"; - } - else if (frameUsed == 1) - { - getTextureString = baseTextureString + "ProvidenceAlt"; - getTextureGlowString = baseGlowTextureString + "ProvidenceAltGlow"; - getTextureGlow2String = baseGlowTextureString + "ProvidenceAltGlow2"; - } - else if (frameUsed == 2) - { - getTextureString = baseTextureString + "ProvidenceAttack"; - getTextureGlowString = baseGlowTextureString + "ProvidenceAttackGlow"; - getTextureGlow2String = baseGlowTextureString + "ProvidenceAttackGlow2"; - } - else - { - getTextureString = baseTextureString + "ProvidenceAttackAlt"; - getTextureGlowString = baseGlowTextureString + "ProvidenceAttackAltGlow"; - getTextureGlow2String = baseGlowTextureString + "ProvidenceAttackAltGlow2"; - } - } + if (AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon) + { + if (!useDefenseFrames) + { + getTextureString = baseTextureString + "ProvidenceDefense"; + getTextureGlowString = baseGlowTextureString + "ProvidenceDefenseGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceDefenseGlow2"; + } + else + { + getTextureString = baseTextureString + "ProvidenceDefenseAlt"; + getTextureGlowString = baseGlowTextureString + "ProvidenceDefenseAltGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceDefenseAltGlow2"; + } + } + else + { + if (frameUsed == 0) + { + getTextureGlowString = baseGlowTextureString + "ProvidenceGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceGlow2"; + } + else if (frameUsed == 1) + { + getTextureString = baseTextureString + "ProvidenceAlt"; + getTextureGlowString = baseGlowTextureString + "ProvidenceAltGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceAltGlow2"; + } + else if (frameUsed == 2) + { + getTextureString = baseTextureString + "ProvidenceAttack"; + getTextureGlowString = baseGlowTextureString + "ProvidenceAttackGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceAttackGlow2"; + } + else + { + getTextureString = baseTextureString + "ProvidenceAttackAlt"; + getTextureGlowString = baseGlowTextureString + "ProvidenceAttackAltGlow"; + getTextureGlow2String = baseGlowTextureString + "ProvidenceAttackAltGlow2"; + } + } - if (nightTime) - { - getTextureString += "Night"; - getTextureGlowString += "Night"; - getTextureGlow2String += "Night"; - } + if (nightTime) + { + getTextureString += "Night"; + getTextureGlowString += "Night"; + getTextureGlow2String += "Night"; + } - Texture2D texture = ModContent.GetTexture(getTextureString); - Texture2D textureGlow = ModContent.GetTexture(getTextureGlowString); - Texture2D textureGlow2 = ModContent.GetTexture(getTextureGlow2String); + Texture2D texture = ModContent.GetTexture(getTextureString); + Texture2D textureGlow = ModContent.GetTexture(getTextureGlowString); + Texture2D textureGlow2 = ModContent.GetTexture(getTextureGlow2String); - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - if (colorOverride != null) - color38 = colorOverride.Value; + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + if (colorOverride != null) + color38 = colorOverride.Value; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY) + drawOffset; - spriteBatch.Draw(texture, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY) + drawOffset; + spriteBatch.Draw(texture, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY) + drawOffset; - spriteBatch.Draw(texture, vector43, npc.frame, colorOverride ?? npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY) + drawOffset; + spriteBatch.Draw(texture, vector43, npc.frame, colorOverride ?? npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - Color color37 = Color.Lerp(Color.White, nightTime ? Color.Cyan : Color.Yellow, 0.5f) * npc.Opacity; - Color color42 = Color.Lerp(Color.White, nightTime ? Color.BlueViolet : Color.Violet, 0.5f) * npc.Opacity; - if (colorOverride != null) - { - color37 = colorOverride.Value; - color42 = colorOverride.Value; - } + Color color37 = Color.Lerp(Color.White, nightTime ? Color.Cyan : Color.Yellow, 0.5f) * npc.Opacity; + Color color42 = Color.Lerp(Color.White, nightTime ? Color.BlueViolet : Color.Violet, 0.5f) * npc.Opacity; + if (colorOverride != null) + { + color37 = colorOverride.Value; + color42 = colorOverride.Value; + } - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - if (colorOverride != null) - color41 = colorOverride.Value; + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + if (colorOverride != null) + color41 = colorOverride.Value; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(textureGlow.Width, textureGlow.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY) + drawOffset; - spriteBatch.Draw(textureGlow, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(textureGlow.Width, textureGlow.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY) + drawOffset; + spriteBatch.Draw(textureGlow, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 = npc.GetAlpha(color43); - color43 *= (num153 - num163) / 15f; - if (colorOverride != null) - color43 = colorOverride.Value; - spriteBatch.Draw(textureGlow2, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + Color color43 = color42; + color43 = Color.Lerp(color43, color36, amount9); + color43 = npc.GetAlpha(color43); + color43 *= (num153 - num163) / 15f; + if (colorOverride != null) + color43 = colorOverride.Value; + spriteBatch.Draw(textureGlow2, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(textureGlow, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(textureGlow, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - spriteBatch.Draw(textureGlow2, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + spriteBatch.Draw(textureGlow2, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } - float burnIntensity = Utils.InverseLerp(0f, 45f, DeathAnimationTimer, true); - int totalProvidencesToDraw = (int)MathHelper.Lerp(1f, 30f, burnIntensity); - for (int i = 0; i < totalProvidencesToDraw; i++) - { - float offsetAngle = MathHelper.TwoPi * i * 2f / totalProvidencesToDraw; - float drawOffsetFactor = (float)Math.Sin(offsetAngle * 6f + Main.GlobalTime * MathHelper.Pi); - drawOffsetFactor *= (float)Math.Pow(burnIntensity, 3f) * 50f; + float burnIntensity = Utils.InverseLerp(0f, 45f, DeathAnimationTimer, true); + int totalProvidencesToDraw = (int)MathHelper.Lerp(1f, 30f, burnIntensity); + for (int i = 0; i < totalProvidencesToDraw; i++) + { + float offsetAngle = MathHelper.TwoPi * i * 2f / totalProvidencesToDraw; + float drawOffsetFactor = (float)Math.Sin(offsetAngle * 6f + Main.GlobalTime * MathHelper.Pi); + drawOffsetFactor *= (float)Math.Pow(burnIntensity, 3f) * 50f; - Vector2 drawOffset = offsetAngle.ToRotationVector2() * drawOffsetFactor; - Color baseColor = Color.White * (MathHelper.Lerp(0.4f, 0.8f, burnIntensity) / totalProvidencesToDraw * 1.5f); - baseColor.A = 0; + Vector2 drawOffset = offsetAngle.ToRotationVector2() * drawOffsetFactor; + Color baseColor = Color.White * (MathHelper.Lerp(0.4f, 0.8f, burnIntensity) / totalProvidencesToDraw * 1.5f); + baseColor.A = 0; - baseColor = Color.Lerp(Color.White, baseColor, burnIntensity); - drawProvidenceInstance(drawOffset, totalProvidencesToDraw == 1 ? null : (Color?)baseColor); - } - return false; + baseColor = Color.Lerp(Color.White, baseColor, burnIntensity); + drawProvidenceInstance(drawOffset, totalProvidencesToDraw == 1 ? null : (Color?)baseColor); + } + return false; } public override void FindFrame(int frameHeight) //9 total frames @@ -1800,116 +1800,116 @@ namespace CalamityMod.NPCs.Providence public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit) { - if (!hasTakenDaytimeDamage) - { - if (Main.dayTime) - { - hasTakenDaytimeDamage = true; + if (!hasTakenDaytimeDamage) + { + if (Main.dayTime) + { + hasTakenDaytimeDamage = true; - if (Main.netMode != NetmodeID.SinglePlayer) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.ProvidenceDyeConditionSync); - netMessage.Write((byte)npc.whoAmI); - netMessage.Write(hasTakenDaytimeDamage); - netMessage.Send(); - } - } - } + if (Main.netMode != NetmodeID.SinglePlayer) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.ProvidenceDyeConditionSync); + netMessage.Write((byte)npc.whoAmI); + netMessage.Write(hasTakenDaytimeDamage); + netMessage.Send(); + } + } + } - if (challenge) - { - List exceptionList = new List() - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType() - }; + if (challenge) + { + List exceptionList = new List() + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() + }; - bool allowedClass = projectile.IsSummon() || (!projectile.melee && !projectile.ranged && !projectile.magic && !projectile.thrown && !projectile.Calamity().rogue); - bool allowedDamage = allowedClass && damage <= 75; //Flat 75 regardless of difficulty. - //Absorber on-hit effects likely won't proc this but Deific Amulet and Astral Bulwark stars will proc this. - bool allowedBabs = Main.player[projectile.owner].Calamity().pArtifact && !Main.player[projectile.owner].Calamity().profanedCrystalBuffs; + bool allowedClass = projectile.IsSummon() || (!projectile.melee && !projectile.ranged && !projectile.magic && !projectile.thrown && !projectile.Calamity().rogue); + bool allowedDamage = allowedClass && damage <= 75; //Flat 75 regardless of difficulty. + //Absorber on-hit effects likely won't proc this but Deific Amulet and Astral Bulwark stars will proc this. + bool allowedBabs = Main.player[projectile.owner].Calamity().pArtifact && !Main.player[projectile.owner].Calamity().profanedCrystalBuffs; - if ((exceptionList.TrueForAll(x => projectile.type != x) && !allowedDamage) || !allowedBabs) - { - challenge = false; + if ((exceptionList.TrueForAll(x => projectile.type != x) && !allowedDamage) || !allowedBabs) + { + challenge = false; - if (Main.netMode != NetmodeID.SinglePlayer) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.PSCChallengeSync); - netMessage.Write((byte)npc.whoAmI); - netMessage.Write(challenge); - netMessage.Send(); - } - } - } + if (Main.netMode != NetmodeID.SinglePlayer) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.PSCChallengeSync); + netMessage.Write((byte)npc.whoAmI); + netMessage.Write(challenge); + netMessage.Send(); + } + } + } } public override void OnHitByItem(Player player, Item item, int damage, float knockback, bool crit) - { - if (!hasTakenDaytimeDamage) - { - if (Main.dayTime) - { - hasTakenDaytimeDamage = true; + { + if (!hasTakenDaytimeDamage) + { + if (Main.dayTime) + { + hasTakenDaytimeDamage = true; - if (Main.netMode != NetmodeID.SinglePlayer) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.ProvidenceDyeConditionSync); - netMessage.Write((byte)npc.whoAmI); - netMessage.Write(hasTakenDaytimeDamage); - netMessage.Send(); - } - } - } + if (Main.netMode != NetmodeID.SinglePlayer) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.ProvidenceDyeConditionSync); + netMessage.Write((byte)npc.whoAmI); + netMessage.Write(hasTakenDaytimeDamage); + netMessage.Send(); + } + } + } - if (challenge) - { - challenge = false; + if (challenge) + { + challenge = false; - if (Main.netMode != NetmodeID.SinglePlayer) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.PSCChallengeSync); - netMessage.Write((byte)npc.whoAmI); - netMessage.Write(challenge); - netMessage.Send(); - } - } - } + if (Main.netMode != NetmodeID.SinglePlayer) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.PSCChallengeSync); + netMessage.Write((byte)npc.whoAmI); + netMessage.Write(challenge); + netMessage.Send(); + } + } + } - public override bool CheckDead() - { - if (!Dying) - { - DespawnSpecificProjectiles(true); - Dying = true; - npc.active = true; - npc.netUpdate = true; - } - return false; - } + public override bool CheckDead() + { + if (!Dying) + { + DespawnSpecificProjectiles(true); + Dying = true; + npc.active = true; + npc.netUpdate = true; + } + return false; + } public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { - if ((damage * (crit ? 2D : 1D)) >= npc.life) + if ((damage * (crit ? 2D : 1D)) >= npc.life) { - damage = 0D; + damage = 0D; - npc.life = 1; - npc.dontTakeDamage = true; - if (!Dying) - CheckDead(); - return false; + npc.life = 1; + npc.dontTakeDamage = true; + if (!Dying) + CheckDead(); + return false; } return base.StrikeNPC(ref damage, defense, ref knockback, hitDirection, ref crit); @@ -1923,8 +1923,8 @@ namespace CalamityMod.NPCs.Providence Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/ProvidenceHurt"), npc.Center); } - int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; - for (int k = 0; k < 15; k++) + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int k = 0; k < 15; k++) Dust.NewDust(npc.position, npc.width, npc.height, dustType, hitDirection, -1f, 0, default, 1f); if (npc.life <= 0) @@ -1937,7 +1937,7 @@ namespace CalamityMod.NPCs.Providence npc.position = npc.Center; npc.width = 400; npc.height = 350; - npc.position -= npc.Size * 0.5f; + npc.position -= npc.Size * 0.5f; for (int d = 0; d < 60; d++) { int fire = Dust.NewDust(npc.position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 2f); diff --git a/NPCs/Ravager/FlamePillar.cs b/NPCs/Ravager/FlamePillar.cs index dec62c1a22..dadc498cfb 100644 --- a/NPCs/Ravager/FlamePillar.cs +++ b/NPCs/Ravager/FlamePillar.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { - public class FlamePillar : ModNPC + public class FlamePillar : ModNPC { public override void SetStaticDefaults() { @@ -19,23 +19,23 @@ namespace CalamityMod.NPCs.Ravager public override void SetDefaults() { - npc.GetNPCDamage(); - npc.width = 40; + npc.GetNPCDamage(); + npc.width = 40; npc.height = 150; - npc.defense = 35; - npc.DR_NERD(0.2f); - npc.chaseable = false; - npc.canGhostHeal = false; - npc.lifeMax = CalamityWorld.downedProvidence ? 14000 : 3500; - npc.alpha = 255; + npc.defense = 35; + npc.DR_NERD(0.2f); + npc.chaseable = false; + npc.canGhostHeal = false; + npc.lifeMax = CalamityWorld.downedProvidence ? 14000 : 3500; + npc.alpha = 255; npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; npc.HitSound = SoundID.NPCHit41; npc.DeathSound = SoundID.NPCDeath14; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void FindFrame(int frameHeight) { @@ -48,9 +48,9 @@ namespace CalamityMod.NPCs.Ravager public override void AI() { bool provy = CalamityWorld.downedProvidence; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (CalamityGlobalNPC.scavenger < 0 || !Main.npc[CalamityGlobalNPC.scavenger].active) + if (CalamityGlobalNPC.scavenger < 0 || !Main.npc[CalamityGlobalNPC.scavenger].active) { npc.life = 0; HitEffect(npc.direction, 9999); @@ -61,32 +61,32 @@ namespace CalamityMod.NPCs.Ravager 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); + 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) + if (npc.alpha > 0) { - npc.damage = 0; + npc.damage = 0; - npc.alpha -= 5; + npc.alpha -= 5; if (npc.alpha < 0) - npc.alpha = 0; + npc.alpha = 0; + } + else + { + if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) + npc.damage = (int)(npc.defDamage * 1.5); + else + npc.damage = npc.defDamage; } - else - { - if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) - npc.damage = (int)(npc.defDamage * 1.5); - else - npc.damage = npc.defDamage; - } if (npc.ai[0] == 0f) { npc.ai[1] += 1f; - if (npc.ai[1] >= 60f) - { - npc.ai[0] = 1f; - npc.ai[1] = 180f; - } + if (npc.ai[1] >= 60f) + { + npc.ai[0] = 1f; + npc.ai[1] = 180f; + } } else if (npc.ai[0] == 1f) { @@ -98,27 +98,27 @@ namespace CalamityMod.NPCs.Ravager { if (Main.netMode != NetmodeID.MultiplayerClient) { - float speedY = -12f; - float speedX = 0f; - switch ((int)npc.ai[2]) - { - case 0: - break; - case 1: - speedX = 2f; - break; - case 2: - speedX = -2f; - break; - default: - break; - } - Vector2 velocity = new Vector2(speedX, speedY); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, velocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, 0f); + float speedY = -12f; + float speedX = 0f; + switch ((int)npc.ai[2]) + { + case 0: + break; + case 1: + speedX = 2f; + break; + case 2: + speedX = -2f; + break; + default: + break; + } + Vector2 velocity = new Vector2(speedX, speedY); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center, velocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, 0f); } - npc.ai[2] += 1f; + npc.ai[2] += 1f; npc.localAI[0] = 0f; npc.netUpdate = true; } @@ -132,33 +132,33 @@ namespace CalamityMod.NPCs.Ravager } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Texture2D texture2D15 = Main.npcTexture[npc.type]; + 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(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Ravager/FlamePillarGlow"); - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Ravager/FlamePillarGlow"); + Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { @@ -187,27 +187,27 @@ namespace CalamityMod.NPCs.Ravager Main.dust[num624].velocity *= 2f; } } - else - { - for (int num621 = 0; num621 < 2; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 2; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } + else + { + for (int num621 = 0; num621 < 2; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 2; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + } } } diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index 53431e5c62..9a98a3dd06 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -21,12 +21,12 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { - [AutoloadBossHead] + [AutoloadBossHead] public class RavagerBody : ModNPC { - private float velocityY = -16f; + private float velocityY = -16f; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Ravager"); Main.npcFrameCount[npc.type] = 7; @@ -34,17 +34,17 @@ namespace CalamityMod.NPCs.Ravager public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.lavaImmune = true; - npc.noGravity = true; + npc.Calamity().canBreakPlayerDefense = true; + npc.lavaImmune = true; + npc.noGravity = true; npc.npcSlots = 20f; npc.aiStyle = -1; - npc.GetNPCDamage(); - npc.width = 332; + npc.GetNPCDamage(); + npc.width = 332; npc.height = 214; npc.defense = 55; npc.value = Item.buyPrice(0, 75, 0, 0); - npc.DR_NERD(0.35f); + npc.DR_NERD(0.35f); npc.LifeMaxNERB(44600, 53500, 460000); if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { @@ -64,25 +64,25 @@ namespace CalamityMod.NPCs.Ravager npc.DeathSound = SoundID.NPCDeath14; music = CalamityMod.Instance.GetMusicFromMusicMod("Ravager") ?? MusicID.Boss4; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(npc.dontTakeDamage); - writer.Write(velocityY); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + writer.Write(velocityY); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { npc.dontTakeDamage = reader.ReadBoolean(); - velocityY = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + velocityY = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void FindFrame(int frameHeight) { @@ -94,20 +94,20 @@ namespace CalamityMod.NPCs.Ravager public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; - // Large fire light - Lighting.AddLight((int)(npc.Center.X - 110f) / 16, (int)(npc.Center.Y - 30f) / 16, 0f, 0.5f, 2f); + // Large fire light + Lighting.AddLight((int)(npc.Center.X - 110f) / 16, (int)(npc.Center.Y - 30f) / 16, 0f, 0.5f, 2f); Lighting.AddLight((int)(npc.Center.X + 110f) / 16, (int)(npc.Center.Y - 30f) / 16, 0f, 0.5f, 2f); // Small fire light @@ -133,7 +133,7 @@ namespace CalamityMod.NPCs.Ravager npc.noTileCollide = true; } - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; if (npc.alpha > 0) { @@ -149,7 +149,7 @@ namespace CalamityMod.NPCs.Ravager bool headActive = false; bool rightClawActive = false; bool leftClawActive = false; - bool freeHeadActive = false; + bool freeHeadActive = false; for (int i = 0; i < Main.maxNPCs; i++) { @@ -163,37 +163,37 @@ namespace CalamityMod.NPCs.Ravager rightLegActive = true; if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) leftLegActive = true; - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - freeHeadActive = true; - } + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + freeHeadActive = true; + } - bool anyHeadActive = headActive || freeHeadActive; - bool immunePhase = headActive || rightClawActive || leftClawActive || rightLegActive || leftLegActive; - bool finalPhase = !leftClawActive && !rightClawActive && !headActive && !leftLegActive && !rightLegActive && expertMode; - bool phase2 = npc.ai[0] == 2f; - bool reduceFallSpeed = npc.velocity.Y > 0f && npc.Bottom.Y > player.Top.Y; + bool anyHeadActive = headActive || freeHeadActive; + bool immunePhase = headActive || rightClawActive || leftClawActive || rightLegActive || leftLegActive; + bool finalPhase = !leftClawActive && !rightClawActive && !headActive && !leftLegActive && !rightLegActive && expertMode; + bool phase2 = npc.ai[0] == 2f; + bool reduceFallSpeed = npc.velocity.Y > 0f && npc.Bottom.Y > player.Top.Y; - if (immunePhase) - { - npc.dontTakeDamage = true; - if (malice) - { - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && revenge) - Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); - } - } - } - else - { - npc.dontTakeDamage = false; - if (Main.netMode != NetmodeID.Server) - { - if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && revenge) - Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); - } - } + if (immunePhase) + { + npc.dontTakeDamage = true; + if (malice) + { + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && revenge) + Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); + } + } + } + else + { + npc.dontTakeDamage = false; + if (Main.netMode != NetmodeID.Server) + { + if (!Main.player[Main.myPlayer].dead && Main.player[Main.myPlayer].active && revenge) + Main.player[Main.myPlayer].AddBuff(ModContent.BuffType(), 2); + } + } if (!headActive) { @@ -308,15 +308,15 @@ namespace CalamityMod.NPCs.Ravager } } - if (npc.noTileCollide && !player.dead) - { - if (npc.velocity.Y > 0f && npc.Bottom.Y > player.Top.Y) - npc.noTileCollide = false; - else if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.noTileCollide = false; - } + if (npc.noTileCollide && !player.dead) + { + if (npc.velocity.Y > 0f && npc.Bottom.Y > player.Top.Y) + npc.noTileCollide = false; + else if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + npc.noTileCollide = false; + } - if (npc.ai[0] == 0f) + if (npc.ai[0] == 0f) { if (npc.velocity.Y == 0f) { @@ -325,15 +325,15 @@ namespace CalamityMod.NPCs.Ravager npc.ai[1] += 1f; if (npc.ai[1] > 0f) { - if (revenge) - { - if (calamityGlobalNPC.newAI[0] % 3f == 0f) - npc.ai[1] += 1f; - else if (calamityGlobalNPC.newAI[0] % 2f == 0f) - npc.ai[1] += 1f; - } + if (revenge) + { + if (calamityGlobalNPC.newAI[0] % 3f == 0f) + npc.ai[1] += 1f; + else if (calamityGlobalNPC.newAI[0] % 2f == 0f) + npc.ai[1] += 1f; + } - if (!rightClawActive && !leftClawActive) + if (!rightClawActive && !leftClawActive) npc.ai[1] += 1f; if (!headActive) npc.ai[1] += 1f; @@ -341,120 +341,120 @@ namespace CalamityMod.NPCs.Ravager npc.ai[1] += 1f; } - float jumpGateValue = 180f; - if (npc.ai[1] >= jumpGateValue) - { - npc.ai[1] = -20f; - } - else if (npc.ai[1] == -1f) - { - npc.noTileCollide = true; + float jumpGateValue = 180f; + if (npc.ai[1] >= jumpGateValue) + { + npc.ai[1] = -20f; + } + else if (npc.ai[1] == -1f) + { + npc.noTileCollide = true; - npc.TargetClosest(); + npc.TargetClosest(); - bool shouldFall = player.position.Y >= npc.Bottom.Y; - float velocityXBoost = !anyHeadActive ? 6f : death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); - float velocityX = 4f + velocityXBoost; - velocityY = -16f; + bool shouldFall = player.position.Y >= npc.Bottom.Y; + float velocityXBoost = !anyHeadActive ? 6f : death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); + float velocityX = 4f + velocityXBoost; + velocityY = -16f; - float distanceBelowTarget = npc.position.Y - (player.position.Y + 80f); + float distanceBelowTarget = npc.position.Y - (player.position.Y + 80f); - if (revenge) - { - float multiplier = malice ? 0.003f : 0.0015f; - if (distanceBelowTarget > 0f) - calamityGlobalNPC.newAI[1] += 1f + distanceBelowTarget * multiplier; + if (revenge) + { + float multiplier = malice ? 0.003f : 0.0015f; + if (distanceBelowTarget > 0f) + calamityGlobalNPC.newAI[1] += 1f + distanceBelowTarget * multiplier; - float speedMultLimit = malice ? 3f : 2f; - if (calamityGlobalNPC.newAI[1] > speedMultLimit) - calamityGlobalNPC.newAI[1] = speedMultLimit; + float speedMultLimit = malice ? 3f : 2f; + if (calamityGlobalNPC.newAI[1] > speedMultLimit) + calamityGlobalNPC.newAI[1] = speedMultLimit; - if (calamityGlobalNPC.newAI[1] > 1f) - velocityY *= calamityGlobalNPC.newAI[1]; - } + if (calamityGlobalNPC.newAI[1] > 1f) + velocityY *= calamityGlobalNPC.newAI[1]; + } - if (expertMode && !finalPhase) - { - if (shouldFall) - velocityY = 1f; + if (expertMode && !finalPhase) + { + if (shouldFall) + velocityY = 1f; - if (calamityGlobalNPC.newAI[0] % 3f == 0f) - { - velocityX *= 2f; - if (!shouldFall) - velocityY *= 0.5f; - } - else if (calamityGlobalNPC.newAI[0] % 2f == 0f) - { - velocityX *= 1.5f; - if (!shouldFall) - velocityY *= 0.75f; - } - } + if (calamityGlobalNPC.newAI[0] % 3f == 0f) + { + velocityX *= 2f; + if (!shouldFall) + velocityY *= 0.5f; + } + else if (calamityGlobalNPC.newAI[0] % 2f == 0f) + { + velocityX *= 1.5f; + if (!shouldFall) + velocityY *= 0.75f; + } + } - if (finalPhase) - calamityGlobalNPC.newAI[2] = player.direction; + if (finalPhase) + calamityGlobalNPC.newAI[2] = player.direction; - float playerLocation = npc.Center.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; + float playerLocation = npc.Center.X - player.Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; - npc.velocity.X = velocityX * npc.direction; - npc.velocity.Y = velocityY; + npc.velocity.X = velocityX * npc.direction; + npc.velocity.Y = velocityY; - npc.ai[0] = finalPhase ? 2f : 1f; - npc.ai[1] = 0f; - } + npc.ai[0] = finalPhase ? 2f : 1f; + npc.ai[1] = 0f; + } } - CustomGravity(); - } + CustomGravity(); + } else if (npc.ai[0] >= 1f) { if (npc.velocity.Y == 0f && (npc.ai[1] == 31f || npc.ai[0] == 1f)) { - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 14, 1.25f, -0.25f); + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 14, 1.25f, -0.25f); - npc.ai[0] = 0f; - npc.ai[1] = 0f; + npc.ai[0] = 0f; + npc.ai[1] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) { - if (expertMode) - { - for (int i = 0; i < Main.maxNPCs; i++) - { + if (expertMode) + { + for (int i = 0; i < Main.maxNPCs; i++) + { if (Main.npc[i].type == ModContent.NPCType() && Main.npc[i].ai[0] == 0f) { Main.npc[i].ai[1] = -1f; Main.npc[i].direction = npc.direction; Main.npc[i].netUpdate = true; } - } + } - int spawnDistance = 360; + int spawnDistance = 360; - if (!NPC.AnyNPCs(ModContent.NPCType())) - { - NPC.NewNPC((int)(player.Center.X - spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType()); - NPC.NewNPC((int)(player.Center.X + spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType()); - } - else if (!NPC.AnyNPCs(ModContent.NPCType())) - { - float distanceMultiplier = finalPhase ? 2.5f : 2f; - NPC.NewNPC((int)player.Center.X - (int)(spawnDistance * distanceMultiplier), (int)player.Center.Y - 100, ModContent.NPCType()); - NPC.NewNPC((int)player.Center.X + (int)(spawnDistance * distanceMultiplier), (int)player.Center.Y - 100, ModContent.NPCType()); - } - } + if (!NPC.AnyNPCs(ModContent.NPCType())) + { + NPC.NewNPC((int)(player.Center.X - spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType()); + NPC.NewNPC((int)(player.Center.X + spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType()); + } + else if (!NPC.AnyNPCs(ModContent.NPCType())) + { + float distanceMultiplier = finalPhase ? 2.5f : 2f; + NPC.NewNPC((int)player.Center.X - (int)(spawnDistance * distanceMultiplier), (int)player.Center.Y - 100, ModContent.NPCType()); + NPC.NewNPC((int)player.Center.X + (int)(spawnDistance * distanceMultiplier), (int)player.Center.Y - 100, ModContent.NPCType()); + } + } } - if (revenge) - calamityGlobalNPC.newAI[0] += 1f; + if (revenge) + calamityGlobalNPC.newAI[0] += 1f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.TargetClosest(); + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.TargetClosest(); - for (int stompDustArea = (int)npc.position.X - 30; stompDustArea < (int)npc.position.X + npc.width + 60; stompDustArea += 30) + for (int stompDustArea = (int)npc.position.X - 30; stompDustArea < (int)npc.position.X + npc.width + 60; stompDustArea += 30) { for (int stompDustAmount = 0; stompDustAmount < 6; stompDustAmount++) { @@ -468,113 +468,113 @@ namespace CalamityMod.NPCs.Ravager } else { - Vector2 targetVector = player.position; - float aimY = targetVector.Y - 640f; - float distanceFromTargetPos = Math.Abs(npc.Top.Y - aimY); - bool inRange = npc.Top.Y <= aimY + 160f && npc.Top.Y >= aimY - 16f; + Vector2 targetVector = player.position; + float aimY = targetVector.Y - 640f; + float distanceFromTargetPos = Math.Abs(npc.Top.Y - aimY); + bool inRange = npc.Top.Y <= aimY + 160f && npc.Top.Y >= aimY - 16f; - if (phase2 && npc.ai[1] == 0f) - { - npc.noTileCollide = true; - - calamityGlobalNPC.newAI[3] += 1f; - - if (inRange) - npc.velocity.Y = 0f; - else if (npc.Top.Y > aimY) - npc.velocity.Y -= 0.2f + distanceFromTargetPos * 0.001f; - else - npc.velocity.Y += 0.2f + distanceFromTargetPos * 0.001f; - - if (npc.velocity.Y < velocityY) - npc.velocity.Y = velocityY; - if (npc.velocity.Y > -velocityY) - npc.velocity.Y = -velocityY; - } - - float maxOffsetScale = death ? 320f : 240f; - float maxOffset = maxOffsetScale * (1f - lifeRatio); - float offset = phase2 ? maxOffset * calamityGlobalNPC.newAI[2] : 0f; - - // Set offset to 0 if the target stops moving - if (Math.Abs(player.velocity.X) < 0.5f) - calamityGlobalNPC.newAI[2] = 0f; - else - calamityGlobalNPC.newAI[2] = player.direction; - - if ((npc.position.X < targetVector.X + offset && npc.position.X + npc.width > targetVector.X + player.width + offset && (inRange || npc.ai[0] != 2f)) || npc.ai[1] > 0f || calamityGlobalNPC.newAI[3] >= 180f) + if (phase2 && npc.ai[1] == 0f) { - npc.damage = npc.defDamage; + npc.noTileCollide = true; - if (phase2) - { - float stopBeforeFallTime = malice ? 25f : 30f; - if (!anyHeadActive) - stopBeforeFallTime -= 15f; - else if (expertMode) - stopBeforeFallTime -= death ? 15f * (1f - lifeRatio) : 10f * (1f - lifeRatio); + calamityGlobalNPC.newAI[3] += 1f; - if (npc.ai[1] < stopBeforeFallTime) - { - npc.ai[1] += 1f; - npc.velocity = Vector2.Zero; - } - else - { - float fallSpeedBoost = !anyHeadActive ? 1.8f : death ? 1.8f * (1f - lifeRatio) : 1.2f * (1f - lifeRatio); - float fallSpeed = (malice ? 1.8f : 1.2f) + fallSpeedBoost; + if (inRange) + npc.velocity.Y = 0f; + else if (npc.Top.Y > aimY) + npc.velocity.Y -= 0.2f + distanceFromTargetPos * 0.001f; + else + npc.velocity.Y += 0.2f + distanceFromTargetPos * 0.001f; - if (calamityGlobalNPC.newAI[1] > 1f) - fallSpeed *= calamityGlobalNPC.newAI[1]; + if (npc.velocity.Y < velocityY) + npc.velocity.Y = velocityY; + if (npc.velocity.Y > -velocityY) + npc.velocity.Y = -velocityY; + } - npc.velocity.Y += fallSpeed; + float maxOffsetScale = death ? 320f : 240f; + float maxOffset = maxOffsetScale * (1f - lifeRatio); + float offset = phase2 ? maxOffset * calamityGlobalNPC.newAI[2] : 0f; - npc.ai[1] = 31f; - } - } - else - { - npc.velocity.X *= 0.9f; + // Set offset to 0 if the target stops moving + if (Math.Abs(player.velocity.X) < 0.5f) + calamityGlobalNPC.newAI[2] = 0f; + else + calamityGlobalNPC.newAI[2] = player.direction; - if (npc.Bottom.Y < player.position.Y) - { - float fallSpeedBoost = !anyHeadActive ? 0.9f : death ? 0.9f * (1f - lifeRatio) : 0.6f * (1f - lifeRatio); - float fallSpeed = (malice ? 0.9f : 0.6f) + fallSpeedBoost; + if ((npc.position.X < targetVector.X + offset && npc.position.X + npc.width > targetVector.X + player.width + offset && (inRange || npc.ai[0] != 2f)) || npc.ai[1] > 0f || calamityGlobalNPC.newAI[3] >= 180f) + { + npc.damage = npc.defDamage; - if (calamityGlobalNPC.newAI[1] > 1f) - fallSpeed *= calamityGlobalNPC.newAI[1]; + if (phase2) + { + float stopBeforeFallTime = malice ? 25f : 30f; + if (!anyHeadActive) + stopBeforeFallTime -= 15f; + else if (expertMode) + stopBeforeFallTime -= death ? 15f * (1f - lifeRatio) : 10f * (1f - lifeRatio); - npc.velocity.Y += fallSpeed; - } - } + if (npc.ai[1] < stopBeforeFallTime) + { + npc.ai[1] += 1f; + npc.velocity = Vector2.Zero; + } + else + { + float fallSpeedBoost = !anyHeadActive ? 1.8f : death ? 1.8f * (1f - lifeRatio) : 1.2f * (1f - lifeRatio); + float fallSpeed = (malice ? 1.8f : 1.2f) + fallSpeedBoost; + + if (calamityGlobalNPC.newAI[1] > 1f) + fallSpeed *= calamityGlobalNPC.newAI[1]; + + npc.velocity.Y += fallSpeed; + + npc.ai[1] = 31f; + } + } + else + { + npc.velocity.X *= 0.9f; + + if (npc.Bottom.Y < player.position.Y) + { + float fallSpeedBoost = !anyHeadActive ? 0.9f : death ? 0.9f * (1f - lifeRatio) : 0.6f * (1f - lifeRatio); + float fallSpeed = (malice ? 0.9f : 0.6f) + fallSpeedBoost; + + if (calamityGlobalNPC.newAI[1] > 1f) + fallSpeed *= calamityGlobalNPC.newAI[1]; + + npc.velocity.Y += fallSpeed; + } + } } else { - float velocityMult = malice ? 2f : 1.8f; - float velocityXChange = 0.2f + Math.Abs(npc.Center.X - player.Center.X) * 0.001f; + float velocityMult = malice ? 2f : 1.8f; + float velocityXChange = 0.2f + Math.Abs(npc.Center.X - player.Center.X) * 0.001f; - float velocityXBoost = !anyHeadActive ? 6f : death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); - float velocityX = 8f + velocityXBoost + Math.Abs(npc.Center.X - player.Center.X) * 0.001f; + float velocityXBoost = !anyHeadActive ? 6f : death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); + float velocityX = 8f + velocityXBoost + Math.Abs(npc.Center.X - player.Center.X) * 0.001f; - if (!rightClawActive) - velocityX += 1f; - if (!leftClawActive) - velocityX += 1f; - if (!headActive) - velocityX += 1f; - if (!rightLegActive) - velocityX += 1f; - if (!leftLegActive) - velocityX += 1f; + if (!rightClawActive) + velocityX += 1f; + if (!leftClawActive) + velocityX += 1f; + if (!headActive) + velocityX += 1f; + if (!rightLegActive) + velocityX += 1f; + if (!leftLegActive) + velocityX += 1f; - if (phase2) - { - npc.damage = 0; - velocityXChange *= velocityMult; - velocityX *= velocityMult; - } + if (phase2) + { + npc.damage = 0; + velocityXChange *= velocityMult; + velocityX *= velocityMult; + } - if (npc.direction < 0) + if (npc.direction < 0) npc.velocity.X -= velocityXChange; else if (npc.direction > 0) npc.velocity.X += velocityXChange; @@ -585,42 +585,42 @@ namespace CalamityMod.NPCs.Ravager npc.velocity.X = velocityX; } - CustomGravity(); - } + CustomGravity(); + } } - void CustomGravity() - { - float gravity = phase2 ? 0f : 0.45f; - float maxFallSpeed = reduceFallSpeed ? 12f : phase2 ? 24f : 15f; - if (malice && !reduceFallSpeed) - { - gravity *= 1.25f; - maxFallSpeed *= 1.25f; - } + void CustomGravity() + { + float gravity = phase2 ? 0f : 0.45f; + float maxFallSpeed = reduceFallSpeed ? 12f : phase2 ? 24f : 15f; + if (malice && !reduceFallSpeed) + { + gravity *= 1.25f; + maxFallSpeed *= 1.25f; + } - if (calamityGlobalNPC.newAI[1] > 1f && !reduceFallSpeed) - maxFallSpeed *= calamityGlobalNPC.newAI[1]; + if (calamityGlobalNPC.newAI[1] > 1f && !reduceFallSpeed) + maxFallSpeed *= calamityGlobalNPC.newAI[1]; - npc.velocity.Y += gravity; - if (npc.velocity.Y > maxFallSpeed) - npc.velocity.Y = maxFallSpeed; - } + npc.velocity.Y += gravity; + if (npc.velocity.Y > maxFallSpeed) + npc.velocity.Y = maxFallSpeed; + } - player = Main.player[npc.target]; - if (npc.target <= 0 || npc.target == 255 || player.dead || !player.active) - { - npc.TargetClosest(); - player = Main.player[npc.target]; - } + player = Main.player[npc.target]; + if (npc.target <= 0 || npc.target == 255 || player.dead || !player.active) + { + npc.TargetClosest(); + player = Main.player[npc.target]; + } int distanceFromTarget = player.dead ? 1600 : malice ? 8400 : 5600; if (Vector2.Distance(npc.Center, player.Center) > distanceFromTarget) { npc.TargetClosest(); - player = Main.player[npc.target]; + player = Main.player[npc.target]; - if (Vector2.Distance(npc.Center, player.Center) > distanceFromTarget) + if (Vector2.Distance(npc.Center, player.Center) > distanceFromTarget) { npc.active = false; npc.netUpdate = true; @@ -686,77 +686,77 @@ namespace CalamityMod.NPCs.Ravager } } - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - Vector2 npcCenter = npc.Center; - - // NOTE: Right and left hitboxes are interchangeable, each hitbox is the same size and is located to the right or left of the center hitbox. - // Width = 83, Height = 107 - Rectangle leftHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 2f) + 8f), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); - // Width = 166, Height = 214 - Rectangle bodyHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 4f)), (int)(npcCenter.Y - (npc.height / 2f) + 8f), npc.width / 2, npc.height); - // Width = 83, Height = 107 - Rectangle rightHitbox = new Rectangle((int)(npcCenter.X + (npc.width / 4f) - 8f), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); - - Vector2 leftHitboxCenter = new Vector2(leftHitbox.X + (leftHitbox.Width / 2), leftHitbox.Y + (leftHitbox.Height / 2)); - Vector2 bodyHitboxCenter = new Vector2(bodyHitbox.X + (bodyHitbox.Width / 2), bodyHitbox.Y + (bodyHitbox.Height / 2)); - Vector2 rightHitboxCenter = new Vector2(rightHitbox.X + (rightHitbox.Width / 2), rightHitbox.Y + (rightHitbox.Height / 2)); - - Rectangle targetHitbox = target.Hitbox; - - float leftDist1 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopLeft()); - float leftDist2 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopRight()); - float leftDist3 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomLeft()); - float leftDist4 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomRight()); - - float minLeftDist = leftDist1; - if (leftDist2 < minLeftDist) - minLeftDist = leftDist2; - if (leftDist3 < minLeftDist) - minLeftDist = leftDist3; - if (leftDist4 < minLeftDist) - minLeftDist = leftDist4; - - bool insideLeftHitbox = minLeftDist <= 55f; - - float bodyDist1 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopLeft()); - float bodyDist2 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopRight()); - float bodyDist3 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomLeft()); - float bodyDist4 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomRight()); - - float minBodyDist = bodyDist1; - if (bodyDist2 < minBodyDist) - minBodyDist = bodyDist2; - if (bodyDist3 < minBodyDist) - minBodyDist = bodyDist3; - if (bodyDist4 < minBodyDist) - minBodyDist = bodyDist4; - - bool insideBodyHitbox = minBodyDist <= 110f; - - float rightDist1 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopLeft()); - float rightDist2 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopRight()); - float rightDist3 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomLeft()); - float rightDist4 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomRight()); - - float minRightDist = rightDist1; - if (rightDist2 < minRightDist) - minRightDist = rightDist2; - if (rightDist3 < minRightDist) - minRightDist = rightDist3; - if (rightDist4 < minRightDist) - minRightDist = rightDist4; - - bool insideRightHitbox = minRightDist <= 55f; - - return insideLeftHitbox || insideBodyHitbox || insideRightHitbox; - } - - public override void OnHitPlayer(Player player, int damage, bool crit) + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { - player.AddBuff(ModContent.BuffType(), 300, true); - } + Vector2 npcCenter = npc.Center; + + // NOTE: Right and left hitboxes are interchangeable, each hitbox is the same size and is located to the right or left of the center hitbox. + // Width = 83, Height = 107 + Rectangle leftHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 2f) + 8f), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); + // Width = 166, Height = 214 + Rectangle bodyHitbox = new Rectangle((int)(npcCenter.X - (npc.width / 4f)), (int)(npcCenter.Y - (npc.height / 2f) + 8f), npc.width / 2, npc.height); + // Width = 83, Height = 107 + Rectangle rightHitbox = new Rectangle((int)(npcCenter.X + (npc.width / 4f) - 8f), (int)(npcCenter.Y - (npc.height / 4f)), npc.width / 4, npc.height / 2); + + Vector2 leftHitboxCenter = new Vector2(leftHitbox.X + (leftHitbox.Width / 2), leftHitbox.Y + (leftHitbox.Height / 2)); + Vector2 bodyHitboxCenter = new Vector2(bodyHitbox.X + (bodyHitbox.Width / 2), bodyHitbox.Y + (bodyHitbox.Height / 2)); + Vector2 rightHitboxCenter = new Vector2(rightHitbox.X + (rightHitbox.Width / 2), rightHitbox.Y + (rightHitbox.Height / 2)); + + Rectangle targetHitbox = target.Hitbox; + + float leftDist1 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopLeft()); + float leftDist2 = Vector2.Distance(leftHitboxCenter, targetHitbox.TopRight()); + float leftDist3 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomLeft()); + float leftDist4 = Vector2.Distance(leftHitboxCenter, targetHitbox.BottomRight()); + + float minLeftDist = leftDist1; + if (leftDist2 < minLeftDist) + minLeftDist = leftDist2; + if (leftDist3 < minLeftDist) + minLeftDist = leftDist3; + if (leftDist4 < minLeftDist) + minLeftDist = leftDist4; + + bool insideLeftHitbox = minLeftDist <= 55f; + + float bodyDist1 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopLeft()); + float bodyDist2 = Vector2.Distance(bodyHitboxCenter, targetHitbox.TopRight()); + float bodyDist3 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomLeft()); + float bodyDist4 = Vector2.Distance(bodyHitboxCenter, targetHitbox.BottomRight()); + + float minBodyDist = bodyDist1; + if (bodyDist2 < minBodyDist) + minBodyDist = bodyDist2; + if (bodyDist3 < minBodyDist) + minBodyDist = bodyDist3; + if (bodyDist4 < minBodyDist) + minBodyDist = bodyDist4; + + bool insideBodyHitbox = minBodyDist <= 110f; + + float rightDist1 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopLeft()); + float rightDist2 = Vector2.Distance(rightHitboxCenter, targetHitbox.TopRight()); + float rightDist3 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomLeft()); + float rightDist4 = Vector2.Distance(rightHitboxCenter, targetHitbox.BottomRight()); + + float minRightDist = rightDist1; + if (rightDist2 < minRightDist) + minRightDist = rightDist2; + if (rightDist3 < minRightDist) + minRightDist = rightDist3; + if (rightDist4 < minRightDist) + minRightDist = rightDist4; + + bool insideRightHitbox = minRightDist <= 55f; + + return insideLeftHitbox || insideBodyHitbox || insideRightHitbox; + } + + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 300, true); + } public override void BossLoot(ref string name, ref int potionType) { @@ -766,19 +766,19 @@ namespace CalamityMod.NPCs.Ravager public override void NPCLoot() { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedScavenger); - // All other drops are contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) + // All other drops are contained in the bag, so they only drop directly on Normal + if (!Main.expertMode) { // Materials - DropHelper.DropItemCondition(npc, ModContent.ItemType(), !CalamityWorld.downedProvidence); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), !CalamityWorld.downedProvidence); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedProvidence); // Weapons float w = DropHelper.NormalWeaponDropRateFloat; @@ -788,11 +788,11 @@ namespace CalamityMod.NPCs.Ravager DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w) - ); + ); - // Equipment - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.downedProvidence); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); + // Equipment + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.downedProvidence); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); // Vanity diff --git a/NPCs/Ravager/RavagerClawLeft.cs b/NPCs/Ravager/RavagerClawLeft.cs index 968c775652..75ac570620 100644 --- a/NPCs/Ravager/RavagerClawLeft.cs +++ b/NPCs/Ravager/RavagerClawLeft.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { - public class RavagerClawLeft : ModNPC + public class RavagerClawLeft : ModNPC { public override void SetStaticDefaults() { @@ -19,14 +19,14 @@ namespace CalamityMod.NPCs.Ravager public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.lavaImmune = true; + npc.Calamity().canBreakPlayerDefense = true; + npc.lavaImmune = true; npc.aiStyle = -1; - npc.GetNPCDamage(); - npc.width = 80; + npc.GetNPCDamage(); + npc.width = 80; npc.height = 40; npc.defense = 40; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 12788; npc.knockBackResist = 0f; aiType = -1; @@ -38,8 +38,8 @@ namespace CalamityMod.NPCs.Ravager npc.DeathSound = SoundID.NPCDeath14; if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { - npc.damage = (int)(npc.damage * 1.5); - npc.defense *= 2; + npc.damage = (int)(npc.damage * 1.5); + npc.defense *= 2; npc.lifeMax *= 4; } if (BossRushEvent.BossRushActive) @@ -48,9 +48,9 @@ namespace CalamityMod.NPCs.Ravager } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { @@ -60,8 +60,8 @@ namespace CalamityMod.NPCs.Ravager npc.netUpdate = true; return; } - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (npc.timeLeft < 1800) + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + if (npc.timeLeft < 1800) { npc.timeLeft = 1800; } @@ -77,18 +77,18 @@ namespace CalamityMod.NPCs.Ravager if (npc.ai[0] == 0f) { npc.noTileCollide = true; - float num659 = 36f; - Vector2 vector79 = new Vector2(npc.Center.X, npc.Center.Y); + float num659 = 36f; + Vector2 vector79 = new Vector2(npc.Center.X, npc.Center.Y); float num660 = Main.npc[CalamityGlobalNPC.scavenger].Center.X - vector79.X; float num661 = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - vector79.Y; - num660 -= 120f; - num661 += 50f; - float num662 = (float)Math.Sqrt(num660 * num660 + num661 * num661); + num660 -= 120f; + num661 += 50f; + float num662 = (float)Math.Sqrt(num660 * num660 + num661 * num661); if (num662 < 12f + num659) { npc.rotation = 0f; - npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(-120f, 50f); - npc.ai[1] += 1f; + npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(-120f, 50f); + npc.ai[1] += 1f; if (npc.life < npc.lifeMax / 2 || death) { npc.ai[1] += 1f; @@ -103,15 +103,15 @@ namespace CalamityMod.NPCs.Ravager } if (npc.ai[1] >= 60f) { - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - if (npc.Center.X + 100f > Main.player[npc.target].Center.X) + if (npc.Center.X + 100f > Main.player[npc.target].Center.X) { npc.ai[1] = 0f; npc.ai[0] = 1f; @@ -279,17 +279,17 @@ namespace CalamityMod.NPCs.Ravager return true; } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() + { + return false; + } public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(ModContent.BuffType(), 180, true); - } + player.AddBuff(ModContent.BuffType(), 180, true); + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/Ravager/RavagerClawRight.cs b/NPCs/Ravager/RavagerClawRight.cs index 52957dda8b..d823b8b155 100644 --- a/NPCs/Ravager/RavagerClawRight.cs +++ b/NPCs/Ravager/RavagerClawRight.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { - public class RavagerClawRight : ModNPC + public class RavagerClawRight : ModNPC { public override void SetStaticDefaults() { @@ -19,14 +19,14 @@ namespace CalamityMod.NPCs.Ravager public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.lavaImmune = true; + npc.Calamity().canBreakPlayerDefense = true; + npc.lavaImmune = true; npc.aiStyle = -1; - npc.GetNPCDamage(); - npc.width = 80; + npc.GetNPCDamage(); + npc.width = 80; npc.height = 40; npc.defense = 40; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 12788; npc.knockBackResist = 0f; aiType = -1; @@ -38,8 +38,8 @@ namespace CalamityMod.NPCs.Ravager npc.DeathSound = SoundID.NPCDeath14; if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { - npc.damage = (int)(npc.damage * 1.5); - npc.defense *= 2; + npc.damage = (int)(npc.damage * 1.5); + npc.defense *= 2; npc.lifeMax *= 4; } if (BossRushEvent.BossRushActive) @@ -48,9 +48,9 @@ namespace CalamityMod.NPCs.Ravager } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { @@ -60,8 +60,8 @@ namespace CalamityMod.NPCs.Ravager npc.netUpdate = true; return; } - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (npc.timeLeft < 1800) + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + if (npc.timeLeft < 1800) { npc.timeLeft = 1800; } @@ -72,8 +72,8 @@ namespace CalamityMod.NPCs.Ravager { npc.alpha = 0; } - npc.ai[1] = -90f; - } + npc.ai[1] = -90f; + } if (npc.ai[0] == 0f) { npc.noTileCollide = true; @@ -81,14 +81,14 @@ namespace CalamityMod.NPCs.Ravager Vector2 vector79 = new Vector2(npc.Center.X, npc.Center.Y); float num660 = Main.npc[CalamityGlobalNPC.scavenger].Center.X - vector79.X; float num661 = Main.npc[CalamityGlobalNPC.scavenger].Center.Y - vector79.Y; - num660 += 120f; - num661 += 50f; + num660 += 120f; + num661 += 50f; float num662 = (float)Math.Sqrt(num660 * num660 + num661 * num661); if (num662 < 12f + num659) { npc.rotation = 0f; - npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(120f, 50f); - npc.ai[1] += 1f; + npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(120f, 50f); + npc.ai[1] += 1f; if (npc.life < npc.lifeMax / 2 || death) { npc.ai[1] += 1f; @@ -103,15 +103,15 @@ namespace CalamityMod.NPCs.Ravager } if (npc.ai[1] >= 60f) { - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - if (npc.Center.X - 100f < Main.player[npc.target].Center.X) + if (npc.Center.X - 100f < Main.player[npc.target].Center.X) { npc.ai[1] = 0f; npc.ai[0] = 1f; @@ -279,17 +279,17 @@ namespace CalamityMod.NPCs.Ravager return true; } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() + { + return false; + } public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(ModContent.BuffType(), 180, true); - } + player.AddBuff(ModContent.BuffType(), 180, true); + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/Ravager/RavagerHead.cs b/NPCs/Ravager/RavagerHead.cs index d34eef8285..02c128b05e 100644 --- a/NPCs/Ravager/RavagerHead.cs +++ b/NPCs/Ravager/RavagerHead.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { - public class RavagerHead : ModNPC + public class RavagerHead : ModNPC { public override void SetStaticDefaults() { @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.Ravager npc.width = 80; npc.height = 80; npc.defense = 40; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 19182; npc.knockBackResist = 0f; aiType = -1; @@ -44,29 +44,29 @@ namespace CalamityMod.NPCs.Ravager } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { - if (CalamityGlobalNPC.scavenger < 0 || !Main.npc[CalamityGlobalNPC.scavenger].active) + if (CalamityGlobalNPC.scavenger < 0 || !Main.npc[CalamityGlobalNPC.scavenger].active) { npc.active = false; npc.netUpdate = true; return; } - bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - npc.damage = 0; + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + npc.damage = 0; - if (npc.timeLeft < 1800) + if (npc.timeLeft < 1800) npc.timeLeft = 1800; - npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(1f, -20f); + npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(1f, -20f); if (npc.alpha > 0) { @@ -80,32 +80,32 @@ namespace CalamityMod.NPCs.Ravager { Main.PlaySound(SoundID.Item62, npc.position); - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - npc.ai[1] = 0f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (Main.netMode != NetmodeID.MultiplayerClient) + npc.ai[1] = 0f; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 shootFromVector = new Vector2(npc.Center.X, npc.Center.Y - 20f); - Vector2 velocity = new Vector2(0f, -15f); + Vector2 shootFromVector = new Vector2(npc.Center.X, npc.Center.Y - 20f); + Vector2 velocity = new Vector2(0f, -15f); int nuke = Projectile.NewProjectile(shootFromVector, velocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, npc.target, 0f); Main.projectile[nuke].velocity.Y = -15f; } } } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.life > 0) { diff --git a/NPCs/Ravager/RavagerHead2.cs b/NPCs/Ravager/RavagerHead2.cs index c0063c42d3..c7ca017050 100644 --- a/NPCs/Ravager/RavagerHead2.cs +++ b/NPCs/Ravager/RavagerHead2.cs @@ -22,31 +22,31 @@ namespace CalamityMod.NPCs.Ravager npc.damage = 50; npc.width = 80; npc.height = 80; - npc.defense = 40; - npc.DR_NERD(0.15f); - npc.lifeMax = 9591; - npc.knockBackResist = 0f; + npc.defense = 40; + npc.DR_NERD(0.15f); + npc.lifeMax = 9591; + npc.knockBackResist = 0f; aiType = -1; - npc.netAlways = true; - npc.noGravity = true; - npc.canGhostHeal = false; - npc.noTileCollide = true; + npc.netAlways = true; + npc.noGravity = true; + npc.canGhostHeal = false; + npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit41; npc.DeathSound = SoundID.NPCDeath14; - if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) - { - npc.defense *= 2; - npc.lifeMax *= 4; - } - if (BossRushEvent.BossRushActive) - { - npc.lifeMax = 22500; - } - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) + { + npc.defense *= 2; + npc.lifeMax *= 4; + } + if (BossRushEvent.BossRushActive) + { + npc.lifeMax = 22500; + } + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { @@ -58,134 +58,134 @@ namespace CalamityMod.NPCs.Ravager return; } - // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - npc.damage = 0; + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + npc.damage = 0; - Player player = Main.player[Main.npc[CalamityGlobalNPC.scavenger].target]; + Player player = Main.player[Main.npc[CalamityGlobalNPC.scavenger].target]; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; if (npc.timeLeft < 1800) npc.timeLeft = 1800; - // Rotation - 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 += MathHelper.TwoPi; - else if (num803 > MathHelper.TwoPi) - num803 -= MathHelper.TwoPi; + // Rotation + 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 += MathHelper.TwoPi; + else if (num803 > MathHelper.TwoPi) + num803 -= MathHelper.TwoPi; - float num804 = 0.1f; - if (npc.rotation < num803) - { - if ((num803 - npc.rotation) > MathHelper.Pi) - npc.rotation -= num804; - else - npc.rotation += num804; - } - else if (npc.rotation > num803) - { - if ((npc.rotation - num803) > MathHelper.Pi) - npc.rotation += num804; - else - npc.rotation -= num804; - } - - if (npc.rotation > num803 - num804 && npc.rotation < num803 + num804) - npc.rotation = num803; - if (npc.rotation < 0f) - 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; - - npc.ai[1] += 1f; - bool fireProjectiles = npc.ai[1] >= (malice ? 240f : 480f); - if (fireProjectiles && Vector2.Distance(npc.Center, player.Center) > 80f) + float num804 = 0.1f; + if (npc.rotation < num803) { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float projectileVelocity = death ? 8f : 6f; - - if (npc.ai[1] >= 600f) - { - npc.ai[0] += 1f; - npc.ai[1] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(SoundID.Item62, npc.position); - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, Vector2.Normalize(player.Center - npc.Center) * projectileVelocity * 0.25f, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, Main.npc[CalamityGlobalNPC.scavenger].target, 0f); - } - } - else - { - if (npc.ai[1] % 40f == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(SoundID.Item33, npc.position); - Projectile.NewProjectile(npc.Center, Vector2.Normalize(player.Center - npc.Center) * projectileVelocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, -1f); - } - } - } + if ((num803 - npc.rotation) > MathHelper.Pi) + npc.rotation -= num804; + else + npc.rotation += num804; + } + else if (npc.rotation > num803) + { + if ((npc.rotation - num803) > MathHelper.Pi) + npc.rotation += num804; + else + npc.rotation -= num804; } - float num823 = 22f; - float num824 = 0.3f; - if (death) - { - num823 += 4f; - num824 += 0.05f; - } - if (provy) - { - num823 *= 1.25f; - num824 *= 1.25f; - } + if (npc.rotation > num803 - num804 && npc.rotation < num803 + num804) + npc.rotation = num803; + if (npc.rotation < 0f) + 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; - Vector2 vector82 = npc.Center; - float distanceX = npc.ai[0] % 2f == 0f ? 480f : -480f; - float distanceY = fireProjectiles ? -320f : 320f; - float num825 = player.Center.X + (fireProjectiles ? distanceX : 0f) - vector82.X; - float num826 = player.Center.Y + distanceY - vector82.Y; - float num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); - num827 = num823 / num827; - num825 *= num827; - num826 *= num827; + npc.ai[1] += 1f; + bool fireProjectiles = npc.ai[1] >= (malice ? 240f : 480f); + if (fireProjectiles && Vector2.Distance(npc.Center, player.Center) > 80f) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float projectileVelocity = death ? 8f : 6f; - if (npc.velocity.X < num825) - { - npc.velocity.X += num824; - if (npc.velocity.X < 0f && num825 > 0f) - npc.velocity.X += num824; - } - else if (npc.velocity.X > num825) - { - npc.velocity.X -= num824; - if (npc.velocity.X > 0f && num825 < 0f) - npc.velocity.X -= num824; - } - if (npc.velocity.Y < num826) - { - npc.velocity.Y += num824; - if (npc.velocity.Y < 0f && num826 > 0f) - npc.velocity.Y += num824; - } - else if (npc.velocity.Y > num826) - { - npc.velocity.Y -= num824; - if (npc.velocity.Y > 0f && num826 < 0f) - npc.velocity.Y -= num824; - } - } + if (npc.ai[1] >= 600f) + { + npc.ai[0] += 1f; + npc.ai[1] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(SoundID.Item62, npc.position); + type = ModContent.ProjectileType(); + damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center, Vector2.Normalize(player.Center - npc.Center) * projectileVelocity * 0.25f, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, Main.npc[CalamityGlobalNPC.scavenger].target, 0f); + } + } + else + { + if (npc.ai[1] % 40f == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(SoundID.Item33, npc.position); + Projectile.NewProjectile(npc.Center, Vector2.Normalize(player.Center - npc.Center) * projectileVelocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, -1f); + } + } + } + } + + float num823 = 22f; + float num824 = 0.3f; + if (death) + { + num823 += 4f; + num824 += 0.05f; + } + if (provy) + { + num823 *= 1.25f; + num824 *= 1.25f; + } + + Vector2 vector82 = npc.Center; + float distanceX = npc.ai[0] % 2f == 0f ? 480f : -480f; + float distanceY = fireProjectiles ? -320f : 320f; + float num825 = player.Center.X + (fireProjectiles ? distanceX : 0f) - vector82.X; + float num826 = player.Center.Y + distanceY - vector82.Y; + float num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); + num827 = num823 / num827; + num825 *= num827; + num826 *= num827; + + if (npc.velocity.X < num825) + { + npc.velocity.X += num824; + if (npc.velocity.X < 0f && num825 > 0f) + npc.velocity.X += num824; + } + else if (npc.velocity.X > num825) + { + npc.velocity.X -= num824; + if (npc.velocity.X > 0f && num825 < 0f) + npc.velocity.X -= num824; + } + if (npc.velocity.Y < num826) + { + npc.velocity.Y += num824; + if (npc.velocity.Y < 0f && num826 > 0f) + npc.velocity.Y += num824; + } + else if (npc.velocity.Y > num826) + { + npc.velocity.Y -= num824; + if (npc.velocity.Y > 0f && num826 < 0f) + npc.velocity.Y -= num824; + } + } public override void HitEffect(int hitDirection, double damage) { @@ -207,8 +207,8 @@ namespace CalamityMod.NPCs.Ravager } } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; } } diff --git a/NPCs/Ravager/RavagerLegLeft.cs b/NPCs/Ravager/RavagerLegLeft.cs index ef44ef81af..5543c05d4a 100644 --- a/NPCs/Ravager/RavagerLegLeft.cs +++ b/NPCs/Ravager/RavagerLegLeft.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { - public class RavagerLegLeft : ModNPC + public class RavagerLegLeft : ModNPC { public override void SetStaticDefaults() { @@ -21,7 +21,7 @@ namespace CalamityMod.NPCs.Ravager npc.width = 60; npc.height = 60; npc.defense = 40; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 12788; npc.knockBackResist = 0f; aiType = -1; @@ -43,9 +43,9 @@ namespace CalamityMod.NPCs.Ravager } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { @@ -56,8 +56,8 @@ namespace CalamityMod.NPCs.Ravager return; } - // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - npc.damage = 0; + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + npc.damage = 0; if (npc.alpha > 0) { @@ -68,10 +68,10 @@ namespace CalamityMod.NPCs.Ravager npc.ai[1] = 0f; } - npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(-70f, 88f); + npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(-70f, 88f); } - public override bool CheckActive() => false; + public override bool CheckActive() => false; public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/Ravager/RavagerLegRight.cs b/NPCs/Ravager/RavagerLegRight.cs index 29f9ee646f..a5748c75c5 100644 --- a/NPCs/Ravager/RavagerLegRight.cs +++ b/NPCs/Ravager/RavagerLegRight.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { - public class RavagerLegRight : ModNPC + public class RavagerLegRight : ModNPC { public override void SetStaticDefaults() { @@ -21,7 +21,7 @@ namespace CalamityMod.NPCs.Ravager npc.width = 60; npc.height = 60; npc.defense = 40; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 12788; npc.knockBackResist = 0f; aiType = -1; @@ -43,35 +43,35 @@ namespace CalamityMod.NPCs.Ravager } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { - if (CalamityGlobalNPC.scavenger < 0 || !Main.npc[CalamityGlobalNPC.scavenger].active) - { - npc.active = false; - npc.netUpdate = true; - return; - } + if (CalamityGlobalNPC.scavenger < 0 || !Main.npc[CalamityGlobalNPC.scavenger].active) + { + npc.active = false; + npc.netUpdate = true; + return; + } - // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - npc.damage = 0; + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + npc.damage = 0; - if (npc.alpha > 0) - { - npc.alpha -= 10; - if (npc.alpha < 0) - npc.alpha = 0; + if (npc.alpha > 0) + { + npc.alpha -= 10; + if (npc.alpha < 0) + npc.alpha = 0; - npc.ai[1] = 0f; - } + npc.ai[1] = 0f; + } - npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(70f, 88f); - } + npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(70f, 88f); + } - public override bool CheckActive() => false; + public override bool CheckActive() => false; public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/Ravager/RockPillar.cs b/NPCs/Ravager/RockPillar.cs index 0a0ce2d403..14754917c3 100644 --- a/NPCs/Ravager/RockPillar.cs +++ b/NPCs/Ravager/RockPillar.cs @@ -17,24 +17,24 @@ namespace CalamityMod.NPCs.Ravager public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.width = 60; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.width = 60; npc.height = 300; - npc.defense = 50; - npc.DR_NERD(0.3f); - npc.chaseable = false; - npc.canGhostHeal = false; - npc.lifeMax = CalamityWorld.downedProvidence ? 20000 : 5000; + npc.defense = 50; + npc.DR_NERD(0.3f); + npc.chaseable = false; + npc.canGhostHeal = false; + npc.lifeMax = CalamityWorld.downedProvidence ? 20000 : 5000; npc.alpha = 255; npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; - npc.HitSound = SoundID.NPCHit41; - npc.DeathSound = SoundID.NPCDeath14; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToWater = true; - } + npc.HitSound = SoundID.NPCHit41; + npc.DeathSound = SoundID.NPCDeath14; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToWater = true; + } public override void AI() { @@ -49,19 +49,19 @@ namespace CalamityMod.NPCs.Ravager if (npc.timeLeft < 1800) npc.timeLeft = 1800; - if (npc.alpha > 0) + if (npc.alpha > 0) { - npc.damage = 0; + npc.damage = 0; - npc.alpha -= 10; + npc.alpha -= 10; if (npc.alpha < 0) npc.alpha = 0; } else { if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) - npc.damage = (int)(npc.defDamage * 1.5); - else + npc.damage = (int)(npc.defDamage * 1.5); + else npc.damage = npc.defDamage; } @@ -71,29 +71,29 @@ namespace CalamityMod.NPCs.Ravager { if (npc.ai[1] == -1f) { - Main.PlaySound(SoundID.Item62, npc.position); + Main.PlaySound(SoundID.Item62, npc.position); - for (int num621 = 0; num621 < 10; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 10; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } + for (int num621 = 0; num621 < 10; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 10; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } - npc.noTileCollide = true; - npc.velocity.X = ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 15 : 12) * npc.direction; + npc.noTileCollide = true; + npc.velocity.X = ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 15 : 12) * npc.direction; npc.velocity.Y = -28.5f; npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -115,27 +115,27 @@ namespace CalamityMod.NPCs.Ravager { npc.velocity.Y += 0.2f; - if (npc.velocity.Y >= 0f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.noTileCollide = false; - } + if (npc.velocity.Y >= 0f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + npc.noTileCollide = false; + } } } - public override bool CheckActive() => false; + public override bool CheckActive() => false; - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 180, true); - Main.PlaySound(SoundID.Item14, npc.position); - npc.ai[0] = 0f; - npc.life = 0; - HitEffect(npc.direction, 9999); - npc.netUpdate = true; - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 180, true); + Main.PlaySound(SoundID.Item14, npc.position); + npc.ai[0] = 0f; + npc.life = 0; + HitEffect(npc.direction, 9999); + npc.netUpdate = true; + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { @@ -164,40 +164,40 @@ namespace CalamityMod.NPCs.Ravager Main.dust[num624].velocity *= 2f; } - float y = npc.height / 6f; - float randomVelocityScale = 0.25f; - for (int i = 0; i < 2; i++) - { - Vector2 randomVelocity = npc.velocity * Main.rand.NextFloat() * randomVelocityScale; - Gore.NewGore(npc.position, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar"), 1f); - Gore.NewGore(npc.position + Vector2.UnitY * y, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar2"), 1f); - Gore.NewGore(npc.position + Vector2.UnitY * y * 2f, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar3"), 1f); - Gore.NewGore(npc.position + Vector2.UnitY * y * 3f, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar4"), 1f); - Gore.NewGore(npc.position + Vector2.UnitY * y * 4f, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar5"), 1f); - Gore.NewGore(npc.position + Vector2.UnitY * y * 5f, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar6"), 1f); - } - } - else - { - for (int num621 = 0; num621 < 2; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 2; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Stone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } + float y = npc.height / 6f; + float randomVelocityScale = 0.25f; + for (int i = 0; i < 2; i++) + { + Vector2 randomVelocity = npc.velocity * Main.rand.NextFloat() * randomVelocityScale; + Gore.NewGore(npc.position, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar"), 1f); + Gore.NewGore(npc.position + Vector2.UnitY * y, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar2"), 1f); + Gore.NewGore(npc.position + Vector2.UnitY * y * 2f, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar3"), 1f); + Gore.NewGore(npc.position + Vector2.UnitY * y * 3f, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar4"), 1f); + Gore.NewGore(npc.position + Vector2.UnitY * y * 4f, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar5"), 1f); + Gore.NewGore(npc.position + Vector2.UnitY * y * 5f, npc.velocity + randomVelocity, mod.GetGoreSlot("Gores/ScavengerGores/RockPillar6"), 1f); + } + } + else + { + for (int num621 = 0; num621 < 2; num621++) + { + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 2; num623++) + { + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Stone, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Iron, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } } } } diff --git a/NPCs/Signus/CosmicLantern.cs b/NPCs/Signus/CosmicLantern.cs index 4adb728ea5..7b83129185 100644 --- a/NPCs/Signus/CosmicLantern.cs +++ b/NPCs/Signus/CosmicLantern.cs @@ -8,21 +8,21 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.Signus { - public class CosmicLantern : ModNPC + public class CosmicLantern : ModNPC { public override void SetStaticDefaults() { DisplayName.SetDefault("Cosmic Lantern"); Main.npcFrameCount[npc.type] = 4; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { npc.aiStyle = -1; aiType = -1; - npc.GetNPCDamage(); - npc.width = 25; + npc.GetNPCDamage(); + npc.width = 25; npc.height = 25; npc.defense = 50; npc.lifeMax = 25; @@ -35,8 +35,8 @@ namespace CalamityMod.NPCs.Signus npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit53; npc.DeathSound = SoundID.NPCDeath44; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToSickness = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -58,16 +58,16 @@ namespace CalamityMod.NPCs.Signus public override void AI() { - if (CalamityGlobalNPC.signus < 0 || !Main.npc[CalamityGlobalNPC.signus].active) - { - npc.active = false; - npc.netUpdate = true; - return; - } + if (CalamityGlobalNPC.signus < 0 || !Main.npc[CalamityGlobalNPC.signus].active) + { + npc.active = false; + npc.netUpdate = true; + return; + } - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.3f, 0.3f, 0.3f); + Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.3f, 0.3f, 0.3f); - npc.alpha -= 3; + npc.alpha -= 3; if (npc.alpha < 0) { npc.alpha = 0; @@ -76,71 +76,71 @@ namespace CalamityMod.NPCs.Signus Main.dust[num1262].noGravity = true; } - bool revenge = CalamityWorld.revenge; - float playerDistNormMult = revenge ? 24f : 22f; - if (BossRushEvent.BossRushActive || CalamityWorld.malice) - playerDistNormMult = 30f; + bool revenge = CalamityWorld.revenge; + float playerDistNormMult = revenge ? 24f : 22f; + if (BossRushEvent.BossRushActive || CalamityWorld.malice) + playerDistNormMult = 30f; CalamityAI.DungeonSpiritAI(npc, mod, playerDistNormMult, 0f, true); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Signus/CosmicLanternGlow"); - Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/Signus/CosmicLanternGlow"); + Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return npc.alpha == 0; diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index 8e08aec14a..1df220aed7 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -32,20 +32,20 @@ namespace CalamityMod.NPCs.Signus { DisplayName.SetDefault("Signus, Envoy of the Devourer"); Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 32f; - npc.GetNPCDamage(); - npc.width = 130; + npc.Calamity().canBreakPlayerDefense = true; + npc.npcSlots = 32f; + npc.GetNPCDamage(); + npc.width = 130; npc.height = 130; npc.defense = 60; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel3; - npc.LifeMaxNERB(notDoGFight ? 297000 : 73000, notDoGFight ? 356400 : 87600, 240000); + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel3; + npc.LifeMaxNERB(notDoGFight ? 297000 : 73000, notDoGFight ? 356400 : 87600, 240000); // If fought alone, Signus plays his own theme if (notDoGFight) @@ -69,110 +69,110 @@ namespace CalamityMod.NPCs.Signus npc.HitSound = SoundID.NPCHit49; npc.DeathSound = SoundID.NPCDeath51; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToSickness = false; + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(spawnX); writer.Write(spawnY); writer.Write(lifeToAlpha); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { spawnX = reader.ReadInt32(); spawnY = reader.ReadInt32(); lifeToAlpha = reader.ReadInt32(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - CalamityGlobalNPC.signus = npc.whoAmI; + CalamityGlobalNPC.signus = npc.whoAmI; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - Vector2 vectorCenter = npc.Center; + Vector2 vectorCenter = npc.Center; - double lifeRatio = npc.life / (double)npc.lifeMax; + double lifeRatio = npc.life / (double)npc.lifeMax; - lifeToAlpha = (int)(100.0 * (1.0 - lifeRatio)); - int maxCharges = death ? 1 : revenge ? 2 : expertMode ? 3 : 4; - int maxTeleports = (death && lifeRatio < 0.9) ? 1 : revenge ? 2 : expertMode ? 3 : 4; - float inertia = malice ? 9f : death ? 10f : revenge ? 11f : expertMode ? 12f : 14f; - float chargeVelocity = malice ? 16f : death ? 14f : revenge ? 13f : expertMode ? 12f : 10f; - bool phase2 = lifeRatio < 0.75f && expertMode; + lifeToAlpha = (int)(100.0 * (1.0 - lifeRatio)); + int maxCharges = death ? 1 : revenge ? 2 : expertMode ? 3 : 4; + int maxTeleports = (death && lifeRatio < 0.9) ? 1 : revenge ? 2 : expertMode ? 3 : 4; + float inertia = malice ? 9f : death ? 10f : revenge ? 11f : expertMode ? 12f : 14f; + float chargeVelocity = malice ? 16f : death ? 14f : revenge ? 13f : expertMode ? 12f : 10f; + bool phase2 = lifeRatio < 0.75f && expertMode; bool phase3 = lifeRatio < 0.5f; - bool phase4 = lifeRatio < 0.33f; + bool phase4 = lifeRatio < 0.33f; npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; npc.damage = npc.defDamage; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, vectorCenter) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, vectorCenter) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 6400f) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 6400f) - { - if (npc.timeLeft < 10) - { - CalamityWorld.DoGSecondStageCountdown = 0; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); - netMessage.Write(CalamityWorld.DoGSecondStageCountdown); - netMessage.Send(); - } - } + if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 6400f) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 6400f) + { + if (npc.timeLeft < 10) + { + CalamityWorld.DoGSecondStageCountdown = 0; + if (Main.netMode == NetmodeID.Server) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); + netMessage.Write(CalamityWorld.DoGSecondStageCountdown); + netMessage.Send(); + } + } - npc.rotation = npc.velocity.X * 0.04f; + npc.rotation = npc.velocity.X * 0.04f; - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.15f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; + if (npc.velocity.Y > 3f) + npc.velocity.Y = 3f; + npc.velocity.Y -= 0.15f; + if (npc.velocity.Y < -12f) + npc.velocity.Y = -12f; - if (npc.timeLeft > 60) - npc.timeLeft = 60; + if (npc.timeLeft > 60) + npc.timeLeft = 60; - if (npc.ai[0] != 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - spawnY = 120; - npc.netUpdate = true; - } - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + if (npc.ai[0] != 0f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + spawnY = 120; + npc.netUpdate = true; + } + return; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; if (lifeToAlpha < 50 && npc.ai[0] != 1f) { @@ -191,11 +191,11 @@ namespace CalamityMod.NPCs.Signus if (npc.ai[0] <= 2f) { npc.rotation = npc.velocity.X * 0.04f; - float playerLocation = vectorCenter.X - player.Center.X; - npc.direction = playerLocation < 0f ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = vectorCenter.X - player.Center.X; + npc.direction = playerLocation < 0f ? 1 : -1; + npc.spriteDirection = npc.direction; - npc.knockBackResist = 0.05f; + npc.knockBackResist = 0.05f; if (expertMode) npc.knockBackResist *= Main.expertKnockBack; if (phase3 || revenge) @@ -217,28 +217,28 @@ namespace CalamityMod.NPCs.Signus else npc.knockBackResist = 0f; - if (npc.ai[0] == -1f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int phase; - do phase = Main.rand.Next(5); - while (phase == npc.ai[1] || (phase == 0 && phase4) || phase == 1 || phase == 2); + if (npc.ai[0] == -1f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int phase; + do phase = Main.rand.Next(5); + while (phase == npc.ai[1] || (phase == 0 && phase4) || phase == 1 || phase == 2); - npc.ai[0] = phase; - npc.ai[1] = 0f; + npc.ai[0] = phase; + npc.ai[1] = 0f; npc.netUpdate = true; - } - } - else if (npc.ai[0] == 0f) + } + } + else if (npc.ai[0] == 0f) { - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[1] += malice ? 1.5f : 1f; - if (expertMode) - npc.localAI[1] += death ? 3f * (float)(1D - lifeRatio) : 2f * (float)(1D - lifeRatio); + if (expertMode) + npc.localAI[1] += death ? 3f * (float)(1D - lifeRatio) : 2f * (float)(1D - lifeRatio); if (npc.localAI[1] >= 120f) { @@ -296,8 +296,8 @@ namespace CalamityMod.NPCs.Signus } npc.alpha += malice ? 3 : 2; - if (expertMode) - npc.alpha += death ? (int)Math.Round(4.5D * (1D - lifeRatio)) : (int)Math.Round(3D * (1D - lifeRatio)); + if (expertMode) + npc.alpha += death ? (int)Math.Round(4.5D * (1D - lifeRatio)) : (int)Math.Round(3D * (1D - lifeRatio)); if (npc.alpha >= 255) { @@ -325,9 +325,9 @@ namespace CalamityMod.NPCs.Signus { if (Main.netMode != NetmodeID.MultiplayerClient && revenge) { - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 122); + Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 122); - int num660 = NPC.NewNPC((int)(player.position.X + 750f), (int)player.position.Y, ModContent.NPCType()); + int num660 = NPC.NewNPC((int)(player.position.X + 750f), (int)player.position.Y, ModContent.NPCType()); if (Main.netMode == NetmodeID.Server) NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num660, 0f, 0f, 0f, 0, 0, 0); @@ -374,7 +374,7 @@ namespace CalamityMod.NPCs.Signus npc.alpha = lifeToAlpha; if (npc.ai[3] >= maxTeleports) { - npc.ai[0] = -1f; + npc.ai[0] = -1f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -387,44 +387,44 @@ namespace CalamityMod.NPCs.Signus } else if (npc.ai[0] == 3f) { - npc.damage = 0; + npc.damage = 0; npc.rotation = npc.velocity.X * 0.04f; - float playerLocation = vectorCenter.X - player.Center.X; - npc.direction = playerLocation < 0f ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = vectorCenter.X - player.Center.X; + npc.direction = playerLocation < 0f ? 1 : -1; + npc.spriteDirection = npc.direction; - float divisor = expertMode ? (malice ? 10f : death ? 12f : revenge ? 15f : 20f) - (float)Math.Ceiling(5D * (1D - lifeRatio)) : 20f; - float scytheBarrageTime = divisor * 3f; - float scytheBarrageCooldown = divisor * 3f; + float divisor = expertMode ? (malice ? 10f : death ? 12f : revenge ? 15f : 20f) - (float)Math.Ceiling(5D * (1D - lifeRatio)) : 20f; + float scytheBarrageTime = divisor * 3f; + float scytheBarrageCooldown = divisor * 3f; - npc.ai[1] += 1f; - if (npc.ai[2] > 0f) - npc.ai[2] -= 1f; - else - npc.ai[2] = scytheBarrageTime + scytheBarrageCooldown; + npc.ai[1] += 1f; + if (npc.ai[2] > 0f) + npc.ai[2] -= 1f; + else + npc.ai[2] = scytheBarrageTime + scytheBarrageCooldown; if (npc.ai[2] <= scytheBarrageTime) { - if (npc.ai[1] % divisor == divisor - 1f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float num1070 = 15f; - float num1071 = player.Center.X - vectorCenter.X; - float num1072 = player.Center.Y - vectorCenter.Y; - float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); - num1073 = num1070 / num1073; - num1071 *= num1073; - num1072 *= num1073; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, num1071, num1072, type, damage, 0f, Main.myPlayer, 0f, npc.target + 1); - } - } + if (npc.ai[1] % divisor == divisor - 1f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float num1070 = 15f; + float num1071 = player.Center.X - vectorCenter.X; + float num1072 = player.Center.Y - vectorCenter.Y; + float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); + num1073 = num1070 / num1073; + num1071 *= num1073; + num1072 *= num1073; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(vectorCenter.X, vectorCenter.Y, num1071, num1072, type, damage, 0f, Main.myPlayer, 0f, npc.target + 1); + } + } } - float maxVelocityY = malice ? 1.5f : death ? 2.5f : 3f; - float maxVelocityX = malice ? 5f : death ? 7f : 8f; + float maxVelocityY = malice ? 1.5f : death ? 2.5f : 3f; + float maxVelocityX = malice ? 5f : death ? 7f : 8f; if (npc.position.Y > player.position.Y - 200f) { @@ -471,11 +471,11 @@ namespace CalamityMod.NPCs.Signus if (npc.ai[1] >= divisor * 20f) { - npc.ai[0] = -1f; - npc.ai[1] = 3f; + npc.ai[0] = -1f; + npc.ai[1] = 3f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); + npc.TargetClosest(); npc.netUpdate = true; } } @@ -516,8 +516,8 @@ namespace CalamityMod.NPCs.Signus if (calamityGlobalNPC.newAI[0] == 0f) // Line up the charge { float velocity = malice ? 18f : revenge ? 16f : expertMode ? 15f : 14f; - if (expertMode) - velocity += death ? 6f * (float)(1D - lifeRatio) : 4f * (float)(1D - lifeRatio); + if (expertMode) + velocity += death ? 6f * (float)(1D - lifeRatio) : 4f * (float)(1D - lifeRatio); Vector2 vector126 = player.Center - vectorCenter; Vector2 vector127 = vector126 - Vector2.UnitY * 300f; @@ -545,7 +545,7 @@ namespace CalamityMod.NPCs.Signus } else { - calamityGlobalNPC.newAI[0] = 1f; + calamityGlobalNPC.newAI[0] = 1f; npc.ai[2] = vector126.X; npc.ai[3] = vector126.Y; npc.netUpdate = true; @@ -553,12 +553,12 @@ namespace CalamityMod.NPCs.Signus } else if (calamityGlobalNPC.newAI[0] == 1f) // Pause before charge { - npc.velocity *= 0.8f; + npc.velocity *= 0.8f; npc.ai[1] += 1f; if (npc.ai[1] >= 5f) { - calamityGlobalNPC.newAI[0] = 2f; + calamityGlobalNPC.newAI[0] = 2f; npc.netUpdate = true; @@ -567,30 +567,30 @@ namespace CalamityMod.NPCs.Signus velocity *= chargeVelocity; npc.velocity = velocity; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + } } else if (calamityGlobalNPC.newAI[0] == 2f) // Charging { - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[2] += 1f; + npc.ai[2] += 1f; if (phase2 && npc.ai[2] % 3f == 0f) { Main.PlaySound(SoundID.Item73, npc.position); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(vectorCenter, Vector2.Zero, type, damage, 0f, Main.myPlayer); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(vectorCenter, Vector2.Zero, type, damage, 0f, Main.myPlayer); } } npc.ai[1] += 1f; - bool flag65 = vectorCenter.Y + 50f > player.Center.Y; - if ((npc.ai[1] >= 90f && flag65) || npc.velocity.Length() < 8f) + bool flag65 = vectorCenter.Y + 50f > player.Center.Y; + if ((npc.ai[1] >= 90f && flag65) || npc.velocity.Length() < 8f) { - calamityGlobalNPC.newAI[0] = 3f; + calamityGlobalNPC.newAI[0] = 3f; npc.ai[1] = 30f; npc.ai[2] = 0f; npc.velocity /= 2f; @@ -611,23 +611,23 @@ namespace CalamityMod.NPCs.Signus npc.ai[1] -= 1f; if (npc.ai[1] <= 0f) { - npc.TargetClosest(); - calamityGlobalNPC.newAI[1] += 1f; - if (calamityGlobalNPC.newAI[1] >= maxCharges) - { - npc.ai[0] = -1f; - npc.ai[1] = 4f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - } - else - { - npc.ai[1] = 0f; - } - calamityGlobalNPC.newAI[0] = 0f; - npc.netUpdate = true; - } + npc.TargetClosest(); + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] >= maxCharges) + { + npc.ai[0] = -1f; + npc.ai[1] = 4f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + } + else + { + npc.ai[1] = 0f; + } + calamityGlobalNPC.newAI[0] = 0f; + npc.netUpdate = true; + } npc.velocity *= 0.97f; } } @@ -661,85 +661,85 @@ namespace CalamityMod.NPCs.Signus public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { Texture2D NPCTexture = Main.npcTexture[npc.type]; - Texture2D glowMaskTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusGlow"); + Texture2D glowMaskTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusGlow"); - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - int num153 = 5; - Rectangle frame = npc.frame; - int frameCount = Main.npcFrameCount[npc.type]; + int num153 = 5; + Rectangle frame = npc.frame; + int frameCount = Main.npcFrameCount[npc.type]; - if (npc.ai[0] == 4f) - { - NPCTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusAlt2"); - glowMaskTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusAlt2Glow"); - num153 = 10; - int frameY = 94 * (int)(npc.frameCounter / 12.0); - if (frameY >= 94 * 6) - frameY = 0; - frame = new Rectangle(0, frameY, NPCTexture.Width, NPCTexture.Height / frameCount); - } - else if (npc.ai[0] == 3f) - { - NPCTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusAlt"); - glowMaskTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusAltGlow"); - num153 = 7; - } - else - { - NPCTexture = Main.npcTexture[npc.type]; - glowMaskTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusGlow"); - } + if (npc.ai[0] == 4f) + { + NPCTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusAlt2"); + glowMaskTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusAlt2Glow"); + num153 = 10; + int frameY = 94 * (int)(npc.frameCounter / 12.0); + if (frameY >= 94 * 6) + frameY = 0; + frame = new Rectangle(0, frameY, NPCTexture.Width, NPCTexture.Height / frameCount); + } + else if (npc.ai[0] == 3f) + { + NPCTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusAlt"); + glowMaskTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusAltGlow"); + num153 = 7; + } + else + { + NPCTexture = Main.npcTexture[npc.type]; + glowMaskTexture = ModContent.GetTexture("CalamityMod/NPCs/Signus/SignusGlow"); + } - Vector2 vector11 = new Vector2(NPCTexture.Width / 2, NPCTexture.Height / frameCount / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - float scale = npc.scale; - float rotation = npc.rotation; - float offsetY = npc.gfxOffY; + Vector2 vector11 = new Vector2(NPCTexture.Width / 2, NPCTexture.Height / frameCount / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + float scale = npc.scale; + float rotation = npc.rotation; + float offsetY = npc.gfxOffY; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; - vector41 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(NPCTexture, vector41, new Rectangle?(frame), color38, rotation, vector11, scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = drawColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; + vector41 += vector11 * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(NPCTexture, vector41, new Rectangle?(frame), color38, rotation, vector11, scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; - vector43 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(NPCTexture, vector43, new Rectangle?(frame), npc.GetAlpha(drawColor), rotation, vector11, scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(NPCTexture.Width, NPCTexture.Height / frameCount) * scale / 2f; + vector43 += vector11 * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(NPCTexture, vector43, new Rectangle?(frame), npc.GetAlpha(drawColor), rotation, vector11, scale, spriteEffects, 0f); - Color color40 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + Color color40 = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color40; - color41 = Color.Lerp(color41, color36, amount9); - color41 = npc.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(glowMaskTexture.Width, glowMaskTexture.Height / frameCount) * scale / 2f; - vector44 += vector11 * scale + new Vector2(0f, 4f + offsetY); - spriteBatch.Draw(glowMaskTexture, vector44, new Rectangle?(frame), color41, rotation, vector11, scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color40; + color41 = Color.Lerp(color41, color36, amount9); + color41 = npc.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(glowMaskTexture.Width, glowMaskTexture.Height / frameCount) * scale / 2f; + vector44 += vector11 * scale + new Vector2(0f, 4f + offsetY); + spriteBatch.Draw(glowMaskTexture, vector44, new Rectangle?(frame), color41, rotation, vector11, scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(glowMaskTexture, vector43, new Rectangle?(frame), color40, rotation, vector11, scale, spriteEffects, 0f); + spriteBatch.Draw(glowMaskTexture, vector43, new Rectangle?(frame), color40, rotation, vector11, scale, spriteEffects, 0f); - return false; + return false; } public override void BossLoot(ref string name, ref int potionType) @@ -750,38 +750,38 @@ namespace CalamityMod.NPCs.Signus public override void NPCLoot() { // Only drop items if fought at full strength - bool fullStrength = !CalamityWorld.downedSentinel3 || CalamityWorld.DoGSecondStageCountdown <= 0; + bool fullStrength = !CalamityWorld.downedSentinel3 || CalamityWorld.DoGSecondStageCountdown <= 0; if (fullStrength) { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - bool lastSentinelKilled = CalamityWorld.downedSentinel1 && CalamityWorld.downedSentinel2 && !CalamityWorld.downedSentinel3; - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, lastSentinelKilled); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + bool lastSentinelKilled = CalamityWorld.downedSentinel1 && CalamityWorld.downedSentinel2 && !CalamityWorld.downedSentinel3; + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, lastSentinelKilled); - if (!Main.expertMode) - { - // Materials - DropHelper.DropItem(npc, ModContent.ItemType(), true, 2, 3); + if (!Main.expertMode) + { + // Materials + DropHelper.DropItem(npc, ModContent.ItemType(), true, 2, 3); - // Weapons - DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + // Weapons + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - if (Main.rand.NextBool(20)) - { - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - } - } + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + if (Main.rand.NextBool(20)) + { + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + } + } } // If DoG's fight is active, set the timer precisely for DoG phase 2 to spawn @@ -796,17 +796,17 @@ namespace CalamityMod.NPCs.Signus netMessage.Send(); } - // Mark DoG fight sentinels as dead - CalamityWorld.downedSecondSentinels = true; - CalamityNetcode.SyncWorld(); - } + // Mark DoG fight sentinels as dead + CalamityWorld.downedSecondSentinels = true; + CalamityNetcode.SyncWorld(); + } - // Mark Signus as dead - if (fullStrength) - { - CalamityWorld.downedSentinel3 = true; - CalamityNetcode.SyncWorld(); - } + // Mark Signus as dead + if (fullStrength) + { + CalamityWorld.downedSentinel3 = true; + CalamityNetcode.SyncWorld(); + } } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) @@ -856,30 +856,30 @@ namespace CalamityMod.NPCs.Signus } } - // Can only hit the target if within certain distance - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + cooldownSlot = 1; - Rectangle targetHitbox = target.Hitbox; + Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); + float dist1 = Vector2.Distance(npc.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(npc.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(npc.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(npc.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= 60f; - } + return minDist <= 60f; + } - public override void OnHitPlayer(Player player, int damage, bool crit) + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 420, true); } diff --git a/NPCs/Signus/SignusBomb.cs b/NPCs/Signus/SignusBomb.cs index f9e2c84faa..26d38db737 100644 --- a/NPCs/Signus/SignusBomb.cs +++ b/NPCs/Signus/SignusBomb.cs @@ -16,14 +16,14 @@ namespace CalamityMod.NPCs.Signus public override void SetStaticDefaults() { DisplayName.SetDefault("Cosmic Mine"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.width = 30; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.width = 30; npc.height = 30; npc.lifeMax = 4800; npc.aiStyle = -1; @@ -31,11 +31,11 @@ namespace CalamityMod.NPCs.Signus npc.knockBackResist = 0f; npc.noGravity = true; npc.noTileCollide = true; - npc.dontTakeDamage = true; + npc.dontTakeDamage = true; npc.HitSound = SoundID.NPCHit53; npc.DeathSound = SoundID.NPCDeath44; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToSickness = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -49,72 +49,72 @@ namespace CalamityMod.NPCs.Signus public override void AI() { - if (CalamityGlobalNPC.signus < 0 || !Main.npc[CalamityGlobalNPC.signus].active) - { - npc.active = false; - npc.netUpdate = true; - return; - } - - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.7f, 0.2f, 1.1f); - - npc.rotation = npc.velocity.X * 0.04f; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - Vector2 vector = player.Center - npc.Center; - npc.ai[2] = vector.Length(); - - npc.damage = 0; - npc.ai[3] += 1f; - if (npc.ai[2] < 90f || npc.ai[3] >= 300f || npc.Calamity().newAI[0] > 0f) + if (CalamityGlobalNPC.signus < 0 || !Main.npc[CalamityGlobalNPC.signus].active) { - npc.Calamity().newAI[0] += 1f; - npc.velocity *= 0.98f; - npc.dontTakeDamage = false; - npc.scale = MathHelper.Lerp(1f, 3f, npc.Calamity().newAI[0] / 45f); - - if (npc.Calamity().newAI[0] >= 45f) - { - CheckDead(); - npc.life = 0; - } - - return; + npc.active = false; + npc.netUpdate = true; + return; } - if (npc.ai[1] == 0f) - { - npc.scale -= 0.02f; - npc.alpha += 30; - if (npc.alpha >= 250) - { - npc.alpha = 255; - npc.ai[1] = 1f; - } - } - else if (npc.ai[1] == 1f) - { - npc.scale += 0.02f; - npc.alpha -= 30; - if (npc.alpha <= 0) - { - npc.alpha = 0; - npc.ai[1] = 0f; - } - } + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - float num1372 = death ? 16f : 14f; + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.7f, 0.2f, 1.1f); + + npc.rotation = npc.velocity.X * 0.04f; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + Player player = Main.player[npc.target]; + + Vector2 vector = player.Center - npc.Center; + npc.ai[2] = vector.Length(); + + npc.damage = 0; + npc.ai[3] += 1f; + if (npc.ai[2] < 90f || npc.ai[3] >= 300f || npc.Calamity().newAI[0] > 0f) + { + npc.Calamity().newAI[0] += 1f; + npc.velocity *= 0.98f; + npc.dontTakeDamage = false; + npc.scale = MathHelper.Lerp(1f, 3f, npc.Calamity().newAI[0] / 45f); + + if (npc.Calamity().newAI[0] >= 45f) + { + CheckDead(); + npc.life = 0; + } + + return; + } + + if (npc.ai[1] == 0f) + { + npc.scale -= 0.02f; + npc.alpha += 30; + if (npc.alpha >= 250) + { + npc.alpha = 255; + npc.ai[1] = 1f; + } + } + else if (npc.ai[1] == 1f) + { + npc.scale += 0.02f; + npc.alpha -= 30; + if (npc.alpha <= 0) + { + npc.alpha = 0; + npc.ai[1] = 0f; + } + } + + float num1372 = death ? 16f : 14f; Vector2 vector167 = new Vector2(npc.Center.X + (npc.direction * 20), npc.Center.Y + 6f); float num1373 = player.position.X + player.width * 0.5f - vector167.X; float num1374 = player.Center.Y - vector167.Y; @@ -159,47 +159,47 @@ namespace CalamityMod.NPCs.Signus return new Color(200, Main.DiscoG, 255, 0); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (npc.Calamity().newAI[0] >= 45f) - return false; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (npc.Calamity().newAI[0] >= 45f) + return false; - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override bool CheckDead() + public override bool CheckDead() { Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 14); npc.position.X = npc.position.X + (npc.width / 2); diff --git a/NPCs/Signus/SignusScreenShaderData.cs b/NPCs/Signus/SignusScreenShaderData.cs index b144eaa9c2..32af221316 100644 --- a/NPCs/Signus/SignusScreenShaderData.cs +++ b/NPCs/Signus/SignusScreenShaderData.cs @@ -20,12 +20,12 @@ namespace CalamityMod.NPCs.Signus { return; } - SignusIndex = -1; + SignusIndex = -1; for (int i = 0; i < Main.npc.Length; i++) { if (Main.npc[i].active && Main.npc[i].type == SignusType) { - SignusIndex = i; + SignusIndex = i; break; } } diff --git a/NPCs/Signus/SignusSky.cs b/NPCs/Signus/SignusSky.cs index 5ac75af597..ea0bb1bdf5 100644 --- a/NPCs/Signus/SignusSky.cs +++ b/NPCs/Signus/SignusSky.cs @@ -36,12 +36,12 @@ namespace CalamityMod.NPCs.Signus x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[this.SignusIndex].Center); } - float maxIntensity = 0.1f; - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - maxIntensity = 1f - (float)Main.npc[this.SignusIndex].life / (float)Main.npc[this.SignusIndex].lifeMax; - } - return (1f - Utils.SmoothStep(3000f, 6000f, x)) * maxIntensity; + float maxIntensity = 0.1f; + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + { + maxIntensity = 1f - (float)Main.npc[this.SignusIndex].life / (float)Main.npc[this.SignusIndex].lifeMax; + } + return (1f - Utils.SmoothStep(3000f, 6000f, x)) * maxIntensity; } return 0f; } @@ -59,12 +59,12 @@ namespace CalamityMod.NPCs.Signus { return true; } - SignusIndex = -1; + SignusIndex = -1; for (int i = 0; i < Main.npc.Length; i++) { if (Main.npc[i].active && Main.npc[i].type == SignusType) { - SignusIndex = i; + SignusIndex = i; break; } } diff --git a/NPCs/SlimeGod/SlimeGod.cs b/NPCs/SlimeGod/SlimeGod.cs index b807daf03a..edde478527 100644 --- a/NPCs/SlimeGod/SlimeGod.cs +++ b/NPCs/SlimeGod/SlimeGod.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SlimeGod { - [AutoloadBossHead] + [AutoloadBossHead] public class SlimeGod : ModNPC { private float bossLife; @@ -24,9 +24,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.width = 150; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.width = 150; npc.height = 92; npc.scale = 1.1f; npc.defense = 10; @@ -43,79 +43,79 @@ namespace CalamityMod.NPCs.SlimeGod npc.DeathSound = SoundID.NPCDeath1; music = CalamityMod.Instance.GetMusicFromMusicMod("SlimeGod") ?? MusicID.Boss1; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.localAI[1]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.localAI[1]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.localAI[1] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.localAI[1] = reader.ReadSingle(); + } - public override void AI() + public override void AI() { CalamityGlobalNPC.slimeGodPurple = npc.whoAmI; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || npc.localAI[1] == 1f || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || npc.localAI[1] == 1f || BossRushEvent.BossRushActive; npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; Vector2 vector = npc.Center; - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; - npc.defense = npc.defDefense; - npc.damage = npc.defDamage; - if (npc.localAI[1] == 1f) - { - npc.defense = npc.defDefense + 20; - npc.damage = npc.defDamage + 22; - } + npc.defense = npc.defDefense; + npc.damage = npc.defDamage; + if (npc.localAI[1] == 1f) + { + npc.defense = npc.defDefense + 20; + npc.damage = npc.defDamage + 22; + } - npc.aiAction = 0; - npc.noTileCollide = false; - npc.noGravity = false; + npc.aiAction = 0; + npc.noTileCollide = false; + npc.noGravity = false; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - if (npc.ai[0] != 6f && (player.dead || !player.active)) - { - npc.TargetClosest(); - player = Main.player[npc.target]; - if (player.dead || !player.active) - { - npc.ai[0] = 6f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + if (npc.ai[0] != 6f && (player.dead || !player.active)) + { + npc.TargetClosest(); + player = Main.player[npc.target]; + if (player.dead || !player.active) + { + npc.ai[0] = 6f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; - if (Vector2.Distance(player.Center, vector) > 5400f) + if (Vector2.Distance(player.Center, vector) > 5400f) { npc.position.X = player.Center.X / 16 * 16f - (npc.width / 2); npc.position.Y = player.Center.Y / 16 * 16f - (npc.height / 2) - 150f; } - float distanceSpeedBoost = Vector2.Distance(player.Center, vector) * (malice ? 0.008f : 0.005f); + float distanceSpeedBoost = Vector2.Distance(player.Center, vector) * (malice ? 0.008f : 0.005f); - if (lifeRatio <= 0.5f && Main.netMode != NetmodeID.MultiplayerClient && expertMode) + if (lifeRatio <= 0.5f && Main.netMode != NetmodeID.MultiplayerClient && expertMode) { Main.PlaySound(SoundID.NPCDeath1, npc.position); Vector2 spawnAt = vector + new Vector2(0f, npc.height / 2f); @@ -137,56 +137,56 @@ namespace CalamityMod.NPCs.SlimeGod } if (CalamityGlobalNPC.slimeGod < 0 || !Main.npc[CalamityGlobalNPC.slimeGod].active) { - npc.localAI[1] = 0f; - flag100 = false; - hyperMode = true; + npc.localAI[1] = 0f; + flag100 = false; + hyperMode = true; + } + if (malice) + { + flag100 = false; + hyperMode = true; } - if (malice) - { - flag100 = false; - hyperMode = true; - } if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[0] += flag100 ? 1f : 2f; - if (revenge) - npc.localAI[0] += 0.5f; - if (malice) - npc.localAI[0] += 1f; + if (revenge) + npc.localAI[0] += 0.5f; + if (malice) + npc.localAI[0] += 1f; - if (npc.localAI[0] >= 600f && Vector2.Distance(player.Center, npc.Center) > 160f) - { - npc.localAI[0] = 0f; - float num179 = 6f; - 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; - 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)); - npc.netUpdate = true; - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - value9.X += num180; - value9.Y += num182; - int totalProjectiles = expertMode ? 6 : 4; - int spread = expertMode ? 90 : 60; - for (int num186 = 0; num186 < totalProjectiles; 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)); - num183 = num179 / num183; - num180 += (float)Main.rand.Next(-spread, spread + 1); - num182 += (float)Main.rand.Next(-spread, spread + 1); - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } + if (npc.localAI[0] >= 600f && Vector2.Distance(player.Center, npc.Center) > 160f) + { + npc.localAI[0] = 0f; + float num179 = 6f; + 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; + 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)); + npc.netUpdate = true; + num183 = num179 / num183; + num180 *= num183; + num182 *= num183; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + value9.X += num180; + value9.Y += num182; + int totalProjectiles = expertMode ? 6 : 4; + int spread = expertMode ? 90 : 60; + for (int num186 = 0; num186 < totalProjectiles; 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)); + num183 = num179 / num183; + num180 += (float)Main.rand.Next(-spread, spread + 1); + num182 += (float)Main.rand.Next(-spread, spread + 1); + num180 *= num183; + num182 *= num183; + Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); + } + } } if (npc.ai[0] == 0f) @@ -212,13 +212,13 @@ namespace CalamityMod.NPCs.SlimeGod npc.ai[1] += flag100 ? 1f : 2f; float num1879 = 60f; float num1880 = death ? 3.5f : revenge ? 3f : expertMode ? 2.5f : 2f; - if (revenge) - { - float moveBoost = death ? 80f * (1f - lifeRatio) : 40f * (1f - lifeRatio); - float speedBoost = death ? 8f * (1f - lifeRatio) : 4f * (1f - lifeRatio); - num1879 -= moveBoost; - num1880 += speedBoost; - } + if (revenge) + { + float moveBoost = death ? 80f * (1f - lifeRatio) : 40f * (1f - lifeRatio); + float speedBoost = death ? 8f * (1f - lifeRatio) : 4f * (1f - lifeRatio); + num1879 -= moveBoost; + num1880 += speedBoost; + } float num1881 = 5f; if (!Collision.CanHit(vector, 1, 1, player.Center, 1, 1)) { @@ -252,29 +252,29 @@ namespace CalamityMod.NPCs.SlimeGod } } npc.ai[2] += 1f; - if (revenge) - { - npc.ai[2] += death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - } + if (revenge) + { + npc.ai[2] += death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + } if (npc.ai[2] >= 420f && npc.velocity.Y == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - int random = Main.rand.Next(2) + (lifeRatio < 0.75f ? 1 : 0); - switch (random) - { - case 0: - npc.ai[0] = 2f; - break; - case 1: - npc.ai[0] = 3f; - npc.noTileCollide = true; - npc.velocity.Y = death ? -9f : revenge ? -8f : expertMode ? -7f : -6f; - break; - case 2: - npc.ai[0] = 5f; - break; - default: - break; - } + int random = Main.rand.Next(2) + (lifeRatio < 0.75f ? 1 : 0); + switch (random) + { + case 0: + npc.ai[0] = 2f; + break; + case 1: + npc.ai[0] = 3f; + npc.noTileCollide = true; + npc.velocity.Y = death ? -9f : revenge ? -8f : expertMode ? -7f : -6f; + break; + case 2: + npc.ai[0] = 5f; + break; + default: + break; + } npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -283,8 +283,8 @@ namespace CalamityMod.NPCs.SlimeGod } else if (npc.ai[0] == 2f) { - npc.localAI[0] += 5f; - npc.velocity.X *= 0.85f; + npc.localAI[0] += 5f; + npc.velocity.X *= 0.85f; npc.ai[1] += 1f; if (npc.ai[1] >= 80f) { @@ -316,7 +316,7 @@ namespace CalamityMod.NPCs.SlimeGod vector272 = player.Center - vector; vector272.Normalize(); vector272 *= death ? 9f : revenge ? 8f : expertMode ? 7f : 6f; - npc.velocity = (npc.velocity * 4f + vector272) / 5f; + npc.velocity = (npc.velocity * 4f + vector272) / 5f; if (npc.ai[1] > 12f) { npc.ai[1] = 0f; @@ -340,8 +340,8 @@ namespace CalamityMod.NPCs.SlimeGod } else if (npc.ai[0] == 3.1f) { - bool atTargetPosition = npc.position.Y + npc.height >= player.position.Y; - if (npc.ai[2] == 0f && (atTargetPosition || npc.localAI[1] == 0f) && Collision.CanHit(vector, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + bool atTargetPosition = npc.position.Y + npc.height >= player.position.Y; + if (npc.ai[2] == 0f && (atTargetPosition || npc.localAI[1] == 0f) && Collision.CanHit(vector, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) { npc.ai[2] = 1f; npc.netUpdate = true; @@ -365,10 +365,10 @@ namespace CalamityMod.NPCs.SlimeGod { npc.noTileCollide = true; } - npc.noGravity = true; - npc.velocity.Y += 0.5f; - float velocityLimit = malice ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; - if (npc.velocity.Y > velocityLimit) + npc.noGravity = true; + npc.velocity.Y += 0.5f; + float velocityLimit = malice ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; + if (npc.velocity.Y > velocityLimit) { npc.velocity.Y = velocityLimit; } @@ -452,7 +452,7 @@ namespace CalamityMod.NPCs.SlimeGod else { npc.velocity.X *= 0.98f; - float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f) + distanceSpeedBoost; + float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f) + distanceSpeedBoost; if (npc.direction < 0 && npc.velocity.X > -velocityLimit) { npc.velocity.X = -velocityLimit; @@ -539,14 +539,14 @@ namespace CalamityMod.NPCs.SlimeGod } } - public override Color? GetAlpha(Color drawColor) - { - Color lightColor = new Color(200, 150, Main.DiscoB, npc.alpha); - Color newColor = npc.localAI[1] == 1f ? lightColor : drawColor; - return newColor; - } + public override Color? GetAlpha(Color drawColor) + { + Color lightColor = new Color(200, 150, Main.DiscoB, npc.alpha); + Color newColor = npc.localAI[1] == 1f ? lightColor : drawColor; + return newColor; + } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref string name, ref int potionType) { potionType = ItemID.HealingPotion; } @@ -589,6 +589,6 @@ namespace CalamityMod.NPCs.SlimeGod public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Weak, 300, true); - } + } } } diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 02bd469880..00e562860a 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -22,11 +22,11 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.SlimeGod { - [AutoloadBossHead] + [AutoloadBossHead] public class SlimeGodCore : ModNPC { - private bool slimesSpawned = false; - private int buffedSlime = 0; + private bool slimesSpawned = false; + private int buffedSlime = 0; public override void SetStaticDefaults() { @@ -35,9 +35,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 10f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 10f; npc.width = 44; npc.height = 44; npc.defense = 6; @@ -50,143 +50,143 @@ namespace CalamityMod.NPCs.SlimeGod aiType = -1; npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 25, 0, 0); - npc.Opacity = 0.8f; + npc.Opacity = 0.8f; npc.boss = true; npc.noGravity = true; npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - music = CalamityMod.Instance.GetMusicFromMusicMod("SlimeGod") ?? MusicID.Boss1; + music = CalamityMod.Instance.GetMusicFromMusicMod("SlimeGod") ?? MusicID.Boss1; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.dontTakeDamage); - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - writer.Write(npc.localAI[3]); - writer.Write(buffedSlime); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.dontTakeDamage = reader.ReadBoolean(); - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - buffedSlime = reader.ReadInt32(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + writer.Write(npc.dontTakeDamage); + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + writer.Write(npc.localAI[3]); + writer.Write(buffedSlime); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.dontTakeDamage = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + buffedSlime = reader.ReadInt32(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); CalamityGlobalNPC.slimeGod = npc.whoAmI; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - Vector2 vectorCenter = npc.Center; + Vector2 vectorCenter = npc.Center; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, vectorCenter) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, vectorCenter) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - if (Main.netMode != NetmodeID.MultiplayerClient && !slimesSpawned) - { - slimesSpawned = true; - NPC.NewNPC((int)vectorCenter.X, (int)vectorCenter.Y, ModContent.NPCType()); - NPC.NewNPC((int)vectorCenter.X, (int)vectorCenter.Y, ModContent.NPCType()); - } + if (Main.netMode != NetmodeID.MultiplayerClient && !slimesSpawned) + { + slimesSpawned = true; + NPC.NewNPC((int)vectorCenter.X, (int)vectorCenter.Y, ModContent.NPCType()); + NPC.NewNPC((int)vectorCenter.X, (int)vectorCenter.Y, ModContent.NPCType()); + } - // Emit dust - int randomDust = Main.rand.NextBool(2) ? 173 : 260; + // Emit dust + int randomDust = Main.rand.NextBool(2) ? 173 : 260; int num658 = Dust.NewDust(npc.position, npc.width, npc.height, randomDust, npc.velocity.X, npc.velocity.Y, 255, new Color(0, 80, 255, 80), npc.scale * 1.5f); Main.dust[num658].noGravity = true; Main.dust[num658].velocity *= 0.5f; - npc.dontTakeDamage = false; + npc.dontTakeDamage = false; - // Set damage - npc.damage = npc.defDamage; + // Set damage + npc.damage = npc.defDamage; - // Enrage based on large slimes - bool phase2 = lifeRatio < 0.4f || malice; - bool hyperMode = true; - bool purpleSlimeAlive = false; - bool redSlimeAlive = false; + // Enrage based on large slimes + bool phase2 = lifeRatio < 0.4f || malice; + bool hyperMode = true; + bool purpleSlimeAlive = false; + bool redSlimeAlive = false; - if (CalamityGlobalNPC.slimeGodPurple != -1) - { - if (Main.npc[CalamityGlobalNPC.slimeGodPurple].active) - { - if (buffedSlime == 1) - Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 1f; - else - Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 0f; + if (CalamityGlobalNPC.slimeGodPurple != -1) + { + if (Main.npc[CalamityGlobalNPC.slimeGodPurple].active) + { + if (buffedSlime == 1) + Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 1f; + else + Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.X; - calamityGlobalNPC.newAI[1] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.Y; + calamityGlobalNPC.newAI[0] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.X; + calamityGlobalNPC.newAI[1] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.Y; - purpleSlimeAlive = true; - phase2 = lifeRatio < 0.2f; - hyperMode = false; - } - } + purpleSlimeAlive = true; + phase2 = lifeRatio < 0.2f; + hyperMode = false; + } + } - if (CalamityGlobalNPC.slimeGodRed != -1) - { - if (Main.npc[CalamityGlobalNPC.slimeGodRed].active) - { - if (buffedSlime == 2) - Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 1f; - else - Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 0f; + if (CalamityGlobalNPC.slimeGodRed != -1) + { + if (Main.npc[CalamityGlobalNPC.slimeGodRed].active) + { + if (buffedSlime == 2) + Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 1f; + else + Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 0f; - npc.localAI[2] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.X; - npc.localAI[3] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.Y; + npc.localAI[2] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.X; + npc.localAI[3] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.Y; - redSlimeAlive = true; - phase2 = lifeRatio < 0.2f; - hyperMode = false; - } - } + redSlimeAlive = true; + phase2 = lifeRatio < 0.2f; + hyperMode = false; + } + } - // Despawn + // Despawn if (!player.active || player.dead) { npc.TargetClosest(false); player = Main.player[npc.target]; if (!player.active || player.dead) { - if (npc.velocity.Y < -3f) - npc.velocity.Y = -3f; - npc.velocity.Y += 0.2f; - if (npc.velocity.Y > 16f) - npc.velocity.Y = 16f; + if (npc.velocity.Y < -3f) + npc.velocity.Y = -3f; + npc.velocity.Y += 0.2f; + if (npc.velocity.Y > 16f) + npc.velocity.Y = 16f; - if (npc.position.Y > Main.worldSurface * 16.0) + if (npc.position.Y > Main.worldSurface * 16.0) { for (int x = 0; x < Main.maxNPCs; x++) { @@ -201,278 +201,278 @@ namespace CalamityMod.NPCs.SlimeGod npc.netUpdate = true; } - if (npc.ai[0] != 0f || npc.ai[1] != 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.netUpdate = true; - } - return; + if (npc.ai[0] != 0f || npc.ai[1] != 0f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.netUpdate = true; + } + return; } } else if (npc.timeLeft < 1800) npc.timeLeft = 1800; - float ai1 = malice ? 210f : hyperMode ? 270f : 360f; + float ai1 = malice ? 210f : hyperMode ? 270f : 360f; - // Hide inside large slime - if (!hyperMode && npc.ai[1] < ai1) - { - if (calamityGlobalNPC.newAI[2] == 0f && npc.life > 0) - { - calamityGlobalNPC.newAI[2] = npc.lifeMax; - } - if (npc.life > 0) - { - int num660 = (int)(npc.lifeMax * 0.05); - if ((npc.life + num660) < calamityGlobalNPC.newAI[2]) - { - calamityGlobalNPC.newAI[2] = npc.life; - calamityGlobalNPC.newAI[3] = 1f; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SlimeGodPossession"), (int)npc.position.X, (int)npc.position.Y); - } - } + // Hide inside large slime + if (!hyperMode && npc.ai[1] < ai1) + { + if (calamityGlobalNPC.newAI[2] == 0f && npc.life > 0) + { + calamityGlobalNPC.newAI[2] = npc.lifeMax; + } + if (npc.life > 0) + { + int num660 = (int)(npc.lifeMax * 0.05); + if ((npc.life + num660) < calamityGlobalNPC.newAI[2]) + { + calamityGlobalNPC.newAI[2] = npc.life; + calamityGlobalNPC.newAI[3] = 1f; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SlimeGodPossession"), (int)npc.position.X, (int)npc.position.Y); + } + } - if (calamityGlobalNPC.newAI[3] == 1f) - { - npc.dontTakeDamage = true; + if (calamityGlobalNPC.newAI[3] == 1f) + { + npc.dontTakeDamage = true; - npc.rotation = npc.velocity.X * 0.1f; + npc.rotation = npc.velocity.X * 0.1f; - if (buffedSlime == 0) - { - if (purpleSlimeAlive && redSlimeAlive) - buffedSlime = Main.rand.Next(2) + 1; - else if (purpleSlimeAlive) - buffedSlime = 1; - else if (redSlimeAlive) - buffedSlime = 2; - } + if (buffedSlime == 0) + { + if (purpleSlimeAlive && redSlimeAlive) + buffedSlime = Main.rand.Next(2) + 1; + else if (purpleSlimeAlive) + buffedSlime = 1; + else if (redSlimeAlive) + buffedSlime = 2; + } - Vector2 purpleSlimeVector = new Vector2(calamityGlobalNPC.newAI[0], calamityGlobalNPC.newAI[1]); - Vector2 redSlimeVector = new Vector2(npc.localAI[2], npc.localAI[3]); - Vector2 goToVector = buffedSlime == 1 ? purpleSlimeVector : redSlimeVector; + Vector2 purpleSlimeVector = new Vector2(calamityGlobalNPC.newAI[0], calamityGlobalNPC.newAI[1]); + Vector2 redSlimeVector = new Vector2(npc.localAI[2], npc.localAI[3]); + Vector2 goToVector = buffedSlime == 1 ? purpleSlimeVector : redSlimeVector; - Vector2 goToPosition = goToVector - vectorCenter; - npc.velocity = Vector2.Normalize(goToPosition) * 24f; + Vector2 goToPosition = goToVector - vectorCenter; + npc.velocity = Vector2.Normalize(goToPosition) * 24f; - // Reduce velocity to 0 to avoid spastic movement when inside big slime. - if (Vector2.Distance(npc.Center, goToVector) < 24f) - { - npc.velocity = Vector2.Zero; + // Reduce velocity to 0 to avoid spastic movement when inside big slime. + if (Vector2.Distance(npc.Center, goToVector) < 24f) + { + npc.velocity = Vector2.Zero; - npc.Opacity -= 0.2f; - if (npc.Opacity < 0f) - npc.Opacity = 0f; - } + npc.Opacity -= 0.2f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } - bool slimeDead = false; - if (goToVector == purpleSlimeVector) - slimeDead = CalamityGlobalNPC.slimeGodPurple < 0 || !Main.npc[CalamityGlobalNPC.slimeGodPurple].active; - else - slimeDead = CalamityGlobalNPC.slimeGodRed < 0 || !Main.npc[CalamityGlobalNPC.slimeGodRed].active; + bool slimeDead = false; + if (goToVector == purpleSlimeVector) + slimeDead = CalamityGlobalNPC.slimeGodPurple < 0 || !Main.npc[CalamityGlobalNPC.slimeGodPurple].active; + else + slimeDead = CalamityGlobalNPC.slimeGodRed < 0 || !Main.npc[CalamityGlobalNPC.slimeGodRed].active; - npc.ai[2] += 1f; - if (npc.ai[2] >= 600f || slimeDead) - { - npc.TargetClosest(); - npc.ai[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.velocity = Vector2.UnitY * -12f; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SlimeGodExit"), (int)npc.position.X, (int)npc.position.Y); - for (int i = 0; i < 20; i++) - { - int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 4, 0f, 0f, 100, default, 2f); - Main.dust[dust].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[dust].scale = 0.5f; - Main.dust[dust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 30; j++) - { - int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 4, 0f, 0f, 100, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 5f; - dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 4, 0f, 0f, 100, default, 2f); - Main.dust[dust].velocity *= 2f; - } - } + npc.ai[2] += 1f; + if (npc.ai[2] >= 600f || slimeDead) + { + npc.TargetClosest(); + npc.ai[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.velocity = Vector2.UnitY * -12f; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SlimeGodExit"), (int)npc.position.X, (int)npc.position.Y); + for (int i = 0; i < 20; i++) + { + int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 4, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int j = 0; j < 30; j++) + { + int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 4, 0f, 0f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 5f; + dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 4, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 2f; + } + } - return; - } + return; + } - npc.Opacity += 0.2f; - if (npc.Opacity > 0.8f) - npc.Opacity = 0.8f; + npc.Opacity += 0.2f; + if (npc.Opacity > 0.8f) + npc.Opacity = 0.8f; - buffedSlime = 0; - } - else if (npc.ai[1] < ai1) - { - npc.Opacity += 0.2f; - if (npc.Opacity > 0.8f) - npc.Opacity = 0.8f; - } + buffedSlime = 0; + } + else if (npc.ai[1] < ai1) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 0.8f) + npc.Opacity = 0.8f; + } - // Spin and shoot orbs + // Spin and shoot orbs if (phase2) { - npc.ai[1] += 1f; - if (revenge) - { - if (npc.ai[1] >= ai1) - { - if (npc.localAI[1] == 0f) - { - // Slow down, rotation - npc.rotation = npc.velocity.X * 0.1f; + npc.ai[1] += 1f; + if (revenge) + { + if (npc.ai[1] >= ai1) + { + if (npc.localAI[1] == 0f) + { + // Slow down, rotation + npc.rotation = npc.velocity.X * 0.1f; - // Set teleport location, turn invisible, spin direction - npc.Opacity -= 0.2f; - if (npc.Opacity <= 0f) - { - npc.Opacity = 0f; - npc.velocity.Normalize(); + // Set teleport location, turn invisible, spin direction + npc.Opacity -= 0.2f; + if (npc.Opacity <= 0f) + { + npc.Opacity = 0f; + npc.velocity.Normalize(); - int teleportX = player.velocity.X < 0f ? -20 : 20; - int teleportY = player.velocity.Y < 0f ? -10 : 10; - int playerPosX = (int)player.Center.X / 16 + teleportX; - int playerPosY = (int)player.Center.Y / 16 - teleportY; + int teleportX = player.velocity.X < 0f ? -20 : 20; + int teleportY = player.velocity.Y < 0f ? -10 : 10; + int playerPosX = (int)player.Center.X / 16 + teleportX; + int playerPosY = (int)player.Center.Y / 16 - teleportY; - npc.ai[2] = playerPosX; - npc.ai[3] = playerPosY; - npc.localAI[1] = 1f; - npc.netUpdate = true; - } - } - else if (npc.localAI[1] == 1f) - { - // Rotation - npc.rotation = npc.velocity.X * 0.1f; + npc.ai[2] = playerPosX; + npc.ai[3] = playerPosY; + npc.localAI[1] = 1f; + npc.netUpdate = true; + } + } + else if (npc.localAI[1] == 1f) + { + // Rotation + npc.rotation = npc.velocity.X * 0.1f; - // Teleport to location - if (npc.Opacity == 0f) - { - Vector2 position = new Vector2(npc.ai[2] * 16f - (npc.width / 2), npc.ai[3] * 16f - (npc.height / 2)); - npc.position = position; - } + // Teleport to location + if (npc.Opacity == 0f) + { + Vector2 position = new Vector2(npc.ai[2] * 16f - (npc.width / 2), npc.ai[3] * 16f - (npc.height / 2)); + npc.position = position; + } - // Turn visible - npc.Opacity += 0.2f; - if (npc.Opacity >= 0.8f) - { - npc.Opacity = 0.8f; - npc.localAI[0] = vectorCenter.X - player.Center.X < 0 ? 1f : -1f; - npc.localAI[1] = 2f; - } - npc.netUpdate = true; - } - else - { - // No damage while spinning - npc.damage = 0; + // Turn visible + npc.Opacity += 0.2f; + if (npc.Opacity >= 0.8f) + { + npc.Opacity = 0.8f; + npc.localAI[0] = vectorCenter.X - player.Center.X < 0 ? 1f : -1f; + npc.localAI[1] = 2f; + } + npc.netUpdate = true; + } + else + { + // No damage while spinning + npc.damage = 0; - // Rotation - npc.rotation += npc.direction * 0.3f; + // Rotation + npc.rotation += npc.direction * 0.3f; - // Velocity boost - if (npc.localAI[1] == 2f) - { - npc.localAI[1] = 3f; - npc.velocity *= 12f; - } + // Velocity boost + if (npc.localAI[1] == 2f) + { + npc.localAI[1] = 3f; + npc.velocity *= 12f; + } - // Spin velocity - float velocity = MathHelper.TwoPi / (180f - (npc.ai[1] - ai1)); - npc.velocity = npc.velocity.RotatedBy(-(double)velocity * npc.localAI[0]); + // Spin velocity + 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 + 100f) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - float chargeVelocity = death ? 12f : 9f; - npc.velocity = Vector2.Normalize(player.Center + (malice ? player.velocity * 20f : Vector2.Zero) - vectorCenter) * chargeVelocity; - npc.TargetClosest(); - return; - } + // Reset and charge at target + if (npc.ai[1] >= ai1 + 100f) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + float chargeVelocity = death ? 12f : 9f; + npc.velocity = Vector2.Normalize(player.Center + (malice ? player.velocity * 20f : Vector2.Zero) - vectorCenter) * chargeVelocity; + npc.TargetClosest(); + return; + } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float divisor = malice ? 10f : 15f; - if (npc.ai[1] % divisor == 0f && Vector2.Distance(player.Center, vectorCenter) > 160f) - { - float num179 = expertMode ? 9f : 7.5f; - 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 + player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - value9.X += num180; - value9.Y += 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; - Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - return; - } - } - else - { - if (Main.netMode != NetmodeID.MultiplayerClient && Vector2.Distance(player.Center, vectorCenter) > 160f) - { - if (npc.ai[1] % 40f == 0f) - { - float num179 = expertMode ? 12f : 10f; - 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 + player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - value9.X += num180; - value9.Y += num182; - int totalProjectiles = expertMode ? 3 : 2; - int spread = expertMode ? 45 : 30; - for (int num186 = 0; num186 < totalProjectiles; num186++) - { - 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 += Main.rand.Next(-spread, spread + 1); - num182 += Main.rand.Next(-spread, spread + 1); - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float divisor = malice ? 10f : 15f; + if (npc.ai[1] % divisor == 0f && Vector2.Distance(player.Center, vectorCenter) > 160f) + { + float num179 = expertMode ? 9f : 7.5f; + 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 + player.height * 0.5f - value9.Y - num181; + float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); + num183 = num179 / num183; + num180 *= num183; + num182 *= num183; + int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + value9.X += num180; + value9.Y += 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; + Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); + } + } + } + return; + } + } + else + { + if (Main.netMode != NetmodeID.MultiplayerClient && Vector2.Distance(player.Center, vectorCenter) > 160f) + { + if (npc.ai[1] % 40f == 0f) + { + float num179 = expertMode ? 12f : 10f; + 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 + player.height * 0.5f - value9.Y - num181; + float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); + num183 = num179 / num183; + num180 *= num183; + num182 *= num183; + int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + value9.X += num180; + value9.Y += num182; + int totalProjectiles = expertMode ? 3 : 2; + int spread = expertMode ? 45 : 30; + for (int num186 = 0; num186 < totalProjectiles; num186++) + { + 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 += Main.rand.Next(-spread, spread + 1); + num182 += Main.rand.Next(-spread, spread + 1); + num180 *= num183; + num182 *= num183; + Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); + } + } + } + } } float num1372 = death ? 14f : revenge ? 11f : expertMode ? 8.5f : 6f; @@ -480,10 +480,10 @@ namespace CalamityMod.NPCs.SlimeGod { num1372 = revenge ? 18f : expertMode ? 16f : 14f; } - if (hyperMode || malice) - { - num1372 *= 1.25f; - } + if (hyperMode || malice) + { + num1372 *= 1.25f; + } Vector2 vector167 = new Vector2(vectorCenter.X + (npc.direction * 20), vectorCenter.Y + 6f); float num1373 = player.position.X + player.width * 0.5f - vector167.X; @@ -508,8 +508,8 @@ namespace CalamityMod.NPCs.SlimeGod { npc.direction = 1; } - npc.rotation += npc.direction * 0.3f; - return; + npc.rotation += npc.direction * 0.3f; + return; } npc.velocity.X = (npc.velocity.X * 50f + num1373) / 51f; @@ -524,12 +524,12 @@ namespace CalamityMod.NPCs.SlimeGod npc.velocity.X = (npc.velocity.X * 7f + num1373) / 8f; npc.velocity.Y = (npc.velocity.Y * 7f + num1374) / 8f; } - npc.rotation = npc.velocity.X * 0.1f; - } + npc.rotation = npc.velocity.X * 0.1f; + } public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; + { + SpriteEffects spriteEffects = SpriteEffects.None; if (npc.spriteDirection == 1) { spriteEffects = SpriteEffects.FlipHorizontally; @@ -567,8 +567,8 @@ namespace CalamityMod.NPCs.SlimeGod float num165 = npc.rotation; Main.spriteBatch.Draw(texture2D3, value4 + npc.Size / 2f - Main.screenPosition + new Vector2(0, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + npc.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, npc.scale, spriteEffects, 0f); goto IL_6881; - } - return false; + } + return false; } public override void BossLoot(ref string name, ref int potionType) @@ -590,17 +590,17 @@ namespace CalamityMod.NPCs.SlimeGod // This loot code is shared with every other Slime God component. public static void DropSlimeGodLoot(NPC npc) { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedSlimeGod); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedSlimeGod); + CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedSlimeGod); - // Purified Jam is once per player, but drops for all players. - CalamityPlayer mp = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Calamity(); + // Purified Jam is once per player, but drops for all players. + CalamityPlayer mp = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Calamity(); if (!mp.revJamDrop) { DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedSlimeGod, 6, 8); @@ -616,23 +616,23 @@ namespace CalamityMod.NPCs.SlimeGod // Materials DropHelper.DropItemSpray(npc, ModContent.ItemType(), 30, 45, 3); - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + // Weapons + float w = DropHelper.NormalWeaponDropRateFloat; + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) + ); - // Vanity - DropHelper.DropItemFromSetChance(npc, 0.142857f, ModContent.ItemType(), ModContent.ItemType()); + // Vanity + DropHelper.DropItemFromSetChance(npc, 0.142857f, ModContent.ItemType(), ModContent.ItemType()); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); - } + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); + } // Mark the Slime God as dead CalamityWorld.downedSlimeGod = true; @@ -682,8 +682,8 @@ namespace CalamityMod.NPCs.SlimeGod public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.VortexDebuff, 120, true); - player.AddBuff(BuffID.Weak, 120, true); - player.AddBuff(BuffID.Darkness, 120, true); - } + player.AddBuff(BuffID.Weak, 120, true); + player.AddBuff(BuffID.Darkness, 120, true); + } } } diff --git a/NPCs/SlimeGod/SlimeGodRun.cs b/NPCs/SlimeGod/SlimeGodRun.cs index c02effe189..7adff13d2f 100644 --- a/NPCs/SlimeGod/SlimeGodRun.cs +++ b/NPCs/SlimeGod/SlimeGodRun.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SlimeGod { - [AutoloadBossHead] + [AutoloadBossHead] public class SlimeGodRun : ModNPC { private float bossLife; @@ -24,9 +24,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.width = 150; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.width = 150; npc.height = 92; npc.scale = 1.1f; npc.defense = 12; @@ -46,80 +46,80 @@ namespace CalamityMod.NPCs.SlimeGod npc.aiStyle = -1; aiType = -1; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.localAI[1]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.localAI[1]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.localAI[1] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.localAI[1] = reader.ReadSingle(); + } - public override void AI() + public override void AI() { CalamityGlobalNPC.slimeGodRed = npc.whoAmI; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || npc.localAI[1] == 1f || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || npc.localAI[1] == 1f || BossRushEvent.BossRushActive; npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; Vector2 vector = npc.Center; - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; - npc.defense = npc.defDefense; - npc.damage = npc.defDamage; - if (npc.localAI[1] == 1f) - { - npc.defense = npc.defDefense + 24; - npc.damage = npc.defDamage + 25; - } + npc.defense = npc.defDefense; + npc.damage = npc.defDamage; + if (npc.localAI[1] == 1f) + { + npc.defense = npc.defDefense + 24; + npc.damage = npc.defDamage + 25; + } - npc.aiAction = 0; - npc.noTileCollide = false; - npc.noGravity = false; + npc.aiAction = 0; + npc.noTileCollide = false; + npc.noGravity = false; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - if (npc.ai[0] != 6f && (player.dead || !player.active)) - { - npc.TargetClosest(); - player = Main.player[npc.target]; - if (player.dead || !player.active) - { - npc.ai[0] = 6f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; + if (npc.ai[0] != 6f && (player.dead || !player.active)) + { + npc.TargetClosest(); + player = Main.player[npc.target]; + if (player.dead || !player.active) + { + npc.ai[0] = 6f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; npc.netUpdate = true; } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; - if (Vector2.Distance(player.Center, vector) > 5400f) + if (Vector2.Distance(player.Center, vector) > 5400f) { npc.position.X = player.Center.X / 16 * 16f - (npc.width / 2); npc.position.Y = player.Center.Y / 16 * 16f - (npc.height / 2) - 150f; } - float distanceSpeedBoost = Vector2.Distance(player.Center, vector) * (malice ? 0.008f : 0.005f); + float distanceSpeedBoost = Vector2.Distance(player.Center, vector) * (malice ? 0.008f : 0.005f); - if (lifeRatio <= 0.5f && Main.netMode != NetmodeID.MultiplayerClient && expertMode) + if (lifeRatio <= 0.5f && Main.netMode != NetmodeID.MultiplayerClient && expertMode) { Main.PlaySound(SoundID.NPCDeath1, npc.position); Vector2 spawnAt = vector + new Vector2(0f, npc.height / 2f); @@ -141,59 +141,59 @@ namespace CalamityMod.NPCs.SlimeGod } if (CalamityGlobalNPC.slimeGod < 0 || !Main.npc[CalamityGlobalNPC.slimeGod].active) { - npc.localAI[1] = 0f; - hyperMode = true; + npc.localAI[1] = 0f; + hyperMode = true; flag100 = false; } - if (malice) - { - flag100 = false; - hyperMode = true; - } + if (malice) + { + flag100 = false; + hyperMode = true; + } - if (npc.localAI[1] != 1f) - { - if (!flag100) - npc.defense = npc.defDefense * 2; - } + if (npc.localAI[1] != 1f) + { + if (!flag100) + npc.defense = npc.defDefense * 2; + } if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] += flag100 ? 1f : 2f; - if (revenge) - npc.localAI[0] += 0.5f; - if (malice) - npc.localAI[0] += 1f; + npc.localAI[0] += flag100 ? 1f : 2f; + if (revenge) + npc.localAI[0] += 0.5f; + if (malice) + npc.localAI[0] += 1f; - if (npc.localAI[0] >= 450f && Vector2.Distance(player.Center, npc.Center) > 160f) - { - npc.localAI[0] = 0f; - float num179 = expertMode ? 12f : 10f; - 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; - 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)); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - value9.X += num180; - 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)); - num183 = num179 / num183; - num180 += (float)Main.rand.Next(-10, 11); - num182 += (float)Main.rand.Next(-10, 11); - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } + if (npc.localAI[0] >= 450f && Vector2.Distance(player.Center, npc.Center) > 160f) + { + npc.localAI[0] = 0f; + float num179 = expertMode ? 12f : 10f; + 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; + 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)); + num183 = num179 / num183; + num180 *= num183; + num182 *= num183; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + value9.X += num180; + 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)); + num183 = num179 / num183; + num180 += (float)Main.rand.Next(-10, 11); + num182 += (float)Main.rand.Next(-10, 11); + num180 *= num183; + num182 *= num183; + Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); + } + } } if (npc.ai[0] == 0f) @@ -218,14 +218,14 @@ namespace CalamityMod.NPCs.SlimeGod npc.ai[1] += 1f; float num1879 = 50f; float num1880 = death ? 4.5f : revenge ? 4f : expertMode ? 3.5f : 3f; - if (revenge) - { - float moveBoost = death ? 60f * (1f - lifeRatio) : 30f * (1f - lifeRatio); - float speedBoost = death ? 8f * (1f - lifeRatio) : 4f * (1f - lifeRatio); - num1879 -= moveBoost; - num1880 += speedBoost; - } - float num1881 = 4f; + if (revenge) + { + float moveBoost = death ? 60f * (1f - lifeRatio) : 30f * (1f - lifeRatio); + float speedBoost = death ? 8f * (1f - lifeRatio) : 4f * (1f - lifeRatio); + num1879 -= moveBoost; + num1880 += speedBoost; + } + float num1881 = 4f; if (!Collision.CanHit(vector, 1, 1, player.Center, 1, 1)) { num1881 += 2f; @@ -258,29 +258,29 @@ namespace CalamityMod.NPCs.SlimeGod } } npc.ai[2] += 1f; - if (revenge) - { - npc.ai[2] += death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - } - if (npc.ai[2] >= 360f && npc.velocity.Y == 0f && Main.netMode != NetmodeID.MultiplayerClient) + if (revenge) { - int random = Main.rand.Next(2) + (lifeRatio < 0.75f ? 1 : 0); - switch (random) - { - case 0: - npc.ai[0] = 2f; - break; - case 1: - npc.ai[0] = 3f; - npc.noTileCollide = true; - npc.velocity.Y = death ? -10f : revenge ? -9f : expertMode ? -8f : -7f; - break; - case 2: - npc.ai[0] = 5f; - break; - default: - break; - } + npc.ai[2] += death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + } + if (npc.ai[2] >= 360f && npc.velocity.Y == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + int random = Main.rand.Next(2) + (lifeRatio < 0.75f ? 1 : 0); + switch (random) + { + case 0: + npc.ai[0] = 2f; + break; + case 1: + npc.ai[0] = 3f; + npc.noTileCollide = true; + npc.velocity.Y = death ? -10f : revenge ? -9f : expertMode ? -8f : -7f; + break; + case 2: + npc.ai[0] = 5f; + break; + default: + break; + } npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -289,7 +289,7 @@ namespace CalamityMod.NPCs.SlimeGod } else if (npc.ai[0] == 2f) { - npc.velocity.X *= 0.85f; + npc.velocity.X *= 0.85f; npc.ai[1] += 1f; if (npc.ai[1] >= 40f) { @@ -341,14 +341,14 @@ namespace CalamityMod.NPCs.SlimeGod return; } vector272.Normalize(); - vector272 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; - npc.velocity = (npc.velocity * 5f + vector272) / 6f; + vector272 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; + npc.velocity = (npc.velocity * 5f + vector272) / 6f; } } else if (npc.ai[0] == 3.1f) { - bool atTargetPosition = npc.position.Y + npc.height >= player.position.Y; - if (npc.ai[2] == 0f && (atTargetPosition || npc.localAI[1] == 0f) && Collision.CanHit(vector, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + bool atTargetPosition = npc.position.Y + npc.height >= player.position.Y; + if (npc.ai[2] == 0f && (atTargetPosition || npc.localAI[1] == 0f) && Collision.CanHit(vector, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) { npc.ai[2] = 1f; npc.netUpdate = true; @@ -372,10 +372,10 @@ namespace CalamityMod.NPCs.SlimeGod { npc.noTileCollide = true; } - npc.noGravity = true; - npc.velocity.Y += 0.5f; - float velocityLimit = malice ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; - if (npc.velocity.Y > velocityLimit) + npc.noGravity = true; + npc.velocity.Y += 0.5f; + float velocityLimit = malice ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; + if (npc.velocity.Y > velocityLimit) { npc.velocity.Y = velocityLimit; } @@ -408,8 +408,8 @@ namespace CalamityMod.NPCs.SlimeGod if (value74.Length() > 100f) { value74.Normalize(); - value74 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; - } + value74 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; + } npc.velocity = (npc.velocity * 4f + value74) / 5f; return; } @@ -452,15 +452,15 @@ namespace CalamityMod.NPCs.SlimeGod { npc.velocity.Y -= 2f; } - npc.velocity.X = ((death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * npc.direction; - npc.ai[2] += 1f; + npc.velocity.X = ((death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * npc.direction; + npc.ai[2] += 1f; } } else { npc.velocity.X *= 0.98f; - float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f) + distanceSpeedBoost; - if (npc.direction < 0 && npc.velocity.X > -velocityLimit) + float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f) + distanceSpeedBoost; + if (npc.direction < 0 && npc.velocity.X > -velocityLimit) { npc.velocity.X = -velocityLimit; } @@ -521,39 +521,39 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { int num660 = (int)((double)npc.lifeMax * 0.15); - if ((float)(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)); - int num663 = ModContent.NPCType(); - if (Main.rand.NextBool(3)) - { - num663 = ModContent.NPCType(); - } - int num664 = NPC.NewNPC(x, y, num663, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num664].SetDefaults(num663, -1f); - Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); - Main.npc[num664].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num664 < 200) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); - } - } + if ((float)(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)); + int num663 = ModContent.NPCType(); + if (Main.rand.NextBool(3)) + { + num663 = ModContent.NPCType(); + } + int num664 = NPC.NewNPC(x, y, num663, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[num664].SetDefaults(num663, -1f); + Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; + Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; + Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[num664].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && num664 < 200) + { + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + } + } } } } - public override Color? GetAlpha(Color drawColor) - { - Color lightColor = new Color(Main.DiscoR, 100, 150, npc.alpha); - Color newColor = npc.localAI[1] == 1f ? lightColor : drawColor; - return newColor; - } + public override Color? GetAlpha(Color drawColor) + { + Color lightColor = new Color(Main.DiscoR, 100, 150, npc.alpha); + Color newColor = npc.localAI[1] == 1f ? lightColor : drawColor; + return newColor; + } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref string name, ref int potionType) { potionType = ItemID.HealingPotion; } @@ -595,7 +595,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(BuffID.Darkness, 300, true); - } + player.AddBuff(BuffID.Darkness, 300, true); + } } } diff --git a/NPCs/SlimeGod/SlimeGodRunSplit.cs b/NPCs/SlimeGod/SlimeGodRunSplit.cs index ac3097c472..81bdeaeb48 100644 --- a/NPCs/SlimeGod/SlimeGodRunSplit.cs +++ b/NPCs/SlimeGod/SlimeGodRunSplit.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SlimeGod { - [AutoloadBossHead] + [AutoloadBossHead] public class SlimeGodRunSplit : ModNPC { private float bossLife; @@ -24,12 +24,12 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.LifeMaxNERB(1005, 1205, 80000); + npc.Calamity().canBreakPlayerDefense = true; + npc.LifeMaxNERB(1005, 1205, 80000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.GetNPCDamage(); - npc.width = 150; + npc.GetNPCDamage(); + npc.width = 150; npc.height = 92; npc.scale = 0.8f; npc.defense = 10; @@ -46,76 +46,76 @@ namespace CalamityMod.NPCs.SlimeGod npc.aiStyle = -1; aiType = -1; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.localAI[1]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.localAI[1] = reader.ReadSingle(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - if (CalamityGlobalNPC.slimeGodRed < 0 || !Main.npc[CalamityGlobalNPC.slimeGodRed].active) - CalamityGlobalNPC.slimeGodRed = npc.whoAmI; + writer.Write(npc.localAI[1]); + } - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.localAI[1] = reader.ReadSingle(); + } + + public override void AI() + { + if (CalamityGlobalNPC.slimeGodRed < 0 || !Main.npc[CalamityGlobalNPC.slimeGodRed].active) + CalamityGlobalNPC.slimeGodRed = npc.whoAmI; + + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || npc.localAI[1] == 1f || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || npc.localAI[1] == 1f || BossRushEvent.BossRushActive; npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; Vector2 vector = npc.Center; - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; - npc.defense = npc.defDefense; - npc.damage = npc.defDamage; - if (npc.localAI[1] == 1f) - { - npc.defense = npc.defDefense + 20; - npc.damage = npc.defDamage + 22; - } + npc.defense = npc.defDefense; + npc.damage = npc.defDamage; + if (npc.localAI[1] == 1f) + { + npc.defense = npc.defDefense + 20; + npc.damage = npc.defDamage + 22; + } - npc.aiAction = 0; - npc.noTileCollide = false; - npc.noGravity = false; + npc.aiAction = 0; + npc.noTileCollide = false; + npc.noGravity = false; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - if (npc.ai[0] != 6f && (player.dead || !player.active)) - { - npc.TargetClosest(); - player = Main.player[npc.target]; - if (player.dead || !player.active) - { - npc.ai[0] = 6f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; + if (npc.ai[0] != 6f && (player.dead || !player.active)) + { + npc.TargetClosest(); + player = Main.player[npc.target]; + if (player.dead || !player.active) + { + npc.ai[0] = 6f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; npc.netUpdate = true; } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; - float distanceSpeedBoost = Vector2.Distance(player.Center, vector) * (malice ? 0.008f : 0.005f); + float distanceSpeedBoost = Vector2.Distance(player.Center, vector) * (malice ? 0.008f : 0.005f); - bool flag100 = false; + bool flag100 = false; bool hyperMode = npc.localAI[1] == 1f; if (CalamityGlobalNPC.slimeGodPurple != -1) { @@ -126,55 +126,55 @@ namespace CalamityMod.NPCs.SlimeGod } if (CalamityGlobalNPC.slimeGod < 0 || !Main.npc[CalamityGlobalNPC.slimeGod].active) { - npc.localAI[1] = 0f; - hyperMode = true; + npc.localAI[1] = 0f; + hyperMode = true; flag100 = false; } - if (malice) - { - flag100 = false; - hyperMode = true; - } + if (malice) + { + flag100 = false; + hyperMode = true; + } - if (npc.localAI[1] != 1f) - { - if (!flag100) - npc.defense = npc.defDefense * 2; - } + if (npc.localAI[1] != 1f) + { + if (!flag100) + npc.defense = npc.defDefense * 2; + } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] += flag100 ? 0.5f : 1f; - if (revenge) - npc.localAI[0] += 0.5f; - if (malice) - npc.localAI[0] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[0] += flag100 ? 0.5f : 1f; + if (revenge) + npc.localAI[0] += 0.5f; + if (malice) + npc.localAI[0] += 1f; - if (npc.localAI[0] >= 450f && Vector2.Distance(player.Center, npc.Center) > 160f) - { - npc.localAI[0] = 0f; - float num179 = expertMode ? 12f : 10f; - 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; - 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)); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - 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)); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } + if (npc.localAI[0] >= 450f && Vector2.Distance(player.Center, npc.Center) > 160f) + { + npc.localAI[0] = 0f; + float num179 = expertMode ? 12f : 10f; + 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; + 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)); + num183 = num179 / num183; + num180 *= num183; + num182 *= num183; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + 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)); + num183 = num179 / num183; + num180 *= num183; + num182 *= num183; + Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); + } + } if (npc.ai[0] == 0f) { @@ -199,14 +199,14 @@ namespace CalamityMod.NPCs.SlimeGod npc.ai[1] += 1f; float num1879 = 35f; float num1880 = death ? 5.5f : revenge ? 5f : expertMode ? 4.5f : 4f; - if (revenge) - { - float moveBoost = death ? 14f * (1f - lifeRatio) : 7f * (1f - lifeRatio); - float speedBoost = death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - num1879 -= moveBoost; - num1880 += speedBoost; - } - float num1881 = 4f; + if (revenge) + { + float moveBoost = death ? 14f * (1f - lifeRatio) : 7f * (1f - lifeRatio); + float speedBoost = death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + num1879 -= moveBoost; + num1880 += speedBoost; + } + float num1881 = 4f; if (!Collision.CanHit(vector, 1, 1, player.Center, 1, 1)) { num1881 += 2f; @@ -217,7 +217,7 @@ namespace CalamityMod.NPCs.SlimeGod num1880 *= 1.25f; npc.ai[1] = 0f; npc.velocity.Y -= num1881; - npc.velocity.X = (num1880 + distanceSpeedBoost) * npc.direction; + npc.velocity.X = (num1880 + distanceSpeedBoost) * npc.direction; npc.netUpdate = true; } } @@ -234,30 +234,30 @@ namespace CalamityMod.NPCs.SlimeGod } } npc.ai[2] += 1f; - if (revenge) - { - npc.ai[2] += death ? 1f - lifeRatio : 0.5f * (1f - lifeRatio); - } - if (npc.ai[2] >= 180f && npc.velocity.Y == 0f && Main.netMode != NetmodeID.MultiplayerClient) + if (revenge) { - int random = Main.rand.Next(2) + (lifeRatio < 0.5f ? 1 : 0); - switch (random) - { - case 0: - npc.ai[0] = 2f; - break; - case 1: - npc.ai[0] = 3f; - npc.noTileCollide = true; - npc.velocity.Y = death ? -11f : revenge ? -10f : expertMode ? -9f : -8f; - break; - case 2: - npc.ai[0] = 5f; - break; - default: - break; - } - npc.ai[1] = 0f; + npc.ai[2] += death ? 1f - lifeRatio : 0.5f * (1f - lifeRatio); + } + if (npc.ai[2] >= 180f && npc.velocity.Y == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + int random = Main.rand.Next(2) + (lifeRatio < 0.5f ? 1 : 0); + switch (random) + { + case 0: + npc.ai[0] = 2f; + break; + case 1: + npc.ai[0] = 3f; + npc.noTileCollide = true; + npc.velocity.Y = death ? -11f : revenge ? -10f : expertMode ? -9f : -8f; + break; + case 2: + npc.ai[0] = 5f; + break; + default: + break; + } + npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; npc.netUpdate = true; @@ -316,14 +316,14 @@ namespace CalamityMod.NPCs.SlimeGod return; } vector272.Normalize(); - vector272 *= (death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; - npc.velocity = (npc.velocity * 5f + vector272) / 6f; + vector272 *= (death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; + npc.velocity = (npc.velocity * 5f + vector272) / 6f; } } else if (npc.ai[0] == 3.1f) { - bool atTargetPosition = npc.position.Y + npc.height >= player.position.Y; - if (npc.ai[2] == 0f && (atTargetPosition || npc.localAI[1] == 0f) && Collision.CanHit(vector, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + bool atTargetPosition = npc.position.Y + npc.height >= player.position.Y; + if (npc.ai[2] == 0f && (atTargetPosition || npc.localAI[1] == 0f) && Collision.CanHit(vector, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) { npc.ai[2] = 1f; } @@ -346,10 +346,10 @@ namespace CalamityMod.NPCs.SlimeGod { npc.noTileCollide = true; } - npc.noGravity = true; - npc.velocity.Y += 0.5f; - float velocityLimit = malice ? 22f : death ? 16f : revenge ? 15f : expertMode ? 14f : 13f; - if (npc.velocity.Y > velocityLimit) + npc.noGravity = true; + npc.velocity.Y += 0.5f; + float velocityLimit = malice ? 22f : death ? 16f : revenge ? 15f : expertMode ? 14f : 13f; + if (npc.velocity.Y > velocityLimit) { npc.velocity.Y = velocityLimit; } @@ -382,8 +382,8 @@ namespace CalamityMod.NPCs.SlimeGod if (value74.Length() > 50f) { value74.Normalize(); - value74 *= (death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; - } + value74 *= (death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; + } npc.velocity = (npc.velocity * 4f + value74) / 5f; return; } @@ -426,15 +426,15 @@ namespace CalamityMod.NPCs.SlimeGod { npc.velocity.Y -= 2f; } - npc.velocity.X = ((death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * npc.direction; - npc.ai[2] += 1f; + npc.velocity.X = ((death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * npc.direction; + npc.ai[2] += 1f; } } else { npc.velocity.X *= 0.98f; - float velocityLimit = (death ? 7f : revenge ? 6f : expertMode ? 5f : 4f) + distanceSpeedBoost; - if (npc.direction < 0 && npc.velocity.X > -velocityLimit) + float velocityLimit = (death ? 7f : revenge ? 6f : expertMode ? 5f : 4f) + distanceSpeedBoost; + if (npc.direction < 0 && npc.velocity.X > -velocityLimit) { npc.velocity.X = -velocityLimit; } @@ -495,48 +495,48 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { int num660 = (int)((double)npc.lifeMax * 0.15); - if ((float)(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)); - int num663 = ModContent.NPCType(); - if (Main.rand.NextBool(3)) - { - num663 = ModContent.NPCType(); - } - int num664 = NPC.NewNPC(x, y, num663, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num664].SetDefaults(num663, -1f); - Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); - Main.npc[num664].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num664 < 200) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); - } - } + if ((float)(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)); + int num663 = ModContent.NPCType(); + if (Main.rand.NextBool(3)) + { + num663 = ModContent.NPCType(); + } + int num664 = NPC.NewNPC(x, y, num663, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[num664].SetDefaults(num663, -1f); + Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; + Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; + Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[num664].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && num664 < 200) + { + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + } + } } } } - public override Color? GetAlpha(Color drawColor) - { - Color lightColor = new Color(Main.DiscoR, 100, 150, npc.alpha); - Color newColor = npc.localAI[1] == 1f ? lightColor : drawColor; - return newColor; - } - - public override void NPCLoot() + public override Color? GetAlpha(Color drawColor) { - if (!CalamityWorld.revenge) - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + Color lightColor = new Color(Main.DiscoR, 100, 150, npc.alpha); + Color newColor = npc.localAI[1] == 1f ? lightColor : drawColor; + return newColor; + } - bool otherSlimeGodsAlive = + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int heartAmt = Main.rand.Next(3) + 3; + for (int i = 0; i < heartAmt; i++) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + + bool otherSlimeGodsAlive = NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || @@ -598,7 +598,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(BuffID.Darkness, 120, true); - } + player.AddBuff(BuffID.Darkness, 120, true); + } } } diff --git a/NPCs/SlimeGod/SlimeGodSplit.cs b/NPCs/SlimeGod/SlimeGodSplit.cs index d4f73657fd..b9321e2503 100644 --- a/NPCs/SlimeGod/SlimeGodSplit.cs +++ b/NPCs/SlimeGod/SlimeGodSplit.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SlimeGod { - [AutoloadBossHead] + [AutoloadBossHead] public class SlimeGodSplit : ModNPC { private float bossLife; @@ -24,12 +24,12 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.LifeMaxNERB(1500, 1800, 110000); + npc.Calamity().canBreakPlayerDefense = true; + npc.LifeMaxNERB(1500, 1800, 110000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.GetNPCDamage(); - npc.width = 150; + npc.GetNPCDamage(); + npc.width = 150; npc.height = 92; npc.scale = 0.8f; npc.defense = 8; @@ -46,76 +46,76 @@ namespace CalamityMod.NPCs.SlimeGod npc.DeathSound = SoundID.NPCDeath1; music = CalamityMod.Instance.GetMusicFromMusicMod("SlimeGod") ?? MusicID.Boss1; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.localAI[1]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.localAI[1] = reader.ReadSingle(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - if (CalamityGlobalNPC.slimeGodPurple < 0 || !Main.npc[CalamityGlobalNPC.slimeGodPurple].active) - CalamityGlobalNPC.slimeGodPurple = npc.whoAmI; + writer.Write(npc.localAI[1]); + } - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.localAI[1] = reader.ReadSingle(); + } + + public override void AI() + { + if (CalamityGlobalNPC.slimeGodPurple < 0 || !Main.npc[CalamityGlobalNPC.slimeGodPurple].active) + CalamityGlobalNPC.slimeGodPurple = npc.whoAmI; + + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || npc.localAI[1] == 1f || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || npc.localAI[1] == 1f || BossRushEvent.BossRushActive; npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; Vector2 vector = npc.Center; - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; - npc.defense = npc.defDefense; - npc.damage = npc.defDamage; - if (npc.localAI[1] == 1f) - { - npc.defense = npc.defDefense + 16; - npc.damage = npc.defDamage + 20; - } + npc.defense = npc.defDefense; + npc.damage = npc.defDamage; + if (npc.localAI[1] == 1f) + { + npc.defense = npc.defDefense + 16; + npc.damage = npc.defDamage + 20; + } - npc.aiAction = 0; - npc.noTileCollide = false; - npc.noGravity = false; + npc.aiAction = 0; + npc.noTileCollide = false; + npc.noGravity = false; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - if (npc.ai[0] != 6f && (player.dead || !player.active)) - { - npc.TargetClosest(); - player = Main.player[npc.target]; - if (player.dead || !player.active) - { - npc.ai[0] = 6f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; + if (npc.ai[0] != 6f && (player.dead || !player.active)) + { + npc.TargetClosest(); + player = Main.player[npc.target]; + if (player.dead || !player.active) + { + npc.ai[0] = 6f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; npc.netUpdate = true; } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; - float distanceSpeedBoost = Vector2.Distance(player.Center, vector) * (malice ? 0.008f : 0.005f); + float distanceSpeedBoost = Vector2.Distance(player.Center, vector) * (malice ? 0.008f : 0.005f); - bool flag100 = false; + bool flag100 = false; bool hyperMode = npc.localAI[1] == 1f; if (CalamityGlobalNPC.slimeGodRed != -1) { @@ -126,56 +126,56 @@ namespace CalamityMod.NPCs.SlimeGod } if (CalamityGlobalNPC.slimeGod < 0 || !Main.npc[CalamityGlobalNPC.slimeGod].active) { - npc.localAI[1] = 0f; - hyperMode = true; + npc.localAI[1] = 0f; + hyperMode = true; flag100 = false; } - if (malice) - { - flag100 = false; - hyperMode = true; - } + if (malice) + { + flag100 = false; + hyperMode = true; + } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] += flag100 ? 0.5f : 1f; - if (revenge) - npc.localAI[0] += 0.5f; - if (malice) - npc.localAI[0] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[0] += flag100 ? 0.5f : 1f; + if (revenge) + npc.localAI[0] += 0.5f; + if (malice) + npc.localAI[0] += 1f; - if (npc.localAI[0] >= 600f && Vector2.Distance(player.Center, npc.Center) > 160f) - { - npc.localAI[0] = 0f; - float num179 = 6f; - 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; - 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)); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - value9.X += num180; - value9.Y += num182; - int totalProjectiles = expertMode ? 3 : 2; - int spread = expertMode ? 45 : 30; - for (int num186 = 0; num186 < totalProjectiles; 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)); - num183 = num179 / num183; - num180 += (float)Main.rand.Next(-spread, spread + 1); - num182 += (float)Main.rand.Next(-spread, spread + 1); - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } + if (npc.localAI[0] >= 600f && Vector2.Distance(player.Center, npc.Center) > 160f) + { + npc.localAI[0] = 0f; + float num179 = 6f; + 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; + 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)); + num183 = num179 / num183; + num180 *= num183; + num182 *= num183; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + value9.X += num180; + value9.Y += num182; + int totalProjectiles = expertMode ? 3 : 2; + int spread = expertMode ? 45 : 30; + for (int num186 = 0; num186 < totalProjectiles; 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)); + num183 = num179 / num183; + num180 += (float)Main.rand.Next(-spread, spread + 1); + num182 += (float)Main.rand.Next(-spread, spread + 1); + num180 *= num183; + num182 *= num183; + Projectile.NewProjectile(value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); + } + } + } if (npc.ai[0] == 0f) { @@ -200,14 +200,14 @@ namespace CalamityMod.NPCs.SlimeGod npc.ai[1] += flag100 ? 1f : 2f; float num1879 = 40f; float num1880 = death ? 5.5f : revenge ? 5f : expertMode ? 4.5f : 4f; - if (revenge) - { - float moveBoost = death ? 20f * (1f - lifeRatio) : 10f * (1f - lifeRatio); - float speedBoost = death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - num1879 -= moveBoost; - num1880 += speedBoost; - } - float num1881 = 5f; + if (revenge) + { + float moveBoost = death ? 20f * (1f - lifeRatio) : 10f * (1f - lifeRatio); + float speedBoost = death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + num1879 -= moveBoost; + num1880 += speedBoost; + } + float num1881 = 5f; if (!Collision.CanHit(vector, 1, 1, player.Center, 1, 1)) { num1881 += 2f; @@ -218,8 +218,8 @@ namespace CalamityMod.NPCs.SlimeGod num1880 *= 0.75f; npc.ai[1] = 0f; npc.velocity.Y -= num1881; - npc.velocity.X = (num1880 + distanceSpeedBoost) * npc.direction; - } + npc.velocity.X = (num1880 + distanceSpeedBoost) * npc.direction; + } } else { @@ -234,29 +234,29 @@ namespace CalamityMod.NPCs.SlimeGod } } npc.ai[2] += 1f; - if (revenge) - { - npc.ai[2] += death ? 1f - lifeRatio : 0.5f * (1f - lifeRatio); - } - if (npc.ai[2] >= 210f && npc.velocity.Y == 0f && Main.netMode != NetmodeID.MultiplayerClient) + if (revenge) { - int random = Main.rand.Next(2) + (lifeRatio < 0.5f ? 1 : 0); - switch (random) - { - case 0: - npc.ai[0] = 2f; - break; - case 1: - npc.ai[0] = 3f; - npc.noTileCollide = true; - npc.velocity.Y = death ? -10f : revenge ? -9f : expertMode ? -8f : -7f; - break; - case 2: - npc.ai[0] = 5f; - break; - default: - break; - } + npc.ai[2] += death ? 1f - lifeRatio : 0.5f * (1f - lifeRatio); + } + if (npc.ai[2] >= 210f && npc.velocity.Y == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + int random = Main.rand.Next(2) + (lifeRatio < 0.5f ? 1 : 0); + switch (random) + { + case 0: + npc.ai[0] = 2f; + break; + case 1: + npc.ai[0] = 3f; + npc.noTileCollide = true; + npc.velocity.Y = death ? -10f : revenge ? -9f : expertMode ? -8f : -7f; + break; + case 2: + npc.ai[0] = 5f; + break; + default: + break; + } npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -265,8 +265,8 @@ namespace CalamityMod.NPCs.SlimeGod } else if (npc.ai[0] == 2f) { - npc.localAI[0] += 5f; - npc.velocity.X *= 0.85f; + npc.localAI[0] += 5f; + npc.velocity.X *= 0.85f; npc.ai[1] += 1f; if (npc.ai[1] >= 40f) { @@ -317,14 +317,14 @@ namespace CalamityMod.NPCs.SlimeGod return; } vector272.Normalize(); - vector272 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; - npc.velocity = (npc.velocity * 5f + vector272) / 6f; + vector272 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; + npc.velocity = (npc.velocity * 5f + vector272) / 6f; } } else if (npc.ai[0] == 3.1f) { - bool atTargetPosition = npc.position.Y + npc.height >= player.position.Y; - if (npc.ai[2] == 0f && (atTargetPosition || npc.localAI[1] == 0f) && Collision.CanHit(vector, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + bool atTargetPosition = npc.position.Y + npc.height >= player.position.Y; + if (npc.ai[2] == 0f && (atTargetPosition || npc.localAI[1] == 0f) && Collision.CanHit(vector, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) { npc.ai[2] = 1f; } @@ -347,10 +347,10 @@ namespace CalamityMod.NPCs.SlimeGod { npc.noTileCollide = true; } - npc.noGravity = true; - npc.velocity.Y += 0.5f; - float velocityLimit = malice ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; - if (npc.velocity.Y > velocityLimit) + npc.noGravity = true; + npc.velocity.Y += 0.5f; + float velocityLimit = malice ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; + if (npc.velocity.Y > velocityLimit) { npc.velocity.Y = velocityLimit; } @@ -383,8 +383,8 @@ namespace CalamityMod.NPCs.SlimeGod if (value74.Length() > 50f) { value74.Normalize(); - value74 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; - } + value74 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; + } npc.velocity = (npc.velocity * 4f + value74) / 5f; return; } @@ -398,44 +398,44 @@ namespace CalamityMod.NPCs.SlimeGod if (npc.ai[1] > 5f) { npc.ai[1] = 0f; - npc.velocity.Y -= 3f; - if (player.position.Y + player.height < vector.Y) - { - npc.velocity.Y -= 1.2f; - } - if (player.position.Y + player.height < vector.Y - 40f) - { - npc.velocity.Y -= 1.4f; - } - if (player.position.Y + player.height < vector.Y - 80f) - { - npc.velocity.Y -= 1.7f; - } - if (player.position.Y + player.height < vector.Y - 120f) - { - npc.velocity.Y -= 2f; - } - if (player.position.Y + player.height < vector.Y - 160f) - { - npc.velocity.Y -= 2.2f; - } - if (player.position.Y + player.height < vector.Y - 200f) - { - npc.velocity.Y -= 2.4f; - } - if (!Collision.CanHit(vector, 1, 1, player.Center, 1, 1)) - { - npc.velocity.Y -= 2f; - } - npc.velocity.X = ((death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * npc.direction; - npc.ai[2] += 1f; + npc.velocity.Y -= 3f; + if (player.position.Y + player.height < vector.Y) + { + npc.velocity.Y -= 1.2f; + } + if (player.position.Y + player.height < vector.Y - 40f) + { + npc.velocity.Y -= 1.4f; + } + if (player.position.Y + player.height < vector.Y - 80f) + { + npc.velocity.Y -= 1.7f; + } + if (player.position.Y + player.height < vector.Y - 120f) + { + npc.velocity.Y -= 2f; + } + if (player.position.Y + player.height < vector.Y - 160f) + { + npc.velocity.Y -= 2.2f; + } + if (player.position.Y + player.height < vector.Y - 200f) + { + npc.velocity.Y -= 2.4f; + } + if (!Collision.CanHit(vector, 1, 1, player.Center, 1, 1)) + { + npc.velocity.Y -= 2f; + } + npc.velocity.X = ((death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * npc.direction; + npc.ai[2] += 1f; } } else { npc.velocity.X *= 0.98f; - float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f) + distanceSpeedBoost; - if (npc.direction < 0 && npc.velocity.X > -velocityLimit) + float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f) + distanceSpeedBoost; + if (npc.direction < 0 && npc.velocity.X > -velocityLimit) { npc.velocity.X = -velocityLimit; } @@ -496,44 +496,44 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { int num660 = (int)((double)npc.lifeMax * 0.2); - if ((float)(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)); - int num663 = ModContent.NPCType(); - int num664 = NPC.NewNPC(x, y, num663, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num664].SetDefaults(num663, -1f); - Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); - Main.npc[num664].ai[1] = 0f; - if (Main.netMode == NetmodeID.Server && num664 < 200) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); - } - } + if ((float)(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)); + int num663 = ModContent.NPCType(); + int num664 = NPC.NewNPC(x, y, num663, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[num664].SetDefaults(num663, -1f); + Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; + Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; + Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3)); + Main.npc[num664].ai[1] = 0f; + if (Main.netMode == NetmodeID.Server && num664 < 200) + { + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0); + } + } } } } - public override Color? GetAlpha(Color drawColor) - { - Color lightColor = new Color(200, 150, Main.DiscoB, npc.alpha); - Color newColor = npc.localAI[1] == 1f ? lightColor : drawColor; - return newColor; - } - - public override void NPCLoot() + public override Color? GetAlpha(Color drawColor) { - if (!CalamityWorld.revenge) - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + Color lightColor = new Color(200, 150, Main.DiscoB, npc.alpha); + Color newColor = npc.localAI[1] == 1f ? lightColor : drawColor; + return newColor; + } - bool otherSlimeGodsAlive = + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int heartAmt = Main.rand.Next(3) + 3; + for (int i = 0; i < heartAmt; i++) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + + bool otherSlimeGodsAlive = NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || NPC.CountNPCS(ModContent.NPCType()) > 1 || // the other ebonian split is alive @@ -595,7 +595,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(BuffID.Weak, 120, true); - } + player.AddBuff(BuffID.Weak, 120, true); + } } } diff --git a/NPCs/SlimeGod/SlimeSpawnCorrupt.cs b/NPCs/SlimeGod/SlimeSpawnCorrupt.cs index c8c4868dbc..a502cc8986 100644 --- a/NPCs/SlimeGod/SlimeSpawnCorrupt.cs +++ b/NPCs/SlimeGod/SlimeSpawnCorrupt.cs @@ -17,8 +17,8 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { npc.aiStyle = 14; - npc.GetNPCDamage(); - npc.width = 40; + npc.GetNPCDamage(); + npc.width = 40; npc.height = 30; npc.defense = 6; npc.lifeMax = 180; @@ -35,13 +35,13 @@ namespace CalamityMod.NPCs.SlimeGod npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } - public override bool PreNPCLoot() => false; + public override bool PreNPCLoot() => false; - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (Main.netMode != NetmodeID.MultiplayerClient && npc.life <= 0) { @@ -56,7 +56,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(BuffID.Weak, 90, true); - } + player.AddBuff(BuffID.Weak, 90, true); + } } } diff --git a/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs b/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs index 24c21db2b5..ce362d9517 100644 --- a/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs +++ b/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SlimeGod { - public class SlimeSpawnCorrupt2 : ModNPC + public class SlimeSpawnCorrupt2 : ModNPC { public override void SetStaticDefaults() { @@ -17,8 +17,8 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { npc.aiStyle = 1; - npc.GetNPCDamage(); - npc.width = 40; + npc.GetNPCDamage(); + npc.width = 40; npc.height = 30; npc.defense = 4; npc.lifeMax = 90; @@ -35,9 +35,9 @@ namespace CalamityMod.NPCs.SlimeGod npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void HitEffect(int hitDirection, double damage) { @@ -54,23 +54,23 @@ namespace CalamityMod.NPCs.SlimeGod } } - public override bool PreNPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override bool PreNPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - DropHelper.DropItemChance(npc, ItemID.Vitamins, Main.expertMode ? 50 : 100); + DropHelper.DropItemChance(npc, ItemID.Vitamins, Main.expertMode ? 50 : 100); - return false; - } + return false; + } public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(BuffID.Weak, 90, true); - } + player.AddBuff(BuffID.Weak, 90, true); + } } } diff --git a/NPCs/SlimeGod/SlimeSpawnCrimson.cs b/NPCs/SlimeGod/SlimeSpawnCrimson.cs index ff39eb9c14..11b46b6dd2 100644 --- a/NPCs/SlimeGod/SlimeSpawnCrimson.cs +++ b/NPCs/SlimeGod/SlimeSpawnCrimson.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SlimeGod { - public class SlimeSpawnCrimson : ModNPC + public class SlimeSpawnCrimson : ModNPC { public override void SetStaticDefaults() { @@ -17,8 +17,8 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { npc.aiStyle = 1; - npc.GetNPCDamage(); - npc.width = 40; + npc.GetNPCDamage(); + npc.width = 40; npc.height = 30; npc.defense = 4; npc.lifeMax = 110; @@ -35,9 +35,9 @@ namespace CalamityMod.NPCs.SlimeGod npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void HitEffect(int hitDirection, double damage) { @@ -54,23 +54,23 @@ namespace CalamityMod.NPCs.SlimeGod } } - public override bool PreNPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override bool PreNPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - DropHelper.DropItemChance(npc, ItemID.Blindfold, Main.expertMode ? 50 : 100); + DropHelper.DropItemChance(npc, ItemID.Blindfold, Main.expertMode ? 50 : 100); - return false; - } + return false; + } public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(BuffID.Darkness, 90, true); - } + player.AddBuff(BuffID.Darkness, 90, true); + } } } diff --git a/NPCs/SlimeGod/SlimeSpawnCrimson2.cs b/NPCs/SlimeGod/SlimeSpawnCrimson2.cs index 581dd5be4e..6de4023aa6 100644 --- a/NPCs/SlimeGod/SlimeSpawnCrimson2.cs +++ b/NPCs/SlimeGod/SlimeSpawnCrimson2.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SlimeGod { - public class SlimeSpawnCrimson2 : ModNPC + public class SlimeSpawnCrimson2 : ModNPC { public float spikeTimer = 60f; @@ -22,8 +22,8 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { npc.aiStyle = 1; - npc.GetNPCDamage(); - npc.width = 40; + npc.GetNPCDamage(); + npc.width = 40; npc.height = 30; npc.defense = 6; npc.lifeMax = 130; @@ -39,37 +39,37 @@ namespace CalamityMod.NPCs.SlimeGod npc.canGhostHeal = false; npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToSickness = false; - } + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToSickness = false; + } public override void FindFrame(int frameHeight) { - int frameY = 1; - if (!Main.dedServ) - { - if (!Main.NPCLoaded[npc.type] || Main.npcTexture[npc.type] is null) - return; - frameY = Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type]; - } - int aiState = 0; - if (npc.aiAction == 0) - aiState = npc.velocity.Y >= 0f ? (npc.velocity.Y <= 0f ? (npc.velocity.X == 0f ? 0 : 1) : 3) : 2; - else if (npc.aiAction == 1) - aiState = 4; + int frameY = 1; + if (!Main.dedServ) + { + if (!Main.NPCLoaded[npc.type] || Main.npcTexture[npc.type] is null) + return; + frameY = Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type]; + } + int aiState = 0; + if (npc.aiAction == 0) + aiState = npc.velocity.Y >= 0f ? (npc.velocity.Y <= 0f ? (npc.velocity.X == 0f ? 0 : 1) : 3) : 2; + else if (npc.aiAction == 1) + aiState = 4; - npc.frameCounter++; - if (aiState > 0) - npc.frameCounter++; - if (aiState == 4) - npc.frameCounter++; - if (npc.frameCounter >= 8f) - { - npc.frame.Y += frameY; - npc.frameCounter = 0f; - } - if (npc.frame.Y >= frameY * Main.npcFrameCount[npc.type]) - npc.frame.Y = 0; + npc.frameCounter++; + if (aiState > 0) + npc.frameCounter++; + if (aiState == 4) + npc.frameCounter++; + if (npc.frameCounter >= 8f) + { + npc.frame.Y += frameY; + npc.frameCounter = 0f; + } + if (npc.frame.Y >= frameY * Main.npcFrameCount[npc.type]) + npc.frame.Y = 0; } public override void AI() @@ -77,9 +77,9 @@ namespace CalamityMod.NPCs.SlimeGod if (spikeTimer > 0f) spikeTimer -= 1f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (!npc.wet) + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + if (!npc.wet) { Vector2 vector3 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num14 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector3.X; @@ -142,23 +142,23 @@ namespace CalamityMod.NPCs.SlimeGod } } - public override bool PreNPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } + public override bool PreNPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(8) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } - DropHelper.DropItemChance(npc, ItemID.Blindfold, Main.expertMode ? 50 : 100); + DropHelper.DropItemChance(npc, ItemID.Blindfold, Main.expertMode ? 50 : 100); - return false; - } + return false; + } public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(BuffID.Darkness, 90, true); - } + player.AddBuff(BuffID.Darkness, 90, true); + } } } diff --git a/NPCs/StormWeaver/StormWeaverBody.cs b/NPCs/StormWeaver/StormWeaverBody.cs index a7f7eb8da5..97ec59380e 100644 --- a/NPCs/StormWeaver/StormWeaverBody.cs +++ b/NPCs/StormWeaver/StormWeaverBody.cs @@ -15,38 +15,38 @@ namespace CalamityMod.NPCs.StormWeaver public override void SetStaticDefaults() { DisplayName.SetDefault("Storm Weaver"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 40; npc.height = 40; - // 10% of HP is phase one - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.lifeMax = notDoGFight ? 825500 : 139750; - npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); + // 10% of HP is phase one + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; + npc.lifeMax = notDoGFight ? 825500 : 139750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) + // If fought alone, Storm Weaver plays its own theme + if (notDoGFight) music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; // If fought as a DoG interlude, keep the DoG music playing else music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - // Phase one settings - CalamityGlobalNPC global = npc.Calamity(); - npc.defense = 150; - global.DR = 0.999999f; - global.unbreakableDR = true; - npc.chaseable = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; + // Phase one settings + CalamityGlobalNPC global = npc.Calamity(); + npc.defense = 150; + global.DR = 0.999999f; + global.unbreakableDR = true; + npc.chaseable = false; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -69,17 +69,17 @@ namespace CalamityMod.NPCs.StormWeaver else if (Main.expertMode) npc.scale = 1.1f; - npc.Calamity().VulnerableToElectricity = false; - } + npc.Calamity().VulnerableToElectricity = false; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(npc.chaseable); + writer.Write(npc.chaseable); } public override void ReceiveExtraAI(BinaryReader reader) { - npc.chaseable = reader.ReadBoolean(); + npc.chaseable = reader.ReadBoolean(); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) @@ -89,68 +89,68 @@ namespace CalamityMod.NPCs.StormWeaver public override void AI() { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; - // Shed armor - bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + // Shed armor + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; - // Update armored settings to naked settings - if (shedArmor) - { - // Spawn armor gore and set other crucial variables - if (!npc.chaseable) - { - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; + // Update armored settings to naked settings + if (shedArmor) + { + // Spawn armor gore and set other crucial variables + if (!npc.chaseable) + { + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody1"), npc.scale); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody2"), npc.scale); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody3"), npc.scale); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody1"), npc.scale); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody2"), npc.scale); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody3"), npc.scale); - CalamityGlobalNPC global = npc.Calamity(); - npc.defense = 30; - global.DR = 0.2f; - global.unbreakableDR = false; - npc.chaseable = true; - npc.HitSound = SoundID.NPCHit13; - npc.DeathSound = SoundID.NPCDeath13; - npc.frame = new Rectangle(0, 0, 54, 52); - } - } + CalamityGlobalNPC global = npc.Calamity(); + npc.defense = 30; + global.DR = 0.2f; + global.unbreakableDR = false; + npc.chaseable = true; + npc.HitSound = SoundID.NPCHit13; + npc.DeathSound = SoundID.NPCDeath13; + npc.frame = new Rectangle(0, 0, 54, 52); + } + } - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (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); - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { if (npc.alpha != 0) { @@ -206,24 +206,24 @@ namespace CalamityMod.NPCs.StormWeaver } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; - Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverBodyNaked") : Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverBodyNaked") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { @@ -233,20 +233,20 @@ namespace CalamityMod.NPCs.StormWeaver color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp(Main.npc[(int)npc.ai[2]].localAI[3] / 60f, 0f, 1f)); } - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { @@ -258,8 +258,8 @@ namespace CalamityMod.NPCs.StormWeaver spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } public override bool CanHitPlayer(Player target, ref int cooldownSlot) { @@ -267,13 +267,13 @@ namespace CalamityMod.NPCs.StormWeaver return true; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 180 : 90; - player.AddBuff(BuffID.Electrified, buffDuration, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 180 : 90; + player.AddBuff(BuffID.Electrified, buffDuration, true); + } - public override bool CheckActive() + public override bool CheckActive() { return false; } @@ -283,23 +283,23 @@ namespace CalamityMod.NPCs.StormWeaver return false; } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x) && npc.life / (float)npc.lifeMax >= 0.9f) - { - if (projectile.penetrate == -1 && !projectile.minion) - projectile.penetrate = 1; - else if (projectile.penetrate >= 1) - projectile.penetrate = 1; - } - } - - public override void HitEffect(int hitDirection, double damage) + public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - for (int k = 0; k < 3; k++) - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); + if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x) && npc.life / (float)npc.lifeMax >= 0.9f) + { + if (projectile.penetrate == -1 && !projectile.minion) + projectile.penetrate = 1; + else if (projectile.penetrate >= 1) + projectile.penetrate = 1; + } + } - if (npc.life <= 0) + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); + + if (npc.life <= 0) { Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody1"), npc.scale); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody2"), npc.scale); diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index 2e3316022a..64bc94e317 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -22,50 +22,50 @@ namespace CalamityMod.NPCs.StormWeaver { public class StormWeaverHead : ModNPC { - public static int normalIconIndex; - public static int vulnerableIconIndex; + public static int normalIconIndex; + public static int vulnerableIconIndex; - internal static void LoadHeadIcons() - { - string normalIconPath = "CalamityMod/NPCs/StormWeaver/StormWeaverHead_Head_Boss"; - string vulnerableIconPath = "CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked_Head_Boss"; + internal static void LoadHeadIcons() + { + string normalIconPath = "CalamityMod/NPCs/StormWeaver/StormWeaverHead_Head_Boss"; + string vulnerableIconPath = "CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked_Head_Boss"; - CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); - normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); + CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); + normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); - CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); - vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); - } + CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); + vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); + } - private const float BoltAngleSpread = 280; + private const float BoltAngleSpread = 280; private bool tail = false; - // Lightning flash variables - public float lightning = 0f; - private float lightningDecay = 1f; - private float lightningSpeed = 0f; + // Lightning flash variables + public float lightning = 0f; + private float lightningDecay = 1f; + private float lightningSpeed = 0f; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Storm Weaver"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 74; npc.height = 74; - // 10% of HP is phase one - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.lifeMax = notDoGFight ? 825500 : 139750; - npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); + // 10% of HP is phase one + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; + npc.lifeMax = notDoGFight ? 825500 : 139750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) + // If fought alone, Storm Weaver plays its own theme + if (notDoGFight) { npc.value = Item.buyPrice(2, 0, 0, 0); music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; @@ -74,16 +74,16 @@ namespace CalamityMod.NPCs.StormWeaver else music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - // Phase one settings - CalamityGlobalNPC global = npc.Calamity(); - npc.defense = 150; - global.DR = 0.999999f; - global.unbreakableDR = true; - npc.chaseable = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; + // Phase one settings + CalamityGlobalNPC global = npc.Calamity(); + npc.defense = 150; + global.DR = 0.999999f; + global.unbreakableDR = true; + npc.chaseable = false; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -96,113 +96,113 @@ namespace CalamityMod.NPCs.StormWeaver npc.netAlways = true; bossBag = ModContent.ItemType(); - if (CalamityWorld.malice || BossRushEvent.BossRushActive) - npc.scale = 1.25f; - else if (CalamityWorld.death) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; + if (CalamityWorld.malice || BossRushEvent.BossRushActive) + npc.scale = 1.25f; + else if (CalamityWorld.death) + npc.scale = 1.2f; + else if (CalamityWorld.revenge) + npc.scale = 1.15f; + else if (Main.expertMode) + npc.scale = 1.1f; - npc.Calamity().VulnerableToElectricity = false; - } + npc.Calamity().VulnerableToElectricity = false; + } - public override void BossHeadSlot(ref int index) - { - if (npc.life / (float)npc.lifeMax < 0.9f) - index = vulnerableIconIndex; - else - index = normalIconIndex; - } - - public override void SendExtraAI(BinaryWriter writer) + public override void BossHeadSlot(ref int index) { - writer.Write(npc.chaseable); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - writer.Write(npc.localAI[3]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } + if (npc.life / (float)npc.lifeMax < 0.9f) + index = vulnerableIconIndex; + else + index = normalIconIndex; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + writer.Write(npc.localAI[3]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { - npc.chaseable = reader.ReadBoolean(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } + npc.chaseable = reader.ReadBoolean(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; if (!Main.raining) - CalamityUtils.StartRain(); + CalamityUtils.StartRain(); float lifeRatio = npc.life / (float)npc.lifeMax; - // Shed armor - bool shedArmor = lifeRatio < 0.9f; + // Shed armor + bool shedArmor = lifeRatio < 0.9f; - // Start charging at the target - bool phase2 = lifeRatio < 0.7f; + // Start charging at the target + bool phase2 = lifeRatio < 0.7f; - // Lightning strike flash phase - bool phase3 = lifeRatio < 0.4f; + // Lightning strike flash phase + bool phase3 = lifeRatio < 0.4f; - // Become weak and cancel the storm - bool phase4 = lifeRatio < 0.05f; + // Become weak and cancel the storm + bool phase4 = lifeRatio < 0.05f; - // Update armored settings to naked settings - if (shedArmor) - { - // Spawn armor gore, roar and set other crucial variables - if (!npc.chaseable) - { - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; + // Update armored settings to naked settings + if (shedArmor) + { + // Spawn armor gore, roar and set other crucial variables + if (!npc.chaseable) + { + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorHead1"), npc.scale); - Main.PlaySound(SoundID.NPCDeath14, (int)npc.Center.X, (int)npc.Center.Y); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorHead1"), npc.scale); + Main.PlaySound(SoundID.NPCDeath14, (int)npc.Center.X, (int)npc.Center.Y); - CalamityGlobalNPC global = npc.Calamity(); - npc.defense = 15; - global.DR = 0.1f; - global.unbreakableDR = false; - npc.chaseable = true; - npc.HitSound = SoundID.NPCHit13; - npc.DeathSound = SoundID.NPCDeath13; - npc.frame = new Rectangle(0, 0, 62, 86); - } - } + CalamityGlobalNPC global = npc.Calamity(); + npc.defense = 15; + global.DR = 0.1f; + global.unbreakableDR = false; + npc.chaseable = true; + npc.HitSound = SoundID.NPCHit13; + npc.DeathSound = SoundID.NPCDeath13; + npc.frame = new Rectangle(0, 0, 62, 86); + } + } - int boltProjectiles = (phase3 || death) ? 4 : phase2 ? 3 : 2; + int boltProjectiles = (phase3 || death) ? 4 : phase2 ? 3 : 2; Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - if (npc.alpha != 0) + if (npc.alpha != 0) { for (int num934 = 0; num934 < 2; num934++) { @@ -221,8 +221,8 @@ namespace CalamityMod.NPCs.StormWeaver if (!tail && npc.ai[0] == 0f) { int Previous = npc.whoAmI; - int totalLength = death ? 60 : revenge ? 50 : expertMode ? 40 : 30; - for (int num36 = 0; num36 < totalLength; num36++) + int totalLength = death ? 60 : revenge ? 50 : expertMode ? 40 : 30; + for (int num36 = 0; num36 < totalLength; num36++) { int lol; if (num36 >= 0 && num36 < totalLength - 1) @@ -241,35 +241,35 @@ namespace CalamityMod.NPCs.StormWeaver tail = true; } - if (expertMode && !phase4) - { - npc.localAI[0] += malice ? 1.5f : 1f; - float spawnOrbGateValue = shedArmor ? 450f : 360f; - if (npc.localAI[0] >= spawnOrbGateValue) - { - npc.localAI[0] = 0f; - npc.netUpdate = true; + if (expertMode && !phase4) + { + npc.localAI[0] += malice ? 1.5f : 1f; + float spawnOrbGateValue = shedArmor ? 450f : 360f; + if (npc.localAI[0] >= spawnOrbGateValue) + { + npc.localAI[0] = 0f; + npc.netUpdate = true; - float orbDistance = shedArmor ? 250f : 350f; - float xPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.X + orbDistance : Main.player[npc.target].position.X - orbDistance; - float yPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.Y + orbDistance : Main.player[npc.target].position.Y - orbDistance; - Vector2 spawnPos = new Vector2(xPos, yPos); + float orbDistance = shedArmor ? 250f : 350f; + float xPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.X + orbDistance : Main.player[npc.target].position.X - orbDistance; + float yPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.Y + orbDistance : Main.player[npc.target].position.Y - orbDistance; + Vector2 spawnPos = new Vector2(xPos, yPos); - int type = ProjectileID.CultistBossLightningOrb; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(spawnPos, Vector2.Zero, type, damage, 0f, Main.myPlayer); - } - } + int type = ProjectileID.CultistBossLightningOrb; + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(spawnPos, Vector2.Zero, type, damage, 0f, Main.myPlayer); + } + } } - if (npc.life > Main.npc[(int)npc.ai[0]].life) - npc.life = Main.npc[(int)npc.ai[0]].life; + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; - if (Main.player[npc.target].dead && npc.life > 0) + if (Main.player[npc.target].dead && npc.life > 0) { - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - npc.TargetClosest(false); + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + npc.TargetClosest(false); npc.velocity.Y -= 3f; if ((double)npc.position.Y < Main.topWorld + 16f) @@ -331,74 +331,74 @@ namespace CalamityMod.NPCs.StormWeaver float num188 = (shedArmor ? 12f : 10f) + (malice ? 3f : revenge ? 1.5f : expertMode ? 1f : 0f); float num189 = (shedArmor ? 0.24f : 0.2f) + (malice ? 0.12f : revenge ? 0.08f : expertMode ? 0.04f : 0f); - // Start charging at the player when in phase 2 - if (phase2 && !phase4) - { - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] >= 400f) - { - npc.localAI[3] = 60f; + // Start charging at the player when in phase 2 + if (phase2 && !phase4) + { + calamityGlobalNPC.newAI[0] += 1f; + if (calamityGlobalNPC.newAI[0] >= 400f) + { + npc.localAI[3] = 60f; - if (npc.localAI[1] == 0f) - npc.localAI[1] = 1f; + if (npc.localAI[1] == 0f) + npc.localAI[1] = 1f; - if (calamityGlobalNPC.newAI[0] >= 500f) - { - npc.TargetClosest(); - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } + if (calamityGlobalNPC.newAI[0] >= 500f) + { + npc.TargetClosest(); + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } - if (revenge) - { - if (npc.localAI[1] == 2f) - { - num188 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio); - num189 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.0001f * (0.7f - lifeRatio); - num188 *= 2f; - num189 *= 0.85f; + if (revenge) + { + if (npc.localAI[1] == 2f) + { + num188 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio); + num189 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.0001f * (0.7f - lifeRatio); + num188 *= 2f; + num189 *= 0.85f; - float stopChargeDistance = 800f * npc.localAI[2]; - if (stopChargeDistance < 0) - { - if (npc.Center.X < Main.player[npc.target].Center.X + stopChargeDistance) - { - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - } - else - { - if (npc.Center.X > Main.player[npc.target].Center.X + stopChargeDistance) - { - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - } - } + float stopChargeDistance = 800f * npc.localAI[2]; + if (stopChargeDistance < 0) + { + if (npc.Center.X < Main.player[npc.target].Center.X + stopChargeDistance) + { + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + } + else + { + if (npc.Center.X > Main.player[npc.target].Center.X + stopChargeDistance) + { + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + } + } - int dustAmt = 5; - for (int num1474 = 0; num1474 < dustAmt; num1474++) - { - Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; - vector171 = vector171.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)MathHelper.Pi / (float)dustAmt) + npc.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 206, value18.X, value18.Y, 100, default, 3f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= npc.velocity; - } - } - } - else if (revenge) - { - calamityGlobalNPC.newAI[0] += malice ? 4f : death ? 2f : 2f * (0.7f - lifeRatio); + int dustAmt = 5; + for (int num1474 = 0; num1474 < dustAmt; num1474++) + { + Vector2 vector171 = Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f; + vector171 = vector171.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)MathHelper.Pi / (float)dustAmt) + npc.Center; + Vector2 value18 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 206, value18.X, value18.Y, 100, default, 3f); + Main.dust[num1475].noGravity = true; + Main.dust[num1475].noLight = true; + Main.dust[num1475].velocity /= 4f; + Main.dust[num1475].velocity -= npc.velocity; + } + } + } + else if (revenge) + { + calamityGlobalNPC.newAI[0] += malice ? 4f : death ? 2f : 2f * (0.7f - lifeRatio); - if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; - } - } + if (npc.localAI[3] > 0f) + npc.localAI[3] -= 1f; + } + } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; @@ -417,75 +417,75 @@ namespace CalamityMod.NPCs.StormWeaver } } - if (phase2 && !phase4) - { - if (npc.localAI[1] == 1f) - { - // Play lightning sound on the target if not in phase 3 - Vector2 soundCenter = Main.player[npc.target].Center; + if (phase2 && !phase4) + { + if (npc.localAI[1] == 1f) + { + // Play lightning sound on the target if not in phase 3 + Vector2 soundCenter = Main.player[npc.target].Center; - // Play lightning sound on all nearby players if in phase 3 - if (phase3) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < 2800f) - { - soundCenter = Main.player[Main.myPlayer].Center; + // Play lightning sound on all nearby players if in phase 3 + if (phase3) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < 2800f) + { + soundCenter = Main.player[Main.myPlayer].Center; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); - if (Main.netMode != NetmodeID.Server) - { - // Set how quickly the lightning flash dissipates - lightningDecay = Main.rand.NextFloat() * 0.05f + 0.008f; + if (Main.netMode != NetmodeID.Server) + { + // Set how quickly the lightning flash dissipates + lightningDecay = Main.rand.NextFloat() * 0.05f + 0.008f; - // Set how quickly the lightning flash intensifies - lightningSpeed = Main.rand.NextFloat() * 0.05f + 0.05f; - } - } - } - else - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); + // Set how quickly the lightning flash intensifies + lightningSpeed = Main.rand.NextFloat() * 0.05f + 0.05f; + } + } + } + else + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); - npc.localAI[1] = 2f; + npc.localAI[1] = 2f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int speed2 = revenge ? 8 : 7; - float spawnX2 = npc.Center.X > Main.player[npc.target].Center.X ? 1000f : -1000f; - float spawnY2 = -1000f + Main.player[npc.target].Center.Y; - Vector2 baseSpawn = new Vector2(spawnX2 + Main.player[npc.target].Center.X, spawnY2); - Vector2 baseVelocity = Main.player[npc.target].Center - baseSpawn; - baseVelocity.Normalize(); - baseVelocity *= speed2; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int speed2 = revenge ? 8 : 7; + float spawnX2 = npc.Center.X > Main.player[npc.target].Center.X ? 1000f : -1000f; + float spawnY2 = -1000f + Main.player[npc.target].Center.Y; + Vector2 baseSpawn = new Vector2(spawnX2 + Main.player[npc.target].Center.X, spawnY2); + Vector2 baseVelocity = Main.player[npc.target].Center - baseSpawn; + baseVelocity.Normalize(); + baseVelocity *= speed2; - for (int i = 0; i < boltProjectiles; i++) - { - Vector2 source = baseSpawn; - source.X += i * 30f - (boltProjectiles * 15f); - Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-BoltAngleSpread / 2 + (BoltAngleSpread * i / boltProjectiles))); - velocity.X = velocity.X + 3f * Main.rand.NextFloat() - 1.5f; - Vector2 vector94 = Main.player[npc.target].Center - source; - float ai = Main.rand.Next(100); - int type = ProjectileID.CultistBossLightningOrbArc; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(source, velocity, type, damage, 0f, Main.myPlayer, vector94.ToRotation(), ai); - } - } + for (int i = 0; i < boltProjectiles; i++) + { + Vector2 source = baseSpawn; + source.X += i * 30f - (boltProjectiles * 15f); + Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-BoltAngleSpread / 2 + (BoltAngleSpread * i / boltProjectiles))); + velocity.X = velocity.X + 3f * Main.rand.NextFloat() - 1.5f; + Vector2 vector94 = Main.player[npc.target].Center - source; + float ai = Main.rand.Next(100); + int type = ProjectileID.CultistBossLightningOrbArc; + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(source, velocity, type, damage, 0f, Main.myPlayer, vector94.ToRotation(), ai); + } + } - if (revenge) - npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * (num188 + Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio)) * 2f; + if (revenge) + npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * (num188 + Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio)) * 2f; - float chargeDirection = 0; - if (npc.velocity.X < 0f) - chargeDirection = -1f; - else if (npc.velocity.X > 0f) - chargeDirection = 1f; + float chargeDirection = 0; + if (npc.velocity.X < 0f) + chargeDirection = -1f; + else if (npc.velocity.X > 0f) + chargeDirection = 1f; - npc.localAI[2] = chargeDirection; - } - } + npc.localAI[2] = chargeDirection; + } + } - num191 = (int)(num191 / 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; @@ -572,91 +572,91 @@ namespace CalamityMod.NPCs.StormWeaver npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - if (phase4) - { - // Become weak and stop the storm when in phase 4 - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - CalamityMod.StopRain(); - } - else if (phase3) - { - // Adjust lightning flash variables when in phase 3 - if (Main.netMode != NetmodeID.Server) - { - if (lightningSpeed > 0f) - { - lightning += lightningSpeed; - if (lightning >= 1f) - { - lightning = 1f; - lightningSpeed = 0f; - } - } - else if (lightning > 0f) - lightning -= lightningDecay; - } + if (phase4) + { + // Become weak and stop the storm when in phase 4 + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + CalamityMod.StopRain(); + } + else if (phase3) + { + // Adjust lightning flash variables when in phase 3 + if (Main.netMode != NetmodeID.Server) + { + if (lightningSpeed > 0f) + { + lightning += lightningSpeed; + if (lightning >= 1f) + { + lightning = 1f; + lightningSpeed = 0f; + } + } + else if (lightning > 0f) + lightning -= lightningDecay; + } - // Start a storm when in third phase - if (Main.netMode == NetmodeID.MultiplayerClient || (Main.netMode == NetmodeID.SinglePlayer && Main.gameMenu) || calamityGlobalNPC.newAI[1] > 0f) - return; + // Start a storm when in third phase + if (Main.netMode == NetmodeID.MultiplayerClient || (Main.netMode == NetmodeID.SinglePlayer && Main.gameMenu) || calamityGlobalNPC.newAI[1] > 0f) + return; - CalamityUtils.StartRain(true, true); - calamityGlobalNPC.newAI[1] = 1f; - } - } + CalamityUtils.StartRain(true, true); + calamityGlobalNPC.newAI[1] = 1f; + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; - Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked") : Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - if (npc.Calamity().newAI[0] > 280f) - color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - else if (npc.localAI[3] > 0f) - color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp(npc.localAI[3] / 60f, 0f, 1f)); - } + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + { + if (npc.Calamity().newAI[0] > 280f) + color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + else if (npc.localAI[3] > 0f) + color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp(npc.localAI[3] / 60f, 0f, 1f)); + } - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - if (npc.Calamity().newAI[0] > 280f) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - else if (npc.localAI[3] > 0f) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp(npc.localAI[3] / 60f, 0f, 1f)); - } + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + { + if (npc.Calamity().newAI[0] > 280f) + color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + else if (npc.localAI[3] > 0f) + color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp(npc.localAI[3] / 60f, 0f, 1f)); + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); return false; } @@ -667,13 +667,13 @@ namespace CalamityMod.NPCs.StormWeaver return true; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - int buffDuration = npc.Calamity().newAI[0] >= 400f ? 360 : 180; - player.AddBuff(BuffID.Electrified, buffDuration, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + int buffDuration = npc.Calamity().newAI[0] >= 400f ? 360 : 180; + player.AddBuff(BuffID.Electrified, buffDuration, true); + } - public override bool CheckActive() + public override bool CheckActive() { return false; } @@ -746,39 +746,39 @@ namespace CalamityMod.NPCs.StormWeaver public override void NPCLoot() { // Only drop items if fought at full strength - bool fullStrength = !CalamityWorld.downedSentinel2 || CalamityWorld.DoGSecondStageCountdown <= 0; + bool fullStrength = !CalamityWorld.downedSentinel2 || CalamityWorld.DoGSecondStageCountdown <= 0; if (fullStrength) { - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - bool lastSentinelKilled = CalamityWorld.downedSentinel1 && !CalamityWorld.downedSentinel2 && CalamityWorld.downedSentinel3; - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, lastSentinelKilled); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + bool lastSentinelKilled = CalamityWorld.downedSentinel1 && !CalamityWorld.downedSentinel2 && CalamityWorld.downedSentinel3; + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, lastSentinelKilled); - if (!Main.expertMode) - { - // Materials - DropHelper.DropItem(npc, ModContent.ItemType(), true, 5, 8); + if (!Main.expertMode) + { + // Materials + DropHelper.DropItem(npc, ModContent.ItemType(), true, 5, 8); - // Weapons - DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + // Weapons + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); // Light pet. DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); if (Main.rand.NextBool(20)) - { - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - } - } + { + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + } + } } // If DoG's fight is active, set the timer for Signus' phase @@ -794,12 +794,12 @@ namespace CalamityMod.NPCs.StormWeaver } } - // Mark Storm Weaver as dead - if (fullStrength) - { - CalamityWorld.downedSentinel2 = true; - CalamityNetcode.SyncWorld(); - } + // Mark Storm Weaver as dead + if (fullStrength) + { + CalamityWorld.downedSentinel2 = true; + CalamityNetcode.SyncWorld(); + } } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) diff --git a/NPCs/StormWeaver/StormWeaverTail.cs b/NPCs/StormWeaver/StormWeaverTail.cs index 8e7a0c25c6..496026fe5c 100644 --- a/NPCs/StormWeaver/StormWeaverTail.cs +++ b/NPCs/StormWeaver/StormWeaverTail.cs @@ -17,34 +17,34 @@ namespace CalamityMod.NPCs.StormWeaver public override void SetStaticDefaults() { DisplayName.SetDefault("Storm Weaver"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.GetNPCDamage(); - npc.npcSlots = 5f; + npc.GetNPCDamage(); + npc.npcSlots = 5f; npc.width = 48; npc.height = 80; - // 10% of HP is phase one - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.lifeMax = notDoGFight ? 825500 : 139750; - npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); + // 10% of HP is phase one + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; + npc.lifeMax = notDoGFight ? 825500 : 139750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) + // If fought alone, Storm Weaver plays its own theme + if (notDoGFight) music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; // If fought as a DoG interlude, keep the DoG music playing else music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - // Phase one settings - npc.takenDamageMultiplier = 3f; - npc.HitSound = SoundID.NPCHit53; - npc.DeathSound = SoundID.NPCDeath14; + // Phase one settings + npc.takenDamageMultiplier = 3f; + npc.HitSound = SoundID.NPCHit53; + npc.DeathSound = SoundID.NPCDeath14; - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -68,17 +68,17 @@ namespace CalamityMod.NPCs.StormWeaver npc.scale = 1.1f; npc.Calamity().VulnerableToElectricity = false; - } + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(invinceTime); + writer.Write(invinceTime); writer.Write(npc.dontTakeDamage); } public override void ReceiveExtraAI(BinaryReader reader) { - invinceTime = reader.ReadInt32(); + invinceTime = reader.ReadInt32(); npc.dontTakeDamage = reader.ReadBoolean(); } @@ -101,66 +101,66 @@ namespace CalamityMod.NPCs.StormWeaver npc.dontTakeDamage = false; } - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; - // Shed armor - bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + // Shed armor + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; - // Update armored settings to naked settings - if (shedArmor) - { - // Spawn armor gore and set other crucial variables - if (npc.takenDamageMultiplier == 3f) - { - npc.Calamity().VulnerableToHeat = true; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; + // Update armored settings to naked settings + if (shedArmor) + { + // Spawn armor gore and set other crucial variables + if (npc.takenDamageMultiplier == 3f) + { + npc.Calamity().VulnerableToHeat = true; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail1"), npc.scale); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail2"), npc.scale); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail1"), npc.scale); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail2"), npc.scale); - CalamityGlobalNPC global = npc.Calamity(); - npc.defense = 45; - global.DR = 0.3f; - npc.takenDamageMultiplier = 1f; - npc.HitSound = SoundID.NPCHit13; - npc.DeathSound = SoundID.NPCDeath13; - npc.frame = new Rectangle(0, 0, 42, 68); - } - } + CalamityGlobalNPC global = npc.Calamity(); + npc.defense = 45; + global.DR = 0.3f; + npc.takenDamageMultiplier = 1f; + npc.HitSound = SoundID.NPCHit13; + npc.DeathSound = SoundID.NPCDeath13; + npc.frame = new Rectangle(0, 0, 42, 68); + } + } - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (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); - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { if (npc.alpha != 0) { @@ -177,13 +177,13 @@ namespace CalamityMod.NPCs.StormWeaver npc.alpha = 0; } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].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; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; @@ -216,24 +216,24 @@ namespace CalamityMod.NPCs.StormWeaver } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; - Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverTailNaked") : Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverTailNaked") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { @@ -244,19 +244,19 @@ namespace CalamityMod.NPCs.StormWeaver } color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { @@ -268,30 +268,30 @@ namespace CalamityMod.NPCs.StormWeaver spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - if (!shedArmor) - { - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverTailGlow"); - Color rainbowBecauseWhyTheFuckNot = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - Color color37 = Color.Lerp(Color.White, rainbowBecauseWhyTheFuckNot, 0.5f); - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + if (!shedArmor) + { + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverTailGlow"); + Color rainbowBecauseWhyTheFuckNot = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); + Color color37 = Color.Lerp(Color.White, rainbowBecauseWhyTheFuckNot, 0.5f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } - return false; - } + return false; + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 120 : 60; - player.AddBuff(BuffID.Electrified, buffDuration, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 120 : 60; + player.AddBuff(BuffID.Electrified, buffDuration, true); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); diff --git a/NPCs/SulphurousSea/AnthozoanCrab.cs b/NPCs/SulphurousSea/AnthozoanCrab.cs index 7543887cea..49515ed00d 100644 --- a/NPCs/SulphurousSea/AnthozoanCrab.cs +++ b/NPCs/SulphurousSea/AnthozoanCrab.cs @@ -13,7 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SulphurousSea { - public class AnthozoanCrab : ModNPC + public class AnthozoanCrab : ModNPC { public int boulderIndex; public override void SetStaticDefaults() @@ -37,11 +37,11 @@ namespace CalamityMod.NPCs.SulphurousSea npc.knockBackResist = 0.04f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(boulderIndex); @@ -196,12 +196,12 @@ namespace CalamityMod.NPCs.SulphurousSea DropHelper.DropItemChance(npc, ModContent.ItemType(), 15); // Rarer to encourage fighting Acid Rain } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 180); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { diff --git a/NPCs/SulphurousSea/BelchingCoral.cs b/NPCs/SulphurousSea/BelchingCoral.cs index 039757da53..f941dcc646 100644 --- a/NPCs/SulphurousSea/BelchingCoral.cs +++ b/NPCs/SulphurousSea/BelchingCoral.cs @@ -13,7 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SulphurousSea { - public class BelchingCoral : ModNPC + public class BelchingCoral : ModNPC { public const float CheckDistance = 480f; public override void SetStaticDefaults() @@ -36,11 +36,11 @@ namespace CalamityMod.NPCs.SulphurousSea npc.knockBackResist = 0f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { npc.velocity.Y += 0.25f; @@ -71,12 +71,12 @@ namespace CalamityMod.NPCs.SulphurousSea DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 180); + } - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { diff --git a/NPCs/SulphurousSea/Catfish.cs b/NPCs/SulphurousSea/Catfish.cs index e9ff882381..4e747904d0 100644 --- a/NPCs/SulphurousSea/Catfish.cs +++ b/NPCs/SulphurousSea/Catfish.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SulphurousSea { - public class Catfish : ModNPC + public class Catfish : ModNPC { public override void SetStaticDefaults() { @@ -32,11 +32,11 @@ namespace CalamityMod.NPCs.SulphurousSea banner = npc.type; bannerItem = ModContent.ItemType(); npc.chaseable = false; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -77,8 +77,8 @@ namespace CalamityMod.NPCs.SulphurousSea public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(ModContent.BuffType(), 180); - } + player.AddBuff(ModContent.BuffType(), 180); + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { diff --git a/NPCs/SulphurousSea/Flounder.cs b/NPCs/SulphurousSea/Flounder.cs index 1851317cbd..eebd38c4a0 100644 --- a/NPCs/SulphurousSea/Flounder.cs +++ b/NPCs/SulphurousSea/Flounder.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SulphurousSea { - public class Flounder : ModNPC + public class Flounder : ModNPC { public override void SetStaticDefaults() { @@ -32,11 +32,11 @@ namespace CalamityMod.NPCs.SulphurousSea banner = npc.type; bannerItem = ModContent.ItemType(); npc.chaseable = false; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { @@ -79,14 +79,14 @@ namespace CalamityMod.NPCs.SulphurousSea if (npc.ai[2] == 1f) { npc.chaseable = true; - CalamityAI.PassiveSwimmingAI(npc, mod, 0, 0f, 0.1f, 0.1f, 2f, 1f, 0.1f); + CalamityAI.PassiveSwimmingAI(npc, mod, 0, 0f, 0.1f, 0.1f, 2f, 1f, 0.1f); } } public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(ModContent.BuffType(), 120); - } + player.AddBuff(ModContent.BuffType(), 120); + } public override void FindFrame(int frameHeight) { diff --git a/NPCs/SulphurousSea/Gnasher.cs b/NPCs/SulphurousSea/Gnasher.cs index 2c5200ce52..ef4938e027 100644 --- a/NPCs/SulphurousSea/Gnasher.cs +++ b/NPCs/SulphurousSea/Gnasher.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SulphurousSea { - public class Gnasher : ModNPC + public class Gnasher : ModNPC { public override void SetStaticDefaults() { @@ -17,12 +17,12 @@ namespace CalamityMod.NPCs.SulphurousSea public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.damage = 25; + npc.Calamity().canBreakPlayerDefense = true; + npc.damage = 25; npc.width = 50; npc.height = 36; npc.defense = 30; - npc.DR_NERD(0.15f); + npc.DR_NERD(0.15f); npc.lifeMax = 35; npc.knockBackResist = 0.25f; npc.aiStyle = 3; @@ -32,11 +32,11 @@ namespace CalamityMod.NPCs.SulphurousSea npc.DeathSound = SoundID.NPCDeath54; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { @@ -92,8 +92,8 @@ namespace CalamityMod.NPCs.SulphurousSea public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(ModContent.BuffType(), 120); - } + player.AddBuff(ModContent.BuffType(), 120); + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { diff --git a/NPCs/SulphurousSea/MicrobialCluster.cs b/NPCs/SulphurousSea/MicrobialCluster.cs index c7046b8da1..33240650ce 100644 --- a/NPCs/SulphurousSea/MicrobialCluster.cs +++ b/NPCs/SulphurousSea/MicrobialCluster.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SulphurousSea { - public class MicrobialCluster : ModNPC + public class MicrobialCluster : ModNPC { public const int ChargeRate = 120; public const int SlowdownTime = 45; diff --git a/NPCs/SulphurousSea/Trasher.cs b/NPCs/SulphurousSea/Trasher.cs index 392c1164a1..99db054101 100644 --- a/NPCs/SulphurousSea/Trasher.cs +++ b/NPCs/SulphurousSea/Trasher.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SulphurousSea { - public class Trasher : ModNPC + public class Trasher : ModNPC { private bool hasBeenHit = false; @@ -23,8 +23,8 @@ namespace CalamityMod.NPCs.SulphurousSea public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.noGravity = true; + npc.Calamity().canBreakPlayerDefense = true; + npc.noGravity = true; npc.damage = 50; npc.width = 150; npc.height = 40; @@ -38,11 +38,11 @@ namespace CalamityMod.NPCs.SulphurousSea npc.knockBackResist = 0f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = false; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = false; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -113,9 +113,9 @@ namespace CalamityMod.NPCs.SulphurousSea npc.TargetClosest(true); npc.velocity.X = npc.velocity.X + (float)npc.direction * (CalamityWorld.death ? 0.6f : 0.3f); npc.velocity.Y = npc.velocity.Y + (float)npc.directionY * (CalamityWorld.death ? 0.2f : 0.1f); - float velocityX = CalamityWorld.death ? 20f : 10f; - float velocityY = CalamityWorld.death ? 10f : 5f; - if (npc.velocity.X > velocityX) + float velocityX = CalamityWorld.death ? 20f : 10f; + float velocityY = CalamityWorld.death ? 10f : 5f; + if (npc.velocity.X > velocityX) { npc.velocity.X = velocityX; } @@ -281,7 +281,7 @@ namespace CalamityMod.NPCs.SulphurousSea } } npc.rotation = npc.velocity.Y * (float)npc.direction * 0.05f; - npc.rotation = MathHelper.Clamp(npc.rotation, -0.1f, 0.1f); + npc.rotation = MathHelper.Clamp(npc.rotation, -0.1f, 0.1f); } public override void FindFrame(int frameHeight) @@ -316,8 +316,8 @@ namespace CalamityMod.NPCs.SulphurousSea public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(ModContent.BuffType(), 180); - } + player.AddBuff(ModContent.BuffType(), 180); + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { diff --git a/NPCs/SunkenSea/BlindedAngler.cs b/NPCs/SunkenSea/BlindedAngler.cs index 2615bce212..aba06d53a4 100644 --- a/NPCs/SunkenSea/BlindedAngler.cs +++ b/NPCs/SunkenSea/BlindedAngler.cs @@ -9,7 +9,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.SunkenSea { - public class BlindedAngler : ModNPC + public class BlindedAngler : ModNPC { public override void SetStaticDefaults() { @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.SunkenSea npc.width = 56; npc.height = 44; npc.defense = 30; - npc.DR_NERD(0.2f); + npc.DR_NERD(0.2f); npc.lifeMax = 750; npc.aiStyle = -1; aiType = -1; @@ -34,12 +34,12 @@ namespace CalamityMod.NPCs.SunkenSea npc.knockBackResist = 0.1f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.chaseable = false; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.chaseable = false; + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -54,7 +54,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void AI() { Lighting.AddLight(npc.Center, (255 - npc.alpha) * 0f / 255f, (255 - npc.alpha) * 0.75f / 255f, (255 - npc.alpha) * 0.75f / 255f); - CalamityAI.PassiveSwimmingAI(npc, mod, 1, 100f, 0.1f, 0.1f, 3f, 3f, 0.1f); + CalamityAI.PassiveSwimmingAI(npc, mod, 1, 100f, 0.1f, 0.1f, 3f, 3f, 0.1f); } public override void FindFrame(int frameHeight) @@ -102,8 +102,8 @@ namespace CalamityMod.NPCs.SunkenSea public override void NPCLoot() { - DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.25f); - DropHelper.DropItem(npc, ModContent.ItemType(), 5, 9); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.25f); + DropHelper.DropItem(npc, ModContent.ItemType(), 5, 9); } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/SunkenSea/Clam.cs b/NPCs/SunkenSea/Clam.cs index c1c909361c..9af6fcab88 100644 --- a/NPCs/SunkenSea/Clam.cs +++ b/NPCs/SunkenSea/Clam.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.SunkenSea npc.width = 56; npc.height = 38; npc.defense = 9999; - npc.DR_NERD(0.25f); + npc.DR_NERD(0.25f); npc.lifeMax = Main.hardMode ? 300 : 150; if (Main.expertMode) { @@ -38,11 +38,11 @@ namespace CalamityMod.NPCs.SunkenSea npc.knockBackResist = 0.05f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -78,7 +78,7 @@ namespace CalamityMod.NPCs.SunkenSea { if (!statChange) { - npc.buffImmune[BuffID.Confused] = false; + npc.buffImmune[BuffID.Confused] = false; npc.defense = 6; npc.damage = Main.expertMode ? 60 : 30; if (Main.hardMode) @@ -223,8 +223,8 @@ namespace CalamityMod.NPCs.SunkenSea } public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 8, 12); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode, 0.5f); + DropHelper.DropItem(npc, ModContent.ItemType(), 8, 12); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode, 0.5f); } } } diff --git a/NPCs/SunkenSea/EutrophicRay.cs b/NPCs/SunkenSea/EutrophicRay.cs index d8f4af0e84..b3c6293344 100644 --- a/NPCs/SunkenSea/EutrophicRay.cs +++ b/NPCs/SunkenSea/EutrophicRay.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.SunkenSea npc.width = 116; npc.height = 36; npc.defense = Main.hardMode ? 15 : 5; - npc.DR_NERD(0.05f); + npc.DR_NERD(0.05f); npc.lifeMax = Main.hardMode ? 500 : 150; npc.aiStyle = -1; aiType = -1; @@ -35,11 +35,11 @@ namespace CalamityMod.NPCs.SunkenSea npc.knockBackResist = 0f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/NPCs/SunkenSea/GhostBell.cs b/NPCs/SunkenSea/GhostBell.cs index 1f8ddee7c8..fb515ad0a4 100644 --- a/NPCs/SunkenSea/GhostBell.cs +++ b/NPCs/SunkenSea/GhostBell.cs @@ -37,11 +37,11 @@ namespace CalamityMod.NPCs.SunkenSea npc.DeathSound = SoundID.NPCDeath28; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = false; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = false; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -159,7 +159,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void NPCLoot() { DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedDesertScourge, 0.2f); - DropHelper.DropItemChance(npc, ItemID.JellyfishNecklace, 0.01f); + DropHelper.DropItemChance(npc, ItemID.JellyfishNecklace, 0.01f); } } } diff --git a/NPCs/SunkenSea/GhostBellSmall.cs b/NPCs/SunkenSea/GhostBellSmall.cs index 45bc1f1ada..1248dcf7cd 100644 --- a/NPCs/SunkenSea/GhostBellSmall.cs +++ b/NPCs/SunkenSea/GhostBellSmall.cs @@ -57,25 +57,25 @@ namespace CalamityMod.NPCs.SunkenSea { if (npc.localAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.rand.NextBool(20)) - npc.catchItem = (short)ModContent.ItemType(); + if (Main.rand.NextBool(20)) + npc.catchItem = (short)ModContent.ItemType(); npc.localAI[0] = 1f; npc.velocity.Y = -3f; npc.netUpdate = true; } if (Main.rand.Next(8) < 1 && npc.catchItem == (short)ModContent.ItemType()) - { - int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, 68, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 200, default, 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.1f; - Main.dust[dust].velocity.Y += 0.25f; - Main.dust[dust].noLight = true; - if (Main.rand.NextBool(2)) - { - Main.dust[dust].noGravity = false; - Main.dust[dust].scale *= 0.5f; - } - } + { + int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, 68, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 200, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.1f; + Main.dust[dust].velocity.Y += 0.25f; + Main.dust[dust].noLight = true; + if (Main.rand.NextBool(2)) + { + Main.dust[dust].noGravity = false; + Main.dust[dust].scale *= 0.5f; + } + } Lighting.AddLight(npc.Center, 0f, (255 - npc.alpha) * 1f / 255f, (255 - npc.alpha) * 1f / 255f); if (npc.wet) { diff --git a/NPCs/SunkenSea/GiantClam.cs b/NPCs/SunkenSea/GiantClam.cs index 39a29638f3..ede86e92d8 100644 --- a/NPCs/SunkenSea/GiantClam.cs +++ b/NPCs/SunkenSea/GiantClam.cs @@ -37,14 +37,14 @@ namespace CalamityMod.NPCs.SunkenSea public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.lavaImmune = true; + npc.Calamity().canBreakPlayerDefense = true; + npc.lavaImmune = true; npc.npcSlots = 5f; npc.damage = 50; npc.width = 160; npc.height = 120; npc.defense = 9999; - npc.DR_NERD(0.3f); + npc.DR_NERD(0.3f); npc.lifeMax = Main.hardMode ? 7500 : 1250; npc.aiStyle = -1; aiType = -1; @@ -54,11 +54,11 @@ namespace CalamityMod.NPCs.SunkenSea npc.rarity = 2; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -406,7 +406,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void NPCLoot() { // Spawn Amidias if he isn't in the world - //This doesn't check for Desert Scourge because Giant Clam only spawns post-Desert Scourge + //This doesn't check for Desert Scourge because Giant Clam only spawns post-Desert Scourge int amidiasNPC = NPC.FindFirstNPC(ModContent.NPCType()); if (amidiasNPC == -1 && Main.netMode != NetmodeID.MultiplayerClient) { @@ -418,8 +418,8 @@ namespace CalamityMod.NPCs.SunkenSea DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.hardMode, 6, 11); // Weapons - if (Main.hardMode) - { + if (Main.hardMode) + { float w = DropHelper.NormalWeaponDropRateFloat; DropHelper.DropEntireWeightedSet(npc, DropHelper.WeightStack(w), @@ -427,7 +427,7 @@ namespace CalamityMod.NPCs.SunkenSea DropHelper.WeightStack(w), DropHelper.WeightStack(w) ); - } + } // Equipment DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedDesertScourge, 3, 1, 1); diff --git a/NPCs/SunkenSea/PrismTurtle.cs b/NPCs/SunkenSea/PrismTurtle.cs index 441451f171..cdf1d3761c 100644 --- a/NPCs/SunkenSea/PrismTurtle.cs +++ b/NPCs/SunkenSea/PrismTurtle.cs @@ -9,7 +9,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.SunkenSea { - public class PrismTurtle : ModNPC + public class PrismTurtle : ModNPC { public override void SetStaticDefaults() { @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.SunkenSea npc.width = 72; npc.height = 58; npc.defense = Main.hardMode ? 25 : 10; - npc.DR_NERD(0.25f); + npc.DR_NERD(0.25f); npc.lifeMax = Main.hardMode ? 1000 : 350; npc.aiStyle = -1; aiType = -1; @@ -34,12 +34,12 @@ namespace CalamityMod.NPCs.SunkenSea npc.knockBackResist = 0.15f; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.chaseable = false; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.chaseable = false; + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void SendExtraAI(BinaryWriter writer) { @@ -92,7 +92,7 @@ namespace CalamityMod.NPCs.SunkenSea } } Lighting.AddLight(npc.Center, (255 - npc.alpha) * 0f / 255f, (255 - npc.alpha) * 0.75f / 255f, (255 - npc.alpha) * 0.75f / 255f); - CalamityAI.PassiveSwimmingAI(npc, mod, 2, 0f, 0f, 0f, 0f, 0f, 0.1f); + CalamityAI.PassiveSwimmingAI(npc, mod, 2, 0f, 0f, 0f, 0f, 0f, 0.1f); } public override void FindFrame(int frameHeight) @@ -140,7 +140,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedDesertScourge, 1, 1, 3); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedDesertScourge, 1, 1, 3); } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/SunkenSea/SeaMinnow.cs b/NPCs/SunkenSea/SeaMinnow.cs index 0c9f8ceac4..13aa25aeac 100644 --- a/NPCs/SunkenSea/SeaMinnow.cs +++ b/NPCs/SunkenSea/SeaMinnow.cs @@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void AI() { - CalamityAI.PassiveSwimmingAI(npc, mod, 3, 150f, 0.25f, 0.15f, 6f, 6f, 0.05f); + CalamityAI.PassiveSwimmingAI(npc, mod, 3, 150f, 0.25f, 0.15f, 6f, 6f, 0.05f); npc.spriteDirection = (npc.direction > 0) ? 1 : -1; npc.noGravity = true; bool flag14 = false; diff --git a/NPCs/SunkenSea/SeaSerpent1.cs b/NPCs/SunkenSea/SeaSerpent1.cs index ebf763505a..73dab45d26 100644 --- a/NPCs/SunkenSea/SeaSerpent1.cs +++ b/NPCs/SunkenSea/SeaSerpent1.cs @@ -38,11 +38,11 @@ namespace CalamityMod.NPCs.SunkenSea npc.netAlways = true; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override void AI() { @@ -115,26 +115,26 @@ namespace CalamityMod.NPCs.SunkenSea Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - if (npc.life > npc.lifeMax * 0.99) - { - num192 += 300; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 250f) - { - if (npc.velocity.X > 0f) - { - num191 = Main.player[npc.target].Center.X + 300f; - } - else - { - num191 = Main.player[npc.target].Center.X - 300f; - } - } - } - else - { - num188 *= 1.5f; - num189 *= 1.5f; - } + if (npc.life > npc.lifeMax * 0.99) + { + num192 += 300; + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 250f) + { + if (npc.velocity.X > 0f) + { + num191 = Main.player[npc.target].Center.X + 300f; + } + else + { + num191 = Main.player[npc.target].Center.X - 300f; + } + } + } + else + { + num188 *= 1.5f; + num189 *= 1.5f; + } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; float num50 = npc.velocity.Length(); @@ -272,7 +272,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void NPCLoot() { - DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.25f); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 0.25f); } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/SunkenSea/SeaSerpent2.cs b/NPCs/SunkenSea/SeaSerpent2.cs index e624eb6277..7babac0900 100644 --- a/NPCs/SunkenSea/SeaSerpent2.cs +++ b/NPCs/SunkenSea/SeaSerpent2.cs @@ -36,11 +36,11 @@ namespace CalamityMod.NPCs.SunkenSea npc.chaseable = false; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -54,32 +54,32 @@ namespace CalamityMod.NPCs.SunkenSea if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/SunkenSea/SeaSerpent3.cs b/NPCs/SunkenSea/SeaSerpent3.cs index 1915444a38..7b037fb5ca 100644 --- a/NPCs/SunkenSea/SeaSerpent3.cs +++ b/NPCs/SunkenSea/SeaSerpent3.cs @@ -33,11 +33,11 @@ namespace CalamityMod.NPCs.SunkenSea npc.chaseable = false; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -51,32 +51,32 @@ namespace CalamityMod.NPCs.SunkenSea if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/SunkenSea/SeaSerpent4.cs b/NPCs/SunkenSea/SeaSerpent4.cs index 9ef9d1d84e..298649eb47 100644 --- a/NPCs/SunkenSea/SeaSerpent4.cs +++ b/NPCs/SunkenSea/SeaSerpent4.cs @@ -33,11 +33,11 @@ namespace CalamityMod.NPCs.SunkenSea npc.chaseable = false; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -51,32 +51,32 @@ namespace CalamityMod.NPCs.SunkenSea if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/SunkenSea/SeaSerpent5.cs b/NPCs/SunkenSea/SeaSerpent5.cs index bdad3ae963..53637965f5 100644 --- a/NPCs/SunkenSea/SeaSerpent5.cs +++ b/NPCs/SunkenSea/SeaSerpent5.cs @@ -33,11 +33,11 @@ namespace CalamityMod.NPCs.SunkenSea npc.chaseable = false; banner = ModContent.NPCType(); bannerItem = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToSickness = true; - npc.Calamity().VulnerableToElectricity = true; - npc.Calamity().VulnerableToWater = false; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToSickness = true; + npc.Calamity().VulnerableToElectricity = true; + npc.Calamity().VulnerableToWater = false; + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -51,32 +51,32 @@ namespace CalamityMod.NPCs.SunkenSea if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + { + shouldDespawn = false; + break; + } + } + if (!shouldDespawn) + { + if (npc.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + } - if (Main.npc[(int)npc.ai[1]].alpha < 128) + if (Main.npc[(int)npc.ai[1]].alpha < 128) { npc.alpha -= 42; if (npc.alpha < 0) diff --git a/NPCs/SupremeCalamitas/BrimstoneHeart.cs b/NPCs/SupremeCalamitas/BrimstoneHeart.cs index 2e7528d3b3..89b3e4ee9a 100644 --- a/NPCs/SupremeCalamitas/BrimstoneHeart.cs +++ b/NPCs/SupremeCalamitas/BrimstoneHeart.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SupremeCalamitas { - public class BrimstoneHeart : ModNPC + public class BrimstoneHeart : ModNPC { public PrimitiveTrail ChainDrawer = null; public int ChainHeartIndex => (int)npc.ai[0]; @@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.width = 24; npc.height = 24; npc.defense = 0; - npc.LifeMaxNERB(24550, 29440, 10000); + npc.LifeMaxNERB(24550, 29440, 10000); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; @@ -39,9 +39,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.hide = true; npc.HitSound = SoundID.NPCHit13; npc.DeathSound = SoundID.NPCDeath1; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -72,17 +72,17 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.alpha = 0; } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } - public float PrimitiveWidthFunction(float completionRatio) + public float PrimitiveWidthFunction(float completionRatio) { float widthInterpolant = Utils.InverseLerp(0f, 0.16f, completionRatio, true) * Utils.InverseLerp(1f, 0.84f, completionRatio, true); widthInterpolant = (float)Math.Pow(widthInterpolant, 8D); @@ -158,6 +158,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas damage = (int)(damage * 0.66); } - public override bool CheckActive() => false; - } + public override bool CheckActive() => false; + } } diff --git a/NPCs/SupremeCalamitas/SCalWormArm.cs b/NPCs/SupremeCalamitas/SCalWormArm.cs index 9b0de91f8e..7f295d7f67 100644 --- a/NPCs/SupremeCalamitas/SCalWormArm.cs +++ b/NPCs/SupremeCalamitas/SCalWormArm.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SupremeCalamitas { - public class SCalWormArm : ModNPC + public class SCalWormArm : ModNPC { public class SepulcherArmLimb { @@ -72,8 +72,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.999999f; global.unbreakableDR = true; - npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; - npc.aiStyle = aiType = -1; + npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; + npc.aiStyle = aiType = -1; npc.knockBackResist = 0f; npc.scale = Main.expertMode ? 1.35f : 1.2f; npc.dontTakeDamage = true; @@ -170,7 +170,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { + { Texture2D armTexture = Main.npcTexture[npc.type]; Texture2D foreArmTexture = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormForeArm"); Texture2D handTexture = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormHand"); @@ -188,7 +188,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas spriteBatch.Draw(handTexture, handDrawPosition, null, drawColor, Limbs[1].Rotation - MathHelper.PiOver2, handTexture.Size() * new Vector2(0.5f, 0f), npc.scale, handDirection, 0f); return false; - } + } public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/SupremeCalamitas/SCalWormBody.cs b/NPCs/SupremeCalamitas/SCalWormBody.cs index 823e3798a5..47602cd0bc 100644 --- a/NPCs/SupremeCalamitas/SCalWormBody.cs +++ b/NPCs/SupremeCalamitas/SCalWormBody.cs @@ -7,9 +7,9 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SupremeCalamitas { - public class SCalWormBody : ModNPC + public class SCalWormBody : ModNPC { - private bool setAlpha = false; + private bool setAlpha = false; public NPC AheadSegment => Main.npc[(int)npc.ai[1]]; public NPC HeadSegment => Main.npc[(int)npc.ai[2]]; @@ -27,8 +27,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.999999f; global.unbreakableDR = true; - npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; - npc.aiStyle = -1; //new + npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; + npc.aiStyle = -1; //new aiType = -1; //new npc.knockBackResist = 0f; npc.scale = 1.2f; @@ -49,14 +49,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void SendExtraAI(BinaryWriter writer) { writer.Write(npc.localAI[3]); - writer.Write(setAlpha); - } + writer.Write(setAlpha); + } public override void ReceiveExtraAI(BinaryReader reader) { npc.localAI[3] = reader.ReadSingle(); - setAlpha = reader.ReadBoolean(); - } + setAlpha = reader.ReadBoolean(); + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -65,10 +65,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void AI() { - if (npc.ai[2] > 0f) - { - npc.realLife = (int)npc.ai[2]; - } + if (npc.ai[2] > 0f) + { + npc.realLife = (int)npc.ai[2]; + } bool shouldDie = false; if (npc.ai[1] <= 0f) @@ -116,35 +116,35 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x)) - { - if (projectile.penetrate == -1 && !projectile.minion) - { - projectile.penetrate = 1; - } - else if (projectile.penetrate >= 1) - { - projectile.penetrate = 1; - } - } + if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x)) + { + if (projectile.penetrate == -1 && !projectile.minion) + { + projectile.penetrate = 1; + } + else if (projectile.penetrate >= 1) + { + projectile.penetrate = 1; + } + } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = npc.localAI[3] / 2f % 2f == 0f ? ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormBodyAlt") : Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + Texture2D texture2D15 = npc.localAI[3] / 2f % 2f == 0f ? ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormBodyAlt") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } public override bool CheckActive() { diff --git a/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs b/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs index a1bada9b73..11316d7359 100644 --- a/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs +++ b/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs @@ -12,15 +12,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas { public class SCalWormBodyWeak : ModNPC { - private bool setAlpha = false; - public NPC AheadSegment => Main.npc[(int)npc.ai[1]]; - public NPC HeadSegment => Main.npc[(int)npc.ai[2]]; - public ref float AttackTimer => ref npc.localAI[0]; + private bool setAlpha = false; + public NPC AheadSegment => Main.npc[(int)npc.ai[1]]; + public NPC HeadSegment => Main.npc[(int)npc.ai[2]]; + public ref float AttackTimer => ref npc.localAI[0]; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Brimstone Heart"); - Main.npcFrameCount[npc.type] = 5; + Main.npcFrameCount[npc.type] = 5; } public override void SetDefaults() @@ -43,128 +43,128 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.netAlways = true; npc.dontCountMe = true; - CalamityGlobalNPC global = npc.Calamity(); - global.DR = 0.999999f; - global.unbreakableDR = true; - } + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0.999999f; + global.unbreakableDR = true; + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(AttackTimer); - writer.Write(setAlpha); - } + writer.Write(setAlpha); + } public override void ReceiveExtraAI(BinaryReader reader) { - AttackTimer = reader.ReadSingle(); - setAlpha = reader.ReadBoolean(); - } + AttackTimer = reader.ReadSingle(); + setAlpha = reader.ReadBoolean(); + } public override void AI() { - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - bool shouldDie = false; - if (npc.ai[1] <= 0f) - shouldDie = true; - else if (AheadSegment.life <= 0 || !AheadSegment.active || npc.life <= 0) - shouldDie = true; + bool shouldDie = false; + if (npc.ai[1] <= 0f) + shouldDie = true; + else if (AheadSegment.life <= 0 || !AheadSegment.active || npc.life <= 0) + shouldDie = true; - if (shouldDie) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - } + if (shouldDie) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + } - if (AheadSegment.alpha < 128 && !setAlpha) - { - if (npc.alpha != 0) - { - for (int i = 0; i < 2; i++) - { - Dust fire = Dust.NewDustDirect(npc.position, npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - fire.noGravity = true; - fire.noLight = true; - } - } - npc.alpha -= 42; - if (npc.alpha <= 0) - { - setAlpha = true; - npc.alpha = 0; - } - } - else - npc.alpha = HeadSegment.alpha; + if (AheadSegment.alpha < 128 && !setAlpha) + { + if (npc.alpha != 0) + { + for (int i = 0; i < 2; i++) + { + Dust fire = Dust.NewDustDirect(npc.position, npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); + fire.noGravity = true; + fire.noLight = true; + } + } + npc.alpha -= 42; + if (npc.alpha <= 0) + { + setAlpha = true; + npc.alpha = 0; + } + } + else + npc.alpha = HeadSegment.alpha; - AttackTimer += (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.5f : 1f; - if (AttackTimer >= 900f) - { - AttackTimer = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; - Vector2 spinningPoint = Vector2.Normalize(new Vector2(-1f, -1f)); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, velocity, type, damage, 0f, Main.myPlayer); - } - npc.netUpdate = true; - } - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), npc.Center); - } + AttackTimer += (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.5f : 1f; + if (AttackTimer >= 900f) + { + AttackTimer = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + int totalProjectiles = 4; + float radians = MathHelper.TwoPi / totalProjectiles; + Vector2 spinningPoint = Vector2.Normalize(new Vector2(-1f, -1f)); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, velocity, type, damage, 0f, Main.myPlayer); + } + npc.netUpdate = true; + } + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), npc.Center); + } - if (Main.npc.IndexInRange((int)npc.ai[1])) - { - Vector2 offsetToAheadSegment = AheadSegment.Center - npc.Center; - npc.rotation = offsetToAheadSegment.ToRotation() + MathHelper.PiOver2; - npc.velocity = Vector2.Zero; - npc.Center = AheadSegment.Center - offsetToAheadSegment.SafeNormalize(Vector2.UnitY) * 34f; - npc.spriteDirection = (offsetToAheadSegment.X > 0f).ToDirectionInt(); - } + if (Main.npc.IndexInRange((int)npc.ai[1])) + { + Vector2 offsetToAheadSegment = AheadSegment.Center - npc.Center; + npc.rotation = offsetToAheadSegment.ToRotation() + MathHelper.PiOver2; + npc.velocity = Vector2.Zero; + npc.Center = AheadSegment.Center - offsetToAheadSegment.SafeNormalize(Vector2.UnitY) * 34f; + npc.spriteDirection = (offsetToAheadSegment.X > 0f).ToDirectionInt(); + } } public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x)) - { - if (projectile.penetrate == -1 && !projectile.minion) - { - projectile.penetrate = 1; - } - else if (projectile.penetrate >= 1) - { - projectile.penetrate = 1; - } - } + if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x)) + { + if (projectile.penetrate == -1 && !projectile.minion) + { + projectile.penetrate = 1; + } + else if (projectile.penetrate >= 1) + { + projectile.penetrate = 1; + } + } } public override void FindFrame(int frameHeight) { - npc.frameCounter++; - npc.frame.Y = ((int)(npc.frameCounter / 5) + npc.whoAmI) % Main.npcFrameCount[npc.type] * frameHeight; + npc.frameCounter++; + npc.frame.Y = ((int)(npc.frameCounter / 5) + npc.whoAmI) % Main.npcFrameCount[npc.type] * frameHeight; } public override void HitEffect(int hitDirection, double damage) - { - if (Main.netMode != NetmodeID.MultiplayerClient && npc.life <= 0) - { - for (int i = 0; i < Main.rand.Next(1, 3 + 1); i++) + { + if (Main.netMode != NetmodeID.MultiplayerClient && npc.life <= 0) + { + for (int i = 0; i < Main.rand.Next(1, 3 + 1); i++) { - if (!Main.rand.NextBool(3)) - continue; + if (!Main.rand.NextBool(3)) + continue; - Vector2 soulVelocity = -Vector2.UnitY.RotatedByRandom(0.53f) * Main.rand.NextFloat(2.5f, 4f); - Projectile.NewProjectile(npc.Center, soulVelocity, ModContent.ProjectileType(), 0, 0f); - } - } - } + Vector2 soulVelocity = -Vector2.UnitY.RotatedByRandom(0.53f) * Main.rand.NextFloat(2.5f, 4f); + Projectile.NewProjectile(npc.Center, soulVelocity, ModContent.ProjectileType(), 0, 0f); + } + } + } public override bool CheckActive() { diff --git a/NPCs/SupremeCalamitas/SCalWormHead.cs b/NPCs/SupremeCalamitas/SCalWormHead.cs index f7dbf9de88..8edf90966e 100644 --- a/NPCs/SupremeCalamitas/SCalWormHead.cs +++ b/NPCs/SupremeCalamitas/SCalWormHead.cs @@ -32,33 +32,33 @@ namespace CalamityMod.NPCs.SupremeCalamitas CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.999999f; global.unbreakableDR = true; - npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; - npc.aiStyle = -1; //new + npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; + npc.aiStyle = -1; //new aiType = -1; //new npc.knockBackResist = 0f; npc.scale = Main.expertMode ? 1.35f : 1.2f; - npc.scale *= 1.25f; + npc.scale *= 1.25f; - npc.alpha = 255; + npc.alpha = 255; npc.chaseable = false; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.netAlways = true; + npc.netAlways = true; } public override void SendExtraAI(BinaryWriter writer) { writer.Write(npc.localAI[0]); - writer.Write(npc.alpha); - } + writer.Write(npc.alpha); + } public override void ReceiveExtraAI(BinaryReader reader) { npc.localAI[0] = reader.ReadSingle(); - npc.alpha = reader.ReadInt32(); - } + npc.alpha = reader.ReadInt32(); + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -69,22 +69,22 @@ namespace CalamityMod.NPCs.SupremeCalamitas { CalamityGlobalNPC.SCalWorm = npc.whoAmI; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && npc.ai[0] == 0f) { - float rotationalOffset = 0f; + float rotationalOffset = 0f; int Previous = npc.whoAmI; for (int i = 0; i < maxLength; i++) { @@ -98,36 +98,36 @@ namespace CalamityMod.NPCs.SupremeCalamitas else if (i >= 0 && i < minLength) { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - Main.npc[lol].localAI[3] = i; - } + Main.npc[lol].localAI[3] = i; + } else lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - - // Create arms. - if (i >= 3 && i % 4 == 0) + + // Create arms. + if (i >= 3 && i % 4 == 0) { - NPC segment = Main.npc[lol]; - int arm = NPC.NewNPC((int)segment.Center.X, (int)segment.Center.Y, ModContent.NPCType(), lol); - if (Main.npc.IndexInRange(arm)) - { - Main.npc[arm].ai[0] = lol; - Main.npc[arm].direction = 1; - Main.npc[arm].rotation = rotationalOffset; - } + NPC segment = Main.npc[lol]; + int arm = NPC.NewNPC((int)segment.Center.X, (int)segment.Center.Y, ModContent.NPCType(), lol); + if (Main.npc.IndexInRange(arm)) + { + Main.npc[arm].ai[0] = lol; + Main.npc[arm].direction = 1; + Main.npc[arm].rotation = rotationalOffset; + } - rotationalOffset += MathHelper.Pi / 6f; + rotationalOffset += MathHelper.Pi / 6f; - arm = NPC.NewNPC((int)segment.Center.X, (int)segment.Center.Y, ModContent.NPCType(), lol); - if (Main.npc.IndexInRange(arm)) - { - Main.npc[arm].ai[0] = lol; - Main.npc[arm].direction = -1; - Main.npc[arm].rotation = rotationalOffset + MathHelper.Pi; - } + arm = NPC.NewNPC((int)segment.Center.X, (int)segment.Center.Y, ModContent.NPCType(), lol); + if (Main.npc.IndexInRange(arm)) + { + Main.npc[arm].ai[0] = lol; + Main.npc[arm].direction = -1; + Main.npc[arm].rotation = rotationalOffset + MathHelper.Pi; + } - rotationalOffset += MathHelper.Pi / 6f; - rotationalOffset = MathHelper.WrapAngle(rotationalOffset); - } + rotationalOffset += MathHelper.Pi / 6f; + rotationalOffset = MathHelper.WrapAngle(rotationalOffset); + } Main.npc[lol].realLife = npc.whoAmI; Main.npc[lol].ai[2] = npc.whoAmI; @@ -143,180 +143,180 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - if (Main.player[npc.target].dead || !NPC.AnyNPCs(ModContent.NPCType()) || CalamityGlobalNPC.SCal < 0 || !Main.npc[CalamityGlobalNPC.SCal].active) - { - npc.TargetClosest(false); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/SepulcherDeath"), Main.player[npc.target].Center); - npc.life = 0; - npc.HitEffect(); - npc.active = false; - npc.netUpdate = true; - } - else - npc.Opacity = MathHelper.Clamp(npc.Opacity + 0.165f, 0f, 1f); + if (Main.player[npc.target].dead || !NPC.AnyNPCs(ModContent.NPCType()) || CalamityGlobalNPC.SCal < 0 || !Main.npc[CalamityGlobalNPC.SCal].active) + { + npc.TargetClosest(false); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/SepulcherDeath"), Main.player[npc.target].Center); + npc.life = 0; + npc.HitEffect(); + npc.active = false; + npc.netUpdate = true; + } + else + npc.Opacity = MathHelper.Clamp(npc.Opacity + 0.165f, 0f, 1f); - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - float num188 = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 12.5f : 10f; - float num189 = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 0.125f : 0.1f; + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + float num188 = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 12.5f : 10f; + float num189 = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 0.125f : 0.1f; - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = npc.velocity.Length(); - if (num50 > 0f) - { - if (num50 > num48) - { - npc.velocity.Normalize(); - npc.velocity *= num48; - } - else if (num50 < num49) - { - npc.velocity.Normalize(); - npc.velocity *= num49; - } - } + float num48 = num188 * 1.3f; + float num49 = num188 * 0.7f; + float num50 = npc.velocity.Length(); + if (num50 > 0f) + { + if (num50 > num48) + { + npc.velocity.Normalize(); + npc.velocity *= num48; + } + else if (num50 < num49) + { + npc.velocity.Normalize(); + npc.velocity *= num49; + } + } - 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)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189; - } - else - { - if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num189; - } - } - if (npc.velocity.Y < num192) - { - npc.velocity.Y = npc.velocity.Y + num189; - } - else - { - if (npc.velocity.Y > num192) - { - npc.velocity.Y = npc.velocity.Y - num189; - } - } - 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 = npc.velocity.Y + num189 * 2f; - } - else - { - npc.velocity.Y = npc.velocity.Y - num189 * 2f; - } - } - 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 = npc.velocity.X + num189 * 2f; //changed from 2 - } - else - { - npc.velocity.X = npc.velocity.X - num189 * 2f; //changed from 2 - } - } - } - else - { - if (num196 > num197) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189 * 1.1f; //changed from 1.1 - } - else if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num189 * 1.1f; //changed from 1.1 - } - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num189; - } - else - { - npc.velocity.Y = npc.velocity.Y - num189; - } - } - } - else - { - if (npc.velocity.Y < num192) - { - npc.velocity.Y = npc.velocity.Y + num189 * 1.1f; - } - else if (npc.velocity.Y > num192) - { - npc.velocity.Y = npc.velocity.Y - num189 * 1.1f; - } - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num189; - } - else - { - npc.velocity.X = npc.velocity.X - num189; - } - } - } - } - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - } + 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)Math.Sqrt(num191 * num191 + num192 * num192); + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); + float num198 = num188 / num193; + num191 *= num198; + num192 *= num198; + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + { + npc.velocity.X = npc.velocity.X + num189; + } + else + { + if (npc.velocity.X > num191) + { + npc.velocity.X = npc.velocity.X - num189; + } + } + if (npc.velocity.Y < num192) + { + npc.velocity.Y = npc.velocity.Y + num189; + } + else + { + if (npc.velocity.Y > num192) + { + npc.velocity.Y = npc.velocity.Y - num189; + } + } + 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 = npc.velocity.Y + num189 * 2f; + } + else + { + npc.velocity.Y = npc.velocity.Y - num189 * 2f; + } + } + 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 = npc.velocity.X + num189 * 2f; //changed from 2 + } + else + { + npc.velocity.X = npc.velocity.X - num189 * 2f; //changed from 2 + } + } + } + else + { + if (num196 > num197) + { + if (npc.velocity.X < num191) + { + npc.velocity.X = npc.velocity.X + num189 * 1.1f; //changed from 1.1 + } + else if (npc.velocity.X > num191) + { + npc.velocity.X = npc.velocity.X - num189 * 1.1f; //changed from 1.1 + } + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y + num189; + } + else + { + npc.velocity.Y = npc.velocity.Y - num189; + } + } + } + else + { + if (npc.velocity.Y < num192) + { + npc.velocity.Y = npc.velocity.Y + num189 * 1.1f; + } + else if (npc.velocity.Y > num192) + { + npc.velocity.Y = npc.velocity.Y - num189 * 1.1f; + } + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) + { + if (npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X + num189; + } + else + { + npc.velocity.X = npc.velocity.X - num189; + } + } + } + } + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x)) - { - if (projectile.penetrate == -1 && !projectile.minion) - { - projectile.penetrate = 1; - } - else if (projectile.penetrate >= 1) - { - projectile.penetrate = 1; - } - } + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; + } + + public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x)) + { + if (projectile.penetrate == -1 && !projectile.minion) + { + projectile.penetrate = 1; + } + else if (projectile.penetrate >= 1) + { + projectile.penetrate = 1; + } + } } public override bool CheckActive() @@ -326,20 +326,20 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void HitEffect(int hitDirection, double damage) { - if (npc.life <= 0) - { - for (int i = 1; i <= 3; i++) + if (npc.life <= 0) + { + for (int i = 1; i <= 3; i++) { - Vector2 goreSpawnPosition = npc.Center; + Vector2 goreSpawnPosition = npc.Center; - // Spawn at a slight offset when spawning mandibles. - if (i == 2) - goreSpawnPosition += npc.velocity.SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver4) * 16f; - if (i == 3) - goreSpawnPosition += npc.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-MathHelper.PiOver4) * 16f; - Gore.NewGorePerfect(goreSpawnPosition, npc.velocity, mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherHead_Gore{i}"), npc.scale); + // Spawn at a slight offset when spawning mandibles. + if (i == 2) + goreSpawnPosition += npc.velocity.SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver4) * 16f; + if (i == 3) + goreSpawnPosition += npc.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-MathHelper.PiOver4) * 16f; + Gore.NewGorePerfect(goreSpawnPosition, npc.velocity, mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherHead_Gore{i}"), npc.scale); } - } + } } } } diff --git a/NPCs/SupremeCalamitas/SCalWormTail.cs b/NPCs/SupremeCalamitas/SCalWormTail.cs index 1ada86054d..d767d5a3e3 100644 --- a/NPCs/SupremeCalamitas/SCalWormTail.cs +++ b/NPCs/SupremeCalamitas/SCalWormTail.cs @@ -7,11 +7,11 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SupremeCalamitas { - public class SCalWormTail : ModNPC + public class SCalWormTail : ModNPC { - private bool setAlpha = false; + private bool setAlpha = false; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Sepulcher"); } @@ -26,8 +26,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.999999f; global.unbreakableDR = true; - npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; - npc.aiStyle = -1; //new + npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; + npc.aiStyle = -1; //new aiType = -1; //new npc.knockBackResist = 0f; npc.scale = 1.2f; @@ -45,152 +45,152 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.dontCountMe = true; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(setAlpha); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(setAlpha); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - setAlpha = reader.ReadBoolean(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + setAlpha = reader.ReadBoolean(); + } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; } public override void AI() { - if (npc.ai[2] > 0f) - { - npc.realLife = (int)npc.ai[2]; - } + if (npc.ai[2] > 0f) + { + npc.realLife = (int)npc.ai[2]; + } - bool flag = false; - if (npc.ai[1] <= 0f) - { - flag = true; - } - else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0) - { - flag = true; - } - if (flag) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - } + bool flag = false; + if (npc.ai[1] <= 0f) + { + flag = true; + } + else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0) + { + flag = true; + } + if (flag) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + } - if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - npc.alpha -= 42; - if (npc.alpha <= 0) - { - setAlpha = true; - npc.alpha = 0; - } - } - else - { - npc.alpha = Main.npc[(int)npc.ai[2]].alpha; - } + if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha) + { + if (npc.alpha != 0) + { + for (int num934 = 0; num934 < 2; num934++) + { + int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); + Main.dust[num935].noGravity = true; + Main.dust[num935].noLight = true; + } + } + npc.alpha -= 42; + if (npc.alpha <= 0) + { + setAlpha = true; + npc.alpha = 0; + } + } + else + { + npc.alpha = Main.npc[(int)npc.ai[2]].alpha; + } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].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(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - 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(num192, num191) + 1.57f; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - { - npc.spriteDirection = -1; - } - else if (num191 > 0f) - { - npc.spriteDirection = 1; - } - } - } + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].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(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + { + try + { + 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(num192, num191) + 1.57f; + num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + int num194 = npc.width; + num193 = (num193 - num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; + if (num191 < 0f) + { + npc.spriteDirection = -1; + } + else if (num191 > 0f) + { + npc.spriteDirection = 1; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x)) - { - if (projectile.penetrate == -1 && !projectile.minion) - { - projectile.penetrate = 1; - } - else if (projectile.penetrate >= 1) - { - projectile.penetrate = 1; - } - } + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; + } + + public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x)) + { + if (projectile.penetrate == -1 && !projectile.minion) + { + projectile.penetrate = 1; + } + else if (projectile.penetrate >= 1) + { + projectile.penetrate = 1; + } + } } public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) - { - for (int i = 1; i <= 2; i++) - { - Vector2 goreSpawnPosition = npc.Center; - if (i == 2) - goreSpawnPosition -= (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * 20f; - Gore.NewGorePerfect(goreSpawnPosition, Main.rand.NextVector2Circular(3f, 3f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherTail_Gore{i}"), npc.scale); - } - } + { + for (int i = 1; i <= 2; i++) + { + Vector2 goreSpawnPosition = npc.Center; + if (i == 2) + goreSpawnPosition -= (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * 20f; + Gore.NewGorePerfect(goreSpawnPosition, Main.rand.NextVector2Circular(3f, 3f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherTail_Gore{i}"), npc.scale); + } + } } public override bool CheckActive() diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs index bc07513e9e..6b72cae98b 100644 --- a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs +++ b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs @@ -11,7 +11,7 @@ using System.IO; namespace CalamityMod.NPCs.SupremeCalamitas { - public class SoulSeekerSupreme : ModNPC + public class SoulSeekerSupreme : ModNPC { private int timer = 0; private bool start = true; @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas DisplayName.SetDefault("Soul Seeker"); Main.npcFrameCount[npc.type] = 6; NPCID.Sets.TrailingMode[npc.type] = 1; - } + } public override void SetDefaults() { @@ -38,12 +38,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.canGhostHeal = false; npc.damage = 0; npc.defense = 60; - npc.DR_NERD(0.25f); - npc.LifeMaxNERB(Main.expertMode ? 24000 : 15000, 28000); + npc.DR_NERD(0.25f); + npc.LifeMaxNERB(Main.expertMode ? 24000 : 15000, 28000); npc.DeathSound = SoundID.DD2_SkeletonDeath; - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -82,36 +82,36 @@ namespace CalamityMod.NPCs.SupremeCalamitas start = false; } - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Target.dead || !Target.active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Target.dead || !Target.active) + npc.TargetClosest(); - // Target another player if the current player target is too far away - if (!npc.WithinRange(Target.Center, CalamityGlobalNPC.CatchUpDistance200Tiles)) - npc.TargetClosest(); + // Target another player if the current player target is too far away + if (!npc.WithinRange(Target.Center, CalamityGlobalNPC.CatchUpDistance200Tiles)) + npc.TargetClosest(); npc.spriteDirection = (Target.Center.X < npc.Center.X).ToDirectionInt(); timer++; - int shootRate = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 120 : 180; + int shootRate = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 120 : 180; if (timer > shootRate) { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC seeker = Main.npc[i]; - if (seeker.type == npc.type) - { - if (seeker == npc) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), SCal.Center); - break; - } - } + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC seeker = Main.npc[i]; + if (seeker.type == npc.type) + { + if (seeker == npc) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), SCal.Center); + break; + } + } if (Main.netMode != NetmodeID.MultiplayerClient) { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); Vector2 shootVelocity = (Target.Center - EyePosition).SafeNormalize(Vector2.UnitY) * 9f; - Projectile.NewProjectile(EyePosition, shootVelocity, type, damage, 1f, Main.myPlayer); + Projectile.NewProjectile(EyePosition, shootVelocity, type, damage, 1f, Main.myPlayer); } timer = 0; npc.netUpdate = true; @@ -122,17 +122,17 @@ namespace CalamityMod.NPCs.SupremeCalamitas return false; } - public override void NPCLoot() - { - if (!CalamityWorld.revenge) - { - int closestPlayer = Player.FindClosest(npc.Center, 1, 1); - if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); - } - } + public override void NPCLoot() + { + if (!CalamityWorld.revenge) + { + int closestPlayer = Player.FindClosest(npc.Center, 1, 1); + if (Main.rand.Next(4) == 0 && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Heart); + } + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; @@ -174,58 +174,58 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override bool CheckActive() => false; - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 2; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 2; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow"); + Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (float)(num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } - } + return false; + } + } } diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 70c5ceda2d..5b8905c7a7 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -30,7 +30,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SupremeCalamitas { - public class SupremeCalamitas : ModNPC + public class SupremeCalamitas : ModNPC { internal enum FrameAnimationType { @@ -172,19 +172,19 @@ namespace CalamityMod.NPCs.SupremeCalamitas { DisplayName.SetDefault("Supreme Calamitas"); Main.npcFrameCount[npc.type] = 21; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 50f; + npc.Calamity().canBreakPlayerDefense = true; + npc.GetNPCDamage(); + npc.npcSlots = 50f; npc.width = npc.height = 44; npc.defense = 100; - npc.DR_NERD(normalDR); + npc.DR_NERD(normalDR); npc.value = Item.buyPrice(30, 0, 0, 0); - npc.LifeMaxNERB(960000, 1150000, 500000); + npc.LifeMaxNERB(960000, 1150000, 500000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -199,10 +199,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.HitSound = SoundID.NPCHit1; music = CalamityMod.Instance.GetMusicFromMusicMod("SupremeCalamitas1") ?? MusicID.Boss2; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void BossHeadSlot(ref int index) { @@ -324,7 +324,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas CalamityGlobalNPC.SCal = npc.whoAmI; - bool wormAlive = false; + bool wormAlive = false; if (CalamityGlobalNPC.SCalWorm != -1) { wormAlive = Main.npc[CalamityGlobalNPC.SCalWorm].active; @@ -350,35 +350,35 @@ namespace CalamityMod.NPCs.SupremeCalamitas CalamityMod.StopRain(); - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Projectile damage values - int bulletHellblastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); - int firstBulletHellblastDamage = (int)Math.Round(bulletHellblastDamage * 1.25); - int barrageDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); - int gigablastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); - int fireblastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); - int monsterDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); - int waveDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); - int hellblastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); + // Projectile damage values + int bulletHellblastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); + int firstBulletHellblastDamage = (int)Math.Round(bulletHellblastDamage * 1.25); + int barrageDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); + int gigablastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); + int fireblastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); + int monsterDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); + int waveDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); + int hellblastDamage = npc.GetProjectileDamage(ModContent.ProjectileType()); int bodyWidth = 44; int bodyHeight = 42; - int baseBulletHellProjectileGateValue = revenge ? 8 : expertMode ? 9 : 10; + int baseBulletHellProjectileGateValue = revenge ? 8 : expertMode ? 9 : 10; - Vector2 vectorCenter = npc.Center; + Vector2 vectorCenter = npc.Center; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; if (!startText) { @@ -556,8 +556,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (startFifthAttack) global.DR *= 1.2f; } - #endregion - #region Despawn + #endregion + #region Despawn if (!player.active || player.dead) { npc.TargetClosest(false); @@ -566,7 +566,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Slow down and disappear in a burst of fire if should despawn. if (!player.active || player.dead) { - canDespawn = true; + canDespawn = true; npc.Opacity = MathHelper.Lerp(npc.Opacity, 0f, 0.065f); npc.velocity = Vector2.Lerp(Vector2.UnitY * -4f, Vector2.Zero, (float)Math.Sin(MathHelper.Pi * npc.Opacity)); @@ -600,8 +600,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas } else canDespawn = false; - #endregion - #region Cast Charge Countdown + #endregion + #region Cast Charge Countdown if (attackCastDelay > 0) { attackCastDelay--; @@ -640,9 +640,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas FrameType = FrameAnimationType.Casting; return; } - #endregion - #region FirstAttack - if (bulletHellCounter2 < 900) + #endregion + #region FirstAttack + if (bulletHellCounter2 < 900) { despawnProj = true; bulletHellCounter2 += 1; @@ -650,22 +650,22 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.chaseable = false; npc.dontTakeDamage = true; - if (!canDespawn) - npc.velocity *= 0.95f; + if (!canDespawn) + npc.velocity *= 0.95f; if (Main.netMode != NetmodeID.MultiplayerClient) { bulletHellCounter += 1; - if (bulletHellCounter >= baseBulletHellProjectileGateValue) - { - bulletHellCounter = 0; - if (bulletHellCounter2 % (baseBulletHellProjectileGateValue * 6) == 0) - { - float distance = Main.rand.NextBool() ? -1000f : 1000f; - float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; - Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, ModContent.ProjectileType(), firstBulletHellblastDamage, 0f, Main.myPlayer); - } - if (bulletHellCounter2 < 300) // Blasts from above + if (bulletHellCounter >= baseBulletHellProjectileGateValue) + { + bulletHellCounter = 0; + if (bulletHellCounter2 % (baseBulletHellProjectileGateValue * 6) == 0) + { + float distance = Main.rand.NextBool() ? -1000f : 1000f; + float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; + Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, ModContent.ProjectileType(), firstBulletHellblastDamage, 0f, Main.myPlayer); + } + if (bulletHellCounter2 < 300) // Blasts from above { Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 4f * uDieLul, ModContent.ProjectileType(), firstBulletHellblastDamage, 0f, Main.myPlayer); } @@ -721,8 +721,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.chaseable = false; npc.dontTakeDamage = true; - if (!canDespawn) - npc.velocity *= 0.95f; + if (!canDespawn) + npc.velocity *= 0.95f; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -745,13 +745,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (bulletHellCounter >= baseBulletHellProjectileGateValue + 1) { bulletHellCounter = 0; - if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 1) * 6) == 0) - { - float distance = Main.rand.NextBool() ? -1000f : 1000f; - float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; - Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, ModContent.ProjectileType(), firstBulletHellblastDamage, 0f, Main.myPlayer); - } - if (bulletHellCounter2 < 1200) // Blasts from below + if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 1) * 6) == 0) + { + float distance = Main.rand.NextBool() ? -1000f : 1000f; + float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; + Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, ModContent.ProjectileType(), firstBulletHellblastDamage, 0f, Main.myPlayer); + } + if (bulletHellCounter2 < 1200) // Blasts from below { Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y + 1000f, 0f, -4f * uDieLul, ModContent.ProjectileType(), bulletHellblastDamage, 0f, Main.myPlayer); } @@ -791,8 +791,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.chaseable = false; npc.dontTakeDamage = true; - if (!canDespawn) - npc.velocity *= 0.95f; + if (!canDespawn) + npc.velocity *= 0.95f; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -806,13 +806,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (bulletHellCounter >= baseBulletHellProjectileGateValue + 4) { bulletHellCounter = 0; - if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 4) * 6) == 0) - { - float distance = Main.rand.NextBool() ? -1000f : 1000f; - float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; - Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, ModContent.ProjectileType(), firstBulletHellblastDamage, 0f, Main.myPlayer); - } - if (bulletHellCounter2 < 2100) // Blasts from above + if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 4) * 6) == 0) + { + float distance = Main.rand.NextBool() ? -1000f : 1000f; + float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; + Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, ModContent.ProjectileType(), firstBulletHellblastDamage, 0f, Main.myPlayer); + } + if (bulletHellCounter2 < 2100) // Blasts from above { Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 4f * uDieLul, ModContent.ProjectileType(), bulletHellblastDamage, 0f, Main.myPlayer); } @@ -855,8 +855,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.chaseable = false; npc.dontTakeDamage = true; - if (!canDespawn) - npc.velocity *= 0.95f; + if (!canDespawn) + npc.velocity *= 0.95f; if (Main.netMode != NetmodeID.MultiplayerClient) // More clustered attack { @@ -866,7 +866,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (bulletHellCounter2 % 240 == 0) // Fireblasts from above Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 10f * uDieLul, ModContent.ProjectileType(), fireblastDamage, 0f, Main.myPlayer); - int divisor = revenge ? 225 : expertMode ? 450 : 675; + int divisor = revenge ? 225 : expertMode ? 450 : 675; // TODO -- Resprite Brimstone Monsters to be something else. WIPs posted by Iban. if (bulletHellCounter2 % divisor == 0 && expertMode) // Giant homing fireballs @@ -879,13 +879,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (bulletHellCounter >= baseBulletHellProjectileGateValue + 6) { bulletHellCounter = 0; - if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 6) * 6) == 0) - { - float distance = Main.rand.NextBool() ? -1000f : 1000f; - float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; - Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, ModContent.ProjectileType(), firstBulletHellblastDamage, 0f, Main.myPlayer); - } - if (bulletHellCounter2 < 3000) // Blasts from below + if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 6) * 6) == 0) + { + float distance = Main.rand.NextBool() ? -1000f : 1000f; + float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; + Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, ModContent.ProjectileType(), firstBulletHellblastDamage, 0f, Main.myPlayer); + } + if (bulletHellCounter2 < 3000) // Blasts from below { Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y + 1000f, 0f, -4f * uDieLul, ModContent.ProjectileType(), bulletHellblastDamage, 0f, Main.myPlayer); } @@ -905,8 +905,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (!startFourthAttack && (npc.life <= npc.lifeMax * 0.3)) { - // Switch from the Lament section of Stained, Brutal Calamity to the Epiphany section. - music = CalamityMod.Instance.GetMusicFromMusicMod("SupremeCalamitas3") ?? MusicID.LunarBoss; + // Switch from the Lament section of Stained, Brutal Calamity to the Epiphany section. + music = CalamityMod.Instance.GetMusicFromMusicMod("SupremeCalamitas3") ?? MusicID.LunarBoss; if (!BossRushEvent.BossRushActive) { @@ -928,8 +928,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.chaseable = false; npc.dontTakeDamage = true; - if (!canDespawn) - npc.velocity *= 0.95f; + if (!canDespawn) + npc.velocity *= 0.95f; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -941,22 +941,22 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (bulletHellCounter2 % 30 == 0) // Projectiles that move in wave pattern { - int random = Main.rand.Next(-500, 501); - Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + random, -5f * uDieLul, 0f, ModContent.ProjectileType(), waveDamage, 0f, Main.myPlayer); - Projectile.NewProjectile(player.position.X - 1000f, player.position.Y - random, 5f * uDieLul, 0f, ModContent.ProjectileType(), waveDamage, 0f, Main.myPlayer); - } + int random = Main.rand.Next(-500, 501); + Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + random, -5f * uDieLul, 0f, ModContent.ProjectileType(), waveDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(player.position.X - 1000f, player.position.Y - random, 5f * uDieLul, 0f, ModContent.ProjectileType(), waveDamage, 0f, Main.myPlayer); + } bulletHellCounter += 1; if (bulletHellCounter >= baseBulletHellProjectileGateValue + 8) { bulletHellCounter = 0; - if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 8) * 6) == 0) - { - float distance = Main.rand.NextBool() ? -1000f : 1000f; - float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; - Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, ModContent.ProjectileType(), firstBulletHellblastDamage, 0f, Main.myPlayer); - } - if (bulletHellCounter2 < 3900) // Blasts from above + if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 8) * 6) == 0) + { + float distance = Main.rand.NextBool() ? -1000f : 1000f; + float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; + Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, ModContent.ProjectileType(), firstBulletHellblastDamage, 0f, Main.myPlayer); + } + if (bulletHellCounter2 < 3900) // Blasts from above { Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 4f * uDieLul, ModContent.ProjectileType(), bulletHellblastDamage, 0f, Main.myPlayer); } @@ -1004,8 +1004,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.noGravity = false; npc.damage = 0; - if (!canDespawn) - npc.velocity.X *= 0.96f; + if (!canDespawn) + npc.velocity.X *= 0.96f; if (CalamityWorld.downedSCal && !BossRushEvent.BossRushActive) { @@ -1063,15 +1063,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (!gettingTired5 && (npc.life <= npc.lifeMax * 0.01)) { - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active && projectile.type == ModContent.ProjectileType()) - { - if (projectile.timeLeft > 90) - projectile.timeLeft = 90; - } - } + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active && projectile.type == ModContent.ProjectileType()) + { + if (projectile.timeLeft > 90) + projectile.timeLeft = 90; + } + } if (!BossRushEvent.BossRushActive) { @@ -1160,16 +1160,16 @@ namespace CalamityMod.NPCs.SupremeCalamitas projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) { - if (projectile.timeLeft > 60) - projectile.timeLeft = 60; + if (projectile.timeLeft > 60) + projectile.timeLeft = 60; } else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) { - projectile.ai[1] = 1f; + projectile.ai[1] = 1f; - if (projectile.timeLeft > 60) - projectile.timeLeft = 60; - } + if (projectile.timeLeft > 60) + projectile.timeLeft = 60; + } } } despawnProj = false; @@ -1247,8 +1247,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.chaseable = false; npc.damage = 0; - if (!canDespawn) - npc.velocity *= 0.95f; + if (!canDespawn) + npc.velocity *= 0.95f; return; } else @@ -1258,163 +1258,163 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - if (npc.ai[1] == -1f) - { - phaseChange++; - if (phaseChange > 23) - phaseChange = 0; + if (npc.ai[1] == -1f) + { + phaseChange++; + if (phaseChange > 23) + phaseChange = 0; - int phase = 0; //0 = shots above 1 = charge 2 = nothing 3 = hellblasts 4 = fireblasts - switch (phaseChange) - { - case 0: - phase = 0; - willCharge = false; - break; //0341 - case 1: - phase = 3; - break; - case 2: - phase = 4; - willCharge = true; - break; - case 3: - phase = 1; - break; - case 4: - phase = 1; - break; //1430 - case 5: - phase = 4; - willCharge = false; - break; - case 6: - phase = 3; - break; - case 7: - phase = 0; - willCharge = true; - break; - case 8: - phase = 1; - break; //1034 - case 9: - phase = 0; - willCharge = false; - break; - case 10: - phase = 3; - break; - case 11: - phase = 4; - break; - case 12: - phase = 4; - break; //4310 - case 13: - phase = 3; - willCharge = true; - break; - case 14: - phase = 1; - break; - case 15: - phase = 0; - willCharge = false; - break; - case 16: - phase = 4; - break; //4411 - case 17: - phase = 4; - willCharge = true; - break; - case 18: - phase = 1; - break; - case 19: - phase = 1; - break; - case 20: - phase = 0; - break; //0101 - case 21: - phase = 1; - break; - case 22: - phase = 0; - break; - case 23: - phase = 1; - break; - } + int phase = 0; //0 = shots above 1 = charge 2 = nothing 3 = hellblasts 4 = fireblasts + switch (phaseChange) + { + case 0: + phase = 0; + willCharge = false; + break; //0341 + case 1: + phase = 3; + break; + case 2: + phase = 4; + willCharge = true; + break; + case 3: + phase = 1; + break; + case 4: + phase = 1; + break; //1430 + case 5: + phase = 4; + willCharge = false; + break; + case 6: + phase = 3; + break; + case 7: + phase = 0; + willCharge = true; + break; + case 8: + phase = 1; + break; //1034 + case 9: + phase = 0; + willCharge = false; + break; + case 10: + phase = 3; + break; + case 11: + phase = 4; + break; + case 12: + phase = 4; + break; //4310 + case 13: + phase = 3; + willCharge = true; + break; + case 14: + phase = 1; + break; + case 15: + phase = 0; + willCharge = false; + break; + case 16: + phase = 4; + break; //4411 + case 17: + phase = 4; + willCharge = true; + break; + case 18: + phase = 1; + break; + case 19: + phase = 1; + break; + case 20: + phase = 0; + break; //0101 + case 21: + phase = 1; + break; + case 22: + phase = 0; + break; + case 23: + phase = 1; + break; + } - npc.ai[1] = phase; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - else - { - if (npc.ai[1] == 0f) - { - float num823 = 12f; - float num824 = 0.12f; + npc.ai[1] = phase; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + } + else + { + if (npc.ai[1] == 0f) + { + float num823 = 12f; + float num824 = 0.12f; - // Reduce acceleration if target is holding a true melee weapon - Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) - { - num824 *= 0.5f; - } + // Reduce acceleration if target is holding a true melee weapon + Item targetSelectedItem = player.inventory[player.selectedItem]; + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) + { + num824 *= 0.5f; + } - 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) - 550f - vector82.Y; - float num827 = (float)Math.Sqrt(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) - 550f - vector82.Y; + float num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); - num827 = num823 / num827; - num825 *= num827; - num826 *= num827; + num827 = num823 / num827; + num825 *= num827; + num826 *= num827; - if (!canDespawn) - { - if (npc.velocity.X < num825) - { - npc.velocity.X += num824; - if (npc.velocity.X < 0f && num825 > 0f) - npc.velocity.X += num824; - } - else if (npc.velocity.X > num825) - { - npc.velocity.X -= num824; - if (npc.velocity.X > 0f && num825 < 0f) - npc.velocity.X -= num824; - } - if (npc.velocity.Y < num826) - { - npc.velocity.Y += num824; - if (npc.velocity.Y < 0f && num826 > 0f) - npc.velocity.Y += num824; - } - else if (npc.velocity.Y > num826) - { - npc.velocity.Y -= num824; - if (npc.velocity.Y > 0f && num826 < 0f) - npc.velocity.Y -= num824; - } - } + if (!canDespawn) + { + if (npc.velocity.X < num825) + { + npc.velocity.X += num824; + if (npc.velocity.X < 0f && num825 > 0f) + npc.velocity.X += num824; + } + else if (npc.velocity.X > num825) + { + npc.velocity.X -= num824; + if (npc.velocity.X > 0f && num825 < 0f) + npc.velocity.X -= num824; + } + if (npc.velocity.Y < num826) + { + npc.velocity.Y += num824; + if (npc.velocity.Y < 0f && num826 > 0f) + npc.velocity.Y += num824; + } + else if (npc.velocity.Y > num826) + { + npc.velocity.Y -= num824; + if (npc.velocity.Y > 0f && num826 < 0f) + npc.velocity.Y -= num824; + } + } - npc.ai[2] += 1f; - if (npc.ai[2] >= 300f) - { - npc.ai[1] = -1f; - npc.TargetClosest(); - npc.netUpdate = true; - } + npc.ai[2] += 1f; + if (npc.ai[2] >= 300f) + { + npc.ai[1] = -1f; + npc.TargetClosest(); + npc.netUpdate = true; + } - vector82 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num825 = player.position.X + (player.width / 2) - vector82.X; - num826 = player.position.Y + (player.height / 2) - vector82.Y; + vector82 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num825 = player.position.X + (player.width / 2) - vector82.X; + num826 = player.position.Y + (player.height / 2) - vector82.Y; npc.localAI[1] += wormAlive ? 0.5f : 1f; if (npc.localAI[1] > 90f) @@ -1532,70 +1532,70 @@ namespace CalamityMod.NPCs.SupremeCalamitas } FrameType = FrameAnimationType.FasterUpwardDraft; - } - else if (npc.ai[1] == 1f) - { - float num383 = wormAlive ? 26f : 30f; - if (npc.life < npc.lifeMax * 0.95) - num383 += 1f; - if (npc.life < npc.lifeMax * 0.85) - num383 += 1f; - if (npc.life < npc.lifeMax * 0.7) - num383 += 1f; - if (npc.life < npc.lifeMax * 0.6) - num383 += 1f; - if (npc.life < npc.lifeMax * 0.5) - num383 += 1f; + } + else if (npc.ai[1] == 1f) + { + float num383 = wormAlive ? 26f : 30f; + if (npc.life < npc.lifeMax * 0.95) + num383 += 1f; + if (npc.life < npc.lifeMax * 0.85) + num383 += 1f; + if (npc.life < npc.lifeMax * 0.7) + num383 += 1f; + if (npc.life < npc.lifeMax * 0.6) + num383 += 1f; + if (npc.life < npc.lifeMax * 0.5) + num383 += 1f; - Vector2 vector37 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num384 = player.position.X + (player.width / 2) - vector37.X; - float num385 = player.position.Y + (player.height / 2) - vector37.Y; - float num386 = (float)Math.Sqrt(num384 * num384 + num385 * num385); - num386 = num383 / num386; + Vector2 vector37 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num384 = player.position.X + (player.width / 2) - vector37.X; + float num385 = player.position.Y + (player.height / 2) - vector37.Y; + float num386 = (float)Math.Sqrt(num384 * num384 + num385 * num385); + num386 = num383 / num386; - if (!canDespawn) - { - npc.velocity.X = num384 * num386; - npc.velocity.Y = num385 * num386; + if (!canDespawn) + { + npc.velocity.X = num384 * num386; + npc.velocity.Y = num385 * num386; shieldRotation = npc.velocity.ToRotation(); npc.netUpdate = true; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/SCalDash"), npc.Center); - } + } - npc.ai[1] = 2f; - } - else if (npc.ai[1] == 2f) - { - npc.ai[2] += 1f; + npc.ai[1] = 2f; + } + else if (npc.ai[1] == 2f) + { + npc.ai[2] += 1f; if (Math.Abs(npc.velocity.X) > 0.15f) npc.spriteDirection = (npc.velocity.X < 0f).ToDirectionInt(); - if (npc.ai[2] >= 25f) - { - if (!canDespawn) - { - npc.velocity *= 0.96f; + if (npc.ai[2] >= 25f) + { + if (!canDespawn) + { + npc.velocity *= 0.96f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - } + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) + npc.velocity.X = 0f; + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) + npc.velocity.Y = 0f; + } + } bool willChargeAgain = npc.ai[3] + 1 < 2; if (npc.ai[2] >= 70f) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.TargetClosest(); + { + npc.ai[3] += 1f; + npc.ai[2] = 0f; + npc.TargetClosest(); - if (!willChargeAgain) - npc.ai[1] = -1f; - else - npc.ai[1] = 1f; + if (!willChargeAgain) + npc.ai[1] = -1f; + else + npc.ai[1] = 1f; } if (willChargeAgain && npc.ai[2] > 50f) @@ -1607,79 +1607,79 @@ namespace CalamityMod.NPCs.SupremeCalamitas FrameType = FrameAnimationType.FasterUpwardDraft; } - else if (npc.ai[1] == 3f) - { - float num412 = 32f; - float num413 = 1.2f; + else if (npc.ai[1] == 3f) + { + float num412 = 32f; + float num413 = 1.2f; - // Reduce acceleration if target is holding a true melee weapon - Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) - { - num413 *= 0.5f; - } + // Reduce acceleration if target is holding a true melee weapon + Item targetSelectedItem = player.inventory[player.selectedItem]; + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) + { + num413 *= 0.5f; + } - int num414 = 1; - if (npc.position.X + (npc.width / 2) < player.position.X + player.width) - num414 = -1; + int num414 = 1; + if (npc.position.X + (npc.width / 2) < player.position.X + player.width) + num414 = -1; Vector2 handPosition = npc.Center + new Vector2(npc.spriteDirection * -18f, 2f); Vector2 vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num415 = player.position.X + (player.width / 2) + (num414 * 600) - vector40.X; - float num416 = player.position.Y + (player.height / 2) - vector40.Y; - float num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); + float num415 = player.position.X + (player.width / 2) + (num414 * 600) - vector40.X; + float num416 = player.position.Y + (player.height / 2) - vector40.Y; + float num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); - num417 = num412 / num417; - num415 *= num417; - num416 *= num417; + num417 = num412 / num417; + num415 *= num417; + num416 *= num417; - if (!canDespawn) - { - if (npc.velocity.X < num415) - { - npc.velocity.X += num413; - if (npc.velocity.X < 0f && num415 > 0f) - npc.velocity.X += num413; - } - else if (npc.velocity.X > num415) - { - npc.velocity.X -= num413; - if (npc.velocity.X > 0f && num415 < 0f) - npc.velocity.X -= num413; - } - if (npc.velocity.Y < num416) - { - npc.velocity.Y += num413; - if (npc.velocity.Y < 0f && num416 > 0f) - npc.velocity.Y += num413; - } - else if (npc.velocity.Y > num416) - { - npc.velocity.Y -= num413; - if (npc.velocity.Y > 0f && num416 < 0f) - npc.velocity.Y -= num413; - } - } + if (!canDespawn) + { + if (npc.velocity.X < num415) + { + npc.velocity.X += num413; + if (npc.velocity.X < 0f && num415 > 0f) + npc.velocity.X += num413; + } + else if (npc.velocity.X > num415) + { + npc.velocity.X -= num413; + if (npc.velocity.X > 0f && num415 < 0f) + npc.velocity.X -= num413; + } + if (npc.velocity.Y < num416) + { + npc.velocity.Y += num413; + if (npc.velocity.Y < 0f && num416 > 0f) + npc.velocity.Y += num413; + } + else if (npc.velocity.Y > num416) + { + npc.velocity.Y -= num413; + if (npc.velocity.Y > 0f && num416 < 0f) + npc.velocity.Y -= num413; + } + } - npc.ai[2] += 1f; - if (npc.ai[2] >= 480f) - { - npc.ai[1] = -1f; - npc.TargetClosest(); - npc.netUpdate = true; - } - else - { - if (!player.dead) - npc.ai[3] += wormAlive ? 0.5f : 1f; + npc.ai[2] += 1f; + if (npc.ai[2] >= 480f) + { + npc.ai[1] = -1f; + npc.TargetClosest(); + npc.netUpdate = true; + } + else + { + if (!player.dead) + npc.ai[3] += wormAlive ? 0.5f : 1f; - if (npc.ai[3] >= 20f) - { - npc.ai[3] = 0f; - vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num415 = player.position.X + (player.width / 2) - vector40.X; - num416 = player.position.Y + (player.height / 2) - vector40.Y; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneHellblastSound"), npc.Center); + if (npc.ai[3] >= 20f) + { + npc.ai[3] = 0f; + vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num415 = player.position.X + (player.width / 2) - vector40.X; + num416 = player.position.Y + (player.height / 2) - vector40.Y; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneHellblastSound"), npc.Center); // Release a burst of magic dust along with a brimstone hellblast skull. for (int i = 0; i < 25; i++) @@ -1693,19 +1693,19 @@ namespace CalamityMod.NPCs.SupremeCalamitas brimstoneMagic.noLight = true; } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float num418 = 10f * uDieLul; - int num420 = ModContent.ProjectileType(); - num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); - num417 = num418 / num417; - num415 *= num417; - num416 *= num417; - vector40.X += num415 * 2f; - vector40.Y += num416 * 2f; - Projectile.NewProjectile(vector40.X, vector40.Y, num415, num416, num420, hellblastDamage, 0f, Main.myPlayer, 0f, 0f); - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float num418 = 10f * uDieLul; + int num420 = ModContent.ProjectileType(); + num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); + num417 = num418 / num417; + num415 *= num417; + num416 *= num417; + vector40.X += num415 * 2f; + vector40.Y += num416 * 2f; + Projectile.NewProjectile(vector40.X, vector40.Y, num415, num416, num420, hellblastDamage, 0f, Main.myPlayer, 0f, 0f); + } + } } if (Main.rand.NextBool(2)) @@ -1719,62 +1719,62 @@ namespace CalamityMod.NPCs.SupremeCalamitas FrameType = FrameAnimationType.OutwardHandCast; } - else if (npc.ai[1] == 4f) - { - int num831 = 1; - if (npc.position.X + (npc.width / 2) < player.position.X + player.width) - num831 = -1; + else if (npc.ai[1] == 4f) + { + int num831 = 1; + if (npc.position.X + (npc.width / 2) < player.position.X + player.width) + num831 = -1; - float num832 = 32f; - float num833 = 1.2f; + float num832 = 32f; + float num833 = 1.2f; - // Reduce acceleration if target is holding a true melee weapon - Item targetSelectedItem = player.HeldItem; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) - { - num833 *= 0.5f; - } + // Reduce acceleration if target is holding a true melee weapon + Item targetSelectedItem = player.HeldItem; + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) + { + num833 *= 0.5f; + } - 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 * 750) - vector83.X; //600 - float num835 = player.position.Y + (player.height / 2) - vector83.Y; - float num836 = (float)Math.Sqrt(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 * 750) - vector83.X; //600 + 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; + num836 = num832 / num836; + num834 *= num836; + num835 *= num836; - if (!canDespawn) - { - if (npc.velocity.X < num834) - { - npc.velocity.X += num833; - if (npc.velocity.X < 0f && num834 > 0f) - npc.velocity.X += num833; - } - else if (npc.velocity.X > num834) - { - npc.velocity.X -= num833; - if (npc.velocity.X > 0f && num834 < 0f) - npc.velocity.X -= num833; - } - if (npc.velocity.Y < num835) - { - npc.velocity.Y += num833; - if (npc.velocity.Y < 0f && num835 > 0f) - npc.velocity.Y += num833; - } - else if (npc.velocity.Y > num835) - { - npc.velocity.Y -= num833; - if (npc.velocity.Y > 0f && num835 < 0f) - npc.velocity.Y -= num833; - } - } + if (!canDespawn) + { + if (npc.velocity.X < num834) + { + npc.velocity.X += num833; + if (npc.velocity.X < 0f && num834 > 0f) + npc.velocity.X += num833; + } + else if (npc.velocity.X > num834) + { + npc.velocity.X -= num833; + if (npc.velocity.X > 0f && num834 < 0f) + npc.velocity.X -= num833; + } + if (npc.velocity.Y < num835) + { + npc.velocity.Y += num833; + if (npc.velocity.Y < 0f && num835 > 0f) + npc.velocity.Y += num833; + } + else if (npc.velocity.Y > num835) + { + npc.velocity.Y -= num833; + if (npc.velocity.Y > 0f && num835 < 0f) + npc.velocity.Y -= num833; + } + } - vector83 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num834 = player.position.X + (player.width / 2) - vector83.X; - num835 = player.position.Y + (player.height / 2) - vector83.Y; + vector83 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num834 = player.position.X + (player.width / 2) - vector83.X; + num835 = player.position.Y + (player.height / 2) - vector83.Y; int shootRate = wormAlive ? 280 : 140; npc.localAI[1]++; @@ -1799,26 +1799,26 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.localAI[1] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); - float num837 = 5f * uDieLul; - int num839 = ModContent.ProjectileType(); - num836 = (float)Math.Sqrt(num834 * num834 + num835 * num835); - num836 = num837 / num836; - num834 *= num836; - num835 *= num836; - vector83.X += num834 * 8f; - vector83.Y += num835 * 8f; - Projectile.NewProjectile(vector83.X, vector83.Y, num834, num835, num839, fireblastDamage, 0f, Main.myPlayer, 0f, 0f); - } - } + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); + float num837 = 5f * uDieLul; + int num839 = ModContent.ProjectileType(); + num836 = (float)Math.Sqrt(num834 * num834 + num835 * num835); + num836 = num837 / num836; + num834 *= num836; + num835 *= num836; + vector83.X += num834 * 8f; + vector83.Y += num835 * 8f; + Projectile.NewProjectile(vector83.X, vector83.Y, num834, num835, num839, fireblastDamage, 0f, Main.myPlayer, 0f, 0f); + } + } - npc.ai[2] += 1f; - if (npc.ai[2] >= 300f) - { - npc.ai[1] = -1f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.ai[2] += 1f; + if (npc.ai[2] >= 300f) + { + npc.ai[1] = -1f; + npc.TargetClosest(); + npc.netUpdate = true; } } } @@ -1829,7 +1829,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); + npc.TargetClosest(); npc.netUpdate = true; } } @@ -1878,15 +1878,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas brimstoneFire.noGravity = true; } - if (!canDespawn) - { - npc.velocity *= 0.98f; + if (!canDespawn) + { + npc.velocity *= 0.98f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) + npc.velocity.X = 0f; + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) + npc.velocity.Y = 0f; + } } #endregion #region LastStage @@ -1912,164 +1912,164 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - if (npc.ai[1] == -1f) - { - phaseChange++; - if (phaseChange > 23) - phaseChange = 0; + if (npc.ai[1] == -1f) + { + phaseChange++; + if (phaseChange > 23) + phaseChange = 0; - int phase = 0; //0 = shots above 1 = charge 2 = nothing 3 = hellblasts 4 = fireblasts - switch (phaseChange) - { - case 0: - phase = 0; - willCharge = false; - break; //0341 - case 1: - phase = 3; - break; - case 2: - phase = 4; - willCharge = true; - break; - case 3: - phase = 1; - break; - case 4: - phase = 1; - break; //1430 - case 5: - phase = 4; - willCharge = false; - break; - case 6: - phase = 3; - break; - case 7: - phase = 0; - willCharge = true; - break; - case 8: - phase = 1; - break; //1034 - case 9: - phase = 0; - willCharge = false; - break; - case 10: - phase = 3; - break; - case 11: - phase = 4; - break; - case 12: - phase = 4; - break; //4310 - case 13: - phase = 3; - willCharge = true; - break; - case 14: - phase = 1; - break; - case 15: - phase = 0; - willCharge = false; - break; - case 16: - phase = 4; - break; //4411 - case 17: - phase = 4; - willCharge = true; - break; - case 18: - phase = 1; - break; - case 19: - phase = 1; - break; - case 20: - phase = 0; - break; //0101 - case 21: - phase = 1; - break; - case 22: - phase = 0; - break; - case 23: - phase = 1; - break; - } + int phase = 0; //0 = shots above 1 = charge 2 = nothing 3 = hellblasts 4 = fireblasts + switch (phaseChange) + { + case 0: + phase = 0; + willCharge = false; + break; //0341 + case 1: + phase = 3; + break; + case 2: + phase = 4; + willCharge = true; + break; + case 3: + phase = 1; + break; + case 4: + phase = 1; + break; //1430 + case 5: + phase = 4; + willCharge = false; + break; + case 6: + phase = 3; + break; + case 7: + phase = 0; + willCharge = true; + break; + case 8: + phase = 1; + break; //1034 + case 9: + phase = 0; + willCharge = false; + break; + case 10: + phase = 3; + break; + case 11: + phase = 4; + break; + case 12: + phase = 4; + break; //4310 + case 13: + phase = 3; + willCharge = true; + break; + case 14: + phase = 1; + break; + case 15: + phase = 0; + willCharge = false; + break; + case 16: + phase = 4; + break; //4411 + case 17: + phase = 4; + willCharge = true; + break; + case 18: + phase = 1; + break; + case 19: + phase = 1; + break; + case 20: + phase = 0; + break; //0101 + case 21: + phase = 1; + break; + case 22: + phase = 0; + break; + case 23: + phase = 1; + break; + } - npc.ai[1] = phase; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - else - { - if (npc.ai[1] == 0f) - { - float num823 = 12f; - float num824 = 0.12f; + npc.ai[1] = phase; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + } + else + { + if (npc.ai[1] == 0f) + { + float num823 = 12f; + float num824 = 0.12f; - // Reduce acceleration if target is holding a true melee weapon - Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) - { - num824 *= 0.5f; - } + // Reduce acceleration if target is holding a true melee weapon + Item targetSelectedItem = player.inventory[player.selectedItem]; + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) + { + num824 *= 0.5f; + } - 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) - 550f - vector82.Y; - float num827 = (float)Math.Sqrt(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) - 550f - vector82.Y; + float num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); - num827 = num823 / num827; - num825 *= num827; - num826 *= num827; + num827 = num823 / num827; + num825 *= num827; + num826 *= num827; - if (!canDespawn) - { - if (npc.velocity.X < num825) - { - npc.velocity.X += num824; - if (npc.velocity.X < 0f && num825 > 0f) - npc.velocity.X += num824; - } - else if (npc.velocity.X > num825) - { - npc.velocity.X -= num824; - if (npc.velocity.X > 0f && num825 < 0f) - npc.velocity.X -= num824; - } + if (!canDespawn) + { + if (npc.velocity.X < num825) + { + npc.velocity.X += num824; + if (npc.velocity.X < 0f && num825 > 0f) + npc.velocity.X += num824; + } + else if (npc.velocity.X > num825) + { + npc.velocity.X -= num824; + if (npc.velocity.X > 0f && num825 < 0f) + npc.velocity.X -= num824; + } - if (npc.velocity.Y < num826) - { - npc.velocity.Y += num824; - if (npc.velocity.Y < 0f && num826 > 0f) - npc.velocity.Y += num824; - } - else if (npc.velocity.Y > num826) - { - npc.velocity.Y -= num824; - if (npc.velocity.Y > 0f && num826 < 0f) - npc.velocity.Y -= num824; - } - } + if (npc.velocity.Y < num826) + { + npc.velocity.Y += num824; + if (npc.velocity.Y < 0f && num826 > 0f) + npc.velocity.Y += num824; + } + else if (npc.velocity.Y > num826) + { + npc.velocity.Y -= num824; + if (npc.velocity.Y > 0f && num826 < 0f) + npc.velocity.Y -= num824; + } + } - npc.ai[2] += 1f; - if (npc.ai[2] >= 240f) - { - npc.ai[1] = -1f; - npc.TargetClosest(); - npc.netUpdate = true; - } + npc.ai[2] += 1f; + if (npc.ai[2] >= 240f) + { + npc.ai[1] = -1f; + npc.TargetClosest(); + npc.netUpdate = true; + } - vector82 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num825 = player.position.X + (player.width / 2) - vector82.X; - num826 = player.position.Y + (player.height / 2) - vector82.Y; + vector82 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num825 = player.position.X + (player.width / 2) - vector82.X; + num826 = player.position.Y + (player.height / 2) - vector82.Y; npc.localAI[1] += wormAlive ? 0.5f : 1f; if (npc.localAI[1] > 60f) @@ -2186,49 +2186,49 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } } - else if (npc.ai[1] == 1f) - { - float num383 = wormAlive ? 31f : 35f; - if (npc.life < npc.lifeMax * 0.3) - num383 += 1f; - if (npc.life < npc.lifeMax * 0.2) - num383 += 1f; - if (npc.life < npc.lifeMax * 0.1) - num383 += 1f; + else if (npc.ai[1] == 1f) + { + float num383 = wormAlive ? 31f : 35f; + if (npc.life < npc.lifeMax * 0.3) + num383 += 1f; + if (npc.life < npc.lifeMax * 0.2) + num383 += 1f; + if (npc.life < npc.lifeMax * 0.1) + num383 += 1f; - Vector2 vector37 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num384 = player.position.X + (player.width / 2) - vector37.X; - float num385 = player.position.Y + (player.height / 2) - vector37.Y; - float num386 = (float)Math.Sqrt(num384 * num384 + num385 * num385); - num386 = num383 / num386; + Vector2 vector37 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num384 = player.position.X + (player.width / 2) - vector37.X; + float num385 = player.position.Y + (player.height / 2) - vector37.Y; + float num386 = (float)Math.Sqrt(num384 * num384 + num385 * num385); + num386 = num383 / num386; - if (!canDespawn) - { - npc.velocity.X = num384 * num386; - npc.velocity.Y = num385 * num386; + if (!canDespawn) + { + npc.velocity.X = num384 * num386; + npc.velocity.Y = num385 * num386; shieldRotation = npc.velocity.ToRotation(); npc.netUpdate = true; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/SCalDash"), npc.Center); } - npc.ai[1] = 2f; - } - else if (npc.ai[1] == 2f) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= 25f) - { - if (!canDespawn) - { - npc.velocity *= 0.96f; + npc.ai[1] = 2f; + } + else if (npc.ai[1] == 2f) + { + npc.ai[2] += 1f; + if (npc.ai[2] >= 25f) + { + if (!canDespawn) + { + npc.velocity *= 0.96f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - } + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) + npc.velocity.X = 0f; + if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) + npc.velocity.Y = 0f; + } + } bool willChargeAgain = npc.ai[3] + 1 < 1; @@ -2254,79 +2254,79 @@ namespace CalamityMod.NPCs.SupremeCalamitas FrameType = FrameAnimationType.FasterUpwardDraft; } - else if (npc.ai[1] == 3f) - { - float num412 = 32f; - float num413 = 1.2f; + else if (npc.ai[1] == 3f) + { + float num412 = 32f; + float num413 = 1.2f; - // Reduce acceleration if target is holding a true melee weapon - Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) - { - num413 *= 0.5f; - } + // Reduce acceleration if target is holding a true melee weapon + Item targetSelectedItem = player.inventory[player.selectedItem]; + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) + { + num413 *= 0.5f; + } - int num414 = 1; - if (npc.position.X + (npc.width / 2) < player.position.X + player.width) - num414 = -1; + int num414 = 1; + if (npc.position.X + (npc.width / 2) < player.position.X + player.width) + num414 = -1; Vector2 handPosition = npc.Center + new Vector2(npc.spriteDirection * -18f, 2f); Vector2 vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num415 = player.position.X + (player.width / 2) + (num414 * 600) - vector40.X; - float num416 = player.position.Y + (player.height / 2) - vector40.Y; - float num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); + float num415 = player.position.X + (player.width / 2) + (num414 * 600) - vector40.X; + float num416 = player.position.Y + (player.height / 2) - vector40.Y; + float num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); - num417 = num412 / num417; - num415 *= num417; - num416 *= num417; + num417 = num412 / num417; + num415 *= num417; + num416 *= num417; - if (!canDespawn) - { - if (npc.velocity.X < num415) - { - npc.velocity.X += num413; - if (npc.velocity.X < 0f && num415 > 0f) - npc.velocity.X += num413; - } - else if (npc.velocity.X > num415) - { - npc.velocity.X -= num413; - if (npc.velocity.X > 0f && num415 < 0f) - npc.velocity.X -= num413; - } - if (npc.velocity.Y < num416) - { - npc.velocity.Y += num413; - if (npc.velocity.Y < 0f && num416 > 0f) - npc.velocity.Y += num413; - } - else if (npc.velocity.Y > num416) - { - npc.velocity.Y -= num413; - if (npc.velocity.Y > 0f && num416 < 0f) - npc.velocity.Y -= num413; - } - } + if (!canDespawn) + { + if (npc.velocity.X < num415) + { + npc.velocity.X += num413; + if (npc.velocity.X < 0f && num415 > 0f) + npc.velocity.X += num413; + } + else if (npc.velocity.X > num415) + { + npc.velocity.X -= num413; + if (npc.velocity.X > 0f && num415 < 0f) + npc.velocity.X -= num413; + } + if (npc.velocity.Y < num416) + { + npc.velocity.Y += num413; + if (npc.velocity.Y < 0f && num416 > 0f) + npc.velocity.Y += num413; + } + else if (npc.velocity.Y > num416) + { + npc.velocity.Y -= num413; + if (npc.velocity.Y > 0f && num416 < 0f) + npc.velocity.Y -= num413; + } + } - npc.ai[2] += 1f; - if (npc.ai[2] >= 300f) - { - npc.ai[1] = -1f; - npc.TargetClosest(); - npc.netUpdate = true; - } - else - { - if (!player.dead) - npc.ai[3] += wormAlive ? 0.5f : 1f; + npc.ai[2] += 1f; + if (npc.ai[2] >= 300f) + { + npc.ai[1] = -1f; + npc.TargetClosest(); + npc.netUpdate = true; + } + else + { + if (!player.dead) + npc.ai[3] += wormAlive ? 0.5f : 1f; - if (npc.ai[3] >= 24f) - { - npc.ai[3] = 0f; - vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num415 = player.position.X + (player.width / 2) - vector40.X; - num416 = player.position.Y + (player.height / 2) - vector40.Y; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneHellblastSound"), npc.Center); + if (npc.ai[3] >= 24f) + { + npc.ai[3] = 0f; + vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num415 = player.position.X + (player.width / 2) - vector40.X; + num416 = player.position.Y + (player.height / 2) - vector40.Y; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneHellblastSound"), npc.Center); // Release a burst of magic dust along with a brimstone hellblast skull. for (int i = 0; i < 25; i++) @@ -2341,18 +2341,18 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (Main.netMode != NetmodeID.MultiplayerClient) - { - float num418 = 10f * uDieLul; - int num420 = ModContent.ProjectileType(); - num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); - num417 = num418 / num417; - num415 *= num417; - num416 *= num417; - vector40.X += num415 * 4f; - vector40.Y += num416 * 4f; - Projectile.NewProjectile(vector40.X, vector40.Y, num415, num416, num420, hellblastDamage, 0f, Main.myPlayer, 0f, 0f); - } - } + { + float num418 = 10f * uDieLul; + int num420 = ModContent.ProjectileType(); + num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); + num417 = num418 / num417; + num415 *= num417; + num416 *= num417; + vector40.X += num415 * 4f; + vector40.Y += num416 * 4f; + Projectile.NewProjectile(vector40.X, vector40.Y, num415, num416, num420, hellblastDamage, 0f, Main.myPlayer, 0f, 0f); + } + } } if (Main.rand.NextBool(2)) @@ -2367,62 +2367,62 @@ namespace CalamityMod.NPCs.SupremeCalamitas FrameChangeSpeed = 0.245f; FrameType = FrameAnimationType.PunchHandCast; } - else if (npc.ai[1] == 4f) - { - int num831 = 1; - if (npc.position.X + (npc.width / 2) < player.position.X + player.width) - num831 = -1; + else if (npc.ai[1] == 4f) + { + int num831 = 1; + if (npc.position.X + (npc.width / 2) < player.position.X + player.width) + num831 = -1; - float num832 = 32f; - float num833 = 1.2f; + float num832 = 32f; + float num833 = 1.2f; - // Reduce acceleration if target is holding a true melee weapon - Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) - { - num833 *= 0.5f; - } + // Reduce acceleration if target is holding a true melee weapon + Item targetSelectedItem = player.inventory[player.selectedItem]; + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) + { + num833 *= 0.5f; + } - 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 * 750) - vector83.X; //600 - float num835 = player.position.Y + (player.height / 2) - vector83.Y; - float num836 = (float)Math.Sqrt(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 * 750) - vector83.X; //600 + 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; + num836 = num832 / num836; + num834 *= num836; + num835 *= num836; - if (!canDespawn) - { - if (npc.velocity.X < num834) - { - npc.velocity.X += num833; - if (npc.velocity.X < 0f && num834 > 0f) - npc.velocity.X += num833; - } - else if (npc.velocity.X > num834) - { - npc.velocity.X -= num833; - if (npc.velocity.X > 0f && num834 < 0f) - npc.velocity.X -= num833; - } - if (npc.velocity.Y < num835) - { - npc.velocity.Y += num833; - if (npc.velocity.Y < 0f && num835 > 0f) - npc.velocity.Y += num833; - } - else if (npc.velocity.Y > num835) - { - npc.velocity.Y -= num833; - if (npc.velocity.Y > 0f && num835 < 0f) - npc.velocity.Y -= num833; - } - } + if (!canDespawn) + { + if (npc.velocity.X < num834) + { + npc.velocity.X += num833; + if (npc.velocity.X < 0f && num834 > 0f) + npc.velocity.X += num833; + } + else if (npc.velocity.X > num834) + { + npc.velocity.X -= num833; + if (npc.velocity.X > 0f && num834 < 0f) + npc.velocity.X -= num833; + } + if (npc.velocity.Y < num835) + { + npc.velocity.Y += num833; + if (npc.velocity.Y < 0f && num835 > 0f) + npc.velocity.Y += num833; + } + else if (npc.velocity.Y > num835) + { + npc.velocity.Y -= num833; + if (npc.velocity.Y > 0f && num835 < 0f) + npc.velocity.Y -= num833; + } + } - vector83 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num834 = player.position.X + (player.width / 2) - vector83.X; - num835 = player.position.Y + (player.height / 2) - vector83.Y; + vector83 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num834 = player.position.X + (player.width / 2) - vector83.X; + num835 = player.position.Y + (player.height / 2) - vector83.Y; int shootRate = wormAlive ? 200 : 100; npc.localAI[1]++; @@ -2466,14 +2466,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas } npc.ai[2] += 1f; - if (npc.ai[2] >= 240f) - { - npc.ai[1] = -1f; - npc.TargetClosest(); - npc.netUpdate = true; + if (npc.ai[2] >= 240f) + { + npc.ai[1] = -1f; + npc.TargetClosest(); + npc.netUpdate = true; } } - } + } } #endregion } @@ -2716,12 +2716,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas Dust.QuickDustLine(npc.Center, initialRitualPosition, 500f, Color.Red); npc.Center = initialRitualPosition; - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - DropHelper.DropBags(npc); + DropHelper.DropBags(npc); - // Only drops in Malice because this is Leviathan's item - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); + // Only drops in Malice because this is Leviathan's item + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); // Levi drops directly from the boss so that you cannot obtain it by difficulty swapping bags // It is one of extremely few Deathmode exclusive drops in the game @@ -2745,11 +2745,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas DropHelper.WeightStack(w) ); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); - // SCal vanity set (This drops all at once, or not at all) - if (Main.rand.NextBool(7)) + // SCal vanity set (This drops all at once, or not at all) + if (Main.rand.NextBool(7)) { DropHelper.DropItem(npc, ModContent.ItemType()); DropHelper.DropItem(npc, ModContent.ItemType()); @@ -2836,47 +2836,47 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - public override Color? GetAlpha(Color drawColor) - { - if (willCharge) - return drawColor * npc.Opacity * 0.45f; - return null; - } + public override Color? GetAlpha(Color drawColor) + { + if (willCharge) + return drawColor * npc.Opacity * 0.45f; + return null; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = CalamityWorld.downedSCal && !BossRushEvent.BossRushActive ? Main.npcTexture[npc.type] : ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SupremeCalamitasHooded"); + Texture2D texture2D15 = CalamityWorld.downedSCal && !BossRushEvent.BossRushActive ? Main.npcTexture[npc.type] : ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SupremeCalamitasHooded"); Vector2 vector11 = new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[npc.type] / 2f); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 7; Rectangle frame = texture2D15.Frame(2, Main.npcFrameCount[npc.type], npc.frame.Y / Main.npcFrameCount[npc.type], npc.frame.Y % Main.npcFrameCount[npc.type]); if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } bool inPhase2 = npc.ai[0] >= 3f && npc.life > npc.lifeMax * 0.01; - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); if (inPhase2) { @@ -2897,8 +2897,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas DrawForcefield(spriteBatch); DrawShield(spriteBatch); - return false; - } + return false; + } public void DrawForcefield(SpriteBatch spriteBatch) { diff --git a/NPCs/TownNPCs/DILF.cs b/NPCs/TownNPCs/DILF.cs index fa94e0f5c1..9660cea1cd 100644 --- a/NPCs/TownNPCs/DILF.cs +++ b/NPCs/TownNPCs/DILF.cs @@ -18,7 +18,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.TownNPCs { - [AutoloadHead] + [AutoloadHead] public class DILF : ModNPC { public override void SetStaticDefaults() @@ -51,13 +51,13 @@ namespace CalamityMod.NPCs.TownNPCs animationType = NPCID.Guide; } - public override void AI() - { - if (!CalamityWorld.foundHomePermafrost && !npc.homeless) - { - CalamityWorld.foundHomePermafrost = true; - } - } + public override void AI() + { + if (!CalamityWorld.foundHomePermafrost && !npc.homeless) + { + CalamityWorld.foundHomePermafrost = true; + } + } public override bool CanTownNPCSpawn(int numTownNPCs, int money) => CalamityWorld.downedCryogen; @@ -116,21 +116,21 @@ namespace CalamityMod.NPCs.TownNPCs public override void OnChatButtonClicked(bool firstButton, ref bool shop) { - if (firstButton) - { - Main.LocalPlayer.Calamity().newPermafrostInventory = false; - shop = true; - } + if (firstButton) + { + Main.LocalPlayer.Calamity().newPermafrostInventory = false; + shop = true; + } } public override void SetupShop(Chest shop, ref int nextSlot) { - shop.item[nextSlot].SetDefaults(ItemID.WarmthPotion); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); + shop.item[nextSlot].SetDefaults(ItemID.WarmthPotion); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); if (Main.LocalPlayer.discount) shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); - nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); nextSlot++; @@ -138,30 +138,30 @@ namespace CalamityMod.NPCs.TownNPCs nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); nextSlot++; - if (NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - nextSlot++; - } - if (NPC.downedChristmasIceQueen && NPC.downedChristmasTree && NPC.downedChristmasSantank) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - nextSlot++; - } + if (NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3) + { + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + } + if (NPC.downedChristmasIceQueen && NPC.downedChristmasTree && NPC.downedChristmasSantank) + { + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + } shop.item[nextSlot].SetDefaults(ModContent.ItemType()); nextSlot++; shop.item[nextSlot].SetDefaults(ItemID.SuperManaPotion); @@ -169,10 +169,10 @@ namespace CalamityMod.NPCs.TownNPCs shop.item[nextSlot].SetDefaults(ModContent.ItemType()); nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(5, 0, 0, 0); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(5, 0, 0, 0); if (Main.LocalPlayer.discount) shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); - nextSlot++; + nextSlot++; if (Main.LocalPlayer.HasItem(ModContent.ItemType())) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); diff --git a/NPCs/TownNPCs/FAP.cs b/NPCs/TownNPCs/FAP.cs index 6d0e62bbb9..600cbca370 100644 --- a/NPCs/TownNPCs/FAP.cs +++ b/NPCs/TownNPCs/FAP.cs @@ -46,20 +46,20 @@ namespace CalamityMod.NPCs.TownNPCs animationType = NPCID.Guide; } - public override void AI() - { - if (!CalamityWorld.spawnedCirrus) - { - CalamityWorld.spawnedCirrus = true; - } - } + public override void AI() + { + if (!CalamityWorld.spawnedCirrus) + { + CalamityWorld.spawnedCirrus = true; + } + } public override bool CanTownNPCSpawn(int numTownNPCs, int money) { for (int k = 0; k < Main.maxPlayers; k++) { Player player = Main.player[k]; - bool hasVodka = player.InventoryHas(ModContent.ItemType())/* || player.PortableStorageHas(ModContent.ItemType())*/; + bool hasVodka = player.InventoryHas(ModContent.ItemType())/* || player.PortableStorageHas(ModContent.ItemType())*/; if (player.active && hasVodka) { return Main.hardMode || CalamityWorld.spawnedCirrus; @@ -86,11 +86,11 @@ namespace CalamityMod.NPCs.TownNPCs return "Have any spare rooms available? Preferably candle-lit with a hefty supply of booze?"; } - int wife = NPC.FindFirstNPC(NPCID.Stylist); - bool wifeIsAround = wife != -1; - bool beLessDrunk = wifeIsAround && NPC.downedMoonlord; + int wife = NPC.FindFirstNPC(NPCID.Stylist); + bool wifeIsAround = wife != -1; + bool beLessDrunk = wifeIsAround && NPC.downedMoonlord; - if (Main.bloodMoon) + if (Main.bloodMoon) { int random = Main.rand.Next(4); if (random == 0) @@ -114,31 +114,31 @@ namespace CalamityMod.NPCs.TownNPCs IList dialogue = new List(); - if (wifeIsAround) - { - dialogue.Add("You can't stop me from trying to move in with " + Main.npc[wife].GivenName + "."); - dialogue.Add("I love it when " + Main.npc[wife].GivenName + "'s hands get sticky from all that... wax."); - dialogue.Add(Main.npc[wife].GivenName + " works wonders for my hair... among other things."); - dialogue.Add("Ever since " + Main.npc[wife].GivenName + " moved in I haven't been drinking as much... a strange but not unwelcome feeling."); - } - - if (Main.dayTime) + if (wifeIsAround) { - if (beLessDrunk) - dialogue.Add(Main.npc[wife].GivenName + " helped me learn to accept my past. It's been rough, but I think I'm on the right track now."); - else - dialogue.Add("I drink to forget certain... things. What things, you might ask? Well, the point is to forget them, isn't it?"); + dialogue.Add("You can't stop me from trying to move in with " + Main.npc[wife].GivenName + "."); + dialogue.Add("I love it when " + Main.npc[wife].GivenName + "'s hands get sticky from all that... wax."); + dialogue.Add(Main.npc[wife].GivenName + " works wonders for my hair... among other things."); + dialogue.Add("Ever since " + Main.npc[wife].GivenName + " moved in I haven't been drinking as much... a strange but not unwelcome feeling."); + } + + if (Main.dayTime) + { + if (beLessDrunk) + dialogue.Add(Main.npc[wife].GivenName + " helped me learn to accept my past. It's been rough, but I think I'm on the right track now."); + else + dialogue.Add("I drink to forget certain... things. What things, you might ask? Well, the point is to forget them, isn't it?"); dialogue.Add("I'm literally balls drunk off my sass right now, what do you want?"); dialogue.Add("I'm either laughing because I'm drunk or because I've lost my mind, probably both."); dialogue.Add("When I'm drunk I'm way happier... at least until the talking worms start to appear."); dialogue.Add("I should reprogram the whole mod, while drunk, then send it back to the testers."); - if (beLessDrunk) - dialogue.Add("Might go out for a jog later with " + Main.npc[wife].GivenName + ". Nice day for it."); - else - dialogue.Add("What a great day! Might just drink so much that I get poisoned again."); - } + if (beLessDrunk) + dialogue.Add("Might go out for a jog later with " + Main.npc[wife].GivenName + ". Nice day for it."); + else + dialogue.Add("What a great day! Might just drink so much that I get poisoned again."); + } else { dialogue.Add("A perfect night to light some candles, drink some wine and relax."); @@ -147,16 +147,16 @@ namespace CalamityMod.NPCs.TownNPCs dialogue.Add("You lost or something? I don't mind company, but I'd rather be left alone at night."); dialogue.Add("Are you sure you're 21? ...Alright, fine, but don't tell anyone I sold you these."); - if (wifeIsAround) - dialogue.Add("I should watch some movies with " + Main.npc[wife].GivenName + " tonight. You could come too, but only if you bring snacks for us."); - } + if (wifeIsAround) + dialogue.Add("I should watch some movies with " + Main.npc[wife].GivenName + " tonight. You could come too, but only if you bring snacks for us."); + } - dialogue.Add("I HATE WALMART! ...Anyway, what do you want this time?"); - dialogue.Add("Drink something that turns you into a magical flying unicorn so you can be just like me."); + dialogue.Add("I HATE WALMART! ...Anyway, what do you want this time?"); + dialogue.Add("Drink something that turns you into a magical flying unicorn so you can be just like me."); dialogue.Add("Did anyone ever tell you that large assets cause back pain? Well, they were right."); - dialogue.Add("Deals so good I'll [$$!$] myself! ...Sorry, just had a minor stroke!"); + dialogue.Add("Deals so good I'll [$$!$] myself! ...Sorry, just had a minor stroke!"); - if (BirthdayParty.PartyIsUp) + if (BirthdayParty.PartyIsUp) dialogue.Add("You'll always find me at parties where booze is involved... well, you'll always find BOOZE where I'M involved!"); if (Main.invasionType == InvasionID.MartianMadness) @@ -171,7 +171,7 @@ namespace CalamityMod.NPCs.TownNPCs if (NPC.downedMoonlord) dialogue.Add("Ever wondered why the Moon Lord needed so many tentacles? Uh... on second thought, I won't answer that."); - if (CalamityWorld.rainingAcid) + if (CalamityWorld.rainingAcid) dialogue.Add("I'm melting! Put a stop to this inclement weather this instant before it ruins my hair!"); if (CalamityWorld.downedPolterghast) @@ -180,11 +180,11 @@ namespace CalamityMod.NPCs.TownNPCs if (CalamityWorld.downedDoG) dialogue.Add("I hear it's amazing when the famous Devourer of Gods out in flap-jaw space, with the tuning fork, does a raw blink on Hara-kiri rock. I need scissors! 61!"); - int tavernKeep = NPC.FindFirstNPC(NPCID.DD2Bartender); + int tavernKeep = NPC.FindFirstNPC(NPCID.DD2Bartender); if (tavernKeep != -1) { - dialogue.Add("I've had to tell baldie where my eyes are so many times that I've lost count."); - dialogue.Add("Tell " + Main.npc[tavernKeep].GivenName + " to stop calling me. He's not wanted."); + dialogue.Add("I've had to tell baldie where my eyes are so many times that I've lost count."); + dialogue.Add("Tell " + Main.npc[tavernKeep].GivenName + " to stop calling me. He's not wanted."); dialogue.Add("My booze will always be better than " + Main.npc[tavernKeep].GivenName + "'s, and nobody can convince me otherwise."); } @@ -192,11 +192,11 @@ namespace CalamityMod.NPCs.TownNPCs if (permadong != -1) dialogue.Add("I never realized how well-endowed " + Main.npc[permadong].GivenName + " was. It had to be the largest icicle I'd ever seen."); - int witch = NPC.FindFirstNPC(ModContent.NPCType()); - if (witch != -1) - dialogue.Add("The abuse " + Main.npc[witch].GivenName + " went through is something I can hardly comprehend. I'd offer her a drink, but I don't think she'd enjoy it."); + int witch = NPC.FindFirstNPC(ModContent.NPCType()); + if (witch != -1) + dialogue.Add("The abuse " + Main.npc[witch].GivenName + " went through is something I can hardly comprehend. I'd offer her a drink, but I don't think she'd enjoy it."); - if (Main.player[Main.myPlayer].Calamity().chibii) + if (Main.player[Main.myPlayer].Calamity().chibii) dialogue.Add("The hell is that? Looks like something I'd carry around if I was 5 years old."); if (Main.player[Main.myPlayer].Calamity().sirenBoobs && !Main.player[Main.myPlayer].Calamity().sirenBoobsHide) @@ -212,46 +212,46 @@ namespace CalamityMod.NPCs.TownNPCs dialogue.Add("Before you ask, no, I do NOT have a heart on my butt while in human form. Don't question my transformation preferences!"); } - IList donorList = new List(CalamityLists.donatorList); - int maxDonorsListed = 15; - string[] donors = new string[maxDonorsListed]; - for (int i = 0; i < maxDonorsListed; i++) - { - donors[i] = donorList[Main.rand.Next(donorList.Count)]; - donorList.Remove(donors[i]); - } + IList donorList = new List(CalamityLists.donatorList); + int maxDonorsListed = 15; + string[] donors = new string[maxDonorsListed]; + for (int i = 0; i < maxDonorsListed; i++) + { + donors[i] = donorList[Main.rand.Next(donorList.Count)]; + donorList.Remove(donors[i]); + } - dialogue.Add("Hey " + donors[0] + ", " + donors[1] + ", " + donors[2] + ", " + donors[3] + ", " + donors[4] + ", " + donors[5] + ", " + donors[6] + - ", " + donors[7] + ", " + donors[8] + ", " + donors[9] + ", " + donors[10] + ", " + donors[11] + ", " + donors[12] + ", " + donors[13] + - " and " + donors[14] + "! You're all pretty good!"); + dialogue.Add("Hey " + donors[0] + ", " + donors[1] + ", " + donors[2] + ", " + donors[3] + ", " + donors[4] + ", " + donors[5] + ", " + donors[6] + + ", " + donors[7] + ", " + donors[8] + ", " + donors[9] + ", " + donors[10] + ", " + donors[11] + ", " + donors[12] + ", " + donors[13] + + " and " + donors[14] + "! You're all pretty good!"); return dialogue[Main.rand.Next(dialogue.Count)]; } - public string Death() - { - int deaths = Main.player[Main.myPlayer].Calamity().deathCount; + public string Death() + { + int deaths = Main.player[Main.myPlayer].Calamity().deathCount; - string text = "You have failed " + Main.player[Main.myPlayer].Calamity().deathCount + - (Main.player[Main.myPlayer].Calamity().deathCount == 1 ? " time." : " times."); + string text = "You have failed " + Main.player[Main.myPlayer].Calamity().deathCount + + (Main.player[Main.myPlayer].Calamity().deathCount == 1 ? " time." : " times."); - if (deaths > 10000) - text += " Congratulations! You are now, officially, the biggest loser in Terraria's history! Who was number two? Hell if I know."; - else if (deaths > 5000) - text += " I'm not sure what to say this time. That you're bad and should feel bad? That much was known already."; - else if (deaths > 2500) - text += " Bless your heart. I could dodge better than you even if I were drunk high."; - else if (deaths > 1000) - text += " It is said the average Terrarian has a lifespan of 2 minutes or less. ...Well, not really, but I feel like you'd be part of that statistic."; - else if (deaths > 500) - text += " Your inability to avoid dying to even the most basic of attacks is astonishing to me."; - else if (deaths > 250) - text += " I admire your tenacity. Keep it up, your enemies are racking up quite the kill count!"; - else if (deaths > 100) - text += " Consider lowering the difficulty. If you found that statement irritating, good."; + if (deaths > 10000) + text += " Congratulations! You are now, officially, the biggest loser in Terraria's history! Who was number two? Hell if I know."; + else if (deaths > 5000) + text += " I'm not sure what to say this time. That you're bad and should feel bad? That much was known already."; + else if (deaths > 2500) + text += " Bless your heart. I could dodge better than you even if I were drunk high."; + else if (deaths > 1000) + text += " It is said the average Terrarian has a lifespan of 2 minutes or less. ...Well, not really, but I feel like you'd be part of that statistic."; + else if (deaths > 500) + text += " Your inability to avoid dying to even the most basic of attacks is astonishing to me."; + else if (deaths > 250) + text += " I admire your tenacity. Keep it up, your enemies are racking up quite the kill count!"; + else if (deaths > 100) + text += " Consider lowering the difficulty. If you found that statement irritating, good."; - return text; - } + return text; + } public override void SetChatButtons(ref string button, ref string button2) { @@ -263,8 +263,8 @@ namespace CalamityMod.NPCs.TownNPCs { if (firstButton) { - Main.LocalPlayer.Calamity().newCirrusInventory = false; - shop = true; + Main.LocalPlayer.Calamity().newCirrusInventory = false; + shop = true; } else { @@ -275,22 +275,22 @@ namespace CalamityMod.NPCs.TownNPCs public override void SetupShop(Chest shop, ref int nextSlot) //charges 50% extra than the original alcohol value { - // All prices are manually set. This means the Discount Card does not work. - // Cirrus doesn't accept your card. - shop.item[nextSlot].SetDefaults(ItemID.HeartreachPotion); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); - nextSlot++; + // All prices are manually set. This means the Discount Card does not work. + // Cirrus doesn't accept your card. + shop.item[nextSlot].SetDefaults(ItemID.HeartreachPotion); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.LifeforcePotion); - int goldCost = NPC.downedMoonlord ? 8 : 4; - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, goldCost, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ItemID.LifeforcePotion); + int goldCost = NPC.downedMoonlord ? 8 : 4; + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, goldCost, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.LovePotion); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ItemID.LovePotion); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 0, 30, 0); nextSlot++; @@ -298,95 +298,95 @@ namespace CalamityMod.NPCs.TownNPCs shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 3, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 3, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 4, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 4, 0, 0); + nextSlot++; - if (NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); - nextSlot++; + if (NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3) + { + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 6, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 6, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 6, 0, 0); - nextSlot++; - } + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 6, 0, 0); + nextSlot++; + } - if (NPC.downedPlantBoss) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 8, 0, 0); - nextSlot++; + if (NPC.downedPlantBoss) + { + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 8, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 8, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 8, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 8, 0, 0); - nextSlot++; - } + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 8, 0, 0); + nextSlot++; + } if (CalamityWorld.downedAstrageldon) { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 3, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 3, 0, 0); + nextSlot++; - if (Main.bloodMoon) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 4, 0, 0); - nextSlot++; - } + if (Main.bloodMoon) + { + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 4, 0, 0); + nextSlot++; + } - if (!Main.dayTime) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 6, 0, 0); - nextSlot++; - } - } + if (!Main.dayTime) + { + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 6, 0, 0); + nextSlot++; + } + } - if (NPC.downedGolemBoss) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); - nextSlot++; + if (NPC.downedGolemBoss) + { + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 8, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 8, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 8, 0, 0); - nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 8, 0, 0); + nextSlot++; - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 10, 0, 0); - nextSlot++; - } + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 10, 0, 0); + nextSlot++; + } shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 50, 0, 0); diff --git a/NPCs/TownNPCs/SEAHOE.cs b/NPCs/TownNPCs/SEAHOE.cs index af01e4a9e3..efb0c200f8 100644 --- a/NPCs/TownNPCs/SEAHOE.cs +++ b/NPCs/TownNPCs/SEAHOE.cs @@ -14,7 +14,7 @@ using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.NPCs.TownNPCs { - [AutoloadHead] + [AutoloadHead] public class SEAHOE : ModNPC { public override void SetStaticDefaults() @@ -104,15 +104,15 @@ namespace CalamityMod.NPCs.TownNPCs int cirrus = NPC.FindFirstNPC(ModContent.NPCType()); if (cirrus != -1) - { + { dialogue.Add("Rumor has it " + Main.npc[cirrus].GivenName + " drinks to forget her troubled past."); - } + } - int witch = NPC.FindFirstNPC(ModContent.NPCType()); - if (witch != -1) - { - dialogue.Add("I must admit, the Witch's presence is unsettling to me. But so many years have passed, and she too has suffered much."); - } + int witch = NPC.FindFirstNPC(ModContent.NPCType()); + if (witch != -1) + { + dialogue.Add("I must admit, the Witch's presence is unsettling to me. But so many years have passed, and she too has suffered much."); + } if (Main.bloodMoon) { @@ -144,169 +144,169 @@ namespace CalamityMod.NPCs.TownNPCs { IList dialogue = new List(); string worldEvil = WorldGen.crimson ? "Crimson" : "Corruption"; - string displayThisText = "If this shows up, something went wrong."; + string displayThisText = "If this shows up, something went wrong."; if (CalamityWorld.downedYharon) { - switch (npc.Calamity().newAI[0] % 3f) - { - case 0f: - displayThisText = "Pockets of ore have appeared once more in the land. This will allow you to create the most powerful weaponry and armor imagined!"; - break; - case 1f: - displayThisText = "Lord Yharim possesses god-like strength. He may not even fight you at full power which is fortunate for you. His attacks may just kill you in one hit, so be careful."; - break; - case 2f: - displayThisText = "Draedon's style of confrontation is very... alien and hands-off. You may be more likely to fight any one of his mechs before taking him down."; - break; - } + switch (npc.Calamity().newAI[0] % 3f) + { + case 0f: + displayThisText = "Pockets of ore have appeared once more in the land. This will allow you to create the most powerful weaponry and armor imagined!"; + break; + case 1f: + displayThisText = "Lord Yharim possesses god-like strength. He may not even fight you at full power which is fortunate for you. His attacks may just kill you in one hit, so be careful."; + break; + case 2f: + displayThisText = "Draedon's style of confrontation is very... alien and hands-off. You may be more likely to fight any one of his mechs before taking him down."; + break; + } } else if (CalamityWorld.downedDoG) { - switch (npc.Calamity().newAI[0] % 3f) - { - case 0f: - displayThisText = "The Devourer of God's cosmic armor is unique in that it is capable of not only protecting his body from tearing itself apart when ripping through the fabric of space and time, but also allows him to control his powers."; - break; - case 1f: - displayThisText = "With the cosmic steel you can fashion many of your weapons into much more powerful forms."; - break; - case 2f: - displayThisText = "The Devourer of Gods is extremely powerful. However, he is young, foolhardy, and very lazy. Perhaps if he had been given time to develop he would have turned into quite the threat."; - break; - } + switch (npc.Calamity().newAI[0] % 3f) + { + case 0f: + displayThisText = "The Devourer of God's cosmic armor is unique in that it is capable of not only protecting his body from tearing itself apart when ripping through the fabric of space and time, but also allows him to control his powers."; + break; + case 1f: + displayThisText = "With the cosmic steel you can fashion many of your weapons into much more powerful forms."; + break; + case 2f: + displayThisText = "The Devourer of Gods is extremely powerful. However, he is young, foolhardy, and very lazy. Perhaps if he had been given time to develop he would have turned into quite the threat."; + break; + } } else if (CalamityWorld.downedPolterghast) { - switch (npc.Calamity().newAI[0] % 2f) - { - case 0f: - displayThisText = "The Abyss holds many secrets revealed with time. Checking it out again may not be a bad idea."; - break; - case 1f: - displayThisText = "Ah... I can sense a powerful change in the weather. You may want to venture to the Sulphurous Seas once more during the rain to experience it."; - break; - } + switch (npc.Calamity().newAI[0] % 2f) + { + case 0f: + displayThisText = "The Abyss holds many secrets revealed with time. Checking it out again may not be a bad idea."; + break; + case 1f: + displayThisText = "Ah... I can sense a powerful change in the weather. You may want to venture to the Sulphurous Seas once more during the rain to experience it."; + break; + } } else if (CalamityWorld.downedProvidence) { - switch (npc.Calamity().newAI[0] % 3f) - { - case 0f: - displayThisText = "The Rune of Kos holds a significant portion of Providence's brand of magic, easily distinguishable from all others. Activating it in certain places would have some... risky consequences."; - break; - case 1f: - displayThisText = "Ironic, is it not, that Statis was defeated by the very Sentinel his people fashioned their art of stealth from. Fate so often weaves cruel tales."; - break; - case 2f: - displayThisText = "The Dungeon seems to be more active now. You may hear the faint whisperings of angry spirits who have not left to the Void... I would recommend searching there before taking on the Sentinels."; - break; - } + switch (npc.Calamity().newAI[0] % 3f) + { + case 0f: + displayThisText = "The Rune of Kos holds a significant portion of Providence's brand of magic, easily distinguishable from all others. Activating it in certain places would have some... risky consequences."; + break; + case 1f: + displayThisText = "Ironic, is it not, that Statis was defeated by the very Sentinel his people fashioned their art of stealth from. Fate so often weaves cruel tales."; + break; + case 2f: + displayThisText = "The Dungeon seems to be more active now. You may hear the faint whisperings of angry spirits who have not left to the Void... I would recommend searching there before taking on the Sentinels."; + break; + } } else if (NPC.downedMoonlord) { - switch (npc.Calamity().newAI[0] % 6f) - { - case 0f: - displayThisText = "Your adventure focuses to the jungle it seems. The Dragonfolly and its swarming offspring should be eliminated before their numbers spiral out of control."; - break; - case 1f: - displayThisText = "Profaned creatures now lurk in the Hallow and in Hell. If you destroy enough and gather their essence together you shall be able to capture the attention of the Profaned Guardians."; - break; - case 2f: - displayThisText = "The Profaned Guardians will do anything to protect their goddess. Makes sense they would die for her since they can be revived just as quickly."; - break; - case 3f: - displayThisText = "Touching Providence's offerings is usually a death wish. Shame that Yharim didn't think to just mess with her things to get her out of hiding."; - break; - case 4f: - displayThisText = "Providence is as much the sun goddess as much as the Moon Lord is the moon god. They are two sides of the same coin, choosing to remain neutral amongst our petty squabbles."; - break; - case 5f: - displayThisText = "The stories have it that when Providence faced and defeated Yharim and his forces she lost a lot of energy and reverted to a more skeletal form. She's merely a fraction of the power she was before."; - break; - } + switch (npc.Calamity().newAI[0] % 6f) + { + case 0f: + displayThisText = "Your adventure focuses to the jungle it seems. The Dragonfolly and its swarming offspring should be eliminated before their numbers spiral out of control."; + break; + case 1f: + displayThisText = "Profaned creatures now lurk in the Hallow and in Hell. If you destroy enough and gather their essence together you shall be able to capture the attention of the Profaned Guardians."; + break; + case 2f: + displayThisText = "The Profaned Guardians will do anything to protect their goddess. Makes sense they would die for her since they can be revived just as quickly."; + break; + case 3f: + displayThisText = "Touching Providence's offerings is usually a death wish. Shame that Yharim didn't think to just mess with her things to get her out of hiding."; + break; + case 4f: + displayThisText = "Providence is as much the sun goddess as much as the Moon Lord is the moon god. They are two sides of the same coin, choosing to remain neutral amongst our petty squabbles."; + break; + case 5f: + displayThisText = "The stories have it that when Providence faced and defeated Yharim and his forces she lost a lot of energy and reverted to a more skeletal form. She's merely a fraction of the power she was before."; + break; + } } else if (NPC.downedGolemBoss) { - switch (npc.Calamity().newAI[0] % 3f) - { - case 0f: - displayThisText = "The men at the front of the dungeon are performing a ritual to keep the Moon Lord contained in his prison. In order to gain Yharim's attention, however, you may need to defeat them."; - break; - case 1f: - displayThisText = "The Abyss has become far more active than before. You might be able to mine some of the volcanic rubble contained within."; - break; - case 2f: - displayThisText = "The plague was just one of the many experiments authorized by Yharim to raze towns to the ground. This is probably one of the few he shelved for being too terrible."; - break; - } + switch (npc.Calamity().newAI[0] % 3f) + { + case 0f: + displayThisText = "The men at the front of the dungeon are performing a ritual to keep the Moon Lord contained in his prison. In order to gain Yharim's attention, however, you may need to defeat them."; + break; + case 1f: + displayThisText = "The Abyss has become far more active than before. You might be able to mine some of the volcanic rubble contained within."; + break; + case 2f: + displayThisText = "The plague was just one of the many experiments authorized by Yharim to raze towns to the ground. This is probably one of the few he shelved for being too terrible."; + break; + } } else if (Main.hardMode) { - switch (npc.Calamity().newAI[0] % 8f) - { - case 0f: - displayThisText = !CalamityWorld.downedCryogen ? "Have you heard of the story of Archmage Permafrost? Rumor has it he's been locked away in an icy prison by Lord Yharim. Perhaps you would be able to free him if Cryogen was destroyed." : "You will find more ores have been unlocked due to the magic sealing them away being dispelled. Some of them may require more than just the ore itself to create."; - break; - case 1f: - displayThisText = "I would recommend saving some of your old items. You never know if you can engineer them into stronger weapons in the future."; - break; - case 2f: - displayThisText = "Once those mechanical creations have been defeated you would do well to seek out the crippled clone of the witch, Calamitas. It might provide some useful weaponry."; - break; - case 3f: - displayThisText = "If you take an idol down to the Brimstone Crags you might be able to see just what is lurking in the shadows."; - break; - case 4f: - displayThisText = "The Brimstone Crags... Yharim despised that place, and did everything he could to raze it to the ground. It might explain a few things about him."; - break; - case 5f: - displayThisText = "If you've gathered the souls used to power those automatons head once more to the jungle. You will find a powerful enemy to fight, which will unleash the full fervor of the jungle once defeated. Do not underestimate it!"; - break; - case 6f: - displayThisText = "Be careful when defeating Plantera and the Golem. You might accidentally unleash a new threat in the jungle that needs to be quelled."; - break; - case 7f: - displayThisText = "When exploring the jungle temple be careful. You may not wish to disturb the Lihzahrd's idol, the Golem. It's quite the destructive force."; - break; - } + switch (npc.Calamity().newAI[0] % 8f) + { + case 0f: + displayThisText = !CalamityWorld.downedCryogen ? "Have you heard of the story of Archmage Permafrost? Rumor has it he's been locked away in an icy prison by Lord Yharim. Perhaps you would be able to free him if Cryogen was destroyed." : "You will find more ores have been unlocked due to the magic sealing them away being dispelled. Some of them may require more than just the ore itself to create."; + break; + case 1f: + displayThisText = "I would recommend saving some of your old items. You never know if you can engineer them into stronger weapons in the future."; + break; + case 2f: + displayThisText = "Once those mechanical creations have been defeated you would do well to seek out the crippled clone of the witch, Calamitas. It might provide some useful weaponry."; + break; + case 3f: + displayThisText = "If you take an idol down to the Brimstone Crags you might be able to see just what is lurking in the shadows."; + break; + case 4f: + displayThisText = "The Brimstone Crags... Yharim despised that place, and did everything he could to raze it to the ground. It might explain a few things about him."; + break; + case 5f: + displayThisText = "If you've gathered the souls used to power those automatons head once more to the jungle. You will find a powerful enemy to fight, which will unleash the full fervor of the jungle once defeated. Do not underestimate it!"; + break; + case 6f: + displayThisText = "Be careful when defeating Plantera and the Golem. You might accidentally unleash a new threat in the jungle that needs to be quelled."; + break; + case 7f: + displayThisText = "When exploring the jungle temple be careful. You may not wish to disturb the Lihzahrd's idol, the Golem. It's quite the destructive force."; + break; + } } else { - switch (npc.Calamity().newAI[0] % 10f) - { - case 0f: - displayThisText = "There are rumors of ores that lay in latency. When you defeat certain bosses you will undo the ancient magic which conceals those materials."; - break; - case 1f: - displayThisText = "Have you heard of the Brimstone Crags? It was once a grand kingdom, not too different from my own. However, it also met a similar fate. I would not advise going down there, unless you seek a painful death."; - break; - case 2f: - displayThisText = "Ah yes, the Abyss. That trench is full of powerful creatures that could devour you in a heartbeat. I would explore the dungeon first."; - break; - case 3f: - displayThisText = "The Sulphurous Seas are dangerous. The toxic waters will burn your skin, but if you can brave them you will be able to reach the Abyss, where there are powerful weapons and dangers aplenty."; - break; - case 4f: - displayThisText = "The Sulphurous Seas were created long ago, when Yharim's dungeon could no longer hold as many corpses as it needed to. Many of the bodies were dumped into the ocean. This, along with severe pollution from the heydays of Draedon's experiments have turned a paradise into a wasteland."; - break; - case 5f: - displayThisText = "Be careful what you attack in the " + worldEvil + ". You might just unveil a greater threat than what was there before."; - break; - case 6f: - displayThisText = "Scattered across the lands are shrines dedicated to the gods. They contain powerful gear that may help you on your adventures."; - break; - case 7f: - displayThisText = "I'm assuming you've heard the legends that speak of the ninja, Statis? There are some who say that if you were able to defeat the gods which his clan once worshipped you would be able to harness some of his powers."; - break; - case 8f: - displayThisText = "The " + worldEvil + " used to be easily manageable and controlled by nature. However, the recent wars and pollution have tipped the balance out of favor."; - break; - case 9f: - displayThisText = "Throughout the world lie various structures left behind by Draedon. Archaic defenses may remain, but the goods inside may be worth your while."; - break; - } + switch (npc.Calamity().newAI[0] % 10f) + { + case 0f: + displayThisText = "There are rumors of ores that lay in latency. When you defeat certain bosses you will undo the ancient magic which conceals those materials."; + break; + case 1f: + displayThisText = "Have you heard of the Brimstone Crags? It was once a grand kingdom, not too different from my own. However, it also met a similar fate. I would not advise going down there, unless you seek a painful death."; + break; + case 2f: + displayThisText = "Ah yes, the Abyss. That trench is full of powerful creatures that could devour you in a heartbeat. I would explore the dungeon first."; + break; + case 3f: + displayThisText = "The Sulphurous Seas are dangerous. The toxic waters will burn your skin, but if you can brave them you will be able to reach the Abyss, where there are powerful weapons and dangers aplenty."; + break; + case 4f: + displayThisText = "The Sulphurous Seas were created long ago, when Yharim's dungeon could no longer hold as many corpses as it needed to. Many of the bodies were dumped into the ocean. This, along with severe pollution from the heydays of Draedon's experiments have turned a paradise into a wasteland."; + break; + case 5f: + displayThisText = "Be careful what you attack in the " + worldEvil + ". You might just unveil a greater threat than what was there before."; + break; + case 6f: + displayThisText = "Scattered across the lands are shrines dedicated to the gods. They contain powerful gear that may help you on your adventures."; + break; + case 7f: + displayThisText = "I'm assuming you've heard the legends that speak of the ninja, Statis? There are some who say that if you were able to defeat the gods which his clan once worshipped you would be able to harness some of his powers."; + break; + case 8f: + displayThisText = "The " + worldEvil + " used to be easily manageable and controlled by nature. However, the recent wars and pollution have tipped the balance out of favor."; + break; + case 9f: + displayThisText = "Throughout the world lie various structures left behind by Draedon. Archaic defenses may remain, but the goods inside may be worth your while."; + break; + } } return displayThisText; @@ -323,14 +323,14 @@ namespace CalamityMod.NPCs.TownNPCs { if (firstButton) { - Main.LocalPlayer.Calamity().newAmidiasInventory = false; - shop = true; + Main.LocalPlayer.Calamity().newAmidiasInventory = false; + shop = true; } else { shop = false; Main.npcChatText = Lore(); - npc.Calamity().newAI[0]++; + npc.Calamity().newAI[0]++; Player player = Main.player[Main.myPlayer]; player.AddBuff(ModContent.BuffType(), 36000); } @@ -357,34 +357,34 @@ namespace CalamityMod.NPCs.TownNPCs shop.item[nextSlot].SetDefaults(ModContent.ItemType()); nextSlot++; shop.item[nextSlot].SetDefaults(ItemID.GillsPotion); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); if (Main.LocalPlayer.discount) shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.WaterWalkingPotion); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + nextSlot++; + shop.item[nextSlot].SetDefaults(ItemID.WaterWalkingPotion); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); if (Main.LocalPlayer.discount) shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.FlipperPotion); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + nextSlot++; + shop.item[nextSlot].SetDefaults(ItemID.FlipperPotion); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); if (Main.LocalPlayer.discount) shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); - nextSlot++; + nextSlot++; if (NPC.downedFishron) { shop.item[nextSlot].SetDefaults(ItemID.TruffleWorm); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 10, 0, 0); - if (Main.LocalPlayer.discount) - shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); + if (Main.LocalPlayer.discount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); nextSlot++; } if (CalamityWorld.downedBoomerDuke) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(2, 0, 0, 0); - if (Main.LocalPlayer.discount) - shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); + if (Main.LocalPlayer.discount) + shop.item[nextSlot].shopCustomPrice = (int)(shop.item[nextSlot].shopCustomPrice * 0.8); nextSlot++; } } diff --git a/NPCs/TownNPCs/THIEF.cs b/NPCs/TownNPCs/THIEF.cs index 7210b389a4..64d7f5f184 100644 --- a/NPCs/TownNPCs/THIEF.cs +++ b/NPCs/TownNPCs/THIEF.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.TownNPCs { // Patron names "Xplizzy", // <@!98826096237109248> Whitegiraffe#6342 - "Freakish", // <@!750363283520749598> Freakish#0001 + "Freakish", // <@!750363283520749598> Freakish#0001 // Original names "Laura", "Mie", "Bonnie", @@ -63,20 +63,20 @@ namespace CalamityMod.NPCs.TownNPCs animationType = NPCID.PartyGirl; } - public override void AI() - { - if (!CalamityWorld.spawnedBandit) - { - CalamityWorld.spawnedBandit = true; - } - } + public override void AI() + { + if (!CalamityWorld.spawnedBandit) + { + CalamityWorld.spawnedBandit = true; + } + } public override bool CanTownNPCSpawn(int numTownNPCs, int money) { for (int k = 0; k < Main.maxPlayers; k++) { Player player = Main.player[k]; - bool rich = player.InventoryHas(ItemID.PlatinumCoin) || player.PortableStorageHas(ItemID.PlatinumCoin); + bool rich = player.InventoryHas(ItemID.PlatinumCoin) || player.PortableStorageHas(ItemID.PlatinumCoin); if (player.active && rich) { return NPC.downedBoss3 || CalamityWorld.spawnedBandit; @@ -232,8 +232,8 @@ namespace CalamityMod.NPCs.TownNPCs { if (firstButton) { - Main.LocalPlayer.Calamity().newBanditInventory = false; - shop = true; + Main.LocalPlayer.Calamity().newBanditInventory = false; + shop = true; } else { @@ -244,8 +244,8 @@ namespace CalamityMod.NPCs.TownNPCs public override void SetupShop(Chest shop, ref int nextSlot) { - // All prices are manually set. This means the Discount Card does not work. - // The Bandit doesn't believe in discounts. + // All prices are manually set. This means the Discount Card does not work. + // The Bandit doesn't believe in discounts. shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 9, 0, 0); nextSlot++; @@ -261,19 +261,19 @@ namespace CalamityMod.NPCs.TownNPCs shop.item[nextSlot].SetDefaults(ItemID.TigerClimbingGear); shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.InvisibilityPotion); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.NightOwlPotion); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); - nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.TrapsightPotion); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); - nextSlot++; - if (CalamityWorld.downedSlimeGod) + shop.item[nextSlot].SetDefaults(ItemID.InvisibilityPotion); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + nextSlot++; + shop.item[nextSlot].SetDefaults(ItemID.NightOwlPotion); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + nextSlot++; + shop.item[nextSlot].SetDefaults(ItemID.TrapsightPotion); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); + nextSlot++; + if (CalamityWorld.downedSlimeGod) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; } if (Main.hardMode) @@ -295,38 +295,38 @@ namespace CalamityMod.NPCs.TownNPCs nextSlot++; } if (NPC.downedMechBossAny) - { + { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; - nextSlot++; + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; + nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; - nextSlot++; + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; + nextSlot++; } - if (CalamityWorld.downedCalamitas) - { + if (CalamityWorld.downedCalamitas) + { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; - nextSlot++; - } + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; + nextSlot++; + } if (NPC.downedPlantBoss) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; nextSlot++; } if (NPC.downedGolemBoss) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(1, 0, 0, 0); - nextSlot++; - } + { + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(1, 0, 0, 0); + nextSlot++; + } if (NPC.downedMoonlord) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); @@ -334,11 +334,11 @@ namespace CalamityMod.NPCs.TownNPCs nextSlot++; } if (CalamityWorld.downedProvidence) - { - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = Item.buyPrice(5, 0, 0, 0); - nextSlot++; - } + { + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = Item.buyPrice(5, 0, 0, 0); + nextSlot++; + } if (CalamityWorld.downedDoG) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); @@ -352,9 +352,9 @@ namespace CalamityMod.NPCs.TownNPCs nextSlot++; } //:BearWatchingYou: - shop.item[nextSlot].SetDefaults(ModContent.ItemType()); - shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; - nextSlot++; + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + shop.item[nextSlot].shopCustomPrice = shop.item[nextSlot].value; + nextSlot++; } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/TownNPCs/WITCH.cs b/NPCs/TownNPCs/WITCH.cs index 88e2c4673e..a36199b5a8 100644 --- a/NPCs/TownNPCs/WITCH.cs +++ b/NPCs/TownNPCs/WITCH.cs @@ -14,167 +14,167 @@ using SCalBoss = CalamityMod.NPCs.SupremeCalamitas.SupremeCalamitas; namespace CalamityMod.NPCs.TownNPCs { - [AutoloadHead] - public class WITCH : ModNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Brimstone Witch"); + [AutoloadHead] + public class WITCH : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brimstone Witch"); - Main.npcFrameCount[npc.type] = 27; - NPCID.Sets.ExtraFramesCount[npc.type] = 9; - NPCID.Sets.AttackFrameCount[npc.type] = 4; - NPCID.Sets.DangerDetectRange[npc.type] = 700; - NPCID.Sets.AttackType[npc.type] = 1; - NPCID.Sets.AttackTime[npc.type] = 30; - NPCID.Sets.AttackAverageChance[npc.type] = 5; - } + Main.npcFrameCount[npc.type] = 27; + NPCID.Sets.ExtraFramesCount[npc.type] = 9; + NPCID.Sets.AttackFrameCount[npc.type] = 4; + NPCID.Sets.DangerDetectRange[npc.type] = 700; + NPCID.Sets.AttackType[npc.type] = 1; + NPCID.Sets.AttackTime[npc.type] = 30; + NPCID.Sets.AttackAverageChance[npc.type] = 5; + } - public override void SetDefaults() - { - npc.townNPC = true; - npc.friendly = true; - npc.lavaImmune = true; - npc.width = 18; - npc.height = 40; - npc.aiStyle = 7; - npc.damage = 10; + public override void SetDefaults() + { + npc.townNPC = true; + npc.friendly = true; + npc.lavaImmune = true; + npc.width = 18; + npc.height = 40; + npc.aiStyle = 7; + npc.damage = 10; - // You should not be able to kill SCal under any typical circumstances. - npc.lifeMax = 1000000; + // You should not be able to kill SCal under any typical circumstances. + npc.lifeMax = 1000000; - npc.defense = 120; - npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = SoundID.NPCDeath6; - npc.knockBackResist = 0.8f; - animationType = NPCID.Wizard; - } + npc.defense = 120; + npc.HitSound = SoundID.NPCHit1; + npc.DeathSound = SoundID.NPCDeath6; + npc.knockBackResist = 0.8f; + animationType = NPCID.Wizard; + } - public override bool CanTownNPCSpawn(int numTownNPCs, int money) => CalamityWorld.downedSCal && !NPC.AnyNPCs(NPCType()); + public override bool CanTownNPCSpawn(int numTownNPCs, int money) => CalamityWorld.downedSCal && !NPC.AnyNPCs(NPCType()); - public override string TownNPCName() => "Calamitas"; + public override string TownNPCName() => "Calamitas"; - // The way this works is by having an RNG based on weights. - // With certain conditions (such as if a blood moon is happening) you can add possibilities - // to the RNG via textSelector.Add("text", weight); - // Text can always appear assuming the weight is greater than 0 and there's no if condition deciding whether it can. - // The higher the weight is, the more likely it is to be selected from all the choices. - // To give an example of this, assume you have two possibilities: - // "a" with a weight of 1, and "b" with a weight of 5. The chance of "a" being displayed would be - // 1/6, while "b" wold have a 5/6 chance of being displayed. - // If only one possibility exists it will be the only thing that is displayed, regardless of weight. - public override string GetChat() - { - WeightedRandom textSelector = new WeightedRandom(Main.rand); + // The way this works is by having an RNG based on weights. + // With certain conditions (such as if a blood moon is happening) you can add possibilities + // to the RNG via textSelector.Add("text", weight); + // Text can always appear assuming the weight is greater than 0 and there's no if condition deciding whether it can. + // The higher the weight is, the more likely it is to be selected from all the choices. + // To give an example of this, assume you have two possibilities: + // "a" with a weight of 1, and "b" with a weight of 5. The chance of "a" being displayed would be + // 1/6, while "b" wold have a 5/6 chance of being displayed. + // If only one possibility exists it will be the only thing that is displayed, regardless of weight. + public override string GetChat() + { + WeightedRandom textSelector = new WeightedRandom(Main.rand); - if (npc.homeless) - { - textSelector.Add("I'm considering moving back to that old cave of mine."); - textSelector.Add("I certainly can't return to the Tyrant's old dwellings now, have you got any places to stay?"); - } - else - { - textSelector.Add("I can't pay rent, but if you've got any dead relative you want me to try and... what? You don't?"); - textSelector.Add("One of these days, I was thinking of starting a garden with the flowers from the old capitol of hell." + - " I love the smell of brimstone in the morning."); - textSelector.Add("I think I've settled comfortably, thank you very much."); - textSelector.Add("Many seasons have gone by since I first met with the Tyrant, and only now did I break free." + - " I wish I'd been stronger..."); - textSelector.Add("If you've got any curses you want dispelled... well I'm not your person."); + if (npc.homeless) + { + textSelector.Add("I'm considering moving back to that old cave of mine."); + textSelector.Add("I certainly can't return to the Tyrant's old dwellings now, have you got any places to stay?"); + } + else + { + textSelector.Add("I can't pay rent, but if you've got any dead relative you want me to try and... what? You don't?"); + textSelector.Add("One of these days, I was thinking of starting a garden with the flowers from the old capitol of hell." + + " I love the smell of brimstone in the morning."); + textSelector.Add("I think I've settled comfortably, thank you very much."); + textSelector.Add("Many seasons have gone by since I first met with the Tyrant, and only now did I break free." + + " I wish I'd been stronger..."); + textSelector.Add("If you've got any curses you want dispelled... well I'm not your person."); - if (!Main.dayTime) - { - if (Main.bloodMoon) - { - textSelector.Add("Such an unnatural shade of red. Nothing like my brimstone flames.", 5.15); - textSelector.Add("I can't work with nights like these. The stars seem to have shrunk away in fear.", 5.15); - } - else - { - textSelector.Add("These undead are horrific, I can't stand to look at them. How could anyone be satisfied" + - " with such amateur work?", 2.8); - textSelector.Add("I don't think it's a stretch to say that astrology is utter nonsense... but it was a hobby" + - " of mine once.", 2.8); - } - } + if (!Main.dayTime) + { + if (Main.bloodMoon) + { + textSelector.Add("Such an unnatural shade of red. Nothing like my brimstone flames.", 5.15); + textSelector.Add("I can't work with nights like these. The stars seem to have shrunk away in fear.", 5.15); + } + else + { + textSelector.Add("These undead are horrific, I can't stand to look at them. How could anyone be satisfied" + + " with such amateur work?", 2.8); + textSelector.Add("I don't think it's a stretch to say that astrology is utter nonsense... but it was a hobby" + + " of mine once.", 2.8); + } + } - if (BirthdayParty.PartyIsUp) - textSelector.Add("If another person asks me if I can dance or not, I will light their hat on fire.", 5.5); + if (BirthdayParty.PartyIsUp) + textSelector.Add("If another person asks me if I can dance or not, I will light their hat on fire.", 5.5); - if (NPC.AnyNPCs(NPCType())) - { - textSelector.Add("I cannot understand the Sea King. He does not seem to want me dead. That amount of compassion" + - " I just can't understand.", 1.45); - } - if (NPC.AnyNPCs(NPCType())) - { - textSelector.Add("That frosty old man... even if you ignore our brands of magic and our old alliances, I doubt I'd ever" + - " get along with him.", 1.45); - } + if (NPC.AnyNPCs(NPCType())) + { + textSelector.Add("I cannot understand the Sea King. He does not seem to want me dead. That amount of compassion" + + " I just can't understand.", 1.45); + } + if (NPC.AnyNPCs(NPCType())) + { + textSelector.Add("That frosty old man... even if you ignore our brands of magic and our old alliances, I doubt I'd ever" + + " get along with him.", 1.45); + } - int fab = NPC.FindFirstNPC(NPCType()); - if (fab != -1) - { - textSelector.Add("I wonder if " + Main.npc[fab].GivenName + " ever feels cold given how revealing her dress is." + - " Perhaps she should cover up a bit more.", 1.45); - } - } + int fab = NPC.FindFirstNPC(NPCType()); + if (fab != -1) + { + textSelector.Add("I wonder if " + Main.npc[fab].GivenName + " ever feels cold given how revealing her dress is." + + " Perhaps she should cover up a bit more.", 1.45); + } + } - // Select a possibility from the RNG and choose it as the thing that should be said. - string thingToSay = textSelector.Get(); + // Select a possibility from the RNG and choose it as the thing that should be said. + string thingToSay = textSelector.Get(); - // Have a flat chance (1/4444) to simply ignore the above selection and say something humorous instead. - if (Main.rand.NextBool(4444)) - thingToSay = "Mrrp is cringe."; + // Have a flat chance (1/4444) to simply ignore the above selection and say something humorous instead. + if (Main.rand.NextBool(4444)) + thingToSay = "Mrrp is cringe."; - return thingToSay; - } + return thingToSay; + } - public override void SetChatButtons(ref string button, ref string button2) => button = "Enchant"; + public override void SetChatButtons(ref string button, ref string button2) => button = "Enchant"; - public override void OnChatButtonClicked(bool firstButton, ref bool shop) - { - if (firstButton) - { - Main.playerInventory = true; - Main.LocalPlayer.Calamity().newCalamitasInventory = false; - CalamitasEnchantUI.NPCIndex = npc.whoAmI; - CalamitasEnchantUI.CurrentlyViewing = true; + public override void OnChatButtonClicked(bool firstButton, ref bool shop) + { + if (firstButton) + { + Main.playerInventory = true; + Main.LocalPlayer.Calamity().newCalamitasInventory = false; + CalamitasEnchantUI.NPCIndex = npc.whoAmI; + CalamitasEnchantUI.CurrentlyViewing = true; - if (!Main.LocalPlayer.Calamity().GivenBrimstoneLocus) - { - DropHelper.DropItem(npc, ItemType()); - Main.LocalPlayer.Calamity().GivenBrimstoneLocus = true; - } + if (!Main.LocalPlayer.Calamity().GivenBrimstoneLocus) + { + DropHelper.DropItem(npc, ItemType()); + Main.LocalPlayer.Calamity().GivenBrimstoneLocus = true; + } - shop = false; - } - } + shop = false; + } + } - // Make this Town NPC teleport to the Queen statue when triggered. - public override bool CanGoToStatue(bool toKingStatue) => !toKingStatue; + // Make this Town NPC teleport to the Queen statue when triggered. + public override bool CanGoToStatue(bool toKingStatue) => !toKingStatue; - public override void TownNPCAttackStrength(ref int damage, ref float knockback) - { - damage = 50; - knockback = 10f; - } + public override void TownNPCAttackStrength(ref int damage, ref float knockback) + { + damage = 50; + knockback = 10f; + } - public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown) - { - cooldown = 10; - randExtraCooldown = 50; - } + public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown) + { + cooldown = 10; + randExtraCooldown = 50; + } public override bool PreAI() { - // Disappear if the SCal boss is active. She's supposed to be the boss. - // However, this doesn't happen in Boss Rush; the SCal there is a silent puppet created by Xeroc, not SCal herself. - if (NPC.AnyNPCs(NPCType()) && !BossRushEvent.BossRushActive) + // Disappear if the SCal boss is active. She's supposed to be the boss. + // However, this doesn't happen in Boss Rush; the SCal there is a silent puppet created by Xeroc, not SCal herself. + if (NPC.AnyNPCs(NPCType()) && !BossRushEvent.BossRushActive) { - npc.active = false; - npc.netUpdate = true; - return false; + npc.active = false; + npc.netUpdate = true; + return false; } return true; } @@ -182,46 +182,46 @@ namespace CalamityMod.NPCs.TownNPCs //public override void TownNPCAttackMagic(ref float auraLightMultiplier) public override void TownNPCAttackProj(ref int projType, ref int attackDelay) - { - projType = ProjectileType(); - attackDelay = 1; - } + { + projType = ProjectileType(); + attackDelay = 1; + } - public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset) - { - multiplier = 2f; - } + public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset) + { + multiplier = 2f; + } - // Explode into red dust on death. - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - npc.position = npc.Center; - npc.width = npc.height = 50; - npc.position.X -= npc.width / 2; - npc.position.Y -= npc.height / 2; - for (int i = 0; i < 5; i++) - { - int brimstone = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[brimstone].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[brimstone].scale = 0.5f; - Main.dust[brimstone].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } + // Explode into red dust on death. + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + { + npc.position = npc.Center; + npc.width = npc.height = 50; + npc.position.X -= npc.width / 2; + npc.position.Y -= npc.height / 2; + for (int i = 0; i < 5; i++) + { + int brimstone = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimstone].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[brimstone].scale = 0.5f; + Main.dust[brimstone].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } - for (int i = 0; i < 10; i++) - { - int fire = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[fire].noGravity = true; - Main.dust[fire].velocity *= 5f; + for (int i = 0; i < 10; i++) + { + int fire = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[fire].noGravity = true; + Main.dust[fire].velocity *= 5f; - fire = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[fire].velocity *= 2f; - } - } - } - } + fire = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[fire].velocity *= 2f; + } + } + } + } } diff --git a/NPCs/VanillaNPCOverrides/Bosses/CultistAI.cs b/NPCs/VanillaNPCOverrides/Bosses/CultistAI.cs index 5539900a9e..8090e02681 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/CultistAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/CultistAI.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; - + // Phases bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; @@ -1070,7 +1070,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Percent life remaining for Cultist or Eidolon Wyrm float lifeRatio = Main.npc[(int)npc.ai[0]].life / (float)Main.npc[(int)npc.ai[0]].lifeMax; - + bool phase2 = lifeRatio < 0.7f; bool phase3 = lifeRatio < (Main.npc[(int)npc.ai[0]].type == ModContent.NPCType() ? 0.6f : 0.55f); bool phase4 = lifeRatio < 0.4f; diff --git a/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs index 8d8eb0623c..5cdcd96566 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; - + // Phases based on life percentage bool phase2 = lifeRatio < 0.85f; bool phase3 = lifeRatio < 0.7f; @@ -173,7 +173,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { if (calamityGlobalNPC.newAI[0] % 30f == 0f) - { + { Vector2 vectorCenter = npc.Center; float num742 = npc.velocity.Length() * 0.33f + 1f; float num743 = player.position.X + player.width * 0.5f - vectorCenter.X; @@ -711,8 +711,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses for (int i = 0; i < totalProjectiles; i++) { float velocityMultiplier = 1f; - switch (i) - { + switch (i) + { case 0: break; case 1: @@ -722,7 +722,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses velocityMultiplier = 0.8f; break; } - Projectile.NewProjectile(vector.X, vector.Y, num4 * velocityMultiplier, num5 * velocityMultiplier, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(vector.X, vector.Y, num4 * velocityMultiplier, num5 * velocityMultiplier, type, damage, 0f, Main.myPlayer); } npc.netUpdate = true; diff --git a/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs b/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs index af44451934..37d3e1faa6 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs @@ -20,7 +20,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; - + // Variables bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; diff --git a/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs b/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs index eb77ca7a24..1c2c8afc10 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { - public static class EyeOfCthulhuAI + public static class EyeOfCthulhuAI { // Master Mode changes /* 1 - Spawns a clone of itself that copies every movement of the main eye but inverted (if main is on top and to the left, the mirror is on bottom and to the right) @@ -21,7 +21,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; - + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; bool phase2 = lifeRatio < 0.75f; diff --git a/NPCs/VanillaNPCOverrides/Bosses/GolemAI.cs b/NPCs/VanillaNPCOverrides/Bosses/GolemAI.cs index 583a8ff9fb..f6dc049fb7 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/GolemAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/GolemAI.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; - + // Phases bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; diff --git a/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs index ca384b8d43..926008adaf 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs @@ -46,9 +46,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Spawn crystal in phase 2 if (phase3 && npc.Calamity().newAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - npc.Calamity().newAI[0] = 1f; - npc.SyncExtraAI(); - Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2); + npc.Calamity().newAI[0] = 1f; + npc.SyncExtraAI(); + 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); diff --git a/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs index ffc31c6795..fcfbb5bf4a 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs @@ -44,7 +44,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; - + // Phases bool phase2 = lifeRatio < 0.75f; bool phase3 = lifeRatio < 0.5f; diff --git a/NPCs/VanillaNPCOverrides/Bosses/WallOfFleshAI.cs b/NPCs/VanillaNPCOverrides/Bosses/WallOfFleshAI.cs index 3a105a788a..61b46127fa 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/WallOfFleshAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/WallOfFleshAI.cs @@ -41,7 +41,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; - + // Clamp life ratio to prevent bad velocity math. lifeRatio = MathHelper.Clamp(lifeRatio, 0f, 1f); diff --git a/NPCs/VanillaNPCOverrides/RegularEnemies/DemonEyeAI.cs b/NPCs/VanillaNPCOverrides/RegularEnemies/DemonEyeAI.cs index f64fa16578..f245121e3a 100644 --- a/NPCs/VanillaNPCOverrides/RegularEnemies/DemonEyeAI.cs +++ b/NPCs/VanillaNPCOverrides/RegularEnemies/DemonEyeAI.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCOverrides.RegularEnemies { - public static class DemonEyeAI + public static class DemonEyeAI { // Subtypes of enemies with this AI. Made for programmer convenience. public static List NightTimeEnemies => new List() diff --git a/Particles/AresCannonChargeParticleSet.cs b/Particles/AresCannonChargeParticleSet.cs index 676377f5d4..5211b1a935 100644 --- a/Particles/AresCannonChargeParticleSet.cs +++ b/Particles/AresCannonChargeParticleSet.cs @@ -6,110 +6,110 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Particles { - public class AresCannonChargeParticleSet : BaseParticleSet - { - public override int ParticleLifetime => 30; - public Color ParticleColor; - public float SpawnAreaCompactness; - public float MoveRotationOffset; - public float chargeProgress = 0f; - public Particle bloom; - public List Pulses = new List(); + public class AresCannonChargeParticleSet : BaseParticleSet + { + public override int ParticleLifetime => 30; + public Color ParticleColor; + public float SpawnAreaCompactness; + public float MoveRotationOffset; + public float chargeProgress = 0f; + public Particle bloom; + public List Pulses = new List(); - public AresCannonChargeParticleSet(int setLifetime, int particleSpawnRate, float spawnAreaCompactness, Color particleColor) : - base(setLifetime, particleSpawnRate) - { - ParticleColor = particleColor; - MoveRotationOffset = Main.rand.NextFloat(-0.36f, 0.36f); - SpawnAreaCompactness = spawnAreaCompactness; - } - - //We'll use more than one here actually, so this doesnt matter that much - public override Particle SpawnParticle() - { - Vector2 originPoint = Main.rand.NextVector2CircularEdge(1f, 1f) * SpawnAreaCompactness; - return new ChargeUpLineVFX(originPoint, originPoint.ToRotation(), 0.5f, ParticleColor, ParticleLifetime, 0.75f, true, 0.2f, 10f); - } - - public CurveSegment Rise1 = new CurveSegment(EasingType.SineInOut, 0f, 0f, 0.25f); - public CurveSegment Fall1 = new CurveSegment(EasingType.SineInOut, 0.13f, 0.25f, -0.05f); - - public CurveSegment Rise2 = new CurveSegment(EasingType.SineInOut, 0.2f, 0.2f, 0.3f); - public CurveSegment Fall2 = new CurveSegment(EasingType.SineInOut, 0.33f, 0.5f, -0.1f); - - public CurveSegment Rise3 = new CurveSegment(EasingType.SineInOut, 0.4f, 0.4f, 0.3f); - public CurveSegment Fall3 = new CurveSegment(EasingType.SineInOut, 0.53f, 0.7f, -0.1f); - - public CurveSegment Rise4 = new CurveSegment(EasingType.SineInOut, 0.6f, 0.6f, 0.3f); - public CurveSegment Fall4 = new CurveSegment(EasingType.SineInOut, 0.73f, 0.9f, -0.1f); - - public CurveSegment Rise5 = new CurveSegment(EasingType.SineInOut, 0.8f, 0.8f, 0.3f); - public CurveSegment Finale = new CurveSegment(EasingType.SineIn, 0.93f, 1.1f, -1.1f); - public float ChargeSize() => PiecewiseAnimation(chargeProgress, new CurveSegment[] { Rise1, Fall1, Rise2, Fall2, Rise3, Fall3, Rise4, Fall4, Rise5, Finale }); - - public override void Update() - { - // Don't perform any operations on the server. Doing so would be a waste of space as these sets are entirely based on drawcode. - if (Main.netMode == NetmodeID.Server) - return; - - if (bloom == null) - bloom = new StrongBloom(Vector2.Zero, Vector2.Zero, ParticleColor, 0.5f, 2); - else - { - bloom.Time = 0; - bloom.Color = ParticleColor * 0.8f * chargeProgress; - bloom.Scale = ChargeSize() * 2f; - } - - //Spawn new particles if time remains - bool closeToDeath = LocalTimer >= SetLifetime - ParticleLifetime && SetLifetime > 0; - if (LocalTimer % ParticleSpawnRate == ParticleSpawnRate - 1 && !closeToDeath) - { - Particle particle = SpawnParticle(); - Particles.Add(particle); - } - - // Update and increment the time of all particles, alongside modifying their offset based on their velocity. - foreach (Particle particle in Particles) - { - particle.RelativeOffset += particle.Velocity; - particle.Time++; - particle.Update(); - } - - foreach (Particle pulse in Pulses) - { - pulse.Time++; - pulse.Update(); - } - - // Clear all expired particles. - Particles.RemoveAll(particle => particle.Time >= particle.Lifetime && particle.SetLifetime); - Pulses.RemoveAll(pulse => pulse.Time >= pulse.Lifetime && pulse.SetLifetime); - LocalTimer++; - } - - public void DrawBloom(Vector2 basePosition) - { - if (bloom != null) - { - bloom.CustomDraw(Main.spriteBatch, basePosition); - } - } - - public void AddPulse(float pulseCounter) - { - Particle pulse = new PulseRing(Vector2.Zero, Vector2.Zero, pulseCounter == 5 ? Color.Lerp(Color.White, ParticleColor, 0.5f) : ParticleColor, 0.2f, 0.5f * pulseCounter * 0.5f, 20); - Pulses.Add(pulse); - } - - public void DrawPulses(Vector2 basePosition) + public AresCannonChargeParticleSet(int setLifetime, int particleSpawnRate, float spawnAreaCompactness, Color particleColor) : + base(setLifetime, particleSpawnRate) { - foreach (Particle pulse in Pulses) - { - pulse.CustomDraw(Main.spriteBatch, basePosition); - } - } - } + ParticleColor = particleColor; + MoveRotationOffset = Main.rand.NextFloat(-0.36f, 0.36f); + SpawnAreaCompactness = spawnAreaCompactness; + } + + //We'll use more than one here actually, so this doesnt matter that much + public override Particle SpawnParticle() + { + Vector2 originPoint = Main.rand.NextVector2CircularEdge(1f, 1f) * SpawnAreaCompactness; + return new ChargeUpLineVFX(originPoint, originPoint.ToRotation(), 0.5f, ParticleColor, ParticleLifetime, 0.75f, true, 0.2f, 10f); + } + + public CurveSegment Rise1 = new CurveSegment(EasingType.SineInOut, 0f, 0f, 0.25f); + public CurveSegment Fall1 = new CurveSegment(EasingType.SineInOut, 0.13f, 0.25f, -0.05f); + + public CurveSegment Rise2 = new CurveSegment(EasingType.SineInOut, 0.2f, 0.2f, 0.3f); + public CurveSegment Fall2 = new CurveSegment(EasingType.SineInOut, 0.33f, 0.5f, -0.1f); + + public CurveSegment Rise3 = new CurveSegment(EasingType.SineInOut, 0.4f, 0.4f, 0.3f); + public CurveSegment Fall3 = new CurveSegment(EasingType.SineInOut, 0.53f, 0.7f, -0.1f); + + public CurveSegment Rise4 = new CurveSegment(EasingType.SineInOut, 0.6f, 0.6f, 0.3f); + public CurveSegment Fall4 = new CurveSegment(EasingType.SineInOut, 0.73f, 0.9f, -0.1f); + + public CurveSegment Rise5 = new CurveSegment(EasingType.SineInOut, 0.8f, 0.8f, 0.3f); + public CurveSegment Finale = new CurveSegment(EasingType.SineIn, 0.93f, 1.1f, -1.1f); + public float ChargeSize() => PiecewiseAnimation(chargeProgress, new CurveSegment[] { Rise1, Fall1, Rise2, Fall2, Rise3, Fall3, Rise4, Fall4, Rise5, Finale }); + + public override void Update() + { + // Don't perform any operations on the server. Doing so would be a waste of space as these sets are entirely based on drawcode. + if (Main.netMode == NetmodeID.Server) + return; + + if (bloom == null) + bloom = new StrongBloom(Vector2.Zero, Vector2.Zero, ParticleColor, 0.5f, 2); + else + { + bloom.Time = 0; + bloom.Color = ParticleColor * 0.8f * chargeProgress; + bloom.Scale = ChargeSize() * 2f; + } + + //Spawn new particles if time remains + bool closeToDeath = LocalTimer >= SetLifetime - ParticleLifetime && SetLifetime > 0; + if (LocalTimer % ParticleSpawnRate == ParticleSpawnRate - 1 && !closeToDeath) + { + Particle particle = SpawnParticle(); + Particles.Add(particle); + } + + // Update and increment the time of all particles, alongside modifying their offset based on their velocity. + foreach (Particle particle in Particles) + { + particle.RelativeOffset += particle.Velocity; + particle.Time++; + particle.Update(); + } + + foreach (Particle pulse in Pulses) + { + pulse.Time++; + pulse.Update(); + } + + // Clear all expired particles. + Particles.RemoveAll(particle => particle.Time >= particle.Lifetime && particle.SetLifetime); + Pulses.RemoveAll(pulse => pulse.Time >= pulse.Lifetime && pulse.SetLifetime); + LocalTimer++; + } + + public void DrawBloom(Vector2 basePosition) + { + if (bloom != null) + { + bloom.CustomDraw(Main.spriteBatch, basePosition); + } + } + + public void AddPulse(float pulseCounter) + { + Particle pulse = new PulseRing(Vector2.Zero, Vector2.Zero, pulseCounter == 5 ? Color.Lerp(Color.White, ParticleColor, 0.5f) : ParticleColor, 0.2f, 0.5f * pulseCounter * 0.5f, 20); + Pulses.Add(pulse); + } + + public void DrawPulses(Vector2 basePosition) + { + foreach (Particle pulse in Pulses) + { + pulse.CustomDraw(Main.spriteBatch, basePosition); + } + } + } } \ No newline at end of file diff --git a/Particles/BaseFusableParticleSet.cs b/Particles/BaseFusableParticleSet.cs index d76ad8091c..3986a30950 100644 --- a/Particles/BaseFusableParticleSet.cs +++ b/Particles/BaseFusableParticleSet.cs @@ -7,97 +7,97 @@ using Terraria.ID; namespace CalamityMod.Particles { - public abstract class BaseFusableParticleSet - { - public class FusableParticleRenderCollection - { - public BaseFusableParticleSet ParticleSet; - public List BackgroundTargets; - public FusableParticleRenderCollection(BaseFusableParticleSet set, List backgroundTargets) - { - ParticleSet = set; - BackgroundTargets = backgroundTargets; - } - } + public abstract class BaseFusableParticleSet + { + public class FusableParticleRenderCollection + { + public BaseFusableParticleSet ParticleSet; + public List BackgroundTargets; + public FusableParticleRenderCollection(BaseFusableParticleSet set, List backgroundTargets) + { + ParticleSet = set; + BackgroundTargets = backgroundTargets; + } + } - public class FusableParticle - { - public Vector2 Center; - public float Size; - public Vector2 TopLeft => Center + new Vector2(-1f, -1f) * Size * 0.5f; - public Vector2 TopRight => Center + new Vector2(1f, -1f) * Size * 0.5f; - public Vector2 BottomLeft => Center + new Vector2(-1f, 1f) * Size * 0.5f; - public Vector2 BottomRight => Center + new Vector2(1f, 1f) * Size * 0.5f; + public class FusableParticle + { + public Vector2 Center; + public float Size; + public Vector2 TopLeft => Center + new Vector2(-1f, -1f) * Size * 0.5f; + public Vector2 TopRight => Center + new Vector2(1f, -1f) * Size * 0.5f; + public Vector2 BottomLeft => Center + new Vector2(-1f, 1f) * Size * 0.5f; + public Vector2 BottomRight => Center + new Vector2(1f, 1f) * Size * 0.5f; - public FusableParticle(Vector2 center, float size) - { - Center = center; - Size = size; - } - } + public FusableParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + } - public int LayerCount - { - get - { - // Not doing this will result in inevitable crashes down the line as the graphics engine fails. - if (BackgroundShaders.Count != BackgroundTextures.Count) - throw new InvalidOperationException("The number of texture maps and shaders are not equivalent."); + public int LayerCount + { + get + { + // Not doing this will result in inevitable crashes down the line as the graphics engine fails. + if (BackgroundShaders.Count != BackgroundTextures.Count) + throw new InvalidOperationException("The number of texture maps and shaders are not equivalent."); - return BackgroundShaders.Count; - } - } + return BackgroundShaders.Count; + } + } - public List Particles = new List(); + public List Particles = new List(); - public FusableParticleRenderCollection RenderCollection => FusableParticleManager.GetParticleRenderCollectionByType(GetType()); + public FusableParticleRenderCollection RenderCollection => FusableParticleManager.GetParticleRenderCollectionByType(GetType()); - public List GetBackgroundTargets => RenderCollection.BackgroundTargets; + public List GetBackgroundTargets => RenderCollection.BackgroundTargets; - public virtual float BorderSize => 0f; - public virtual bool BorderShouldBeSolid => false; - public virtual Color BorderColor => Color.Transparent; - public virtual void PrepareOptionalShaderData(Effect effect, int index) { } - public abstract FusableParticleRenderLayer RenderLayer { get; } - public abstract List BackgroundShaders { get; } - public abstract List BackgroundTextures { get; } - public abstract FusableParticle SpawnParticle(Vector2 center, float sizeStrength); - public abstract void UpdateBehavior(FusableParticle particle); - public abstract void DrawParticles(); + public virtual float BorderSize => 0f; + public virtual bool BorderShouldBeSolid => false; + public virtual Color BorderColor => Color.Transparent; + public virtual void PrepareOptionalShaderData(Effect effect, int index) { } + public abstract FusableParticleRenderLayer RenderLayer { get; } + public abstract List BackgroundShaders { get; } + public abstract List BackgroundTextures { get; } + public abstract FusableParticle SpawnParticle(Vector2 center, float sizeStrength); + public abstract void UpdateBehavior(FusableParticle particle); + public abstract void DrawParticles(); - /// - /// Temporarily moves from the backbuffer to a specialized render target, draws all particles, and caches the resulting render target for drawing later. - /// - internal void PrepareRenderTargetForDrawing() - { - // Don't bother doing anything if this method is called serverside. - if (Main.netMode == NetmodeID.Server) - return; + /// + /// Temporarily moves from the backbuffer to a specialized render target, draws all particles, and caches the resulting render target for drawing later. + /// + internal void PrepareRenderTargetForDrawing() + { + // Don't bother doing anything if this method is called serverside. + if (Main.netMode == NetmodeID.Server) + return; - // Don't bother doing anything if the set has no particles to render at the moment, for the sake of optimization. - if (Particles.Count <= 0) - return; + // Don't bother doing anything if the set has no particles to render at the moment, for the sake of optimization. + if (Particles.Count <= 0) + return; - // Go through each background render target in the set and clear the entire thing to use a base of transparent pixels. - foreach (RenderTarget2D backgroundTarget in GetBackgroundTargets) - { - Main.instance.GraphicsDevice.SetRenderTarget(backgroundTarget); - Main.instance.GraphicsDevice.Clear(Color.Transparent); + // Go through each background render target in the set and clear the entire thing to use a base of transparent pixels. + foreach (RenderTarget2D backgroundTarget in GetBackgroundTargets) + { + Main.instance.GraphicsDevice.SetRenderTarget(backgroundTarget); + Main.instance.GraphicsDevice.Clear(Color.Transparent); - // Clear away any particles that shouldn't exist anymore. - Particles.RemoveAll(p => p.Size <= 5f); + // Clear away any particles that shouldn't exist anymore. + Particles.RemoveAll(p => p.Size <= 5f); - // Prepare the sprite batch for specialized drawing in prepration that the graphics device will draw to new render targets. - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix); + // Prepare the sprite batch for specialized drawing in prepration that the graphics device will draw to new render targets. + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix); - // Draw the surviving particles. - DrawParticles(); + // Draw the surviving particles. + DrawParticles(); - Main.spriteBatch.End(); - } + Main.spriteBatch.End(); + } - // Return to using the backbuffer after done drawing everything to the background targets. - Main.instance.GraphicsDevice.SetRenderTarget(null); - } - } + // Return to using the backbuffer after done drawing everything to the background targets. + Main.instance.GraphicsDevice.SetRenderTarget(null); + } + } } diff --git a/Particles/BaseParticleSet.cs b/Particles/BaseParticleSet.cs index 96795ac889..09ec9c137e 100644 --- a/Particles/BaseParticleSet.cs +++ b/Particles/BaseParticleSet.cs @@ -9,93 +9,93 @@ using Terraria.ModLoader; namespace CalamityMod.Particles { - /// - /// A set of particles that aren't attached to any particular position in the world, but instead an arbitrary center point defined in the draw function - /// The particles in particle sets don't count towards the general particle handler's particle cap since it doesn't process them at all. - /// You'll have to manually update and draw these sets. - /// TLDR: Groups of particles that work with relative positions instead of world positions and have to be manually updated and drawn - /// - public abstract class BaseParticleSet - { - public int LocalTimer { get; internal set; } - public int SetLifetime { get; internal set; } - /// - /// The amount of frames it takes for a new particle to be spawned in the set. - /// - public int ParticleSpawnRate; - /// - /// The particles in the set - /// - public List Particles = new List(); - /// - /// The lifetime of the particles in the set. - /// If the particles spawned don't have this same lifetime set they may get cut off when the set dies. - /// - public abstract int ParticleLifetime { get; } - /// - /// The particle spawned by the set - /// - /// - public abstract Particle SpawnParticle(); - public virtual Func OrderFunction { get; } = null; + /// + /// A set of particles that aren't attached to any particular position in the world, but instead an arbitrary center point defined in the draw function + /// The particles in particle sets don't count towards the general particle handler's particle cap since it doesn't process them at all. + /// You'll have to manually update and draw these sets. + /// TLDR: Groups of particles that work with relative positions instead of world positions and have to be manually updated and drawn + /// + public abstract class BaseParticleSet + { + public int LocalTimer { get; internal set; } + public int SetLifetime { get; internal set; } + /// + /// The amount of frames it takes for a new particle to be spawned in the set. + /// + public int ParticleSpawnRate; + /// + /// The particles in the set + /// + public List Particles = new List(); + /// + /// The lifetime of the particles in the set. + /// If the particles spawned don't have this same lifetime set they may get cut off when the set dies. + /// + public abstract int ParticleLifetime { get; } + /// + /// The particle spawned by the set + /// + /// + public abstract Particle SpawnParticle(); + public virtual Func OrderFunction { get; } = null; - public BaseParticleSet(int setLifetime, int particleSpawnRate) - { - SetLifetime = setLifetime; - ParticleSpawnRate = particleSpawnRate; - } + public BaseParticleSet(int setLifetime, int particleSpawnRate) + { + SetLifetime = setLifetime; + ParticleSpawnRate = particleSpawnRate; + } - public virtual void Update() - { - // Don't perform any operations on the server. Doing so would be a waste of space as these sets are entirely based on drawcode. - if (Main.netMode == NetmodeID.Server) - return; + public virtual void Update() + { + // Don't perform any operations on the server. Doing so would be a waste of space as these sets are entirely based on drawcode. + if (Main.netMode == NetmodeID.Server) + return; - //Spawn new particles if time remains - bool closeToDeath = LocalTimer >= SetLifetime - ParticleLifetime && SetLifetime > 0; - if (LocalTimer % ParticleSpawnRate == ParticleSpawnRate - 1 && !closeToDeath) - { - Particle particle = SpawnParticle(); - Particles.Add(particle); - } + //Spawn new particles if time remains + bool closeToDeath = LocalTimer >= SetLifetime - ParticleLifetime && SetLifetime > 0; + if (LocalTimer % ParticleSpawnRate == ParticleSpawnRate - 1 && !closeToDeath) + { + Particle particle = SpawnParticle(); + Particles.Add(particle); + } - // Update and increment the time of all particles, alongside modifying their offset based on their velocity. - foreach(Particle particle in Particles) - { - particle.RelativeOffset += particle.Velocity; - particle.Time++; - particle.Update(); - } + // Update and increment the time of all particles, alongside modifying their offset based on their velocity. + foreach(Particle particle in Particles) + { + particle.RelativeOffset += particle.Velocity; + particle.Time++; + particle.Update(); + } - // Clear all expired particles. - Particles.RemoveAll(particle => particle.Time >= particle.Lifetime && particle.SetLifetime); - LocalTimer++; - } + // Clear all expired particles. + Particles.RemoveAll(particle => particle.Time >= particle.Lifetime && particle.SetLifetime); + LocalTimer++; + } - public virtual void DrawSet(Vector2 basePosition) - { - if (Main.netMode == NetmodeID.Server) - return; + public virtual void DrawSet(Vector2 basePosition) + { + if (Main.netMode == NetmodeID.Server) + return; - IEnumerable orderedParticles = Particles; - if (OrderFunction != null) - orderedParticles = orderedParticles.OrderBy(OrderFunction); + IEnumerable orderedParticles = Particles; + if (OrderFunction != null) + orderedParticles = orderedParticles.OrderBy(OrderFunction); - foreach (Particle particle in Particles.OrderBy(p => p.Time)) - { - if (particle.UseCustomDraw) - particle.CustomDraw(Main.spriteBatch, basePosition); - else - { - var tex = ModContent.GetTexture(particle.Texture); + foreach (Particle particle in Particles.OrderBy(p => p.Time)) + { + if (particle.UseCustomDraw) + particle.CustomDraw(Main.spriteBatch, basePosition); + else + { + var tex = ModContent.GetTexture(particle.Texture); - Vector2 drawPosition = basePosition - Main.screenPosition + particle.RelativeOffset; - Color particleColor = particle.Color; - Rectangle frame = tex.Frame(1, particle.FrameVariants, 0, particle.Variant); + Vector2 drawPosition = basePosition - Main.screenPosition + particle.RelativeOffset; + Color particleColor = particle.Color; + Rectangle frame = tex.Frame(1, particle.FrameVariants, 0, particle.Variant); - Main.spriteBatch.Draw(tex, drawPosition, frame, particle.Color, 0f, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); - } - } - } - } + Main.spriteBatch.Draw(tex, drawPosition, frame, particle.Color, 0f, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); + } + } + } + } } \ No newline at end of file diff --git a/Particles/BloomLineVFX.cs b/Particles/BloomLineVFX.cs index 9669b0ae6b..6ce3d3c175 100644 --- a/Particles/BloomLineVFX.cs +++ b/Particles/BloomLineVFX.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Particles { - public class BloomLineVFX : Particle + public class BloomLineVFX : Particle { public override string Texture => "CalamityMod/Particles/BloomLine"; public override bool UseAdditiveBlend => true; diff --git a/Particles/BloomRing.cs b/Particles/BloomRing.cs index d616014ec3..9dad40b433 100644 --- a/Particles/BloomRing.cs +++ b/Particles/BloomRing.cs @@ -5,7 +5,7 @@ using Terraria; namespace CalamityMod.Particles { - public class BloomRing : Particle + public class BloomRing : Particle { public override string Texture => "CalamityMod/Particles/BloomRing"; public override bool UseAdditiveBlend => true; diff --git a/Particles/CircularSmearSmokeyVFX .cs b/Particles/CircularSmearSmokeyVFX .cs index c65d74989e..f8767e10a0 100644 --- a/Particles/CircularSmearSmokeyVFX .cs +++ b/Particles/CircularSmearSmokeyVFX .cs @@ -2,7 +2,7 @@ namespace CalamityMod.Particles { - public class CircularSmearSmokeyVFX : Particle //Also check out random noise generation! + public class CircularSmearSmokeyVFX : Particle //Also check out random noise generation! { public override string Texture => "CalamityMod/Particles/CircularSmearSmokey"; public override bool UseAdditiveBlend => true; diff --git a/Particles/CircularSmearVFX.cs b/Particles/CircularSmearVFX.cs index 4fbecee58b..35c866c06f 100644 --- a/Particles/CircularSmearVFX.cs +++ b/Particles/CircularSmearVFX.cs @@ -2,7 +2,7 @@ namespace CalamityMod.Particles { - public class CircularSmearVFX : Particle //Also check out Split mod! + public class CircularSmearVFX : Particle //Also check out Split mod! { public override string Texture => "CalamityMod/Particles/CircularSmear"; public override bool UseAdditiveBlend => true; diff --git a/Particles/ElectricSpark.cs b/Particles/ElectricSpark.cs index 245179bc73..6ddfcfcc97 100644 --- a/Particles/ElectricSpark.cs +++ b/Particles/ElectricSpark.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Particles { - public class ElectricSpark : Particle + public class ElectricSpark : Particle { public override string Texture => "CalamityMod/Particles/ElectricSpark"; public override bool UseAdditiveBlend => true; diff --git a/Particles/EnchantedParticle.cs b/Particles/EnchantedParticle.cs index 7faa4fdf19..4e7f206b39 100644 --- a/Particles/EnchantedParticle.cs +++ b/Particles/EnchantedParticle.cs @@ -3,7 +3,7 @@ using Terraria; namespace CalamityMod.Particles { - public class EnchantedParticle : Particle + public class EnchantedParticle : Particle { public float RelativePower; public override bool SetLifetime => true; diff --git a/Particles/EnchantedParticleSet.cs b/Particles/EnchantedParticleSet.cs index b803ced82a..4f4a5d894d 100644 --- a/Particles/EnchantedParticleSet.cs +++ b/Particles/EnchantedParticleSet.cs @@ -3,22 +3,22 @@ using Terraria; namespace CalamityMod.Particles { - public class ChargingEnergyParticleSet : BaseParticleSet - { - public float InterpolationSpeed; - public float EdgeOffset; - public Color EdgeColor; - public Color CenterColor; - public override int ParticleLifetime => 50; - public ChargingEnergyParticleSet(int setLifetime, int particleSpawnRate, Color edgeColor, Color centerColor, float interpolationSpeed, float edgeOffset) : - base(setLifetime, particleSpawnRate) - { - EdgeColor = edgeColor; - CenterColor = centerColor; - InterpolationSpeed = interpolationSpeed; - EdgeOffset = edgeOffset; - } + public class ChargingEnergyParticleSet : BaseParticleSet + { + public float InterpolationSpeed; + public float EdgeOffset; + public Color EdgeColor; + public Color CenterColor; + public override int ParticleLifetime => 50; + public ChargingEnergyParticleSet(int setLifetime, int particleSpawnRate, Color edgeColor, Color centerColor, float interpolationSpeed, float edgeOffset) : + base(setLifetime, particleSpawnRate) + { + EdgeColor = edgeColor; + CenterColor = centerColor; + InterpolationSpeed = interpolationSpeed; + EdgeOffset = edgeOffset; + } - public override Particle SpawnParticle() => new EnchantedParticle(Main.rand.NextVector2CircularEdge(1f, 1f) * EdgeOffset, ParticleLifetime, 0.1f, EdgeColor, CenterColor, InterpolationSpeed, EdgeOffset); - } + public override Particle SpawnParticle() => new EnchantedParticle(Main.rand.NextVector2CircularEdge(1f, 1f) * EdgeOffset, ParticleLifetime, 0.1f, EdgeColor, CenterColor, InterpolationSpeed, EdgeOffset); + } } \ No newline at end of file diff --git a/Particles/FireParticle.cs b/Particles/FireParticle.cs index 0d585f5f43..6ab15c7b70 100644 --- a/Particles/FireParticle.cs +++ b/Particles/FireParticle.cs @@ -3,7 +3,7 @@ using Terraria; namespace CalamityMod.Particles { - public class FireParticle : Particle + public class FireParticle : Particle { public float RelativePower; public override bool SetLifetime => true; diff --git a/Particles/FireParticleSet.cs b/Particles/FireParticleSet.cs index d0ec3d85e7..c6b51c2898 100644 --- a/Particles/FireParticleSet.cs +++ b/Particles/FireParticleSet.cs @@ -3,23 +3,23 @@ using Terraria; namespace CalamityMod.Particles { - public class FireParticleSet : BaseParticleSet - { - public float SpawnAreaCompactness; - public float RelativePower; - public Color BrightColor; - public Color DarkColor; - public override int ParticleLifetime => 50; + public class FireParticleSet : BaseParticleSet + { + public float SpawnAreaCompactness; + public float RelativePower; + public Color BrightColor; + public Color DarkColor; + public override int ParticleLifetime => 50; - public FireParticleSet(int setLifetime, int particleSpawnRate, Color brightColor, Color darkColor, float spawnAreaCompactness, float relativePower) : - base(setLifetime, particleSpawnRate) - { - BrightColor = brightColor; - DarkColor = darkColor; - SpawnAreaCompactness = spawnAreaCompactness; - RelativePower = relativePower; - } + public FireParticleSet(int setLifetime, int particleSpawnRate, Color brightColor, Color darkColor, float spawnAreaCompactness, float relativePower) : + base(setLifetime, particleSpawnRate) + { + BrightColor = brightColor; + DarkColor = darkColor; + SpawnAreaCompactness = spawnAreaCompactness; + RelativePower = relativePower; + } - public override Particle SpawnParticle() => new FireParticle(Main.rand.NextVector2Circular(1f, 1f) * SpawnAreaCompactness, ParticleLifetime, 0.06f, RelativePower, BrightColor, DarkColor); - } + public override Particle SpawnParticle() => new FireParticle(Main.rand.NextVector2Circular(1f, 1f) * SpawnAreaCompactness, ParticleLifetime, 0.06f, RelativePower, BrightColor, DarkColor); + } } \ No newline at end of file diff --git a/Particles/FusableParticleManager.cs b/Particles/FusableParticleManager.cs index 5313e4f48a..784cbdf9d0 100644 --- a/Particles/FusableParticleManager.cs +++ b/Particles/FusableParticleManager.cs @@ -10,181 +10,181 @@ using static CalamityMod.Particles.BaseFusableParticleSet; namespace CalamityMod.Particles { - // NOTE: A lot of the functionalities within this system cannot under really any circumstance be used serverside. - // This system is entirely visual. However, servers do not have drawing capabilities, nor even a proper GraphicsDevice - // instance. This system utilizes many things that require both of these things, such as shaders and render targets. - // As such, it is littered with many netMode checks. While some may be overprotective in their nature it is critical that - // failsafes exist there, as visual failures tend to result in engine crashes, which will kill a lot of MP servers. - // If someone other than me for any reason attempts to notably expand upon this system you must keep this in mind. -Dominic - public static class FusableParticleManager - { - internal static List ParticleSets = new List(); - internal static bool HasBeenFormallyDefined = false; + // NOTE: A lot of the functionalities within this system cannot under really any circumstance be used serverside. + // This system is entirely visual. However, servers do not have drawing capabilities, nor even a proper GraphicsDevice + // instance. This system utilizes many things that require both of these things, such as shaders and render targets. + // As such, it is littered with many netMode checks. While some may be overprotective in their nature it is critical that + // failsafes exist there, as visual failures tend to result in engine crashes, which will kill a lot of MP servers. + // If someone other than me for any reason attempts to notably expand upon this system you must keep this in mind. -Dominic + public static class FusableParticleManager + { + internal static List ParticleSets = new List(); + internal static bool HasBeenFormallyDefined = false; - /// - /// Loads all render sets. - /// - internal static void LoadParticleRenderSets(bool reload = false, int width = -1, int height = -1) - { - // Don't attempt to prepare anything serverside. - if (Main.netMode == NetmodeID.Server) - return; + /// + /// Loads all render sets. + /// + internal static void LoadParticleRenderSets(bool reload = false, int width = -1, int height = -1) + { + // Don't attempt to prepare anything serverside. + if (Main.netMode == NetmodeID.Server) + return; - // Use fallbacks for width and height based on the screen. - if (width == -1 || height == -1) - { - width = Main.screenWidth; - height = Main.screenHeight; - } + // Use fallbacks for width and height based on the screen. + if (width == -1 || height == -1) + { + width = Main.screenWidth; + height = Main.screenHeight; + } - // Otherwise, if a width and height are defined, but they are the exact same as the screen bounds, - // do nothing. This indicates that the render targets already have the correct size and re-initailizing would be unnecessary. - else if (width == Main.screenWidth && height == Main.screenHeight) - return; + // Otherwise, if a width and height are defined, but they are the exact same as the screen bounds, + // do nothing. This indicates that the render targets already have the correct size and re-initailizing would be unnecessary. + else if (width == Main.screenWidth && height == Main.screenHeight) + return; - // Redefine the particle set list in case the mod was reloaded and this field was nullified during that. - // This does not happen during reloads, as that would delete particles outside of load-time. - if (!reload) - { - ParticleSets = new List(); - HasBeenFormallyDefined = true; - } + // Redefine the particle set list in case the mod was reloaded and this field was nullified during that. + // This does not happen during reloads, as that would delete particles outside of load-time. + if (!reload) + { + ParticleSets = new List(); + HasBeenFormallyDefined = true; + } - // Look through every type in the mod, and check if it's derived from BaseFusableParticleSet. - // If it is, create a default instance of said particle, save it, and create a RenderTarget2D for each individual texture/shader. - foreach (Type type in typeof(CalamityMod).Assembly.GetTypes()) - { - // Don't load abstract classes; they cannot have instances. - if (type.IsAbstract) - continue; + // Look through every type in the mod, and check if it's derived from BaseFusableParticleSet. + // If it is, create a default instance of said particle, save it, and create a RenderTarget2D for each individual texture/shader. + foreach (Type type in typeof(CalamityMod).Assembly.GetTypes()) + { + // Don't load abstract classes; they cannot have instances. + if (type.IsAbstract) + continue; - if (type.IsSubclassOf(typeof(BaseFusableParticleSet))) - { - BaseFusableParticleSet instance = Activator.CreateInstance(type) as BaseFusableParticleSet; - List backgroundTargets = new List(); + if (type.IsSubclassOf(typeof(BaseFusableParticleSet))) + { + BaseFusableParticleSet instance = Activator.CreateInstance(type) as BaseFusableParticleSet; + List backgroundTargets = new List(); - // Only generate render targets to use if this isn't called serverside. - if (Main.netMode != NetmodeID.Server) - { - for (int i = 0; i < instance.LayerCount; i++) - backgroundTargets.Add(new RenderTarget2D(Main.instance.GraphicsDevice, width, height, false, default, default, 0, RenderTargetUsage.PreserveContents)); - } + // Only generate render targets to use if this isn't called serverside. + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < instance.LayerCount; i++) + backgroundTargets.Add(new RenderTarget2D(Main.instance.GraphicsDevice, width, height, false, default, default, 0, RenderTargetUsage.PreserveContents)); + } - FusableParticleRenderCollection particleRenderCollection = new FusableParticleRenderCollection(instance, backgroundTargets); - ParticleSets.Add(particleRenderCollection); - } - } - } + FusableParticleRenderCollection particleRenderCollection = new FusableParticleRenderCollection(instance, backgroundTargets); + ParticleSets.Add(particleRenderCollection); + } + } + } - /// - /// Unloads all render sets, disposing any created s in the process. - /// - internal static void UnloadParticleRenderSets() - { - // Go through each render collection and manually clear away any render targets. - foreach (FusableParticleRenderCollection particleRenderSet in ParticleSets) - { - particleRenderSet.ParticleSet = null; - foreach (RenderTarget2D target in particleRenderSet.BackgroundTargets) - target?.Dispose(); - } - HasBeenFormallyDefined = false; - ParticleSets = null; - } + /// + /// Unloads all render sets, disposing any created s in the process. + /// + internal static void UnloadParticleRenderSets() + { + // Go through each render collection and manually clear away any render targets. + foreach (FusableParticleRenderCollection particleRenderSet in ParticleSets) + { + particleRenderSet.ParticleSet = null; + foreach (RenderTarget2D target in particleRenderSet.BackgroundTargets) + target?.Dispose(); + } + HasBeenFormallyDefined = false; + ParticleSets = null; + } - /// - /// Prepares the render targets of each cached instance in advance. - /// - internal static void PrepareFusableParticleTargets() - { - // Don't attempt to prepare anything serverside, if the particle sets are unloaded, or if on the menu. - if (Main.netMode == NetmodeID.Server || ParticleSets is null || Main.gameMenu) - return; + /// + /// Prepares the render targets of each cached instance in advance. + /// + internal static void PrepareFusableParticleTargets() + { + // Don't attempt to prepare anything serverside, if the particle sets are unloaded, or if on the menu. + if (Main.netMode == NetmodeID.Server || ParticleSets is null || Main.gameMenu) + return; - // Prepare the render target for all fusable particles. - for (int i = 0; i < ParticleSets.Count; i++) - ParticleSets[i].ParticleSet.PrepareRenderTargetForDrawing(); - } + // Prepare the render target for all fusable particles. + for (int i = 0; i < ParticleSets.Count; i++) + ParticleSets[i].ParticleSet.PrepareRenderTargetForDrawing(); + } - /// - /// Renders each cached instance with its connecting shader. - /// - internal static void RenderAllFusableParticles() - { - // Don't attempt to render anything serverside or on the menu. - if (Main.netMode == NetmodeID.Server || Main.gameMenu) - return; + /// + /// Renders each cached instance with its connecting shader. + /// + internal static void RenderAllFusableParticles() + { + // Don't attempt to render anything serverside or on the menu. + if (Main.netMode == NetmodeID.Server || Main.gameMenu) + return; - for (int i = 0; i < ParticleSets.Count; i++) - { - BaseFusableParticleSet particleSet = ParticleSets[i].ParticleSet; + for (int i = 0; i < ParticleSets.Count; i++) + { + BaseFusableParticleSet particleSet = ParticleSets[i].ParticleSet; - // Don't bother rendering if the set has no particles to render at the moment, for the sake of optimization. - if (particleSet.Particles.Count <= 0) - continue; + // Don't bother rendering if the set has no particles to render at the moment, for the sake of optimization. + if (particleSet.Particles.Count <= 0) + continue; - List backgroundTargets = particleSet.GetBackgroundTargets; + List backgroundTargets = particleSet.GetBackgroundTargets; - // Restart the sprite batch. This must be done with an immediate sort mode since a shader is going to be applied. - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + // Restart the sprite batch. This must be done with an immediate sort mode since a shader is going to be applied. + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - for (int j = 0; j < particleSet.LayerCount; j++) - { - Effect shader = particleSet.BackgroundShaders[j]; - Texture2D backgroundTexture = particleSet.BackgroundTextures[j]; + for (int j = 0; j < particleSet.LayerCount; j++) + { + Effect shader = particleSet.BackgroundShaders[j]; + Texture2D backgroundTexture = particleSet.BackgroundTextures[j]; - // Draw the current target with the specified shader. - shader.Parameters["edgeBorderSize"].SetValue(particleSet.BorderSize); - shader.Parameters["borderShouldBeSolid"].SetValue(particleSet.BorderShouldBeSolid); - shader.Parameters["edgeBorderColor"].SetValue(particleSet.BorderColor.ToVector3()); - shader.Parameters["screenArea"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight) / Main.GameViewMatrix.Zoom); - shader.Parameters["screenMoveOffset"].SetValue(Main.screenPosition - Main.screenLastPosition); - shader.Parameters["uWorldPosition"].SetValue(Main.screenPosition); - shader.Parameters["renderTargetArea"].SetValue(new Vector2(backgroundTargets[j].Width, backgroundTargets[j].Height)); - shader.Parameters["invertedScreen"].SetValue(Main.LocalPlayer.gravDir == -1f); - shader.Parameters["upscaleFactor"].SetValue(Vector2.One); - shader.Parameters["generalBackgroundOffset"].SetValue(Vector2.Zero); + // Draw the current target with the specified shader. + shader.Parameters["edgeBorderSize"].SetValue(particleSet.BorderSize); + shader.Parameters["borderShouldBeSolid"].SetValue(particleSet.BorderShouldBeSolid); + shader.Parameters["edgeBorderColor"].SetValue(particleSet.BorderColor.ToVector3()); + shader.Parameters["screenArea"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight) / Main.GameViewMatrix.Zoom); + shader.Parameters["screenMoveOffset"].SetValue(Main.screenPosition - Main.screenLastPosition); + shader.Parameters["uWorldPosition"].SetValue(Main.screenPosition); + shader.Parameters["renderTargetArea"].SetValue(new Vector2(backgroundTargets[j].Width, backgroundTargets[j].Height)); + shader.Parameters["invertedScreen"].SetValue(Main.LocalPlayer.gravDir == -1f); + shader.Parameters["upscaleFactor"].SetValue(Vector2.One); + shader.Parameters["generalBackgroundOffset"].SetValue(Vector2.Zero); - // Prepare the background texture for loading. - Main.graphics.GraphicsDevice.Textures[1] = backgroundTexture; - shader.Parameters["uImageSize1"].SetValue(backgroundTexture.Size()); + // Prepare the background texture for loading. + Main.graphics.GraphicsDevice.Textures[1] = backgroundTexture; + shader.Parameters["uImageSize1"].SetValue(backgroundTexture.Size()); - // Do any optional shader operations prior to applying the shader. - particleSet.PrepareOptionalShaderData(shader, j); + // Do any optional shader operations prior to applying the shader. + particleSet.PrepareOptionalShaderData(shader, j); - // Apply the shader. This is what is used to connect separated blobs together. - shader.CurrentTechnique.Passes[0].Apply(); + // Apply the shader. This is what is used to connect separated blobs together. + shader.CurrentTechnique.Passes[0].Apply(); - // And draw the particle set's render target with said shader. - Main.spriteBatch.Draw(backgroundTargets[j], Vector2.Zero, Color.White); - } + // And draw the particle set's render target with said shader. + Main.spriteBatch.Draw(backgroundTargets[j], Vector2.Zero, Color.White); + } - Main.spriteBatch.End(); - } - } + Main.spriteBatch.End(); + } + } - /// - /// Obtains the instance from a given if it is a . - /// - /// The type to check. - internal static FusableParticleRenderCollection GetParticleRenderCollectionByType(Type type) - { - if (Main.netMode == NetmodeID.Server) - return null; + /// + /// Obtains the instance from a given if it is a . + /// + /// The type to check. + internal static FusableParticleRenderCollection GetParticleRenderCollectionByType(Type type) + { + if (Main.netMode == NetmodeID.Server) + return null; - return ParticleSets.First(s => s.ParticleSet.GetType() == type); - } + return ParticleSets.First(s => s.ParticleSet.GetType() == type); + } - /// - /// Obtains the cached singleton instance of a given . - /// - /// The type to check. - public static T GetParticleSetByType() where T : BaseFusableParticleSet - { - if (Main.netMode == NetmodeID.Server) - return null; + /// + /// Obtains the cached singleton instance of a given . + /// + /// The type to check. + public static T GetParticleSetByType() where T : BaseFusableParticleSet + { + if (Main.netMode == NetmodeID.Server) + return null; - return ParticleSets.First(s => s.ParticleSet.GetType() == typeof(T)).ParticleSet as T; - } - } + return ParticleSets.First(s => s.ParticleSet.GetType() == typeof(T)).ParticleSet as T; + } + } } diff --git a/Particles/FusableParticleRenderLayer.cs b/Particles/FusableParticleRenderLayer.cs index d208264b7c..9d9941d6e1 100644 --- a/Particles/FusableParticleRenderLayer.cs +++ b/Particles/FusableParticleRenderLayer.cs @@ -1,11 +1,11 @@ namespace CalamityMod.Particles { - // The order of entries in this enumeration are in line with draw order - // e.g. the first entry is the first drawn thing, the last entry is the last drawn thing. - public enum FusableParticleRenderLayer - { - OverNPCsBeforeProjectiles, - OverPlayers, - OverWater - } + // The order of entries in this enumeration are in line with draw order + // e.g. the first entry is the first drawn thing, the last entry is the last drawn thing. + public enum FusableParticleRenderLayer + { + OverNPCsBeforeProjectiles, + OverPlayers, + OverWater + } } diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index fb3bb7c567..7b3c70fcf8 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Particles { - public static class GeneralParticleHandler + public static class GeneralParticleHandler { private static List particles; //List containing the particles to delete diff --git a/Particles/GenericBloom.cs b/Particles/GenericBloom.cs index acb5fda1f9..f439d0f340 100644 --- a/Particles/GenericBloom.cs +++ b/Particles/GenericBloom.cs @@ -5,7 +5,7 @@ using Terraria; namespace CalamityMod.Particles { - public class GenericBloom : Particle + public class GenericBloom : Particle { public override string Texture => "CalamityMod/Particles/Light"; public override bool UseAdditiveBlend => true; diff --git a/Particles/GruesomeEminenceParticleSet.cs b/Particles/GruesomeEminenceParticleSet.cs index 0b4723fa3e..72e757d089 100644 --- a/Particles/GruesomeEminenceParticleSet.cs +++ b/Particles/GruesomeEminenceParticleSet.cs @@ -9,90 +9,90 @@ using Terraria.ModLoader; namespace CalamityMod.Particles { - public class GruesomeEminenceParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 3f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.Fuchsia, Color.Black, 0.55f) * 0.85f; - public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverNPCsBeforeProjectiles; + public class GruesomeEminenceParticleSet : BaseFusableParticleSet + { + public override float BorderSize => 3f; + public override bool BorderShouldBeSolid => false; + public override Color BorderColor => Color.Lerp(Color.Fuchsia, Color.Black, 0.55f) * 0.85f; + public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverNPCsBeforeProjectiles; - public override List BackgroundShaders => new List() - { - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new List() - { - ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer1"), - ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer2"), - ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer3"), - ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer4"), - ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer5"), - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } + public override List BackgroundShaders => new List() + { + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + }; + public override List BackgroundTextures => new List() + { + ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer1"), + ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer2"), + ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer3"), + ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer4"), + ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/GruesomeEminence_Ghost_Layer5"), + }; + public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) + { + Particles.Add(new FusableParticle(center, sizeStrength)); + return Particles.Last(); + } - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 2.5f, 0f, 400f) * 0.97f; - } + public override void UpdateBehavior(FusableParticle particle) + { + particle.Size = MathHelper.Clamp(particle.Size - 2.5f, 0f, 400f) * 0.97f; + } - public override void PrepareOptionalShaderData(Effect effect, int index) - { - switch (index) - { - // Background. - case 0: - Vector2 offset = Vector2.UnitX * Main.GlobalTime * 0.03f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; + public override void PrepareOptionalShaderData(Effect effect, int index) + { + switch (index) + { + // Background. + case 0: + Vector2 offset = Vector2.UnitX * Main.GlobalTime * 0.03f; + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + break; - // Gaseous skulls. - case 1: - offset = Vector2.One * (float)Math.Cos(Main.GlobalTime * 0.041f) * 2f; - offset = offset.RotatedBy((float)Math.Cos(Main.GlobalTime * 0.08f) * 0.97f); - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; + // Gaseous skulls. + case 1: + offset = Vector2.One * (float)Math.Cos(Main.GlobalTime * 0.041f) * 2f; + offset = offset.RotatedBy((float)Math.Cos(Main.GlobalTime * 0.08f) * 0.97f); + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + break; - // Spooky faces 1. - case 2: - offset = (Main.GlobalTime * 2.02f).ToRotationVector2() * 0.036f; - offset.Y += (float)Math.Cos(Main.GlobalTime * 0.161f) * 0.5f + 0.5f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; + // Spooky faces 1. + case 2: + offset = (Main.GlobalTime * 2.02f).ToRotationVector2() * 0.036f; + offset.Y += (float)Math.Cos(Main.GlobalTime * 0.161f) * 0.5f + 0.5f; + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + break; - // Spooky faces 2. - case 3: - offset = Vector2.UnitX * Main.GlobalTime * -0.04f + (Main.GlobalTime * 1.89f).ToRotationVector2() * 0.03f; - offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTime * 0.187f, Main.GlobalTime * 0.193f, 2, 466920161) * 0.025f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; + // Spooky faces 2. + case 3: + offset = Vector2.UnitX * Main.GlobalTime * -0.04f + (Main.GlobalTime * 1.89f).ToRotationVector2() * 0.03f; + offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTime * 0.187f, Main.GlobalTime * 0.193f, 2, 466920161) * 0.025f; + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + break; - // Spooky faces 3. - case 4: - offset = Vector2.UnitX * Main.GlobalTime * 0.037f + (Main.GlobalTime * 1.77f).ToRotationVector2() * 0.04725f; - offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTime * 0.187f, Main.GlobalTime * 0.193f, 2, 577215664) * 0.05f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; - } - } + // Spooky faces 3. + case 4: + offset = Vector2.UnitX * Main.GlobalTime * 0.037f + (Main.GlobalTime * 1.77f).ToRotationVector2() * 0.04725f; + offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTime * 0.187f, Main.GlobalTime * 0.193f, 2, 577215664) * 0.05f; + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + break; + } + } - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase"); - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } + public override void DrawParticles() + { + Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase"); + foreach (FusableParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = fusableParticleBase.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); + Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } } diff --git a/Particles/HeavySmoke.cs b/Particles/HeavySmoke.cs index 43ec89b23f..c3bebcb39e 100644 --- a/Particles/HeavySmoke.cs +++ b/Particles/HeavySmoke.cs @@ -5,7 +5,7 @@ using Terraria; namespace CalamityMod.Particles { - public class HeavySmokeParticle : Particle + public class HeavySmokeParticle : Particle { public override bool SetLifetime => true; public override int FrameVariants => 7; diff --git a/Particles/MediumMistParticle.cs b/Particles/MediumMistParticle.cs index 876d769ef5..d96a30f0f6 100644 --- a/Particles/MediumMistParticle.cs +++ b/Particles/MediumMistParticle.cs @@ -4,7 +4,7 @@ using Terraria; namespace CalamityMod.Particles { - public class MediumMistParticle : Particle + public class MediumMistParticle : Particle { public override string Texture => "CalamityMod/Particles/MediumMist"; public override int FrameVariants => 3; diff --git a/Particles/Particle.cs b/Particles/Particle.cs index c3525fbfec..f69530d024 100644 --- a/Particles/Particle.cs +++ b/Particles/Particle.cs @@ -3,85 +3,85 @@ using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Particles { - public class Particle - { - /// - /// The ID of the particle inside of the general particle handler's array. This is set automatically when the particle is created - /// - public int ID; - /// - /// The ID of the particle type as registered by the general particle handler. This is set automatically when the particle handler loads - /// - public int Type; - /// - /// The amount of frames this particle has existed for. You shouldn't have to touch this manually. - /// - public int Time; + public class Particle + { + /// + /// The ID of the particle inside of the general particle handler's array. This is set automatically when the particle is created + /// + public int ID; + /// + /// The ID of the particle type as registered by the general particle handler. This is set automatically when the particle handler loads + /// + public int Type; + /// + /// The amount of frames this particle has existed for. You shouldn't have to touch this manually. + /// + public int Time; - /// - /// Set this to true if you NEED the particle to render even if the particle cap is reached. - /// - public virtual bool Important => false; + /// + /// Set this to true if you NEED the particle to render even if the particle cap is reached. + /// + public virtual bool Important => false; - /// - /// Set this to true if you want your particle to automatically get removed when its time reaches its maximum lifetime - /// - public virtual bool SetLifetime => false; - /// - /// The maximum amount of frames a particle may stay alive if Particle.SetLifeTime is set to true - /// - public int Lifetime = 0; + /// + /// Set this to true if you want your particle to automatically get removed when its time reaches its maximum lifetime + /// + public virtual bool SetLifetime => false; + /// + /// The maximum amount of frames a particle may stay alive if Particle.SetLifeTime is set to true + /// + public int Lifetime = 0; - public float LifetimeCompletion => Lifetime != 0 ? Time / (float)Lifetime : 0; + public float LifetimeCompletion => Lifetime != 0 ? Time / (float)Lifetime : 0; - /// - /// The offset of the particle in relation to the origin of the set it belongs to. This is only used in the context of a Particle Set - /// - public Vector2 RelativeOffset; - /// - /// The inworld position of a particle. Keep in mind this isn't used in the context of a Particle Set, since all the particles work off their relative position to the set's origin - /// - public Vector2 Position; - public Vector2 Velocity; + /// + /// The offset of the particle in relation to the origin of the set it belongs to. This is only used in the context of a Particle Set + /// + public Vector2 RelativeOffset; + /// + /// The inworld position of a particle. Keep in mind this isn't used in the context of a Particle Set, since all the particles work off their relative position to the set's origin + /// + public Vector2 Position; + public Vector2 Velocity; - public Vector2 Origin; - public Color Color; - public float Rotation; - public float Scale; + public Vector2 Origin; + public Color Color; + public float Rotation; + public float Scale; - public virtual int FrameVariants => 1; - public int Variant = 0; - public virtual string Texture => ""; - /// - /// Set this to true to disable default particle drawing, thus calling Particle.CustomDraw() instead. - /// - public virtual bool UseCustomDraw => false; - /// - /// Use this method if you want to handle the particle drawing yourself. Only called if Particle.UseCustomDraw is set to true. - /// - public virtual void CustomDraw(SpriteBatch spriteBatch) { } + public virtual int FrameVariants => 1; + public int Variant = 0; + public virtual string Texture => ""; + /// + /// Set this to true to disable default particle drawing, thus calling Particle.CustomDraw() instead. + /// + public virtual bool UseCustomDraw => false; + /// + /// Use this method if you want to handle the particle drawing yourself. Only called if Particle.UseCustomDraw is set to true. + /// + public virtual void CustomDraw(SpriteBatch spriteBatch) { } - public virtual void CustomDraw(SpriteBatch spriteBatch, Vector2 basePosition) { } - /// - /// Called for every update of the particle handler. - /// The particle's velocity gets automatically added to its position, and its time automatically increases. - /// - public virtual void Update() { } + public virtual void CustomDraw(SpriteBatch spriteBatch, Vector2 basePosition) { } + /// + /// Called for every update of the particle handler. + /// The particle's velocity gets automatically added to its position, and its time automatically increases. + /// + public virtual void Update() { } - /// - /// Set this to true to make your particle use additive blending instead of alphablend. - /// - public virtual bool UseAdditiveBlend => false; + /// + /// Set this to true to make your particle use additive blending instead of alphablend. + /// + public virtual bool UseAdditiveBlend => false; - /// - /// Set this to true to make your particles work with semi transparent pixels. Is overriden if UseAdditiveBlend is set to true. - /// - public virtual bool UseHalfTransparency => false; + /// + /// Set this to true to make your particles work with semi transparent pixels. Is overriden if UseAdditiveBlend is set to true. + /// + public virtual bool UseHalfTransparency => false; - /// - /// Removes the particle from the handler - /// - public void Kill() => GeneralParticleHandler.RemoveParticle(this); + /// + /// Removes the particle from the handler + /// + public void Kill() => GeneralParticleHandler.RemoveParticle(this); - } + } } \ No newline at end of file diff --git a/Particles/RancorGroundLavaParticleSet.cs b/Particles/RancorGroundLavaParticleSet.cs index 96fa1b6cc0..783f6c16a7 100644 --- a/Particles/RancorGroundLavaParticleSet.cs +++ b/Particles/RancorGroundLavaParticleSet.cs @@ -8,45 +8,45 @@ using Terraria.ModLoader; namespace CalamityMod.Particles { - public class RancorGroundLavaParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 18f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.Yellow, Color.Red, 0.85f) * 0.85f; - public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverWater; + public class RancorGroundLavaParticleSet : BaseFusableParticleSet + { + public override float BorderSize => 18f; + public override bool BorderShouldBeSolid => false; + public override Color BorderColor => Color.Lerp(Color.Yellow, Color.Red, 0.85f) * 0.85f; + public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverWater; - public override List BackgroundShaders => new List() - { - GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new List() - { - ModContent.GetTexture("CalamityMod/Projectiles/InvisibleProj"), - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } + public override List BackgroundShaders => new List() + { + GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, + }; + public override List BackgroundTextures => new List() + { + ModContent.GetTexture("CalamityMod/Projectiles/InvisibleProj"), + }; + public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) + { + Particles.Add(new FusableParticle(center, sizeStrength)); + return Particles.Last(); + } - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 0.15f, 0f, 200f) * 0.997f; - if (particle.Size < 20f) - particle.Size = particle.Size * 0.95f - 0.9f; - } + public override void UpdateBehavior(FusableParticle particle) + { + particle.Size = MathHelper.Clamp(particle.Size - 0.15f, 0f, 200f) * 0.997f; + if (particle.Size < 20f) + particle.Size = particle.Size * 0.95f - 0.9f; + } - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase"); - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size() * new Vector2(1f, 0.5f); - Color drawColor = Color.Lerp(BorderColor, new Color(0f, 0f, 1f), Utils.InverseLerp(120f, 135f, particle.Size, true) * 0.1f) * 1.4f; - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } + public override void DrawParticles() + { + Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase"); + foreach (FusableParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = fusableParticleBase.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size() * new Vector2(1f, 0.5f); + Color drawColor = Color.Lerp(BorderColor, new Color(0f, 0f, 1f), Utils.InverseLerp(120f, 135f, particle.Size, true) * 0.1f) * 1.4f; + Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } } diff --git a/Particles/RancorLavaParticleSet.cs b/Particles/RancorLavaParticleSet.cs index c190b256d6..dca39c16b1 100644 --- a/Particles/RancorLavaParticleSet.cs +++ b/Particles/RancorLavaParticleSet.cs @@ -8,44 +8,44 @@ using Terraria.ModLoader; namespace CalamityMod.Particles { - public class RancorLavaParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 18f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.Yellow, Color.Red, 0.85f) * 0.85f; - public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverNPCsBeforeProjectiles; + public class RancorLavaParticleSet : BaseFusableParticleSet + { + public override float BorderSize => 18f; + public override bool BorderShouldBeSolid => false; + public override Color BorderColor => Color.Lerp(Color.Yellow, Color.Red, 0.85f) * 0.85f; + public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverNPCsBeforeProjectiles; - public override List BackgroundShaders => new List() - { - GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new List() - { - ModContent.GetTexture("CalamityMod/Projectiles/InvisibleProj"), - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } + public override List BackgroundShaders => new List() + { + GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, + }; + public override List BackgroundTextures => new List() + { + ModContent.GetTexture("CalamityMod/Projectiles/InvisibleProj"), + }; + public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) + { + Particles.Add(new FusableParticle(center, sizeStrength)); + return Particles.Last(); + } - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 0.24f, 0f, 200f) * 0.9956f; - if (particle.Size < 15f) - particle.Size = particle.Size * 0.95f - 0.9f; - } + public override void UpdateBehavior(FusableParticle particle) + { + particle.Size = MathHelper.Clamp(particle.Size - 0.24f, 0f, 200f) * 0.9956f; + if (particle.Size < 15f) + particle.Size = particle.Size * 0.95f - 0.9f; + } - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase"); - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, BorderColor * 1.2f, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } + public override void DrawParticles() + { + Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase"); + foreach (FusableParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = fusableParticleBase.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); + Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, BorderColor * 1.2f, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } } diff --git a/Particles/SeaFoamParticle.cs b/Particles/SeaFoamParticle.cs index 54a16b7d77..e496181cf4 100644 --- a/Particles/SeaFoamParticle.cs +++ b/Particles/SeaFoamParticle.cs @@ -4,7 +4,7 @@ using Terraria; namespace CalamityMod.Particles { - public class SeaFoamParticle : Particle + public class SeaFoamParticle : Particle { public override string Texture => "CalamityMod/Particles/SeaFoam"; public override int FrameVariants => 3; diff --git a/Particles/SemiCircularSmearVFX.cs b/Particles/SemiCircularSmearVFX.cs index 41ff135567..eee194cd8e 100644 --- a/Particles/SemiCircularSmearVFX.cs +++ b/Particles/SemiCircularSmearVFX.cs @@ -4,7 +4,7 @@ using Terraria; namespace CalamityMod.Particles { - public class SemiCircularSmearVFX : Particle //Also check out Split mod! + public class SemiCircularSmearVFX : Particle //Also check out Split mod! { public override string Texture => "CalamityMod/Particles/SemiCircularSmear"; public override bool UseAdditiveBlend => true; diff --git a/Particles/SmallSmokeParticle.cs b/Particles/SmallSmokeParticle.cs index 01656c9e52..244555699f 100644 --- a/Particles/SmallSmokeParticle.cs +++ b/Particles/SmallSmokeParticle.cs @@ -4,7 +4,7 @@ using Terraria; namespace CalamityMod.Particles { - public class SmallSmokeParticle : Particle + public class SmallSmokeParticle : Particle { public override string Texture => "CalamityMod/Particles/SmallSmoke"; diff --git a/Particles/SquishyLightParticle.cs b/Particles/SquishyLightParticle.cs index 2257579e3e..ae2ad2fb5f 100644 --- a/Particles/SquishyLightParticle.cs +++ b/Particles/SquishyLightParticle.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Particles { - public class SquishyLightParticle : Particle + public class SquishyLightParticle : Particle { public override string Texture => "CalamityMod/Particles/Light"; public override bool UseAdditiveBlend => true; diff --git a/Particles/StoneDebrisParticle.cs b/Particles/StoneDebrisParticle.cs index 7038326aa3..fb58e0feea 100644 --- a/Particles/StoneDebrisParticle.cs +++ b/Particles/StoneDebrisParticle.cs @@ -4,7 +4,7 @@ using Terraria; namespace CalamityMod.Particles { - public class StoneDebrisParticle : Particle + public class StoneDebrisParticle : Particle { public override string Texture => "CalamityMod/Particles/StoneDebris"; public override bool SetLifetime => true; diff --git a/Particles/StreamGougeParticleSet.cs b/Particles/StreamGougeParticleSet.cs index 01b803e10d..051cf4090b 100644 --- a/Particles/StreamGougeParticleSet.cs +++ b/Particles/StreamGougeParticleSet.cs @@ -8,55 +8,55 @@ using Terraria.ModLoader; namespace CalamityMod.Particles { - public class StreamGougeParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 3f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.DarkBlue, Color.Black, 0.75f) * 0.85f; - public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverNPCsBeforeProjectiles; + public class StreamGougeParticleSet : BaseFusableParticleSet + { + public override float BorderSize => 3f; + public override bool BorderShouldBeSolid => false; + public override Color BorderColor => Color.Lerp(Color.DarkBlue, Color.Black, 0.75f) * 0.85f; + public override FusableParticleRenderLayer RenderLayer => FusableParticleRenderLayer.OverNPCsBeforeProjectiles; - public override List BackgroundShaders => new List() - { - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new List() - { - ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/StreamGougeLayer"), - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } + public override List BackgroundShaders => new List() + { + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + }; + public override List BackgroundTextures => new List() + { + ModContent.GetTexture("CalamityMod/ExtraTextures/ParticleBackgrounds/StreamGougeLayer"), + }; + public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) + { + Particles.Add(new FusableParticle(center, sizeStrength)); + return Particles.Last(); + } - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 1f, 0f, 200f) * 0.98f; - } + public override void UpdateBehavior(FusableParticle particle) + { + particle.Size = MathHelper.Clamp(particle.Size - 1f, 0f, 200f) * 0.98f; + } - public override void PrepareOptionalShaderData(Effect effect, int index) - { - switch (index) - { - // Background. - case 0: - Vector2 offset = Vector2.UnitX * Main.GlobalTime * 0.045f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - effect.Parameters["upscaleFactor"].SetValue(Vector2.One * -0.3f); - break; - } - } + public override void PrepareOptionalShaderData(Effect effect, int index) + { + switch (index) + { + // Background. + case 0: + Vector2 offset = Vector2.UnitX * Main.GlobalTime * 0.045f; + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + effect.Parameters["upscaleFactor"].SetValue(Vector2.One * -0.3f); + break; + } + } - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase"); - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } + public override void DrawParticles() + { + Texture2D fusableParticleBase = ModContent.GetTexture("CalamityMod/ExtraTextures/FusableParticleBase"); + foreach (FusableParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = fusableParticleBase.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); + Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } } diff --git a/Particles/ThanatosSmokeParticle.cs b/Particles/ThanatosSmokeParticle.cs index 424310a36f..04317d2cbc 100644 --- a/Particles/ThanatosSmokeParticle.cs +++ b/Particles/ThanatosSmokeParticle.cs @@ -4,7 +4,7 @@ using Terraria; namespace CalamityMod.Particles { - public class ThanatosSmokeParticle : Particle + public class ThanatosSmokeParticle : Particle { public float RelativePower; public float BaseMoveRotation; diff --git a/Particles/ThanatosSmokeParticleSet.cs b/Particles/ThanatosSmokeParticleSet.cs index 68d018ea6e..48d48ef6db 100644 --- a/Particles/ThanatosSmokeParticleSet.cs +++ b/Particles/ThanatosSmokeParticleSet.cs @@ -2,23 +2,23 @@ using Terraria; namespace CalamityMod.Particles { - public class ThanatosSmokeParticleSet : BaseParticleSet - { - public override int ParticleLifetime => 30; + public class ThanatosSmokeParticleSet : BaseParticleSet + { + public override int ParticleLifetime => 30; public float SpawnAreaCompactness; - public float RelativePower; - public float BaseMoveRotation; - public float MoveRotationOffset; + public float RelativePower; + public float BaseMoveRotation; + public float MoveRotationOffset; - public ThanatosSmokeParticleSet(int setLifetime, int particleSpawnRate, float baseMoveRotation, float spawnAreaCompactness, float relativePower) : - base(setLifetime, particleSpawnRate) - { - MoveRotationOffset = Main.rand.NextFloat(-0.36f, 0.36f); - BaseMoveRotation = baseMoveRotation; - SpawnAreaCompactness = spawnAreaCompactness; - RelativePower = relativePower; - } + public ThanatosSmokeParticleSet(int setLifetime, int particleSpawnRate, float baseMoveRotation, float spawnAreaCompactness, float relativePower) : + base(setLifetime, particleSpawnRate) + { + MoveRotationOffset = Main.rand.NextFloat(-0.36f, 0.36f); + BaseMoveRotation = baseMoveRotation; + SpawnAreaCompactness = spawnAreaCompactness; + RelativePower = relativePower; + } - public override Particle SpawnParticle() => new ThanatosSmokeParticle(Main.rand.NextVector2Circular(1f, 1f) * SpawnAreaCompactness, ParticleLifetime, 0.06f, RelativePower, BaseMoveRotation); - } + public override Particle SpawnParticle() => new ThanatosSmokeParticle(Main.rand.NextVector2Circular(1f, 1f) * SpawnAreaCompactness, ParticleLifetime, 0.06f, RelativePower, BaseMoveRotation); + } } \ No newline at end of file diff --git a/Particles/ThunderBoltVFX.cs b/Particles/ThunderBoltVFX.cs index b076862e9c..14f7c5b725 100644 --- a/Particles/ThunderBoltVFX.cs +++ b/Particles/ThunderBoltVFX.cs @@ -4,7 +4,7 @@ using Terraria; namespace CalamityMod.Particles { - public class ThunderBoltVFX : Particle //Also check out Split mod! + public class ThunderBoltVFX : Particle //Also check out Split mod! { public override string Texture => "CalamityMod/Particles/ThunderBolt"; public override bool UseAdditiveBlend => true; diff --git a/Particles/TrientCircularSmearVFX.cs b/Particles/TrientCircularSmearVFX.cs index 70c36f4b23..69d0d712cc 100644 --- a/Particles/TrientCircularSmearVFX.cs +++ b/Particles/TrientCircularSmearVFX.cs @@ -2,7 +2,7 @@ namespace CalamityMod.Particles { - public class TrientCircularSmear : Particle //Trient aka semi but for thirds + public class TrientCircularSmear : Particle //Trient aka semi but for thirds { public override string Texture => "CalamityMod/Particles/TrientCircularSmear"; public override bool UseAdditiveBlend => true; diff --git a/Particles/WaterGlobParticle.cs b/Particles/WaterGlobParticle.cs index 2708360116..c416c4eb64 100644 --- a/Particles/WaterGlobParticle.cs +++ b/Particles/WaterGlobParticle.cs @@ -4,7 +4,7 @@ using Terraria; namespace CalamityMod.Particles { - public class WaterGlobParticle : Particle + public class WaterGlobParticle : Particle { public override string Texture => "CalamityMod/Particles/WaterGlob"; diff --git a/Prefixes/AccessoryPrefix.cs b/Prefixes/AccessoryPrefix.cs index 0235bbd3d0..cfce2c0cf2 100644 --- a/Prefixes/AccessoryPrefix.cs +++ b/Prefixes/AccessoryPrefix.cs @@ -5,75 +5,75 @@ using Terraria.ModLoader; namespace CalamityMod.Prefixes { - public class AccessoryPrefix : ModPrefix - { - //Thank you Thomas for helping me set this up =D - internal static List AccessoryModifiers; - internal float stealthGenBonus = 1f; + public class AccessoryPrefix : ModPrefix + { + //Thank you Thomas for helping me set this up =D + internal static List AccessoryModifiers; + internal float stealthGenBonus = 1f; - public override PrefixCategory Category => PrefixCategory.Accessory; + public override PrefixCategory Category => PrefixCategory.Accessory; - public AccessoryPrefix() - { + public AccessoryPrefix() + { - } + } - public AccessoryPrefix(float stealthGenBonus = 1f) - { - this.stealthGenBonus = stealthGenBonus; - } + public AccessoryPrefix(float stealthGenBonus = 1f) + { + this.stealthGenBonus = stealthGenBonus; + } - public override bool Autoload(ref string name) - { - if (base.Autoload(ref name)) - { - AccessoryModifiers = new List(); - AddAccessoryPrefix(mod, AccPrefixType.Quiet, 1.02f); - AddAccessoryPrefix(mod, AccPrefixType.Cloaked, 1.04f); - AddAccessoryPrefix(mod, AccPrefixType.Camouflaged, 1.06f); - AddAccessoryPrefix(mod, AccPrefixType.Silent, 1.08f); - } - return false; - } + public override bool Autoload(ref string name) + { + if (base.Autoload(ref name)) + { + AccessoryModifiers = new List(); + AddAccessoryPrefix(mod, AccPrefixType.Quiet, 1.02f); + AddAccessoryPrefix(mod, AccPrefixType.Cloaked, 1.04f); + AddAccessoryPrefix(mod, AccPrefixType.Camouflaged, 1.06f); + AddAccessoryPrefix(mod, AccPrefixType.Silent, 1.08f); + } + return false; + } - public override void Apply(Item item) - { - item.Calamity().StealthGenBonus = stealthGenBonus; - } + public override void Apply(Item item) + { + item.Calamity().StealthGenBonus = stealthGenBonus; + } - public override void ModifyValue(ref float valueMult) - { - float extraValue = 1f + (2.5f * (stealthGenBonus - 1f)); - valueMult *= extraValue; - } + public override void ModifyValue(ref float valueMult) + { + float extraValue = 1f + (2.5f * (stealthGenBonus - 1f)); + valueMult *= extraValue; + } - public override float RollChance(Item item) - { - if (item.vanity) - return 0f; - if (item.type == ItemID.GuideVoodooDoll || item.type == ItemID.MusicBox || item.type == ItemID.ClothierVoodooDoll) - return 0f; - if (item.type >= ItemID.MusicBoxOverworldDay && item.type <= ItemID.MusicBoxBoss3) - return 0f; - if (item.type >= ItemID.MusicBoxSnow && item.type <= ItemID.MusicBoxMushrooms) - return 0f; + public override float RollChance(Item item) + { + if (item.vanity) + return 0f; + if (item.type == ItemID.GuideVoodooDoll || item.type == ItemID.MusicBox || item.type == ItemID.ClothierVoodooDoll) + return 0f; + if (item.type >= ItemID.MusicBoxOverworldDay && item.type <= ItemID.MusicBoxBoss3) + return 0f; + if (item.type >= ItemID.MusicBoxSnow && item.type <= ItemID.MusicBoxMushrooms) + return 0f; - return 1f; - } + return 1f; + } - private static void AddAccessoryPrefix(Mod mod, AccPrefixType prefixType, float stealthGenBonus = 1f) - { - string name = prefixType.ToString(); - mod.AddPrefix(name, new AccessoryPrefix(stealthGenBonus)); - AccessoryModifiers.Add(mod.GetPrefix(name).Type); - } - } + private static void AddAccessoryPrefix(Mod mod, AccPrefixType prefixType, float stealthGenBonus = 1f) + { + string name = prefixType.ToString(); + mod.AddPrefix(name, new AccessoryPrefix(stealthGenBonus)); + AccessoryModifiers.Add(mod.GetPrefix(name).Type); + } + } - public enum AccPrefixType : byte - { - Quiet, - Cloaked, - Camouflaged, - Silent - } + public enum AccPrefixType : byte + { + Quiet, + Cloaked, + Camouflaged, + Silent + } } \ No newline at end of file diff --git a/Prefixes/RoguePrefix.cs b/Prefixes/RoguePrefix.cs index 0a4ecd5ec4..2e5ed4fb9d 100644 --- a/Prefixes/RoguePrefix.cs +++ b/Prefixes/RoguePrefix.cs @@ -5,108 +5,108 @@ using Terraria.ModLoader; namespace CalamityMod.Prefixes { - public class RoguePrefix : ModPrefix - { - //Thank you Thomas for helping me set this up =D - internal static List RogueModifiers; - internal float damageMult = 1f; - internal float useTimeMult = 1f; - internal int critBonus = 0; - internal float shootSpeedMult = 1f; - internal float stealthDmgMult = 1f; + public class RoguePrefix : ModPrefix + { + //Thank you Thomas for helping me set this up =D + internal static List RogueModifiers; + internal float damageMult = 1f; + internal float useTimeMult = 1f; + internal int critBonus = 0; + internal float shootSpeedMult = 1f; + internal float stealthDmgMult = 1f; - public override PrefixCategory Category => PrefixCategory.Custom; + public override PrefixCategory Category => PrefixCategory.Custom; - public RoguePrefix() - { + public RoguePrefix() + { - } + } - public RoguePrefix(float damageMult = 1f, float useTimeMult = 1f, int critBonus = 0, float shootSpeedMult = 1f, float stealthDmgMult = 1f) - { - this.damageMult = damageMult; - this.useTimeMult = useTimeMult; - this.critBonus = critBonus; - this.shootSpeedMult = shootSpeedMult; - this.stealthDmgMult = stealthDmgMult; - } + public RoguePrefix(float damageMult = 1f, float useTimeMult = 1f, int critBonus = 0, float shootSpeedMult = 1f, float stealthDmgMult = 1f) + { + this.damageMult = damageMult; + this.useTimeMult = useTimeMult; + this.critBonus = critBonus; + this.shootSpeedMult = shootSpeedMult; + this.stealthDmgMult = stealthDmgMult; + } - public override bool Autoload(ref string name) - { - if (base.Autoload(ref name)) - { - //Damage, Use Time, Crit, Velocity, SS Dmg - RogueModifiers = new List(); - AddRoguePrefix(mod, RoguePrefixType.Pointy, 1.1f, 1f, 0, 1f, 1f); - AddRoguePrefix(mod, RoguePrefixType.Sharp, 1.15f, 1f, 0, 1f, 1f); - AddRoguePrefix(mod, RoguePrefixType.Feathered, 1f, 0.85f, 0, 1.1f, 1f); - AddRoguePrefix(mod, RoguePrefixType.Sleek, 1f, 0.9f, 0, 1.15f, 1f); - AddRoguePrefix(mod, RoguePrefixType.Hefty, 1.1f, 1f, 0, 1f, 1.15f); - AddRoguePrefix(mod, RoguePrefixType.Mighty, 1.15f, 1f, 0, 1f, 1.05f); - AddRoguePrefix(mod, RoguePrefixType.Glorious, 1.1f, 0.95f, 0, 1f, 1f); - AddRoguePrefix(mod, RoguePrefixType.Serrated, 1.1f, 0.9f, 0, 1.05f, 1f); - AddRoguePrefix(mod, RoguePrefixType.Vicious, 1.1f, 0.95f, 0, 1.15f, 1f); - AddRoguePrefix(mod, RoguePrefixType.Lethal, 1.1f, 0.95f, 2, 1.05f, 1.05f); - AddRoguePrefix(mod, RoguePrefixType.Flawless, 1.15f, 0.9f, 5, 1.1f, 1.15f); - AddRoguePrefix(mod, RoguePrefixType.Radical, 1.05f, 0.95f, 0, 1.05f, 0.9f); - AddRoguePrefix(mod, RoguePrefixType.Blunt, 0.85f, 1f, 0, 1f, 1f); - AddRoguePrefix(mod, RoguePrefixType.Flimsy, 0.9f, 1f, 0, 1f, 0.9f); - AddRoguePrefix(mod, RoguePrefixType.Unbalanced, 1f, 1.15f, 0, 0.95f, 1f); - AddRoguePrefix(mod, RoguePrefixType.Atrocious, 0.85f, 1f, 0, 0.9f, 0.9f); - } - return false; - } + public override bool Autoload(ref string name) + { + if (base.Autoload(ref name)) + { + //Damage, Use Time, Crit, Velocity, SS Dmg + RogueModifiers = new List(); + AddRoguePrefix(mod, RoguePrefixType.Pointy, 1.1f, 1f, 0, 1f, 1f); + AddRoguePrefix(mod, RoguePrefixType.Sharp, 1.15f, 1f, 0, 1f, 1f); + AddRoguePrefix(mod, RoguePrefixType.Feathered, 1f, 0.85f, 0, 1.1f, 1f); + AddRoguePrefix(mod, RoguePrefixType.Sleek, 1f, 0.9f, 0, 1.15f, 1f); + AddRoguePrefix(mod, RoguePrefixType.Hefty, 1.1f, 1f, 0, 1f, 1.15f); + AddRoguePrefix(mod, RoguePrefixType.Mighty, 1.15f, 1f, 0, 1f, 1.05f); + AddRoguePrefix(mod, RoguePrefixType.Glorious, 1.1f, 0.95f, 0, 1f, 1f); + AddRoguePrefix(mod, RoguePrefixType.Serrated, 1.1f, 0.9f, 0, 1.05f, 1f); + AddRoguePrefix(mod, RoguePrefixType.Vicious, 1.1f, 0.95f, 0, 1.15f, 1f); + AddRoguePrefix(mod, RoguePrefixType.Lethal, 1.1f, 0.95f, 2, 1.05f, 1.05f); + AddRoguePrefix(mod, RoguePrefixType.Flawless, 1.15f, 0.9f, 5, 1.1f, 1.15f); + AddRoguePrefix(mod, RoguePrefixType.Radical, 1.05f, 0.95f, 0, 1.05f, 0.9f); + AddRoguePrefix(mod, RoguePrefixType.Blunt, 0.85f, 1f, 0, 1f, 1f); + AddRoguePrefix(mod, RoguePrefixType.Flimsy, 0.9f, 1f, 0, 1f, 0.9f); + AddRoguePrefix(mod, RoguePrefixType.Unbalanced, 1f, 1.15f, 0, 0.95f, 1f); + AddRoguePrefix(mod, RoguePrefixType.Atrocious, 0.85f, 1f, 0, 0.9f, 0.9f); + } + return false; + } - public override void Apply(Item item) - { - ModItem moddedItem = item.modItem; - if (moddedItem != null && moddedItem is RogueWeapon rogueWep) - { - rogueWep.StealthStrikePrefixBonus = stealthDmgMult; - } - } + public override void Apply(Item item) + { + ModItem moddedItem = item.modItem; + if (moddedItem != null && moddedItem is RogueWeapon rogueWep) + { + rogueWep.StealthStrikePrefixBonus = stealthDmgMult; + } + } - public override void ModifyValue(ref float valueMult) - { - float extraValue = 1f + (1f * (stealthDmgMult - 1f)); - valueMult *= extraValue; - } + public override void ModifyValue(ref float valueMult) + { + float extraValue = 1f + (1f * (stealthDmgMult - 1f)); + valueMult *= extraValue; + } - public override bool CanRoll(Item item) => item.Calamity().rogue && item.maxStack == 1; + public override bool CanRoll(Item item) => item.Calamity().rogue && item.maxStack == 1; - public override void SetStats(ref float damageMult, ref float knockbackMult, ref float useTimeMult, ref float scaleMult, ref float shootSpeedMult, ref float manaMult, ref int critBonus) - { - damageMult = this.damageMult; - useTimeMult = this.useTimeMult; - critBonus = this.critBonus; - shootSpeedMult = this.shootSpeedMult; - } + public override void SetStats(ref float damageMult, ref float knockbackMult, ref float useTimeMult, ref float scaleMult, ref float shootSpeedMult, ref float manaMult, ref int critBonus) + { + damageMult = this.damageMult; + useTimeMult = this.useTimeMult; + critBonus = this.critBonus; + shootSpeedMult = this.shootSpeedMult; + } - private static void AddRoguePrefix(Mod mod, RoguePrefixType prefixType, float damageMult = 1f, float useTimeMult = 1f, int critBonus = 0, float shootSpeedMult = 1f, float stealthDmgMult = 1f) - { - string name = prefixType.ToString(); - mod.AddPrefix(name, new RoguePrefix(damageMult, useTimeMult, critBonus, shootSpeedMult, stealthDmgMult)); - RogueModifiers.Add(mod.GetPrefix(name).Type); - } - } + private static void AddRoguePrefix(Mod mod, RoguePrefixType prefixType, float damageMult = 1f, float useTimeMult = 1f, int critBonus = 0, float shootSpeedMult = 1f, float stealthDmgMult = 1f) + { + string name = prefixType.ToString(); + mod.AddPrefix(name, new RoguePrefix(damageMult, useTimeMult, critBonus, shootSpeedMult, stealthDmgMult)); + RogueModifiers.Add(mod.GetPrefix(name).Type); + } + } - public enum RoguePrefixType : byte - { - Pointy, - Sharp, - Feathered, - Sleek, - Hefty, - Mighty, - Glorious, - Serrated, - Vicious, - Lethal, - Flawless, - Radical, - Blunt, - Flimsy, - Unbalanced, - Atrocious - } + public enum RoguePrefixType : byte + { + Pointy, + Sharp, + Feathered, + Sleek, + Hefty, + Mighty, + Glorious, + Serrated, + Vicious, + Lethal, + Flawless, + Radical, + Blunt, + Flimsy, + Unbalanced, + Atrocious + } } \ No newline at end of file diff --git a/Projectiles/Boss/AbyssBallVolley.cs b/Projectiles/Boss/AbyssBallVolley.cs index 090923ad3e..caa4bab2c7 100644 --- a/Projectiles/Boss/AbyssBallVolley.cs +++ b/Projectiles/Boss/AbyssBallVolley.cs @@ -16,29 +16,29 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 30; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 30; projectile.height = 30; projectile.hostile = true; projectile.penetrate = 1; - projectile.alpha = 60; - projectile.tileCollide = false; - projectile.timeLeft = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 780 : CalamityWorld.death ? 600 : CalamityWorld.revenge ? 540 : Main.expertMode ? 480 : 300; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.alpha = 60; + projectile.tileCollide = false; + projectile.timeLeft = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 780 : CalamityWorld.death ? 600 : CalamityWorld.revenge ? 540 : Main.expertMode ? 480 : 300; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { - if (projectile.velocity.Length() < 16f && (Main.expertMode || BossRushEvent.BossRushActive)) - { - float velocityMult = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1f; - projectile.velocity *= velocityMult; - } + if (projectile.velocity.Length() < 16f && (Main.expertMode || BossRushEvent.BossRushActive)) + { + float velocityMult = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1f; + projectile.velocity *= velocityMult; + } - if (projectile.timeLeft < 60) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); + if (projectile.timeLeft < 60) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); - if (projectile.ai[1] == 0f) + if (projectile.ai[1] == 0f) { projectile.ai[1] = 1f; Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 33); @@ -50,14 +50,14 @@ namespace CalamityMod.Projectiles.Boss public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 12f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.timeLeft >= 60; + public override bool CanHitPlayer(Player target) => projectile.timeLeft >= 60; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.timeLeft < 60) - return; + if (projectile.timeLeft < 60) + return; - target.AddBuff(BuffID.Weak, 120); + target.AddBuff(BuffID.Weak, 120); } } } diff --git a/Projectiles/Boss/AbyssBallVolley2.cs b/Projectiles/Boss/AbyssBallVolley2.cs index 7a831c5291..d8b97961ea 100644 --- a/Projectiles/Boss/AbyssBallVolley2.cs +++ b/Projectiles/Boss/AbyssBallVolley2.cs @@ -16,29 +16,29 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 30; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 30; projectile.height = 30; projectile.hostile = true; projectile.penetrate = 1; - projectile.alpha = 60; - projectile.tileCollide = false; - projectile.timeLeft = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 640 : CalamityWorld.death ? 490 : CalamityWorld.revenge ? 440 : Main.expertMode ? 390 : 240; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.alpha = 60; + projectile.tileCollide = false; + projectile.timeLeft = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 640 : CalamityWorld.death ? 490 : CalamityWorld.revenge ? 440 : Main.expertMode ? 390 : 240; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { - if (projectile.velocity.Length() < 18f && (Main.expertMode || BossRushEvent.BossRushActive)) - { - float velocityMult = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1f; - projectile.velocity *= velocityMult; - } + if (projectile.velocity.Length() < 18f && (Main.expertMode || BossRushEvent.BossRushActive)) + { + float velocityMult = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1f; + projectile.velocity *= velocityMult; + } - if (projectile.timeLeft < 60) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); + if (projectile.timeLeft < 60) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); - if (projectile.ai[1] == 0f) + if (projectile.ai[1] == 0f) { projectile.ai[1] = 1f; Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 33); @@ -53,14 +53,14 @@ namespace CalamityMod.Projectiles.Boss public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 12f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.timeLeft >= 60; + public override bool CanHitPlayer(Player target) => projectile.timeLeft >= 60; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.timeLeft < 60) - return; + if (projectile.timeLeft < 60) + return; - target.AddBuff(BuffID.Darkness, 120); + target.AddBuff(BuffID.Darkness, 120); } } } diff --git a/Projectiles/Boss/ApolloChargeTelegraph.cs b/Projectiles/Boss/ApolloChargeTelegraph.cs index e75ad6b7b3..f082c973f0 100644 --- a/Projectiles/Boss/ApolloChargeTelegraph.cs +++ b/Projectiles/Boss/ApolloChargeTelegraph.cs @@ -35,13 +35,13 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 255; projectile.penetrate = -1; - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - projectile.timeLeft = malice ? 30 : death ? 40 : revenge ? 45 : expertMode ? 50 : 60; + projectile.timeLeft = malice ? 30 : death ? 40 : revenge ? 45 : expertMode ? 50 : 60; } public override void SendExtraAI(BinaryWriter writer) @@ -74,15 +74,15 @@ namespace CalamityMod.Projectiles.Boss return; } - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - // Determine opacity - float telegraphTotalTime = malice ? 30f : death ? 40f : revenge ? 45f : expertMode ? 50f : 60f; - projectile.Opacity = Utils.InverseLerp(0f, 6f, projectile.timeLeft, true) * Utils.InverseLerp(telegraphTotalTime, telegraphTotalTime - 6f, projectile.timeLeft, true); + // Determine opacity + float telegraphTotalTime = malice ? 30f : death ? 40f : revenge ? 45f : expertMode ? 50f : 60f; + projectile.Opacity = Utils.InverseLerp(0f, 6f, projectile.timeLeft, true) * Utils.InverseLerp(telegraphTotalTime, telegraphTotalTime - 6f, projectile.timeLeft, true); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Boss/ApolloFireball.cs b/Projectiles/Boss/ApolloFireball.cs index 1bf371c5d0..5a90cb25dd 100644 --- a/Projectiles/Boss/ApolloFireball.cs +++ b/Projectiles/Boss/ApolloFireball.cs @@ -11,228 +11,228 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class ApolloFireball : ModProjectile - { - private const int timeLeft = 60; + public class ApolloFireball : ModProjectile + { + private const int timeLeft = 60; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Volatile Plasma Blast"); - Main.projFrames[projectile.type] = 6; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Volatile Plasma Blast"); + Main.projFrames[projectile.type] = 6; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 48; - projectile.height = 48; - projectile.hostile = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.Opacity = 0f; - cooldownSlot = 1; - projectile.timeLeft = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 48 : timeLeft; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 48; + projectile.height = 48; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.Opacity = 0f; + cooldownSlot = 1; + projectile.timeLeft = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 48 : timeLeft; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + } - public override void AI() - { - Vector2 targetLocation = new Vector2(projectile.ai[0], projectile.ai[1]); - if (Vector2.Distance(targetLocation, projectile.Center) < 80f) - projectile.tileCollide = true; + public override void AI() + { + Vector2 targetLocation = new Vector2(projectile.ai[0], projectile.ai[1]); + if (Vector2.Distance(targetLocation, projectile.Center) < 80f) + projectile.tileCollide = true; - int fadeInTime = 3; - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - (((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 48 : timeLeft) - fadeInTime)) / (float)fadeInTime), 0f, 1f); + int fadeInTime = 3; + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - (((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 48 : timeLeft) - fadeInTime)) / (float)fadeInTime), 0f, 1f); - Lighting.AddLight(projectile.Center, 0f, 0.6f * projectile.Opacity, 0f); + Lighting.AddLight(projectile.Center, 0f, 0.6f * projectile.Opacity, 0f); - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 5) - projectile.frame = 0; + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 5) + projectile.frame = 0; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; - float speed1 = 1.8f; - float speed2 = 2.8f; - float angleRandom = 0.35f; + float speed1 = 1.8f; + float speed2 = 2.8f; + float angleRandom = 0.35f; - for (int num53 = 0; num53 < 40; num53++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int randomDustType = Main.rand.NextBool(2) ? 107 : 110; + for (int num53 = 0; num53 < 40; num53++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + int randomDustType = Main.rand.NextBool(2) ? 107 : 110; - int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - Main.dust[num54].noGravity = true; + int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + Main.dust[num54].noGravity = true; - Dust dust = Main.dust[num54]; - dust.velocity *= 3f; - dust = Main.dust[num54]; + Dust dust = Main.dust[num54]; + dust.velocity *= 3f; + dust = Main.dust[num54]; - num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - dust = Main.dust[num54]; - dust.velocity *= 2f; + dust = Main.dust[num54]; + dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Green * 0.5f; + Main.dust[num54].noGravity = true; + Main.dust[num54].fadeIn = 1f; + Main.dust[num54].color = Color.Green * 0.5f; - dust = Main.dust[num54]; - } - for (int num55 = 0; num55 < 20; num55++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int randomDustType = Main.rand.NextBool(2) ? 107 : 110; + dust = Main.dust[num54]; + } + for (int num55 = 0; num55 < 20; num55++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + int randomDustType = Main.rand.NextBool(2) ? 107 : 110; - int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); - Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; - Main.dust[num56].noGravity = true; + int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); + Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; + Main.dust[num56].noGravity = true; - Dust dust = Main.dust[num56]; - dust.velocity *= 0.5f; - dust = Main.dust[num56]; - } - } - } + Dust dust = Main.dust[num56]; + dust.velocity *= 0.5f; + dust = Main.dust[num56]; + } + } + } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.Opacity != 1f) - return; + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.Opacity != 1f) + return; - target.AddBuff(BuffID.OnFire, 360); - target.AddBuff(BuffID.CursedInferno, 180); - } + target.AddBuff(BuffID.OnFire, 360); + target.AddBuff(BuffID.CursedInferno, 180); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - lightColor.R = (byte)(255 * projectile.Opacity); - lightColor.G = (byte)(255 * projectile.Opacity); - lightColor.B = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.G = (byte)(255 * projectile.Opacity); + lightColor.B = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void Kill(int timeLeft) - { - int height = 90; - projectile.position = projectile.Center; - projectile.width = projectile.height = height; - projectile.Center = projectile.position; - projectile.Damage(); + public override void Kill(int timeLeft) + { + int height = 90; + projectile.position = projectile.Center; + projectile.width = projectile.height = height; + projectile.Center = projectile.position; + projectile.Damage(); - Main.PlaySound(SoundID.Item93, projectile.Center); + Main.PlaySound(SoundID.Item93, projectile.Center); - if (Main.myPlayer == projectile.owner) - { - bool splitNormal = true; - if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) - splitNormal = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ai[2] % 2f == 0f; - } + if (Main.myPlayer == projectile.owner) + { + bool splitNormal = true; + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + splitNormal = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ai[2] % 2f == 0f; + } - // Plasma bolts - int totalProjectiles = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 6 : 4; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - float velocity = 0.5f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = splitNormal ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(projectile.Center, velocity2, type, (int)Math.Round(projectile.damage * 0.8), 0f, Main.myPlayer); - } - } + // Plasma bolts + int totalProjectiles = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 6 : 4; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + float velocity = 0.5f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = splitNormal ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(projectile.Center, velocity2, type, (int)Math.Round(projectile.damage * 0.8), 0f, Main.myPlayer); + } + } - for (int num640 = 0; num640 < 200; num640++) - { - float num641 = 16f; - if (num640 < 150) - num641 = 12f; - if (num640 < 100) - num641 = 8f; - if (num640 < 50) - num641 = 4f; + for (int num640 = 0; num640 < 200; num640++) + { + float num641 = 16f; + if (num640 < 150) + num641 = 12f; + if (num640 < 100) + num641 = 8f; + if (num640 < 50) + num641 = 4f; - int num643 = Dust.NewDust(projectile.Center, 6, 6, Main.rand.NextBool(2) ? 107 : 110, 0f, 0f, 100, default, 1f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + int num643 = Dust.NewDust(projectile.Center, 6, 6, Main.rand.NextBool(2) ? 107 : 110, 0f, 0f, 100, default, 1f); + float num644 = Main.dust[num643].velocity.X; + float num645 = Main.dust[num643].velocity.Y; - if (num644 == 0f && num645 == 0f) - num644 = 1f; + if (num644 == 0f && num645 == 0f) + num644 = 1f; - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; + float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); + num646 = num641 / num646; + num644 *= num646; + num645 *= num646; - float scale = 1f; - switch ((int)num641) - { - case 4: - scale = 1.2f; - break; - case 8: - scale = 1.1f; - break; - case 12: - scale = 1f; - break; - case 16: - scale = 0.9f; - break; - default: - break; - } + float scale = 1f; + switch ((int)num641) + { + case 4: + scale = 1.2f; + break; + case 8: + scale = 1.1f; + break; + case 12: + scale = 1f; + break; + case 16: + scale = 0.9f; + break; + default: + break; + } - Dust dust = Main.dust[num643]; - dust.velocity *= 0.5f; - dust.velocity.X = dust.velocity.X + num644; - dust.velocity.Y = dust.velocity.Y + num645; - dust.scale = scale; - dust.noGravity = true; - } - } + Dust dust = Main.dust[num643]; + dust.velocity *= 0.5f; + dust.velocity.X = dust.velocity.X + num644; + dust.velocity.Y = dust.velocity.Y + num645; + dust.scale = scale; + dust.noGravity = true; + } + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/ApolloRocket.cs b/Projectiles/Boss/ApolloRocket.cs index 8aca64e77f..3662996c84 100644 --- a/Projectiles/Boss/ApolloRocket.cs +++ b/Projectiles/Boss/ApolloRocket.cs @@ -117,21 +117,21 @@ namespace CalamityMod.Projectiles.Boss } } - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - // Light - Lighting.AddLight(projectile.Center, 0f, 0.6f, 0f); + // Light + Lighting.AddLight(projectile.Center, 0f, 0.6f, 0f); // Get a target and calculate distance from it int target = Player.FindClosest(projectile.Center, 1, 1); Vector2 distanceFromTarget = Main.player[target].Center - projectile.Center; - // Set AI to stop homing, start accelerating - float stopHomingDistance = malice ? 120f : death ? 160f : revenge ? 180f : expertMode ? 200f : 240f; + // Set AI to stop homing, start accelerating + float stopHomingDistance = malice ? 120f : death ? 160f : revenge ? 180f : expertMode ? 200f : 240f; if (distanceFromTarget.Length() < stopHomingDistance || projectile.ai[0] == 1f || projectile.timeLeft < 480) { projectile.ai[0] = 1f; @@ -151,33 +151,33 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity.Normalize(); projectile.velocity *= scaleFactor; - // Fly away from other rockets - float pushForce = malice ? 0.07f : death ? 0.06f : revenge ? 0.055f : expertMode ? 0.05f : 0.04f; - float pushDistance = malice ? 120f : death ? 100f : revenge ? 90f : expertMode ? 80f : 60f; - for (int k = 0; k < Main.maxProjectiles; k++) - { - Projectile otherProj = Main.projectile[k]; - // Short circuits to make the loop as fast as possible - if (!otherProj.active || k == projectile.whoAmI) - continue; + // Fly away from other rockets + float pushForce = malice ? 0.07f : death ? 0.06f : revenge ? 0.055f : expertMode ? 0.05f : 0.04f; + float pushDistance = malice ? 120f : death ? 100f : revenge ? 90f : expertMode ? 80f : 60f; + for (int k = 0; k < Main.maxProjectiles; k++) + { + Projectile otherProj = Main.projectile[k]; + // Short circuits to make the loop as fast as possible + if (!otherProj.active || k == projectile.whoAmI) + continue; - // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. - bool sameProjType = otherProj.type == projectile.type; - float taxicabDist = Vector2.Distance(projectile.Center, otherProj.Center); - if (sameProjType && taxicabDist < pushDistance) - { - if (projectile.position.X < otherProj.position.X) - projectile.velocity.X -= pushForce; - else - projectile.velocity.X += pushForce; + // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. + bool sameProjType = otherProj.type == projectile.type; + float taxicabDist = Vector2.Distance(projectile.Center, otherProj.Center); + if (sameProjType && taxicabDist < pushDistance) + { + if (projectile.position.X < otherProj.position.X) + projectile.velocity.X -= pushForce; + else + projectile.velocity.X += pushForce; - if (projectile.position.Y < otherProj.position.Y) - projectile.velocity.Y -= pushForce; - else - projectile.velocity.Y += pushForce; - } - } - } + if (projectile.position.Y < otherProj.position.Y) + projectile.velocity.Y -= pushForce; + else + projectile.velocity.Y += pushForce; + } + } + } public override void OnHitPlayer(Player target, int damage, bool crit) { diff --git a/Projectiles/Boss/AresDeathBeamStart.cs b/Projectiles/Boss/AresDeathBeamStart.cs index 514b669866..7bd92fb7ac 100644 --- a/Projectiles/Boss/AresDeathBeamStart.cs +++ b/Projectiles/Boss/AresDeathBeamStart.cs @@ -54,14 +54,14 @@ namespace CalamityMod.Projectiles.Boss public override void SendExtraAI(BinaryWriter writer) { writer.Write(projectile.localAI[0]); - writer.Write(projectile.localAI[1]); - } + writer.Write(projectile.localAI[1]); + } public override void ReceiveExtraAI(BinaryReader reader) { projectile.localAI[0] = reader.ReadSingle(); - projectile.localAI[1] = reader.ReadSingle(); - } + projectile.localAI[1] = reader.ReadSingle(); + } public override void AttachToSomething() { @@ -86,17 +86,17 @@ namespace CalamityMod.Projectiles.Boss return; } - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - // Telegraph duration for deathray spiral - float deathrayTelegraphDuration = malice ? AresBody.deathrayTelegraphDuration_Malice : death ? AresBody.deathrayTelegraphDuration_Death : - revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; + // Telegraph duration for deathray spiral + float deathrayTelegraphDuration = malice ? AresBody.deathrayTelegraphDuration_Malice : death ? AresBody.deathrayTelegraphDuration_Death : + revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; - Time = Main.npc[OwnerIndex].Calamity().newAI[2] - deathrayTelegraphDuration; + Time = Main.npc[OwnerIndex].Calamity().newAI[2] - deathrayTelegraphDuration; } public override void UpdateLaserMotion() @@ -109,8 +109,8 @@ namespace CalamityMod.Projectiles.Boss float angularSlowdownDivisor = malice ? 300f : death ? 320f : revenge ? 330f : expertMode ? 340f : 360f; float angularVelocity = MathHelper.TwoPi * Time / Lifetime / angularSlowdownDivisor; - if (Main.npc[OwnerIndex].ai[3] % 2f == 0f) - angularVelocity *= -1f; + if (Main.npc[OwnerIndex].ai[3] % 2f == 0f) + angularVelocity *= -1f; // Update the direction and rotation of the laser. projectile.velocity = projectile.velocity.RotatedBy(angularVelocity); @@ -229,15 +229,15 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.OnFire, 360); - target.AddBuff(BuffID.Frostburn, 360); - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.OnFire, 360); + target.AddBuff(BuffID.Frostburn, 360); + } - public override bool CanHitPlayer(Player target) => projectile.scale >= 0.5f; + public override bool CanHitPlayer(Player target) => projectile.scale >= 0.5f; - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { target.Calamity().lastProjectileHit = projectile; } diff --git a/Projectiles/Boss/AresDeathBeamTelegraph.cs b/Projectiles/Boss/AresDeathBeamTelegraph.cs index 84c3b0605e..dfd4d416d1 100644 --- a/Projectiles/Boss/AresDeathBeamTelegraph.cs +++ b/Projectiles/Boss/AresDeathBeamTelegraph.cs @@ -21,12 +21,12 @@ namespace CalamityMod.Projectiles.Boss public NPC ThingToAttachTo => Main.npc.IndexInRange((int)projectile.ai[1]) ? Main.npc[(int)projectile.ai[1]] : null; public Vector2 OldVelocity; - public const float deathrayTelegraphDuration_Normal = 150f; - public const float deathrayTelegraphDuration_Expert = 120f; - public const float deathrayTelegraphDuration_Rev = 105f; - public const float deathrayTelegraphDuration_Death = 90f; - public const float deathrayTelegraphDuration_Malice = 60f; - public const float TelegraphFadeTime = 15f; + public const float deathrayTelegraphDuration_Normal = 150f; + public const float deathrayTelegraphDuration_Expert = 120f; + public const float deathrayTelegraphDuration_Rev = 105f; + public const float deathrayTelegraphDuration_Death = 90f; + public const float deathrayTelegraphDuration_Malice = 60f; + public const float TelegraphFadeTime = 15f; public const float TelegraphWidth = 2400f; public override void SetStaticDefaults() @@ -45,14 +45,14 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 255; projectile.penetrate = -1; - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - projectile.timeLeft = (int)(malice ? deathrayTelegraphDuration_Malice : death ? deathrayTelegraphDuration_Death : - revenge ? deathrayTelegraphDuration_Rev : expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal); + projectile.timeLeft = (int)(malice ? deathrayTelegraphDuration_Malice : death ? deathrayTelegraphDuration_Death : + revenge ? deathrayTelegraphDuration_Rev : expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal); } public override void SendExtraAI(BinaryWriter writer) @@ -103,16 +103,16 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - float TelegraphTotalTime = malice ? deathrayTelegraphDuration_Malice : death ? deathrayTelegraphDuration_Death : - revenge ? deathrayTelegraphDuration_Rev : expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal; + float TelegraphTotalTime = malice ? deathrayTelegraphDuration_Malice : death ? deathrayTelegraphDuration_Death : + revenge ? deathrayTelegraphDuration_Rev : expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal; - if (TelegraphDelay >= TelegraphTotalTime) + if (TelegraphDelay >= TelegraphTotalTime) return true; Texture2D laserTelegraph = ModContent.GetTexture("CalamityMod/ExtraTextures/LaserWallTelegraphBeam"); diff --git a/Projectiles/Boss/AresGaussNukeProjectile.cs b/Projectiles/Boss/AresGaussNukeProjectile.cs index edd870b100..fbee040d8a 100644 --- a/Projectiles/Boss/AresGaussNukeProjectile.cs +++ b/Projectiles/Boss/AresGaussNukeProjectile.cs @@ -14,9 +14,9 @@ namespace CalamityMod.Projectiles.Boss { public class AresGaussNukeProjectile : ModProjectile { - private const int timeLeft = 180; + private const int timeLeft = 180; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Gauss Nuke"); Main.projFrames[projectile.type] = 12; @@ -26,35 +26,35 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 100; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 100; projectile.height = 100; projectile.hostile = true; projectile.ignoreWater = true; projectile.tileCollide = false; projectile.penetrate = -1; - cooldownSlot = 1; - projectile.timeLeft = timeLeft; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + cooldownSlot = 1; + projectile.timeLeft = timeLeft; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - if (projectile.position.Y > projectile.ai[1]) - projectile.tileCollide = true; + writer.Write(projectile.localAI[0]); + } - // Animation - projectile.frameCounter++; + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + } + + public override void AI() + { + if (projectile.position.Y > projectile.ai[1]) + projectile.tileCollide = true; + + // Animation + projectile.frameCounter++; if (projectile.frameCounter >= 6) { projectile.frame++; @@ -63,153 +63,153 @@ namespace CalamityMod.Projectiles.Boss if (projectile.frame >= 12) projectile.frame = 0; - // Rotation - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; + // Rotation + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - // Spawn effects - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; - for (int i = 0; i < 25; i++) - { - // Choose a random speed and angle - float dustSpeed = Main.rand.NextFloat(3f, 13f); - float angleRandom = 0.06f; - Vector2 dustVel = new Vector2(dustSpeed, 0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2f * angleRandom); - - // Random size - float scale = Main.rand.NextFloat(0.5f, 1.6f); - - // Spawn dust - Dust dust = Dust.NewDustPerfect(projectile.Center, 107, -dustVel, 0, default, scale); - dust.noGravity = true; - } - - // Gauss sparks - if (Main.myPlayer == projectile.owner) - { - int totalProjectiles = malice ? 18 : 12; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - float velocity = projectile.velocity.Length(); - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(projectile.Center, velocity2 + Vector2.Normalize(projectile.velocity) * -6f, type, (int)Math.Round(projectile.damage * 0.5), 0f, Main.myPlayer); - } - } - } - - // Light - Lighting.AddLight(projectile.Center, 0.2f, 0.25f, 0.05f); - - // Get a target and calculate distance from it - int target = Player.FindClosest(projectile.Center, 1, 1); - Vector2 distanceFromTarget = Main.player[target].Center - projectile.Center; - - // Set AI to stop homing, start accelerating - float stopHomingDistance = malice ? 260f : death ? 280f : revenge ? 290f : expertMode ? 300f : 320f; - if ((distanceFromTarget.Length() < stopHomingDistance && projectile.ai[0] != -1f) || projectile.ai[0] == 1f) + // Spawn effects + if (projectile.localAI[0] == 0f) { - projectile.ai[0] = 1f; + projectile.localAI[0] = 1f; + for (int i = 0; i < 25; i++) + { + // Choose a random speed and angle + float dustSpeed = Main.rand.NextFloat(3f, 13f); + float angleRandom = 0.06f; + Vector2 dustVel = new Vector2(dustSpeed, 0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2f * angleRandom); - if (projectile.velocity.Length() < 24f) - projectile.velocity *= 1.025f; + // Random size + float scale = Main.rand.NextFloat(0.5f, 1.6f); - return; + // Spawn dust + Dust dust = Dust.NewDustPerfect(projectile.Center, 107, -dustVel, 0, default, scale); + dust.noGravity = true; + } + + // Gauss sparks + if (Main.myPlayer == projectile.owner) + { + int totalProjectiles = malice ? 18 : 12; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + float velocity = projectile.velocity.Length(); + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(projectile.Center, velocity2 + Vector2.Normalize(projectile.velocity) * -6f, type, (int)Math.Round(projectile.damage * 0.5), 0f, Main.myPlayer); + } + } } - // Home in on target - float scaleFactor = projectile.velocity.Length(); - float inertia = malice ? 6f : death ? 8f : revenge ? 9f : expertMode ? 10f : 12f; - distanceFromTarget.Normalize(); - distanceFromTarget *= scaleFactor; - projectile.velocity = (projectile.velocity * inertia + distanceFromTarget) / (inertia + 1f); - projectile.velocity.Normalize(); - projectile.velocity *= scaleFactor; - } + // Light + Lighting.AddLight(projectile.Center, 0.2f, 0.25f, 0.05f); + + // Get a target and calculate distance from it + int target = Player.FindClosest(projectile.Center, 1, 1); + Vector2 distanceFromTarget = Main.player[target].Center - projectile.Center; + + // Set AI to stop homing, start accelerating + float stopHomingDistance = malice ? 260f : death ? 280f : revenge ? 290f : expertMode ? 300f : 320f; + if ((distanceFromTarget.Length() < stopHomingDistance && projectile.ai[0] != -1f) || projectile.ai[0] == 1f) + { + projectile.ai[0] = 1f; + + if (projectile.velocity.Length() < 24f) + projectile.velocity *= 1.025f; + + return; + } + + // Home in on target + float scaleFactor = projectile.velocity.Length(); + float inertia = malice ? 6f : death ? 8f : revenge ? 9f : expertMode ? 10f : 12f; + distanceFromTarget.Normalize(); + distanceFromTarget *= scaleFactor; + projectile.velocity = (projectile.velocity * inertia + distanceFromTarget) / (inertia + 1f); + projectile.velocity.Normalize(); + projectile.velocity *= scaleFactor; + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - spriteBatch.EnterShaderRegion(); - Texture2D telegraphBase = ModContent.GetTexture("CalamityMod/Projectiles/InvisibleProj"); + spriteBatch.EnterShaderRegion(); + Texture2D telegraphBase = ModContent.GetTexture("CalamityMod/Projectiles/InvisibleProj"); - GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseOpacity(0.4f * MathHelper.Clamp((1 - projectile.timeLeft / (float)timeLeft) * 8f, 0, 1)); - GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseColor(Color.Lerp(Color.Goldenrod, Color.Gold, 0.7f * (float)Math.Pow(0.5 + 0.5 * Math.Sin(Main.GlobalTime), 3))); - GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSecondaryColor(Color.Lerp(Color.Yellow, Color.White, 0.5f)); - GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSaturation(1 - projectile.timeLeft / (float)timeLeft); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseOpacity(0.4f * MathHelper.Clamp((1 - projectile.timeLeft / (float)timeLeft) * 8f, 0, 1)); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseColor(Color.Lerp(Color.Goldenrod, Color.Gold, 0.7f * (float)Math.Pow(0.5 + 0.5 * Math.Sin(Main.GlobalTime), 3))); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSecondaryColor(Color.Lerp(Color.Yellow, Color.White, 0.5f)); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSaturation(1 - projectile.timeLeft / (float)timeLeft); - GameShaders.Misc["CalamityMod:CircularAoETelegraph"].Apply(); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].Apply(); - Vector2 drawPosition = projectile.Center - Main.screenPosition; - spriteBatch.Draw(telegraphBase, drawPosition, null, lightColor, 0, telegraphBase.Size() / 2f, 1070f, 0, 0); - spriteBatch.ExitShaderRegion(); + Vector2 drawPosition = projectile.Center - Main.screenPosition; + spriteBatch.Draw(telegraphBase, drawPosition, null, lightColor, 0, telegraphBase.Size() / 2f, 1070f, 0, 0); + spriteBatch.ExitShaderRegion(); CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; + return false; } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int height = texture.Height / Main.projFrames[projectile.type]; - int drawStart = height * projectile.frame; - Vector2 origin = projectile.Size / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int drawStart = height * projectile.frame; + Vector2 origin = projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/AresGaussNukeProjectileGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - } + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/AresGaussNukeProjectileGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 45f, targetHitbox); - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { - // Nuke explosion sound - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"), projectile.Center); + // Nuke explosion sound + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"), projectile.Center); - // Nuke gores - Gore.NewGore(projectile.position, projectile.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke1"), 1f); - Gore.NewGore(projectile.position, projectile.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke3"), 1f); + // Nuke gores + Gore.NewGore(projectile.position, projectile.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke1"), 1f); + Gore.NewGore(projectile.position, projectile.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke3"), 1f); - // Create a bunch of lightning bolts in the sky - ExoMechsSky.CreateLightningBolt(12); + // Create a bunch of lightning bolts in the sky + ExoMechsSky.CreateLightningBolt(12); - if (Main.myPlayer == projectile.owner && projectile.ai[0] != -1f) - { - // Explosion waves - for (int i = 0; i < 3; i++) - { - Projectile explosion = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, Main.myPlayer); - if (explosion.whoAmI.WithinBounds(Main.maxProjectiles)) - { - // Make the max explosion radius decrease over time, creating a ring effect. - explosion.ai[1] = 560f + i * 90f; - explosion.localAI[1] = 0.25f; - explosion.Opacity = MathHelper.Lerp(0.18f, 0.6f, i / 7f) + Main.rand.NextFloat(-0.08f, 0.08f); - explosion.netUpdate = true; - } - } - } - } + if (Main.myPlayer == projectile.owner && projectile.ai[0] != -1f) + { + // Explosion waves + for (int i = 0; i < 3; i++) + { + Projectile explosion = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, Main.myPlayer); + if (explosion.whoAmI.WithinBounds(Main.maxProjectiles)) + { + // Make the max explosion radius decrease over time, creating a ring effect. + explosion.ai[1] = 560f + i * 90f; + explosion.localAI[1] = 0.25f; + explosion.Opacity = MathHelper.Lerp(0.18f, 0.6f, i / 7f) + Main.rand.NextFloat(-0.08f, 0.08f); + explosion.netUpdate = true; + } + } + } + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/AresGaussNukeProjectileBoom.cs b/Projectiles/Boss/AresGaussNukeProjectileBoom.cs index afae30dc26..0789392486 100644 --- a/Projectiles/Boss/AresGaussNukeProjectileBoom.cs +++ b/Projectiles/Boss/AresGaussNukeProjectileBoom.cs @@ -6,47 +6,47 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Boss { - public class AresGaussNukeProjectileBoom : BaseMassiveExplosionProjectile - { - public override int Lifetime => 60; - public override bool UsesScreenshake => true; - public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 16f; - public override Color GetCurrentExplosionColor(float pulseCompletionRatio) => Color.Lerp(Color.Yellow * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f)); + public class AresGaussNukeProjectileBoom : BaseMassiveExplosionProjectile + { + public override int Lifetime => 60; + public override bool UsesScreenshake => true; + public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 16f; + public override Color GetCurrentExplosionColor(float pulseCompletionRatio) => Color.Lerp(Color.Yellow * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f)); public override float Fadeout(float completion) { - float opacity; - //Opacity is high for most of the blast - if (completion < 0.8f) - opacity = 1f; + float opacity; + //Opacity is high for most of the blast + if (completion < 0.8f) + opacity = 1f; - //It only fades out near the end - else - opacity = (float)Math.Cos(((completion - 0.8f) / 0.2f * MathHelper.Pi) / 2f); ; - - return opacity * 0.85f; - } + //It only fades out near the end + else + opacity = (float)Math.Cos(((completion - 0.8f) / 0.2f * MathHelper.Pi) / 2f); ; + + return opacity * 0.85f; + } public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() => DisplayName.SetDefault("Gauss Explosion"); + public override void SetStaticDefaults() => DisplayName.SetDefault("Gauss Explosion"); - public override void SetDefaults() - { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = projectile.height = 2; - projectile.hostile = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.timeLeft = Lifetime; - cooldownSlot = 1; - } + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = projectile.height = 2; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = Lifetime; + cooldownSlot = 1; + } - public override void PostAI() => Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f); + public override void PostAI() => Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f); - public override bool CanHitPlayer(Player target) => CalamityUtils.CircularHitboxCollision(projectile.Center, CurrentRadius * projectile.scale * 0.4f, target.Hitbox) && projectile.timeLeft > 6; + public override bool CanHitPlayer(Player target) => CalamityUtils.CircularHitboxCollision(projectile.Center, CurrentRadius * projectile.scale * 0.4f, target.Hitbox) && projectile.timeLeft > 6; - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) => target.Calamity().lastProjectileHit = projectile; + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) => target.Calamity().lastProjectileHit = projectile; - public override void OnHitPlayer(Player target, int damage, bool crit) => target.AddBuff(BuffID.OnFire, 480); - } + public override void OnHitPlayer(Player target, int damage, bool crit) => target.AddBuff(BuffID.OnFire, 480); + } } diff --git a/Projectiles/Boss/AresGaussNukeProjectileSpark.cs b/Projectiles/Boss/AresGaussNukeProjectileSpark.cs index da4a5927fe..83be235e35 100644 --- a/Projectiles/Boss/AresGaussNukeProjectileSpark.cs +++ b/Projectiles/Boss/AresGaussNukeProjectileSpark.cs @@ -10,9 +10,9 @@ namespace CalamityMod.Projectiles.Boss { public class AresGaussNukeProjectileSpark : ModProjectile { - private const int timeLeft = 180; + private const int timeLeft = 180; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Gauss Spark"); Main.projFrames[projectile.type] = 4; @@ -26,46 +26,46 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 14; projectile.hostile = true; projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.Opacity = 0f; - cooldownSlot = 1; - projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.Opacity = 0f; + cooldownSlot = 1; + projectile.penetrate = -1; projectile.timeLeft = timeLeft; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 15f) - { - projectile.localAI[0] = 15f; - projectile.velocity.Y += 0.1f; - } + writer.Write(projectile.localAI[0]); + } - if (projectile.velocity.Y > 16f) - projectile.velocity.Y = 16f; + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + } - int fadeOutTime = 15; - int fadeInTime = 3; - if (projectile.timeLeft < fadeOutTime) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / (float)fadeOutTime, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - (timeLeft - fadeInTime)) / (float)fadeInTime), 0f, 1f); + public override void AI() + { + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= 15f) + { + projectile.localAI[0] = 15f; + projectile.velocity.Y += 0.1f; + } - Lighting.AddLight(projectile.Center, 0.1f * projectile.Opacity, 0.125f * projectile.Opacity, 0.025f * projectile.Opacity); + if (projectile.velocity.Y > 16f) + projectile.velocity.Y = 16f; - projectile.frameCounter++; + int fadeOutTime = 15; + int fadeInTime = 3; + if (projectile.timeLeft < fadeOutTime) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / (float)fadeOutTime, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - (timeLeft - fadeInTime)) / (float)fadeInTime), 0f, 1f); + + Lighting.AddLight(projectile.Center, 0.1f * projectile.Opacity, 0.125f * projectile.Opacity, 0.025f * projectile.Opacity); + + projectile.frameCounter++; if (projectile.frameCounter > 4) { projectile.frame++; @@ -77,28 +77,28 @@ namespace CalamityMod.Projectiles.Boss projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.Opacity != 1f) - return; + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.Opacity != 1f) + return; - target.AddBuff(BuffID.OnFire, 180); - } + target.AddBuff(BuffID.OnFire, 180); + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - lightColor.R = (byte)(255 * projectile.Opacity); - lightColor.G = (byte)(255 * projectile.Opacity); - lightColor.B = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.G = (byte)(255 * projectile.Opacity); + lightColor.B = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/AresLaserBeamStart.cs b/Projectiles/Boss/AresLaserBeamStart.cs index 4c66f731e9..c706a73f42 100644 --- a/Projectiles/Boss/AresLaserBeamStart.cs +++ b/Projectiles/Boss/AresLaserBeamStart.cs @@ -12,230 +12,230 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class AresLaserBeamStart : ModProjectile - { - private const int maxFrames = 5; - private int frameDrawn = 0; + public class AresLaserBeamStart : ModProjectile + { + private const int maxFrames = 5; + private int frameDrawn = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Exothermal Laser"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Exothermal Laser"); + } - public override void SetDefaults() - { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 30; - projectile.height = 30; - projectile.hostile = true; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.timeLeft = 600; - cooldownSlot = 1; - } + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 30; + projectile.height = 30; + projectile.hostile = true; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft = 600; + cooldownSlot = 1; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(frameDrawn); - writer.Write(projectile.localAI[0]); - writer.Write(projectile.localAI[1]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(frameDrawn); + writer.Write(projectile.localAI[0]); + writer.Write(projectile.localAI[1]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - frameDrawn = reader.ReadInt32(); - projectile.localAI[0] = reader.ReadSingle(); - projectile.localAI[1] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + frameDrawn = reader.ReadInt32(); + projectile.localAI[0] = reader.ReadSingle(); + projectile.localAI[1] = reader.ReadSingle(); + } - public override void AI() - { - Vector2? vector78 = null; + public override void AI() + { + Vector2? vector78 = null; - if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) - projectile.velocity = -Vector2.UnitY; + if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) + projectile.velocity = -Vector2.UnitY; - // Kill laser to prevent bullshit hits when Ares enters passive and immune phase - bool killLaser = false; - if (CalamityGlobalNPC.draedonExoMechPrime != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - { - killLaser = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune || - Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[0] == (float)AresBody.Phase.Deathrays; - } - } + // Kill laser to prevent bullshit hits when Ares enters passive and immune phase + bool killLaser = false; + if (CalamityGlobalNPC.draedonExoMechPrime != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + killLaser = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune || + Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[0] == (float)AresBody.Phase.Deathrays; + } + } - if (Main.npc[(int)projectile.ai[1]].active && Main.npc[(int)projectile.ai[1]].type == ModContent.NPCType() && !killLaser) - { - float offset = 84f; - float offset2 = 16f; - Vector2 fireFrom = Main.npc[(int)projectile.ai[1]].Calamity().newAI[3] == 0f ? new Vector2(Main.npc[(int)projectile.ai[1]].Center.X - offset2 * Main.npc[(int)projectile.ai[1]].direction, Main.npc[(int)projectile.ai[1]].Center.Y + offset) : new Vector2(Main.npc[(int)projectile.ai[1]].Center.X + offset * Main.npc[(int)projectile.ai[1]].direction, Main.npc[(int)projectile.ai[1]].Center.Y + offset2); - projectile.position = fireFrom - new Vector2(projectile.width, projectile.height) / 2f; - } - else - projectile.Kill(); + if (Main.npc[(int)projectile.ai[1]].active && Main.npc[(int)projectile.ai[1]].type == ModContent.NPCType() && !killLaser) + { + float offset = 84f; + float offset2 = 16f; + Vector2 fireFrom = Main.npc[(int)projectile.ai[1]].Calamity().newAI[3] == 0f ? new Vector2(Main.npc[(int)projectile.ai[1]].Center.X - offset2 * Main.npc[(int)projectile.ai[1]].direction, Main.npc[(int)projectile.ai[1]].Center.Y + offset) : new Vector2(Main.npc[(int)projectile.ai[1]].Center.X + offset * Main.npc[(int)projectile.ai[1]].direction, Main.npc[(int)projectile.ai[1]].Center.Y + offset2); + projectile.position = fireFrom - new Vector2(projectile.width, projectile.height) / 2f; + } + else + projectile.Kill(); - float num801 = 1f; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 60f) - { - projectile.Kill(); - return; - } + float num801 = 1f; + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= 60f) + { + projectile.Kill(); + return; + } - projectile.scale = (float)Math.Sin(projectile.localAI[0] * (float)Math.PI / 60f) * 10f * num801; - if (projectile.scale > num801) - projectile.scale = num801; + projectile.scale = (float)Math.Sin(projectile.localAI[0] * (float)Math.PI / 60f) * 10f * num801; + if (projectile.scale > num801) + projectile.scale = num801; - float num804 = projectile.velocity.ToRotation(); - projectile.rotation = num804 - MathHelper.PiOver2; - projectile.velocity = num804.ToRotationVector2(); + float num804 = projectile.velocity.ToRotation(); + projectile.rotation = num804 - MathHelper.PiOver2; + projectile.velocity = num804.ToRotationVector2(); - float num805 = 3f; //3f - float num806 = projectile.width; + float num805 = 3f; //3f + float num806 = projectile.width; - Vector2 samplingPoint = projectile.Center; - if (vector78.HasValue) - samplingPoint = vector78.Value; + Vector2 samplingPoint = projectile.Center; + if (vector78.HasValue) + samplingPoint = vector78.Value; - float[] array3 = new float[(int)num805]; - Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 2400f, array3); - float num807 = 0f; - for (int num808 = 0; num808 < array3.Length; num808++) - { - num807 += array3[num808]; - } - num807 /= num805; + float[] array3 = new float[(int)num805]; + Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 2400f, array3); + float num807 = 0f; + for (int num808 = 0; num808 < array3.Length; num808++) + { + num807 += array3[num808]; + } + num807 /= num805; - // Fire laser through walls at max length if target cannot be seen - if (!Collision.CanHitLine(Main.npc[(int)projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)projectile.ai[1]].target].Center, 1, 1)) - { - num807 = 2400f; - } + // Fire laser through walls at max length if target cannot be seen + if (!Collision.CanHitLine(Main.npc[(int)projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)projectile.ai[1]].target].Center, 1, 1)) + { + num807 = 2400f; + } - float amount = 0.5f; - projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); //length of laser, linear interpolation + float amount = 0.5f; + projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); //length of laser, linear interpolation - // Spawn dust at the end of the beam - int dustType = (int)CalamityDusts.Brimstone; - Vector2 dustPos = projectile.Center + projectile.velocity * (projectile.localAI[1] - 14f); - for (int i = 0; i < 2; i++) - { - float dustRot = projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; - float dustVelMult = (float)Main.rand.NextDouble() * 2f + 2f; - Vector2 dustVel = new Vector2((float)Math.Cos(dustRot) * dustVelMult, (float)Math.Sin(dustRot) * dustVelMult); - int dust = Dust.NewDust(dustPos, 0, 0, dustType, dustVel.X, dustVel.Y, 0, default, 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].scale = 1.7f; - } + // Spawn dust at the end of the beam + int dustType = (int)CalamityDusts.Brimstone; + Vector2 dustPos = projectile.Center + projectile.velocity * (projectile.localAI[1] - 14f); + for (int i = 0; i < 2; i++) + { + float dustRot = projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; + float dustVelMult = (float)Main.rand.NextDouble() * 2f + 2f; + Vector2 dustVel = new Vector2((float)Math.Cos(dustRot) * dustVelMult, (float)Math.Sin(dustRot) * dustVelMult); + int dust = Dust.NewDust(dustPos, 0, 0, dustType, dustVel.X, dustVel.Y, 0, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].scale = 1.7f; + } - if (Main.rand.NextBool(5)) - { - Vector2 dustRot = projectile.velocity.RotatedBy(MathHelper.PiOver2, default) * ((float)Main.rand.NextDouble() - 0.5f) * projectile.width; - int dust = Dust.NewDust(dustPos + dustRot - Vector2.One * 4f, 8, 8, dustType, 0f, 0f, 100, default, 1.5f); - Main.dust[dust].velocity *= 0.5f; - Main.dust[dust].velocity.Y = -Math.Abs(Main.dust[dust].velocity.Y); - } + if (Main.rand.NextBool(5)) + { + Vector2 dustRot = projectile.velocity.RotatedBy(MathHelper.PiOver2, default) * ((float)Main.rand.NextDouble() - 0.5f) * projectile.width; + int dust = Dust.NewDust(dustPos + dustRot - Vector2.One * 4f, 8, 8, dustType, 0f, 0f, 100, default, 1.5f); + Main.dust[dust].velocity *= 0.5f; + Main.dust[dust].velocity.Y = -Math.Abs(Main.dust[dust].velocity.Y); + } - DelegateMethods.v3_1 = new Vector3(0.9f, 0.3f, 0.3f); - Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); - } + DelegateMethods.v3_1 = new Vector3(0.9f, 0.3f, 0.3f); + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.velocity == Vector2.Zero) - return false; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.velocity == Vector2.Zero) + return false; - Texture2D beamStart = Main.projectileTexture[projectile.type]; - Texture2D beamMiddle = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/AresLaserBeamMiddle"); - Texture2D beamEnd = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/AresLaserBeamEnd"); + Texture2D beamStart = Main.projectileTexture[projectile.type]; + Texture2D beamMiddle = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/AresLaserBeamMiddle"); + Texture2D beamEnd = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/AresLaserBeamEnd"); - float drawLength = projectile.localAI[1]; - Color color = new Color(250, 250, 250, 100); + float drawLength = projectile.localAI[1]; + Color color = new Color(250, 250, 250, 100); - if (projectile.localAI[0] % 5f == 0f) - { - frameDrawn++; - if (frameDrawn >= maxFrames) - frameDrawn = 0; - } + if (projectile.localAI[0] % 5f == 0f) + { + frameDrawn++; + if (frameDrawn >= maxFrames) + frameDrawn = 0; + } - // Draw start of beam - Vector2 vector = projectile.Center - Main.screenPosition; - Rectangle? sourceRectangle = new Rectangle(0, beamStart.Height / maxFrames * frameDrawn, beamStart.Width, beamStart.Height / maxFrames); - spriteBatch.Draw(beamStart, vector, sourceRectangle, color, projectile.rotation, new Vector2(beamStart.Width, beamStart.Height / maxFrames) / 2f, projectile.scale, SpriteEffects.None, 0f); + // Draw start of beam + Vector2 vector = projectile.Center - Main.screenPosition; + Rectangle? sourceRectangle = new Rectangle(0, beamStart.Height / maxFrames * frameDrawn, beamStart.Width, beamStart.Height / maxFrames); + spriteBatch.Draw(beamStart, vector, sourceRectangle, color, projectile.rotation, new Vector2(beamStart.Width, beamStart.Height / maxFrames) / 2f, projectile.scale, SpriteEffects.None, 0f); - // Draw middle of beam - drawLength -= (beamStart.Height / maxFrames / 2 + beamEnd.Height / maxFrames) * projectile.scale; - Vector2 center = projectile.Center; - center += projectile.velocity * projectile.scale * beamStart.Height / maxFrames / 2f; - if (drawLength > 0f) - { - float i = 0f; - int middleFrameDrawn = frameDrawn; - while (i + 1f < drawLength) - { - Rectangle rectangle = new Rectangle(0, beamMiddle.Height / maxFrames * middleFrameDrawn, beamMiddle.Width, beamMiddle.Height / maxFrames); + // Draw middle of beam + drawLength -= (beamStart.Height / maxFrames / 2 + beamEnd.Height / maxFrames) * projectile.scale; + Vector2 center = projectile.Center; + center += projectile.velocity * projectile.scale * beamStart.Height / maxFrames / 2f; + if (drawLength > 0f) + { + float i = 0f; + int middleFrameDrawn = frameDrawn; + while (i + 1f < drawLength) + { + Rectangle rectangle = new Rectangle(0, beamMiddle.Height / maxFrames * middleFrameDrawn, beamMiddle.Width, beamMiddle.Height / maxFrames); - if (drawLength - i < rectangle.Height) - rectangle.Height = (int)(drawLength - i); + if (drawLength - i < rectangle.Height) + rectangle.Height = (int)(drawLength - i); - spriteBatch.Draw(beamMiddle, center - Main.screenPosition, rectangle, color, projectile.rotation, new Vector2(rectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f); + spriteBatch.Draw(beamMiddle, center - Main.screenPosition, rectangle, color, projectile.rotation, new Vector2(rectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f); - middleFrameDrawn++; - if (middleFrameDrawn >= maxFrames) - middleFrameDrawn = 0; + middleFrameDrawn++; + if (middleFrameDrawn >= maxFrames) + middleFrameDrawn = 0; - i += rectangle.Height * projectile.scale; - center += projectile.velocity * rectangle.Height * projectile.scale; + i += rectangle.Height * projectile.scale; + center += projectile.velocity * rectangle.Height * projectile.scale; - rectangle.Y += beamMiddle.Height / maxFrames; - if (rectangle.Y + rectangle.Height > beamMiddle.Height / maxFrames) - rectangle.Y = 0; - } - } + rectangle.Y += beamMiddle.Height / maxFrames; + if (rectangle.Y + rectangle.Height > beamMiddle.Height / maxFrames) + rectangle.Y = 0; + } + } - // Draw end of beam - Vector2 vector2 = center - Main.screenPosition; - sourceRectangle = new Rectangle(0, beamEnd.Height / maxFrames * frameDrawn, beamEnd.Width, beamEnd.Height / maxFrames); - spriteBatch.Draw(beamEnd, vector2, sourceRectangle, color, projectile.rotation, new Vector2(beamEnd.Width, beamEnd.Height / maxFrames) / 2f, projectile.scale, SpriteEffects.None, 0f); + // Draw end of beam + Vector2 vector2 = center - Main.screenPosition; + sourceRectangle = new Rectangle(0, beamEnd.Height / maxFrames * frameDrawn, beamEnd.Width, beamEnd.Height / maxFrames); + spriteBatch.Draw(beamEnd, vector2, sourceRectangle, color, projectile.rotation, new Vector2(beamEnd.Width, beamEnd.Height / maxFrames) / 2f, projectile.scale, SpriteEffects.None, 0f); - return false; - } + return false; + } - public override void CutTiles() - { - DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; - Vector2 unit = projectile.velocity; - Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); - } + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 unit = projectile.velocity; + Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (projHitbox.Intersects(targetHitbox)) - { - return true; - } - float num6 = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 30f * projectile.scale, ref num6)) - { - return true; - } - return false; - } - - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + { + return true; + } + float num6 = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 30f * projectile.scale, ref num6)) + { + return true; + } + return false; + } + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + } - public override bool CanHitPlayer(Player target) => projectile.scale >= 0.5f; + public override bool CanHitPlayer(Player target) => projectile.scale >= 0.5f; - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/AresPlasmaBolt.cs b/Projectiles/Boss/AresPlasmaBolt.cs index 0d55b8a7fa..dff5e23828 100644 --- a/Projectiles/Boss/AresPlasmaBolt.cs +++ b/Projectiles/Boss/AresPlasmaBolt.cs @@ -7,94 +7,94 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class AresPlasmaBolt : ModProjectile - { - private const int timeLeft = 360; + public class AresPlasmaBolt : ModProjectile + { + private const int timeLeft = 360; - private const float maxVelocity = 12f; + private const float maxVelocity = 12f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Exoplasma Bolt"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Exoplasma Bolt"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 18; - projectile.height = 18; - projectile.hostile = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.Opacity = 0f; - cooldownSlot = 1; - projectile.penetrate = -1; - projectile.extraUpdates = 1; - projectile.timeLeft = timeLeft; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 18; + projectile.height = 18; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.Opacity = 0f; + cooldownSlot = 1; + projectile.penetrate = -1; + projectile.extraUpdates = 1; + projectile.timeLeft = timeLeft; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } - public override void AI() - { - // 22 frames starting at 0.5 - // 17 frames starting at 1 - if (projectile.velocity.Length() < maxVelocity) - { - projectile.velocity *= 1.075f; - if (projectile.velocity.Length() > maxVelocity) - { - projectile.velocity.Normalize(); - projectile.velocity *= maxVelocity; - } - } + public override void AI() + { + // 22 frames starting at 0.5 + // 17 frames starting at 1 + if (projectile.velocity.Length() < maxVelocity) + { + projectile.velocity *= 1.075f; + if (projectile.velocity.Length() > maxVelocity) + { + projectile.velocity.Normalize(); + projectile.velocity *= maxVelocity; + } + } - int fadeOutTime = 15; - int fadeInTime = 3; - if (projectile.timeLeft < fadeOutTime) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / (float)fadeOutTime, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - (timeLeft - fadeInTime)) / (float)fadeInTime), 0f, 1f); + int fadeOutTime = 15; + int fadeInTime = 3; + if (projectile.timeLeft < fadeOutTime) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / (float)fadeOutTime, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - (timeLeft - fadeInTime)) / (float)fadeInTime), 0f, 1f); - Lighting.AddLight(projectile.Center, 0f, 0.4f * projectile.Opacity, 0f); + Lighting.AddLight(projectile.Center, 0f, 0.4f * projectile.Opacity, 0f); - projectile.frameCounter++; - if (projectile.frameCounter > 8) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - projectile.frame = 0; + projectile.frameCounter++; + if (projectile.frameCounter > 8) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + projectile.frame = 0; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; - } + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; + } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.Opacity != 1f) - return; + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.Opacity != 1f) + return; - target.AddBuff(BuffID.OnFire, 180); - target.AddBuff(BuffID.CursedInferno, 90); - } + target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.CursedInferno, 90); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - lightColor.R = (byte)(255 * projectile.Opacity); - lightColor.G = (byte)(255 * projectile.Opacity); - lightColor.B = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.G = (byte)(255 * projectile.Opacity); + lightColor.B = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/AresPlasmaFireball.cs b/Projectiles/Boss/AresPlasmaFireball.cs index 8b6a4286b0..eb1430bdbb 100644 --- a/Projectiles/Boss/AresPlasmaFireball.cs +++ b/Projectiles/Boss/AresPlasmaFireball.cs @@ -11,236 +11,236 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class AresPlasmaFireball : ModProjectile - { - private const int timeLeft = 120; + public class AresPlasmaFireball : ModProjectile + { + private const int timeLeft = 120; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Volatile Plasma Blast"); - Main.projFrames[projectile.type] = 6; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Volatile Plasma Blast"); + Main.projFrames[projectile.type] = 6; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 36; - projectile.height = 36; - projectile.hostile = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.Opacity = 0f; - cooldownSlot = 1; - projectile.timeLeft = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 96 : timeLeft; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 36; + projectile.height = 36; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.Opacity = 0f; + cooldownSlot = 1; + projectile.timeLeft = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 96 : timeLeft; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + } - public override void AI() - { - if (projectile.ai[0] != -1f) - { - Vector2 targetLocation = new Vector2(projectile.ai[0], projectile.ai[1]); - if (Vector2.Distance(targetLocation, projectile.Center) < 80f) - projectile.tileCollide = true; - } + public override void AI() + { + if (projectile.ai[0] != -1f) + { + Vector2 targetLocation = new Vector2(projectile.ai[0], projectile.ai[1]); + if (Vector2.Distance(targetLocation, projectile.Center) < 80f) + projectile.tileCollide = true; + } - int fadeInTime = 3; - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - (((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 96 : timeLeft) - fadeInTime)) / (float)fadeInTime), 0f, 1f); + int fadeInTime = 3; + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - (((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 96 : timeLeft) - fadeInTime)) / (float)fadeInTime), 0f, 1f); - Lighting.AddLight(projectile.Center, 0f, 0.6f * projectile.Opacity, 0f); + Lighting.AddLight(projectile.Center, 0f, 0.6f * projectile.Opacity, 0f); - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 5) - projectile.frame = 0; + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 5) + projectile.frame = 0; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; - float speed1 = 1.8f; - float speed2 = 2.8f; - float angleRandom = 0.35f; + float speed1 = 1.8f; + float speed2 = 2.8f; + float angleRandom = 0.35f; - for (int num53 = 0; num53 < 40; num53++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int randomDustType = Main.rand.NextBool(2) ? 107 : 110; + for (int num53 = 0; num53 < 40; num53++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + int randomDustType = Main.rand.NextBool(2) ? 107 : 110; - int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - Main.dust[num54].noGravity = true; + int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + Main.dust[num54].noGravity = true; - Dust dust = Main.dust[num54]; - dust.velocity *= 3f; - dust = Main.dust[num54]; + Dust dust = Main.dust[num54]; + dust.velocity *= 3f; + dust = Main.dust[num54]; - num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - dust = Main.dust[num54]; - dust.velocity *= 2f; + dust = Main.dust[num54]; + dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Green * 0.5f; + Main.dust[num54].noGravity = true; + Main.dust[num54].fadeIn = 1f; + Main.dust[num54].color = Color.Green * 0.5f; - dust = Main.dust[num54]; - } - for (int num55 = 0; num55 < 20; num55++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int randomDustType = Main.rand.NextBool(2) ? 107 : 110; + dust = Main.dust[num54]; + } + for (int num55 = 0; num55 < 20; num55++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + int randomDustType = Main.rand.NextBool(2) ? 107 : 110; - int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); - Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; - Main.dust[num56].noGravity = true; + int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); + Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; + Main.dust[num56].noGravity = true; - Dust dust = Main.dust[num56]; - dust.velocity *= 0.5f; - dust = Main.dust[num56]; - } - } - } + Dust dust = Main.dust[num56]; + dust.velocity *= 0.5f; + dust = Main.dust[num56]; + } + } + } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.Opacity != 1f) - return; + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.Opacity != 1f) + return; - target.AddBuff(BuffID.OnFire, 360); - target.AddBuff(BuffID.CursedInferno, 180); - } + target.AddBuff(BuffID.OnFire, 360); + target.AddBuff(BuffID.CursedInferno, 180); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - lightColor.R = (byte)(255 * projectile.Opacity); - lightColor.G = (byte)(255 * projectile.Opacity); - lightColor.B = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.G = (byte)(255 * projectile.Opacity); + lightColor.B = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void Kill(int timeLeft) - { - int height = 90; - projectile.position = projectile.Center; - projectile.width = projectile.height = height; - projectile.Center = projectile.position; - projectile.Damage(); + public override void Kill(int timeLeft) + { + int height = 90; + projectile.position = projectile.Center; + projectile.width = projectile.height = height; + projectile.Center = projectile.position; + projectile.Damage(); - Main.PlaySound(SoundID.Item93, projectile.Center); + Main.PlaySound(SoundID.Item93, projectile.Center); - if (Main.myPlayer == projectile.owner && projectile.ai[1] != -1f) - { - bool splitNormal = true; - if (CalamityGlobalNPC.draedonExoMechPrimePlasmaCannon != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrimePlasmaCannon].active) - splitNormal = Main.npc[CalamityGlobalNPC.draedonExoMechPrimePlasmaCannon].ai[3] % 2f == 0f; - } + if (Main.myPlayer == projectile.owner && projectile.ai[1] != -1f) + { + bool splitNormal = true; + if (CalamityGlobalNPC.draedonExoMechPrimePlasmaCannon != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrimePlasmaCannon].active) + splitNormal = Main.npc[CalamityGlobalNPC.draedonExoMechPrimePlasmaCannon].ai[3] % 2f == 0f; + } - // Plasma bolts - int totalProjectiles = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 12 : 8; + // Plasma bolts + int totalProjectiles = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 12 : 8; - // Reduce the total amount of projectiles by half if Ares Plasma Arm is shooting them and in deathray phase and not the last mech - if (projectile.ai[0] == -1f) - totalProjectiles /= 2; + // Reduce the total amount of projectiles by half if Ares Plasma Arm is shooting them and in deathray phase and not the last mech + if (projectile.ai[0] == -1f) + totalProjectiles /= 2; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - float velocity = 0.5f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = splitNormal ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(projectile.Center, velocity2, type, (int)Math.Round(projectile.damage * 0.8), 0f, Main.myPlayer); - } - } + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + float velocity = 0.5f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = splitNormal ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(projectile.Center, velocity2, type, (int)Math.Round(projectile.damage * 0.8), 0f, Main.myPlayer); + } + } - for (int num640 = 0; num640 < 200; num640++) - { - float num641 = 16f; - if (num640 < 150) - num641 = 12f; - if (num640 < 100) - num641 = 8f; - if (num640 < 50) - num641 = 4f; + for (int num640 = 0; num640 < 200; num640++) + { + float num641 = 16f; + if (num640 < 150) + num641 = 12f; + if (num640 < 100) + num641 = 8f; + if (num640 < 50) + num641 = 4f; - int num643 = Dust.NewDust(projectile.Center, 6, 6, Main.rand.NextBool(2) ? 107 : 110, 0f, 0f, 100, default, 1f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + int num643 = Dust.NewDust(projectile.Center, 6, 6, Main.rand.NextBool(2) ? 107 : 110, 0f, 0f, 100, default, 1f); + float num644 = Main.dust[num643].velocity.X; + float num645 = Main.dust[num643].velocity.Y; - if (num644 == 0f && num645 == 0f) - num644 = 1f; + if (num644 == 0f && num645 == 0f) + num644 = 1f; - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; + float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); + num646 = num641 / num646; + num644 *= num646; + num645 *= num646; - float scale = 1f; - switch ((int)num641) - { - case 4: - scale = 1.2f; - break; - case 8: - scale = 1.1f; - break; - case 12: - scale = 1f; - break; - case 16: - scale = 0.9f; - break; - default: - break; - } + float scale = 1f; + switch ((int)num641) + { + case 4: + scale = 1.2f; + break; + case 8: + scale = 1.1f; + break; + case 12: + scale = 1f; + break; + case 16: + scale = 0.9f; + break; + default: + break; + } - Dust dust = Main.dust[num643]; - dust.velocity *= 0.5f; - dust.velocity.X = dust.velocity.X + num644; - dust.velocity.Y = dust.velocity.Y + num645; - dust.scale = scale; - dust.noGravity = true; - } - } + Dust dust = Main.dust[num643]; + dust.velocity *= 0.5f; + dust.velocity.X = dust.velocity.X + num644; + dust.velocity.Y = dust.velocity.Y + num645; + dust.scale = scale; + dust.noGravity = true; + } + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/AresTeslaOrb.cs b/Projectiles/Boss/AresTeslaOrb.cs index 25e7562175..fc6850e7e8 100644 --- a/Projectiles/Boss/AresTeslaOrb.cs +++ b/Projectiles/Boss/AresTeslaOrb.cs @@ -13,256 +13,256 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class AresTeslaOrb : ModProjectile - { - public ref float Identity => ref projectile.ai[0]; - public PrimitiveTrail LightningDrawer; - public PrimitiveTrail LightningBackgroundDrawer; - private const int timeLeft = 480; + public class AresTeslaOrb : ModProjectile + { + public ref float Identity => ref projectile.ai[0]; + public PrimitiveTrail LightningDrawer; + public PrimitiveTrail LightningBackgroundDrawer; + private const int timeLeft = 480; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tesla Sphere"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tesla Sphere"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 32; - projectile.height = 32; - projectile.hostile = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.Opacity = 0f; - cooldownSlot = 1; - projectile.timeLeft = timeLeft; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + public override void SetDefaults() + { + projectile.width = 32; + projectile.height = 32; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.Opacity = 0f; + cooldownSlot = 1; + projectile.timeLeft = timeLeft; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + } - public override void AI() - { - bool deathrayPhase = false; - if (CalamityGlobalNPC.draedonExoMechPrime != -1) - { - if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - deathrayPhase = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[0] == (float)AresBody.Phase.Deathrays; - } + public override void AI() + { + bool deathrayPhase = false; + if (CalamityGlobalNPC.draedonExoMechPrime != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + deathrayPhase = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[0] == (float)AresBody.Phase.Deathrays; + } - if (projectile.velocity.Length() < (deathrayPhase ? 10.4f : 20.8f)) - projectile.velocity *= 1.01f; + if (projectile.velocity.Length() < (deathrayPhase ? 10.4f : 20.8f)) + projectile.velocity *= 1.01f; - int fadeOutTime = 15; - int fadeInTime = 3; - if (projectile.timeLeft < fadeOutTime) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / (float)fadeOutTime, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - (timeLeft - fadeInTime)) / (float)fadeInTime), 0f, 1f); + int fadeOutTime = 15; + int fadeInTime = 3; + if (projectile.timeLeft < fadeOutTime) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / (float)fadeOutTime, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - (timeLeft - fadeInTime)) / (float)fadeInTime), 0f, 1f); - Lighting.AddLight(projectile.Center, 0.1f * projectile.Opacity, 0.25f * projectile.Opacity, 0.25f * projectile.Opacity); + Lighting.AddLight(projectile.Center, 0.1f * projectile.Opacity, 0.25f * projectile.Opacity, 0.25f * projectile.Opacity); - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - projectile.frame = 0; + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + projectile.frame = 0; - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; - float speed1 = 1.8f; - float speed2 = 2.8f; - float angleRandom = 0.35f; + float speed1 = 1.8f; + float speed2 = 2.8f; + float angleRandom = 0.35f; - for (int num53 = 0; num53 < 40; num53++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2f * angleRandom); - int randomDustType = Main.rand.Next(2) == 0 ? 206 : 229; - float scale = randomDustType == 206 ? 1.5f : 1f; + for (int num53 = 0; num53 < 40; num53++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2f * angleRandom); + int randomDustType = Main.rand.Next(2) == 0 ? 206 : 229; + float scale = randomDustType == 206 ? 1.5f : 1f; - int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 2.5f * scale); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - Main.dust[num54].noGravity = true; + int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 2.5f * scale); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + Main.dust[num54].noGravity = true; - Dust dust = Main.dust[num54]; - dust.velocity *= 3f; + Dust dust = Main.dust[num54]; + dust.velocity *= 3f; - num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 1.5f * scale); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 1.5f * scale); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - dust = Main.dust[num54]; - dust.velocity *= 2f; + dust = Main.dust[num54]; + dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Cyan * 0.5f; - } - for (int num55 = 0; num55 < 20; num55++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2f * angleRandom); - int randomDustType = Main.rand.Next(2) == 0 ? 206 : 229; - float scale = randomDustType == 206 ? 1.5f : 1f; + Main.dust[num54].noGravity = true; + Main.dust[num54].fadeIn = 1f; + Main.dust[num54].color = Color.Cyan * 0.5f; + } + for (int num55 = 0; num55 < 20; num55++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2f * angleRandom); + int randomDustType = Main.rand.Next(2) == 0 ? 206 : 229; + float scale = randomDustType == 206 ? 1.5f : 1f; - int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 3f * scale); - Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; - Main.dust[num56].noGravity = true; + int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 3f * scale); + Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; + Main.dust[num56].noGravity = true; - Dust dust = Main.dust[num56]; - dust.velocity *= 0.5f; - } - } - } + Dust dust = Main.dust[num56]; + dust.velocity *= 0.5f; + } + } + } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.Opacity != 1f) - return; + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.Opacity != 1f) + return; - target.AddBuff(BuffID.Electrified, 240); - } + target.AddBuff(BuffID.Electrified, 240); + } - public Projectile GetOrbToAttachTo() - { - if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) - return null; + public Projectile GetOrbToAttachTo() + { + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + return null; - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - float detachDistance = malice ? 1600f : death ? 1360f : revenge ? 1280f : expertMode ? 1200f : 960f; - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].type != projectile.type || Main.projectile[i].ai[0] != Identity + 1f || !Main.projectile[i].active || Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[0] == (float)AresBody.Phase.Deathrays) - continue; + float detachDistance = malice ? 1600f : death ? 1360f : revenge ? 1280f : expertMode ? 1200f : 960f; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != projectile.type || Main.projectile[i].ai[0] != Identity + 1f || !Main.projectile[i].active || Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[0] == (float)AresBody.Phase.Deathrays) + continue; - if (Vector2.Distance(projectile.Center, Main.projectile[i].Center) > detachDistance) - continue; + if (Vector2.Distance(projectile.Center, Main.projectile[i].Center) > detachDistance) + continue; - return Main.projectile[i]; - } + return Main.projectile[i]; + } - return null; - } + return null; + } - public static List DetermineElectricArcPoints(Vector2 start, Vector2 end, int seed) - { - List points = new List(); + public static List DetermineElectricArcPoints(Vector2 start, Vector2 end, int seed) + { + List points = new List(); - // Determine the base points based on a linear path from the start the end end point. - for (int i = 0; i <= 75; i++) - points.Add(Vector2.Lerp(start, end, i / 73.5f)); + // Determine the base points based on a linear path from the start the end end point. + for (int i = 0; i <= 75; i++) + points.Add(Vector2.Lerp(start, end, i / 73.5f)); - // Then, add continuous randomness to the positions of various points. - for (int i = 0; i < points.Count; i++) - { - float completionRatio = i / (float)points.Count; + // Then, add continuous randomness to the positions of various points. + for (int i = 0; i < points.Count; i++) + { + float completionRatio = i / (float)points.Count; - // Noise offsets should taper off at the ends of the line. - float offsetMuffleFactor = Utils.InverseLerp(0.12f, 0.25f, completionRatio, true) * Utils.InverseLerp(0.88f, 0.75f, completionRatio, true); + // Noise offsets should taper off at the ends of the line. + float offsetMuffleFactor = Utils.InverseLerp(0.12f, 0.25f, completionRatio, true) * Utils.InverseLerp(0.88f, 0.75f, completionRatio, true); - // Give a sense of time for the noise on the vertical axis. This is achieved via a 0-1 constricted sinusoid. - float noiseY = (float)Math.Cos(completionRatio * 17.2f + Main.GlobalTime * 10.7f) * 0.5f + 0.5f; + // Give a sense of time for the noise on the vertical axis. This is achieved via a 0-1 constricted sinusoid. + float noiseY = (float)Math.Cos(completionRatio * 17.2f + Main.GlobalTime * 10.7f) * 0.5f + 0.5f; - float noise = CalamityUtils.PerlinNoise2D(completionRatio, noiseY, 2, seed); + float noise = CalamityUtils.PerlinNoise2D(completionRatio, noiseY, 2, seed); - // Now that the noise value has been computed, convert it to a direction by treating the noise as an angle - // and then converting it into a unit vector. - Vector2 offsetDirection = (noise * MathHelper.Pi * 0.7f).ToRotationVector2(); + // Now that the noise value has been computed, convert it to a direction by treating the noise as an angle + // and then converting it into a unit vector. + Vector2 offsetDirection = (noise * MathHelper.Pi * 0.7f).ToRotationVector2(); - // Then, determine the factor of the offset. This is based on the initial direction (but squashed) and the muffle factor from above. - Vector2 offset = offsetDirection * (float)Math.Pow(offsetDirection.Y, 2D) * offsetMuffleFactor * 15f; + // Then, determine the factor of the offset. This is based on the initial direction (but squashed) and the muffle factor from above. + Vector2 offset = offsetDirection * (float)Math.Pow(offsetDirection.Y, 2D) * offsetMuffleFactor * 15f; - points[i] += offset; - } + points[i] += offset; + } - return points; - } + return points; + } - internal float WidthFunction(float completionRatio) - { - return MathHelper.Lerp(0.75f, 1.85f, (float)Math.Sin(MathHelper.Pi * completionRatio)) * projectile.scale; - } + internal float WidthFunction(float completionRatio) + { + return MathHelper.Lerp(0.75f, 1.85f, (float)Math.Sin(MathHelper.Pi * completionRatio)) * projectile.scale; + } - internal Color ColorFunction(float completionRatio) - { - float fadeToWhite = MathHelper.Lerp(0f, 0.65f, (float)Math.Sin(MathHelper.TwoPi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f); - Color baseColor = Color.Lerp(Color.Cyan, Color.White, fadeToWhite); - return Color.Lerp(baseColor, Color.LightBlue, ((float)Math.Sin(MathHelper.Pi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f) * 0.8f) * projectile.Opacity; - } + internal Color ColorFunction(float completionRatio) + { + float fadeToWhite = MathHelper.Lerp(0f, 0.65f, (float)Math.Sin(MathHelper.TwoPi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f); + Color baseColor = Color.Lerp(Color.Cyan, Color.White, fadeToWhite); + return Color.Lerp(baseColor, Color.LightBlue, ((float)Math.Sin(MathHelper.Pi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f) * 0.8f) * projectile.Opacity; + } - internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 4f; + internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 4f; - internal Color BackgroundColorFunction(float completionRatio) - { - Color color = Color.CornflowerBlue * projectile.Opacity * 0.4f; - return color; - } + internal Color BackgroundColorFunction(float completionRatio) + { + Color color = Color.CornflowerBlue * projectile.Opacity * 0.4f; + return color; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (LightningDrawer is null) - LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); - if (LightningBackgroundDrawer is null) - LightningBackgroundDrawer = new PrimitiveTrail(BackgroundWidthFunction, BackgroundColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (LightningDrawer is null) + LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); + if (LightningBackgroundDrawer is null) + LightningBackgroundDrawer = new PrimitiveTrail(BackgroundWidthFunction, BackgroundColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); - Projectile orbToAttachTo = GetOrbToAttachTo(); - if (orbToAttachTo != null) - { - List arcPoints = DetermineElectricArcPoints(projectile.Center, orbToAttachTo.Center, 117); - LightningBackgroundDrawer.Draw(arcPoints, -Main.screenPosition, 90); - LightningDrawer.Draw(arcPoints, -Main.screenPosition, 90); - } + Projectile orbToAttachTo = GetOrbToAttachTo(); + if (orbToAttachTo != null) + { + List arcPoints = DetermineElectricArcPoints(projectile.Center, orbToAttachTo.Center, 117); + LightningBackgroundDrawer.Draw(arcPoints, -Main.screenPosition, 90); + LightningDrawer.Draw(arcPoints, -Main.screenPosition, 90); + } - lightColor.R = (byte)(255 * projectile.Opacity); - lightColor.G = (byte)(255 * projectile.Opacity); - lightColor.B = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.G = (byte)(255 * projectile.Opacity); + lightColor.B = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (projHitbox.Intersects(targetHitbox)) - return true; + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + return true; - float _ = 0f; - Projectile orbToAttachTo = GetOrbToAttachTo(); - if (orbToAttachTo != null && Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, orbToAttachTo.Center, 8f, ref _)) - return true; + float _ = 0f; + Projectile orbToAttachTo = GetOrbToAttachTo(); + if (orbToAttachTo != null && Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, orbToAttachTo.Center, 8f, ref _)) + return true; - return false; - } + return false; + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/ArtemisChargeTelegraph.cs b/Projectiles/Boss/ArtemisChargeTelegraph.cs index 119917ba02..f0e20c5ab7 100644 --- a/Projectiles/Boss/ArtemisChargeTelegraph.cs +++ b/Projectiles/Boss/ArtemisChargeTelegraph.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class ArtemisChargeTelegraph : ModProjectile + public class ArtemisChargeTelegraph : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Boss/ArtemisDeathrayTelegraph.cs b/Projectiles/Boss/ArtemisDeathrayTelegraph.cs index 323293a018..009d799149 100644 --- a/Projectiles/Boss/ArtemisDeathrayTelegraph.cs +++ b/Projectiles/Boss/ArtemisDeathrayTelegraph.cs @@ -8,17 +8,17 @@ namespace CalamityMod.Projectiles.Boss { public class ArtemisDeathrayTelegraph : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public float TelegraphDelay + public float TelegraphDelay { get => projectile.ai[0]; set => projectile.ai[0] = value; } - public NPC ThingToAttachTo => Main.npc.IndexInRange((int)projectile.ai[1]) ? Main.npc[(int)projectile.ai[1]] : null; + public NPC ThingToAttachTo => Main.npc.IndexInRange((int)projectile.ai[1]) ? Main.npc[(int)projectile.ai[1]] : null; - public Vector2 OldVelocity; + public Vector2 OldVelocity; public const float TelegraphTotalTime = 60f; public const float TelegraphFadeTime = 15f; public const float TelegraphWidth = 4800f; @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.width = 10; + projectile.width = 10; projectile.height = 10; projectile.hostile = true; projectile.ignoreWater = true; @@ -38,19 +38,19 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 60; - } + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.WriteVector2(OldVelocity); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(OldVelocity); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - OldVelocity = reader.ReadVector2(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + OldVelocity = reader.ReadVector2(); + } - public override void AI() + public override void AI() { // Determine the relative opacities for each player based on their distance. if (projectile.localAI[0] == 0f) @@ -59,18 +59,18 @@ namespace CalamityMod.Projectiles.Boss projectile.netUpdate = true; } - // Die if the thing to attach to disappears. - if (ThingToAttachTo is null || !ThingToAttachTo.active) - { - projectile.Kill(); - return; - } + // Die if the thing to attach to disappears. + if (ThingToAttachTo is null || !ThingToAttachTo.active) + { + projectile.Kill(); + return; + } - // Set start of telegraph to the npc center. - projectile.Center = ThingToAttachTo.Center + Vector2.Normalize(OldVelocity) * 70f; + // Set start of telegraph to the npc center. + projectile.Center = ThingToAttachTo.Center + Vector2.Normalize(OldVelocity) * 70f; - // Be sure to save the velocity the projectile started with. It will be set again when the telegraph is over. - if (OldVelocity == Vector2.Zero) + // Be sure to save the velocity the projectile started with. It will be set again when the telegraph is over. + if (OldVelocity == Vector2.Zero) { OldVelocity = projectile.velocity; projectile.velocity = Vector2.Zero; @@ -102,8 +102,8 @@ namespace CalamityMod.Projectiles.Boss Vector2 origin = laserTelegraph.Size() * new Vector2(0f, 0.5f); Vector2 scaleOuter = scaleInner * new Vector2(1f, 1.6f); - Color colorOuter = Color.Lerp(Color.Red, Color.Crimson, TelegraphDelay / TelegraphTotalTime * 2f % 1f); // Iterate through crimson and red once and then flash. - Color colorInner = Color.Lerp(colorOuter, Color.White, 0.75f); + Color colorOuter = Color.Lerp(Color.Red, Color.Crimson, TelegraphDelay / TelegraphTotalTime * 2f % 1f); // Iterate through crimson and red once and then flash. + Color colorInner = Color.Lerp(colorOuter, Color.White, 0.75f); colorOuter *= 0.7f; colorInner *= 0.7f; diff --git a/Projectiles/Boss/ArtemisLaser.cs b/Projectiles/Boss/ArtemisLaser.cs index 9d36c4531f..898539d08a 100644 --- a/Projectiles/Boss/ArtemisLaser.cs +++ b/Projectiles/Boss/ArtemisLaser.cs @@ -11,226 +11,226 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class ArtemisLaser : ModProjectile - { - public float TelegraphDelay - { - get => projectile.localAI[1]; - set => projectile.localAI[1] = value; - } + public class ArtemisLaser : ModProjectile + { + public float TelegraphDelay + { + get => projectile.localAI[1]; + set => projectile.localAI[1] = value; + } - public NPC ThingToAttachTo => Main.npc.IndexInRange((int)projectile.ai[1]) ? Main.npc[(int)projectile.ai[1]] : null; + public NPC ThingToAttachTo => Main.npc.IndexInRange((int)projectile.ai[1]) ? Main.npc[(int)projectile.ai[1]] : null; - public ref float LaserVelocity => ref projectile.ai[0]; + public ref float LaserVelocity => ref projectile.ai[0]; - public Vector2 Destination; - public Vector2 Velocity; - public const float TelegraphTotalTime = 30f; - public const float TelegraphFadeTime = 15f; - public const float TelegraphWidth = 4200f; + public Vector2 Destination; + public Vector2 Velocity; + public const float TelegraphTotalTime = 30f; + public const float TelegraphFadeTime = 15f; + public const float TelegraphWidth = 4200f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Exo Pulse Laser"); - Main.projFrames[projectile.type] = 4; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Exo Pulse Laser"); + Main.projFrames[projectile.type] = 4; + } - public override void SetDefaults() - { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 22; - projectile.height = 22; - projectile.hostile = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.extraUpdates = 1; - projectile.timeLeft = 600; - cooldownSlot = 1; - } + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 22; + projectile.height = 22; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.extraUpdates = 1; + projectile.timeLeft = 600; + cooldownSlot = 1; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(TelegraphDelay); - writer.WriteVector2(Destination); - writer.WriteVector2(Velocity); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(TelegraphDelay); + writer.WriteVector2(Destination); + writer.WriteVector2(Velocity); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - TelegraphDelay = reader.ReadSingle(); - Destination = reader.ReadVector2(); - Velocity = reader.ReadVector2(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + TelegraphDelay = reader.ReadSingle(); + Destination = reader.ReadVector2(); + Velocity = reader.ReadVector2(); + } - public override void AI() - { - // Determine the relative opacities for each player based on their distance. - // This has a lower bound of 0.35 to prevent the laser from going completely invisible and players getting hit by cheap shots. - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; - projectile.netUpdate = true; - } + public override void AI() + { + // Determine the relative opacities for each player based on their distance. + // This has a lower bound of 0.35 to prevent the laser from going completely invisible and players getting hit by cheap shots. + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; + projectile.netUpdate = true; + } - projectile.frameCounter++; - if (projectile.frameCounter > 12) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - projectile.frame = 0; + projectile.frameCounter++; + if (projectile.frameCounter > 12) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + projectile.frame = 0; - Lighting.AddLight(projectile.Center, 0.6f, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.6f, 0f, 0f); - // Die if the thing to attach to disappears. - if (ThingToAttachTo is null || !ThingToAttachTo.active) - { - projectile.Kill(); - return; - } + // Die if the thing to attach to disappears. + if (ThingToAttachTo is null || !ThingToAttachTo.active) + { + projectile.Kill(); + return; + } - // Fade in after telegraphs have faded. - if (TelegraphDelay > TelegraphTotalTime) - { - if (projectile.alpha > 0) - projectile.alpha -= 25; - if (projectile.alpha < 0) - projectile.alpha = 0; + // Fade in after telegraphs have faded. + if (TelegraphDelay > TelegraphTotalTime) + { + if (projectile.alpha > 0) + projectile.alpha -= 25; + if (projectile.alpha < 0) + projectile.alpha = 0; - // If a velocity is in reserve, set the true velocity to it and make it as "taken" by setting it to <0,0> - if (Velocity != Vector2.Zero) - { - projectile.extraUpdates = 3; - projectile.velocity = Velocity * ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.25f : 1f); - Velocity = Vector2.Zero; - projectile.netUpdate = true; - } + // If a velocity is in reserve, set the true velocity to it and make it as "taken" by setting it to <0,0> + if (Velocity != Vector2.Zero) + { + projectile.extraUpdates = 3; + projectile.velocity = Velocity * ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.25f : 1f); + Velocity = Vector2.Zero; + projectile.netUpdate = true; + } - // Direction and rotation. - if (projectile.velocity.X < 0f) - { - projectile.spriteDirection = -1; - projectile.rotation = (float)Math.Atan2((double)-(double)projectile.velocity.Y, (double)-(double)projectile.velocity.X); - } - else - { - projectile.spriteDirection = 1; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); - } - } - else if (Destination == Vector2.Zero) - { - // Set start of telegraph to the npc center. - projectile.Center = ThingToAttachTo.Center; + // Direction and rotation. + if (projectile.velocity.X < 0f) + { + projectile.spriteDirection = -1; + projectile.rotation = (float)Math.Atan2((double)-(double)projectile.velocity.Y, (double)-(double)projectile.velocity.X); + } + else + { + projectile.spriteDirection = 1; + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); + } + } + else if (Destination == Vector2.Zero) + { + // Set start of telegraph to the npc center. + projectile.Center = ThingToAttachTo.Center; - // Set destination of the laser, the target's center. - Destination = projectile.velocity; + // Set destination of the laser, the target's center. + Destination = projectile.velocity; - projectile.Center += Vector2.Normalize(Destination - ThingToAttachTo.Center) * 70f; + projectile.Center += Vector2.Normalize(Destination - ThingToAttachTo.Center) * 70f; - // Calculate and store the velocity that will be used for laser telegraph rotation and beam firing. - Vector2 projectileDestination = Destination - ThingToAttachTo.Center; - Velocity = Vector2.Normalize(projectileDestination) * LaserVelocity; + // Calculate and store the velocity that will be used for laser telegraph rotation and beam firing. + Vector2 projectileDestination = Destination - ThingToAttachTo.Center; + Velocity = Vector2.Normalize(projectileDestination) * LaserVelocity; - // Set velocity to zero. - projectile.velocity = Vector2.Zero; - projectile.netUpdate = true; + // Set velocity to zero. + projectile.velocity = Vector2.Zero; + projectile.netUpdate = true; - // Direction and rotation. - if (projectile.velocity.X < 0f) - { - projectile.spriteDirection = -1; - projectile.rotation = (float)Math.Atan2((double)-(double)Velocity.Y, (double)-(double)Velocity.X); - } - else - { - projectile.spriteDirection = 1; - projectile.rotation = (float)Math.Atan2((double)Velocity.Y, (double)Velocity.X); - } - } - else - { - // Set start of telegraph to the npc center. - projectile.Center = ThingToAttachTo.Center; + // Direction and rotation. + if (projectile.velocity.X < 0f) + { + projectile.spriteDirection = -1; + projectile.rotation = (float)Math.Atan2((double)-(double)Velocity.Y, (double)-(double)Velocity.X); + } + else + { + projectile.spriteDirection = 1; + projectile.rotation = (float)Math.Atan2((double)Velocity.Y, (double)Velocity.X); + } + } + else + { + // Set start of telegraph to the npc center. + projectile.Center = ThingToAttachTo.Center; - projectile.Center += Vector2.Normalize(Destination - ThingToAttachTo.Center) * 70f; + projectile.Center += Vector2.Normalize(Destination - ThingToAttachTo.Center) * 70f; - // Calculate and store the velocity that will be used for laser telegraph rotation and beam firing. - Vector2 projectileDestination = Destination - ThingToAttachTo.Center; - Velocity = Vector2.Normalize(projectileDestination) * LaserVelocity; + // Calculate and store the velocity that will be used for laser telegraph rotation and beam firing. + Vector2 projectileDestination = Destination - ThingToAttachTo.Center; + Velocity = Vector2.Normalize(projectileDestination) * LaserVelocity; - // Direction and rotation. - if (projectile.velocity.X < 0f) - { - projectile.spriteDirection = -1; - projectile.rotation = (float)Math.Atan2((double)-(double)Velocity.Y, (double)-(double)Velocity.X); - } - else - { - projectile.spriteDirection = 1; - projectile.rotation = (float)Math.Atan2((double)Velocity.Y, (double)Velocity.X); - } - } + // Direction and rotation. + if (projectile.velocity.X < 0f) + { + projectile.spriteDirection = -1; + projectile.rotation = (float)Math.Atan2((double)-(double)Velocity.Y, (double)-(double)Velocity.X); + } + else + { + projectile.spriteDirection = 1; + projectile.rotation = (float)Math.Atan2((double)Velocity.Y, (double)Velocity.X); + } + } - TelegraphDelay++; - } + TelegraphDelay++; + } - public override bool CanHitPlayer(Player target) => TelegraphDelay > TelegraphTotalTime; + public override bool CanHitPlayer(Player target) => TelegraphDelay > TelegraphTotalTime; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (TelegraphDelay > TelegraphTotalTime) - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (TelegraphDelay > TelegraphTotalTime) + target.AddBuff(ModContent.BuffType(), 180); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - return CalamityUtils.CircularHitboxCollision(projHitbox.Center(), projectile.Size.Length() * 0.5f, targetHitbox); - } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + return CalamityUtils.CircularHitboxCollision(projHitbox.Center(), projectile.Size.Length() * 0.5f, targetHitbox); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (TelegraphDelay >= TelegraphTotalTime) - { - lightColor.R = (byte)(255 * projectile.Opacity); - lightColor.G = (byte)(255 * projectile.Opacity); - lightColor.B = (byte)(255 * projectile.Opacity); - Vector2 drawOffset = projectile.velocity.SafeNormalize(Vector2.Zero) * -30f; - projectile.Center += drawOffset; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - projectile.Center -= drawOffset; - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (TelegraphDelay >= TelegraphTotalTime) + { + lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.G = (byte)(255 * projectile.Opacity); + lightColor.B = (byte)(255 * projectile.Opacity); + Vector2 drawOffset = projectile.velocity.SafeNormalize(Vector2.Zero) * -30f; + projectile.Center += drawOffset; + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + projectile.Center -= drawOffset; + return false; + } - Texture2D laserTelegraph = ModContent.GetTexture("CalamityMod/ExtraTextures/LaserWallTelegraphBeam"); + Texture2D laserTelegraph = ModContent.GetTexture("CalamityMod/ExtraTextures/LaserWallTelegraphBeam"); - float yScale = 2f; - if (TelegraphDelay < TelegraphFadeTime) - yScale = MathHelper.Lerp(0f, 2f, TelegraphDelay / 15f); - if (TelegraphDelay > TelegraphTotalTime - TelegraphFadeTime) - yScale = MathHelper.Lerp(2f, 0f, (TelegraphDelay - (TelegraphTotalTime - TelegraphFadeTime)) / 15f); + float yScale = 2f; + if (TelegraphDelay < TelegraphFadeTime) + yScale = MathHelper.Lerp(0f, 2f, TelegraphDelay / 15f); + if (TelegraphDelay > TelegraphTotalTime - TelegraphFadeTime) + yScale = MathHelper.Lerp(2f, 0f, (TelegraphDelay - (TelegraphTotalTime - TelegraphFadeTime)) / 15f); - Vector2 scaleInner = new Vector2(TelegraphWidth / laserTelegraph.Width, yScale); - Vector2 origin = laserTelegraph.Size() * new Vector2(0f, 0.5f); - Vector2 scaleOuter = scaleInner * new Vector2(1f, 2.2f); + Vector2 scaleInner = new Vector2(TelegraphWidth / laserTelegraph.Width, yScale); + Vector2 origin = laserTelegraph.Size() * new Vector2(0f, 0.5f); + Vector2 scaleOuter = scaleInner * new Vector2(1f, 2.2f); - Color colorOuter = Color.Lerp(Color.Orange, Color.OrangeRed, TelegraphDelay / TelegraphTotalTime * 2f % 1f); // Iterate through orange and dark orange once and then flash. - Color colorInner = Color.Lerp(colorOuter, Color.White, 0.75f); + Color colorOuter = Color.Lerp(Color.Orange, Color.OrangeRed, TelegraphDelay / TelegraphTotalTime * 2f % 1f); // Iterate through orange and dark orange once and then flash. + Color colorInner = Color.Lerp(colorOuter, Color.White, 0.75f); - colorOuter *= 0.6f; - colorInner *= 0.6f; + colorOuter *= 0.6f; + colorInner *= 0.6f; - spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorInner, Velocity.ToRotation(), origin, scaleInner, SpriteEffects.None, 0f); - spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorOuter, Velocity.ToRotation(), origin, scaleOuter, SpriteEffects.None, 0f); - return false; - } - } + spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorInner, Velocity.ToRotation(), origin, scaleInner, SpriteEffects.None, 0f); + spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorOuter, Velocity.ToRotation(), origin, scaleOuter, SpriteEffects.None, 0f); + return false; + } + } } diff --git a/Projectiles/Boss/ArtemisLaserBeamStart.cs b/Projectiles/Boss/ArtemisLaserBeamStart.cs index cdec407a56..d3a3670c52 100644 --- a/Projectiles/Boss/ArtemisLaserBeamStart.cs +++ b/Projectiles/Boss/ArtemisLaserBeamStart.cs @@ -180,9 +180,9 @@ namespace CalamityMod.Projectiles.Boss target.AddBuff(ModContent.BuffType(), 300); } - public override bool CanHitPlayer(Player target) => projectile.scale >= 0.5f; + public override bool CanHitPlayer(Player target) => projectile.scale >= 0.5f; - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { target.Calamity().lastProjectileHit = projectile; } diff --git a/Projectiles/Boss/AstralFlame.cs b/Projectiles/Boss/AstralFlame.cs index 587a98f543..c74f2d965a 100644 --- a/Projectiles/Boss/AstralFlame.cs +++ b/Projectiles/Boss/AstralFlame.cs @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 50; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 50; projectile.height = 50; projectile.hostile = true; projectile.ignoreWater = true; @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 100; projectile.penetrate = 1; projectile.timeLeft = 485; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -46,13 +46,13 @@ namespace CalamityMod.Projectiles.Boss if (projectile.velocity.X < 0f) { projectile.spriteDirection = -1; - projectile.rotation = (float)Math.Atan2((double)-(double)projectile.velocity.Y, (double)-(double)projectile.velocity.X); - } + projectile.rotation = (float)Math.Atan2((double)-(double)projectile.velocity.Y, (double)-(double)projectile.velocity.X); + } else { projectile.spriteDirection = 1; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); - } + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); + } Lighting.AddLight(projectile.Center, 0.3f, 0.5f, 0.1f); @@ -76,10 +76,10 @@ namespace CalamityMod.Projectiles.Boss { if (projectile.ai[1] < 120f) { - if (projectile.ai[1] < 15f) - projectile.velocity *= 1.02f; + if (projectile.ai[1] < 15f) + projectile.velocity *= 1.02f; - float scaleFactor2 = projectile.velocity.Length(); + float scaleFactor2 = projectile.velocity.Length(); vector11.Normalize(); vector11 *= scaleFactor2; projectile.velocity = (projectile.velocity * 15f + vector11) / 16f; @@ -89,9 +89,9 @@ namespace CalamityMod.Projectiles.Boss else if (projectile.velocity.Length() < 18f) projectile.velocity *= 1.01f; - projectile.ai[1] += 1f; - } - } + projectile.ai[1] += 1f; + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Boss/AstralGodRay.cs b/Projectiles/Boss/AstralGodRay.cs index d9ef0b693f..7894b91cff 100644 --- a/Projectiles/Boss/AstralGodRay.cs +++ b/Projectiles/Boss/AstralGodRay.cs @@ -40,17 +40,17 @@ namespace CalamityMod.Projectiles.Boss projectile.timeLeft = 1200; projectile.tileCollide = false; projectile.ignoreWater = true; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { - Vector2 targetLocation = new Vector2(projectile.ai[0], projectile.ai[1]); - if (Vector2.Distance(targetLocation, projectile.Center) < 80f) - projectile.tileCollide = true; + Vector2 targetLocation = new Vector2(projectile.ai[0], projectile.ai[1]); + if (Vector2.Distance(targetLocation, projectile.Center) < 80f) + projectile.tileCollide = true; - // Very rapidly fade into existence. - if (projectile.alpha > 0) + // Very rapidly fade into existence. + if (projectile.alpha > 0) projectile.alpha -= 25; if (projectile.alpha < 0) projectile.alpha = 0; @@ -83,14 +83,14 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity = projectile.velocity.RotatedBy(waveSign * WaveTheta); projectile.rotation = projectile.velocity.ToRotation(); - // Emit light. - if (WaveFrameState < 0f) - Lighting.AddLight(projectile.Center, 0.87f, 0.65f, 0.1725f); - else - Lighting.AddLight(projectile.Center, 0.1725f, 0.87f, 0.65f); + // Emit light. + if (WaveFrameState < 0f) + Lighting.AddLight(projectile.Center, 0.87f, 0.65f, 0.1725f); + else + Lighting.AddLight(projectile.Center, 0.1725f, 0.87f, 0.65f); - // Laser length shenanigans. If the laser is still growing, increase localAI 0 to indicate it is getting longer. - projectile.localAI[0] += 10f; // LaserLengthChangeRate; + // Laser length shenanigans. If the laser is still growing, increase localAI 0 to indicate it is getting longer. + projectile.localAI[0] += 10f; // LaserLengthChangeRate; // Cap it at max length. if (projectile.localAI[0] > LaserLength) @@ -105,20 +105,20 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 120); + } - public override Color? GetAlpha(Color lightColor) - { - if (WaveFrameState < 0f) - return new Color(255, 100, 0, projectile.alpha); + public override Color? GetAlpha(Color lightColor) + { + if (WaveFrameState < 0f) + return new Color(255, 100, 0, projectile.alpha); - return new Color(0, 255, 200, projectile.alpha); - } + return new Color(0, 255, 200, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(LaserLength, 2f, lightColor, curve: true); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(LaserLength, 2f, lightColor, curve: true); public override void Kill(int timeLeft) { diff --git a/Projectiles/Boss/AstralLaser.cs b/Projectiles/Boss/AstralLaser.cs index 9cfb695807..2b9a433176 100644 --- a/Projectiles/Boss/AstralLaser.cs +++ b/Projectiles/Boss/AstralLaser.cs @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 240; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override bool CanHitPlayer(Player target) => projectile.timeLeft >= 85; + public override bool CanHitPlayer(Player target) => projectile.timeLeft >= 85; public override Color? GetAlpha(Color lightColor) { @@ -83,8 +83,8 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.timeLeft >= 85) - target.AddBuff(ModContent.BuffType(), 120); + if (projectile.timeLeft >= 85) + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/Boss/AstralShot2.cs b/Projectiles/Boss/AstralShot2.cs index eb8e47dd2b..124a1a84ff 100644 --- a/Projectiles/Boss/AstralShot2.cs +++ b/Projectiles/Boss/AstralShot2.cs @@ -26,36 +26,36 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 10; projectile.hostile = true; projectile.ignoreWater = true; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 600; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { - if (projectile.ai[0] == 1f) - { - projectile.extraUpdates = 2; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - float maxVelocity = malice ? 3.75f : 3f; - if (projectile.velocity.Length() < maxVelocity) - { - projectile.velocity *= malice ? 1.02f : 1.015f; - if (projectile.velocity.Length() > maxVelocity) - { - projectile.velocity.Normalize(); - projectile.velocity *= maxVelocity; - } - } - } - else - { - Vector2 targetLocation = new Vector2(projectile.ai[0], projectile.ai[1]); - if (Vector2.Distance(targetLocation, projectile.Center) < 80f) - projectile.tileCollide = true; - } + if (projectile.ai[0] == 1f) + { + projectile.extraUpdates = 2; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + float maxVelocity = malice ? 3.75f : 3f; + if (projectile.velocity.Length() < maxVelocity) + { + projectile.velocity *= malice ? 1.02f : 1.015f; + if (projectile.velocity.Length() > maxVelocity) + { + projectile.velocity.Normalize(); + projectile.velocity *= maxVelocity; + } + } + } + else + { + Vector2 targetLocation = new Vector2(projectile.ai[0], projectile.ai[1]); + if (Vector2.Distance(targetLocation, projectile.Center) < 80f) + projectile.tileCollide = true; + } projectile.frameCounter++; if (projectile.frameCounter > 4) diff --git a/Projectiles/Boss/BigFlare.cs b/Projectiles/Boss/BigFlare.cs index 46e317852b..2ad80a73e5 100644 --- a/Projectiles/Boss/BigFlare.cs +++ b/Projectiles/Boss/BigFlare.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class BigFlare : ModProjectile + public class BigFlare : ModProjectile { public override void SetStaticDefaults() { @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 1200; - projectile.scale = 1.5f; - } + projectile.scale = 1.5f; + } public override void SendExtraAI(BinaryWriter writer) { @@ -155,11 +155,11 @@ namespace CalamityMod.Projectiles.Boss break; } } - int spawnLimitY = (int)(Main.player[projectile.owner].Center.Y / 16f) + 50; - if (num231 > spawnLimitY) - { - num231 = spawnLimitY; - } + int spawnLimitY = (int)(Main.player[projectile.owner].Center.Y / 16f) + 50; + if (num231 > spawnLimitY) + { + num231 = spawnLimitY; + } int num236 = Projectile.NewProjectile((float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 0, 4f, Main.myPlayer, 11f, 16f + (revenge ? 2f : 0f)); Main.projectile[num236].netUpdate = true; } diff --git a/Projectiles/Boss/BigFlare2.cs b/Projectiles/Boss/BigFlare2.cs index 3c8e34ecce..f60cfe62e7 100644 --- a/Projectiles/Boss/BigFlare2.cs +++ b/Projectiles/Boss/BigFlare2.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class BigFlare2 : ModProjectile + public class BigFlare2 : ModProjectile { public override void SetStaticDefaults() { @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 1200; - projectile.scale = 1.5f; + projectile.scale = 1.5f; } public override void SendExtraAI(BinaryWriter writer) @@ -111,8 +111,8 @@ namespace CalamityMod.Projectiles.Boss public override void Kill(int timeLeft) { - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 20); + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 20); int num226 = 36; for (int num227 = 0; num227 < num226; num227++) { @@ -155,12 +155,12 @@ namespace CalamityMod.Projectiles.Boss break; } } - int spawnLimitY = (int)(Main.player[projectile.owner].Center.Y / 16f) + 75; - if (num231 > spawnLimitY) - { - num231 = spawnLimitY; - } - int num236 = Projectile.NewProjectile((float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 0, 4f, Main.myPlayer, 11f, 24f + (revenge ? 2f : 0f)); + int spawnLimitY = (int)(Main.player[projectile.owner].Center.Y / 16f) + 75; + if (num231 > spawnLimitY) + { + num231 = spawnLimitY; + } + int num236 = Projectile.NewProjectile((float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 0, 4f, Main.myPlayer, 11f, 24f + (revenge ? 2f : 0f)); Main.projectile[num236].netUpdate = true; } } diff --git a/Projectiles/Boss/BirbAura.cs b/Projectiles/Boss/BirbAura.cs index 908b1c6c34..024458849d 100644 --- a/Projectiles/Boss/BirbAura.cs +++ b/Projectiles/Boss/BirbAura.cs @@ -7,10 +7,10 @@ using Terraria.Enums; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class BirbAura : ModProjectile + public class BirbAura : ModProjectile { - float timer = 135f; - float timeBeforeVanish = 0f; + float timer = 135f; + float timeBeforeVanish = 0f; public override void SetStaticDefaults() { @@ -32,23 +32,23 @@ namespace CalamityMod.Projectiles.Boss { writer.Write(projectile.localAI[0]); writer.Write(projectile.localAI[1]); - writer.Write(timer); - writer.Write(timeBeforeVanish); - } + writer.Write(timer); + writer.Write(timeBeforeVanish); + } public override void ReceiveExtraAI(BinaryReader reader) { projectile.localAI[0] = reader.ReadSingle(); projectile.localAI[1] = reader.ReadSingle(); - timer = reader.ReadSingle(); - timeBeforeVanish = reader.ReadSingle(); - } + timer = reader.ReadSingle(); + timeBeforeVanish = reader.ReadSingle(); + } public override void AI() { - Vector2? vector78 = null; + Vector2? vector78 = null; - if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) + if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) projectile.velocity = -Vector2.UnitY; Vector2 fireFrom = new Vector2(projectile.ai[0], projectile.ai[1]); @@ -57,12 +57,12 @@ namespace CalamityMod.Projectiles.Boss if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) projectile.velocity = -Vector2.UnitY; - if (timer > 0f) - timer -= 1f; + if (timer > 0f) + timer -= 1f; float num801 = 1f; - if (timeBeforeVanish == 0f) - timeBeforeVanish = projectile.timeLeft <= 900 ? 900f : 1200f; + if (timeBeforeVanish == 0f) + timeBeforeVanish = projectile.timeLeft <= 900 ? 900f : 1200f; projectile.localAI[0] += 1f; if (projectile.localAI[0] >= timeBeforeVanish) @@ -75,71 +75,71 @@ namespace CalamityMod.Projectiles.Boss if (projectile.scale > num801) projectile.scale = num801; - float num804 = projectile.velocity.ToRotation(); - projectile.rotation = num804 - MathHelper.PiOver2; - projectile.velocity = num804.ToRotationVector2(); + float num804 = projectile.velocity.ToRotation(); + projectile.rotation = num804 - MathHelper.PiOver2; + projectile.velocity = num804.ToRotationVector2(); - float num805 = 3f; //3f - float num806 = projectile.width; + float num805 = 3f; //3f + float num806 = projectile.width; - Vector2 samplingPoint = projectile.Center; - if (vector78.HasValue) - samplingPoint = vector78.Value; + Vector2 samplingPoint = projectile.Center; + if (vector78.HasValue) + samplingPoint = vector78.Value; - float laserLength = projectile.ai[1] - 160f; - float[] array3 = new float[(int)num805]; - Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, laserLength, array3); - float num807 = 0f; - for (int num808 = 0; num808 < array3.Length; num808++) - { - num807 += array3[num808]; - } - num807 /= num805; + float laserLength = projectile.ai[1] - 160f; + float[] array3 = new float[(int)num805]; + Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, laserLength, array3); + float num807 = 0f; + for (int num808 = 0; num808 < array3.Length; num808++) + { + num807 += array3[num808]; + } + num807 /= num805; - num807 = MathHelper.Clamp(num807, 3600f, 4800f); + num807 = MathHelper.Clamp(num807, 3600f, 4800f); - float amount = 0.5f; + float amount = 0.5f; projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); DelegateMethods.v3_1 = new Vector3(0.9f, 0.3f, 0.3f); Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - if (timer <= 0f && (projectile.localAI[0] >= 120f || projectile.timeLeft <= 900)) - { - if (projectile.owner == Main.myPlayer) - { - timer = 15f; - Vector2 fireFrom = new Vector2(target.Center.X, target.Center.Y - 900f); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)target.Center.X, (int)target.Center.Y - 300); - Vector2 ai0 = target.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, 0f, projectile.owner, ai0.ToRotation(), ai); - } - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + if (timer <= 0f && (projectile.localAI[0] >= 120f || projectile.timeLeft <= 900)) + { + if (projectile.owner == Main.myPlayer) + { + timer = 15f; + Vector2 fireFrom = new Vector2(target.Center.X, target.Center.Y - 900f); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)target.Center.X, (int)target.Center.Y - 300); + Vector2 ai0 = target.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, 0f, projectile.owner, ai0.ToRotation(), ai); + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { if (projectile.velocity == Vector2.Zero) { return false; } - Texture2D texture = Main.projectileTexture[projectile.type]; - Texture2D texture2 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/BirbAuraStart"); - Texture2D texture3 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/BirbAuraEnd"); - float num223 = projectile.localAI[1]; //length of laser - Color color44 = new Color(128, 128, 128, 0); - Vector2 vector = projectile.Center - Main.screenPosition; - Rectangle? sourceRectangle2 = null; - spriteBatch.Draw(texture2, vector, sourceRectangle2, color44, projectile.rotation, texture2.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); - num223 -= (texture2.Height / 2 + texture3.Height) * projectile.scale; - Vector2 value20 = projectile.Center; - value20 += projectile.velocity * projectile.scale * texture2.Height / 2f; - if (num223 > 0f) + Texture2D texture = Main.projectileTexture[projectile.type]; + Texture2D texture2 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/BirbAuraStart"); + Texture2D texture3 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/BirbAuraEnd"); + float num223 = projectile.localAI[1]; //length of laser + Color color44 = new Color(128, 128, 128, 0); + Vector2 vector = projectile.Center - Main.screenPosition; + Rectangle? sourceRectangle2 = null; + spriteBatch.Draw(texture2, vector, sourceRectangle2, color44, projectile.rotation, texture2.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + num223 -= (texture2.Height / 2 + texture3.Height) * projectile.scale; + Vector2 value20 = projectile.Center; + value20 += projectile.velocity * projectile.scale * texture2.Height / 2f; + if (num223 > 0f) { float num224 = 0f; Rectangle rectangle7 = new Rectangle(0, 0, texture.Width, texture.Height); @@ -159,35 +159,35 @@ namespace CalamityMod.Projectiles.Boss } } } - Vector2 vector2 = value20 - Main.screenPosition; - sourceRectangle2 = null; - spriteBatch.Draw(texture3, vector2, sourceRectangle2, color44, projectile.rotation, texture3.Frame(1, 1, 0, 0).Top(), projectile.scale, SpriteEffects.None, 0f); - return false; + Vector2 vector2 = value20 - Main.screenPosition; + sourceRectangle2 = null; + spriteBatch.Draw(texture3, vector2, sourceRectangle2, color44, projectile.rotation, texture3.Frame(1, 1, 0, 0).Top(), projectile.scale, SpriteEffects.None, 0f); + return false; } - public override void CutTiles() - { - DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; - Vector2 unit = projectile.velocity; - Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); - } + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 unit = projectile.velocity; + Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (timer > 15f) - { - return false; - } - if (projHitbox.Intersects(targetHitbox)) - { - return true; - } - float num6 = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 80f * projectile.scale, ref num6)) - { - return true; - } - return false; - } - } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (timer > 15f) + { + return false; + } + if (projHitbox.Intersects(targetHitbox)) + { + return true; + } + float num6 = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 80f * projectile.scale, ref num6)) + { + return true; + } + return false; + } + } } diff --git a/Projectiles/Boss/BirbAuraFlare.cs b/Projectiles/Boss/BirbAuraFlare.cs index b5afacd09f..7e499efae3 100644 --- a/Projectiles/Boss/BirbAuraFlare.cs +++ b/Projectiles/Boss/BirbAuraFlare.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class BirbAuraFlare : ModProjectile + public class BirbAuraFlare : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -22,22 +22,22 @@ namespace CalamityMod.Projectiles.Boss projectile.width = 32; projectile.height = 32; projectile.hostile = true; - projectile.ignoreWater = true; + projectile.ignoreWater = true; projectile.penetrate = -1; projectile.timeLeft = 1200; - } + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(projectile.localAI[0]); - writer.Write(projectile.localAI[1]); - } + writer.Write(projectile.localAI[1]); + } public override void ReceiveExtraAI(BinaryReader reader) { projectile.localAI[0] = reader.ReadSingle(); - projectile.localAI[1] = reader.ReadSingle(); - } + projectile.localAI[1] = reader.ReadSingle(); + } public override void AI() { @@ -49,8 +49,8 @@ namespace CalamityMod.Projectiles.Boss projectile.localAI[0] += 1f; if (projectile.localAI[0] > 10f) { - // Dust pulse effect - projectile.localAI[1] = (float)Math.Abs(Math.Cos(MathHelper.ToRadians(projectile.localAI[0] * 2f))); + // Dust pulse effect + projectile.localAI[1] = (float)Math.Abs(Math.Cos(MathHelper.ToRadians(projectile.localAI[0] * 2f))); int num626 = 18; for (int num627 = 0; num627 < num626; num627++) { @@ -58,18 +58,18 @@ namespace CalamityMod.Projectiles.Boss vector45 = vector45.RotatedBy((num627 - (num626 / 2 - 1)) * 3.1415926535897931 / (float)num626) + projectile.Center; Vector2 value15 = ((float)(Main.rand.NextDouble() * Math.PI) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); int num628 = Dust.NewDust(vector45 + value15, 0, 0, 60, value15.X * 2f, value15.Y * 2f, 100, default, 1f); - Main.dust[num628].scale = 1.4f; + Main.dust[num628].scale = 1.4f; Main.dust[num628].noGravity = true; Main.dust[num628].noLight = true; Main.dust[num628].velocity /= 4f; Main.dust[num628].velocity -= projectile.velocity; } - } + } Vector2 value16 = Main.player[num625].Center - projectile.Center; float num629 = 4f; - float divisor = 60f - 15f * projectile.ai[0]; - num629 += projectile.localAI[0] / divisor; + float divisor = 60f - 15f * projectile.ai[0]; + num629 += projectile.localAI[0] / divisor; projectile.velocity = Vector2.Normalize(value16) * num629; if (value16.Length() < 32f) { @@ -81,8 +81,8 @@ namespace CalamityMod.Projectiles.Boss public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.DD2_BetsyFireballImpact, (int)projectile.position.X, (int)projectile.position.Y); - int num226 = 36; + Main.PlaySound(SoundID.DD2_BetsyFireballImpact, (int)projectile.position.X, (int)projectile.position.Y); + int num226 = 36; for (int num227 = 0; num227 < num226; num227++) { Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2(projectile.width / 2f, projectile.height) * 0.75f; @@ -95,10 +95,10 @@ namespace CalamityMod.Projectiles.Boss } if (projectile.owner == Main.myPlayer) { - int num231 = (int)(projectile.Center.Y / 16f); - int num232 = (int)(projectile.Center.X / 16f); - int num233 = 100; - if (num232 < 10) + int num231 = (int)(projectile.Center.Y / 16f); + int num232 = (int)(projectile.Center.X / 16f); + int num233 = 100; + if (num232 < 10) { num232 = 10; } @@ -106,49 +106,49 @@ namespace CalamityMod.Projectiles.Boss { num232 = Main.maxTilesX - 10; } - if (num231 < 10) - { - num231 = 10; - } - if (num231 > Main.maxTilesY - num233 - 10) - { - num231 = Main.maxTilesY - num233 - 10; - } - float x = num232 * 16; - float y = num231 * 16 + 900; - Vector2 laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); - int type = ModContent.ProjectileType(); - int damage = projectile.GetProjectileDamage(ModContent.NPCType()); - if (projectile.ai[0] >= 2f) - { - x += 1000f; - if ((int)(x / 16f) > Main.maxTilesX - 10) - { - x = (Main.maxTilesX - 10) * 16f; - } - laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); - laserVelocity.Normalize(); - int num237 = Projectile.NewProjectile(x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); - Main.projectile[num237].timeLeft = 900; - Main.projectile[num237].netUpdate = true; + if (num231 < 10) + { + num231 = 10; + } + if (num231 > Main.maxTilesY - num233 - 10) + { + num231 = Main.maxTilesY - num233 - 10; + } + float x = num232 * 16; + float y = num231 * 16 + 900; + Vector2 laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); + int type = ModContent.ProjectileType(); + int damage = projectile.GetProjectileDamage(ModContent.NPCType()); + if (projectile.ai[0] >= 2f) + { + x += 1000f; + if ((int)(x / 16f) > Main.maxTilesX - 10) + { + x = (Main.maxTilesX - 10) * 16f; + } + laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); + laserVelocity.Normalize(); + int num237 = Projectile.NewProjectile(x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); + Main.projectile[num237].timeLeft = 900; + Main.projectile[num237].netUpdate = true; - x -= 2000f; - if ((int)(x / 16f) < 10) - { - x = 160f; - } - laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); - laserVelocity.Normalize(); - int num238 = Projectile.NewProjectile(x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); - Main.projectile[num238].timeLeft = 900; - Main.projectile[num238].netUpdate = true; - } - else - { - laserVelocity.Normalize(); - int num236 = Projectile.NewProjectile(x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); - Main.projectile[num236].netUpdate = true; - } + x -= 2000f; + if ((int)(x / 16f) < 10) + { + x = 160f; + } + laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); + laserVelocity.Normalize(); + int num238 = Projectile.NewProjectile(x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); + Main.projectile[num238].timeLeft = 900; + Main.projectile[num238].netUpdate = true; + } + else + { + laserVelocity.Normalize(); + int num236 = Projectile.NewProjectile(x, y, 0f, laserVelocity.Y, type, damage, 0f, Main.myPlayer, x, y); + Main.projectile[num236].netUpdate = true; + } } } } diff --git a/Projectiles/Boss/BloodGeyser.cs b/Projectiles/Boss/BloodGeyser.cs index dbd9aad4a7..5c4b403a95 100644 --- a/Projectiles/Boss/BloodGeyser.cs +++ b/Projectiles/Boss/BloodGeyser.cs @@ -25,27 +25,27 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - if (projectile.position.Y > projectile.ai[1]) - projectile.tileCollide = true; + if (projectile.position.Y > projectile.ai[1]) + projectile.tileCollide = true; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Blood, 0f, 0f, 100, default, 0.5f); Main.dust[num469].noGravity = true; Main.dust[num469].velocity *= 0f; - projectile.velocity.Y += 0.06f; - projectile.velocity.X *= 0.995f; - } + projectile.velocity.Y += 0.06f; + projectile.velocity.X *= 0.995f; + } public override void OnHitPlayer(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 50, 50, projectile.alpha); - } - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(250, 50, 50, projectile.alpha); + } + } } diff --git a/Projectiles/Boss/BrimstoneBall.cs b/Projectiles/Boss/BrimstoneBall.cs index 7ac02074a8..6e52b6279d 100644 --- a/Projectiles/Boss/BrimstoneBall.cs +++ b/Projectiles/Boss/BrimstoneBall.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Boss projectile.hostile = true; projectile.penetrate = 1; projectile.timeLeft = 300; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Boss Main.dust[num469].noGravity = true; Main.dust[num469].velocity = dspeed; } - } + } public override void OnHitPlayer(Player target, int damage, bool crit) { diff --git a/Projectiles/Boss/BrimstoneBarrage.cs b/Projectiles/Boss/BrimstoneBarrage.cs index a91fb86372..c2516b8e0c 100644 --- a/Projectiles/Boss/BrimstoneBarrage.cs +++ b/Projectiles/Boss/BrimstoneBarrage.cs @@ -11,9 +11,9 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class BrimstoneBarrage : ModProjectile + public class BrimstoneBarrage : ModProjectile { - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Brimstone Dart"); Main.projFrames[projectile.type] = 4; @@ -30,29 +30,29 @@ namespace CalamityMod.Projectiles.Boss projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 690; - cooldownSlot = 1; - } + cooldownSlot = 1; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + writer.Write(projectile.localAI[0]); + } - if (projectile.velocity.Length() < (projectile.ai[1] == 0f ? (malice ? 17.5f : 14f) : (malice ? 12.5f : 10f))) - projectile.velocity *= malice ? 1.0125f : 1.01f; + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + } - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + public override void AI() + { + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - projectile.frameCounter++; + if (projectile.velocity.Length() < (projectile.ai[1] == 0f ? (malice ? 17.5f : 14f) : (malice ? 12.5f : 10f))) + projectile.velocity *= malice ? 1.0125f : 1.01f; + + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + + projectile.frameCounter++; if (projectile.frameCounter > 4) { projectile.frame++; @@ -61,61 +61,61 @@ namespace CalamityMod.Projectiles.Boss if (projectile.frame > 3) projectile.frame = 0; - if (projectile.timeLeft < 60) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); + if (projectile.timeLeft < 60) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); - if (projectile.ai[0] == 2f) - { - if (projectile.timeLeft > 570) - { - int player = Player.FindClosest(projectile.Center, 1, 1); - Vector2 vector = Main.player[player].Center - projectile.Center; - float scaleFactor = projectile.velocity.Length(); - vector.Normalize(); - vector *= scaleFactor; - projectile.velocity = (projectile.velocity * 15f + vector) / 16f; - projectile.velocity.Normalize(); - projectile.velocity *= scaleFactor; - } - } + if (projectile.ai[0] == 2f) + { + if (projectile.timeLeft > 570) + { + int player = Player.FindClosest(projectile.Center, 1, 1); + Vector2 vector = Main.player[player].Center - projectile.Center; + float scaleFactor = projectile.velocity.Length(); + vector.Normalize(); + vector *= scaleFactor; + projectile.velocity = (projectile.velocity * 15f + vector) / 16f; + projectile.velocity.Normalize(); + projectile.velocity *= scaleFactor; + } + } - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; - if (projectile.ai[0] == 0f) - projectile.damage = NPC.AnyNPCs(ModContent.NPCType()) ? projectile.GetProjectileDamage(ModContent.NPCType()) : projectile.GetProjectileDamage(ModContent.NPCType()); - } + if (projectile.ai[0] == 0f) + projectile.damage = NPC.AnyNPCs(ModContent.NPCType()) ? projectile.GetProjectileDamage(ModContent.NPCType()) : projectile.GetProjectileDamage(ModContent.NPCType()); + } - Lighting.AddLight(projectile.Center, 0.75f * projectile.Opacity, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.75f * projectile.Opacity, 0f, 0f); } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.Opacity != 1f) - return; + if (projectile.Opacity != 1f) + return; - if (projectile.ai[0] == 0f) - { - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 120); - } - else - target.AddBuff(ModContent.BuffType(), 120); - } + if (projectile.ai[0] == 0f) + { + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 120); + } + else + target.AddBuff(ModContent.BuffType(), 120); + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - lightColor.R = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + lightColor.R = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/BrimstoneFire.cs b/Projectiles/Boss/BrimstoneFire.cs index 61edbf86c0..1189de8ba5 100644 --- a/Projectiles/Boss/BrimstoneFire.cs +++ b/Projectiles/Boss/BrimstoneFire.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class BrimstoneFire : ModProjectile + public class BrimstoneFire : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.extraUpdates = 3; projectile.timeLeft = 90; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -45,25 +45,25 @@ namespace CalamityMod.Projectiles.Boss } projectile.ai[0] += 1f; int dustType = (int)CalamityDusts.Brimstone; - if (Main.rand.NextBool(2)) - { - int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 100, default, 1f); - Dust dust = Main.dust[fire]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 3f; - dust.velocity.X *= 1.5f; - dust.velocity.Y *= 1.5f; - } - else - { - dust.scale *= 1.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= scalar; - } + if (Main.rand.NextBool(2)) + { + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 100, default, 1f); + Dust dust = Main.dust[fire]; + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 3f; + dust.velocity.X *= 1.5f; + dust.velocity.Y *= 1.5f; + } + else + { + dust.scale *= 1.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= scalar; + } } else { diff --git a/Projectiles/Boss/BrimstoneFireblast.cs b/Projectiles/Boss/BrimstoneFireblast.cs index 46652bd2c9..fa4ac4d058 100644 --- a/Projectiles/Boss/BrimstoneFireblast.cs +++ b/Projectiles/Boss/BrimstoneFireblast.cs @@ -19,94 +19,94 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 50; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 50; projectile.height = 50; projectile.hostile = true; projectile.ignoreWater = true; projectile.penetrate = 1; - projectile.timeLeft = 120; - projectile.Opacity = 0f; - cooldownSlot = 1; + projectile.timeLeft = 120; + projectile.Opacity = 0f; + cooldownSlot = 1; } - public override void AI() - { - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 5) - projectile.frame = 0; + public override void AI() + { + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 5) + projectile.frame = 0; - if (projectile.ai[1] == 1f) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 60) / 60f), 0f, 1f); + if (projectile.ai[1] == 1f) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 60) / 60f), 0f, 1f); - Lighting.AddLight(projectile.Center, 0.9f * projectile.Opacity, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.9f * projectile.Opacity, 0f, 0f); - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; - Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 20); - } + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; + Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 20); + } - int target = Player.FindClosest(projectile.Center, 1, 1); - float projSpeed = projectile.velocity.Length(); - Vector2 playerVec = Main.player[target].Center - projectile.Center; - playerVec.Normalize(); - playerVec *= projSpeed; - projectile.velocity = (projectile.velocity * 24f + playerVec) / 25f; - projectile.velocity.Normalize(); - projectile.velocity *= projSpeed; - } + int target = Player.FindClosest(projectile.Center, 1, 1); + float projSpeed = projectile.velocity.Length(); + Vector2 playerVec = Main.player[target].Center - projectile.Center; + playerVec.Normalize(); + playerVec *= projSpeed; + projectile.velocity = (projectile.velocity * 24f + playerVec) / 25f; + projectile.velocity.Normalize(); + projectile.velocity *= projSpeed; + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; int frameHeight = texture.Height / Main.projFrames[projectile.type]; int drawStart = frameHeight * projectile.frame; - lightColor.R = (byte)(255 * projectile.Opacity); - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, SpriteEffects.None, 0f); + lightColor.R = (byte)(255 * projectile.Opacity); + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, SpriteEffects.None, 0f); return false; } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.Opacity != 1f) - return; + if (projectile.Opacity != 1f) + return; - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 240); target.AddBuff(ModContent.BuffType(), 180, true); } public override void Kill(int timeLeft) { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneGigablastImpact"), projectile.Center); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneGigablastImpact"), projectile.Center); - if (projectile.ai[1] == 0f) - { - float spread = 12f * MathHelper.PiOver2 * 0.01f; - double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 30f; - double offsetAngle; - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < 30; 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, 1f); - 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, 1f); - } - } - } + if (projectile.ai[1] == 0f) + { + float spread = 12f * MathHelper.PiOver2 * 0.01f; + double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; + double deltaAngle = spread / 30f; + double offsetAngle; + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < 30; 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, 1f); + 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, 1f); + } + } + } for (int j = 0; j < 2; j++) { @@ -123,9 +123,9 @@ namespace CalamityMod.Projectiles.Boss } } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/BrimstoneGigaBlast.cs b/Projectiles/Boss/BrimstoneGigaBlast.cs index 1f892f184c..3886930607 100644 --- a/Projectiles/Boss/BrimstoneGigaBlast.cs +++ b/Projectiles/Boss/BrimstoneGigaBlast.cs @@ -21,14 +21,14 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 36; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 36; projectile.height = 36; projectile.hostile = true; projectile.ignoreWater = true; projectile.penetrate = 1; - projectile.Opacity = 0f; - projectile.timeLeft = 150; + projectile.Opacity = 0f; + projectile.timeLeft = 150; cooldownSlot = 1; } @@ -47,12 +47,12 @@ namespace CalamityMod.Projectiles.Boss Lighting.AddLight(projectile.Center, 0.9f * projectile.Opacity, 0f, 0f); - if (projectile.ai[1] == 1f) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 90) / 60f), 0f, 1f); + if (projectile.ai[1] == 1f) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 90) / 60f), 0f, 1f); - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; if (projectile.localAI[0] == 0f) { @@ -87,42 +87,42 @@ namespace CalamityMod.Projectiles.Boss Texture2D texture = Main.projectileTexture[projectile.type]; int frameHeight = texture.Height / Main.projFrames[projectile.type]; int drawStart = frameHeight * projectile.frame; - lightColor.R = (byte)(255 * projectile.Opacity); - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, SpriteEffects.None, 0f); + lightColor.R = (byte)(255 * projectile.Opacity); + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, SpriteEffects.None, 0f); return false; } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.Opacity != 1f) - return; + if (projectile.Opacity != 1f) + return; - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 240); target.AddBuff(ModContent.BuffType(), 180, true); } public override void Kill(int timeLeft) { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneFireblastImpact"), projectile.Center); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneFireblastImpact"), projectile.Center); - if (projectile.ai[1] == 0f) - { - float spread = 45f * MathHelper.PiOver2 * 0.01f; - double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - double offsetAngle; - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < 8; i++) - { - offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 7f), (float)(Math.Cos(offsetAngle) * 7f), ModContent.ProjectileType(), (int)Math.Round(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 1f); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 7f), (float)(-Math.Cos(offsetAngle) * 7f), ModContent.ProjectileType(), (int)Math.Round(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 1f); - } - } - } + if (projectile.ai[1] == 0f) + { + float spread = 45f * MathHelper.PiOver2 * 0.01f; + double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; + double deltaAngle = spread / 8f; + double offsetAngle; + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < 8; i++) + { + offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 7f), (float)(Math.Cos(offsetAngle) * 7f), ModContent.ProjectileType(), (int)Math.Round(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 1f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 7f), (float)(-Math.Cos(offsetAngle) * 7f), ModContent.ProjectileType(), (int)Math.Round(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 1f); + } + } + } Dust.NewDust(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 50, default, 1f); for (int j = 0; j < 10; j++) @@ -136,9 +136,9 @@ namespace CalamityMod.Projectiles.Boss } } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/BrimstoneHellblast.cs b/Projectiles/Boss/BrimstoneHellblast.cs index 6528af93ad..9f3543d6fc 100644 --- a/Projectiles/Boss/BrimstoneHellblast.cs +++ b/Projectiles/Boss/BrimstoneHellblast.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 40; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 40; projectile.height = 40; projectile.hostile = true; projectile.ignoreWater = true; @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.timeLeft = 255; cooldownSlot = 1; - } + } public override void AI() { @@ -43,10 +43,10 @@ namespace CalamityMod.Projectiles.Boss if (projectile.frame > 3) projectile.frame = 0; - Lighting.AddLight(projectile.Center, 0.9f * projectile.Opacity, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.9f * projectile.Opacity, 0f, 0f); - if (projectile.timeLeft < 51) - projectile.Opacity -= 0.02f; + if (projectile.timeLeft < 51) + projectile.Opacity -= 0.02f; if (projectile.ai[1] == 0f) { @@ -71,26 +71,26 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - lightColor.R = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + lightColor.R = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } - public override bool CanHitPlayer(Player target) => projectile.timeLeft >= 51; + public override bool CanHitPlayer(Player target) => projectile.timeLeft >= 51; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.timeLeft < 51) - return; + if (projectile.timeLeft < 51) + return; - if (projectile.ai[0] == 0f) - { - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 120); - } - else - target.AddBuff(ModContent.BuffType(), 120); - } + if (projectile.ai[0] == 0f) + { + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 120); + } + else + target.AddBuff(ModContent.BuffType(), 120); + } public override void Kill(int timeLeft) { @@ -101,9 +101,9 @@ namespace CalamityMod.Projectiles.Boss } } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/BrimstoneHellblast2.cs b/Projectiles/Boss/BrimstoneHellblast2.cs index 373b0741e0..da60ef8d7f 100644 --- a/Projectiles/Boss/BrimstoneHellblast2.cs +++ b/Projectiles/Boss/BrimstoneHellblast2.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 40; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 40; projectile.height = 40; projectile.hostile = true; projectile.ignoreWater = true; @@ -28,18 +28,18 @@ namespace CalamityMod.Projectiles.Boss projectile.extraUpdates = 1; projectile.penetrate = -1; projectile.timeLeft = 1500; - projectile.Opacity = 0f; + projectile.Opacity = 0f; cooldownSlot = 1; } public override void AI() { - // Cal Clone bullet hell projectiles accelerate after a certain time has passed - if (projectile.ai[0] == 2f && Main.expertMode && projectile.timeLeft < 1260) - { - if (projectile.velocity.Length() < ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 10f : 8f)) - projectile.velocity *= 1.01f; - } + // Cal Clone bullet hell projectiles accelerate after a certain time has passed + if (projectile.ai[0] == 2f && Main.expertMode && projectile.timeLeft < 1260) + { + if (projectile.velocity.Length() < ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 10f : 8f)) + projectile.velocity *= 1.01f; + } projectile.frameCounter++; if (projectile.frameCounter >= 10) @@ -50,10 +50,10 @@ namespace CalamityMod.Projectiles.Boss if (projectile.frame > 3) projectile.frame = 0; - if (projectile.timeLeft < 60) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 1440) / 60f), 0f, 1f); + if (projectile.timeLeft < 60) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 1440) / 60f), 0f, 1f); Lighting.AddLight(projectile.Center, 0.9f * projectile.Opacity, 0f, 0f); @@ -75,30 +75,30 @@ namespace CalamityMod.Projectiles.Boss Texture2D texture = Main.projectileTexture[projectile.type]; int frameHeight = texture.Height / Main.projFrames[projectile.type]; int drawStart = frameHeight * projectile.frame; - lightColor.R = (byte)(255 * projectile.Opacity); - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f); + lightColor.R = (byte)(255 * projectile.Opacity); + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f); return false; } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.Opacity != 1f) - return; + if (projectile.Opacity != 1f) + return; - if (projectile.ai[0] == 0f) - { - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 120); - } - else - target.AddBuff(ModContent.BuffType(), 120); - } + if (projectile.ai[0] == 0f) + { + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 120); + } + else + target.AddBuff(ModContent.BuffType(), 120); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/BrimstoneHellfireball.cs b/Projectiles/Boss/BrimstoneHellfireball.cs index d13caf05d1..de1c0c3afa 100644 --- a/Projectiles/Boss/BrimstoneHellfireball.cs +++ b/Projectiles/Boss/BrimstoneHellfireball.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 34; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 34; projectile.height = 34; projectile.hostile = true; projectile.ignoreWater = true; @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.timeLeft = 300; projectile.alpha = 255; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -49,24 +49,24 @@ namespace CalamityMod.Projectiles.Boss if (projectile.alpha < 5) projectile.alpha = 5; - if (projectile.ai[0] != 0f && projectile.ai[1] != 0f) - { - bool flag15 = false; - bool flag16 = false; - if (projectile.velocity.X < 0f && projectile.position.X < projectile.ai[0]) - flag15 = true; - if (projectile.velocity.X > 0f && projectile.position.X > projectile.ai[0]) - flag15 = true; - if (projectile.velocity.Y < 0f && projectile.position.Y < projectile.ai[1]) - flag16 = true; - if (projectile.velocity.Y > 0f && projectile.position.Y > projectile.ai[1]) - flag16 = true; - if (flag15 & flag16) - projectile.Kill(); - } + if (projectile.ai[0] != 0f && projectile.ai[1] != 0f) + { + bool flag15 = false; + bool flag16 = false; + if (projectile.velocity.X < 0f && projectile.position.X < projectile.ai[0]) + flag15 = true; + if (projectile.velocity.X > 0f && projectile.position.X > projectile.ai[0]) + flag15 = true; + if (projectile.velocity.Y < 0f && projectile.position.Y < projectile.ai[1]) + flag16 = true; + if (projectile.velocity.Y > 0f && projectile.position.Y > projectile.ai[1]) + flag16 = true; + if (flag15 & flag16) + projectile.Kill(); + } - // Rotation - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + // Rotation + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) - MathHelper.ToRadians(90f) * projectile.direction; if (projectile.velocity.Length() < 16f) @@ -86,12 +86,12 @@ namespace CalamityMod.Projectiles.Boss Main.dust[num458].velocity += projectile.velocity * 0.1f; } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 50, 50, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(250, 50, 50, projectile.alpha); + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { if (projectile.owner == Main.myPlayer) Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); diff --git a/Projectiles/Boss/BrimstoneMonster.cs b/Projectiles/Boss/BrimstoneMonster.cs index 258cf61bfa..8fe2b635ac 100644 --- a/Projectiles/Boss/BrimstoneMonster.cs +++ b/Projectiles/Boss/BrimstoneMonster.cs @@ -11,183 +11,183 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class BrimstoneMonster : ModProjectile - { - private float speedAdd = 0f; - private float speedLimit = 0f; + public class BrimstoneMonster : ModProjectile + { + private float speedAdd = 0f; + private float speedLimit = 0f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Brimstone Monster"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brimstone Monster"); + } - public override void SetDefaults() - { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 320; - projectile.height = 320; - projectile.hostile = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.hide = true; - projectile.penetrate = -1; - projectile.timeLeft = 36000; - projectile.Opacity = 0f; - cooldownSlot = 1; - } + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 320; + projectile.height = 320; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.hide = true; + projectile.penetrate = -1; + projectile.timeLeft = 36000; + projectile.Opacity = 0f; + cooldownSlot = 1; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(speedAdd); - writer.Write(projectile.localAI[0]); - writer.Write(speedLimit); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(speedAdd); + writer.Write(projectile.localAI[0]); + writer.Write(speedLimit); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - speedAdd = reader.ReadSingle(); - projectile.localAI[0] = reader.ReadSingle(); - speedLimit = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + speedAdd = reader.ReadSingle(); + projectile.localAI[0] = reader.ReadSingle(); + speedLimit = reader.ReadSingle(); + } - public override void AI() - { - if (!CalamityPlayer.areThereAnyDamnBosses) - { - projectile.active = false; - projectile.netUpdate = true; - return; - } + public override void AI() + { + if (!CalamityPlayer.areThereAnyDamnBosses) + { + projectile.active = false; + projectile.netUpdate = true; + return; + } - int choice = (int)projectile.ai[1]; - if (projectile.localAI[0] == 0f) - { - projectile.soundDelay = 1125 - (choice * 225); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/BrimstoneMonsterSpawn"), projectile.Center); - projectile.localAI[0] += 1f; - switch (choice) - { - case 0: - speedLimit = 10f; - break; - case 1: - speedLimit = 20f; - break; - case 2: - speedLimit = 30f; - break; - case 3: - speedLimit = 40f; - break; - default: - break; - } - } + int choice = (int)projectile.ai[1]; + if (projectile.localAI[0] == 0f) + { + projectile.soundDelay = 1125 - (choice * 225); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/BrimstoneMonsterSpawn"), projectile.Center); + projectile.localAI[0] += 1f; + switch (choice) + { + case 0: + speedLimit = 10f; + break; + case 1: + speedLimit = 20f; + break; + case 2: + speedLimit = 30f; + break; + case 3: + speedLimit = 40f; + break; + default: + break; + } + } - if (speedAdd < speedLimit) - speedAdd += 0.04f; + if (speedAdd < speedLimit) + speedAdd += 0.04f; - if (projectile.soundDelay <= 0 && (choice == 0 || choice == 2)) - { - projectile.soundDelay = 420; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/BrimstoneMonsterDrone"), projectile.Center); - } + if (projectile.soundDelay <= 0 && (choice == 0 || choice == 2)) + { + projectile.soundDelay = 420; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/BrimstoneMonsterDrone"), projectile.Center); + } - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - Lighting.AddLight(projectile.Center, 3f * projectile.Opacity, 0f, 0f); + Lighting.AddLight(projectile.Center, 3f * projectile.Opacity, 0f, 0f); - float inertia = (revenge ? 4.5f : 5f) + speedAdd; - float speed = (revenge ? 1.5f : 1.35f) + (speedAdd * 0.25f); - float minDist = 160f; + float inertia = (revenge ? 4.5f : 5f) + speedAdd; + float speed = (revenge ? 1.5f : 1.35f) + (speedAdd * 0.25f); + float minDist = 160f; - if (NPC.AnyNPCs(ModContent.NPCType())) - { - inertia *= 1.5f; - speed *= 0.5f; - } + if (NPC.AnyNPCs(ModContent.NPCType())) + { + inertia *= 1.5f; + speed *= 0.5f; + } - if (projectile.timeLeft < 90) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 90f, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 35910) / 90f), 0f, 1f); + if (projectile.timeLeft < 90) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 90f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 35910) / 90f), 0f, 1f); - int target = (int)projectile.ai[0]; - if (target >= 0 && Main.player[target].active && !Main.player[target].dead) - { - if (projectile.Distance(Main.player[target].Center) > minDist) - { - Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[target].Center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * speed) / inertia; - } - } - else - { - projectile.ai[0] = Player.FindClosest(projectile.Center, 1, 1); - projectile.netUpdate = true; - } + int target = (int)projectile.ai[0]; + if (target >= 0 && Main.player[target].active && !Main.player[target].dead) + { + if (projectile.Distance(Main.player[target].Center) > minDist) + { + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[target].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * speed) / inertia; + } + } + else + { + projectile.ai[0] = Player.FindClosest(projectile.Center, 1, 1); + projectile.netUpdate = true; + } - if (death) - return; + if (death) + return; - // Fly away from other brimstone monsters - float pushForce = 0.05f; - for (int k = 0; k < Main.maxProjectiles; k++) - { - Projectile otherProj = Main.projectile[k]; - // Short circuits to make the loop as fast as possible - if (!otherProj.active || k == projectile.whoAmI) - continue; + // Fly away from other brimstone monsters + float pushForce = 0.05f; + for (int k = 0; k < Main.maxProjectiles; k++) + { + Projectile otherProj = Main.projectile[k]; + // Short circuits to make the loop as fast as possible + if (!otherProj.active || k == projectile.whoAmI) + continue; - // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. - bool sameProjType = otherProj.type == projectile.type; - float taxicabDist = Vector2.Distance(projectile.Center, otherProj.Center); - if (sameProjType && taxicabDist < 320f) - { - if (projectile.position.X < otherProj.position.X) - projectile.velocity.X -= pushForce; - else - projectile.velocity.X += pushForce; + // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. + bool sameProjType = otherProj.type == projectile.type; + float taxicabDist = Vector2.Distance(projectile.Center, otherProj.Center); + if (sameProjType && taxicabDist < 320f) + { + if (projectile.position.X < otherProj.position.X) + projectile.velocity.X -= pushForce; + else + projectile.velocity.X += pushForce; - if (projectile.position.Y < otherProj.position.Y) - projectile.velocity.Y -= pushForce; - else - projectile.velocity.Y += pushForce; - } - } - } + if (projectile.position.Y < otherProj.position.Y) + projectile.velocity.Y -= pushForce; + else + projectile.velocity.Y += pushForce; + } + } + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 170f, targetHitbox); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D tex = Main.projectileTexture[projectile.type]; - lightColor.R = (byte)(255 * projectile.Opacity); - 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 bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = Main.projectileTexture[projectile.type]; + lightColor.R = (byte)(255 * projectile.Opacity); + 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 bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.Opacity != 1f) - return; + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.Opacity != 1f) + return; - target.AddBuff(ModContent.BuffType(), 900); - target.AddBuff(ModContent.BuffType(), 300, true); - } + target.AddBuff(ModContent.BuffType(), 900); + target.AddBuff(ModContent.BuffType(), 300, true); + } - public override void DrawBehind(int index, List drawCacheProjsBehindNPCsAndTiles, List drawCacheProjsBehindNPCs, List drawCacheProjsBehindProjectiles, List drawCacheProjsOverWiresUI) - { - drawCacheProjsBehindProjectiles.Add(index); - drawCacheProjsBehindNPCs.Add(index); - } + public override void DrawBehind(int index, List drawCacheProjsBehindNPCsAndTiles, List drawCacheProjsBehindNPCs, List drawCacheProjsBehindProjectiles, List drawCacheProjsOverWiresUI) + { + drawCacheProjsBehindProjectiles.Add(index); + drawCacheProjsBehindNPCs.Add(index); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/BrimstoneRay.cs b/Projectiles/Boss/BrimstoneRay.cs index 78f7261394..5db4e22cae 100644 --- a/Projectiles/Boss/BrimstoneRay.cs +++ b/Projectiles/Boss/BrimstoneRay.cs @@ -12,7 +12,7 @@ using Terraria.Enums; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class BrimstoneRay : ModProjectile + public class BrimstoneRay : ModProjectile { public override void SetStaticDefaults() { @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 10; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 10; projectile.height = 10; projectile.hostile = true; projectile.alpha = 255; @@ -45,9 +45,9 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - Vector2? vector78 = null; + Vector2? vector78 = null; - if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) + if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) projectile.velocity = -Vector2.UnitY; if (Main.npc[(int)projectile.ai[1]].active && Main.npc[(int)projectile.ai[1]].type == ModContent.NPCType()) @@ -55,10 +55,10 @@ 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(projectile.width, projectile.height) / 2f; } - else - projectile.Kill(); + else + projectile.Kill(); - float num801 = 1f; + float num801 = 1f; projectile.localAI[0] += 1f; if (projectile.localAI[0] >= 45f) { @@ -70,40 +70,40 @@ namespace CalamityMod.Projectiles.Boss if (projectile.scale > num801) projectile.scale = num801; - float num804 = projectile.velocity.ToRotation(); + float num804 = projectile.velocity.ToRotation(); - // Rotating beam for test AI - if (projectile.ai[0] > 0f) - num804 += Main.npc[(int)projectile.ai[1]].spriteDirection * MathHelper.TwoPi / 360f; + // Rotating beam for test AI + if (projectile.ai[0] > 0f) + num804 += Main.npc[(int)projectile.ai[1]].spriteDirection * MathHelper.TwoPi / 360f; - projectile.rotation = num804 - MathHelper.PiOver2; - projectile.velocity = num804.ToRotationVector2(); + projectile.rotation = num804 - MathHelper.PiOver2; + projectile.velocity = num804.ToRotationVector2(); - float num805 = 3f; //3f - float num806 = projectile.width; + float num805 = 3f; //3f + float num806 = projectile.width; - Vector2 samplingPoint = projectile.Center; - if (vector78.HasValue) - { - samplingPoint = vector78.Value; - } + Vector2 samplingPoint = projectile.Center; + if (vector78.HasValue) + { + samplingPoint = vector78.Value; + } - float[] array3 = new float[(int)num805]; - Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 2400f, array3); - float num807 = 0f; - for (int num808 = 0; num808 < array3.Length; num808++) - { - num807 += array3[num808]; - } - num807 /= num805; + float[] array3 = new float[(int)num805]; + Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 2400f, array3); + float num807 = 0f; + for (int num808 = 0; num808 < array3.Length; num808++) + { + num807 += array3[num808]; + } + num807 /= num805; - // Fire laser through walls at max length if target cannot be seen - if (!Collision.CanHitLine(Main.npc[(int)projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)projectile.ai[1]].target].Center, 1, 1)) - { - num807 = 2400f; - } + // Fire laser through walls at max length if target cannot be seen + if (!Collision.CanHitLine(Main.npc[(int)projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)projectile.ai[1]].target].Center, 1, 1)) + { + num807 = 2400f; + } - float amount = 0.5f; //0.5f + float amount = 0.5f; //0.5f projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); //length of laser, linear interpolation Vector2 vector79 = projectile.Center + projectile.velocity * (projectile.localAI[1] - 14f); @@ -111,29 +111,29 @@ namespace CalamityMod.Projectiles.Boss bool death = CalamityWorld.death || BossRushEvent.BossRushActive; bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; if (Main.npc[(int)projectile.ai[1]].ai[1] == 210f && projectile.owner == Main.myPlayer) - { - Vector2 velocity = projectile.velocity; - velocity.Normalize(); - float distanceBetweenProjectiles = malice ? 72f : 144f; - 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) + velocity * distanceBetweenProjectiles; - int projectileAmt = (int)(projectile.localAI[1] / distanceBetweenProjectiles); - int type = ModContent.ProjectileType(); - int damage = projectile.GetProjectileDamage(ModContent.NPCType()); - for (int i = 0; i < projectileAmt; i++) - { - int totalProjectiles = 2; - float radians = MathHelper.TwoPi / totalProjectiles; - for (int j = 0; j < totalProjectiles; j++) - { - Vector2 projVelocity = projectile.velocity.RotatedBy(radians * j + MathHelper.PiOver2); - int proj = Projectile.NewProjectile(fireFrom, projVelocity, type, damage, 0f, Main.myPlayer, death ? 2f : 1f, 0f); - Main.projectile[proj].tileCollide = true; - } - fireFrom += velocity * distanceBetweenProjectiles; - } - } + { + Vector2 velocity = projectile.velocity; + velocity.Normalize(); + float distanceBetweenProjectiles = malice ? 72f : 144f; + 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) + velocity * distanceBetweenProjectiles; + int projectileAmt = (int)(projectile.localAI[1] / distanceBetweenProjectiles); + int type = ModContent.ProjectileType(); + int damage = projectile.GetProjectileDamage(ModContent.NPCType()); + for (int i = 0; i < projectileAmt; i++) + { + int totalProjectiles = 2; + float radians = MathHelper.TwoPi / totalProjectiles; + for (int j = 0; j < totalProjectiles; j++) + { + Vector2 projVelocity = projectile.velocity.RotatedBy(radians * j + MathHelper.PiOver2); + int proj = Projectile.NewProjectile(fireFrom, projVelocity, type, damage, 0f, Main.myPlayer, death ? 2f : 1f, 0f); + Main.projectile[proj].tileCollide = true; + } + fireFrom += velocity * distanceBetweenProjectiles; + } + } - for (int num809 = 0; num809 < 2; num809++) + for (int num809 = 0; num809 < 2; num809++) { float num810 = projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; float num811 = (float)Main.rand.NextDouble() * 2f + 2f; @@ -225,11 +225,11 @@ namespace CalamityMod.Projectiles.Boss target.AddBuff(ModContent.BuffType(), 300); } - public override bool CanHitPlayer(Player target) => projectile.scale >= 0.5f; + public override bool CanHitPlayer(Player target) => projectile.scale >= 0.5f; - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/BrimstoneTargetRay.cs b/Projectiles/Boss/BrimstoneTargetRay.cs index 1b60d35147..3cfe11e5e3 100644 --- a/Projectiles/Boss/BrimstoneTargetRay.cs +++ b/Projectiles/Boss/BrimstoneTargetRay.cs @@ -7,7 +7,7 @@ using Terraria.Enums; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class BrimstoneTargetRay : ModProjectile + public class BrimstoneTargetRay : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -18,163 +18,163 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.width = 10; - projectile.height = 10; - projectile.hostile = true; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.timeLeft = 600; - projectile.scale = 0.1f; - } + projectile.width = 10; + projectile.height = 10; + projectile.hostile = true; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft = 600; + projectile.scale = 0.1f; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - writer.Write(projectile.localAI[1]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + writer.Write(projectile.localAI[1]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - projectile.localAI[1] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + projectile.localAI[1] = reader.ReadSingle(); + } - public override void AI() - { - Vector2? vector78 = null; + public override void AI() + { + Vector2? vector78 = null; - if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) - projectile.velocity = -Vector2.UnitY; + if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) + projectile.velocity = -Vector2.UnitY; - if (Main.npc[(int)projectile.ai[1]].active && Main.npc[(int)projectile.ai[1]].type == ModContent.NPCType()) - { - 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(projectile.width, projectile.height) / 2f; - } - else - projectile.Kill(); + if (Main.npc[(int)projectile.ai[1]].active && Main.npc[(int)projectile.ai[1]].type == ModContent.NPCType()) + { + 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(projectile.width, 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(); - projectile.rotation = rotationVelocity - MathHelper.PiOver2; - projectile.velocity = rotationVelocity.ToRotationVector2(); + 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(); + projectile.rotation = rotationVelocity - MathHelper.PiOver2; + projectile.velocity = rotationVelocity.ToRotationVector2(); - if (projectile.ai[0] == 0f) - { - if (Main.npc[(int)projectile.ai[1]].ai[1] >= 150f) - { - projectile.Kill(); - return; - } - } - else - { - if (Main.npc[(int)projectile.ai[1]].ai[1] >= 180f) - { - projectile.Kill(); - return; - } - } + if (projectile.ai[0] == 0f) + { + if (Main.npc[(int)projectile.ai[1]].ai[1] >= 150f) + { + projectile.Kill(); + return; + } + } + else + { + if (Main.npc[(int)projectile.ai[1]].ai[1] >= 180f) + { + projectile.Kill(); + return; + } + } - float num805 = 3f; //3f - float num806 = projectile.width; + float num805 = 3f; //3f + float num806 = projectile.width; - Vector2 samplingPoint = projectile.Center; - if (vector78.HasValue) - { - samplingPoint = vector78.Value; - } + Vector2 samplingPoint = projectile.Center; + if (vector78.HasValue) + { + samplingPoint = vector78.Value; + } - float[] array3 = new float[(int)num805]; - Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 2400f, array3); - float num807 = 0f; - for (int num808 = 0; num808 < array3.Length; num808++) - { - num807 += array3[num808]; - } - num807 /= num805; + float[] array3 = new float[(int)num805]; + Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 2400f, array3); + float num807 = 0f; + for (int num808 = 0; num808 < array3.Length; num808++) + { + num807 += array3[num808]; + } + num807 /= num805; - // Fire laser through walls at max length if target cannot be seen - if (!Collision.CanHitLine(Main.npc[(int)projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)projectile.ai[1]].target].Center, 1, 1)) - { - num807 = 2400f; - } + // Fire laser through walls at max length if target cannot be seen + if (!Collision.CanHitLine(Main.npc[(int)projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)projectile.ai[1]].target].Center, 1, 1)) + { + num807 = 2400f; + } - float amount = 0.5f; //0.5f - projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); //length of laser, linear interpolation + float amount = 0.5f; //0.5f + projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); //length of laser, linear interpolation - DelegateMethods.v3_1 = new Vector3(0.9f, 0.3f, 0.3f); - Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); - } + DelegateMethods.v3_1 = new Vector3(0.9f, 0.3f, 0.3f); + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.velocity == Vector2.Zero) - { - return false; - } - Texture2D texture2D19 = Main.projectileTexture[projectile.type]; - Texture2D texture2D20 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/BrimstoneRayMid"); - Texture2D texture2D21 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/BrimstoneRayEnd"); - float num223 = projectile.localAI[1]; //length of laser - Color color44 = new Color(255, 255, 255, 0) * 0.9f; - Vector2 vector = projectile.Center - Main.screenPosition; - Rectangle? sourceRectangle2 = null; - spriteBatch.Draw(texture2D19, vector, sourceRectangle2, color44, projectile.rotation, texture2D19.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); - num223 -= (texture2D19.Height / 2 + texture2D21.Height) * projectile.scale; - Vector2 value20 = projectile.Center; - value20 += projectile.velocity * projectile.scale * texture2D19.Height / 2f; - if (num223 > 0f) - { - float num224 = 0f; - Rectangle rectangle7 = new Rectangle(0, 16 * (projectile.timeLeft / 3 % 5), texture2D20.Width, 16); - while (num224 + 1f < num223) - { - if (num223 - num224 < rectangle7.Height) - { - rectangle7.Height = (int)(num223 - num224); - } - spriteBatch.Draw(texture2D20, value20 - Main.screenPosition, new Rectangle?(rectangle7), color44, projectile.rotation, new Vector2(rectangle7.Width / 2, 0f), projectile.scale, SpriteEffects.None, 0f); - num224 += rectangle7.Height * projectile.scale; - value20 += projectile.velocity * rectangle7.Height * projectile.scale; - rectangle7.Y += 16; - if (rectangle7.Y + rectangle7.Height > texture2D20.Height) - { - rectangle7.Y = 0; - } - } - } - Vector2 vector2 = value20 - Main.screenPosition; - sourceRectangle2 = null; - spriteBatch.Draw(texture2D21, vector2, sourceRectangle2, color44, projectile.rotation, texture2D21.Frame(1, 1, 0, 0).Top(), projectile.scale, SpriteEffects.None, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.velocity == Vector2.Zero) + { + return false; + } + Texture2D texture2D19 = Main.projectileTexture[projectile.type]; + Texture2D texture2D20 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/BrimstoneRayMid"); + Texture2D texture2D21 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/BrimstoneRayEnd"); + float num223 = projectile.localAI[1]; //length of laser + Color color44 = new Color(255, 255, 255, 0) * 0.9f; + Vector2 vector = projectile.Center - Main.screenPosition; + Rectangle? sourceRectangle2 = null; + spriteBatch.Draw(texture2D19, vector, sourceRectangle2, color44, projectile.rotation, texture2D19.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + num223 -= (texture2D19.Height / 2 + texture2D21.Height) * projectile.scale; + Vector2 value20 = projectile.Center; + value20 += projectile.velocity * projectile.scale * texture2D19.Height / 2f; + if (num223 > 0f) + { + float num224 = 0f; + Rectangle rectangle7 = new Rectangle(0, 16 * (projectile.timeLeft / 3 % 5), texture2D20.Width, 16); + while (num224 + 1f < num223) + { + if (num223 - num224 < rectangle7.Height) + { + rectangle7.Height = (int)(num223 - num224); + } + spriteBatch.Draw(texture2D20, value20 - Main.screenPosition, new Rectangle?(rectangle7), color44, projectile.rotation, new Vector2(rectangle7.Width / 2, 0f), projectile.scale, SpriteEffects.None, 0f); + num224 += rectangle7.Height * projectile.scale; + value20 += projectile.velocity * rectangle7.Height * projectile.scale; + rectangle7.Y += 16; + if (rectangle7.Y + rectangle7.Height > texture2D20.Height) + { + rectangle7.Y = 0; + } + } + } + Vector2 vector2 = value20 - Main.screenPosition; + sourceRectangle2 = null; + spriteBatch.Draw(texture2D21, vector2, sourceRectangle2, color44, projectile.rotation, texture2D21.Frame(1, 1, 0, 0).Top(), projectile.scale, SpriteEffects.None, 0f); + return false; + } - public override void CutTiles() - { - DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; - Vector2 unit = projectile.velocity; - Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); - } + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 unit = projectile.velocity; + Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (projHitbox.Intersects(targetHitbox)) - { - return true; - } - float num6 = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref num6)) - { - return true; - } - return false; - } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + { + return true; + } + float num6 = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref num6)) + { + return true; + } + return false; + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/BrimstoneWave.cs b/Projectiles/Boss/BrimstoneWave.cs index bb215aa8c3..1b8fb238bc 100644 --- a/Projectiles/Boss/BrimstoneWave.cs +++ b/Projectiles/Boss/BrimstoneWave.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Boss projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 1200; - projectile.Opacity = 0f; + projectile.Opacity = 0f; cooldownSlot = 1; } @@ -54,12 +54,12 @@ namespace CalamityMod.Projectiles.Boss if (projectile.frame > 3) projectile.frame = 0; - if (projectile.timeLeft < 30) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 1170) / 30f), 0f, 1f); + if (projectile.timeLeft < 30) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 1170) / 30f), 0f, 1f); - Lighting.AddLight(projectile.Center, 0.5f * projectile.Opacity, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.5f * projectile.Opacity, 0f, 0f); if (projectile.velocity.X < 0f) projectile.spriteDirection = 1; @@ -73,25 +73,25 @@ namespace CalamityMod.Projectiles.Boss Texture2D texture2D13 = Main.projectileTexture[projectile.type]; int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; - lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.R = (byte)(255 * projectile.Opacity); Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, spriteEffects, 0f); return false; } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.Opacity != 1f) - return; + if (projectile.Opacity != 1f) + return; target.AddBuff(ModContent.BuffType(), 180); target.AddBuff(ModContent.BuffType(), 120, true); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/DarkEnergyBall.cs b/Projectiles/Boss/DarkEnergyBall.cs index 9e80c6271a..36834e2f6a 100644 --- a/Projectiles/Boss/DarkEnergyBall.cs +++ b/Projectiles/Boss/DarkEnergyBall.cs @@ -14,44 +14,44 @@ namespace CalamityMod.Projectiles.Boss { DisplayName.SetDefault("Dark Energy"); Main.projFrames[projectile.type] = 6; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 80; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 80; projectile.height = 80; projectile.hostile = true; projectile.tileCollide = false; projectile.timeLeft = 600; projectile.penetrate = -1; - projectile.Opacity = 0f; + projectile.Opacity = 0f; cooldownSlot = 1; } public override void AI() { - if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) - { - projectile.active = false; - projectile.netUpdate = true; - return; - } + if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) + { + projectile.active = false; + projectile.netUpdate = true; + return; + } - if (Vector2.Distance(projectile.Center, Main.npc[CalamityGlobalNPC.voidBoss].Center) < 80f) - projectile.Kill(); + if (Vector2.Distance(projectile.Center, Main.npc[CalamityGlobalNPC.voidBoss].Center) < 80f) + projectile.Kill(); - if (projectile.velocity.Length() < 10f) - projectile.velocity *= 1.05f; + if (projectile.velocity.Length() < 10f) + projectile.velocity *= 1.05f; - if (projectile.timeLeft < 30) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 570) / 30f), 0f, 1f); + if (projectile.timeLeft < 30) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 570) / 30f), 0f, 1f); - projectile.frameCounter++; + projectile.frameCounter++; if (projectile.frameCounter > 4) { projectile.frame++; @@ -61,68 +61,68 @@ namespace CalamityMod.Projectiles.Boss projectile.frame = 0; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color = Color.Lerp(Color.White, Color.Fuchsia, 0.5f) * projectile.Opacity; - Texture2D texture = Main.projectileTexture[projectile.type]; - int height = texture.Height / Main.projFrames[projectile.type]; - int drawStart = height * projectile.frame; - Vector2 origin = projectile.Size / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Color color = Color.Lerp(Color.White, Color.Fuchsia, 0.5f) * projectile.Opacity; + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int drawStart = height * projectile.frame; + Vector2 origin = projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - color = Color.Lerp(Color.White, Color.Cyan, 0.5f) * projectile.Opacity; + color = Color.Lerp(Color.White, Color.Cyan, 0.5f) * projectile.Opacity; - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow2"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow2"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - } + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 35f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.Opacity == 1f) - target.AddBuff(BuffID.VortexDebuff, 60); - } - - public override void Kill(int timeLeft) + public override void OnHitPlayer(Player target, int damage, bool crit) { - for (int num621 = 0; num621 < 3; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 5; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 2f; - } + if (projectile.Opacity == 1f) + target.AddBuff(BuffID.VortexDebuff, 60); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void Kill(int timeLeft) { - target.Calamity().lastProjectileHit = projectile; - } + for (int num621 = 0; num621 < 3; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.2f); + Main.dust[num622].velocity *= 3f; + Main.dust[num622].noGravity = true; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 5; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.7f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 2f; + } + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/DarkEnergyBall2.cs b/Projectiles/Boss/DarkEnergyBall2.cs index c4f4923052..50a742c975 100644 --- a/Projectiles/Boss/DarkEnergyBall2.cs +++ b/Projectiles/Boss/DarkEnergyBall2.cs @@ -16,44 +16,44 @@ namespace CalamityMod.Projectiles.Boss { DisplayName.SetDefault("Dark Energy"); Main.projFrames[projectile.type] = 6; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 80; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 80; projectile.height = 80; projectile.hostile = true; projectile.tileCollide = false; projectile.timeLeft = 600; projectile.penetrate = -1; - projectile.Opacity = 0f; - cooldownSlot = 1; + projectile.Opacity = 0f; + cooldownSlot = 1; } public override void AI() { - if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) - { - projectile.active = false; - projectile.netUpdate = true; - return; - } + if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) + { + projectile.active = false; + projectile.netUpdate = true; + return; + } - if (Vector2.Distance(projectile.Center, Main.npc[CalamityGlobalNPC.voidBoss].Center) < 80f) - projectile.Kill(); + if (Vector2.Distance(projectile.Center, Main.npc[CalamityGlobalNPC.voidBoss].Center) < 80f) + projectile.Kill(); - if (projectile.velocity.Length() < 10f) - projectile.velocity *= 1.05f; + if (projectile.velocity.Length() < 10f) + projectile.velocity *= 1.05f; - if (projectile.timeLeft < 30) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 570) / 30f), 0f, 1f); + if (projectile.timeLeft < 30) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 570) / 30f), 0f, 1f); - projectile.frameCounter++; + projectile.frameCounter++; if (projectile.frameCounter > 4) { projectile.frame++; @@ -61,70 +61,70 @@ namespace CalamityMod.Projectiles.Boss } if (projectile.frame > 5) projectile.frame = 0; - } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color = Color.Lerp(Color.White, Color.Fuchsia, 0.5f) * projectile.Opacity; - Texture2D texture = Main.projectileTexture[projectile.type]; - int height = texture.Height / Main.projFrames[projectile.type]; - int drawStart = height * projectile.frame; - Vector2 origin = projectile.Size / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Color color = Color.Lerp(Color.White, Color.Fuchsia, 0.5f) * projectile.Opacity; + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int drawStart = height * projectile.frame; + Vector2 origin = projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - color = Color.Lerp(Color.White, Color.Cyan, 0.5f) * projectile.Opacity; + color = Color.Lerp(Color.White, Color.Cyan, 0.5f) * projectile.Opacity; - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow2"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow2"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - } + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 35f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.Opacity == 1f) - target.AddBuff(BuffID.VortexDebuff, 60); - } - - public override void Kill(int timeLeft) + public override void OnHitPlayer(Player target, int damage, bool crit) { - for (int num621 = 0; num621 < 3; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 5; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 2f; - } - } + if (projectile.Opacity == 1f) + target.AddBuff(BuffID.VortexDebuff, 60); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void Kill(int timeLeft) + { + for (int num621 = 0; num621 < 3; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.2f); + Main.dust[num622].velocity *= 3f; + Main.dust[num622].noGravity = true; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 5; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1.7f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 1f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 2f; + } + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/DarkOrb.cs b/Projectiles/Boss/DarkOrb.cs index b5afef14fb..54a311961d 100644 --- a/Projectiles/Boss/DarkOrb.cs +++ b/Projectiles/Boss/DarkOrb.cs @@ -8,16 +8,16 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class DarkOrb : ModProjectile + public class DarkOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/LightningProj"; - private bool start = true; - private Vector2 center = Vector2.Zero; - private Vector2 velocity = Vector2.Zero; - private double[] distances = new double[4]; + private bool start = true; + private Vector2 center = Vector2.Zero; + private Vector2 velocity = Vector2.Zero; + private double[] distances = new double[4]; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Dark Orb"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; @@ -36,522 +36,522 @@ namespace CalamityMod.Projectiles.Boss cooldownSlot = 1; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - writer.Write(projectile.localAI[1]); - writer.Write(start); - writer.WriteVector2(center); - 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(); - distances[0] = reader.ReadDouble(); - distances[1] = reader.ReadDouble(); - distances[2] = reader.ReadDouble(); - distances[3] = reader.ReadDouble(); - velocity = reader.ReadVector2(); - } - - public override void AI() + public override void SendExtraAI(BinaryWriter writer) { - if (projectile.ai[0] != 8f) - { - // Pulse in and out - if (projectile.localAI[1] == 0f) - { - projectile.scale -= 0.012f; - if (projectile.scale <= 0.8f) - { - projectile.scale = 0.8f; - projectile.localAI[1] = 1f; - } - } - else - { - projectile.scale += 0.012f; - if (projectile.scale >= 1.2f) - { - projectile.scale = 1.2f; - projectile.localAI[1] = 0f; - } - } - } - - switch ((int)projectile.ai[0]) - { - // No AI - case -1: - break; - - // Rotate around a point, spread outward and move - case 0: - case 1: - - if (start) - { - center = projectile.Center; - velocity = Vector2.Normalize(Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center) * 2f; - start = false; - } - - center += velocity; - - double rad = MathHelper.ToRadians(projectile.ai[1]); - - float amount = 1f - projectile.localAI[0] / 360f; - if (amount < 0f) - amount = 0f; - - distances[0] += MathHelper.Lerp(1f, 6f, amount); - - if (projectile.ai[0] == 0f) - { - 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) * 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; - projectile.localAI[0] += 1f; - - break; - - // Lurch forward - case 2: - - LurchForward(0.05f, 0.95f, 1.05f); - - break; - - // Wavy motion - case 3: - case 4: - - bool useSin = projectile.ai[0] == 3f; - - WavyMotion(0.1f, 0f, useSin, false); - - break; - - // Speed up then slow down on a timer - case 5: - case 16: - - float fastGateValue = projectile.ai[0] == 5f ? 30f : 60f; - float maxVelocity = projectile.ai[0] == 5f ? 12f : 6f; - - LurchForwardOnTimer(90f, fastGateValue, 3f, maxVelocity, 0.95f, 1.2f); - - break; - - // Split into 4 projectiles that can use any of the first 6 AIs - case 6: - - projectile.ai[1] += 1f; - - if (projectile.ai[1] >= 90f) - { - if (projectile.owner == Main.myPlayer) - { - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 vector = new Vector2(0f, -8f).RotatedBy(radians * i); - Projectile.NewProjectile(projectile.Center, vector, projectile.type, projectile.damage, 0f, Main.myPlayer, Main.rand.Next(6), 0f); - } - } - - projectile.Kill(); - } - - break; - - // Split into 8 projectiles that can use either of the first 2 AIs - case 7: - - projectile.ai[1] += 1f; - - if (projectile.ai[1] >= 120f) - { - if (projectile.owner == Main.myPlayer) - { - int totalProjectiles = 8; - float radians = MathHelper.TwoPi / totalProjectiles; - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 vector = new Vector2(0f, -8f).RotatedBy(radians * i); - Projectile.NewProjectile(projectile.Center, vector, projectile.type, projectile.damage, 0f, Main.myPlayer, Main.rand.Next(2), 0f); - } - } - - projectile.Kill(); - } - - break; - - // Split into 3 wavy projectiles multiple times - case 8: - - bool splitOnce = projectile.timeLeft < 1800; - bool splitTwice = projectile.timeLeft < 900; - bool splitThrice = projectile.timeLeft < 450; - - if (splitOnce) - WavyMotion(0.05f, 2f, true, true); - - projectile.localAI[0] += 1f; - - if (projectile.localAI[0] >= 180f) - { - if (projectile.owner == Main.myPlayer) - { - int totalProjectiles = 3; - float radians = MathHelper.TwoPi / totalProjectiles; - 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 < totalProjectiles; i++) - { - 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; - } - } - - projectile.Kill(); - } - - break; - - // idk yet - case 9: - case 10: - - bool useSin2 = projectile.ai[0] == 9f; - - OscillationMotion(0.05f, useSin2); - - break; - - // Homing - case 11: - - projectile.ai[1] += 1f; - - if (projectile.ai[1] >= 180f) - { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] < 180f) - { - Vector2 vector = Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center; - float scaleFactor = projectile.velocity.Length(); - vector.Normalize(); - vector *= scaleFactor; - projectile.velocity = (projectile.velocity * 15f + vector) / 16f; - projectile.velocity.Normalize(); - projectile.velocity *= scaleFactor; - } - else if (projectile.velocity.Length() < 18f) - projectile.velocity *= 1.01f; - } - - break; - - // Rotate around a moving point and spread outward then inward in an oval pattern - case 12: - case 13: - - if (start) - { - center = projectile.Center; - velocity = Vector2.Normalize(Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center); - start = false; - } - - center += velocity; - - float velocityGateValue3 = 240f; - float amount2 = 1f; - - bool flyOutward = projectile.localAI[0] < velocityGateValue3; - - if (flyOutward) - amount2 -= projectile.localAI[0] / velocityGateValue3; - else - amount2 = (projectile.localAI[0] - velocityGateValue3) / velocityGateValue3; - - amount2 = MathHelper.Clamp(0f, 1f, amount2); - - double distanceVariable = MathHelper.Lerp(0f, 6f, amount2); - - 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) * 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) * 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; - } + writer.Write(projectile.localAI[0]); + writer.Write(projectile.localAI[1]); + writer.Write(start); + writer.WriteVector2(center); + writer.Write(distances[0]); + writer.Write(distances[1]); + writer.Write(distances[2]); + writer.Write(distances[3]); + writer.WriteVector2(velocity); } - private void WavyMotion(float frequency, float amplitude, bool useSin, bool waveWithVelocity) - { - 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]); - - if (waveWithVelocity) - projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity) * amplitude; - else - 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) + public override void ReceiveExtraAI(BinaryReader reader) { - switch ((int)projectile.ai[0]) - { - // No AI - case -1: + projectile.localAI[0] = reader.ReadSingle(); + projectile.localAI[1] = reader.ReadSingle(); + start = reader.ReadBoolean(); + center = reader.ReadVector2(); + distances[0] = reader.ReadDouble(); + distances[1] = reader.ReadDouble(); + distances[2] = reader.ReadDouble(); + distances[3] = reader.ReadDouble(); + velocity = reader.ReadVector2(); + } - return new Color(0, 100, 255, projectile.alpha); + public override void AI() + { + if (projectile.ai[0] != 8f) + { + // Pulse in and out + if (projectile.localAI[1] == 0f) + { + projectile.scale -= 0.012f; + if (projectile.scale <= 0.8f) + { + projectile.scale = 0.8f; + projectile.localAI[1] = 1f; + } + } + else + { + projectile.scale += 0.012f; + if (projectile.scale >= 1.2f) + { + projectile.scale = 1.2f; + projectile.localAI[1] = 0f; + } + } + } - // Rotate around a point, spread outward and move - case 0: - case 1: + switch ((int)projectile.ai[0]) + { + // No AI + case -1: + break; - return new Color(0, 100, 255, projectile.alpha); + // Rotate around a point, spread outward and move + case 0: + case 1: - // Lurch forward - case 2: + if (start) + { + center = projectile.Center; + velocity = Vector2.Normalize(Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center) * 2f; + start = false; + } - return new Color(255, 200, 0, projectile.alpha); + center += velocity; - // Wavy motion - case 3: - case 4: + double rad = MathHelper.ToRadians(projectile.ai[1]); - return new Color(0, 255, 200, projectile.alpha); + float amount = 1f - projectile.localAI[0] / 360f; + if (amount < 0f) + amount = 0f; - // Speed up then slow down on a timer - case 5: - case 16: + distances[0] += MathHelper.Lerp(1f, 6f, amount); - return new Color(0, 255, 100, projectile.alpha); + if (projectile.ai[0] == 0f) + { + 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) * distances[0]) - projectile.width / 2; + projectile.position.Y = center.Y - (int)(Math.Sin(rad) * distances[0]) - projectile.height / 2; + } - // Split into 4 projectiles that can use any of the first 6 AIs - case 6: + projectile.ai[1] += 0.25f + amount; + projectile.localAI[0] += 1f; - return new Color(200, 0, 255, projectile.alpha); + break; - // Split into 8 projectiles that can use either of the first 2 AIs - case 7: + // Lurch forward + case 2: - return new Color(255, 0, 150, projectile.alpha); + LurchForward(0.05f, 0.95f, 1.05f); - // Split into 3 wavy projectiles multiple times - case 8: + break; - return new Color(200, 0, 0, projectile.alpha); + // Wavy motion + case 3: + case 4: - // idk yet - case 9: - case 10: + bool useSin = projectile.ai[0] == 3f; - return new Color(255, 255, 0, projectile.alpha); + WavyMotion(0.1f, 0f, useSin, false); - // Homing - case 11: + break; - return new Color(150, 0, 200, projectile.alpha); + // Speed up then slow down on a timer + case 5: + case 16: - // Rotate around a moving point and spread outward then inward in an oval pattern - case 12: - case 13: + float fastGateValue = projectile.ai[0] == 5f ? 30f : 60f; + float maxVelocity = projectile.ai[0] == 5f ? 12f : 6f; - return new Color(0, 100, 255, projectile.alpha); + LurchForwardOnTimer(90f, fastGateValue, 3f, maxVelocity, 0.95f, 1.2f); - // Spread out then drift inward after some time and then drift outward - case 14: - case 15: + break; - return new Color(0, 100, 255, projectile.alpha); - } + // Split into 4 projectiles that can use any of the first 6 AIs + case 6: - return null; + projectile.ai[1] += 1f; + + if (projectile.ai[1] >= 90f) + { + if (projectile.owner == Main.myPlayer) + { + int totalProjectiles = 4; + float radians = MathHelper.TwoPi / totalProjectiles; + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 vector = new Vector2(0f, -8f).RotatedBy(radians * i); + Projectile.NewProjectile(projectile.Center, vector, projectile.type, projectile.damage, 0f, Main.myPlayer, Main.rand.Next(6), 0f); + } + } + + projectile.Kill(); + } + + break; + + // Split into 8 projectiles that can use either of the first 2 AIs + case 7: + + projectile.ai[1] += 1f; + + if (projectile.ai[1] >= 120f) + { + if (projectile.owner == Main.myPlayer) + { + int totalProjectiles = 8; + float radians = MathHelper.TwoPi / totalProjectiles; + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 vector = new Vector2(0f, -8f).RotatedBy(radians * i); + Projectile.NewProjectile(projectile.Center, vector, projectile.type, projectile.damage, 0f, Main.myPlayer, Main.rand.Next(2), 0f); + } + } + + projectile.Kill(); + } + + break; + + // Split into 3 wavy projectiles multiple times + case 8: + + bool splitOnce = projectile.timeLeft < 1800; + bool splitTwice = projectile.timeLeft < 900; + bool splitThrice = projectile.timeLeft < 450; + + if (splitOnce) + WavyMotion(0.05f, 2f, true, true); + + projectile.localAI[0] += 1f; + + if (projectile.localAI[0] >= 180f) + { + if (projectile.owner == Main.myPlayer) + { + int totalProjectiles = 3; + float radians = MathHelper.TwoPi / totalProjectiles; + 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 < totalProjectiles; i++) + { + 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; + } + } + + projectile.Kill(); + } + + break; + + // idk yet + case 9: + case 10: + + bool useSin2 = projectile.ai[0] == 9f; + + OscillationMotion(0.05f, useSin2); + + break; + + // Homing + case 11: + + projectile.ai[1] += 1f; + + if (projectile.ai[1] >= 180f) + { + projectile.localAI[0] += 1f; + if (projectile.localAI[0] < 180f) + { + Vector2 vector = Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center; + float scaleFactor = projectile.velocity.Length(); + vector.Normalize(); + vector *= scaleFactor; + projectile.velocity = (projectile.velocity * 15f + vector) / 16f; + projectile.velocity.Normalize(); + projectile.velocity *= scaleFactor; + } + else if (projectile.velocity.Length() < 18f) + projectile.velocity *= 1.01f; + } + + break; + + // Rotate around a moving point and spread outward then inward in an oval pattern + case 12: + case 13: + + if (start) + { + center = projectile.Center; + velocity = Vector2.Normalize(Main.player[Player.FindClosest(projectile.Center, 1, 1)].Center - projectile.Center); + start = false; + } + + center += velocity; + + float velocityGateValue3 = 240f; + float amount2 = 1f; + + bool flyOutward = projectile.localAI[0] < velocityGateValue3; + + if (flyOutward) + amount2 -= projectile.localAI[0] / velocityGateValue3; + else + amount2 = (projectile.localAI[0] - velocityGateValue3) / velocityGateValue3; + + amount2 = MathHelper.Clamp(0f, 1f, amount2); + + double distanceVariable = MathHelper.Lerp(0f, 6f, amount2); + + 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) * 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) * 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; + } + } + + private void WavyMotion(float frequency, float amplitude, bool useSin, bool waveWithVelocity) + { + 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]); + + if (waveWithVelocity) + projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity) * amplitude; + else + 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) + { + 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) { target.AddBuff(ModContent.BuffType(), 300); //target.AddBuff(ModContent.BuffType(), 300, true); - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -559,9 +559,9 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/DestroyerCursedLaser.cs b/Projectiles/Boss/DestroyerCursedLaser.cs index 8bf00ad4ef..7ec2d08586 100644 --- a/Projectiles/Boss/DestroyerCursedLaser.cs +++ b/Projectiles/Boss/DestroyerCursedLaser.cs @@ -22,9 +22,9 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = 1; projectile.timeLeft = 600; projectile.scale = 1.8f; - projectile.extraUpdates = 2; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.extraUpdates = 2; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -41,8 +41,8 @@ namespace CalamityMod.Projectiles.Boss if (projectile.localAI[1] == 0f) { Main.PlaySound(SoundID.Item33, (int)projectile.position.X, (int)projectile.position.Y); - projectile.localAI[1] = 1f; - } + projectile.localAI[1] = 1f; + } if (projectile.velocity.Length() < 12f) { projectile.velocity *= 1.0025f; @@ -58,9 +58,9 @@ namespace CalamityMod.Projectiles.Boss return Color.Transparent; } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.CursedInferno, 120); - } - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.CursedInferno, 120); + } + } } diff --git a/Projectiles/Boss/DestroyerElectricLaser.cs b/Projectiles/Boss/DestroyerElectricLaser.cs index 51375c0593..2d02fc5291 100644 --- a/Projectiles/Boss/DestroyerElectricLaser.cs +++ b/Projectiles/Boss/DestroyerElectricLaser.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class DestroyerElectricLaser : ModProjectile + public class DestroyerElectricLaser : ModProjectile { public override void SetStaticDefaults() { @@ -14,42 +14,42 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.ignoreWater = true; - projectile.width = 4; - projectile.height = 4; - projectile.hostile = true; - projectile.penetrate = 1; - projectile.alpha = 255; - projectile.scale = 1.2f; - projectile.timeLeft = 600; - projectile.extraUpdates = 2; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.ignoreWater = true; + projectile.width = 4; + projectile.height = 4; + projectile.hostile = true; + projectile.penetrate = 1; + projectile.alpha = 255; + projectile.scale = 1.2f; + projectile.timeLeft = 600; + projectile.extraUpdates = 2; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } - public override void AI() - { - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - Lighting.AddLight(projectile.Center, 0f, (255 - projectile.alpha) * 0.35f / 255f, (255 - projectile.alpha) * 0.35f / 255f); - if (projectile.alpha > 0) - { - projectile.alpha -= 125; - } - if (projectile.alpha < 0) - { - projectile.alpha = 0; - } - if (projectile.localAI[1] == 0f) - { - Main.PlaySound(SoundID.Item33, (int)projectile.position.X, (int)projectile.position.Y); - projectile.localAI[1] = 1f; - } - if (projectile.velocity.Length() < 12f) - { - projectile.velocity *= 1.0025f; - } - } + public override void AI() + { + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + Lighting.AddLight(projectile.Center, 0f, (255 - projectile.alpha) * 0.35f / 255f, (255 - projectile.alpha) * 0.35f / 255f); + if (projectile.alpha > 0) + { + projectile.alpha -= 125; + } + if (projectile.alpha < 0) + { + projectile.alpha = 0; + } + if (projectile.localAI[1] == 0f) + { + Main.PlaySound(SoundID.Item33, (int)projectile.position.X, (int)projectile.position.Y); + projectile.localAI[1] = 1f; + } + if (projectile.velocity.Length() < 12f) + { + projectile.velocity *= 1.0025f; + } + } - public override Color? GetAlpha(Color lightColor) + public override Color? GetAlpha(Color lightColor) { if (projectile.alpha < 200) { @@ -58,9 +58,9 @@ namespace CalamityMod.Projectiles.Boss return Color.Transparent; } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.Electrified, 60); - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Electrified, 60); + } } } diff --git a/Projectiles/Boss/DeusMine.cs b/Projectiles/Boss/DeusMine.cs index a883a514a2..fd320f8b69 100644 --- a/Projectiles/Boss/DeusMine.cs +++ b/Projectiles/Boss/DeusMine.cs @@ -11,8 +11,8 @@ namespace CalamityMod.Projectiles.Boss { public class DeusMine : ModProjectile { - private const int MaxTimeLeft = 600; - private const int FadeTime = 85; + private const int MaxTimeLeft = 600; + private const int FadeTime = 85; public override void SetStaticDefaults() { @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 30; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 30; projectile.height = 30; projectile.hostile = true; projectile.alpha = 100; @@ -45,28 +45,28 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - // Sound on spawn + // Sound on spawn if (projectile.ai[1] == 0f) { projectile.ai[1] = 1f; Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 33); } - // Deal no damage if fading out and not set to explode - if (projectile.timeLeft < FadeTime) - { - if (projectile.ai[0] == 0f) - projectile.damage = 0; - } - } + // Deal no damage if fading out and not set to explode + if (projectile.timeLeft < FadeTime) + { + if (projectile.ai[0] == 0f) + projectile.damage = 0; + } + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 12f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.timeLeft <= MaxTimeLeft - FadeTime && (projectile.timeLeft >= FadeTime || projectile.ai[0] == 1f); + public override bool CanHitPlayer(Player target) => projectile.timeLeft <= MaxTimeLeft - FadeTime && (projectile.timeLeft >= FadeTime || projectile.ai[0] == 1f); public override Color? GetAlpha(Color lightColor) { - // Fade in + // Fade in if (projectile.timeLeft > MaxTimeLeft - FadeTime) { projectile.localAI[1] += 1f; @@ -75,78 +75,78 @@ namespace CalamityMod.Projectiles.Boss return new Color(b2, b2, b2, a2); } - // Fade out if not set to explode - // Glow more red over time if set to explode + // Fade out if not set to explode + // Glow more red over time if set to explode if (projectile.timeLeft < FadeTime) { - byte b2 = (byte)(projectile.timeLeft * 3); - if (projectile.ai[0] == 0f) - { - byte a2 = (byte)(projectile.alpha * (b2 / 255f)); - return new Color(b2, b2, b2, a2); - } - else - return new Color(255, b2, b2, projectile.alpha); + byte b2 = (byte)(projectile.timeLeft * 3); + if (projectile.ai[0] == 0f) + { + byte a2 = (byte)(projectile.alpha * (b2 / 255f)); + return new Color(b2, b2, b2, a2); + } + else + return new Color(255, b2, b2, projectile.alpha); } - // Normal + // Normal return new Color(255, 255, 255, projectile.alpha); } public override void Kill(int timeLeft) { - // Explode and split into accelerating lasers - if (projectile.ai[0] == 1f) - { - Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); - projectile.position = projectile.Center; - projectile.width = projectile.height = 96; - projectile.position.X = projectile.position.X - (projectile.width / 2); - projectile.position.Y = projectile.position.Y - (projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 173, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 10; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 1.5f; - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1f); - } + // Explode and split into accelerating lasers + if (projectile.ai[0] == 1f) + { + Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); + projectile.position = projectile.Center; + projectile.width = projectile.height = 96; + projectile.position.X = projectile.position.X - (projectile.width / 2); + projectile.position.Y = projectile.position.Y - (projectile.height / 2); + for (int num621 = 0; num621 < 5; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 173, 0f, 0f, 100, default, 1.2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 10; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1.7f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 1.5f; + Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1f); + } - // Spawn diagonal lasers - if (Main.myPlayer == projectile.owner) - { - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - float velocity = 1f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = new Vector2(-velocityX2, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(projectile.Center, velocity2, type, (int)Math.Round(projectile.damage * 0.75), 0f, Main.myPlayer, 1f, 0f); - } - } - } + // Spawn diagonal lasers + if (Main.myPlayer == projectile.owner) + { + int totalProjectiles = 4; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + float velocity = 1f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = new Vector2(-velocityX2, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(projectile.Center, velocity2, type, (int)Math.Round(projectile.damage * 0.75), 0f, Main.myPlayer, 1f, 0f); + } + } + } } public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.timeLeft > MaxTimeLeft - FadeTime || (projectile.timeLeft < FadeTime && projectile.ai[0] == 0f)) - return; + if (projectile.timeLeft > MaxTimeLeft - FadeTime || (projectile.timeLeft < FadeTime && projectile.ai[0] == 0f)) + return; - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); } } } diff --git a/Projectiles/Boss/DeusRitualDrama.cs b/Projectiles/Boss/DeusRitualDrama.cs index 01fb23a709..b307ade999 100644 --- a/Projectiles/Boss/DeusRitualDrama.cs +++ b/Projectiles/Boss/DeusRitualDrama.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class DeusRitualDrama : ModProjectile + public class DeusRitualDrama : ModProjectile { public float Time { @@ -109,7 +109,7 @@ namespace CalamityMod.Projectiles.Boss dust.velocity = angle.ToRotationVector2() * 7f; dust.noGravity = true; } - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AstralBeaconOrbPulse"), projectile.Center); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AstralBeaconOrbPulse"), projectile.Center); } DrawStars(spriteBatch, offset); diff --git a/Projectiles/Boss/DoGBeam.cs b/Projectiles/Boss/DoGBeam.cs index 4ad7dd6f33..7ce0438753 100644 --- a/Projectiles/Boss/DoGBeam.cs +++ b/Projectiles/Boss/DoGBeam.cs @@ -54,14 +54,14 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity *= scaleFactor2; } - if (projectile.timeLeft == 950) - projectile.damage = (int)projectile.ai[0]; - if (projectile.timeLeft < 30) - projectile.damage = 0; + if (projectile.timeLeft == 950) + projectile.damage = (int)projectile.ai[0]; + if (projectile.timeLeft < 30) + projectile.damage = 0; } public override bool CanHitPlayer(Player target) - { + { if (projectile.timeLeft > 950 || projectile.timeLeft < 30) { return false; @@ -84,9 +84,9 @@ namespace CalamityMod.Projectiles.Boss return new Color(255, 255, 255, 100); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/DoGBeamPortal.cs b/Projectiles/Boss/DoGBeamPortal.cs index 18a1ae879a..20709402a9 100644 --- a/Projectiles/Boss/DoGBeamPortal.cs +++ b/Projectiles/Boss/DoGBeamPortal.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Projectiles.Boss { public class DoGBeamPortal : ModProjectile { - public bool start = true; + public bool start = true; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Beam Portal"); Main.projFrames[projectile.type] = 6; @@ -45,51 +45,51 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) - { - projectile.active = false; - projectile.netUpdate = true; - return; - } + if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) + { + projectile.active = false; + projectile.netUpdate = true; + return; + } - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; - if (start) - { - Main.PlaySound(SoundID.Item92, (int)projectile.Center.X, (int)projectile.Center.Y); + if (start) + { + Main.PlaySound(SoundID.Item92, (int)projectile.Center.X, (int)projectile.Center.Y); - for (int num621 = 0; num621 < 15; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 30; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 2f; - } + for (int num621 = 0; num621 < 15; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1.2f); + Main.dust[num622].velocity *= 3f; + Main.dust[num622].noGravity = true; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 30; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1.7f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 1f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 2f; + } - projectile.ai[1] = projectile.ai[0]; - start = false; - } + projectile.ai[1] = projectile.ai[0]; + start = false; + } - // Difficulty modes - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - Lighting.AddLight(projectile.Center, 0f, 0.95f, 1.15f); + Lighting.AddLight(projectile.Center, 0f, 0.95f, 1.15f); projectile.frameCounter++; if (projectile.frameCounter > 4) @@ -100,38 +100,38 @@ namespace CalamityMod.Projectiles.Boss if (projectile.frame > 5) projectile.frame = 0; - double deg = projectile.ai[1]; - double rad = deg * (Math.PI / 180); - double dist = malice ? 800D : death ? 960D : revenge ? 1000D : expertMode ? 1040D : 1080D; - projectile.position.X = player.Center.X - (int)(Math.Cos(rad) * dist) - projectile.width / 2; - projectile.position.Y = player.Center.Y - (int)(Math.Sin(rad) * dist) - projectile.height / 2; - projectile.ai[1] += 1f; + double deg = projectile.ai[1]; + double rad = deg * (Math.PI / 180); + double dist = malice ? 800D : death ? 960D : revenge ? 1000D : expertMode ? 1040D : 1080D; + projectile.position.X = player.Center.X - (int)(Math.Cos(rad) * dist) - projectile.width / 2; + projectile.position.Y = player.Center.Y - (int)(Math.Sin(rad) * dist) - projectile.height / 2; + projectile.ai[1] += 1f; - // Don't fire projectiles if Ceaseless Void is entering a new phase - if (projectile.timeLeft > 30) - { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 240f) - { - projectile.localAI[0] = 0f; - if (projectile.owner == Main.myPlayer) - { - Main.PlaySound(SoundID.Item33, (int)projectile.position.X, (int)projectile.position.Y); - float speed = death ? 5f : revenge ? 4.5f : expertMode ? 4f : 3f; - speed *= Main.npc[CalamityGlobalNPC.voidBoss].ai[1]; - int totalProjectiles = 3; - float radians = MathHelper.TwoPi / totalProjectiles; - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 velocity = new Vector2(0f, -speed).RotatedBy(radians * i); - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), 0, 0f, projectile.owner, projectile.damage, 0f); - } - } - } - } + // Don't fire projectiles if Ceaseless Void is entering a new phase + if (projectile.timeLeft > 30) + { + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= 240f) + { + projectile.localAI[0] = 0f; + if (projectile.owner == Main.myPlayer) + { + Main.PlaySound(SoundID.Item33, (int)projectile.position.X, (int)projectile.position.Y); + float speed = death ? 5f : revenge ? 4.5f : expertMode ? 4f : 3f; + speed *= Main.npc[CalamityGlobalNPC.voidBoss].ai[1]; + int totalProjectiles = 3; + float radians = MathHelper.TwoPi / totalProjectiles; + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 velocity = new Vector2(0f, -speed).RotatedBy(radians * i); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), 0, 0f, projectile.owner, projectile.damage, 0f); + } + } + } + } } - public override bool CanHitPlayer(Player target) => false; + public override bool CanHitPlayer(Player target) => false; public override Color? GetAlpha(Color lightColor) { @@ -144,9 +144,9 @@ namespace CalamityMod.Projectiles.Boss return new Color(255, 255, 255, 100); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/DoGDeath.cs b/Projectiles/Boss/DoGDeath.cs index 5d48f7ac4a..286027d931 100644 --- a/Projectiles/Boss/DoGDeath.cs +++ b/Projectiles/Boss/DoGDeath.cs @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 10; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 10; projectile.height = 10; projectile.hostile = true; projectile.ignoreWater = true; @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Boss projectile.extraUpdates = 1; projectile.timeLeft = 450; cooldownSlot = 1; - } + } public override void SendExtraAI(BinaryWriter writer) { @@ -96,8 +96,8 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - if (TelegraphDelay > TelegraphTotalTime) - target.AddBuff(ModContent.BuffType(), 180); + if (TelegraphDelay > TelegraphTotalTime) + target.AddBuff(ModContent.BuffType(), 180); } public override Color? GetAlpha(Color lightColor) @@ -105,10 +105,10 @@ namespace CalamityMod.Projectiles.Boss return new Color(255, 255, 255, projectile.alpha); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Boss/DoGDeathBoom.cs b/Projectiles/Boss/DoGDeathBoom.cs index 4eb291ebcb..d32e85a743 100644 --- a/Projectiles/Boss/DoGDeathBoom.cs +++ b/Projectiles/Boss/DoGDeathBoom.cs @@ -4,33 +4,33 @@ using Terraria; namespace CalamityMod.Projectiles.Boss { - public class DoGDeathBoom : BaseMassiveExplosionProjectile - { - public override int Lifetime => 180; - public override bool UsesScreenshake => true; - public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 28f; - public override Color GetCurrentExplosionColor(float pulseCompletionRatio) - { - return Color.Lerp(Color.Cyan, Color.Fuchsia, MathHelper.Clamp(pulseCompletionRatio * 1.75f, 0f, 1f)); - } - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() => DisplayName.SetDefault("Cosmic Explosion"); - - public override void SetDefaults() - { - projectile.width = projectile.height = 2; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.timeLeft = Lifetime; - cooldownSlot = 1; - } - - public override void PostAI() + public class DoGDeathBoom : BaseMassiveExplosionProjectile + { + public override int Lifetime => 180; + public override bool UsesScreenshake => true; + public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 28f; + public override Color GetCurrentExplosionColor(float pulseCompletionRatio) { - MaxRadius = 4200f; - Lighting.AddLight(projectile.Center, 0.1f, 0.1f, 0.1f); - } - } + return Color.Lerp(Color.Cyan, Color.Fuchsia, MathHelper.Clamp(pulseCompletionRatio * 1.75f, 0f, 1f)); + } + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() => DisplayName.SetDefault("Cosmic Explosion"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 2; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = Lifetime; + cooldownSlot = 1; + } + + public override void PostAI() + { + MaxRadius = 4200f; + Lighting.AddLight(projectile.Center, 0.1f, 0.1f, 0.1f); + } + } } diff --git a/Projectiles/Boss/DoGFire.cs b/Projectiles/Boss/DoGFire.cs index c43e1b561c..ba3ac281f0 100644 --- a/Projectiles/Boss/DoGFire.cs +++ b/Projectiles/Boss/DoGFire.cs @@ -19,19 +19,19 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 34; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 34; projectile.height = 34; projectile.hostile = true; projectile.ignoreWater = true; projectile.tileCollide = false; projectile.alpha = 255; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; projectile.penetrate = -1; projectile.timeLeft = 480; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -62,9 +62,9 @@ namespace CalamityMod.Projectiles.Boss if (projectile.ai[1] > 0f) { - if (projectile.velocity.Length() < projectile.ai[1]) - projectile.velocity *= projectile.ai[0]; - } + if (projectile.velocity.Length() < projectile.ai[1]) + projectile.velocity *= projectile.ai[0]; + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -106,9 +106,9 @@ namespace CalamityMod.Projectiles.Boss projectile.Damage(); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/DoGP1EndPortal.cs b/Projectiles/Boss/DoGP1EndPortal.cs index 23cf4ea922..0f308db262 100644 --- a/Projectiles/Boss/DoGP1EndPortal.cs +++ b/Projectiles/Boss/DoGP1EndPortal.cs @@ -20,13 +20,13 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.width = projectile.height = 120; + projectile.width = projectile.height = 120; projectile.penetrate = -1; projectile.tileCollide = false; projectile.ignoreWater = true; projectile.timeLeft = 60000; projectile.hide = true; - } + } public override void AI() { @@ -66,6 +66,6 @@ namespace CalamityMod.Projectiles.Boss spriteBatch.ExitShaderRegion(); return false; - } - } + } + } } diff --git a/Projectiles/Boss/DoGTeleportRift.cs b/Projectiles/Boss/DoGTeleportRift.cs index d5145e1553..076ae94603 100644 --- a/Projectiles/Boss/DoGTeleportRift.cs +++ b/Projectiles/Boss/DoGTeleportRift.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class DoGTeleportRift : ModProjectile + public class DoGTeleportRift : ModProjectile { public override string Texture => "CalamityMod/Projectiles/StarProj"; @@ -19,118 +19,118 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { projectile.width = projectile.height = 30; - projectile.scale = 2.5f; + projectile.scale = 2.5f; projectile.hostile = true; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.Opacity = 0f; + projectile.Opacity = 0f; projectile.penetrate = -1; projectile.timeLeft = 200; } public override void AI() { - if (projectile.ai[0] == -1f) - return; + if (projectile.ai[0] == -1f) + return; - if (projectile.timeLeft < 160) - projectile.timeLeft = 160; + if (projectile.timeLeft < 160) + projectile.timeLeft = 160; - if (!Main.npc[(int)projectile.ai[0]].active) - projectile.Kill(); + if (!Main.npc[(int)projectile.ai[0]].active) + projectile.Kill(); - projectile.ai[1] += MathHelper.Pi / 30f; - projectile.Opacity = MathHelper.Clamp(projectile.ai[1], 0f, 1f); + projectile.ai[1] += MathHelper.Pi / 30f; + projectile.Opacity = MathHelper.Clamp(projectile.ai[1], 0f, 1f); - if (projectile.Opacity == 1f && Main.rand.NextBool(15)) - { - Dust dust = Main.dust[Dust.NewDust(projectile.Top, 0, 0, 267, 0f, 0f, 100, new Color(150, 100, 255, 255), 1f)]; - dust.velocity.X = 0f; - dust.noGravity = true; - dust.fadeIn = 1f; - dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * (4f * Main.rand.NextFloat() + 26f); - dust.scale = 0.5f; - } - } + if (projectile.Opacity == 1f && Main.rand.NextBool(15)) + { + Dust dust = Main.dust[Dust.NewDust(projectile.Top, 0, 0, 267, 0f, 0f, 100, new Color(150, 100, 255, 255), 1f)]; + dust.velocity.X = 0f; + dust.noGravity = true; + dust.fadeIn = 1f; + dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * (4f * Main.rand.NextFloat() + 26f); + dust.scale = 0.5f; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - float lerpMult = Utils.InverseLerp(15f, 30f, projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f / 0.5f * (MathHelper.Pi * 2f) * 3f)) * 0.8f; - - Texture2D texture = Main.projectileTexture[projectile.type]; - Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - Color baseColor = new Color(150, 100, 255, 255) * projectile.Opacity; - baseColor *= 0.5f; - baseColor.A = 0; - Color colorA = baseColor; - Color colorB = baseColor * 0.5f; - colorA *= lerpMult; - colorB *= lerpMult; - Vector2 origin = texture.Size() / 2f; - Vector2 scale = new Vector2(3f, 9f) * projectile.Opacity * lerpMult; - - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, 0f, origin, scale, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver2, origin, scale * 0.8f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, 0f, origin, scale * 0.8f, spriteEffects, 0); - - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2 + projectile.ai[1] * 0.25f, origin, scale, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, projectile.ai[1] * 0.25f, origin, scale, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver2 + projectile.ai[1] * 0.5f, origin, scale * 0.8f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, projectile.ai[1] * 0.5f, origin, scale * 0.8f, spriteEffects, 0); - - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4, origin, scale * 0.6f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f, origin, scale * 0.6f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4, origin, scale * 0.4f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f, origin, scale * 0.4f, spriteEffects, 0); - - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 + projectile.ai[1] * 0.75f, origin, scale * 0.6f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f + projectile.ai[1] * 0.75f, origin, scale * 0.6f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 + projectile.ai[1], origin, scale * 0.4f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f + projectile.ai[1], origin, scale * 0.4f, spriteEffects, 0); - - return false; - } - - public override void Kill(int timeLeft) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.ai[0] == -1f) - return; + float lerpMult = Utils.InverseLerp(15f, 30f, projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f / 0.5f * (MathHelper.Pi * 2f) * 3f)) * 0.8f; - int dustAmt = 50; - int random = 5; + Texture2D texture = Main.projectileTexture[projectile.type]; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Color baseColor = new Color(150, 100, 255, 255) * projectile.Opacity; + baseColor *= 0.5f; + baseColor.A = 0; + Color colorA = baseColor; + Color colorB = baseColor * 0.5f; + colorA *= lerpMult; + colorB *= lerpMult; + Vector2 origin = texture.Size() / 2f; + Vector2 scale = new Vector2(3f, 9f) * projectile.Opacity * lerpMult; - for (int j = 0; j < 10; j++) - { - random += j * 2; - int dustAmtSpawned = 0; - int scale = random * 13; - float dustPositionX = projectile.Center.X - (scale / 2); - float dustPositionY = projectile.Center.Y - (scale / 2); - while (dustAmtSpawned < dustAmt) - { - float dustVelocityX = Main.rand.Next(-random, random); - float dustVelocityY = Main.rand.Next(-random, random); - float dustVelocityScalar = random * 2f; - float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); - dustVelocity = dustVelocityScalar / dustVelocity; - dustVelocityX *= dustVelocity; - dustVelocityY *= dustVelocity; - int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].position.X = projectile.Center.X; - Main.dust[dust].position.Y = projectile.Center.Y; - Main.dust[dust].position.X += Main.rand.Next(-10, 11); - Main.dust[dust].position.Y += Main.rand.Next(-10, 11); - Main.dust[dust].velocity.X = dustVelocityX; - Main.dust[dust].velocity.Y = dustVelocityY; - dustAmtSpawned++; - } - } - } + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, 0f, origin, scale, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver2, origin, scale * 0.8f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, 0f, origin, scale * 0.8f, spriteEffects, 0); + + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2 + projectile.ai[1] * 0.25f, origin, scale, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, projectile.ai[1] * 0.25f, origin, scale, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver2 + projectile.ai[1] * 0.5f, origin, scale * 0.8f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, projectile.ai[1] * 0.5f, origin, scale * 0.8f, spriteEffects, 0); + + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4, origin, scale * 0.4f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f, origin, scale * 0.4f, spriteEffects, 0); + + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 + projectile.ai[1] * 0.75f, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f + projectile.ai[1] * 0.75f, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 + projectile.ai[1], origin, scale * 0.4f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f + projectile.ai[1], origin, scale * 0.4f, spriteEffects, 0); + + return false; + } + + public override void Kill(int timeLeft) + { + if (projectile.ai[0] == -1f) + return; + + int dustAmt = 50; + int random = 5; + + for (int j = 0; j < 10; j++) + { + random += j * 2; + int dustAmtSpawned = 0; + int scale = random * 13; + float dustPositionX = projectile.Center.X - (scale / 2); + float dustPositionY = projectile.Center.Y - (scale / 2); + while (dustAmtSpawned < dustAmt) + { + float dustVelocityX = Main.rand.Next(-random, random); + float dustVelocityY = Main.rand.Next(-random, random); + float dustVelocityScalar = random * 2f; + float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); + dustVelocity = dustVelocityScalar / dustVelocity; + dustVelocityX *= dustVelocity; + dustVelocityY *= dustVelocity; + int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].position.X = projectile.Center.X; + Main.dust[dust].position.Y = projectile.Center.Y; + Main.dust[dust].position.X += Main.rand.Next(-10, 11); + Main.dust[dust].position.Y += Main.rand.Next(-10, 11); + Main.dust[dust].velocity.X = dustVelocityX; + Main.dust[dust].velocity.Y = dustVelocityY; + dustAmtSpawned++; + } + } + } } } diff --git a/Projectiles/Boss/DraedonSummonLaser.cs b/Projectiles/Boss/DraedonSummonLaser.cs index 5cd53e6515..e379fc7a96 100644 --- a/Projectiles/Boss/DraedonSummonLaser.cs +++ b/Projectiles/Boss/DraedonSummonLaser.cs @@ -32,19 +32,19 @@ namespace CalamityMod.Projectiles.Boss public override bool CanDamage() => projectile.timeLeft < Lifetime - 30; public override void AI() - { + { if (projectile.localAI[0] == 0f) - { + { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"), projectile.Center); for (int i = 0; i < 36; i++) - { + { Dust exoDust = Dust.NewDustPerfect(projectile.BottomRight, 267); exoDust.color = CalamityUtils.MulticolorLerp(i / 36f, CalamityUtils.ExoPalette); exoDust.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * new Vector2(3f, 1.45f) - Vector2.UnitY * 2f; exoDust.scale = 2.8f; exoDust.fadeIn = Main.rand.NextFloat(0.8f, 1.85f); exoDust.noGravity = true; - } + } for (int i = 0; i < 10; i++) { @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Boss exoDust.noGravity = true; } projectile.localAI[0] = 1f; - } + } Lighting.AddLight(projectile.Center, Color.White.ToVector3()); projectile.scale = Utils.InverseLerp(-1f, 15f, projectile.timeLeft, true) * Utils.InverseLerp(Lifetime + 1f, Lifetime - 15f, projectile.timeLeft, true); @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Boss } private Color PrimitiveColorFunction(float completionRatio) - { + { return CalamityUtils.MulticolorLerp((Main.GlobalTime * 0.67f - completionRatio * 3f) % 1f, CalamityUtils.ExoPalette) * 1.2f; } @@ -94,8 +94,8 @@ namespace CalamityMod.Projectiles.Boss } public override void DrawBehind(int index, List drawCacheProjsBehindNPCsAndTiles, List drawCacheProjsBehindNPCs, List drawCacheProjsBehindProjectiles, List drawCacheProjsOverWiresUI) - { + { drawCacheProjsBehindNPCsAndTiles.Add(index); } - } + } } diff --git a/Projectiles/Boss/EssenceDust.cs b/Projectiles/Boss/EssenceDust.cs index 38db5cf013..9df3720440 100644 --- a/Projectiles/Boss/EssenceDust.cs +++ b/Projectiles/Boss/EssenceDust.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class EssenceDust : ModProjectile + public class EssenceDust : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Boss projectile.ignoreWater = true; projectile.tileCollide = false; projectile.penetrate = -1; - projectile.timeLeft = 60; + projectile.timeLeft = 60; cooldownSlot = 1; } @@ -65,14 +65,14 @@ namespace CalamityMod.Projectiles.Boss projectile.Damage(); } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/Flare.cs b/Projectiles/Boss/Flare.cs index d88e2ea2c9..793f937b61 100644 --- a/Projectiles/Boss/Flare.cs +++ b/Projectiles/Boss/Flare.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 600; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void SendExtraAI(BinaryWriter writer) @@ -41,43 +41,43 @@ namespace CalamityMod.Projectiles.Boss projectile.localAI[0] = reader.ReadSingle(); } - public override void AI() - { - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; - } + public override void AI() + { + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + { + projectile.frame = 0; + } - float num630 = 0.209439516f; - float num631 = 4f; - float num632 = (float)(Math.Cos((double)(num630 * projectile.ai[0])) - 0.5) * num631; - projectile.velocity.Y = projectile.velocity.Y - num632; - projectile.ai[0] += 1f; - num632 = (float)(Math.Cos((double)(num630 * projectile.ai[0])) - 0.5) * num631; - projectile.velocity.Y = projectile.velocity.Y + num632; + float num630 = 0.209439516f; + float num631 = 4f; + float num632 = (float)(Math.Cos((double)(num630 * projectile.ai[0])) - 0.5) * num631; + projectile.velocity.Y = projectile.velocity.Y - num632; + projectile.ai[0] += 1f; + num632 = (float)(Math.Cos((double)(num630 * projectile.ai[0])) - 0.5) * num631; + projectile.velocity.Y = projectile.velocity.Y + num632; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 10f) - { - projectile.alpha -= 5; - if (projectile.alpha < 100) - { - projectile.alpha = 100; - } - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 10f) + { + projectile.alpha -= 5; + if (projectile.alpha < 100) + { + projectile.alpha = 100; + } + } - if (projectile.wet) - { - projectile.position.Y = projectile.position.Y - 16f; - projectile.Kill(); - } - } + if (projectile.wet) + { + projectile.position.Y = projectile.position.Y - 16f; + projectile.Kill(); + } + } public override Color? GetAlpha(Color lightColor) { @@ -135,12 +135,12 @@ namespace CalamityMod.Projectiles.Boss break; } } - int spawnLimitY = (int)(Main.player[projectile.owner].Center.Y / 16f) + 25; - if (num231 > spawnLimitY) - { - num231 = spawnLimitY; - } - int num236 = Projectile.NewProjectile((float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 0, 4f, Main.myPlayer, 11f, 10f + (revenge ? 1f : 0f)); + int spawnLimitY = (int)(Main.player[projectile.owner].Center.Y / 16f) + 25; + if (num231 > spawnLimitY) + { + num231 = spawnLimitY; + } + int num236 = Projectile.NewProjectile((float)(num232 * 16 + 8), (float)(num231 * 16 - 24), 0f, 0f, ModContent.ProjectileType(), 0, 4f, Main.myPlayer, 11f, 10f + (revenge ? 1f : 0f)); Main.projectile[num236].netUpdate = true; } } diff --git a/Projectiles/Boss/FlareBomb.cs b/Projectiles/Boss/FlareBomb.cs index f6662b0a0c..05b142830d 100644 --- a/Projectiles/Boss/FlareBomb.cs +++ b/Projectiles/Boss/FlareBomb.cs @@ -18,8 +18,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 64; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 64; projectile.height = 66; projectile.hostile = true; projectile.scale = 1.5f; @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 50; projectile.timeLeft = 180; cooldownSlot = 1; - } + } public override void AI() { @@ -52,13 +52,13 @@ namespace CalamityMod.Projectiles.Boss if (projectile.alpha < 0) projectile.alpha = 0; - if (projectile.ai[0] == -1f || (projectile.timeLeft > 135 && projectile.ai[1] == 1f)) - return; + if (projectile.ai[0] == -1f || (projectile.timeLeft > 135 && projectile.ai[1] == 1f)) + return; - float inertia = revenge ? 70f : 77f; - float num954 = 40f; - float scaleFactor12 = revenge ? 35f : 28f; - int num959 = (int)projectile.ai[0]; + float inertia = revenge ? 70f : 77f; + float num954 = 40f; + float scaleFactor12 = revenge ? 35f : 28f; + int num959 = (int)projectile.ai[0]; if (num959 >= 0 && Main.player[num959].active && !Main.player[num959].dead) { if (projectile.Distance(Main.player[num959].Center) > num954) @@ -76,32 +76,32 @@ namespace CalamityMod.Projectiles.Boss } } - if (projectile.timeLeft < 60) - return; + if (projectile.timeLeft < 60) + return; - float num1247 = 0.5f; - for (int num1248 = 0; num1248 < Main.maxProjectiles; num1248++) - { - if (Main.projectile[num1248].active) - { - if (num1248 != projectile.whoAmI && Main.projectile[num1248].type == projectile.type) - { - if (Vector2.Distance(projectile.Center, Main.projectile[num1248].Center) < 24f) - { - if (projectile.position.X < Main.projectile[num1248].position.X) - projectile.velocity.X -= num1247; - else - projectile.velocity.X += num1247; + float num1247 = 0.5f; + for (int num1248 = 0; num1248 < Main.maxProjectiles; num1248++) + { + if (Main.projectile[num1248].active) + { + if (num1248 != projectile.whoAmI && Main.projectile[num1248].type == projectile.type) + { + if (Vector2.Distance(projectile.Center, Main.projectile[num1248].Center) < 24f) + { + if (projectile.position.X < Main.projectile[num1248].position.X) + projectile.velocity.X -= num1247; + else + projectile.velocity.X += num1247; - if (projectile.position.Y < Main.projectile[num1248].position.Y) - projectile.velocity.Y -= num1247; - else - projectile.velocity.Y += num1247; - } - } - } - } - } + if (projectile.position.Y < Main.projectile[num1248].position.Y) + projectile.velocity.Y -= num1247; + else + projectile.velocity.Y += num1247; + } + } + } + } + } public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); @@ -117,7 +117,7 @@ namespace CalamityMod.Projectiles.Boss public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.Center); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 48); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 48); for (int d = 0; d < 2; d++) { int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); @@ -136,20 +136,20 @@ namespace CalamityMod.Projectiles.Boss idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[idx].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); projectile.Damage(); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 16f * projectile.scale, targetHitbox); - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/FlareDust.cs b/Projectiles/Boss/FlareDust.cs index 0ec7cb54d0..c6e4f1ab90 100644 --- a/Projectiles/Boss/FlareDust.cs +++ b/Projectiles/Boss/FlareDust.cs @@ -12,12 +12,12 @@ namespace CalamityMod.Projectiles.Boss { public override string Texture => "CalamityMod/Projectiles/Boss/FlareBomb"; - private bool start = true; - private float startingPosX = 0f; - private float startingPosY = 0f; - private double distance = 0D; + private bool start = true; + private float startingPosX = 0f; + private float startingPosY = 0f; + private double distance = 0D; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Flare Dust"); Main.projFrames[projectile.type] = 5; @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 64; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 64; projectile.height = 66; projectile.scale = 1.5f; projectile.hostile = true; @@ -35,27 +35,27 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.timeLeft = 680; cooldownSlot = 1; - } + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - writer.Write(start); - writer.Write(startingPosX); - writer.Write(startingPosY); - writer.Write(distance); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + writer.Write(start); + writer.Write(startingPosX); + writer.Write(startingPosY); + writer.Write(distance); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - start = reader.ReadBoolean(); - startingPosX = reader.ReadSingle(); - startingPosY = reader.ReadSingle(); - distance = reader.ReadDouble(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + start = reader.ReadBoolean(); + startingPosX = reader.ReadSingle(); + startingPosY = reader.ReadSingle(); + distance = reader.ReadDouble(); + } - public override void AI() + public override void AI() { projectile.frameCounter++; if (projectile.frameCounter > 4) @@ -68,44 +68,44 @@ namespace CalamityMod.Projectiles.Boss Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); - if (projectile.ai[0] == 2f) - return; + if (projectile.ai[0] == 2f) + return; - if (start) - { - startingPosX = projectile.Center.X; - startingPosY = projectile.Center.Y; - start = false; - } + if (start) + { + startingPosX = projectile.Center.X; + startingPosY = projectile.Center.Y; + start = false; + } - float amount = projectile.localAI[0] / 120f; - if (amount > 1f) - amount = 1f; - distance += MathHelper.Lerp(1f, 9f, amount); + float amount = projectile.localAI[0] / 120f; + if (amount > 1f) + amount = 1f; + distance += MathHelper.Lerp(1f, 9f, amount); - if (projectile.timeLeft < 380) - { - float amount2 = (projectile.localAI[0] - 300f) / 240f; - if (amount2 > 1f) - amount2 = 1f; - distance += MathHelper.Lerp(1f, 9f, amount2); - } + if (projectile.timeLeft < 380) + { + float amount2 = (projectile.localAI[0] - 300f) / 240f; + if (amount2 > 1f) + amount2 = 1f; + distance += MathHelper.Lerp(1f, 9f, amount2); + } - double rad = MathHelper.ToRadians(projectile.ai[1]); - if (projectile.ai[0] == 0f) - { - projectile.position.X = startingPosX - (int)(Math.Sin(rad) * distance) - projectile.width / 2; - projectile.position.Y = startingPosY - (int)(Math.Cos(rad) * distance) - projectile.height / 2; - } - else - { - projectile.position.X = startingPosX - (int)(Math.Cos(rad) * distance) - projectile.width / 2; - projectile.position.Y = startingPosY - (int)(Math.Sin(rad) * distance) - projectile.height / 2; - } + double rad = MathHelper.ToRadians(projectile.ai[1]); + if (projectile.ai[0] == 0f) + { + projectile.position.X = startingPosX - (int)(Math.Sin(rad) * distance) - projectile.width / 2; + projectile.position.Y = startingPosY - (int)(Math.Cos(rad) * distance) - projectile.height / 2; + } + else + { + projectile.position.X = startingPosX - (int)(Math.Cos(rad) * distance) - projectile.width / 2; + projectile.position.Y = startingPosY - (int)(Math.Sin(rad) * distance) - projectile.height / 2; + } - projectile.ai[1] += (1.1f - amount) * 0.5f; - projectile.localAI[0] += 1f; - } + projectile.ai[1] += (1.1f - amount) * 0.5f; + projectile.localAI[0] += 1f; + } public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); @@ -121,7 +121,7 @@ namespace CalamityMod.Projectiles.Boss public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.Center); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 48); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 48); for (int d = 0; d < 2; d++) { int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); @@ -140,40 +140,40 @@ namespace CalamityMod.Projectiles.Boss idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[idx].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); projectile.Damage(); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 16f * projectile.scale, targetHitbox); - public override bool CanHitPlayer(Player target) - { - Rectangle targetHitbox = target.Hitbox; - - float dist1 = Vector2.Distance(projectile.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(projectile.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(projectile.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(projectile.Center, targetHitbox.BottomRight()); - - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; - - return minDist <= 16f * projectile.scale; - } - - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override bool CanHitPlayer(Player target) { - target.Calamity().lastProjectileHit = projectile; - } + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(projectile.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(projectile.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(projectile.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(projectile.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= 16f * projectile.scale; + } + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/FlareDust2.cs b/Projectiles/Boss/FlareDust2.cs index 337a03b255..ee3eb1fd64 100644 --- a/Projectiles/Boss/FlareDust2.cs +++ b/Projectiles/Boss/FlareDust2.cs @@ -12,10 +12,10 @@ namespace CalamityMod.Projectiles.Boss { public override string Texture => "CalamityMod/Projectiles/Boss/FlareBomb"; - private bool start = true; - private Vector2 velocity = Vector2.Zero; + private bool start = true; + private Vector2 velocity = Vector2.Zero; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Flare Bomb"); Main.projFrames[projectile.type] = 5; @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 64; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 64; projectile.height = 66; projectile.scale = 1.5f; projectile.hostile = true; @@ -35,19 +35,19 @@ namespace CalamityMod.Projectiles.Boss cooldownSlot = 1; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(start); - writer.WriteVector2(velocity); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(start); + writer.WriteVector2(velocity); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - start = reader.ReadBoolean(); - velocity = reader.ReadVector2(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + start = reader.ReadBoolean(); + velocity = reader.ReadVector2(); + } - public override void AI() + public override void AI() { projectile.frameCounter++; if (projectile.frameCounter > 4) @@ -60,55 +60,55 @@ namespace CalamityMod.Projectiles.Boss if (projectile.ai[0] == 1f) { - if (projectile.timeLeft < 630) - { - if (projectile.velocity.Length() < 6f) - { - projectile.velocity *= 1.025f; - } - else - { - if (start) - { - velocity = projectile.velocity; - start = false; - } + if (projectile.timeLeft < 630) + { + if (projectile.velocity.Length() < 6f) + { + projectile.velocity *= 1.025f; + } + else + { + if (start) + { + velocity = projectile.velocity; + start = false; + } - projectile.ai[1] += 0.1f; + projectile.ai[1] += 0.1f; - float amplitude = 2f; + float amplitude = 2f; - float wavyVelocity = (float)Math.Cos(projectile.ai[1]); + float wavyVelocity = (float)Math.Cos(projectile.ai[1]); - projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity) * amplitude; - } - } + projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity) * amplitude; + } + } } else { - if (projectile.timeLeft < 420) - { - if (projectile.velocity.Length() < 12f) - { - projectile.velocity *= 1.05f; - } - else - { - if (start) - { - velocity = projectile.velocity; - start = false; - } + if (projectile.timeLeft < 420) + { + if (projectile.velocity.Length() < 12f) + { + projectile.velocity *= 1.05f; + } + else + { + if (start) + { + velocity = projectile.velocity; + start = false; + } - projectile.ai[1] += 0.1f; + projectile.ai[1] += 0.1f; - float amplitude = 2f; + float amplitude = 2f; - float wavyVelocity = (float)Math.Sin(projectile.ai[1]); + float wavyVelocity = (float)Math.Sin(projectile.ai[1]); - projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity) * amplitude; - } - } + projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity) * amplitude; + } + } } Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); @@ -128,7 +128,7 @@ namespace CalamityMod.Projectiles.Boss public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.Center); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 48); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 48); for (int d = 0; d < 2; d++) { int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); @@ -147,20 +147,20 @@ namespace CalamityMod.Projectiles.Boss idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[idx].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); projectile.Damage(); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 16f * projectile.scale, targetHitbox); - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/Flarenado.cs b/Projectiles/Boss/Flarenado.cs index 9d5f0c0349..a39f126e40 100644 --- a/Projectiles/Boss/Flarenado.cs +++ b/Projectiles/Boss/Flarenado.cs @@ -18,8 +18,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 320; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 320; projectile.height = 88; projectile.hostile = true; projectile.tileCollide = false; @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - float scaleBase = 24f; + float scaleBase = 24f; float scaleMult = 1f; float baseWidth = 320f; float baseHeight = 88f; @@ -65,7 +65,7 @@ namespace CalamityMod.Projectiles.Boss { projectile.localAI[0] = 1f; projectile.scale = (scaleBase - projectile.ai[1]) * scaleMult / scaleBase; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(baseWidth * projectile.scale), (int)(baseHeight * projectile.scale)); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(baseWidth * projectile.scale), (int)(baseHeight * projectile.scale)); projectile.netUpdate = true; } if (projectile.ai[1] != -1f) @@ -118,11 +118,11 @@ namespace CalamityMod.Projectiles.Boss projectile.position.X += num624 * -projectile.direction; } - if (projectile.timeLeft == 480) - projectile.damage = projectile.GetProjectileDamage(ModContent.NPCType()); + if (projectile.timeLeft == 480) + projectile.damage = projectile.GetProjectileDamage(ModContent.NPCType()); } - public override bool CanHitPlayer(Player target) => projectile.timeLeft <= 480; + public override bool CanHitPlayer(Player target) => projectile.timeLeft <= 480; public override Color? GetAlpha(Color lightColor) { @@ -138,15 +138,15 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.timeLeft <= 480) - target.AddBuff(ModContent.BuffType(), 300); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + if (projectile.timeLeft <= 480) + target.AddBuff(ModContent.BuffType(), 300); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/FrostMist.cs b/Projectiles/Boss/FrostMist.cs index 948215fa45..c8b2290b5d 100644 --- a/Projectiles/Boss/FrostMist.cs +++ b/Projectiles/Boss/FrostMist.cs @@ -24,13 +24,13 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 20; projectile.hostile = true; projectile.ignoreWater = true; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 300; projectile.Opacity = 0f; - projectile.coldDamage = true; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.coldDamage = true; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -44,92 +44,92 @@ namespace CalamityMod.Projectiles.Boss projectile.localAI[1] = reader.ReadSingle(); } - public override void AI() - { - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - projectile.frame = 0; - - if (projectile.ai[1] == 0f) - { - for (int num621 = 0; num621 < 5; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 187, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - projectile.ai[1] = 1f; - } - - projectile.localAI[1] += 1f; - if (projectile.localAI[1] == 16f) - { - projectile.localAI[1] = 0f; - for (int l = 0; l < 12; l++) - { - Vector2 vector3 = Vector2.UnitX * -projectile.width / 2f; - vector3 += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); - vector3 = vector3.RotatedBy(projectile.rotation - MathHelper.PiOver2); - int num9 = Dust.NewDust(projectile.Center, 0, 0, 187, 0f, 0f, 160, default, 1f); - Main.dust[num9].scale = 1.1f; - Main.dust[num9].noGravity = true; - Main.dust[num9].position = projectile.Center + vector3; - Main.dust[num9].velocity = projectile.velocity * 0.1f; - Main.dust[num9].velocity = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; - } - } - - if (projectile.timeLeft < 30) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 270) / 30f), 0f, 1f); - - int num103 = Player.FindClosest(projectile.Center, 1, 1); - projectile.ai[1] += 1f; - if (projectile.ai[1] < 140f && projectile.ai[1] > 60f) - { - float scaleFactor2 = projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - projectile.Center; - vector11.Normalize(); - vector11 *= scaleFactor2; - projectile.velocity = (projectile.velocity * 24f + vector11) / 25f; - projectile.velocity.Normalize(); - projectile.velocity *= scaleFactor2; - } - if (projectile.velocity.Length() < 12f) - projectile.velocity *= 1.02f; - - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - - Lighting.AddLight(projectile.Center, 0f, 0.35f * projectile.Opacity, 0.35f * projectile.Opacity); - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - lightColor.R = (byte)(255 * projectile.Opacity); - lightColor.G = (byte)(255 * projectile.Opacity); - lightColor.B = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void AI() { - if (projectile.Opacity != 1f) - return; + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + projectile.frame = 0; - target.AddBuff(BuffID.Frostburn, 120, true); + if (projectile.ai[1] == 0f) + { + for (int num621 = 0; num621 < 5; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 187, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + projectile.ai[1] = 1f; + } + + projectile.localAI[1] += 1f; + if (projectile.localAI[1] == 16f) + { + projectile.localAI[1] = 0f; + for (int l = 0; l < 12; l++) + { + Vector2 vector3 = Vector2.UnitX * -projectile.width / 2f; + vector3 += -Vector2.UnitY.RotatedBy(l * MathHelper.Pi / 6f) * new Vector2(8f, 16f); + vector3 = vector3.RotatedBy(projectile.rotation - MathHelper.PiOver2); + int num9 = Dust.NewDust(projectile.Center, 0, 0, 187, 0f, 0f, 160, default, 1f); + Main.dust[num9].scale = 1.1f; + Main.dust[num9].noGravity = true; + Main.dust[num9].position = projectile.Center + vector3; + Main.dust[num9].velocity = projectile.velocity * 0.1f; + Main.dust[num9].velocity = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; + } + } + + if (projectile.timeLeft < 30) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 270) / 30f), 0f, 1f); + + int num103 = Player.FindClosest(projectile.Center, 1, 1); + projectile.ai[1] += 1f; + if (projectile.ai[1] < 140f && projectile.ai[1] > 60f) + { + float scaleFactor2 = projectile.velocity.Length(); + Vector2 vector11 = Main.player[num103].Center - projectile.Center; + vector11.Normalize(); + vector11 *= scaleFactor2; + projectile.velocity = (projectile.velocity * 24f + vector11) / 25f; + projectile.velocity.Normalize(); + projectile.velocity *= scaleFactor2; + } + if (projectile.velocity.Length() < 12f) + projectile.velocity *= 1.02f; + + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + + Lighting.AddLight(projectile.Center, 0f, 0.35f * projectile.Opacity, 0.35f * projectile.Opacity); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.G = (byte)(255 * projectile.Opacity); + lightColor.B = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.Opacity != 1f) + return; + + target.AddBuff(BuffID.Frostburn, 120, true); target.AddBuff(BuffID.Chilled, 90, true); } } diff --git a/Projectiles/Boss/HealOrbProv.cs b/Projectiles/Boss/HealOrbProv.cs index ac638c47be..1418f32c90 100644 --- a/Projectiles/Boss/HealOrbProv.cs +++ b/Projectiles/Boss/HealOrbProv.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Boss projectile.tileCollide = false; projectile.timeLeft = 300; projectile.extraUpdates = 3; - } + } public override void AI() { @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Boss if (projectile.owner == Main.myPlayer) { int num492 = (int)projectile.ai[1]; - Main.player[num487].HealEffect(num492, false); + Main.player[num487].HealEffect(num492, false); Main.player[num487].statLife += num492; if (Main.player[num487].statLife > Main.player[num487].statLifeMax2) { diff --git a/Projectiles/Boss/HellfireExplosion.cs b/Projectiles/Boss/HellfireExplosion.cs index 991c6a08ef..09524a68d4 100644 --- a/Projectiles/Boss/HellfireExplosion.cs +++ b/Projectiles/Boss/HellfireExplosion.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class HellfireExplosion : ModProjectile + public class HellfireExplosion : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Boss/HiveBombGoliath.cs b/Projectiles/Boss/HiveBombGoliath.cs index 2ffc1b8e07..ac279a7942 100644 --- a/Projectiles/Boss/HiveBombGoliath.cs +++ b/Projectiles/Boss/HiveBombGoliath.cs @@ -20,20 +20,20 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 22; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 22; projectile.height = 22; projectile.hostile = true; projectile.tileCollide = false; - projectile.ignoreWater = true; + projectile.ignoreWater = true; projectile.penetrate = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { - if (projectile.velocity.Length() < 18f) - projectile.velocity *= 1.01f + (projectile.ai[0] * 0.0002f); + if (projectile.velocity.Length() < 18f) + projectile.velocity *= 1.01f + (projectile.ai[0] * 0.0002f); if (projectile.position.Y > projectile.ai[1]) projectile.tileCollide = true; @@ -118,7 +118,7 @@ namespace CalamityMod.Projectiles.Boss num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitPlayer(Player target, int damage, bool crit) diff --git a/Projectiles/Boss/HolyAura.cs b/Projectiles/Boss/HolyAura.cs index 4a7a81160d..fbbf5f769f 100644 --- a/Projectiles/Boss/HolyAura.cs +++ b/Projectiles/Boss/HolyAura.cs @@ -18,92 +18,92 @@ namespace CalamityMod.Projectiles.Boss projectile.width = 30; projectile.height = 30; projectile.hostile = true; - projectile.aiStyle = -1; - aiType = -1; + projectile.aiStyle = -1; + aiType = -1; projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.ignoreWater = true; + projectile.ignoreWater = true; projectile.timeLeft = 210; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - Vector2 origin = texture.Size() / 2f; - float time = Main.GlobalTime % 10f / 10f; - Vector2 drawPosition = projectile.Center - Main.screenPosition; - int drawnAmt = 30; - float[] posX = new float[drawnAmt]; - float[] posY = new float[drawnAmt]; - float[] hue = new float[drawnAmt]; - float[] size = new float[drawnAmt]; - int totalTime = 210; - float colorChangeAmt = Utils.InverseLerp(0f, 60f, projectile.timeLeft, true) * Utils.InverseLerp(totalTime, totalTime - 60, projectile.timeLeft, true); - float colorChangeAmt2 = Utils.InverseLerp(0f, 60f, projectile.timeLeft, true) * Utils.InverseLerp(totalTime, 90f, projectile.timeLeft, true); - colorChangeAmt2 = Utils.InverseLerp(0.2f, 0.5f, colorChangeAmt2, true); - float sizeScale = 0.8f; - float sizeScalar = (1f - sizeScale) / drawnAmt; - float yPosOffset = 60f; - float xPosOffset = 400f; - Vector2 scale = new Vector2(6f, 6f); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + Vector2 origin = texture.Size() / 2f; + float time = Main.GlobalTime % 10f / 10f; + Vector2 drawPosition = projectile.Center - Main.screenPosition; + int drawnAmt = 30; + float[] posX = new float[drawnAmt]; + float[] posY = new float[drawnAmt]; + float[] hue = new float[drawnAmt]; + float[] size = new float[drawnAmt]; + int totalTime = 210; + float colorChangeAmt = Utils.InverseLerp(0f, 60f, projectile.timeLeft, true) * Utils.InverseLerp(totalTime, totalTime - 60, projectile.timeLeft, true); + float colorChangeAmt2 = Utils.InverseLerp(0f, 60f, projectile.timeLeft, true) * Utils.InverseLerp(totalTime, 90f, projectile.timeLeft, true); + colorChangeAmt2 = Utils.InverseLerp(0.2f, 0.5f, colorChangeAmt2, true); + float sizeScale = 0.8f; + float sizeScalar = (1f - sizeScale) / drawnAmt; + float yPosOffset = 60f; + float xPosOffset = 400f; + Vector2 scale = new Vector2(6f, 6f); - for (int i = 0; i < drawnAmt; i++) - { - float timeScalar = (float)Math.Sin(time * MathHelper.TwoPi + (float)Math.PI / 2f + i / 2f); + for (int i = 0; i < drawnAmt; i++) + { + float timeScalar = (float)Math.Sin(time * MathHelper.TwoPi + (float)Math.PI / 2f + i / 2f); - posX[i] = timeScalar * (xPosOffset - i * 3f); + posX[i] = timeScalar * (xPosOffset - i * 3f); - posY[i] = (float)Math.Sin(time * MathHelper.TwoPi * 2f + (float)Math.PI / 3f + i) * yPosOffset; - posY[i] -= i * 3f; + posY[i] = (float)Math.Sin(time * MathHelper.TwoPi * 2f + (float)Math.PI / 3f + i) * yPosOffset; + posY[i] -= i * 3f; - hue[i] = i / (float)drawnAmt * 2f + time; - hue[i] = (timeScalar * 0.5f + 0.5f) * 0.6f + time; + hue[i] = i / (float)drawnAmt * 2f + time; + hue[i] = (timeScalar * 0.5f + 0.5f) * 0.6f + time; - size[i] = sizeScale + (i + 1) * sizeScalar; - size[i] *= 0.3f; + size[i] = sizeScale + (i + 1) * sizeScalar; + size[i] *= 0.3f; - Color color = Main.hslToRgb(hue[i] % 1f, 1f, 0.5f) * colorChangeAmt * colorChangeAmt2; + Color color = Main.hslToRgb(hue[i] % 1f, 1f, 0.5f) * colorChangeAmt * colorChangeAmt2; - bool underworld = projectile.ai[0] == 2f; - if (Main.dayTime) - { - color.R = 255; - if (underworld) - color.B = 0; - } - else - { - color.B = 255; - if (underworld) - color.G = 0; - else - color.R = 0; - } + bool underworld = projectile.ai[0] == 2f; + if (Main.dayTime) + { + color.R = 255; + if (underworld) + color.B = 0; + } + else + { + color.B = 255; + if (underworld) + color.G = 0; + else + color.R = 0; + } - color.A /= 4; + color.A /= 4; - int fadeTime = 30; - if (projectile.timeLeft < fadeTime) - { - float amount2 = projectile.timeLeft / (float)fadeTime; + int fadeTime = 30; + if (projectile.timeLeft < fadeTime) + { + float amount2 = projectile.timeLeft / (float)fadeTime; - if (color.R > 0) - color.R = (byte)MathHelper.Lerp(0, color.R, amount2); - if (color.G > 0) - color.G = (byte)MathHelper.Lerp(0, color.G, amount2); - if (color.B > 0) - color.B = (byte)MathHelper.Lerp(0, color.B, amount2); + if (color.R > 0) + color.R = (byte)MathHelper.Lerp(0, color.R, amount2); + if (color.G > 0) + color.G = (byte)MathHelper.Lerp(0, color.G, amount2); + if (color.B > 0) + color.B = (byte)MathHelper.Lerp(0, color.B, amount2); - color.A = (byte)MathHelper.Lerp(0, color.A, amount2); - } + color.A = (byte)MathHelper.Lerp(0, color.A, amount2); + } - float rotation = MathHelper.PiOver2 + timeScalar * MathHelper.PiOver4 * -0.3f + (float)Math.PI * i; + float rotation = MathHelper.PiOver2 + timeScalar * MathHelper.PiOver4 * -0.3f + (float)Math.PI * i; - spriteBatch.Draw(texture, drawPosition + new Vector2(posX[i], posY[i]), null, color, rotation, origin, new Vector2(size[i], size[i]) * scale, SpriteEffects.None, 0); - } + spriteBatch.Draw(texture, drawPosition + new Vector2(posX[i], posY[i]), null, color, rotation, origin, new Vector2(size[i], size[i]) * scale, SpriteEffects.None, 0); + } - return false; - } - } + return false; + } + } } diff --git a/Projectiles/Boss/HolyBlast.cs b/Projectiles/Boss/HolyBlast.cs index f2d11a24d4..f574a34143 100644 --- a/Projectiles/Boss/HolyBlast.cs +++ b/Projectiles/Boss/HolyBlast.cs @@ -21,15 +21,15 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 180; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 180; projectile.height = 180; projectile.hostile = true; projectile.penetrate = 1; projectile.timeLeft = 120; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -49,8 +49,8 @@ namespace CalamityMod.Projectiles.Boss } if (projectile.ai[1] == 0f) { - int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; - for (int num621 = 0; num621 < 10; num621++) + int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num621 = 0; num621 < 10; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; @@ -100,18 +100,18 @@ namespace CalamityMod.Projectiles.Boss double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; - float velocity = 5f; - int totalProjectiles = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 5 : 4; - int type = ModContent.ProjectileType(); - int damage = (int)Math.Round(projectile.damage * 0.75); - for (int i = 0; i < totalProjectiles; i++) + float velocity = 5f; + int totalProjectiles = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 5 : 4; + int type = ModContent.ProjectileType(); + int damage = (int)Math.Round(projectile.damage * 0.75); + for (int i = 0; i < totalProjectiles; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; Projectile.NewProjectile(shootFromVector.X, shootFromVector.Y, (float)(Math.Sin(offsetAngle) * velocity), (float)(Math.Cos(offsetAngle) * velocity), type, damage, 0f, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(shootFromVector.X, shootFromVector.Y, (float)(-Math.Sin(offsetAngle) * velocity), (float)(-Math.Cos(offsetAngle) * velocity), type, damage, 0f, Main.myPlayer, 0f, 0f); } } - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceHolyBlastImpact"), projectile.Center); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ProvidenceHolyBlastImpact"), projectile.Center); int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; for (int num193 = 0; num193 < 4; num193++) { @@ -130,13 +130,13 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(buffType, 240); - } + int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 240); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/HolyBomb.cs b/Projectiles/Boss/HolyBomb.cs index 2875ea2dca..733c4bc343 100644 --- a/Projectiles/Boss/HolyBomb.cs +++ b/Projectiles/Boss/HolyBomb.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.tileCollide = false; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -81,15 +81,15 @@ namespace CalamityMod.Projectiles.Boss } } - public override Color? GetAlpha(Color lightColor) - { - return ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture2D13 = ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/HolyBombNight"); - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); return false; @@ -104,8 +104,8 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 150; projectile.position.X = projectile.position.X - (projectile.width / 2); projectile.position.Y = projectile.position.Y - (projectile.height / 2); - int dustType = ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; - for (int num193 = 0; num193 < 2; num193++) + int dustType = ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num193 = 0; num193 < 2; num193++) { Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 50, default, 1.5f); } @@ -122,13 +122,13 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - int buffType = ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(buffType, 180); - } + int buffType = ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 180); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/HolyBurnOrb.cs b/Projectiles/Boss/HolyBurnOrb.cs index ab38e1e0d2..bc12af3148 100644 --- a/Projectiles/Boss/HolyBurnOrb.cs +++ b/Projectiles/Boss/HolyBurnOrb.cs @@ -27,16 +27,16 @@ namespace CalamityMod.Projectiles.Boss projectile.ignoreWater = true; projectile.tileCollide = false; projectile.alpha = 255; - cooldownSlot = 1; - projectile.penetrate = 1; + cooldownSlot = 1; + projectile.penetrate = 1; projectile.timeLeft = 200; - projectile.Calamity().canBreakPlayerDefense = true; - } + projectile.Calamity().canBreakPlayerDefense = true; + } public override void AI() { - if (projectile.ai[0] == 0f && (CalamityWorld.malice || BossRushEvent.BossRushActive)) - projectile.velocity *= 1.25f; + if (projectile.ai[0] == 0f && (CalamityWorld.malice || BossRushEvent.BossRushActive)) + projectile.velocity *= 1.25f; if (projectile.ai[0] < 240f) { @@ -115,12 +115,12 @@ namespace CalamityMod.Projectiles.Boss { int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); target.AddBuff(buffType, 180); - projectile.Kill(); + projectile.Kill(); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/HolyExplosionBoom.cs b/Projectiles/Boss/HolyExplosionBoom.cs index 004f649224..80545d0bb4 100644 --- a/Projectiles/Boss/HolyExplosionBoom.cs +++ b/Projectiles/Boss/HolyExplosionBoom.cs @@ -4,34 +4,34 @@ using Terraria; namespace CalamityMod.Projectiles.Boss { - public class HolyExplosionBoom : BaseMassiveExplosionProjectile - { - public override int Lifetime => 60; - public override bool UsesScreenshake => true; - public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 16f; - public override Color GetCurrentExplosionColor(float pulseCompletionRatio) + public class HolyExplosionBoom : BaseMassiveExplosionProjectile + { + public override int Lifetime => 60; + public override bool UsesScreenshake => true; + public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 16f; + public override Color GetCurrentExplosionColor(float pulseCompletionRatio) { - Color explosionColor = Main.dayTime ? Color.Orange : Color.BlueViolet; - return Color.Lerp(explosionColor * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f)); - } - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + Color explosionColor = Main.dayTime ? Color.Orange : Color.BlueViolet; + return Color.Lerp(explosionColor * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f)); + } + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() => DisplayName.SetDefault("Holy Explosion"); + public override void SetStaticDefaults() => DisplayName.SetDefault("Holy Explosion"); - public override void SetDefaults() - { - projectile.width = projectile.height = 2; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.timeLeft = Lifetime; - cooldownSlot = 1; - } - - public override void PostAI() + public override void SetDefaults() { - MaxRadius = 3000f; - Lighting.AddLight(projectile.Center, 0.1f, 0.1f, 0.1f); - } - } + projectile.width = projectile.height = 2; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = Lifetime; + cooldownSlot = 1; + } + + public override void PostAI() + { + MaxRadius = 3000f; + Lighting.AddLight(projectile.Center, 0.1f, 0.1f, 0.1f); + } + } } diff --git a/Projectiles/Boss/HolyFire.cs b/Projectiles/Boss/HolyFire.cs index 32bcacaf1c..c5f6f83c21 100644 --- a/Projectiles/Boss/HolyFire.cs +++ b/Projectiles/Boss/HolyFire.cs @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Boss projectile.aiStyle = 1; projectile.tileCollide = false; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -56,15 +56,15 @@ namespace CalamityMod.Projectiles.Boss } } - public override Color? GetAlpha(Color lightColor) - { - return (Main.dayTime && !CalamityWorld.malice) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return (Main.dayTime && !CalamityWorld.malice) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture2D13 = (Main.dayTime && !CalamityWorld.malice) ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/HolyFireNight"); - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); return false; @@ -96,8 +96,8 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 150; projectile.position.X = projectile.position.X - (projectile.width / 2); projectile.position.Y = projectile.position.Y - (projectile.height / 2); - int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; - for (int num621 = 0; num621 < 5; num621++) + int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num621 = 0; num621 < 5; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); if (Main.rand.NextBool(2)) @@ -116,13 +116,13 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(buffType, 120); - } + int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 120); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/HolyFire2.cs b/Projectiles/Boss/HolyFire2.cs index 05fe4a9b8b..412ac64605 100644 --- a/Projectiles/Boss/HolyFire2.cs +++ b/Projectiles/Boss/HolyFire2.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Boss projectile.tileCollide = false; projectile.timeLeft = 600; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -50,10 +50,10 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity.X *= 1.05f; } int num103 = Player.FindClosest(projectile.Center, 1, 1); - if (projectile.ai[1] == 0f) - { - projectile.damage = projectile.GetProjectileDamage(ModContent.NPCType()); - } + if (projectile.ai[1] == 0f) + { + projectile.damage = projectile.GetProjectileDamage(ModContent.NPCType()); + } projectile.ai[1] += 1f; if (projectile.ai[1] < 180f && projectile.ai[1] > 60f) { @@ -61,22 +61,22 @@ namespace CalamityMod.Projectiles.Boss Vector2 vector11 = Main.player[num103].Center - projectile.Center; vector11.Normalize(); vector11 *= scaleFactor2; - float inertia = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 20f : 25f; - projectile.velocity = (projectile.velocity * (inertia - 1f) + vector11) / inertia; + float inertia = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 20f : 25f; + projectile.velocity = (projectile.velocity * (inertia - 1f) + vector11) / inertia; projectile.velocity.Normalize(); projectile.velocity *= scaleFactor2; } } - public override Color? GetAlpha(Color lightColor) - { - return (Main.dayTime && !CalamityWorld.malice) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return (Main.dayTime && !CalamityWorld.malice) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture2D13 = (Main.dayTime && !CalamityWorld.malice) ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/HolyFire2Night"); - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); return false; @@ -91,8 +91,8 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 150; projectile.position.X = projectile.position.X - (projectile.width / 2); projectile.position.Y = projectile.position.Y - (projectile.height / 2); - int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; - for (int num621 = 0; num621 < 5; num621++) + int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num621 = 0; num621 < 5; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); if (Main.rand.NextBool(2)) @@ -111,13 +111,13 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(buffType, 120); - } + int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 120); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/HolyFlare.cs b/Projectiles/Boss/HolyFlare.cs index 597043dfe7..264cbc2a2e 100644 --- a/Projectiles/Boss/HolyFlare.cs +++ b/Projectiles/Boss/HolyFlare.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Boss projectile.extraUpdates = 1; projectile.timeLeft = 840; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -46,12 +46,12 @@ namespace CalamityMod.Projectiles.Boss if (projectile.frame > 3) projectile.frame = 0; - float velocityYCap = projectile.position.Y + projectile.height < player.position.Y ? 1f : 0.25f; - projectile.velocity.Y += 0.01f; + float velocityYCap = projectile.position.Y + projectile.height < player.position.Y ? 1f : 0.25f; + projectile.velocity.Y += 0.01f; if (projectile.velocity.Y > velocityYCap) projectile.velocity.Y = velocityYCap; - float velocityX = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 0.025f : 0.02f; + float velocityX = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 0.025f : 0.02f; if (projectile.position.X + projectile.width < player.position.X) { if (projectile.velocity.X < 0f) @@ -65,22 +65,22 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity.X -= velocityX; } - float velocityXCap = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 10f : 8f; + float velocityXCap = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 10f : 8f; if (projectile.velocity.X > velocityXCap || projectile.velocity.X < -velocityXCap) projectile.velocity.X *= 0.97f; projectile.rotation = projectile.velocity.X * 0.025f; } - public override Color? GetAlpha(Color lightColor) - { - return ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture2D13 = ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/HolyFlareNight"); - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); return false; @@ -95,8 +95,8 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 50; projectile.position.X = projectile.position.X - (projectile.width / 2); projectile.position.Y = projectile.position.Y - (projectile.height / 2); - int dustType = ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; - for (int num621 = 0; num621 < 5; num621++) + int dustType = ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num621 = 0; num621 < 5; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); if (Main.rand.NextBool(2)) @@ -115,13 +115,13 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - int buffType = ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(buffType, 120); - } + int buffType = ((Main.dayTime && !CalamityWorld.malice) || !NPC.AnyNPCs(ModContent.NPCType())) ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 120); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/HolyLight.cs b/Projectiles/Boss/HolyLight.cs index 046515bef3..af3bbd0267 100644 --- a/Projectiles/Boss/HolyLight.cs +++ b/Projectiles/Boss/HolyLight.cs @@ -23,34 +23,34 @@ namespace CalamityMod.Projectiles.Boss projectile.hostile = true; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.alpha = 255; + projectile.alpha = 255; projectile.penetrate = 1; projectile.timeLeft = 200; } public override void AI() { - if (projectile.ai[0] < 240f) - { - projectile.ai[0] += 1f; + if (projectile.ai[0] < 240f) + { + projectile.ai[0] += 1f; - if (projectile.timeLeft < 160) - projectile.timeLeft = 160; - } + if (projectile.timeLeft < 160) + projectile.timeLeft = 160; + } - if (projectile.velocity.Length() < 16f) - projectile.velocity *= 1.01f; + if (projectile.velocity.Length() < 16f) + projectile.velocity *= 1.01f; - int index = Player.FindClosest(projectile.position, projectile.width, projectile.height); - Player player = Main.player[index]; - if (player is null) - return; + int index = Player.FindClosest(projectile.position, projectile.width, projectile.height); + Player player = Main.player[index]; + if (player is null) + return; - float playerDist = Vector2.Distance(player.Center, projectile.Center); - if (!player.immune && playerDist < 50f && !player.dead && 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) + float playerDist = Vector2.Distance(player.Center, projectile.Center); + if (!player.immune && playerDist < 50f && !player.dead && 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) { int healAmt = (int)projectile.ai[1]; - player.HealEffect(healAmt, false); + player.HealEffect(healAmt, false); player.statLife += healAmt; if (player.statLife > player.statLifeMax2) { @@ -61,41 +61,41 @@ namespace CalamityMod.Projectiles.Boss } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D value = Main.projectileTexture[projectile.type]; - Color color33 = new Color(54, 209, 54, 0); - Vector2 vector28 = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - Color color34 = color33; - Vector2 origin5 = value.Size() / 2f; - Color color35 = color33 * 0.5f; - float num162 = Utils.InverseLerp(15f, 30f, projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; - Vector2 vector29 = new Vector2(0.5f, 1f) * num162; - Vector2 vector30 = new Vector2(0.5f, 1f) * num162; - color34 *= num162; - color35 *= num162; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D value = Main.projectileTexture[projectile.type]; + Color color33 = new Color(54, 209, 54, 0); + Vector2 vector28 = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Color color34 = color33; + Vector2 origin5 = value.Size() / 2f; + Color color35 = color33 * 0.5f; + float num162 = Utils.InverseLerp(15f, 30f, projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; + Vector2 vector29 = new Vector2(0.5f, 1f) * num162; + Vector2 vector30 = new Vector2(0.5f, 1f) * num162; + color34 *= num162; + color35 *= num162; - int num163 = 0; - Vector2 position3 = vector28 + projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.InverseLerp(0.5f, 1f, projectile.localAI[0] / 60f, clamped: true) * num163; + int num163 = 0; + Vector2 position3 = vector28 + projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.InverseLerp(0.5f, 1f, projectile.localAI[0] / 60f, clamped: true) * num163; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(value, position3, null, color34, (float)Math.PI / 2f, origin5, vector29, spriteEffects, 0); - spriteBatch.Draw(value, position3, null, color34, 0f, origin5, vector30, spriteEffects, 0); - spriteBatch.Draw(value, position3, null, color35, (float)Math.PI / 2f, origin5, vector29 * 0.6f, spriteEffects, 0); - spriteBatch.Draw(value, position3, null, color35, 0f, origin5, vector30 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color34, (float)Math.PI / 2f, origin5, vector29, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color34, 0f, origin5, vector30, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, (float)Math.PI / 2f, origin5, vector29 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, 0f, origin5, vector30 * 0.6f, spriteEffects, 0); - spriteBatch.Draw(value, position3, null, color34, MathHelper.PiOver4, origin5, vector29 * 0.6f, spriteEffects, 0); - spriteBatch.Draw(value, position3, null, color34, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.6f, spriteEffects, 0); - spriteBatch.Draw(value, position3, null, color35, MathHelper.PiOver4, origin5, vector29 * 0.36f, spriteEffects, 0); - spriteBatch.Draw(value, position3, null, color35, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.36f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color34, MathHelper.PiOver4, origin5, vector29 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color34, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, MathHelper.PiOver4, origin5, vector29 * 0.36f, spriteEffects, 0); + spriteBatch.Draw(value, position3, null, color35, MathHelper.PiOver4 * 3f, origin5, vector30 * 0.36f, spriteEffects, 0); - return false; - } + return false; + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.Center); projectile.position.X = projectile.position.X + (projectile.width / 2); diff --git a/Projectiles/Boss/HolySpear.cs b/Projectiles/Boss/HolySpear.cs index 325bcca6bc..4cf4f31e20 100644 --- a/Projectiles/Boss/HolySpear.cs +++ b/Projectiles/Boss/HolySpear.cs @@ -11,9 +11,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class HolySpear : ModProjectile + public class HolySpear : ModProjectile { - Vector2 velocity = Vector2.Zero; + Vector2 velocity = Vector2.Zero; public override void SetStaticDefaults() { @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 30; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 30; projectile.height = 30; projectile.hostile = true; projectile.ignoreWater = true; @@ -33,154 +33,154 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.timeLeft = 200; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(projectile.localAI[0]); writer.Write(projectile.localAI[1]); - writer.WriteVector2(velocity); - } + writer.WriteVector2(velocity); + } public override void ReceiveExtraAI(BinaryReader reader) { projectile.localAI[0] = reader.ReadSingle(); projectile.localAI[1] = reader.ReadSingle(); - velocity = reader.ReadVector2(); - } + velocity = reader.ReadVector2(); + } public override void AI() { - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; - if (projectile.ai[0] == 1f) - velocity = projectile.velocity; - } + if (projectile.ai[0] == 1f) + velocity = projectile.velocity; + } - float timeGateValue = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 420f : 540f; - if (projectile.ai[0] == 0f) - { - projectile.ai[1] += 1f; + float timeGateValue = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 420f : 540f; + if (projectile.ai[0] == 0f) + { + projectile.ai[1] += 1f; - float slowGateValue = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 60f : 90f; - float fastGateValue = 30f; - float minVelocity = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 4f : 3f; - float maxVelocity = minVelocity * 4f; - float extremeVelocity = maxVelocity * 2f; - float deceleration = 0.95f; - float acceleration = 1.2f; + float slowGateValue = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 60f : 90f; + float fastGateValue = 30f; + float minVelocity = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 4f : 3f; + float maxVelocity = minVelocity * 4f; + float extremeVelocity = maxVelocity * 2f; + float deceleration = 0.95f; + float acceleration = 1.2f; - if (projectile.localAI[1] >= timeGateValue) - { - if (projectile.velocity.Length() < extremeVelocity) - projectile.velocity *= acceleration; - } - else - { - 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; - } - } - else - { - float frequency = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 0.2f : 0.1f; - float amplitude = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 4f : 2f; + if (projectile.localAI[1] >= timeGateValue) + { + if (projectile.velocity.Length() < extremeVelocity) + projectile.velocity *= acceleration; + } + else + { + 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; + } + } + else + { + float frequency = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 0.2f : 0.1f; + float amplitude = (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 4f : 2f; - projectile.ai[1] += frequency; + projectile.ai[1] += frequency; - float wavyVelocity = (float)Math.Sin(projectile.ai[1]); + float wavyVelocity = (float)Math.Sin(projectile.ai[1]); - projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity).RotatedBy(MathHelper.ToRadians(velocity.ToRotation())) * amplitude; - } + projectile.velocity = velocity + new Vector2(wavyVelocity, wavyVelocity).RotatedBy(MathHelper.ToRadians(velocity.ToRotation())) * amplitude; + } - if (projectile.localAI[1] < timeGateValue) - { - projectile.localAI[1] += 1f; + if (projectile.localAI[1] < timeGateValue) + { + projectile.localAI[1] += 1f; - if (projectile.timeLeft < 160) - projectile.timeLeft = 160; - } + if (projectile.timeLeft < 160) + projectile.timeLeft = 160; + } - projectile.Opacity = MathHelper.Lerp(240f, 220f, projectile.timeLeft); + projectile.Opacity = MathHelper.Lerp(240f, 220f, projectile.timeLeft); - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D value = Main.projectileTexture[projectile.type]; - int green = projectile.ai[0] != 0f ? 255 : 125; - int blue = projectile.ai[0] != 0f ? 0 : 125; - Color baseColor = new Color(255, green, blue, 255); + Texture2D value = Main.projectileTexture[projectile.type]; + int green = projectile.ai[0] != 0f ? 255 : 125; + int blue = projectile.ai[0] != 0f ? 0 : 125; + Color baseColor = new Color(255, green, blue, 255); - if (!Main.dayTime || CalamityWorld.malice) - { - int red = projectile.ai[0] != 0f ? 100 : 175; - green = projectile.ai[0] != 0f ? 255 : 175; - baseColor = new Color(red, green, 255, 255); - } + if (!Main.dayTime || CalamityWorld.malice) + { + int red = projectile.ai[0] != 0f ? 100 : 175; + green = projectile.ai[0] != 0f ? 255 : 175; + baseColor = new Color(red, green, 255, 255); + } - Color color33 = baseColor * 0.5f; - color33.A = 0; - Vector2 vector28 = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - Color color34 = color33; - Vector2 origin5 = value.Size() / 2f; - Color color35 = color33 * 0.5f; - float num162 = Utils.InverseLerp(15f, 30f, projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; - Vector2 vector29 = new Vector2(1f, 1.5f) * num162; - Vector2 vector30 = new Vector2(0.5f, 1f) * num162; - color34 *= num162; - color35 *= num162; + Color color33 = baseColor * 0.5f; + color33.A = 0; + Vector2 vector28 = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Color color34 = color33; + Vector2 origin5 = value.Size() / 2f; + Color color35 = color33 * 0.5f; + float num162 = Utils.InverseLerp(15f, 30f, projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; + Vector2 vector29 = new Vector2(1f, 1.5f) * num162; + Vector2 vector30 = new Vector2(0.5f, 1f) * num162; + color34 *= num162; + color35 *= num162; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - if (CalamityConfig.Instance.Afterimages) - { - for (int i = 0; i < projectile.oldPos.Length; i++) - { - Vector2 drawPos = projectile.oldPos[i] + vector28; - Color color = projectile.GetAlpha(color34) * ((projectile.oldPos.Length - i) / projectile.oldPos.Length); - Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector29, spriteEffects, 0f); - Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector30, spriteEffects, 0f); + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 0; i < projectile.oldPos.Length; i++) + { + Vector2 drawPos = projectile.oldPos[i] + vector28; + Color color = projectile.GetAlpha(color34) * ((projectile.oldPos.Length - i) / projectile.oldPos.Length); + Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector29, spriteEffects, 0f); + Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector30, spriteEffects, 0f); - color = projectile.GetAlpha(color35) * ((projectile.oldPos.Length - i) / projectile.oldPos.Length); - Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector29 * 0.6f, spriteEffects, 0f); - Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector30 * 0.6f, spriteEffects, 0f); - } - } + color = projectile.GetAlpha(color35) * ((projectile.oldPos.Length - i) / projectile.oldPos.Length); + Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector29 * 0.6f, spriteEffects, 0f); + Main.spriteBatch.Draw(value, drawPos, null, color, projectile.rotation, origin5, vector30 * 0.6f, spriteEffects, 0f); + } + } - spriteBatch.Draw(value, vector28, null, color34, projectile.rotation, origin5, vector29, spriteEffects, 0); - spriteBatch.Draw(value, vector28, null, color34, projectile.rotation, origin5, vector30, spriteEffects, 0); - spriteBatch.Draw(value, vector28, null, color35, projectile.rotation, origin5, vector29 * 0.6f, spriteEffects, 0); - spriteBatch.Draw(value, vector28, null, color35, projectile.rotation, origin5, vector30 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, vector28, null, color34, projectile.rotation, origin5, vector29, spriteEffects, 0); + spriteBatch.Draw(value, vector28, null, color34, projectile.rotation, origin5, vector30, spriteEffects, 0); + spriteBatch.Draw(value, vector28, null, color35, projectile.rotation, origin5, vector29 * 0.6f, spriteEffects, 0); + spriteBatch.Draw(value, vector28, null, color35, projectile.rotation, origin5, vector30 * 0.6f, spriteEffects, 0); - return false; + return false; } public override void OnHitPlayer(Player target, int damage, bool crit) { - int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(buffType, 180); - } + int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 180); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/IceBlast.cs b/Projectiles/Boss/IceBlast.cs index a7d08fc10b..d9ef369c25 100644 --- a/Projectiles/Boss/IceBlast.cs +++ b/Projectiles/Boss/IceBlast.cs @@ -20,9 +20,9 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 10; projectile.penetrate = -1; projectile.hostile = true; - projectile.timeLeft = 300; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.timeLeft = 300; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -38,34 +38,34 @@ namespace CalamityMod.Projectiles.Boss dust.velocity *= 0.3f; } - if (projectile.localAI[0] == 0f) - { - projectile.scale += 0.01f; - projectile.alpha -= 50; - if (projectile.alpha <= 0) - { - projectile.localAI[0] = 1f; - projectile.alpha = 0; - } - } - else - { - projectile.scale -= 0.01f; - projectile.alpha += 50; - if (projectile.alpha >= 255) - { - projectile.localAI[0] = 0f; - projectile.alpha = 255; - } - } - } + if (projectile.localAI[0] == 0f) + { + projectile.scale += 0.01f; + projectile.alpha -= 50; + if (projectile.alpha <= 0) + { + projectile.localAI[0] = 1f; + projectile.alpha = 0; + } + } + else + { + projectile.scale -= 0.01f; + projectile.alpha += 50; + if (projectile.alpha >= 255) + { + projectile.localAI[0] = 0f; + projectile.alpha = 255; + } + } + } - public override Color? GetAlpha(Color lightColor) - { - return Main.dayTime ? new Color(50, 50, 255, projectile.alpha) : new Color(255, 255, 255, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return Main.dayTime ? new Color(50, 50, 255, projectile.alpha) : new Color(255, 255, 255, projectile.alpha); + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { int num497 = 5; Main.PlaySound(SoundID.Item27, projectile.position); diff --git a/Projectiles/Boss/IceBomb.cs b/Projectiles/Boss/IceBomb.cs index 9200ef0619..0fc1ac29f9 100644 --- a/Projectiles/Boss/IceBomb.cs +++ b/Projectiles/Boss/IceBomb.cs @@ -18,96 +18,96 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 30; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 30; projectile.height = 30; - projectile.scale = 0.5f; + projectile.scale = 0.5f; projectile.hostile = true; projectile.penetrate = 1; projectile.timeLeft = 300; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } - public override bool CanHitPlayer(Player target) => projectile.ai[0] >= 120f; + public override bool CanHitPlayer(Player target) => projectile.ai[0] >= 120f; - public override void AI() - { - projectile.velocity *= 0.99f; + public override void AI() + { + projectile.velocity *= 0.99f; - if (projectile.localAI[0] == 0f) - { - projectile.scale += 0.01f; - projectile.alpha -= 50; - if (projectile.alpha <= 0) - { - projectile.localAI[0] = 1f; - projectile.alpha = 0; - } - } - else - { - projectile.scale -= 0.01f; - projectile.alpha += 50; - if (projectile.alpha >= 255) - { - projectile.localAI[0] = 0f; - projectile.alpha = 255; - } - } + if (projectile.localAI[0] == 0f) + { + projectile.scale += 0.01f; + projectile.alpha -= 50; + if (projectile.alpha <= 0) + { + projectile.localAI[0] = 1f; + projectile.alpha = 0; + } + } + else + { + projectile.scale -= 0.01f; + projectile.alpha += 50; + if (projectile.alpha >= 255) + { + projectile.localAI[0] = 0f; + projectile.alpha = 255; + } + } - if (projectile.ai[0] < 120f) - { - projectile.ai[0] += 1f; - if (projectile.ai[0] == 120f) - { - for (int num621 = 0; num621 < 8; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 14; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } + if (projectile.ai[0] < 120f) + { + projectile.ai[0] += 1f; + if (projectile.ai[0] == 120f) + { + for (int num621 = 0; num621 < 8; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 14; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } - projectile.scale = 1f; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(30f * projectile.scale)); - Main.PlaySound(SoundID.Item30, projectile.Center); - } - } - } + projectile.scale = 1f; + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(30f * projectile.scale)); + Main.PlaySound(SoundID.Item30, projectile.Center); + } + } + } - public override Color? GetAlpha(Color lightColor) - { - return Main.dayTime ? new Color(50, 50, 255, projectile.alpha) : new Color(255, 255, 255, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return Main.dayTime ? new Color(50, 50, 255, projectile.alpha) : new Color(255, 255, 255, projectile.alpha); + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item27, projectile.position); if (projectile.owner == Main.myPlayer) { - int totalProjectiles = (CalamityWorld.revenge || BossRushEvent.BossRushActive ? 3 : 2) + (int)projectile.ai[1]; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - int damage = (int)Math.Round(projectile.damage * 0.75); - float velocity = CalamityWorld.revenge || BossRushEvent.BossRushActive ? 7f : 6f; - Vector2 spinningPoint = new Vector2(0f, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(projectile.Center, vector255, type, damage, 0f, projectile.owner, 1f, 0f); - } + int totalProjectiles = (CalamityWorld.revenge || BossRushEvent.BossRushActive ? 3 : 2) + (int)projectile.ai[1]; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + int damage = (int)Math.Round(projectile.damage * 0.75); + float velocity = CalamityWorld.revenge || BossRushEvent.BossRushActive ? 7f : 6f; + Vector2 spinningPoint = new Vector2(0f, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(projectile.Center, vector255, type, damage, 0f, projectile.owner, 1f, 0f); + } } for (int k = 0; k < 10; k++) @@ -116,12 +116,12 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.ai[0] >= 120f) - { - target.AddBuff(BuffID.Frostburn, 120, true); - target.AddBuff(BuffID.Chilled, 90, true); - target.AddBuff(ModContent.BuffType(), 60); - } + if (projectile.ai[0] >= 120f) + { + target.AddBuff(BuffID.Frostburn, 120, true); + target.AddBuff(BuffID.Chilled, 90, true); + target.AddBuff(ModContent.BuffType(), 60); + } } } } diff --git a/Projectiles/Boss/IceRain.cs b/Projectiles/Boss/IceRain.cs index 919add3fe6..3ebc17e9f0 100644 --- a/Projectiles/Boss/IceRain.cs +++ b/Projectiles/Boss/IceRain.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 10; projectile.hostile = true; projectile.penetrate = -1; - projectile.timeLeft = 300; + projectile.timeLeft = 300; } public override void SendExtraAI(BinaryWriter writer) @@ -37,64 +37,64 @@ namespace CalamityMod.Projectiles.Boss { Lighting.AddLight((int)((projectile.position.X + (projectile.width / 2)) / 16f), (int)((projectile.position.Y + (projectile.height / 2)) / 16f), 0f, 0.25f, 0.25f); - if (projectile.ai[0] == 0f) - { - if (projectile.velocity.Length() < projectile.ai[1]) - projectile.velocity *= 1.015f; + if (projectile.ai[0] == 0f) + { + if (projectile.velocity.Length() < projectile.ai[1]) + projectile.velocity *= 1.015f; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - for (int num322 = 0; num322 < 2; num322++) - { - int num323 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 92, projectile.velocity.X, projectile.velocity.Y, 50, default, 0.6f); - Main.dust[num323].noGravity = true; - Dust dust = Main.dust[num323]; - dust.velocity *= 0.3f; - } - } - else if (projectile.ai[0] == 1f) - { - projectile.aiStyle = 1; + for (int num322 = 0; num322 < 2; num322++) + { + int num323 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 92, projectile.velocity.X, projectile.velocity.Y, 50, default, 0.6f); + Main.dust[num323].noGravity = true; + Dust dust = Main.dust[num323]; + dust.velocity *= 0.3f; + } + } + else if (projectile.ai[0] == 1f) + { + projectile.aiStyle = 1; - for (int num322 = 0; num322 < 2; num322++) - { - int num323 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 92, projectile.velocity.X, projectile.velocity.Y, 50, default, 0.6f); - Main.dust[num323].noGravity = true; - Dust dust = Main.dust[num323]; - dust.velocity *= 0.3f; - } - } - else if (projectile.ai[0] == 2f) - { - projectile.velocity.Y += 0.1f; + for (int num322 = 0; num322 < 2; num322++) + { + int num323 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 92, projectile.velocity.X, projectile.velocity.Y, 50, default, 0.6f); + Main.dust[num323].noGravity = true; + Dust dust = Main.dust[num323]; + dust.velocity *= 0.3f; + } + } + else if (projectile.ai[0] == 2f) + { + projectile.velocity.Y += 0.1f; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - if (projectile.velocity.Y > 6f) - projectile.velocity.Y = 6f; - } + if (projectile.velocity.Y > 6f) + projectile.velocity.Y = 6f; + } - if (projectile.localAI[0] == 0f) - { - projectile.scale += 0.01f; - projectile.alpha -= 50; - if (projectile.alpha <= 0) - { - projectile.localAI[0] = 1f; - projectile.alpha = 0; - } - } - else - { - projectile.scale -= 0.01f; - projectile.alpha += 50; - if (projectile.alpha >= 255) - { - projectile.localAI[0] = 0f; - projectile.alpha = 255; - } - } - } + if (projectile.localAI[0] == 0f) + { + projectile.scale += 0.01f; + projectile.alpha -= 50; + if (projectile.alpha <= 0) + { + projectile.localAI[0] = 1f; + projectile.alpha = 0; + } + } + else + { + projectile.scale -= 0.01f; + projectile.alpha += 50; + if (projectile.alpha >= 255) + { + projectile.localAI[0] = 0f; + projectile.alpha = 255; + } + } + } public override Color? GetAlpha(Color lightColor) { @@ -103,7 +103,7 @@ namespace CalamityMod.Projectiles.Boss public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 27, 0.25f); + Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 27, 0.25f); 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/IchorBlob.cs b/Projectiles/Boss/IchorBlob.cs index beacb15e27..649617c23c 100644 --- a/Projectiles/Boss/IchorBlob.cs +++ b/Projectiles/Boss/IchorBlob.cs @@ -10,183 +10,183 @@ namespace CalamityMod.Projectiles.Boss { public class IchorBlob : ModProjectile { - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Ichor Blob"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; ProjectileID.Sets.TrailingMode[projectile.type] = 0; - Main.projFrames[projectile.type] = 6; - } + Main.projFrames[projectile.type] = 6; + } public override void SetDefaults() { - projectile.width = 52; + projectile.width = 52; projectile.height = 56; projectile.hostile = true; projectile.ignoreWater = true; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.penetrate = -1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(projectile.localAI[0]); - writer.Write(projectile.localAI[1]); - } + writer.Write(projectile.localAI[1]); + } public override void ReceiveExtraAI(BinaryReader reader) { projectile.localAI[0] = reader.ReadSingle(); - projectile.localAI[1] = reader.ReadSingle(); - } + projectile.localAI[1] = reader.ReadSingle(); + } public override void AI() { - if (projectile.position.Y > projectile.ai[1] - 32f) - projectile.tileCollide = true; + if (projectile.position.Y > projectile.ai[1] - 32f) + projectile.tileCollide = true; - // Deal no damage and increment the variable used to kill the projectile after 15 seconds - projectile.localAI[1] += 1f; + // Deal no damage and increment the variable used to kill the projectile after 15 seconds + projectile.localAI[1] += 1f; if (projectile.localAI[1] > 900f) - { + { projectile.localAI[0] += 10f; - projectile.damage = 0; - } + projectile.damage = 0; + } - // Kill the projectile 26 frames after it stops dealing damage + // Kill the projectile 26 frames after it stops dealing damage if (projectile.localAI[0] > 255f) { projectile.Kill(); projectile.localAI[0] = 255f; } - // Add yellow light based on alpha + // Add yellow light based on alpha Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.16f / 255f, (255 - projectile.alpha) * 0.04f / 255f); - // Adjust projectile visibility based on the kill timer + // Adjust projectile visibility based on the kill timer projectile.alpha = (int)(100.0 + projectile.localAI[0] * 0.7); - if (projectile.velocity.Y != 0f && projectile.ai[0] == 0f) - { - // Rotate based on velocity, only do this here, because it's falling - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; + if (projectile.velocity.Y != 0f && projectile.ai[0] == 0f) + { + // Rotate based on velocity, only do this here, because it's falling + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; - projectile.frameCounter++; - if (projectile.frameCounter > 6) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 1) - projectile.frame = 0; - } - else - { - // Prevent sliding - projectile.velocity.X = 0f; + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 1) + projectile.frame = 0; + } + else + { + // Prevent sliding + projectile.velocity.X = 0f; - // Do not animate falling frames - projectile.ai[0] = 1f; + // Do not animate falling frames + projectile.ai[0] = 1f; - if (projectile.frame < 2) - { - // Set frame to blob and frame counter to 0 - projectile.frame = 2; - projectile.frameCounter = 0; + if (projectile.frame < 2) + { + // Set frame to blob and frame counter to 0 + projectile.frame = 2; + projectile.frameCounter = 0; - // Play squish sound - Main.PlaySound(SoundID.NPCDeath21, projectile.Center); + // Play squish sound + Main.PlaySound(SoundID.NPCDeath21, projectile.Center); - // Emit dust - float num50 = 1.6f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 value4 = value3 * projectile.velocity.Length(); - for (int num53 = 0; num53 < 10; num53++) - { - int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 170, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; - dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - dust.noGravity = true; - dust.velocity.Y -= 2f; - dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 170, 0f, 0f, 100, default, num51); - dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - dust.velocity.Y -= 2f; - dust.velocity *= 2f; - dust.noGravity = true; - dust.fadeIn = 1f; - dust.velocity += value4 * Main.rand.NextFloat(); - } - for (int num55 = 0; num55 < 5; num55++) - { - int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 170, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; - dust.position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; - dust.noGravity = true; - dust.velocity.Y -= 2f; - dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - } - } + // Emit dust + float num50 = 1.6f; + float num51 = 0.8f; + float num52 = 2f; + Vector2 value3 = (projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); + Vector2 value4 = value3 * projectile.velocity.Length(); + for (int num53 = 0; num53 < 10; num53++) + { + int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 170, 0f, 0f, 200, default, num50); + Dust dust = Main.dust[num54]; + dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + dust.noGravity = true; + dust.velocity.Y -= 2f; + dust.velocity *= 3f; + dust.velocity += value4 * Main.rand.NextFloat(); + num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 170, 0f, 0f, 100, default, num51); + dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + dust.velocity.Y -= 2f; + dust.velocity *= 2f; + dust.noGravity = true; + dust.fadeIn = 1f; + dust.velocity += value4 * Main.rand.NextFloat(); + } + for (int num55 = 0; num55 < 5; num55++) + { + int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 170, 0f, 0f, 0, default, num52); + Dust dust = Main.dust[num56]; + dust.position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; + dust.noGravity = true; + dust.velocity.Y -= 2f; + dust.velocity *= 0.5f; + dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); + } + } - projectile.rotation = 0f; + projectile.rotation = 0f; - projectile.frameCounter++; - if (projectile.frameCounter > 6) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 5) - projectile.frame = 5; - } + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 5) + projectile.frame = 5; + } - // Do velocity code after the frame code, to avoid messing anything up - // Reduce x velocity every frame - projectile.velocity.X *= 0.99f; + // Do velocity code after the frame code, to avoid messing anything up + // Reduce x velocity every frame + projectile.velocity.X *= 0.99f; - // Stop falling if water or lava is hit - if (projectile.wet || projectile.lavaWet) - { - projectile.velocity.Y = 0f; - } - else - { - // Fall - projectile.velocity.Y += 0.1f; - if (projectile.velocity.Y > 6f) - projectile.velocity.Y = 6f; - } - } + // Stop falling if water or lava is hit + if (projectile.wet || projectile.lavaWet) + { + projectile.velocity.Y = 0f; + } + else + { + // Fall + projectile.velocity.Y += 0.1f; + if (projectile.velocity.Y > 6f) + projectile.velocity.Y = 6f; + } + } - public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) - { - fallThrough = false; - return true; - } + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) + { + fallThrough = false; + return true; + } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 16f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.localAI[1] <= 900f && projectile.localAI[1] > 120f; + public override bool CanHitPlayer(Player target) => projectile.localAI[1] <= 900f && projectile.localAI[1] > 120f; - public override Color? GetAlpha(Color lightColor) - { - if (projectile.localAI[1] > 900f) - { - byte b2 = (byte)((26f - (projectile.localAI[1] - 900f)) * 10f); - byte a2 = (byte)(projectile.alpha * (b2 / 255f)); - return new Color(b2, b2, b2, a2); - } - return new Color(255, 255, 255, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + if (projectile.localAI[1] > 900f) + { + byte b2 = (byte)((26f - (projectile.localAI[1] - 900f)) * 10f); + byte a2 = (byte)(projectile.alpha * (b2 / 255f)); + return new Color(b2, b2, b2, a2); + } + return new Color(255, 255, 255, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); return false; @@ -194,8 +194,8 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.localAI[1] <= 900f && projectile.localAI[1] > 120f) - target.AddBuff(BuffID.Ichor, 240); + if (projectile.localAI[1] <= 900f && projectile.localAI[1] > 120f) + target.AddBuff(BuffID.Ichor, 240); } } } diff --git a/Projectiles/Boss/IchorShot.cs b/Projectiles/Boss/IchorShot.cs index 0fef693982..69a5eba1e3 100644 --- a/Projectiles/Boss/IchorShot.cs +++ b/Projectiles/Boss/IchorShot.cs @@ -26,10 +26,10 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - if (projectile.position.Y > projectile.ai[1]) - projectile.tileCollide = true; + if (projectile.position.Y > projectile.ai[1]) + projectile.tileCollide = true; - projectile.frameCounter++; + projectile.frameCounter++; if (projectile.frameCounter > 4) { projectile.frame++; @@ -53,9 +53,9 @@ namespace CalamityMod.Projectiles.Boss target.AddBuff(BuffID.Ichor, 180); } - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 200, 50, projectile.alpha); - } - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(200, 200, 50, projectile.alpha); + } + } } diff --git a/Projectiles/Boss/Infernado.cs b/Projectiles/Boss/Infernado.cs index 6026f9b7ed..72ab89fd2d 100644 --- a/Projectiles/Boss/Infernado.cs +++ b/Projectiles/Boss/Infernado.cs @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 320; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 320; projectile.height = 88; projectile.hostile = true; projectile.tileCollide = false; @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - float scaleBase = 36f; + float scaleBase = 36f; float scaleMult = 1.5f; float baseWidth = 320f; float baseHeight = 88f; @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Boss { projectile.localAI[0] = 1f; projectile.scale = (scaleBase - projectile.ai[1]) * scaleMult / scaleBase; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(baseWidth * projectile.scale), (int)(baseHeight * projectile.scale)); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(baseWidth * projectile.scale), (int)(baseHeight * projectile.scale)); projectile.netUpdate = true; } if (projectile.ai[1] != -1f) @@ -120,13 +120,13 @@ namespace CalamityMod.Projectiles.Boss projectile.position.X += num624 * -projectile.direction; } - if (projectile.timeLeft == 600) - projectile.damage = projectile.GetProjectileDamage(ModContent.NPCType()); - } + if (projectile.timeLeft == 600) + projectile.damage = projectile.GetProjectileDamage(ModContent.NPCType()); + } - public override bool CanHitPlayer(Player target) => projectile.timeLeft <= 600; + public override bool CanHitPlayer(Player target) => projectile.timeLeft <= 600; - public override Color? GetAlpha(Color lightColor) + public override Color? GetAlpha(Color lightColor) { return new Color(255, 255, 53, projectile.alpha); } @@ -140,15 +140,15 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.timeLeft <= 600) - target.AddBuff(ModContent.BuffType(), 420); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + if (projectile.timeLeft <= 600) + target.AddBuff(ModContent.BuffType(), 420); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/Infernado2.cs b/Projectiles/Boss/Infernado2.cs index 2696b09953..7314962449 100644 --- a/Projectiles/Boss/Infernado2.cs +++ b/Projectiles/Boss/Infernado2.cs @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 320; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 320; projectile.height = 88; projectile.hostile = true; projectile.tileCollide = false; @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - float scaleBase = 48f; + float scaleBase = 48f; float scaleMult = 1.5f; float baseWidth = 320f; float baseHeight = 88f; @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Boss { projectile.localAI[0] = 1f; projectile.scale = (scaleBase - projectile.ai[1]) * scaleMult / scaleBase; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(baseWidth * projectile.scale), (int)(baseHeight * projectile.scale)); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(baseWidth * projectile.scale), (int)(baseHeight * projectile.scale)); projectile.netUpdate = true; } if (projectile.ai[1] != -1f) @@ -120,13 +120,13 @@ namespace CalamityMod.Projectiles.Boss projectile.position.X += num624 * -projectile.direction; } - if (projectile.timeLeft == 720) - projectile.damage = projectile.GetProjectileDamage(ModContent.NPCType()); - } + if (projectile.timeLeft == 720) + projectile.damage = projectile.GetProjectileDamage(ModContent.NPCType()); + } - public override bool CanHitPlayer(Player target) => projectile.timeLeft <= 720; + public override bool CanHitPlayer(Player target) => projectile.timeLeft <= 720; - public override Color? GetAlpha(Color lightColor) + public override Color? GetAlpha(Color lightColor) { return new Color(255, 255, 53, projectile.alpha); } @@ -140,15 +140,15 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.timeLeft <= 720) - target.AddBuff(ModContent.BuffType(), 420); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + if (projectile.timeLeft <= 720) + target.AddBuff(ModContent.BuffType(), 420); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/InfernadoRevenge.cs b/Projectiles/Boss/InfernadoRevenge.cs index d6c43e35ea..969f9107cf 100644 --- a/Projectiles/Boss/InfernadoRevenge.cs +++ b/Projectiles/Boss/InfernadoRevenge.cs @@ -53,12 +53,12 @@ namespace CalamityMod.Projectiles.Boss } internal Color ColorFunction(float completionRatio) - { + { return Color.Lerp(Color.Yellow, Color.Yellow, completionRatio); - } + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { float _ = 0f; return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Boss ref _); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { if (TornadoDrawer is null) TornadoDrawer = new PrimitiveTrail(_ => projectile.width * 0.5f + 16f, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:Bordernado"]); @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Boss Texture2D vortexTexture = ModContent.GetTexture("CalamityMod/Projectiles/Boss/OldDukeVortex"); for (int i = 0; i < 110; i++) - { + { float angle = MathHelper.TwoPi * i / 50f + Main.GlobalTime * MathHelper.TwoPi; Color drawColor = Color.White * 0.04f; drawColor.A = 0; @@ -97,19 +97,19 @@ namespace CalamityMod.Projectiles.Boss drawPosition += (angle + Main.GlobalTime * i / 16f).ToRotationVector2() * 6f; spriteBatch.Draw(vortexTexture, drawPosition, null, drawColor, angle + MathHelper.PiOver2, vortexTexture.Size() * 0.5f, 0.9f, SpriteEffects.None, 0f); - } + } return false; } public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 420); - } + target.AddBuff(ModContent.BuffType(), 420); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/JewelProjectile.cs b/Projectiles/Boss/JewelProjectile.cs index a454e653a7..81bfafa8d9 100644 --- a/Projectiles/Boss/JewelProjectile.cs +++ b/Projectiles/Boss/JewelProjectile.cs @@ -17,38 +17,38 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.width = 10; - projectile.height = 10; - projectile.penetrate = -1; - projectile.hostile = true; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + projectile.width = 10; + projectile.height = 10; + projectile.penetrate = -1; + projectile.hostile = true; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = 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; - } + 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(SoundID.Dig, (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; - } + Main.PlaySound(SoundID.Dig, (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) diff --git a/Projectiles/Boss/LeviathanBomb.cs b/Projectiles/Boss/LeviathanBomb.cs index c557f3f646..a7d57ddc78 100644 --- a/Projectiles/Boss/LeviathanBomb.cs +++ b/Projectiles/Boss/LeviathanBomb.cs @@ -18,16 +18,16 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 172; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 172; projectile.height = 172; projectile.hostile = true; projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; projectile.timeLeft = 120; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -64,12 +64,12 @@ namespace CalamityMod.Projectiles.Boss public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 80f, targetHitbox); - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.position); for (int num621 = 0; num621 < 10; num621++) diff --git a/Projectiles/Boss/MoltenBlast.cs b/Projectiles/Boss/MoltenBlast.cs index 801ab731a1..383a60bf3c 100644 --- a/Projectiles/Boss/MoltenBlast.cs +++ b/Projectiles/Boss/MoltenBlast.cs @@ -22,15 +22,15 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 42; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 42; projectile.height = 42; projectile.hostile = true; projectile.penetrate = 1; projectile.timeLeft = 90; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -56,8 +56,8 @@ namespace CalamityMod.Projectiles.Boss if (projectile.wet || projectile.lavaWet) projectile.Kill(); - int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; - if (projectile.ai[1] == 0f) + int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + if (projectile.ai[1] == 0f) { for (int d = 0; d < 10; d++) { @@ -94,15 +94,15 @@ namespace CalamityMod.Projectiles.Boss projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f; } - public override Color? GetAlpha(Color lightColor) - { - return (Main.dayTime && !CalamityWorld.malice) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return (Main.dayTime && !CalamityWorld.malice) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture2D13 = (Main.dayTime && !CalamityWorld.malice) ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/MoltenBlastNight"); - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y6 = num214 * projectile.frame; Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); return false; @@ -115,7 +115,7 @@ namespace CalamityMod.Projectiles.Boss { for (int b = 0; b < blobAmt; b++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)Math.Round(projectile.damage * 0.75), 0f, projectile.owner, 0f, 0f); } } @@ -139,15 +139,15 @@ namespace CalamityMod.Projectiles.Boss public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 18f, targetHitbox); - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(buffType, 240); - } + int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 240); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/MoltenBlob.cs b/Projectiles/Boss/MoltenBlob.cs index daa35eef32..4ab9c88a4c 100644 --- a/Projectiles/Boss/MoltenBlob.cs +++ b/Projectiles/Boss/MoltenBlob.cs @@ -18,16 +18,16 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 12; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 12; projectile.height = 12; projectile.hostile = true; projectile.penetrate = -1; projectile.timeLeft = 900; projectile.scale = 1.5f; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -62,21 +62,21 @@ namespace CalamityMod.Projectiles.Boss public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override Color? GetAlpha(Color lightColor) - { - return (Main.dayTime && !CalamityWorld.malice) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return (Main.dayTime && !CalamityWorld.malice) ? new Color(250, 150, 0, projectile.alpha) : new Color(100, 200, 250, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture2D13 = (Main.dayTime && !CalamityWorld.malice) ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/MoltenBlobNight"); - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; - int y6 = num214 * projectile.frame; - Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture2D13 = (Main.dayTime && !CalamityWorld.malice) ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/MoltenBlobNight"); + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int y6 = num214 * projectile.frame; + Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture2D13.Width / 2f, num214 / 2f), projectile.scale, SpriteEffects.None, 0f); + return false; + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item20, projectile.Center); projectile.position.X = projectile.position.X + (projectile.width / 2); @@ -85,8 +85,8 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 10; projectile.position.X = projectile.position.X - (projectile.width / 2); projectile.position.Y = projectile.position.Y - (projectile.height / 2); - int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; - for (int num621 = 0; num621 < 3; num621++) + int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int num621 = 0; num621 < 3; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); if (Main.rand.NextBool(2)) @@ -105,13 +105,13 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(buffType, 90); - } + int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 90); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/MushBomb.cs b/Projectiles/Boss/MushBomb.cs index aafb1f24b9..1a1d4fb09b 100644 --- a/Projectiles/Boss/MushBomb.cs +++ b/Projectiles/Boss/MushBomb.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Boss projectile.timeLeft = 480; projectile.aiStyle = 1; aiType = ProjectileID.WoodenArrowFriendly; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -46,32 +46,32 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity.X *= 0.99f; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int height = texture.Height / Main.projFrames[projectile.type]; - int drawStart = height * projectile.frame; - Vector2 origin = projectile.Size / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int drawStart = height * projectile.frame; + Vector2 origin = projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - return false; - } + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int height = texture.Height / Main.projFrames[projectile.type]; - int drawStart = height * projectile.frame; - Vector2 origin = projectile.Size / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int drawStart = height * projectile.frame; + Vector2 origin = projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/MushBombGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - } + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/MushBombGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Boss/MushBombFall.cs b/Projectiles/Boss/MushBombFall.cs index a4f12ba4cb..1c990c0386 100644 --- a/Projectiles/Boss/MushBombFall.cs +++ b/Projectiles/Boss/MushBombFall.cs @@ -49,36 +49,36 @@ namespace CalamityMod.Projectiles.Boss Lighting.AddLight(projectile.Center, 0f, 0.15f, 0.3f); - if (Math.Abs(projectile.velocity.X) > 2f) - projectile.velocity.X *= 0.99f; + if (Math.Abs(projectile.velocity.X) > 2f) + projectile.velocity.X *= 0.99f; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int height = texture.Height / Main.projFrames[projectile.type]; - int drawStart = height * projectile.frame; - Vector2 origin = projectile.Size / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int drawStart = height * projectile.frame; + Vector2 origin = projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - return false; - } + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int height = texture.Height / Main.projFrames[projectile.type]; - int drawStart = height * projectile.frame; - Vector2 origin = projectile.Size / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int drawStart = height * projectile.frame; + Vector2 origin = projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/MushBombGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - } + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/MushBombGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Boss/OldDukeGore.cs b/Projectiles/Boss/OldDukeGore.cs index d898d09bd5..84eb903c4a 100644 --- a/Projectiles/Boss/OldDukeGore.cs +++ b/Projectiles/Boss/OldDukeGore.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class OldDukeGore : ModProjectile + public class OldDukeGore : ModProjectile { public override void SetStaticDefaults() { @@ -17,54 +17,54 @@ namespace CalamityMod.Projectiles.Boss ProjectileID.Sets.TrailingMode[projectile.type] = 0; } - public override void SetDefaults() - { - projectile.width = 24; - projectile.height = 24; - projectile.hostile = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; - projectile.timeLeft = 300; - projectile.alpha = 255; - cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + public override void SetDefaults() + { + projectile.width = 24; + projectile.height = 24; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.penetrate = 1; + projectile.timeLeft = 300; + projectile.alpha = 255; + cooldownSlot = 1; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { - projectile.alpha -= 50; - if (projectile.alpha < 0) - projectile.alpha = 0; + projectile.alpha -= 50; + if (projectile.alpha < 0) + projectile.alpha = 0; - projectile.ai[0] += 1f; - if (projectile.ai[0] >= 15f) - { - projectile.velocity.Y += 0.1f; - } + projectile.ai[0] += 1f; + if (projectile.ai[0] >= 15f) + { + projectile.velocity.Y += 0.1f; + } - if (projectile.velocity.Y > 16f) - { - projectile.velocity.Y = 16f; - } + if (projectile.velocity.Y > 16f) + { + projectile.velocity.Y = 16f; + } - projectile.tileCollide = projectile.timeLeft < 240; + projectile.tileCollide = projectile.timeLeft < 240; - projectile.rotation += projectile.velocity.X * 0.1f; + projectile.rotation += projectile.velocity.X * 0.1f; - int blood = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Blood, 0f, 0f, 100, default, 1f); + int blood = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Blood, 0f, 0f, 100, default, 1f); Main.dust[blood].noGravity = true; Main.dust[blood].velocity *= 0f; - int acid = Dust.NewDust(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 1f); - Main.dust[acid].noGravity = true; - Main.dust[acid].velocity *= 0f; - } + int acid = Dust.NewDust(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 1f); + Main.dust[acid].noGravity = true; + Main.dust[acid].velocity *= 0f; + } public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.NPCDeath12, projectile.position); + { + Main.PlaySound(SoundID.NPCDeath12, projectile.position); - int num226 = 8; + int num226 = 8; for (int num227 = 0; num227 < num226; num227++) { Vector2 source = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; @@ -76,28 +76,28 @@ namespace CalamityMod.Projectiles.Boss Main.dust[blood].velocity = dustVel; } - for (int d = 0; d < 6; d++) - { - int acid = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default(Color), 3f); - Main.dust[acid].noGravity = true; - Main.dust[acid].velocity *= 5f; - acid = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default(Color), 2f); - Main.dust[acid].velocity *= 2f; - Main.dust[acid].noGravity = true; - } - } + for (int d = 0; d < 6; d++) + { + int acid = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default(Color), 3f); + Main.dust[acid].noGravity = true; + Main.dust[acid].velocity *= 5f; + acid = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default(Color), 2f); + Main.dust[acid].velocity *= 2f; + Main.dust[acid].noGravity = true; + } + } public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 180); - } + target.AddBuff(ModContent.BuffType(), 180); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; diff --git a/Projectiles/Boss/OldDukeSummonDrop.cs b/Projectiles/Boss/OldDukeSummonDrop.cs index 2af9d88ab3..3272537a2b 100644 --- a/Projectiles/Boss/OldDukeSummonDrop.cs +++ b/Projectiles/Boss/OldDukeSummonDrop.cs @@ -52,23 +52,23 @@ namespace CalamityMod.Projectiles.Boss return true; } - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (Main.rand.NextBool(2)) - { - // 1 to 3 seconds of poisoned - target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(1, 4)); - } - else if (Main.rand.NextBool(4)) - { - // 1 to 2 second of Sulphuric Poisoning - target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(1, 3)); - } - else - { - // 3 to 5 seconds of Irradiated - target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(3, 6)); - } + if (Main.rand.NextBool(2)) + { + // 1 to 3 seconds of poisoned + target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(1, 4)); + } + else if (Main.rand.NextBool(4)) + { + // 1 to 2 second of Sulphuric Poisoning + target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(1, 3)); + } + else + { + // 3 to 5 seconds of Irradiated + target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(3, 6)); + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Boss/OldDukeVortex.cs b/Projectiles/Boss/OldDukeVortex.cs index 008f0e75e7..af168c3860 100644 --- a/Projectiles/Boss/OldDukeVortex.cs +++ b/Projectiles/Boss/OldDukeVortex.cs @@ -9,143 +9,143 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class OldDukeVortex : ModProjectile + public class OldDukeVortex : ModProjectile { public override void SetStaticDefaults() { DisplayName.SetDefault("Sulphurous Vortex"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 408; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 408; projectile.height = 408; - projectile.scale = 0.004f; - projectile.hostile = true; + projectile.scale = 0.004f; + projectile.hostile = true; projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 1800; - cooldownSlot = 1; - } + projectile.ignoreWater = true; + projectile.timeLeft = 1800; + cooldownSlot = 1; + } public override void AI() { - if (projectile.scale < 1f) - { - if (projectile.alpha > 0) - projectile.alpha -= 1; - - projectile.scale += 0.004f; - if (projectile.scale > 1f) - projectile.scale = 1f; - - projectile.width = projectile.height = (int)(408f * projectile.scale); - } - else - { - if (projectile.timeLeft <= 85) - { - if (projectile.alpha < 255) - projectile.alpha += 3; - - projectile.scale += 0.012f; - projectile.width = projectile.height = (int)(408f * projectile.scale); - } - else - projectile.width = projectile.height = 408; - } - - projectile.velocity = Vector2.Normalize(new Vector2(projectile.ai[0], projectile.ai[1]) - projectile.Center) * 1.5f; - - projectile.rotation -= 0.1f * (float)(1D - (projectile.alpha / 255D)); - - float lightAmt = 2f * projectile.scale; - Lighting.AddLight(projectile.Center, lightAmt, lightAmt * 2f, lightAmt); - - if (projectile.soundDelay == 0) + if (projectile.scale < 1f) { - projectile.soundDelay = 174; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeVortex"), (int)projectile.Center.X, (int)projectile.Center.Y); - } + if (projectile.alpha > 0) + projectile.alpha -= 1; - if (projectile.timeLeft > 85) - { - int numDust = (int)(0.2f * MathHelper.TwoPi * 408f * projectile.scale); - float angleIncrement = MathHelper.TwoPi / (float)numDust; - Vector2 dustOffset = new Vector2(408f * projectile.scale, 0f); - dustOffset = dustOffset.RotatedByRandom(MathHelper.TwoPi); + projectile.scale += 0.004f; + if (projectile.scale > 1f) + projectile.scale = 1f; - int var = (int)(408f * projectile.scale); - for (int i = 0; i < numDust; i++) - { - if (Main.rand.NextBool(var)) - { - dustOffset = dustOffset.RotatedBy(angleIncrement); - int dust = Dust.NewDust(projectile.Center, 1, 1, (int)CalamityDusts.SulfurousSeaAcid); - Main.dust[dust].position = projectile.Center + dustOffset; - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity = Vector2.Normalize(projectile.Center - Main.dust[dust].position) * 24f; - Main.dust[dust].scale = projectile.scale * 3f; - } - } + projectile.width = projectile.height = (int)(408f * projectile.scale); + } + else + { + if (projectile.timeLeft <= 85) + { + if (projectile.alpha < 255) + projectile.alpha += 3; - float distanceRequired = 800f * projectile.scale; - float succPower = 0.4f; - for (int i = 0; i < Main.maxPlayers; i++) - { - Player player = Main.player[i]; - - float distance = Vector2.Distance(player.Center, projectile.Center); - if (distance < distanceRequired && player.grappling[0] == -1) - { - if (Collision.CanHit(projectile.Center, 1, 1, player.Center, 1, 1)) - { - float distanceRatio = distance / distanceRequired; + projectile.scale += 0.012f; + projectile.width = projectile.height = (int)(408f * projectile.scale); + } + else + projectile.width = projectile.height = 408; + } - float wingTimeSet = (float)Math.Ceiling((float)player.wingTimeMax * 0.5f * distanceRatio); - if (player.wingTime > wingTimeSet) - player.wingTime = wingTimeSet; + projectile.velocity = Vector2.Normalize(new Vector2(projectile.ai[0], projectile.ai[1]) - projectile.Center) * 1.5f; - float multiplier = 1f - distanceRatio; - if (player.Center.X < projectile.Center.X) - player.velocity.X += succPower * multiplier; - else - player.velocity.X -= succPower * multiplier; + projectile.rotation -= 0.1f * (float)(1D - (projectile.alpha / 255D)); - if (player.Center.Y < projectile.Center.Y) - player.velocity.Y += succPower * multiplier; - else - player.velocity.Y -= succPower * multiplier; - } - } - } - } - } + float lightAmt = 2f * projectile.scale; + Lighting.AddLight(projectile.Center, lightAmt, lightAmt * 2f, lightAmt); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 174; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/OldDukeVortex"), (int)projectile.Center.X, (int)projectile.Center.Y); + } - public override bool CanHitPlayer(Player target) => projectile.timeLeft <= 1680 && projectile.timeLeft > 85; + if (projectile.timeLeft > 85) + { + int numDust = (int)(0.2f * MathHelper.TwoPi * 408f * projectile.scale); + float angleIncrement = MathHelper.TwoPi / (float)numDust; + Vector2 dustOffset = new Vector2(408f * projectile.scale, 0f); + dustOffset = dustOffset.RotatedByRandom(MathHelper.TwoPi); + + int var = (int)(408f * projectile.scale); + for (int i = 0; i < numDust; i++) + { + if (Main.rand.NextBool(var)) + { + dustOffset = dustOffset.RotatedBy(angleIncrement); + int dust = Dust.NewDust(projectile.Center, 1, 1, (int)CalamityDusts.SulfurousSeaAcid); + Main.dust[dust].position = projectile.Center + dustOffset; + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity = Vector2.Normalize(projectile.Center - Main.dust[dust].position) * 24f; + Main.dust[dust].scale = projectile.scale * 3f; + } + } + + float distanceRequired = 800f * projectile.scale; + float succPower = 0.4f; + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + + float distance = Vector2.Distance(player.Center, projectile.Center); + if (distance < distanceRequired && player.grappling[0] == -1) + { + if (Collision.CanHit(projectile.Center, 1, 1, player.Center, 1, 1)) + { + float distanceRatio = distance / distanceRequired; + + float wingTimeSet = (float)Math.Ceiling((float)player.wingTimeMax * 0.5f * distanceRatio); + if (player.wingTime > wingTimeSet) + player.wingTime = wingTimeSet; + + float multiplier = 1f - distanceRatio; + if (player.Center.X < projectile.Center.X) + player.velocity.X += succPower * multiplier; + else + player.velocity.X -= succPower * multiplier; + + if (player.Center.Y < projectile.Center.Y) + player.velocity.Y += succPower * multiplier; + else + player.velocity.Y -= succPower * multiplier; + } + } + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + + public override bool CanHitPlayer(Player target) => projectile.timeLeft <= 1680 && projectile.timeLeft > 85; public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 210f * projectile.scale, targetHitbox); - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.timeLeft <= 1680 && projectile.timeLeft > 85) - target.AddBuff(ModContent.BuffType(), 600); - } + if (projectile.timeLeft <= 1680 && projectile.timeLeft > 85) + target.AddBuff(ModContent.BuffType(), 600); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/OverlyDramaticDukeSummoner.cs b/Projectiles/Boss/OverlyDramaticDukeSummoner.cs index a6de7684d2..7aff492bd8 100644 --- a/Projectiles/Boss/OverlyDramaticDukeSummoner.cs +++ b/Projectiles/Boss/OverlyDramaticDukeSummoner.cs @@ -19,194 +19,194 @@ namespace CalamityMod.Projectiles.Boss public override void SetStaticDefaults() { DisplayName.SetDefault("Old Duke Summoner"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { projectile.width = projectile.height = 1; - projectile.scale = 0.004f; - projectile.hostile = true; + projectile.scale = 0.004f; + projectile.hostile = true; projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 1800; + projectile.ignoreWater = true; + projectile.timeLeft = 1800; } - private static void ExpandVertically(int startX, int startY, out int topY, out int bottomY, int maxExpandUp = 100, int maxExpandDown = 100) - { - topY = startY; - bottomY = startY; - if (!WorldGen.InWorld(startX, startY, 10)) - { - return; - } - int yUp = 0; - while (yUp < maxExpandUp && topY > 0 && topY >= 10 && Main.tile[startX, topY] != null) - { - topY--; - yUp++; - } - int yDown = 0; - while (yDown < maxExpandDown && bottomY < Main.maxTilesY - 10 && bottomY <= Main.maxTilesY - 10) - { - if (Main.tile[startX, bottomY] == null) - { - return; - } - bottomY++; - yDown++; - } - } - - public override void AI() + private static void ExpandVertically(int startX, int startY, out int topY, out int bottomY, int maxExpandUp = 100, int maxExpandDown = 100) { - projectile.rotation -= 0.15f * (float)(1D - (projectile.alpha / 255D)); - projectile.ai[0]++; + topY = startY; + bottomY = startY; + if (!WorldGen.InWorld(startX, startY, 10)) + { + return; + } + int yUp = 0; + while (yUp < maxExpandUp && topY > 0 && topY >= 10 && Main.tile[startX, topY] != null) + { + topY--; + yUp++; + } + int yDown = 0; + while (yDown < maxExpandDown && bottomY < Main.maxTilesY - 10 && bottomY <= Main.maxTilesY - 10) + { + if (Main.tile[startX, bottomY] == null) + { + return; + } + bottomY++; + yDown++; + } + } - float totalTilesToExpand = 1600f * projectile.scale / 16; + public override void AI() + { + projectile.rotation -= 0.15f * (float)(1D - (projectile.alpha / 255D)); + projectile.ai[0]++; - Point centerAsTileCoords = projectile.Center.ToTileCoordinates(); - ExpandVertically(centerAsTileCoords.X, centerAsTileCoords.Y, out int topY, out int bottomY, (int)(totalTilesToExpand / 2), (int)(totalTilesToExpand / 2)); - topY++; - bottomY--; - Vector2 topVector = new Vector2(centerAsTileCoords.X, topY) * 16f + new Vector2(8f); - Vector2 bottomVector = new Vector2(centerAsTileCoords.X, bottomY) * 16f + new Vector2(8f); - Vector2 centerVector = Vector2.Lerp(topVector, bottomVector, 0.5f); - projectile.width = (int)(208 * projectile.scale); - projectile.height = (int)(bottomVector.Y - topVector.Y); - projectile.Center = centerVector; + float totalTilesToExpand = 1600f * projectile.scale / 16; - if (projectile.ai[0] < 90f) - { - projectile.alpha = (int)MathHelper.Lerp(255f, 0f, projectile.ai[0] / 90f); - projectile.scale = MathHelper.Lerp(0.004f, 1f, projectile.ai[0] / 90f); - } - // Spray gore and acid everywhere - else if (projectile.ai[0] < 480f) - { - if (projectile.ai[0] % 10f == 9f) - { - Vector2 velocity = new Vector2(0f, -18f).RotatedByRandom(0.7f); - Projectile.NewProjectile(projectile.Top + new Vector2(Main.rand.NextFloat(-80f, 80f), 100f), velocity, - ModContent.ProjectileType(), 65, 2f); - } - if (projectile.ai[0] % 35f == 34f) - { - Vector2 velocity = new Vector2(Main.rand.NextFloat(-3f, 3f), -7f - Main.rand.NextFloat(4f, 12f)).RotatedByRandom(0.5f); - Projectile.NewProjectile(projectile.Top + new Vector2(Main.rand.NextFloat(-30f, 30f), 100f), velocity, - ModContent.ProjectileType(), 65, 2f); - } - } + Point centerAsTileCoords = projectile.Center.ToTileCoordinates(); + ExpandVertically(centerAsTileCoords.X, centerAsTileCoords.Y, out int topY, out int bottomY, (int)(totalTilesToExpand / 2), (int)(totalTilesToExpand / 2)); + topY++; + bottomY--; + Vector2 topVector = new Vector2(centerAsTileCoords.X, topY) * 16f + new Vector2(8f); + Vector2 bottomVector = new Vector2(centerAsTileCoords.X, bottomY) * 16f + new Vector2(8f); + Vector2 centerVector = Vector2.Lerp(topVector, bottomVector, 0.5f); + projectile.width = (int)(208 * projectile.scale); + projectile.height = (int)(bottomVector.Y - topVector.Y); + projectile.Center = centerVector; - // Fade out and die - if (projectile.ai[0] >= 600f) - { - projectile.alpha = (int)MathHelper.Lerp(0f, 255f, (projectile.ai[0] - 600f) / 120f); + if (projectile.ai[0] < 90f) + { + projectile.alpha = (int)MathHelper.Lerp(255f, 0f, projectile.ai[0] / 90f); + projectile.scale = MathHelper.Lerp(0.004f, 1f, projectile.ai[0] / 90f); + } + // Spray gore and acid everywhere + else if (projectile.ai[0] < 480f) + { + if (projectile.ai[0] % 10f == 9f) + { + Vector2 velocity = new Vector2(0f, -18f).RotatedByRandom(0.7f); + Projectile.NewProjectile(projectile.Top + new Vector2(Main.rand.NextFloat(-80f, 80f), 100f), velocity, + ModContent.ProjectileType(), 65, 2f); + } + if (projectile.ai[0] % 35f == 34f) + { + Vector2 velocity = new Vector2(Main.rand.NextFloat(-3f, 3f), -7f - Main.rand.NextFloat(4f, 12f)).RotatedByRandom(0.5f); + Projectile.NewProjectile(projectile.Top + new Vector2(Main.rand.NextFloat(-30f, 30f), 100f), velocity, + ModContent.ProjectileType(), 65, 2f); + } + } - bool canSpawnBoomer = false; - for (int i = 0; i < Main.player.Length; i++) - { - if (!Main.player[i].dead && projectile.Distance(Main.player[i].Center) < 12000f) - { - canSpawnBoomer = true; - break; - } - } + // Fade out and die + if (projectile.ai[0] >= 600f) + { + projectile.alpha = (int)MathHelper.Lerp(0f, 255f, (projectile.ai[0] - 600f) / 120f); - // Summon the boomer duke - if (projectile.ai[0] == 660f) - { - if (canSpawnBoomer) - { - for (int i = 0; i < 160; i++) - { - Dust dust = Dust.NewDustPerfect(projectile.Top + Vector2.UnitY * 100f, (int)CalamityDusts.SulfurousSeaAcid); - dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(5f, 23f); - dust.noGravity = true; - dust.scale = 3f; - } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int boomer = NPC.NewNPC((int)projectile.Top.X, (int)projectile.Top.Y + 100, ModContent.NPCType()); - string boomerName = Main.npc[boomer].TypeName; + bool canSpawnBoomer = false; + for (int i = 0; i < Main.player.Length; i++) + { + if (!Main.player[i].dead && projectile.Distance(Main.player[i].Center) < 12000f) + { + canSpawnBoomer = true; + break; + } + } - if (Main.netMode == NetmodeID.SinglePlayer) - { - Main.NewText(Language.GetTextValue("Announcement.HasAwoken", boomerName), new Color(175, 75, 255)); - return; - } + // Summon the boomer duke + if (projectile.ai[0] == 660f) + { + if (canSpawnBoomer) + { + for (int i = 0; i < 160; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Top + Vector2.UnitY * 100f, (int)CalamityDusts.SulfurousSeaAcid); + dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(5f, 23f); + dust.noGravity = true; + dust.scale = 3f; + } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int boomer = NPC.NewNPC((int)projectile.Top.X, (int)projectile.Top.Y + 100, ModContent.NPCType()); + string boomerName = Main.npc[boomer].TypeName; - if (Main.netMode == NetmodeID.Server) - { - NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] - { - Main.npc[boomer].GetTypeNetName() - }), new Color(175, 75, 255)); - return; - } + if (Main.netMode == NetmodeID.SinglePlayer) + { + Main.NewText(Language.GetTextValue("Announcement.HasAwoken", boomerName), new Color(175, 75, 255)); + return; + } - CalamityUtils.BossAwakenMessage(boomer); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] + { + Main.npc[boomer].GetTypeNetName() + }), new Color(175, 75, 255)); + return; + } - Main.npc[boomer].velocity = Vector2.UnitY * -12f; - Main.npc[boomer].alpha = 255; - Main.npc[boomer].Calamity().newAI[3] = 1f; // To signal that Old Duke should not deccelerate as it normally would - Main.npc[boomer].netUpdate = true; - CalamityWorld.triedToSummonOldDuke = true; - CalamityWorld.encounteredOldDuke = true; - AcidRainEvent.UpdateInvasion(false); - } - } - else - { - CalamityWorld.acidRainPoints = 0; - CalamityWorld.triedToSummonOldDuke = false; - AcidRainEvent.UpdateInvasion(false); - } - } - } - if (projectile.ai[0] >= 720f) - { - projectile.Kill(); - } - } + CalamityUtils.BossAwakenMessage(boomer); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - float totalTilesToExpand = 1600f * projectile.scale / 16; - Point centerAsTileCoords = projectile.Center.ToTileCoordinates(); - ExpandVertically(centerAsTileCoords.X, centerAsTileCoords.Y, out _, out int bottomY, (int)(totalTilesToExpand / 2), (int)(totalTilesToExpand / 2)); - bottomY--; - Vector2 bottomVector = new Vector2(centerAsTileCoords.X, bottomY) * 16f + new Vector2(8f); + Main.npc[boomer].velocity = Vector2.UnitY * -12f; + Main.npc[boomer].alpha = 255; + Main.npc[boomer].Calamity().newAI[3] = 1f; // To signal that Old Duke should not deccelerate as it normally would + Main.npc[boomer].netUpdate = true; + CalamityWorld.triedToSummonOldDuke = true; + CalamityWorld.encounteredOldDuke = true; + AcidRainEvent.UpdateInvasion(false); + } + } + else + { + CalamityWorld.acidRainPoints = 0; + CalamityWorld.triedToSummonOldDuke = false; + AcidRainEvent.UpdateInvasion(false); + } + } + } + if (projectile.ai[0] >= 720f) + { + projectile.Kill(); + } + } - Texture2D texture = ModContent.GetTexture(Texture); - float yMax = 1600f * projectile.scale; - for (int y = 0; y < yMax; y += 30) - { - float thetaDelta = MathHelper.Pi * y / yMax; - float scale = projectile.scale * MathHelper.Lerp(0.3f, 1.4f, y / yMax); - float alphaMultiplier = MathHelper.Lerp(1f, 0.6f, y / yMax); - spriteBatch.Draw(texture, - bottomVector - Main.screenPosition - Vector2.UnitY * y, - null, - Color.White * projectile.Opacity * 0.3f * alphaMultiplier, - projectile.rotation + thetaDelta, - texture.Size() * 0.5f, - scale, - SpriteEffects.None, - 0f); - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + float totalTilesToExpand = 1600f * projectile.scale / 16; + Point centerAsTileCoords = projectile.Center.ToTileCoordinates(); + ExpandVertically(centerAsTileCoords.X, centerAsTileCoords.Y, out _, out int bottomY, (int)(totalTilesToExpand / 2), (int)(totalTilesToExpand / 2)); + bottomY--; + Vector2 bottomVector = new Vector2(centerAsTileCoords.X, bottomY) * 16f + new Vector2(8f); - public override bool CanHitPlayer(Player target) => projectile.ai[0] >= 90f; + Texture2D texture = ModContent.GetTexture(Texture); + float yMax = 1600f * projectile.scale; + for (int y = 0; y < yMax; y += 30) + { + float thetaDelta = MathHelper.Pi * y / yMax; + float scale = projectile.scale * MathHelper.Lerp(0.3f, 1.4f, y / yMax); + float alphaMultiplier = MathHelper.Lerp(1f, 0.6f, y / yMax); + spriteBatch.Draw(texture, + bottomVector - Main.screenPosition - Vector2.UnitY * y, + null, + Color.White * projectile.Opacity * 0.3f * alphaMultiplier, + projectile.rotation + thetaDelta, + texture.Size() * 0.5f, + scale, + SpriteEffects.None, + 0f); + } + return false; + } + + public override bool CanHitPlayer(Player target) => projectile.ai[0] >= 90f; public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 240f * projectile.scale, targetHitbox); - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 420); - } + target.AddBuff(ModContent.BuffType(), 420); + } } } diff --git a/Projectiles/Boss/PhantomBlast.cs b/Projectiles/Boss/PhantomBlast.cs index ef6668a366..18fe425b25 100644 --- a/Projectiles/Boss/PhantomBlast.cs +++ b/Projectiles/Boss/PhantomBlast.cs @@ -17,17 +17,17 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 18; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 18; projectile.height = 18; projectile.hostile = true; - projectile.ignoreWater = true; - projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -116,14 +116,14 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/PhantomBlast2.cs b/Projectiles/Boss/PhantomBlast2.cs index 4520f37502..10d0a35932 100644 --- a/Projectiles/Boss/PhantomBlast2.cs +++ b/Projectiles/Boss/PhantomBlast2.cs @@ -17,17 +17,17 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 18; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 18; projectile.height = 18; projectile.hostile = true; - projectile.ignoreWater = true; - projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -116,14 +116,14 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/PhantomGhostShot.cs b/Projectiles/Boss/PhantomGhostShot.cs index 4eab148cd1..5682367455 100644 --- a/Projectiles/Boss/PhantomGhostShot.cs +++ b/Projectiles/Boss/PhantomGhostShot.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.timeLeft = 600; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -70,19 +70,19 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 120); + } - public override Color? GetAlpha(Color lightColor) + public override Color? GetAlpha(Color lightColor) { return new Color(100, 250, 250, projectile.alpha); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/PhantomHookShot.cs b/Projectiles/Boss/PhantomHookShot.cs index 34f9397844..acff7b3bf2 100644 --- a/Projectiles/Boss/PhantomHookShot.cs +++ b/Projectiles/Boss/PhantomHookShot.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.timeLeft = 600; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -70,19 +70,19 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 120); + } - public override Color? GetAlpha(Color lightColor) + public override Color? GetAlpha(Color lightColor) { return new Color(100, 250, 250, projectile.alpha); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/PhantomMine.cs b/Projectiles/Boss/PhantomMine.cs index cf63ed1036..39862c65f3 100644 --- a/Projectiles/Boss/PhantomMine.cs +++ b/Projectiles/Boss/PhantomMine.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 30; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 30; projectile.height = 30; projectile.hostile = true; projectile.penetrate = -1; @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Boss projectile.ignoreWater = true; projectile.timeLeft = 480; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -38,11 +38,11 @@ namespace CalamityMod.Projectiles.Boss return new Color(200, 200, 200, projectile.alpha); } - public override bool CanHitPlayer(Player target) => projectile.velocity.Length() >= projectile.ai[0]; + public override bool CanHitPlayer(Player target) => projectile.velocity.Length() >= projectile.ai[0]; public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 12f, targetHitbox); - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.position); projectile.position.X = projectile.position.X + (projectile.width / 2); @@ -71,18 +71,18 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.velocity.Length() >= projectile.ai[0]) - { - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - } - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + if (projectile.velocity.Length() >= projectile.ai[0]) + { + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + } + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/PhantomShot.cs b/Projectiles/Boss/PhantomShot.cs index a3e8e92e92..110b26de04 100644 --- a/Projectiles/Boss/PhantomShot.cs +++ b/Projectiles/Boss/PhantomShot.cs @@ -22,12 +22,12 @@ namespace CalamityMod.Projectiles.Boss projectile.width = 14; projectile.height = 14; projectile.hostile = true; - projectile.ignoreWater = true; - projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.alpha = 255; projectile.penetrate = -1; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -54,33 +54,33 @@ namespace CalamityMod.Projectiles.Boss if (projectile.alpha < 30) projectile.alpha = 30; } - if (projectile.localAI[0] > 180f && projectile.localAI[0] < 240f && Main.expertMode) - { - if (projectile.ai[0] == 0f) - projectile.ai[0] = projectile.velocity.Length() * 3f; + if (projectile.localAI[0] > 180f && projectile.localAI[0] < 240f && Main.expertMode) + { + if (projectile.ai[0] == 0f) + projectile.ai[0] = projectile.velocity.Length() * 3f; - int num189 = Player.FindClosest(projectile.Center, 1, 1); - Vector2 vector20 = Main.player[num189].Center - projectile.Center; - vector20.Normalize(); - vector20 *= projectile.ai[0]; - int num190 = 80; - projectile.velocity = (projectile.velocity * (num190 - 1) + vector20) / num190; - } - } + int num189 = Player.FindClosest(projectile.Center, 1, 1); + Vector2 vector20 = Main.player[num189].Center - projectile.Center; + vector20.Normalize(); + vector20 *= projectile.ai[0]; + int num190 = 80; + projectile.velocity = (projectile.velocity * (num190 - 1) + vector20) / num190; + } + } public override Color? GetAlpha(Color lightColor) { return new Color(100, 250, 250, projectile.alpha); } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.AddBuff(ModContent.BuffType(), 120); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/PhantomShot2.cs b/Projectiles/Boss/PhantomShot2.cs index d44c086613..763eb4d753 100644 --- a/Projectiles/Boss/PhantomShot2.cs +++ b/Projectiles/Boss/PhantomShot2.cs @@ -22,12 +22,12 @@ namespace CalamityMod.Projectiles.Boss projectile.width = 14; projectile.height = 14; projectile.hostile = true; - projectile.ignoreWater = true; - projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.alpha = 255; projectile.penetrate = -1; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -54,18 +54,18 @@ namespace CalamityMod.Projectiles.Boss if (projectile.alpha < 30) projectile.alpha = 30; } - if (projectile.localAI[0] > 180f && projectile.localAI[0] < 300f && Main.expertMode) - { - if (projectile.ai[0] == 0f) - projectile.ai[0] = projectile.velocity.Length() * 2f; + if (projectile.localAI[0] > 180f && projectile.localAI[0] < 300f && Main.expertMode) + { + if (projectile.ai[0] == 0f) + projectile.ai[0] = projectile.velocity.Length() * 2f; - int num189 = Player.FindClosest(projectile.Center, 1, 1); - Vector2 vector20 = Main.player[num189].Center - projectile.Center; - vector20.Normalize(); - vector20 *= projectile.ai[0]; - int num190 = 80; - projectile.velocity = (projectile.velocity * (num190 - 1) + vector20) / num190; - } + int num189 = Player.FindClosest(projectile.Center, 1, 1); + Vector2 vector20 = Main.player[num189].Center - projectile.Center; + vector20.Normalize(); + vector20 *= projectile.ai[0]; + int num190 = 80; + projectile.velocity = (projectile.velocity * (num190 - 1) + vector20) / num190; + } } public override Color? GetAlpha(Color lightColor) @@ -73,14 +73,14 @@ namespace CalamityMod.Projectiles.Boss return new Color(250, 100, 100, projectile.alpha); } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.AddBuff(ModContent.BuffType(), 120); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/PlagueExplosion.cs b/Projectiles/Boss/PlagueExplosion.cs index 9bb9934098..8214753ba6 100644 --- a/Projectiles/Boss/PlagueExplosion.cs +++ b/Projectiles/Boss/PlagueExplosion.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.hostile = true; + projectile.hostile = true; projectile.ignoreWater = true; projectile.tileCollide = false; projectile.penetrate = -1; @@ -54,12 +54,12 @@ namespace CalamityMod.Projectiles.Boss Main.dust[num467].noGravity = true; Main.dust[num467].position.X = projectile.Center.X; Main.dust[num467].position.Y = projectile.Center.Y; - Main.dust[num467].position.X += Main.rand.Next(-10, 11); - Main.dust[num467].position.Y += Main.rand.Next(-10, 11); + Main.dust[num467].position.X += Main.rand.Next(-10, 11); + Main.dust[num467].position.Y += Main.rand.Next(-10, 11); Main.dust[num467].velocity.X = num463; Main.dust[num467].velocity.Y = num464; - Main.dust[num467].scale = projectile.scale * 0.35f; - num462++; + Main.dust[num467].scale = projectile.scale * 0.35f; + num462++; } } diff --git a/Projectiles/Boss/PlagueStingerGoliath.cs b/Projectiles/Boss/PlagueStingerGoliath.cs index 5933b3677c..2fb2905a3c 100644 --- a/Projectiles/Boss/PlagueStingerGoliath.cs +++ b/Projectiles/Boss/PlagueStingerGoliath.cs @@ -17,13 +17,13 @@ namespace CalamityMod.Projectiles.Boss { projectile.width = 10; projectile.height = 10; - projectile.scale = 1.5f; - projectile.hostile = true; + projectile.scale = 1.5f; + projectile.hostile = true; projectile.penetrate = -1; projectile.tileCollide = false; projectile.timeLeft = 300; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { diff --git a/Projectiles/Boss/PlagueStingerGoliathV2.cs b/Projectiles/Boss/PlagueStingerGoliathV2.cs index 47379fa944..799f7b178b 100644 --- a/Projectiles/Boss/PlagueStingerGoliathV2.cs +++ b/Projectiles/Boss/PlagueStingerGoliathV2.cs @@ -21,14 +21,14 @@ namespace CalamityMod.Projectiles.Boss { projectile.width = 10; projectile.height = 10; - projectile.scale = 1.5f; + projectile.scale = 1.5f; projectile.hostile = true; projectile.penetrate = -1; projectile.extraUpdates = 2; projectile.tileCollide = false; projectile.timeLeft = 300; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Boss { spriteEffects = SpriteEffects.FlipHorizontally; } - Texture2D glow = ModContent.GetTexture("CalamityMod/Projectiles/Boss/PlagueStingerGoliathGlow"); + Texture2D glow = ModContent.GetTexture("CalamityMod/Projectiles/Boss/PlagueStingerGoliathGlow"); Vector2 origin = new Vector2(glow.Width / 2, glow.Height / Main.projFrames[projectile.type] / 2); Vector2 drawPos = projectile.Center - Main.screenPosition; drawPos -= new Vector2(glow.Width, glow.Height / Main.projFrames[projectile.type]) * 1f / 2f; @@ -63,17 +63,17 @@ namespace CalamityMod.Projectiles.Boss { Main.PlaySound(SoundID.Item14, projectile.position); - if (projectile.owner == Main.myPlayer) - { - float scale = 1.5f + projectile.ai[0] * 0.015f; - int baseWidthAndHeight = 20; - int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - Main.projectile[proj].scale = scale; - Main.projectile[proj].width = (int)(baseWidthAndHeight * scale); - Main.projectile[proj].height = (int)(baseWidthAndHeight * scale); - Main.projectile[proj].position.X = projectile.Center.X - Main.projectile[proj].width * 0.5f; - Main.projectile[proj].position.Y = projectile.Center.Y - Main.projectile[proj].height * 0.5f; - } + if (projectile.owner == Main.myPlayer) + { + float scale = 1.5f + projectile.ai[0] * 0.015f; + int baseWidthAndHeight = 20; + int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + Main.projectile[proj].scale = scale; + Main.projectile[proj].width = (int)(baseWidthAndHeight * scale); + Main.projectile[proj].height = (int)(baseWidthAndHeight * scale); + Main.projectile[proj].position.X = projectile.Center.X - Main.projectile[proj].width * 0.5f; + Main.projectile[proj].position.Y = projectile.Center.Y - Main.projectile[proj].height * 0.5f; + } } } } diff --git a/Projectiles/Boss/ProfanedSpear.cs b/Projectiles/Boss/ProfanedSpear.cs index 0788cf133c..844179f27c 100644 --- a/Projectiles/Boss/ProfanedSpear.cs +++ b/Projectiles/Boss/ProfanedSpear.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 32; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 32; projectile.height = 32; projectile.hostile = true; projectile.tileCollide = false; @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 255; projectile.timeLeft = 300; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -48,8 +48,8 @@ namespace CalamityMod.Projectiles.Boss projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver4; - if (projectile.alpha > 0) - projectile.alpha -= 17; + if (projectile.alpha > 0) + projectile.alpha -= 17; projectile.ai[1] += 1f; if (projectile.ai[1] <= 20f) @@ -93,10 +93,10 @@ namespace CalamityMod.Projectiles.Boss { target.AddBuff(ModContent.BuffType(), 180); } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/ProvidenceCrystal.cs b/Projectiles/Boss/ProvidenceCrystal.cs index 482e53a910..de744ad3ee 100644 --- a/Projectiles/Boss/ProvidenceCrystal.cs +++ b/Projectiles/Boss/ProvidenceCrystal.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Boss return; } - bool dayTime = Main.dayTime && !CalamityWorld.malice; + bool dayTime = Main.dayTime && !CalamityWorld.malice; projectile.position.X = Main.player[projectile.owner].Center.X - (projectile.width / 2); projectile.position.Y = Main.player[projectile.owner].Center.Y - (projectile.height / 2) + Main.player[projectile.owner].gfxOffY - 360f; @@ -84,38 +84,38 @@ namespace CalamityMod.Projectiles.Boss dust34.scale = 0.5f; } - float lifeRatio = projectile.ai[0]; + float lifeRatio = projectile.ai[0]; - // Increment timer + // Increment timer projectile.localAI[0] += 1f; - // Spawn daytime shards every 300 frames - // Spawn nighttime shards every 30 frames + // Spawn daytime shards every 300 frames + // Spawn nighttime shards every 30 frames if (projectile.localAI[0] >= (dayTime ? 300f : 30f)) { - // Spawn shards every 30 frames at night or at 300 frames during day - if (projectile.localAI[0] % 30f == 0f || dayTime) - { - Main.PlaySound(SoundID.Item109, projectile.position); - projectile.netUpdate = true; - if (projectile.owner == Main.myPlayer) - { - int totalProjectiles = dayTime ? 15 : (projectile.localAI[0] % 60f == 0f ? 15 : 10); - float speedX = dayTime ? -21f : -15f; - float speedAdjustment = Math.Abs(speedX * 2f / (totalProjectiles - 1)); - float speedY = -3f; - for (int i = 0; i < totalProjectiles; i++) - { - float x4 = dayTime ? Main.rgbToHsl(new Color(255, 200, Main.DiscoB)).X : Main.rgbToHsl(new Color(Main.DiscoR, 200, 255)).X; - float randomSpread = dayTime ? 0f : Main.rand.Next(-150, 151) * 0.01f * (1f - lifeRatio); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speedX + speedAdjustment * i + randomSpread, speedY, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, x4, projectile.whoAmI); - } - } + // Spawn shards every 30 frames at night or at 300 frames during day + if (projectile.localAI[0] % 30f == 0f || dayTime) + { + Main.PlaySound(SoundID.Item109, projectile.position); + projectile.netUpdate = true; + if (projectile.owner == Main.myPlayer) + { + int totalProjectiles = dayTime ? 15 : (projectile.localAI[0] % 60f == 0f ? 15 : 10); + float speedX = dayTime ? -21f : -15f; + float speedAdjustment = Math.Abs(speedX * 2f / (totalProjectiles - 1)); + float speedY = -3f; + for (int i = 0; i < totalProjectiles; i++) + { + float x4 = dayTime ? Main.rgbToHsl(new Color(255, 200, Main.DiscoB)).X : Main.rgbToHsl(new Color(Main.DiscoR, 200, 255)).X; + float randomSpread = dayTime ? 0f : Main.rand.Next(-150, 151) * 0.01f * (1f - lifeRatio); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speedX + speedAdjustment * i + randomSpread, speedY, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, x4, projectile.whoAmI); + } + } - // Reset timer - if (projectile.localAI[0] >= 60f) - projectile.localAI[0] = 0f; - } + // Reset timer + if (projectile.localAI[0] >= 60f) + projectile.localAI[0] = 0f; + } } } @@ -142,9 +142,9 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/ProvidenceCrystalShard.cs b/Projectiles/Boss/ProvidenceCrystalShard.cs index a5687f6fea..bcd328f006 100644 --- a/Projectiles/Boss/ProvidenceCrystalShard.cs +++ b/Projectiles/Boss/ProvidenceCrystalShard.cs @@ -17,14 +17,14 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 34; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 34; projectile.height = 34; projectile.hostile = true; projectile.alpha = 255; projectile.penetrate = 1; projectile.tileCollide = false; - projectile.ignoreWater = true; + projectile.ignoreWater = true; projectile.timeLeft = 600; cooldownSlot = 1; } @@ -43,10 +43,10 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - if (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) - projectile.extraUpdates = 1; + if (!Main.dayTime || CalamityWorld.malice || BossRushEvent.BossRushActive) + projectile.extraUpdates = 1; - if (projectile.timeLeft < 300) + if (projectile.timeLeft < 300) { projectile.tileCollide = true; } @@ -203,9 +203,9 @@ namespace CalamityMod.Projectiles.Boss return new Color(255 - projectile.alpha, 255 - projectile.alpha, 255 - projectile.alpha, 0); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/ProvidenceHolyRay.cs b/Projectiles/Boss/ProvidenceHolyRay.cs index b2502ba6c6..d0d69441b5 100644 --- a/Projectiles/Boss/ProvidenceHolyRay.cs +++ b/Projectiles/Boss/ProvidenceHolyRay.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 48; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 48; projectile.height = 48; projectile.hostile = true; projectile.alpha = 255; @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - bool scissorLasers = CalamityWorld.revenge || !Main.dayTime || BossRushEvent.BossRushActive; + bool scissorLasers = CalamityWorld.revenge || !Main.dayTime || BossRushEvent.BossRushActive; Vector2? vector78 = null; if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) @@ -59,8 +59,8 @@ namespace CalamityMod.Projectiles.Boss Vector2 fireFrom = new Vector2(Main.npc[(int)projectile.ai[1]].Center.X, Main.npc[(int)projectile.ai[1]].Center.Y + 32f); projectile.position = fireFrom - new Vector2(projectile.width, projectile.height) / 2f; } - else - projectile.Kill(); + else + projectile.Kill(); if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) { @@ -110,8 +110,8 @@ namespace CalamityMod.Projectiles.Boss num807 = 2400f; } - int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; - float amount = 0.5f; //0.5f + int dustType = (Main.dayTime && !CalamityWorld.malice) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + float amount = 0.5f; //0.5f projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); //length of laser, linear interpolation Vector2 vector79 = projectile.Center + projectile.velocity * (projectile.localAI[1] - 14f); for (int num809 = 0; num809 < 2; num809++) @@ -143,8 +143,8 @@ namespace CalamityMod.Projectiles.Boss { return false; } - bool dayTime = Main.dayTime && !CalamityWorld.malice; - Texture2D texture2D19 = dayTime ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/ProvidenceHolyRayNight"); + bool dayTime = Main.dayTime && !CalamityWorld.malice; + Texture2D texture2D19 = dayTime ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/ProvidenceHolyRayNight"); Texture2D texture2D20 = dayTime ? ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayMid") : ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayMidNight"); Texture2D texture2D21 = dayTime ? ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayEnd") : ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayEndNight"); float num223 = projectile.localAI[1]; //length of laser @@ -204,15 +204,15 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); + int buffType = (Main.dayTime && !CalamityWorld.malice) ? ModContent.BuffType() : ModContent.BuffType(); target.AddBuff(buffType, 420); } - public override bool CanHitPlayer(Player target) => projectile.scale >= 0.5f; + public override bool CanHitPlayer(Player target) => projectile.scale >= 0.5f; - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/RavagerFlame.cs b/Projectiles/Boss/RavagerFlame.cs index 6519188435..e78a015ebf 100644 --- a/Projectiles/Boss/RavagerFlame.cs +++ b/Projectiles/Boss/RavagerFlame.cs @@ -26,9 +26,9 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = 1; projectile.timeLeft = 300; projectile.aiStyle = 1; - projectile.extraUpdates = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 2 : 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.extraUpdates = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 2 : 1; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { diff --git a/Projectiles/Boss/RedLightning.cs b/Projectiles/Boss/RedLightning.cs index 2770a97bb0..b8d1144e2b 100644 --- a/Projectiles/Boss/RedLightning.cs +++ b/Projectiles/Boss/RedLightning.cs @@ -8,219 +8,219 @@ using Terraria.ModLoader; using Terraria.Utilities; namespace CalamityMod.Projectiles.Boss { - public class RedLightning : ModProjectile + public class RedLightning : ModProjectile { public override string Texture => "CalamityMod/Projectiles/LightningProj"; public override void SetStaticDefaults() { DisplayName.SetDefault("Red Lightning"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 20; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 20; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 14; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 14; projectile.height = 14; projectile.hostile = true; projectile.alpha = 255; projectile.penetrate = -1; - projectile.ignoreWater = true; + projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.extraUpdates = 20; + projectile.extraUpdates = 20; projectile.timeLeft = 1260; - cooldownSlot = 1; - } + cooldownSlot = 1; + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(projectile.localAI[0]); writer.Write(projectile.localAI[1]); - } + } public override void ReceiveExtraAI(BinaryReader reader) { projectile.localAI[0] = reader.ReadSingle(); projectile.localAI[1] = reader.ReadSingle(); - } + } public override void AI() { - if (projectile.frameCounter == 0 || projectile.oldPos[0] == Vector2.Zero) - { - for (int num31 = projectile.oldPos.Length - 1; num31 > 0; num31--) - { - projectile.oldPos[num31] = projectile.oldPos[num31 - 1]; - } - projectile.oldPos[0] = projectile.position; - if (projectile.velocity == Vector2.Zero) - { - float num32 = projectile.rotation + MathHelper.PiOver2 + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; - float num33 = (float)Main.rand.NextDouble() * 2f + 2f; - Vector2 vector2 = new Vector2((float)Math.Cos((double)num32) * num33, (float)Math.Sin((double)num32) * num33); - int num34 = Dust.NewDust(projectile.oldPos[projectile.oldPos.Length - 1], 0, 0, 60, vector2.X, vector2.Y, 0, default, 1f); - Main.dust[num34].noGravity = true; - Main.dust[num34].scale = 1.7f; - } - } + if (projectile.frameCounter == 0 || projectile.oldPos[0] == Vector2.Zero) + { + for (int num31 = projectile.oldPos.Length - 1; num31 > 0; num31--) + { + projectile.oldPos[num31] = projectile.oldPos[num31 - 1]; + } + projectile.oldPos[0] = projectile.position; + if (projectile.velocity == Vector2.Zero) + { + float num32 = projectile.rotation + MathHelper.PiOver2 + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; + float num33 = (float)Main.rand.NextDouble() * 2f + 2f; + Vector2 vector2 = new Vector2((float)Math.Cos((double)num32) * num33, (float)Math.Sin((double)num32) * num33); + int num34 = Dust.NewDust(projectile.oldPos[projectile.oldPos.Length - 1], 0, 0, 60, vector2.X, vector2.Y, 0, default, 1f); + Main.dust[num34].noGravity = true; + Main.dust[num34].scale = 1.7f; + } + } - int num3 = projectile.frameCounter; - projectile.frameCounter = num3 + 1; - Lighting.AddLight(projectile.Center, 0.8f, 0.25f, 0.15f); - if (projectile.velocity == Vector2.Zero) - { - if (projectile.frameCounter >= projectile.extraUpdates * 2) - { - projectile.frameCounter = 0; - bool flag36 = true; - for (int num855 = 1; num855 < projectile.oldPos.Length; num855 = num3 + 1) - { - if (projectile.oldPos[num855] != projectile.oldPos[0]) - { - flag36 = false; - } - num3 = num855; - } - if (flag36) - { - projectile.Kill(); - return; - } - } - if (Main.rand.Next(projectile.extraUpdates) == 0) - { - for (int num856 = 0; num856 < 2; num856 = num3 + 1) - { - float num857 = projectile.rotation + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; - float num858 = (float)Main.rand.NextDouble() * 0.8f + 1f; - Vector2 vector96 = new Vector2((float)Math.Cos((double)num857) * num858, (float)Math.Sin((double)num857) * num858); - int num859 = Dust.NewDust(projectile.Center, 0, 0, 60, vector96.X, vector96.Y, 0, default, 1f); - Main.dust[num859].noGravity = true; - Main.dust[num859].scale = 1.2f; - num3 = num856; - } - 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); - Dust dust = Main.dust[num860]; - dust.velocity *= 0.5f; - Main.dust[num860].velocity.Y = -Math.Abs(Main.dust[num860].velocity.Y); - } - } - } - else if (projectile.frameCounter >= projectile.extraUpdates * 2) - { - projectile.frameCounter = 0; - float num861 = projectile.velocity.Length(); - UnifiedRandom unifiedRandom = new UnifiedRandom((int)projectile.ai[1]); - int num862 = 0; - Vector2 vector97 = -Vector2.UnitY; - Vector2 vector98; - do - { - int num863 = unifiedRandom.Next(); - projectile.ai[1] = (float)num863; - num863 %= 100; - float f = (float)num863 / 100f * MathHelper.TwoPi; - vector98 = f.ToRotationVector2(); - if (vector98.Y > 0f) - { - vector98.Y *= -1f; - } - bool flag37 = false; - if (vector98.Y > -0.02f) - { - flag37 = true; - } - if (vector98.X * (float)(projectile.extraUpdates + 1) * 2f * num861 + projectile.localAI[0] > 40f) - { - flag37 = true; - } - if (vector98.X * (float)(projectile.extraUpdates + 1) * 2f * num861 + projectile.localAI[0] < -40f) - { - flag37 = true; - } - if (!flag37) - { - goto IL_25086; - } - num3 = num862; - num862 = num3 + 1; - } - while (num3 < 100); + int num3 = projectile.frameCounter; + projectile.frameCounter = num3 + 1; + Lighting.AddLight(projectile.Center, 0.8f, 0.25f, 0.15f); + if (projectile.velocity == Vector2.Zero) + { + if (projectile.frameCounter >= projectile.extraUpdates * 2) + { + projectile.frameCounter = 0; + bool flag36 = true; + for (int num855 = 1; num855 < projectile.oldPos.Length; num855 = num3 + 1) + { + if (projectile.oldPos[num855] != projectile.oldPos[0]) + { + flag36 = false; + } + num3 = num855; + } + if (flag36) + { + projectile.Kill(); + return; + } + } + if (Main.rand.Next(projectile.extraUpdates) == 0) + { + for (int num856 = 0; num856 < 2; num856 = num3 + 1) + { + float num857 = projectile.rotation + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; + float num858 = (float)Main.rand.NextDouble() * 0.8f + 1f; + Vector2 vector96 = new Vector2((float)Math.Cos((double)num857) * num858, (float)Math.Sin((double)num857) * num858); + int num859 = Dust.NewDust(projectile.Center, 0, 0, 60, vector96.X, vector96.Y, 0, default, 1f); + Main.dust[num859].noGravity = true; + Main.dust[num859].scale = 1.2f; + num3 = num856; + } + 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); + Dust dust = Main.dust[num860]; + dust.velocity *= 0.5f; + Main.dust[num860].velocity.Y = -Math.Abs(Main.dust[num860].velocity.Y); + } + } + } + else if (projectile.frameCounter >= projectile.extraUpdates * 2) + { + projectile.frameCounter = 0; + float num861 = projectile.velocity.Length(); + UnifiedRandom unifiedRandom = new UnifiedRandom((int)projectile.ai[1]); + int num862 = 0; + Vector2 vector97 = -Vector2.UnitY; + Vector2 vector98; + do + { + int num863 = unifiedRandom.Next(); + projectile.ai[1] = (float)num863; + num863 %= 100; + float f = (float)num863 / 100f * MathHelper.TwoPi; + vector98 = f.ToRotationVector2(); + if (vector98.Y > 0f) + { + vector98.Y *= -1f; + } + bool flag37 = false; + if (vector98.Y > -0.02f) + { + flag37 = true; + } + if (vector98.X * (float)(projectile.extraUpdates + 1) * 2f * num861 + projectile.localAI[0] > 40f) + { + flag37 = true; + } + if (vector98.X * (float)(projectile.extraUpdates + 1) * 2f * num861 + projectile.localAI[0] < -40f) + { + flag37 = true; + } + if (!flag37) + { + goto IL_25086; + } + num3 = num862; + num862 = num3 + 1; + } + while (num3 < 100); - projectile.velocity = Vector2.Zero; - projectile.localAI[1] = 1f; + projectile.velocity = Vector2.Zero; + projectile.localAI[1] = 1f; - goto IL_25092; + goto IL_25092; - IL_25086: - vector97 = vector98; + IL_25086: + vector97 = vector98; - IL_25092: - if (projectile.velocity != Vector2.Zero) - { - projectile.localAI[0] += vector97.X * (float)(projectile.extraUpdates + 1) * 2f * num861; - projectile.velocity = vector97.RotatedBy((double)(projectile.ai[0] + MathHelper.PiOver2), default(Vector2)) * num861; - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - } - } - } - - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.Electrified, 120); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Vector2 end = projectile.position + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; - Texture2D tex3 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/RedLightningTexture"); - projectile.GetAlpha(lightColor); - Vector2 scale16 = new Vector2(projectile.scale) / 2f; - for (int num289 = 0; num289 < 3; num289++) - { - if (num289 == 0) - { - scale16 = new Vector2(projectile.scale) * 0.6f; - DelegateMethods.c_1 = new Microsoft.Xna.Framework.Color(219, 104, 58, 0) * 0.5f; - } - else if (num289 == 1) - { - scale16 = new Vector2(projectile.scale) * 0.4f; - DelegateMethods.c_1 = new Microsoft.Xna.Framework.Color(255, 126, 56, 0) * 0.5f; - } - else - { - scale16 = new Vector2(projectile.scale) * 0.2f; - DelegateMethods.c_1 = new Microsoft.Xna.Framework.Color(255, 128, 128, 0) * 0.5f; - } - DelegateMethods.f_1 = 1f; - for (int num290 = projectile.oldPos.Length - 1; num290 > 0; num290--) - { - if (!(projectile.oldPos[num290] == Vector2.Zero)) - { - Vector2 start = projectile.oldPos[num290] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; - Vector2 end2 = projectile.oldPos[num290 - 1] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; - Utils.DrawLaser(spriteBatch, tex3, start, end2, scale16, new Utils.LaserLineFraming(DelegateMethods.LightningLaserDraw)); - } - } - if (projectile.oldPos[0] != Vector2.Zero) - { - DelegateMethods.f_1 = 1f; - Vector2 start2 = projectile.oldPos[0] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; - Utils.DrawLaser(Main.spriteBatch, tex3, start2, end, scale16, new Utils.LaserLineFraming(DelegateMethods.LightningLaserDraw)); - } - } - return false; + IL_25092: + if (projectile.velocity != Vector2.Zero) + { + projectile.localAI[0] += vector97.X * (float)(projectile.extraUpdates + 1) * 2f * num861; + projectile.velocity = vector97.RotatedBy((double)(projectile.ai[0] + MathHelper.PiOver2), default(Vector2)) * num861; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + } } - } + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Electrified, 120); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Vector2 end = projectile.position + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; + Texture2D tex3 = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/RedLightningTexture"); + projectile.GetAlpha(lightColor); + Vector2 scale16 = new Vector2(projectile.scale) / 2f; + for (int num289 = 0; num289 < 3; num289++) + { + if (num289 == 0) + { + scale16 = new Vector2(projectile.scale) * 0.6f; + DelegateMethods.c_1 = new Microsoft.Xna.Framework.Color(219, 104, 58, 0) * 0.5f; + } + else if (num289 == 1) + { + scale16 = new Vector2(projectile.scale) * 0.4f; + DelegateMethods.c_1 = new Microsoft.Xna.Framework.Color(255, 126, 56, 0) * 0.5f; + } + else + { + scale16 = new Vector2(projectile.scale) * 0.2f; + DelegateMethods.c_1 = new Microsoft.Xna.Framework.Color(255, 128, 128, 0) * 0.5f; + } + DelegateMethods.f_1 = 1f; + for (int num290 = projectile.oldPos.Length - 1; num290 > 0; num290--) + { + if (!(projectile.oldPos[num290] == Vector2.Zero)) + { + Vector2 start = projectile.oldPos[num290] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; + Vector2 end2 = projectile.oldPos[num290 - 1] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; + Utils.DrawLaser(spriteBatch, tex3, start, end2, scale16, new Utils.LaserLineFraming(DelegateMethods.LightningLaserDraw)); + } + } + if (projectile.oldPos[0] != Vector2.Zero) + { + DelegateMethods.f_1 = 1f; + Vector2 start2 = projectile.oldPos[0] + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; + Utils.DrawLaser(Main.spriteBatch, tex3, start2, end, scale16, new Utils.LaserLineFraming(DelegateMethods.LightningLaserDraw)); + } + } + return false; + } + } } diff --git a/Projectiles/Boss/RedLightningFeather.cs b/Projectiles/Boss/RedLightningFeather.cs index fac0313295..411ff4119a 100644 --- a/Projectiles/Boss/RedLightningFeather.cs +++ b/Projectiles/Boss/RedLightningFeather.cs @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.timeLeft = 1200; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -54,50 +54,50 @@ namespace CalamityMod.Projectiles.Boss projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X); } - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 1170) / 30f), 0f, 1f); + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 1170) / 30f), 0f, 1f); - Lighting.AddLight(projectile.Center, 0.7f * projectile.Opacity, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.7f * projectile.Opacity, 0f, 0f); - projectile.ai[0] += 1f; - float timeGateValue = 150f; - float timeGateValue2 = 300f; + projectile.ai[0] += 1f; + float timeGateValue = 150f; + float timeGateValue2 = 300f; if (projectile.ai[0] > timeGateValue) { int num103 = Player.FindClosest(projectile.Center, 1, 1); if (projectile.ai[0] <= timeGateValue2) { - if (projectile.ai[0] == timeGateValue2) - { - Vector2 aimVector = projectile.ai[1] == 0f ? (Main.player[num103].velocity * 20f) : Vector2.Zero; - Vector2 v4 = Main.player[num103].Center + aimVector - projectile.Center; + if (projectile.ai[0] == timeGateValue2) + { + Vector2 aimVector = projectile.ai[1] == 0f ? (Main.player[num103].velocity * 20f) : Vector2.Zero; + Vector2 v4 = Main.player[num103].Center + aimVector - projectile.Center; - if (float.IsNaN(v4.X) || float.IsNaN(v4.Y)) - v4 = -Vector2.UnitY; + if (float.IsNaN(v4.X) || float.IsNaN(v4.Y)) + v4 = -Vector2.UnitY; - EmitDust(); + EmitDust(); - projectile.velocity = Vector2.Normalize(v4) * 18f; - } - else if (projectile.ai[0] > timeGateValue2 - 30f) - { - if (projectile.velocity.Length() > 2f) - projectile.velocity *= 0.9f; - } - else - { - if (projectile.velocity.Length() < 12f) - projectile.velocity *= 1.02f; + projectile.velocity = Vector2.Normalize(v4) * 18f; + } + else if (projectile.ai[0] > timeGateValue2 - 30f) + { + if (projectile.velocity.Length() > 2f) + projectile.velocity *= 0.9f; + } + else + { + if (projectile.velocity.Length() < 12f) + projectile.velocity *= 1.02f; - float scaleFactor2 = projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - projectile.Center; - vector11.Normalize(); - vector11 *= scaleFactor2; + float scaleFactor2 = projectile.velocity.Length(); + Vector2 vector11 = Main.player[num103].Center - projectile.Center; + vector11.Normalize(); + vector11 *= scaleFactor2; - projectile.velocity = (projectile.velocity * 24f + vector11) / 25f; - projectile.velocity.Normalize(); - projectile.velocity *= scaleFactor2; - } + projectile.velocity = (projectile.velocity * 24f + vector11) / 25f; + projectile.velocity.Normalize(); + projectile.velocity *= scaleFactor2; + } } else projectile.tileCollide = true; @@ -116,41 +116,41 @@ namespace CalamityMod.Projectiles.Boss projectile.width = projectile.height = 64; projectile.position.X = projectile.position.X - (projectile.width / 2); projectile.position.Y = projectile.position.Y - (projectile.height / 2); - EmitDust(); + EmitDust(); projectile.Damage(); } - private void EmitDust() + private void EmitDust() { Main.PlaySound(SoundID.Item109, projectile.position); for (int num193 = 0; num193 < 6; num193++) - { - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 60, 0f, 0f, 100, default, 1.5f); - } - for (int num194 = 0; num194 < 10; num194++) - { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 60, 0f, 0f, 0, default, 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 60, 0f, 0f, 100, default, 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - } + { + Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 60, 0f, 0f, 100, default, 1.5f); + } + for (int num194 = 0; num194 < 10; num194++) + { + int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 60, 0f, 0f, 0, default, 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 60, 0f, 0f, 100, default, 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.Opacity != 1f) - return; - - target.AddBuff(BuffID.Electrified, 60); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + if (projectile.Opacity != 1f) + return; + + target.AddBuff(BuffID.Electrified, 60); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/SandBlast.cs b/Projectiles/Boss/SandBlast.cs index b81feaaf2e..ecd1974bc8 100644 --- a/Projectiles/Boss/SandBlast.cs +++ b/Projectiles/Boss/SandBlast.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Boss projectile.timeLeft = 600; projectile.Opacity = 0f; projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + } public override void AI() { @@ -46,20 +46,20 @@ namespace CalamityMod.Projectiles.Boss Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 21); } - if (projectile.ai[0] == 1f) - { - int num103 = Player.FindClosest(projectile.Center, 1, 1); - float inertia = 60f; - float scaleFactor2 = projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - projectile.Center; - vector11.Normalize(); - vector11 *= scaleFactor2; - projectile.velocity = (projectile.velocity * (inertia - 1f) + vector11) / inertia; - projectile.velocity.Normalize(); - projectile.velocity *= scaleFactor2; - } + if (projectile.ai[0] == 1f) + { + int num103 = Player.FindClosest(projectile.Center, 1, 1); + float inertia = 60f; + float scaleFactor2 = projectile.velocity.Length(); + Vector2 vector11 = Main.player[num103].Center - projectile.Center; + vector11.Normalize(); + vector11 *= scaleFactor2; + projectile.velocity = (projectile.velocity * (inertia - 1f) + vector11) / inertia; + projectile.velocity.Normalize(); + projectile.velocity *= scaleFactor2; + } - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; projectile.Opacity += 0.2f; if (projectile.Opacity > 1f) @@ -72,8 +72,8 @@ namespace CalamityMod.Projectiles.Boss public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Item14, projectile.position); - for (int dust = 0; dust <= 3; dust++) + Main.PlaySound(SoundID.Item14, projectile.position); + for (int dust = 0; dust <= 3; dust++) { float num463 = Main.rand.Next(-10, 11); float num464 = Main.rand.Next(-10, 11); diff --git a/Projectiles/Boss/SandPoisonCloud.cs b/Projectiles/Boss/SandPoisonCloud.cs index 7d17dac978..9b7134e779 100644 --- a/Projectiles/Boss/SandPoisonCloud.cs +++ b/Projectiles/Boss/SandPoisonCloud.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 52; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 52; projectile.height = 48; projectile.hostile = true; projectile.Opacity = 0f; @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Boss projectile.tileCollide = false; projectile.ignoreWater = true; projectile.timeLeft = 1800; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -78,12 +78,12 @@ namespace CalamityMod.Projectiles.Boss public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 20f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.Opacity == 0.9f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 0.9f; public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.Opacity == 0.9f) - target.AddBuff(ModContent.BuffType(), 240, true); - } + if (projectile.Opacity == 0.9f) + target.AddBuff(ModContent.BuffType(), 240, true); + } } } diff --git a/Projectiles/Boss/SandPoisonCloudOldDuke.cs b/Projectiles/Boss/SandPoisonCloudOldDuke.cs index 28141de200..9952c4b25a 100644 --- a/Projectiles/Boss/SandPoisonCloudOldDuke.cs +++ b/Projectiles/Boss/SandPoisonCloudOldDuke.cs @@ -9,9 +9,9 @@ namespace CalamityMod.Projectiles.Boss { public class SandPoisonCloudOldDuke : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/Boss/SandPoisonCloud"; + public override string Texture => "CalamityMod/Projectiles/Boss/SandPoisonCloud"; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Toxic Cloud"); Main.projFrames[projectile.type] = 4; @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Boss projectile.tileCollide = false; projectile.ignoreWater = true; projectile.timeLeft = 1800; - cooldownSlot = 1; + cooldownSlot = 1; } public override void AI() @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Boss if (projectile.timeLeft < 180) { - projectile.damage = 0; + projectile.damage = 0; if (projectile.Opacity > 0f) { projectile.Opacity -= 0.02f; @@ -79,17 +79,17 @@ namespace CalamityMod.Projectiles.Boss public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 20f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.Opacity == 0.9f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 0.9f; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.Opacity == 0.9f) - target.AddBuff(ModContent.BuffType(), 240, true); - } + if (projectile.Opacity == 0.9f) + target.AddBuff(ModContent.BuffType(), 240, true); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/SandTooth.cs b/Projectiles/Boss/SandTooth.cs index dd13482776..2556f4087d 100644 --- a/Projectiles/Boss/SandTooth.cs +++ b/Projectiles/Boss/SandTooth.cs @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Boss projectile.ignoreWater = true; projectile.penetrate = 1; projectile.timeLeft = 600; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Boss projectile.ai[1] += 1f; if (projectile.ai[1] < 150f && projectile.ai[1] > 30f) { - float inertia = 20f; - float scaleFactor2 = projectile.velocity.Length(); + float inertia = 20f; + float scaleFactor2 = projectile.velocity.Length(); Vector2 vector11 = Main.player[num103].Center - projectile.Center; vector11.Normalize(); vector11 *= scaleFactor2; @@ -38,13 +38,13 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity.Normalize(); projectile.velocity *= scaleFactor2; } - else if (projectile.ai[0] == 1f) - { - if (projectile.velocity.Length() < 16f) - projectile.velocity *= 1.01f; - } + else if (projectile.ai[0] == 1f) + { + if (projectile.velocity.Length() < 16f) + projectile.velocity *= 1.01f; + } - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver4; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver4; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Boss/SandToothOldDuke.cs b/Projectiles/Boss/SandToothOldDuke.cs index fa22b735e0..5a79d95a7a 100644 --- a/Projectiles/Boss/SandToothOldDuke.cs +++ b/Projectiles/Boss/SandToothOldDuke.cs @@ -7,9 +7,9 @@ namespace CalamityMod.Projectiles.Boss { public class SandToothOldDuke : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/Boss/SandTooth"; + public override string Texture => "CalamityMod/Projectiles/Boss/SandTooth"; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Sand Tooth"); } @@ -22,9 +22,9 @@ namespace CalamityMod.Projectiles.Boss projectile.ignoreWater = true; projectile.penetrate = 1; projectile.timeLeft = 450; - cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + cooldownSlot = 1; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { @@ -50,9 +50,9 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/ScavengerLaser.cs b/Projectiles/Boss/ScavengerLaser.cs index 501369def1..4fdd01ca89 100644 --- a/Projectiles/Boss/ScavengerLaser.cs +++ b/Projectiles/Boss/ScavengerLaser.cs @@ -59,23 +59,23 @@ namespace CalamityMod.Projectiles.Boss if (projectile.alpha < 0) projectile.alpha = 0; - if (projectile.alpha < 40) - { - int num805 = Dust.NewDust(projectile.Center - Vector2.One * 5f, 10, 10, 244, -projectile.velocity.X / 3f, -projectile.velocity.Y / 3f, 150, Color.Transparent, 0.6f); - Main.dust[num805].noGravity = true; - } + if (projectile.alpha < 40) + { + int num805 = Dust.NewDust(projectile.Center - Vector2.One * 5f, 10, 10, 244, -projectile.velocity.X / 3f, -projectile.velocity.Y / 3f, 150, Color.Transparent, 0.6f); + Main.dust[num805].noGravity = true; + } - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (projectile.ai[1] == -1f) - { - if (projectile.velocity.Length() < 18f) - projectile.velocity *= 1.05f; - else - projectile.tileCollide = true; + if (projectile.ai[1] == -1f) + { + if (projectile.velocity.Length() < 18f) + projectile.velocity *= 1.05f; + else + projectile.tileCollide = true; - return; - } + return; + } if (projectile.ai[0] == 0f) { diff --git a/Projectiles/Boss/ScavengerNuke.cs b/Projectiles/Boss/ScavengerNuke.cs index bf0ea05ad3..07f31921f5 100644 --- a/Projectiles/Boss/ScavengerNuke.cs +++ b/Projectiles/Boss/ScavengerNuke.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 44; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 44; projectile.height = 44; projectile.hostile = true; projectile.ignoreWater = true; @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; if (projectile.timeLeft < 180) projectile.tileCollide = true; @@ -105,7 +105,7 @@ namespace CalamityMod.Projectiles.Boss num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Boss/ShadeNimbusHostile.cs b/Projectiles/Boss/ShadeNimbusHostile.cs index 5308788f9d..21900c7545 100644 --- a/Projectiles/Boss/ShadeNimbusHostile.cs +++ b/Projectiles/Boss/ShadeNimbusHostile.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 28; projectile.tileCollide = false; projectile.ignoreWater = true; - projectile.hostile = true; + projectile.hostile = true; projectile.timeLeft = 360; projectile.penetrate = -1; } @@ -58,9 +58,9 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 60); - } - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 60); + } + } } diff --git a/Projectiles/Boss/ShaderainHostile.cs b/Projectiles/Boss/ShaderainHostile.cs index b2b1bd7b5e..c4af7a58e3 100644 --- a/Projectiles/Boss/ShaderainHostile.cs +++ b/Projectiles/Boss/ShaderainHostile.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.ignoreWater = true; projectile.timeLeft = 300; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { diff --git a/Projectiles/Boss/ShadowflameFireball.cs b/Projectiles/Boss/ShadowflameFireball.cs index 0aebe9fd6b..abb56b79cf 100644 --- a/Projectiles/Boss/ShadowflameFireball.cs +++ b/Projectiles/Boss/ShadowflameFireball.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.timeLeft = 360; projectile.scale = 1.25f; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { diff --git a/Projectiles/Boss/Shadowflamethrower.cs b/Projectiles/Boss/Shadowflamethrower.cs index cfe5e4d2ba..8a94e8f2c2 100644 --- a/Projectiles/Boss/Shadowflamethrower.cs +++ b/Projectiles/Boss/Shadowflamethrower.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Boss projectile.penetrate = -1; projectile.extraUpdates = 3; projectile.timeLeft = 60; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { diff --git a/Projectiles/Boss/SignusScythe.cs b/Projectiles/Boss/SignusScythe.cs index 79a11b42b6..840d5b1e30 100644 --- a/Projectiles/Boss/SignusScythe.cs +++ b/Projectiles/Boss/SignusScythe.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class SignusScythe : ModProjectile + public class SignusScythe : ModProjectile { private int counter = 0; @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 100; projectile.penetrate = -1; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -86,9 +86,9 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); } public override void Kill(int timeLeft) @@ -114,9 +114,9 @@ namespace CalamityMod.Projectiles.Boss } } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/SirenSong.cs b/Projectiles/Boss/SirenSong.cs index e32ec24404..3c807e593a 100644 --- a/Projectiles/Boss/SirenSong.cs +++ b/Projectiles/Boss/SirenSong.cs @@ -13,20 +13,20 @@ namespace CalamityMod.Projectiles.Boss public override void SetStaticDefaults() { DisplayName.SetDefault("Musical Note"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { projectile.width = 24; projectile.height = 58; projectile.hostile = true; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 960; - projectile.Opacity = 0f; - } + projectile.Opacity = 0f; + } public override void SendExtraAI(BinaryWriter writer) { @@ -42,12 +42,12 @@ namespace CalamityMod.Projectiles.Boss { projectile.velocity *= 0.985f; - if (projectile.timeLeft < 30) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 930) / 30f), 0f, 1f); + if (projectile.timeLeft < 30) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 930) / 30f), 0f, 1f); - if (projectile.localAI[0] == 0f) + if (projectile.localAI[0] == 0f) { projectile.scale += 0.01f; if (projectile.scale >= 1.1f) @@ -62,30 +62,30 @@ namespace CalamityMod.Projectiles.Boss Lighting.AddLight(projectile.Center, 0.7f * projectile.Opacity, 0.5f * projectile.Opacity, 0f); - if (CalamityGlobalNPC.leviathan != -1) - { - if (Main.npc[CalamityGlobalNPC.leviathan].active) - projectile.extraUpdates = 1; - } - } + if (CalamityGlobalNPC.leviathan != -1) + { + if (Main.npc[CalamityGlobalNPC.leviathan].active) + projectile.extraUpdates = 1; + } + } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - lightColor.R = (byte)(255 * projectile.Opacity); - lightColor.G = (byte)(255 * projectile.Opacity); - lightColor.B = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - - public override void OnHitPlayer(Player target, int damage, bool crit) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.Opacity != 1f) - return; + lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.G = (byte)(255 * projectile.Opacity); + lightColor.B = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - target.AddBuff(BuffID.Confused, 120); + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.Opacity != 1f) + return; + + target.AddBuff(BuffID.Confused, 120); } } } diff --git a/Projectiles/Boss/SkyFlare.cs b/Projectiles/Boss/SkyFlare.cs index d84a1064e5..13a7ee2894 100644 --- a/Projectiles/Boss/SkyFlare.cs +++ b/Projectiles/Boss/SkyFlare.cs @@ -122,9 +122,9 @@ namespace CalamityMod.Projectiles.Boss } } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/SkyFlareRevenge.cs b/Projectiles/Boss/SkyFlareRevenge.cs index f39d157b8c..30472d4cd3 100644 --- a/Projectiles/Boss/SkyFlareRevenge.cs +++ b/Projectiles/Boss/SkyFlareRevenge.cs @@ -71,17 +71,17 @@ namespace CalamityMod.Projectiles.Boss } if (projectile.owner == Main.myPlayer) { - int type = ModContent.ProjectileType(); - int damage = projectile.GetProjectileDamage(ModContent.NPCType()); - int nado = Projectile.NewProjectile(projectile.Center, Vector2.Zero, type, damage, 4f, Main.myPlayer, 16f, 50f); + int type = ModContent.ProjectileType(); + int damage = projectile.GetProjectileDamage(ModContent.NPCType()); + int nado = Projectile.NewProjectile(projectile.Center, Vector2.Zero, type, damage, 4f, Main.myPlayer, 16f, 50f); Main.projectile[nado].Bottom = projectile.Center; Main.projectile[nado].netUpdate = true; } } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/SporeGasPlantera.cs b/Projectiles/Boss/SporeGasPlantera.cs index 0b7b154d92..56a79f23c4 100644 --- a/Projectiles/Boss/SporeGasPlantera.cs +++ b/Projectiles/Boss/SporeGasPlantera.cs @@ -18,15 +18,15 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 32; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 32; projectile.height = 32; projectile.hostile = true; projectile.ignoreWater = true; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -42,10 +42,10 @@ namespace CalamityMod.Projectiles.Boss { projectile.ai[1] += 1f; if (projectile.ai[1] > 1800f) - { + { projectile.localAI[0] += 10f; - projectile.damage = 0; - } + projectile.damage = 0; + } if (projectile.localAI[0] > 255f) { @@ -63,20 +63,20 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity *= 0.98f; } - public override bool CanHitPlayer(Player target) => projectile.ai[1] <= 1800f && projectile.ai[1] > 120f; + public override bool CanHitPlayer(Player target) => projectile.ai[1] <= 1800f && projectile.ai[1] > 120f; - public override Color? GetAlpha(Color lightColor) - { - if (projectile.ai[1] > 1800f) - { - byte b2 = (byte)((26f - (projectile.ai[1] - 1800f)) * 10f); - byte a2 = (byte)(projectile.alpha * (b2 / 255f)); - return new Color(b2, b2, b2, a2); - } - return new Color(255, 255, 255, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + if (projectile.ai[1] > 1800f) + { + byte b2 = (byte)((26f - (projectile.ai[1] - 1800f)) * 10f); + byte a2 = (byte)(projectile.alpha * (b2 / 255f)); + return new Color(b2, b2, b2, a2); + } + return new Color(255, 255, 255, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { // Changes the texture of the projectile Texture2D texture = Main.projectileTexture[projectile.type]; @@ -99,8 +99,8 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.ai[1] <= 1800f && projectile.ai[1] > 120f) - target.AddBuff(BuffID.Poisoned, 240); + if (projectile.ai[1] <= 1800f && projectile.ai[1] > 120f) + target.AddBuff(BuffID.Poisoned, 240); } } } diff --git a/Projectiles/Boss/SupremeCataclysmFist.cs b/Projectiles/Boss/SupremeCataclysmFist.cs index 4c4f93941c..ecc52365fe 100644 --- a/Projectiles/Boss/SupremeCataclysmFist.cs +++ b/Projectiles/Boss/SupremeCataclysmFist.cs @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Boss target.AddBuff(ModContent.BuffType(), 120, true); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { target.Calamity().lastProjectileHit = projectile; } diff --git a/Projectiles/Boss/SupremeCatastropheSlash.cs b/Projectiles/Boss/SupremeCatastropheSlash.cs index 6bde7b6261..ebacc36022 100644 --- a/Projectiles/Boss/SupremeCatastropheSlash.cs +++ b/Projectiles/Boss/SupremeCatastropheSlash.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class SupremeCatastropheSlash : ModProjectile + public class SupremeCatastropheSlash : ModProjectile { public ref float Time => ref projectile.ai[0]; @@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.Boss target.AddBuff(ModContent.BuffType(), 120, true); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { target.Calamity().lastProjectileHit = projectile; } diff --git a/Projectiles/Boss/SwirlingFire.cs b/Projectiles/Boss/SwirlingFire.cs index 0978ac2b30..0f5cb05e31 100644 --- a/Projectiles/Boss/SwirlingFire.cs +++ b/Projectiles/Boss/SwirlingFire.cs @@ -4,21 +4,21 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class SwirlingFire : ModProjectile + public class SwirlingFire : ModProjectile { - public ref float AngularTurnSpeed => ref projectile.ai[0]; - public ref float Time => ref projectile.ai[1]; + public ref float AngularTurnSpeed => ref projectile.ai[0]; + public ref float Time => ref projectile.ai[1]; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetStaticDefaults() { DisplayName.SetDefault("Fire"); - } + } public override void SetDefaults() { projectile.width = projectile.height = 10; projectile.hostile = true; - projectile.ignoreWater = true; + projectile.ignoreWater = true; projectile.tileCollide = false; projectile.alpha = 255; projectile.penetrate = -1; diff --git a/Projectiles/Boss/ThanatosBeamStart.cs b/Projectiles/Boss/ThanatosBeamStart.cs index 54b22b988a..0379b817e3 100644 --- a/Projectiles/Boss/ThanatosBeamStart.cs +++ b/Projectiles/Boss/ThanatosBeamStart.cs @@ -14,236 +14,236 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class ThanatosBeamStart : BaseLaserbeamProjectile - { - public int OwnerIndex - { - get => (int)projectile.ai[1]; - set => projectile.ai[1] = value; - } + public class ThanatosBeamStart : BaseLaserbeamProjectile + { + public int OwnerIndex + { + get => (int)projectile.ai[1]; + set => projectile.ai[1] = value; + } - public bool OwnerIsValid => Main.npc[OwnerIndex].active && Main.npc[OwnerIndex].type == ModContent.NPCType(); + public bool OwnerIsValid => Main.npc[OwnerIndex].active && Main.npc[OwnerIndex].type == ModContent.NPCType(); - public override float MaxScale => 1f; - public override float MaxLaserLength => 3600f; - public override float Lifetime => 180; - public override Color LaserOverlayColor => new Color(250, 250, 250, 100); - public override Color LightCastColor => Color.White; - public override Texture2D LaserBeginTexture => Main.projectileTexture[projectile.type]; - public override Texture2D LaserMiddleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ThanatosBeamMiddle"); - public override Texture2D LaserEndTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ThanatosBeamEnd"); + public override float MaxScale => 1f; + public override float MaxLaserLength => 3600f; + public override float Lifetime => 180; + public override Color LaserOverlayColor => new Color(250, 250, 250, 100); + public override Color LightCastColor => Color.White; + public override Texture2D LaserBeginTexture => Main.projectileTexture[projectile.type]; + public override Texture2D LaserMiddleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ThanatosBeamMiddle"); + public override Texture2D LaserEndTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ThanatosBeamEnd"); - public override void SetStaticDefaults() - { - // Thanatos' mouth laser - DisplayName.SetDefault("T Hanos Beam"); - // This is its serious name - // DisplayName.SetDefault("Gamma Disintegration Beam"); - Main.projFrames[projectile.type] = 5; - } + public override void SetStaticDefaults() + { + // Thanatos' mouth laser + DisplayName.SetDefault("T Hanos Beam"); + // This is its serious name + // DisplayName.SetDefault("Gamma Disintegration Beam"); + Main.projFrames[projectile.type] = 5; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 40; - projectile.hostile = true; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.timeLeft = 600; - projectile.Calamity().canBreakPlayerDefense = true; - cooldownSlot = 1; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 40; + projectile.hostile = true; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft = 600; + projectile.Calamity().canBreakPlayerDefense = true; + cooldownSlot = 1; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - writer.Write(projectile.localAI[1]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + writer.Write(projectile.localAI[1]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - projectile.localAI[1] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + projectile.localAI[1] = reader.ReadSingle(); + } - public override void AttachToSomething() - { - if (OwnerIsValid) - { - Vector2 fireFrom = Main.npc[OwnerIndex].Center + Vector2.UnitY * Main.npc[OwnerIndex].gfxOffY; - fireFrom += projectile.velocity.SafeNormalize(Vector2.UnitY) * projectile.scale * 174f; - projectile.Center = fireFrom; - } + public override void AttachToSomething() + { + if (OwnerIsValid) + { + Vector2 fireFrom = Main.npc[OwnerIndex].Center + Vector2.UnitY * Main.npc[OwnerIndex].gfxOffY; + fireFrom += projectile.velocity.SafeNormalize(Vector2.UnitY) * projectile.scale * 174f; + projectile.Center = fireFrom; + } - // Die of the owner is invalid in some way. - // This is not done client-side, as it's possible that they may not have recieved the proper owner index yet. - else - { - if (Main.netMode != NetmodeID.MultiplayerClient) - projectile.Kill(); - return; - } + // Die of the owner is invalid in some way. + // This is not done client-side, as it's possible that they may not have recieved the proper owner index yet. + else + { + if (Main.netMode != NetmodeID.MultiplayerClient) + projectile.Kill(); + return; + } - // Die if the owner is not performing Thanatos' deathray attack. - if (Main.npc[OwnerIndex].Calamity().newAI[0] != (float)ThanatosHead.Phase.Deathray) - { - projectile.Kill(); - return; - } - } + // Die if the owner is not performing Thanatos' deathray attack. + if (Main.npc[OwnerIndex].Calamity().newAI[0] != (float)ThanatosHead.Phase.Deathray) + { + projectile.Kill(); + return; + } + } - public override void UpdateLaserMotion() - { - projectile.velocity = Main.npc[OwnerIndex].velocity.SafeNormalize(Vector2.UnitY); - projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; - } + public override void UpdateLaserMotion() + { + projectile.velocity = Main.npc[OwnerIndex].velocity.SafeNormalize(Vector2.UnitY); + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + } - public override void PostAI() - { - if (!OwnerIsValid) - return; + public override void PostAI() + { + if (!OwnerIsValid) + return; - // Difficulty modes. Used during the firing of the perpendicular lasers. - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + // Difficulty modes. Used during the firing of the perpendicular lasers. + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - // Spawn dust at the end of the beam. - int dustType = (int)CalamityDusts.Brimstone; - Vector2 dustCreationPosition = projectile.Center + projectile.velocity * (LaserLength - 14f); - for (int i = 0; i < 2; i++) - { - float dustDirection = projectile.velocity.ToRotation() + Main.rand.NextBool().ToDirectionInt() * MathHelper.PiOver2; - Vector2 dustVelocity = dustDirection.ToRotationVector2() * Main.rand.NextFloat(2f, 4f); + // Spawn dust at the end of the beam. + int dustType = (int)CalamityDusts.Brimstone; + Vector2 dustCreationPosition = projectile.Center + projectile.velocity * (LaserLength - 14f); + for (int i = 0; i < 2; i++) + { + float dustDirection = projectile.velocity.ToRotation() + Main.rand.NextBool().ToDirectionInt() * MathHelper.PiOver2; + Vector2 dustVelocity = dustDirection.ToRotationVector2() * Main.rand.NextFloat(2f, 4f); - Dust redFlame = Dust.NewDustDirect(dustCreationPosition, 0, 0, dustType, dustVelocity.X, dustVelocity.Y, 0, default, 1f); - redFlame.noGravity = true; - redFlame.scale = 1.7f; - } + Dust redFlame = Dust.NewDustDirect(dustCreationPosition, 0, 0, dustType, dustVelocity.X, dustVelocity.Y, 0, default, 1f); + redFlame.noGravity = true; + redFlame.scale = 1.7f; + } - if (Main.rand.NextBool(5)) - { - Vector2 dustSpawnOffset = projectile.velocity.RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloatDirection() * projectile.width * 0.5f; + if (Main.rand.NextBool(5)) + { + Vector2 dustSpawnOffset = projectile.velocity.RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloatDirection() * projectile.width * 0.5f; - Dust redFlame = Dust.NewDustDirect(dustCreationPosition + dustSpawnOffset - Vector2.One * 4f, 8, 8, dustType, 0f, 0f, 100, default, 1.5f); - redFlame.velocity *= 0.5f; + Dust redFlame = Dust.NewDustDirect(dustCreationPosition + dustSpawnOffset - Vector2.One * 4f, 8, 8, dustType, 0f, 0f, 100, default, 1.5f); + redFlame.velocity *= 0.5f; - // Ensure that the dust always moves up. - redFlame.velocity.Y = -Math.Abs(redFlame.velocity.Y); - } + // Ensure that the dust always moves up. + redFlame.velocity.Y = -Math.Abs(redFlame.velocity.Y); + } - // Periodically fire beams along the laser perpendicular to its direction. - float laserFireRate = expertMode ? 80f : 160f; - if (Main.npc[OwnerIndex].Calamity().newAI[2] % laserFireRate == 0f) - { - // Play a laser sound to go with the beams. - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), Main.npc[OwnerIndex].Center); + // Periodically fire beams along the laser perpendicular to its direction. + float laserFireRate = expertMode ? 80f : 160f; + if (Main.npc[OwnerIndex].Calamity().newAI[2] % laserFireRate == 0f) + { + // Play a laser sound to go with the beams. + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), Main.npc[OwnerIndex].Center); - if (projectile.owner == Main.myPlayer) - { - Vector2 beamDirection = projectile.velocity.SafeNormalize(Vector2.UnitY); - float distanceBetweenProjectiles = malice ? 160f : death ? 256f : revenge ? 288f : 320f; - Vector2 laserFirePosition = Main.npc[OwnerIndex].Center + beamDirection * distanceBetweenProjectiles; - int laserCount = (int)(LaserLength / distanceBetweenProjectiles); - int type = ModContent.ProjectileType(); - int damage = projectile.GetProjectileDamage(Main.npc[OwnerIndex].type); - for (int i = 0; i < laserCount; i++) - { - int totalProjectiles = 2; - float radians = MathHelper.TwoPi / totalProjectiles; - for (int j = 0; j < totalProjectiles; j++) - { - Vector2 projVelocity = projectile.velocity.RotatedBy(radians * j + MathHelper.PiOver2) * 12f; - Projectile.NewProjectile(laserFirePosition, projVelocity, type, damage, 0f, Main.myPlayer, 0f, -1f); - } - laserFirePosition += beamDirection * distanceBetweenProjectiles; - } - } - } + if (projectile.owner == Main.myPlayer) + { + Vector2 beamDirection = projectile.velocity.SafeNormalize(Vector2.UnitY); + float distanceBetweenProjectiles = malice ? 160f : death ? 256f : revenge ? 288f : 320f; + Vector2 laserFirePosition = Main.npc[OwnerIndex].Center + beamDirection * distanceBetweenProjectiles; + int laserCount = (int)(LaserLength / distanceBetweenProjectiles); + int type = ModContent.ProjectileType(); + int damage = projectile.GetProjectileDamage(Main.npc[OwnerIndex].type); + for (int i = 0; i < laserCount; i++) + { + int totalProjectiles = 2; + float radians = MathHelper.TwoPi / totalProjectiles; + for (int j = 0; j < totalProjectiles; j++) + { + Vector2 projVelocity = projectile.velocity.RotatedBy(radians * j + MathHelper.PiOver2) * 12f; + Projectile.NewProjectile(laserFirePosition, projVelocity, type, damage, 0f, Main.myPlayer, 0f, -1f); + } + laserFirePosition += beamDirection * distanceBetweenProjectiles; + } + } + } - // Determine frames. - projectile.frameCounter++; - if (projectile.frameCounter % 5f == 0f) - projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; - } + // Determine frames. + projectile.frameCounter++; + if (projectile.frameCounter % 5f == 0f) + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (!OwnerIsValid) - return false; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (!OwnerIsValid) + return false; - // This should never happen, but just in case. - if (projectile.velocity == Vector2.Zero || projectile.localAI[0] < 2f) - return false; + // This should never happen, but just in case. + if (projectile.velocity == Vector2.Zero || projectile.localAI[0] < 2f) + return false; - Color beamColor = LaserOverlayColor; - Rectangle startFrameArea = LaserBeginTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); - Rectangle middleFrameArea = LaserMiddleTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); - Rectangle endFrameArea = LaserEndTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + Color beamColor = LaserOverlayColor; + Rectangle startFrameArea = LaserBeginTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + Rectangle middleFrameArea = LaserMiddleTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + Rectangle endFrameArea = LaserEndTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); - // Start texture drawing. - spriteBatch.Draw(LaserBeginTexture, - projectile.Center - Main.screenPosition, - startFrameArea, - beamColor, - projectile.rotation, - LaserBeginTexture.Size() / 2f, - projectile.scale, - SpriteEffects.None, - 0f); + // Start texture drawing. + spriteBatch.Draw(LaserBeginTexture, + projectile.Center - Main.screenPosition, + startFrameArea, + beamColor, + projectile.rotation, + LaserBeginTexture.Size() / 2f, + projectile.scale, + SpriteEffects.None, + 0f); - // Prepare things for body drawing. - float laserBodyLength = LaserLength + middleFrameArea.Height; - Vector2 centerOnLaser = projectile.Center + projectile.velocity * -5f; + // Prepare things for body drawing. + float laserBodyLength = LaserLength + middleFrameArea.Height; + Vector2 centerOnLaser = projectile.Center + projectile.velocity * -5f; - // Body drawing. - if (laserBodyLength > 0f) - { - float laserOffset = middleFrameArea.Height * projectile.scale; - float incrementalBodyLength = 0f; - while (incrementalBodyLength + 1f < laserBodyLength) - { - spriteBatch.Draw(LaserMiddleTexture, - centerOnLaser - Main.screenPosition, - middleFrameArea, - beamColor, - projectile.rotation, - LaserMiddleTexture.Size() * 0.5f, - projectile.scale, - SpriteEffects.None, - 0f); - incrementalBodyLength += laserOffset; - centerOnLaser += projectile.velocity * laserOffset; - middleFrameArea.Y += LaserMiddleTexture.Height / Main.projFrames[projectile.type]; - if (middleFrameArea.Y + middleFrameArea.Height > LaserMiddleTexture.Height) - middleFrameArea.Y = 0; - } - } + // Body drawing. + if (laserBodyLength > 0f) + { + float laserOffset = middleFrameArea.Height * projectile.scale; + float incrementalBodyLength = 0f; + while (incrementalBodyLength + 1f < laserBodyLength) + { + spriteBatch.Draw(LaserMiddleTexture, + centerOnLaser - Main.screenPosition, + middleFrameArea, + beamColor, + projectile.rotation, + LaserMiddleTexture.Size() * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + incrementalBodyLength += laserOffset; + centerOnLaser += projectile.velocity * laserOffset; + middleFrameArea.Y += LaserMiddleTexture.Height / Main.projFrames[projectile.type]; + if (middleFrameArea.Y + middleFrameArea.Height > LaserMiddleTexture.Height) + middleFrameArea.Y = 0; + } + } - Vector2 laserEndCenter = centerOnLaser - Main.screenPosition; - spriteBatch.Draw(LaserEndTexture, - laserEndCenter, - endFrameArea, - beamColor, - projectile.rotation, - LaserEndTexture.Size() * 0.5f, - projectile.scale, - SpriteEffects.None, - 0f); - return false; - } + Vector2 laserEndCenter = centerOnLaser - Main.screenPosition; + spriteBatch.Draw(LaserEndTexture, + laserEndCenter, + endFrameArea, + beamColor, + projectile.rotation, + LaserEndTexture.Size() * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + return false; + } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 360); - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 360); + } - public override bool CanHitPlayer(Player target) => OwnerIsValid && projectile.scale >= 0.5f; + public override bool CanHitPlayer(Player target) => OwnerIsValid && projectile.scale >= 0.5f; - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/ThanatosBeamTelegraph.cs b/Projectiles/Boss/ThanatosBeamTelegraph.cs index 8740b4e632..1b3f77c614 100644 --- a/Projectiles/Boss/ThanatosBeamTelegraph.cs +++ b/Projectiles/Boss/ThanatosBeamTelegraph.cs @@ -17,18 +17,18 @@ namespace CalamityMod.Projectiles.Boss public ref float Time => ref projectile.localAI[1]; public const int Lifetime = 180; public const float TelegraphWidth = 3600f; - public const float BeamPosOffset = 16f; - public override void SetStaticDefaults() => DisplayName.SetDefault("Gamma Disintegration Beam Telegraph"); + public const float BeamPosOffset = 16f; + public override void SetStaticDefaults() => DisplayName.SetDefault("Gamma Disintegration Beam Telegraph"); public override void SetDefaults() { - projectile.width = projectile.height = 4; + projectile.width = projectile.height = 4; projectile.ignoreWater = true; projectile.tileCollide = false; projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = Lifetime; - } + } public override void SendExtraAI(BinaryWriter writer) { @@ -51,20 +51,20 @@ namespace CalamityMod.Projectiles.Boss return; } - // The direction of the host NPC. - Vector2 hostNPCDirection = Vector2.Normalize(ThingToAttachTo.velocity); + // The direction of the host NPC. + Vector2 hostNPCDirection = Vector2.Normalize(ThingToAttachTo.velocity); - // Offset to move the beam forward so that it starts inside the NPC's mouth. - float beamStartForwardsOffset = -8f; + // Offset to move the beam forward so that it starts inside the NPC's mouth. + float beamStartForwardsOffset = -8f; - // Set the starting location of the beam to the center of the NPC. - projectile.Center = ThingToAttachTo.Center; - // Add a fixed offset to align with the NPC's spritesheet (?) - projectile.position += hostNPCDirection * BeamPosOffset + new Vector2(0f, -ThingToAttachTo.gfxOffY); - // Add the forwards offset, measured in pixels. - projectile.position += hostNPCDirection * beamStartForwardsOffset; + // Set the starting location of the beam to the center of the NPC. + projectile.Center = ThingToAttachTo.Center; + // Add a fixed offset to align with the NPC's spritesheet (?) + projectile.position += hostNPCDirection * BeamPosOffset + new Vector2(0f, -ThingToAttachTo.gfxOffY); + // Add the forwards offset, measured in pixels. + projectile.position += hostNPCDirection * beamStartForwardsOffset; - projectile.rotation = StartingRotationalOffset.AngleLerp(ConvergenceAngle, ConvergenceRatio) + ThingToAttachTo.velocity.ToRotation(); + projectile.rotation = StartingRotationalOffset.AngleLerp(ConvergenceAngle, ConvergenceRatio) + ThingToAttachTo.velocity.ToRotation(); Time++; } diff --git a/Projectiles/Boss/ThanatosLaser.cs b/Projectiles/Boss/ThanatosLaser.cs index 594129480b..4383f72132 100644 --- a/Projectiles/Boss/ThanatosLaser.cs +++ b/Projectiles/Boss/ThanatosLaser.cs @@ -12,284 +12,284 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class ThanatosLaser : ModProjectile - { - public float TelegraphDelay - { - get => projectile.ai[0]; - set => projectile.ai[0] = value; - } + public class ThanatosLaser : ModProjectile + { + public float TelegraphDelay + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } - public NPC ThingToAttachTo => Main.npc.IndexInRange((int)projectile.ai[1]) ? Main.npc[(int)projectile.ai[1]] : null; + public NPC ThingToAttachTo => Main.npc.IndexInRange((int)projectile.ai[1]) ? Main.npc[(int)projectile.ai[1]] : null; - public Vector2 Destination; - public Vector2 Velocity; - public const float TelegraphTotalTime = 30f; - public const float TelegraphFadeTime = 15f; - public const float TelegraphWidth = 4200f; - public const float LaserVelocity = 10f; + public Vector2 Destination; + public Vector2 Velocity; + public const float TelegraphTotalTime = 30f; + public const float TelegraphFadeTime = 15f; + public const float TelegraphWidth = 4200f; + public const float LaserVelocity = 10f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Exo Pulse Laser"); - Main.projFrames[projectile.type] = 4; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Exo Pulse Laser"); + Main.projFrames[projectile.type] = 4; + } - public override void SetDefaults() - { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 22; - projectile.height = 22; - projectile.hostile = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.extraUpdates = 1; - projectile.timeLeft = 600; - cooldownSlot = 1; - } + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 22; + projectile.height = 22; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.extraUpdates = 1; + projectile.timeLeft = 600; + cooldownSlot = 1; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.WriteVector2(Destination); - writer.WriteVector2(Velocity); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(Destination); + writer.WriteVector2(Velocity); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - Destination = reader.ReadVector2(); - Velocity = reader.ReadVector2(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + Destination = reader.ReadVector2(); + Velocity = reader.ReadVector2(); + } - public override void AI() - { - // Determine the relative opacities for each player based on their distance. - // This has a lower bound of 0.35 to prevent the laser from going completely invisible and players getting hit by cheap shots. - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; - projectile.netUpdate = true; - } + public override void AI() + { + // Determine the relative opacities for each player based on their distance. + // This has a lower bound of 0.35 to prevent the laser from going completely invisible and players getting hit by cheap shots. + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; + projectile.netUpdate = true; + } - projectile.frameCounter++; - if (projectile.frameCounter > 12) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - projectile.frame = 0; + projectile.frameCounter++; + if (projectile.frameCounter > 12) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + projectile.frame = 0; - Lighting.AddLight(projectile.Center, 0.6f, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.6f, 0f, 0f); - // If there is no NPC to attach to, run this instead. - if (projectile.ai[1] == -1f) - { - // Fade in after telegraphs have faded. - if (TelegraphDelay > TelegraphTotalTime) - { - if (projectile.alpha > 0) - projectile.alpha -= 25; - if (projectile.alpha < 0) - projectile.alpha = 0; + // If there is no NPC to attach to, run this instead. + if (projectile.ai[1] == -1f) + { + // Fade in after telegraphs have faded. + if (TelegraphDelay > TelegraphTotalTime) + { + if (projectile.alpha > 0) + projectile.alpha -= 25; + if (projectile.alpha < 0) + projectile.alpha = 0; - // If a velocity is in reserve, set the true velocity to it and make it as "taken" by setting it to <0,0> - if (Velocity != Vector2.Zero) - { - projectile.extraUpdates = 3; - projectile.velocity = Velocity * ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.25f : 1f); - Velocity = Vector2.Zero; - projectile.netUpdate = true; - } + // If a velocity is in reserve, set the true velocity to it and make it as "taken" by setting it to <0,0> + if (Velocity != Vector2.Zero) + { + projectile.extraUpdates = 3; + projectile.velocity = Velocity * ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.25f : 1f); + Velocity = Vector2.Zero; + projectile.netUpdate = true; + } - // Direction and rotation. - if (projectile.velocity.X < 0f) - { - projectile.spriteDirection = -1; - projectile.rotation = (float)Math.Atan2((double)-(double)projectile.velocity.Y, (double)-(double)projectile.velocity.X); - } - else - { - projectile.spriteDirection = 1; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); - } - } - else if (Velocity == Vector2.Zero) - { - Velocity = projectile.velocity; - projectile.velocity = Vector2.Zero; - projectile.netUpdate = true; + // Direction and rotation. + if (projectile.velocity.X < 0f) + { + projectile.spriteDirection = -1; + projectile.rotation = (float)Math.Atan2((double)-(double)projectile.velocity.Y, (double)-(double)projectile.velocity.X); + } + else + { + projectile.spriteDirection = 1; + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); + } + } + else if (Velocity == Vector2.Zero) + { + Velocity = projectile.velocity; + projectile.velocity = Vector2.Zero; + projectile.netUpdate = true; - // Direction and rotation. - if (projectile.velocity.X < 0f) - { - projectile.spriteDirection = -1; - projectile.rotation = (float)Math.Atan2((double)-(double)Velocity.Y, (double)-(double)Velocity.X); - } - else - { - projectile.spriteDirection = 1; - projectile.rotation = (float)Math.Atan2((double)Velocity.Y, (double)Velocity.X); - } - } + // Direction and rotation. + if (projectile.velocity.X < 0f) + { + projectile.spriteDirection = -1; + projectile.rotation = (float)Math.Atan2((double)-(double)Velocity.Y, (double)-(double)Velocity.X); + } + else + { + projectile.spriteDirection = 1; + projectile.rotation = (float)Math.Atan2((double)Velocity.Y, (double)Velocity.X); + } + } - TelegraphDelay++; + TelegraphDelay++; - return; - } + return; + } - // Die if the thing to attach to disappears. - if (ThingToAttachTo is null || !ThingToAttachTo.active) - { - projectile.Kill(); - return; - } + // Die if the thing to attach to disappears. + if (ThingToAttachTo is null || !ThingToAttachTo.active) + { + projectile.Kill(); + return; + } - // If the Ares Laser Cannon is the owner. - bool aresLaserIsOwner = ThingToAttachTo.type == ModContent.NPCType(); + // If the Ares Laser Cannon is the owner. + bool aresLaserIsOwner = ThingToAttachTo.type == ModContent.NPCType(); - // Fade in after telegraphs have faded. - if (TelegraphDelay > TelegraphTotalTime) - { - if (projectile.alpha > 0) - projectile.alpha -= 25; - if (projectile.alpha < 0) - projectile.alpha = 0; + // Fade in after telegraphs have faded. + if (TelegraphDelay > TelegraphTotalTime) + { + if (projectile.alpha > 0) + projectile.alpha -= 25; + if (projectile.alpha < 0) + projectile.alpha = 0; - // If a velocity is in reserve, set the true velocity to it and make it as "taken" by setting it to <0,0> - if (Velocity != Vector2.Zero) - { - projectile.extraUpdates = 3; - projectile.velocity = Velocity * ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.25f : 1f); - Velocity = Vector2.Zero; - projectile.netUpdate = true; - } + // If a velocity is in reserve, set the true velocity to it and make it as "taken" by setting it to <0,0> + if (Velocity != Vector2.Zero) + { + projectile.extraUpdates = 3; + projectile.velocity = Velocity * ((CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.25f : 1f); + Velocity = Vector2.Zero; + projectile.netUpdate = true; + } - // Direction and rotation. - if (projectile.velocity.X < 0f) - { - projectile.spriteDirection = -1; - projectile.rotation = (float)Math.Atan2((double)-(double)projectile.velocity.Y, (double)-(double)projectile.velocity.X); - } - else - { - projectile.spriteDirection = 1; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); - } - } - else if (Destination == Vector2.Zero) - { - // Set start of telegraph to the npc center. - projectile.Center = ThingToAttachTo.Center; + // Direction and rotation. + if (projectile.velocity.X < 0f) + { + projectile.spriteDirection = -1; + projectile.rotation = (float)Math.Atan2((double)-(double)projectile.velocity.Y, (double)-(double)projectile.velocity.X); + } + else + { + projectile.spriteDirection = 1; + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); + } + } + else if (Destination == Vector2.Zero) + { + // Set start of telegraph to the npc center. + projectile.Center = ThingToAttachTo.Center; - // Set destination of the laser, the target's center. - Destination = projectile.velocity; + // Set destination of the laser, the target's center. + Destination = projectile.velocity; - if (aresLaserIsOwner) - projectile.Center += Vector2.Normalize(Destination - ThingToAttachTo.Center) * 70f + Vector2.UnitY * 16f; + if (aresLaserIsOwner) + projectile.Center += Vector2.Normalize(Destination - ThingToAttachTo.Center) * 70f + Vector2.UnitY * 16f; - // Calculate and store the velocity that will be used for laser telegraph rotation and beam firing. - Vector2 projectileDestination = Destination - ThingToAttachTo.Center; - Velocity = Vector2.Normalize(projectileDestination) * LaserVelocity; + // Calculate and store the velocity that will be used for laser telegraph rotation and beam firing. + Vector2 projectileDestination = Destination - ThingToAttachTo.Center; + Velocity = Vector2.Normalize(projectileDestination) * LaserVelocity; - // Set velocity to zero. - projectile.velocity = Vector2.Zero; - projectile.netUpdate = true; + // Set velocity to zero. + projectile.velocity = Vector2.Zero; + projectile.netUpdate = true; - // Direction and rotation. - if (projectile.velocity.X < 0f) - { - projectile.spriteDirection = -1; - projectile.rotation = (float)Math.Atan2((double)-(double)Velocity.Y, (double)-(double)Velocity.X); - } - else - { - projectile.spriteDirection = 1; - projectile.rotation = (float)Math.Atan2((double)Velocity.Y, (double)Velocity.X); - } - } - else - { - // Set start of telegraph to the npc center. - projectile.Center = ThingToAttachTo.Center; + // Direction and rotation. + if (projectile.velocity.X < 0f) + { + projectile.spriteDirection = -1; + projectile.rotation = (float)Math.Atan2((double)-(double)Velocity.Y, (double)-(double)Velocity.X); + } + else + { + projectile.spriteDirection = 1; + projectile.rotation = (float)Math.Atan2((double)Velocity.Y, (double)Velocity.X); + } + } + else + { + // Set start of telegraph to the npc center. + projectile.Center = ThingToAttachTo.Center; - if (aresLaserIsOwner) - projectile.Center += Vector2.Normalize(Destination - ThingToAttachTo.Center) * 70f + Vector2.UnitY * 16f; + if (aresLaserIsOwner) + projectile.Center += Vector2.Normalize(Destination - ThingToAttachTo.Center) * 70f + Vector2.UnitY * 16f; - // Calculate and store the velocity that will be used for laser telegraph rotation and beam firing. - Vector2 projectileDestination = Destination - ThingToAttachTo.Center; - Velocity = Vector2.Normalize(projectileDestination) * LaserVelocity; + // Calculate and store the velocity that will be used for laser telegraph rotation and beam firing. + Vector2 projectileDestination = Destination - ThingToAttachTo.Center; + Velocity = Vector2.Normalize(projectileDestination) * LaserVelocity; - // Direction and rotation. - if (projectile.velocity.X < 0f) - { - projectile.spriteDirection = -1; - projectile.rotation = (float)Math.Atan2((double)-(double)Velocity.Y, (double)-(double)Velocity.X); - } - else - { - projectile.spriteDirection = 1; - projectile.rotation = (float)Math.Atan2((double)Velocity.Y, (double)Velocity.X); - } - } + // Direction and rotation. + if (projectile.velocity.X < 0f) + { + projectile.spriteDirection = -1; + projectile.rotation = (float)Math.Atan2((double)-(double)Velocity.Y, (double)-(double)Velocity.X); + } + else + { + projectile.spriteDirection = 1; + projectile.rotation = (float)Math.Atan2((double)Velocity.Y, (double)Velocity.X); + } + } - TelegraphDelay++; - } + TelegraphDelay++; + } - public override bool CanHitPlayer(Player target) => TelegraphDelay > TelegraphTotalTime; + public override bool CanHitPlayer(Player target) => TelegraphDelay > TelegraphTotalTime; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (TelegraphDelay > TelegraphTotalTime) - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (TelegraphDelay > TelegraphTotalTime) + target.AddBuff(ModContent.BuffType(), 180); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { - target.Calamity().lastProjectileHit = projectile; - } + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - return CalamityUtils.CircularHitboxCollision(projHitbox.Center(), projectile.Size.Length() * 0.5f, targetHitbox); - } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + return CalamityUtils.CircularHitboxCollision(projHitbox.Center(), projectile.Size.Length() * 0.5f, targetHitbox); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (TelegraphDelay >= TelegraphTotalTime) - { - lightColor.R = (byte)(255 * projectile.Opacity); - lightColor.G = (byte)(255 * projectile.Opacity); - lightColor.B = (byte)(255 * projectile.Opacity); - Vector2 drawOffset = projectile.velocity.SafeNormalize(Vector2.Zero) * -30f; - projectile.Center += drawOffset; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - projectile.Center -= drawOffset; - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (TelegraphDelay >= TelegraphTotalTime) + { + lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.G = (byte)(255 * projectile.Opacity); + lightColor.B = (byte)(255 * projectile.Opacity); + Vector2 drawOffset = projectile.velocity.SafeNormalize(Vector2.Zero) * -30f; + projectile.Center += drawOffset; + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + projectile.Center -= drawOffset; + return false; + } - Texture2D laserTelegraph = ModContent.GetTexture("CalamityMod/ExtraTextures/LaserWallTelegraphBeam"); + Texture2D laserTelegraph = ModContent.GetTexture("CalamityMod/ExtraTextures/LaserWallTelegraphBeam"); - float yScale = 2f; - if (TelegraphDelay < TelegraphFadeTime) - yScale = MathHelper.Lerp(0f, 2f, TelegraphDelay / 15f); - if (TelegraphDelay > TelegraphTotalTime - TelegraphFadeTime) - yScale = MathHelper.Lerp(2f, 0f, (TelegraphDelay - (TelegraphTotalTime - TelegraphFadeTime)) / 15f); + float yScale = 2f; + if (TelegraphDelay < TelegraphFadeTime) + yScale = MathHelper.Lerp(0f, 2f, TelegraphDelay / 15f); + if (TelegraphDelay > TelegraphTotalTime - TelegraphFadeTime) + yScale = MathHelper.Lerp(2f, 0f, (TelegraphDelay - (TelegraphTotalTime - TelegraphFadeTime)) / 15f); - Vector2 scaleInner = new Vector2(TelegraphWidth / laserTelegraph.Width, yScale); - Vector2 origin = laserTelegraph.Size() * new Vector2(0f, 0.5f); - Vector2 scaleOuter = scaleInner * new Vector2(1f, 2.2f); + Vector2 scaleInner = new Vector2(TelegraphWidth / laserTelegraph.Width, yScale); + Vector2 origin = laserTelegraph.Size() * new Vector2(0f, 0.5f); + Vector2 scaleOuter = scaleInner * new Vector2(1f, 2.2f); - Color colorOuter = Color.Lerp(Color.Red, Color.Crimson, TelegraphDelay / TelegraphTotalTime * 2f % 1f); // Iterate through crimson and red once and then flash. - Color colorInner = Color.Lerp(colorOuter, Color.White, 0.75f); + Color colorOuter = Color.Lerp(Color.Red, Color.Crimson, TelegraphDelay / TelegraphTotalTime * 2f % 1f); // Iterate through crimson and red once and then flash. + Color colorInner = Color.Lerp(colorOuter, Color.White, 0.75f); - colorOuter *= 0.6f; - colorInner *= 0.6f; + colorOuter *= 0.6f; + colorInner *= 0.6f; - spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorInner, Velocity.ToRotation(), origin, scaleInner, SpriteEffects.None, 0f); - spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorOuter, Velocity.ToRotation(), origin, scaleOuter, SpriteEffects.None, 0f); - return false; - } - } + spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorInner, Velocity.ToRotation(), origin, scaleInner, SpriteEffects.None, 0f); + spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorOuter, Velocity.ToRotation(), origin, scaleOuter, SpriteEffects.None, 0f); + return false; + } + } } diff --git a/Projectiles/Boss/ToxicCloud.cs b/Projectiles/Boss/ToxicCloud.cs index a50cc42242..8e0204152a 100644 --- a/Projectiles/Boss/ToxicCloud.cs +++ b/Projectiles/Boss/ToxicCloud.cs @@ -11,9 +11,9 @@ namespace CalamityMod.Projectiles.Boss { public class ToxicCloud : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/Enemy/ToxicMinnowCloud"; + public override string Texture => "CalamityMod/Projectiles/Enemy/ToxicMinnowCloud"; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Toxic Cloud"); Main.projFrames[projectile.type] = 4; @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 52; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 52; projectile.height = 48; projectile.hostile = true; projectile.Opacity = 0f; @@ -32,18 +32,18 @@ namespace CalamityMod.Projectiles.Boss projectile.tileCollide = false; projectile.ignoreWater = true; projectile.timeLeft = 900; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void AI() { - Lighting.AddLight(projectile.Center, 0.1f, 0.7f, 0f); + Lighting.AddLight(projectile.Center, 0.1f, 0.7f, 0f); - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - if (projectile.velocity.Length() < (malice ? 6.25f : 5f)) - projectile.velocity *= 1.01f; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + if (projectile.velocity.Length() < (malice ? 6.25f : 5f)) + projectile.velocity *= 1.01f; - projectile.frameCounter++; + projectile.frameCounter++; if (projectile.frameCounter > 9) { projectile.frame++; @@ -85,15 +85,15 @@ namespace CalamityMod.Projectiles.Boss public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 20f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.Opacity == 0.9f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 0.9f; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.Opacity == 0.9f) - { - target.AddBuff(BuffID.Poisoned, 120); - target.AddBuff(ModContent.BuffType(), 120); - } + if (projectile.Opacity == 0.9f) + { + target.AddBuff(BuffID.Poisoned, 120); + target.AddBuff(ModContent.BuffType(), 120); + } } } } diff --git a/Projectiles/Boss/VileClot.cs b/Projectiles/Boss/VileClot.cs index f4a7c8f51b..038f9048a1 100644 --- a/Projectiles/Boss/VileClot.cs +++ b/Projectiles/Boss/VileClot.cs @@ -17,46 +17,46 @@ namespace CalamityMod.Projectiles.Boss { projectile.width = 12; projectile.height = 12; - projectile.light = 0.6f; - projectile.hostile = true; + projectile.light = 0.6f; + projectile.hostile = true; projectile.penetrate = -1; projectile.timeLeft = 300; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } - public override void AI() - { - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; - Main.PlaySound(SoundID.Item20, projectile.position); - } + public override void AI() + { + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; + Main.PlaySound(SoundID.Item20, projectile.position); + } - int num104 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), - projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 100, default, 1.5f); - Main.dust[num104].noGravity = true; + int num104 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), + projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 100, default, 1.5f); + Main.dust[num104].noGravity = true; - projectile.rotation += 0.3f * (float)projectile.direction; - } + projectile.rotation += 0.3f * (float)projectile.direction; + } public override void OnHitPlayer(Player target, int damage, bool crit) { target.AddBuff(BuffID.CursedInferno, 60); } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item10, projectile.position); - for (int num584 = 0; num584 < 6; num584++) - { - int num585 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, -projectile.velocity.X * 0.2f, -projectile.velocity.Y * 0.2f, 100, default, 2.5f); - Main.dust[num585].noGravity = true; - Dust dust = Main.dust[num585]; - dust.velocity *= 2f; - num585 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, -projectile.velocity.X * 0.2f, -projectile.velocity.Y * 0.2f, 100, default, 1.2f); - dust = Main.dust[num585]; - dust.velocity *= 2f; - } - } - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item10, projectile.position); + for (int num584 = 0; num584 < 6; num584++) + { + int num585 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, -projectile.velocity.X * 0.2f, -projectile.velocity.Y * 0.2f, 100, default, 2.5f); + Main.dust[num585].noGravity = true; + Dust dust = Main.dust[num585]; + dust.velocity *= 2f; + num585 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, -projectile.velocity.X * 0.2f, -projectile.velocity.Y * 0.2f, 100, default, 1.2f); + dust = Main.dust[num585]; + dust.velocity *= 2f; + } + } + } } diff --git a/Projectiles/Boss/WaterSpear.cs b/Projectiles/Boss/WaterSpear.cs index 3ebf575324..02646e3ecc 100644 --- a/Projectiles/Boss/WaterSpear.cs +++ b/Projectiles/Boss/WaterSpear.cs @@ -23,12 +23,12 @@ namespace CalamityMod.Projectiles.Boss projectile.height = 14; projectile.hostile = true; projectile.ignoreWater = true; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 300; projectile.Opacity = 0f; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -42,8 +42,8 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - if (projectile.velocity.Length() < 10f) - projectile.velocity *= 1.01f; + if (projectile.velocity.Length() < 10f) + projectile.velocity *= 1.01f; if (projectile.ai[1] == 0f) { @@ -60,28 +60,28 @@ namespace CalamityMod.Projectiles.Boss projectile.ai[1] = 1f; } - if (projectile.timeLeft < 30) - projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); - else - projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 270) / 30f), 0f, 1f); + if (projectile.timeLeft < 30) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 30f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 270) / 30f), 0f, 1f); - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; Lighting.AddLight(projectile.Center, 0f, 0f, 0.5f * projectile.Opacity); } - public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - lightColor.R = (byte)(255 * projectile.Opacity); - lightColor.G = (byte)(255 * projectile.Opacity); - lightColor.B = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.G = (byte)(255 * projectile.Opacity); + lightColor.B = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { for (int k = 0; k < 5; k++) { diff --git a/Projectiles/Boss/YharonFireball.cs b/Projectiles/Boss/YharonFireball.cs index 0fc17a5f0e..403d399537 100644 --- a/Projectiles/Boss/YharonFireball.cs +++ b/Projectiles/Boss/YharonFireball.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 34; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 34; projectile.height = 34; projectile.hostile = true; projectile.alpha = 255; @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Boss projectile.frame = 0; } projectile.rotation += MathHelper.Pi; - } + } public override void SendExtraAI(BinaryWriter writer) { @@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Boss speedX2 += 10f; } } - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 144); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 144); for (int d = 0; d < 2; d++) { Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 50, default, 1.5f); @@ -124,14 +124,14 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/YharonFireball2.cs b/Projectiles/Boss/YharonFireball2.cs index 7ba7cd8a79..a0a7156cd4 100644 --- a/Projectiles/Boss/YharonFireball2.cs +++ b/Projectiles/Boss/YharonFireball2.cs @@ -22,16 +22,16 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 34; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 34; projectile.height = 34; projectile.hostile = true; projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 3600; cooldownSlot = 1; - projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; - } + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -56,14 +56,14 @@ namespace CalamityMod.Projectiles.Boss if (projectile.velocity.Y < -1f) { - // 129 frames to get from -50 to -1 + // 129 frames to get from -50 to -1 projectile.velocity.Y *= 0.97f; } else { - // 85 frames to get from -1 to 16 - projectile.velocity.Y += 0.2f; - if (projectile.velocity.Y > 16f) + // 85 frames to get from -1 to 16 + projectile.velocity.Y += 0.2f; + if (projectile.velocity.Y > 16f) projectile.velocity.Y = 16f; } @@ -92,7 +92,7 @@ namespace CalamityMod.Projectiles.Boss } } - public override bool CanHitPlayer(Player target) => projectile.velocity.Y >= -16f; + public override bool CanHitPlayer(Player target) => projectile.velocity.Y >= -16f; public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); @@ -105,7 +105,7 @@ namespace CalamityMod.Projectiles.Boss public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 14, 0.5f, 0f); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 144); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 144); for (int d = 0; d < 2; d++) { Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 100, default, 1.5f); @@ -122,15 +122,15 @@ namespace CalamityMod.Projectiles.Boss projectile.Damage(); } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.velocity.Y >= -16f) - target.AddBuff(ModContent.BuffType(), 180); - } - - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.Calamity().lastProjectileHit = projectile; - } + if (projectile.velocity.Y >= -16f) + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 6c9d2ef535..eec174d461 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -58,18 +58,18 @@ namespace CalamityMod.Projectiles public int spawnedPlayerMinionProjectileDamageValue = 0; public int defDamage = 0; - // Enables "supercrits". When crit is over 100%, projectiles with this bool enabled can "supercrit". - // For every 100% critical strike chance over 100%, "supercrit" projectiles do a guaranteed +100% damage. - // They then take the remainder (e.g. the remaining 16%) and roll against that for a final +100% (like normal crits). - // For example if you have 716% critical strike chance, you are guaranteed +700% damage and then have a 16% chance for +800% damage instead. - // These are currently only enabled for Soma Prime, but any bullet fired from that gun can supercrit. - public bool canSupercrit = false; + // Enables "supercrits". When crit is over 100%, projectiles with this bool enabled can "supercrit". + // For every 100% critical strike chance over 100%, "supercrit" projectiles do a guaranteed +100% damage. + // They then take the remainder (e.g. the remaining 16%) and roll against that for a final +100% (like normal crits). + // For example if you have 716% critical strike chance, you are guaranteed +700% damage and then have a 16% chance for +800% damage instead. + // These are currently only enabled for Soma Prime, but any bullet fired from that gun can supercrit. + public bool canSupercrit = false; - // If true, this projectile can apply the infinitely-stacking Shred debuff iconic to Soma Prime. - public bool appliesSomaShred = false; + // If true, this projectile can apply the infinitely-stacking Shred debuff iconic to Soma Prime. + public bool appliesSomaShred = false; - // Amount of extra updates that are set in SetDefaults. - public int defExtraUpdates = -1; + // Amount of extra updates that are set in SetDefaults. + public int defExtraUpdates = -1; // How many times this projectile has pierced. public int timesPierced = 0; @@ -78,17 +78,17 @@ namespace CalamityMod.Projectiles public int pointBlankShotDuration = 0; public const int basePointBlankShotDuration = 12; - // Temporary damage reduction effects. - public int damageReductionTimer = 0; - /// - /// The amount of damage substracted from the projectile's own damage count when hitting the player. Resets to 0 if the damageReductionTimer variable drops to 0 - /// - public int damageReduction = 0; + // Temporary damage reduction effects. + public int damageReductionTimer = 0; + /// + /// The amount of damage substracted from the projectile's own damage count when hitting the player. Resets to 0 if the damageReductionTimer variable drops to 0 + /// + public int damageReduction = 0; - /// - /// Allows hostile Projectiles to deal damage to the player's defense stat, used mostly for hard-hitting bosses. - /// - public bool canBreakPlayerDefense = false; + /// + /// Allows hostile Projectiles to deal damage to the player's defense stat, used mostly for hard-hitting bosses. + /// + public bool canBreakPlayerDefense = false; // Rogue Stuff public bool stealthStrike = false; // Update all existing rogue weapons with this @@ -123,9 +123,9 @@ namespace CalamityMod.Projectiles ProjectileType() }; - // Boss projectile velocity multiplier in Malice Mode - public bool affectedByMaliceModeVelocityMultiplier = false; - public const float MaliceModeProjectileVelocityMultiplier = 1.25f; + // Boss projectile velocity multiplier in Malice Mode + public bool affectedByMaliceModeVelocityMultiplier = false; + public const float MaliceModeProjectileVelocityMultiplier = 1.25f; // Enchantment variables. public int ExplosiveEnchantCountdown = 0; @@ -332,13 +332,13 @@ namespace CalamityMod.Projectiles projectile.penetrate = 2; break; - case ProjectileID.CrystalVileShardHead: - case ProjectileID.CrystalVileShardShaft: - case ProjectileID.PoisonFang: - case ProjectileID.VenomFang: - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - break; + case ProjectileID.CrystalVileShardHead: + case ProjectileID.CrystalVileShardShaft: + case ProjectileID.PoisonFang: + case ProjectileID.VenomFang: + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + break; case ProjectileID.Retanimini: case ProjectileID.MiniRetinaLaser: @@ -1034,7 +1034,7 @@ namespace CalamityMod.Projectiles } } - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { if (projectile.type == ProjectileID.DemonSickle) { @@ -1659,10 +1659,10 @@ namespace CalamityMod.Projectiles return false; } - float velocityLimit = ((CalamityWorld.death || BossRushEvent.BossRushActive) ? 28f : 24f) / MathHelper.Clamp(lineColor * 0.75f, 1f, 3f); - if (projectile.velocity.Length() < velocityLimit) - projectile.velocity *= 1.01f; - } + float velocityLimit = ((CalamityWorld.death || BossRushEvent.BossRushActive) ? 28f : 24f) / MathHelper.Clamp(lineColor * 0.75f, 1f, 3f); + if (projectile.velocity.Length() < velocityLimit) + projectile.velocity *= 1.01f; + } if (projectile.alpha < 40) { @@ -1675,12 +1675,12 @@ namespace CalamityMod.Projectiles return false; } - // Moon Lord big eye spheres - else if (projectile.type == ProjectileID.PhantasmalSphere && Main.npc[(int)projectile.ai[1]].type == NPCID.MoonLordHand) - { - float velocityLimit = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 14f : 12f; - if (projectile.velocity.Length() < velocityLimit) - projectile.velocity *= 1.0075f; + // Moon Lord big eye spheres + else if (projectile.type == ProjectileID.PhantasmalSphere && Main.npc[(int)projectile.ai[1]].type == NPCID.MoonLordHand) + { + float velocityLimit = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 14f : 12f; + if (projectile.velocity.Length() < velocityLimit) + projectile.velocity *= 1.0075f; return true; } @@ -1779,9 +1779,9 @@ namespace CalamityMod.Projectiles DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f); Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); - return false; - } - } + return false; + } + } } return true; @@ -1794,12 +1794,12 @@ namespace CalamityMod.Projectiles Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (defDamage == 0) - { - if (projectile.hostile) - { - if (CalamityPlayer.areThereAnyDamnBosses && affectedByMaliceModeVelocityMultiplier && (CalamityWorld.malice || BossRushEvent.BossRushActive)) - projectile.velocity *= MaliceModeProjectileVelocityMultiplier; + if (defDamage == 0) + { + if (projectile.hostile) + { + if (CalamityPlayer.areThereAnyDamnBosses && affectedByMaliceModeVelocityMultiplier && (CalamityWorld.malice || BossRushEvent.BossRushActive)) + projectile.velocity *= MaliceModeProjectileVelocityMultiplier; // Reduce Nail damage from Nailheads because they're stupid if (projectile.type == ProjectileID.Nail && Main.expertMode) @@ -2243,15 +2243,15 @@ namespace CalamityMod.Projectiles Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (projectile.FinalExtraUpdate() && damageReductionTimer > 0) - { - damageReductionTimer--; - if (damageReductionTimer <= 0) - damageReduction = 0; - } + if (projectile.FinalExtraUpdate() && damageReductionTimer > 0) + { + damageReductionTimer--; + if (damageReductionTimer <= 0) + damageReduction = 0; + } - // optimization to remove conversion X/Y loop for irrelevant projectiles - bool isConversionProjectile = projectile.type == ProjectileID.PurificationPowder + // optimization to remove conversion X/Y loop for irrelevant projectiles + bool isConversionProjectile = projectile.type == ProjectileID.PurificationPowder || projectile.type == ProjectileID.PureSpray || projectile.type == ProjectileID.CorruptSpray || projectile.type == ProjectileID.CrimsonSpray @@ -2346,22 +2346,22 @@ namespace CalamityMod.Projectiles damage = (int)(damage * 2f / 3f); } } - #endregion + #endregion - #region ModifyHitPlayer - public override void ModifyHitPlayer(Projectile projectile, Player target, ref int damage, ref bool crit) - { - damage -= (int)(damageReduction * (Main.expertMode ? 0.25f : 0.5f)); - if (damage < 0) - damage = 0; - } - #endregion - - #region CanDamage - public override bool CanDamage(Projectile projectile) + #region ModifyHitPlayer + public override void ModifyHitPlayer(Projectile projectile, Player target, ref int damage, ref bool crit) { - if (projectile.hostile && (projectile.damage - (int)(damageReduction * (Main.expertMode ? 0.25f : 0.5f)) <= 0)) - return false; + damage -= (int)(damageReduction * (Main.expertMode ? 0.25f : 0.5f)); + if (damage < 0) + damage = 0; + } + #endregion + + #region CanDamage + public override bool CanDamage(Projectile projectile) + { + if (projectile.hostile && (projectile.damage - (int)(damageReduction * (Main.expertMode ? 0.25f : 0.5f)) <= 0)) + return false; switch (projectile.type) { @@ -2559,9 +2559,9 @@ namespace CalamityMod.Projectiles } #endregion - // TODO -- this entire region needs to go to Projectile Utilities - #region AI Shortcuts - public static Projectile SpawnOrb(Projectile projectile, int damage, int projType, float distanceRequired, float speedMult, bool gsPhantom = false) + // TODO -- this entire region needs to go to Projectile Utilities + #region AI Shortcuts + public static Projectile SpawnOrb(Projectile projectile, int damage, int projType, float distanceRequired, float speedMult, bool gsPhantom = false) { Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); diff --git a/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs b/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs index 27c59a60ee..c3152637e2 100644 --- a/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs +++ b/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs @@ -16,9 +16,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal set => projectile.ai[0] = value; } public const int Lifetime = 360; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pulse Energy"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pulse Energy"); ProjectileID.Sets.TrailingMode[projectile.type] = 2; ProjectileID.Sets.TrailCacheLength[projectile.type] = 12; } @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.height = 8; projectile.friendly = true; projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = Lifetime; projectile.extraUpdates = 1; } diff --git a/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs b/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs index 270b2eda5d..4aa1383ed1 100644 --- a/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs +++ b/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs @@ -5,117 +5,117 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class FrequencyManipulatorProjectile : ModProjectile - { + public class FrequencyManipulatorProjectile : ModProjectile + { public override string Texture => "CalamityMod/Items/Weapons/DraedonsArsenal/FrequencyManipulator"; - public float Time - { - get => projectile.ai[0]; - set => projectile.ai[0] = value; - } - public const int TotalSpins = 2; - public const float SpinTime = 30f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Frequency Manipulator"); - } + public float Time + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } + public const int TotalSpins = 2; + public const float SpinTime = 30f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Frequency Manipulator"); + } - public override void SetDefaults() - { - projectile.width = 34; - projectile.height = 34; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.timeLeft = 180; - projectile.penetrate = 4; - projectile.extraUpdates = 1; - projectile.Calamity().rogue = true; - projectile.tileCollide = false; - } + public override void SetDefaults() + { + projectile.width = 34; + projectile.height = 34; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.timeLeft = 180; + projectile.penetrate = 4; + projectile.extraUpdates = 1; + projectile.Calamity().rogue = true; + projectile.tileCollide = false; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, Color.Purple.ToVector3()); + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.Purple.ToVector3()); - Time++; - Player player = Main.player[projectile.owner]; - if (Time <= SpinTime) - { - projectile.velocity = projectile.velocity.RotatedBy(MathHelper.TwoPi * TotalSpins / SpinTime); - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; - projectile.Center = player.itemLocation + projectile.velocity; - ManipulatePlayerItemValues(player); - } - else if (Time == SpinTime + 1f) - { - projectile.tileCollide = true; - RingDustEffect(player.itemLocation, 1f, 1f, 5f, 2f); - projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitX * player.direction) * player.ActiveItem().shootSpeed; - } - } + Time++; + Player player = Main.player[projectile.owner]; + if (Time <= SpinTime) + { + projectile.velocity = projectile.velocity.RotatedBy(MathHelper.TwoPi * TotalSpins / SpinTime); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; + projectile.Center = player.itemLocation + projectile.velocity; + ManipulatePlayerItemValues(player); + } + else if (Time == SpinTime + 1f) + { + projectile.tileCollide = true; + RingDustEffect(player.itemLocation, 1f, 1f, 5f, 2f); + projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitX * player.direction) * player.ActiveItem().shootSpeed; + } + } - public void ManipulatePlayerItemValues(Player player) - { - player.direction = projectile.direction; - player.heldProj = projectile.whoAmI; - player.itemRotation = projectile.rotation; - player.itemTime = player.itemAnimation; - } + public void ManipulatePlayerItemValues(Player player) + { + player.direction = projectile.direction; + player.heldProj = projectile.whoAmI; + player.itemRotation = projectile.rotation; + player.itemTime = player.itemAnimation; + } - public void RingDustEffect(Vector2 spawnPosition, float scale, float fadeIn, float ringSpeed, float secondaryRingSpeedMultiplier) - { - if (Main.dedServ) - return; - for (int i = 0; i < 36; i++) - { - float angle = MathHelper.TwoPi * i / 36f; - Dust dust = Dust.NewDustPerfect(spawnPosition, 234); - dust.scale = scale; - dust.fadeIn = scale; - dust.velocity = angle.ToRotationVector2() * ringSpeed; + public void RingDustEffect(Vector2 spawnPosition, float scale, float fadeIn, float ringSpeed, float secondaryRingSpeedMultiplier) + { + if (Main.dedServ) + return; + for (int i = 0; i < 36; i++) + { + float angle = MathHelper.TwoPi * i / 36f; + Dust dust = Dust.NewDustPerfect(spawnPosition, 234); + dust.scale = scale; + dust.fadeIn = scale; + dust.velocity = angle.ToRotationVector2() * ringSpeed; - dust = Dust.NewDustPerfect(spawnPosition, 173); - dust.scale = scale; - dust.fadeIn = scale; - dust.velocity = angle.ToRotationVector2() * ringSpeed * secondaryRingSpeedMultiplier; - } - } + dust = Dust.NewDustPerfect(spawnPosition, 173); + dust.scale = scale; + dust.fadeIn = scale; + dust.velocity = angle.ToRotationVector2() * ringSpeed * secondaryRingSpeedMultiplier; + } + } - public void OnHitEffects() - { - if (Main.myPlayer != projectile.owner) - return; - // Explode if the projectile is a stealth strike projectile. - int totalEnergyParticlesToSpawn = 4; - if (projectile.Calamity().stealthStrike) - { - Main.PlaySound(SoundID.Item14, projectile.Center); - totalEnergyParticlesToSpawn = 4; - RingDustEffect(projectile.Center, 1.6f, 1.4f, 7f, 2.6f); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 160); - projectile.damage /= 2; - projectile.Damage(); - projectile.damage *= 2; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 34); - } + public void OnHitEffects() + { + if (Main.myPlayer != projectile.owner) + return; + // Explode if the projectile is a stealth strike projectile. + int totalEnergyParticlesToSpawn = 4; + if (projectile.Calamity().stealthStrike) + { + Main.PlaySound(SoundID.Item14, projectile.Center); + totalEnergyParticlesToSpawn = 4; + RingDustEffect(projectile.Center, 1.6f, 1.4f, 7f, 2.6f); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 160); + projectile.damage /= 2; + projectile.Damage(); + projectile.damage *= 2; + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 34); + } - for (int i = 0; i < totalEnergyParticlesToSpawn; i++) - { - float offsetAngle = MathHelper.Lerp(-0.35f, 0.35f, i / (float)totalEnergyParticlesToSpawn); - Vector2 velocity = -projectile.oldVelocity.RotatedBy(offsetAngle) * 0.66f; - Projectile.NewProjectile(projectile.Center + velocity * 1.8f, velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack * 0.4f, projectile.owner); - } - } + for (int i = 0; i < totalEnergyParticlesToSpawn; i++) + { + float offsetAngle = MathHelper.Lerp(-0.35f, 0.35f, i / (float)totalEnergyParticlesToSpawn); + Vector2 velocity = -projectile.oldVelocity.RotatedBy(offsetAngle) * 0.66f; + Projectile.NewProjectile(projectile.Center + velocity * 1.8f, velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack * 0.4f, projectile.owner); + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - OnHitEffects(); - } - public override bool OnTileCollide(Vector2 oldVelocity) - { - OnHitEffects(); - return true; - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + OnHitEffects(); + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + OnHitEffects(); + return true; + } + } } diff --git a/Projectiles/DraedonsArsenal/GalvanizingGlaiveProjectile.cs b/Projectiles/DraedonsArsenal/GalvanizingGlaiveProjectile.cs index 8898f4cc1a..334ba20f84 100644 --- a/Projectiles/DraedonsArsenal/GalvanizingGlaiveProjectile.cs +++ b/Projectiles/DraedonsArsenal/GalvanizingGlaiveProjectile.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return false; } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { float angle = projectile.rotation - MathHelper.PiOver4 * (projectile.spriteDirection == -1).ToInt(); float _ = 0f; diff --git a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs index 444e546a54..6d3127489c 100644 --- a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs +++ b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs @@ -8,144 +8,144 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class GatlingLaserProj : ModProjectile - { - private SoundEffectInstance gatlingLaserLoop; - private bool fireLasers = false; + public class GatlingLaserProj : ModProjectile + { + private SoundEffectInstance gatlingLaserLoop; + private bool fireLasers = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gatling Laser"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gatling Laser"); + } - public override void SetDefaults() - { - projectile.width = 24; - projectile.height = 58; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.magic = true; - } + public override void SetDefaults() + { + projectile.width = 24; + projectile.height = 58; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.magic = true; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - float num = MathHelper.PiOver2; - Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); - if (projectile.type == ModContent.ProjectileType()) - { - if (projectile.ai[0] < 5f) - projectile.ai[0] += 1f; + public override void AI() + { + Player player = Main.player[projectile.owner]; + float num = MathHelper.PiOver2; + Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); + if (projectile.type == ModContent.ProjectileType()) + { + if (projectile.ai[0] < 5f) + projectile.ai[0] += 1f; - if (projectile.ai[0] > 4f) - projectile.ai[0] = 2f; + if (projectile.ai[0] > 4f) + projectile.ai[0] = 2f; - // The Gatling Laser shoots every other frame (effective use time of 2). - int fireRate = 2; - projectile.ai[1] += 1f; - bool shootThisFrame = false; - if (projectile.ai[1] >= fireRate) - { - projectile.ai[1] = 0f; - shootThisFrame = true; - } + // The Gatling Laser shoots every other frame (effective use time of 2). + int fireRate = 2; + projectile.ai[1] += 1f; + bool shootThisFrame = false; + if (projectile.ai[1] >= fireRate) + { + projectile.ai[1] = 0f; + shootThisFrame = true; + } - if (projectile.soundDelay <= 0) - { - projectile.soundDelay = fireRate * 6; - if (projectile.ai[0] != 1f) - { - fireLasers = true; - projectile.soundDelay *= 6; - gatlingLaserLoop = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GatlingLaserFireLoop"), (int)projectile.position.X, (int)projectile.position.Y); - } - } - if (shootThisFrame && Main.myPlayer == projectile.owner && fireLasers) - { - Item gatling = player.ActiveItem(); + if (projectile.soundDelay <= 0) + { + projectile.soundDelay = fireRate * 6; + if (projectile.ai[0] != 1f) + { + fireLasers = true; + projectile.soundDelay *= 6; + gatlingLaserLoop = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GatlingLaserFireLoop"), (int)projectile.position.X, (int)projectile.position.Y); + } + } + if (shootThisFrame && Main.myPlayer == projectile.owner && fireLasers) + { + Item gatling = player.ActiveItem(); - // This grabs the weapon's current damage, taking current charge level into account. - int currentDamage = player.GetWeaponDamage(gatling); + // This grabs the weapon's current damage, taking current charge level into account. + int currentDamage = player.GetWeaponDamage(gatling); - bool stillInUse = player.channel && !player.noItems && !player.CCed; + bool stillInUse = player.channel && !player.noItems && !player.CCed; - // This both checks if the player has sufficient mana and consumes it if they do. - // If this is false, the Gatling Laser stops functioning. - bool hasMana = player.CheckMana(gatling, -1, true, false); + // This both checks if the player has sufficient mana and consumes it if they do. + // If this is false, the Gatling Laser stops functioning. + bool hasMana = player.CheckMana(gatling, -1, true, false); - // Checks if the Gatling Laser has sufficient charge to fire. If this is false, it stops functioning. - CalamityGlobalItem modItem = gatling.Calamity(); - bool hasCharge = modItem.Charge >= GatlingLaser.HoldoutChargeUse; + // Checks if the Gatling Laser has sufficient charge to fire. If this is false, it stops functioning. + CalamityGlobalItem modItem = gatling.Calamity(); + bool hasCharge = modItem.Charge >= GatlingLaser.HoldoutChargeUse; - if (stillInUse && hasMana && hasCharge) - { - float scaleFactor = player.ActiveItem().shootSpeed * projectile.scale; - Vector2 value2 = vector; - Vector2 value3 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - value2; - if (player.gravDir == -1f) - { - 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)) - { - vector3 = -Vector2.UnitY; - } - vector3 *= scaleFactor; - if (vector3.X != projectile.velocity.X || vector3.Y != projectile.velocity.Y) - { - projectile.netUpdate = true; - } - projectile.velocity = vector3; - int type = ModContent.ProjectileType(); - float velocity = 3f; - value2 = projectile.Center; - Vector2 spinningpoint = Vector2.Normalize(projectile.velocity) * velocity; + if (stillInUse && hasMana && hasCharge) + { + float scaleFactor = player.ActiveItem().shootSpeed * projectile.scale; + Vector2 value2 = vector; + Vector2 value3 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - value2; + if (player.gravDir == -1f) + { + 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)) + { + vector3 = -Vector2.UnitY; + } + vector3 *= scaleFactor; + if (vector3.X != projectile.velocity.X || vector3.Y != projectile.velocity.Y) + { + projectile.netUpdate = true; + } + projectile.velocity = vector3; + int type = ModContent.ProjectileType(); + float velocity = 3f; + value2 = projectile.Center; + Vector2 spinningpoint = Vector2.Normalize(projectile.velocity) * velocity; - double spread = Math.PI / 32D; - spinningpoint = spinningpoint.RotatedBy(Main.rand.NextDouble() * 2D * spread - spread); + double spread = Math.PI / 32D; + spinningpoint = spinningpoint.RotatedBy(Main.rand.NextDouble() * 2D * spread - spread); - if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y)) - { - spinningpoint = -Vector2.UnitY; - } - Vector2 velocity2 = new Vector2(spinningpoint.X, spinningpoint.Y); - if (velocity2.Length() > 5f) - { - velocity2.Normalize(); - velocity2 *= 5f; - } - float SpeedX = velocity2.X + Main.rand.Next(-1, 2) * 0.005f; - float SpeedY = velocity2.Y + Main.rand.Next(-1, 2) * 0.005f; - float ai0 = projectile.ai[0] - 2f; // 0, 1, or 2 + if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y)) + { + spinningpoint = -Vector2.UnitY; + } + Vector2 velocity2 = new Vector2(spinningpoint.X, spinningpoint.Y); + if (velocity2.Length() > 5f) + { + velocity2.Normalize(); + velocity2 *= 5f; + } + float SpeedX = velocity2.X + Main.rand.Next(-1, 2) * 0.005f; + float SpeedY = velocity2.Y + Main.rand.Next(-1, 2) * 0.005f; + float ai0 = projectile.ai[0] - 2f; // 0, 1, or 2 - // Use charge when firing a laser. - modItem.Charge -= GatlingLaser.HoldoutChargeUse; - Projectile.NewProjectile(value2.X, value2.Y, SpeedX, SpeedY, type, currentDamage, projectile.knockBack, projectile.owner, ai0, 0f); - } - else - { - if (gatlingLaserLoop != null) - gatlingLaserLoop.Stop(); + // Use charge when firing a laser. + modItem.Charge -= GatlingLaser.HoldoutChargeUse; + Projectile.NewProjectile(value2.X, value2.Y, SpeedX, SpeedY, type, currentDamage, projectile.knockBack, projectile.owner, ai0, 0f); + } + else + { + if (gatlingLaserLoop != null) + gatlingLaserLoop.Stop(); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GatlingLaserFireEnd"), (int)projectile.position.X, (int)projectile.position.Y); - projectile.Kill(); - } - } - } - projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - projectile.Size / 2f; - projectile.rotation = projectile.velocity.ToRotation() + num; - projectile.spriteDirection = projectile.direction; - projectile.timeLeft = 2; - player.ChangeDir(projectile.direction); - 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); - } + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/GatlingLaserFireEnd"), (int)projectile.position.X, (int)projectile.position.Y); + projectile.Kill(); + } + } + } + projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - projectile.Size / 2f; + projectile.rotation = projectile.velocity.ToRotation() + num; + projectile.spriteDirection = projectile.direction; + projectile.timeLeft = 2; + player.ChangeDir(projectile.direction); + 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); + } - public override bool CanDamage() => false; - } + public override bool CanDamage() => false; + } } diff --git a/Projectiles/DraedonsArsenal/GatlingLaserShot.cs b/Projectiles/DraedonsArsenal/GatlingLaserShot.cs index 125df44776..d9c73029a4 100644 --- a/Projectiles/DraedonsArsenal/GatlingLaserShot.cs +++ b/Projectiles/DraedonsArsenal/GatlingLaserShot.cs @@ -10,12 +10,12 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private int dust = 182; + private int dust = 182; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gatling Laser"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gatling Laser"); + } public override void SetDefaults() { @@ -30,144 +30,144 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { - Lighting.AddLight(projectile.Center, 0.2f, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.2f, 0f, 0f); - float createDustVar = 10f; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > createDustVar) - { - Vector2 value7 = new Vector2(5f, 10f); - Vector2 value8 = Vector2.UnitX * -12f; + float createDustVar = 10f; + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > createDustVar) + { + Vector2 value7 = new Vector2(5f, 10f); + Vector2 value8 = Vector2.UnitX * -12f; - switch ((int)projectile.ai[0]) - { - case 0: - int num41 = Dust.NewDust(projectile.Center, 0, 0, dust, 0f, 0f, 160, default, 0.8f); - Main.dust[num41].noGravity = true; - Main.dust[num41].position = projectile.Center; - Main.dust[num41].velocity = projectile.velocity; - break; - case 1: - value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 0f * MathHelper.Pi) * value7 * 0.5f; - int num42 = Dust.NewDust(projectile.Center, 0, 0, dust, 0f, 0f, 160, default, 0.8f); - Main.dust[num42].noGravity = true; - Main.dust[num42].position = projectile.Center + value8; - Main.dust[num42].velocity = projectile.velocity; - break; - case 2: - value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 1f * MathHelper.Pi) * value7 * 0.5f; - int num43 = Dust.NewDust(projectile.Center, 0, 0, dust, 0f, 0f, 160, default, 0.8f); - Main.dust[num43].noGravity = true; - Main.dust[num43].position = projectile.Center + value8; - Main.dust[num43].velocity = projectile.velocity; - break; - default: - break; - } - } + switch ((int)projectile.ai[0]) + { + case 0: + int num41 = Dust.NewDust(projectile.Center, 0, 0, dust, 0f, 0f, 160, default, 0.8f); + Main.dust[num41].noGravity = true; + Main.dust[num41].position = projectile.Center; + Main.dust[num41].velocity = projectile.velocity; + break; + case 1: + value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 0f * MathHelper.Pi) * value7 * 0.5f; + int num42 = Dust.NewDust(projectile.Center, 0, 0, dust, 0f, 0f, 160, default, 0.8f); + Main.dust[num42].noGravity = true; + Main.dust[num42].position = projectile.Center + value8; + Main.dust[num42].velocity = projectile.velocity; + break; + case 2: + value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 1f * MathHelper.Pi) * value7 * 0.5f; + int num43 = Dust.NewDust(projectile.Center, 0, 0, dust, 0f, 0f, 160, default, 0.8f); + Main.dust[num43].noGravity = true; + Main.dust[num43].position = projectile.Center + value8; + Main.dust[num43].velocity = projectile.velocity; + break; + default: + break; + } + } - if (projectile.localAI[0] == createDustVar) - LaserBurst(1.8f, 3f); - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.OnFire, 90); + if (projectile.localAI[0] == createDustVar) + LaserBurst(1.8f, 3f); } - public override void Kill(int timeLeft) - { - int height = 20; - projectile.position = projectile.Center; - projectile.width = projectile.height = height; - projectile.Center = projectile.position; - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.OnFire, 90); + } - LaserBurst(2.4f, 4.2f); // 60 dusts + public override void Kill(int timeLeft) + { + int height = 20; + projectile.position = projectile.Center; + projectile.width = projectile.height = height; + projectile.Center = projectile.position; + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); - int num3; - for (int num640 = 0; num640 < 100; num640 = num3 + 1) - { - float num641 = 4f; + LaserBurst(2.4f, 4.2f); // 60 dusts - int num643 = Dust.NewDust(projectile.Center, 6, 6, dust, 0f, 0f, 100, default, 1f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + int num3; + for (int num640 = 0; num640 < 100; num640 = num3 + 1) + { + float num641 = 4f; - if (num644 == 0f && num645 == 0f) - num644 = 1f; + int num643 = Dust.NewDust(projectile.Center, 6, 6, dust, 0f, 0f, 100, default, 1f); + float num644 = Main.dust[num643].velocity.X; + float num645 = Main.dust[num643].velocity.Y; - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; + if (num644 == 0f && num645 == 0f) + num644 = 1f; - Dust dust2 = Main.dust[num643]; - dust2.velocity *= 0.5f; - dust2.velocity.X = dust2.velocity.X + num644; - dust2.velocity.Y = dust2.velocity.Y + num645; - dust2.scale = 0.66f; - dust2.noGravity = true; + float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); + num646 = num641 / num646; + num644 *= num646; + num645 *= num646; - num3 = num640; - } - } + Dust dust2 = Main.dust[num643]; + dust2.velocity *= 0.5f; + dust2.velocity.X = dust2.velocity.X + num644; + dust2.velocity.Y = dust2.velocity.Y + num645; + dust2.scale = 0.66f; + dust2.noGravity = true; - private void LaserBurst(float speed1, float speed2) - { - float angleRandom = 0.05f; + num3 = num640; + } + } - int num3; - for (int num53 = 0; num53 < 4; num53 = num3 + 1) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + private void LaserBurst(float speed1, float speed2) + { + float angleRandom = 0.05f; - int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 200, default, 0.9f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - Main.dust[num54].noGravity = true; + int num3; + for (int num53 = 0; num53 < 4; num53 = num3 + 1) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - Dust dust2 = Main.dust[num54]; - dust2.velocity *= 3f; - dust2 = Main.dust[num54]; + int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 200, default, 0.9f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + Main.dust[num54].noGravity = true; - num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 100, default, 0.66f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + Dust dust2 = Main.dust[num54]; + dust2.velocity *= 3f; + dust2 = Main.dust[num54]; - dust2 = Main.dust[num54]; - dust2.velocity *= 2f; + num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 100, default, 0.66f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Crimson * 0.5f; + dust2 = Main.dust[num54]; + dust2.velocity *= 2f; - dust2 = Main.dust[num54]; + Main.dust[num54].noGravity = true; + Main.dust[num54].fadeIn = 1f; + Main.dust[num54].color = Color.Crimson * 0.5f; - num3 = num53; - } - for (int num55 = 0; num55 < 2; num55 = num3 + 1) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + dust2 = Main.dust[num54]; - int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 0, default, 1.2f); - Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; - Main.dust[num56].noGravity = true; + num3 = num53; + } + for (int num55 = 0; num55 < 2; num55 = num3 + 1) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - Dust dust2 = Main.dust[num56]; - dust2.velocity *= 0.5f; - dust2 = Main.dust[num56]; + int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 0, default, 1.2f); + Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; + Main.dust[num56].noGravity = true; - num3 = num55; - } - } - } + Dust dust2 = Main.dust[num56]; + dust2.velocity *= 0.5f; + dust2 = Main.dust[num56]; + + num3 = num55; + } + } + } } diff --git a/Projectiles/DraedonsArsenal/GaussEnergy.cs b/Projectiles/DraedonsArsenal/GaussEnergy.cs index 9971fc503d..c47e7ec50d 100644 --- a/Projectiles/DraedonsArsenal/GaussEnergy.cs +++ b/Projectiles/DraedonsArsenal/GaussEnergy.cs @@ -7,9 +7,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gauss Energy"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gauss Energy"); } public override void SetDefaults() diff --git a/Projectiles/DraedonsArsenal/GaussFlux.cs b/Projectiles/DraedonsArsenal/GaussFlux.cs index 2fce06a109..c596885fe0 100644 --- a/Projectiles/DraedonsArsenal/GaussFlux.cs +++ b/Projectiles/DraedonsArsenal/GaussFlux.cs @@ -20,9 +20,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal set => projectile.ai[1] = value.whoAmI; } public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gauss Flux"); - } + { + DisplayName.SetDefault("Gauss Flux"); + } public override void SetDefaults() { @@ -32,13 +32,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.melee = true; projectile.penetrate = -1; projectile.timeLeft = 180; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 10; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 10; } public override void AI() { - Lighting.AddLight(projectile.Center, Color.Lime.ToVector3()); + Lighting.AddLight(projectile.Center, Color.Lime.ToVector3()); if (!Target.active) { projectile.Kill(); @@ -79,5 +79,5 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } Time++; } - } + } } diff --git a/Projectiles/DraedonsArsenal/GaussPistolShot.cs b/Projectiles/DraedonsArsenal/GaussPistolShot.cs index 4158f915aa..db8e8b43f9 100644 --- a/Projectiles/DraedonsArsenal/GaussPistolShot.cs +++ b/Projectiles/DraedonsArsenal/GaussPistolShot.cs @@ -22,9 +22,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public const float MaxEnergyParticleSpeed = 4f; public const float EnergyChargeRadiusRatio = 1.45f; public const float ChargeTime = 30f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gauss Shot"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gauss Shot"); ProjectileID.Sets.TrailingMode[projectile.type] = 2; ProjectileID.Sets.TrailCacheLength[projectile.type] = 12; } diff --git a/Projectiles/DraedonsArsenal/GaussRifleBlast.cs b/Projectiles/DraedonsArsenal/GaussRifleBlast.cs index 739fac4046..09a3015d71 100644 --- a/Projectiles/DraedonsArsenal/GaussRifleBlast.cs +++ b/Projectiles/DraedonsArsenal/GaussRifleBlast.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { Time++; - projectile.tileCollide = Time > 3f; + projectile.tileCollide = Time > 3f; if (!Main.dedServ) { // Idle dust. diff --git a/Projectiles/DraedonsArsenal/GaussRifleExplosion.cs b/Projectiles/DraedonsArsenal/GaussRifleExplosion.cs index 6fad3ee233..9cf003f5f0 100644 --- a/Projectiles/DraedonsArsenal/GaussRifleExplosion.cs +++ b/Projectiles/DraedonsArsenal/GaussRifleExplosion.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.width = projectile.height = 500; projectile.friendly = true; projectile.ranged = true; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 20; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs b/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs index 16b2386702..df7da2377f 100644 --- a/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs +++ b/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.ownerHitCheck = true; projectile.melee = true; projectile.scale = 1.75f; - projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override void AI() @@ -105,10 +105,10 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (Main.rand.NextBool(5)) { - Vector2 spawnPosition = projectile.velocity; - spawnPosition.Normalize(); - spawnPosition *= projectile.Size; - spawnPosition += projectile.Center; + Vector2 spawnPosition = projectile.velocity; + spawnPosition.Normalize(); + spawnPosition *= projectile.Size; + spawnPosition += projectile.Center; Dust dust = Dust.NewDustPerfect(spawnPosition, 226); dust.velocity = projectile.velocity.SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(2f, 3.6f); dust.velocity += player.velocity * 0.4f; @@ -169,17 +169,17 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return true; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int height = texture.Height / Main.projFrames[projectile.type]; - int frameHeight = height * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int frameHeight = height * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), lightColor, projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), projectile.scale, spriteEffects, 0f); - return false; - } + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), lightColor, projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), projectile.scale, spriteEffects, 0f); + return false; + } } } diff --git a/Projectiles/DraedonsArsenal/LaserRifleShot.cs b/Projectiles/DraedonsArsenal/LaserRifleShot.cs index 8ba69d902d..2307f63a4d 100644 --- a/Projectiles/DraedonsArsenal/LaserRifleShot.cs +++ b/Projectiles/DraedonsArsenal/LaserRifleShot.cs @@ -6,141 +6,141 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class LaserRifleShot : ModProjectile - { + public class LaserRifleShot : ModProjectile + { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private int dust = 127; + private int dust = 127; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Laser Rifle"); - } - - public override void SetDefaults() - { - projectile.width = 2; - projectile.height = 2; - projectile.friendly = true; - projectile.ranged = true; - projectile.penetrate = 1; - projectile.extraUpdates = 100; - projectile.timeLeft = 600; - } - - public override void AI() - { - Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f); - - float createDustVar = 12f; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > createDustVar) - { - Vector2 value7 = new Vector2(5f, 10f); - Vector2 value8 = Vector2.UnitX * -12f; - - for (int i = 0; i < 2; i++) - { - int num41 = Dust.NewDust(projectile.Center, 0, 0, dust, 0f, 0f, 160, projectile.ai[0] == 0f ? default : new Color(255, 255, 0), 2f); - Main.dust[num41].noGravity = true; - Main.dust[num41].position = projectile.Center; - Main.dust[num41].velocity = projectile.velocity; - } - } - - if (projectile.localAI[0] == createDustVar) - LaserBurst(1.8f, 3f); - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void SetStaticDefaults() { - target.AddBuff(BuffID.OnFire, 180); + DisplayName.SetDefault("Laser Rifle"); } - public override void Kill(int timeLeft) - { - int height = 60; - projectile.position = projectile.Center; - projectile.width = projectile.height = height; - projectile.Center = projectile.position; - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); + public override void SetDefaults() + { + projectile.width = 2; + projectile.height = 2; + projectile.friendly = true; + projectile.ranged = true; + projectile.penetrate = 1; + projectile.extraUpdates = 100; + projectile.timeLeft = 600; + } - LaserBurst(2.4f, 4.2f); // 60 dusts + public override void AI() + { + Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f); - for (int num640 = 0; num640 < 100; num640++) - { - float num641 = 4f; + float createDustVar = 12f; + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > createDustVar) + { + Vector2 value7 = new Vector2(5f, 10f); + Vector2 value8 = Vector2.UnitX * -12f; - int num643 = Dust.NewDust(projectile.Center, 6, 6, dust, 0f, 0f, 100, default, 2f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + for (int i = 0; i < 2; i++) + { + int num41 = Dust.NewDust(projectile.Center, 0, 0, dust, 0f, 0f, 160, projectile.ai[0] == 0f ? default : new Color(255, 255, 0), 2f); + Main.dust[num41].noGravity = true; + Main.dust[num41].position = projectile.Center; + Main.dust[num41].velocity = projectile.velocity; + } + } - if (num644 == 0f && num645 == 0f) - num644 = 1f; + if (projectile.localAI[0] == createDustVar) + LaserBurst(1.8f, 3f); + } - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.OnFire, 180); + } - Dust dust2 = Main.dust[num643]; - dust2.velocity *= 0.5f; - dust2.velocity.X = dust2.velocity.X + num644; - dust2.velocity.Y = dust2.velocity.Y + num645; - dust2.noGravity = true; - } - } + public override void Kill(int timeLeft) + { + int height = 60; + projectile.position = projectile.Center; + projectile.width = projectile.height = height; + projectile.Center = projectile.position; + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); - private void LaserBurst(float speed1, float speed2) - { - float angleRandom = 0.05f; + LaserBurst(2.4f, 4.2f); // 60 dusts - for (int num53 = 0; num53 < 20; num53++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + for (int num640 = 0; num640 < 100; num640++) + { + float num641 = 4f; - int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 200, default, 2.5f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - Main.dust[num54].noGravity = true; + int num643 = Dust.NewDust(projectile.Center, 6, 6, dust, 0f, 0f, 100, default, 2f); + float num644 = Main.dust[num643].velocity.X; + float num645 = Main.dust[num643].velocity.Y; - Dust dust2 = Main.dust[num54]; - dust2.velocity *= 3f; - dust2 = Main.dust[num54]; + if (num644 == 0f && num645 == 0f) + num644 = 1f; - num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 100, default, 1.9f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); + num646 = num641 / num646; + num644 *= num646; + num645 *= num646; - dust2 = Main.dust[num54]; - dust2.velocity *= 2f; + Dust dust2 = Main.dust[num643]; + dust2.velocity *= 0.5f; + dust2.velocity.X = dust2.velocity.X + num644; + dust2.velocity.Y = dust2.velocity.Y + num645; + dust2.noGravity = true; + } + } - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Orange * 0.5f; + private void LaserBurst(float speed1, float speed2) + { + float angleRandom = 0.05f; - dust2 = Main.dust[num54]; - } - for (int num55 = 0; num55 < 10; num55++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + for (int num53 = 0; num53 < 20; num53++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 0, default, 3.2f); - Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; - Main.dust[num56].noGravity = true; + int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 200, default, 2.5f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + Main.dust[num54].noGravity = true; - Dust dust2 = Main.dust[num56]; - dust2.velocity *= 0.5f; - dust2 = Main.dust[num56]; - } - } - } + Dust dust2 = Main.dust[num54]; + dust2.velocity *= 3f; + dust2 = Main.dust[num54]; + + num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 100, default, 1.9f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + + dust2 = Main.dust[num54]; + dust2.velocity *= 2f; + + Main.dust[num54].noGravity = true; + Main.dust[num54].fadeIn = 1f; + Main.dust[num54].color = Color.Orange * 0.5f; + + dust2 = Main.dust[num54]; + } + for (int num55 = 0; num55 < 10; num55++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + + int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust, dustVel.X, dustVel.Y, 0, default, 3.2f); + Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; + Main.dust[num56].noGravity = true; + + Dust dust2 = Main.dust[num56]; + dust2.velocity *= 0.5f; + dust2 = Main.dust[num56]; + } + } + } } diff --git a/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.cs b/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.cs index 9768c2a1bf..db65f294fa 100644 --- a/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.cs +++ b/Projectiles/DraedonsArsenal/MassivePlasmaExplosion.cs @@ -6,79 +6,79 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class MassivePlasmaExplosion : ModProjectile - { - public float Time - { - get => projectile.ai[0]; - set => projectile.ai[0] = value; - } - private float lightAmt = 1f; + public class MassivePlasmaExplosion : ModProjectile + { + public float Time + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } + private float lightAmt = 1f; - public int frameX = 0; - public int frameY = 0; - private const int horizontalFrames = 4; - private const int verticalFrames = 5; - private const int frameLength = 5; - private const float radius = 191.5f; + public int frameX = 0; + public int frameY = 0; + private const int horizontalFrames = 4; + private const int verticalFrames = 5; + private const int frameLength = 5; + private const float radius = 191.5f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Plasma Explosion"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plasma Explosion"); + } - public override void SetDefaults() - { - projectile.width = projectile.height = 383; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.Calamity().rogue = true; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = frameLength * horizontalFrames * verticalFrames / 2; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 383; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.Calamity().rogue = true; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = frameLength * horizontalFrames * verticalFrames / 2; + } - public override void AI() - { - projectile.frameCounter++; - if (projectile.frameCounter % frameLength == frameLength - 1) - { - frameY++; - if (frameY >= verticalFrames) - { - frameX++; - frameY = 0; - } - if (frameX >= horizontalFrames) - { - projectile.Kill(); - } - } + public override void AI() + { + projectile.frameCounter++; + if (projectile.frameCounter % frameLength == frameLength - 1) + { + frameY++; + if (frameY >= verticalFrames) + { + frameX++; + frameY = 0; + } + if (frameX >= horizontalFrames) + { + projectile.Kill(); + } + } - Lighting.AddLight(projectile.Center, Color.White.ToVector3() * 4f * lightAmt); - if (projectile.localAI[0] == 0f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/FlareSound"), projectile.Center); - projectile.localAI[0] = 1f; - } - lightAmt = (float)Math.Sin(Time / 37 * MathHelper.Pi) * 2f; - if (lightAmt > 1f) - lightAmt = 1f; - Time++; - } + Lighting.AddLight(projectile.Center, Color.White.ToVector3() * 4f * lightAmt); + if (projectile.localAI[0] == 0f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/FlareSound"), projectile.Center); + projectile.localAI[0] = 1f; + } + lightAmt = (float)Math.Sin(Time / 37 * MathHelper.Pi) * 2f; + if (lightAmt > 1f) + lightAmt = 1f; + Time++; + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, radius, targetHitbox); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int length = texture.Width / horizontalFrames; - int height = texture.Height / verticalFrames; - Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - Rectangle frame = new Rectangle(frameX * length, frameY * height, length, height); - Vector2 origin = new Vector2(length / 2f, height / 2f); - spriteBatch.Draw(texture, drawPos, frame, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int length = texture.Width / horizontalFrames; + int height = texture.Height / verticalFrames; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Rectangle frame = new Rectangle(frameX * length, frameY * height, length, height); + Vector2 origin = new Vector2(length / 2f, height / 2f); + spriteBatch.Draw(texture, drawPos, frame, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + return false; + } + } } diff --git a/Projectiles/DraedonsArsenal/MountedScannerLaser.cs b/Projectiles/DraedonsArsenal/MountedScannerLaser.cs index 1ac91ee7ad..648bcde31c 100644 --- a/Projectiles/DraedonsArsenal/MountedScannerLaser.cs +++ b/Projectiles/DraedonsArsenal/MountedScannerLaser.cs @@ -89,12 +89,12 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - projectile.damage = (int)(projectile.damage * 0.6); - } + projectile.damage = (int)(projectile.damage * 0.6); + } public override void OnHitPvp(Player target, int damage, bool crit) { - projectile.damage = (int)(projectile.damage * 0.6); - } + projectile.damage = (int)(projectile.damage * 0.6); + } } } diff --git a/Projectiles/DraedonsArsenal/MountedScannerSummon.cs b/Projectiles/DraedonsArsenal/MountedScannerSummon.cs index 07a9121584..ba79156e04 100644 --- a/Projectiles/DraedonsArsenal/MountedScannerSummon.cs +++ b/Projectiles/DraedonsArsenal/MountedScannerSummon.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class MountedScannerSummon : ModProjectile + public class MountedScannerSummon : ModProjectile { public float AngularOffsetRelativeToPlayer { diff --git a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs index 97f08dfd0d..3217040cf9 100644 --- a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs +++ b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs @@ -13,330 +13,330 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class PhaseslayerProjectile : ModProjectile - { + public class PhaseslayerProjectile : ModProjectile + { public override string Texture => "CalamityMod/Items/Weapons/DraedonsArsenal/Phaseslayer"; - // The "average" or "expected" swing speed which the sword's damage balance is based off of. - // This is rotation EVERY FRAME. The "average" swing speed is 360 degrees in one second, aka pi/30 radians per frame. - public const float StandardSwingSpeed = MathHelper.Pi / 30f; + // The "average" or "expected" swing speed which the sword's damage balance is based off of. + // This is rotation EVERY FRAME. The "average" swing speed is 360 degrees in one second, aka pi/30 radians per frame. + public const float StandardSwingSpeed = MathHelper.Pi / 30f; - // How quickly the sword's damage updates to reflect its current speed. Higher values make it change damage more quickly. - public const float DamageUpdateResponsiveness = 0.08f; + // How quickly the sword's damage updates to reflect its current speed. Higher values make it change damage more quickly. + public const float DamageUpdateResponsiveness = 0.08f; - public const int SwordBeamCooldown = 15; - public const float SwordBeamDamageMultiplier = 0.15f; - private const float MaximumMouseRange = 360f; - private const float ProjCenterOffset = 36f; + public const int SwordBeamCooldown = 15; + public const float SwordBeamDamageMultiplier = 0.15f; + private const float MaximumMouseRange = 360f; + private const float ProjCenterOffset = 36f; - public bool IsSmall - { - get - { - CalamityGlobalItem swordItem = Main.player[projectile.owner].ActiveItem().Calamity(); - return swordItem.ChargeRatio < Phaseslayer.SizeChargeThreshold; - } - } - - // ai[0] wrapper. Stores a rolling lerped average of angular momentum which is used as the swing speed damage multiplier. - public float AngularDamageFactor - { - get => projectile.ai[0]; - set => projectile.ai[0] = value; - } + public bool IsSmall + { + get + { + CalamityGlobalItem swordItem = Main.player[projectile.owner].ActiveItem().Calamity(); + return swordItem.ChargeRatio < Phaseslayer.SizeChargeThreshold; + } + } + + // ai[0] wrapper. Stores a rolling lerped average of angular momentum which is used as the swing speed damage multiplier. + public float AngularDamageFactor + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } - // ai[1] wrapper. Stores the sword's vanishing timer. - public float FadeoutTime - { - get => projectile.ai[1]; - set => projectile.ai[1] = value; - } + // ai[1] wrapper. Stores the sword's vanishing timer. + public float FadeoutTime + { + get => projectile.ai[1]; + set => projectile.ai[1] = value; + } - public int BladeFrameX => IsSmall ? 1 : projectile.frame / 7; - public int BladeFrameY => IsSmall ? projectile.frame % 3 : projectile.frame % 7; + public int BladeFrameX => IsSmall ? 1 : projectile.frame / 7; + public int BladeFrameY => IsSmall ? projectile.frame % 3 : projectile.frame % 7; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Phaseslayer"); - ProjectileID.Sets.TrailingMode[projectile.type] = 2; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 13; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Phaseslayer"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 13; + } - public override void SetDefaults() - { - projectile.width = 46; // Collision logic is done manually. - projectile.height = 46; - projectile.friendly = true; - projectile.melee = true; - projectile.tileCollide = false; - projectile.ignoreWater = true; + public override void SetDefaults() + { + projectile.width = 46; // Collision logic is done manually. + projectile.height = 46; + projectile.friendly = true; + projectile.melee = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 13; - } + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 13; + } - // Vanilla Terraria doesn't sync projectile rotation, but it does sync velocity. - // Rather than hacking velocity to reflect rotation, I'd rather just send the rotation directly. - // - Ozzatron (09/21/2020) - public override void SendExtraAI(BinaryWriter writer) => writer.Write(projectile.rotation); - public override void ReceiveExtraAI(BinaryReader reader) => projectile.rotation = reader.ReadSingle(); + // Vanilla Terraria doesn't sync projectile rotation, but it does sync velocity. + // Rather than hacking velocity to reflect rotation, I'd rather just send the rotation directly. + // - Ozzatron (09/21/2020) + public override void SendExtraAI(BinaryWriter writer) => writer.Write(projectile.rotation); + public override void ReceiveExtraAI(BinaryReader reader) => projectile.rotation = reader.ReadSingle(); - public override void AI() - { - Player player = Main.player[projectile.owner]; - CalamityGlobalItem modItem = player.ActiveItem().Calamity(); + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityGlobalItem modItem = player.ActiveItem().Calamity(); - // Angles are wrapped to be 0 to 2pi instead of -pi to pi for convenience with absolute values. - float rotationAdjusted = MathHelper.WrapAngle(projectile.rotation) + MathHelper.Pi; - float oldRotationAdjusted = MathHelper.WrapAngle(projectile.oldRot[1]) + MathHelper.Pi; - float deltaAngle = Math.Abs(MathHelper.WrapAngle(rotationAdjusted - oldRotationAdjusted)); + // Angles are wrapped to be 0 to 2pi instead of -pi to pi for convenience with absolute values. + float rotationAdjusted = MathHelper.WrapAngle(projectile.rotation) + MathHelper.Pi; + float oldRotationAdjusted = MathHelper.WrapAngle(projectile.oldRot[1]) + MathHelper.Pi; + float deltaAngle = Math.Abs(MathHelper.WrapAngle(rotationAdjusted - oldRotationAdjusted)); - // Frame 1 effect: Prevent the sword from instantly firing a sword beam. - if (projectile.localAI[1] == 0f) - { - projectile.localAI[1] = 1f; - projectile.soundDelay = SwordBeamCooldown; - } + // Frame 1 effect: Prevent the sword from instantly firing a sword beam. + if (projectile.localAI[1] == 0f) + { + projectile.localAI[1] = 1f; + projectile.soundDelay = SwordBeamCooldown; + } - ManipulatePlayer(player, modItem); + ManipulatePlayer(player, modItem); - bool wasBig = !IsSmall; - bool justShrunk = IsSmall && wasBig; - if (justShrunk) - OnShrinkEffects(); + bool wasBig = !IsSmall; + bool justShrunk = IsSmall && wasBig; + if (justShrunk) + OnShrinkEffects(); - AdjustCurrentDamage(player, deltaAngle); - ManipulateFrames(); - HandleSwordBeams(player, modItem, deltaAngle); + AdjustCurrentDamage(player, deltaAngle); + ManipulateFrames(); + HandleSwordBeams(player, modItem, deltaAngle); - // Because sword beams (or just holding the sword while it's fizzling) can take energy even when the sword's at zero energy, - // this is here to ensure the sword item's charge never goes below zero. - if (modItem.Charge < 0f) - modItem.Charge = 0f; + // Because sword beams (or just holding the sword while it's fizzling) can take energy even when the sword's at zero energy, + // this is here to ensure the sword item's charge never goes below zero. + if (modItem.Charge < 0f) + modItem.Charge = 0f; - HandleFadeout(); - } + HandleFadeout(); + } - private void ManipulatePlayer(Player player, CalamityGlobalItem modItem) - { - if (Main.myPlayer == player.whoAmI) - { - // In addition to typical channel cancellation criteria, the sword fizzles out if it runs out of charge. - Item playerItem = player.ActiveItem(); - bool hasCharge = modItem.Charge > 0f; - if (player.channel && !player.noItems && !player.CCed && playerItem.type == ModContent.ItemType() && hasCharge) - { - // The distance ratio ranges from 0 (your mouse is directly on the player) to 1 (your mouse is at the max range considered, or any further distance). - float mouseDistance = projectile.Distance(Main.MouseWorld); - float distRatio = Utils.InverseLerp(0f, MaximumMouseRange, mouseDistance, true); + private void ManipulatePlayer(Player player, CalamityGlobalItem modItem) + { + if (Main.myPlayer == player.whoAmI) + { + // In addition to typical channel cancellation criteria, the sword fizzles out if it runs out of charge. + Item playerItem = player.ActiveItem(); + bool hasCharge = modItem.Charge > 0f; + if (player.channel && !player.noItems && !player.CCed && playerItem.type == ModContent.ItemType() && hasCharge) + { + // The distance ratio ranges from 0 (your mouse is directly on the player) to 1 (your mouse is at the max range considered, or any further distance). + float mouseDistance = projectile.Distance(Main.MouseWorld); + float distRatio = Utils.InverseLerp(0f, MaximumMouseRange, mouseDistance, true); - // This formula ensures that the sword has a sudden and extremely harsh responsiveness penalty when the mouse is close to the player. - // Otherwise it controls perfectly fine. - float aimResponsiveness = 0.035f + 0.3f * (float)Math.Pow(distRatio, 1D/3); + // This formula ensures that the sword has a sudden and extremely harsh responsiveness penalty when the mouse is close to the player. + // Otherwise it controls perfectly fine. + float aimResponsiveness = 0.035f + 0.3f * (float)Math.Pow(distRatio, 1D/3); - // Update the sword's angle with the responsiveness determined by mouse position. - // Also flag for netcode sync if applicable (this is the only way the sword can rotate in multiplayer). - float newRotation = projectile.rotation.AngleLerp(player.AngleTo(Main.MouseWorld), aimResponsiveness); - if (projectile.rotation != newRotation) - { - projectile.netUpdate = true; - projectile.netSpam = 0; // You cannot stop Phaseslayer from sending packets. - } - projectile.rotation = newRotation; - } + // Update the sword's angle with the responsiveness determined by mouse position. + // Also flag for netcode sync if applicable (this is the only way the sword can rotate in multiplayer). + float newRotation = projectile.rotation.AngleLerp(player.AngleTo(Main.MouseWorld), aimResponsiveness); + if (projectile.rotation != newRotation) + { + projectile.netUpdate = true; + projectile.netSpam = 0; // You cannot stop Phaseslayer from sending packets. + } + projectile.rotation = newRotation; + } - // If the player is not wielding the sword, determine whether it should fade out or instantly vanish. - else if (FadeoutTime == 0f) - { - // If the player voluntarily stopped holding left mouse, start the fadeout timer. - if (!player.channel) - FadeoutTime = 10f; - // If the player was killed, frozen, cursed, etc. just delete it immediately. - else - projectile.Kill(); - } - } + // If the player is not wielding the sword, determine whether it should fade out or instantly vanish. + else if (FadeoutTime == 0f) + { + // If the player voluntarily stopped holding left mouse, start the fadeout timer. + if (!player.channel) + FadeoutTime = 10f; + // If the player was killed, frozen, cursed, etc. just delete it immediately. + else + projectile.Kill(); + } + } - // This line ensures the sword stays glued to the player, even for other players in multiplayer. - projectile.Center = player.MountedCenter + projectile.rotation.ToRotationVector2() * ProjCenterOffset; + // This line ensures the sword stays glued to the player, even for other players in multiplayer. + projectile.Center = player.MountedCenter + projectile.rotation.ToRotationVector2() * ProjCenterOffset; - // These lines ensure the player and their arm are rotated the correct direction to hold the sword. - projectile.direction = (Math.Cos(projectile.rotation) > 0).ToDirectionInt(); - player.ChangeDir(projectile.direction); - player.itemTime = 2; - player.itemAnimation = 2; - player.itemRotation = CalamityUtils.WrapAngle90Degrees(projectile.rotation); - } + // These lines ensure the player and their arm are rotated the correct direction to hold the sword. + projectile.direction = (Math.Cos(projectile.rotation) > 0).ToDirectionInt(); + player.ChangeDir(projectile.direction); + player.itemTime = 2; + player.itemAnimation = 2; + player.itemRotation = CalamityUtils.WrapAngle90Degrees(projectile.rotation); + } - private void OnShrinkEffects() - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/MechGaussRifle"), projectile.Center); - if (Main.dedServ) - return; + private void OnShrinkEffects() + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/MechGaussRifle"), projectile.Center); + if (Main.dedServ) + return; - for (int i = 0; i < 60; i++) - { - Dust dust = Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.Brimstone); - dust.velocity = Main.rand.NextVector2Circular(20f, 20f); - dust.scale = 2.5f; - dust.fadeIn = 1.2f; - dust.noGravity = true; - } - } + for (int i = 0; i < 60; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.Brimstone); + dust.velocity = Main.rand.NextVector2Circular(20f, 20f); + dust.scale = 2.5f; + dust.fadeIn = 1.2f; + dust.noGravity = true; + } + } - private void AdjustCurrentDamage(Player player, float deltaAngle) - { - // Update the rolling "blade angular momentum" average by gently lerping in the newest data point. - AngularDamageFactor = MathHelper.Lerp(AngularDamageFactor, deltaAngle, DamageUpdateResponsiveness); + private void AdjustCurrentDamage(Player player, float deltaAngle) + { + // Update the rolling "blade angular momentum" average by gently lerping in the newest data point. + AngularDamageFactor = MathHelper.Lerp(AngularDamageFactor, deltaAngle, DamageUpdateResponsiveness); - // 0x expected speed gives you 53.5% damage. - // 1x expected speed gives you 100.0% damage. - // 1.5x expected speed gives you 116.6% damage. - // 2x expected speed gives you 130.6% damage. - // 3x expected speed gives you 153.5% damage. - // 4x expected speed gives you 171.7% damage. - // 5x expected speed gives you 187.0% damage. - float speedDamageScalar = 0.166f + (float)Math.Log(AngularDamageFactor / StandardSwingSpeed + 1.5f, 3f); + // 0x expected speed gives you 53.5% damage. + // 1x expected speed gives you 100.0% damage. + // 1.5x expected speed gives you 116.6% damage. + // 2x expected speed gives you 130.6% damage. + // 3x expected speed gives you 153.5% damage. + // 4x expected speed gives you 171.7% damage. + // 5x expected speed gives you 187.0% damage. + float speedDamageScalar = 0.166f + (float)Math.Log(AngularDamageFactor / StandardSwingSpeed + 1.5f, 3f); - // Get the underlying sword item's current damage. This takes into account the player's stats and the sword's current charge. - int damageWithChargeAndStats = player.GetWeaponDamage(player.ActiveItem()); - float sizeDamageScalar = IsSmall ? Phaseslayer.SmallDamageMultiplier : 1f; - projectile.damage = (int)(damageWithChargeAndStats * speedDamageScalar * sizeDamageScalar); - } + // Get the underlying sword item's current damage. This takes into account the player's stats and the sword's current charge. + int damageWithChargeAndStats = player.GetWeaponDamage(player.ActiveItem()); + float sizeDamageScalar = IsSmall ? Phaseslayer.SmallDamageMultiplier : 1f; + projectile.damage = (int)(damageWithChargeAndStats * speedDamageScalar * sizeDamageScalar); + } - private void ManipulateFrames() - { - projectile.frame = 0; + private void ManipulateFrames() + { + projectile.frame = 0; - if (IsSmall) - { - // Fadeout frames. - if (FadeoutTime > 5) - projectile.frame = 1; - else if (FadeoutTime > 0) - projectile.frame = 2; - } - else - { - projectile.frameCounter++; - int adjustFrameCounter = projectile.frameCounter % 120; + if (IsSmall) + { + // Fadeout frames. + if (FadeoutTime > 5) + projectile.frame = 1; + else if (FadeoutTime > 0) + projectile.frame = 2; + } + else + { + projectile.frameCounter++; + int adjustFrameCounter = projectile.frameCounter % 120; - // Idle lightning frames. - if (adjustFrameCounter >= 50 && adjustFrameCounter <= 78) - projectile.frame = (int)MathHelper.Lerp(1, 9, Utils.InverseLerp(50, 75, adjustFrameCounter, true)); - if (adjustFrameCounter >= 90 && adjustFrameCounter <= 120) - projectile.frame = (int)MathHelper.Lerp(10, 18, Utils.InverseLerp(90, 117, adjustFrameCounter, true)); + // Idle lightning frames. + if (adjustFrameCounter >= 50 && adjustFrameCounter <= 78) + projectile.frame = (int)MathHelper.Lerp(1, 9, Utils.InverseLerp(50, 75, adjustFrameCounter, true)); + if (adjustFrameCounter >= 90 && adjustFrameCounter <= 120) + projectile.frame = (int)MathHelper.Lerp(10, 18, Utils.InverseLerp(90, 117, adjustFrameCounter, true)); - // Fadeout frames. - if (FadeoutTime > 5) - projectile.frame = 19; - else if (FadeoutTime > 0) - projectile.frame = 20; - } - } + // Fadeout frames. + if (FadeoutTime > 5) + projectile.frame = 19; + else if (FadeoutTime > 0) + projectile.frame = 20; + } + } - private void HandleSwordBeams(Player player, CalamityGlobalItem modItem, float deltaAngle) - { - // Producing a sword beam takes a bit higher of a speed than the "typical" speed the sword is balanced around. - if (projectile.soundDelay <= 0 && deltaAngle >= 1.3f * StandardSwingSpeed) - { - // Sword beams cost a noticeable amount of energy, but deal the blade's current damage. Swing harder to get more damage! - if (Main.myPlayer == player.whoAmI) - { - Vector2 velocity = projectile.rotation.ToRotationVector2() * 20f; - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * SwordBeamDamageMultiplier), 0f, player.whoAmI); + private void HandleSwordBeams(Player player, CalamityGlobalItem modItem, float deltaAngle) + { + // Producing a sword beam takes a bit higher of a speed than the "typical" speed the sword is balanced around. + if (projectile.soundDelay <= 0 && deltaAngle >= 1.3f * StandardSwingSpeed) + { + // Sword beams cost a noticeable amount of energy, but deal the blade's current damage. Swing harder to get more damage! + if (Main.myPlayer == player.whoAmI) + { + Vector2 velocity = projectile.rotation.ToRotationVector2() * 20f; + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * SwordBeamDamageMultiplier), 0f, player.whoAmI); - // Actually consume energy to fire the sword beam. - modItem.Charge -= Phaseslayer.SwordBeamChargeUse; - } + // Actually consume energy to fire the sword beam. + modItem.Charge -= Phaseslayer.SwordBeamChargeUse; + } - // The sound delay doubles as the sword beam's cooldown. - projectile.soundDelay = SwordBeamCooldown; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ELRFire"), projectile.Center); - } - } + // The sound delay doubles as the sword beam's cooldown. + projectile.soundDelay = SwordBeamCooldown; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ELRFire"), projectile.Center); + } + } - private void HandleFadeout() - { - if (FadeoutTime > 0) - { - FadeoutTime--; - if (FadeoutTime <= 0f) - projectile.Kill(); - } - } + private void HandleFadeout() + { + if (FadeoutTime > 0) + { + FadeoutTime--; + if (FadeoutTime <= 0f) + projectile.Kill(); + } + } - internal PrimitiveTrail TrailDrawer; - internal Color ColorFunction(float completionRatio) - { - float averageRotation = projectile.oldRot.Take(20).Average(angle => MathHelper.WrapAngle(angle) + MathHelper.Pi); - float deltaAngle = Math.Abs(averageRotation - (MathHelper.WrapAngle(projectile.rotation) + MathHelper.Pi)); - float opacity = projectile.Opacity; - opacity *= Utils.InverseLerp(StandardSwingSpeed * 0.7f, StandardSwingSpeed, AngularDamageFactor, true); - opacity *= (float)Math.Pow(Utils.InverseLerp(1f, 0.45f, completionRatio, true), 4D); - opacity *= (float)Math.Pow(Utils.InverseLerp(0.9f, 1.1f, deltaAngle, true), 2D); + internal PrimitiveTrail TrailDrawer; + internal Color ColorFunction(float completionRatio) + { + float averageRotation = projectile.oldRot.Take(20).Average(angle => MathHelper.WrapAngle(angle) + MathHelper.Pi); + float deltaAngle = Math.Abs(averageRotation - (MathHelper.WrapAngle(projectile.rotation) + MathHelper.Pi)); + float opacity = projectile.Opacity; + opacity *= Utils.InverseLerp(StandardSwingSpeed * 0.7f, StandardSwingSpeed, AngularDamageFactor, true); + opacity *= (float)Math.Pow(Utils.InverseLerp(1f, 0.45f, completionRatio, true), 4D); + opacity *= (float)Math.Pow(Utils.InverseLerp(0.9f, 1.1f, deltaAngle, true), 2D); - float rotationAdjusted = MathHelper.WrapAngle(projectile.rotation) + MathHelper.Pi; - float oldRotationAdjusted = MathHelper.WrapAngle(projectile.oldRot[1]) + MathHelper.Pi; - deltaAngle = Math.Abs(MathHelper.WrapAngle(rotationAdjusted - oldRotationAdjusted)); + float rotationAdjusted = MathHelper.WrapAngle(projectile.rotation) + MathHelper.Pi; + float oldRotationAdjusted = MathHelper.WrapAngle(projectile.oldRot[1]) + MathHelper.Pi; + deltaAngle = Math.Abs(MathHelper.WrapAngle(rotationAdjusted - oldRotationAdjusted)); - if (deltaAngle < 0.04f) - opacity = 0f; + if (deltaAngle < 0.04f) + opacity = 0f; - return Color.Lerp(Color.Red, Color.PaleVioletRed * completionRatio, MathHelper.Clamp(completionRatio * 0.8f, 0f, 1f)) * opacity; - } + return Color.Lerp(Color.Red, Color.PaleVioletRed * completionRatio, MathHelper.Clamp(completionRatio * 0.8f, 0f, 1f)) * opacity; + } - internal float WidthFunction(float completionRatio) => (IsSmall ? 101f : 127f) * (1f - completionRatio) * 0.8f; + internal float WidthFunction(float completionRatio) => (IsSmall ? 101f : 127f) * (1f - completionRatio) * 0.8f; - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D bladeTexture = ModContent.GetTexture("CalamityMod/Projectiles/DraedonsArsenal/PhaseslayerBlade"); - Texture2D hiltTexture = ModContent.GetTexture(Texture); - if (IsSmall) - bladeTexture = ModContent.GetTexture("CalamityMod/Projectiles/DraedonsArsenal/PhaseslayerBladeSmall"); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D bladeTexture = ModContent.GetTexture("CalamityMod/Projectiles/DraedonsArsenal/PhaseslayerBlade"); + Texture2D hiltTexture = ModContent.GetTexture(Texture); + if (IsSmall) + bladeTexture = ModContent.GetTexture("CalamityMod/Projectiles/DraedonsArsenal/PhaseslayerBladeSmall"); - float bladeLength = (IsSmall ? 90f : 132f) * projectile.scale; - Vector2 bladeOffset = projectile.rotation.ToRotationVector2() * bladeLength; - Vector2 origin = bladeTexture.Size() * 0.5f; - origin /= IsSmall ? new Vector2(1f, 3f) : new Vector2(3f, 7f); + float bladeLength = (IsSmall ? 90f : 132f) * projectile.scale; + Vector2 bladeOffset = projectile.rotation.ToRotationVector2() * bladeLength; + Vector2 origin = bladeTexture.Size() * 0.5f; + origin /= IsSmall ? new Vector2(1f, 3f) : new Vector2(3f, 7f); - Rectangle frame = IsSmall ? bladeTexture.Frame(1, 3, 0, BladeFrameY) : bladeTexture.Frame(3, 7, BladeFrameX, BladeFrameY); + Rectangle frame = IsSmall ? bladeTexture.Frame(1, 3, 0, BladeFrameY) : bladeTexture.Frame(3, 7, BladeFrameX, BladeFrameY); - if (TrailDrawer is null) - TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]); + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]); - GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/SwordSlashTexture")); + GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/SwordSlashTexture")); - Player player = Main.player[projectile.owner]; - float swingAngularDirection = Math.Sign(MathHelper.WrapAngle(projectile.rotation - projectile.oldRot[1])); + Player player = Main.player[projectile.owner]; + float swingAngularDirection = Math.Sign(MathHelper.WrapAngle(projectile.rotation - projectile.oldRot[1])); - Vector2[] drawPoints = new Vector2[projectile.oldPos.Length]; - Vector2 perpendicularDirection = bladeOffset.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.PiOver2); - for (int i = 0; i < drawPoints.Length; i++) - { - if (projectile.oldPos[i] == Vector2.Zero) - continue; + Vector2[] drawPoints = new Vector2[projectile.oldPos.Length]; + Vector2 perpendicularDirection = bladeOffset.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.PiOver2); + for (int i = 0; i < drawPoints.Length; i++) + { + if (projectile.oldPos[i] == Vector2.Zero) + continue; - float swingFactor = MathHelper.Min(1f, AngularDamageFactor); - float offsetFactor = i * -swingAngularDirection * MathHelper.Min(0.8f, swingFactor) * 100f; - float angularTurn = i * swingAngularDirection * -0.09f; - drawPoints[i] = projectile.position + perpendicularDirection.RotatedBy(angularTurn) * offsetFactor; - } + float swingFactor = MathHelper.Min(1f, AngularDamageFactor); + float offsetFactor = i * -swingAngularDirection * MathHelper.Min(0.8f, swingFactor) * 100f; + float angularTurn = i * swingAngularDirection * -0.09f; + drawPoints[i] = projectile.position + perpendicularDirection.RotatedBy(angularTurn) * offsetFactor; + } - TrailDrawer.Draw(drawPoints, projectile.Size * 0.5f + bladeOffset - Main.screenPosition, 50); - spriteBatch.Draw(bladeTexture, projectile.Center + bladeOffset - Main.screenPosition, frame, Color.White, projectile.rotation + MathHelper.PiOver2, origin, projectile.scale, SpriteEffects.None, 0f); - spriteBatch.Draw(hiltTexture, projectile.Center - Main.screenPosition, null, lightColor, projectile.rotation + MathHelper.PiOver2, hiltTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + TrailDrawer.Draw(drawPoints, projectile.Size * 0.5f + bladeOffset - Main.screenPosition, 50); + spriteBatch.Draw(bladeTexture, projectile.Center + bladeOffset - Main.screenPosition, frame, Color.White, projectile.rotation + MathHelper.PiOver2, origin, projectile.scale, SpriteEffects.None, 0f); + spriteBatch.Draw(hiltTexture, projectile.Center - Main.screenPosition, null, lightColor, projectile.rotation + MathHelper.PiOver2, hiltTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); - return false; - } + return false; + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - float _ = 0f; - Vector2 start = projectile.Center + projectile.rotation.ToRotationVector2() * 28f; - Vector2 end = start + projectile.rotation.ToRotationVector2() * (IsSmall ? 202f : 254f) * projectile.scale; - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, 60f * projectile.scale, ref _); - } - } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float _ = 0f; + Vector2 start = projectile.Center + projectile.rotation.ToRotationVector2() * 28f; + Vector2 end = start + projectile.rotation.ToRotationVector2() * (IsSmall ? 202f : 254f) * projectile.scale; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, 60f * projectile.scale, ref _); + } + } } diff --git a/Projectiles/DraedonsArsenal/PlasmaCasterShot.cs b/Projectiles/DraedonsArsenal/PlasmaCasterShot.cs index 8d27929e02..7de5d6872c 100644 --- a/Projectiles/DraedonsArsenal/PlasmaCasterShot.cs +++ b/Projectiles/DraedonsArsenal/PlasmaCasterShot.cs @@ -10,13 +10,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private int dust1 = 107; //160 - private int dust2 = 110; //187 + private int dust1 = 107; //160 + private int dust2 = 110; //187 - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Plasma Bolt"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plasma Bolt"); + } public override void SetDefaults() { @@ -31,190 +31,190 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { - Lighting.AddLight(projectile.Center, 0f, 0.6f, 0f); + Lighting.AddLight(projectile.Center, 0f, 0.6f, 0f); - int dustTypeOnTimer = dust1; + int dustTypeOnTimer = dust1; - float createDustVar = 10f; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > createDustVar) - { - for (int num447 = 0; num447 < 2; num447++) - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * (num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, dustTypeOnTimer, 0f, 0f, 0, default, 1f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.2f; - } + float createDustVar = 10f; + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > createDustVar) + { + for (int num447 = 0; num447 < 2; num447++) + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * (num447 * 0.25f); + int num448 = Dust.NewDust(vector33, 1, 1, dustTypeOnTimer, 0f, 0f, 0, default, 1f); + Main.dust[num448].noGravity = true; + Main.dust[num448].position = vector33; + Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.013f; + Main.dust[num448].velocity *= 0.2f; + } - projectile.ai[0] += 1f; - if (projectile.ai[0] == 48f) - { - projectile.ai[0] = 0f; + projectile.ai[0] += 1f; + if (projectile.ai[0] == 48f) + { + projectile.ai[0] = 0f; - if (dustTypeOnTimer == dust1) - dustTypeOnTimer = dust2; - else - dustTypeOnTimer = dust1; - } - else - { - Vector2 value7 = new Vector2(5f, 10f); + if (dustTypeOnTimer == dust1) + dustTypeOnTimer = dust2; + else + dustTypeOnTimer = dust1; + } + else + { + Vector2 value7 = new Vector2(5f, 10f); - for (int num41 = 0; num41 < 2; num41++) - { - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy(projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 0.75f; - int num42 = Dust.NewDust(projectile.Center, 0, 0, dust1, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 0.6f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = projectile.Center + value8; - Main.dust[num42].velocity = projectile.velocity; - } + for (int num41 = 0; num41 < 2; num41++) + { + Vector2 value8 = Vector2.UnitX * -12f; + value8 = -Vector2.UnitY.RotatedBy(projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 0.75f; + int num42 = Dust.NewDust(projectile.Center, 0, 0, dust1, 0f, 0f, 160, default, 1f); + Main.dust[num42].scale = 0.6f; + Main.dust[num42].noGravity = true; + Main.dust[num42].position = projectile.Center + value8; + Main.dust[num42].velocity = projectile.velocity; + } - for (int num41 = 0; num41 < 2; num41++) - { - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy(projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 1.5f; - int num42 = Dust.NewDust(projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 0.6f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = projectile.Center + value8; - Main.dust[num42].velocity = projectile.velocity; - } - } - } + for (int num41 = 0; num41 < 2; num41++) + { + Vector2 value8 = Vector2.UnitX * -12f; + value8 = -Vector2.UnitY.RotatedBy(projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 1.5f; + int num42 = Dust.NewDust(projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); + Main.dust[num42].scale = 0.6f; + Main.dust[num42].noGravity = true; + Main.dust[num42].position = projectile.Center + value8; + Main.dust[num42].velocity = projectile.velocity; + } + } + } - if (projectile.localAI[0] == createDustVar) - PlasmaBurst(1f, 1.6f); - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.OnFire, 180); - target.AddBuff(BuffID.CursedInferno, 90); + if (projectile.localAI[0] == createDustVar) + PlasmaBurst(1f, 1.6f); } - public override void Kill(int timeLeft) - { - int height = 90; - projectile.position = projectile.Center; - projectile.width = projectile.height = height; - projectile.Center = projectile.position; - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.CursedInferno, 90); + } - Main.PlaySound(SoundID.Item93, projectile.Center); + public override void Kill(int timeLeft) + { + int height = 90; + projectile.position = projectile.Center; + projectile.width = projectile.height = height; + projectile.Center = projectile.position; + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); - PlasmaBurst(1.8f, 3.6f); // 60 dusts + Main.PlaySound(SoundID.Item93, projectile.Center); - int num3; - for (int num640 = 0; num640 < 400; num640 = num3 + 1) - { - float num641 = 16f; - if (num640 < 300) - num641 = 12f; - if (num640 < 200) - num641 = 8f; - if (num640 < 100) - num641 = 4f; + PlasmaBurst(1.8f, 3.6f); // 60 dusts - int num643 = Dust.NewDust(projectile.Center, 6, 6, Main.rand.Next(2) == 0 ? dust1 : dust2, 0f, 0f, 100, default, 1f); - float num644 = Main.dust[num643].velocity.X; - float num645 = Main.dust[num643].velocity.Y; + int num3; + for (int num640 = 0; num640 < 400; num640 = num3 + 1) + { + float num641 = 16f; + if (num640 < 300) + num641 = 12f; + if (num640 < 200) + num641 = 8f; + if (num640 < 100) + num641 = 4f; - if (num644 == 0f && num645 == 0f) - num644 = 1f; + int num643 = Dust.NewDust(projectile.Center, 6, 6, Main.rand.Next(2) == 0 ? dust1 : dust2, 0f, 0f, 100, default, 1f); + float num644 = Main.dust[num643].velocity.X; + float num645 = Main.dust[num643].velocity.Y; - float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); - num646 = num641 / num646; - num644 *= num646; - num645 *= num646; + if (num644 == 0f && num645 == 0f) + num644 = 1f; - float scale = 1f; - switch ((int)num641) - { - case 4: - scale = 1.2f; - break; - case 8: - scale = 1.1f; - break; - case 12: - scale = 1f; - break; - case 16: - scale = 0.9f; - break; - default: - break; - } + float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); + num646 = num641 / num646; + num644 *= num646; + num645 *= num646; - Dust dust = Main.dust[num643]; - dust.velocity *= 0.5f; - dust.velocity.X = dust.velocity.X + num644; - dust.velocity.Y = dust.velocity.Y + num645; - dust.scale = scale; - dust.noGravity = true; + float scale = 1f; + switch ((int)num641) + { + case 4: + scale = 1.2f; + break; + case 8: + scale = 1.1f; + break; + case 12: + scale = 1f; + break; + case 16: + scale = 0.9f; + break; + default: + break; + } - num3 = num640; - } - } + Dust dust = Main.dust[num643]; + dust.velocity *= 0.5f; + dust.velocity.X = dust.velocity.X + num644; + dust.velocity.Y = dust.velocity.Y + num645; + dust.scale = scale; + dust.noGravity = true; - private void PlasmaBurst(float speed1, float speed2) - { - float angleRandom = 0.35f; + num3 = num640; + } + } - for (int num53 = 0; num53 < 40; num53++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int randomDustType = Main.rand.Next(2) == 0 ? dust1 : dust2; + private void PlasmaBurst(float speed1, float speed2) + { + float angleRandom = 0.35f; - int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - Main.dust[num54].noGravity = true; + for (int num53 = 0; num53 < 40; num53++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + int randomDustType = Main.rand.Next(2) == 0 ? dust1 : dust2; - Dust dust = Main.dust[num54]; - dust.velocity *= 3f; - dust = Main.dust[num54]; + int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + Main.dust[num54].noGravity = true; - num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + Dust dust = Main.dust[num54]; + dust.velocity *= 3f; + dust = Main.dust[num54]; - dust = Main.dust[num54]; - dust.velocity *= 2f; + num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Green * 0.5f; + dust = Main.dust[num54]; + dust.velocity *= 2f; - dust = Main.dust[num54]; - } - for (int num55 = 0; num55 < 20; num55++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int randomDustType = Main.rand.Next(2) == 0 ? dust1 : dust2; + Main.dust[num54].noGravity = true; + Main.dust[num54].fadeIn = 1f; + Main.dust[num54].color = Color.Green * 0.5f; - int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); - Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; - Main.dust[num56].noGravity = true; + dust = Main.dust[num54]; + } + for (int num55 = 0; num55 < 20; num55++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + int randomDustType = Main.rand.Next(2) == 0 ? dust1 : dust2; - Dust dust = Main.dust[num56]; - dust.velocity *= 0.5f; - dust = Main.dust[num56]; - } - } - } + int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); + Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; + Main.dust[num56].noGravity = true; + + Dust dust = Main.dust[num56]; + dust.velocity *= 0.5f; + dust = Main.dust[num56]; + } + } + } } diff --git a/Projectiles/DraedonsArsenal/PlasmaGrenadeSmallExplosion.cs b/Projectiles/DraedonsArsenal/PlasmaGrenadeSmallExplosion.cs index 4342c19823..3fb89e59ee 100644 --- a/Projectiles/DraedonsArsenal/PlasmaGrenadeSmallExplosion.cs +++ b/Projectiles/DraedonsArsenal/PlasmaGrenadeSmallExplosion.cs @@ -5,67 +5,67 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class PlasmaGrenadeSmallExplosion : ModProjectile - { - public float Time - { - get => projectile.ai[0]; - set => projectile.ai[0] = value; - } + public class PlasmaGrenadeSmallExplosion : ModProjectile + { + public float Time + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } - public int frameX = 0; - public int frameY = 0; - private const int horizontalFrames = 2; - private const int verticalFrames = 7; - private const int frameLength = 5; - private const float radius = 139.5f; + public int frameX = 0; + public int frameY = 0; + private const int horizontalFrames = 2; + private const int verticalFrames = 7; + private const int frameLength = 5; + private const float radius = 139.5f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Plasma Explosion"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plasma Explosion"); + } - public override void SetDefaults() - { - projectile.width = projectile.height = 279; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.Calamity().rogue = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = -1; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 279; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.Calamity().rogue = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; + } - public override void AI() - { - projectile.frameCounter++; - if (projectile.frameCounter % frameLength == frameLength - 1) - { - frameY++; - if (frameY >= verticalFrames) - { - frameX++; - frameY = 0; - } - if (frameX >= horizontalFrames) - { - projectile.Kill(); - } - } - } + public override void AI() + { + projectile.frameCounter++; + if (projectile.frameCounter % frameLength == frameLength - 1) + { + frameY++; + if (frameY >= verticalFrames) + { + frameX++; + frameY = 0; + } + if (frameX >= horizontalFrames) + { + projectile.Kill(); + } + } + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, radius, targetHitbox); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int length = texture.Width / horizontalFrames; - int height = texture.Height / verticalFrames; - Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - Rectangle frame = new Rectangle(frameX * length, frameY * height, length, height); - Vector2 origin = new Vector2(length / 2f, height / 2f); - spriteBatch.Draw(texture, drawPos, frame, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int length = texture.Width / horizontalFrames; + int height = texture.Height / verticalFrames; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Rectangle frame = new Rectangle(frameX * length, frameY * height, length, height); + Vector2 origin = new Vector2(length / 2f, height / 2f); + spriteBatch.Draw(texture, drawPos, frame, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + return false; + } + } } diff --git a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs index 32e631d304..d6e4f5e8ba 100644 --- a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs +++ b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs @@ -9,7 +9,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class PulseDragonProjectile : ModProjectile + public class PulseDragonProjectile : ModProjectile { public bool ReelingBack { @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 4; projectile.tileCollide = false; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void SendExtraAI(BinaryWriter writer) @@ -126,13 +126,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (Main.myPlayer != projectile.owner) return; Projectile field = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ProjectileID.Electrosphere, projectile.damage, projectile.knockBack, projectile.owner); - if (field.whoAmI.WithinBounds(Main.maxProjectiles)) - { - field.Calamity().forceMelee = true; - field.usesLocalNPCImmunity = true; - field.localNPCHitCooldown = 3; - field.timeLeft = 12; - } + if (field.whoAmI.WithinBounds(Main.maxProjectiles)) + { + field.Calamity().forceMelee = true; + field.usesLocalNPCImmunity = true; + field.localNPCHitCooldown = 3; + field.timeLeft = 12; + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/DraedonsArsenal/PulsePistolShot.cs b/Projectiles/DraedonsArsenal/PulsePistolShot.cs index 90667d4dae..364e0c0084 100644 --- a/Projectiles/DraedonsArsenal/PulsePistolShot.cs +++ b/Projectiles/DraedonsArsenal/PulsePistolShot.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class PulsePistolShot : ModProjectile + public class PulsePistolShot : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -22,9 +22,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal set => projectile.ai[1] = value; } public List NPCsAlreadyHit = new List(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pulse Bolt"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pulse Bolt"); ProjectileID.Sets.TrailingMode[projectile.type] = 2; ProjectileID.Sets.TrailCacheLength[projectile.type] = 12; } @@ -40,8 +40,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.timeLeft = 120 * (1 + projectile.extraUpdates); } - public override void AI() - { + public override void AI() + { Time++; if (Time >= 10f || NPCsAlreadyHit.Count > 0) { diff --git a/Projectiles/DraedonsArsenal/PulseRifleShot.cs b/Projectiles/DraedonsArsenal/PulseRifleShot.cs index 1062666d67..e95be8bafd 100644 --- a/Projectiles/DraedonsArsenal/PulseRifleShot.cs +++ b/Projectiles/DraedonsArsenal/PulseRifleShot.cs @@ -10,15 +10,15 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private int dust1 = 27; //purple - private int dust2 = 173; //shortlived purple - private int dust3 = 234; //cyan and pink - private bool hasHit = false; + private int dust1 = 27; //purple + private int dust2 = 173; //shortlived purple + private int dust3 = 234; //cyan and pink + private bool hasHit = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pulse Bolt"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pulse Bolt"); + } public override void SetDefaults() { @@ -33,234 +33,234 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { - bool notSplitProjectile = projectile.ai[1] == 0f; + bool notSplitProjectile = projectile.ai[1] == 0f; - Lighting.AddLight(projectile.Center, 0.3f, 0f, 0.5f); + Lighting.AddLight(projectile.Center, 0.3f, 0f, 0.5f); - float createDustVar = 10f; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > createDustVar) - { - for (int num447 = 0; num447 < 2; num447++) - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * (num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, dust1, 0f, 0f, 0, default, 1f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.013f; + float createDustVar = 10f; + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > createDustVar) + { + for (int num447 = 0; num447 < 2; num447++) + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * (num447 * 0.25f); + int num448 = Dust.NewDust(vector33, 1, 1, dust1, 0f, 0f, 0, default, 1f); + Main.dust[num448].noGravity = true; + Main.dust[num448].position = vector33; + Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.013f; - int num449 = Dust.NewDust(vector33, 1, 1, dust3, 0f, 0f, 0, default, 1f); - Main.dust[num449].noGravity = true; - Main.dust[num449].position = vector33; - Main.dust[num449].scale = Main.rand.Next(70, 110) * 0.013f; - } + int num449 = Dust.NewDust(vector33, 1, 1, dust3, 0f, 0f, 0, default, 1f); + Main.dust[num449].noGravity = true; + Main.dust[num449].position = vector33; + Main.dust[num449].scale = Main.rand.Next(70, 110) * 0.013f; + } - if (notSplitProjectile) - { - Vector2 value7 = new Vector2(5f, 10f); - Vector2 value8 = Vector2.UnitX * -12f; + if (notSplitProjectile) + { + Vector2 value7 = new Vector2(5f, 10f); + Vector2 value8 = Vector2.UnitX * -12f; - for (int num41 = 0; num41 < 2; num41++) - { - value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 0f * MathHelper.Pi) * value7; - int num42 = Dust.NewDust(projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 1.5f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = projectile.Center + value8; - } + for (int num41 = 0; num41 < 2; num41++) + { + value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 0f * MathHelper.Pi) * value7; + int num42 = Dust.NewDust(projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); + Main.dust[num42].scale = 1.5f; + Main.dust[num42].noGravity = true; + Main.dust[num42].position = projectile.Center + value8; + } - for (int num41 = 0; num41 < 2; num41++) - { - value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 1f * MathHelper.Pi) * value7; - int num42 = Dust.NewDust(projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 1.5f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = projectile.Center + value8; - } - } - } + for (int num41 = 0; num41 < 2; num41++) + { + value8 = -Vector2.UnitY.RotatedBy(24f * 0.1308997f + 1f * MathHelper.Pi) * value7; + int num42 = Dust.NewDust(projectile.Center, 0, 0, dust2, 0f, 0f, 160, default, 1f); + Main.dust[num42].scale = 1.5f; + Main.dust[num42].noGravity = true; + Main.dust[num42].position = projectile.Center + value8; + } + } + } - if (projectile.localAI[0] == createDustVar && notSplitProjectile) - PulseBurst(4f, 5f); - } + if (projectile.localAI[0] == createDustVar && notSplitProjectile) + PulseBurst(4f, 5f); + } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 280 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 280 && target.CanBeChasedBy(projectile); - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.ai[1] < 5f && !hasHit && Main.myPlayer == projectile.owner) - { - hasHit = true; + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (projectile.ai[1] < 5f && !hasHit && Main.myPlayer == projectile.owner) + { + hasHit = true; - int alreadyTargetedNPCType = 0; - if (projectile.ai[1] > 0f) - alreadyTargetedNPCType = (int)projectile.ai[0]; - else - alreadyTargetedNPCType = target.whoAmI; + int alreadyTargetedNPCType = 0; + if (projectile.ai[1] > 0f) + alreadyTargetedNPCType = (int)projectile.ai[0]; + else + alreadyTargetedNPCType = target.whoAmI; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (!Main.npc[i].CanBeChasedBy(projectile, false) || !Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) - continue; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (!Main.npc[i].CanBeChasedBy(projectile, false) || !Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + continue; - if (alreadyTargetedNPCType != Main.npc[i].whoAmI && projectile.Center.ManhattanDistance(Main.npc[i].Center) < 600f) - { - Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(Main.npc[i].Center) * 5f, projectile.type, projectile.damage / 2, 0f, projectile.owner, Main.npc[i].whoAmI, projectile.ai[1] + 1f); - break; - } - } - } - } + if (alreadyTargetedNPCType != Main.npc[i].whoAmI && projectile.Center.ManhattanDistance(Main.npc[i].Center) < 600f) + { + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(Main.npc[i].Center) * 5f, projectile.type, projectile.damage / 2, 0f, projectile.owner, Main.npc[i].whoAmI, projectile.ai[1] + 1f); + break; + } + } + } + } - public override void Kill(int timeLeft) - { - int timesSplit = (int)projectile.ai[1]; + public override void Kill(int timeLeft) + { + int timesSplit = (int)projectile.ai[1]; - int height = 40; - int totalDust = 400; - float speed1 = 10f; - switch (timesSplit) - { - case 1: - height = 35; - totalDust = 350; - speed1 = 8.5f; - break; - case 2: - height = 30; - totalDust = 300; - speed1 = 7f; - break; - case 3: - height = 25; - totalDust = 250; - speed1 = 5.5f; - break; - case 4: - height = 20; - totalDust = 200; - speed1 = 4f; - break; - case 5: - height = 15; - totalDust = 150; - speed1 = 2.5f; - break; - default: - break; - } + int height = 40; + int totalDust = 400; + float speed1 = 10f; + switch (timesSplit) + { + case 1: + height = 35; + totalDust = 350; + speed1 = 8.5f; + break; + case 2: + height = 30; + totalDust = 300; + speed1 = 7f; + break; + case 3: + height = 25; + totalDust = 250; + speed1 = 5.5f; + break; + case 4: + height = 20; + totalDust = 200; + speed1 = 4f; + break; + case 5: + height = 15; + totalDust = 150; + speed1 = 2.5f; + break; + default: + break; + } - projectile.position = projectile.Center; - projectile.width = projectile.height = height; - projectile.Center = projectile.position; - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); + projectile.position = projectile.Center; + projectile.width = projectile.height = height; + projectile.Center = projectile.position; + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); - Main.PlaySound(SoundID.Item93, projectile.Center); + Main.PlaySound(SoundID.Item93, projectile.Center); - int fourth = totalDust / 4; - int half = totalDust / 2; - int x = (int)(totalDust * 0.625f); + int fourth = totalDust / 4; + int half = totalDust / 2; + int x = (int)(totalDust * 0.625f); - for (int num647 = 0; num647 < totalDust; num647++) - { - float num648 = 2f * (num647 / (float)fourth); - int dustType = dust1; - if (num647 > fourth) - { - num648 = speed1; - } - if (num647 > x) - { - num648 = speed1 * 1.3f; - dustType = dust3; - } + for (int num647 = 0; num647 < totalDust; num647++) + { + float num648 = 2f * (num647 / (float)fourth); + int dustType = dust1; + if (num647 > fourth) + { + num648 = speed1; + } + if (num647 > x) + { + num648 = speed1 * 1.3f; + dustType = dust3; + } - int num650 = Dust.NewDust(projectile.Center, 6, 6, dustType, 0f, 0f, 100, default, 1f); - float num651 = Main.dust[num650].velocity.X; - float num652 = Main.dust[num650].velocity.Y; - if (num651 == 0f && num652 == 0f) - { - num651 = 1f; - } + int num650 = Dust.NewDust(projectile.Center, 6, 6, dustType, 0f, 0f, 100, default, 1f); + float num651 = Main.dust[num650].velocity.X; + float num652 = Main.dust[num650].velocity.Y; + if (num651 == 0f && num652 == 0f) + { + num651 = 1f; + } - float num653 = (float)Math.Sqrt(num651 * num651 + num652 * num652); - num653 = num648 / num653; - if (num647 <= half) - { - num651 *= num653; - num652 *= num653; - } - else - { - num651 = num651 * num653 * 1.25f; - num652 = num652 * num653 * 0.75f; - } + float num653 = (float)Math.Sqrt(num651 * num651 + num652 * num652); + num653 = num648 / num653; + if (num647 <= half) + { + num651 *= num653; + num652 *= num653; + } + else + { + num651 = num651 * num653 * 1.25f; + num652 = num652 * num653 * 0.75f; + } - Dust dust2 = Main.dust[num650]; - dust2.velocity *= 0.5f; - dust2.velocity.X = dust2.velocity.X + num651; - dust2.velocity.Y = dust2.velocity.Y + num652; + Dust dust2 = Main.dust[num650]; + dust2.velocity *= 0.5f; + dust2.velocity.X = dust2.velocity.X + num651; + dust2.velocity.Y = dust2.velocity.Y + num652; - if (num647 > fourth) - { - dust2.scale = 1.3f; - } + if (num647 > fourth) + { + dust2.scale = 1.3f; + } - dust2.noGravity = true; - } - } + dust2.noGravity = true; + } + } - private void PulseBurst(float speed1, float speed2) - { - float angleRandom = 0.05f; + private void PulseBurst(float speed1, float speed2) + { + float angleRandom = 0.05f; - for (int num53 = 0; num53 < 50; num53++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + for (int num53 = 0; num53 < 50; num53++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust3, dustVel.X, dustVel.Y, 200, default, 1.7f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - Main.dust[num54].noGravity = true; + int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust3, dustVel.X, dustVel.Y, 200, default, 1.7f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + Main.dust[num54].noGravity = true; - Dust dust = Main.dust[num54]; - dust.velocity *= 3f; - dust = Main.dust[num54]; + Dust dust = Main.dust[num54]; + dust.velocity *= 3f; + dust = Main.dust[num54]; - num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust1, dustVel.X, dustVel.Y, 100, default, 1f); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust1, dustVel.X, dustVel.Y, 100, default, 1f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - dust = Main.dust[num54]; - dust.velocity *= 2f; + dust = Main.dust[num54]; + dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Green * 0.5f; + Main.dust[num54].noGravity = true; + Main.dust[num54].fadeIn = 1f; + Main.dust[num54].color = Color.Green * 0.5f; - dust = Main.dust[num54]; - } - for (int num55 = 0; num55 < 25; num55++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + dust = Main.dust[num54]; + } + for (int num55 = 0; num55 < 25; num55++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust2, dustVel.X, dustVel.Y, 0, default, 3f); - Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; - Main.dust[num56].noGravity = true; + int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dust2, dustVel.X, dustVel.Y, 0, default, 3f); + Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; + Main.dust[num56].noGravity = true; - Dust dust = Main.dust[num56]; - dust.velocity *= 0.5f; - dust = Main.dust[num56]; - } - } - } + Dust dust = Main.dust[num56]; + dust.velocity *= 0.5f; + dust = Main.dust[num56]; + } + } + } } diff --git a/Projectiles/DraedonsArsenal/PulseTurret.cs b/Projectiles/DraedonsArsenal/PulseTurret.cs index e01f1347e2..f536de6fa5 100644 --- a/Projectiles/DraedonsArsenal/PulseTurret.cs +++ b/Projectiles/DraedonsArsenal/PulseTurret.cs @@ -117,7 +117,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.rotation = projectile.rotation.AngleLerp(0f, MathHelper.TwoPi / 50f); } - projectile.StickToTiles(false, false); + projectile.StickToTiles(false, false); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/DraedonsArsenal/PulseTurretShot.cs b/Projectiles/DraedonsArsenal/PulseTurretShot.cs index 49dfb4ac07..406f265631 100644 --- a/Projectiles/DraedonsArsenal/PulseTurretShot.cs +++ b/Projectiles/DraedonsArsenal/PulseTurretShot.cs @@ -13,10 +13,10 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public const int SpiralPrecision = 36; public const int SpiralRings = 6; public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pulse Bolt"); + { + DisplayName.SetDefault("Pulse Bolt"); ProjectileID.Sets.SentryShot[projectile.type] = true; - } + } public override void SetDefaults() { @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.minion = true; projectile.penetrate = 1; projectile.timeLeft = 600; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() diff --git a/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs b/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs index fe04b4d994..5bb09a39f8 100644 --- a/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs +++ b/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs @@ -204,13 +204,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 shootPosition = projectile.Center + Utils.Vector2FromElipse(EyeRotation.ToRotationVector2(), projectile.Size * 0.5f * EyeOutwardness); Vector2 shootVelocity = projectile.SafeDirectionTo(npc.Center, Main.rand.NextVector2Unit()) * 4f; int laser = Projectile.NewProjectile(shootPosition, shootVelocity, ProjectileID.UFOLaser, projectile.damage, projectile.knockBack, projectile.owner); - if (laser.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[laser].timeLeft *= 2; + if (laser.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[laser].timeLeft *= 2; Main.projectile[laser].tileCollide = false; Main.projectile[laser].netUpdate = true; Main.projectile[laser].Calamity().forceMinion = true; - } + } } projectile.ai[1]++; OldCenter = projectile.Center; diff --git a/Projectiles/DraedonsArsenal/StarSwallowerAcid.cs b/Projectiles/DraedonsArsenal/StarSwallowerAcid.cs index 7b94c0b31a..ca8fc62c97 100644 --- a/Projectiles/DraedonsArsenal/StarSwallowerAcid.cs +++ b/Projectiles/DraedonsArsenal/StarSwallowerAcid.cs @@ -62,9 +62,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return true; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs b/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs index 648aaa1eb4..9a026d96d2 100644 --- a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs +++ b/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; bool isCorrectProjectile = projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); @@ -194,7 +194,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } Vector2 returnPosition = projectile.Center; returnPosition.Y -= 200 * 16; - returnPosition.Y = MathHelper.Clamp(returnPosition.Y, 50, Main.maxTilesX * 16 - 50); + returnPosition.Y = MathHelper.Clamp(returnPosition.Y, 50, Main.maxTilesX * 16 - 50); bool noGround = !WorldUtils.Find(returnPosition.ToTileCoordinates(), Searches.Chain(new Searches.Down(400), new GenCondition[] { diff --git a/Projectiles/DraedonsArsenal/SystemBaneLightning.cs b/Projectiles/DraedonsArsenal/SystemBaneLightning.cs index 20bdea949d..a1ff583428 100644 --- a/Projectiles/DraedonsArsenal/SystemBaneLightning.cs +++ b/Projectiles/DraedonsArsenal/SystemBaneLightning.cs @@ -35,8 +35,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.height = 22; projectile.friendly = true; projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.extraUpdates = 1; projectile.tileCollide = false; projectile.timeLeft = 40 * (projectile.extraUpdates + 1); diff --git a/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs b/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs index 437c7a12aa..5e793b5798 100644 --- a/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs +++ b/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.width = 36; projectile.height = 36; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 16; projectile.tileCollide = true; @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { - projectile.StickToTiles(false, true); + projectile.StickToTiles(false, true); Time++; projectile.rotation = projectile.velocity.ToRotation(); diff --git a/Projectiles/DraedonsArsenal/TaserHook.cs b/Projectiles/DraedonsArsenal/TaserHook.cs index e2de844eaf..647954afc0 100644 --- a/Projectiles/DraedonsArsenal/TaserHook.cs +++ b/Projectiles/DraedonsArsenal/TaserHook.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class TaserHook : ModProjectile + public class TaserHook : ModProjectile { public enum TaserAIState { diff --git a/Projectiles/DraedonsArsenal/TeslaCannonShot.cs b/Projectiles/DraedonsArsenal/TeslaCannonShot.cs index 5092b4fcbd..7bf0e4efeb 100644 --- a/Projectiles/DraedonsArsenal/TeslaCannonShot.cs +++ b/Projectiles/DraedonsArsenal/TeslaCannonShot.cs @@ -6,18 +6,18 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class TeslaCannonShot : ModProjectile + public class TeslaCannonShot : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private int[] dustArray = new int[7] { 56, 111, 137, 160, 206, 229, 226 }; + private int[] dustArray = new int[7] { 56, 111, 137, 160, 206, 229, 226 }; - private int arcs = 0; + private int arcs = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tesla Beam"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tesla Beam"); + } public override void SetDefaults() { @@ -32,253 +32,253 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { - bool notArcingProjectile = projectile.ai[1] >= 0f; + bool notArcingProjectile = projectile.ai[1] >= 0f; - Lighting.AddLight(projectile.Center, 0f, 0.3f, 0.4f); + Lighting.AddLight(projectile.Center, 0f, 0.3f, 0.4f); - float createDustVar = 10f; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > createDustVar) - { - for (int num447 = 0; num447 < 2; num447++) - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * (num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, dustArray[3], 0f, 0f, 0, default, 1f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.026f; - } + float createDustVar = 10f; + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > createDustVar) + { + for (int num447 = 0; num447 < 2; num447++) + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * (num447 * 0.25f); + int num448 = Dust.NewDust(vector33, 1, 1, dustArray[3], 0f, 0f, 0, default, 1f); + Main.dust[num448].noGravity = true; + Main.dust[num448].position = vector33; + Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.026f; + } - if (Main.rand.Next(6) == 0) - Dust.NewDust(projectile.Center, projectile.width, projectile.height, dustArray[6], 0f, 0f); + if (Main.rand.Next(6) == 0) + Dust.NewDust(projectile.Center, projectile.width, projectile.height, dustArray[6], 0f, 0f); - if (notArcingProjectile) - { - if (projectile.ai[1] > 0f) - projectile.ai[1] -= 1f; + if (notArcingProjectile) + { + if (projectile.ai[1] > 0f) + projectile.ai[1] -= 1f; - projectile.ai[0] += 1f; - if (projectile.ai[0] == 48f) - projectile.ai[0] = 0f; - else - { - Vector2 value7 = new Vector2(5f, 10f); - Vector2 value8 = Vector2.UnitX * -12f; - float scale = 1f; + projectile.ai[0] += 1f; + if (projectile.ai[0] == 48f) + projectile.ai[0] = 0f; + else + { + Vector2 value7 = new Vector2(5f, 10f); + Vector2 value8 = Vector2.UnitX * -12f; + float scale = 1f; - for (int num41 = 0; num41 < 2; num41++) - { - value8 = -Vector2.UnitY.RotatedBy(projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7; - int num42 = Dust.NewDust(projectile.Center, 0, 0, dustArray[2], 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = scale; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = projectile.Center + value8; - } + for (int num41 = 0; num41 < 2; num41++) + { + value8 = -Vector2.UnitY.RotatedBy(projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7; + int num42 = Dust.NewDust(projectile.Center, 0, 0, dustArray[2], 0f, 0f, 160, default, 1f); + Main.dust[num42].scale = scale; + Main.dust[num42].noGravity = true; + Main.dust[num42].position = projectile.Center + value8; + } - for (int num41 = 0; num41 < 2; num41++) - { - value8 = -Vector2.UnitY.RotatedBy(projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 1.5f; - int num42 = Dust.NewDust(projectile.Center, 0, 0, dustArray[1], 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = scale; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = projectile.Center + value8; - } + for (int num41 = 0; num41 < 2; num41++) + { + value8 = -Vector2.UnitY.RotatedBy(projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 1.5f; + int num42 = Dust.NewDust(projectile.Center, 0, 0, dustArray[1], 0f, 0f, 160, default, 1f); + Main.dust[num42].scale = scale; + Main.dust[num42].noGravity = true; + Main.dust[num42].position = projectile.Center + value8; + } - for (int num41 = 0; num41 < 2; num41++) - { - value8 = -Vector2.UnitY.RotatedBy(projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 2f; - int num42 = Dust.NewDust(projectile.Center, 0, 0, dustArray[0], 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = scale; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = projectile.Center + value8; - } - } + for (int num41 = 0; num41 < 2; num41++) + { + value8 = -Vector2.UnitY.RotatedBy(projectile.ai[0] * 0.1308997f + num41 * MathHelper.Pi) * value7 * 2f; + int num42 = Dust.NewDust(projectile.Center, 0, 0, dustArray[0], 0f, 0f, 160, default, 1f); + Main.dust[num42].scale = scale; + Main.dust[num42].noGravity = true; + Main.dust[num42].position = projectile.Center + value8; + } + } - if (projectile.ai[1] == 0f && Main.myPlayer == projectile.owner) - { - if (arcs < 10) - { - Vector2 vector35 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f); - float num474 = 600f; + if (projectile.ai[1] == 0f && Main.myPlayer == projectile.owner) + { + if (arcs < 10) + { + Vector2 vector35 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f); + float num474 = 600f; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (!Main.npc[i].CanBeChasedBy(projectile, false) || !Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) - continue; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (!Main.npc[i].CanBeChasedBy(projectile, false) || !Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + continue; - if (projectile.Center.ManhattanDistance(Main.npc[i].Center) < num474) - { - Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(Main.npc[i].Center) * 2f, projectile.type, (int)(projectile.damage * 0.6), projectile.knockBack * 0.6f, projectile.owner, 0f, -1f); + if (projectile.Center.ManhattanDistance(Main.npc[i].Center) < num474) + { + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(Main.npc[i].Center) * 2f, projectile.type, (int)(projectile.damage * 0.6), projectile.knockBack * 0.6f, projectile.owner, 0f, -1f); - projectile.ai[1] = 60f; + projectile.ai[1] = 60f; - arcs++; - break; - } - } - } - } - } - } + arcs++; + break; + } + } + } + } + } + } - if (projectile.localAI[0] == createDustVar && notArcingProjectile) - ElectricalBurst(5f, 9f); - } + if (projectile.localAI[0] == createDustVar && notArcingProjectile) + ElectricalBurst(5f, 9f); + } - public override void Kill(int timeLeft) - { - bool notArcingProjectile = projectile.ai[1] >= 0f; + public override void Kill(int timeLeft) + { + bool notArcingProjectile = projectile.ai[1] >= 0f; - int height = notArcingProjectile ? 120 : 60; - projectile.position = projectile.Center; - projectile.width = projectile.height = height; - projectile.Center = projectile.position; - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); + int height = notArcingProjectile ? 120 : 60; + projectile.position = projectile.Center; + projectile.width = projectile.height = height; + projectile.Center = projectile.position; + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); - Main.PlaySound(SoundID.Item125, projectile.Center); + Main.PlaySound(SoundID.Item125, projectile.Center); - int dustAmt = notArcingProjectile ? 400 : 100; - int fourth = notArcingProjectile ? 100 : 25; - int half = notArcingProjectile ? 200 : 50; - int threeFourths = notArcingProjectile ? 300 : 75; + int dustAmt = notArcingProjectile ? 400 : 100; + int fourth = notArcingProjectile ? 100 : 25; + int half = notArcingProjectile ? 200 : 50; + int threeFourths = notArcingProjectile ? 300 : 75; - float dustSpeed = notArcingProjectile ? 12f : 6f; + float dustSpeed = notArcingProjectile ? 12f : 6f; - for (int num672 = 0; num672 < dustAmt; num672++) - { - int dustType = dustArray[4]; - float num674 = dustSpeed; - if (num672 > fourth) - { - num674 = dustSpeed * 0.6875f; - dustType = dustArray[5]; - } - if (num672 > half) - { - num674 = dustSpeed * 0.5f; - dustType = dustArray[4]; - } - if (num672 > threeFourths) - { - num674 = dustSpeed * 0.3125f; - dustType = dustArray[5]; - } - float scale = (dustType == dustArray[4] ? 3f : 1.5f); + for (int num672 = 0; num672 < dustAmt; num672++) + { + int dustType = dustArray[4]; + float num674 = dustSpeed; + if (num672 > fourth) + { + num674 = dustSpeed * 0.6875f; + dustType = dustArray[5]; + } + if (num672 > half) + { + num674 = dustSpeed * 0.5f; + dustType = dustArray[4]; + } + if (num672 > threeFourths) + { + num674 = dustSpeed * 0.3125f; + dustType = dustArray[5]; + } + float scale = (dustType == dustArray[4] ? 3f : 1.5f); - int num675 = Dust.NewDust(projectile.Center, 6, 6, dustType, 0f, 0f, 100, default, scale); - float num676 = Main.dust[num675].velocity.X; - float num677 = Main.dust[num675].velocity.Y; + int num675 = Dust.NewDust(projectile.Center, 6, 6, dustType, 0f, 0f, 100, default, scale); + float num676 = Main.dust[num675].velocity.X; + float num677 = Main.dust[num675].velocity.Y; - if (num676 == 0f && num677 == 0f) - num676 = 1f; + if (num676 == 0f && num677 == 0f) + num676 = 1f; - float num678 = (float)Math.Sqrt(num676 * num676 + num677 * num677); - num678 = num674 / num678; - if (num672 > threeFourths) - { - num676 = num676 * num678 * 0.7f; - num677 *= num678; - } - else if (num672 > half) - { - num676 *= num678; - num677 = num677 * num678 * 0.7f; - } - else if (num672 > fourth) - { - num676 = num676 * num678 * 0.7f; - num677 *= num678; - } - else - { - num676 *= num678; - num677 = num677 * num678 * 0.7f; - } + float num678 = (float)Math.Sqrt(num676 * num676 + num677 * num677); + num678 = num674 / num678; + if (num672 > threeFourths) + { + num676 = num676 * num678 * 0.7f; + num677 *= num678; + } + else if (num672 > half) + { + num676 *= num678; + num677 = num677 * num678 * 0.7f; + } + else if (num672 > fourth) + { + num676 = num676 * num678 * 0.7f; + num677 *= num678; + } + else + { + num676 *= num678; + num677 = num677 * num678 * 0.7f; + } - Dust dust8 = Main.dust[num675]; - dust8.velocity *= 0.5f; - dust8.velocity.X = dust8.velocity.X + num676; - dust8.velocity.Y = dust8.velocity.Y + num677; - dust8.noGravity = true; + Dust dust8 = Main.dust[num675]; + dust8.velocity *= 0.5f; + dust8.velocity.X = dust8.velocity.X + num676; + dust8.velocity.Y = dust8.velocity.Y + num677; + dust8.noGravity = true; - if (num672 > threeFourths) - { - int num650 = Dust.NewDust(projectile.Center, 6, 6, dustArray[5], 0f, 0f, 100, default, 1.3f); - float num651 = Main.dust[num650].velocity.X; - float num652 = Main.dust[num650].velocity.Y; + if (num672 > threeFourths) + { + int num650 = Dust.NewDust(projectile.Center, 6, 6, dustArray[5], 0f, 0f, 100, default, 1.3f); + float num651 = Main.dust[num650].velocity.X; + float num652 = Main.dust[num650].velocity.Y; - if (num651 == 0f && num652 == 0f) - num651 = 1f; + if (num651 == 0f && num652 == 0f) + num651 = 1f; - float num653 = (float)Math.Sqrt(num651 * num651 + num652 * num652); - num653 = 16f / num653; - num651 = num651 * num653 * 1.25f; - num652 = num652 * num653 * 0.75f; + float num653 = (float)Math.Sqrt(num651 * num651 + num652 * num652); + num653 = 16f / num653; + num651 = num651 * num653 * 1.25f; + num652 = num652 * num653 * 0.75f; - Dust dust9 = Main.dust[num650]; - dust9.velocity *= 0.5f; - dust9.velocity.X = dust9.velocity.X + num651; - dust9.velocity.Y = dust9.velocity.Y + num652; - dust9.noGravity = true; - } - } - } + Dust dust9 = Main.dust[num650]; + dust9.velocity *= 0.5f; + dust9.velocity.X = dust9.velocity.X + num651; + dust9.velocity.Y = dust9.velocity.Y + num652; + dust9.noGravity = true; + } + } + } - private void ElectricalBurst(float speed1, float speed2) - { - float angleRandom = 0.05f; + private void ElectricalBurst(float speed1, float speed2) + { + float angleRandom = 0.05f; - for (int num53 = 0; num53 < 40; num53++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2f * angleRandom); - int randomDustType = Main.rand.Next(2) == 0 ? dustArray[4] : dustArray[5]; - float scale = randomDustType == dustArray[4] ? 1.5f : 1f; + for (int num53 = 0; num53 < 40; num53++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2f * angleRandom); + int randomDustType = Main.rand.Next(2) == 0 ? dustArray[4] : dustArray[5]; + float scale = randomDustType == dustArray[4] ? 1.5f : 1f; - int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 2.5f * scale); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - Main.dust[num54].noGravity = true; + int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 2.5f * scale); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + Main.dust[num54].noGravity = true; - Dust dust = Main.dust[num54]; - dust.velocity *= 3f; - dust = Main.dust[num54]; + Dust dust = Main.dust[num54]; + dust.velocity *= 3f; + dust = Main.dust[num54]; - num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 1.5f * scale); - Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 1.5f * scale); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; - dust = Main.dust[num54]; - dust.velocity *= 2f; + dust = Main.dust[num54]; + dust.velocity *= 2f; - Main.dust[num54].noGravity = true; - Main.dust[num54].fadeIn = 1f; - Main.dust[num54].color = Color.Cyan * 0.5f; + Main.dust[num54].noGravity = true; + Main.dust[num54].fadeIn = 1f; + Main.dust[num54].color = Color.Cyan * 0.5f; - dust = Main.dust[num54]; - } - for (int num55 = 0; num55 < 20; num55++) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0f).RotatedBy(projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2f * angleRandom); - int randomDustType = Main.rand.Next(2) == 0 ? dustArray[4] : dustArray[5]; - float scale = randomDustType == dustArray[4] ? 1.5f : 1f; + dust = Main.dust[num54]; + } + for (int num55 = 0; num55 < 20; num55++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2f * angleRandom); + int randomDustType = Main.rand.Next(2) == 0 ? dustArray[4] : dustArray[5]; + float scale = randomDustType == dustArray[4] ? 1.5f : 1f; - int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 3f * scale); - Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; - Main.dust[num56].noGravity = true; + int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 3f * scale); + Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; + Main.dust[num56].noGravity = true; - Dust dust = Main.dust[num56]; - dust.velocity *= 0.5f; - dust = Main.dust[num56]; - } - } - } + Dust dust = Main.dust[num56]; + dust.velocity *= 0.5f; + dust = Main.dust[num56]; + } + } + } } diff --git a/Projectiles/DraedonsArsenal/TrackingDiskLaser.cs b/Projectiles/DraedonsArsenal/TrackingDiskLaser.cs index 8c0a1f1912..c5653055cf 100644 --- a/Projectiles/DraedonsArsenal/TrackingDiskLaser.cs +++ b/Projectiles/DraedonsArsenal/TrackingDiskLaser.cs @@ -3,58 +3,58 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class TrackingDiskLaser : ModProjectile - { + public class TrackingDiskLaser : ModProjectile + { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public float Time - { - get => projectile.localAI[0]; - set => projectile.localAI[0] = value; - } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Laser"); - } + public float Time + { + get => projectile.localAI[0]; + set => projectile.localAI[0] = value; + } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Laser"); + } - public override void SetDefaults() - { - projectile.width = 2; - projectile.height = 2; - projectile.friendly = true; - projectile.Calamity().rogue = true; - projectile.tileCollide = false; - projectile.penetrate = 1; - projectile.extraUpdates = 100; - projectile.timeLeft = 600; - } + public override void SetDefaults() + { + projectile.width = 2; + projectile.height = 2; + projectile.friendly = true; + projectile.Calamity().rogue = true; + projectile.tileCollide = false; + projectile.penetrate = 1; + projectile.extraUpdates = 100; + projectile.timeLeft = 600; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f); + public override void AI() + { + Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f); - Time++; - if (Time >= 10f) - { - for (int i = 0; i < 2; i++) - { - Dust dust = Dust.NewDustDirect(projectile.Center, 0, 0, 182, 0f, 0f, 160, default, 2f); - dust.position = projectile.Center; - dust.velocity = projectile.velocity; - dust.scale = projectile.scale; - dust.noGravity = true; - } - } - } + Time++; + if (Time >= 10f) + { + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustDirect(projectile.Center, 0, 0, 182, 0f, 0f, 160, default, 2f); + dust.position = projectile.Center; + dust.velocity = projectile.velocity; + dust.scale = projectile.scale; + dust.noGravity = true; + } + } + } - public override void Kill(int timeLeft) - { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 60); - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); - } - } + public override void Kill(int timeLeft) + { + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 60); + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + } + } } diff --git a/Projectiles/DraedonsArsenal/TrackingDiskProjectile.cs b/Projectiles/DraedonsArsenal/TrackingDiskProjectile.cs index ca362da460..4f6a62b50c 100644 --- a/Projectiles/DraedonsArsenal/TrackingDiskProjectile.cs +++ b/Projectiles/DraedonsArsenal/TrackingDiskProjectile.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class TrackingDiskProjectile : ModProjectile + public class TrackingDiskProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/DraedonsArsenal/TrackingDisk"; diff --git a/Projectiles/DraedonsArsenal/UnstableMatter.cs b/Projectiles/DraedonsArsenal/UnstableMatter.cs index 97cd8efafb..e68fff574c 100644 --- a/Projectiles/DraedonsArsenal/UnstableMatter.cs +++ b/Projectiles/DraedonsArsenal/UnstableMatter.cs @@ -5,104 +5,104 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class UnstableMatter : ModProjectile - { + public class UnstableMatter : ModProjectile + { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public bool HasCollidedWithATile - { - get => projectile.ai[0] == 1f; - set => projectile.ai[0] = value.ToInt(); - } + public bool HasCollidedWithATile + { + get => projectile.ai[0] == 1f; + set => projectile.ai[0] = value.ToInt(); + } - public float Time - { - get => projectile.ai[1]; - set => projectile.ai[1] = value; - } + public float Time + { + get => projectile.ai[1]; + set => projectile.ai[1] = value; + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Unstable Matter"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Unstable Matter"); + } - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.friendly = true; - projectile.ranged = true; - projectile.tileCollide = true; - projectile.penetrate = -1; - projectile.timeLeft = 480; - } + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.friendly = true; + projectile.ranged = true; + projectile.tileCollide = true; + projectile.penetrate = -1; + projectile.timeLeft = 480; + } - public override void AI() - { - // Cast some lime light at the projectile's position. - Lighting.AddLight(projectile.Center, Color.GreenYellow.ToVector3()); - Time++; - if (Time >= 10f) - GenerateIdleDust(); - } - - public void GenerateIdleDust() - { - if (Main.dedServ) - return; + public override void AI() + { + // Cast some lime light at the projectile's position. + Lighting.AddLight(projectile.Center, Color.GreenYellow.ToVector3()); + Time++; + if (Time >= 10f) + GenerateIdleDust(); + } + + public void GenerateIdleDust() + { + if (Main.dedServ) + return; - // Release some dust outward. - // The faster the projectile itself is, the slower the dust, and the longer it lasts. - // This is done to give the projectile a "streak" movement the faster it is versus a expansion. - int dustCount = HasCollidedWithATile ? 5 : 12; - float baseSpeedRatio = Utils.InverseLerp(6f, 14f, projectile.velocity.Length(), true); - float speed = MathHelper.Lerp(6f, 1.8f, (float)Math.Pow(baseSpeedRatio, 3f)); - if (!HasCollidedWithATile) - speed += MathHelper.Lerp(-6f, 4f, Utils.InverseLerp(10f, 150f, Time, true)); - float persistence = MathHelper.Lerp(0f, 0.8f, baseSpeedRatio); - for (int i = 0; i < dustCount; i++) - { - Dust dust = Dust.NewDustPerfect(projectile.Center, 107); - dust.velocity = Main.rand.NextVector2CircularEdge(speed, speed) - projectile.velocity; - dust.fadeIn = persistence; - dust.scale = 0.9f; - dust.noGravity = true; - } - } + // Release some dust outward. + // The faster the projectile itself is, the slower the dust, and the longer it lasts. + // This is done to give the projectile a "streak" movement the faster it is versus a expansion. + int dustCount = HasCollidedWithATile ? 5 : 12; + float baseSpeedRatio = Utils.InverseLerp(6f, 14f, projectile.velocity.Length(), true); + float speed = MathHelper.Lerp(6f, 1.8f, (float)Math.Pow(baseSpeedRatio, 3f)); + if (!HasCollidedWithATile) + speed += MathHelper.Lerp(-6f, 4f, Utils.InverseLerp(10f, 150f, Time, true)); + float persistence = MathHelper.Lerp(0f, 0.8f, baseSpeedRatio); + for (int i = 0; i < dustCount; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, 107); + dust.velocity = Main.rand.NextVector2CircularEdge(speed, speed) - projectile.velocity; + dust.fadeIn = persistence; + dust.scale = 0.9f; + dust.noGravity = true; + } + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (!HasCollidedWithATile) - damage /= 3; - else if (projectile.penetrate == -1) - projectile.penetrate = 1; - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (!HasCollidedWithATile) + damage /= 3; + else if (projectile.penetrate == -1) + projectile.penetrate = 1; + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - // Register the tile collision, if one has not happened yet. - if (!HasCollidedWithATile) - { - HasCollidedWithATile = true; + public override bool OnTileCollide(Vector2 oldVelocity) + { + // Register the tile collision, if one has not happened yet. + if (!HasCollidedWithATile) + { + HasCollidedWithATile = true; - // And bounce off the tile. Or towards a nearby enemy, if there is one. - NPC potentialTarget = projectile.Center.ClosestNPCAt(700f, false); - if (potentialTarget != null) - projectile.velocity = projectile.SafeDirectionTo(potentialTarget.Center); - else - { - if (projectile.velocity.X != oldVelocity.X) - projectile.velocity.X = -oldVelocity.X; - if (projectile.velocity.Y != oldVelocity.Y) - projectile.velocity.Y = -oldVelocity.Y; - } + // And bounce off the tile. Or towards a nearby enemy, if there is one. + NPC potentialTarget = projectile.Center.ClosestNPCAt(700f, false); + if (potentialTarget != null) + projectile.velocity = projectile.SafeDirectionTo(potentialTarget.Center); + else + { + if (projectile.velocity.X != oldVelocity.X) + projectile.velocity.X = -oldVelocity.X; + if (projectile.velocity.Y != oldVelocity.Y) + projectile.velocity.Y = -oldVelocity.Y; + } - projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitY) * 14f; + projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitY) * 14f; - projectile.netUpdate = true; - return false; - } - return true; - } - } + projectile.netUpdate = true; + return false; + } + return true; + } + } } diff --git a/Projectiles/DraedonsArsenal/VoltageStream.cs b/Projectiles/DraedonsArsenal/VoltageStream.cs index 7962649b15..1654868696 100644 --- a/Projectiles/DraedonsArsenal/VoltageStream.cs +++ b/Projectiles/DraedonsArsenal/VoltageStream.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class VoltageStream : ModProjectile + public class VoltageStream : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,9 +23,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } public override void SetStaticDefaults() - { - DisplayName.SetDefault("Voltage Stream"); - } + { + DisplayName.SetDefault("Voltage Stream"); + } public override void SetDefaults() { @@ -35,13 +35,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.melee = true; projectile.penetrate = 5; projectile.timeLeft = 180; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 12; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 12; } public override void AI() { - Lighting.AddLight(projectile.Center, Color.SkyBlue.ToVector3()); + Lighting.AddLight(projectile.Center, Color.SkyBlue.ToVector3()); if (!Target.active) { projectile.Kill(); @@ -100,18 +100,18 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } Time++; - if (projectile.damage <= 0) - projectile.Kill(); + if (projectile.damage <= 0) + projectile.Kill(); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - projectile.damage = (int)(projectile.damage * 0.75); - } + projectile.damage = (int)(projectile.damage * 0.75); + } public override void OnHitPvp(Player target, int damage, bool crit) { - projectile.damage = (int)(projectile.damage * 0.75); - } - } + projectile.damage = (int)(projectile.damage * 0.75); + } + } } diff --git a/Projectiles/DraedonsArsenal/WavePounderBoom.cs b/Projectiles/DraedonsArsenal/WavePounderBoom.cs index 91f469061c..d7f2aadaf1 100644 --- a/Projectiles/DraedonsArsenal/WavePounderBoom.cs +++ b/Projectiles/DraedonsArsenal/WavePounderBoom.cs @@ -4,26 +4,26 @@ using Terraria; namespace CalamityMod.Projectiles.DraedonsArsenal { - public class WavePounderBoom : BaseMassiveExplosionProjectile - { - public override int Lifetime => 60; - public override bool UsesScreenshake => projectile.Calamity().stealthStrike; - public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 16f; - public override Color GetCurrentExplosionColor(float pulseCompletionRatio) => Color.Lerp(Color.Yellow * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f)); - public override void SetStaticDefaults() => DisplayName.SetDefault("Explosion"); + public class WavePounderBoom : BaseMassiveExplosionProjectile + { + public override int Lifetime => 60; + public override bool UsesScreenshake => projectile.Calamity().stealthStrike; + public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 16f; + public override Color GetCurrentExplosionColor(float pulseCompletionRatio) => Color.Lerp(Color.Yellow * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f)); + public override void SetStaticDefaults() => DisplayName.SetDefault("Explosion"); - public override void SetDefaults() - { - projectile.width = projectile.height = 2; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.timeLeft = Lifetime; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 2; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.timeLeft = Lifetime; + projectile.Calamity().rogue = true; + } - public override void PostAI() => Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f); - } + public override void PostAI() => Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f); + } } diff --git a/Projectiles/DraedonsArsenal/WavePounderProjectile.cs b/Projectiles/DraedonsArsenal/WavePounderProjectile.cs index 0e6b376d8d..14821d45b0 100644 --- a/Projectiles/DraedonsArsenal/WavePounderProjectile.cs +++ b/Projectiles/DraedonsArsenal/WavePounderProjectile.cs @@ -68,14 +68,14 @@ namespace CalamityMod.Projectiles.DraedonsArsenal for (int i = 0; i < 7; i++) { Projectile explosion = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), projectile.knockBack, projectile.owner); - if (explosion.whoAmI.WithinBounds(Main.maxProjectiles)) - { - explosion.ai[1] = Main.rand.NextFloat(320f, 870f) + i * 45f; // Randomize the maximum radius. - explosion.localAI[1] = Main.rand.NextFloat(0.08f, 0.25f); // And the interpolation step. - explosion.Opacity = MathHelper.Lerp(0.18f, 0.6f, i / 7f) + Main.rand.NextFloat(-0.08f, 0.08f); - explosion.Calamity().stealthStrike = true; - explosion.netUpdate = true; - } + if (explosion.whoAmI.WithinBounds(Main.maxProjectiles)) + { + explosion.ai[1] = Main.rand.NextFloat(320f, 870f) + i * 45f; // Randomize the maximum radius. + explosion.localAI[1] = Main.rand.NextFloat(0.08f, 0.25f); // And the interpolation step. + explosion.Opacity = MathHelper.Lerp(0.18f, 0.6f, i / 7f) + Main.rand.NextFloat(-0.08f, 0.08f); + explosion.Calamity().stealthStrike = true; + explosion.netUpdate = true; + } } } } diff --git a/Projectiles/Enemy/CragmawBeam.cs b/Projectiles/Enemy/CragmawBeam.cs index 6ae7209da8..c51f6137b5 100644 --- a/Projectiles/Enemy/CragmawBeam.cs +++ b/Projectiles/Enemy/CragmawBeam.cs @@ -213,9 +213,9 @@ namespace CalamityMod.Projectiles.Enemy } return false; } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - } - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + } + } } diff --git a/Projectiles/Enemy/CragmawBubble.cs b/Projectiles/Enemy/CragmawBubble.cs index 2e1eafd8ec..907468cd1a 100644 --- a/Projectiles/Enemy/CragmawBubble.cs +++ b/Projectiles/Enemy/CragmawBubble.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Enemy { - public class CragmawBubble : ModProjectile + public class CragmawBubble : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Enemy/SulphuricAcidBubble"; diff --git a/Projectiles/Enemy/CragmawExplosion.cs b/Projectiles/Enemy/CragmawExplosion.cs index 3a443f8879..53f7195916 100644 --- a/Projectiles/Enemy/CragmawExplosion.cs +++ b/Projectiles/Enemy/CragmawExplosion.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Enemy { - public class CragmawExplosion : ModProjectile + public class CragmawExplosion : ModProjectile { public int FrameX = 0; public int FrameY = 0; diff --git a/Projectiles/Enemy/EarthRockBig.cs b/Projectiles/Enemy/EarthRockBig.cs index f18ff4cc8a..78ddbee317 100644 --- a/Projectiles/Enemy/EarthRockBig.cs +++ b/Projectiles/Enemy/EarthRockBig.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Projectiles.Enemy public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.width = 32; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 32; projectile.height = 32; projectile.hostile = true; projectile.penetrate = 3; @@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Enemy num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 8, 0f, 0f, 100, default, 1f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitPlayer(Player target, int damage, bool crit) diff --git a/Projectiles/Enemy/EarthRockSmall.cs b/Projectiles/Enemy/EarthRockSmall.cs index 23f4b6378d..50fbd84713 100644 --- a/Projectiles/Enemy/EarthRockSmall.cs +++ b/Projectiles/Enemy/EarthRockSmall.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Enemy num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 8, 0f, 0f, 100, default, 1f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitPlayer(Player target, int damage, bool crit) diff --git a/Projectiles/Enemy/FlakAcid.cs b/Projectiles/Enemy/FlakAcid.cs index c21ac0fd3f..6fd041b7e7 100644 --- a/Projectiles/Enemy/FlakAcid.cs +++ b/Projectiles/Enemy/FlakAcid.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Enemy } public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 150); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 150); projectile.Damage(); for (int i = 0; i <= 40; i++) { diff --git a/Projectiles/Enemy/FlameBurstHostile.cs b/Projectiles/Enemy/FlameBurstHostile.cs index 9378955fb3..24384de399 100644 --- a/Projectiles/Enemy/FlameBurstHostile.cs +++ b/Projectiles/Enemy/FlameBurstHostile.cs @@ -87,12 +87,12 @@ namespace CalamityMod.Projectiles.Enemy } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { for (int k = 0; k < 5; k++) { diff --git a/Projectiles/Enemy/GammaAcid.cs b/Projectiles/Enemy/GammaAcid.cs index 187ecac66e..5847c76e60 100644 --- a/Projectiles/Enemy/GammaAcid.cs +++ b/Projectiles/Enemy/GammaAcid.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Enemy } public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 80); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 80); projectile.Damage(); for (int i = 0; i <= 40; i++) { diff --git a/Projectiles/Enemy/GammaBeam.cs b/Projectiles/Enemy/GammaBeam.cs index b42f69b30a..afb65bd04c 100644 --- a/Projectiles/Enemy/GammaBeam.cs +++ b/Projectiles/Enemy/GammaBeam.cs @@ -208,9 +208,9 @@ namespace CalamityMod.Projectiles.Enemy } return false; } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 600); - } - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 600); + } + } } diff --git a/Projectiles/Enemy/InkBombHostile.cs b/Projectiles/Enemy/InkBombHostile.cs index 09ea4e2cc2..2b0156afd7 100644 --- a/Projectiles/Enemy/InkBombHostile.cs +++ b/Projectiles/Enemy/InkBombHostile.cs @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Enemy public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 12f, targetHitbox); - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { target.AddBuff(BuffID.Darkness, 300, true); projectile.Kill(); diff --git a/Projectiles/Enemy/InkPoisonCloud.cs b/Projectiles/Enemy/InkPoisonCloud.cs index 0b3426b4ac..c0b6736aac 100644 --- a/Projectiles/Enemy/InkPoisonCloud.cs +++ b/Projectiles/Enemy/InkPoisonCloud.cs @@ -60,12 +60,12 @@ namespace CalamityMod.Projectiles.Enemy public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 20f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.alpha == 80; + public override bool CanHitPlayer(Player target) => projectile.alpha == 80; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.alpha == 80) - target.AddBuff(BuffID.Darkness, 300, true); + if (projectile.alpha == 80) + target.AddBuff(BuffID.Darkness, 300, true); } } } diff --git a/Projectiles/Enemy/InkPoisonCloud2.cs b/Projectiles/Enemy/InkPoisonCloud2.cs index 04b2854094..6d9accc61a 100644 --- a/Projectiles/Enemy/InkPoisonCloud2.cs +++ b/Projectiles/Enemy/InkPoisonCloud2.cs @@ -60,12 +60,12 @@ namespace CalamityMod.Projectiles.Enemy public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 20f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.alpha == 80; + public override bool CanHitPlayer(Player target) => projectile.alpha == 80; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.alpha == 80) - target.AddBuff(BuffID.Darkness, 300, true); - } - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.alpha == 80) + target.AddBuff(BuffID.Darkness, 300, true); + } + } } diff --git a/Projectiles/Enemy/InkPoisonCloud3.cs b/Projectiles/Enemy/InkPoisonCloud3.cs index e3c32f5a86..cb8dad85c0 100644 --- a/Projectiles/Enemy/InkPoisonCloud3.cs +++ b/Projectiles/Enemy/InkPoisonCloud3.cs @@ -60,12 +60,12 @@ namespace CalamityMod.Projectiles.Enemy public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 20f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.alpha == 80; + public override bool CanHitPlayer(Player target) => projectile.alpha == 80; - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.alpha == 80) - target.AddBuff(BuffID.Darkness, 300, true); - } - } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.alpha == 80) + target.AddBuff(BuffID.Darkness, 300, true); + } + } } diff --git a/Projectiles/Enemy/LightningCloud.cs b/Projectiles/Enemy/LightningCloud.cs index 6d66a05fb6..a7096d76e6 100644 --- a/Projectiles/Enemy/LightningCloud.cs +++ b/Projectiles/Enemy/LightningCloud.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Enemy projectile.height = 28; projectile.tileCollide = false; projectile.ignoreWater = true; - projectile.hostile = true; + projectile.hostile = true; projectile.timeLeft = 180; projectile.Opacity = 0f; projectile.penetrate = -1; diff --git a/Projectiles/Enemy/MantisRing.cs b/Projectiles/Enemy/MantisRing.cs index 7e328061a3..52929ff3a1 100644 --- a/Projectiles/Enemy/MantisRing.cs +++ b/Projectiles/Enemy/MantisRing.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Enemy public override void SetDefaults() { - projectile.Calamity().canBreakPlayerDefense = true; - projectile.knockBack = 3f; + projectile.Calamity().canBreakPlayerDefense = true; + projectile.knockBack = 3f; projectile.width = 72; projectile.height = 30; projectile.hostile = true; diff --git a/Projectiles/Enemy/MaulerAcidBubble.cs b/Projectiles/Enemy/MaulerAcidBubble.cs index d27033c406..953bd2f0af 100644 --- a/Projectiles/Enemy/MaulerAcidBubble.cs +++ b/Projectiles/Enemy/MaulerAcidBubble.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Enemy { - public class MaulerAcidBubble : ModProjectile + public class MaulerAcidBubble : ModProjectile { public ref float Time => ref projectile.ai[0]; public override string Texture => "CalamityMod/Projectiles/Enemy/SulphuricAcidBubble"; diff --git a/Projectiles/Enemy/SulphuricAcidBubble.cs b/Projectiles/Enemy/SulphuricAcidBubble.cs index c886df086b..1178ba5d9a 100644 --- a/Projectiles/Enemy/SulphuricAcidBubble.cs +++ b/Projectiles/Enemy/SulphuricAcidBubble.cs @@ -104,8 +104,8 @@ namespace CalamityMod.Projectiles.Enemy { return; } - target.AddBuff(ModContent.BuffType(), 120); - projectile.Kill(); + target.AddBuff(ModContent.BuffType(), 120); + projectile.Kill(); } public override void Kill(int timeLeft) diff --git a/Projectiles/Enemy/SulphuricAcidMist.cs b/Projectiles/Enemy/SulphuricAcidMist.cs index ed4519027d..e5efb7b074 100644 --- a/Projectiles/Enemy/SulphuricAcidMist.cs +++ b/Projectiles/Enemy/SulphuricAcidMist.cs @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Enemy public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/Enemy/ToxicMinnowCloud.cs b/Projectiles/Enemy/ToxicMinnowCloud.cs index fc8b4b062c..65d0abb2fe 100644 --- a/Projectiles/Enemy/ToxicMinnowCloud.cs +++ b/Projectiles/Enemy/ToxicMinnowCloud.cs @@ -68,20 +68,20 @@ namespace CalamityMod.Projectiles.Enemy public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, 20f, targetHitbox); - public override bool CanHitPlayer(Player target) => projectile.alpha == 80; + public override bool CanHitPlayer(Player target) => projectile.alpha == 80; - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (projectile.alpha == 80) - target.AddBuff(BuffID.Poisoned, 120); + if (projectile.alpha == 80) + target.AddBuff(BuffID.Poisoned, 120); } - public override bool? CanHitNPC(NPC target) => projectile.alpha == 80; + public override bool? CanHitNPC(NPC target) => projectile.alpha == 80; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.alpha == 80) - target.AddBuff(BuffID.Poisoned, 120); + if (projectile.alpha == 80) + target.AddBuff(BuffID.Poisoned, 120); } } } diff --git a/Projectiles/Environment/AcidDrop.cs b/Projectiles/Environment/AcidDrop.cs index 23c0d34b99..c22bdb0871 100644 --- a/Projectiles/Environment/AcidDrop.cs +++ b/Projectiles/Environment/AcidDrop.cs @@ -8,7 +8,7 @@ using CalamityMod.Buffs.StatDebuffs; namespace CalamityMod.Projectiles.Environment { - public class AcidDrop : ModProjectile + public class AcidDrop : ModProjectile { public override void SetStaticDefaults() { @@ -47,23 +47,23 @@ namespace CalamityMod.Projectiles.Environment return true; } - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPlayer(Player target, int damage, bool crit) { - if (Main.rand.NextBool(2)) - { - // 1 to 3 seconds of poisoned - target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(1, 4)); - } - else if (Main.rand.NextBool(4)) - { - // 1 to 2 second of Sulphuric Poisoning - target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(1, 3)); - } - else - { - // 3 to 5 seconds of Irradiated - target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(3, 6)); - } + if (Main.rand.NextBool(2)) + { + // 1 to 3 seconds of poisoned + target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(1, 4)); + } + else if (Main.rand.NextBool(4)) + { + // 1 to 2 second of Sulphuric Poisoning + target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(1, 3)); + } + else + { + // 3 to 5 seconds of Irradiated + target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(3, 6)); + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Environment/BrimstoneGeyser.cs b/Projectiles/Environment/BrimstoneGeyser.cs index 030cb71862..45653e3f88 100644 --- a/Projectiles/Environment/BrimstoneGeyser.cs +++ b/Projectiles/Environment/BrimstoneGeyser.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Projectiles.Environment { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private int dustType = (int)CalamityDusts.Brimstone; + private int dustType = (int)CalamityDusts.Brimstone; public override void SetStaticDefaults() { DisplayName.SetDefault("Smoke"); @@ -19,152 +19,152 @@ namespace CalamityMod.Projectiles.Environment public override void SetDefaults() { - projectile.width = 30; - projectile.height = 30; - projectile.alpha = 255; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 120; - projectile.hostile = true; - projectile.penetrate = -1; - projectile.trap = true; + projectile.width = 30; + projectile.height = 30; + projectile.alpha = 255; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 120; + projectile.hostile = true; + projectile.penetrate = -1; + projectile.trap = true; } public override void AI() { - int num1 = Math.Sign(projectile.velocity.Y); - int num2 = num1 == -1 ? 0 : 1; - if (projectile.ai[0] == 0f) - { - if (!Collision.SolidCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float) (projectile.height - 48) : 0f), projectile.width, 48) && !Collision.WetCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float) (projectile.height - 20) : 0f), projectile.width, 20)) - { - projectile.velocity = new Vector2(0f, (float) Math.Sign(projectile.velocity.Y) * (1f / 1000f)); - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - projectile.timeLeft = 60; - } - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 60f) - projectile.Kill(); - for (int index1 = 0; index1 < 3; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, new Color(), 1f); - Main.dust[index2].scale = 0.1f + Main.rand.Next(5) * 0.1f; - Main.dust[index2].fadeIn = 1.5f + Main.rand.Next(5) * 0.1f; - Main.dust[index2].noGravity = true; - Main.dust[index2].position = projectile.Center + new Vector2(0f, (float) (-projectile.height / 2)).RotatedBy((double)projectile.rotation, new Vector2()) * 1.1f; - } - } - if (projectile.ai[0] != 1f) - return; - projectile.velocity = new Vector2(0f, (float) Math.Sign(projectile.velocity.Y) * (1f / 1000f)); - if (num1 != 0) - { - int num3 = 16; - int num4 = 320; - while (num3 < num4 && !Collision.SolidCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float)(projectile.height - num3 - 16) : 0f), projectile.width, num3 + 16)) - num3 += 16; - if (num1 == -1) - { - projectile.position.Y += (float)projectile.height; - projectile.height = num3; - projectile.position.Y -= (float)num3; - } - else - projectile.height = num3; - } - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 60f) - projectile.Kill(); - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; - for (int index1 = 0; index1 < 60; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; - dust.alpha = 200; - dust.velocity *= new Vector2(0.3f, 2f); - dust.velocity.Y += (float)(2 * num1); - dust.scale += Main.rand.NextFloat(); - dust.position = new Vector2(projectile.Center.X, projectile.Center.Y + (float) projectile.height * 0.5f * (float) -num1); - dust.customData = (object) num2; - if (num1 == -1 && Main.rand.Next(4) != 0) - { - dust.velocity.Y -= 0.2f; - } - } - Main.PlaySound(SoundID.Item34, projectile.position); - } - if (num1 == 1) - { - for (int index1 = 0; index1 < 9; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; - dust.alpha = 200; - dust.velocity *= new Vector2(0.3f, 2f); - dust.velocity.Y += (float)(2 * num1); - dust.scale += Main.rand.NextFloat(); - dust.position = new Vector2(projectile.Center.X, projectile.Center.Y + (float) projectile.height * 0.5f * (float) -num1); - dust.customData = (object)num2; - if (num1 == -1 && Main.rand.Next(4) != 0) - { - Main.dust[index2].velocity.Y -= 0.2f; - } - } - } - int Height = (int)(projectile.ai[1] / 60f * (float)projectile.height) * 3; - if (Height > projectile.height) - Height = projectile.height; - Vector2 Position = projectile.position + (num1 == -1 ? new Vector2(0f, (float) (projectile.height - Height)) : Vector2.Zero); - Vector2 vector2 = projectile.position + (num1 == -1 ? new Vector2(0f, (float) projectile.height) : Vector2.Zero); - for (int index1 = 0; index1 < 6; ++index1) - { - if (Main.rand.Next(3) < 2) - { - int index2 = Dust.NewDust(Position, projectile.width, Height, dustType, 0f, 0f, 90, new Color(), 2.5f); - Dust dust = Main.dust[index2]; - dust.noGravity = true; - dust.fadeIn = 1f; - if (dust.velocity.Y > 0f) - { - dust.velocity.Y *= -1f; - } - if (Main.rand.Next(6) < 3) - { - dust.position.Y = MathHelper.Lerp(dust.position.Y, vector2.Y, 0.5f); - dust.velocity *= 5f; - dust.velocity.Y -= 3f; - dust.position.X = projectile.Center.X; - dust.noGravity = false; - dust.noLight = true; - dust.fadeIn = 0.4f; - dust.scale *= 0.3f; - } - else - Main.dust[index2].velocity = projectile.DirectionFrom(Main.dust[index2].position) * Main.dust[index2].velocity.Length() * 0.25f; - Main.dust[index2].velocity.Y *= (float)-num1; - Main.dust[index2].customData = (object)num2; - } - } - for (int index1 = 0; index1 < 6; ++index1) - { - if (Main.rand.NextFloat() >= 0.5f) - { - int index2 = Dust.NewDust(Position, projectile.width, Height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; - dust.alpha = 200; - dust.velocity *= new Vector2(0.6f, 1.5f); - dust.scale += Main.rand.NextFloat(); - if (num1 == -1 && Main.rand.Next(4) != 0) - { - dust.velocity.Y -= 0.2f; - } - dust.customData = (object)num2; - } - } - } + int num1 = Math.Sign(projectile.velocity.Y); + int num2 = num1 == -1 ? 0 : 1; + if (projectile.ai[0] == 0f) + { + if (!Collision.SolidCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float) (projectile.height - 48) : 0f), projectile.width, 48) && !Collision.WetCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float) (projectile.height - 20) : 0f), projectile.width, 20)) + { + projectile.velocity = new Vector2(0f, (float) Math.Sign(projectile.velocity.Y) * (1f / 1000f)); + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + projectile.timeLeft = 60; + } + projectile.ai[1] += 1f; + if (projectile.ai[1] >= 60f) + projectile.Kill(); + for (int index1 = 0; index1 < 3; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, new Color(), 1f); + Main.dust[index2].scale = 0.1f + Main.rand.Next(5) * 0.1f; + Main.dust[index2].fadeIn = 1.5f + Main.rand.Next(5) * 0.1f; + Main.dust[index2].noGravity = true; + Main.dust[index2].position = projectile.Center + new Vector2(0f, (float) (-projectile.height / 2)).RotatedBy((double)projectile.rotation, new Vector2()) * 1.1f; + } + } + if (projectile.ai[0] != 1f) + return; + projectile.velocity = new Vector2(0f, (float) Math.Sign(projectile.velocity.Y) * (1f / 1000f)); + if (num1 != 0) + { + int num3 = 16; + int num4 = 320; + while (num3 < num4 && !Collision.SolidCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float)(projectile.height - num3 - 16) : 0f), projectile.width, num3 + 16)) + num3 += 16; + if (num1 == -1) + { + projectile.position.Y += (float)projectile.height; + projectile.height = num3; + projectile.position.Y -= (float)num3; + } + else + projectile.height = num3; + } + projectile.ai[1] += 1f; + if (projectile.ai[1] >= 60f) + projectile.Kill(); + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; + for (int index1 = 0; index1 < 60; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); + Dust dust = Main.dust[index2]; + dust.alpha = 200; + dust.velocity *= new Vector2(0.3f, 2f); + dust.velocity.Y += (float)(2 * num1); + dust.scale += Main.rand.NextFloat(); + dust.position = new Vector2(projectile.Center.X, projectile.Center.Y + (float) projectile.height * 0.5f * (float) -num1); + dust.customData = (object) num2; + if (num1 == -1 && Main.rand.Next(4) != 0) + { + dust.velocity.Y -= 0.2f; + } + } + Main.PlaySound(SoundID.Item34, projectile.position); + } + if (num1 == 1) + { + for (int index1 = 0; index1 < 9; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); + Dust dust = Main.dust[index2]; + dust.alpha = 200; + dust.velocity *= new Vector2(0.3f, 2f); + dust.velocity.Y += (float)(2 * num1); + dust.scale += Main.rand.NextFloat(); + dust.position = new Vector2(projectile.Center.X, projectile.Center.Y + (float) projectile.height * 0.5f * (float) -num1); + dust.customData = (object)num2; + if (num1 == -1 && Main.rand.Next(4) != 0) + { + Main.dust[index2].velocity.Y -= 0.2f; + } + } + } + int Height = (int)(projectile.ai[1] / 60f * (float)projectile.height) * 3; + if (Height > projectile.height) + Height = projectile.height; + Vector2 Position = projectile.position + (num1 == -1 ? new Vector2(0f, (float) (projectile.height - Height)) : Vector2.Zero); + Vector2 vector2 = projectile.position + (num1 == -1 ? new Vector2(0f, (float) projectile.height) : Vector2.Zero); + for (int index1 = 0; index1 < 6; ++index1) + { + if (Main.rand.Next(3) < 2) + { + int index2 = Dust.NewDust(Position, projectile.width, Height, dustType, 0f, 0f, 90, new Color(), 2.5f); + Dust dust = Main.dust[index2]; + dust.noGravity = true; + dust.fadeIn = 1f; + if (dust.velocity.Y > 0f) + { + dust.velocity.Y *= -1f; + } + if (Main.rand.Next(6) < 3) + { + dust.position.Y = MathHelper.Lerp(dust.position.Y, vector2.Y, 0.5f); + dust.velocity *= 5f; + dust.velocity.Y -= 3f; + dust.position.X = projectile.Center.X; + dust.noGravity = false; + dust.noLight = true; + dust.fadeIn = 0.4f; + dust.scale *= 0.3f; + } + else + Main.dust[index2].velocity = projectile.DirectionFrom(Main.dust[index2].position) * Main.dust[index2].velocity.Length() * 0.25f; + Main.dust[index2].velocity.Y *= (float)-num1; + Main.dust[index2].customData = (object)num2; + } + } + for (int index1 = 0; index1 < 6; ++index1) + { + if (Main.rand.NextFloat() >= 0.5f) + { + int index2 = Dust.NewDust(Position, projectile.width, Height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); + Dust dust = Main.dust[index2]; + dust.alpha = 200; + dust.velocity *= new Vector2(0.6f, 1.5f); + dust.scale += Main.rand.NextFloat(); + if (num1 == -1 && Main.rand.Next(4) != 0) + { + dust.velocity.Y -= 0.2f; + } + dust.customData = (object)num2; + } + } + } public override void OnHitPlayer(Player target, int damage, bool crit) { diff --git a/Projectiles/Environment/GeyserTelegraph.cs b/Projectiles/Environment/GeyserTelegraph.cs index 987361eb1a..13ea7b7b51 100644 --- a/Projectiles/Environment/GeyserTelegraph.cs +++ b/Projectiles/Environment/GeyserTelegraph.cs @@ -4,11 +4,11 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Environment { - public class GeyserTelegraph : ModProjectile + public class GeyserTelegraph : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private bool initialized = false; + private bool initialized = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Geyser"); @@ -21,37 +21,37 @@ namespace CalamityMod.Projectiles.Environment projectile.hostile = true; projectile.penetrate = -1; projectile.timeLeft = 100; - projectile.trap = true; + projectile.trap = true; } public override void AI() { - if (!initialized && Main.myPlayer != projectile.owner) - { - int projectileType = ModContent.ProjectileType(); - float randomVelocity = Main.rand.NextFloat() + 0.5f; - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, -8f * randomVelocity, projectileType, 0, 0f, projectile.owner, 0f, 0f); - Main.projectile[proj].netUpdate = true; - initialized = true; - } - } + if (!initialized && Main.myPlayer != projectile.owner) + { + int projectileType = ModContent.ProjectileType(); + float randomVelocity = Main.rand.NextFloat() + 0.5f; + int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, -8f * randomVelocity, projectileType, 0, 0f, projectile.owner, 0f, 0f); + Main.projectile[proj].netUpdate = true; + initialized = true; + } + } - public override void Kill(int timeLeft) - { - if (Main.myPlayer != projectile.owner) - return; + public override void Kill(int timeLeft) + { + if (Main.myPlayer != projectile.owner) + return; - int projectileType = ProjectileID.GeyserTrap; - if (projectile.ai[0] == 1f) - { - projectileType = ModContent.ProjectileType(); - } - float randomVelocity = Main.rand.NextFloat() + 0.5f; - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, -8f * randomVelocity, projectileType, 20, 2f, projectile.owner, 0f, 0f); - Main.projectile[proj].friendly = false; - Main.projectile[proj].netUpdate = true; - } + int projectileType = ProjectileID.GeyserTrap; + if (projectile.ai[0] == 1f) + { + projectileType = ModContent.ProjectileType(); + } + float randomVelocity = Main.rand.NextFloat() + 0.5f; + int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, -8f * randomVelocity, projectileType, 20, 2f, projectile.owner, 0f, 0f); + Main.projectile[proj].friendly = false; + Main.projectile[proj].netUpdate = true; + } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Environment/LightningMark.cs b/Projectiles/Environment/LightningMark.cs index 26aa22600a..3627457199 100644 --- a/Projectiles/Environment/LightningMark.cs +++ b/Projectiles/Environment/LightningMark.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Environment { - public class LightningMark : ModProjectile + public class LightningMark : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -20,84 +20,84 @@ namespace CalamityMod.Projectiles.Environment projectile.hostile = true; projectile.penetrate = -1; projectile.timeLeft = 1800; - projectile.extraUpdates = 10; + projectile.extraUpdates = 10; } public override void AI() { - if (projectile.timeLeft <= 600) - { - if (projectile.ai[0] == 0f && projectile.owner == Main.myPlayer) - { - projectile.ai[0] = 1f; + if (projectile.timeLeft <= 600) + { + if (projectile.ai[0] == 0f && projectile.owner == Main.myPlayer) + { + projectile.ai[0] = 1f; - Vector2 fireFrom = new Vector2(projectile.Center.X, projectile.Center.Y - 900f); - int tries = 0; - while (CalamityUtils.ParanoidTileRetrieval((int)(fireFrom.X / 16f), (int)(fireFrom.Y / 16f)).active()) - { - fireFrom.Y += 16f; + Vector2 fireFrom = new Vector2(projectile.Center.X, projectile.Center.Y - 900f); + int tries = 0; + while (CalamityUtils.ParanoidTileRetrieval((int)(fireFrom.X / 16f), (int)(fireFrom.Y / 16f)).active()) + { + fireFrom.Y += 16f; - tries += 1; - if (tries > 25) - return; - } + tries += 1; + if (tries > 25) + return; + } - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), projectile.Center); - Vector2 ai0 = projectile.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), projectile.Center); + Vector2 ai0 = projectile.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - int damage = NPC.downedMoonlord ? 80 : NPC.downedPlantBoss ? 40 : Main.hardMode ? 20 : 10; + int damage = NPC.downedMoonlord ? 80 : NPC.downedPlantBoss ? 40 : Main.hardMode ? 20 : 10; - int proj = Projectile.NewProjectile(fireFrom, velocity, ProjectileID.CultistBossLightningOrbArc, damage, 0f, projectile.owner, ai0.ToRotation(), ai); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].extraUpdates += 11; - Main.projectile[proj].friendly = true; - Main.projectile[proj].Calamity().lineColor = 1; - } - } - } - else if (projectile.velocity.Y == 0f) - { - Lighting.AddLight(projectile.Center, 0.6f, 0.9f, 1f); + int proj = Projectile.NewProjectile(fireFrom, velocity, ProjectileID.CultistBossLightningOrbArc, damage, 0f, projectile.owner, ai0.ToRotation(), ai); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].extraUpdates += 11; + Main.projectile[proj].friendly = true; + Main.projectile[proj].Calamity().lineColor = 1; + } + } + } + else if (projectile.velocity.Y == 0f) + { + Lighting.AddLight(projectile.Center, 0.6f, 0.9f, 1f); - if (Main.rand.NextBool(3)) - { - int num199 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 226, 0f, 0f, 100, default, 1f); - Main.dust[num199].position.X -= 2f; - Main.dust[num199].position.Y += 2f; - Main.dust[num199].scale = 0.7f; - Main.dust[num199].noGravity = true; - Main.dust[num199].velocity.Y -= 2f; - } + if (Main.rand.NextBool(3)) + { + int num199 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 226, 0f, 0f, 100, default, 1f); + Main.dust[num199].position.X -= 2f; + Main.dust[num199].position.Y += 2f; + Main.dust[num199].scale = 0.7f; + Main.dust[num199].noGravity = true; + Main.dust[num199].velocity.Y -= 2f; + } - if (Main.rand.NextBool(15)) - { - int num200 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); - Main.dust[num200].position.X -= 2f; - Main.dust[num200].position.Y += 2f; - Main.dust[num200].scale = 0.7f; - Main.dust[num200].noGravity = true; - Main.dust[num200].velocity *= 0.1f; - } - } + if (Main.rand.NextBool(15)) + { + int num200 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); + Main.dust[num200].position.X -= 2f; + Main.dust[num200].position.Y += 2f; + Main.dust[num200].scale = 0.7f; + Main.dust[num200].noGravity = true; + Main.dust[num200].velocity *= 0.1f; + } + } - if (projectile.velocity.Y != projectile.velocity.Y && projectile.velocity.Y > 1f) - projectile.velocity.Y *= -0.5f; + if (projectile.velocity.Y != projectile.velocity.Y && projectile.velocity.Y > 1f) + projectile.velocity.Y *= -0.5f; - projectile.velocity.Y += 0.2f; + projectile.velocity.Y += 0.2f; - if (projectile.velocity.Y > 16f) - projectile.velocity.Y = 16f; - } + if (projectile.velocity.Y > 16f) + projectile.velocity.Y = 16f; + } - public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) - { - fallThrough = false; - return true; - } + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) + { + fallThrough = false; + return true; + } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Environment/SmokeTelegraph.cs b/Projectiles/Environment/SmokeTelegraph.cs index cad442541f..5700ab53f4 100644 --- a/Projectiles/Environment/SmokeTelegraph.cs +++ b/Projectiles/Environment/SmokeTelegraph.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Projectiles.Environment { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private int dustType = 31; + private int dustType = 31; public override void SetStaticDefaults() { DisplayName.SetDefault("Smoke"); @@ -17,152 +17,152 @@ namespace CalamityMod.Projectiles.Environment public override void SetDefaults() { - projectile.width = 30; - projectile.height = 30; - projectile.alpha = 255; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 120; - projectile.hostile = true; - projectile.penetrate = -1; - projectile.trap = true; + projectile.width = 30; + projectile.height = 30; + projectile.alpha = 255; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 120; + projectile.hostile = true; + projectile.penetrate = -1; + projectile.trap = true; } public override void AI() { - int num1 = Math.Sign(projectile.velocity.Y); - int num2 = num1 == -1 ? 0 : 1; - if (projectile.ai[0] == 0f) - { - if (!Collision.SolidCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float) (projectile.height - 48) : 0f), projectile.width, 48) && !Collision.WetCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float) (projectile.height - 20) : 0f), projectile.width, 20)) - { - projectile.velocity = new Vector2(0f, (float) Math.Sign(projectile.velocity.Y) * (1f / 1000f)); - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - projectile.timeLeft = 60; - } - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 60f) - projectile.Kill(); - for (int index1 = 0; index1 < 3; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, new Color(), 1f); - Main.dust[index2].scale = 0.1f + Main.rand.Next(5) * 0.1f; - Main.dust[index2].fadeIn = 1.5f + Main.rand.Next(5) * 0.1f; - Main.dust[index2].noGravity = true; - Main.dust[index2].position = projectile.Center + new Vector2(0f, (float) (-projectile.height / 2)).RotatedBy((double)projectile.rotation, new Vector2()) * 1.1f; - } - } - if (projectile.ai[0] != 1f) - return; - projectile.velocity = new Vector2(0f, (float) Math.Sign(projectile.velocity.Y) * (1f / 1000f)); - if (num1 != 0) - { - int num3 = 16; - int num4 = 320; - while (num3 < num4 && !Collision.SolidCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float)(projectile.height - num3 - 16) : 0f), projectile.width, num3 + 16)) - num3 += 16; - if (num1 == -1) - { - projectile.position.Y += (float)projectile.height; - projectile.height = num3; - projectile.position.Y -= (float)num3; - } - else - projectile.height = num3; - } - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 60f) - projectile.Kill(); - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; - for (int index1 = 0; index1 < 60; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; - dust.alpha = 200; - dust.velocity *= new Vector2(0.3f, 2f); - dust.velocity.Y += (float)(2 * num1); - dust.scale += Main.rand.NextFloat(); - dust.position = new Vector2(projectile.Center.X, projectile.Center.Y + (float) projectile.height * 0.5f * (float) -num1); - dust.customData = (object) num2; - if (num1 == -1 && Main.rand.Next(4) != 0) - { - dust.velocity.Y -= 0.2f; - } - } - Main.PlaySound(SoundID.Item34, projectile.position); - } - if (num1 == 1) - { - for (int index1 = 0; index1 < 9; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; - dust.alpha = 200; - dust.velocity *= new Vector2(0.3f, 2f); - dust.velocity.Y += (float)(2 * num1); - dust.scale += Main.rand.NextFloat(); - dust.position = new Vector2(projectile.Center.X, projectile.Center.Y + (float) projectile.height * 0.5f * (float) -num1); - dust.customData = (object)num2; - if (num1 == -1 && Main.rand.Next(4) != 0) - { - Main.dust[index2].velocity.Y -= 0.2f; - } - } - } - int Height = (int)(projectile.ai[1] / 60f * (float)projectile.height) * 3; - if (Height > projectile.height) - Height = projectile.height; - Vector2 Position = projectile.position + (num1 == -1 ? new Vector2(0f, (float) (projectile.height - Height)) : Vector2.Zero); - Vector2 vector2 = projectile.position + (num1 == -1 ? new Vector2(0f, (float) projectile.height) : Vector2.Zero); - for (int index1 = 0; index1 < 6; ++index1) - { - if (Main.rand.Next(3) < 2) - { - int index2 = Dust.NewDust(Position, projectile.width, Height, dustType, 0f, 0f, 90, new Color(), 2.5f); - Dust dust = Main.dust[index2]; - dust.noGravity = true; - dust.fadeIn = 1f; - if (dust.velocity.Y > 0f) - { - dust.velocity.Y *= -1f; - } - if (Main.rand.Next(6) < 3) - { - dust.position.Y = MathHelper.Lerp(dust.position.Y, vector2.Y, 0.5f); - dust.velocity *= 5f; - dust.velocity.Y -= 3f; - dust.position.X = projectile.Center.X; - dust.noGravity = false; - dust.noLight = true; - dust.fadeIn = 0.4f; - dust.scale *= 0.3f; - } - else - Main.dust[index2].velocity = projectile.DirectionFrom(Main.dust[index2].position) * Main.dust[index2].velocity.Length() * 0.25f; - Main.dust[index2].velocity.Y *= (float)-num1; - Main.dust[index2].customData = (object)num2; - } - } - for (int index1 = 0; index1 < 6; ++index1) - { - if (Main.rand.NextFloat() >= 0.5f) - { - int index2 = Dust.NewDust(Position, projectile.width, Height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); - Dust dust = Main.dust[index2]; - dust.alpha = 200; - dust.velocity *= new Vector2(0.6f, 1.5f); - dust.scale += Main.rand.NextFloat(); - if (num1 == -1 && Main.rand.Next(4) != 0) - { - dust.velocity.Y -= 0.2f; - } - dust.customData = (object)num2; - } - } - } + int num1 = Math.Sign(projectile.velocity.Y); + int num2 = num1 == -1 ? 0 : 1; + if (projectile.ai[0] == 0f) + { + if (!Collision.SolidCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float) (projectile.height - 48) : 0f), projectile.width, 48) && !Collision.WetCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float) (projectile.height - 20) : 0f), projectile.width, 20)) + { + projectile.velocity = new Vector2(0f, (float) Math.Sign(projectile.velocity.Y) * (1f / 1000f)); + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + projectile.timeLeft = 60; + } + projectile.ai[1] += 1f; + if (projectile.ai[1] >= 60f) + projectile.Kill(); + for (int index1 = 0; index1 < 3; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, new Color(), 1f); + Main.dust[index2].scale = 0.1f + Main.rand.Next(5) * 0.1f; + Main.dust[index2].fadeIn = 1.5f + Main.rand.Next(5) * 0.1f; + Main.dust[index2].noGravity = true; + Main.dust[index2].position = projectile.Center + new Vector2(0f, (float) (-projectile.height / 2)).RotatedBy((double)projectile.rotation, new Vector2()) * 1.1f; + } + } + if (projectile.ai[0] != 1f) + return; + projectile.velocity = new Vector2(0f, (float) Math.Sign(projectile.velocity.Y) * (1f / 1000f)); + if (num1 != 0) + { + int num3 = 16; + int num4 = 320; + while (num3 < num4 && !Collision.SolidCollision(projectile.position + new Vector2(0f, num1 == -1 ? (float)(projectile.height - num3 - 16) : 0f), projectile.width, num3 + 16)) + num3 += 16; + if (num1 == -1) + { + projectile.position.Y += (float)projectile.height; + projectile.height = num3; + projectile.position.Y -= (float)num3; + } + else + projectile.height = num3; + } + projectile.ai[1] += 1f; + if (projectile.ai[1] >= 60f) + projectile.Kill(); + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; + for (int index1 = 0; index1 < 60; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); + Dust dust = Main.dust[index2]; + dust.alpha = 200; + dust.velocity *= new Vector2(0.3f, 2f); + dust.velocity.Y += (float)(2 * num1); + dust.scale += Main.rand.NextFloat(); + dust.position = new Vector2(projectile.Center.X, projectile.Center.Y + (float) projectile.height * 0.5f * (float) -num1); + dust.customData = (object) num2; + if (num1 == -1 && Main.rand.Next(4) != 0) + { + dust.velocity.Y -= 0.2f; + } + } + Main.PlaySound(SoundID.Item34, projectile.position); + } + if (num1 == 1) + { + for (int index1 = 0; index1 < 9; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); + Dust dust = Main.dust[index2]; + dust.alpha = 200; + dust.velocity *= new Vector2(0.3f, 2f); + dust.velocity.Y += (float)(2 * num1); + dust.scale += Main.rand.NextFloat(); + dust.position = new Vector2(projectile.Center.X, projectile.Center.Y + (float) projectile.height * 0.5f * (float) -num1); + dust.customData = (object)num2; + if (num1 == -1 && Main.rand.Next(4) != 0) + { + Main.dust[index2].velocity.Y -= 0.2f; + } + } + } + int Height = (int)(projectile.ai[1] / 60f * (float)projectile.height) * 3; + if (Height > projectile.height) + Height = projectile.height; + Vector2 Position = projectile.position + (num1 == -1 ? new Vector2(0f, (float) (projectile.height - Height)) : Vector2.Zero); + Vector2 vector2 = projectile.position + (num1 == -1 ? new Vector2(0f, (float) projectile.height) : Vector2.Zero); + for (int index1 = 0; index1 < 6; ++index1) + { + if (Main.rand.Next(3) < 2) + { + int index2 = Dust.NewDust(Position, projectile.width, Height, dustType, 0f, 0f, 90, new Color(), 2.5f); + Dust dust = Main.dust[index2]; + dust.noGravity = true; + dust.fadeIn = 1f; + if (dust.velocity.Y > 0f) + { + dust.velocity.Y *= -1f; + } + if (Main.rand.Next(6) < 3) + { + dust.position.Y = MathHelper.Lerp(dust.position.Y, vector2.Y, 0.5f); + dust.velocity *= 5f; + dust.velocity.Y -= 3f; + dust.position.X = projectile.Center.X; + dust.noGravity = false; + dust.noLight = true; + dust.fadeIn = 0.4f; + dust.scale *= 0.3f; + } + else + Main.dust[index2].velocity = projectile.DirectionFrom(Main.dust[index2].position) * Main.dust[index2].velocity.Length() * 0.25f; + Main.dust[index2].velocity.Y *= (float)-num1; + Main.dust[index2].customData = (object)num2; + } + } + for (int index1 = 0; index1 < 6; ++index1) + { + if (Main.rand.NextFloat() >= 0.5f) + { + int index2 = Dust.NewDust(Position, projectile.width, Height, dustType, 0f, -2.5f * (float) -num1, 0, new Color(), 1f); + Dust dust = Main.dust[index2]; + dust.alpha = 200; + dust.velocity *= new Vector2(0.6f, 1.5f); + dust.scale += Main.rand.NextFloat(); + if (num1 == -1 && Main.rand.Next(4) != 0) + { + dust.velocity.Y -= 0.2f; + } + dust.customData = (object)num2; + } + } + } public override bool CanDamage() => false; } diff --git a/Projectiles/Healing/AtaxiaHealOrb.cs b/Projectiles/Healing/AtaxiaHealOrb.cs index 1a13723cd4..e02d5f88b8 100644 --- a/Projectiles/Healing/AtaxiaHealOrb.cs +++ b/Projectiles/Healing/AtaxiaHealOrb.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class AtaxiaHealOrb : ModProjectile + public class AtaxiaHealOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,14 +23,14 @@ namespace CalamityMod.Projectiles.Healing projectile.extraUpdates = 3; } - public override void AI() - { - projectile.HealingProjectile((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; - } + public override void AI() + { + projectile.HealingProjectile((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 60995c3d47..31c373e15c 100644 --- a/Projectiles/Healing/AuricOrb.cs +++ b/Projectiles/Healing/AuricOrb.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class AuricOrb : ModProjectile + public class AuricOrb : ModProjectile { public override void SetStaticDefaults() { @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Healing } } - projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f); return; } diff --git a/Projectiles/Healing/BurntSiennaProj.cs b/Projectiles/Healing/BurntSiennaProj.cs index 22c1e81856..c34bafa181 100644 --- a/Projectiles/Healing/BurntSiennaProj.cs +++ b/Projectiles/Healing/BurntSiennaProj.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class BurntSiennaProj : ModProjectile + public class BurntSiennaProj : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,16 +23,16 @@ namespace CalamityMod.Projectiles.Healing projectile.timeLeft = 180; } - public override void AI() - { - projectile.velocity *= 0.95f; + public override void AI() + { + projectile.velocity *= 0.95f; - projectile.HealingProjectile(3, (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 -= projectile.velocity.X * 0.2f; - dust.position.Y += projectile.velocity.Y * 0.2f; - } + projectile.HealingProjectile(3, (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 -= 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 73fc1f8bcb..8becd8cfb3 100644 --- a/Projectiles/Healing/CactusHealOrb.cs +++ b/Projectiles/Healing/CactusHealOrb.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class CactusHealOrb : ModProjectile + public class CactusHealOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -27,12 +27,12 @@ namespace CalamityMod.Projectiles.Healing { projectile.velocity.Y *= 0.98f; - projectile.HealingProjectile(15, projectile.owner, 12f, 15f, false); - 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; + projectile.HealingProjectile(15, projectile.owner, 12f, 15f, false); + 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/DemonHeal.cs b/Projectiles/Healing/DemonHeal.cs index fcff05e107..05a253ef83 100644 --- a/Projectiles/Healing/DemonHeal.cs +++ b/Projectiles/Healing/DemonHeal.cs @@ -3,14 +3,14 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class DemonHeal : ModProjectile + public class DemonHeal : ModProjectile { - public Player Owner => Main.player[projectile.owner]; + public Player Owner => Main.player[projectile.owner]; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetStaticDefaults() => DisplayName.SetDefault("Heal"); - public override void SetDefaults() + public override void SetDefaults() { projectile.width = 4; projectile.height = 4; @@ -19,15 +19,15 @@ namespace CalamityMod.Projectiles.Healing projectile.timeLeft = 640; } - public override void AI() - { - projectile.HealingProjectile(10, projectile.owner, 20f, 20f, true, 640); + public override void AI() + { + projectile.HealingProjectile(10, projectile.owner, 20f, 20f, true, 640); Dust fire = Dust.NewDustPerfect(projectile.Center, 130); fire.velocity = Microsoft.Xna.Framework.Vector2.Zero; fire.scale = Main.rand.NextFloat(1f, 1.15f); fire.fadeIn = 0.45f; fire.noGravity = true; - } + } } } diff --git a/Projectiles/Healing/EarthHealOrb.cs b/Projectiles/Healing/EarthHealOrb.cs index 24e2d86347..d94a12a07a 100644 --- a/Projectiles/Healing/EarthHealOrb.cs +++ b/Projectiles/Healing/EarthHealOrb.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class EarthHealOrb : ModProjectile + public class EarthHealOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,14 +23,14 @@ namespace CalamityMod.Projectiles.Healing projectile.extraUpdates = 3; } - public override void AI() - { - projectile.HealingProjectile((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 -= projectile.velocity.X * 0.2f; - dust.position.Y += projectile.velocity.Y * 0.2f; - } + public override void AI() + { + projectile.HealingProjectile((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 -= 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 2080699aaf..1527235534 100644 --- a/Projectiles/Healing/EssenceFlame.cs +++ b/Projectiles/Healing/EssenceFlame.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class EssenceFlame : ModProjectile + public class EssenceFlame : ModProjectile { public override void SetStaticDefaults() { @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Healing projectile.frame = 0; } - projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 3.5f, 15f); + projectile.HealingProjectile((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 b6f8f262cb..99b9cbb39a 100644 --- a/Projectiles/Healing/Exoheal.cs +++ b/Projectiles/Healing/Exoheal.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class Exoheal : ModProjectile + public class Exoheal : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,14 +23,14 @@ namespace CalamityMod.Projectiles.Healing projectile.extraUpdates = 3; } - public override void AI() - { - projectile.HealingProjectile((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 -= projectile.velocity.X * 0.2f; - dust.position.Y += projectile.velocity.Y * 0.2f; - } + public override void AI() + { + projectile.HealingProjectile((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 -= 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 fea1ecad96..15be959080 100644 --- a/Projectiles/Healing/FungalHeal.cs +++ b/Projectiles/Healing/FungalHeal.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class FungalHeal : ModProjectile + public class FungalHeal : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Healing projectile.localAI[0] += 1f; } - projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 5f, 15f); + projectile.HealingProjectile((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(projectile.position, projectile.width, projectile.height, 56, 0f, 0f, 100, default, 0.5f); diff --git a/Projectiles/Healing/GodSlayerHealOrb.cs b/Projectiles/Healing/GodSlayerHealOrb.cs index 1843faeb77..4351d24dc3 100644 --- a/Projectiles/Healing/GodSlayerHealOrb.cs +++ b/Projectiles/Healing/GodSlayerHealOrb.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class GodSlayerHealOrb : ModProjectile + public class GodSlayerHealOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,14 +23,14 @@ namespace CalamityMod.Projectiles.Healing projectile.extraUpdates = 3; } - public override void AI() - { - projectile.HealingProjectile((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 -= projectile.velocity.X * 0.2f; - dust.position.Y += projectile.velocity.Y * 0.2f; - } + public override void AI() + { + projectile.HealingProjectile((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 -= 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 index 5b3416ed3e..710379066e 100644 --- a/Projectiles/Healing/ManaOverloaderHealOrb.cs +++ b/Projectiles/Healing/ManaOverloaderHealOrb.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class ManaOverloaderHealOrb : ModProjectile + public class ManaOverloaderHealOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,14 +23,14 @@ namespace CalamityMod.Projectiles.Healing projectile.extraUpdates = 3; } - public override void AI() - { - projectile.HealingProjectile((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; - } + public override void AI() + { + projectile.HealingProjectile((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/PhoenixHeal.cs b/Projectiles/Healing/PhoenixHeal.cs index f4da16f6d4..4ed7189924 100644 --- a/Projectiles/Healing/PhoenixHeal.cs +++ b/Projectiles/Healing/PhoenixHeal.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class PhoenixHeal : ModProjectile + public class PhoenixHeal : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -22,18 +22,18 @@ namespace CalamityMod.Projectiles.Healing projectile.extraUpdates = 3; } - public override void AI() - { - projectile.velocity.X *= 0.95f; - projectile.velocity.Y *= 0.95f; - projectile.HealingProjectile(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); - Dust dust = Main.dust[num500]; - dust.noGravity = true; - dust.position.X -= num498; - dust.position.Y -= num499; - } + public override void AI() + { + projectile.velocity.X *= 0.95f; + projectile.velocity.Y *= 0.95f; + projectile.HealingProjectile(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); + Dust dust = Main.dust[num500]; + dust.noGravity = true; + dust.position.X -= num498; + dust.position.Y -= num499; + } } } diff --git a/Projectiles/Healing/RainHeal.cs b/Projectiles/Healing/RainHeal.cs index 3a4669b204..8249fee0be 100644 --- a/Projectiles/Healing/RainHeal.cs +++ b/Projectiles/Healing/RainHeal.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class RainHeal : ModProjectile + public class RainHeal : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -25,15 +25,15 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - if (projectile.timeLeft < 165) - { - if (projectile.timeLeft > 150) - projectile.velocity *= 0.9f; - else - projectile.HealingProjectile(8, projectile.owner, 12f, 15f, false); - } + if (projectile.timeLeft < 165) + { + if (projectile.timeLeft > 150) + projectile.velocity *= 0.9f; + else + projectile.HealingProjectile(8, projectile.owner, 12f, 15f, false); + } - float num498 = projectile.velocity.X * 0.2f; + 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); Dust dust = Main.dust[num500]; diff --git a/Projectiles/Healing/ReaverHealOrb.cs b/Projectiles/Healing/ReaverHealOrb.cs index 55f2e8dc23..b0aa542221 100644 --- a/Projectiles/Healing/ReaverHealOrb.cs +++ b/Projectiles/Healing/ReaverHealOrb.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class ReaverHealOrb : ModProjectile + public class ReaverHealOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetStaticDefaults() @@ -22,14 +22,14 @@ namespace CalamityMod.Projectiles.Healing projectile.extraUpdates = 3; } - public override void AI() - { - projectile.HealingProjectile((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, 74, 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; - } + public override void AI() + { + projectile.HealingProjectile((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, 74, 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/RoyalHeal.cs b/Projectiles/Healing/RoyalHeal.cs index 41f7ab45ea..bdd8c010b4 100644 --- a/Projectiles/Healing/RoyalHeal.cs +++ b/Projectiles/Healing/RoyalHeal.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class RoyalHeal : ModProjectile + public class RoyalHeal : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f); + projectile.HealingProjectile((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 1afc198660..afd6e7749d 100644 --- a/Projectiles/Healing/ShinobiHealOrb.cs +++ b/Projectiles/Healing/ShinobiHealOrb.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class ShinobiHealOrb : ModProjectile + public class ShinobiHealOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - projectile.HealingProjectile((int)projectile.ai[1], projectile.owner, 6f, 15f); + projectile.HealingProjectile((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 9bece10e72..f413e11c86 100644 --- a/Projectiles/Healing/SilvaOrb.cs +++ b/Projectiles/Healing/SilvaOrb.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class SilvaOrb : ModProjectile + public class SilvaOrb : ModProjectile { public override void SetStaticDefaults() { @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Healing } } - projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f); return; } diff --git a/Projectiles/Healing/TerracottaProj.cs b/Projectiles/Healing/TerracottaProj.cs index 25e4c0c8ec..608b4e9e6f 100644 --- a/Projectiles/Healing/TerracottaProj.cs +++ b/Projectiles/Healing/TerracottaProj.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class TerracottaProj : ModProjectile + public class TerracottaProj : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,19 +23,19 @@ namespace CalamityMod.Projectiles.Healing projectile.timeLeft = 360; } - public override void AI() - { - projectile.velocity *= 0.99f; + public override void AI() + { + projectile.velocity *= 0.99f; - projectile.HealingProjectile(9, (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); - Dust dust = Main.dust[num500]; - dust.noGravity = true; - dust.position.X -= num498; - dust.position.Y -= num499; - } + projectile.HealingProjectile(9, (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); + Dust dust = Main.dust[num500]; + dust.noGravity = true; + dust.position.X -= num498; + dust.position.Y -= num499; + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Healing/TransfusionTrail.cs b/Projectiles/Healing/TransfusionTrail.cs index 78b8539890..20cddb6036 100644 --- a/Projectiles/Healing/TransfusionTrail.cs +++ b/Projectiles/Healing/TransfusionTrail.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class TransfusionTrail : ModProjectile + public class TransfusionTrail : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -21,26 +21,26 @@ namespace CalamityMod.Projectiles.Healing projectile.extraUpdates = 10; } - public override void AI() - { - projectile.HealingProjectile((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); - Dust dust = Main.dust[num496]; - dust.noGravity = true; - dust.position.X -= num494; - dust.position.Y -= num495; - for (int num497 = 0; num497 < 2; num497++) - { - float num498 = projectile.velocity.X * 0.2f * (float)num497; - float num499 = -(projectile.velocity.Y * 0.2f) * (float)num497; - int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 183, 0f, 0f, 100, default, 0.9f); - Dust dust2 = Main.dust[num500]; - dust2.noGravity = true; - dust2.position.X -= num498; - dust2.position.Y -= num499; - } - } + public override void AI() + { + projectile.HealingProjectile((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); + Dust dust = Main.dust[num496]; + dust.noGravity = true; + dust.position.X -= num494; + dust.position.Y -= num495; + for (int num497 = 0; num497 < 2; num497++) + { + float num498 = projectile.velocity.X * 0.2f * (float)num497; + float num499 = -(projectile.velocity.Y * 0.2f) * (float)num497; + int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 183, 0f, 0f, 100, default, 0.9f); + Dust dust2 = Main.dust[num500]; + dust2.noGravity = true; + dust2.position.X -= num498; + dust2.position.Y -= num499; + } + } } } diff --git a/Projectiles/Healing/XerocHealOrb.cs b/Projectiles/Healing/XerocHealOrb.cs index 4c9f4ecb0a..3be81d7384 100644 --- a/Projectiles/Healing/XerocHealOrb.cs +++ b/Projectiles/Healing/XerocHealOrb.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing { - public class XerocHealOrb : ModProjectile + public class XerocHealOrb : ModProjectile { public override void SetStaticDefaults() { @@ -21,19 +21,19 @@ namespace CalamityMod.Projectiles.Healing projectile.extraUpdates = 3; } - public override void AI() - { - projectile.HealingProjectile((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); - if (projectile.timeLeft % 2 == 0) - { - int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 62, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num500]; - dust.noGravity = true; - dust.position.X -= num498; - dust.position.Y -= num499; - } - } + public override void AI() + { + projectile.HealingProjectile((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); + if (projectile.timeLeft % 2 == 0) + { + int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 62, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[num500]; + dust.noGravity = true; + dust.position.X -= num498; + dust.position.Y -= num499; + } + } } } diff --git a/Projectiles/Magic/AcidGunStream.cs b/Projectiles/Magic/AcidGunStream.cs index 7a955893a2..fe51b26ecf 100644 --- a/Projectiles/Magic/AcidGunStream.cs +++ b/Projectiles/Magic/AcidGunStream.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Magic projectile.width = 32; projectile.height = 32; projectile.friendly = true; - projectile.magic = true; + projectile.magic = true; projectile.ignoreWater = true; projectile.penetrate = 3; projectile.extraUpdates = 2; diff --git a/Projectiles/Magic/AcidicReed.cs b/Projectiles/Magic/AcidicReed.cs index 722784a951..f2d9e0fb0d 100644 --- a/Projectiles/Magic/AcidicReed.cs +++ b/Projectiles/Magic/AcidicReed.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class AcidicReed : ModProjectile + public class AcidicReed : ModProjectile { public override void SetStaticDefaults() { @@ -16,29 +16,29 @@ namespace CalamityMod.Projectiles.Magic projectile.width = 10; projectile.height = 10; projectile.friendly = true; - projectile.magic = true; + projectile.magic = true; projectile.timeLeft = 600; projectile.tileCollide = true; projectile.ignoreWater = false; - projectile.penetrate = 1; + projectile.penetrate = 1; } public override void AI() { - if (projectile.ai[0] == 1f) - { + if (projectile.ai[0] == 1f) + { Terraria.Audio.LegacySoundStyle saxSound = Utils.SelectRandom(Main.rand, new Terraria.Audio.LegacySoundStyle[] { - mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax1"), - mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax2"), - mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax3"), - mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax4"), - mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax5"), - mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax6") + mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax1"), + mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax2"), + mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax3"), + mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax4"), + mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax5"), + mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/Saxophone/Sax6") }); - Main.PlaySound(saxSound, projectile.position); - projectile.ai[0] = 0f; - } + Main.PlaySound(saxSound, projectile.position); + projectile.ai[0] = 0f; + } if (projectile.velocity.Y < 10f) projectile.velocity.Y += 0.25f; projectile.rotation = projectile.velocity.ToRotation(); diff --git a/Projectiles/Magic/Ancient.cs b/Projectiles/Magic/Ancient.cs index 04e1483107..ef3648affb 100644 --- a/Projectiles/Magic/Ancient.cs +++ b/Projectiles/Magic/Ancient.cs @@ -7,48 +7,48 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class Ancient : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ancient"); + public class Ancient : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ancient"); Main.projFrames[projectile.type] = 6; ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; ProjectileID.Sets.TrailingMode[projectile.type] = 2; - } + } - public override void SetDefaults() - { - projectile.width = 100; - projectile.height = 100; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.magic = true; - projectile.tileCollide = false; - projectile.penetrate = 6; - projectile.extraUpdates = 6; - projectile.timeLeft = 151; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 6; - } + public override void SetDefaults() + { + projectile.width = 100; + projectile.height = 100; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.magic = true; + projectile.tileCollide = false; + projectile.penetrate = 6; + projectile.extraUpdates = 6; + projectile.timeLeft = 151; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0.6f, 0.5f, 0f); - if (projectile.timeLeft % 30 == 0) - { - int numProj = 3; - float randomSpread = Main.rand.NextFloat(3f, 18f); - float rotation = MathHelper.ToRadians(randomSpread); - if (projectile.owner == Main.myPlayer) - { - for (int i = -1; i < numProj - 1; i++) - { - Vector2 perturbedSpeed = projectile.velocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i)); - Projectile.NewProjectile(projectile.Center, perturbedSpeed, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, 0f, projectile.ai[1]); - } - } - } + public override void AI() + { + Lighting.AddLight(projectile.Center, 0.6f, 0.5f, 0f); + if (projectile.timeLeft % 30 == 0) + { + int numProj = 3; + float randomSpread = Main.rand.NextFloat(3f, 18f); + float rotation = MathHelper.ToRadians(randomSpread); + if (projectile.owner == Main.myPlayer) + { + for (int i = -1; i < numProj - 1; i++) + { + Vector2 perturbedSpeed = projectile.velocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i)); + Projectile.NewProjectile(projectile.Center, perturbedSpeed, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, 0f, projectile.ai[1]); + } + } + } projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; projectile.frameCounter++; if (projectile.frameCounter > 3) @@ -60,68 +60,68 @@ namespace CalamityMod.Projectiles.Magic { projectile.frame = 0; } - if (projectile.ai[0] > 4f && projectile.numUpdates % 2 == 0) - { - int dustType = 22; - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[idx]; - if (Main.rand.NextBool(2)) - { - dust.noGravity = true; - dust.scale *= 2f; - dust.velocity.X *= 3f; - dust.velocity.Y *= 3f; - } - else - { - dust.scale *= 1.25f; - } - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.5f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.1f; - } - dust.velocity.X *= 1.5f; - dust.velocity.Y *= 1.5f; - } - projectile.ai[0] += 1f; - projectile.rotation += 0.3f * (float)projectile.direction; - } + if (projectile.ai[0] > 4f && projectile.numUpdates % 2 == 0) + { + int dustType = 22; + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[idx]; + if (Main.rand.NextBool(2)) + { + dust.noGravity = true; + dust.scale *= 2f; + dust.velocity.X *= 3f; + dust.velocity.Y *= 3f; + } + else + { + dust.scale *= 1.25f; + } + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 1.5f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 1.1f; + } + dust.velocity.X *= 1.5f; + dust.velocity.Y *= 1.5f; + } + projectile.ai[0] += 1f; + projectile.rotation += 0.3f * (float)projectile.direction; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - // Dust effects - Circle dustCircle = new Circle(projectile.Center, projectile.width / 2); + // Dust effects + Circle dustCircle = new Circle(projectile.Center, projectile.width / 2); - for (int i = 0; i < 20; i++) - { - // Dust - Vector2 dustPos = dustCircle.RandomPointInCircle(); - if ((dustPos - projectile.Center).Length() > 48) - { - int dustIndex = Dust.NewDust(dustPos, 1, 1, 22); - Main.dust[dustIndex].noGravity = true; - Main.dust[dustIndex].fadeIn = 1f; - Vector2 dustVelocity = projectile.Center - Main.dust[dustIndex].position; - float distToCenter = dustVelocity.Length(); - dustVelocity.Normalize(); - dustVelocity = dustVelocity.RotatedBy(MathHelper.ToRadians(-90f)); - dustVelocity *= distToCenter * 0.04f; - Main.dust[dustIndex].velocity = dustVelocity; - } - } - return false; - } - } + for (int i = 0; i < 20; i++) + { + // Dust + Vector2 dustPos = dustCircle.RandomPointInCircle(); + if ((dustPos - projectile.Center).Length() > 48) + { + int dustIndex = Dust.NewDust(dustPos, 1, 1, 22); + Main.dust[dustIndex].noGravity = true; + Main.dust[dustIndex].fadeIn = 1f; + Vector2 dustVelocity = projectile.Center - Main.dust[dustIndex].position; + float distToCenter = dustVelocity.Length(); + dustVelocity.Normalize(); + dustVelocity = dustVelocity.RotatedBy(MathHelper.ToRadians(-90f)); + dustVelocity *= distToCenter * 0.04f; + Main.dust[dustIndex].velocity = dustVelocity; + } + } + return false; + } + } } diff --git a/Projectiles/Magic/Ancient2.cs b/Projectiles/Magic/Ancient2.cs index 1da2c20e4c..524683df69 100644 --- a/Projectiles/Magic/Ancient2.cs +++ b/Projectiles/Magic/Ancient2.cs @@ -6,34 +6,34 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class Ancient2 : ModProjectile - { + public class Ancient2 : ModProjectile + { public override string Texture => "CalamityMod/Projectiles/Magic/Ancient"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ancient"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ancient"); Main.projFrames[projectile.type] = 6; - } + } - public override void SetDefaults() - { - projectile.width = 50; - projectile.height = 50; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.magic = true; - projectile.penetrate = 4; - projectile.extraUpdates = 12; - projectile.timeLeft = 30; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 6; - projectile.scale = 0.5f; - } + public override void SetDefaults() + { + projectile.width = 50; + projectile.height = 50; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.magic = true; + projectile.penetrate = 4; + projectile.extraUpdates = 12; + projectile.timeLeft = 30; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + projectile.scale = 0.5f; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0.3f, 0.25f, 0f); + public override void AI() + { + Lighting.AddLight(projectile.Center, 0.3f, 0.25f, 0f); projectile.frameCounter++; if (projectile.frameCounter > 3) { @@ -45,78 +45,78 @@ namespace CalamityMod.Projectiles.Magic projectile.frame = 0; } projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; - if (projectile.ai[0] > 7f && projectile.numUpdates % 2 == 0) - { - int dustType = 22; - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[idx]; - if (Main.rand.NextBool(2)) - { - dust.noGravity = true; - dust.scale *= 2f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.25f; - } - dust.velocity.X *= 3f; - dust.velocity.Y *= 3f; - idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 2.5f; - dust.velocity.X *= 1.5f; - dust.velocity.Y *= 1.5f; - } - else - { - dust.scale *= 1.5f; - } - dust.velocity.X *= 1.1f; - dust.velocity.Y *= 1.1f; - } - projectile.ai[0] += 1f; - projectile.rotation += 0.3f * (float)projectile.direction; - } + if (projectile.ai[0] > 7f && projectile.numUpdates % 2 == 0) + { + int dustType = 22; + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[idx]; + if (Main.rand.NextBool(2)) + { + dust.noGravity = true; + dust.scale *= 2f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 1.25f; + } + dust.velocity.X *= 3f; + dust.velocity.Y *= 3f; + idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 2.5f; + dust.velocity.X *= 1.5f; + dust.velocity.Y *= 1.5f; + } + else + { + dust.scale *= 1.5f; + } + dust.velocity.X *= 1.1f; + dust.velocity.Y *= 1.1f; + } + projectile.ai[0] += 1f; + projectile.rotation += 0.3f * (float)projectile.direction; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - int height = texture.Height / Main.projFrames[projectile.type]; - int frameHeight = height * projectile.frame; - Rectangle rectangle = new Rectangle(0, frameHeight, texture.Width, height); - Vector2 origin = new Vector2(texture.Width / 2f, height / 2f); - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + int height = texture.Height / Main.projFrames[projectile.type]; + int frameHeight = height * projectile.frame; + Rectangle rectangle = new Rectangle(0, frameHeight, texture.Width, height); + Vector2 origin = new Vector2(texture.Width / 2f, height / 2f); + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - // Dust effects - Circle dustCircle = new Circle(projectile.Center, projectile.width / 2); + // Dust effects + Circle dustCircle = new Circle(projectile.Center, projectile.width / 2); - for (int i = 0; i < 20; i++) - { - // Dust - Vector2 dustPos = dustCircle.RandomPointInCircle(); - if ((dustPos - projectile.Center).Length() > 48) - { - int dustIndex = Dust.NewDust(dustPos, 1, 1, 22); - Main.dust[dustIndex].noGravity = true; - Main.dust[dustIndex].fadeIn = 1f; - Vector2 dustVelocity = projectile.Center - Main.dust[dustIndex].position; - float distToCenter = dustVelocity.Length(); - dustVelocity.Normalize(); - dustVelocity = dustVelocity.RotatedBy(MathHelper.ToRadians(-90f)); - dustVelocity *= distToCenter * 0.04f; - Main.dust[dustIndex].velocity = dustVelocity; - } - } - return false; - } - } + for (int i = 0; i < 20; i++) + { + // Dust + Vector2 dustPos = dustCircle.RandomPointInCircle(); + if ((dustPos - projectile.Center).Length() > 48) + { + int dustIndex = Dust.NewDust(dustPos, 1, 1, 22); + Main.dust[dustIndex].noGravity = true; + Main.dust[dustIndex].fadeIn = 1f; + Vector2 dustVelocity = projectile.Center - Main.dust[dustIndex].position; + float distToCenter = dustVelocity.Length(); + dustVelocity.Normalize(); + dustVelocity = dustVelocity.RotatedBy(MathHelper.ToRadians(-90f)); + dustVelocity *= distToCenter * 0.04f; + Main.dust[dustIndex].velocity = dustVelocity; + } + } + return false; + } + } } diff --git a/Projectiles/Magic/ApotheosisEnergy.cs b/Projectiles/Magic/ApotheosisEnergy.cs index e5ddffec0c..9fcd4318e3 100644 --- a/Projectiles/Magic/ApotheosisEnergy.cs +++ b/Projectiles/Magic/ApotheosisEnergy.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class ApotheosisEnergy : ModProjectile + public class ApotheosisEnergy : ModProjectile { internal PrimitiveTrail TrailDrawer = null; diff --git a/Projectiles/Magic/AquamarineBolt.cs b/Projectiles/Magic/AquamarineBolt.cs index 99fb0719c4..19ff595c7a 100644 --- a/Projectiles/Magic/AquamarineBolt.cs +++ b/Projectiles/Magic/AquamarineBolt.cs @@ -27,11 +27,11 @@ 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); - 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; + 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; diff --git a/Projectiles/Magic/ArcticBearPawProj.cs b/Projectiles/Magic/ArcticBearPawProj.cs index c2bf591c1c..2a872a9904 100644 --- a/Projectiles/Magic/ArcticBearPawProj.cs +++ b/Projectiles/Magic/ArcticBearPawProj.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = 5; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.coldDamage = true; + projectile.coldDamage = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } diff --git a/Projectiles/Magic/AstralStarMagic.cs b/Projectiles/Magic/AstralStarMagic.cs index 8019b4635c..f7646a71bb 100644 --- a/Projectiles/Magic/AstralStarMagic.cs +++ b/Projectiles/Magic/AstralStarMagic.cs @@ -31,8 +31,8 @@ namespace CalamityMod.Projectiles.Magic projectile.alpha = 50; projectile.penetrate = 1; projectile.tileCollide = false; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/AstralachneaFang.cs b/Projectiles/Magic/AstralachneaFang.cs index 3f76a6f4a7..63e2891def 100644 --- a/Projectiles/Magic/AstralachneaFang.cs +++ b/Projectiles/Magic/AstralachneaFang.cs @@ -7,54 +7,54 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class AstralachneaFang : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Fang"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public class AstralachneaFang : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fang"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.magic = true; - projectile.timeLeft = 240; - } + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.magic = true; + projectile.timeLeft = 240; + } - public override void AI() - { - int astral = Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1f); - Main.dust[astral].noGravity = true; + public override void AI() + { + int astral = Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType(), 0f, 0f, 100, default, 1f); + Main.dust[astral].noGravity = true; - projectile.rotation = projectile.velocity.ToRotation(); + projectile.rotation = projectile.velocity.ToRotation(); - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 25f); - } + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 25f); + } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item10, projectile.position); - for (int k = 0; k < 3; k++) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, ModContent.DustType(), 0f, 0f); - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, ModContent.DustType(), 0f, 0f); - } - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item10, projectile.position); + for (int k = 0; k < 3; k++) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, ModContent.DustType(), 0f, 0f); + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, ModContent.DustType(), 0f, 0f); + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Magic/AtlantisSpear.cs b/Projectiles/Magic/AtlantisSpear.cs index 417aab221b..ccb523b612 100644 --- a/Projectiles/Magic/AtlantisSpear.cs +++ b/Projectiles/Magic/AtlantisSpear.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Magic projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.magic = true; + projectile.ignoreWater = true; + projectile.magic = true; aiType = ProjectileID.CrystalVileShardHead; } diff --git a/Projectiles/Magic/AtlantisSpear2.cs b/Projectiles/Magic/AtlantisSpear2.cs index 7db196bcd0..8b5fdac034 100644 --- a/Projectiles/Magic/AtlantisSpear2.cs +++ b/Projectiles/Magic/AtlantisSpear2.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Projectiles.Magic { public class AtlantisSpear2 : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/Magic/AtlantisSpear"; + public override string Texture => "CalamityMod/Projectiles/Magic/AtlantisSpear"; public override void SetStaticDefaults() { @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Magic projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.magic = true; + projectile.ignoreWater = true; + projectile.magic = true; aiType = ProjectileID.CrystalVileShardShaft; } diff --git a/Projectiles/Magic/AuroraAustralis.cs b/Projectiles/Magic/AuroraAustralis.cs index 74852ff6a9..1159e9a93d 100644 --- a/Projectiles/Magic/AuroraAustralis.cs +++ b/Projectiles/Magic/AuroraAustralis.cs @@ -6,109 +6,109 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class AuroraAustralis : ModProjectile - { + public class AuroraAustralis : ModProjectile + { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private static float CosFrequency = 0.05f; - private static float CosAmplitude = 0.008f; - public int[] dustTypes = new int[] - { - ModContent.DustType(), - ModContent.DustType() - }; + private static float CosFrequency = 0.05f; + private static float CosAmplitude = 0.008f; + public int[] dustTypes = new int[] + { + ModContent.DustType(), + ModContent.DustType() + }; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Aurora Australis"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Aurora Australis"); + } - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 300; - projectile.magic = true; - projectile.alpha = 255; + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 300; + projectile.magic = true; + projectile.alpha = 255; - CosFrequency = 0.15f; - CosAmplitude = 0.06f; - } + CosFrequency = 0.15f; + CosAmplitude = 0.06f; + } - public override void AI() - { - // On-spawn effects - if (projectile.ai[0] == 0) - { - // Store the X and Y of the spawn velocity so it can be used for trig calculations - projectile.localAI[0] = projectile.velocity.X; - projectile.localAI[1] = projectile.velocity.Y; - } + public override void AI() + { + // On-spawn effects + if (projectile.ai[0] == 0) + { + // Store the X and Y of the spawn velocity so it can be used for trig calculations + projectile.localAI[0] = projectile.velocity.X; + projectile.localAI[1] = projectile.velocity.Y; + } - // Doesn't collide with tiles for the first 2 frames - projectile.tileCollide = projectile.ai[0] > 2f; + // Doesn't collide with tiles for the first 2 frames + projectile.tileCollide = projectile.ai[0] > 2f; - // Apply fancy cosine movement, then slight gravity, then cap velocity. - // Original velocity is reconstructed so that it can be used in the calculation - Vector2 originalVelocity = new Vector2(projectile.localAI[0], projectile.localAI[1]); - ApplyCosVelocity(originalVelocity); - float currentSpeed = projectile.velocity.Length(); - float maxSpeed = 1.4f * originalVelocity.Length(); - if (currentSpeed > maxSpeed) - projectile.velocity *= maxSpeed / currentSpeed; + // Apply fancy cosine movement, then slight gravity, then cap velocity. + // Original velocity is reconstructed so that it can be used in the calculation + Vector2 originalVelocity = new Vector2(projectile.localAI[0], projectile.localAI[1]); + ApplyCosVelocity(originalVelocity); + float currentSpeed = projectile.velocity.Length(); + float maxSpeed = 1.4f * originalVelocity.Length(); + if (currentSpeed > maxSpeed) + projectile.velocity *= maxSpeed / currentSpeed; - // spawn dust - if (Main.rand.NextBool(5)) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.Next(dustTypes), projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } - int rainbow = Dust.NewDust(projectile.Center, projectile.width, projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Dust dust = Main.dust[rainbow]; - dust.velocity *= 0.1f; - dust.velocity += projectile.velocity * 0.2f; - dust.position.X = projectile.Center.X + 4f + Main.rand.Next(-2, 3); - dust.position.Y = projectile.Center.Y + Main.rand.Next(-2, 3); - dust.noGravity = true; + // spawn dust + if (Main.rand.NextBool(5)) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.Next(dustTypes), projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } + int rainbow = Dust.NewDust(projectile.Center, projectile.width, projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Dust dust = Main.dust[rainbow]; + dust.velocity *= 0.1f; + dust.velocity += projectile.velocity * 0.2f; + dust.position.X = projectile.Center.X + 4f + Main.rand.Next(-2, 3); + dust.position.Y = projectile.Center.Y + Main.rand.Next(-2, 3); + dust.noGravity = true; - if (projectile.timeLeft % 10 == 0 && Main.myPlayer == projectile.owner) //spawn stars every 10 ticks - { - if (Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] < 30) - { - float dmgKBMult = Main.rand.NextFloat(0.25f, 0.75f); - Projectile star = CalamityUtils.ProjectileRain(projectile.Center, projectile.velocity.X, 100f, 500f, 800f, Main.rand.NextFloat(10f, 20f), ModContent.ProjectileType(), (int)(projectile.damage * dmgKBMult), projectile.knockBack * dmgKBMult, projectile.owner); - star.timeLeft = 120; - } - } + if (projectile.timeLeft % 10 == 0 && Main.myPlayer == projectile.owner) //spawn stars every 10 ticks + { + if (Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] < 30) + { + float dmgKBMult = Main.rand.NextFloat(0.25f, 0.75f); + Projectile star = CalamityUtils.ProjectileRain(projectile.Center, projectile.velocity.X, 100f, 500f, 800f, Main.rand.NextFloat(10f, 20f), ModContent.ProjectileType(), (int)(projectile.damage * dmgKBMult), projectile.knockBack * dmgKBMult, projectile.owner); + star.timeLeft = 120; + } + } - projectile.ai[0]++; - } + projectile.ai[0]++; + } - private void ApplyCosVelocity(Vector2 baseVelocity) - { - float radians = -(-MathHelper.PiOver2 + CosFrequency * projectile.ai[0]); - projectile.velocity += CosAmplitude * baseVelocity.RotatedBy(radians); - } + private void ApplyCosVelocity(Vector2 baseVelocity) + { + float radians = -(-MathHelper.PiOver2 + CosFrequency * projectile.ai[0]); + projectile.velocity += CosAmplitude * baseVelocity.RotatedBy(radians); + } - public override void Kill(int timeLeft) - { - for (int i = 0; i <= 5; i++) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.Next(dustTypes), projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); - } - } + public override void Kill(int timeLeft) + { + for (int i = 0; i <= 5; i++) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.Next(dustTypes), projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } + } } diff --git a/Projectiles/Magic/BeamStar.cs b/Projectiles/Magic/BeamStar.cs index 08746a6162..0dcac1aa6e 100644 --- a/Projectiles/Magic/BeamStar.cs +++ b/Projectiles/Magic/BeamStar.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Magic NPC potentialTarget = projectile.Center.ClosestNPCAt(800f, false); if (potentialTarget != null) { - float destinationDeltaAngle = MathHelper.WrapAngle(projectile.AngleTo(potentialTarget.Center) - projectile.velocity.ToRotation()); + float destinationDeltaAngle = MathHelper.WrapAngle(projectile.AngleTo(potentialTarget.Center) - projectile.velocity.ToRotation()); // If the angle is <0, meaning it's to the left, the sine will return a negative number, // and a positive number if >0, because WrapAngle constricts to angle to a bound of @@ -73,11 +73,11 @@ namespace CalamityMod.Projectiles.Magic Vector2 drawPosition; Texture2D starTexture = Main.projectileTexture[projectile.type]; for (int i = 1; i < projectile.oldPos.Length; i++) - { + { float scale = projectile.scale * MathHelper.Lerp(0.9f, 0.6f, i / (float)projectile.oldPos.Length) * 0.56f; drawPosition = projectile.oldPos[i] + projectile.Size * 0.5f - Main.screenPosition; spriteBatch.Draw(starTexture, drawPosition, null, Color.White, 0f, starTexture.Size() * 0.5f, scale, SpriteEffects.None, 0f); - } + } drawPosition = projectile.Center - Main.screenPosition; spriteBatch.Draw(starTexture, drawPosition, null, Color.White, 0f, starTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); diff --git a/Projectiles/Magic/BeamingBolt.cs b/Projectiles/Magic/BeamingBolt.cs index 38ad3ba37f..854dc8274f 100644 --- a/Projectiles/Magic/BeamingBolt.cs +++ b/Projectiles/Magic/BeamingBolt.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D tex = Main.projectileTexture[projectile.type]; - if (projectile.ai[0] == 1f) - tex = ModContent.GetTexture("CalamityMod/Projectiles/Magic/BeamingThornBlossom"); + if (projectile.ai[0] == 1f) + tex = ModContent.GetTexture("CalamityMod/Projectiles/Magic/BeamingThornBlossom"); spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); return false; @@ -39,12 +39,12 @@ namespace CalamityMod.Projectiles.Magic projectile.velocity.Y *= 0.985f; for (int dust = 0; dust < 2; dust++) { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 164, - 58, - 204 - }); + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 164, + 58, + 204 + }); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } } @@ -53,12 +53,12 @@ namespace CalamityMod.Projectiles.Magic { for (int k = 0; k < 6; k++) { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 164, - 58, - 204 - }); + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 164, + 58, + 204 + }); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } float spread = 90f * 0.0174f; diff --git a/Projectiles/Magic/BeamingBolt2.cs b/Projectiles/Magic/BeamingBolt2.cs index c5fd72da18..048bf84368 100644 --- a/Projectiles/Magic/BeamingBolt2.cs +++ b/Projectiles/Magic/BeamingBolt2.cs @@ -22,13 +22,13 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D tex = Main.projectileTexture[projectile.type]; - if (projectile.ai[0] == 1f) - tex = ModContent.GetTexture("CalamityMod/Projectiles/Magic/BeamingThorn"); + if (projectile.ai[0] == 1f) + tex = ModContent.GetTexture("CalamityMod/Projectiles/Magic/BeamingThorn"); spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); return false; @@ -37,28 +37,28 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 164, - 58, - 204 - }); - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 164, + 58, + 204 + }); + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); + if (projectile.timeLeft < 90) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } public override void Kill(int timeLeft) { for (int k = 0; k < 3; k++) { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 164, - 58, - 204 - }); + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 164, + 58, + 204 + }); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } } diff --git a/Projectiles/Magic/BeastScythe.cs b/Projectiles/Magic/BeastScythe.cs index 1168113d9c..1ea68ef780 100644 --- a/Projectiles/Magic/BeastScythe.cs +++ b/Projectiles/Magic/BeastScythe.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class BeastScythe : ModProjectile + public class BeastScythe : ModProjectile { public override void SetStaticDefaults() { @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = 1; projectile.timeLeft = 600; projectile.magic = true; - projectile.extraUpdates = 1; - projectile.tileCollide = false; + projectile.extraUpdates = 1; + projectile.tileCollide = false; } public override void AI() @@ -52,10 +52,10 @@ namespace CalamityMod.Projectiles.Magic } projectile.ai[0] += 1f; - if (projectile.ai[0] <= 30f) - { - projectile.velocity *= 0.999f; - } + if (projectile.ai[0] <= 30f) + { + projectile.velocity *= 0.999f; + } if (Main.myPlayer == projectile.owner && projectile.ai[0] == 30f) { if (Main.player[projectile.owner].channel) @@ -126,29 +126,29 @@ namespace CalamityMod.Projectiles.Magic projectile.velocity.Y = num129; } } - if (projectile.ai[0] >= 30f) - { - projectile.velocity *= 1.001f; + if (projectile.ai[0] >= 30f) + { + projectile.velocity *= 1.001f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); - } + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.OnFire, 180); - if (Main.rand.NextBool(3)) - { - target.AddBuff(BuffID.ShadowFlame, 90); - } - else if (Main.rand.NextBool(2)) - { - target.AddBuff(ModContent.BuffType(), 120); - } - else - { - target.AddBuff(BuffID.Frostburn, 150); - } + if (Main.rand.NextBool(3)) + { + target.AddBuff(BuffID.ShadowFlame, 90); + } + else if (Main.rand.NextBool(2)) + { + target.AddBuff(ModContent.BuffType(), 120); + } + else + { + target.AddBuff(BuffID.Frostburn, 150); + } } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/BigBeamofDeath.cs b/Projectiles/Magic/BigBeamofDeath.cs index 59b9c68b3d..cc9b509f71 100644 --- a/Projectiles/Magic/BigBeamofDeath.cs +++ b/Projectiles/Magic/BigBeamofDeath.cs @@ -43,14 +43,14 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 9f) - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 206, 0f, 0f, 0, default, 3f); - Main.dust[num448].position = vector33; - Main.dust[num448].velocity *= 0.1f; - } + if (projectile.localAI[0] > 9f) + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * 0.25f; + int num448 = Dust.NewDust(vector33, 1, 1, 206, 0f, 0f, 0, default, 3f); + Main.dust[num448].position = vector33; + Main.dust[num448].velocity *= 0.1f; + } } } } diff --git a/Projectiles/Magic/BigBeamofDeath2.cs b/Projectiles/Magic/BigBeamofDeath2.cs index 846979c023..f2bc155eac 100644 --- a/Projectiles/Magic/BigBeamofDeath2.cs +++ b/Projectiles/Magic/BigBeamofDeath2.cs @@ -26,13 +26,13 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = 80; } - public override void AI() - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 206, 0f, 0f, 0, default, 3f); - Main.dust[num448].position = vector33; - Main.dust[num448].velocity *= 0.1f; - } + public override void AI() + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * 0.25f; + int num448 = Dust.NewDust(vector33, 1, 1, 206, 0f, 0f, 0, default, 3f); + Main.dust[num448].position = vector33; + Main.dust[num448].velocity *= 0.1f; + } } } diff --git a/Projectiles/Magic/BloodRay.cs b/Projectiles/Magic/BloodRay.cs index e28a0cdd0a..2fb86fb15e 100644 --- a/Projectiles/Magic/BloodRay.cs +++ b/Projectiles/Magic/BloodRay.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; - projectile.ignoreWater = true; - projectile.penetrate = 10; + projectile.ignoreWater = true; + projectile.penetrate = 10; projectile.extraUpdates = 100; projectile.timeLeft = Lifetime; } @@ -36,10 +36,10 @@ namespace CalamityMod.Projectiles.Magic // The exponential base would be too small for a weapon like this, and the // cast (which removes the fractional part) would overtake any increases before the damage can rise. if (InitialDamage == 0f) - { + { InitialDamage = projectile.damage; projectile.netUpdate = true; - } + } Time++; projectile.damage = (int)(InitialDamage * Math.Pow(ExponentialDamageBoost, Time)); diff --git a/Projectiles/Magic/BlueBubble.cs b/Projectiles/Magic/BlueBubble.cs index 8e62069c6d..16697b8ef8 100644 --- a/Projectiles/Magic/BlueBubble.cs +++ b/Projectiles/Magic/BlueBubble.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Magic { - public class BlueBubble : ModProjectile + public class BlueBubble : ModProjectile { public override void SetStaticDefaults() { @@ -22,12 +22,12 @@ namespace CalamityMod.Projectiles.Magic projectile.alpha = 255; projectile.ignoreWater = true; projectile.magic = true; - projectile.timeLeft = 120; - } + projectile.timeLeft = 120; + } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.velocity *= 0.99f; @@ -45,12 +45,12 @@ namespace CalamityMod.Projectiles.Magic if (num745 > MathHelper.Pi) num745 -= MathHelper.TwoPi; if (num745 < -MathHelper.Pi) - num745 += MathHelper.TwoPi; + num745 += MathHelper.TwoPi; projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; - if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 400f, 8f, 20f); + if (projectile.timeLeft < 90) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 400f, 8f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/BlushieStaffProj.cs b/Projectiles/Magic/BlushieStaffProj.cs index 4584a1e29a..a9bbf8042a 100644 --- a/Projectiles/Magic/BlushieStaffProj.cs +++ b/Projectiles/Magic/BlushieStaffProj.cs @@ -26,9 +26,9 @@ namespace CalamityMod.Projectiles.Magic projectile.tileCollide = false; projectile.ignoreWater = true; projectile.magic = true; - projectile.Calamity().PierceResistHarshness = 0.06f; - projectile.Calamity().PierceResistCap = 0.4f; - } + projectile.Calamity().PierceResistHarshness = 0.06f; + projectile.Calamity().PierceResistCap = 0.4f; + } public override void AI() { diff --git a/Projectiles/Magic/BrimstoneBeam.cs b/Projectiles/Magic/BrimstoneBeam.cs index 6a2f24ef45..6b3963fc4b 100644 --- a/Projectiles/Magic/BrimstoneBeam.cs +++ b/Projectiles/Magic/BrimstoneBeam.cs @@ -38,21 +38,21 @@ namespace CalamityMod.Projectiles.Magic } } - public override void AI() - { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 9f) - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity; - projectile.alpha = 255; - int num249 = 235; - int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 1.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].velocity *= 0.1f; - Main.dust[num448].noGravity = true; - } - } + public override void AI() + { + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 9f) + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity; + projectile.alpha = 255; + int num249 = 235; + int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 1.5f); + Main.dust[num448].position = vector33; + Main.dust[num448].velocity *= 0.1f; + Main.dust[num448].noGravity = true; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Magic/BrimstoneBeam2.cs b/Projectiles/Magic/BrimstoneBeam2.cs index 535a84f19e..eb12f4a7c9 100644 --- a/Projectiles/Magic/BrimstoneBeam2.cs +++ b/Projectiles/Magic/BrimstoneBeam2.cs @@ -38,17 +38,17 @@ namespace CalamityMod.Projectiles.Magic } } - public override void AI() - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity; - projectile.alpha = 255; - int num249 = 235; - int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 1.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].velocity *= 0.1f; - Main.dust[num448].noGravity = true; - } + public override void AI() + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity; + projectile.alpha = 255; + int num249 = 235; + int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 1.5f); + Main.dust[num448].position = vector33; + Main.dust[num448].velocity *= 0.1f; + Main.dust[num448].noGravity = true; + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Magic/BrimstoneBeam3.cs b/Projectiles/Magic/BrimstoneBeam3.cs index 9fb0419746..8beb89fee4 100644 --- a/Projectiles/Magic/BrimstoneBeam3.cs +++ b/Projectiles/Magic/BrimstoneBeam3.cs @@ -38,17 +38,17 @@ namespace CalamityMod.Projectiles.Magic } } - public override void AI() - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity; - projectile.alpha = 255; - int num249 = 235; - int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 1.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].velocity *= 0.1f; - Main.dust[num448].noGravity = true; - } + public override void AI() + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity; + projectile.alpha = 255; + int num249 = 235; + int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 1.5f); + Main.dust[num448].position = vector33; + Main.dust[num448].velocity *= 0.1f; + Main.dust[num448].noGravity = true; + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Magic/BrimstoneBeam4.cs b/Projectiles/Magic/BrimstoneBeam4.cs index 844fc123c3..ba4bb7c661 100644 --- a/Projectiles/Magic/BrimstoneBeam4.cs +++ b/Projectiles/Magic/BrimstoneBeam4.cs @@ -38,17 +38,17 @@ namespace CalamityMod.Projectiles.Magic } } - public override void AI() - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity; - projectile.alpha = 255; - int num249 = 235; - int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 1.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].velocity *= 0.1f; - Main.dust[num448].noGravity = true; - } + public override void AI() + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity; + projectile.alpha = 255; + int num249 = 235; + int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 1.5f); + Main.dust[num448].position = vector33; + Main.dust[num448].velocity *= 0.1f; + Main.dust[num448].noGravity = true; + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Magic/BrimstoneBeam5.cs b/Projectiles/Magic/BrimstoneBeam5.cs index b6d4bb5db7..d13b28b041 100644 --- a/Projectiles/Magic/BrimstoneBeam5.cs +++ b/Projectiles/Magic/BrimstoneBeam5.cs @@ -24,17 +24,17 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = 30; } - public override void AI() - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity; - projectile.alpha = 255; - int num249 = 235; - int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 1.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].velocity *= 0.1f; - Main.dust[num448].noGravity = true; - } + public override void AI() + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity; + projectile.alpha = 255; + int num249 = 235; + int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 1.5f); + Main.dust[num448].position = vector33; + Main.dust[num448].velocity *= 0.1f; + Main.dust[num448].noGravity = true; + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Magic/BrimstoneFireball.cs b/Projectiles/Magic/BrimstoneFireball.cs index 61eab1f49a..b955cbed8a 100644 --- a/Projectiles/Magic/BrimstoneFireball.cs +++ b/Projectiles/Magic/BrimstoneFireball.cs @@ -52,29 +52,29 @@ namespace CalamityMod.Projectiles.Magic projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f) { - int brimstone = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[brimstone].noGravity = true; - Main.dust[brimstone].velocity *= 0f; + int brimstone = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimstone].noGravity = true; + Main.dust[brimstone].velocity *= 0f; } - projectile.ai[0] += 1f; - if (projectile.ai[0] > 5f) - { - projectile.ai[0] = 5f; - if (projectile.velocity.Y == 0.0 && projectile.velocity.X != 0.0) - { - projectile.velocity.X *= 0.97f; - if (projectile.velocity.X > -0.01f && projectile.velocity.X < 0.01f) - { - projectile.velocity.X = 0f; - projectile.netUpdate = true; - } - } - projectile.velocity.Y += 0.2f; - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.1f * projectile.direction; - } - if (projectile.velocity.Y <= 16f) - return; - projectile.velocity.Y = 16f; + projectile.ai[0] += 1f; + if (projectile.ai[0] > 5f) + { + projectile.ai[0] = 5f; + if (projectile.velocity.Y == 0.0 && projectile.velocity.X != 0.0) + { + projectile.velocity.X *= 0.97f; + if (projectile.velocity.X > -0.01f && projectile.velocity.X < 0.01f) + { + projectile.velocity.X = 0f; + projectile.netUpdate = true; + } + } + projectile.velocity.Y += 0.2f; + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.1f * projectile.direction; + } + if (projectile.velocity.Y <= 16f) + return; + projectile.velocity.Y = 16f; } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Magic/BrimstoneHellfireballFriendly.cs b/Projectiles/Magic/BrimstoneHellfireballFriendly.cs index 58c5d36774..a8a9c52fda 100644 --- a/Projectiles/Magic/BrimstoneHellfireballFriendly.cs +++ b/Projectiles/Magic/BrimstoneHellfireballFriendly.cs @@ -53,8 +53,8 @@ namespace CalamityMod.Projectiles.Magic if (projectile.alpha < 5) projectile.alpha = 5; - //Rotation - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + //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); diff --git a/Projectiles/Magic/BrimstoneHomer.cs b/Projectiles/Magic/BrimstoneHomer.cs index 22f7fd7817..c4e3a8bb29 100644 --- a/Projectiles/Magic/BrimstoneHomer.cs +++ b/Projectiles/Magic/BrimstoneHomer.cs @@ -5,7 +5,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class BrimstoneHomer : ModProjectile + public class BrimstoneHomer : ModProjectile { public override void SetStaticDefaults() { @@ -24,17 +24,17 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.rotation += 0.7f * projectile.direction; - int brimstone = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Main.dust[brimstone].noGravity = true; + int brimstone = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + Main.dust[brimstone].noGravity = true; - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 8f, 20f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 8f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Magic/BrimstoneTentacle.cs b/Projectiles/Magic/BrimstoneTentacle.cs index e451e5b5ef..269066d555 100644 --- a/Projectiles/Magic/BrimstoneTentacle.cs +++ b/Projectiles/Magic/BrimstoneTentacle.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - projectile.localAI[1]++; + projectile.localAI[1]++; if (projectile.velocity.X != projectile.velocity.X) { if (Math.Abs(projectile.velocity.X) < 1f) diff --git a/Projectiles/Magic/ClamorNoctusStar.cs b/Projectiles/Magic/ClamorNoctusStar.cs index 4b81df408c..665c220cb7 100644 --- a/Projectiles/Magic/ClamorNoctusStar.cs +++ b/Projectiles/Magic/ClamorNoctusStar.cs @@ -7,7 +7,7 @@ using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Magic { - public class ClamorNoctusStar : ModProjectile + public class ClamorNoctusStar : ModProjectile { public override void SetStaticDefaults() { @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; projectile.aiStyle = 93; aiType = ProjectileID.NailFriendly; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } diff --git a/Projectiles/Magic/ClamorNoctusWyvern.cs b/Projectiles/Magic/ClamorNoctusWyvern.cs index a71be34eb8..a7b10636ea 100644 --- a/Projectiles/Magic/ClamorNoctusWyvern.cs +++ b/Projectiles/Magic/ClamorNoctusWyvern.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Magic projectile.alpha = 255; projectile.magic = true; projectile.aiStyle = 93; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() @@ -37,10 +37,10 @@ namespace CalamityMod.Projectiles.Magic { if (projectile.owner == Main.myPlayer) { - projectile.timeLeft = 0; - } - return false; - } + projectile.timeLeft = 0; + } + return false; + } public override void Kill(int timeLeft) { @@ -49,12 +49,12 @@ namespace CalamityMod.Projectiles.Magic { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 126, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } - int head = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/ClamorNoctusHead")); - Main.gore[head].timeLeft /= 10; - int body = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/ClamorNoctusBody")); - Main.gore[body].timeLeft /= 10; - int tail = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/ClamorNoctusTail")); - Main.gore[tail].timeLeft /= 10; + int head = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/ClamorNoctusHead")); + Main.gore[head].timeLeft /= 10; + int body = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/ClamorNoctusBody")); + Main.gore[body].timeLeft /= 10; + int tail = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/ClamorNoctusTail")); + Main.gore[tail].timeLeft /= 10; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Magic/CosmicTentacle.cs b/Projectiles/Magic/CosmicTentacle.cs index 2cb513bdf2..5f892d65ac 100644 --- a/Projectiles/Magic/CosmicTentacle.cs +++ b/Projectiles/Magic/CosmicTentacle.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class CosmicTentacle : ModProjectile + public class CosmicTentacle : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - projectile.localAI[1]++; + projectile.localAI[1]++; if (projectile.velocity.X != projectile.velocity.X) { if (Math.Abs(projectile.velocity.X) < 1f) diff --git a/Projectiles/Magic/Crescent.cs b/Projectiles/Magic/Crescent.cs index 5205767607..d453a2f80f 100644 --- a/Projectiles/Magic/Crescent.cs +++ b/Projectiles/Magic/Crescent.cs @@ -5,30 +5,30 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Projectiles.Magic { - public class Crescent : ModProjectile - { - public override void SetStaticDefaults() - { + public class Crescent : ModProjectile + { + public override void SetStaticDefaults() + { DisplayName.SetDefault("Crescent Cutter"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.friendly = true; - projectile.timeLeft = 200; - projectile.aiStyle = 0; - projectile.width = 20; - projectile.height = 20; - projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.knockBack = 0; + public override void SetDefaults() + { + projectile.friendly = true; + projectile.timeLeft = 200; + projectile.aiStyle = 0; + projectile.width = 20; + projectile.height = 20; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.knockBack = 0; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.magic = true; - } + projectile.magic = true; + } public override Color? GetAlpha(Color lightColor) { @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Magic { Projectile parent = Main.projectile[(int)projectile.ai[0]]; if (!parent.active) - projectile.Kill(); + projectile.Kill(); projectile.rotation += 0.7f; @@ -48,8 +48,8 @@ namespace CalamityMod.Projectiles.Magic if (projectile.ai[1] > 20) { projectile.velocity += projectile.SafeDirectionTo(parent.Center) * 2.5f; - if (projectile.WithinRange(parent.Center, 75f)) - projectile.Kill(); + if (projectile.WithinRange(parent.Center, 75f)) + projectile.Kill(); } } } diff --git a/Projectiles/Magic/CryoBlast.cs b/Projectiles/Magic/CryoBlast.cs index 2b8161aed5..d9e8af2c2f 100644 --- a/Projectiles/Magic/CryoBlast.cs +++ b/Projectiles/Magic/CryoBlast.cs @@ -8,9 +8,9 @@ namespace CalamityMod.Projectiles.Magic { public class CryoBlast : ModProjectile { - private const float Spread = 0.15f; + private const float Spread = 0.15f; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Blast"); Main.projFrames[projectile.type] = 4; @@ -23,9 +23,9 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; projectile.penetrate = 3; projectile.timeLeft = 90; - projectile.coldDamage = true; - projectile.ignoreWater = true; - projectile.alpha = 255; + projectile.coldDamage = true; + projectile.ignoreWater = true; + projectile.alpha = 255; } public override void AI() @@ -33,21 +33,21 @@ namespace CalamityMod.Projectiles.Magic if (projectile.scale <= 2.5f) { projectile.scale *= 1.02f; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(35f * projectile.scale)); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(35f * projectile.scale)); } - else if (projectile.ai[0] < 2f) - { - projectile.ai[0] += 1f; + else if (projectile.ai[0] < 2f) + { + projectile.ai[0] += 1f; - // Fire extra waves to the left and right - for (int i = 0; i < 2; i++) - { - Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(-Spread * (i + 1)), projectile.type, projectile.damage / 2, projectile.knockBack, projectile.owner, projectile.ai[0], 0f); - Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(+Spread * (i + 1)), projectile.type, projectile.damage / 2, projectile.knockBack, projectile.owner, projectile.ai[0], 0f); - } + // Fire extra waves to the left and right + for (int i = 0; i < 2; i++) + { + Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(-Spread * (i + 1)), projectile.type, projectile.damage / 2, projectile.knockBack, projectile.owner, projectile.ai[0], 0f); + Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(+Spread * (i + 1)), projectile.type, projectile.damage / 2, projectile.knockBack, projectile.owner, projectile.ai[0], 0f); + } - projectile.Kill(); - } + projectile.Kill(); + } projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); @@ -66,61 +66,61 @@ namespace CalamityMod.Projectiles.Magic projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f || projectile.ai[0] > 0f) { - int ice = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, 0f, 0f, 100, default, projectile.scale * 0.5f); - Main.dust[ice].noGravity = true; - Main.dust[ice].velocity *= 0f; - int snow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 185, 0f, 0f, 100, default, projectile.scale * 0.5f); - Main.dust[snow].noGravity = true; - Main.dust[snow].velocity *= 0f; + int ice = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, 0f, 0f, 100, default, projectile.scale * 0.5f); + Main.dust[ice].noGravity = true; + Main.dust[ice].velocity *= 0f; + int snow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 185, 0f, 0f, 100, default, projectile.scale * 0.5f); + Main.dust[snow].noGravity = true; + Main.dust[snow].velocity *= 0f; } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if ((projectile.timeLeft > 596 && projectile.ai[0] == 0f) || (projectile.timeLeft > 599 && projectile.ai[0] > 0f)) - return false; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if ((projectile.timeLeft > 596 && projectile.ai[0] == 0f) || (projectile.timeLeft > 599 && projectile.ai[0] > 0f)) + return false; - Texture2D texture = Main.projectileTexture[projectile.type]; - Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - int height = texture.Height / Main.projFrames[projectile.type]; - int frameHeight = height * projectile.frame; - Rectangle rectangle = new Rectangle(0, frameHeight, texture.Width, height); - Vector2 origin = new Vector2(texture.Width / 2f, height / 2f); - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + Texture2D texture = Main.projectileTexture[projectile.type]; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + int height = texture.Height / Main.projFrames[projectile.type]; + int frameHeight = height * projectile.frame; + Rectangle rectangle = new Rectangle(0, frameHeight, texture.Width, height); + Vector2 origin = new Vector2(texture.Width / 2f, height / 2f); + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - return false; - } + spriteBatch.Draw(texture, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + return false; + } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item27, projectile.Center); - for (int index1 = 0; index1 < 15; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 88, 0f, 0f, 0, new Color(), 0.9f); - Main.dust[index2].noGravity = true; - Main.dust[index2].velocity *= 1.5f; - } - if (projectile.owner == Main.myPlayer) - { - Vector2 shardPos = projectile.oldPosition + 0.5f * projectile.Size; - for (int i = 0; i < 3; i++) - { - Vector2 shardVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - while (shardVel.X == 0f && shardVel.Y == 0f) - { - shardVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - } - shardVel.Normalize(); - shardVel *= Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(shardPos, shardVel, ProjectileID.Blizzard, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner); - } - } - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item27, projectile.Center); + for (int index1 = 0; index1 < 15; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 88, 0f, 0f, 0, new Color(), 0.9f); + Main.dust[index2].noGravity = true; + Main.dust[index2].velocity *= 1.5f; + } + if (projectile.owner == Main.myPlayer) + { + Vector2 shardPos = projectile.oldPosition + 0.5f * projectile.Size; + for (int i = 0; i < 3; i++) + { + Vector2 shardVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + while (shardVel.X == 0f && shardVel.Y == 0f) + { + shardVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + } + shardVel.Normalize(); + shardVel *= Main.rand.Next(70, 101) * 0.1f; + Projectile.NewProjectile(shardPos, shardVel, ProjectileID.Blizzard, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner); + } + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 30); target.AddBuff(BuffID.Frostburn, 180); diff --git a/Projectiles/Magic/DarkSparkBeam.cs b/Projectiles/Magic/DarkSparkBeam.cs index 19d4f71cf9..84d4f4712a 100644 --- a/Projectiles/Magic/DarkSparkBeam.cs +++ b/Projectiles/Magic/DarkSparkBeam.cs @@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Magic projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 15; - projectile.Calamity().PierceResistHarshness = 0.06f; - projectile.Calamity().PierceResistCap = 0.4f; - } + projectile.Calamity().PierceResistHarshness = 0.06f; + projectile.Calamity().PierceResistCap = 0.4f; + } public override void SendExtraAI(BinaryWriter writer) { @@ -133,13 +133,13 @@ namespace CalamityMod.Projectiles.Magic projectile.velocity = Vector2.Normalize(projectile2.velocity).RotatedBy(num811); projectile.scale = 1.5f * (1.5f - num812); - // Takes 360 frames to reach normal damage - float amount = projectile2.ai[0] / 1200f; - if (amount > 1f) - amount = 1f; - projectile.damage = (int)(projectile2.damage * MathHelper.Lerp(0.25f, 2.2f, amount)); + // Takes 360 frames to reach normal damage + float amount = projectile2.ai[0] / 1200f; + if (amount > 1f) + amount = 1f; + projectile.damage = (int)(projectile2.damage * MathHelper.Lerp(0.25f, 2.2f, amount)); - if (projectile2.ai[0] >= 720f) + if (projectile2.ai[0] >= 720f) vector71 = new Vector2?(projectile2.Center); if (!Collision.CanHitLine(Main.player[projectile.owner].Center, 0, 0, projectile2.Center, 0, 0)) diff --git a/Projectiles/Magic/DeathhailBeam.cs b/Projectiles/Magic/DeathhailBeam.cs index 80b0d5461e..0b748b1a13 100644 --- a/Projectiles/Magic/DeathhailBeam.cs +++ b/Projectiles/Magic/DeathhailBeam.cs @@ -7,57 +7,57 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class DeathhailBeam : BaseLaserbeamProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public class DeathhailBeam : BaseLaserbeamProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private Color startingColor = new Color(119, 210, 255); - private Color secondColor = new Color(247, 119, 255); - public override float MaxScale => 0.7f; - public override float MaxLaserLength => 1599.999999f; - public override float Lifetime => 20f; - public override Color LaserOverlayColor => CalamityUtils.ColorSwap(startingColor, secondColor, 0.9f); - public override Color LightCastColor => LaserOverlayColor; - public override Texture2D LaserBeginTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayStart"); - public override Texture2D LaserMiddleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayMid"); - public override Texture2D LaserEndTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayEnd"); + private Color startingColor = new Color(119, 210, 255); + private Color secondColor = new Color(247, 119, 255); + public override float MaxScale => 0.7f; + public override float MaxLaserLength => 1599.999999f; + public override float Lifetime => 20f; + public override Color LaserOverlayColor => CalamityUtils.ColorSwap(startingColor, secondColor, 0.9f); + public override Color LightCastColor => LaserOverlayColor; + public override Texture2D LaserBeginTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayStart"); + public override Texture2D LaserMiddleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayMid"); + public override Texture2D LaserEndTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayEnd"); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Deathhail"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Deathhail"); + } - public override void SetDefaults() - { - projectile.width = projectile.height = 22; - projectile.friendly = true; - projectile.magic = true; - projectile.penetrate = -1; - projectile.alpha = 255; - projectile.localNPCHitCooldown = -1; - projectile.usesLocalNPCImmunity = true; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 22; + projectile.friendly = true; + projectile.magic = true; + projectile.penetrate = -1; + projectile.alpha = 255; + projectile.localNPCHitCooldown = -1; + projectile.usesLocalNPCImmunity = true; + } - public override bool PreAI() - { - // Initialization. Using the AI hook would override the base laser's code, and we don't want that. - if (projectile.localAI[0] == 0f) - { - if (Main.rand.NextBool()) - { - secondColor = new Color(119, 210, 255); - startingColor = new Color(247, 119, 255); - } - } - return true; - } + public override bool PreAI() + { + // Initialization. Using the AI hook would override the base laser's code, and we don't want that. + if (projectile.localAI[0] == 0f) + { + if (Main.rand.NextBool()) + { + secondColor = new Color(119, 210, 255); + startingColor = new Color(247, 119, 255); + } + } + return true; + } - public override bool ShouldUpdatePosition() => false; + public override bool ShouldUpdatePosition() => false; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.OnFire, 180); - target.AddBuff(BuffID.Frostburn, 90); - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.Frostburn, 90); + } + } } diff --git a/Projectiles/Magic/DivineRetributionSpear.cs b/Projectiles/Magic/DivineRetributionSpear.cs index b3f13eeb56..0ffcbb052e 100644 --- a/Projectiles/Magic/DivineRetributionSpear.cs +++ b/Projectiles/Magic/DivineRetributionSpear.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Magic return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 9f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 9f, 20f); } else { diff --git a/Projectiles/Magic/DustProjectile.cs b/Projectiles/Magic/DustProjectile.cs index 17035c4fec..8c2f285fff 100644 --- a/Projectiles/Magic/DustProjectile.cs +++ b/Projectiles/Magic/DustProjectile.cs @@ -7,32 +7,32 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class DustProjectile : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Dust"); + public class DustProjectile : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Dust"); Main.projFrames[projectile.type] = 6; ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; ProjectileID.Sets.TrailingMode[projectile.type] = 2; - } + } - public override void SetDefaults() - { - projectile.width = 64; - projectile.height = 64; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.magic = true; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.timeLeft = 90; - } + public override void SetDefaults() + { + projectile.width = 64; + projectile.height = 64; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.magic = true; + projectile.penetrate = -1; + projectile.extraUpdates = 3; + projectile.timeLeft = 90; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0.5f, 0.4f, 0.01f); + public override void AI() + { + Lighting.AddLight(projectile.Center, 0.5f, 0.4f, 0.01f); projectile.frameCounter++; if (projectile.frameCounter > 6) { @@ -44,54 +44,54 @@ namespace CalamityMod.Projectiles.Magic projectile.frame = 0; } projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; - if (projectile.ai[0] > 7f) - { - int dustType = 22; - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[idx]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 2f; - dust.velocity.X *= 3f; - dust.velocity.Y *= 3f; - } - dust.velocity.X *= 1.5f; - dust.velocity.Y *= 1.5f; - } - projectile.ai[0] += 1f; - projectile.rotation += 0.3f * (float)projectile.direction; - if (projectile.timeLeft < 30) - projectile.Opacity = MathHelper.Lerp(0f, 1f, (float)projectile.timeLeft / 30f); - } + if (projectile.ai[0] > 7f) + { + int dustType = 22; + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[idx]; + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 2f; + dust.velocity.X *= 3f; + dust.velocity.Y *= 3f; + } + dust.velocity.X *= 1.5f; + dust.velocity.Y *= 1.5f; + } + projectile.ai[0] += 1f; + projectile.rotation += 0.3f * (float)projectile.direction; + if (projectile.timeLeft < 30) + projectile.Opacity = MathHelper.Lerp(0f, 1f, (float)projectile.timeLeft / 30f); + } - public override bool CanDamage() => projectile.timeLeft > 30; + public override bool CanDamage() => projectile.timeLeft > 30; - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - // Dust effects - Circle dustCircle = new Circle(projectile.Center, projectile.width / 2); + // Dust effects + Circle dustCircle = new Circle(projectile.Center, projectile.width / 2); - for (int i = 0; i < 20; i++) - { - // Dust - Vector2 dustPos = dustCircle.RandomPointInCircle(); - if ((dustPos - projectile.Center).Length() > 48) - { - int dustIndex = Dust.NewDust(dustPos, 1, 1, 22); - Main.dust[dustIndex].noGravity = true; - Main.dust[dustIndex].fadeIn = 1f; - Vector2 dustVelocity = projectile.Center - Main.dust[dustIndex].position; - float distToCenter = dustVelocity.Length(); - dustVelocity.Normalize(); - dustVelocity = dustVelocity.RotatedBy(MathHelper.ToRadians(-90f)); - dustVelocity *= distToCenter * 0.04f; - Main.dust[dustIndex].velocity = dustVelocity; - } - } - return false; - } - } + for (int i = 0; i < 20; i++) + { + // Dust + Vector2 dustPos = dustCircle.RandomPointInCircle(); + if ((dustPos - projectile.Center).Length() > 48) + { + int dustIndex = Dust.NewDust(dustPos, 1, 1, 22); + Main.dust[dustIndex].noGravity = true; + Main.dust[dustIndex].fadeIn = 1f; + Vector2 dustVelocity = projectile.Center - Main.dust[dustIndex].position; + float distToCenter = dustVelocity.Length(); + dustVelocity.Normalize(); + dustVelocity = dustVelocity.RotatedBy(MathHelper.ToRadians(-90f)); + dustVelocity *= distToCenter * 0.04f; + Main.dust[dustIndex].velocity = dustVelocity; + } + } + return false; + } + } } diff --git a/Projectiles/Magic/EidolicWailSoundwave.cs b/Projectiles/Magic/EidolicWailSoundwave.cs index d99917b966..92d7d7d55e 100644 --- a/Projectiles/Magic/EidolicWailSoundwave.cs +++ b/Projectiles/Magic/EidolicWailSoundwave.cs @@ -26,13 +26,13 @@ namespace CalamityMod.Projectiles.Magic projectile.ignoreWater = true; projectile.penetrate = -1; projectile.magic = true; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 16; projectile.timeLeft = 450; - projectile.Calamity().PierceResistHarshness = 0.06f; - projectile.Calamity().PierceResistCap = 0.4f; - } + projectile.Calamity().PierceResistHarshness = 0.06f; + projectile.Calamity().PierceResistCap = 0.4f; + } public override void AI() { @@ -72,7 +72,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 240); - } + } public override Color? GetAlpha(Color lightColor) { diff --git a/Projectiles/Magic/ElementBolt.cs b/Projectiles/Magic/ElementBolt.cs index 7f88a1a055..9ac5a14daf 100644 --- a/Projectiles/Magic/ElementBolt.cs +++ b/Projectiles/Magic/ElementBolt.cs @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.timeLeft = 30; projectile.magic = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { @@ -32,16 +32,16 @@ namespace CalamityMod.Projectiles.Magic Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.7f), projectile.knockBack, projectile.owner, 0f, 0f); } - for (int num447 = 0; num447 < 2; num447++) - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * ((float)num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.25f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; - } + for (int num447 = 0; num447 < 2; num447++) + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * ((float)num447 * 0.25f); + int num448 = Dust.NewDust(vector33, 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.25f); + Main.dust[num448].noGravity = true; + Main.dust[num448].position = vector33; + Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[num448].velocity *= 0.1f; + } } } } diff --git a/Projectiles/Magic/ElementBolt2.cs b/Projectiles/Magic/ElementBolt2.cs index 85964c68ac..b0d87927d4 100644 --- a/Projectiles/Magic/ElementBolt2.cs +++ b/Projectiles/Magic/ElementBolt2.cs @@ -20,18 +20,18 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.timeLeft = 15; projectile.magic = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } - public override void AI() - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.25f); - Main.dust[num448].position = vector33; - Main.dust[num448].noGravity = true; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; - } + public override void AI() + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * 0.25f; + int num448 = Dust.NewDust(vector33, 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.25f); + Main.dust[num448].position = vector33; + Main.dust[num448].noGravity = true; + Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[num448].velocity *= 0.1f; + } } } diff --git a/Projectiles/Magic/ElementOrb.cs b/Projectiles/Magic/ElementOrb.cs index 53a5b58350..0ac7c0a41c 100644 --- a/Projectiles/Magic/ElementOrb.cs +++ b/Projectiles/Magic/ElementOrb.cs @@ -1,7 +1,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class ElementOrb : ModProjectile + public class ElementOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -19,12 +19,12 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.timeLeft = 30; projectile.magic = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 24f, 5, ModContent.ProjectileType()); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 24f, 5, ModContent.ProjectileType()); } } } diff --git a/Projectiles/Magic/ElementOrb2.cs b/Projectiles/Magic/ElementOrb2.cs index d123f573b1..0d2c6e9dd3 100644 --- a/Projectiles/Magic/ElementOrb2.cs +++ b/Projectiles/Magic/ElementOrb2.cs @@ -1,7 +1,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class ElementOrb2 : ModProjectile + public class ElementOrb2 : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -19,12 +19,12 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.timeLeft = 30; projectile.magic = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 24f, 5, ModContent.ProjectileType()); - } + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 24f, 5, ModContent.ProjectileType()); + } } } diff --git a/Projectiles/Magic/ElementTentacle.cs b/Projectiles/Magic/ElementTentacle.cs index 12622733c0..b29babc641 100644 --- a/Projectiles/Magic/ElementTentacle.cs +++ b/Projectiles/Magic/ElementTentacle.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class ElementTentacle : ModProjectile + public class ElementTentacle : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -95,9 +95,9 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } } } diff --git a/Projectiles/Magic/ElementalRayBeam.cs b/Projectiles/Magic/ElementalRayBeam.cs index 0166cd9c98..9463679ccc 100644 --- a/Projectiles/Magic/ElementalRayBeam.cs +++ b/Projectiles/Magic/ElementalRayBeam.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class ElementalRayBeam : ModProjectile + public class ElementalRayBeam : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = 10; projectile.extraUpdates = 100; projectile.timeLeft = 180; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { @@ -46,16 +46,16 @@ namespace CalamityMod.Projectiles.Magic Main.dust[num448].noGravity = true; Main.dust[num448].position = vector33; Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; - } + Main.dust[num448].velocity *= 0.1f; + } } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } } } diff --git a/Projectiles/Magic/EternityBook.cs b/Projectiles/Magic/EternityBook.cs index ab373b7042..1a4a9738dc 100644 --- a/Projectiles/Magic/EternityBook.cs +++ b/Projectiles/Magic/EternityBook.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class EternityBook : ModProjectile + public class EternityBook : ModProjectile { public float Time { diff --git a/Projectiles/Magic/EternityCrystal.cs b/Projectiles/Magic/EternityCrystal.cs index d42866dc1c..b825c50b4f 100644 --- a/Projectiles/Magic/EternityCrystal.cs +++ b/Projectiles/Magic/EternityCrystal.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; // Delete the crystal if any necessary components are incorrect/would cause errors. if (projectile.localAI[1] >= Main.projectile.Length || projectile.localAI[0] < 0) diff --git a/Projectiles/Magic/EternityHex.cs b/Projectiles/Magic/EternityHex.cs index 91ca33bd9f..4b18741a68 100644 --- a/Projectiles/Magic/EternityHex.cs +++ b/Projectiles/Magic/EternityHex.cs @@ -216,7 +216,7 @@ namespace CalamityMod.Projectiles.Magic } public Color PrimitiveColorFunction(float completionRatio) - { + { float leftoverTimeScale = (float)Math.Sin(Main.GlobalTime * 4f) * 0.5f + 0.5f; leftoverTimeScale *= 0.5f; @@ -226,22 +226,22 @@ namespace CalamityMod.Projectiles.Magic float fadeToMagenta = MathHelper.SmoothStep(0f, 1f, (float)Math.Pow(completionRatio, 0.6D)); return Color.Lerp(headColor, tailColor, fadeToMagenta) * opacity; - } + } public float PrimitiveWidthFunction(float completionRatio) - { + { float widthInterpolant = Utils.InverseLerp(0f, 0.12f, completionRatio, true); return MathHelper.SmoothStep(1f, 10f, widthInterpolant); - } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { if (LemniscateDrawer is null) LemniscateDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, null, GameShaders.Misc["CalamityMod:TrailStreak"]); GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/EternityStreak")); LemniscateDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f - Main.screenPosition, 84); return false; - } - } + } + } } diff --git a/Projectiles/Magic/EventHorizonBlackhole.cs b/Projectiles/Magic/EventHorizonBlackhole.cs index eb68026f53..6af0f72fff 100644 --- a/Projectiles/Magic/EventHorizonBlackhole.cs +++ b/Projectiles/Magic/EventHorizonBlackhole.cs @@ -6,9 +6,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class EventHorizonBlackhole : ModProjectile + public class EventHorizonBlackhole : ModProjectile { - public int killCounter = 21; + public int killCounter = 21; public override void SetStaticDefaults() { @@ -29,12 +29,12 @@ namespace CalamityMod.Projectiles.Magic projectile.localNPCHitCooldown = 12; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 60; + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 60; - public override void AI() + public override void AI() { - if (projectile.frame == 8) - return; + if (projectile.frame == 8) + return; // Update animation projectile.frameCounter++; @@ -44,18 +44,18 @@ namespace CalamityMod.Projectiles.Magic projectile.frameCounter = 0; } - if (projectile.timeLeft > 15) - { - if (projectile.frame >= 4) - projectile.frame = 0; - } - else - { - if (projectile.frame < 4) - projectile.frame = 4; - if (projectile.frame >= 8) - projectile.frame = 4; - } + if (projectile.timeLeft > 15) + { + if (projectile.frame >= 4) + projectile.frame = 0; + } + else + { + if (projectile.frame < 4) + projectile.frame = 4; + if (projectile.frame >= 8) + projectile.frame = 4; + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -63,10 +63,10 @@ namespace CalamityMod.Projectiles.Magic target.AddBuff(BuffID.Daybreak, 180); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Magic/EventHorizonStar.cs b/Projectiles/Magic/EventHorizonStar.cs index 7a29ebc4c6..ecbc9854c1 100644 --- a/Projectiles/Magic/EventHorizonStar.cs +++ b/Projectiles/Magic/EventHorizonStar.cs @@ -9,8 +9,8 @@ namespace CalamityMod.Projectiles.Magic { public class EventHorizonStar : ModProjectile { - private bool initialized = false; - Vector2 initialPosition; + private bool initialized = false; + Vector2 initialPosition; public override void SetStaticDefaults() { @@ -27,26 +27,26 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = 1; projectile.magic = true; projectile.tileCollide = false; - projectile.timeLeft = 300; - projectile.alpha = 180; + projectile.timeLeft = 300; + projectile.alpha = 180; } public override void AI() { - //rotation + //rotation projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; - //sound effects + //sound effects if (projectile.soundDelay == 0) { projectile.soundDelay = 20 + Main.rand.Next(40); if (Main.rand.NextBool(5)) - { - Main.PlaySound(SoundID.Item9, (int)projectile.position.X, (int)projectile.position.Y); - } + { + Main.PlaySound(SoundID.Item9, (int)projectile.position.X, (int)projectile.position.Y); + } } - //dust effects + //dust effects if (Main.rand.NextBool(10)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 262, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 0, default, 0.75f); @@ -55,21 +55,21 @@ namespace CalamityMod.Projectiles.Magic projectile.localAI[0]++; Vector2 playerCenter = Main.player[projectile.owner].Center; - float centerX = projectile.Center.X; - float centerY = projectile.Center.Y; + float centerX = projectile.Center.X; + float centerY = projectile.Center.Y; - if (!initialized) - { - initialPosition = playerCenter; - initialized = true; - } - else if (playerCenter != initialPosition) - { - playerCenter = initialPosition; - } + if (!initialized) + { + initialPosition = playerCenter; + initialized = true; + } + else if (playerCenter != initialPosition) + { + playerCenter = initialPosition; + } - float xDist = playerCenter.X - centerX; - float yDist = playerCenter.Y - centerY; + float xDist = playerCenter.X - centerX; + float yDist = playerCenter.Y - centerY; float radius = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); if (projectile.localAI[0] > 10 && projectile.localAI[0] < 100) @@ -83,40 +83,40 @@ namespace CalamityMod.Projectiles.Magic } } - //homing - if (projectile.localAI[0] >= 100) - { - Vector2 center = projectile.Center; - float homingRange = 325f; - bool homeIn = false; - float inertia = 25f; - float homingSpeed = 23f; + //homing + if (projectile.localAI[0] >= 100) + { + Vector2 center = projectile.Center; + float homingRange = 325f; + bool homeIn = false; + float inertia = 25f; + float homingSpeed = 23f; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false)) - { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (homingRange + extraDistance)) - { - center = Main.npc[i].Center; - homeIn = true; - break; - } - } - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (homingRange + extraDistance)) + { + center = Main.npc[i].Center; + homeIn = true; + break; + } + } + } - if (homeIn) - { - projectile.extraUpdates = 1; - Vector2 homeInVector = projectile.SafeDirectionTo(center, Vector2.UnitY); + if (homeIn) + { + projectile.extraUpdates = 1; + Vector2 homeInVector = projectile.SafeDirectionTo(center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * inertia + homeInVector * homingSpeed) / (inertia + 1f); - } - else - projectile.extraUpdates = 0; - } + projectile.velocity = (projectile.velocity * inertia + homeInVector * homingSpeed) / (inertia + 1f); + } + else + projectile.extraUpdates = 0; + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -131,14 +131,14 @@ namespace CalamityMod.Projectiles.Magic return false; } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { Texture2D texture = Main.projectileTexture[projectile.type]; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), new Color(255, 255, 255, 127), projectile.rotation, texture.Size() / 2f, projectile.scale, spriteEffects, 0f); - } + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), new Color(255, 255, 255, 127), projectile.rotation, texture.Size() / 2f, projectile.scale, spriteEffects, 0f); + } } } diff --git a/Projectiles/Magic/FabBolt.cs b/Projectiles/Magic/FabBolt.cs index 8abf0447a1..0fff02f6ce 100644 --- a/Projectiles/Magic/FabBolt.cs +++ b/Projectiles/Magic/FabBolt.cs @@ -7,16 +7,16 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class FabBolt : ModProjectile + public class FabBolt : ModProjectile { internal PrimitiveTrail TrailDrawer; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public bool FadingOut - { + { get => projectile.ai[0] == 1f; set => projectile.ai[0] = value.ToInt(); - } + } public override void SetStaticDefaults() { @@ -39,8 +39,8 @@ namespace CalamityMod.Projectiles.Magic projectile.localNPCHitCooldown = 0; } - public override void AI() - { + public override void AI() + { if (FadingOut) { projectile.Opacity = MathHelper.Lerp(projectile.Opacity, 0f, 0.27f); @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Magic Lighting.AddLight(projectile.Center, Vector3.One * projectile.Opacity * 0.45f); } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio) { float fadeToEnd = MathHelper.Lerp(0.25f, 0.5f, (float)Math.Cos(-Main.GlobalTime * 3f) * 0.5f + 0.5f); fadeToEnd *= 1f - Utils.InverseLerp(0.35f, 0f, completionRatio, true); @@ -79,18 +79,18 @@ namespace CalamityMod.Projectiles.Magic return false; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { if (!FadingOut && projectile.penetrate < 2) - { + { FadingOut = true; projectile.velocity *= 0.1f; projectile.extraUpdates = 0; projectile.netUpdate = true; } - } + } - public override bool OnTileCollide(Vector2 oldVelocity) + public override bool OnTileCollide(Vector2 oldVelocity) { if (!FadingOut) { @@ -102,11 +102,11 @@ namespace CalamityMod.Projectiles.Magic return false; } - public override bool CanDamage() - { + public override bool CanDamage() + { if (FadingOut) return false; - return base.CanDamage(); - } - } + return base.CanDamage(); + } + } } diff --git a/Projectiles/Magic/ForbiddenAxeBlade.cs b/Projectiles/Magic/ForbiddenAxeBlade.cs index aa3ff8c279..9c2b92b5d4 100644 --- a/Projectiles/Magic/ForbiddenAxeBlade.cs +++ b/Projectiles/Magic/ForbiddenAxeBlade.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class ForbiddenAxeBlade : ModProjectile + public class ForbiddenAxeBlade : ModProjectile { public override void SetStaticDefaults() { @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Magic else if (projectile.ai[1] > 20f && projectile.ai[1] <= 39f) { projectile.velocity *= 1.25f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 10f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 10f, 20f); } else if (projectile.ai[1] == 40f) { diff --git a/Projectiles/Magic/ForbiddenSunProjectile.cs b/Projectiles/Magic/ForbiddenSunProjectile.cs index f086fa8d1c..06a22127a9 100644 --- a/Projectiles/Magic/ForbiddenSunProjectile.cs +++ b/Projectiles/Magic/ForbiddenSunProjectile.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class ForbiddenSunProjectile : ModProjectile + public class ForbiddenSunProjectile : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/ChaosFlameSmall"; diff --git a/Projectiles/Magic/FrostBoltProjectile.cs b/Projectiles/Magic/FrostBoltProjectile.cs index 093b3619cd..0466976a67 100644 --- a/Projectiles/Magic/FrostBoltProjectile.cs +++ b/Projectiles/Magic/FrostBoltProjectile.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = 2; projectile.timeLeft = 480; projectile.magic = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Magic/GhastlyBlast.cs b/Projectiles/Magic/GhastlyBlast.cs index 433c3a069a..97815317ce 100644 --- a/Projectiles/Magic/GhastlyBlast.cs +++ b/Projectiles/Magic/GhastlyBlast.cs @@ -259,7 +259,7 @@ namespace CalamityMod.Projectiles.Magic { int num98 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 60, 0f, 0f, 200, default, 3.7f); Dust dust = Main.dust[num98]; - dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; dust.noGravity = true; dust.velocity *= 3f; num98 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 60, 0f, 0f, 100, default, 1.5f); diff --git a/Projectiles/Magic/GhastlyExplosionShard.cs b/Projectiles/Magic/GhastlyExplosionShard.cs index bc39226c3b..cf17ff01bd 100644 --- a/Projectiles/Magic/GhastlyExplosionShard.cs +++ b/Projectiles/Magic/GhastlyExplosionShard.cs @@ -18,14 +18,14 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 8; projectile.friendly = true; projectile.alpha = 255; - projectile.timeLeft = 80; + projectile.timeLeft = 80; projectile.penetrate = 1; projectile.magic = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 50 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 50 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { int num332 = (int)projectile.ai[0]; @@ -66,9 +66,9 @@ namespace CalamityMod.Projectiles.Magic num3 = num336; } - if (projectile.timeLeft < 50) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); - } + if (projectile.timeLeft < 50) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Magic/GhastlySubBlast.cs b/Projectiles/Magic/GhastlySubBlast.cs index fb02effb27..e2fdc64e54 100644 --- a/Projectiles/Magic/GhastlySubBlast.cs +++ b/Projectiles/Magic/GhastlySubBlast.cs @@ -18,8 +18,8 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 420; + projectile.ignoreWater = true; + projectile.timeLeft = 420; projectile.magic = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 8; diff --git a/Projectiles/Magic/GhastlyVisageProj.cs b/Projectiles/Magic/GhastlyVisageProj.cs index 3d26aeca19..e77337775a 100644 --- a/Projectiles/Magic/GhastlyVisageProj.cs +++ b/Projectiles/Magic/GhastlyVisageProj.cs @@ -193,19 +193,19 @@ namespace CalamityMod.Projectiles.Magic player.itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture2D13 = Main.projectileTexture[projectile.type]; - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; - int y6 = num214 * projectile.frame; - Vector2 origin = new Vector2(13f, 16f); - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture2D13 = Main.projectileTexture[projectile.type]; + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int y6 = num214 * projectile.frame; + Vector2 origin = new Vector2(13f, 16f); + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Magic/GhastlyVisageProjGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - } + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Magic/GhastlyVisageProjGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + } - public override bool CanDamage() => false; - } + public override bool CanDamage() => false; + } } diff --git a/Projectiles/Magic/GleamingBolt.cs b/Projectiles/Magic/GleamingBolt.cs index 5f9aa73c12..598944c4d6 100644 --- a/Projectiles/Magic/GleamingBolt.cs +++ b/Projectiles/Magic/GleamingBolt.cs @@ -27,11 +27,11 @@ namespace CalamityMod.Projectiles.Magic projectile.velocity *= 0.985f; for (int dust = 0; dust < 2; dust++) { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 64, - 204 - }); + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 64, + 204 + }); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } } @@ -40,11 +40,11 @@ namespace CalamityMod.Projectiles.Magic { for (int k = 0; k < 5; k++) { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 64, - 204 - }); + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 64, + 204 + }); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } float spread = 90f * 0.0174f; diff --git a/Projectiles/Magic/GleamingBolt2.cs b/Projectiles/Magic/GleamingBolt2.cs index 3c2e79cc99..cbdbeb2c02 100644 --- a/Projectiles/Magic/GleamingBolt2.cs +++ b/Projectiles/Magic/GleamingBolt2.cs @@ -21,23 +21,23 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 8f, 20f); - else - projectile.velocity *= 0.985f; + if (projectile.timeLeft < 90) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 8f, 20f); + else + projectile.velocity *= 0.985f; - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 64, - 204 - }); - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 64, + 204 + }); + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/GraniteEnergy.cs b/Projectiles/Magic/GraniteEnergy.cs index 07156b0a76..1927e3e1b1 100644 --- a/Projectiles/Magic/GraniteEnergy.cs +++ b/Projectiles/Magic/GraniteEnergy.cs @@ -21,16 +21,16 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = 90; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 60 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 60 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.ToRadians(90); - if (Main.rand.NextBool(2)) - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 229, 0f, 0f, 100, default, 0.6f); + if (Main.rand.NextBool(2)) + Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 229, 0f, 0f, 100, default, 0.6f); - if (projectile.timeLeft < 60) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); + if (projectile.timeLeft < 60) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } } } diff --git a/Projectiles/Magic/GranitePulse.cs b/Projectiles/Magic/GranitePulse.cs index 6ca7cb8d9a..a9c4972b4a 100644 --- a/Projectiles/Magic/GranitePulse.cs +++ b/Projectiles/Magic/GranitePulse.cs @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Magic int projType = projectile.type; for (int i = 0; i < Main.maxProjectiles; i++) { - Projectile proj = Main.projectile[i]; + Projectile proj = Main.projectile[i]; if (proj.active && proj.owner == projectile.owner && proj.type == projType && proj.ai[1] < 3600f) { projCount++; @@ -153,9 +153,9 @@ namespace CalamityMod.Projectiles.Magic Texture2D texture = Main.projectileTexture[projectile.type]; int height = texture.Height / Main.projFrames[projectile.type]; int frameHeight = height * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), projectile.scale, spriteEffects, 0f); return false; } diff --git a/Projectiles/Magic/HadopelagicEchoSoundwave.cs b/Projectiles/Magic/HadopelagicEchoSoundwave.cs index db38ec780f..31edb55995 100644 --- a/Projectiles/Magic/HadopelagicEchoSoundwave.cs +++ b/Projectiles/Magic/HadopelagicEchoSoundwave.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.ignoreWater = true; projectile.penetrate = -1; - projectile.extraUpdates = 1; - projectile.magic = true; + projectile.extraUpdates = 1; + projectile.magic = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 16; projectile.timeLeft = 450; diff --git a/Projectiles/Magic/HellfireExplosionFriendly.cs b/Projectiles/Magic/HellfireExplosionFriendly.cs index c1b62b2da5..7baf8d698f 100644 --- a/Projectiles/Magic/HellfireExplosionFriendly.cs +++ b/Projectiles/Magic/HellfireExplosionFriendly.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Magic projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 180; - projectile.magic = true; + projectile.magic = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } diff --git a/Projectiles/Magic/HellwingPillar.cs b/Projectiles/Magic/HellwingPillar.cs index 51952bd81c..7861302074 100644 --- a/Projectiles/Magic/HellwingPillar.cs +++ b/Projectiles/Magic/HellwingPillar.cs @@ -62,22 +62,22 @@ namespace CalamityMod.Projectiles.Magic int num297 = 127; if (Main.rand.NextBool(3)) { - 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)) - { - dust.noGravity = true; - dust.scale *= 2f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= scalar; + 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)) + { + dust.noGravity = true; + dust.scale *= 2f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 1.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= scalar; } } else diff --git a/Projectiles/Magic/HeresyProj.cs b/Projectiles/Magic/HeresyProj.cs index 89a71ba3fd..7eb11e2dc9 100644 --- a/Projectiles/Magic/HeresyProj.cs +++ b/Projectiles/Magic/HeresyProj.cs @@ -8,7 +8,7 @@ using Terraria.Utilities; namespace CalamityMod.Projectiles.Magic { - public class HeresyProj : ModProjectile + public class HeresyProj : ModProjectile { public Player Owner => Main.player[projectile.owner]; public float ShootIntensity => MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(0f, 275f, Time, true)); diff --git a/Projectiles/Magic/HolyLaser.cs b/Projectiles/Magic/HolyLaser.cs index f8f4282aff..ec20259537 100644 --- a/Projectiles/Magic/HolyLaser.cs +++ b/Projectiles/Magic/HolyLaser.cs @@ -42,24 +42,24 @@ namespace CalamityMod.Projectiles.Magic { num249 = 246; } - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 0.25f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; - } + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * 0.25f; + int num448 = Dust.NewDust(vector33, 1, 1, num249, 0f, 0f, 0, default, 0.25f); + Main.dust[num448].position = vector33; + Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[num448].velocity *= 0.1f; + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); - if (projectile.owner == Main.myPlayer) + if (projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMagic = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMagic = true; } } } diff --git a/Projectiles/Magic/IceBarrageMain.cs b/Projectiles/Magic/IceBarrageMain.cs index 19bf85a147..8fd54fc4a9 100644 --- a/Projectiles/Magic/IceBarrageMain.cs +++ b/Projectiles/Magic/IceBarrageMain.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() @@ -156,12 +156,12 @@ namespace CalamityMod.Projectiles.Magic { Vector2 projspeed = new Vector2(Main.rand.NextFloat(-5f, 5f), Main.rand.NextFloat(-5f, 5f)); int ice = Projectile.NewProjectile(projectile.Center, projspeed, ProjectileID.NorthPoleSnowflake, (int)(projectile.damage * 0.05f), 2f, projectile.owner, 0f, (float)Main.rand.Next(3)); - if (ice.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[ice].timeLeft = 600; - Main.projectile[ice].melee = false; - Main.projectile[ice].Calamity().forceMagic = true; - } + if (ice.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[ice].timeLeft = 600; + Main.projectile[ice].melee = false; + Main.projectile[ice].Calamity().forceMagic = true; + } projectile.ai[1] = 0f; } } diff --git a/Projectiles/Magic/IceBlock.cs b/Projectiles/Magic/IceBlock.cs index cd6f7918a1..9da87e29b0 100644 --- a/Projectiles/Magic/IceBlock.cs +++ b/Projectiles/Magic/IceBlock.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 60; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() @@ -43,22 +43,22 @@ namespace CalamityMod.Projectiles.Magic Projectile proj = Main.projectile[i]; if (proj.type == ModContent.ProjectileType() && proj.owner == Main.myPlayer) { - Vector2 pos1 = new Vector2(proj.Center.X, proj.Center.Y - (proj.height * 0.5f) - 44f); - Vector2 pos2 = new Vector2(proj.Center.X + (proj.width * 0.5f) + 48f, proj.Center.Y); - Vector2 pos3 = new Vector2(proj.Center.X, proj.Center.Y + (proj.height * 0.5f) + 44f); - Vector2 pos4 = new Vector2(proj.Center.X - (proj.width * 0.5f) - 49f, proj.Center.Y); - switch (projectile.ai[0]) - { - case 0: projectile.Center = pos1; - break; - case 1: projectile.Center = pos2; - break; - case 2: projectile.Center = pos3; - break; - case 3: projectile.Center = pos4; - break; - default: break; - } + Vector2 pos1 = new Vector2(proj.Center.X, proj.Center.Y - (proj.height * 0.5f) - 44f); + Vector2 pos2 = new Vector2(proj.Center.X + (proj.width * 0.5f) + 48f, proj.Center.Y); + Vector2 pos3 = new Vector2(proj.Center.X, proj.Center.Y + (proj.height * 0.5f) + 44f); + Vector2 pos4 = new Vector2(proj.Center.X - (proj.width * 0.5f) - 49f, proj.Center.Y); + switch (projectile.ai[0]) + { + case 0: projectile.Center = pos1; + break; + case 1: projectile.Center = pos2; + break; + case 2: projectile.Center = pos3; + break; + case 3: projectile.Center = pos4; + break; + default: break; + } } } switch (projectile.ai[0]) diff --git a/Projectiles/Magic/IceBlockIcicle.cs b/Projectiles/Magic/IceBlockIcicle.cs index b0fdc30606..b4e8a6670b 100644 --- a/Projectiles/Magic/IceBlockIcicle.cs +++ b/Projectiles/Magic/IceBlockIcicle.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Magic projectile.ignoreWater = true; projectile.magic = true; projectile.timeLeft = 600; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Magic/IceCluster.cs b/Projectiles/Magic/IceCluster.cs index f9d55c4337..0c76e81079 100644 --- a/Projectiles/Magic/IceCluster.cs +++ b/Projectiles/Magic/IceCluster.cs @@ -25,41 +25,41 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = 100; projectile.tileCollide = false; projectile.magic = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } - public override void AI() - { - projectile.rotation += 0.5f; + public override void AI() + { + projectile.rotation += 0.5f; - if (projectile.localAI[1] == 0f) - { - projectile.localAI[1] = 1f; - Main.PlaySound(SoundID.Item120, projectile.position); - } + if (projectile.localAI[1] == 0f) + { + projectile.localAI[1] = 1f; + Main.PlaySound(SoundID.Item120, projectile.position); + } - projectile.ai[0] += 1f; - if (projectile.ai[1] == 1f) - { - if (projectile.ai[0] % 30f == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 vector80 = projectile.rotation.ToRotationVector2(); - Projectile.NewProjectile(projectile.Center, vector80, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - } + projectile.ai[0] += 1f; + if (projectile.ai[1] == 1f) + { + if (projectile.ai[0] % 30f == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 vector80 = projectile.rotation.ToRotationVector2(); + Projectile.NewProjectile(projectile.Center, vector80, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + } - Lighting.AddLight(projectile.Center, 0.3f, 0.75f, 0.9f); - } + Lighting.AddLight(projectile.Center, 0.3f, 0.75f, 0.9f); + } - if (projectile.ai[0] >= 90f) - projectile.alpha += 25; - else - projectile.alpha -= 15; + if (projectile.ai[0] >= 90f) + projectile.alpha += 25; + else + projectile.alpha -= 15; - if (projectile.alpha < 0) - projectile.alpha = 0; - if (projectile.alpha > 255) - projectile.alpha = 255; - } + if (projectile.alpha < 0) + projectile.alpha = 0; + if (projectile.alpha > 255) + projectile.alpha = 255; + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Magic/IceSpike.cs b/Projectiles/Magic/IceSpike.cs index a13430b1d4..169ca5a084 100644 --- a/Projectiles/Magic/IceSpike.cs +++ b/Projectiles/Magic/IceSpike.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class IceSpike : ModProjectile + public class IceSpike : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Boss/IceRain"; @@ -22,18 +22,18 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = 1; projectile.magic = true; projectile.timeLeft = 240; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() { - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + (MathHelper.Pi * 0.5f * projectile.direction); + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + (MathHelper.Pi * 0.5f * projectile.direction); - int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 1f); + int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 1f); Main.dust[num469].noGravity = true; - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 10f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 10f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/Icicle.cs b/Projectiles/Magic/Icicle.cs index 49e94dded2..1d149a549b 100644 --- a/Projectiles/Magic/Icicle.cs +++ b/Projectiles/Magic/Icicle.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; projectile.coldDamage = true; projectile.penetrate = 1; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void SetStaticDefaults() diff --git a/Projectiles/Magic/IcicleStaffProj.cs b/Projectiles/Magic/IcicleStaffProj.cs index 4c49846feb..b5696297b6 100644 --- a/Projectiles/Magic/IcicleStaffProj.cs +++ b/Projectiles/Magic/IcicleStaffProj.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = 1; projectile.extraUpdates = 1; projectile.timeLeft = 600; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Magic/InfernadoFriendly.cs b/Projectiles/Magic/InfernadoFriendly.cs index 8118335fa3..7a39bcbc87 100644 --- a/Projectiles/Magic/InfernadoFriendly.cs +++ b/Projectiles/Magic/InfernadoFriendly.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Projectiles.Magic { public class InfernadoFriendly : ModProjectile { - bool intersectingSomething = false; + bool intersectingSomething = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Infernado"); @@ -24,17 +24,17 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.alpha = 255; projectile.timeLeft = 500; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 10; - projectile.magic = true; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 10; + projectile.magic = true; } public override void AI() { - if (Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - intersectingSomething = true; + if (Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + intersectingSomething = true; - float scaleBase = 44f; + float scaleBase = 44f; float scaleMult = 2.5f; float baseWidth = 320f; float baseHeight = 88f; @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Magic { projectile.localAI[0] = 1f; projectile.scale = (scaleBase - projectile.ai[1]) * scaleMult / scaleBase; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(baseWidth * projectile.scale), (int)(baseHeight * projectile.scale)); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(baseWidth * projectile.scale), (int)(baseHeight * projectile.scale)); projectile.netUpdate = true; } if (projectile.ai[1] != -1f) @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Magic projectile.width = (int)(baseWidth * projectile.scale); projectile.height = (int)(baseHeight * projectile.scale); } - if (!intersectingSomething) + if (!intersectingSomething) { projectile.alpha -= 30; if (projectile.alpha < 100) @@ -98,17 +98,17 @@ namespace CalamityMod.Projectiles.Magic float num618 = (scaleBase - projectile.ai[1] + 1f) * scaleMult / scaleBase; center.Y -= baseHeight * num618 / 2f; center.Y += 2f; - Projectile segment = Projectile.NewProjectileDirect(center, projectile.velocity, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 10f, projectile.ai[1] - 1f); - //Defaults to magic - if (segment.whoAmI.WithinBounds(Main.maxProjectiles)) - { - segment.Calamity().forceMelee = projectile.Calamity().forceMelee; - segment.Calamity().forceRanged = projectile.Calamity().forceRanged; - segment.Calamity().forceMinion = projectile.Calamity().forceMinion; - segment.Calamity().forceRogue = projectile.Calamity().forceRogue; - segment.Calamity().forceTypeless = projectile.Calamity().forceTypeless; - segment.Calamity().forceHostile = projectile.Calamity().forceHostile; - } + Projectile segment = Projectile.NewProjectileDirect(center, projectile.velocity, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 10f, projectile.ai[1] - 1f); + //Defaults to magic + if (segment.whoAmI.WithinBounds(Main.maxProjectiles)) + { + segment.Calamity().forceMelee = projectile.Calamity().forceMelee; + segment.Calamity().forceRanged = projectile.Calamity().forceRanged; + segment.Calamity().forceMinion = projectile.Calamity().forceMinion; + segment.Calamity().forceRogue = projectile.Calamity().forceRogue; + segment.Calamity().forceTypeless = projectile.Calamity().forceTypeless; + segment.Calamity().forceHostile = projectile.Calamity().forceHostile; + } } if (projectile.ai[0] <= 0f) { @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Magic } } - public override Color? GetAlpha(Color lightColor) + public override Color? GetAlpha(Color lightColor) { if (!intersectingSomething) { diff --git a/Projectiles/Magic/InfernalBlade.cs b/Projectiles/Magic/InfernalBlade.cs index 987d3547e7..32caefd5f1 100644 --- a/Projectiles/Magic/InfernalBlade.cs +++ b/Projectiles/Magic/InfernalBlade.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class InfernalBlade : ModProjectile + public class InfernalBlade : ModProjectile { public override void SetStaticDefaults() { @@ -115,22 +115,22 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(target.Center); + OnHitEffects(target.Center); target.AddBuff(ModContent.BuffType(), 180); } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(target.Center); + OnHitEffects(target.Center); target.AddBuff(ModContent.BuffType(), 180); } - private void OnHitEffects(Vector2 targetPos) - { - if (projectile.owner == Main.myPlayer) - { - CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), 1f, projectile.owner, true); - } + private void OnHitEffects(Vector2 targetPos) + { + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), 1f, projectile.owner, true); + } } } } diff --git a/Projectiles/Magic/LightBead.cs b/Projectiles/Magic/LightBead.cs index f3e752388b..750bad1d36 100644 --- a/Projectiles/Magic/LightBead.cs +++ b/Projectiles/Magic/LightBead.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class LightBead : ModProjectile + public class LightBead : ModProjectile { public override void SetStaticDefaults() { @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Magic return; } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 15f, 15f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 15f, 15f); } public override Color? GetAlpha(Color lightColor) @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Magic { for (int b = 0; b < beadAmt; b++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); } } diff --git a/Projectiles/Magic/LightBlade.cs b/Projectiles/Magic/LightBlade.cs index d6c225ead4..b58228ff17 100644 --- a/Projectiles/Magic/LightBlade.cs +++ b/Projectiles/Magic/LightBlade.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { public class LightBlade : ModProjectile - { + { private const int Lifetime = 300; private const int NumAfterimages = 8; private const float LightBrightness = 0.7f; diff --git a/Projectiles/Magic/LightningArc.cs b/Projectiles/Magic/LightningArc.cs index 30114640ac..8177fa87d1 100644 --- a/Projectiles/Magic/LightningArc.cs +++ b/Projectiles/Magic/LightningArc.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Projectiles.Magic public override void SetStaticDefaults() { - DisplayName.SetDefault("Lightning Arc"); + DisplayName.SetDefault("Lightning Arc"); } public override void SetDefaults() @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Magic NPC npc = null; bool pastNPC = false; if (projectile.timeLeft < 18) - { + { for (int k = 0; k < Main.maxNPCs; k++) { if (Main.npc[k].active && !Main.npc[k].dontTakeDamage && !Main.npc[k].friendly && Main.npc[k].lifeMax > 5 && !shockedbefore.Contains(Main.npc[k])) @@ -144,7 +144,7 @@ namespace CalamityMod.Projectiles.Magic return false; } - private void AdjustMagnitude(ref Vector2 vector) + private void AdjustMagnitude(ref Vector2 vector) { float magnitude = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y); if (magnitude > 6f) diff --git a/Projectiles/Magic/LiquidBlade.cs b/Projectiles/Magic/LiquidBlade.cs index 81e0024b34..ef1997ec9c 100644 --- a/Projectiles/Magic/LiquidBlade.cs +++ b/Projectiles/Magic/LiquidBlade.cs @@ -122,26 +122,26 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(target.Center); + OnHitEffects(target.Center); target.AddBuff(BuffID.Ichor, 90); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(BuffID.CursedInferno, 90); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffID.CursedInferno, 90); } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(target.Center); + OnHitEffects(target.Center); target.AddBuff(BuffID.Ichor, 90); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(BuffID.CursedInferno, 90); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffID.CursedInferno, 90); } - private void OnHitEffects(Vector2 targetPos) - { - if (projectile.owner == Main.myPlayer) - { - CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), 1f, projectile.owner, true); - } + private void OnHitEffects(Vector2 targetPos) + { + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), 1f, projectile.owner, true); + } } } } diff --git a/Projectiles/Magic/LiquidBlade2.cs b/Projectiles/Magic/LiquidBlade2.cs index 7e2ec513b3..e75bfcf194 100644 --- a/Projectiles/Magic/LiquidBlade2.cs +++ b/Projectiles/Magic/LiquidBlade2.cs @@ -123,8 +123,8 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Ichor, 60); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 60); + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.CursedInferno, 60); } } } diff --git a/Projectiles/Magic/MadAlchemistsCocktailAlt.cs b/Projectiles/Magic/MadAlchemistsCocktailAlt.cs index 99280da03b..1f81acb5d1 100644 --- a/Projectiles/Magic/MadAlchemistsCocktailAlt.cs +++ b/Projectiles/Magic/MadAlchemistsCocktailAlt.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - int duration = 120; + int duration = 120; target.AddBuff(ModContent.BuffType(), duration); target.AddBuff(ModContent.BuffType(), duration); target.AddBuff(ModContent.BuffType(), duration); diff --git a/Projectiles/Magic/MadAlchemistsCocktailGasCloud.cs b/Projectiles/Magic/MadAlchemistsCocktailGasCloud.cs index 9a03b1bc74..89421c9f01 100644 --- a/Projectiles/Magic/MadAlchemistsCocktailGasCloud.cs +++ b/Projectiles/Magic/MadAlchemistsCocktailGasCloud.cs @@ -1,7 +1,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class MadAlchemistsCocktailGasCloud : ModProjectile + public class MadAlchemistsCocktailGasCloud : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs b/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs index 258fa2ba58..1ae76da089 100644 --- a/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs +++ b/Projectiles/Magic/MadAlchemistsCocktailShrapnel.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class MadAlchemistsCocktailShrapnel : ModProjectile + public class MadAlchemistsCocktailShrapnel : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -24,9 +24,9 @@ namespace CalamityMod.Projectiles.Magic projectile.extraUpdates = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { Vector2 value7 = new Vector2(6f, 12f); projectile.localAI[0] += 1f; @@ -50,8 +50,8 @@ namespace CalamityMod.Projectiles.Magic int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 173, 0f, 0f, 100, default, 1f); Main.dust[num458].noGravity = true; - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 12f, 20f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 12f, 20f); } } } diff --git a/Projectiles/Magic/MagneticBeam.cs b/Projectiles/Magic/MagneticBeam.cs index 8244fc3197..fc18ce2ac9 100644 --- a/Projectiles/Magic/MagneticBeam.cs +++ b/Projectiles/Magic/MagneticBeam.cs @@ -20,17 +20,17 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.timeLeft = 90; projectile.magic = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } - public override void AI() - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 1.25f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; - } + public override void AI() + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * 0.25f; + int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 1.25f); + Main.dust[num448].position = vector33; + Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[num448].velocity *= 0.1f; + } } } diff --git a/Projectiles/Magic/MagneticOrb.cs b/Projectiles/Magic/MagneticOrb.cs index 924084c01b..b5a7d0edce 100644 --- a/Projectiles/Magic/MagneticOrb.cs +++ b/Projectiles/Magic/MagneticOrb.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 38; projectile.friendly = true; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 120; projectile.magic = true; } diff --git a/Projectiles/Magic/MagnusBeam.cs b/Projectiles/Magic/MagnusBeam.cs index cf0547c878..c773fdede1 100644 --- a/Projectiles/Magic/MagnusBeam.cs +++ b/Projectiles/Magic/MagnusBeam.cs @@ -134,22 +134,22 @@ namespace CalamityMod.Projectiles.Magic } if (Main.rand.NextBool(12)) { - Vector2 value9 = -Vector2.UnitX.RotatedByRandom(0.2).RotatedBy((double)projectile.velocity.ToRotation(), default); - int num44 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 234, 0f, 0f, 100, default, 1f); - Main.dust[num44].velocity *= 0.1f; - Main.dust[num44].position = projectile.Center + value9 * (float)projectile.width / 2f + projectile.velocity * 2f; - Main.dust[num44].fadeIn = 0.9f; + Vector2 value9 = -Vector2.UnitX.RotatedByRandom(0.2).RotatedBy((double)projectile.velocity.ToRotation(), default); + int num44 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 234, 0f, 0f, 100, default, 1f); + Main.dust[num44].velocity *= 0.1f; + Main.dust[num44].position = projectile.Center + value9 * (float)projectile.width / 2f + projectile.velocity * 2f; + Main.dust[num44].fadeIn = 0.9f; } if (Main.rand.NextBool(64)) { - Vector2 value10 = -Vector2.UnitX.RotatedByRandom(0.4).RotatedBy((double)projectile.velocity.ToRotation(), default); - int num46 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 234, 0f, 0f, 155, default, 0.8f); - Main.dust[num46].velocity *= 0.3f; - Main.dust[num46].position = projectile.Center + value10 * (float)projectile.width / 2f; - if (Main.rand.NextBool(2)) - { - Main.dust[num46].fadeIn = 1.4f; - } + Vector2 value10 = -Vector2.UnitX.RotatedByRandom(0.4).RotatedBy((double)projectile.velocity.ToRotation(), default); + int num46 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 234, 0f, 0f, 155, default, 0.8f); + Main.dust[num46].velocity *= 0.3f; + Main.dust[num46].position = projectile.Center + value10 * (float)projectile.width / 2f; + if (Main.rand.NextBool(2)) + { + Main.dust[num46].fadeIn = 1.4f; + } } if (Main.rand.NextBool(4)) { @@ -202,16 +202,16 @@ namespace CalamityMod.Projectiles.Magic return false; } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 480); - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 480); + target.AddBuff(ModContent.BuffType(), 480); + } - if (!target.canGhostHeal || Main.player[projectile.owner].moonLeech) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 480); + + if (!target.canGhostHeal || Main.player[projectile.owner].moonLeech) return; Player player = Main.player[projectile.owner]; diff --git a/Projectiles/Magic/ManaBolt.cs b/Projectiles/Magic/ManaBolt.cs index f9f274534c..011d1d951e 100644 --- a/Projectiles/Magic/ManaBolt.cs +++ b/Projectiles/Magic/ManaBolt.cs @@ -25,11 +25,11 @@ namespace CalamityMod.Projectiles.Magic { projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * projectile.direction; projectile.velocity *= 0.985f; - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 15, - 107 - }); + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 15, + 107 + }); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } diff --git a/Projectiles/Magic/ManaBoltSmall.cs b/Projectiles/Magic/ManaBoltSmall.cs index 4ab8bc09a8..170f634ed8 100644 --- a/Projectiles/Magic/ManaBoltSmall.cs +++ b/Projectiles/Magic/ManaBoltSmall.cs @@ -22,19 +22,19 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 40 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 40 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - if (projectile.timeLeft < 40) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 450f, 6f, 20f); - else - projectile.velocity *= 0.975f; + if (projectile.timeLeft < 40) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 450f, 6f, 20f); + else + projectile.velocity *= 0.975f; - if (projectile.timeLeft % 4 == 0) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 15, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + if (projectile.timeLeft % 4 == 0) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 15, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/ManaBoltSmall2.cs b/Projectiles/Magic/ManaBoltSmall2.cs index dd3a502460..c7ec698aa1 100644 --- a/Projectiles/Magic/ManaBoltSmall2.cs +++ b/Projectiles/Magic/ManaBoltSmall2.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Magic projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; projectile.velocity.X *= 0.975f; projectile.velocity.Y *= 0.975f; - if (projectile.timeLeft % 4 == 0) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + if (projectile.timeLeft % 4 == 0) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/MeteorStar.cs b/Projectiles/Magic/MeteorStar.cs index 7f52cab9ec..9d98c36864 100644 --- a/Projectiles/Magic/MeteorStar.cs +++ b/Projectiles/Magic/MeteorStar.cs @@ -6,29 +6,29 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class MeteorStar : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Meteor Star"); + public class MeteorStar : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Meteor Star"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; ProjectileID.Sets.TrailingMode[projectile.type] = 0; Main.projFrames[projectile.type] = 3; - } + } - public override void SetDefaults() - { - projectile.width = 42; - projectile.height = 34; - projectile.friendly = true; - projectile.magic = true; - projectile.timeLeft = 361; - } + public override void SetDefaults() + { + projectile.width = 42; + projectile.height = 34; + projectile.friendly = true; + projectile.magic = true; + projectile.timeLeft = 361; + } - public override void AI() - { + public override void AI() + { Player player = Main.player[projectile.owner]; - bool flippedGravity = player.gravDir == -1f; + bool flippedGravity = player.gravDir == -1f; projectile.frameCounter++; if (projectile.frameCounter > 6) @@ -43,170 +43,170 @@ namespace CalamityMod.Projectiles.Magic Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.15f / 255f); - bool explodingSoon = projectile.timeLeft <= 120; - if (projectile.soundDelay <= 0) - { - projectile.soundDelay = 30 + Main.rand.Next(40); - if (explodingSoon) - projectile.soundDelay -= 30; - if (Main.rand.NextBool(10) || explodingSoon) - { - Main.PlaySound(SoundID.Item9, projectile.Center); - } - } - if (Main.rand.NextBool(20) || explodingSoon && Main.rand.NextBool(3)) - { - int idx = Gore.NewGore(projectile.Center, projectile.velocity * 0.2f, Main.rand.Next(16, 18), 1f); - Main.gore[idx].velocity *= 0.66f; - Main.gore[idx].velocity += projectile.velocity * 0.3f; - } - if (explodingSoon) - { - for (int i = 0; i < 3; i++) - { - int smoke = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[smoke]; - dust.velocity *= 0.3f; - dust.position.X = projectile.Center.X + 4f + Main.rand.NextFloat(-6f, 6f); - dust.position.Y = projectile.Center.Y + Main.rand.NextFloat(-6f, 6f); - dust.noGravity = true; - } - } + bool explodingSoon = projectile.timeLeft <= 120; + if (projectile.soundDelay <= 0) + { + projectile.soundDelay = 30 + Main.rand.Next(40); + if (explodingSoon) + projectile.soundDelay -= 30; + if (Main.rand.NextBool(10) || explodingSoon) + { + Main.PlaySound(SoundID.Item9, projectile.Center); + } + } + if (Main.rand.NextBool(20) || explodingSoon && Main.rand.NextBool(3)) + { + int idx = Gore.NewGore(projectile.Center, projectile.velocity * 0.2f, Main.rand.Next(16, 18), 1f); + Main.gore[idx].velocity *= 0.66f; + Main.gore[idx].velocity += projectile.velocity * 0.3f; + } + if (explodingSoon) + { + for (int i = 0; i < 3; i++) + { + int smoke = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[smoke]; + dust.velocity *= 0.3f; + dust.position.X = projectile.Center.X + 4f + Main.rand.NextFloat(-6f, 6f); + dust.position.Y = projectile.Center.Y + Main.rand.NextFloat(-6f, 6f); + dust.noGravity = true; + } + } - if (Main.myPlayer == projectile.owner) - { - if (player.channel) - { - float speed = 14f; - float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - projectile.Center.X; - float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - projectile.Center.Y; - if (player.gravDir == -1f) - { - mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projectile.Center.Y; - } - Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); - float mouseDist = mouseVec.Length(); - if (mouseDist > speed) - { - mouseDist = speed / mouseDist; - mouseVec.X *= mouseDist; - mouseVec.Y *= mouseDist; - int mouseSpeedX = (int)(mouseVec.X * 1000f); - int projSpeedX = (int)(projectile.velocity.X * 1000f); - int mouseSpeedY = (int)(mouseVec.Y * 1000f); - int projSpeedY = (int)(projectile.velocity.Y * 1000f); - if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) - { - projectile.netUpdate = true; - } - projectile.velocity.X = mouseVec.X; - projectile.velocity.Y = mouseVec.Y; - } - else - { - int mouseSpeedX = (int)(mouseVec.X * 1000f); - int projSpeedX = (int)(projectile.velocity.X * 1000f); - int mouseSpeedY = (int)(mouseVec.Y * 1000f); - int projSpeedY = (int)(projectile.velocity.Y * 1000f); - if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) - { - projectile.netUpdate = true; - } - projectile.velocity.X = mouseVec.X; - projectile.velocity.Y = mouseVec.Y; - } - player.direction = (projectile.velocity.X > 0).ToDirectionInt(); - player.velocity = projectile.velocity; - if (projectile.velocity.Y > 16f) - { - projectile.velocity.Y = 16f; - player.velocity.Y = 16f; - } - if (player.mount != null) - { - player.mount.Dismount(player); - } - if (!flippedGravity) - player.Bottom = projectile.Center; - else - player.Top = projectile.Center; - } - else - { - Explode(true); - } - } + if (Main.myPlayer == projectile.owner) + { + if (player.channel) + { + float speed = 14f; + float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - projectile.Center.X; + float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - projectile.Center.Y; + if (player.gravDir == -1f) + { + mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projectile.Center.Y; + } + Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); + float mouseDist = mouseVec.Length(); + if (mouseDist > speed) + { + mouseDist = speed / mouseDist; + mouseVec.X *= mouseDist; + mouseVec.Y *= mouseDist; + int mouseSpeedX = (int)(mouseVec.X * 1000f); + int projSpeedX = (int)(projectile.velocity.X * 1000f); + int mouseSpeedY = (int)(mouseVec.Y * 1000f); + int projSpeedY = (int)(projectile.velocity.Y * 1000f); + if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) + { + projectile.netUpdate = true; + } + projectile.velocity.X = mouseVec.X; + projectile.velocity.Y = mouseVec.Y; + } + else + { + int mouseSpeedX = (int)(mouseVec.X * 1000f); + int projSpeedX = (int)(projectile.velocity.X * 1000f); + int mouseSpeedY = (int)(mouseVec.Y * 1000f); + int projSpeedY = (int)(projectile.velocity.Y * 1000f); + if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) + { + projectile.netUpdate = true; + } + projectile.velocity.X = mouseVec.X; + projectile.velocity.Y = mouseVec.Y; + } + player.direction = (projectile.velocity.X > 0).ToDirectionInt(); + player.velocity = projectile.velocity; + if (projectile.velocity.Y > 16f) + { + projectile.velocity.Y = 16f; + player.velocity.Y = 16f; + } + if (player.mount != null) + { + player.mount.Dismount(player); + } + if (!flippedGravity) + player.Bottom = projectile.Center; + else + player.Top = projectile.Center; + } + else + { + Explode(true); + } + } - projectile.tileCollide = projectile.velocity != Vector2.Zero && ++projectile.ai[0] >= 5f; + projectile.tileCollide = projectile.velocity != Vector2.Zero && ++projectile.ai[0] >= 5f; // Die immediately if the owner of this projectile is clipping into tiles because of its movement. if (Collision.SolidCollision(player.position, player.width, player.height) && projectile.velocity != Vector2.Zero) { player.velocity.Y = 0f; - Explode(); + Explode(); } - if (projectile.timeLeft <= 1) - Explode(); - } + if (projectile.timeLeft <= 1) + Explode(); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => Explode(); + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => Explode(); - public override void OnHitPvp(Player target, int damage, bool crit) => Explode(); + public override void OnHitPvp(Player target, int damage, bool crit) => Explode(); public override bool OnTileCollide(Vector2 oldVelocity) { - Explode(); + Explode(); return base.OnTileCollide(oldVelocity); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - // Draw the main texture in fullbright - Texture2D texture = Main.projectileTexture[projectile.type]; + // Draw the main texture in fullbright + Texture2D texture = Main.projectileTexture[projectile.type]; - int frameHeight = texture.Height / Main.projFrames[projectile.type]; - int frameY = frameHeight * projectile.frame; - float scale = projectile.scale; - float rotation = projectile.rotation; + int frameHeight = texture.Height / Main.projFrames[projectile.type]; + int frameY = frameHeight * projectile.frame; + float scale = projectile.scale; + float rotation = projectile.rotation; - Rectangle rectangle = new Rectangle(0, frameY, texture.Width, frameHeight); - Vector2 origin = rectangle.Size() / 2f; + Rectangle rectangle = new Rectangle(0, frameY, texture.Width, frameHeight); + Vector2 origin = rectangle.Size() / 2f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), rectangle, Color.White, rotation, origin, scale, spriteEffects, 0f); - return false; - } + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), rectangle, Color.White, rotation, origin, scale, spriteEffects, 0f); + return false; + } - private void Explode(bool reducedDmg = false) - { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 64); - Main.PlaySound(SoundID.Item14, projectile.Center); - Vector2 spawnPos = projectile.Center; - spawnPos.Y -= 70f; - if (reducedDmg) - projectile.damage /= 6; - Projectile.NewProjectile(spawnPos, Vector2.Zero, ModContent.ProjectileType(), projectile.damage * 3, projectile.knockBack * 3f, projectile.owner, reducedDmg.ToInt()); + private void Explode(bool reducedDmg = false) + { + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 64); + Main.PlaySound(SoundID.Item14, projectile.Center); + Vector2 spawnPos = projectile.Center; + spawnPos.Y -= 70f; + if (reducedDmg) + projectile.damage /= 6; + Projectile.NewProjectile(spawnPos, Vector2.Zero, ModContent.ProjectileType(), projectile.damage * 3, projectile.knockBack * 3f, projectile.owner, reducedDmg.ToInt()); - for (int i = 0; i < 10; i++) - { - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1.2f); - Main.dust[idx].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[idx].scale = 0.5f; - Main.dust[idx].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int i = 0; i < 5; i++) - { - Gore.NewGore(projectile.position, projectile.velocity * 0.05f, Main.rand.Next(16, 18), 1f); - } - projectile.Kill(); - } - } + for (int i = 0; i < 10; i++) + { + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1.2f); + Main.dust[idx].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[idx].scale = 0.5f; + Main.dust[idx].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int i = 0; i < 5; i++) + { + Gore.NewGore(projectile.position, projectile.velocity * 0.05f, Main.rand.Next(16, 18), 1f); + } + projectile.Kill(); + } + } } diff --git a/Projectiles/Magic/MeteorStarExplosion.cs b/Projectiles/Magic/MeteorStarExplosion.cs index e365fd996f..4d5daf07cf 100644 --- a/Projectiles/Magic/MeteorStarExplosion.cs +++ b/Projectiles/Magic/MeteorStarExplosion.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class MeteorStarExplosion : ModProjectile + public class MeteorStarExplosion : ModProjectile { public override void SetStaticDefaults() { @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = Main.projFrames[projectile.type] * 5; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 35; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.hostile = true; } @@ -34,27 +34,27 @@ namespace CalamityMod.Projectiles.Magic public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { damage = Main.rand.Next(GloriousEnd.PlayerExplosionDmgMin, GloriousEnd.PlayerExplosionDmgMax + 1); - if (Main.expertMode) - damage /= 2; - if (projectile.ai[0] == 1f) - damage /= 2; + if (Main.expertMode) + damage /= 2; + if (projectile.ai[0] == 1f) + damage /= 2; } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (target.townNPC) - { - damage = Main.rand.Next(GloriousEnd.PlayerExplosionDmgMin, GloriousEnd.PlayerExplosionDmgMax + 1); - if (Main.expertMode) - damage /= 2; - if (projectile.ai[0] == 1f) - damage /= 2; - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (target.townNPC) + { + damage = Main.rand.Next(GloriousEnd.PlayerExplosionDmgMin, GloriousEnd.PlayerExplosionDmgMax + 1); + if (Main.expertMode) + damage /= 2; + if (projectile.ai[0] == 1f) + damage /= 2; + } + } + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.GiveIFrames(target.longInvince ? 100 : 60, true); } - - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.GiveIFrames(target.longInvince ? 100 : 60, true); - } } } diff --git a/Projectiles/Magic/MiasmaGas.cs b/Projectiles/Magic/MiasmaGas.cs index d579a02009..5ebdd10546 100644 --- a/Projectiles/Magic/MiasmaGas.cs +++ b/Projectiles/Magic/MiasmaGas.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Magic { target.AddBuff(ModContent.BuffType(), 180); projectile.ai[1] = 1f; - } + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Magic/NebulaElementalBeam.cs b/Projectiles/Magic/NebulaElementalBeam.cs index e59f42d0d2..aa1feb5c1f 100644 --- a/Projectiles/Magic/NebulaElementalBeam.cs +++ b/Projectiles/Magic/NebulaElementalBeam.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class NebulaElementalBeam : BaseLaserbeamProjectile + public class NebulaElementalBeam : BaseLaserbeamProjectile { public override float MaxScale => 1.4f; public override float MaxLaserLength => 1000f; diff --git a/Projectiles/Magic/NettleRight.cs b/Projectiles/Magic/NettleRight.cs index 00369b457f..9981633d4d 100644 --- a/Projectiles/Magic/NettleRight.cs +++ b/Projectiles/Magic/NettleRight.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class NettleRight : ModProjectile + public class NettleRight : ModProjectile { public override void SetStaticDefaults() { @@ -13,58 +13,58 @@ namespace CalamityMod.Projectiles.Magic public override void SetDefaults() { - projectile.width = 28; - projectile.height = 28; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.tileCollide = false; - projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.magic = true; - projectile.aiStyle = 4; + projectile.width = 28; + projectile.height = 28; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.magic = true; + projectile.aiStyle = 4; } - public override void AI() - { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; - if (projectile.ai[0] == 0f) - { - projectile.alpha -= 50; - if (projectile.alpha > 0) - return; - projectile.alpha = 0; - projectile.ai[0] = 1f; - if (projectile.ai[1] == 0f) - { - projectile.ai[1] += 1f; - projectile.position += projectile.velocity * 1f; - } - if (Main.myPlayer == projectile.owner) - { - int type = projectile.type; - if (projectile.ai[1] >= 10f) - type = ModContent.ProjectileType(); - int number = Projectile.NewProjectile(projectile.position.X + projectile.velocity.X + (float)(projectile.width / 2), projectile.position.Y + projectile.velocity.Y + (float)(projectile.height / 2), projectile.velocity.X, projectile.velocity.Y, type, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[number].ai[1] = projectile.ai[1] + 1f; - } - } - else - { - if (projectile.alpha < 170 && projectile.alpha + 5 >= 170) - { - for (int index1 = 0; index1 < 8; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 7, projectile.velocity.X * 0.025f, projectile.velocity.Y * 0.025f, 200, new Color(), 1.3f); - Dust dust = Main.dust[index2]; - dust.noGravity = true; - dust.velocity *= 0.5f; - } - } - projectile.alpha += 3; - if (projectile.alpha < 255) - return; - projectile.Kill(); - } - } + public override void AI() + { + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; + if (projectile.ai[0] == 0f) + { + projectile.alpha -= 50; + if (projectile.alpha > 0) + return; + projectile.alpha = 0; + projectile.ai[0] = 1f; + if (projectile.ai[1] == 0f) + { + projectile.ai[1] += 1f; + projectile.position += projectile.velocity * 1f; + } + if (Main.myPlayer == projectile.owner) + { + int type = projectile.type; + if (projectile.ai[1] >= 10f) + type = ModContent.ProjectileType(); + int number = Projectile.NewProjectile(projectile.position.X + projectile.velocity.X + (float)(projectile.width / 2), projectile.position.Y + projectile.velocity.Y + (float)(projectile.height / 2), projectile.velocity.X, projectile.velocity.Y, type, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Main.projectile[number].ai[1] = projectile.ai[1] + 1f; + } + } + else + { + if (projectile.alpha < 170 && projectile.alpha + 5 >= 170) + { + for (int index1 = 0; index1 < 8; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 7, projectile.velocity.X * 0.025f, projectile.velocity.Y * 0.025f, 200, new Color(), 1.3f); + Dust dust = Main.dust[index2]; + dust.noGravity = true; + dust.velocity *= 0.5f; + } + } + projectile.alpha += 3; + if (projectile.alpha < 255) + return; + projectile.Kill(); + } + } } } diff --git a/Projectiles/Magic/NettleTip.cs b/Projectiles/Magic/NettleTip.cs index 9ba21f48b7..11d18a41c4 100644 --- a/Projectiles/Magic/NettleTip.cs +++ b/Projectiles/Magic/NettleTip.cs @@ -2,7 +2,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class NettleTip : ModProjectile + public class NettleTip : ModProjectile { public override void SetStaticDefaults() { @@ -11,16 +11,16 @@ namespace CalamityMod.Projectiles.Magic public override void SetDefaults() { - projectile.width = 28; - projectile.height = 28; - projectile.aiStyle = 4; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.tileCollide = false; - projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.magic = true; - aiType = ProjectileID.NettleBurstEnd; + projectile.width = 28; + projectile.height = 28; + projectile.aiStyle = 4; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.magic = true; + aiType = ProjectileID.NettleBurstEnd; } } } diff --git a/Projectiles/Magic/NightBolt.cs b/Projectiles/Magic/NightBolt.cs index b55dd36601..1804429148 100644 --- a/Projectiles/Magic/NightBolt.cs +++ b/Projectiles/Magic/NightBolt.cs @@ -20,20 +20,20 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.timeLeft = 30; projectile.magic = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { - for (int num447 = 0; num447 < 2; num447++) - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * ((float)num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, 27, 0f, 0f, 0, default, 1.25f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; - } + for (int num447 = 0; num447 < 2; num447++) + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * ((float)num447 * 0.25f); + int num448 = Dust.NewDust(vector33, 1, 1, 27, 0f, 0f, 0, default, 1.25f); + Main.dust[num448].position = vector33; + Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; + Main.dust[num448].velocity *= 0.1f; + } } } } diff --git a/Projectiles/Magic/NightOrb.cs b/Projectiles/Magic/NightOrb.cs index c637119196..82dabaff4b 100644 --- a/Projectiles/Magic/NightOrb.cs +++ b/Projectiles/Magic/NightOrb.cs @@ -1,7 +1,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class NightOrb : ModProjectile + public class NightOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -19,12 +19,12 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.timeLeft = 30; projectile.magic = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 24f, 5, ModContent.ProjectileType()); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 24f, 5, ModContent.ProjectileType()); } } } diff --git a/Projectiles/Magic/NuclearFuryProjectile.cs b/Projectiles/Magic/NuclearFuryProjectile.cs index df22d82964..ae1127582e 100644 --- a/Projectiles/Magic/NuclearFuryProjectile.cs +++ b/Projectiles/Magic/NuclearFuryProjectile.cs @@ -30,98 +30,98 @@ namespace CalamityMod.Projectiles.Magic projectile.ignoreWater = true; } - public override void AI() - { - projectile.localAI[1] += 1f; - if (projectile.localAI[1] > 10f && Main.rand.NextBool(3)) - { - int num = 6; - for (int index1 = 0; index1 < num; ++index1) - { - Vector2 vector2_1 = (Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width, (float)projectile.height) / 2f).RotatedBy((double)(index1 - (num / 2 - 1)) * Math.PI / (double)num, new Vector2()) + projectile.Center; - Vector2 vector2_2 = ((Main.rand.NextFloat() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); - int index2 = Dust.NewDust(vector2_1 + vector2_2, 0, 0, 217, vector2_2.X * 2f, vector2_2.Y * 2f, 100, new Color(), 1.4f); - Dust dust = Main.dust[index2]; - dust.noGravity = true; - dust.noLight = true; - dust.velocity /= 4f; - dust.velocity -= projectile.velocity; - } - projectile.alpha -= 5; - if (projectile.alpha < 50) - projectile.alpha = 50; - Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, 0.1f, 0.4f, 0.6f); - } - projectile.rotation += projectile.velocity.X * 0.1f; - int num1 = -1; - Vector2 targetVec = projectile.Center; - float maxDistance = 500f; - if (projectile.localAI[0] > 0f) - { - projectile.localAI[0] -= 1f; - } - if (projectile.ai[0] == 0f && projectile.localAI[0] == 0f) - { - for (int index = 0; index < Main.maxNPCs; ++index) - { - NPC npc = Main.npc[index]; - if (npc.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == (index + 1f))) - { - float extraDistance = (npc.width / 2) + (npc.height / 2); + public override void AI() + { + projectile.localAI[1] += 1f; + if (projectile.localAI[1] > 10f && Main.rand.NextBool(3)) + { + int num = 6; + for (int index1 = 0; index1 < num; ++index1) + { + Vector2 vector2_1 = (Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width, (float)projectile.height) / 2f).RotatedBy((double)(index1 - (num / 2 - 1)) * Math.PI / (double)num, new Vector2()) + projectile.Center; + Vector2 vector2_2 = ((Main.rand.NextFloat() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * (float)Main.rand.Next(3, 8); + int index2 = Dust.NewDust(vector2_1 + vector2_2, 0, 0, 217, vector2_2.X * 2f, vector2_2.Y * 2f, 100, new Color(), 1.4f); + Dust dust = Main.dust[index2]; + dust.noGravity = true; + dust.noLight = true; + dust.velocity /= 4f; + dust.velocity -= projectile.velocity; + } + projectile.alpha -= 5; + if (projectile.alpha < 50) + projectile.alpha = 50; + Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, 0.1f, 0.4f, 0.6f); + } + projectile.rotation += projectile.velocity.X * 0.1f; + int num1 = -1; + Vector2 targetVec = projectile.Center; + float maxDistance = 500f; + if (projectile.localAI[0] > 0f) + { + projectile.localAI[0] -= 1f; + } + if (projectile.ai[0] == 0f && projectile.localAI[0] == 0f) + { + for (int index = 0; index < Main.maxNPCs; ++index) + { + NPC npc = Main.npc[index]; + if (npc.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == (index + 1f))) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); - bool canHit = true; - if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - float npcDist = Vector2.Distance(npc.Center, targetVec); - if (npcDist < (maxDistance + extraDistance) && canHit) - { - maxDistance = npcDist; - targetVec = npc.Center; - num1 = index; - } - } - } - if (num1 >= 0) - { - projectile.ai[0] = num1 + 1f; - projectile.netUpdate = true; - } - } - if (projectile.localAI[0] == 0f && projectile.ai[0] == 0f) - projectile.localAI[0] = 30f; - bool flag = false; - if (projectile.ai[0] != 0f) - { - int index = (int)(projectile.ai[0] - 1); - if (Main.npc[index].active && !Main.npc[index].dontTakeDamage && Main.npc[index].immune[projectile.owner] == 0) - { - if ((Math.Abs(projectile.Center.X - Main.npc[index].Center.X) + Math.Abs(projectile.Center.Y - Main.npc[index].Center.Y)) < 1000f) - { - flag = true; - targetVec = Main.npc[index].Center; - } - } - else - { - projectile.ai[0] = 0f; - flag = false; - projectile.netUpdate = true; - } - } - if (flag) - { - double num3 = (double)(targetVec - projectile.Center).ToRotation() - (double)projectile.velocity.ToRotation(); - if (num3 > Math.PI) - num3 -= 2.0 * Math.PI; - if (num3 < -1.0 * Math.PI) - num3 += 2.0 * Math.PI; - projectile.velocity = projectile.velocity.RotatedBy(num3 * 0.1, new Vector2()); - } - float num4 = projectile.velocity.Length(); - projectile.velocity.Normalize(); - projectile.velocity = projectile.velocity * (num4 + 1f / 400f); - } + float npcDist = Vector2.Distance(npc.Center, targetVec); + if (npcDist < (maxDistance + extraDistance) && canHit) + { + maxDistance = npcDist; + targetVec = npc.Center; + num1 = index; + } + } + } + if (num1 >= 0) + { + projectile.ai[0] = num1 + 1f; + projectile.netUpdate = true; + } + } + if (projectile.localAI[0] == 0f && projectile.ai[0] == 0f) + projectile.localAI[0] = 30f; + bool flag = false; + if (projectile.ai[0] != 0f) + { + int index = (int)(projectile.ai[0] - 1); + if (Main.npc[index].active && !Main.npc[index].dontTakeDamage && Main.npc[index].immune[projectile.owner] == 0) + { + if ((Math.Abs(projectile.Center.X - Main.npc[index].Center.X) + Math.Abs(projectile.Center.Y - Main.npc[index].Center.Y)) < 1000f) + { + flag = true; + targetVec = Main.npc[index].Center; + } + } + else + { + projectile.ai[0] = 0f; + flag = false; + projectile.netUpdate = true; + } + } + if (flag) + { + double num3 = (double)(targetVec - projectile.Center).ToRotation() - (double)projectile.velocity.ToRotation(); + if (num3 > Math.PI) + num3 -= 2.0 * Math.PI; + if (num3 < -1.0 * Math.PI) + num3 += 2.0 * Math.PI; + projectile.velocity = projectile.velocity.RotatedBy(num3 * 0.1, new Vector2()); + } + float num4 = projectile.velocity.Length(); + projectile.velocity.Normalize(); + projectile.velocity = projectile.velocity * (num4 + 1f / 400f); + } public override void Kill(int timeLeft) { @@ -141,18 +141,18 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.buffImmune[BuffID.Wet] = false; //I'm not sorry - target.AddBuff(BuffID.Wet, 600); - if (projectile.ai[1] != 1f) //Nuclear Fury - { - target.immune[projectile.owner] = 5; - } + target.buffImmune[BuffID.Wet] = false; //I'm not sorry + target.AddBuff(BuffID.Wet, 600); + if (projectile.ai[1] != 1f) //Nuclear Fury + { + target.immune[projectile.owner] = 5; + } } public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(BuffID.Wet, 600); - } + target.AddBuff(BuffID.Wet, 600); + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Magic/ParticleBeamofDoom.cs b/Projectiles/Magic/ParticleBeamofDoom.cs index 3acda19dad..1eb4d08eca 100644 --- a/Projectiles/Magic/ParticleBeamofDoom.cs +++ b/Projectiles/Magic/ParticleBeamofDoom.cs @@ -28,15 +28,15 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 9f) - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 206, 0f, 0f, 0, default, 2.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].velocity *= 0.1f; - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 9f) + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * 0.25f; + int num448 = Dust.NewDust(vector33, 1, 1, 206, 0f, 0f, 0, default, 2.5f); + Main.dust[num448].position = vector33; + Main.dust[num448].velocity *= 0.1f; + } } } } diff --git a/Projectiles/Magic/Phantom.cs b/Projectiles/Magic/Phantom.cs index b60d0e5070..3c2dd9a953 100644 --- a/Projectiles/Magic/Phantom.cs +++ b/Projectiles/Magic/Phantom.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class Phantom : ModProjectile + public class Phantom : ModProjectile { public override void SetStaticDefaults() { @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Magic Main.dust[num458].noGravity = true; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); } } } diff --git a/Projectiles/Magic/PlasmaShot.cs b/Projectiles/Magic/PlasmaShot.cs index 604d6ca0bf..b6977b5b4c 100644 --- a/Projectiles/Magic/PlasmaShot.cs +++ b/Projectiles/Magic/PlasmaShot.cs @@ -49,10 +49,10 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i < cloudAmt; i++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); Projectile cloud = Projectile.NewProjectileDirect(projectile.Center, velocity, ProjectileID.ToxicCloud + Main.rand.Next(3), projectile.damage, 1f, projectile.owner, 0f, Main.rand.Next(-45, 1)); - cloud.usesIDStaticNPCImmunity = true; - cloud.idStaticNPCHitCooldown = 10; + cloud.usesIDStaticNPCImmunity = true; + cloud.idStaticNPCHitCooldown = 10; } } for (int k = 0; k < 5; k++) diff --git a/Projectiles/Magic/PoseidonTyphoon.cs b/Projectiles/Magic/PoseidonTyphoon.cs index faa8f40130..4ccd3efb2c 100644 --- a/Projectiles/Magic/PoseidonTyphoon.cs +++ b/Projectiles/Magic/PoseidonTyphoon.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class PoseidonTyphoon : ModProjectile + public class PoseidonTyphoon : ModProjectile { public override void SetStaticDefaults() { @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Magic { projectile.rotation += projectile.velocity.X * 0.05f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 6f, 30f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 6f, 30f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Magic/PrinceFlameSmall.cs b/Projectiles/Magic/PrinceFlameSmall.cs index 44d2a739a5..efc2e96b9d 100644 --- a/Projectiles/Magic/PrinceFlameSmall.cs +++ b/Projectiles/Magic/PrinceFlameSmall.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class PrinceFlameSmall : ModProjectile + public class PrinceFlameSmall : ModProjectile { public ref float Time => ref projectile.ai[0]; public const int AttackDelay = 12; @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = 240; projectile.penetrate = 1; projectile.magic = true; - projectile.extraUpdates = 2; + projectile.extraUpdates = 2; } public override void AI() @@ -50,11 +50,11 @@ namespace CalamityMod.Projectiles.Magic return false; } - public override bool? CanHitNPC(NPC target) - { - if (Time > AttackDelay) - return null; - return false; + public override bool? CanHitNPC(NPC target) + { + if (Time > AttackDelay) + return null; + return false; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Magic/RainbowRocket.cs b/Projectiles/Magic/RainbowRocket.cs index 6b2b51ff60..66e52ea44c 100644 --- a/Projectiles/Magic/RainbowRocket.cs +++ b/Projectiles/Magic/RainbowRocket.cs @@ -52,8 +52,8 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; } - #region AI - public override void AI() + #region AI + public override void AI() { Time++; Lighting.AddLight(projectile.Center, Main.hslToRgb((float)Math.Sin(Time / 20f) * 0.5f + 0.5f, 0.9f, 0.9f).ToVector3()); @@ -152,10 +152,10 @@ namespace CalamityMod.Projectiles.Magic 0f); return false; } - #endregion + #endregion - #region Kill Effects - public override void Kill(int timeLeft) + #region Kill Effects + public override void Kill(int timeLeft) { if (projectile.owner == Main.myPlayer) { @@ -207,10 +207,10 @@ namespace CalamityMod.Projectiles.Magic break; } } - #endregion + #endregion - #region Pink Mark - public void PinkMarkExplosionDust() + #region Pink Mark + public void PinkMarkExplosionDust() { // Spawn the main balloon. BalloonExplosionDust(projectile.Center, Main.rand.NextFloat(8f, 15f), Color.Yellow); diff --git a/Projectiles/Magic/RancorHoldout.cs b/Projectiles/Magic/RancorHoldout.cs index 45d59e908e..5a0d21eea0 100644 --- a/Projectiles/Magic/RancorHoldout.cs +++ b/Projectiles/Magic/RancorHoldout.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class RancorHoldout : ModProjectile + public class RancorHoldout : ModProjectile { public Player Owner => Main.player[projectile.owner]; public ref float Time => ref projectile.ai[0]; diff --git a/Projectiles/Magic/RedirectingFire.cs b/Projectiles/Magic/RedirectingFire.cs index 0f4734b43b..1a80d56d0c 100644 --- a/Projectiles/Magic/RedirectingFire.cs +++ b/Projectiles/Magic/RedirectingFire.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class RedirectingFire : ModProjectile + public class RedirectingFire : ModProjectile { public ref float BurstIntensity => ref projectile.ai[0]; public ref float Time => ref projectile.ai[1]; diff --git a/Projectiles/Magic/RedirectingGildedSoul.cs b/Projectiles/Magic/RedirectingGildedSoul.cs index d54269ddb3..7cbd836204 100644 --- a/Projectiles/Magic/RedirectingGildedSoul.cs +++ b/Projectiles/Magic/RedirectingGildedSoul.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class RedirectingGildedSoul : ModProjectile + public class RedirectingGildedSoul : ModProjectile { public ref float BurstIntensity => ref projectile.ai[0]; public ref float Time => ref projectile.ai[1]; diff --git a/Projectiles/Magic/RedirectingLostSoul.cs b/Projectiles/Magic/RedirectingLostSoul.cs index d11a8cf8a8..34e533869b 100644 --- a/Projectiles/Magic/RedirectingLostSoul.cs +++ b/Projectiles/Magic/RedirectingLostSoul.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class RedirectingLostSoul : ModProjectile + public class RedirectingLostSoul : ModProjectile { public ref float BurstIntensity => ref projectile.ai[0]; public ref float Time => ref projectile.ai[1]; diff --git a/Projectiles/Magic/RedirectingVengefulSoul.cs b/Projectiles/Magic/RedirectingVengefulSoul.cs index fd9ce2250c..45bde8c05e 100644 --- a/Projectiles/Magic/RedirectingVengefulSoul.cs +++ b/Projectiles/Magic/RedirectingVengefulSoul.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class RedirectingVengefulSoul : ModProjectile + public class RedirectingVengefulSoul : ModProjectile { public ref float BurstIntensity => ref projectile.ai[0]; public ref float Time => ref projectile.ai[1]; diff --git a/Projectiles/Magic/RougeSlashLarge.cs b/Projectiles/Magic/RougeSlashLarge.cs index 3908dbef0d..7183c7051a 100644 --- a/Projectiles/Magic/RougeSlashLarge.cs +++ b/Projectiles/Magic/RougeSlashLarge.cs @@ -35,8 +35,8 @@ namespace CalamityMod.Projectiles.Magic projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - if (projectile.alpha > 0) - projectile.alpha -= 17; + if (projectile.alpha > 0) + projectile.alpha -= 17; projectile.localAI[1] += 1f; if (projectile.localAI[1] == 12f) diff --git a/Projectiles/Magic/RougeSlashMedium.cs b/Projectiles/Magic/RougeSlashMedium.cs index 6e3c4ac021..4a72e90e03 100644 --- a/Projectiles/Magic/RougeSlashMedium.cs +++ b/Projectiles/Magic/RougeSlashMedium.cs @@ -35,10 +35,10 @@ namespace CalamityMod.Projectiles.Magic projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - if (projectile.alpha > 0) - projectile.alpha -= 17; + if (projectile.alpha > 0) + projectile.alpha -= 17; - projectile.localAI[1] += 1f; + projectile.localAI[1] += 1f; if (projectile.localAI[1] == 12f) { projectile.localAI[1] = 0f; diff --git a/Projectiles/Magic/RougeSlashSmall.cs b/Projectiles/Magic/RougeSlashSmall.cs index 5d61c1bb18..bd0d06f761 100644 --- a/Projectiles/Magic/RougeSlashSmall.cs +++ b/Projectiles/Magic/RougeSlashSmall.cs @@ -35,10 +35,10 @@ namespace CalamityMod.Projectiles.Magic projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - if (projectile.alpha > 0) - projectile.alpha -= 17; + if (projectile.alpha > 0) + projectile.alpha -= 17; - projectile.localAI[1] += 1f; + projectile.localAI[1] += 1f; if (projectile.localAI[1] == 12f) { projectile.localAI[1] = 0f; diff --git a/Projectiles/Magic/SHPL.cs b/Projectiles/Magic/SHPL.cs index 256a339cba..6276d6a6b1 100644 --- a/Projectiles/Magic/SHPL.cs +++ b/Projectiles/Magic/SHPL.cs @@ -66,12 +66,12 @@ namespace CalamityMod.Projectiles.Magic int dustAmt = Main.rand.Next(3, 7); for (int d = 0; d < dustAmt; d++) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 246, - 73, - 187 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 246, + 73, + 187 + }); int idx = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, dustType, 0f, 0f, 100, default, 2.1f); Main.dust[idx].velocity *= 2f; Main.dust[idx].noGravity = true; diff --git a/Projectiles/Magic/SeethingDischargeBrimstoneHellblast.cs b/Projectiles/Magic/SeethingDischargeBrimstoneHellblast.cs index 7fde79c1bc..e79a9d2f49 100644 --- a/Projectiles/Magic/SeethingDischargeBrimstoneHellblast.cs +++ b/Projectiles/Magic/SeethingDischargeBrimstoneHellblast.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Projectiles.Magic { public class SeethingDischargeBrimstoneHellblast : ModProjectile { - private bool initialized = false; + private bool initialized = false; public override string Texture => "CalamityMod/Projectiles/Boss/BrimstoneHellblast"; public override void SetStaticDefaults() @@ -36,16 +36,16 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - if (!initialized) - { - if (projectile.npcProj) - { - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 5; - projectile.penetrate = 10; - } - initialized = true; - } + if (!initialized) + { + if (projectile.npcProj) + { + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 5; + projectile.penetrate = 10; + } + initialized = true; + } projectile.frameCounter++; if (projectile.frameCounter >= 10) { diff --git a/Projectiles/Magic/ShadeNimbus.cs b/Projectiles/Magic/ShadeNimbus.cs index 969281b540..0e44a8f697 100644 --- a/Projectiles/Magic/ShadeNimbus.cs +++ b/Projectiles/Magic/ShadeNimbus.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Magic int projType = projectile.type; for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) { - Projectile proj = Main.projectile[projIndex]; + Projectile proj = Main.projectile[projIndex]; if (proj.active && proj.owner == projectile.owner && proj.type == projType && proj.ai[1] < 3600f) { projCount++; @@ -89,14 +89,14 @@ namespace CalamityMod.Projectiles.Magic } } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 60); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 60); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 60); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 60); + } + } } diff --git a/Projectiles/Magic/ShadecrystalProjectile.cs b/Projectiles/Magic/ShadecrystalProjectile.cs index 47a2db00fe..8126acfed4 100644 --- a/Projectiles/Magic/ShadecrystalProjectile.cs +++ b/Projectiles/Magic/ShadecrystalProjectile.cs @@ -40,8 +40,8 @@ namespace CalamityMod.Projectiles.Magic projectile.velocity *= 0.99f; - projectile.ai[1] += 1f; - if (projectile.ai[1] > 90f) + projectile.ai[1] += 1f; + if (projectile.ai[1] > 90f) { projectile.scale -= 0.05f; if (projectile.scale <= 0.2) @@ -54,18 +54,18 @@ namespace CalamityMod.Projectiles.Magic } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.velocity.X != oldVelocity.X) - projectile.velocity.X = -oldVelocity.X; + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (projectile.velocity.X != oldVelocity.X) + projectile.velocity.X = -oldVelocity.X; - if (projectile.velocity.Y != oldVelocity.Y) - projectile.velocity.Y = -oldVelocity.Y; + if (projectile.velocity.Y != oldVelocity.Y) + projectile.velocity.Y = -oldVelocity.Y; - return false; - } + return false; + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { for (int k = 0; k < 5; k++) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 70, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); diff --git a/Projectiles/Magic/Shaderain.cs b/Projectiles/Magic/Shaderain.cs index e73462e83a..31e557ea19 100644 --- a/Projectiles/Magic/Shaderain.cs +++ b/Projectiles/Magic/Shaderain.cs @@ -42,14 +42,14 @@ namespace CalamityMod.Projectiles.Magic dust.scale = 0.95f; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 60); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 60); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 60); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 60); + } + } } diff --git a/Projectiles/Magic/Shadowbolt.cs b/Projectiles/Magic/Shadowbolt.cs index f48ac116cf..f84329dc0c 100644 --- a/Projectiles/Magic/Shadowbolt.cs +++ b/Projectiles/Magic/Shadowbolt.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class Shadowbolt : ModProjectile + public class Shadowbolt : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -49,10 +49,10 @@ namespace CalamityMod.Projectiles.Magic return false; } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - projectile.damage = (int)(projectile.damage * 1.15); - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + projectile.damage = (int)(projectile.damage * 1.15); + } public override void AI() { diff --git a/Projectiles/Magic/ShiftingSandsProj.cs b/Projectiles/Magic/ShiftingSandsProj.cs index 92e65748bb..bafe24ae78 100644 --- a/Projectiles/Magic/ShiftingSandsProj.cs +++ b/Projectiles/Magic/ShiftingSandsProj.cs @@ -7,158 +7,158 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class ShiftingSandsProj : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shifting Sands"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public class ShiftingSandsProj : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shifting Sands"); + 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 = 5; - projectile.magic = true; - projectile.extraUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - } + public override void SetDefaults() + { + projectile.width = 18; + projectile.height = 18; + projectile.friendly = true; + projectile.penetrate = 5; + projectile.magic = true; + projectile.extraUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } - public override void AI() - { - if (projectile.soundDelay == 0 && Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) > 2f) - { - projectile.soundDelay = 10; - Main.PlaySound(SoundID.Item20, projectile.Center); - } - int sand = Dust.NewDust(projectile.position, projectile.width, projectile.height, 85, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[sand]; - dust.velocity *= 0.3f; - dust.position.X = projectile.Center.X + 4f + (float)Main.rand.Next(-4, 5); - dust.position.Y = projectile.Center.Y + (float)Main.rand.Next(-4, 5); - dust.noGravity = true; + public override void AI() + { + if (projectile.soundDelay == 0 && Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) > 2f) + { + projectile.soundDelay = 10; + Main.PlaySound(SoundID.Item20, projectile.Center); + } + int sand = Dust.NewDust(projectile.position, projectile.width, projectile.height, 85, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[sand]; + dust.velocity *= 0.3f; + dust.position.X = projectile.Center.X + 4f + (float)Main.rand.Next(-4, 5); + dust.position.Y = projectile.Center.Y + (float)Main.rand.Next(-4, 5); + dust.noGravity = true; - if (Main.myPlayer == projectile.owner && projectile.ai[0] <= 0f) - { - Player player = Main.player[projectile.owner]; - if (player.channel) - { - float speed = 18f; - float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - projectile.Center.X; - float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - projectile.Center.Y; - if (player.gravDir == -1f) - { - mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projectile.Center.Y; - } - Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); - float mouseDist = mouseVec.Length(); - if (projectile.ai[0] < 0f) - { - projectile.ai[0] += 1f; - } - if (mouseDist > speed) - { - mouseDist = speed / mouseDist; - mouseVec.X *= mouseDist; - mouseVec.Y *= mouseDist; - int mouseSpeedX = (int)(mouseVec.X * 1000f); - int projSpeedX = (int)(projectile.velocity.X * 1000f); - int mouseSpeedY = (int)(mouseVec.Y * 1000f); - int projSpeedY = (int)(projectile.velocity.Y * 1000f); - if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) - { - projectile.netUpdate = true; - } - projectile.velocity.X = mouseVec.X; - projectile.velocity.Y = mouseVec.Y; - } - else - { - int mouseSpeedX = (int)(mouseVec.X * 1000f); - int projSpeedX = (int)(projectile.velocity.X * 1000f); - int mouseSpeedY = (int)(mouseVec.Y * 1000f); - int projSpeedY = (int)(projectile.velocity.Y * 1000f); - if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) - { - projectile.netUpdate = true; - } - projectile.velocity.X = mouseVec.X; - projectile.velocity.Y = mouseVec.Y; - } - } - else if (projectile.ai[0] <= 0f) - { - projectile.netUpdate = true; - float speed = 12f; - Vector2 projCenter = projectile.Center; - float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - projCenter.X; - float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - projCenter.Y; - if (player.gravDir == -1f) - { - mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projCenter.Y; - } - Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); - float mouseDist = mouseVec.Length(); - if (mouseDist == 0f || projectile.ai[0] < 0f) - { - projCenter = player.Center; - mouseVec = projectile.Center - projCenter; - mouseDist = mouseVec.Length(); - } - mouseDist = speed / mouseDist; - mouseVec.X *= mouseDist; - mouseVec.Y *= mouseDist; - projectile.velocity.X = mouseVec.X; - projectile.velocity.Y = mouseVec.Y; - if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.Kill(); - } - projectile.ai[0] = 1f; - } - } - if (projectile.velocity.X != 0f || projectile.velocity.Y != 0f) - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - } - if (projectile.velocity.Y > 16f) - { - projectile.velocity.Y = 16f; - } - } + if (Main.myPlayer == projectile.owner && projectile.ai[0] <= 0f) + { + Player player = Main.player[projectile.owner]; + if (player.channel) + { + float speed = 18f; + float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - projectile.Center.X; + float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - projectile.Center.Y; + if (player.gravDir == -1f) + { + mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projectile.Center.Y; + } + Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); + float mouseDist = mouseVec.Length(); + if (projectile.ai[0] < 0f) + { + projectile.ai[0] += 1f; + } + if (mouseDist > speed) + { + mouseDist = speed / mouseDist; + mouseVec.X *= mouseDist; + mouseVec.Y *= mouseDist; + int mouseSpeedX = (int)(mouseVec.X * 1000f); + int projSpeedX = (int)(projectile.velocity.X * 1000f); + int mouseSpeedY = (int)(mouseVec.Y * 1000f); + int projSpeedY = (int)(projectile.velocity.Y * 1000f); + if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) + { + projectile.netUpdate = true; + } + projectile.velocity.X = mouseVec.X; + projectile.velocity.Y = mouseVec.Y; + } + else + { + int mouseSpeedX = (int)(mouseVec.X * 1000f); + int projSpeedX = (int)(projectile.velocity.X * 1000f); + int mouseSpeedY = (int)(mouseVec.Y * 1000f); + int projSpeedY = (int)(projectile.velocity.Y * 1000f); + if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) + { + projectile.netUpdate = true; + } + projectile.velocity.X = mouseVec.X; + projectile.velocity.Y = mouseVec.Y; + } + } + else if (projectile.ai[0] <= 0f) + { + projectile.netUpdate = true; + float speed = 12f; + Vector2 projCenter = projectile.Center; + float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - projCenter.X; + float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - projCenter.Y; + if (player.gravDir == -1f) + { + mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projCenter.Y; + } + Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); + float mouseDist = mouseVec.Length(); + if (mouseDist == 0f || projectile.ai[0] < 0f) + { + projCenter = player.Center; + mouseVec = projectile.Center - projCenter; + mouseDist = mouseVec.Length(); + } + mouseDist = speed / mouseDist; + mouseVec.X *= mouseDist; + mouseVec.Y *= mouseDist; + projectile.velocity.X = mouseVec.X; + projectile.velocity.Y = mouseVec.Y; + if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.Kill(); + } + projectile.ai[0] = 1f; + } + } + if (projectile.velocity.X != 0f || projectile.velocity.Y != 0f) + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + if (projectile.velocity.Y > 16f) + { + projectile.velocity.Y = 16f; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void Kill(int timeLeft) - { - projectile.position = projectile.Center; - projectile.width = projectile.height = 64; - projectile.Center = projectile.position; - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); - Main.PlaySound(SoundID.Item14, projectile.Center); - int dustAmt = 36; - for (int index = 0; index < dustAmt; index++) - { - Vector2 dustPos = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; - dustPos = dustPos.RotatedBy((double)((float)(index - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; - Vector2 dustVel = dustPos - projectile.Center; - int sand = Dust.NewDust(dustPos + dustVel, 0, 0, 85, dustVel.X * 1.5f, dustVel.Y * 1.5f, 100, default, 1.2f); - Main.dust[sand].noGravity = true; - Main.dust[sand].noLight = true; - Main.dust[sand].velocity = dustVel; - } - } - } + public override void Kill(int timeLeft) + { + projectile.position = projectile.Center; + projectile.width = projectile.height = 64; + projectile.Center = projectile.position; + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + Main.PlaySound(SoundID.Item14, projectile.Center); + int dustAmt = 36; + for (int index = 0; index < dustAmt; index++) + { + Vector2 dustPos = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; + dustPos = dustPos.RotatedBy((double)((float)(index - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; + Vector2 dustVel = dustPos - projectile.Center; + int sand = Dust.NewDust(dustPos + dustVel, 0, 0, 85, dustVel.X * 1.5f, dustVel.Y * 1.5f, 100, default, 1.2f); + Main.dust[sand].noGravity = true; + Main.dust[sand].noLight = true; + Main.dust[sand].velocity = dustVel; + } + } + } } diff --git a/Projectiles/Magic/SlitheringEelProjectile.cs b/Projectiles/Magic/SlitheringEelProjectile.cs index 8f75c18154..710548eb54 100644 --- a/Projectiles/Magic/SlitheringEelProjectile.cs +++ b/Projectiles/Magic/SlitheringEelProjectile.cs @@ -8,7 +8,7 @@ using CalamityMod.Buffs.StatDebuffs; namespace CalamityMod.Projectiles.Magic { - public class SlitheringEelProjectile : ModProjectile + public class SlitheringEelProjectile : ModProjectile { public struct EelSegment { diff --git a/Projectiles/Magic/Snowball.cs b/Projectiles/Magic/Snowball.cs index 6a6d13a1fb..fbe8b34be8 100644 --- a/Projectiles/Magic/Snowball.cs +++ b/Projectiles/Magic/Snowball.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Magic projectile.coldDamage = true; projectile.penetrate = 1; projectile.extraUpdates = 1; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void SetStaticDefaults() diff --git a/Projectiles/Magic/Snowflake.cs b/Projectiles/Magic/Snowflake.cs index c6f7c5e7ac..220c9aa1f7 100644 --- a/Projectiles/Magic/Snowflake.cs +++ b/Projectiles/Magic/Snowflake.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = 600; projectile.magic = true; aiType = ProjectileID.FlyingKnife; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Magic/SolarBeam2.cs b/Projectiles/Magic/SolarBeam2.cs index 1c0bc2704e..50e9dd6b9b 100644 --- a/Projectiles/Magic/SolarBeam2.cs +++ b/Projectiles/Magic/SolarBeam2.cs @@ -69,8 +69,8 @@ namespace CalamityMod.Projectiles.Magic if (projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMagic = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMagic = true; } } } diff --git a/Projectiles/Magic/SoulPiercerBeam.cs b/Projectiles/Magic/SoulPiercerBeam.cs index 9d5a47f687..7262d86198 100644 --- a/Projectiles/Magic/SoulPiercerBeam.cs +++ b/Projectiles/Magic/SoulPiercerBeam.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class SoulPiercerBeam : ModProjectile + public class SoulPiercerBeam : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -18,8 +18,8 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.extraUpdates = 100; projectile.timeLeft = 240; projectile.usesLocalNPCImmunity = true; @@ -29,16 +29,16 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 9f) - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity; - projectile.alpha = 255; - int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 0.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.014f; - Main.dust[num448].velocity *= 0.2f; - } + if (projectile.localAI[0] > 9f) + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity; + projectile.alpha = 255; + int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 0.5f); + Main.dust[num448].position = vector33; + Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.014f; + Main.dust[num448].velocity *= 0.2f; + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Magic { if (projectile.owner == Main.myPlayer) { - CalamityUtils.ProjectileBarrage(projectile.Center, target.Center, true, -500f, 500f, 0f, 500f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, projectile.owner, false, 0f); + CalamityUtils.ProjectileBarrage(projectile.Center, target.Center, true, -500f, 500f, 0f, 500f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, projectile.owner, false, 0f); } } } diff --git a/Projectiles/Magic/SoulPiercerBolt.cs b/Projectiles/Magic/SoulPiercerBolt.cs index 7bf3fa417e..a50114daae 100644 --- a/Projectiles/Magic/SoulPiercerBolt.cs +++ b/Projectiles/Magic/SoulPiercerBolt.cs @@ -18,22 +18,22 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.extraUpdates = 100; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.timeLeft = 180; + projectile.ignoreWater = true; + projectile.timeLeft = 180; projectile.penetrate = -1; projectile.magic = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } - public override void AI() - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity; - int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 0.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.014f; - Main.dust[num448].velocity *= 0.2f; - } + public override void AI() + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity; + int num448 = Dust.NewDust(vector33, 1, 1, 173, 0f, 0f, 0, default, 0.5f); + Main.dust[num448].position = vector33; + Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.014f; + Main.dust[num448].velocity *= 0.2f; + } } } diff --git a/Projectiles/Magic/SparkInfernal.cs b/Projectiles/Magic/SparkInfernal.cs index 2bcc782483..0ac2553275 100644 --- a/Projectiles/Magic/SparkInfernal.cs +++ b/Projectiles/Magic/SparkInfernal.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.penetrate = 1; projectile.timeLeft = 300; - projectile.magic = true; + projectile.magic = true; } public override void AI() @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Magic public override void Kill(int timeLeft) { - Player player = Main.player[projectile.owner]; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(TheWand.BaseDamage * (player.allDamage + player.magicDamage - 1f)), projectile.knockBack, projectile.owner, 0f, 0f); + Player player = Main.player[projectile.owner]; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(TheWand.BaseDamage * (player.allDamage + player.magicDamage - 1f)), projectile.knockBack, projectile.owner, 0f, 0f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Magic/SparklingBeam.cs b/Projectiles/Magic/SparklingBeam.cs index aff9d8cd66..6526641425 100644 --- a/Projectiles/Magic/SparklingBeam.cs +++ b/Projectiles/Magic/SparklingBeam.cs @@ -10,273 +10,273 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - // The following laser shows a channeled ability, after charging up the laser will be fired - // Using custom drawing, dust effects, and custom collision checks for tiles - public class SparklingBeam : ModProjectile - { - // Use a different style for constant so it is very clear in code when a constant is used + // The following laser shows a channeled ability, after charging up the laser will be fired + // Using custom drawing, dust effects, and custom collision checks for tiles + public class SparklingBeam : ModProjectile + { + // Use a different style for constant so it is very clear in code when a constant is used - // The maximum charge value - private const float MAX_CHARGE = 50f; - //The distance charge particle from the player center - private const float MOVE_DISTANCE = 60f; + // The maximum charge value + private const float MAX_CHARGE = 50f; + //The distance charge particle from the player center + private const float MOVE_DISTANCE = 60f; - // The actual distance is stored in the ai0 field - // By making a property to handle this it makes our life easier, and the accessibility more readable - public float Distance - { - get => projectile.ai[0]; - set => projectile.ai[0] = value; - } + // The actual distance is stored in the ai0 field + // By making a property to handle this it makes our life easier, and the accessibility more readable + public float Distance + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } - // The actual charge value is stored in the localAI0 field - public float Charge - { - get => projectile.localAI[0]; - set => projectile.localAI[0] = value; - } + // The actual charge value is stored in the localAI0 field + public float Charge + { + get => projectile.localAI[0]; + set => projectile.localAI[0] = value; + } - // Are we at max charge? With c#6 you can simply use => which indicates this is a get only property - public bool IsAtMaxCharge => Charge == MAX_CHARGE; + // Are we at max charge? With c#6 you can simply use => which indicates this is a get only property + public bool IsAtMaxCharge => Charge == MAX_CHARGE; - private bool playedSound = false; + private bool playedSound = false; //private int manaDrain = 0; - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.magic = true; - projectile.hide = true; - projectile.timeLeft = 300; + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.hide = true; + projectile.timeLeft = 300; projectile.usesIDStaticNPCImmunity = true; projectile.idStaticNPCHitCooldown = 19; - projectile.Calamity().PierceResistHarshness = 0.06f; - projectile.Calamity().PierceResistCap = 0.4f; - } + projectile.Calamity().PierceResistHarshness = 0.06f; + projectile.Calamity().PierceResistCap = 0.4f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - // We start drawing the laser if we have charged up - if (IsAtMaxCharge) - { - DrawLaser(spriteBatch, Main.projectileTexture[projectile.type], Main.player[projectile.owner].Center, - projectile.velocity, 10, projectile.damage, -1.57f, 1f, 1000f, Color.White, (int)MOVE_DISTANCE); - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + // We start drawing the laser if we have charged up + if (IsAtMaxCharge) + { + DrawLaser(spriteBatch, Main.projectileTexture[projectile.type], Main.player[projectile.owner].Center, + projectile.velocity, 10, projectile.damage, -1.57f, 1f, 1000f, Color.White, (int)MOVE_DISTANCE); + } + return false; + } - // The core function of drawing a laser - public void DrawLaser(SpriteBatch spriteBatch, Texture2D texture, Vector2 start, Vector2 unit, float step, int damage, float rotation = 0f, float scale = 1f, float maxDist = 2000f, Color color = default(Color), int transDist = 50) - { - float r = unit.ToRotation() + rotation; + // The core function of drawing a laser + public void DrawLaser(SpriteBatch spriteBatch, Texture2D texture, Vector2 start, Vector2 unit, float step, int damage, float rotation = 0f, float scale = 1f, float maxDist = 2000f, Color color = default(Color), int transDist = 50) + { + float r = unit.ToRotation() + rotation; - // Draws the laser 'body' - for (float i = transDist; i <= Distance; i += step) - { - Color c = Color.White; - var origin = start + i * unit; - spriteBatch.Draw(texture, origin - Main.screenPosition, - new Rectangle(0, 26, 28, 26), i < transDist ? Color.Transparent : c, r, - new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); - } + // Draws the laser 'body' + for (float i = transDist; i <= Distance; i += step) + { + Color c = Color.White; + var origin = start + i * unit; + spriteBatch.Draw(texture, origin - Main.screenPosition, + new Rectangle(0, 26, 28, 26), i < transDist ? Color.Transparent : c, r, + new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); + } - // Draws the laser 'tail' - spriteBatch.Draw(texture, start + unit * (transDist - step) - Main.screenPosition, - new Rectangle(0, 0, 28, 26), Color.White, r, new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); + // Draws the laser 'tail' + spriteBatch.Draw(texture, start + unit * (transDist - step) - Main.screenPosition, + new Rectangle(0, 0, 28, 26), Color.White, r, new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); - // Draws the laser 'head' - spriteBatch.Draw(texture, start + (Distance + step) * unit - Main.screenPosition, - new Rectangle(0, 52, 28, 26), Color.White, r, new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); - } + // Draws the laser 'head' + spriteBatch.Draw(texture, start + (Distance + step) * unit - Main.screenPosition, + new Rectangle(0, 52, 28, 26), Color.White, r, new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); + } - // Change the way of collision check of the projectile - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - // We can only collide if we are at max charge, which is when the laser is actually fired - if (!IsAtMaxCharge) - return false; + // Change the way of collision check of the projectile + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + // We can only collide if we are at max charge, which is when the laser is actually fired + if (!IsAtMaxCharge) + return false; - Player player = Main.player[projectile.owner]; - Vector2 unit = projectile.velocity; - float point = 0f; - // Run an AABB versus Line check to look for collisions, look up AABB collision first to see how it works - // It will look for collisions on the given line using AABB - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), player.Center, - player.Center + unit * Distance, 22, ref point); - } + Player player = Main.player[projectile.owner]; + Vector2 unit = projectile.velocity; + float point = 0f; + // Run an AABB versus Line check to look for collisions, look up AABB collision first to see how it works + // It will look for collisions on the given line using AABB + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), player.Center, + player.Center + unit * Distance, 22, ref point); + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { if (target.life <= 0 && target.lifeMax > 5) { - Player player = Main.player[projectile.owner]; - int shardDamage = projectile.damage / 5; - int shardAmt = Main.rand.Next(2, 4); + Player player = Main.player[projectile.owner]; + int shardDamage = projectile.damage / 5; + int shardAmt = Main.rand.Next(2, 4); if (projectile.owner == Main.myPlayer) { - for (int s = 0; s < shardAmt; s++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int shard = Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType(), shardDamage, 0f, projectile.owner); - if (shard.WithinBounds(Main.maxProjectiles)) - Main.projectile[shard].Calamity().forceMagic = true; - } - } + for (int s = 0; s < shardAmt; s++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType(), shardDamage, 0f, projectile.owner); + if (shard.WithinBounds(Main.maxProjectiles)) + Main.projectile[shard].Calamity().forceMagic = true; + } + } } } - // The AI of the projectile - public override void AI() - { - Player player = Main.player[projectile.owner]; - projectile.position = player.Center + projectile.velocity * MOVE_DISTANCE; - projectile.timeLeft = 2; + // The AI of the projectile + public override void AI() + { + Player player = Main.player[projectile.owner]; + projectile.position = player.Center + projectile.velocity * MOVE_DISTANCE; + projectile.timeLeft = 2; - // By separating large AI into methods it becomes very easy to see the flow of the AI in a broader sense - // First we update player variables that are needed to channel the laser - // Then we run our charging laser logic - // If we are fully charged, we proceed to update the laser's position - // Finally we spawn some effects like dusts and light + // By separating large AI into methods it becomes very easy to see the flow of the AI in a broader sense + // First we update player variables that are needed to channel the laser + // Then we run our charging laser logic + // If we are fully charged, we proceed to update the laser's position + // Finally we spawn some effects like dusts and light - UpdatePlayer(player); - ChargeLaser(player); + UpdatePlayer(player); + ChargeLaser(player); - // If laser is not charged yet, stop the AI here. - if (Charge < MAX_CHARGE) - return; + // If laser is not charged yet, stop the AI here. + if (Charge < MAX_CHARGE) + return; - //Play cool sound when fully charged - if (!playedSound) - { - Main.PlaySound(SoundID.Item68, projectile.position); - playedSound = true; - } + //Play cool sound when fully charged + if (!playedSound) + { + Main.PlaySound(SoundID.Item68, projectile.position); + playedSound = true; + } - SetLaserPosition(player); - SpawnDusts(player); - CastLights(); - } + SetLaserPosition(player); + SpawnDusts(player); + CastLights(); + } - private void SpawnDusts(Player player) - { - Vector2 unit = projectile.velocity * -1; - Vector2 dustPos = player.Center + projectile.velocity * Distance; + private void SpawnDusts(Player player) + { + Vector2 unit = projectile.velocity * -1; + Vector2 dustPos = player.Center + projectile.velocity * Distance; - for (int i = 0; i < 2; ++i) - { - float num1 = projectile.velocity.ToRotation() + (Main.rand.Next(2) == 1 ? -1.0f : 1.0f) * 1.57f; - float num2 = (float)(Main.rand.NextDouble() * 0.8f + 1.0f); - Vector2 dustVel = new Vector2((float)Math.Cos(num1) * num2, (float)Math.Sin(num1) * num2); - Dust dust = Main.dust[Dust.NewDust(dustPos, 0, 0, 226, dustVel.X, dustVel.Y)]; - dust.noGravity = true; - dust.scale = 1.2f; - dust = Dust.NewDustDirect(Main.player[projectile.owner].Center, 0, 0, 31, - -unit.X * Distance, -unit.Y * Distance); - dust.fadeIn = 0f; - dust.noGravity = true; - dust.scale = 0.88f; - dust.color = Color.Cyan; - } + for (int i = 0; i < 2; ++i) + { + float num1 = projectile.velocity.ToRotation() + (Main.rand.Next(2) == 1 ? -1.0f : 1.0f) * 1.57f; + float num2 = (float)(Main.rand.NextDouble() * 0.8f + 1.0f); + Vector2 dustVel = new Vector2((float)Math.Cos(num1) * num2, (float)Math.Sin(num1) * num2); + Dust dust = Main.dust[Dust.NewDust(dustPos, 0, 0, 226, dustVel.X, dustVel.Y)]; + dust.noGravity = true; + dust.scale = 1.2f; + dust = Dust.NewDustDirect(Main.player[projectile.owner].Center, 0, 0, 31, + -unit.X * Distance, -unit.Y * Distance); + dust.fadeIn = 0f; + dust.noGravity = true; + dust.scale = 0.88f; + dust.color = Color.Cyan; + } - if (Main.rand.NextBool(5)) - { - Vector2 offset = projectile.velocity.RotatedBy(1.57f) * ((float)Main.rand.NextDouble() - 0.5f) * projectile.width; - Dust dust = Main.dust[Dust.NewDust(dustPos + offset - Vector2.One * 4f, 8, 8, 31, 0.0f, 0.0f, 100, new Color(), 1.5f)]; - dust.velocity *= 0.5f; - dust.velocity.Y = -Math.Abs(dust.velocity.Y); - unit = dustPos - Main.player[projectile.owner].Center; - unit.Normalize(); - dust = Main.dust[Dust.NewDust(Main.player[projectile.owner].Center + 55 * unit, 8, 8, 31, 0.0f, 0.0f, 100, new Color(), 1.5f)]; - dust.velocity = dust.velocity * 0.5f; - dust.velocity.Y = -Math.Abs(dust.velocity.Y); - } - } + if (Main.rand.NextBool(5)) + { + Vector2 offset = projectile.velocity.RotatedBy(1.57f) * ((float)Main.rand.NextDouble() - 0.5f) * projectile.width; + Dust dust = Main.dust[Dust.NewDust(dustPos + offset - Vector2.One * 4f, 8, 8, 31, 0.0f, 0.0f, 100, new Color(), 1.5f)]; + dust.velocity *= 0.5f; + dust.velocity.Y = -Math.Abs(dust.velocity.Y); + unit = dustPos - Main.player[projectile.owner].Center; + unit.Normalize(); + dust = Main.dust[Dust.NewDust(Main.player[projectile.owner].Center + 55 * unit, 8, 8, 31, 0.0f, 0.0f, 100, new Color(), 1.5f)]; + dust.velocity = dust.velocity * 0.5f; + dust.velocity.Y = -Math.Abs(dust.velocity.Y); + } + } - /* - * Sets the end of the laser position based on where it collides with something - */ - private void SetLaserPosition(Player player) - { - float[] samplingPoints = new float[12]; - Collision.LaserScan(player.Center + projectile.velocity * MOVE_DISTANCE, projectile.velocity, projectile.width * 0.5f, 2200f, samplingPoints); - Distance = MathHelper.Max(samplingPoints.Average() + projectile.height * 2f, 40f); - } + /* + * Sets the end of the laser position based on where it collides with something + */ + private void SetLaserPosition(Player player) + { + float[] samplingPoints = new float[12]; + Collision.LaserScan(player.Center + projectile.velocity * MOVE_DISTANCE, projectile.velocity, projectile.width * 0.5f, 2200f, samplingPoints); + Distance = MathHelper.Max(samplingPoints.Average() + projectile.height * 2f, 40f); + } - private void ChargeLaser(Player player) - { - // Kill the projectile if the player stops channeling - if (!player.channel) - { - projectile.Kill(); - } - else { - // Do we still have enough mana? If not, we kill the projectile because we cannot use it anymore - if (Main.player[projectile.owner].miscCounter % 10 == 0 && !player.CheckMana(player.ActiveItem(), -1, true)) - { - projectile.Kill(); - } - Vector2 offset = projectile.velocity; - offset *= MOVE_DISTANCE - 20; - Vector2 pos = player.Center + offset - new Vector2(10, 10); - if (Charge < MAX_CHARGE) - { - Charge++; - } - int chargeFact = (int)(Charge / 20f); - Vector2 dustVelocity = Vector2.UnitX * 18f; - dustVelocity = dustVelocity.RotatedBy(projectile.rotation - 1.57f); - Vector2 spawnPos = projectile.Center + dustVelocity; - for (int k = 0; k < chargeFact + 1; k++) - { - Vector2 spawn = spawnPos + ((float)Main.rand.NextDouble() * 6.28f).ToRotationVector2() * (12f - chargeFact * 2); - Dust dust = Main.dust[Dust.NewDust(pos, 20, 20, 226, projectile.velocity.X / 2f, projectile.velocity.Y / 2f)]; - dust.velocity = Vector2.Normalize(spawnPos - spawn) * 1.5f * (10f - chargeFact * 2f) / 10f; - dust.noGravity = true; - dust.scale = Main.rand.Next(10, 20) * 0.05f; - } - } - } + private void ChargeLaser(Player player) + { + // Kill the projectile if the player stops channeling + if (!player.channel) + { + projectile.Kill(); + } + else { + // Do we still have enough mana? If not, we kill the projectile because we cannot use it anymore + if (Main.player[projectile.owner].miscCounter % 10 == 0 && !player.CheckMana(player.ActiveItem(), -1, true)) + { + projectile.Kill(); + } + Vector2 offset = projectile.velocity; + offset *= MOVE_DISTANCE - 20; + Vector2 pos = player.Center + offset - new Vector2(10, 10); + if (Charge < MAX_CHARGE) + { + Charge++; + } + int chargeFact = (int)(Charge / 20f); + Vector2 dustVelocity = Vector2.UnitX * 18f; + dustVelocity = dustVelocity.RotatedBy(projectile.rotation - 1.57f); + Vector2 spawnPos = projectile.Center + dustVelocity; + for (int k = 0; k < chargeFact + 1; k++) + { + Vector2 spawn = spawnPos + ((float)Main.rand.NextDouble() * 6.28f).ToRotationVector2() * (12f - chargeFact * 2); + Dust dust = Main.dust[Dust.NewDust(pos, 20, 20, 226, projectile.velocity.X / 2f, projectile.velocity.Y / 2f)]; + dust.velocity = Vector2.Normalize(spawnPos - spawn) * 1.5f * (10f - chargeFact * 2f) / 10f; + dust.noGravity = true; + dust.scale = Main.rand.Next(10, 20) * 0.05f; + } + } + } - private void UpdatePlayer(Player player) - { - // Multiplayer support here, only run this code if the client running it is the owner of the projectile - if (projectile.owner == Main.myPlayer) - { - Vector2 diff = Main.MouseWorld - player.Center; - diff.Normalize(); - projectile.velocity = diff; - projectile.direction = Main.MouseWorld.X > player.position.X ? 1 : -1; - projectile.netUpdate = true; - } - int dir = projectile.direction; - player.ChangeDir(dir); // Set player direction to where we are shooting - player.heldProj = projectile.whoAmI; // Update player's held projectile - player.itemTime = 2; // Set item time to 2 frames while we are used - player.itemAnimation = 2; // Set item animation time to 2 frames while we are used - player.itemRotation = (float)Math.Atan2(projectile.velocity.Y * dir, projectile.velocity.X * dir); // Set the item rotation to where we are shooting - } + private void UpdatePlayer(Player player) + { + // Multiplayer support here, only run this code if the client running it is the owner of the projectile + if (projectile.owner == Main.myPlayer) + { + Vector2 diff = Main.MouseWorld - player.Center; + diff.Normalize(); + projectile.velocity = diff; + projectile.direction = Main.MouseWorld.X > player.position.X ? 1 : -1; + projectile.netUpdate = true; + } + int dir = projectile.direction; + player.ChangeDir(dir); // Set player direction to where we are shooting + player.heldProj = projectile.whoAmI; // Update player's held projectile + player.itemTime = 2; // Set item time to 2 frames while we are used + player.itemAnimation = 2; // Set item animation time to 2 frames while we are used + player.itemRotation = (float)Math.Atan2(projectile.velocity.Y * dir, projectile.velocity.X * dir); // Set the item rotation to where we are shooting + } - private void CastLights() - { - // Cast a light along the line of the laser - DelegateMethods.v3_1 = new Vector3(0.8f, 0.8f, 1f); - Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * (Distance - MOVE_DISTANCE), 26, DelegateMethods.CastLight); - } + private void CastLights() + { + // Cast a light along the line of the laser + DelegateMethods.v3_1 = new Vector3(0.8f, 0.8f, 1f); + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * (Distance - MOVE_DISTANCE), 26, DelegateMethods.CastLight); + } - public override bool ShouldUpdatePosition() => false; + public override bool ShouldUpdatePosition() => false; - /* - * Update CutTiles so the laser will cut tiles (like grass) - */ - public override void CutTiles() - { - DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; - Vector2 unit = projectile.velocity; - Utils.PlotTileLine(projectile.Center, projectile.Center + unit * Distance, (projectile.width + 16) * projectile.scale, DelegateMethods.CutTiles); - } - } + /* + * Update CutTiles so the laser will cut tiles (like grass) + */ + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 unit = projectile.velocity; + Utils.PlotTileLine(projectile.Center, projectile.Center + unit * Distance, (projectile.width + 16) * projectile.scale, DelegateMethods.CutTiles); + } + } } diff --git a/Projectiles/Magic/SpiritDust.cs b/Projectiles/Magic/SpiritDust.cs index 849438ff38..c863b60559 100644 --- a/Projectiles/Magic/SpiritDust.cs +++ b/Projectiles/Magic/SpiritDust.cs @@ -5,27 +5,27 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class SpiritDust : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public class SpiritDust : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() => DisplayName.SetDefault("Spirit Dust"); + public override void SetStaticDefaults() => DisplayName.SetDefault("Spirit Dust"); - public override void SetDefaults() - { - projectile.width = projectile.height = 10; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 60; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 10; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 60; + } - public override void AI() - { - float radius = MathHelper.SmoothStep(80f, 48f, 1f - projectile.timeLeft / 90f); - Vector2 spawnPosition = projectile.Center + Main.rand.NextVector2Circular(5f, 5f) * radius / 130f; - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, radius); - } - } + public override void AI() + { + float radius = MathHelper.SmoothStep(80f, 48f, 1f - projectile.timeLeft / 90f); + Vector2 spawnPosition = projectile.Center + Main.rand.NextVector2Circular(5f, 5f) * radius / 130f; + FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, radius); + } + } } diff --git a/Projectiles/Magic/SpiritFlameCurse.cs b/Projectiles/Magic/SpiritFlameCurse.cs index 792c5b454d..065747e2b9 100644 --- a/Projectiles/Magic/SpiritFlameCurse.cs +++ b/Projectiles/Magic/SpiritFlameCurse.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = 1; projectile.alpha = 255; projectile.magic = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Magic/StardustElementalBeam.cs b/Projectiles/Magic/StardustElementalBeam.cs index 4bcf5d92c6..910f62b98a 100644 --- a/Projectiles/Magic/StardustElementalBeam.cs +++ b/Projectiles/Magic/StardustElementalBeam.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class StardustElementalBeam : BaseLaserbeamProjectile + public class StardustElementalBeam : BaseLaserbeamProjectile { public override float MaxScale => 0.85f; public override float MaxLaserLength => 1000f; @@ -74,11 +74,11 @@ namespace CalamityMod.Projectiles.Magic int type = ModContent.ProjectileType(); damage = (int)(projectile.damage * 0.7); for (int i = 0; i < 4; i++) - { + { float spawnOffsetAngle = MathHelper.Lerp(spawnOffsetSpread * -0.5f, spawnOffsetSpread * 0.5f, i / 4f) + baseOffsetAngle; Vector2 spawnPosition = target.Top - Vector2.UnitY.RotatedBy(spawnOffsetAngle) * 65f; Projectile.NewProjectile(spawnPosition, -Vector2.UnitY.RotatedBy(spawnOffsetAngle) * 2f, type, damage, knockback, projectile.owner); - } + } } } } diff --git a/Projectiles/Magic/StickyFeather.cs b/Projectiles/Magic/StickyFeather.cs index 00cdb8f767..fe2ed42193 100644 --- a/Projectiles/Magic/StickyFeather.cs +++ b/Projectiles/Magic/StickyFeather.cs @@ -35,12 +35,12 @@ namespace CalamityMod.Projectiles.Magic } } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 1; - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 1; + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.position); projectile.position.X = projectile.position.X + (float)(projectile.width / 2); diff --git a/Projectiles/Magic/StratusSphereProj.cs b/Projectiles/Magic/StratusSphereProj.cs index 07d03804aa..19bc800952 100644 --- a/Projectiles/Magic/StratusSphereProj.cs +++ b/Projectiles/Magic/StratusSphereProj.cs @@ -5,33 +5,33 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Projectiles.Magic { - public class StratusSphereProj : ModProjectile - { + public class StratusSphereProj : ModProjectile + { int roundsGone = 0; int dust_nut = 0; - public override void SetStaticDefaults() - { + public override void SetStaticDefaults() + { DisplayName.SetDefault("Stratus Sphere"); Main.projFrames[projectile.type] = 6; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.hostile = false; + public override void SetDefaults() + { + projectile.hostile = false; projectile.friendly = true; - projectile.aiStyle = -1; - projectile.width = 314; - projectile.height = 198; - projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.knockBack = 0; + projectile.aiStyle = -1; + projectile.width = 314; + projectile.height = 198; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.knockBack = 0; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.magic = true; - } + projectile.magic = true; + } public override Color? GetAlpha(Color lightColor) { diff --git a/Projectiles/Magic/SubsumingTentacle.cs b/Projectiles/Magic/SubsumingTentacle.cs index 2702fcb497..be24d5a944 100644 --- a/Projectiles/Magic/SubsumingTentacle.cs +++ b/Projectiles/Magic/SubsumingTentacle.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class SubsumingTentacle : ModProjectile + public class SubsumingTentacle : ModProjectile { public int AlphaFade { diff --git a/Projectiles/Magic/SupremeDustProjectile.cs b/Projectiles/Magic/SupremeDustProjectile.cs index bc992ba6ed..504f371303 100644 --- a/Projectiles/Magic/SupremeDustProjectile.cs +++ b/Projectiles/Magic/SupremeDustProjectile.cs @@ -43,22 +43,22 @@ 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); - 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 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)) diff --git a/Projectiles/Magic/TacticiansElectricBoom.cs b/Projectiles/Magic/TacticiansElectricBoom.cs index d72152bdd6..67180af85f 100644 --- a/Projectiles/Magic/TacticiansElectricBoom.cs +++ b/Projectiles/Magic/TacticiansElectricBoom.cs @@ -5,53 +5,53 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class TacticiansElectricBoom : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public class TacticiansElectricBoom : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private const float radius = 50f; + private const float radius = 50f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Electric Explosion"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Electric Explosion"); + } - public override void SetDefaults() - { - projectile.width = 100; - projectile.height = 100; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 10; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = -1; - projectile.magic = true; - } + public override void SetDefaults() + { + projectile.width = 100; + projectile.height = 100; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 10; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; + projectile.magic = true; + } - public override void AI() - { - if (projectile.timeLeft >= 8) - { - for (int i = 0; i < 30; i++) - { - int dustType = Main.rand.NextBool() ? 132 : 264; + public override void AI() + { + if (projectile.timeLeft >= 8) + { + for (int i = 0; i < 30; i++) + { + int dustType = Main.rand.NextBool() ? 132 : 264; - Vector2 dustVelocity = new Vector2(Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1)); - dustVelocity.Normalize(); - dustVelocity *= 6; + Vector2 dustVelocity = new Vector2(Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1)); + dustVelocity.Normalize(); + dustVelocity *= 6; - int dust = Dust.NewDust(projectile.Center, 1, 1, dustType, dustVelocity.X, dustVelocity.Y, 0, default, 0.75f); - Main.dust[dust].noGravity = true; - } - } - } + int dust = Dust.NewDust(projectile.Center, 1, 1, dustType, dustVelocity.X, dustVelocity.Y, 0, default, 0.75f); + Main.dust[dust].noGravity = true; + } + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(BuffID.Electrified, 180); + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(BuffID.Electrified, 180); - public override void OnHitPvp(Player target, int damage, bool crit) => target.AddBuff(BuffID.Electrified, 180); + public override void OnHitPvp(Player target, int damage, bool crit) => target.AddBuff(BuffID.Electrified, 180); public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, radius, targetHitbox); - } + } } diff --git a/Projectiles/Magic/TacticiansTrumpCardProj.cs b/Projectiles/Magic/TacticiansTrumpCardProj.cs index 2491b89473..7121309947 100644 --- a/Projectiles/Magic/TacticiansTrumpCardProj.cs +++ b/Projectiles/Magic/TacticiansTrumpCardProj.cs @@ -5,64 +5,64 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class TacticiansTrumpCardProj : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Beam"); - } + public class TacticiansTrumpCardProj : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Beam"); + } - public override void SetDefaults() - { - projectile.width = 20; - projectile.height = 20; - projectile.aiStyle = 27; - projectile.friendly = true; - projectile.magic = true; - projectile.penetrate = 3; - projectile.timeLeft = 300; - aiType = ProjectileID.LightBeam; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.extraUpdates = 1; - } + public override void SetDefaults() + { + projectile.width = 20; + projectile.height = 20; + projectile.aiStyle = 27; + projectile.friendly = true; + projectile.magic = true; + projectile.penetrate = 3; + projectile.timeLeft = 300; + aiType = ProjectileID.LightBeam; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.extraUpdates = 1; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.37f / 255f, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.47f / 255f); - if (Main.rand.NextBool(5)) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 132, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } - projectile.rotation = projectile.velocity.ToRotation(); - } + public override void AI() + { + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.37f / 255f, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.47f / 255f); + if (Main.rand.NextBool(5)) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 132, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } + projectile.rotation = projectile.velocity.ToRotation(); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.timeLeft > 295) - return false; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.timeLeft > 295) + return false; - 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; - } + 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 void Kill(int timeLeft) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 132, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); - } - } + public override void Kill(int timeLeft) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 132, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); + } + } } diff --git a/Projectiles/Magic/TearsofHeavenProjectile.cs b/Projectiles/Magic/TearsofHeavenProjectile.cs index 9352ca33c5..5aec44e4c2 100644 --- a/Projectiles/Magic/TearsofHeavenProjectile.cs +++ b/Projectiles/Magic/TearsofHeavenProjectile.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class TearsofHeavenProjectile : ModProjectile + public class TearsofHeavenProjectile : ModProjectile { public override void SetStaticDefaults() { @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Magic Main.dust[num102].noGravity = true; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 8f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 8f, 20f); projectile.rotation += 0.3f * (float)projectile.direction; } diff --git a/Projectiles/Magic/TerraBeam.cs b/Projectiles/Magic/TerraBeam.cs index 744feb3203..345605cc44 100644 --- a/Projectiles/Magic/TerraBeam.cs +++ b/Projectiles/Magic/TerraBeam.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Projectiles.Magic public override float MaxScale => 1f; public override float MaxLaserLength => 1200f; public override float Lifetime => 30f; - public override Color LightCastColor => Color.White; + public override Color LightCastColor => Color.White; public override Texture2D LaserBeginTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayStart"); public override Texture2D LaserMiddleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayMid"); public override Texture2D LaserEndTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayEnd"); @@ -36,11 +36,11 @@ namespace CalamityMod.Projectiles.Magic projectile.timeLeft = (int)Lifetime; } - public override void ExtraBehavior() - { + public override void ExtraBehavior() + { // Generate a star-like and circular burst of terra dust. if (!Main.dedServ && Time == 5f) - { + { int starPoints = 6; for (int i = 0; i < starPoints; i++) { @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Magic int ovalPoints = 42; for (int i = 0; i < ovalPoints; i++) - { + { float angle = MathHelper.TwoPi * i / ovalPoints; Dust terraMagic = Dust.NewDustPerfect(projectile.Center, 107); terraMagic.velocity = angle.ToRotationVector2() * 6f; @@ -77,14 +77,14 @@ namespace CalamityMod.Projectiles.Magic public override void DetermineScale() => projectile.scale = projectile.timeLeft / Lifetime * MaxScale; public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { + { DrawBeamWithColor(spriteBatch, Color.Lime * 1.1f, projectile.scale); DrawBeamWithColor(spriteBatch, Color.Yellow * 1.1f, projectile.scale * 0.5f); return false; - } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { if (ShardCooldown > 0f) return; @@ -113,5 +113,5 @@ namespace CalamityMod.Projectiles.Magic ShardCooldown = 3f; projectile.netUpdate = true; } - } + } } diff --git a/Projectiles/Magic/TerraShard.cs b/Projectiles/Magic/TerraShard.cs index 7fedde4035..ad5d9e241d 100644 --- a/Projectiles/Magic/TerraShard.cs +++ b/Projectiles/Magic/TerraShard.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class TerraShard : ModProjectile + public class TerraShard : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Magic/ThunderstormShot.cs b/Projectiles/Magic/ThunderstormShot.cs index 724832b7a3..1dc453429c 100644 --- a/Projectiles/Magic/ThunderstormShot.cs +++ b/Projectiles/Magic/ThunderstormShot.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class ThunderstormShot : ModProjectile + public class ThunderstormShot : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -51,9 +51,9 @@ namespace CalamityMod.Projectiles.Magic Main.PlaySound(SoundID.Item125, projectile.Center); for (int n = 0; n < 5; n++) { - CalamityUtils.ProjectileRain(projectile.Center, 200f, 100f, 1500f, 1500f, 29f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + CalamityUtils.ProjectileRain(projectile.Center, 200f, 100f, 1500f, 1500f, 29f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); } - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 36); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 36); int num226 = 36; for (int num227 = 0; num227 < num226; num227++) { diff --git a/Projectiles/Magic/TridentIcicle.cs b/Projectiles/Magic/TridentIcicle.cs index e3022009d3..04f22f2014 100644 --- a/Projectiles/Magic/TridentIcicle.cs +++ b/Projectiles/Magic/TridentIcicle.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; projectile.penetrate = 2; projectile.ignoreWater = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void SetStaticDefaults() diff --git a/Projectiles/Magic/UberBubble.cs b/Projectiles/Magic/UberBubble.cs index 83043cc6f7..f03664e202 100644 --- a/Projectiles/Magic/UberBubble.cs +++ b/Projectiles/Magic/UberBubble.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Magic projectile.alpha = 255; projectile.ignoreWater = true; projectile.magic = true; - projectile.timeLeft = 30; - } + projectile.timeLeft = 30; + } public override void AI() { @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Magic if (num745 > MathHelper.Pi) num745 -= MathHelper.TwoPi; if (num745 < -MathHelper.Pi) - num745 -= -MathHelper.TwoPi; + num745 -= -MathHelper.TwoPi; projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; } diff --git a/Projectiles/Magic/UndinesRetributionSpear.cs b/Projectiles/Magic/UndinesRetributionSpear.cs index fa231485eb..ee9e332007 100644 --- a/Projectiles/Magic/UndinesRetributionSpear.cs +++ b/Projectiles/Magic/UndinesRetributionSpear.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Magic return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 9f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 9f, 20f); } else { @@ -98,7 +98,7 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage /= 2; + projectile.damage /= 2; projectile.Damage(); Main.PlaySound(SoundID.Item21, projectile.position); for (int num193 = 0; num193 < 4; num193++) diff --git a/Projectiles/Magic/ValkyrieRayStaff.cs b/Projectiles/Magic/ValkyrieRayStaff.cs index 13cbec3ff3..23d693ae49 100644 --- a/Projectiles/Magic/ValkyrieRayStaff.cs +++ b/Projectiles/Magic/ValkyrieRayStaff.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Magic projectile.melee = false; projectile.tileCollide = false; projectile.ignoreWater = true; - projectile.timeLeft = 900; + projectile.timeLeft = 900; } // ai[0] is a time-dilated frame counter. ai[1] is whether the beam has already fired. diff --git a/Projectiles/Magic/VenusianFlame.cs b/Projectiles/Magic/VenusianFlame.cs index 4b6cbfb3b8..da28a9a9a0 100644 --- a/Projectiles/Magic/VenusianFlame.cs +++ b/Projectiles/Magic/VenusianFlame.cs @@ -6,9 +6,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class VenusianFlame : ModProjectile + public class VenusianFlame : ModProjectile { - private bool initialized = false; + private bool initialized = false; public override void SetStaticDefaults() { @@ -32,23 +32,23 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - //Rotation - if (projectile.ai[1] > 0f) - { - projectile.rotation = -projectile.velocity.X * 0.05f + MathHelper.PiOver2; - } - else - { - projectile.rotation = projectile.velocity.ToRotation(); - } - projectile.ai[1]--; + //Rotation + if (projectile.ai[1] > 0f) + { + projectile.rotation = -projectile.velocity.X * 0.05f + MathHelper.PiOver2; + } + else + { + projectile.rotation = projectile.velocity.ToRotation(); + } + projectile.ai[1]--; - //frames - if (!initialized) - { - initialized = true; - projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); - } + //frames + if (!initialized) + { + initialized = true; + projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); + } projectile.frameCounter++; if (projectile.frameCounter > 4) { @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Magic projectile.frame = 0; } - //movement + //movement if (projectile.velocity.X != projectile.velocity.X) { projectile.velocity.X *= -0.1f; @@ -105,17 +105,17 @@ namespace CalamityMod.Projectiles.Magic projectile.velocity.Y = 16f; } - //Dust - if (Main.rand.NextBool(4)) - { - int num199 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 100, default, 1f); - 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 -= 2f; - } + //Dust + if (Main.rand.NextBool(4)) + { + int num199 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 100, default, 1f); + 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 -= 2f; + } if (Main.rand.NextBool(10)) { int num200 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 100, default, 1f); @@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.Magic public override bool OnTileCollide(Vector2 oldVelocity) { - projectile.ai[1] = 10f; + projectile.ai[1] = 10f; return false; } diff --git a/Projectiles/Magic/VisceraBeam.cs b/Projectiles/Magic/VisceraBeam.cs index bd4040a764..a47547c996 100644 --- a/Projectiles/Magic/VisceraBeam.cs +++ b/Projectiles/Magic/VisceraBeam.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class VisceraBeam : ModProjectile + public class VisceraBeam : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -74,8 +74,8 @@ namespace CalamityMod.Projectiles.Magic int num448 = Dust.NewDust(vector33, 1, 1, 5, 0f, 0f, 0, default, 1f); Main.dust[num448].position = vector33; Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; - } + Main.dust[num448].velocity *= 0.1f; + } } } } diff --git a/Projectiles/Magic/VitriolicViperFang.cs b/Projectiles/Magic/VitriolicViperFang.cs index 1bb635035f..3321e1e704 100644 --- a/Projectiles/Magic/VitriolicViperFang.cs +++ b/Projectiles/Magic/VitriolicViperFang.cs @@ -63,6 +63,6 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 180); - } + } } } diff --git a/Projectiles/Magic/VitriolicViperSpit.cs b/Projectiles/Magic/VitriolicViperSpit.cs index b7d68646b9..cae9ee8332 100644 --- a/Projectiles/Magic/VitriolicViperSpit.cs +++ b/Projectiles/Magic/VitriolicViperSpit.cs @@ -45,6 +45,6 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 60); - } + } } } diff --git a/Projectiles/Magic/VividBeam.cs b/Projectiles/Magic/VividBeam.cs index 0f1cb3eaa2..4319360eab 100644 --- a/Projectiles/Magic/VividBeam.cs +++ b/Projectiles/Magic/VividBeam.cs @@ -4,136 +4,136 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class VividBeam : ModProjectile - { + public class VividBeam : ModProjectile + { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private bool initialized = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Beam"); - } + private bool initialized = false; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Beam"); + } - public override void SetDefaults() - { - projectile.width = 4; - projectile.height = 4; - projectile.friendly = true; - projectile.magic = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; - projectile.extraUpdates = 100; - projectile.timeLeft = 240; - } + public override void SetDefaults() + { + projectile.width = 4; + projectile.height = 4; + projectile.friendly = true; + projectile.magic = true; + projectile.ignoreWater = true; + projectile.penetrate = 1; + projectile.extraUpdates = 100; + projectile.timeLeft = 240; + } - public override void AI() - { - if (!initialized) - { - initialized = true; - float dustAmt = 16f; - int d = 0; - while ((float)d < dustAmt) - { - Vector2 offset = Vector2.UnitX * 0f; - offset += -Vector2.UnitY.RotatedBy((double)((float)d * (MathHelper.TwoPi / dustAmt)), default) * new Vector2(1f, 4f); - offset = offset.RotatedBy((double)projectile.velocity.ToRotation(), default); - int i = Dust.NewDust(projectile.Center, 0, 0, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[i].scale = 1.5f; - Main.dust[i].noGravity = true; - Main.dust[i].position = projectile.Center + offset; - Main.dust[i].velocity = projectile.velocity * 0f + offset.SafeNormalize(Vector2.UnitY) * 1f; - d++; - } - } + public override void AI() + { + if (!initialized) + { + initialized = true; + float dustAmt = 16f; + int d = 0; + while ((float)d < dustAmt) + { + Vector2 offset = Vector2.UnitX * 0f; + offset += -Vector2.UnitY.RotatedBy((double)((float)d * (MathHelper.TwoPi / dustAmt)), default) * new Vector2(1f, 4f); + offset = offset.RotatedBy((double)projectile.velocity.ToRotation(), default); + int i = Dust.NewDust(projectile.Center, 0, 0, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[i].scale = 1.5f; + Main.dust[i].noGravity = true; + Main.dust[i].position = projectile.Center + offset; + Main.dust[i].velocity = projectile.velocity * 0f + offset.SafeNormalize(Vector2.UnitY) * 1f; + d++; + } + } - float pi = MathHelper.Pi; - projectile.ai[0] += 1f; - if (projectile.ai[0] == 48f) - { - projectile.ai[0] = 0f; - } - else - { - for (int d = 0; d < 2; d++) - { - Vector2 offset = Vector2.UnitX * -12f; - offset = -Vector2.UnitY.RotatedBy((double)(projectile.ai[0] * pi / 24f + (float)d * pi), default) * new Vector2(5f, 10f) - projectile.rotation.ToRotationVector2() * 10f; - int i = Dust.NewDust(projectile.Center, 0, 0, 66, 0f, 0f, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[i].scale = 0.75f; - Main.dust[i].noGravity = true; - Main.dust[i].position = projectile.Center + offset; - Main.dust[i].velocity = projectile.velocity; - } - } - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - for (int d = 0; d < 2; d++) - { - Vector2 source = projectile.position; - source -= projectile.velocity * ((float)d * 0.25f); - int i = Dust.NewDust(source, 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[i].noGravity = true; - Main.dust[i].position = source; - Main.dust[i].scale = Main.rand.NextFloat(0.91f, 1.417f); - Main.dust[i].velocity *= 0.1f; - } - } - } + float pi = MathHelper.Pi; + projectile.ai[0] += 1f; + if (projectile.ai[0] == 48f) + { + projectile.ai[0] = 0f; + } + else + { + for (int d = 0; d < 2; d++) + { + Vector2 offset = Vector2.UnitX * -12f; + offset = -Vector2.UnitY.RotatedBy((double)(projectile.ai[0] * pi / 24f + (float)d * pi), default) * new Vector2(5f, 10f) - projectile.rotation.ToRotationVector2() * 10f; + int i = Dust.NewDust(projectile.Center, 0, 0, 66, 0f, 0f, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[i].scale = 0.75f; + Main.dust[i].noGravity = true; + Main.dust[i].position = projectile.Center + offset; + Main.dust[i].velocity = projectile.velocity; + } + } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + for (int d = 0; d < 2; d++) + { + Vector2 source = projectile.position; + source -= projectile.velocity * ((float)d * 0.25f); + int i = Dust.NewDust(source, 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[i].noGravity = true; + Main.dust[i].position = source; + Main.dust[i].scale = Main.rand.NextFloat(0.91f, 1.417f); + Main.dust[i].velocity *= 0.1f; + } + } + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.owner == Main.myPlayer) - { - SummonLasers(); - } - return true; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (projectile.owner == Main.myPlayer) + { + SummonLasers(); + } + return true; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (projectile.owner == Main.myPlayer) - { - SummonLasers(); - } - target.ExoDebuffs(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (projectile.owner == Main.myPlayer) + { + SummonLasers(); + } + target.ExoDebuffs(); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - if (projectile.owner == Main.myPlayer) - { - SummonLasers(); - } - target.ExoDebuffs(); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + if (projectile.owner == Main.myPlayer) + { + SummonLasers(); + } + target.ExoDebuffs(); + } - private void SummonLasers() - { - switch (projectile.ai[1]) - { - case 0f: - CalamityUtils.ProjectileRain(projectile.Center, 400f, 100f, 500f, 800f, 6f, ModContent.ProjectileType(), (int)(projectile.damage * 0.7), projectile.knockBack, projectile.owner); - break; + private void SummonLasers() + { + switch (projectile.ai[1]) + { + case 0f: + CalamityUtils.ProjectileRain(projectile.Center, 400f, 100f, 500f, 800f, 6f, ModContent.ProjectileType(), (int)(projectile.damage * 0.7), projectile.knockBack, projectile.owner); + break; - case 1f: - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage * 2, projectile.knockBack, projectile.owner); - break; + case 1f: + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage * 2, projectile.knockBack, projectile.owner); + break; - case 2f: - float spread = 30f * 0.01f * MathHelper.PiOver2; - double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - double offsetAngle; - for (int 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); - 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); - } - break; - } - } - } + case 2f: + float spread = 30f * 0.01f * MathHelper.PiOver2; + double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; + double deltaAngle = spread / 8f; + double offsetAngle; + for (int 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); + 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); + } + break; + } + } + } } diff --git a/Projectiles/Magic/VividBolt.cs b/Projectiles/Magic/VividBolt.cs index 840eb252c4..3e3e1e4675 100644 --- a/Projectiles/Magic/VividBolt.cs +++ b/Projectiles/Magic/VividBolt.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class VividBolt : ModProjectile + public class VividBolt : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.timeLeft = 30; projectile.magic = true; - projectile.ignoreWater = true; - projectile.usesLocalNPCImmunity = true; + projectile.ignoreWater = true; + projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 6; } @@ -58,19 +58,19 @@ namespace CalamityMod.Projectiles.Magic Main.dust[num448].noGravity = true; Main.dust[num448].position = vector33; Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.01f; - Main.dust[num448].velocity *= 0.1f; - } + Main.dust[num448].velocity *= 0.1f; + } } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } } } diff --git a/Projectiles/Magic/VividClarityBeam.cs b/Projectiles/Magic/VividClarityBeam.cs index c2cc38bc8c..4e56d562a1 100644 --- a/Projectiles/Magic/VividClarityBeam.cs +++ b/Projectiles/Magic/VividClarityBeam.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class VividClarityBeam : ModProjectile + public class VividClarityBeam : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; - projectile.ignoreWater = true; - projectile.penetrate = 10; + projectile.ignoreWater = true; + projectile.penetrate = 10; projectile.extraUpdates = 100; projectile.timeLeft = 300; projectile.usesLocalNPCImmunity = true; @@ -67,8 +67,8 @@ namespace CalamityMod.Projectiles.Magic Main.dust[num448].noGravity = true; Main.dust[num448].position = vector33; Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; - } + Main.dust[num448].velocity *= 0.1f; + } } } @@ -96,13 +96,13 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); projectile.damage = (int)(projectile.damage * 1.1); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); projectile.damage = (int)(projectile.damage * 1.1); } } diff --git a/Projectiles/Magic/VividExplosion.cs b/Projectiles/Magic/VividExplosion.cs index c94d130c86..b37c167cbf 100644 --- a/Projectiles/Magic/VividExplosion.cs +++ b/Projectiles/Magic/VividExplosion.cs @@ -3,61 +3,61 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class VividExplosion : ModProjectile - { - private const float radius = 204.5f; + public class VividExplosion : ModProjectile + { + private const float radius = 204.5f; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Explosion"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Explosion"); + } - public override void SetDefaults() - { - projectile.width = projectile.height = 1; //Uses custom collision, this field is irrelevant - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.Calamity().rogue = true; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 6; - projectile.timeLeft = 5; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 1; //Uses custom collision, this field is irrelevant + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.Calamity().rogue = true; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + projectile.timeLeft = 5; + } - public override void AI() - { + public override void AI() + { - Lighting.AddLight(projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f); + Lighting.AddLight(projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f); - float dustSpeed = Main.rand.NextFloat(12f, 35f); - Vector2 dustVel = CalamityUtils.RandomVelocity(40f, dustSpeed, dustSpeed, 1f); - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 107, - 234, - 269 - }); - int rainbow = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[rainbow]; - dust.noGravity = true; - dust.position = projectile.Center; - dust.position.X += (float)Main.rand.Next(-10, 11); - dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity = dustVel; - } + float dustSpeed = Main.rand.NextFloat(12f, 35f); + Vector2 dustVel = CalamityUtils.RandomVelocity(40f, dustSpeed, dustSpeed, 1f); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 107, + 234, + 269 + }); + int rainbow = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[rainbow]; + dust.noGravity = true; + dust.position = projectile.Center; + dust.position.X += (float)Main.rand.Next(-10, 11); + dust.position.Y += (float)Main.rand.Next(-10, 11); + dust.velocity = dustVel; + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, radius, targetHitbox); - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.ExoDebuffs(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.ExoDebuffs(); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.ExoDebuffs(); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); + } + } } diff --git a/Projectiles/Magic/VividLaser2.cs b/Projectiles/Magic/VividLaser2.cs index aa70b1e1b2..49fa5ee9d6 100644 --- a/Projectiles/Magic/VividLaser2.cs +++ b/Projectiles/Magic/VividLaser2.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class VividLaser2 : ModProjectile + public class VividLaser2 : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -18,8 +18,8 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 10; projectile.friendly = true; projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.timeLeft = 120; + projectile.ignoreWater = true; + projectile.timeLeft = 120; projectile.penetrate = 1; projectile.magic = true; } @@ -30,20 +30,20 @@ namespace CalamityMod.Projectiles.Magic projectile.ai[1] += 1f; for (int dust = 0; dust < 2; dust++) { - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy((double)(projectile.ai[1] * 0.1308997f + (float)dust * 3.14159274f), default) * value7 - projectile.rotation.ToRotationVector2() * 10f; - int num42 = Dust.NewDust(projectile.Center, 0, 0, 66, 0f, 0f, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num42].scale = 0.75f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = projectile.Center + value8; - Main.dust[num42].velocity = projectile.velocity; + Vector2 value8 = Vector2.UnitX * -12f; + value8 = -Vector2.UnitY.RotatedBy((double)(projectile.ai[1] * 0.1308997f + (float)dust * 3.14159274f), default) * value7 - projectile.rotation.ToRotationVector2() * 10f; + int num42 = Dust.NewDust(projectile.Center, 0, 0, 66, 0f, 0f, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[num42].scale = 0.75f; + Main.dust[num42].noGravity = true; + Main.dust[num42].position = projectile.Center + value8; + Main.dust[num42].velocity = projectile.velocity; } - if (projectile.timeLeft < 110) - projectile.ai[0] = 1f; + if (projectile.timeLeft < 110) + projectile.ai[0] = 1f; - if (projectile.ai[0] >= 1f) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 400f, 12f, 20f); + if (projectile.ai[0] >= 1f) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 400f, 12f, 20f); } public override void Kill(int timeLeft) @@ -52,9 +52,9 @@ namespace CalamityMod.Projectiles.Magic { int randomDust = Utils.SelectRandom(Main.rand, new int[] { - 107, - 234, - 269 + 107, + 234, + 269 }); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } @@ -62,24 +62,24 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } - // Cannot deal damage for the first several frames of existence. + // Cannot deal damage for the first several frames of existence. public override bool? CanHitNPC(NPC target) - { - if (projectile.timeLeft >= 110) - { - return false; - } - return null; - } + { + if (projectile.timeLeft >= 110) + { + return false; + } + return null; + } - public override bool CanHitPvp(Player target) => projectile.timeLeft < 110; + public override bool CanHitPvp(Player target) => projectile.timeLeft < 110; } } diff --git a/Projectiles/Magic/VividOrb.cs b/Projectiles/Magic/VividOrb.cs index 51061119a2..1fe9a3ab91 100644 --- a/Projectiles/Magic/VividOrb.cs +++ b/Projectiles/Magic/VividOrb.cs @@ -1,7 +1,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class VividOrb : ModProjectile + public class VividOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -21,12 +21,12 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 24f, 5, ModContent.ProjectileType(), 1D, true); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 24f, 5, ModContent.ProjectileType(), 1D, true); } } } diff --git a/Projectiles/Magic/Vortex.cs b/Projectiles/Magic/Vortex.cs index da2719ecd8..193ad83d7f 100644 --- a/Projectiles/Magic/Vortex.cs +++ b/Projectiles/Magic/Vortex.cs @@ -147,12 +147,12 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Magic/VortexElementalBeam.cs b/Projectiles/Magic/VortexElementalBeam.cs index 5a94a1d25a..3bb01e701d 100644 --- a/Projectiles/Magic/VortexElementalBeam.cs +++ b/Projectiles/Magic/VortexElementalBeam.cs @@ -9,174 +9,174 @@ using Terraria.Utilities; namespace CalamityMod.Projectiles.Magic { - public class VortexElementalBeam : ModProjectile - { - public const int Lifetime = 30; - public const float LightningTurnRandomnessFactor = 1.7f; - public ref float InitialVelocityAngle => ref projectile.ai[0]; - // Technically not a ratio, and more of a seed, but it is used in a 0-2pi squash - // later in the code to get an arbitrary unit vector (which is then checked). - public ref float BaseTurnAngleRatio => ref projectile.ai[1]; - public ref float AccumulatedXMovementSpeeds => ref projectile.localAI[0]; + public class VortexElementalBeam : ModProjectile + { + public const int Lifetime = 30; + public const float LightningTurnRandomnessFactor = 1.7f; + public ref float InitialVelocityAngle => ref projectile.ai[0]; + // Technically not a ratio, and more of a seed, but it is used in a 0-2pi squash + // later in the code to get an arbitrary unit vector (which is then checked). + public ref float BaseTurnAngleRatio => ref projectile.ai[1]; + public ref float AccumulatedXMovementSpeeds => ref projectile.localAI[0]; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Lightning"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 30; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + ProjectileID.Sets.MinionShot[projectile.type] = true; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 30; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } public override void SetDefaults() { projectile.width = projectile.height = 16; projectile.friendly = true; - projectile.magic = true; + projectile.magic = true; projectile.alpha = 255; projectile.penetrate = 1; - projectile.ignoreWater = true; + projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.extraUpdates = 20; + projectile.extraUpdates = 20; projectile.timeLeft = 45 * projectile.extraUpdates; - // Readjust the velocity magnitude the moment this projectile is created - // to make velocity setting outside the scope of this projectile less irritating - // to consider alongside extraUpdate multipliers. - // Also set the initial angle. - if (projectile.velocity != Vector2.Zero) - { - projectile.velocity /= projectile.extraUpdates; - } - } + // Readjust the velocity magnitude the moment this projectile is created + // to make velocity setting outside the scope of this projectile less irritating + // to consider alongside extraUpdate multipliers. + // Also set the initial angle. + if (projectile.velocity != Vector2.Zero) + { + projectile.velocity /= projectile.extraUpdates; + } + } public override void SendExtraAI(BinaryWriter writer) => writer.Write(AccumulatedXMovementSpeeds); - public override void ReceiveExtraAI(BinaryReader reader) => AccumulatedXMovementSpeeds = reader.ReadSingle(); + public override void ReceiveExtraAI(BinaryReader reader) => AccumulatedXMovementSpeeds = reader.ReadSingle(); - public override void AI() + public override void AI() { - // frameCounter in this context is really just an arbitrary timer - // which allows random turning to occur. - projectile.frameCounter++; + // frameCounter in this context is really just an arbitrary timer + // which allows random turning to occur. + projectile.frameCounter++; - projectile.scale += 0.04f / projectile.MaxUpdates; - if (projectile.scale > 1f) - projectile.scale = 1f; + projectile.scale += 0.04f / projectile.MaxUpdates; + if (projectile.scale > 1f) + projectile.scale = 1f; - Lighting.AddLight(projectile.Center, Color.Pink.ToVector3()); - if (projectile.frameCounter >= projectile.extraUpdates * 2) - { - projectile.frameCounter = 0; + Lighting.AddLight(projectile.Center, Color.Pink.ToVector3()); + if (projectile.frameCounter >= projectile.extraUpdates * 2) + { + projectile.frameCounter = 0; - float originalSpeed = MathHelper.Min(6f, projectile.velocity.Length()); - UnifiedRandom unifiedRandom = new UnifiedRandom((int)BaseTurnAngleRatio); - int turnTries = 0; - Vector2 newBaseDirection = -Vector2.UnitY; - Vector2 potentialBaseDirection; + float originalSpeed = MathHelper.Min(6f, projectile.velocity.Length()); + UnifiedRandom unifiedRandom = new UnifiedRandom((int)BaseTurnAngleRatio); + int turnTries = 0; + Vector2 newBaseDirection = -Vector2.UnitY; + Vector2 potentialBaseDirection; - do - { - BaseTurnAngleRatio = unifiedRandom.Next() % 100; - potentialBaseDirection = (BaseTurnAngleRatio / 100f * MathHelper.TwoPi).ToRotationVector2(); + do + { + BaseTurnAngleRatio = unifiedRandom.Next() % 100; + potentialBaseDirection = (BaseTurnAngleRatio / 100f * MathHelper.TwoPi).ToRotationVector2(); - // Ensure that the new potential direction base is always moving upwards (this is supposed to be somewhat similar to a -UnitY + RotatedBy). - potentialBaseDirection.Y = -Math.Abs(potentialBaseDirection.Y); + // Ensure that the new potential direction base is always moving upwards (this is supposed to be somewhat similar to a -UnitY + RotatedBy). + potentialBaseDirection.Y = -Math.Abs(potentialBaseDirection.Y); - bool canChangeLightningDirection = true; + bool canChangeLightningDirection = true; - // Potential directions with very little Y speed should not be considered, because this - // consequentially means that the X speed would be quite large. - if (potentialBaseDirection.Y > -0.02f) - canChangeLightningDirection = false; + // Potential directions with very little Y speed should not be considered, because this + // consequentially means that the X speed would be quite large. + if (potentialBaseDirection.Y > -0.02f) + canChangeLightningDirection = false; - // This mess of math basically encourages movement at the ends of an extraUpdate cycle, - // discourages super frequenent randomness as the accumulated X speed changes get larger, - // or if the original speed is quite large. - if (Math.Abs(potentialBaseDirection.X * (projectile.extraUpdates + 1) * 2f * originalSpeed + AccumulatedXMovementSpeeds) > projectile.MaxUpdates * LightningTurnRandomnessFactor) - { - canChangeLightningDirection = false; - } + // This mess of math basically encourages movement at the ends of an extraUpdate cycle, + // discourages super frequenent randomness as the accumulated X speed changes get larger, + // or if the original speed is quite large. + if (Math.Abs(potentialBaseDirection.X * (projectile.extraUpdates + 1) * 2f * originalSpeed + AccumulatedXMovementSpeeds) > projectile.MaxUpdates * LightningTurnRandomnessFactor) + { + canChangeLightningDirection = false; + } - // If the above checks were all passed, redefine the base direction of the lightning. - if (canChangeLightningDirection) - newBaseDirection = potentialBaseDirection; + // If the above checks were all passed, redefine the base direction of the lightning. + if (canChangeLightningDirection) + newBaseDirection = potentialBaseDirection; - turnTries++; - } - while (turnTries < 100); + turnTries++; + } + while (turnTries < 100); - if (projectile.velocity != Vector2.Zero) - { - AccumulatedXMovementSpeeds += newBaseDirection.X * (projectile.extraUpdates + 1) * 2f * originalSpeed; - projectile.velocity = newBaseDirection.RotatedBy(InitialVelocityAngle + MathHelper.PiOver2) * originalSpeed; - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - } - } - } + if (projectile.velocity != Vector2.Zero) + { + AccumulatedXMovementSpeeds += newBaseDirection.X * (projectile.extraUpdates + 1) * 2f * originalSpeed; + projectile.velocity = newBaseDirection.RotatedBy(InitialVelocityAngle + MathHelper.PiOver2) * originalSpeed; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + } + } - #region Drawing - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D lightningSegmentTexture = Main.projectileTexture[projectile.type]; - projectile.GetAlpha(lightColor); - Vector2 lightningScale = new Vector2(projectile.scale) / 2f; - for (int i = 0; i < 3; i++) - { - // c_1 and f_1 are general fields that are used for drawing methods in here. - // c_1 is the color to be used, and f_1 is the opacity. - if (i == 0) - { - lightningScale = new Vector2(projectile.scale) * 0.6f; - DelegateMethods.c_1 = Color.DarkCyan * 0.85f; - } - else if (i == 1) - { - lightningScale = new Vector2(projectile.scale) * 0.4f; - DelegateMethods.c_1 = Color.Cyan * 0.85f; - } - else - { - lightningScale = new Vector2(projectile.scale) * 0.2f; - DelegateMethods.c_1 = Color.White; - } + #region Drawing + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D lightningSegmentTexture = Main.projectileTexture[projectile.type]; + projectile.GetAlpha(lightColor); + Vector2 lightningScale = new Vector2(projectile.scale) / 2f; + for (int i = 0; i < 3; i++) + { + // c_1 and f_1 are general fields that are used for drawing methods in here. + // c_1 is the color to be used, and f_1 is the opacity. + if (i == 0) + { + lightningScale = new Vector2(projectile.scale) * 0.6f; + DelegateMethods.c_1 = Color.DarkCyan * 0.85f; + } + else if (i == 1) + { + lightningScale = new Vector2(projectile.scale) * 0.4f; + DelegateMethods.c_1 = Color.Cyan * 0.85f; + } + else + { + lightningScale = new Vector2(projectile.scale) * 0.2f; + DelegateMethods.c_1 = Color.White; + } - DelegateMethods.f_1 = 1f; - for (int j = projectile.oldPos.Length - 1; j > 0; j--) - { - if (projectile.oldPos[j] != Vector2.Zero) - { - Vector2 start = projectile.oldPos[j] + projectile.Size * 0.5f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; - Vector2 end = projectile.oldPos[j - 1] + projectile.Size * 0.5f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; - Utils.DrawLaser(spriteBatch, lightningSegmentTexture, start, end, lightningScale, DelegateMethods.LightningLaserDraw); - } - } - } - return false; - } - #endregion + DelegateMethods.f_1 = 1f; + for (int j = projectile.oldPos.Length - 1; j > 0; j--) + { + if (projectile.oldPos[j] != Vector2.Zero) + { + Vector2 start = projectile.oldPos[j] + projectile.Size * 0.5f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; + Vector2 end = projectile.oldPos[j - 1] + projectile.Size * 0.5f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; + Utils.DrawLaser(spriteBatch, lightningSegmentTexture, start, end, lightningScale, DelegateMethods.LightningLaserDraw); + } + } + } + return false; + } + #endregion - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.Electrified, 180); + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Electrified, 180); - for (int i = 0; i < projectile.oldPos.Length - 1; i++) - { - // Skip zeroed old positions. They are almost certainly a - // result of incomplete indices. - if (projectile.oldPos[i + 1] == Vector2.Zero) - continue; + for (int i = 0; i < projectile.oldPos.Length - 1; i++) + { + // Skip zeroed old positions. They are almost certainly a + // result of incomplete indices. + if (projectile.oldPos[i + 1] == Vector2.Zero) + continue; - for (int j = 0; j < 8; j++) - { - Vector2 dustSpawnPosition = Vector2.Lerp(projectile.oldPos[i], projectile.oldPos[i + 1], j / 8f); - dustSpawnPosition += projectile.Size * 0.5f; + for (int j = 0; j < 8; j++) + { + Vector2 dustSpawnPosition = Vector2.Lerp(projectile.oldPos[i], projectile.oldPos[i + 1], j / 8f); + dustSpawnPosition += projectile.Size * 0.5f; - Dust electricity = Dust.NewDustPerfect(dustSpawnPosition, Main.rand.NextBool(2) ? 226 : 229); - electricity.velocity = Vector2.Zero; - electricity.scale = Main.rand.NextFloat(1.1f, 1.18f); - electricity.noGravity = true; - } - } - } - } + Dust electricity = Dust.NewDustPerfect(dustSpawnPosition, Main.rand.NextBool(2) ? 226 : 229); + electricity.velocity = Vector2.Zero; + electricity.scale = Main.rand.NextFloat(1.1f, 1.18f); + electricity.noGravity = true; + } + } + } + } } diff --git a/Projectiles/Magic/WaterLeechProj.cs b/Projectiles/Magic/WaterLeechProj.cs index f64ff24f59..791d319d95 100644 --- a/Projectiles/Magic/WaterLeechProj.cs +++ b/Projectiles/Magic/WaterLeechProj.cs @@ -9,27 +9,27 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Magic { - public class WaterLeechProj : ModProjectile - { + public class WaterLeechProj : ModProjectile + { public override string Texture => "CalamityMod/NPCs/AcidRain/WaterLeech"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Leech"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Leech"); Main.projFrames[projectile.type] = 4; - } + } - public override void SetDefaults() - { - projectile.width = projectile.height = 18; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.timeLeft = 540; - projectile.magic = true; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 18; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft = 540; + projectile.magic = true; + } - public override void AI() - { + public override void AI() + { projectile.frameCounter++; if (projectile.frameCounter > 4) { @@ -41,71 +41,71 @@ namespace CalamityMod.Projectiles.Magic projectile.frame = 0; } - if (projectile.ai[0] == 0f) - { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.Pi; - } - //Sticky Behaviour - projectile.StickyProjAI(5); - } + if (projectile.ai[0] == 0f) + { + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.Pi; + } + //Sticky Behaviour + projectile.StickyProjAI(5); + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - projectile.ModifyHitNPCSticky(3, false); - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + projectile.ModifyHitNPCSticky(3, false); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(projectile.position + projectile.velocity, projectile.velocity, projectile.width, projectile.height); - projectile.Kill(); - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(projectile.position + projectile.velocity, projectile.velocity, projectile.width, projectile.height); + projectile.Kill(); + return false; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int height = texture.Height / Main.projFrames[projectile.type]; - int drawStart = height * projectile.frame; - Vector2 origin = projectile.Size / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int drawStart = height * projectile.frame; + Vector2 origin = projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - return false; - } + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int height = texture.Height / Main.projFrames[projectile.type]; - int drawStart = height * projectile.frame; - Vector2 origin = projectile.Size / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int drawStart = height * projectile.frame; + Vector2 origin = projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/AcidRain/WaterLeechGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - } + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/AcidRain/WaterLeechGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.NPCKilled, (int)projectile.position.X, (int)projectile.position.Y, 1, 0.5f, 0f); - for (int i = 0; i < 5; i++) - { - int dust = Dust.NewDust(projectile.Center, 1, 1, (int)CalamityDusts.SulfurousSeaAcid, 0, 0, 0, default, 1.5f); - Main.dust[dust].noGravity = true; - } - } - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.NPCKilled, (int)projectile.position.X, (int)projectile.position.Y, 1, 0.5f, 0f); + for (int i = 0; i < 5; i++) + { + int dust = Dust.NewDust(projectile.Center, 1, 1, (int)CalamityDusts.SulfurousSeaAcid, 0, 0, 0, default, 1.5f); + Main.dust[dust].noGravity = true; + } + } + } } diff --git a/Projectiles/Magic/WyvernFeatherGreen.cs b/Projectiles/Magic/WyvernFeatherGreen.cs index fca16747e0..64361c3a9e 100644 --- a/Projectiles/Magic/WyvernFeatherGreen.cs +++ b/Projectiles/Magic/WyvernFeatherGreen.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; projectile.aiStyle = 93; aiType = ProjectileID.NailFriendly; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() diff --git a/Projectiles/Magic/WyvernProjectile.cs b/Projectiles/Magic/WyvernProjectile.cs index ec21c1b612..cc41e0a057 100644 --- a/Projectiles/Magic/WyvernProjectile.cs +++ b/Projectiles/Magic/WyvernProjectile.cs @@ -36,10 +36,10 @@ namespace CalamityMod.Projectiles.Magic { if (projectile.owner == Main.myPlayer) { - projectile.timeLeft = 0; - } - return false; - } + projectile.timeLeft = 0; + } + return false; + } public override void Kill(int timeLeft) { @@ -48,12 +48,12 @@ namespace CalamityMod.Projectiles.Magic { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 16, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } - int head = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/WyvernHead")); - Main.gore[head].timeLeft /= 10; - int body = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/WyvernBody")); - Main.gore[body].timeLeft /= 10; - int tail = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/WyvernTail")); - Main.gore[tail].timeLeft /= 10; + int head = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/WyvernHead")); + Main.gore[head].timeLeft /= 10; + int body = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/WyvernBody")); + Main.gore[body].timeLeft /= 10; + int tail = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, mod.GetGoreSlot("Gores/WyvernWeapons/WyvernTail")); + Main.gore[tail].timeLeft /= 10; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Magic/YharimsCrystalBeam.cs b/Projectiles/Magic/YharimsCrystalBeam.cs index 51ecb8c15f..bcacdac047 100644 --- a/Projectiles/Magic/YharimsCrystalBeam.cs +++ b/Projectiles/Magic/YharimsCrystalBeam.cs @@ -53,9 +53,9 @@ namespace CalamityMod.Projectiles.Magic projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.Calamity().PierceResistHarshness = 0.06f; - projectile.Calamity().PierceResistCap = 0.4f; - } + projectile.Calamity().PierceResistHarshness = 0.06f; + projectile.Calamity().PierceResistCap = 0.4f; + } public override void SendExtraAI(BinaryWriter writer) => writer.Write(projectile.localAI[1]); public override void ReceiveExtraAI(BinaryReader reader) => projectile.localAI[1] = reader.ReadSingle(); diff --git a/Projectiles/Melee/AegisBeam.cs b/Projectiles/Melee/AegisBeam.cs index 0be8a8f07b..5f37d4e7dd 100644 --- a/Projectiles/Melee/AegisBeam.cs +++ b/Projectiles/Melee/AegisBeam.cs @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Melee { for (int i = 0; i < flameAmt; i++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), 0f, projectile.owner, 0f, 0f); } } diff --git a/Projectiles/Melee/AegisBlast.cs b/Projectiles/Melee/AegisBlast.cs index 92d09a151d..66124d9b3c 100644 --- a/Projectiles/Melee/AegisBlast.cs +++ b/Projectiles/Melee/AegisBlast.cs @@ -95,9 +95,9 @@ namespace CalamityMod.Projectiles.Melee } } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - projectile.damage = (int)(projectile.damage * 0.95); - } - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + projectile.damage = (int)(projectile.damage * 0.95); + } + } } diff --git a/Projectiles/Melee/AegisFlame.cs b/Projectiles/Melee/AegisFlame.cs index 43af8f7713..7d60e6401e 100644 --- a/Projectiles/Melee/AegisFlame.cs +++ b/Projectiles/Melee/AegisFlame.cs @@ -91,6 +91,6 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Melee/AftershockRock.cs b/Projectiles/Melee/AftershockRock.cs index 5b019aba3b..22cea92f68 100644 --- a/Projectiles/Melee/AftershockRock.cs +++ b/Projectiles/Melee/AftershockRock.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Projectiles.Melee projectile.aiStyle = 14; projectile.friendly = true; projectile.penetrate = 6; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; projectile.melee = true; projectile.ignoreWater = true; aiType = ProjectileID.BoulderStaffOfEarth; diff --git a/Projectiles/Melee/AmidiasWhirlpool.cs b/Projectiles/Melee/AmidiasWhirlpool.cs index 1f236e324e..1b5c626512 100644 --- a/Projectiles/Melee/AmidiasWhirlpool.cs +++ b/Projectiles/Melee/AmidiasWhirlpool.cs @@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.Melee vector145 = center13; flag59 = true; num1016 = num1017; - break; + break; } } num3 = num1017; diff --git a/Projectiles/Melee/AncientBeam.cs b/Projectiles/Melee/AncientBeam.cs index 6304d04746..d7d6b3c405 100644 --- a/Projectiles/Melee/AncientBeam.cs +++ b/Projectiles/Melee/AncientBeam.cs @@ -10,7 +10,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class AncientBeam : ModProjectile + public class AncientBeam : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/ArkoftheAncientsGlow"; diff --git a/Projectiles/Melee/AncientStar.cs b/Projectiles/Melee/AncientStar.cs index 85c8b1b2fd..6ca8020580 100644 --- a/Projectiles/Melee/AncientStar.cs +++ b/Projectiles/Melee/AncientStar.cs @@ -10,131 +10,131 @@ namespace CalamityMod.Projectiles.Melee { public class AncientStar : ModProjectile { - const float MaxTime = 120; - public float Timer => MaxTime - projectile.timeLeft; + const float MaxTime = 120; + public float Timer => MaxTime - projectile.timeLeft; - public ref float Shine => ref projectile.ai[0]; + public ref float Shine => ref projectile.ai[0]; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Ancient Star"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.tileCollide = false; - projectile.melee = true; + projectile.tileCollide = false; + projectile.melee = true; projectile.penetrate = 1; projectile.timeLeft = (int)MaxTime; } public override void AI() { - if (Timer == 0) + if (Timer == 0) { - Particle spark = new CritSpark(projectile.Center, Vector2.Zero, Color.White, Color.Cyan, Main.rand.NextFloat(2.3f, 2.6f), 20, 0.1f, 1.5f, hueShift: 0.02f); - GeneralParticleHandler.SpawnParticle(spark); + Particle spark = new CritSpark(projectile.Center, Vector2.Zero, Color.White, Color.Cyan, Main.rand.NextFloat(2.3f, 2.6f), 20, 0.1f, 1.5f, hueShift: 0.02f); + GeneralParticleHandler.SpawnParticle(spark); - for (int i = 0; i < 4; i++) - { - Vector2 particleSpeed = projectile.velocity.RotatedByRandom(MathHelper.PiOver4 * 0.8f) * 0.1f; - Particle energyLeak = new SquishyLightParticle(projectile.Center, particleSpeed, Main.rand.NextFloat(0.8f, 1.4f), Color.Cyan, 60, 0.3f, 1.5f, hueShift: 0.02f); - GeneralParticleHandler.SpawnParticle(energyLeak); - } - } - - if (projectile.timeLeft < MaxTime - 5) - { - projectile.tileCollide = true; + for (int i = 0; i < 4; i++) + { + Vector2 particleSpeed = projectile.velocity.RotatedByRandom(MathHelper.PiOver4 * 0.8f) * 0.1f; + Particle energyLeak = new SquishyLightParticle(projectile.Center, particleSpeed, Main.rand.NextFloat(0.8f, 1.4f), Color.Cyan, 60, 0.3f, 1.5f, hueShift: 0.02f); + GeneralParticleHandler.SpawnParticle(energyLeak); + } } - if (Timer / MaxTime > 0.25f) + if (projectile.timeLeft < MaxTime - 5) { - projectile.velocity *= 0.95f; + projectile.tileCollide = true; } - int dustType = Main.rand.Next(3); - dustType = dustType == 0 ? 15 : dustType == 1 ? 57 : 58; - Dust.NewDust(projectile.Center, 14, 14, dustType, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 150, default, 1.3f); + if (Timer / MaxTime > 0.25f) + { + projectile.velocity *= 0.95f; + } - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 20 + Main.rand.Next(40); - if (Main.rand.NextBool(5)) - { - Main.PlaySound(SoundID.Item9, projectile.position); - } - } + int dustType = Main.rand.Next(3); + dustType = dustType == 0 ? 15 : dustType == 1 ? 57 : 58; + Dust.NewDust(projectile.Center, 14, 14, dustType, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 150, default, 1.3f); - if (Main.rand.NextBool(48)) - { - int starGore = Gore.NewGore(projectile.Center, new Vector2(projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[starGore].velocity *= 0.66f; - Main.gore[starGore].velocity += projectile.velocity * 0.3f; - } + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 20 + Main.rand.Next(40); + if (Main.rand.NextBool(5)) + { + Main.PlaySound(SoundID.Item9, projectile.position); + } + } - if (projectile.velocity.Length() < 2f) - { - projectile.Kill(); - return; - } - - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; + if (Main.rand.NextBool(48)) + { + int starGore = Gore.NewGore(projectile.Center, new Vector2(projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f), 16, 1f); + Main.gore[starGore].velocity *= 0.66f; + Main.gore[starGore].velocity += projectile.velocity * 0.3f; + } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + if (projectile.velocity.Length() < 2f) + { + projectile.Kill(); + return; + } + + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; + + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - if (Shine == 1f) + if (Shine == 1f) { - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - Texture2D starTexture = ModContent.GetTexture("CalamityMod/Particles/Sparkle"); - Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle"); - //Ajust the bloom's texture to be the same size as the star's - float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height; + Texture2D starTexture = ModContent.GetTexture("CalamityMod/Particles/Sparkle"); + Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle"); + //Ajust the bloom's texture to be the same size as the star's + float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height; - Color color = Main.hslToRgb((Main.GlobalTime * 0.6f) % 1, 1, 0.85f); - float rotation = Main.GlobalTime * 8f; - Vector2 sparkCenter = projectile.Center - Main.screenPosition; + Color color = Main.hslToRgb((Main.GlobalTime * 0.6f) % 1, 1, 0.85f); + float rotation = Main.GlobalTime * 8f; + Vector2 sparkCenter = projectile.Center - Main.screenPosition; - spriteBatch.Draw(bloomTexture, sparkCenter, null, color * 0.5f, 0, bloomTexture.Size() / 2f, 2 * properBloomSize, SpriteEffects.None, 0); - spriteBatch.Draw(starTexture, sparkCenter, null, color * 0.5f, rotation + MathHelper.PiOver4, starTexture.Size() / 2f, 1 * 0.75f, SpriteEffects.None, 0); - spriteBatch.Draw(starTexture, sparkCenter, null, Color.White, rotation, starTexture.Size() / 2f, 1, SpriteEffects.None, 0); + spriteBatch.Draw(bloomTexture, sparkCenter, null, color * 0.5f, 0, bloomTexture.Size() / 2f, 2 * properBloomSize, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, sparkCenter, null, color * 0.5f, rotation + MathHelper.PiOver4, starTexture.Size() / 2f, 1 * 0.75f, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, sparkCenter, null, Color.White, rotation, starTexture.Size() / 2f, 1, SpriteEffects.None, 0); - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - } + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + } - return false; - } + return false; + } - public override void Kill(int timeLeft) - { - var breakSound = Main.PlaySound(SoundID.DD2_WitherBeastDeath, projectile.Center); - if (breakSound != null) - breakSound.Volume *= 0.5f; + public override void Kill(int timeLeft) + { + var breakSound = Main.PlaySound(SoundID.DD2_WitherBeastDeath, projectile.Center); + if (breakSound != null) + breakSound.Volume *= 0.5f; - for (int i = 0; i < 5; i++) - { - Vector2 particleSpeed = Main.rand.NextVector2CircularEdge(1, 1) * Main.rand.NextFloat(5.2f, 4.3f); - Particle spark = new CritSpark(projectile.Center, particleSpeed, Color.White, Color.Cyan, Main.rand.NextFloat(1.3f, 1.6f), 40, 0.1f, 3.5f, hueShift: 0.02f); - GeneralParticleHandler.SpawnParticle(spark); - } + for (int i = 0; i < 5; i++) + { + Vector2 particleSpeed = Main.rand.NextVector2CircularEdge(1, 1) * Main.rand.NextFloat(5.2f, 4.3f); + Particle spark = new CritSpark(projectile.Center, particleSpeed, Color.White, Color.Cyan, Main.rand.NextFloat(1.3f, 1.6f), 40, 0.1f, 3.5f, hueShift: 0.02f); + GeneralParticleHandler.SpawnParticle(spark); + } - for (int i = 0; i < 3; i++) - { - Gore.NewGore(projectile.position, new Vector2(projectile.velocity.X * 0.05f, projectile.velocity.Y * 0.05f), Main.rand.Next(16, 18), 1f); - } - } + for (int i = 0; i < 3; i++) + { + Gore.NewGore(projectile.position, new Vector2(projectile.velocity.X * 0.05f, projectile.velocity.Y * 0.05f), Main.rand.Next(16, 18), 1f); + } + } } } diff --git a/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs index 349b2b1f70..a66c1954b4 100644 --- a/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs @@ -12,7 +12,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class ArkoftheAncientsParryHoldout : ModProjectile + public class ArkoftheAncientsParryHoldout : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/ArkoftheAncients"; diff --git a/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs b/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs index 41b88d485c..242d0d6600 100644 --- a/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs +++ b/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class ArkoftheAncientsSwungBlade : ModProjectile + public class ArkoftheAncientsSwungBlade : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/ArkoftheAncients"; diff --git a/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs b/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs index 5e53c082cd..69ff99bb08 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class ArkoftheCosmosBlast : ModProjectile + public class ArkoftheCosmosBlast : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/RendingScissorsRight"; //Umm actually the rending scissors are for aote mr programmer what the hel.. it gets changed in predraw anywyas diff --git a/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs index e828292464..48f408ba15 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class ArkoftheCosmosParryHoldout : ModProjectile + public class ArkoftheCosmosParryHoldout : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/RendingScissorsRight"; diff --git a/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs b/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs index d51d576946..6a89f77cd2 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class ArkoftheCosmosSwungBlade : ModProjectile + public class ArkoftheCosmosSwungBlade : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/SunderingScissorsRight"; diff --git a/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs index 3278332348..a61735a0a8 100644 --- a/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class ArkoftheElementsParryHoldout : ModProjectile + public class ArkoftheElementsParryHoldout : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/RendingScissorsRight"; diff --git a/Projectiles/Melee/ArkOfTheElements_SnapBlast.cs b/Projectiles/Melee/ArkOfTheElements_SnapBlast.cs index 8354507b46..f27dce2806 100644 --- a/Projectiles/Melee/ArkOfTheElements_SnapBlast.cs +++ b/Projectiles/Melee/ArkOfTheElements_SnapBlast.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class ArkoftheElementsSnapBlast : ModProjectile + public class ArkoftheElementsSnapBlast : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/RendingScissorsRight"; diff --git a/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs b/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs index 1cfa80a94d..4f7e294f0d 100644 --- a/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs +++ b/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class ArkoftheElementsSwungBlade : ModProjectile //"Kill la kill reference i wish"? Stop wishing, start creating! + public class ArkoftheElementsSwungBlade : ModProjectile //"Kill la kill reference i wish"? Stop wishing, start creating! { public override string Texture => "CalamityMod/Projectiles/Melee/RendingScissorsRight"; diff --git a/Projectiles/Melee/ArkoftheCosmos_Constellation.cs b/Projectiles/Melee/ArkoftheCosmos_Constellation.cs index 88d6a77a83..eee36d952a 100644 --- a/Projectiles/Melee/ArkoftheCosmos_Constellation.cs +++ b/Projectiles/Melee/ArkoftheCosmos_Constellation.cs @@ -9,7 +9,7 @@ using System.Collections.Generic; namespace CalamityMod.Projectiles.Melee { - public class ArkoftheCosmosConstellation : ModProjectile + public class ArkoftheCosmosConstellation : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/AstralScytheProjectile.cs b/Projectiles/Melee/AstralScytheProjectile.cs index beb2183c59..78227de78c 100644 --- a/Projectiles/Melee/AstralScytheProjectile.cs +++ b/Projectiles/Melee/AstralScytheProjectile.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Projectiles.Melee { public override string Texture => "CalamityMod/Projectiles/Enemy/MantisRing"; - private int tileCounter = 5; + private int tileCounter = 5; public override void SetStaticDefaults() { @@ -32,15 +32,15 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = 8; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 7; - projectile.tileCollide = false; + projectile.tileCollide = false; } public override void AI() { - if (tileCounter > 0) - tileCounter--; - if (tileCounter <= 0) - projectile.tileCollide = true; + if (tileCounter > 0) + tileCounter--; + if (tileCounter <= 0) + projectile.tileCollide = true; projectile.velocity *= 1.03f; diff --git a/Projectiles/Melee/AtaraxiaMain.cs b/Projectiles/Melee/AtaraxiaMain.cs index c35ef612af..76b751c096 100644 --- a/Projectiles/Melee/AtaraxiaMain.cs +++ b/Projectiles/Melee/AtaraxiaMain.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Melee projectile.height = 12; projectile.friendly = true; projectile.melee = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.extraUpdates = 2; projectile.timeLeft = 180; } diff --git a/Projectiles/Melee/AtaraxiaSide.cs b/Projectiles/Melee/AtaraxiaSide.cs index 18290a0e94..bffd94d519 100644 --- a/Projectiles/Melee/AtaraxiaSide.cs +++ b/Projectiles/Melee/AtaraxiaSide.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class AtaraxiaSide : ModProjectile + public class AtaraxiaSide : ModProjectile { private static int NumAnimationFrames = 5; private static int AnimationFrameTime = 9; @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Melee projectile.height = 8; projectile.friendly = true; projectile.melee = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.extraUpdates = 2; projectile.timeLeft = 180; } diff --git a/Projectiles/Melee/AtaraxiaSplit.cs b/Projectiles/Melee/AtaraxiaSplit.cs index 0771c80dd0..986f9091f0 100644 --- a/Projectiles/Melee/AtaraxiaSplit.cs +++ b/Projectiles/Melee/AtaraxiaSplit.cs @@ -16,8 +16,8 @@ namespace CalamityMod.Projectiles.Melee projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 6; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 6; projectile.timeLeft = 25; projectile.tileCollide = false; projectile.ignoreWater = true; diff --git a/Projectiles/Melee/BalefulHarvesterProjectile.cs b/Projectiles/Melee/BalefulHarvesterProjectile.cs index 0014176ff4..e4a1e06d6d 100644 --- a/Projectiles/Melee/BalefulHarvesterProjectile.cs +++ b/Projectiles/Melee/BalefulHarvesterProjectile.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee projectile.friendly = true; projectile.melee = true; projectile.penetrate = 1; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; projectile.timeLeft = 300; projectile.alpha = 255; projectile.tileCollide = false; @@ -45,69 +45,69 @@ namespace CalamityMod.Projectiles.Melee projectile.alpha = 0; } - if (projectile.ai[0] >= 0f && projectile.ai[0] < 200f) - { - int num554 = (int)projectile.ai[0]; - if (Main.npc[num554].active) - { - float num555 = 8f; - Vector2 vector44 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num556 = Main.npc[num554].position.X - vector44.X; - float num557 = Main.npc[num554].position.Y - vector44.Y; - float num558 = (float)Math.Sqrt((double)(num556 * num556 + num557 * num557)); - num558 = num555 / num558; - num556 *= num558; - num557 *= num558; - projectile.velocity.X = (projectile.velocity.X * 14f + num556) / 15f; - projectile.velocity.Y = (projectile.velocity.Y * 14f + num557) / 15f; - } - else - { - float num559 = 1000f; - int num3; - for (int num560 = 0; num560 < 200; num560 = num3 + 1) - { - if (Main.npc[num560].CanBeChasedBy(projectile, false)) - { - float num561 = Main.npc[num560].position.X + (float)(Main.npc[num560].width / 2); - float num562 = Main.npc[num560].position.Y + (float)(Main.npc[num560].height / 2); - float num563 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num561) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num562); - if (num563 < num559 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num560].position, Main.npc[num560].width, Main.npc[num560].height)) - { - num559 = num563; - projectile.ai[0] = (float)num560; - } - } - num3 = num560; - } - } + if (projectile.ai[0] >= 0f && projectile.ai[0] < 200f) + { + int num554 = (int)projectile.ai[0]; + if (Main.npc[num554].active) + { + float num555 = 8f; + Vector2 vector44 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); + float num556 = Main.npc[num554].position.X - vector44.X; + float num557 = Main.npc[num554].position.Y - vector44.Y; + float num558 = (float)Math.Sqrt((double)(num556 * num556 + num557 * num557)); + num558 = num555 / num558; + num556 *= num558; + num557 *= num558; + projectile.velocity.X = (projectile.velocity.X * 14f + num556) / 15f; + projectile.velocity.Y = (projectile.velocity.Y * 14f + num557) / 15f; + } + else + { + float num559 = 1000f; + int num3; + for (int num560 = 0; num560 < 200; num560 = num3 + 1) + { + if (Main.npc[num560].CanBeChasedBy(projectile, false)) + { + float num561 = Main.npc[num560].position.X + (float)(Main.npc[num560].width / 2); + float num562 = Main.npc[num560].position.Y + (float)(Main.npc[num560].height / 2); + float num563 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num561) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num562); + if (num563 < num559 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num560].position, Main.npc[num560].width, Main.npc[num560].height)) + { + num559 = num563; + projectile.ai[0] = (float)num560; + } + } + num3 = num560; + } + } - if (projectile.velocity.X < 0f) - { - projectile.spriteDirection = -1; - projectile.rotation = (float)Math.Atan2((double)-(double)projectile.velocity.Y, (double)-(double)projectile.velocity.X); - } - else - { - projectile.spriteDirection = 1; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); - } + if (projectile.velocity.X < 0f) + { + projectile.spriteDirection = -1; + projectile.rotation = (float)Math.Atan2((double)-(double)projectile.velocity.Y, (double)-(double)projectile.velocity.X); + } + else + { + projectile.spriteDirection = 1; + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); + } - for (int num157 = 0; num157 < 2; num157++) - { - int num158 = Dust.NewDust(new Vector2(projectile.position.X + 4f, projectile.position.Y + 4f), projectile.width - 8, projectile.height - 8, Main.rand.NextBool(2) ? 5 : 6, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 2f); - Main.dust[num158].position -= projectile.velocity * 2f; - Main.dust[num158].noGravity = true; - Dust expr_7A4A_cp_0_cp_0 = Main.dust[num158]; - expr_7A4A_cp_0_cp_0.velocity.X *= 0.3f; - Dust expr_7A65_cp_0_cp_0 = Main.dust[num158]; - expr_7A65_cp_0_cp_0.velocity.Y *= 0.3f; - } + for (int num157 = 0; num157 < 2; num157++) + { + int num158 = Dust.NewDust(new Vector2(projectile.position.X + 4f, projectile.position.Y + 4f), projectile.width - 8, projectile.height - 8, Main.rand.NextBool(2) ? 5 : 6, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 2f); + Main.dust[num158].position -= projectile.velocity * 2f; + Main.dust[num158].noGravity = true; + Dust expr_7A4A_cp_0_cp_0 = Main.dust[num158]; + expr_7A4A_cp_0_cp_0.velocity.X *= 0.3f; + Dust expr_7A65_cp_0_cp_0 = Main.dust[num158]; + expr_7A65_cp_0_cp_0.velocity.Y *= 0.3f; + } - return; - } + return; + } - projectile.Kill(); + projectile.Kill(); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Melee/BallOFuguProj.cs b/Projectiles/Melee/BallOFuguProj.cs index 04cd00513a..793a368f2b 100644 --- a/Projectiles/Melee/BallOFuguProj.cs +++ b/Projectiles/Melee/BallOFuguProj.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; Vector2 projVector = player.Center - projectile.Center; projectile.rotation = projVector.ToRotation() - 1.57f; if (player.dead) diff --git a/Projectiles/Melee/BladecrestOathswordProj.cs b/Projectiles/Melee/BladecrestOathswordProj.cs index 01cc2f831f..411b44627c 100644 --- a/Projectiles/Melee/BladecrestOathswordProj.cs +++ b/Projectiles/Melee/BladecrestOathswordProj.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class BladecrestOathswordProj : BaseIdleHoldoutProjectile + public class BladecrestOathswordProj : BaseIdleHoldoutProjectile { public enum SwingState { diff --git a/Projectiles/Melee/BlazingPhantomBlade.cs b/Projectiles/Melee/BlazingPhantomBlade.cs index 466cb9df42..97e19f7b67 100644 --- a/Projectiles/Melee/BlazingPhantomBlade.cs +++ b/Projectiles/Melee/BlazingPhantomBlade.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class BlazingPhantomBlade : ModProjectile + public class BlazingPhantomBlade : ModProjectile { public override void SetStaticDefaults() { @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Melee { Lighting.AddLight(projectile.Center, 0.6f, 0f, 0f); - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 8f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 8f, 20f); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Melee/Blood.cs b/Projectiles/Melee/Blood.cs index 4e04f7104e..6ce442a8f7 100644 --- a/Projectiles/Melee/Blood.cs +++ b/Projectiles/Melee/Blood.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class Blood : ModProjectile + public class Blood : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -22,9 +22,9 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f) @@ -37,18 +37,18 @@ namespace CalamityMod.Projectiles.Melee } } - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 6f, 20f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 6f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { Player player = Main.player[projectile.owner]; - if (player.moonLeech) - return; + if (player.moonLeech) + return; - int healAmt = 2; - player.statLife += healAmt; + int healAmt = 2; + player.statLife += healAmt; player.HealEffect(healAmt); } } diff --git a/Projectiles/Melee/Blood2.cs b/Projectiles/Melee/Blood2.cs index f55ebc98ae..36d01bb41b 100644 --- a/Projectiles/Melee/Blood2.cs +++ b/Projectiles/Melee/Blood2.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class Blood2 : ModProjectile + public class Blood2 : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -22,9 +22,9 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 150; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 120 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 120 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f) @@ -37,8 +37,8 @@ namespace CalamityMod.Projectiles.Melee } } - if (projectile.timeLeft < 120) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 6f, 20f); + if (projectile.timeLeft < 120) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 6f, 20f); } } } diff --git a/Projectiles/Melee/BloodExplosion.cs b/Projectiles/Melee/BloodExplosion.cs index 0192e780b8..88bd805ae1 100644 --- a/Projectiles/Melee/BloodExplosion.cs +++ b/Projectiles/Melee/BloodExplosion.cs @@ -5,59 +5,59 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Melee { - public class BloodExplosion : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public class BloodExplosion : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Blood"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Blood"); + } - public override void SetDefaults() - { - projectile.width = 100; - projectile.height = 100; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.timeLeft = 5; - projectile.melee = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = -1; - } + public override void SetDefaults() + { + projectile.width = 100; + projectile.height = 100; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = 5; + projectile.melee = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; + } - public override void AI() - { - if (projectile.ai[1] > 0f) - return; + public override void AI() + { + if (projectile.ai[1] > 0f) + return; - Main.PlaySound(SoundID.Item14, projectile.position); - for (int d = 0; d < 4; d++) - { - int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Blood, 0f, 0f, 100, default, 1.5f); - Main.dust[index].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[index].scale = 0.5f; - Main.dust[index].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int d = 0; d < 6; d++) - { - int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Blood, 0f, 0f, 100, default, 2f); - Main.dust[index].noGravity = true; - Main.dust[index].velocity *= 5f; - index = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Blood, 0f, 0f, 100, default, 1.5f); - Main.dust[index].velocity *= 2f; - } - projectile.ai[1]++; - } + Main.PlaySound(SoundID.Item14, projectile.position); + for (int d = 0; d < 4; d++) + { + int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Blood, 0f, 0f, 100, default, 1.5f); + Main.dust[index].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[index].scale = 0.5f; + Main.dust[index].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int d = 0; d < 6; d++) + { + int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[index].noGravity = true; + Main.dust[index].velocity *= 5f; + index = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Blood, 0f, 0f, 100, default, 1.5f); + Main.dust[index].velocity *= 2f; + } + projectile.ai[1]++; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 60); - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 60); + } + } } diff --git a/Projectiles/Melee/BloodyBlade.cs b/Projectiles/Melee/BloodyBlade.cs index 223bebbf57..d8b7f2cd46 100644 --- a/Projectiles/Melee/BloodyBlade.cs +++ b/Projectiles/Melee/BloodyBlade.cs @@ -53,14 +53,14 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.immune[projectile.owner] = 9; - target.AddBuff(ModContent.BuffType(), 60); - target.AddBuff(BuffID.Ichor, 60); + target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(BuffID.Ichor, 60); } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(BuffID.Ichor, 60); - target.AddBuff(ModContent.BuffType(), 60); - } + target.AddBuff(ModContent.BuffType(), 60); + } } } diff --git a/Projectiles/Melee/BlueAura.cs b/Projectiles/Melee/BlueAura.cs index 51f745879f..8411a06fed 100644 --- a/Projectiles/Melee/BlueAura.cs +++ b/Projectiles/Melee/BlueAura.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Melee projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 300; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Melee/BonebreakerFragment1.cs b/Projectiles/Melee/BonebreakerFragment1.cs index 53e5dcf1a6..4973879e74 100644 --- a/Projectiles/Melee/BonebreakerFragment1.cs +++ b/Projectiles/Melee/BonebreakerFragment1.cs @@ -15,14 +15,14 @@ namespace CalamityMod.Projectiles.Melee } public override void SetDefaults() - { - projectile.width = 6; - projectile.height = 6; - projectile.aiStyle = 24; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.alpha = 50; - projectile.timeLeft = 600; + { + projectile.width = 6; + projectile.height = 6; + projectile.aiStyle = 24; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.alpha = 50; + projectile.timeLeft = 600; projectile.melee = true; } diff --git a/Projectiles/Melee/BonebreakerProjectile.cs b/Projectiles/Melee/BonebreakerProjectile.cs index 6d40a73ebe..b9290cf7e5 100644 --- a/Projectiles/Melee/BonebreakerProjectile.cs +++ b/Projectiles/Melee/BonebreakerProjectile.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class BonebreakerProjectile : ModProjectile + public class BonebreakerProjectile : ModProjectile { public override void SetStaticDefaults() { @@ -22,9 +22,9 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = -1; projectile.alpha = 255; projectile.melee = true; - projectile.timeLeft = 600; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = -2; + projectile.timeLeft = 600; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -2; } public override void AI() @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Melee projectile.velocity.X *= 0.98f; projectile.velocity.Y += 0.35f; } - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; } //Sticky Behaviour projectile.StickyProjAI(15); @@ -80,18 +80,18 @@ namespace CalamityMod.Projectiles.Melee } if (projectile.owner == Main.myPlayer) { - for (int s = 0; s < Main.rand.Next(2,5); s++) - { - Vector2 velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (velocity.X == 0f && velocity.Y == 0f) - { - velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - velocity.Normalize(); - velocity *= (float)Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), projectile.knockBack * 0.5f, projectile.owner, Main.rand.Next(0,4), 0f); - } - } + for (int s = 0; s < Main.rand.Next(2,5); s++) + { + Vector2 velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + while (velocity.X == 0f && velocity.Y == 0f) + { + velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + } + velocity.Normalize(); + velocity *= (float)Main.rand.Next(70, 101) * 0.1f; + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), projectile.knockBack * 0.5f, projectile.owner, Main.rand.Next(0,4), 0f); + } + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -109,14 +109,14 @@ namespace CalamityMod.Projectiles.Melee } public override bool? CanHitNPC(NPC target) - { - if (projectile.ai[0] == 1f) - { - return false; - } - return null; - } + { + if (projectile.ai[0] == 1f) + { + return false; + } + return null; + } - public override bool CanHitPvp(Player target) => projectile.ai[0] != 1f; + public override bool CanHitPvp(Player target) => projectile.ai[0] != 1f; } } diff --git a/Projectiles/Melee/Brimblast.cs b/Projectiles/Melee/Brimblast.cs index 572b5c03eb..953fbcb2ad 100644 --- a/Projectiles/Melee/Brimblast.cs +++ b/Projectiles/Melee/Brimblast.cs @@ -82,9 +82,9 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.immune[projectile.owner] = 7; target.AddBuff(ModContent.BuffType(), 120); diff --git a/Projectiles/Melee/BrimlanceHellfireExplosion.cs b/Projectiles/Melee/BrimlanceHellfireExplosion.cs index c0da8e2992..302775f4f3 100644 --- a/Projectiles/Melee/BrimlanceHellfireExplosion.cs +++ b/Projectiles/Melee/BrimlanceHellfireExplosion.cs @@ -27,9 +27,9 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = -1; projectile.timeLeft = 60; projectile.melee = true; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 10; - } + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 10; + } public override void AI() { diff --git a/Projectiles/Melee/BrimlanceStandingFire.cs b/Projectiles/Melee/BrimlanceStandingFire.cs index c1167da451..ad7e3d1ec0 100644 --- a/Projectiles/Melee/BrimlanceStandingFire.cs +++ b/Projectiles/Melee/BrimlanceStandingFire.cs @@ -92,9 +92,9 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.immune[projectile.owner] = 7; target.AddBuff(ModContent.BuffType(), 120); diff --git a/Projectiles/Melee/Brimlash2.cs b/Projectiles/Melee/Brimlash2.cs index 890fc2f6e5..b2c0c97ef0 100644 --- a/Projectiles/Melee/Brimlash2.cs +++ b/Projectiles/Melee/Brimlash2.cs @@ -7,77 +7,77 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class Brimlash2 : ModProjectile + public class Brimlash2 : ModProjectile { public override void SetStaticDefaults() { DisplayName.SetDefault("Brimlash"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { projectile.width = 20; projectile.height = 20; - projectile.aiStyle = 27; - aiType = ProjectileID.LightBeam; - projectile.friendly = true; + projectile.aiStyle = 27; + aiType = ProjectileID.LightBeam; + projectile.friendly = true; projectile.ignoreWater = true; projectile.penetrate = 1; projectile.melee = true; projectile.timeLeft = 120; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.05f / 255f, (255 - projectile.alpha) * 0.05f / 255f); - if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 15f); + if (projectile.timeLeft < 90) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 15f); - int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 235, 0f, 0f, 100, default, 1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += projectile.velocity * 0.1f; - } + int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 235, 0f, 0f, 100, default, 1f); + Main.dust[num458].noGravity = true; + Main.dust[num458].velocity *= 0.5f; + Main.dust[num458].velocity += projectile.velocity * 0.1f; + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 200, 200, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(200, 200, 200, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.timeLeft > 115) - return false; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.timeLeft > 115) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item10, projectile.position); - int num3; - for (int num795 = 4; num795 < 31; num795 = num3 + 1) - { - 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, 235, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; - dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 235, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; - dust.velocity *= 0.05f; - num3 = num795; - } - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item10, projectile.position); + int num3; + for (int num795 = 4; num795 < 31; num795 = num3 + 1) + { + 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, 235, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[num798].noGravity = true; + Dust dust = Main.dust[num798]; + dust.velocity *= 0.5f; + num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 235, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[num798]; + dust.velocity *= 0.05f; + num3 = num795; + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 180); } diff --git a/Projectiles/Melee/BrimlashProj.cs b/Projectiles/Melee/BrimlashProj.cs index 67717d9cc3..3603d1ee14 100644 --- a/Projectiles/Melee/BrimlashProj.cs +++ b/Projectiles/Melee/BrimlashProj.cs @@ -14,70 +14,70 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Brimlash"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { projectile.width = 20; projectile.height = 20; - projectile.aiStyle = 27; - aiType = ProjectileID.LightBeam; - projectile.friendly = true; + projectile.aiStyle = 27; + aiType = ProjectileID.LightBeam; + projectile.friendly = true; projectile.ignoreWater = true; projectile.penetrate = -1; - projectile.timeLeft = 300; + projectile.timeLeft = 300; projectile.melee = true; } - public override void AI() - { - projectile.velocity *= 0.99f; - if (projectile.velocity.Length() < 3f) - { - projectile.Kill(); - } - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.05f / 255f, (255 - projectile.alpha) * 0.05f / 255f); - int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += projectile.velocity * 0.1f; - } - - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 200, 200, projectile.alpha); - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.timeLeft > 295) - return false; - - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - - public override void Kill(int timeLeft) + public override void AI() { - Main.PlaySound(SoundID.Item10, projectile.position); - int num3; - for (int num795 = 4; num795 < 31; num795 = num3 + 1) - { - 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, (int)CalamityDusts.Brimstone, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; - dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, (int)CalamityDusts.Brimstone, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; - dust.velocity *= 0.05f; - num3 = num795; - } + projectile.velocity *= 0.99f; + if (projectile.velocity.Length() < 3f) + { + projectile.Kill(); + } + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.05f / 255f, (255 - projectile.alpha) * 0.05f / 255f); + int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + Main.dust[num458].noGravity = true; + Main.dust[num458].velocity *= 0.5f; + Main.dust[num458].velocity += projectile.velocity * 0.1f; + } - float spread = 90f * 0.0174f; + public override Color? GetAlpha(Color lightColor) + { + return new Color(200, 200, 200, projectile.alpha); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.timeLeft > 295) + return false; + + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item10, projectile.position); + int num3; + for (int num795 = 4; num795 < 31; num795 = num3 + 1) + { + 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, (int)CalamityDusts.Brimstone, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[num798].noGravity = true; + Dust dust = Main.dust[num798]; + dust.velocity *= 0.5f; + num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, (int)CalamityDusts.Brimstone, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[num798]; + dust.velocity *= 0.05f; + num3 = num795; + } + + float spread = 90f * 0.0174f; double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; diff --git a/Projectiles/Melee/BrimstoneBoom.cs b/Projectiles/Melee/BrimstoneBoom.cs index b599a16e14..b88d88e196 100644 --- a/Projectiles/Melee/BrimstoneBoom.cs +++ b/Projectiles/Melee/BrimstoneBoom.cs @@ -22,11 +22,11 @@ namespace CalamityMod.Projectiles.Melee projectile.ignoreWater = true; projectile.tileCollide = false; projectile.melee = true; - projectile.penetrate = -1; + projectile.penetrate = -1; projectile.timeLeft = 5; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 10; - } + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 10; + } public override void AI() { @@ -67,9 +67,9 @@ namespace CalamityMod.Projectiles.Melee } } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 6; - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 6; + } + } } diff --git a/Projectiles/Melee/BrinySpout.cs b/Projectiles/Melee/BrinySpout.cs index 5045a576e4..ab432b0735 100644 --- a/Projectiles/Melee/BrinySpout.cs +++ b/Projectiles/Melee/BrinySpout.cs @@ -24,9 +24,9 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = -1; projectile.alpha = 255; projectile.timeLeft = 60; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 8; - } + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 8; + } public override void AI() { diff --git a/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs b/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs index bc8572cf2b..ff8ed9a4e9 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs @@ -12,7 +12,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class AridGrandeur : ModProjectile + public class AridGrandeur : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur"; private bool initialized = false; diff --git a/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs b/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs index 4ed383a81c..636ba6827d 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs @@ -14,7 +14,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class BitingEmbrace : ModProjectile + public class BitingEmbrace : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/BrokenBiomeBlade_BitingEmbraceSmall"; diff --git a/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs b/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs index daaa442f60..73e945cf78 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs @@ -11,7 +11,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class DecaysRetort : ModProjectile + public class DecaysRetort : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort"; private bool initialized = false; diff --git a/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs b/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs index 290c1cb518..28befa2b95 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs @@ -13,7 +13,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class GrovetendersTouch : ModProjectile + public class GrovetendersTouch : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouchBlade"; private bool initialized = false; diff --git a/Projectiles/Melee/BrokenBiomeBlade_PurityProjection.cs b/Projectiles/Melee/BrokenBiomeBlade_PurityProjection.cs index a9f325cf99..963d2c4cd0 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_PurityProjection.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_PurityProjection.cs @@ -10,7 +10,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class PurityProjection : ModProjectile //The boring plain one + public class PurityProjection : ModProjectile //The boring plain one { public override string Texture => "CalamityMod/Projectiles/Melee/BrokenBiomeBlade_PurityProjection"; diff --git a/Projectiles/Melee/BurningMeteor.cs b/Projectiles/Melee/BurningMeteor.cs index 112bfbe2bb..997bc3497e 100644 --- a/Projectiles/Melee/BurningMeteor.cs +++ b/Projectiles/Melee/BurningMeteor.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.tileCollide = false; projectile.penetrate = 1; - projectile.extraUpdates = 2; + projectile.extraUpdates = 2; projectile.timeLeft = 180; projectile.ignoreWater = true; } @@ -92,10 +92,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 175) - return false; + if (projectile.timeLeft > 175) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } } diff --git a/Projectiles/Melee/ChaosFlameSmall.cs b/Projectiles/Melee/ChaosFlameSmall.cs index 85774e7829..c843b762c1 100644 --- a/Projectiles/Melee/ChaosFlameSmall.cs +++ b/Projectiles/Melee/ChaosFlameSmall.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ChaosFlameSmall : ModProjectile + public class ChaosFlameSmall : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Melee/ClamCrusherFlail.cs b/Projectiles/Melee/ClamCrusherFlail.cs index 193f9a9eba..c601ca5883 100644 --- a/Projectiles/Melee/ClamCrusherFlail.cs +++ b/Projectiles/Melee/ClamCrusherFlail.cs @@ -6,7 +6,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ClamCrusherFlail : ModProjectile + public class ClamCrusherFlail : ModProjectile { public int finalDamage; @@ -127,7 +127,7 @@ namespace CalamityMod.Projectiles.Melee Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ClamImpact"), (int)projectile.position.X, (int)projectile.position.Y); for (int num105 = 0; num105 < 50; num105++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int waterDust = Dust.NewDust(new Vector2(projectile.Center.X, projectile.Center.Y), projectile.width / 2, projectile.height / 2, 33, velocity.X, velocity.Y, 0, new Color(0, 142, 255), 1.5f); Main.dust[waterDust].velocity *= 2f; } @@ -176,12 +176,12 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.ai[1] >= 45f && (projectile.ai[0] != 1f || projectile.ai[0] != 2f)) - target.AddBuff(ModContent.BuffType(), 120); - else - target.AddBuff(ModContent.BuffType(), 60); + if (projectile.ai[1] >= 45f && (projectile.ai[0] != 1f || projectile.ai[0] != 2f)) + target.AddBuff(ModContent.BuffType(), 120); + else + target.AddBuff(ModContent.BuffType(), 60); - projectile.ai[0] = 1f; + projectile.ai[0] = 1f; projectile.netUpdate = true; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ClamImpact"), (int)projectile.position.X, (int)projectile.position.Y); } diff --git a/Projectiles/Melee/CometQuasherMeteor.cs b/Projectiles/Melee/CometQuasherMeteor.cs index cafe691996..ae9034b638 100644 --- a/Projectiles/Melee/CometQuasherMeteor.cs +++ b/Projectiles/Melee/CometQuasherMeteor.cs @@ -16,23 +16,23 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { - projectile.width = 24; - projectile.height = 24; - projectile.aiStyle = 1; - projectile.friendly = true; - projectile.melee = true; - projectile.tileCollide = false; - projectile.extraUpdates = 2; - aiType = ProjectileID.Meteor1; + projectile.width = 24; + projectile.height = 24; + projectile.aiStyle = 1; + projectile.friendly = true; + projectile.melee = true; + projectile.tileCollide = false; + projectile.extraUpdates = 2; + aiType = ProjectileID.Meteor1; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D tex = Main.projectileTexture[projectile.type]; - if (projectile.Calamity().lineColor == 1) - tex = ModContent.GetTexture("CalamityMod/Projectiles/Melee/CometQuasherMeteor2"); - if (projectile.Calamity().lineColor == 2) - tex = ModContent.GetTexture("CalamityMod/Projectiles/Melee/CometQuasherMeteor3"); + if (projectile.Calamity().lineColor == 1) + tex = ModContent.GetTexture("CalamityMod/Projectiles/Melee/CometQuasherMeteor2"); + if (projectile.Calamity().lineColor == 2) + tex = ModContent.GetTexture("CalamityMod/Projectiles/Melee/CometQuasherMeteor3"); CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1, tex); return false; @@ -40,45 +40,45 @@ namespace CalamityMod.Projectiles.Melee public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Item89, projectile.position); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(128f * projectile.scale)); - for (int index = 0; index < 8; ++index) - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); - for (int index1 = 0; index1 < 32; ++index1) - { - int index2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 2.5f); - Dust dust1 = Main.dust[index2]; - dust1.noGravity = true; - dust1.velocity *= 3f; - int index3 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 1.5f); - Dust dust2 = Main.dust[index3]; - dust2.velocity *= 2f; - dust2.noGravity = true; - } - for (int index1 = 0; index1 < 2; ++index1) - { - int index2 = Gore.NewGore(projectile.position + new Vector2((float) (projectile.width * Main.rand.Next(100)) / 100f, (float) (projectile.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, new Vector2(), Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[index2]; - gore.velocity *= 0.3f; - gore.velocity.X += (float) Main.rand.Next(-10, 11) * 0.05f; - gore.velocity.Y += (float) Main.rand.Next(-10, 11) * 0.05f; - } - if (projectile.owner == Main.myPlayer) - { - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.localAI[1] = -1f; - projectile.maxPenetrate = 0; - projectile.Damage(); - } - for (int index1 = 0; index1 < 5; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, Utils.SelectRandom(Main.rand, new int[3]{ DustID.Fire, 259, 158 }), 2.5f * (float) projectile.direction, -2.5f, 0, new Color(), 1f); - Dust dust1 = Main.dust[index2]; - dust1.alpha = 200; - dust1.velocity *= 2.4f; - dust1.scale += Main.rand.NextFloat(); - } + Main.PlaySound(SoundID.Item89, projectile.position); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(128f * projectile.scale)); + for (int index = 0; index < 8; ++index) + Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); + for (int index1 = 0; index1 < 32; ++index1) + { + int index2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 2.5f); + Dust dust1 = Main.dust[index2]; + dust1.noGravity = true; + dust1.velocity *= 3f; + int index3 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 1.5f); + Dust dust2 = Main.dust[index3]; + dust2.velocity *= 2f; + dust2.noGravity = true; + } + for (int index1 = 0; index1 < 2; ++index1) + { + int index2 = Gore.NewGore(projectile.position + new Vector2((float) (projectile.width * Main.rand.Next(100)) / 100f, (float) (projectile.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, new Vector2(), Main.rand.Next(61, 64), 1f); + Gore gore = Main.gore[index2]; + gore.velocity *= 0.3f; + gore.velocity.X += (float) Main.rand.Next(-10, 11) * 0.05f; + gore.velocity.Y += (float) Main.rand.Next(-10, 11) * 0.05f; + } + if (projectile.owner == Main.myPlayer) + { + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.localAI[1] = -1f; + projectile.maxPenetrate = 0; + projectile.Damage(); + } + for (int index1 = 0; index1 < 5; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, Utils.SelectRandom(Main.rand, new int[3]{ DustID.Fire, 259, 158 }), 2.5f * (float) projectile.direction, -2.5f, 0, new Color(), 1f); + Dust dust1 = Main.dust[index2]; + dust1.alpha = 200; + dust1.velocity *= 2.4f; + dust1.scale += Main.rand.NextFloat(); + } } } } diff --git a/Projectiles/Melee/CosmicDischargeFlail.cs b/Projectiles/Melee/CosmicDischargeFlail.cs index 9d78e9ab79..0ac5525aec 100644 --- a/Projectiles/Melee/CosmicDischargeFlail.cs +++ b/Projectiles/Melee/CosmicDischargeFlail.cs @@ -10,7 +10,7 @@ using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee { - public class CosmicDischargeFlail : BaseWhipProjectile + public class CosmicDischargeFlail : BaseWhipProjectile { public override void SetStaticDefaults() { @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Melee projectile.ignoreWater = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 6; - projectile.coldDamage = true; - projectile.extraUpdates = 1; + projectile.coldDamage = true; + projectile.extraUpdates = 1; } public override Color SpecialDrawColor => new Color(150, 255, 255); diff --git a/Projectiles/Melee/CosmicIceBurst.cs b/Projectiles/Melee/CosmicIceBurst.cs index e3ac08aed0..93401e6fa1 100644 --- a/Projectiles/Melee/CosmicIceBurst.cs +++ b/Projectiles/Melee/CosmicIceBurst.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 6; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Melee/CosmicOrb.cs b/Projectiles/Melee/CosmicOrb.cs index 69593741e6..100c3a82e4 100644 --- a/Projectiles/Melee/CosmicOrb.cs +++ b/Projectiles/Melee/CosmicOrb.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class CosmicOrb : ModProjectile + public class CosmicOrb : ModProjectile { public override void SetStaticDefaults() { @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee } } - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 8f, 5, ModContent.ProjectileType()); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 8f, 5, ModContent.ProjectileType()); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/CosmicShivBlade.cs b/Projectiles/Melee/CosmicShivBlade.cs index 4308c8b5ab..c92a0abbc4 100644 --- a/Projectiles/Melee/CosmicShivBlade.cs +++ b/Projectiles/Melee/CosmicShivBlade.cs @@ -7,7 +7,7 @@ using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Melee { - public class CosmicShivBlade : ModProjectile + public class CosmicShivBlade : ModProjectile { public const int penetrateMax = 12; public const float maxScale = 1.8f; diff --git a/Projectiles/Melee/CosmicSpiritBomb1.cs b/Projectiles/Melee/CosmicSpiritBomb1.cs index d6fb01b55c..70e6b6364c 100644 --- a/Projectiles/Melee/CosmicSpiritBomb1.cs +++ b/Projectiles/Melee/CosmicSpiritBomb1.cs @@ -24,58 +24,58 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; } - public override void AI() - { - float num395 = (float)Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - projectile.scale = num395 + 0.95f; + public override void AI() + { + float num395 = (float)Main.mouseTextColor / 200f - 0.35f; + num395 *= 0.2f; + projectile.scale = num395 + 0.95f; - float num947 = (projectile.Center - Main.player[projectile.owner].Center).Length() / 100f; - if (num947 <= 2f) - { - num947 = 1f; - } - else - { - if (num947 > 8f) - { - num947 = 12f; - } - else if (num947 > 6f) - { - num947 = 9f; - } - else if (num947 > 5f) - { - num947 = 7f; - } - else if (num947 > 4f) - { - num947 = 5f; - } - else if (num947 > 3f) - { - num947 = 4f; - } - else if (num947 > 2.5f) - { - num947 = 3f; - } - else - { - num947 = 2f; - } - } - projectile.velocity = Vector2.Normalize(Main.player[projectile.owner].Center - projectile.Center) * num947; - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; - } + float num947 = (projectile.Center - Main.player[projectile.owner].Center).Length() / 100f; + if (num947 <= 2f) + { + num947 = 1f; + } + else + { + if (num947 > 8f) + { + num947 = 12f; + } + else if (num947 > 6f) + { + num947 = 9f; + } + else if (num947 > 5f) + { + num947 = 7f; + } + else if (num947 > 4f) + { + num947 = 5f; + } + else if (num947 > 3f) + { + num947 = 4f; + } + else if (num947 > 2.5f) + { + num947 = 3f; + } + else + { + num947 = 2f; + } + } + projectile.velocity = Vector2.Normalize(Main.player[projectile.owner].Center - projectile.Center) * num947; + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 200, 200, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(200, 200, 200, projectile.alpha); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Frostburn, 180); } diff --git a/Projectiles/Melee/CosmicSpiritBomb2.cs b/Projectiles/Melee/CosmicSpiritBomb2.cs index f7cd17b6bb..52fd254d11 100644 --- a/Projectiles/Melee/CosmicSpiritBomb2.cs +++ b/Projectiles/Melee/CosmicSpiritBomb2.cs @@ -26,64 +26,64 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - float num395 = (float)Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - projectile.scale = num395 + 0.95f; + float num395 = (float)Main.mouseTextColor / 200f - 0.35f; + num395 *= 0.2f; + projectile.scale = num395 + 0.95f; - float num947 = (projectile.Center - Main.player[projectile.owner].Center).Length() / 100f; - if (num947 <= 2f) - { - num947 = 1f; - } - else - { - if (num947 > 8f) - { - num947 = 12f; - } - else if (num947 > 6f) - { - num947 = 9f; - } - else if (num947 > 5f) - { - num947 = 7f; - } - else if (num947 > 4f) - { - num947 = 5f; - } - else if (num947 > 3f) - { - num947 = 4f; - } - else if (num947 > 2.5f) - { - num947 = 3f; - } - else - { - num947 = 2f; - } - } - projectile.velocity = Vector2.Normalize(Main.player[projectile.owner].Center - projectile.Center) * num947; - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; - } + float num947 = (projectile.Center - Main.player[projectile.owner].Center).Length() / 100f; + if (num947 <= 2f) + { + num947 = 1f; + } + else + { + if (num947 > 8f) + { + num947 = 12f; + } + else if (num947 > 6f) + { + num947 = 9f; + } + else if (num947 > 5f) + { + num947 = 7f; + } + else if (num947 > 4f) + { + num947 = 5f; + } + else if (num947 > 3f) + { + num947 = 4f; + } + else if (num947 > 2.5f) + { + num947 = 3f; + } + else + { + num947 = 2f; + } + } + projectile.velocity = Vector2.Normalize(Main.player[projectile.owner].Center - projectile.Center) * num947; + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 200, 200, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(200, 200, 200, projectile.alpha); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.OnFire, 180); } public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); + { + Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); + projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 200; projectile.height = 200; diff --git a/Projectiles/Melee/CosmicSpiritBomb3.cs b/Projectiles/Melee/CosmicSpiritBomb3.cs index 2bafdb7e79..bd1213e18e 100644 --- a/Projectiles/Melee/CosmicSpiritBomb3.cs +++ b/Projectiles/Melee/CosmicSpiritBomb3.cs @@ -26,64 +26,64 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - float num395 = (float)Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - projectile.scale = num395 + 0.95f; + float num395 = (float)Main.mouseTextColor / 200f - 0.35f; + num395 *= 0.2f; + projectile.scale = num395 + 0.95f; - float num947 = (projectile.Center - Main.player[projectile.owner].Center).Length() / 100f; - if (num947 <= 2f) - { - num947 = 1f; - } - else - { - if (num947 > 8f) - { - num947 = 12f; - } - else if (num947 > 6f) - { - num947 = 9f; - } - else if (num947 > 5f) - { - num947 = 7f; - } - else if (num947 > 4f) - { - num947 = 5f; - } - else if (num947 > 3f) - { - num947 = 4f; - } - else if (num947 > 2.5f) - { - num947 = 3f; - } - else - { - num947 = 2f; - } - } - projectile.velocity = Vector2.Normalize(Main.player[projectile.owner].Center - projectile.Center) * num947; - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; - } + float num947 = (projectile.Center - Main.player[projectile.owner].Center).Length() / 100f; + if (num947 <= 2f) + { + num947 = 1f; + } + else + { + if (num947 > 8f) + { + num947 = 12f; + } + else if (num947 > 6f) + { + num947 = 9f; + } + else if (num947 > 5f) + { + num947 = 7f; + } + else if (num947 > 4f) + { + num947 = 5f; + } + else if (num947 > 3f) + { + num947 = 4f; + } + else if (num947 > 2.5f) + { + num947 = 3f; + } + else + { + num947 = 2f; + } + } + projectile.velocity = Vector2.Normalize(Main.player[projectile.owner].Center - projectile.Center) * num947; + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 200, 200, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(200, 200, 200, projectile.alpha); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Ichor, 60); } public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); + { + Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); + projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 200; projectile.height = 200; diff --git a/Projectiles/Melee/CrescentMoonFlail.cs b/Projectiles/Melee/CrescentMoonFlail.cs index b47fd05e52..b4059e52e5 100644 --- a/Projectiles/Melee/CrescentMoonFlail.cs +++ b/Projectiles/Melee/CrescentMoonFlail.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Projectiles.Melee { public class CrescentMoonFlail : BaseWhipProjectile { - public int moonCounter = 6; + public int moonCounter = 6; public override void SetStaticDefaults() { @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Melee } vectorBruh -= new Vector2((float)(player.bodyFrame.Width - player.width), (float)(player.bodyFrame.Height - 42)) / 2f; Vector2 newCenter = player.RotatedRelativePoint(Main.player[projectile.owner].position + vectorBruh, true) + projectile.velocity; - int moonDamage = (int)(projectile.damage * 0.18f); + int moonDamage = (int)(projectile.damage * 0.18f); Projectile.NewProjectile(newCenter.X, newCenter.Y, 0f, 0f, ModContent.ProjectileType(), moonDamage, 0f, projectile.owner, 0f, 0f); moonCounter = 6; } diff --git a/Projectiles/Melee/CrescentMoonProj.cs b/Projectiles/Melee/CrescentMoonProj.cs index 39a122929b..c7fd2503b8 100644 --- a/Projectiles/Melee/CrescentMoonProj.cs +++ b/Projectiles/Melee/CrescentMoonProj.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class CrescentMoonProj : ModProjectile + public class CrescentMoonProj : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Magic/Crescent"; @@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Melee projectile.ignoreWater = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.extraUpdates = 1; - projectile.aiStyle = 18; - aiType = ProjectileID.DeathSickle; + projectile.extraUpdates = 1; + projectile.aiStyle = 18; + aiType = ProjectileID.DeathSickle; } public override void AI() @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Melee } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/CrystalDust.cs b/Projectiles/Melee/CrystalDust.cs index 3e39712389..940bd99361 100644 --- a/Projectiles/Melee/CrystalDust.cs +++ b/Projectiles/Melee/CrystalDust.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class CrystalDust : ModProjectile + public class CrystalDust : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Melee/CrystylCrusherRay.cs b/Projectiles/Melee/CrystylCrusherRay.cs index e0939e54c2..63074bd5cf 100644 --- a/Projectiles/Melee/CrystylCrusherRay.cs +++ b/Projectiles/Melee/CrystylCrusherRay.cs @@ -8,7 +8,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class CrystylCrusherRay : ModProjectile + public class CrystylCrusherRay : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Magic/YharimsCrystalBeam"; @@ -17,307 +17,307 @@ namespace CalamityMod.Projectiles.Melee DisplayName.SetDefault("Crystyl Crusher Ray"); } - // Use a different style for constant so it is very clear in code when a constant is used + // Use a different style for constant so it is very clear in code when a constant is used - // The maximum charge value - private const float MAX_CHARGE = 100f; - //The distance charge particle from the player center - private const float MOVE_DISTANCE = 100f; + // The maximum charge value + private const float MAX_CHARGE = 100f; + //The distance charge particle from the player center + private const float MOVE_DISTANCE = 100f; - // The actual distance is stored in the ai0 field - // By making a property to handle this it makes our life easier, and the accessibility more readable - public float Distance - { - get => projectile.ai[0]; - set => projectile.ai[0] = value; - } + // The actual distance is stored in the ai0 field + // By making a property to handle this it makes our life easier, and the accessibility more readable + public float Distance + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } - // The actual charge value is stored in the localAI0 field - public float Charge - { - get => projectile.localAI[0]; - set => projectile.localAI[0] = value; - } + // The actual charge value is stored in the localAI0 field + public float Charge + { + get => projectile.localAI[0]; + set => projectile.localAI[0] = value; + } - // Are we at max charge? With c#6 you can simply use => which indicates this is a get only property - public bool IsAtMaxCharge => Charge == MAX_CHARGE; + // Are we at max charge? With c#6 you can simply use => which indicates this is a get only property + public bool IsAtMaxCharge => Charge == MAX_CHARGE; - private bool playedSound = false; + private bool playedSound = false; - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.scale = 1.5f; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.melee = true; - projectile.hide = true; - projectile.timeLeft = 300; + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.scale = 1.5f; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.melee = true; + projectile.hide = true; + projectile.timeLeft = 300; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - // We start drawing the laser if we have charged up - if (IsAtMaxCharge) - { - Vector2 maxLength = Main.MouseWorld - Main.player[projectile.owner].Center; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + // We start drawing the laser if we have charged up + if (IsAtMaxCharge) + { + Vector2 maxLength = Main.MouseWorld - Main.player[projectile.owner].Center; - DrawLaser(spriteBatch, Main.projectileTexture[projectile.type], Main.player[projectile.owner].Center, - projectile.velocity, 15f, projectile.damage, -1.57f, projectile.scale, maxLength.Length(), new Color(Main.DiscoR, 0, 255), (int)MOVE_DISTANCE); - } - return false; - } + DrawLaser(spriteBatch, Main.projectileTexture[projectile.type], Main.player[projectile.owner].Center, + projectile.velocity, 15f, projectile.damage, -1.57f, projectile.scale, maxLength.Length(), new Color(Main.DiscoR, 0, 255), (int)MOVE_DISTANCE); + } + return false; + } - // The core function of drawing a laser - public void DrawLaser(SpriteBatch spriteBatch, Texture2D texture, Vector2 start, Vector2 unit, float step, int damage, float rotation = 0f, float scale = 1f, float maxDist = 2000f, Color color = default(Color), int transDist = 50) - { - float r = unit.ToRotation() + rotation; + // The core function of drawing a laser + public void DrawLaser(SpriteBatch spriteBatch, Texture2D texture, Vector2 start, Vector2 unit, float step, int damage, float rotation = 0f, float scale = 1f, float maxDist = 2000f, Color color = default(Color), int transDist = 50) + { + float r = unit.ToRotation() + rotation; - // Draws the laser 'body' - for (float i = transDist; i <= Distance; i += step) - { - Color c = new Color(Main.DiscoR, 0, 255); - var origin = start + i * unit; - spriteBatch.Draw(texture, origin - Main.screenPosition, - new Rectangle(0, 26, 28, 26), i < transDist ? Color.Transparent : c, r, - new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); - } + // Draws the laser 'body' + for (float i = transDist; i <= Distance; i += step) + { + Color c = new Color(Main.DiscoR, 0, 255); + var origin = start + i * unit; + spriteBatch.Draw(texture, origin - Main.screenPosition, + new Rectangle(0, 26, 28, 26), i < transDist ? Color.Transparent : c, r, + new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); + } - // Draws the laser 'tail' - spriteBatch.Draw(texture, start + unit * (transDist - step) - Main.screenPosition, - new Rectangle(0, 0, 28, 26), new Color(Main.DiscoR, 0, 255), r, new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); + // Draws the laser 'tail' + spriteBatch.Draw(texture, start + unit * (transDist - step) - Main.screenPosition, + new Rectangle(0, 0, 28, 26), new Color(Main.DiscoR, 0, 255), r, new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); - // Draws the laser 'head' - spriteBatch.Draw(texture, start + (Distance + step) * unit - Main.screenPosition, - new Rectangle(0, 52, 28, 26), new Color(Main.DiscoR, 0, 255), r, new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); - } + // Draws the laser 'head' + spriteBatch.Draw(texture, start + (Distance + step) * unit - Main.screenPosition, + new Rectangle(0, 52, 28, 26), new Color(Main.DiscoR, 0, 255), r, new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); + } - // Change the way of collision check of the projectile - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - // We can only collide if we are at max charge, which is when the laser is actually fired - if (!IsAtMaxCharge) return false; + // Change the way of collision check of the projectile + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + // We can only collide if we are at max charge, which is when the laser is actually fired + if (!IsAtMaxCharge) return false; - Player player = Main.player[projectile.owner]; - Vector2 unit = projectile.velocity; - float point = 0f; - // Run an AABB versus Line check to look for collisions, look up AABB collision first to see how it works - // It will look for collisions on the given line using AABB - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), player.Center, - player.Center + unit * Distance, 22, ref point); - } + Player player = Main.player[projectile.owner]; + Vector2 unit = projectile.velocity; + float point = 0f; + // Run an AABB versus Line check to look for collisions, look up AABB collision first to see how it works + // It will look for collisions on the given line using AABB + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), player.Center, + player.Center + unit * Distance, 22, ref point); + } - // The AI of the projectile - public override void AI() - { - Player player = Main.player[projectile.owner]; + // The AI of the projectile + public override void AI() + { + Player player = Main.player[projectile.owner]; - if (projectile.timeLeft == 300) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/CrystylCharge"), player.Center); + if (projectile.timeLeft == 300) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/CrystylCharge"), player.Center); - projectile.position = player.Center + projectile.velocity * MOVE_DISTANCE; - projectile.timeLeft = 2; + projectile.position = player.Center + projectile.velocity * MOVE_DISTANCE; + projectile.timeLeft = 2; - // By separating large AI into methods it becomes very easy to see the flow of the AI in a broader sense - // First we update player variables that are needed to channel the laser - // Then we run our charging laser logic - // If we are fully charged, we proceed to update the laser's position + // By separating large AI into methods it becomes very easy to see the flow of the AI in a broader sense + // First we update player variables that are needed to channel the laser + // Then we run our charging laser logic + // If we are fully charged, we proceed to update the laser's position - UpdatePlayer(player); - ChargeLaser(player); + UpdatePlayer(player); + ChargeLaser(player); - // If laser is not charged yet, stop the AI here. - if (Charge < MAX_CHARGE) return; + // If laser is not charged yet, stop the AI here. + if (Charge < MAX_CHARGE) return; - //Play cool sound when fully charged - if (playedSound == false) - { - Main.PlaySound(SoundID.Item68, projectile.Center); - playedSound = true; - } + //Play cool sound when fully charged + if (playedSound == false) + { + Main.PlaySound(SoundID.Item68, projectile.Center); + playedSound = true; + } - SetLaserPosition(player); - CastLights(); - DestroyTiles(); - } + SetLaserPosition(player); + CastLights(); + DestroyTiles(); + } - /* - * Sets the end of the laser position based on where it collides with something - */ - private void SetLaserPosition(Player player) - { - Distance = MathHelper.Max(Main.player[projectile.owner].Distance(Main.MouseWorld) - 20f, MOVE_DISTANCE + 5f); - } + /* + * Sets the end of the laser position based on where it collides with something + */ + private void SetLaserPosition(Player player) + { + Distance = MathHelper.Max(Main.player[projectile.owner].Distance(Main.MouseWorld) - 20f, MOVE_DISTANCE + 5f); + } - private void ChargeLaser(Player player) - { - // Kill the projectile if the player stops channeling - if (!player.channel) - { - projectile.Kill(); - } - else - { - Vector2 offset = projectile.velocity; - offset *= MOVE_DISTANCE - 20; - Vector2 pos = player.Center + offset - new Vector2(15f, 15f); - if (Charge < MAX_CHARGE) - { - Charge++; - } - int chargeFact = (int)(Charge / 20f); - Vector2 dustVelocity = Vector2.UnitX * 18f; - dustVelocity = dustVelocity.RotatedBy(projectile.rotation - 1.57f); - Vector2 spawnPos = projectile.Center + dustVelocity; - for (int k = 0; k < chargeFact + 1; k++) - { - int dustType = Main.rand.Next(3); - switch (dustType) - { - case 0: - dustType = 173; - break; - case 1: - dustType = 57; - break; - case 2: - dustType = 58; - break; - default: - break; - } - Vector2 spawn = spawnPos + ((float)Main.rand.NextDouble() * 6.28f).ToRotationVector2() * (12f - chargeFact * 2); - Dust dust = Main.dust[Dust.NewDust(pos, 20, 20, dustType, projectile.velocity.X / 2f, projectile.velocity.Y / 2f)]; - dust.velocity = Vector2.Normalize(spawnPos - spawn) * 1.5f * (10f - chargeFact * 2f) / 10f; - dust.noGravity = true; - dust.color = new Color(Main.DiscoR, 0, 255); - dust.scale = Main.rand.Next(10, 20) * 0.05f; - } - } - } + private void ChargeLaser(Player player) + { + // Kill the projectile if the player stops channeling + if (!player.channel) + { + projectile.Kill(); + } + else + { + Vector2 offset = projectile.velocity; + offset *= MOVE_DISTANCE - 20; + Vector2 pos = player.Center + offset - new Vector2(15f, 15f); + if (Charge < MAX_CHARGE) + { + Charge++; + } + int chargeFact = (int)(Charge / 20f); + Vector2 dustVelocity = Vector2.UnitX * 18f; + dustVelocity = dustVelocity.RotatedBy(projectile.rotation - 1.57f); + Vector2 spawnPos = projectile.Center + dustVelocity; + for (int k = 0; k < chargeFact + 1; k++) + { + int dustType = Main.rand.Next(3); + switch (dustType) + { + case 0: + dustType = 173; + break; + case 1: + dustType = 57; + break; + case 2: + dustType = 58; + break; + default: + break; + } + Vector2 spawn = spawnPos + ((float)Main.rand.NextDouble() * 6.28f).ToRotationVector2() * (12f - chargeFact * 2); + Dust dust = Main.dust[Dust.NewDust(pos, 20, 20, dustType, projectile.velocity.X / 2f, projectile.velocity.Y / 2f)]; + dust.velocity = Vector2.Normalize(spawnPos - spawn) * 1.5f * (10f - chargeFact * 2f) / 10f; + dust.noGravity = true; + dust.color = new Color(Main.DiscoR, 0, 255); + dust.scale = Main.rand.Next(10, 20) * 0.05f; + } + } + } - private void UpdatePlayer(Player player) - { - // Multiplayer support here, only run this code if the client running it is the owner of the projectile - if (projectile.owner == Main.myPlayer) - { - Vector2 diff = Main.MouseWorld - player.Center; - diff.Normalize(); - projectile.velocity = diff; - projectile.direction = Main.MouseWorld.X > player.position.X ? 1 : -1; - projectile.netUpdate = true; - } - int dir = projectile.direction; - player.ChangeDir(dir); // Set player direction to where we are shooting - player.heldProj = projectile.whoAmI; // Update player's held projectile - player.itemTime = 2; // Set item time to 2 frames while we are used - player.itemAnimation = 2; // Set item animation time to 2 frames while we are used - player.itemRotation = (float)Math.Atan2(projectile.velocity.Y * dir, projectile.velocity.X * dir); // Set the item rotation to where we are shooting - } + private void UpdatePlayer(Player player) + { + // Multiplayer support here, only run this code if the client running it is the owner of the projectile + if (projectile.owner == Main.myPlayer) + { + Vector2 diff = Main.MouseWorld - player.Center; + diff.Normalize(); + projectile.velocity = diff; + projectile.direction = Main.MouseWorld.X > player.position.X ? 1 : -1; + projectile.netUpdate = true; + } + int dir = projectile.direction; + player.ChangeDir(dir); // Set player direction to where we are shooting + player.heldProj = projectile.whoAmI; // Update player's held projectile + player.itemTime = 2; // Set item time to 2 frames while we are used + player.itemAnimation = 2; // Set item animation time to 2 frames while we are used + player.itemRotation = (float)Math.Atan2(projectile.velocity.Y * dir, projectile.velocity.X * dir); // Set the item rotation to where we are shooting + } - private void CastLights() - { - // Cast a light along the line of the laser - DelegateMethods.v3_1 = new Vector3(0.8f, 0.8f, 1f); - Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * (Distance - MOVE_DISTANCE), 26, DelegateMethods.CastLight); - } + private void CastLights() + { + // Cast a light along the line of the laser + DelegateMethods.v3_1 = new Vector3(0.8f, 0.8f, 1f); + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * (Distance - MOVE_DISTANCE), 26, DelegateMethods.CastLight); + } - public override bool ShouldUpdatePosition() => false; + public override bool ShouldUpdatePosition() => false; - /* - * Update CutTiles so the laser will cut tiles (like grass) - */ - public override void CutTiles() - { - DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; - Vector2 unit = projectile.velocity; - Utils.PlotTileLine(projectile.Center, projectile.Center + unit * Distance, projectile.width + 16, DelegateMethods.CutTiles); - } + /* + * Update CutTiles so the laser will cut tiles (like grass) + */ + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 unit = projectile.velocity; + Utils.PlotTileLine(projectile.Center, projectile.Center + unit * Distance, projectile.width + 16, DelegateMethods.CutTiles); + } - private void DestroyTiles() - { - if (projectile.owner == Main.myPlayer) - { - Vector2 destroyVector = projectile.Center + projectile.velocity * (Distance - MOVE_DISTANCE); - int num814 = 3; - int num815 = (int)(destroyVector.X / 16f - num814); - int num816 = (int)(destroyVector.X / 16f + num814); - int num817 = (int)(destroyVector.Y / 16f - num814); - int num818 = (int)(destroyVector.Y / 16f + num814); - if (num815 < 0) - { - num815 = 0; - } - if (num816 > Main.maxTilesX) - { - num816 = Main.maxTilesX; - } - if (num817 < 0) - { - num817 = 0; - } - if (num818 > Main.maxTilesY) - { - num818 = Main.maxTilesY; - } - AchievementsHelper.CurrentlyMining = true; - for (int num824 = num815; num824 <= num816; num824++) - { - for (int num825 = num817; num825 <= num818; num825++) - { - float num826 = Math.Abs(num824 - destroyVector.X / 16f); - float num827 = Math.Abs(num825 - destroyVector.Y / 16f); - double num828 = Math.Sqrt(num826 * num826 + num827 * num827); - if (num828 < num814) - { - if (Main.tile[num824, num825] != null && Main.tile[num824, num825].active()) - { - WorldGen.KillTile(num824, num825, false, false, false); - DustExplosion(destroyVector); - if (!Main.tile[num824, num825].active() && Main.netMode != NetmodeID.SinglePlayer) - { - NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, num824, num825, 0f, 0, 0, 0); - } - } - } - } - } - AchievementsHelper.CurrentlyMining = false; - } - } + private void DestroyTiles() + { + if (projectile.owner == Main.myPlayer) + { + Vector2 destroyVector = projectile.Center + projectile.velocity * (Distance - MOVE_DISTANCE); + int num814 = 3; + int num815 = (int)(destroyVector.X / 16f - num814); + int num816 = (int)(destroyVector.X / 16f + num814); + int num817 = (int)(destroyVector.Y / 16f - num814); + int num818 = (int)(destroyVector.Y / 16f + num814); + if (num815 < 0) + { + num815 = 0; + } + if (num816 > Main.maxTilesX) + { + num816 = Main.maxTilesX; + } + if (num817 < 0) + { + num817 = 0; + } + if (num818 > Main.maxTilesY) + { + num818 = Main.maxTilesY; + } + AchievementsHelper.CurrentlyMining = true; + for (int num824 = num815; num824 <= num816; num824++) + { + for (int num825 = num817; num825 <= num818; num825++) + { + float num826 = Math.Abs(num824 - destroyVector.X / 16f); + float num827 = Math.Abs(num825 - destroyVector.Y / 16f); + double num828 = Math.Sqrt(num826 * num826 + num827 * num827); + if (num828 < num814) + { + if (Main.tile[num824, num825] != null && Main.tile[num824, num825].active()) + { + WorldGen.KillTile(num824, num825, false, false, false); + DustExplosion(destroyVector); + if (!Main.tile[num824, num825].active() && Main.netMode != NetmodeID.SinglePlayer) + { + NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, num824, num825, 0f, 0, 0, 0); + } + } + } + } + } + AchievementsHelper.CurrentlyMining = false; + } + } - private void DustExplosion(Vector2 vector) - { - int num226 = 12; - for (int num227 = 0; num227 < num226; num227++) - { - int dustType = Main.rand.Next(3); - switch (dustType) - { - case 0: - dustType = 173; - break; - case 1: - dustType = 57; - break; - case 2: - dustType = 58; - break; - default: - break; - } - Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2(projectile.width / 2f, projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((num227 - (num226 / 2 - 1)) * MathHelper.TwoPi / num226, default) + vector; - Vector2 vector7 = vector6 - vector; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, dustType, vector7.X * 0.5f, vector7.Y * 0.5f, 100, new Color(Main.DiscoR, 0, 255), 1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; - } - } - } + private void DustExplosion(Vector2 vector) + { + int num226 = 12; + for (int num227 = 0; num227 < num226; num227++) + { + int dustType = Main.rand.Next(3); + switch (dustType) + { + case 0: + dustType = 173; + break; + case 1: + dustType = 57; + break; + case 2: + dustType = 58; + break; + default: + break; + } + Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2(projectile.width / 2f, projectile.height) * 0.75f; + vector6 = vector6.RotatedBy((num227 - (num226 / 2 - 1)) * MathHelper.TwoPi / num226, default) + vector; + Vector2 vector7 = vector6 - vector; + int num228 = Dust.NewDust(vector6 + vector7, 0, 0, dustType, vector7.X * 0.5f, vector7.Y * 0.5f, 100, new Color(Main.DiscoR, 0, 255), 1f); + Main.dust[num228].noGravity = true; + Main.dust[num228].noLight = true; + Main.dust[num228].velocity = vector7; + } + } + } } diff --git a/Projectiles/Melee/Dark.cs b/Projectiles/Melee/Dark.cs index 2474350bf5..aac54e1f8b 100644 --- a/Projectiles/Melee/Dark.cs +++ b/Projectiles/Melee/Dark.cs @@ -6,7 +6,7 @@ namespace CalamityMod.Projectiles.Melee { public class Dark : ModProjectile { - private const int speedTimerMax = 60; + private const int speedTimerMax = 60; private int speedTimer = speedTimerMax; public override void SetStaticDefaults() @@ -32,11 +32,11 @@ namespace CalamityMod.Projectiles.Melee { projectile.rotation += 0.5f; speedTimer--; - if (speedTimer <= 0) - { - speedTimer = speedTimerMax; - projectile.velocity *= -1f; - } + if (speedTimer <= 0) + { + speedTimer = speedTimerMax; + projectile.velocity *= -1f; + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/DarkBeam.cs b/Projectiles/Melee/DarkBeam.cs index c099d2c1b7..5f03704fe9 100644 --- a/Projectiles/Melee/DarkBeam.cs +++ b/Projectiles/Melee/DarkBeam.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class DarkBeam : ModProjectile + public class DarkBeam : ModProjectile { public override void SetStaticDefaults() { @@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Melee { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.2f / 255f, 0f, (255 - projectile.alpha) * 0.6f / 255f); - if (projectile.velocity.Length() < 12f) - projectile.velocity *= 1.1f; - } + if (projectile.velocity.Length() < 12f) + projectile.velocity *= 1.1f; + } public override Color? GetAlpha(Color lightColor) { @@ -54,25 +54,25 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(BuffID.Frostburn, 180); - } + target.AddBuff(BuffID.Frostburn, 180); + } - public override void Kill(int timeLeft) - { - for (int num105 = 0; num105 < 20; num105++) - { - int num102 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 56, 0f, 0f, 0, default, 1f); - Main.dust[num102].noGravity = true; - Main.dust[num102].velocity += projectile.velocity * 0.1f; - } - if (projectile.owner == Main.myPlayer) - { - for (int k = 0; k < 3; k++) - { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, Main.rand.Next(-35, 36) * 0.2f, Main.rand.Next(-35, 36) * 0.2f, ModContent.ProjectileType(), - (int)(projectile.damage * 0.5), projectile.knockBack * 0.15f, Main.myPlayer); - } - } - } - } + public override void Kill(int timeLeft) + { + for (int num105 = 0; num105 < 20; num105++) + { + int num102 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 56, 0f, 0f, 0, default, 1f); + Main.dust[num102].noGravity = true; + Main.dust[num102].velocity += projectile.velocity * 0.1f; + } + if (projectile.owner == Main.myPlayer) + { + for (int k = 0; k < 3; k++) + { + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, Main.rand.Next(-35, 36) * 0.2f, Main.rand.Next(-35, 36) * 0.2f, ModContent.ProjectileType(), + (int)(projectile.damage * 0.5), projectile.knockBack * 0.15f, Main.myPlayer); + } + } + } + } } diff --git a/Projectiles/Melee/DarkIceZero.cs b/Projectiles/Melee/DarkIceZero.cs index ae549440bb..0b5c179800 100644 --- a/Projectiles/Melee/DarkIceZero.cs +++ b/Projectiles/Melee/DarkIceZero.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Projectiles.Melee projectile.height = 28; projectile.aiStyle = 1; aiType = ProjectileID.Bullet; - projectile.timeLeft = 600; + projectile.timeLeft = 600; projectile.friendly = true; projectile.melee = true; projectile.penetrate = 1; @@ -30,15 +30,15 @@ namespace CalamityMod.Projectiles.Melee DisplayName.SetDefault("Dark Ice"); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.timeLeft > 595) - return false; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.timeLeft > 595) + return false; - return true; - } + return true; + } - public override void AI() + public override void AI() { if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < 16f) { diff --git a/Projectiles/Melee/DemonBlast.cs b/Projectiles/Melee/DemonBlast.cs index e4d663f813..ffc2feb58d 100644 --- a/Projectiles/Melee/DemonBlast.cs +++ b/Projectiles/Melee/DemonBlast.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class DemonBlast : ModProjectile + public class DemonBlast : ModProjectile { public override void SetStaticDefaults() { @@ -26,18 +26,18 @@ namespace CalamityMod.Projectiles.Melee projectile.extraUpdates = 5; projectile.tileCollide = false; projectile.melee = true; - projectile.alpha = 180; - projectile.timeLeft = 300; + projectile.alpha = 180; + projectile.timeLeft = 300; } public override void AI() { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 173, - (int)CalamityDusts.Brimstone, - 172 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 173, + (int)CalamityDusts.Brimstone, + 172 + }); if (projectile.position.HasNaNs()) { @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Melee if (tileCheck) dust.noLight = true; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.ToRadians(45); + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.ToRadians(45); } public override void Kill(int timeLeft) @@ -63,22 +63,22 @@ namespace CalamityMod.Projectiles.Melee bool tileCheck = WorldGen.SolidTile(Framing.GetTileSafely((int)projectile.position.X / 16, (int)projectile.position.Y / 16)); for (int m = 0; m < 4; m++) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 173, - (int)CalamityDusts.Brimstone, - 172 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 173, + (int)CalamityDusts.Brimstone, + 172 + }); Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 1.5f); } for (int n = 0; n < 4; n++) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 173, - (int)CalamityDusts.Brimstone, - 172 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 173, + (int)CalamityDusts.Brimstone, + 172 + }); int dustInt = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 2.5f); Main.dust[dustInt].noGravity = true; Main.dust[dustInt].velocity *= 3f; @@ -96,12 +96,12 @@ namespace CalamityMod.Projectiles.Melee } } - //glowmask effect + //glowmask effect public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } diff --git a/Projectiles/Melee/DepthOrb.cs b/Projectiles/Melee/DepthOrb.cs index e56139ef14..d4acd30bd7 100644 --- a/Projectiles/Melee/DepthOrb.cs +++ b/Projectiles/Melee/DepthOrb.cs @@ -37,10 +37,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 25) - return false; + if (projectile.timeLeft > 25) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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; } @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Melee Main.PlaySound(SoundID.Item10, projectile.position); projectile.position = projectile.Center; projectile.width = projectile.height = 64; - projectile.Center = projectile.position; + projectile.Center = projectile.position; for (int dustIndex = 0; dustIndex < 30; dustIndex++) { float num463 = (float)Main.rand.Next(-10, 11); @@ -79,13 +79,13 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage /= 2; + projectile.damage /= 2; projectile.Damage(); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/Melee/DepthOrb2.cs b/Projectiles/Melee/DepthOrb2.cs index f3dae10a25..23e7ecca49 100644 --- a/Projectiles/Melee/DepthOrb2.cs +++ b/Projectiles/Melee/DepthOrb2.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/DivineHatchetBoomerang.cs b/Projectiles/Melee/DivineHatchetBoomerang.cs index 7cd3e8abcb..b1ddde6ae5 100644 --- a/Projectiles/Melee/DivineHatchetBoomerang.cs +++ b/Projectiles/Melee/DivineHatchetBoomerang.cs @@ -35,14 +35,14 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = 4; projectile.timeLeft = Lifetime; projectile.melee = true; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } public override void AI() { - //holy dust + //holy dust if (Main.rand.NextBool(8)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 244, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); @@ -112,37 +112,37 @@ namespace CalamityMod.Projectiles.Melee if (projectile.Hitbox.Intersects(owner.Hitbox)) projectile.Kill(); - //home in on nearby NPCs if not returning to player - if (projectile.penetrate != -1) - { - if (!hasHitEnemy) - { - float range = 999f; - for (int a = 0; a < Main.npc.Length; a++) - { - if (Main.npc[a].CanBeChasedBy(projectile, false)) - { - if (Vector2.Distance(Main.npc[a].Center, projectile.Center) < range) - { - Vector2 newVelocity = Main.npc[a].Center - projectile.Center; - newVelocity.Normalize(); - newVelocity *= 15f; - projectile.velocity = newVelocity; - } - } - } - } - else - { - if (targetNPC >= 0) - { - Vector2 newVelocity = Main.npc[targetNPC].Center - projectile.Center; - newVelocity.Normalize(); - newVelocity *= 15f; - projectile.velocity = newVelocity; - } - } - } + //home in on nearby NPCs if not returning to player + if (projectile.penetrate != -1) + { + if (!hasHitEnemy) + { + float range = 999f; + for (int a = 0; a < Main.npc.Length; a++) + { + if (Main.npc[a].CanBeChasedBy(projectile, false)) + { + if (Vector2.Distance(Main.npc[a].Center, projectile.Center) < range) + { + Vector2 newVelocity = Main.npc[a].Center - projectile.Center; + newVelocity.Normalize(); + newVelocity *= 15f; + projectile.velocity = newVelocity; + } + } + } + } + else + { + if (targetNPC >= 0) + { + Vector2 newVelocity = Main.npc[targetNPC].Center - projectile.Center; + newVelocity.Normalize(); + newVelocity *= 15f; + projectile.velocity = newVelocity; + } + } + } } } @@ -152,70 +152,70 @@ namespace CalamityMod.Projectiles.Melee return false; } - //glowmask effect + //glowmask effect public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - //inflict Holy Flames for 6 seconds - target.AddBuff(ModContent.BuffType(), 180); + //inflict Holy Flames for 6 seconds + target.AddBuff(ModContent.BuffType(), 180); - if (projectile.penetrate != -1) - { - //find a nearby NPC to track - float minDist = 999f; - int index = 0; - for (int i = 0; i < Main.npc.Length; i++) - { - bool hasHitNPC = false; - for (int j = 0; j < previousNPCs.Count; j++) - { - if (previousNPCs[j] == i) - { - hasHitNPC = true; - } - } + if (projectile.penetrate != -1) + { + //find a nearby NPC to track + float minDist = 999f; + int index = 0; + for (int i = 0; i < Main.npc.Length; i++) + { + bool hasHitNPC = false; + for (int j = 0; j < previousNPCs.Count; j++) + { + if (previousNPCs[j] == i) + { + hasHitNPC = true; + } + } - NPC npc = Main.npc[i]; - if (npc == target) - { - previousNPCs.Add(i); - } - if (npc.CanBeChasedBy(projectile, false) && npc != target && !hasHitNPC) - { - float dist = (projectile.Center - npc.Center).Length(); - if (dist < minDist) - { - minDist = dist; - index = i; - } - } - } + NPC npc = Main.npc[i]; + if (npc == target) + { + previousNPCs.Add(i); + } + if (npc.CanBeChasedBy(projectile, false) && npc != target && !hasHitNPC) + { + float dist = (projectile.Center - npc.Center).Length(); + if (dist < minDist) + { + minDist = dist; + index = i; + } + } + } - Vector2 velocityNew; - if (minDist < 999f) - { - hasHitEnemy = true; - targetNPC = index; - velocityNew = Main.npc[index].Center - projectile.Center; - velocityNew.Normalize(); - velocityNew *= 15f; - projectile.velocity = velocityNew; - } - else - { - projectile.penetrate = -1; - projectile.ai[0] = 1f; - targetNPC = -1; - } - } + Vector2 velocityNew; + if (minDist < 999f) + { + hasHitEnemy = true; + targetNPC = index; + velocityNew = Main.npc[index].Center - projectile.Center; + velocityNew.Normalize(); + velocityNew *= 15f; + projectile.velocity = velocityNew; + } + else + { + projectile.penetrate = -1; + projectile.ai[0] = 1f; + targetNPC = -1; + } + } // After its last hit, starts returning instead of vanishing. Can pierce infinitely on the way back. if (projectile.penetrate == 1) { projectile.penetrate = -1; projectile.ai[0] = 1f; - targetNPC = -1; + targetNPC = -1; } } } diff --git a/Projectiles/Melee/DracoBeam.cs b/Projectiles/Melee/DracoBeam.cs index b52bcca4b1..04182a813a 100644 --- a/Projectiles/Melee/DracoBeam.cs +++ b/Projectiles/Melee/DracoBeam.cs @@ -38,10 +38,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 595) - return false; + if (projectile.timeLeft > 595) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); return false; } diff --git a/Projectiles/Melee/DracoBeam2.cs b/Projectiles/Melee/DracoBeam2.cs index 216937f1f1..8752e076c1 100644 --- a/Projectiles/Melee/DracoBeam2.cs +++ b/Projectiles/Melee/DracoBeam2.cs @@ -61,10 +61,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 235) - return false; + if (projectile.timeLeft > 235) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); return false; } diff --git a/Projectiles/Melee/DragonPowFlail.cs b/Projectiles/Melee/DragonPowFlail.cs index 8e20c735fc..1d1f88dac5 100644 --- a/Projectiles/Melee/DragonPowFlail.cs +++ b/Projectiles/Melee/DragonPowFlail.cs @@ -182,18 +182,18 @@ namespace CalamityMod.Projectiles.Melee float petalKB = 0f; for (int i = 0; i < numPetals; ++i) { - if (projectile.owner == Main.myPlayer) - { - float angle = Main.rand.NextFloat(MathHelper.TwoPi); - Projectile petal = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(DragonPow.MinPetalSpeed, DragonPow.MaxPetalSpeed), type, petalDamage, petalKB, projectile.owner); - if (petal.whoAmI.WithinBounds(Main.maxProjectiles)) - { - petal.Calamity().forceMelee = true; - petal.rotation = angle; - petal.usesLocalNPCImmunity = true; - petal.localNPCHitCooldown = -1; - } - } + if (projectile.owner == Main.myPlayer) + { + float angle = Main.rand.NextFloat(MathHelper.TwoPi); + Projectile petal = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(DragonPow.MinPetalSpeed, DragonPow.MaxPetalSpeed), type, petalDamage, petalKB, projectile.owner); + if (petal.whoAmI.WithinBounds(Main.maxProjectiles)) + { + petal.Calamity().forceMelee = true; + petal.rotation = angle; + petal.usesLocalNPCImmunity = true; + petal.localNPCHitCooldown = -1; + } + } } } diff --git a/Projectiles/Melee/DragonRageFireball.cs b/Projectiles/Melee/DragonRageFireball.cs index 81f88090be..3f76ccf1af 100644 --- a/Projectiles/Melee/DragonRageFireball.cs +++ b/Projectiles/Melee/DragonRageFireball.cs @@ -6,11 +6,11 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class DragonRageFireball : ModProjectile + public class DragonRageFireball : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Rogue/DragonShit"; public NPC target; - private int lifeTime = 420; + private int lifeTime = 420; public override void SetStaticDefaults() { DisplayName.SetDefault("Fire"); @@ -31,11 +31,11 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - if (projectile.ai[0] == 0f) - { - projectile.ai[0] = Main.rand.NextFloat(40f, 70f); - projectile.ai[1] = Main.rand.NextFloat(35f, 55f); - } + if (projectile.ai[0] == 0f) + { + projectile.ai[0] = Main.rand.NextFloat(40f, 70f); + projectile.ai[1] = Main.rand.NextFloat(35f, 55f); + } target = projectile.Center.ClosestNPCAt(1200f); projectile.frameCounter++; if (projectile.frameCounter > 4) @@ -48,15 +48,15 @@ namespace CalamityMod.Projectiles.Melee projectile.frame = 0; } - projectile.velocity *= 1.01f; + projectile.velocity *= 1.01f; - if (target != null && projectile.timeLeft < lifeTime - 10) - { - float inertia = projectile.ai[0]; - float speed = projectile.ai[1]; - Vector2 moveDirection = projectile.SafeDirectionTo(target.Center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * speed) / inertia; - } + if (target != null && projectile.timeLeft < lifeTime - 10) + { + float inertia = projectile.ai[0]; + float speed = projectile.ai[1]; + Vector2 moveDirection = projectile.SafeDirectionTo(target.Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (inertia - 1f) + moveDirection * speed) / inertia; + } } public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Melee public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.Center); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 80); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 80); for (int d = 0; d < 5; d++) { int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); @@ -92,7 +92,7 @@ namespace CalamityMod.Projectiles.Melee idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[idx].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.Damage(); diff --git a/Projectiles/Melee/DragonRageStaff.cs b/Projectiles/Melee/DragonRageStaff.cs index c7f19ab221..e62a3ff471 100644 --- a/Projectiles/Melee/DragonRageStaff.cs +++ b/Projectiles/Melee/DragonRageStaff.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Melee projectile.hide = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 5; - projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override void AI() @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Melee Player player = Main.player[projectile.owner]; float spinCycleTime = 50f; - // If the player is dead, destroy the projectile + // If the player is dead, destroy the projectile if (player.dead || !player.channel) { projectile.Kill(); @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Melee int direction = Math.Sign(projectile.velocity.X); projectile.velocity = new Vector2(direction, 0f); - // Initial Rotation + // Initial Rotation if (projectile.ai[0] == 0f) { projectile.rotation = new Vector2(direction, -player.gravDir).ToRotation() + MathHelper.ToRadians(135f); @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Melee projectile.rotation -= MathHelper.PiOver2; } } - + projectile.ai[0] += 1f; projectile.rotation += MathHelper.TwoPi * 2f / spinCycleTime * (float)direction; int expectedDirection = (player.SafeDirectionTo(Main.MouseWorld).X > 0f).ToDirectionInt(); @@ -70,12 +70,12 @@ namespace CalamityMod.Projectiles.Melee projectile.netUpdate = true; } SpawnDust(player, direction); - PositionAndRotation(player); - VisibilityAndLight(); + PositionAndRotation(player); + VisibilityAndLight(); } - private void SpawnDust(Player player, int direction) - { + private void SpawnDust(Player player, int direction) + { float num12 = projectile.rotation - MathHelper.PiOver4 * direction; Vector2 value3 = projectile.Center + (num12 + ((direction == -1) ? MathHelper.Pi : 0f)).ToRotationVector2() * 30f; Vector2 vector2 = num12.ToRotationVector2(); @@ -118,10 +118,10 @@ namespace CalamityMod.Projectiles.Melee } } } - } + } - private void PositionAndRotation(Player player) - { + private void PositionAndRotation(Player player) + { Vector2 plrCtr = player.RotatedRelativePoint(player.MountedCenter, true); Vector2 offset = Vector2.Zero; projectile.Center = plrCtr + offset; @@ -131,79 +131,79 @@ namespace CalamityMod.Projectiles.Melee player.heldProj = projectile.whoAmI; player.itemTime = player.itemAnimation = 2; player.itemRotation = MathHelper.WrapAngle(projectile.rotation); - } + } - private void VisibilityAndLight() - { + private void VisibilityAndLight() + { Lighting.AddLight(projectile.Center, 1.45f, 1.22f, 0.58f); projectile.alpha -= 128; if (projectile.alpha < 0) { projectile.alpha = 0; } - } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Daybreak, 180); - OnHitEffects(target.Center); + OnHitEffects(target.Center); } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(target.Center); + OnHitEffects(target.Center); } - private void OnHitEffects(Vector2 position) - { - if (projectile.owner == Main.myPlayer) - { - CalamityPlayer modPlayer = Main.player[projectile.owner].Calamity(); - modPlayer.dragonRageHits++; - if (modPlayer.dragonRageHits > 10) - { - SpawnFireballs(); - modPlayer.dragonRageHits = 0; - } + private void OnHitEffects(Vector2 position) + { + if (projectile.owner == Main.myPlayer) + { + CalamityPlayer modPlayer = Main.player[projectile.owner].Calamity(); + modPlayer.dragonRageHits++; + if (modPlayer.dragonRageHits > 10) + { + SpawnFireballs(); + modPlayer.dragonRageHits = 0; + } - int proj = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 4, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[proj].Calamity().forceMelee = true; - } - } + int proj = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 4, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + Main.projectile[proj].Calamity().forceMelee = true; + } + } - private void SpawnFireballs() - { - // 10 to 15 fireballs - int fireballAmt = Main.rand.Next(10, 16); - for (int i = 0; i < fireballAmt; i++) - { - float angleStep = MathHelper.TwoPi / fireballAmt; - float speed = 20f; - Vector2 velocity = new Vector2(0f, speed); - velocity = velocity.RotatedBy(angleStep * i * Main.rand.NextFloat(0.9f, 1.1f)); + private void SpawnFireballs() + { + // 10 to 15 fireballs + int fireballAmt = Main.rand.Next(10, 16); + for (int i = 0; i < fireballAmt; i++) + { + float angleStep = MathHelper.TwoPi / fireballAmt; + float speed = 20f; + Vector2 velocity = new Vector2(0f, speed); + velocity = velocity.RotatedBy(angleStep * i * Main.rand.NextFloat(0.9f, 1.1f)); - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 8, projectile.knockBack / 3f, projectile.owner); - } - } + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 8, projectile.knockBack / 3f, projectile.owner); + } + } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; Rectangle myRect = projectile.Hitbox; if (projectile.owner == Main.myPlayer) { for (int i = 0; i < Main.maxNPCs; i++) { - NPC npc = Main.npc[i]; - bool voodooDolls = projectile.owner < Main.maxPlayers && (npc.type == NPCID.Guide && player.killGuide || npc.type == NPCID.Clothier && player.killClothier); - bool friendlyProjs = projectile.friendly && (!npc.friendly || voodooDolls); - bool hostileProjs = projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles; + NPC npc = Main.npc[i]; + bool voodooDolls = projectile.owner < Main.maxPlayers && (npc.type == NPCID.Guide && player.killGuide || npc.type == NPCID.Clothier && player.killClothier); + bool friendlyProjs = projectile.friendly && (!npc.friendly || voodooDolls); + bool hostileProjs = projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles; if (npc.active && !npc.dontTakeDamage && (friendlyProjs || hostileProjs) && (projectile.owner < 0 || npc.immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) { if (npc.noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(npc)) { bool canHit; - Rectangle rect = npc.Hitbox; + Rectangle rect = npc.Hitbox; if (npc.type == NPCID.SolarCrawltipedeTail) { int offset = 8; @@ -251,18 +251,18 @@ namespace CalamityMod.Projectiles.Melee return false; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D tex = Main.projectileTexture[projectile.type]; - Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - Rectangle rectangle = new Rectangle(0, 0, tex.Width, tex.Height); - Vector2 origin = tex.Size() / 2f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = Main.projectileTexture[projectile.type]; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Rectangle rectangle = new Rectangle(0, 0, tex.Width, tex.Height); + Vector2 origin = tex.Size() / 2f; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(tex, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - return false; - } + spriteBatch.Draw(tex, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + return false; + } } } diff --git a/Projectiles/Melee/Earth2.cs b/Projectiles/Melee/Earth2.cs index 07683955e6..6f40ed47f2 100644 --- a/Projectiles/Melee/Earth2.cs +++ b/Projectiles/Melee/Earth2.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class Earth2 : ModProjectile + public class Earth2 : ModProjectile { private int noTileHitCounter = 120; @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = 1; projectile.timeLeft = 300; projectile.ignoreWater = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Melee/Earth3.cs b/Projectiles/Melee/Earth3.cs index 76f4d21772..135a5d8bc7 100644 --- a/Projectiles/Melee/Earth3.cs +++ b/Projectiles/Melee/Earth3.cs @@ -111,7 +111,7 @@ namespace CalamityMod.Projectiles.Melee num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/Earth4.cs b/Projectiles/Melee/Earth4.cs index 72f22c834f..2841912167 100644 --- a/Projectiles/Melee/Earth4.cs +++ b/Projectiles/Melee/Earth4.cs @@ -104,10 +104,10 @@ namespace CalamityMod.Projectiles.Melee if (Main.player[Main.myPlayer].lifeSteal <= 0f) return; - if (healAmt > CalamityMod.lifeStealCap) - healAmt = CalamityMod.lifeStealCap; + if (healAmt > CalamityMod.lifeStealCap) + healAmt = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); } } } diff --git a/Projectiles/Melee/ElementBall.cs b/Projectiles/Melee/ElementBall.cs index 1511e15766..53cb0a0fab 100644 --- a/Projectiles/Melee/ElementBall.cs +++ b/Projectiles/Melee/ElementBall.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ElementBall : ModProjectile + public class ElementBall : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -32,14 +32,14 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num250].noGravity = true; Main.dust[num250].velocity *= 0f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } } } diff --git a/Projectiles/Melee/ElementBallShiv.cs b/Projectiles/Melee/ElementBallShiv.cs index 8718f25cd3..c13213519b 100644 --- a/Projectiles/Melee/ElementBallShiv.cs +++ b/Projectiles/Melee/ElementBallShiv.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ElementBallShiv : ModProjectile + public class ElementBallShiv : ModProjectile { public override void SetStaticDefaults() { @@ -32,18 +32,18 @@ namespace CalamityMod.Projectiles.Melee Main.dust[rainbow].noGravity = true; Main.dust[rainbow].velocity = Vector2.Zero; - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.timeLeft > 115) - return false; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.timeLeft > 115) + return false; - return true; - } + return true; + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { for (int k = 0; k < 4; k++) { @@ -54,29 +54,29 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(target.Center); - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + OnHitEffects(target.Center); + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(target.Center); - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + OnHitEffects(target.Center); + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } - private void OnHitEffects(Vector2 targetPos) - { - for (int x = 0; x < 4; x++) - { - if (projectile.owner == Main.myPlayer) - { - CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, x > 2, 800f, 800f, 0f, 800f, 1f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, false, 50f); - } - } + private void OnHitEffects(Vector2 targetPos) + { + for (int x = 0; x < 4; x++) + { + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, x > 2, 800f, 800f, 0f, 800f, 1f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, false, 50f); + } + } } } } diff --git a/Projectiles/Melee/ElementalExcaliburBeam.cs b/Projectiles/Melee/ElementalExcaliburBeam.cs index 2d7dd4f8ad..dc18b67d8d 100644 --- a/Projectiles/Melee/ElementalExcaliburBeam.cs +++ b/Projectiles/Melee/ElementalExcaliburBeam.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Projectiles.Melee public class ElementalExcaliburBeam : ModProjectile { private int alpha = 50; - private bool playedSound = false; + private bool playedSound = false; public override void SetStaticDefaults() { @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Melee if (!playedSound) { Main.PlaySound(SoundID.Item60, projectile.Center); - playedSound = true; + playedSound = true; } if (projectile.localAI[0] == 0f) { @@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.Melee color = new Color(255, 128, 0, alpha); int p = (int)Player.FindClosest(projectile.Center, 1, 1); - projectile.ai[1] += 1f; + projectile.ai[1] += 1f; if (projectile.ai[1] < 220f && projectile.ai[1] > 60f) { float homeSpeed = projectile.velocity.Length(); @@ -152,7 +152,7 @@ namespace CalamityMod.Projectiles.Melee case 4: // Green, home in on enemies color = new Color(0, 255, 0, alpha); - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 6f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 6f, 20f); break; @@ -240,7 +240,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(2f); + target.ExoDebuffs(2f); if (projectile.ai[0] == 7f) { @@ -254,7 +254,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(2f); + target.ExoDebuffs(2f); if (projectile.ai[0] == 7f) { @@ -341,7 +341,7 @@ namespace CalamityMod.Projectiles.Melee public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item10, projectile.Center); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 64); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 64); projectile.maxPenetrate = projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; @@ -373,13 +373,13 @@ namespace CalamityMod.Projectiles.Melee for (int x = 0; x < 3; x++) { - bool fromRight = x == 1; - if (x == 2) - fromRight = Main.rand.NextBool(2); - if (projectile.owner == Main.myPlayer) - { - CalamityUtils.ProjectileBarrage(projectile.Center, projectile.Center, fromRight, 500f, 500f, 0f, 500f, 5f, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), projectile.knockBack * 0.2f, projectile.owner, false, 0f).ai[0] = 5f; - } + bool fromRight = x == 1; + if (x == 2) + fromRight = Main.rand.NextBool(2); + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, projectile.Center, fromRight, 500f, 500f, 0f, 500f, 5f, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), projectile.knockBack * 0.2f, projectile.owner, false, 0f).ai[0] = 5f; + } } break; diff --git a/Projectiles/Melee/ElementalGlassStar.cs b/Projectiles/Melee/ElementalGlassStar.cs index 8910685111..82b7773c68 100644 --- a/Projectiles/Melee/ElementalGlassStar.cs +++ b/Projectiles/Melee/ElementalGlassStar.cs @@ -10,131 +10,131 @@ namespace CalamityMod.Projectiles.Melee { public class ElementalGlassStar : ModProjectile { - const float MaxTime = 120; - public float Timer => MaxTime - projectile.timeLeft; + const float MaxTime = 120; + public float Timer => MaxTime - projectile.timeLeft; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Glass Star"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.tileCollide = false; - projectile.melee = true; + projectile.tileCollide = false; + projectile.melee = true; projectile.penetrate = 1; projectile.timeLeft = (int)MaxTime; - projectile.scale = 1.5f; + projectile.scale = 1.5f; } public override void AI() { - if (Timer == 0) + if (Timer == 0) { - Particle spark = new FlareShine(projectile.Center, Vector2.Zero, Color.White, Color.OrangeRed, 0f,new Vector2(0.5f, 1f), new Vector2(1.5f, 3f), 20, 0f, hueShift: 0.01f); - GeneralParticleHandler.SpawnParticle(spark); + Particle spark = new FlareShine(projectile.Center, Vector2.Zero, Color.White, Color.OrangeRed, 0f,new Vector2(0.5f, 1f), new Vector2(1.5f, 3f), 20, 0f, hueShift: 0.01f); + GeneralParticleHandler.SpawnParticle(spark); - for (int i = 0; i < 2; i++) - { - Vector2 particleSpeed = projectile.velocity.RotatedByRandom(MathHelper.PiOver4 * 0.8f) * 0.1f; - Particle energyLeak = new SquishyLightParticle(projectile.Center, particleSpeed, Main.rand.NextFloat(0.8f, 1.4f), Color.Cyan, 60, 0.3f, 1.5f, hueShift: 0.02f); - GeneralParticleHandler.SpawnParticle(energyLeak); - } - } - - if (projectile.timeLeft < MaxTime - 5) - { - projectile.tileCollide = true; + for (int i = 0; i < 2; i++) + { + Vector2 particleSpeed = projectile.velocity.RotatedByRandom(MathHelper.PiOver4 * 0.8f) * 0.1f; + Particle energyLeak = new SquishyLightParticle(projectile.Center, particleSpeed, Main.rand.NextFloat(0.8f, 1.4f), Color.Cyan, 60, 0.3f, 1.5f, hueShift: 0.02f); + GeneralParticleHandler.SpawnParticle(energyLeak); + } } - if (Timer / MaxTime > 0.25f) + if (projectile.timeLeft < MaxTime - 5) { - projectile.velocity *= 0.95f; + projectile.tileCollide = true; } - if (Main.rand.Next(3) == 0) - { - int dustType = Main.rand.Next(3); - dustType = dustType == 0 ? 15 : dustType == 1 ? 57 : 58; - Dust.NewDust(projectile.Center, 14, 14, dustType, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 150, default, 1.3f); - } + if (Timer / MaxTime > 0.25f) + { + projectile.velocity *= 0.95f; + } - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 20 + Main.rand.Next(40); - if (Main.rand.NextBool(5)) - { - Main.PlaySound(SoundID.Item9, projectile.position); - } - } + if (Main.rand.Next(3) == 0) + { + int dustType = Main.rand.Next(3); + dustType = dustType == 0 ? 15 : dustType == 1 ? 57 : 58; + Dust.NewDust(projectile.Center, 14, 14, dustType, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 150, default, 1.3f); + } - if (Main.rand.NextBool(48)) - { - int starGore = Gore.NewGore(projectile.Center, new Vector2(projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[starGore].velocity *= 0.66f; - Main.gore[starGore].velocity += projectile.velocity * 0.3f; - } + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 20 + Main.rand.Next(40); + if (Main.rand.NextBool(5)) + { + Main.PlaySound(SoundID.Item9, projectile.position); + } + } - if (projectile.velocity.Length() < 2f && projectile.timeLeft < (int)(MaxTime / 2f)) - { - projectile.Kill(); - return; - } - - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; + if (Main.rand.NextBool(48)) + { + int starGore = Gore.NewGore(projectile.Center, new Vector2(projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f), 16, 1f); + Main.gore[starGore].velocity *= 0.66f; + Main.gore[starGore].velocity += projectile.velocity * 0.3f; + } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 350f, 12f, 20f); + if (projectile.velocity.Length() < 2f && projectile.timeLeft < (int)(MaxTime / 2f)) + { + projectile.Kill(); + return; + } + + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; + + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 350f, 12f, 20f); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - Texture2D starTexture = ModContent.GetTexture("CalamityMod/Particles/Sparkle"); - Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle"); - //Ajust the bloom's texture to be the same size as the star's - float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height; + Texture2D starTexture = ModContent.GetTexture("CalamityMod/Particles/Sparkle"); + Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle"); + //Ajust the bloom's texture to be the same size as the star's + float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height; - Color color = Main.hslToRgb((float)Math.Sin(Main.GlobalTime * 15f) * 0.05f + 0.08f, 1, 0.55f); - float rotation = Main.GlobalTime * 8f; - Vector2 sparkCenter = projectile.Center - Main.screenPosition; + Color color = Main.hslToRgb((float)Math.Sin(Main.GlobalTime * 15f) * 0.05f + 0.08f, 1, 0.55f); + float rotation = Main.GlobalTime * 8f; + Vector2 sparkCenter = projectile.Center - Main.screenPosition; - spriteBatch.Draw(bloomTexture, sparkCenter, null, color * 0.6f, 0, bloomTexture.Size() / 2f, 4f * properBloomSize, SpriteEffects.None, 0); - spriteBatch.Draw(starTexture, sparkCenter, null, color, rotation + MathHelper.PiOver4, starTexture.Size() / 2f, 2f * 0.75f, SpriteEffects.None, 0); - spriteBatch.Draw(starTexture, sparkCenter, null, Color.White, rotation, starTexture.Size() / 2f, 2f, SpriteEffects.None, 0); + spriteBatch.Draw(bloomTexture, sparkCenter, null, color * 0.6f, 0, bloomTexture.Size() / 2f, 4f * properBloomSize, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, sparkCenter, null, color, rotation + MathHelper.PiOver4, starTexture.Size() / 2f, 2f * 0.75f, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, sparkCenter, null, Color.White, rotation, starTexture.Size() / 2f, 2f, SpriteEffects.None, 0); - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - return false; - } + return false; + } - public override void Kill(int timeLeft) - { - var breakSound = Main.PlaySound(SoundID.DD2_WitherBeastDeath, projectile.Center); - if (breakSound != null) - breakSound.Volume *= 0.5f; + public override void Kill(int timeLeft) + { + var breakSound = Main.PlaySound(SoundID.DD2_WitherBeastDeath, projectile.Center); + if (breakSound != null) + breakSound.Volume *= 0.5f; - for (int i = 0; i < 2; i++) - { - Vector2 particleSpeed = Main.rand.NextVector2CircularEdge(1, 1) * Main.rand.NextFloat(5.2f, 4.3f); - Particle spark = new CritSpark(projectile.Center, particleSpeed, Color.White, Color.Cyan, Main.rand.NextFloat(1.3f, 1.6f), 40, 0.1f, 3.5f, hueShift: 0.02f); - GeneralParticleHandler.SpawnParticle(spark); - } + for (int i = 0; i < 2; i++) + { + Vector2 particleSpeed = Main.rand.NextVector2CircularEdge(1, 1) * Main.rand.NextFloat(5.2f, 4.3f); + Particle spark = new CritSpark(projectile.Center, particleSpeed, Color.White, Color.Cyan, Main.rand.NextFloat(1.3f, 1.6f), 40, 0.1f, 3.5f, hueShift: 0.02f); + GeneralParticleHandler.SpawnParticle(spark); + } - for (int i = 0; i < 3; i++) - { - Gore.NewGore(projectile.position, new Vector2(projectile.velocity.X * 0.05f, projectile.velocity.Y * 0.05f), Main.rand.Next(16, 18), 1f); - } - } + for (int i = 0; i < 3; i++) + { + Gore.NewGore(projectile.position, new Vector2(projectile.velocity.X * 0.05f, projectile.velocity.Y * 0.05f), Main.rand.Next(16, 18), 1f); + } + } } } diff --git a/Projectiles/Melee/EmpyreanKnife.cs b/Projectiles/Melee/EmpyreanKnife.cs index d912c25de9..23faf7c9ad 100644 --- a/Projectiles/Melee/EmpyreanKnife.cs +++ b/Projectiles/Melee/EmpyreanKnife.cs @@ -7,110 +7,110 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class EmpyreanKnife : ModProjectile - { - private int bounce = 3; + public class EmpyreanKnife : ModProjectile + { + private int bounce = 3; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Empyrean Knife"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Empyrean Knife"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 12; - projectile.height = 12; - projectile.friendly = true; - projectile.melee = true; - projectile.penetrate = 1; - projectile.timeLeft = 300; - projectile.extraUpdates = 1; - } + public override void SetDefaults() + { + projectile.width = 12; + projectile.height = 12; + projectile.friendly = true; + projectile.melee = true; + projectile.penetrate = 1; + projectile.timeLeft = 300; + projectile.extraUpdates = 1; + } - public override void AI() - { - projectile.ai[0] += 1f; - if (projectile.ai[0] >= 75f) - { - projectile.alpha += 10; - projectile.damage = (int)(projectile.damage * 0.95); - projectile.knockBack = projectile.knockBack * 0.95f; - if (projectile.alpha >= 255) - projectile.active = false; - } - if (projectile.ai[0] < 75f) - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - else - { - projectile.rotation += 0.5f; - } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 20f); - if (Main.rand.NextBool(6)) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 58, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f); - } + public override void AI() + { + projectile.ai[0] += 1f; + if (projectile.ai[0] >= 75f) + { + projectile.alpha += 10; + projectile.damage = (int)(projectile.damage * 0.95); + projectile.knockBack = projectile.knockBack * 0.95f; + if (projectile.alpha >= 255) + projectile.active = false; + } + if (projectile.ai[0] < 75f) + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + else + { + projectile.rotation += 0.5f; + } + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 20f); + if (Main.rand.NextBool(6)) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 58, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f); + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - bounce--; - if (bounce <= 0) - projectile.Kill(); - else - { - if (projectile.velocity.X != oldVelocity.X) - projectile.velocity.X = -oldVelocity.X; - if (projectile.velocity.Y != oldVelocity.Y) - projectile.velocity.Y = -oldVelocity.Y; - } - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + bounce--; + if (bounce <= 0) + projectile.Kill(); + else + { + if (projectile.velocity.X != oldVelocity.X) + projectile.velocity.X = -oldVelocity.X; + if (projectile.velocity.Y != oldVelocity.Y) + projectile.velocity.Y = -oldVelocity.Y; + } + return false; + } - 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, 58, 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 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, 58, 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) - { - float healAmt = damage * 0.005f; - if ((int)healAmt == 0) - return; + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + float healAmt = damage * 0.005f; + if ((int)healAmt == 0) + return; - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - return; + if (Main.player[Main.myPlayer].lifeSteal <= 0f) + return; - if (healAmt > CalamityMod.lifeStealCap) - healAmt = CalamityMod.lifeStealCap; + if (healAmt > CalamityMod.lifeStealCap) + healAmt = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 3f); - } + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 3f); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - float healAmt = damage * 0.005f; - if ((int)healAmt == 0) - return; + public override void OnHitPvp(Player target, int damage, bool crit) + { + float healAmt = damage * 0.005f; + if ((int)healAmt == 0) + return; - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - return; + if (Main.player[Main.myPlayer].lifeSteal <= 0f) + return; - if (healAmt > CalamityMod.lifeStealCap) - healAmt = CalamityMod.lifeStealCap; + if (healAmt > CalamityMod.lifeStealCap) + healAmt = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 3f); - } + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 3f); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Melee/EonBolt.cs b/Projectiles/Melee/EonBolt.cs index 7744a4c40f..14da149785 100644 --- a/Projectiles/Melee/EonBolt.cs +++ b/Projectiles/Melee/EonBolt.cs @@ -10,7 +10,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class EonBolt : ModProjectile + public class EonBolt : ModProjectile { internal PrimitiveTrail TrailDrawer; diff --git a/Projectiles/Melee/EssenceBeam.cs b/Projectiles/Melee/EssenceBeam.cs index 35117b9e53..fe7bc5ac19 100644 --- a/Projectiles/Melee/EssenceBeam.cs +++ b/Projectiles/Melee/EssenceBeam.cs @@ -12,18 +12,18 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Essence Beam"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { projectile.width = 26; projectile.height = 26; - projectile.aiStyle = 27; - aiType = ProjectileID.LightBeam; - projectile.ignoreWater = true; - projectile.friendly = true; + projectile.aiStyle = 27; + aiType = ProjectileID.LightBeam; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.melee = true; projectile.penetrate = 10; projectile.extraUpdates = 1; @@ -32,46 +32,46 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Lighting.AddLight(projectile.Center, 0.6f, 0f, 0.2f); - } + Lighting.AddLight(projectile.Center, 0.6f, 0f, 0.2f); + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 200, 200, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(200, 200, 200, projectile.alpha); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.timeLeft > 595) - return false; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.timeLeft > 595) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 180); target.immune[projectile.owner] = 2; } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item10, projectile.position); - int num3; - for (int num795 = 4; num795 < 31; num795 = num3 + 1) - { - 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, 173, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; - dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 173, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; - dust.velocity *= 0.05f; - num3 = num795; - } - } - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item10, projectile.position); + int num3; + for (int num795 = 4; num795 < 31; num795 = num3 + 1) + { + 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, 173, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[num798].noGravity = true; + Dust dust = Main.dust[num798]; + dust.velocity *= 0.5f; + num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 173, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[num798]; + dust.velocity *= 0.05f; + num3 = num795; + } + } + } } diff --git a/Projectiles/Melee/EssenceFireball.cs b/Projectiles/Melee/EssenceFireball.cs index f4fcecb4cc..fed5d215e1 100644 --- a/Projectiles/Melee/EssenceFireball.cs +++ b/Projectiles/Melee/EssenceFireball.cs @@ -62,10 +62,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 115) - return false; + if (projectile.timeLeft > 115) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } diff --git a/Projectiles/Melee/EssenceFlame2.cs b/Projectiles/Melee/EssenceFlame2.cs index 4ac31bb0fe..037c22e413 100644 --- a/Projectiles/Melee/EssenceFlame2.cs +++ b/Projectiles/Melee/EssenceFlame2.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class EssenceFlame2 : ModProjectile + public class EssenceFlame2 : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Healing/EssenceFlame"; @@ -27,9 +27,9 @@ namespace CalamityMod.Projectiles.Melee projectile.extraUpdates = 3; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.alpha -= 5; @@ -42,8 +42,8 @@ namespace CalamityMod.Projectiles.Melee if (projectile.frame > 3) projectile.frame = 0; - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 10f, 20f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 10f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/EssenceScythe.cs b/Projectiles/Melee/EssenceScythe.cs index c28e45e582..dd57ac7f52 100644 --- a/Projectiles/Melee/EssenceScythe.cs +++ b/Projectiles/Melee/EssenceScythe.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class EssenceScythe : ModProjectile + public class EssenceScythe : ModProjectile { public override void SetStaticDefaults() { @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Melee Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 173, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Melee if (target.life <= 0) { if (projectile.owner == Main.myPlayer) - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], 8, ModContent.ProjectileType(), 1200f, 0f); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], 8, ModContent.ProjectileType(), 1200f, 0f); } } } diff --git a/Projectiles/Melee/EutrophicScimitarProj.cs b/Projectiles/Melee/EutrophicScimitarProj.cs index bef03ae0c6..741613ab66 100644 --- a/Projectiles/Melee/EutrophicScimitarProj.cs +++ b/Projectiles/Melee/EutrophicScimitarProj.cs @@ -5,7 +5,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class EutrophicScimitarProj : ModProjectile + public class EutrophicScimitarProj : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Melee/EutrophicSpark.cs b/Projectiles/Melee/EutrophicSpark.cs index 1bc3c24666..2b4c64eb7c 100644 --- a/Projectiles/Melee/EutrophicSpark.cs +++ b/Projectiles/Melee/EutrophicSpark.cs @@ -85,6 +85,6 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Melee/ExoGladComet.cs b/Projectiles/Melee/ExoGladComet.cs index 2f78cd5268..1be8cf64b1 100644 --- a/Projectiles/Melee/ExoGladComet.cs +++ b/Projectiles/Melee/ExoGladComet.cs @@ -63,19 +63,19 @@ namespace CalamityMod.Projectiles.Melee } Lighting.AddLight(projectile.Center, 0f, 0.5f, 0.5f); projectile.velocity *= 1.005f; - + 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; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/ExoGladProj.cs b/Projectiles/Melee/ExoGladProj.cs index 8fd4df514f..220a068154 100644 --- a/Projectiles/Melee/ExoGladProj.cs +++ b/Projectiles/Melee/ExoGladProj.cs @@ -4,11 +4,11 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ExoGladProj : ModProjectile + public class ExoGladProj : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private float counter = 0f; + private float counter = 0f; public override void SetStaticDefaults() { @@ -39,10 +39,10 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < 2; i++) { int dustType = i == 0 ? 107 : 234; - if (Main.rand.NextBool(4)) - { - dustType = 269; - } + if (Main.rand.NextBool(4)) + { + dustType = 269; + } Vector2 offset = Vector2.UnitX * -12f; offset = -Vector2.UnitY.RotatedBy((double)(counter * 0.1308997f + (float)i * MathHelper.Pi), default) * value7; int exo = Dust.NewDust(projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1.5f); @@ -55,17 +55,17 @@ namespace CalamityMod.Projectiles.Melee } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 12f, 20f); } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 107, - 234, - 269 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 107, + 234, + 269 + }); for (int k = 0; k < 4; k++) { int exo = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, dustType, (float)(projectile.direction * 2), 0f, 150, default, 1f); @@ -73,36 +73,36 @@ namespace CalamityMod.Projectiles.Melee } } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - OnHitEffects(target.Center); - target.ExoDebuffs(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + OnHitEffects(target.Center); + target.ExoDebuffs(); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - OnHitEffects(target.Center); - target.ExoDebuffs(); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center); + target.ExoDebuffs(); + } - private void OnHitEffects(Vector2 targetPos) - { + private void OnHitEffects(Vector2 targetPos) + { float swordKB = projectile.knockBack; - int swordDmg = (int)(projectile.damage * 0.25); + int swordDmg = (int)(projectile.damage * 0.25); int numSwords = Main.rand.Next(1,4); - int spearAmt = Main.rand.Next(1,4); - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < numSwords; ++i) - { - CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(24f, 30f), ModContent.ProjectileType(), swordDmg, swordKB, projectile.owner); - } + int spearAmt = Main.rand.Next(1,4); + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < numSwords; ++i) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(24f, 30f), ModContent.ProjectileType(), swordDmg, swordKB, projectile.owner); + } - for (int n = 0; n < spearAmt; n++) - { - CalamityUtils.ProjectileRain(targetPos, 400f, 100f, -1000f, -800f, 29f, ModContent.ProjectileType(), swordDmg, swordKB, projectile.owner); - } - } + for (int n = 0; n < spearAmt; n++) + { + CalamityUtils.ProjectileRain(targetPos, 400f, 100f, -1000f, -800f, 29f, ModContent.ProjectileType(), swordDmg, swordKB, projectile.owner); + } + } } } } diff --git a/Projectiles/Melee/ExoGladSpears.cs b/Projectiles/Melee/ExoGladSpears.cs index ddd7ed47e5..eeb251f801 100644 --- a/Projectiles/Melee/ExoGladSpears.cs +++ b/Projectiles/Melee/ExoGladSpears.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ExoGladSpears : ModProjectile + public class ExoGladSpears : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/ExoGladius"; @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Melee projectile.friendly = true; projectile.timeLeft = 600; projectile.melee = true; - projectile.tileCollide = false; - projectile.extraUpdates = 1; + projectile.tileCollide = false; + projectile.extraUpdates = 1; } public override void AI() @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Melee if (potentialTarget != null) projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(potentialTarget.Center) * 8f) / 21f; - else if (projectile.Distance(Main.player[projectile.owner].Center) > 1000f) + else if (projectile.Distance(Main.player[projectile.owner].Center) > 1000f) { float inertia = 25f * FlySpeedMultiplier; Vector2 directionToOwner = (Main.player[projectile.owner].Center - projectile.Center).SafeNormalize(Vector2.UnitY); @@ -99,11 +99,11 @@ namespace CalamityMod.Projectiles.Melee projectile.Damage(); Main.PlaySound(SoundID.Item74, (int)projectile.position.X, (int)projectile.position.Y); int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 107, - 234, - 269 - }); + { + 107, + 234, + 269 + }); for (int i = 0; i < 6; i++) { Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0, 0); @@ -122,12 +122,12 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } } } diff --git a/Projectiles/Melee/ExoGladiusBeam.cs b/Projectiles/Melee/ExoGladiusBeam.cs index 91ff0c382b..29819129a6 100644 --- a/Projectiles/Melee/ExoGladiusBeam.cs +++ b/Projectiles/Melee/ExoGladiusBeam.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ExoGladiusBeam : ModProjectile + public class ExoGladiusBeam : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/ExoGladius"; @@ -33,8 +33,8 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 15; - projectile.extraUpdates = 1; - projectile.tileCollide = false; + projectile.extraUpdates = 1; + projectile.tileCollide = false; } public override void AI() @@ -118,7 +118,7 @@ namespace CalamityMod.Projectiles.Melee projectile.scale += (maxScale - 1) / (float)penetrationAmt; projectile.ai[1] = 5 + Main.rand.Next(-2, 3); - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) @@ -126,7 +126,7 @@ namespace CalamityMod.Projectiles.Melee projectile.scale += (maxScale - 1) / (float)penetrationAmt; projectile.ai[1] = 5 + Main.rand.Next(-2, 3); - target.ExoDebuffs(); + target.ExoDebuffs(); } } } diff --git a/Projectiles/Melee/Exobeam.cs b/Projectiles/Melee/Exobeam.cs index 114907d012..54b1a78b45 100644 --- a/Projectiles/Melee/Exobeam.cs +++ b/Projectiles/Melee/Exobeam.cs @@ -135,12 +135,12 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override Color? GetAlpha(Color lightColor) @@ -150,10 +150,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 595) - return false; + if (projectile.timeLeft > 595) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } diff --git a/Projectiles/Melee/Exoboom.cs b/Projectiles/Melee/Exoboom.cs index 624ac67b46..453f35e5bf 100644 --- a/Projectiles/Melee/Exoboom.cs +++ b/Projectiles/Melee/Exoboom.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class Exoboom : ModProjectile + public class Exoboom : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -95,12 +95,12 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } } } diff --git a/Projectiles/Melee/Exocomet.cs b/Projectiles/Melee/Exocomet.cs index dc953a6920..a5dc934e68 100644 --- a/Projectiles/Melee/Exocomet.cs +++ b/Projectiles/Melee/Exocomet.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class Exocomet : ModProjectile + public class Exocomet : ModProjectile { public override void SetStaticDefaults() { @@ -26,12 +26,12 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.penetrate = 1; projectile.alpha = 50; - projectile.timeLeft = 360; + projectile.timeLeft = 360; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 240 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 240 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.frameCounter++; if (projectile.frameCounter > 5) @@ -62,27 +62,27 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(projectile.Center, 0f, 0.5f, 0.5f); - if (projectile.timeLeft < 240) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 12f, 20f); - else - { - float num953 = 100f * projectile.ai[1]; - float scaleFactor12 = 20f * projectile.ai[1]; - float num954 = 40f; - if (Main.player[projectile.owner].active && !Main.player[projectile.owner].dead) - { - if (projectile.Distance(Main.player[projectile.owner].Center) > num954) - { - Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; - } - } - } + if (projectile.timeLeft < 240) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 12f, 20f); + else + { + float num953 = 100f * projectile.ai[1]; + float scaleFactor12 = 20f * projectile.ai[1]; + float num954 = 40f; + if (Main.player[projectile.owner].active && !Main.player[projectile.owner].dead) + { + if (projectile.Distance(Main.player[projectile.owner].Center) > num954) + { + Vector2 moveDirection = projectile.SafeDirectionTo(Main.player[projectile.owner].Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; + } + } + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); float healAmt = damage * 0.01f; if ((int)healAmt == 0) @@ -91,15 +91,15 @@ namespace CalamityMod.Projectiles.Melee if (Main.player[Main.myPlayer].lifeSteal <= 0f) return; - if (healAmt > CalamityMod.lifeStealCap) - healAmt = CalamityMod.lifeStealCap; + if (healAmt > CalamityMod.lifeStealCap) + healAmt = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); float healAmt = damage * 0.01f; if ((int)healAmt == 0) @@ -108,10 +108,10 @@ namespace CalamityMod.Projectiles.Melee if (Main.player[Main.myPlayer].lifeSteal <= 0f) return; - if (healAmt > CalamityMod.lifeStealCap) - healAmt = CalamityMod.lifeStealCap; + if (healAmt > CalamityMod.lifeStealCap) + healAmt = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/FallenPaladinsHammerProj.cs b/Projectiles/Melee/FallenPaladinsHammerProj.cs index 1f507576c3..07b4d1ef17 100644 --- a/Projectiles/Melee/FallenPaladinsHammerProj.cs +++ b/Projectiles/Melee/FallenPaladinsHammerProj.cs @@ -9,126 +9,126 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class FallenPaladinsHammerProj : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Melee/TruePaladinsHammerMelee"; + public class FallenPaladinsHammerProj : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/TruePaladinsHammerMelee"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Fallen Paladin's Hammer"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fallen Paladin's Hammer"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 62; - projectile.height = 62; - projectile.friendly = true; - projectile.melee = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.extraUpdates = 2; - } + public override void SetDefaults() + { + projectile.width = 62; + projectile.height = 62; + projectile.friendly = true; + projectile.melee = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.extraUpdates = 2; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0.35f, 0.35f, 0f); - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 8; - Main.PlaySound(SoundID.Item7, projectile.position); - } - if (projectile.ai[0] == 0f) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 30f) - { - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - } - else - { - projectile.tileCollide = false; - float num42 = 16f; - float num43 = 3.2f; - Vector2 vector2 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f); - float num44 = Main.player[projectile.owner].position.X + Main.player[projectile.owner].width / 2 - vector2.X; - float num45 = Main.player[projectile.owner].position.Y + Main.player[projectile.owner].height / 2 - vector2.Y; - float num46 = (float)Math.Sqrt(num44 * num44 + num45 * num45); - if (num46 > 3000f) - projectile.Kill(); - num46 = num42 / num46; - num44 *= num46; - num45 *= num46; - if (projectile.velocity.X < num44) - { - projectile.velocity.X = projectile.velocity.X + num43; - if (projectile.velocity.X < 0f && num44 > 0f) - projectile.velocity.X = projectile.velocity.X + num43; - } - else if (projectile.velocity.X > num44) - { - projectile.velocity.X = projectile.velocity.X - num43; - if (projectile.velocity.X > 0f && num44 < 0f) - projectile.velocity.X = projectile.velocity.X - num43; - } - if (projectile.velocity.Y < num45) - { - projectile.velocity.Y = projectile.velocity.Y + num43; - if (projectile.velocity.Y < 0f && num45 > 0f) - projectile.velocity.Y = projectile.velocity.Y + num43; - } - else if (projectile.velocity.Y > num45) - { - projectile.velocity.Y = projectile.velocity.Y - num43; - if (projectile.velocity.Y > 0f && num45 < 0f) - projectile.velocity.Y = projectile.velocity.Y - num43; - } - if (Main.myPlayer == projectile.owner) - { - Rectangle rectangle = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); - Rectangle value2 = new Rectangle((int)Main.player[projectile.owner].position.X, (int)Main.player[projectile.owner].position.Y, Main.player[projectile.owner].width, Main.player[projectile.owner].height); - if (rectangle.Intersects(value2)) - projectile.Kill(); - } - } - projectile.rotation += 0.5f; - } + public override void AI() + { + Lighting.AddLight(projectile.Center, 0.35f, 0.35f, 0f); + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 8; + Main.PlaySound(SoundID.Item7, projectile.position); + } + if (projectile.ai[0] == 0f) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] >= 30f) + { + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + } + else + { + projectile.tileCollide = false; + float num42 = 16f; + float num43 = 3.2f; + Vector2 vector2 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f); + float num44 = Main.player[projectile.owner].position.X + Main.player[projectile.owner].width / 2 - vector2.X; + float num45 = Main.player[projectile.owner].position.Y + Main.player[projectile.owner].height / 2 - vector2.Y; + float num46 = (float)Math.Sqrt(num44 * num44 + num45 * num45); + if (num46 > 3000f) + projectile.Kill(); + num46 = num42 / num46; + num44 *= num46; + num45 *= num46; + if (projectile.velocity.X < num44) + { + projectile.velocity.X = projectile.velocity.X + num43; + if (projectile.velocity.X < 0f && num44 > 0f) + projectile.velocity.X = projectile.velocity.X + num43; + } + else if (projectile.velocity.X > num44) + { + projectile.velocity.X = projectile.velocity.X - num43; + if (projectile.velocity.X > 0f && num44 < 0f) + projectile.velocity.X = projectile.velocity.X - num43; + } + if (projectile.velocity.Y < num45) + { + projectile.velocity.Y = projectile.velocity.Y + num43; + if (projectile.velocity.Y < 0f && num45 > 0f) + projectile.velocity.Y = projectile.velocity.Y + num43; + } + else if (projectile.velocity.Y > num45) + { + projectile.velocity.Y = projectile.velocity.Y - num43; + if (projectile.velocity.Y > 0f && num45 < 0f) + projectile.velocity.Y = projectile.velocity.Y - num43; + } + if (Main.myPlayer == projectile.owner) + { + Rectangle rectangle = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); + Rectangle value2 = new Rectangle((int)Main.player[projectile.owner].position.X, (int)Main.player[projectile.owner].position.Y, Main.player[projectile.owner].width, Main.player[projectile.owner].height); + if (rectangle.Intersects(value2)) + projectile.Kill(); + } + } + projectile.rotation += 0.5f; + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 250, 250, 50); - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(250, 250, 250, 50); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 240); - OnHitEffect(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 240); + OnHitEffect(); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 240); - OnHitEffect(); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 240); + OnHitEffect(); + } - private void OnHitEffect() - { - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMelee = true; - } - } + private void OnHitEffect() + { + if (projectile.owner == Main.myPlayer) + { + int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Melee/Flarefrost.cs b/Projectiles/Melee/Flarefrost.cs index f0fdb024bb..2ad586eacf 100644 --- a/Projectiles/Melee/Flarefrost.cs +++ b/Projectiles/Melee/Flarefrost.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class Flarefrost : ModProjectile + public class Flarefrost : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/ForbiddenOathbladeProjectile.cs b/Projectiles/Melee/ForbiddenOathbladeProjectile.cs index fda1d5bb08..3f2732484c 100644 --- a/Projectiles/Melee/ForbiddenOathbladeProjectile.cs +++ b/Projectiles/Melee/ForbiddenOathbladeProjectile.cs @@ -25,9 +25,9 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.tileCollide = true; projectile.penetrate = 3; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 10; - aiType = ProjectileID.DemonScythe; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 10; + aiType = ProjectileID.DemonScythe; } public override void AI() diff --git a/Projectiles/Melee/GaelSkull.cs b/Projectiles/Melee/GaelSkull.cs index b98870f57a..d3a52dace3 100644 --- a/Projectiles/Melee/GaelSkull.cs +++ b/Projectiles/Melee/GaelSkull.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class GaelSkull : ModProjectile + public class GaelSkull : ModProjectile { public override void SetStaticDefaults() { @@ -130,7 +130,7 @@ namespace CalamityMod.Projectiles.Melee } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } @@ -142,8 +142,8 @@ namespace CalamityMod.Projectiles.Melee projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); projectile.maxPenetrate = -1; projectile.penetrate = -1; - if (projectile.scale == 1.75f) - projectile.damage /= 2; + if (projectile.scale == 1.75f) + projectile.damage /= 2; projectile.Damage(); Main.PlaySound((int)SoundType.NPCKilled, (int)projectile.Center.X, (int)projectile.Center.Y, 52, 0.4f); for (int i = 0; i < 3; i++) diff --git a/Projectiles/Melee/GaelSkull2.cs b/Projectiles/Melee/GaelSkull2.cs index 6e8d99c501..615aaa1b4b 100644 --- a/Projectiles/Melee/GaelSkull2.cs +++ b/Projectiles/Melee/GaelSkull2.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class GaelSkull2 : ModProjectile + public class GaelSkull2 : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/GaelSkull"; @@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Melee } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } diff --git a/Projectiles/Melee/GalacticaComet.cs b/Projectiles/Melee/GalacticaComet.cs index c024bf12f2..dc6e688e27 100644 --- a/Projectiles/Melee/GalacticaComet.cs +++ b/Projectiles/Melee/GalacticaComet.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.tileCollide = false; projectile.penetrate = 1; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; projectile.timeLeft = 600; projectile.ignoreWater = true; } @@ -105,10 +105,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 595) - return false; + if (projectile.timeLeft > 595) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); return false; } @@ -146,7 +146,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 180); - } + target.AddBuff(ModContent.BuffType(), 180); + } } } diff --git a/Projectiles/Melee/GalaxiaBolt.cs b/Projectiles/Melee/GalaxiaBolt.cs index 3be27f30bd..8ea77ce22b 100644 --- a/Projectiles/Melee/GalaxiaBolt.cs +++ b/Projectiles/Melee/GalaxiaBolt.cs @@ -9,7 +9,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class GalaxiaBolt : ModProjectile + public class GalaxiaBolt : ModProjectile { public NPC target; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/GalaxiaTropicRing.cs b/Projectiles/Melee/GalaxiaTropicRing.cs index 6a132b8bc7..2a30f03241 100644 --- a/Projectiles/Melee/GalaxiaTropicRing.cs +++ b/Projectiles/Melee/GalaxiaTropicRing.cs @@ -9,7 +9,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class GalaxiaTropicRing : ModProjectile + public class GalaxiaTropicRing : ModProjectile { public Player Owner => Main.player[projectile.owner]; public ref float Mode => ref projectile.ai[0]; diff --git a/Projectiles/Melee/Galaxia_AndromedasStride.cs b/Projectiles/Melee/Galaxia_AndromedasStride.cs index 5609ce02fe..8431e4d24c 100644 --- a/Projectiles/Melee/Galaxia_AndromedasStride.cs +++ b/Projectiles/Melee/Galaxia_AndromedasStride.cs @@ -14,7 +14,7 @@ using Microsoft.Xna.Framework.Audio; namespace CalamityMod.Projectiles.Melee { - public class AndromedasStride : ModProjectile + public class AndromedasStride : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/GalaxiaExtra"; private bool initialized = false; diff --git a/Projectiles/Melee/Galaxia_AndromedasStrideBoltSpawner.cs b/Projectiles/Melee/Galaxia_AndromedasStrideBoltSpawner.cs index 60a58c204a..0da01899a4 100644 --- a/Projectiles/Melee/Galaxia_AndromedasStrideBoltSpawner.cs +++ b/Projectiles/Melee/Galaxia_AndromedasStrideBoltSpawner.cs @@ -9,7 +9,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class AndromedasStrideBoltSpawner : ModProjectile + public class AndromedasStrideBoltSpawner : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/Galaxia_AriesWrath.cs b/Projectiles/Melee/Galaxia_AriesWrath.cs index 7cc41edd19..11f07d7b3c 100644 --- a/Projectiles/Melee/Galaxia_AriesWrath.cs +++ b/Projectiles/Melee/Galaxia_AriesWrath.cs @@ -12,7 +12,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class AriesWrath : ModProjectile + public class AriesWrath : ModProjectile { private NPC[] excludedTargets = new NPC[4]; public override string Texture => "CalamityMod/Items/Weapons/Melee/GalaxiaExtra2"; diff --git a/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs b/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs index 7aebb8fa7d..9d2274d402 100644 --- a/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs +++ b/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs @@ -9,7 +9,7 @@ using System.Collections.Generic; namespace CalamityMod.Projectiles.Melee { - public class AriesWrathConstellation : ModProjectile + public class AriesWrathConstellation : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/Galaxia_PhoenixsPride.cs b/Projectiles/Melee/Galaxia_PhoenixsPride.cs index 4e550b7f96..ffd7dc1958 100644 --- a/Projectiles/Melee/Galaxia_PhoenixsPride.cs +++ b/Projectiles/Melee/Galaxia_PhoenixsPride.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class PhoenixsPride : ModProjectile + public class PhoenixsPride : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/GalaxiaExtra2"; //The blue one, since this is long range private bool initialized = false; diff --git a/Projectiles/Melee/Galaxia_PolarisGaze.cs b/Projectiles/Melee/Galaxia_PolarisGaze.cs index ee084cf29b..4ec60b0933 100644 --- a/Projectiles/Melee/Galaxia_PolarisGaze.cs +++ b/Projectiles/Melee/Galaxia_PolarisGaze.cs @@ -12,7 +12,7 @@ using Microsoft.Xna.Framework.Audio; namespace CalamityMod.Projectiles.Melee { - public class PolarisGaze : ModProjectile + public class PolarisGaze : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/GalaxiaExtra"; //Red cuz close range yget the deal private bool initialized = false; diff --git a/Projectiles/Melee/Galaxia_PolarisGazeDash.cs b/Projectiles/Melee/Galaxia_PolarisGazeDash.cs index f8834a61b3..7ac399fdbf 100644 --- a/Projectiles/Melee/Galaxia_PolarisGazeDash.cs +++ b/Projectiles/Melee/Galaxia_PolarisGazeDash.cs @@ -9,7 +9,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class PolarisGazeDash : ModProjectile + public class PolarisGazeDash : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/Galaxia_PolarisGazeStar.cs b/Projectiles/Melee/Galaxia_PolarisGazeStar.cs index 6327f9a9b1..4cd97ed537 100644 --- a/Projectiles/Melee/Galaxia_PolarisGazeStar.cs +++ b/Projectiles/Melee/Galaxia_PolarisGazeStar.cs @@ -9,7 +9,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class PolarisGazeStar : ModProjectile + public class PolarisGazeStar : ModProjectile { public override string Texture => "CalamityMod/Particles/Sparkle"; private bool initialized = false; diff --git a/Projectiles/Melee/GalaxySmasherHammer.cs b/Projectiles/Melee/GalaxySmasherHammer.cs index 664b357414..e9a0c6bb7e 100644 --- a/Projectiles/Melee/GalaxySmasherHammer.cs +++ b/Projectiles/Melee/GalaxySmasherHammer.cs @@ -9,205 +9,205 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class GalaxySmasherHammer : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Melee/GalaxySmasherMelee"; + public class GalaxySmasherHammer : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/GalaxySmasherMelee"; - private static float RotationIncrement = 0.22f; - private static int Lifetime = 240; - private static float ReboundTime = 26f; + private static float RotationIncrement = 0.22f; + private static int Lifetime = 240; + private static float ReboundTime = 26f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Galaxy Smasher"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Galaxy Smasher"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 62; - projectile.height = 62; - projectile.friendly = true; - projectile.melee = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.timeLeft = Lifetime; + public override void SetDefaults() + { + projectile.width = 62; + projectile.height = 62; + projectile.friendly = true; + projectile.melee = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.extraUpdates = 3; + projectile.timeLeft = Lifetime; - // Slightly ignores iframes so it can easily hit twice. - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 8; - } + // Slightly ignores iframes so it can easily hit twice. + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 8; + } - public override void AI() - { - drawOffsetX = -12; - drawOriginOffsetY = -5; - drawOriginOffsetX = 0; + public override void AI() + { + drawOffsetX = -12; + drawOriginOffsetY = -5; + drawOriginOffsetX = 0; - // Produces violet dust constantly while in flight. This lights the hammer. - int numDust = 2; - for (int i = 0; i < numDust; ++i) - { - int dustType = Main.rand.NextBool(6) ? 112 : 173; - float scale = 0.8f + Main.rand.NextFloat(0.6f); - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity = Vector2.Zero; - Main.dust[idx].scale = scale; - } + // Produces violet dust constantly while in flight. This lights the hammer. + int numDust = 2; + for (int i = 0; i < numDust; ++i) + { + int dustType = Main.rand.NextBool(6) ? 112 : 173; + float scale = 0.8f + Main.rand.NextFloat(0.6f); + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity = Vector2.Zero; + Main.dust[idx].scale = scale; + } - // The hammer makes sound while flying. - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 8; - Main.PlaySound(SoundID.Item7, (int)projectile.position.X, (int)projectile.position.Y); - } + // The hammer makes sound while flying. + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 8; + Main.PlaySound(SoundID.Item7, (int)projectile.position.X, (int)projectile.position.Y); + } - // ai[0] stores whether the hammer is returning. If 0, it isn't. If 1, it is. - if (projectile.ai[0] == 0f) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] >= ReboundTime) - { - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - } - else - { - projectile.tileCollide = false; - float returnSpeed = GalaxySmasherMelee.Speed; - float acceleration = 3.2f; - Player owner = Main.player[projectile.owner]; + // ai[0] stores whether the hammer is returning. If 0, it isn't. If 1, it is. + if (projectile.ai[0] == 0f) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] >= ReboundTime) + { + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + } + else + { + projectile.tileCollide = false; + float returnSpeed = GalaxySmasherMelee.Speed; + float acceleration = 3.2f; + Player owner = Main.player[projectile.owner]; - // Delete the hammer if it's excessively far away. - Vector2 playerCenter = owner.Center; - float xDist = playerCenter.X - projectile.Center.X; - float yDist = playerCenter.Y - projectile.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (dist > 3000f) - projectile.Kill(); + // Delete the hammer if it's excessively far away. + Vector2 playerCenter = owner.Center; + float xDist = playerCenter.X - projectile.Center.X; + float yDist = playerCenter.Y - projectile.Center.Y; + float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); + if (dist > 3000f) + projectile.Kill(); - dist = returnSpeed / dist; - xDist *= dist; - yDist *= dist; + dist = returnSpeed / dist; + xDist *= dist; + yDist *= dist; - // Home back in on the player. - if (projectile.velocity.X < xDist) - { - projectile.velocity.X = projectile.velocity.X + acceleration; - if (projectile.velocity.X < 0f && xDist > 0f) - projectile.velocity.X += acceleration; - } - else if (projectile.velocity.X > xDist) - { - projectile.velocity.X = projectile.velocity.X - acceleration; - if (projectile.velocity.X > 0f && xDist < 0f) - projectile.velocity.X -= acceleration; - } - if (projectile.velocity.Y < yDist) - { - projectile.velocity.Y = projectile.velocity.Y + acceleration; - if (projectile.velocity.Y < 0f && yDist > 0f) - projectile.velocity.Y += acceleration; - } - else if (projectile.velocity.Y > yDist) - { - projectile.velocity.Y = projectile.velocity.Y - acceleration; - if (projectile.velocity.Y > 0f && yDist < 0f) - projectile.velocity.Y -= acceleration; - } + // Home back in on the player. + if (projectile.velocity.X < xDist) + { + projectile.velocity.X = projectile.velocity.X + acceleration; + if (projectile.velocity.X < 0f && xDist > 0f) + projectile.velocity.X += acceleration; + } + else if (projectile.velocity.X > xDist) + { + projectile.velocity.X = projectile.velocity.X - acceleration; + if (projectile.velocity.X > 0f && xDist < 0f) + projectile.velocity.X -= acceleration; + } + if (projectile.velocity.Y < yDist) + { + projectile.velocity.Y = projectile.velocity.Y + acceleration; + if (projectile.velocity.Y < 0f && yDist > 0f) + projectile.velocity.Y += acceleration; + } + else if (projectile.velocity.Y > yDist) + { + projectile.velocity.Y = projectile.velocity.Y - acceleration; + if (projectile.velocity.Y > 0f && yDist < 0f) + projectile.velocity.Y -= acceleration; + } - // Delete the projectile if it touches its owner. - if (Main.myPlayer == projectile.owner) - if (projectile.Hitbox.Intersects(owner.Hitbox)) - projectile.Kill(); - } + // Delete the projectile if it touches its owner. + if (Main.myPlayer == projectile.owner) + if (projectile.Hitbox.Intersects(owner.Hitbox)) + projectile.Kill(); + } - // Rotate the hammer as it flies. - projectile.rotation += RotationIncrement; - return; - } + // Rotate the hammer as it flies. + projectile.rotation += RotationIncrement; + return; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - // Applies God Slayer Inferno on contact. - target.AddBuff(ModContent.BuffType(), 240); - OnHitEffect(target.Center); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + // Applies God Slayer Inferno on contact. + target.AddBuff(ModContent.BuffType(), 240); + OnHitEffect(target.Center); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - // Applies God Slayer Inferno on contact. - target.AddBuff(ModContent.BuffType(), 240); - OnHitEffect(target.Center); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + // Applies God Slayer Inferno on contact. + target.AddBuff(ModContent.BuffType(), 240); + OnHitEffect(target.Center); + } - private void OnHitEffect(Vector2 targetPos) - { - // Some dust gets produced on impact. - int dustSets = Main.rand.Next(5, 8); - int dustRadius = 6; - Vector2 corner = new Vector2(targetPos.X - dustRadius, targetPos.Y - dustRadius); - for (int i = 0; i < dustSets; ++i) - { - // Bigger, flying orb dust - float scaleOrb = 1.2f + Main.rand.NextFloat(1f); - int orb = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, 112); - Main.dust[orb].noGravity = true; - Main.dust[orb].velocity *= 4f; - Main.dust[orb].scale = scaleOrb; + private void OnHitEffect(Vector2 targetPos) + { + // Some dust gets produced on impact. + int dustSets = Main.rand.Next(5, 8); + int dustRadius = 6; + Vector2 corner = new Vector2(targetPos.X - dustRadius, targetPos.Y - dustRadius); + for (int i = 0; i < dustSets; ++i) + { + // Bigger, flying orb dust + float scaleOrb = 1.2f + Main.rand.NextFloat(1f); + int orb = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, 112); + Main.dust[orb].noGravity = true; + Main.dust[orb].velocity *= 4f; + Main.dust[orb].scale = scaleOrb; - // Add six sparkles per flying orb - for (int j = 0; j < 6; ++j) - { - float scaleSparkle = 0.8f + Main.rand.NextFloat(1.1f); - int sparkle = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, 173); - Main.dust[sparkle].noGravity = true; - float dustSpeed = Main.rand.NextFloat(10f, 18f); - Main.dust[sparkle].velocity = Main.rand.NextVector2Unit() * dustSpeed; - Main.dust[sparkle].scale = scaleSparkle; - } - } + // Add six sparkles per flying orb + for (int j = 0; j < 6; ++j) + { + float scaleSparkle = 0.8f + Main.rand.NextFloat(1.1f); + int sparkle = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, 173); + Main.dust[sparkle].noGravity = true; + float dustSpeed = Main.rand.NextFloat(10f, 18f); + Main.dust[sparkle].velocity = Main.rand.NextVector2Unit() * dustSpeed; + Main.dust[sparkle].scale = scaleSparkle; + } + } - // Makes an explosion sound. - Main.PlaySound(SoundID.Item14, projectile.position); + // Makes an explosion sound. + Main.PlaySound(SoundID.Item14, projectile.position); - // Three death lasers (aka "Nebula Shots") swarm the target. - int laserID = ModContent.ProjectileType(); - int laserDamage = (int)(0.2f * projectile.damage); - float laserKB = 2.5f; - int numLasers = 3; - for (int i = 0; i < numLasers; ++i) - { - float startDist = Main.rand.NextFloat(260f, 270f); - Vector2 startDir = Main.rand.NextVector2Unit(); - Vector2 startPoint = targetPos + startDir * startDist; + // Three death lasers (aka "Nebula Shots") swarm the target. + int laserID = ModContent.ProjectileType(); + int laserDamage = (int)(0.2f * projectile.damage); + float laserKB = 2.5f; + int numLasers = 3; + for (int i = 0; i < numLasers; ++i) + { + float startDist = Main.rand.NextFloat(260f, 270f); + Vector2 startDir = Main.rand.NextVector2Unit(); + Vector2 startPoint = targetPos + startDir * startDist; - float laserSpeed = Main.rand.NextFloat(15f, 18f); - Vector2 velocity = startDir * -laserSpeed; + float laserSpeed = Main.rand.NextFloat(15f, 18f); + Vector2 velocity = startDir * -laserSpeed; - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(startPoint, velocity, laserID, laserDamage, laserKB, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].tileCollide = false; - Main.projectile[proj].timeLeft = 30; - } - } - } - } - } + if (projectile.owner == Main.myPlayer) + { + int proj = Projectile.NewProjectile(startPoint, velocity, laserID, laserDamage, laserKB, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].tileCollide = false; + Main.projectile[proj].timeLeft = 30; + } + } + } + } + } } diff --git a/Projectiles/Melee/GalileosMoon.cs b/Projectiles/Melee/GalileosMoon.cs index b50b3e5691..fdf030263f 100644 --- a/Projectiles/Melee/GalileosMoon.cs +++ b/Projectiles/Melee/GalileosMoon.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class GalileosMoon : ModProjectile + public class GalileosMoon : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Magic/Crescent"; @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Melee Main.PlaySound(SoundID.Item9, projectile.position); } } - projectile.rotation += projectile.direction * 0.55f; + projectile.rotation += projectile.direction * 0.55f; CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 10f, 25f); } diff --git a/Projectiles/Melee/GalileosPlanet.cs b/Projectiles/Melee/GalileosPlanet.cs index 7ed754b5a4..34bfe7e781 100644 --- a/Projectiles/Melee/GalileosPlanet.cs +++ b/Projectiles/Melee/GalileosPlanet.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Projectiles.Melee { public class GalileosPlanet : ModProjectile { - private float radius = 84f; + private float radius = 84f; public override void SetStaticDefaults() { @@ -129,7 +129,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num21].velocity *= 2; } } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/GelWave.cs b/Projectiles/Melee/GelWave.cs index 46a69dc997..09de9e64a3 100644 --- a/Projectiles/Melee/GelWave.cs +++ b/Projectiles/Melee/GelWave.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = 2; projectile.alpha = 120; projectile.timeLeft = 200; - projectile.tileCollide = false; + projectile.tileCollide = false; } public override void AI() @@ -47,10 +47,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 195) - return false; + if (projectile.timeLeft > 195) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); return false; } diff --git a/Projectiles/Melee/GreenWater.cs b/Projectiles/Melee/GreenWater.cs index 7758ca4ab4..eac12f7a05 100644 --- a/Projectiles/Melee/GreenWater.cs +++ b/Projectiles/Melee/GreenWater.cs @@ -12,9 +12,9 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Tooth"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { @@ -28,48 +28,48 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0f, 0.25f, 0.5f); - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; - if (projectile.localAI[0] == 0f) - { - Main.PlaySound(SoundID.Item21, projectile.position); - projectile.localAI[0] += 1f; - } - int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 5, 0f, 0f, 100, default, 1f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += projectile.velocity * 0.1f; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.timeLeft > 145) - return false; - - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - - public override void Kill(int timeLeft) + public override void AI() { - Main.PlaySound(SoundID.Item10, projectile.Center); - int num3; - for (int num795 = 4; num795 < 31; num795 = num3 + 1) - { - 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, 5, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f); - Main.dust[num798].noGravity = true; - Dust dust = Main.dust[num798]; - dust.velocity *= 0.5f; - num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 5, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f); - dust = Main.dust[num798]; - dust.velocity *= 0.05f; - num3 = num795; - } - } + Lighting.AddLight(projectile.Center, 0f, 0.25f, 0.5f); + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; + if (projectile.localAI[0] == 0f) + { + Main.PlaySound(SoundID.Item21, projectile.position); + projectile.localAI[0] += 1f; + } + int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 5, 0f, 0f, 100, default, 1f); + Main.dust[num458].noGravity = true; + Main.dust[num458].velocity *= 0.5f; + Main.dust[num458].velocity += projectile.velocity * 0.1f; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.timeLeft > 145) + return false; + + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item10, projectile.Center); + int num3; + for (int num795 = 4; num795 < 31; num795 = num3 + 1) + { + 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, 5, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f); + Main.dust[num798].noGravity = true; + Dust dust = Main.dust[num798]; + dust.velocity *= 0.5f; + num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, 5, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f); + dust = Main.dust[num798]; + dust.velocity *= 0.05f; + num3 = num795; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Melee/HellionSpike.cs b/Projectiles/Melee/HellionSpike.cs index a8b9d58a2f..5c9d85cb79 100644 --- a/Projectiles/Melee/HellionSpike.cs +++ b/Projectiles/Melee/HellionSpike.cs @@ -6,80 +6,80 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class HellionSpike : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Spike"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public class HellionSpike : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Spike"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.aiStyle = 27; - projectile.friendly = true; - projectile.melee = true; - projectile.penetrate = 3; - projectile.timeLeft = 600; - aiType = ProjectileID.SporeCloud; - } + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.aiStyle = 27; + projectile.friendly = true; + projectile.melee = true; + projectile.penetrate = 3; + projectile.timeLeft = 600; + aiType = ProjectileID.SporeCloud; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0f, 0.25f, 0f); - if (Main.rand.NextBool(3)) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 44, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } - } - - public override void Kill(int timeLeft) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 44, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.timeLeft > 595) - return false; - - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); - return false; - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 8; - OnHitEffects(target.Center, crit); - target.AddBuff(BuffID.Venom, 180); - } - - public override void OnHitPvp(Player target, int damage, bool crit) - { - OnHitEffects(target.Center, crit); - target.AddBuff(BuffID.Venom, 180); - } - - private void OnHitEffects(Vector2 targetPos, bool crit) - { - if (crit) + public override void AI() + { + Lighting.AddLight(projectile.Center, 0f, 0.25f, 0f); + if (Main.rand.NextBool(3)) { - if (projectile.owner == Main.myPlayer) - { - Projectile petal = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ProjectileID.FlowerPetal, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, true); - if (petal.whoAmI.WithinBounds(Main.maxProjectiles)) - { - petal.Calamity().forceMelee = true; - petal.localNPCHitCooldown = -1; - } - } + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 44, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } } - } + + public override void Kill(int timeLeft) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 44, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.timeLeft > 595) + return false; + + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + return false; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 8; + OnHitEffects(target.Center, crit); + target.AddBuff(BuffID.Venom, 180); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center, crit); + target.AddBuff(BuffID.Venom, 180); + } + + private void OnHitEffects(Vector2 targetPos, bool crit) + { + if (crit) + { + if (projectile.owner == Main.myPlayer) + { + Projectile petal = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ProjectileID.FlowerPetal, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, true); + if (petal.whoAmI.WithinBounds(Main.maxProjectiles)) + { + petal.Calamity().forceMelee = true; + petal.localNPCHitCooldown = -1; + } + } + } + } + } } diff --git a/Projectiles/Melee/HolyColliderHolyFire.cs b/Projectiles/Melee/HolyColliderHolyFire.cs index 60b5fd08f2..227abac88c 100644 --- a/Projectiles/Melee/HolyColliderHolyFire.cs +++ b/Projectiles/Melee/HolyColliderHolyFire.cs @@ -28,9 +28,9 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 90; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 75 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 75 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.frameCounter++; if (projectile.frameCounter > 6) @@ -44,9 +44,9 @@ namespace CalamityMod.Projectiles.Melee if (Math.Abs(projectile.velocity.X) < 7f) projectile.velocity.X *= 1.05f; - if (projectile.timeLeft < 75) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 450f, 12f, 20f); - } + if (projectile.timeLeft < 75) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 450f, 12f, 20f); + } public override Color? GetAlpha(Color lightColor) { diff --git a/Projectiles/Melee/HyperBlade.cs b/Projectiles/Melee/HyperBlade.cs index ef542bd1b8..0e26cb83a4 100644 --- a/Projectiles/Melee/HyperBlade.cs +++ b/Projectiles/Melee/HyperBlade.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class HyperBlade : ModProjectile + public class HyperBlade : ModProjectile { public override void SetStaticDefaults() { @@ -30,14 +30,14 @@ namespace CalamityMod.Projectiles.Melee aiType = ProjectileID.DeathSickle; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 4; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() { Lighting.AddLight(projectile.Center, 0f, 0.5f, 0f); - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 10f, 10f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 10f, 10f); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Melee/IceBombFriendly.cs b/Projectiles/Melee/IceBombFriendly.cs index 91518fdc80..3792533242 100644 --- a/Projectiles/Melee/IceBombFriendly.cs +++ b/Projectiles/Melee/IceBombFriendly.cs @@ -20,77 +20,77 @@ namespace CalamityMod.Projectiles.Melee { projectile.width = 30; projectile.height = 30; - projectile.scale = 0.5f; + projectile.scale = 0.5f; projectile.friendly = true; projectile.melee = true; projectile.penetrate = 1; projectile.timeLeft = 180; } - public override bool CanDamage() => projectile.ai[0] >= 120f; + public override bool CanDamage() => projectile.ai[0] >= 120f; - public override void AI() + public override void AI() { projectile.velocity *= 0.98f; - if (projectile.localAI[0] == 0f) - { - projectile.scale += 0.01f; - projectile.alpha -= 50; - if (projectile.alpha <= 0) - { - projectile.localAI[0] = 1f; - projectile.alpha = 0; - } - } - else - { - projectile.scale -= 0.01f; - projectile.alpha += 50; - if (projectile.alpha >= 255) - { - projectile.localAI[0] = 0f; - projectile.alpha = 255; - } - } + if (projectile.localAI[0] == 0f) + { + projectile.scale += 0.01f; + projectile.alpha -= 50; + if (projectile.alpha <= 0) + { + projectile.localAI[0] = 1f; + projectile.alpha = 0; + } + } + else + { + projectile.scale -= 0.01f; + projectile.alpha += 50; + if (projectile.alpha >= 255) + { + projectile.localAI[0] = 0f; + projectile.alpha = 255; + } + } - if (projectile.ai[0] < 120f) - { - projectile.ai[0] += 1f; - if (projectile.ai[0] == 120f) - { - for (int num621 = 0; num621 < 8; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 14; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } + if (projectile.ai[0] < 120f) + { + projectile.ai[0] += 1f; + if (projectile.ai[0] == 120f) + { + for (int num621 = 0; num621 < 8; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 14; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } - projectile.scale = 1f; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(30f * projectile.scale)); - Main.PlaySound(SoundID.Item30, projectile.Center); - } - } - } + projectile.scale = 1f; + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(30f * projectile.scale)); + Main.PlaySound(SoundID.Item30, projectile.Center); + } + } + } - public override Color? GetAlpha(Color lightColor) - { - return Main.dayTime ? new Color(50, 50, 255, projectile.alpha) : new Color(255, 255, 255, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return Main.dayTime ? new Color(50, 50, 255, projectile.alpha) : new Color(255, 255, 255, projectile.alpha); + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item27, projectile.position); float spread = 90f * 0.0174f; @@ -104,17 +104,17 @@ namespace CalamityMod.Projectiles.Melee { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; int projectile1 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ProjectileID.FrostShard, (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); - if (projectile1.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[projectile1].Calamity().forceMelee = true; - Main.projectile[projectile1].penetrate = 2; - } + if (projectile1.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[projectile1].Calamity().forceMelee = true; + Main.projectile[projectile1].penetrate = 2; + } int projectile2 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ProjectileID.FrostShard, (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); - if (projectile2.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[projectile2].Calamity().forceMelee = true; - Main.projectile[projectile2].penetrate = 2; - } + if (projectile2.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[projectile2].Calamity().forceMelee = true; + Main.projectile[projectile2].penetrate = 2; + } } } diff --git a/Projectiles/Melee/Iceberg.cs b/Projectiles/Melee/Iceberg.cs index c1ea260c22..0767a762c8 100644 --- a/Projectiles/Melee/Iceberg.cs +++ b/Projectiles/Melee/Iceberg.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.penetrate = 1; projectile.timeLeft = 300; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Melee/IllustriousKnife.cs b/Projectiles/Melee/IllustriousKnife.cs index 3908c920f7..1a20852a7d 100644 --- a/Projectiles/Melee/IllustriousKnife.cs +++ b/Projectiles/Melee/IllustriousKnife.cs @@ -9,94 +9,94 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class IllustriousKnife : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Illustrious Knife"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public class IllustriousKnife : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Illustrious Knife"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 50; - projectile.friendly = true; - projectile.melee = true; - projectile.penetrate = 1; - projectile.timeLeft = 300; - } + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 50; + projectile.friendly = true; + projectile.melee = true; + projectile.penetrate = 1; + projectile.timeLeft = 300; + } - public override void AI() - { - projectile.ai[0] += 1f; - if (projectile.ai[0] >= 240f) - { - projectile.alpha += 4; - projectile.damage = (int)(projectile.damage * 0.95); - projectile.knockBack = (int)(projectile.knockBack * 0.95); - } - if (projectile.ai[0] < 240f) - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f; - else - { - projectile.rotation += 0.5f; - } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 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 AI() + { + projectile.ai[0] += 1f; + if (projectile.ai[0] >= 240f) + { + projectile.alpha += 4; + projectile.damage = (int)(projectile.damage * 0.95); + projectile.knockBack = (int)(projectile.knockBack * 0.95); + } + if (projectile.ai[0] < 240f) + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f; + else + { + projectile.rotation += 0.5f; + } + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 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 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(), 180); + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); - float healAmt = damage * 0.015f; - if ((int)healAmt == 0) - return; + float healAmt = damage * 0.015f; + if ((int)healAmt == 0) + return; - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - return; + if (Main.player[Main.myPlayer].lifeSteal <= 0f) + return; - if (healAmt > CalamityMod.lifeStealCap) - healAmt = CalamityMod.lifeStealCap; + if (healAmt > CalamityMod.lifeStealCap) + healAmt = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); - } + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); - float healAmt = damage * 0.015f; - if ((int)healAmt == 0) - return; + float healAmt = damage * 0.015f; + if ((int)healAmt == 0) + return; - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - return; + if (Main.player[Main.myPlayer].lifeSteal <= 0f) + return; - if (healAmt > CalamityMod.lifeStealCap) - healAmt = CalamityMod.lifeStealCap; + if (healAmt > CalamityMod.lifeStealCap) + healAmt = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); - } + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Melee/InsidiousHarpoon.cs b/Projectiles/Melee/InsidiousHarpoon.cs index 42cc303867..1c3fb31e63 100644 --- a/Projectiles/Melee/InsidiousHarpoon.cs +++ b/Projectiles/Melee/InsidiousHarpoon.cs @@ -24,22 +24,22 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = 8; projectile.alpha = 255; projectile.melee = true; - projectile.extraUpdates = 2; + projectile.extraUpdates = 2; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 20 * projectile.extraUpdates; - projectile.tileCollide = true; + projectile.tileCollide = true; } public override void AI() { - if (projectile.alpha > 0) - { - projectile.alpha -= 25; - } - if (projectile.alpha < 0) - projectile.alpha = 0; + if (projectile.alpha > 0) + { + projectile.alpha -= 25; + } + if (projectile.alpha < 0) + projectile.alpha = 0; - int num297 = 171; + int num297 = 171; if (Main.rand.Next(3) == 0) { num297 = 46; @@ -48,18 +48,18 @@ namespace CalamityMod.Projectiles.Melee { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, num297, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - if (projectile.ai[0] == 0f) - { - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - projectile.rotation += projectile.spriteDirection * MathHelper.ToRadians(45f); - } + if (projectile.ai[0] == 0f) + { + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); + projectile.rotation += projectile.spriteDirection * MathHelper.ToRadians(45f); + } //Sticky Behaviour projectile.StickyProjAI(15); - if (projectile.ai[0] == 2f) - { - projectile.velocity *= 0f; - } + if (projectile.ai[0] == 2f) + { + projectile.velocity *= 0f; + } } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) @@ -70,13 +70,13 @@ namespace CalamityMod.Projectiles.Melee public override bool OnTileCollide(Vector2 oldVelocity) { projectile.ai[0] = 2f; - projectile.timeLeft = 300; + projectile.timeLeft = 300; return false; } public override void Kill(int timeLeft) { - int num297 = 171; + int num297 = 171; if (Main.rand.Next(3) == 0) { num297 = 46; @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Melee projectile.height = 50; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - projectile.Damage(); + projectile.Damage(); for (int num621 = 0; num621 < 15; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, 0f, 0f, 100, default, 1.2f); diff --git a/Projectiles/Melee/JudgementBlah.cs b/Projectiles/Melee/JudgementBlah.cs index dfa50bcd89..f88917cb28 100644 --- a/Projectiles/Melee/JudgementBlah.cs +++ b/Projectiles/Melee/JudgementBlah.cs @@ -14,9 +14,9 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Blah Beam"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { @@ -32,36 +32,36 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; - if (projectile.ai[1] == 0f) - { - projectile.ai[1] = 1f; - Main.PlaySound(SoundID.Item60, projectile.position); - } + if (projectile.ai[1] == 0f) + { + projectile.ai[1] = 1f; + Main.PlaySound(SoundID.Item60, projectile.position); + } - if (projectile.localAI[0] == 0f) - { - projectile.scale -= 0.02f; - projectile.alpha += 30; - if (projectile.alpha >= 250) - { - projectile.alpha = 255; - projectile.localAI[0] = 1f; - } - } - else if (projectile.localAI[0] == 1f) - { - projectile.scale += 0.02f; - projectile.alpha -= 30; - if (projectile.alpha <= 0) - { - projectile.alpha = 0; - projectile.localAI[0] = 0f; - } - } + if (projectile.localAI[0] == 0f) + { + projectile.scale -= 0.02f; + projectile.alpha += 30; + if (projectile.alpha >= 250) + { + projectile.alpha = 255; + projectile.localAI[0] = 1f; + } + } + else if (projectile.localAI[0] == 1f) + { + projectile.scale += 0.02f; + projectile.alpha -= 30; + if (projectile.alpha <= 0) + { + projectile.alpha = 0; + projectile.localAI[0] = 0f; + } + } - Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, (float)Main.DiscoR / 200f, (float)Main.DiscoG / 200f, (float)Main.DiscoB / 200f); + Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, (float)Main.DiscoR / 200f, (float)Main.DiscoG / 200f, (float)Main.DiscoB / 200f); whiteLightTimer--; if (whiteLightTimer == 0) @@ -88,41 +88,41 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 10f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 10f, 20f); } - public override Color? GetAlpha(Color lightColor) - { - return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, projectile.alpha); - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.timeLeft > 115) - return false; - - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - - public override void Kill(int timeLeft) + public override Color? GetAlpha(Color lightColor) { - Main.PlaySound(SoundID.Item122, projectile.Center); - for (int num193 = 0; num193 < 2; num193++) - { - int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f); - Main.dust[dust].noGravity = true; - } - for (int num194 = 0; num194 < 20; num194++) - { - int num195 = 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), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = 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), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - if (projectile.owner == Main.myPlayer) + return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, projectile.alpha); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.timeLeft > 115) + return false; + + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item122, projectile.Center); + for (int num193 = 0; num193 < 2; num193++) + { + int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f); + Main.dust[dust].noGravity = true; + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = 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), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = 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), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + if (projectile.owner == Main.myPlayer) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y - 100, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } diff --git a/Projectiles/Melee/JudgementProj.cs b/Projectiles/Melee/JudgementProj.cs index acea99dd2a..b6166b88ef 100644 --- a/Projectiles/Melee/JudgementProj.cs +++ b/Projectiles/Melee/JudgementProj.cs @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity += projectile.velocity * 0.1f; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 9f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 9f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/LaserFountain.cs b/Projectiles/Melee/LaserFountain.cs index e04bb71148..622300a660 100644 --- a/Projectiles/Melee/LaserFountain.cs +++ b/Projectiles/Melee/LaserFountain.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class LaserFountain : ModProjectile + public class LaserFountain : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -33,11 +33,11 @@ namespace CalamityMod.Projectiles.Melee if (projectile.owner == Main.myPlayer) { int projectile1 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(350f * Main.player[projectile.owner].MeleeDamage()), projectile.knockBack, projectile.owner, 0f, 0f); - if (projectile1.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[projectile1].Calamity().forceMelee = true; - Main.projectile[projectile1].aiStyle = 1; - } + if (projectile1.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[projectile1].Calamity().forceMelee = true; + Main.projectile[projectile1].aiStyle = 1; + } } projectile.localAI[0] = 0f; } diff --git a/Projectiles/Melee/Leech.cs b/Projectiles/Melee/Leech.cs index 6bd904b1b7..d57d1800af 100644 --- a/Projectiles/Melee/Leech.cs +++ b/Projectiles/Melee/Leech.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class Leech : ModProjectile + public class Leech : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -22,9 +22,9 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f) @@ -37,8 +37,8 @@ namespace CalamityMod.Projectiles.Melee } } - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 6f, 20f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 6f, 20f); } public override void Kill(int timeLeft) @@ -49,8 +49,8 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (Main.player[projectile.owner].moonLeech) - return; + if (Main.player[projectile.owner].moonLeech) + return; Player player = Main.player[projectile.owner]; player.statLife += 2; diff --git a/Projectiles/Melee/LifeScythe.cs b/Projectiles/Melee/LifeScythe.cs index 946a1feb42..c6c30db90d 100644 --- a/Projectiles/Melee/LifeScythe.cs +++ b/Projectiles/Melee/LifeScythe.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = 5; projectile.timeLeft = 240; projectile.ignoreWater = true; - projectile.tileCollide = false; + projectile.tileCollide = false; aiType = ProjectileID.DeathSickle; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 4; @@ -34,11 +34,11 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - float num395 = Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - projectile.scale = num395 + 0.95f; + float num395 = Main.mouseTextColor / 200f - 0.35f; + num395 *= 0.2f; + projectile.scale = num395 + 0.95f; - Lighting.AddLight(projectile.Center, 0.1f, 0.5f, 0.15f); + Lighting.AddLight(projectile.Center, 0.1f, 0.5f, 0.15f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/Light.cs b/Projectiles/Melee/Light.cs index 324ee2484f..c89e9a10e4 100644 --- a/Projectiles/Melee/Light.cs +++ b/Projectiles/Melee/Light.cs @@ -6,7 +6,7 @@ namespace CalamityMod.Projectiles.Melee { public class Light : ModProjectile { - private const int speedTimerMax = 60; + private const int speedTimerMax = 60; private int speedTimer = 0; public override void SetStaticDefaults() @@ -31,13 +31,13 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { projectile.rotation += 0.5f; - speedTimer--; - if (speedTimer <= 0) - { - speedTimer = speedTimerMax; - projectile.velocity *= -1f; - } - } + speedTimer--; + if (speedTimer <= 0) + { + speedTimer = speedTimerMax; + projectile.velocity *= -1f; + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Melee/LightBeam.cs b/Projectiles/Melee/LightBeam.cs index d4012f3aa6..9658221aa9 100644 --- a/Projectiles/Melee/LightBeam.cs +++ b/Projectiles/Melee/LightBeam.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class LightBeam : ModProjectile + public class LightBeam : ModProjectile { public override void SetStaticDefaults() { @@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Melee { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.6f / 255f, 0f, (255 - projectile.alpha) * 0.2f / 255f); - if (projectile.velocity.Length() < 18f) - projectile.velocity *= 1.1f; - } + if (projectile.velocity.Length() < 18f) + projectile.velocity *= 1.1f; + } public override Color? GetAlpha(Color lightColor) { @@ -54,25 +54,25 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(BuffID.OnFire, 240); - } + target.AddBuff(BuffID.OnFire, 240); + } - public override void Kill(int timeLeft) - { - for (int num105 = 0; num105 < 20; num105++) - { - int num102 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 73, 0f, 0f, 0, default, 1f); - Main.dust[num102].noGravity = true; - Main.dust[num102].velocity += projectile.velocity * 0.1f; - } - if (projectile.owner == Main.myPlayer) - { - for (int k = 0; k < 3; k++) - { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, Main.rand.Next(-35, 36) * 0.2f, Main.rand.Next(-35, 36) * 0.2f, ModContent.ProjectileType(), - (int)(projectile.damage * 0.5), projectile.knockBack * 0.15f, Main.myPlayer, 1f, 0f); - } - } - } - } + public override void Kill(int timeLeft) + { + for (int num105 = 0; num105 < 20; num105++) + { + int num102 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 73, 0f, 0f, 0, default, 1f); + Main.dust[num102].noGravity = true; + Main.dust[num102].velocity += projectile.velocity * 0.1f; + } + if (projectile.owner == Main.myPlayer) + { + for (int k = 0; k < 3; k++) + { + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, Main.rand.Next(-35, 36) * 0.2f, Main.rand.Next(-35, 36) * 0.2f, ModContent.ProjectileType(), + (int)(projectile.damage * 0.5), projectile.knockBack * 0.15f, Main.myPlayer, 1f, 0f); + } + } + } + } } diff --git a/Projectiles/Melee/LightningThing.cs b/Projectiles/Melee/LightningThing.cs index 5684463aef..4524bb304f 100644 --- a/Projectiles/Melee/LightningThing.cs +++ b/Projectiles/Melee/LightningThing.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; using CalamityMod.Items.Weapons.Melee; namespace CalamityMod.Projectiles.Melee { - public class LightningThing : ModProjectile + public class LightningThing : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -30,16 +30,16 @@ namespace CalamityMod.Projectiles.Melee int idx = Projectile.NewProjectile(projectile.Center + new Vector2(Main.rand.NextFloat(-35f, 35f), -1600f), Vector2.UnitY * 12f, ProjectileID.CultistBossLightningOrbArc, damage, 0f, projectile.owner, MathHelper.PiOver2, Main.rand.Next(100)); - if (idx.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[idx].usesLocalNPCImmunity = true; - Main.projectile[idx].localNPCHitCooldown = GaelsGreatsword.ImmunityFrames; - // In death mode (and under a few other select conditions), the lightning has a PreAI return false in global projectile - // So forceMelee won't work unless the projectile is friendly (because a friendly exception was added) - Main.projectile[idx].friendly = true; - Main.projectile[idx].hostile = false; - Main.projectile[idx].Calamity().forceMelee = true; - } + if (idx.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[idx].usesLocalNPCImmunity = true; + Main.projectile[idx].localNPCHitCooldown = GaelsGreatsword.ImmunityFrames; + // In death mode (and under a few other select conditions), the lightning has a PreAI return false in global projectile + // So forceMelee won't work unless the projectile is friendly (because a friendly exception was added) + Main.projectile[idx].friendly = true; + Main.projectile[idx].hostile = false; + Main.projectile[idx].Calamity().forceMelee = true; + } } } } diff --git a/Projectiles/Melee/MarianaProjectile.cs b/Projectiles/Melee/MarianaProjectile.cs index c6bac1aa4d..a394cd8f79 100644 --- a/Projectiles/Melee/MarianaProjectile.cs +++ b/Projectiles/Melee/MarianaProjectile.cs @@ -22,15 +22,15 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { Lighting.AddLight(projectile.Center, 0f, 0.2f, 0.8f); - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 9f, 20f); - } + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 9f, 20f); + } public override Color? GetAlpha(Color lightColor) { diff --git a/Projectiles/Melee/MeldGreatswordBigProjectile.cs b/Projectiles/Melee/MeldGreatswordBigProjectile.cs index ded6ad31d2..44afbfdc7a 100644 --- a/Projectiles/Melee/MeldGreatswordBigProjectile.cs +++ b/Projectiles/Melee/MeldGreatswordBigProjectile.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class MeldGreatswordBigProjectile : ModProjectile + public class MeldGreatswordBigProjectile : ModProjectile { public override void SetStaticDefaults() { @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/MeldGreatswordMediumProjectile.cs b/Projectiles/Melee/MeldGreatswordMediumProjectile.cs index 9f09ffface..f690fc272c 100644 --- a/Projectiles/Melee/MeldGreatswordMediumProjectile.cs +++ b/Projectiles/Melee/MeldGreatswordMediumProjectile.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class MeldGreatswordMediumProjectile : ModProjectile + public class MeldGreatswordMediumProjectile : ModProjectile { public override void SetStaticDefaults() { @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/MeldGreatswordSmallProjectile.cs b/Projectiles/Melee/MeldGreatswordSmallProjectile.cs index 2d345ff58f..aa364244ff 100644 --- a/Projectiles/Melee/MeldGreatswordSmallProjectile.cs +++ b/Projectiles/Melee/MeldGreatswordSmallProjectile.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class MeldGreatswordSmallProjectile : ModProjectile + public class MeldGreatswordSmallProjectile : ModProjectile { public override void SetStaticDefaults() { @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/MendedBiomeBlade_BitingEmbraceMist.cs b/Projectiles/Melee/MendedBiomeBlade_BitingEmbraceMist.cs index 03d96798f0..04f550b5a0 100644 --- a/Projectiles/Melee/MendedBiomeBlade_BitingEmbraceMist.cs +++ b/Projectiles/Melee/MendedBiomeBlade_BitingEmbraceMist.cs @@ -7,7 +7,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class BitingEmbraceMist : ModProjectile + public class BitingEmbraceMist : ModProjectile { public override string Texture => "CalamityMod/Particles/MediumMist"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs b/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs index ebfd6a8bce..9b3f61f78c 100644 --- a/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs +++ b/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs @@ -8,7 +8,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class DecaysRetortDash : ModProjectile + public class DecaysRetortDash : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs b/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs index f9a588b727..39943ec364 100644 --- a/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs +++ b/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class ExtantAbhorrence : ModProjectile + public class ExtantAbhorrence : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence"; private bool initialized = false; diff --git a/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrenceMonolith.cs b/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrenceMonolith.cs index 2113572fb2..1b17fc3bd9 100644 --- a/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrenceMonolith.cs +++ b/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrenceMonolith.cs @@ -12,7 +12,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class ExtantAbhorrenceMonolith : ModProjectile + public class ExtantAbhorrenceMonolith : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrenceMonolith"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrowned.cs b/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrowned.cs index b42b4b3481..cc1d559902 100644 --- a/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrowned.cs +++ b/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrowned.cs @@ -10,7 +10,7 @@ using Terraria.Audio; namespace CalamityMod.Projectiles.Melee { - public class GestureForTheDrowned : ModProjectile + public class GestureForTheDrowned : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/TrueBiomeBlade"; Vector2 direction = Vector2.Zero; diff --git a/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrownedOrb.cs b/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrownedOrb.cs index c8c57538d4..cf20d45338 100644 --- a/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrownedOrb.cs +++ b/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrownedOrb.cs @@ -13,7 +13,7 @@ using Terraria.Audio; namespace CalamityMod.Projectiles.Melee { - public class GestureForTheDrownedOrb : ModProjectile + public class GestureForTheDrownedOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrowned"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/MendedBiomeBlade_GrovetendersEntanglingVines.cs b/Projectiles/Melee/MendedBiomeBlade_GrovetendersEntanglingVines.cs index 6532ac1b1c..96033e5124 100644 --- a/Projectiles/Melee/MendedBiomeBlade_GrovetendersEntanglingVines.cs +++ b/Projectiles/Melee/MendedBiomeBlade_GrovetendersEntanglingVines.cs @@ -7,7 +7,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class GrovetendersEntanglingVines : ModProjectile + public class GrovetendersEntanglingVines : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouchChain"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs b/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs index 0c24a056a0..af7f88d189 100644 --- a/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs +++ b/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class HeavensMight : ModProjectile + public class HeavensMight : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/MendedBiomeBlade_HeavensMight"; private bool initialized = false; diff --git a/Projectiles/Melee/MendedBiomeBlade_PurityProjectionSigil.cs b/Projectiles/Melee/MendedBiomeBlade_PurityProjectionSigil.cs index e7c88ad2eb..695820fd31 100644 --- a/Projectiles/Melee/MendedBiomeBlade_PurityProjectionSigil.cs +++ b/Projectiles/Melee/MendedBiomeBlade_PurityProjectionSigil.cs @@ -8,7 +8,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class PurityProjectionSigil : ModProjectile + public class PurityProjectionSigil : ModProjectile { private NPC target => Main.npc[(int)projectile.ai[0]]; diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs index e9444cf237..2d23217c58 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs @@ -11,7 +11,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class TrueAridGrandeur : ModProjectile + public class TrueAridGrandeur : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/MendedBiomeBlade_AridGrandeur"; private bool initialized = false; diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeurShot.cs b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeurShot.cs index dbb545cd5d..f59fc4b5e4 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeurShot.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeurShot.cs @@ -9,7 +9,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class TrueAridGrandeurShot : ModProjectile + public class TrueAridGrandeurShot : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/MendedBiomeBlade_AridGrandeurExtra"; private bool initialized = false; diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs b/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs index 7b9cc4cba9..eb2239aa62 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class TrueBitingEmbrace : ModProjectile + public class TrueBitingEmbrace : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/MendedBiomeBlade_BitingEmbrace"; diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs b/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs index 99cd0d771d..15753915b0 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs @@ -10,7 +10,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class TrueDecaysRetort : ModProjectile + public class TrueDecaysRetort : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/MendedBiomeBlade_DecaysRetort"; private bool initialized = false; diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs b/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs index 8f552d108d..1cee6bb1be 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs @@ -13,7 +13,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class TrueGrovetendersTouch : ModProjectile + public class TrueGrovetendersTouch : ModProjectile { private NPC[] excludedTargets = new NPC[4]; public override string Texture => "CalamityMod/Projectiles/Melee/MendedBiomeBlade_GrovetendersTouchBlade"; diff --git a/Projectiles/Melee/MendedBiomeBlade_TruePurityProjection.cs b/Projectiles/Melee/MendedBiomeBlade_TruePurityProjection.cs index 7c83e42270..06faa9297d 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TruePurityProjection.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TruePurityProjection.cs @@ -10,7 +10,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class TruePurityProjection : ModProjectile //The boring plain one. With cool homing now + public class TruePurityProjection : ModProjectile //The boring plain one. With cool homing now { public NPC target; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/MicrowaveAura.cs b/Projectiles/Melee/MicrowaveAura.cs index 6786cce40e..1bb0b5da73 100644 --- a/Projectiles/Melee/MicrowaveAura.cs +++ b/Projectiles/Melee/MicrowaveAura.cs @@ -6,11 +6,11 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class MicrowaveAura : ModProjectile + public class MicrowaveAura : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private int radius = 100; + private int radius = 100; public override void SetStaticDefaults() { @@ -22,64 +22,64 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.width = 200; - projectile.height = 200; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.timeLeft = 300; + projectile.width = 200; + projectile.height = 200; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.timeLeft = 300; } - public override void AI() - { - Projectile parent = FindParent(); - if (parent != null && parent.active) - { - projectile.Center = parent.Center; - projectile.timeLeft = 2; - } - else - { - projectile.Kill(); - } - } + public override void AI() + { + Projectile parent = FindParent(); + if (parent != null && parent.active) + { + projectile.Center = parent.Center; + projectile.timeLeft = 2; + } + else + { + projectile.Kill(); + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 180); - if (target.life <= 0 && (FindParent().modProjectile as MicrowaveYoyo).soundCooldown <= 0) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); - (FindParent().modProjectile as MicrowaveYoyo).soundCooldown = 60; - } + if (target.life <= 0 && (FindParent().modProjectile as MicrowaveYoyo).soundCooldown <= 0) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); + (FindParent().modProjectile as MicrowaveYoyo).soundCooldown = 60; + } } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 180); - if (target.statLife <= 0 && (FindParent().modProjectile as MicrowaveYoyo).soundCooldown <= 0) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); - (FindParent().modProjectile as MicrowaveYoyo).soundCooldown = 60; - } + if (target.statLife <= 0 && (FindParent().modProjectile as MicrowaveYoyo).soundCooldown <= 0) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); + (FindParent().modProjectile as MicrowaveYoyo).soundCooldown = 60; + } } - private Projectile FindParent() - { - Projectile parent = null; - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile p = Main.projectile[i]; - if (p.identity == projectile.ai[0] && p.active && p.type == ModContent.ProjectileType() && p.owner == projectile.owner) - { - parent = p; - break; - } - } - return parent; - } + private Projectile FindParent() + { + Projectile parent = null; + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile p = Main.projectile[i]; + if (p.identity == projectile.ai[0] && p.active && p.type == ModContent.ProjectileType() && p.owner == projectile.owner) + { + parent = p; + break; + } + } + return parent; + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, radius, targetHitbox); } diff --git a/Projectiles/Melee/MirrorBlast.cs b/Projectiles/Melee/MirrorBlast.cs index fa16337150..e18640d3d9 100644 --- a/Projectiles/Melee/MirrorBlast.cs +++ b/Projectiles/Melee/MirrorBlast.cs @@ -54,10 +54,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 295) - return false; + if (projectile.timeLeft > 295) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); return false; } } diff --git a/Projectiles/Melee/MonstrousKnife.cs b/Projectiles/Melee/MonstrousKnife.cs index f24cac9b6b..dc9fea9f14 100644 --- a/Projectiles/Melee/MonstrousKnife.cs +++ b/Projectiles/Melee/MonstrousKnife.cs @@ -14,84 +14,84 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 2; - projectile.friendly = true; - projectile.melee = true; - projectile.ignoreWater = true; + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 2; + projectile.friendly = true; + projectile.melee = true; + projectile.ignoreWater = true; } public override void AI() { - projectile.ai[0] += 1f; - if (projectile.ai[0] >= 30f) - { - projectile.alpha += 10; - if (projectile.damage > 1) - projectile.damage = (int)(projectile.damage * 0.9); - projectile.knockBack = projectile.knockBack * 0.9f; - if (projectile.alpha >= 255) - projectile.Kill(); - } - if (projectile.ai[0] < 30f) - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; + projectile.ai[0] += 1f; + if (projectile.ai[0] >= 30f) + { + projectile.alpha += 10; + if (projectile.damage > 1) + projectile.damage = (int)(projectile.damage * 0.9); + projectile.knockBack = projectile.knockBack * 0.9f; + if (projectile.alpha >= 255) + projectile.Kill(); + } + if (projectile.ai[0] < 30f) + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; } public override void Kill(int timeLeft) { - for (int dustIndex = 0; dustIndex < 3; ++dustIndex) - { - int redDust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 182, 0f, 0f, 100, new Color(), 0.8f); - Dust dust = Main.dust[redDust]; - dust.noGravity = true; - dust.velocity *= 1.2f; - dust.velocity -= projectile.oldVelocity * 0.3f; - } - } + for (int dustIndex = 0; dustIndex < 3; ++dustIndex) + { + int redDust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 182, 0f, 0f, 100, new Color(), 0.8f); + Dust dust = Main.dust[redDust]; + dust.noGravity = true; + dust.velocity *= 1.2f; + dust.velocity -= projectile.oldVelocity * 0.3f; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (Main.myPlayer != projectile.owner) - return; + if (Main.myPlayer != projectile.owner) + return; if (target.lifeMax <= 5 || Main.player[projectile.owner].moonLeech) return; if (Main.player[projectile.owner].lifeSteal <= 0f) - return; + return; float healAmt = damage * Main.rand.NextFloat(0.075f, 0.9f); if (healAmt < 1f) healAmt = 1f; - if (healAmt > CalamityMod.lifeStealCap) - healAmt = CalamityMod.lifeStealCap; + if (healAmt > CalamityMod.lifeStealCap) + healAmt = CalamityMod.lifeStealCap; - if (Main.rand.NextBool(3)) - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 3f); + if (Main.rand.NextBool(3)) + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 3f); } public override void OnHitPvp(Player target, int damage, bool crit) { - if (Main.myPlayer != projectile.owner) - return; + if (Main.myPlayer != projectile.owner) + return; if (Main.player[projectile.owner].moonLeech) return; if (Main.player[projectile.owner].lifeSteal <= 0f) - return; + return; float healAmt = damage * Main.rand.NextFloat(0.075f, 0.9f); if (healAmt < 1f) healAmt = 1f; - if (healAmt > CalamityMod.lifeStealCap) - healAmt = CalamityMod.lifeStealCap; + if (healAmt > CalamityMod.lifeStealCap) + healAmt = CalamityMod.lifeStealCap; - if (Main.rand.NextBool(3)) - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 3f); + if (Main.rand.NextBool(3)) + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 3f); } } } diff --git a/Projectiles/Melee/MourningstarFlail.cs b/Projectiles/Melee/MourningstarFlail.cs index 0686dbb68d..beb0772a82 100644 --- a/Projectiles/Melee/MourningstarFlail.cs +++ b/Projectiles/Melee/MourningstarFlail.cs @@ -4,7 +4,7 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Melee { - public class MourningstarFlail : BaseWhipProjectile + public class MourningstarFlail : BaseWhipProjectile { public override void SetStaticDefaults() { @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee projectile.ignoreWater = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 4; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -34,9 +34,9 @@ namespace CalamityMod.Projectiles.Melee if (projectile.localAI[1] <= 0f && projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ProjectileID.SolarWhipSwordExplosion, projectile.damage, knockback, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 4; - } + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 4; + } projectile.localAI[1] = 4f; } } diff --git a/Projectiles/Melee/MurasamaSlash.cs b/Projectiles/Melee/MurasamaSlash.cs index ef161d7879..c185a2a5dd 100644 --- a/Projectiles/Melee/MurasamaSlash.cs +++ b/Projectiles/Melee/MurasamaSlash.cs @@ -8,138 +8,138 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class MurasamaSlash : ModProjectile - { - public int frameX = 0; - public int frameY = 0; + public class MurasamaSlash : ModProjectile + { + public int frameX = 0; + public int frameY = 0; - public int CurrentFrame - { - get => frameX * 7 + frameY; - set - { - frameX = value / 7; - frameY = value % 7; - } - } + public int CurrentFrame + { + get => frameX * 7 + frameY; + set + { + frameX = value / 7; + frameY = value % 7; + } + } - // A "slash" is only present during 2 specific frames (ones with a slash effect) right before they transition to the next frame. - // Note: This bool is unused. Murasama formerly only dealt damage when on these frames, but it created a few issues with player usability. - public bool Slashing => CurrentFrame % 7 == 0 && projectile.frameCounter % 3 == 2; + // A "slash" is only present during 2 specific frames (ones with a slash effect) right before they transition to the next frame. + // Note: This bool is unused. Murasama formerly only dealt damage when on these frames, but it created a few issues with player usability. + public bool Slashing => CurrentFrame % 7 == 0 && projectile.frameCounter % 3 == 2; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Murasama"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Murasama"); + } - public override void SetDefaults() - { - projectile.width = 236; - projectile.height = 180; - projectile.scale = 2f; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.melee = true; - projectile.ownerHitCheck = true; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 21; - projectile.frameCounter = 0; - projectile.Calamity().trueMelee = true; - } + public override void SetDefaults() + { + projectile.width = 236; + projectile.height = 180; + projectile.scale = 2f; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.melee = true; + projectile.ownerHitCheck = true; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 21; + projectile.frameCounter = 0; + projectile.Calamity().trueMelee = true; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.frameCounter <= 1) - return false; - Texture2D texture = Main.projectileTexture[projectile.type]; - Vector2 origin = texture.Size() / new Vector2(2f, 7f) * 0.5f; - Rectangle frame = texture.Frame(2, 7, frameX, frameY); - SpriteEffects spriteEffects = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, frame, Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.frameCounter <= 1) + return false; + Texture2D texture = Main.projectileTexture[projectile.type]; + Vector2 origin = texture.Size() / new Vector2(2f, 7f) * 0.5f; + Rectangle frame = texture.Frame(2, 7, frameX, frameY); + SpriteEffects spriteEffects = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, frame, Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + return false; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; + public override void AI() + { + Player player = Main.player[projectile.owner]; - //Frames and crap - projectile.frameCounter++; - if (projectile.frameCounter % 3 == 0) - { - CurrentFrame++; - if (frameX >= 2) - CurrentFrame = 0; - } + //Frames and crap + projectile.frameCounter++; + if (projectile.frameCounter % 3 == 0) + { + CurrentFrame++; + if (frameX >= 2) + CurrentFrame = 0; + } - // Play a "droning" noise every so often. - if (Slashing) - { - Main.PlaySound(SoundID.Item15, projectile.Center); - } + // Play a "droning" noise every so often. + if (Slashing) + { + Main.PlaySound(SoundID.Item15, projectile.Center); + } - // Create idle light and dust. - Vector2 origin = projectile.Center + projectile.velocity * 3f; - Lighting.AddLight(origin, 3f, 0.2f, 0.2f); - if (Main.rand.NextBool(3)) - { - int redDust = Dust.NewDust(origin - projectile.Size / 2f, projectile.width, projectile.height, (int)CalamityDusts.Brimstone, projectile.velocity.X, projectile.velocity.Y, 100, default, 2f); - Main.dust[redDust].noGravity = true; - Main.dust[redDust].position -= projectile.velocity; - } + // Create idle light and dust. + Vector2 origin = projectile.Center + projectile.velocity * 3f; + Lighting.AddLight(origin, 3f, 0.2f, 0.2f); + if (Main.rand.NextBool(3)) + { + int redDust = Dust.NewDust(origin - projectile.Size / 2f, projectile.width, projectile.height, (int)CalamityDusts.Brimstone, projectile.velocity.X, projectile.velocity.Y, 100, default, 2f); + Main.dust[redDust].noGravity = true; + Main.dust[redDust].position -= projectile.velocity; + } - Vector2 playerRotatedPoint = player.RotatedRelativePoint(player.MountedCenter, true); - if (Main.myPlayer == projectile.owner) - { - if (player.channel && !player.noItems && !player.CCed) - HandleChannelMovement(player, playerRotatedPoint); - else - projectile.Kill(); - } + Vector2 playerRotatedPoint = player.RotatedRelativePoint(player.MountedCenter, true); + if (Main.myPlayer == projectile.owner) + { + if (player.channel && !player.noItems && !player.CCed) + HandleChannelMovement(player, playerRotatedPoint); + else + projectile.Kill(); + } - // Rotation and directioning. - float velocityAngle = projectile.velocity.ToRotation(); - projectile.rotation = velocityAngle + (projectile.spriteDirection == -1).ToInt() * MathHelper.Pi; - projectile.direction = (Math.Cos(velocityAngle) > 0).ToDirectionInt(); + // Rotation and directioning. + float velocityAngle = projectile.velocity.ToRotation(); + projectile.rotation = velocityAngle + (projectile.spriteDirection == -1).ToInt() * MathHelper.Pi; + projectile.direction = (Math.Cos(velocityAngle) > 0).ToDirectionInt(); - // Positioning close to the end of the player's arm. - float offset = 80f * projectile.scale; - projectile.position = playerRotatedPoint - projectile.Size * 0.5f + velocityAngle.ToRotationVector2() * offset; + // Positioning close to the end of the player's arm. + float offset = 80f * projectile.scale; + projectile.position = playerRotatedPoint - projectile.Size * 0.5f + velocityAngle.ToRotationVector2() * offset; - // Sprite and player directioning. - projectile.spriteDirection = projectile.direction; - player.ChangeDir(projectile.direction); + // Sprite and player directioning. + projectile.spriteDirection = projectile.direction; + player.ChangeDir(projectile.direction); - // Prevents the projectile from dying - projectile.timeLeft = 2; + // Prevents the projectile from dying + projectile.timeLeft = 2; - // Player item-based field manipulation. - player.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); - player.heldProj = projectile.whoAmI; - player.itemTime = 2; - player.itemAnimation = 2; - } + // Player item-based field manipulation. + player.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); + player.heldProj = projectile.whoAmI; + player.itemTime = 2; + player.itemAnimation = 2; + } - public void HandleChannelMovement(Player player, Vector2 playerRotatedPoint) - { - float speed = 1f; - if (player.ActiveItem().shoot == projectile.type) - { - speed = player.ActiveItem().shootSpeed * projectile.scale; - } - Vector2 newVelocity = (Main.MouseWorld - playerRotatedPoint).SafeNormalize(Vector2.UnitX * player.direction) * speed; + public void HandleChannelMovement(Player player, Vector2 playerRotatedPoint) + { + float speed = 1f; + if (player.ActiveItem().shoot == projectile.type) + { + speed = player.ActiveItem().shootSpeed * projectile.scale; + } + Vector2 newVelocity = (Main.MouseWorld - playerRotatedPoint).SafeNormalize(Vector2.UnitX * player.direction) * speed; - // Sync if a velocity component changes. - if (projectile.velocity.X != newVelocity.X || projectile.velocity.Y != newVelocity.Y) - { - projectile.netUpdate = true; - } - projectile.velocity = newVelocity; - } + // Sync if a velocity component changes. + if (projectile.velocity.X != newVelocity.X || projectile.velocity.Y != newVelocity.Y) + { + projectile.netUpdate = true; + } + projectile.velocity = newVelocity; + } - public override Color? GetAlpha(Color lightColor) => new Color(200, 0, 0, 0); + public override Color? GetAlpha(Color lightColor) => new Color(200, 0, 0, 0); - //public override bool CanDamage() => Slashing; - } + //public override bool CanDamage() => Slashing; + } } diff --git a/Projectiles/Melee/Nebudust.cs b/Projectiles/Melee/Nebudust.cs index 83edf2475c..b7c0f710cd 100644 --- a/Projectiles/Melee/Nebudust.cs +++ b/Projectiles/Melee/Nebudust.cs @@ -24,9 +24,9 @@ namespace CalamityMod.Projectiles.Melee projectile.ignoreWater = true; projectile.tileCollide = false; projectile.penetrate = -1; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 6; - } + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 6; + } public override void AI() { diff --git a/Projectiles/Melee/NebulashFlail.cs b/Projectiles/Melee/NebulashFlail.cs index ebde77e458..cb3a780e2d 100644 --- a/Projectiles/Melee/NebulashFlail.cs +++ b/Projectiles/Melee/NebulashFlail.cs @@ -7,7 +7,7 @@ using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee { - public class NebulashFlail : BaseWhipProjectile + public class NebulashFlail : BaseWhipProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Melee/NightStabber.cs b/Projectiles/Melee/NightStabber.cs index c7c57a7b87..99b9dee17f 100644 --- a/Projectiles/Melee/NightStabber.cs +++ b/Projectiles/Melee/NightStabber.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class NightStabber : ModProjectile + public class NightStabber : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,9 +23,9 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f) @@ -38,8 +38,8 @@ namespace CalamityMod.Projectiles.Melee } } - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 7f, 20f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 7f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/OceanBeam.cs b/Projectiles/Melee/OceanBeam.cs index ebc7132934..c87195247d 100644 --- a/Projectiles/Melee/OceanBeam.cs +++ b/Projectiles/Melee/OceanBeam.cs @@ -12,10 +12,10 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Spear"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { @@ -33,31 +33,31 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - projectile.frameCounter++; - if (projectile.frameCounter > 24) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; - } + projectile.frameCounter++; + if (projectile.frameCounter > 24) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + { + projectile.frame = 0; + } - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); - projectile.ai[1] += 1f; + projectile.ai[1] += 1f; if (projectile.ai[1] >= 60f) projectile.tileCollide = true; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override bool OnTileCollide(Vector2 oldVelocity) + public override bool OnTileCollide(Vector2 oldVelocity) { projectile.penetrate--; if (projectile.penetrate <= 0) diff --git a/Projectiles/Melee/OldLordOathswordProj.cs b/Projectiles/Melee/OldLordOathswordProj.cs index 303108fd0c..6abb8d0763 100644 --- a/Projectiles/Melee/OldLordOathswordProj.cs +++ b/Projectiles/Melee/OldLordOathswordProj.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class OldLordOathswordProj : BaseIdleHoldoutProjectile + public class OldLordOathswordProj : BaseIdleHoldoutProjectile { public enum SwingState { diff --git a/Projectiles/Melee/OmnibladeSwing.cs b/Projectiles/Melee/OmnibladeSwing.cs index bd28b34ebb..e834f1099f 100644 --- a/Projectiles/Melee/OmnibladeSwing.cs +++ b/Projectiles/Melee/OmnibladeSwing.cs @@ -5,95 +5,95 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class OmnibladeSwing : ModProjectile - { - public Player Owner => Main.player[projectile.owner]; + public class OmnibladeSwing : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { - DisplayName.SetDefault("Omniblade"); - Main.projFrames[projectile.type] = 6; - } + DisplayName.SetDefault("Omniblade"); + Main.projFrames[projectile.type] = 6; + } - public override void SetDefaults() - { - projectile.width = 246; - projectile.height = 184; - projectile.scale = 1.15f; + public override void SetDefaults() + { + projectile.width = 246; + projectile.height = 184; + projectile.scale = 1.15f; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.melee = true; - projectile.ownerHitCheck = true; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 3; - projectile.Calamity().trueMelee = true; - } + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.melee = true; + projectile.ownerHitCheck = true; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 3; + projectile.Calamity().trueMelee = true; + } - public override void AI() - { - projectile.frameCounter++; - projectile.frame = projectile.frameCounter / 3; - if (projectile.frame >= Main.projFrames[projectile.type]) - projectile.Kill(); + public override void AI() + { + projectile.frameCounter++; + projectile.frame = projectile.frameCounter / 3; + if (projectile.frame >= Main.projFrames[projectile.type]) + projectile.Kill(); - Vector2 playerRotatedPoint = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - if (Main.myPlayer == projectile.owner) - { - if (Owner.channel && !Owner.noItems && !Owner.CCed) - HandleChannelMovement(playerRotatedPoint); - else - projectile.Kill(); - } + Vector2 playerRotatedPoint = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + if (Main.myPlayer == projectile.owner) + { + if (Owner.channel && !Owner.noItems && !Owner.CCed) + HandleChannelMovement(playerRotatedPoint); + else + projectile.Kill(); + } - // Rotation and directioning. - projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + // Rotation and directioning. + projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - // Sprite and player directioning. - projectile.spriteDirection = -projectile.direction; - if (projectile.direction == 1) - projectile.Left = Owner.Center; - else - projectile.Right = Owner.Center; - projectile.position.X += projectile.spriteDirection == -1 ? -116f : 88f; - projectile.position.Y -= projectile.scale * 66f; - Owner.ChangeDir(projectile.direction); + // Sprite and player directioning. + projectile.spriteDirection = -projectile.direction; + if (projectile.direction == 1) + projectile.Left = Owner.Center; + else + projectile.Right = Owner.Center; + projectile.position.X += projectile.spriteDirection == -1 ? -116f : 88f; + projectile.position.Y -= projectile.scale * 66f; + Owner.ChangeDir(projectile.direction); - // Prevents the projectile from dying - projectile.timeLeft = 2; + // Prevents the projectile from dying + projectile.timeLeft = 2; - // Player item-based field manipulation. - Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); - Owner.heldProj = projectile.whoAmI; - Owner.itemTime = 2; - Owner.itemAnimation = 2; - } + // Player item-based field manipulation. + Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); + Owner.heldProj = projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + } - public void HandleChannelMovement(Vector2 playerRotatedPoint) - { - Vector2 newVelocity = Vector2.UnitX * (Main.MouseWorld.X > playerRotatedPoint.X).ToDirectionInt(); + public void HandleChannelMovement(Vector2 playerRotatedPoint) + { + Vector2 newVelocity = Vector2.UnitX * (Main.MouseWorld.X > playerRotatedPoint.X).ToDirectionInt(); - // Sync if a velocity component changes. - if (projectile.velocity.X != newVelocity.X || projectile.velocity.Y != newVelocity.Y) - projectile.netUpdate = true; + // Sync if a velocity component changes. + if (projectile.velocity.X != newVelocity.X || projectile.velocity.Y != newVelocity.Y) + projectile.netUpdate = true; - projectile.velocity = newVelocity; - } + projectile.velocity = newVelocity; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + } - public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 170); + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 170); - // Don't suffer from the same issues Murasama did in the past; encouraging people to kill their wrists for some extra DPS is bad lmao - public override bool CanDamage() => projectile.frameCounter > 6; + // Don't suffer from the same issues Murasama did in the past; encouraging people to kill their wrists for some extra DPS is bad lmao + public override bool CanDamage() => projectile.frameCounter > 6; } } diff --git a/Projectiles/Melee/PhosphorescentGauntletPunches.cs b/Projectiles/Melee/PhosphorescentGauntletPunches.cs index dd3da4a43e..6662efab02 100644 --- a/Projectiles/Melee/PhosphorescentGauntletPunches.cs +++ b/Projectiles/Melee/PhosphorescentGauntletPunches.cs @@ -8,167 +8,167 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class PhosphorescentGauntletPunches : ModProjectile - { - public Player Owner => Main.player[projectile.owner]; - public bool HasPerformedLunge - { - get => projectile.ai[0] == 1f; - set - { - int newValue = value.ToInt(); - if (projectile.ai[0] != newValue) - { - projectile.ai[0] = newValue; - projectile.netUpdate = true; - } - } - } + public class PhosphorescentGauntletPunches : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public bool HasPerformedLunge + { + get => projectile.ai[0] == 1f; + set + { + int newValue = value.ToInt(); + if (projectile.ai[0] != newValue) + { + projectile.ai[0] = newValue; + projectile.netUpdate = true; + } + } + } - public ref float Time => ref projectile.ai[1]; + public ref float Time => ref projectile.ai[1]; - public const float LungeSpeed = 19f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Punch"); - Main.projFrames[projectile.type] = 14; - } + public const float LungeSpeed = 19f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Punch"); + Main.projFrames[projectile.type] = 14; + } - public override void SetDefaults() - { - projectile.scale = 1.6f; - projectile.width = projectile.height = (int)(projectile.scale * 60); - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.melee = true; - projectile.ownerHitCheck = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 12; - projectile.frameCounter = 0; - projectile.Calamity().trueMelee = true; - } + public override void SetDefaults() + { + projectile.scale = 1.6f; + projectile.width = projectile.height = (int)(projectile.scale * 60); + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.melee = true; + projectile.ownerHitCheck = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 12; + projectile.frameCounter = 0; + projectile.Calamity().trueMelee = true; + } - #region AI - public override void AI() - { - if (!HasPerformedLunge) - PerformLunge(); + #region AI + public override void AI() + { + if (!HasPerformedLunge) + PerformLunge(); - Vector2 topLeft = projectile.Center + projectile.velocity.RotatedBy(-MathHelper.PiOver2) * 40f; - Vector2 topRight = projectile.Center + projectile.velocity.RotatedBy(MathHelper.PiOver2) * 40f; - if (Time >= 8f && !Collision.CanHitLine(topLeft, 8, 8, topRight, 8, 8)) - ReelBack(); - HandleProjectileVisuals(); - HandlePositioning(); - Time++; - } + Vector2 topLeft = projectile.Center + projectile.velocity.RotatedBy(-MathHelper.PiOver2) * 40f; + Vector2 topRight = projectile.Center + projectile.velocity.RotatedBy(MathHelper.PiOver2) * 40f; + if (Time >= 8f && !Collision.CanHitLine(topLeft, 8, 8, topRight, 8, 8)) + ReelBack(); + HandleProjectileVisuals(); + HandlePositioning(); + Time++; + } - internal void PerformLunge() - { - if (Main.myPlayer != projectile.owner) - return; - Owner.velocity = projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction) * LungeSpeed; - HasPerformedLunge = true; - } + internal void PerformLunge() + { + if (Main.myPlayer != projectile.owner) + return; + Owner.velocity = projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction) * LungeSpeed; + HasPerformedLunge = true; + } - internal void ReelBack() - { - Owner.GiveIFrames(PhosphorescentGauntlet.OnHitIFrames); + internal void ReelBack() + { + Owner.GiveIFrames(PhosphorescentGauntlet.OnHitIFrames); - // Create some visual effects. - if (!Main.dedServ) - { - Vector2 topLeft = projectile.Center + projectile.velocity.RotatedBy(-MathHelper.PiOver2) * 40f; - Vector2 top = projectile.Center + projectile.velocity * 70f; - Vector2 topRight = projectile.Center + projectile.velocity.RotatedBy(MathHelper.PiOver2) * 40f; - foreach (Vector2 spawnPosition in new BezierCurve(topLeft, top, topRight).GetPoints(50)) - { - Dust sulphurousAcid = Dust.NewDustPerfect(spawnPosition + projectile.velocity * 16f, (int)CalamityDusts.SulfurousSeaAcid); - sulphurousAcid.velocity = projectile.velocity * 4f; - sulphurousAcid.noGravity = true; - sulphurousAcid.scale = 1.2f; - } - } - if (Main.myPlayer != projectile.owner) - return; + // Create some visual effects. + if (!Main.dedServ) + { + Vector2 topLeft = projectile.Center + projectile.velocity.RotatedBy(-MathHelper.PiOver2) * 40f; + Vector2 top = projectile.Center + projectile.velocity * 70f; + Vector2 topRight = projectile.Center + projectile.velocity.RotatedBy(MathHelper.PiOver2) * 40f; + foreach (Vector2 spawnPosition in new BezierCurve(topLeft, top, topRight).GetPoints(50)) + { + Dust sulphurousAcid = Dust.NewDustPerfect(spawnPosition + projectile.velocity * 16f, (int)CalamityDusts.SulfurousSeaAcid); + sulphurousAcid.velocity = projectile.velocity * 4f; + sulphurousAcid.noGravity = true; + sulphurousAcid.scale = 1.2f; + } + } + if (Main.myPlayer != projectile.owner) + return; - // Reel back after collision. - Owner.velocity = Vector2.Reflect(Owner.velocity.SafeNormalize(Vector2.Zero), projectile.velocity.SafeNormalize(Vector2.Zero)) * Owner.velocity.Length(); + // Reel back after collision. + Owner.velocity = Vector2.Reflect(Owner.velocity.SafeNormalize(Vector2.Zero), projectile.velocity.SafeNormalize(Vector2.Zero)) * Owner.velocity.Length(); - // Create on-hit tile dust. - Collision.HitTiles(projectile.position, projectile.velocity, projectile.width + 16, projectile.height + 16); - projectile.Kill(); - } + // Create on-hit tile dust. + Collision.HitTiles(projectile.position, projectile.velocity, projectile.width + 16, projectile.height + 16); + projectile.Kill(); + } - internal static void GenerateDustOnOwnerHand(Player player) - { - if (Main.dedServ) - return; + internal static void GenerateDustOnOwnerHand(Player player) + { + if (Main.dedServ) + return; - Vector2 handOffset = Main.OffsetsPlayerOnhand[player.bodyFrame.Y / 56] * 2f; - if (player.direction != 1) - handOffset.X = player.bodyFrame.Width - handOffset.X; - if (player.gravDir != 1f) - handOffset.Y = player.bodyFrame.Height - handOffset.Y; + Vector2 handOffset = Main.OffsetsPlayerOnhand[player.bodyFrame.Y / 56] * 2f; + if (player.direction != 1) + handOffset.X = player.bodyFrame.Width - handOffset.X; + if (player.gravDir != 1f) + handOffset.Y = player.bodyFrame.Height - handOffset.Y; - handOffset -= new Vector2(player.bodyFrame.Width - player.width, player.bodyFrame.Height - player.height) / 2f; - Vector2 rotatedHandPosition = player.RotatedRelativePoint(player.position + handOffset, true); - for (int i = 0; i < 4; i++) - { - Dust dust = Dust.NewDustDirect(player.Center, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 150, default, 1.3f); - dust.position = rotatedHandPosition; - dust.velocity = Vector2.Zero; - dust.noGravity = true; - dust.fadeIn = 1f; - dust.velocity += player.velocity; - if (Main.rand.NextBool(2)) - { - dust.position += Utils.RandomVector2(Main.rand, -4f, 4f); - dust.scale += Main.rand.NextFloat(); - } - } - } + handOffset -= new Vector2(player.bodyFrame.Width - player.width, player.bodyFrame.Height - player.height) / 2f; + Vector2 rotatedHandPosition = player.RotatedRelativePoint(player.position + handOffset, true); + for (int i = 0; i < 4; i++) + { + Dust dust = Dust.NewDustDirect(player.Center, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 150, default, 1.3f); + dust.position = rotatedHandPosition; + dust.velocity = Vector2.Zero; + dust.noGravity = true; + dust.fadeIn = 1f; + dust.velocity += player.velocity; + if (Main.rand.NextBool(2)) + { + dust.position += Utils.RandomVector2(Main.rand, -4f, 4f); + dust.scale += Main.rand.NextFloat(); + } + } + } - internal void HandleProjectileVisuals() - { - float velocityAngle = projectile.velocity.ToRotation(); - projectile.rotation = velocityAngle + MathHelper.Pi; - projectile.frameCounter++; - if (projectile.frameCounter % 3 == 2) - { - projectile.frame++; + internal void HandleProjectileVisuals() + { + float velocityAngle = projectile.velocity.ToRotation(); + projectile.rotation = velocityAngle + MathHelper.Pi; + projectile.frameCounter++; + if (projectile.frameCounter % 3 == 2) + { + projectile.frame++; - // Die at the end of the final punch. - if (projectile.frame >= Main.projFrames[projectile.type]) - projectile.Kill(); - } - } + // Die at the end of the final punch. + if (projectile.frame >= Main.projFrames[projectile.type]) + projectile.Kill(); + } + } - internal void HandlePositioning() - { - projectile.Center = Owner.RotatedRelativePoint(Owner.MountedCenter); - projectile.Center += projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction) * 30f; - } - #endregion + internal void HandlePositioning() + { + projectile.Center = Owner.RotatedRelativePoint(Owner.MountedCenter); + projectile.Center += projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction) * 30f; + } + #endregion - #region Drawing + #region Drawing - // Manual drawing is used to correct the origin of the projectile when drawn. - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D punchTexture = ModContent.GetTexture(Texture); - Rectangle frame = punchTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); - Vector2 origin = frame.Size() * 0.5f; - SpriteEffects directionEffect = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - spriteBatch.Draw(punchTexture, projectile.Center - Main.screenPosition, frame, lightColor, projectile.rotation, origin, projectile.scale, directionEffect, 0f); - return false; - } - #endregion + // Manual drawing is used to correct the origin of the projectile when drawn. + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D punchTexture = ModContent.GetTexture(Texture); + Rectangle frame = punchTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + SpriteEffects directionEffect = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(punchTexture, projectile.Center - Main.screenPosition, frame, lightColor, projectile.rotation, origin, projectile.scale, directionEffect, 0f); + return false; + } + #endregion - #region NPC Hit Collision Logic + #region NPC Hit Collision Logic - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => ReelBack(); - #endregion - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => ReelBack(); + #endregion + } } diff --git a/Projectiles/Melee/PhotonRipperProjectile.cs b/Projectiles/Melee/PhotonRipperProjectile.cs index 9cdf90ee11..4ae321e91d 100644 --- a/Projectiles/Melee/PhotonRipperProjectile.cs +++ b/Projectiles/Melee/PhotonRipperProjectile.cs @@ -7,233 +7,233 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class PhotonRipperProjectile : ModProjectile - { - public Player Owner => Main.player[projectile.owner]; - public const float ZeroChargeDamageRatio = 0.36f; - public const float ToothDamageRatio = 0.1666667f; - public const int ToothShootRate = 5; // One chainsaw tooth is emitted every this many frames. - public const int ChargeUpTime = 150; - public ref float Time => ref projectile.ai[0]; + public class PhotonRipperProjectile : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public const float ZeroChargeDamageRatio = 0.36f; + public const float ToothDamageRatio = 0.1666667f; + public const int ToothShootRate = 5; // One chainsaw tooth is emitted every this many frames. + public const int ChargeUpTime = 150; + public ref float Time => ref projectile.ai[0]; - // This is the damage dealt by the chainsaw teeth. It is recalculated every frame in two steps: - // 1) The chainsaw's damage itself is calculated as a long-lasting holdout (like Last Prism -- in case buffs wear off or similar) - // 2) The chainsaw teeth damage scales with charging up. The chainsaw's own damage does not. - public ref float ToothDamage => ref projectile.ai[1]; - public float ChargeUpPower => MathHelper.Clamp((float)Math.Pow(Time / ChargeUpTime, 1.6D), 0f, 1f); + // This is the damage dealt by the chainsaw teeth. It is recalculated every frame in two steps: + // 1) The chainsaw's damage itself is calculated as a long-lasting holdout (like Last Prism -- in case buffs wear off or similar) + // 2) The chainsaw teeth damage scales with charging up. The chainsaw's own damage does not. + public ref float ToothDamage => ref projectile.ai[1]; + public float ChargeUpPower => MathHelper.Clamp((float)Math.Pow(Time / ChargeUpTime, 1.6D), 0f, 1f); - // Seriously though Draedon this seems a bit over the top lmfao. - public override void SetStaticDefaults() => DisplayName.SetDefault("Extraordinarily Cost-Inefficient Chainsaw"); + // Seriously though Draedon this seems a bit over the top lmfao. + public override void SetStaticDefaults() => DisplayName.SetDefault("Extraordinarily Cost-Inefficient Chainsaw"); - public override void SetDefaults() - { - projectile.width = 132; - projectile.height = 56; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.melee = true; - projectile.ownerHitCheck = true; - // No reason to ID-static the chainsaw -- multiple players can true melee simultaneously! - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 8; - } + public override void SetDefaults() + { + projectile.width = 132; + projectile.height = 56; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.melee = true; + projectile.ownerHitCheck = true; + // No reason to ID-static the chainsaw -- multiple players can true melee simultaneously! + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 8; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - Texture2D glowmaskTexture = ModContent.GetTexture("CalamityMod/Projectiles/Melee/PhotonRipperGlowmask"); - Rectangle glowmaskRectangle = glowmaskTexture.Frame(1, 6, 0, projectile.frame); - Vector2 origin = texture.Size() * 0.5f; - Vector2 drawPosition = projectile.Center - Main.screenPosition; - SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + Texture2D glowmaskTexture = ModContent.GetTexture("CalamityMod/Projectiles/Melee/PhotonRipperGlowmask"); + Rectangle glowmaskRectangle = glowmaskTexture.Frame(1, 6, 0, projectile.frame); + Vector2 origin = texture.Size() * 0.5f; + Vector2 drawPosition = projectile.Center - Main.screenPosition; + SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, drawPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, direction, 0f); - spriteBatch.Draw(glowmaskTexture, drawPosition, glowmaskRectangle, Color.White, projectile.rotation, origin, projectile.scale, direction, 0f); - return false; - } + spriteBatch.Draw(texture, drawPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, direction, 0f); + spriteBatch.Draw(glowmaskTexture, drawPosition, glowmaskRectangle, Color.White, projectile.rotation, origin, projectile.scale, direction, 0f); + return false; + } - public override void AI() - { - // Recalculate damage every frame for balance reasons, as this is a long-lasting holdout. - // This is important because you could start using it while benefitting from Auric Tesla standstill bonus, for example. - projectile.damage = (int)((Owner.ActiveItem()?.damage ?? 0) * Owner.MeleeDamage()); - DetermineDamage(); + public override void AI() + { + // Recalculate damage every frame for balance reasons, as this is a long-lasting holdout. + // This is important because you could start using it while benefitting from Auric Tesla standstill bonus, for example. + projectile.damage = (int)((Owner.ActiveItem()?.damage ?? 0) * Owner.MeleeDamage()); + DetermineDamage(); - PlayChainsawSounds(); + PlayChainsawSounds(); - // Determines the owner's position whilst incorporating their fullRotation field. - // It uses vector transformation on a Z rotation matrix based on said rotation under the hood. - // This is essentially just the pure mathematical definition of the RotatedBy method. - Vector2 playerRotatedPosition = Owner.RotatedRelativePoint(Owner.MountedCenter); - if (Main.myPlayer == projectile.owner) - { - if (Owner.channel && !Owner.noItems && !Owner.CCed) - HandleChannelMovement(playerRotatedPosition); - else - projectile.Kill(); - } + // Determines the owner's position whilst incorporating their fullRotation field. + // It uses vector transformation on a Z rotation matrix based on said rotation under the hood. + // This is essentially just the pure mathematical definition of the RotatedBy method. + Vector2 playerRotatedPosition = Owner.RotatedRelativePoint(Owner.MountedCenter); + if (Main.myPlayer == projectile.owner) + { + if (Owner.channel && !Owner.noItems && !Owner.CCed) + HandleChannelMovement(playerRotatedPosition); + else + projectile.Kill(); + } - DetermineVisuals(playerRotatedPosition); - ManipulatePlayerValues(); - EmitPrettyDust(); + DetermineVisuals(playerRotatedPosition); + ManipulatePlayerValues(); + EmitPrettyDust(); - if (Time % ToothShootRate == ToothShootRate - 1f) - ReleasePrismTeeth(); + if (Time % ToothShootRate == ToothShootRate - 1f) + ReleasePrismTeeth(); - // Prevent the projectile from dying normally. However, if anything for whatever reason - // goes wrong it will immediately be destroyed on the next frame. - projectile.timeLeft = 2; + // Prevent the projectile from dying normally. However, if anything for whatever reason + // goes wrong it will immediately be destroyed on the next frame. + projectile.timeLeft = 2; - Time++; - } + Time++; + } - public void PlayChainsawSounds() - { - if (projectile.soundDelay <= 0) - { - Main.PlaySound(SoundID.Item22, projectile.Center); - projectile.soundDelay = (int)MathHelper.Lerp(30f, 12f, ChargeUpPower); - } - } + public void PlayChainsawSounds() + { + if (projectile.soundDelay <= 0) + { + Main.PlaySound(SoundID.Item22, projectile.Center); + projectile.soundDelay = (int)MathHelper.Lerp(30f, 12f, ChargeUpPower); + } + } - public void DetermineDamage() - { - // Set the initial tooth damage the instant the projectile is created. - if (Main.myPlayer == projectile.owner && ToothDamage == 0f) - { - ToothDamage = ToothDamageRatio * projectile.damage; - projectile.netUpdate = true; - } + public void DetermineDamage() + { + // Set the initial tooth damage the instant the projectile is created. + if (Main.myPlayer == projectile.owner && ToothDamage == 0f) + { + ToothDamage = ToothDamageRatio * projectile.damage; + projectile.netUpdate = true; + } - // And then do time based damage calculations. This does not execute if the original damage is 0. - // This line covers adjusting tooth damage if the projectile's own damage changes. - if (ToothDamage != 0f) - { - float fullMult = ToothDamageRatio; - float zeroMult = ZeroChargeDamageRatio * ToothDamageRatio; - ToothDamage = (int)MathHelper.SmoothStep(projectile.damage * zeroMult, projectile.damage * fullMult, ChargeUpPower); - } - } + // And then do time based damage calculations. This does not execute if the original damage is 0. + // This line covers adjusting tooth damage if the projectile's own damage changes. + if (ToothDamage != 0f) + { + float fullMult = ToothDamageRatio; + float zeroMult = ZeroChargeDamageRatio * ToothDamageRatio; + ToothDamage = (int)MathHelper.SmoothStep(projectile.damage * zeroMult, projectile.damage * fullMult, ChargeUpPower); + } + } - public void DetermineVisuals(Vector2 playerRotatedPosition) - { - float directionAngle = projectile.velocity.ToRotation(); - projectile.rotation = directionAngle; + public void DetermineVisuals(Vector2 playerRotatedPosition) + { + float directionAngle = projectile.velocity.ToRotation(); + projectile.rotation = directionAngle; - int oldDirection = projectile.spriteDirection; - if (oldDirection == -1) - projectile.rotation += MathHelper.Pi; + int oldDirection = projectile.spriteDirection; + if (oldDirection == -1) + projectile.rotation += MathHelper.Pi; - projectile.direction = projectile.spriteDirection = (Math.Cos(directionAngle) > 0).ToDirectionInt(); + projectile.direction = projectile.spriteDirection = (Math.Cos(directionAngle) > 0).ToDirectionInt(); - // If the direction differs from what it originaly was, undo the previous 180 degree turn. - // If this is not done, the chainsaw will have 1 frame of rotational "jitter" when the direction changes based on the - // original angle. This effect looks very strange in-game. - if (projectile.spriteDirection != oldDirection) - projectile.rotation -= MathHelper.Pi; + // If the direction differs from what it originaly was, undo the previous 180 degree turn. + // If this is not done, the chainsaw will have 1 frame of rotational "jitter" when the direction changes based on the + // original angle. This effect looks very strange in-game. + if (projectile.spriteDirection != oldDirection) + projectile.rotation -= MathHelper.Pi; - // Positioning close to the player's arm. - projectile.position = playerRotatedPosition - projectile.Size * 0.5f + directionAngle.ToRotationVector2() * 30f; + // Positioning close to the player's arm. + projectile.position = playerRotatedPosition - projectile.Size * 0.5f + directionAngle.ToRotationVector2() * 30f; - // Update the position a tiny bit every frame at random to make it look like the saw is vibrating. - // It is reset on the next frame. - projectile.position += Main.rand.NextVector2Circular(1.4f, 1.4f); + // Update the position a tiny bit every frame at random to make it look like the saw is vibrating. + // It is reset on the next frame. + projectile.position += Main.rand.NextVector2Circular(1.4f, 1.4f); - // Update glowmask frames. - // Smoothstep is essentially like a linear interpolation but instead of being a straight line its - // curve is pseudo-logistic, with low increases at the ends of the curve. - projectile.frameCounter += (int)MathHelper.SmoothStep(12f, 33f, ChargeUpPower); - if (projectile.frameCounter >= 32) - { - projectile.frame = (projectile.frame + 1) % 6; - projectile.frameCounter = 0; - } - } + // Update glowmask frames. + // Smoothstep is essentially like a linear interpolation but instead of being a straight line its + // curve is pseudo-logistic, with low increases at the ends of the curve. + projectile.frameCounter += (int)MathHelper.SmoothStep(12f, 33f, ChargeUpPower); + if (projectile.frameCounter >= 32) + { + projectile.frame = (projectile.frame + 1) % 6; + projectile.frameCounter = 0; + } + } - public void HandleChannelMovement(Vector2 playerRotatedPosition) - { - Vector2 idealAimDirection = (Main.MouseWorld - playerRotatedPosition).SafeNormalize(Vector2.UnitX * Owner.direction); + public void HandleChannelMovement(Vector2 playerRotatedPosition) + { + Vector2 idealAimDirection = (Main.MouseWorld - playerRotatedPosition).SafeNormalize(Vector2.UnitX * Owner.direction); - float angularAimVelocity = 0.15f; - float directionAngularDisparity = projectile.velocity.AngleBetween(idealAimDirection) / MathHelper.Pi; + float angularAimVelocity = 0.15f; + float directionAngularDisparity = projectile.velocity.AngleBetween(idealAimDirection) / MathHelper.Pi; - // Increase the turn speed if close to the ideal direction, since successive linear interpolations - // are asymptotic. - angularAimVelocity += MathHelper.Lerp(0f, 0.25f, Utils.InverseLerp(0.28f, 0.08f, directionAngularDisparity, true)); + // Increase the turn speed if close to the ideal direction, since successive linear interpolations + // are asymptotic. + angularAimVelocity += MathHelper.Lerp(0f, 0.25f, Utils.InverseLerp(0.28f, 0.08f, directionAngularDisparity, true)); - if (directionAngularDisparity > 0.02f) - projectile.velocity = Vector2.Lerp(projectile.velocity, idealAimDirection, angularAimVelocity); - else - projectile.velocity = idealAimDirection; + if (directionAngularDisparity > 0.02f) + projectile.velocity = Vector2.Lerp(projectile.velocity, idealAimDirection, angularAimVelocity); + else + projectile.velocity = idealAimDirection; - projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction); - } + projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction); + } - public void ManipulatePlayerValues() - { - Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); - Owner.itemTime = 2; - Owner.itemAnimation = 2; - Owner.ChangeDir(projectile.direction); - } + public void ManipulatePlayerValues() + { + Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.ChangeDir(projectile.direction); + } - public void EmitPrettyDust() - { - if (Main.dedServ) - return; + public void EmitPrettyDust() + { + if (Main.dedServ) + return; - for (int i = 0; i < 2; i++) - { - Vector2 spawnPosition = projectile.Center + projectile.velocity * 35f; + for (int i = 0; i < 2; i++) + { + Vector2 spawnPosition = projectile.Center + projectile.velocity * 35f; - // Spawn the dust a little bit on the chainsaw. X variance is less than Y variance to ensure that dust does not - // spawn too far from the blade. - spawnPosition += Main.rand.NextVector2CircularEdge(9f, 35f).RotatedBy(projectile.velocity.ToRotation() + MathHelper.PiOver2); + // Spawn the dust a little bit on the chainsaw. X variance is less than Y variance to ensure that dust does not + // spawn too far from the blade. + spawnPosition += Main.rand.NextVector2CircularEdge(9f, 35f).RotatedBy(projectile.velocity.ToRotation() + MathHelper.PiOver2); - Dust rainbowSpark = Dust.NewDustPerfect(spawnPosition, 261); - rainbowSpark.velocity = projectile.velocity * 3f + Main.rand.NextVector2CircularEdge(1.5f, 1.5f); - rainbowSpark.noGravity = true; - rainbowSpark.color = Main.hslToRgb((Time / 40f + Main.rand.NextFloat(-0.1f, 0.1f)) % 1f, 0.95f, 0.6f); - rainbowSpark.scale = Main.rand.NextFloat(0.9f, 1.25f); - } - } + Dust rainbowSpark = Dust.NewDustPerfect(spawnPosition, 261); + rainbowSpark.velocity = projectile.velocity * 3f + Main.rand.NextVector2CircularEdge(1.5f, 1.5f); + rainbowSpark.noGravity = true; + rainbowSpark.color = Main.hslToRgb((Time / 40f + Main.rand.NextFloat(-0.1f, 0.1f)) % 1f, 0.95f, 0.6f); + rainbowSpark.scale = Main.rand.NextFloat(0.9f, 1.25f); + } + } - public void ReleasePrismTeeth() - { - // Play the sound that the crystal vile shard uses. - // Hopefully this isn't too cancerous to listen to, given the shoot rate of the crystals. - Main.PlaySound(SoundID.Item101, projectile.Center); + public void ReleasePrismTeeth() + { + // Play the sound that the crystal vile shard uses. + // Hopefully this isn't too cancerous to listen to, given the shoot rate of the crystals. + Main.PlaySound(SoundID.Item101, projectile.Center); - if (Main.myPlayer != projectile.owner) - return; + if (Main.myPlayer != projectile.owner) + return; - float shootReach = MathHelper.SmoothStep(projectile.width * 1.8f, projectile.width * 5.3f + 16f, ChargeUpPower); + float shootReach = MathHelper.SmoothStep(projectile.width * 1.8f, projectile.width * 5.3f + 16f, ChargeUpPower); - // Incorporate item shoot speed into the range of the crystals. - // This means that projectile speed boosts will improve the range of the chainsaw. - shootReach *= Owner.ActiveItem().shootSpeed; + // Incorporate item shoot speed into the range of the crystals. + // This means that projectile speed boosts will improve the range of the chainsaw. + shootReach *= Owner.ActiveItem().shootSpeed; - float distanceFromMouse = Owner.Distance(Main.MouseWorld); + float distanceFromMouse = Owner.Distance(Main.MouseWorld); - // If the distance to the mouse is less than the base reach, reach only to mouse. - // This way the player can more directly control the crystals if they want. - // This comes with a small constant offset to cancel out other factors. - if (distanceFromMouse < shootReach && distanceFromMouse > 40f) - shootReach = distanceFromMouse + 32f; + // If the distance to the mouse is less than the base reach, reach only to mouse. + // This way the player can more directly control the crystals if they want. + // This comes with a small constant offset to cancel out other factors. + if (distanceFromMouse < shootReach && distanceFromMouse > 40f) + shootReach = distanceFromMouse + 32f; - Projectile.NewProjectile(Owner.Center, projectile.velocity, ModContent.ProjectileType(), (int)ToothDamage, 0f, projectile.owner, shootReach, projectile.whoAmI); - } + Projectile.NewProjectile(Owner.Center, projectile.velocity, ModContent.ProjectileType(), (int)ToothDamage, 0f, projectile.owner, shootReach, projectile.whoAmI); + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - // Collision is done as a line to bypass the fact that hitboxes cannot rotate and that - // this projectile is notably flat in terms of sprite shape. - float _ = 0f; - float width = projectile.scale * 36f; - Vector2 start = projectile.Center; - Vector2 end = projectile.Center + projectile.velocity * 70f; - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, width, ref _); - } - } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + // Collision is done as a line to bypass the fact that hitboxes cannot rotate and that + // this projectile is notably flat in terms of sprite shape. + float _ = 0f; + float width = projectile.scale * 36f; + Vector2 start = projectile.Center; + Vector2 end = projectile.Center + projectile.velocity * 70f; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, width, ref _); + } + } } diff --git a/Projectiles/Melee/PlagueBeeDust.cs b/Projectiles/Melee/PlagueBeeDust.cs index 47f6fc4133..c4dccab3ec 100644 --- a/Projectiles/Melee/PlagueBeeDust.cs +++ b/Projectiles/Melee/PlagueBeeDust.cs @@ -7,128 +7,128 @@ using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Projectiles.Melee { - public class PlagueBeeDust : ModProjectile - { + public class PlagueBeeDust : ModProjectile + { public override string Texture => "CalamityMod/Projectiles/Melee/PlagueDust"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Dust"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Dust"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 70; - projectile.height = 70; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.melee = true; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.timeLeft = 150; - projectile.alpha = 100; - } + public override void SetDefaults() + { + projectile.width = 70; + projectile.height = 70; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.melee = true; + projectile.penetrate = -1; + projectile.extraUpdates = 3; + projectile.timeLeft = 150; + projectile.alpha = 100; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - projectile.ai[1]++; - Lighting.AddLight(projectile.Center, 0.05f, 0.4f, 0f); - if (projectile.ai[1] < 60f) - { - if (projectile.ai[0] > 7f) - { - float scalar = 1f; - if (projectile.ai[0] == 8f) - { - scalar = 0.25f; - } - else if (projectile.ai[0] == 9f) - { - scalar = 0.5f; - } - else if (projectile.ai[0] == 10f) - { - scalar = 0.75f; - } - projectile.ai[0] += 1f; - if (projectile.ai[0] % 2f == 0f) - { - int spawnX = (int)(projectile.width / 2); - int spawnY = (int)(projectile.width / 2); - int bee = Projectile.NewProjectile(projectile.Center.X + (float)Main.rand.Next(-spawnX, spawnX), projectile.Center.Y + (float)Main.rand.Next(-spawnY, spawnY), projectile.velocity.X, projectile.velocity.Y, player.beeType(), player.beeDamage(projectile.damage / 3), player.beeKB(0f), projectile.owner); - if (bee.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[bee].Calamity().forceMelee = true; - Main.projectile[bee].penetrate = 1; - } - } - //Dust - int dustType = 89; - int plague = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[plague]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.8f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.3f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= scalar; - } - else - { - projectile.ai[0] += 1f; - } - } - else - { - projectile.damage = (int)(projectile.damage * 0.6); - projectile.velocity *= 0.85f; - //Fade out - if (projectile.alpha < 255) - projectile.alpha += 5; - if (projectile.alpha >= 255) - projectile.Kill(); - } + public override void AI() + { + Player player = Main.player[projectile.owner]; + projectile.ai[1]++; + Lighting.AddLight(projectile.Center, 0.05f, 0.4f, 0f); + if (projectile.ai[1] < 60f) + { + if (projectile.ai[0] > 7f) + { + float scalar = 1f; + if (projectile.ai[0] == 8f) + { + scalar = 0.25f; + } + else if (projectile.ai[0] == 9f) + { + scalar = 0.5f; + } + else if (projectile.ai[0] == 10f) + { + scalar = 0.75f; + } + projectile.ai[0] += 1f; + if (projectile.ai[0] % 2f == 0f) + { + int spawnX = (int)(projectile.width / 2); + int spawnY = (int)(projectile.width / 2); + int bee = Projectile.NewProjectile(projectile.Center.X + (float)Main.rand.Next(-spawnX, spawnX), projectile.Center.Y + (float)Main.rand.Next(-spawnY, spawnY), projectile.velocity.X, projectile.velocity.Y, player.beeType(), player.beeDamage(projectile.damage / 3), player.beeKB(0f), projectile.owner); + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].Calamity().forceMelee = true; + Main.projectile[bee].penetrate = 1; + } + } + //Dust + int dustType = 89; + int plague = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[plague]; + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 1.8f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 1.3f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= scalar; + } + else + { + projectile.ai[0] += 1f; + } + } + else + { + projectile.damage = (int)(projectile.damage * 0.6); + projectile.velocity *= 0.85f; + //Fade out + if (projectile.alpha < 255) + projectile.alpha += 5; + if (projectile.alpha >= 255) + projectile.Kill(); + } - //Rotation - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); + //Rotation + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - //Animation - projectile.frameCounter++; - if (projectile.frameCounter > 8) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; - } - } + //Animation + projectile.frameCounter++; + if (projectile.frameCounter > 8) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + { + projectile.frame = 0; + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 8; - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 8; + target.AddBuff(ModContent.BuffType(), 180); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Melee/PlagueDust.cs b/Projectiles/Melee/PlagueDust.cs index b67a157084..8ebbaa6664 100644 --- a/Projectiles/Melee/PlagueDust.cs +++ b/Projectiles/Melee/PlagueDust.cs @@ -6,113 +6,113 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class PlagueDust : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Dust"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public class PlagueDust : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Dust"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 70; - projectile.height = 70; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.melee = true; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.timeLeft = 150; - projectile.alpha = 100; - } + public override void SetDefaults() + { + projectile.width = 70; + projectile.height = 70; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.melee = true; + projectile.penetrate = -1; + projectile.extraUpdates = 3; + projectile.timeLeft = 150; + projectile.alpha = 100; + } - public override void AI() - { - projectile.ai[1]++; - Lighting.AddLight(projectile.Center, 0.05f, 0.4f, 0f); - if (projectile.ai[1] < 60) - { - if (projectile.ai[0] > 7f) - { - float scalar = 1f; - if (projectile.ai[0] == 8f) - { - scalar = 0.25f; - } - else if (projectile.ai[0] == 9f) - { - scalar = 0.5f; - } - else if (projectile.ai[0] == 10f) - { - scalar = 0.75f; - } - projectile.ai[0] += 1f; - //Dust - int dustType = 89; - int plague = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[plague]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.8f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.3f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= scalar; - } - else - { - projectile.ai[0] += 1f; - } - } - else - { - projectile.damage = (int)(projectile.damage * 0.6); - projectile.velocity *= 0.85f; - //Fade out - if (projectile.alpha < 255) - projectile.alpha += 5; - if (projectile.alpha >= 255) - projectile.Kill(); - } - //Rotation - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); + public override void AI() + { + projectile.ai[1]++; + Lighting.AddLight(projectile.Center, 0.05f, 0.4f, 0f); + if (projectile.ai[1] < 60) + { + if (projectile.ai[0] > 7f) + { + float scalar = 1f; + if (projectile.ai[0] == 8f) + { + scalar = 0.25f; + } + else if (projectile.ai[0] == 9f) + { + scalar = 0.5f; + } + else if (projectile.ai[0] == 10f) + { + scalar = 0.75f; + } + projectile.ai[0] += 1f; + //Dust + int dustType = 89; + int plague = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[plague]; + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 1.8f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 1.3f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= scalar; + } + else + { + projectile.ai[0] += 1f; + } + } + else + { + projectile.damage = (int)(projectile.damage * 0.6); + projectile.velocity *= 0.85f; + //Fade out + if (projectile.alpha < 255) + projectile.alpha += 5; + if (projectile.alpha >= 255) + projectile.Kill(); + } + //Rotation + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - //Animation - projectile.frameCounter++; - if (projectile.frameCounter > 8) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; - } - } + //Animation + projectile.frameCounter++; + if (projectile.frameCounter > 8) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + { + projectile.frame = 0; + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 5; - target.AddBuff(ModContent.BuffType(), 120); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 5; + target.AddBuff(ModContent.BuffType(), 120); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Melee/PlagueSeeker.cs b/Projectiles/Melee/PlagueSeeker.cs index 350b6a36af..fb7f6ff7f8 100644 --- a/Projectiles/Melee/PlagueSeeker.cs +++ b/Projectiles/Melee/PlagueSeeker.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class PlagueSeeker : ModProjectile + public class PlagueSeeker : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -18,30 +18,30 @@ namespace CalamityMod.Projectiles.Melee projectile.width = 4; projectile.height = 4; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.melee = true; projectile.timeLeft = 180; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } - // Reduce damage of projectiles if more than the cap are active - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; - int cap = 3; - int oldDamage = damage; - if (projectileCount > cap) - { - damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); - if (damage < 1) - damage = 1; - } - } + // Reduce damage of projectiles if more than the cap are active + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; + int cap = 3; + int oldDamage = damage; + if (projectileCount > cap) + { + damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); + if (damage < 1) + damage = 1; + } + } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f) @@ -54,13 +54,13 @@ namespace CalamityMod.Projectiles.Melee } } - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 180); } - } + } } diff --git a/Projectiles/Melee/PrismRay.cs b/Projectiles/Melee/PrismRay.cs index 7633d8682d..079bbbb8df 100644 --- a/Projectiles/Melee/PrismRay.cs +++ b/Projectiles/Melee/PrismRay.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Melee projectile.friendly = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.melee = true; + projectile.melee = true; } public override void AI() @@ -97,13 +97,13 @@ namespace CalamityMod.Projectiles.Melee projectile.Kill(); } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { float _ = 0f; - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), StartingPosition, projectile.Center, projectile.scale * 22f, ref _); - } + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), StartingPosition, projectile.Center, projectile.scale * 22f, ref _); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Vector2 baseDrawPosition = projectile.Center + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; Texture2D texture = Main.projectileTexture[projectile.type]; diff --git a/Projectiles/Melee/PrismTooth.cs b/Projectiles/Melee/PrismTooth.cs index ca657dbc22..05a7dac1e0 100644 --- a/Projectiles/Melee/PrismTooth.cs +++ b/Projectiles/Melee/PrismTooth.cs @@ -9,137 +9,137 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class PrismTooth : ModProjectile - { - internal PrimitiveTrail TrailDrawer; - public const int Lifetime = 80; - public Player Owner => Main.player[projectile.owner]; - public ref float ShootReach => ref projectile.ai[0]; - public ref float Time => ref projectile.ai[1]; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Photon Ripper"); - ProjectileID.Sets.TrailingMode[projectile.type] = 2; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 36; - } + public class PrismTooth : ModProjectile + { + internal PrimitiveTrail TrailDrawer; + public const int Lifetime = 80; + public Player Owner => Main.player[projectile.owner]; + public ref float ShootReach => ref projectile.ai[0]; + public ref float Time => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Photon Ripper"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 36; + } - public override void SetDefaults() - { - projectile.width = 30; - projectile.height = 52; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.extraUpdates = 5; - projectile.usesIDStaticNPCImmunity = true; - // THIS IS INTENTIONALLY VERY LOW. Do not increase this; it is essential for Photon Ripper to function properly. - projectile.idStaticNPCHitCooldown = 4; - projectile.timeLeft = Lifetime; - projectile.melee = true; - } + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 52; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.extraUpdates = 5; + projectile.usesIDStaticNPCImmunity = true; + // THIS IS INTENTIONALLY VERY LOW. Do not increase this; it is essential for Photon Ripper to function properly. + projectile.idStaticNPCHitCooldown = 4; + projectile.timeLeft = Lifetime; + projectile.melee = true; + } - public override void AI() - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi * Time / Lifetime; + public override void AI() + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi * Time / Lifetime; - Vector2 baseDirection = (MathHelper.TwoPi * Time / Lifetime - MathHelper.PiOver2).ToRotationVector2(); - baseDirection.X *= 0.25f; + Vector2 baseDirection = (MathHelper.TwoPi * Time / Lifetime - MathHelper.PiOver2).ToRotationVector2(); + baseDirection.X *= 0.25f; - // Constrain the Y offset into the bounds of 0-1 instead of -1-1. This prevents - // the crystal from flying behind the owner. In this context, the Y offset becomes how far away the - // crystal is from its own in terms of reach. - baseDirection.Y = baseDirection.Y * 0.5f + 0.5f; - Vector2 positionOffset = baseDirection * ShootReach; + // Constrain the Y offset into the bounds of 0-1 instead of -1-1. This prevents + // the crystal from flying behind the owner. In this context, the Y offset becomes how far away the + // crystal is from its own in terms of reach. + baseDirection.Y = baseDirection.Y * 0.5f + 0.5f; + Vector2 positionOffset = baseDirection * ShootReach; - // Don't allow the X offset to go too far. - // This hard limit turns the squashed circle into bending, semi-rectangular shape. - if (Math.Abs(positionOffset.X) > 45f) - positionOffset.X = Math.Sign(baseDirection.X) * 45f; + // Don't allow the X offset to go too far. + // This hard limit turns the squashed circle into bending, semi-rectangular shape. + if (Math.Abs(positionOffset.X) > 45f) + positionOffset.X = Math.Sign(baseDirection.X) * 45f; - // In this context, the velocity is simply the initial direction as a unit vector- it does not - // actually influence movement in any way. - positionOffset = positionOffset.RotatedBy(projectile.velocity.ToRotation() - MathHelper.PiOver2); + // In this context, the velocity is simply the initial direction as a unit vector- it does not + // actually influence movement in any way. + positionOffset = positionOffset.RotatedBy(projectile.velocity.ToRotation() - MathHelper.PiOver2); - projectile.Center = Owner.RotatedRelativePoint(Owner.MountedCenter) + projectile.velocity * 42f + positionOffset; - projectile.Opacity = Utils.InverseLerp(0f, 12f, Time, true) * Utils.InverseLerp(Lifetime, Lifetime - 12f, Lifetime - projectile.timeLeft, true); + projectile.Center = Owner.RotatedRelativePoint(Owner.MountedCenter) + projectile.velocity * 42f + positionOffset; + projectile.Opacity = Utils.InverseLerp(0f, 12f, Time, true) * Utils.InverseLerp(Lifetime, Lifetime - 12f, Lifetime - projectile.timeLeft, true); - // Destroy trees within the range of the past 20 oldPos positions. - for (int i = 0; i < 20; i++) - { - Point pointToCheck = (projectile.oldPos[i] + projectile.Size * 0.5f).ToTileCoordinates(); - AbsolutelyFuckingAnnihilateTrees(pointToCheck.X, pointToCheck.Y); - } + // Destroy trees within the range of the past 20 oldPos positions. + for (int i = 0; i < 20; i++) + { + Point pointToCheck = (projectile.oldPos[i] + projectile.Size * 0.5f).ToTileCoordinates(); + AbsolutelyFuckingAnnihilateTrees(pointToCheck.X, pointToCheck.Y); + } - // Emit light. - Lighting.AddLight(projectile.Center, Vector3.One * 0.7f); + // Emit light. + Lighting.AddLight(projectile.Center, Vector3.One * 0.7f); - Time++; - } + Time++; + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projectile.RotatingHitboxCollision(targetHitbox.TopLeft(), targetHitbox.Size()); + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projectile.RotatingHitboxCollision(targetHitbox.TopLeft(), targetHitbox.Size()); - public void AbsolutelyFuckingAnnihilateTrees(int x, int y) - { - Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); + public void AbsolutelyFuckingAnnihilateTrees(int x, int y) + { + Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); - // Ignore tiles that are not active and are not breakable by axes. - if (!tileAtPosition.active() || !Main.tileAxe[tileAtPosition.type]) - return; + // Ignore tiles that are not active and are not breakable by axes. + if (!tileAtPosition.active() || !Main.tileAxe[tileAtPosition.type]) + return; - // Don't attempt to mine the tile if for whatever reason it's not supposed to be broken. - if (!WorldGen.CanKillTile(x, y)) - return; + // Don't attempt to mine the tile if for whatever reason it's not supposed to be broken. + if (!WorldGen.CanKillTile(x, y)) + return; - AchievementsHelper.CurrentlyMining = true; + AchievementsHelper.CurrentlyMining = true; - WorldGen.KillTile(x, y); - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, x, y); + WorldGen.KillTile(x, y); + if (Main.netMode == NetmodeID.MultiplayerClient) + NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, x, y); - AchievementsHelper.CurrentlyMining = false; - } + AchievementsHelper.CurrentlyMining = false; + } - public override Color? GetAlpha(Color lightColor) => Color.White; + public override Color? GetAlpha(Color lightColor) => Color.White; - internal float WidthFunction(float completionRatio) => projectile.scale * 24f * (1f - Utils.InverseLerp(0.7f, 1f, completionRatio, true)) + 1f; + internal float WidthFunction(float completionRatio) => projectile.scale * 24f * (1f - Utils.InverseLerp(0.7f, 1f, completionRatio, true)) + 1f; - internal Color ColorFunction(float completionRatio) - { - float hue = (projectile.identity % 9f / 9f + completionRatio * 0.7f) % 1f; - return Color.Lerp(Color.White, Main.hslToRgb(hue, 0.95f, 0.55f), 0.35f) * projectile.Opacity; - } + internal Color ColorFunction(float completionRatio) + { + float hue = (projectile.identity % 9f / 9f + completionRatio * 0.7f) % 1f; + return Color.Lerp(Color.White, Main.hslToRgb(hue, 0.95f, 0.55f), 0.35f) * projectile.Opacity; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (Time <= 5f) - return true; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (Time <= 5f) + return true; - if (TrailDrawer is null) - TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:PrismaticStreak"]); + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:PrismaticStreak"]); - // Variable adjustment vector used to prevent the trail for starting somewhat that isn't behind - // the crystal. This may appear in small amounts, with offsets of a few pixels, but at the speed - // these crystals go, it's probably not something to worry too much about. - Vector2 generalOffset = projectile.rotation.ToRotationVector2().RotatedBy(MathHelper.PiOver2) * 15f; - generalOffset += projectile.rotation.ToRotationVector2() * -5f * (float)Math.Sin(projectile.rotation); + // Variable adjustment vector used to prevent the trail for starting somewhat that isn't behind + // the crystal. This may appear in small amounts, with offsets of a few pixels, but at the speed + // these crystals go, it's probably not something to worry too much about. + Vector2 generalOffset = projectile.rotation.ToRotationVector2().RotatedBy(MathHelper.PiOver2) * 15f; + generalOffset += projectile.rotation.ToRotationVector2() * -5f * (float)Math.Sin(projectile.rotation); - // Mess with the oldPos array so that the trail always points towards the crystal. - Vector2 oldPosition = projectile.oldPos[1]; - projectile.oldPos[1] = projectile.oldPos[0] - projectile.rotation.ToRotationVector2() * Vector2.Distance(projectile.oldPos[0], projectile.oldPos[1]); + // Mess with the oldPos array so that the trail always points towards the crystal. + Vector2 oldPosition = projectile.oldPos[1]; + projectile.oldPos[1] = projectile.oldPos[0] - projectile.rotation.ToRotationVector2() * Vector2.Distance(projectile.oldPos[0], projectile.oldPos[1]); - // Revert back if the above calculations caused any NaNs. - if (projectile.oldPos[1].HasNaNs()) - projectile.oldPos[1] = oldPosition; + // Revert back if the above calculations caused any NaNs. + if (projectile.oldPos[1].HasNaNs()) + projectile.oldPos[1] = oldPosition; - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:PrismaticStreak"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak")); + spriteBatch.EnterShaderRegion(); + GameShaders.Misc["CalamityMod:PrismaticStreak"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak")); - TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f + generalOffset - Main.screenPosition, 65); - spriteBatch.ExitShaderRegion(); - return true; - } + TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f + generalOffset - Main.screenPosition, 65); + spriteBatch.ExitShaderRegion(); + return true; + } - // Prevent the crystals from utilizing velocity. Their movement is entirely dependant on Center setting. - public override bool ShouldUpdatePosition() => false; - } + // Prevent the crystals from utilizing velocity. Their movement is entirely dependant on Center setting. + public override bool ShouldUpdatePosition() => false; + } } diff --git a/Projectiles/Melee/PrismaticBeam.cs b/Projectiles/Melee/PrismaticBeam.cs index f24f1331a1..f8969e4369 100644 --- a/Projectiles/Melee/PrismaticBeam.cs +++ b/Projectiles/Melee/PrismaticBeam.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class PrismaticBeam : BaseLaserbeamProjectile + public class PrismaticBeam : BaseLaserbeamProjectile { public override string Texture => "CalamityMod/Projectiles/Magic/YharimsCrystalBeam"; @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Melee } public override void DetermineScale() - { + { projectile.scale = Time < ChargeupTime ? 0f : Utils.InverseLerp(0f, 40f, projectile.timeLeft, true) * MaxScale; } diff --git a/Projectiles/Melee/PrismaticWave.cs b/Projectiles/Melee/PrismaticWave.cs index 9ba706520d..5d2c8c9652 100644 --- a/Projectiles/Melee/PrismaticWave.cs +++ b/Projectiles/Melee/PrismaticWave.cs @@ -10,33 +10,33 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class PrismaticWave : ModProjectile + public class PrismaticWave : ModProjectile { private int alpha = 50; - public Color[] colors = new Color[] - { - new Color(255, 0, 0, 50), //Red - new Color(255, 128, 0, 50), //Orange - new Color(255, 255, 0, 50), //Yellow - new Color(128, 255, 0, 50), //Lime - new Color(0, 255, 0, 50), //Green - new Color(0, 255, 128, 50), //Turquoise - new Color(0, 255, 255, 50), //Cyan - new Color(0, 128, 255, 50), //Light Blue - new Color(0, 0, 255, 50), //Blue - new Color(128, 0, 255, 50), //Purple - new Color(255, 0, 255, 50), //Fuschia - new Color(255, 0, 128, 50) //Hot Pink - }; - List colorSet = new List() - { - new Color(255, 0, 0, 50), //Red - new Color(255, 255, 0, 50), //Yellow - new Color(0, 255, 0, 50), //Green - new Color(0, 255, 255, 50), //Cyan - new Color(0, 0, 255, 50), //Blue - new Color(255, 0, 255, 50), //Fuschia - }; + public Color[] colors = new Color[] + { + new Color(255, 0, 0, 50), //Red + new Color(255, 128, 0, 50), //Orange + new Color(255, 255, 0, 50), //Yellow + new Color(128, 255, 0, 50), //Lime + new Color(0, 255, 0, 50), //Green + new Color(0, 255, 128, 50), //Turquoise + new Color(0, 255, 255, 50), //Cyan + new Color(0, 128, 255, 50), //Light Blue + new Color(0, 0, 255, 50), //Blue + new Color(128, 0, 255, 50), //Purple + new Color(255, 0, 255, 50), //Fuschia + new Color(255, 0, 128, 50) //Hot Pink + }; + List colorSet = new List() + { + new Color(255, 0, 0, 50), //Red + new Color(255, 255, 0, 50), //Yellow + new Color(0, 255, 0, 50), //Green + new Color(0, 255, 255, 50), //Cyan + new Color(0, 0, 255, 50), //Blue + new Color(255, 0, 255, 50), //Fuschia + }; public override void SetStaticDefaults() { @@ -52,10 +52,10 @@ namespace CalamityMod.Projectiles.Melee projectile.friendly = true; projectile.ignoreWater = true; projectile.ranged = true; - projectile.melee = true; + projectile.melee = true; projectile.penetrate = 3; projectile.timeLeft = 360; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } @@ -97,48 +97,48 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.NextBool(2)) { int rainbow = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 267, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, alpha, Main.rand.Next(colors)); - Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].noGravity = true; } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 355) - return false; + if (projectile.timeLeft > 355) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); return false; } public override Color? GetAlpha(Color lightColor) - { - int colorIndex = (int)(Main.GlobalTime / 2 % colorSet.Count); - Color currentColor = colorSet[colorIndex]; - Color nextColor = colorSet[(colorIndex + 1) % colorSet.Count]; - return Color.Lerp(currentColor, nextColor, Main.GlobalTime % 2f > 1f ? 1f : Main.GlobalTime % 1f); - } + { + int colorIndex = (int)(Main.GlobalTime / 2 % colorSet.Count); + Color currentColor = colorSet[colorIndex]; + Color nextColor = colorSet[(colorIndex + 1) % colorSet.Count]; + return Color.Lerp(currentColor, nextColor, Main.GlobalTime % 2f > 1f ? 1f : Main.GlobalTime % 1f); + } public override void Kill(int timeLeft) { for (int k = 0; k < 3; k++) { int rainbow = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 267, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f, alpha, Main.rand.Next(colors)); - Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].noGravity = true; } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 150); - target.AddBuff(BuffID.Daybreak, 150); - projectile.velocity *= 0.75f; + target.AddBuff(ModContent.BuffType(), 150); + target.AddBuff(BuffID.Daybreak, 150); + projectile.velocity *= 0.75f; } public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 150); - target.AddBuff(BuffID.Daybreak, 150); - projectile.velocity *= 0.75f; + target.AddBuff(ModContent.BuffType(), 150); + target.AddBuff(BuffID.Daybreak, 150); + projectile.velocity *= 0.75f; } } } diff --git a/Projectiles/Melee/ProfanedSwordProj.cs b/Projectiles/Melee/ProfanedSwordProj.cs index b579ec3874..ed2cd7bc35 100644 --- a/Projectiles/Melee/ProfanedSwordProj.cs +++ b/Projectiles/Melee/ProfanedSwordProj.cs @@ -8,11 +8,11 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ProfanedSwordProj : ModProjectile + public class ProfanedSwordProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/ProfanedSword"; - private int explosionCount = 0; + private int explosionCount = 0; public override void SetStaticDefaults() { DisplayName.SetDefault("Profaned Sword"); @@ -45,10 +45,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 595) - return false; + if (projectile.timeLeft > 595) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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; } @@ -65,18 +65,18 @@ namespace CalamityMod.Projectiles.Melee { target.immune[projectile.owner] = 6; target.AddBuff(ModContent.BuffType(), 180); - if (Main.myPlayer == 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; + if (Main.myPlayer == 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/PwnagehammerEcho.cs b/Projectiles/Melee/PwnagehammerEcho.cs index 6b9a5e5cfa..a07ec9c167 100644 --- a/Projectiles/Melee/PwnagehammerEcho.cs +++ b/Projectiles/Melee/PwnagehammerEcho.cs @@ -8,152 +8,152 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class PwnagehammerEcho : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pwnagehammer Echo"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 7; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public class PwnagehammerEcho : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pwnagehammer Echo"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 7; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 40; - projectile.height = 40; - projectile.aiStyle = 0; - projectile.friendly = true; - projectile.melee = true; - projectile.penetrate = 1; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.usesLocalNPCImmunity = true; - } + public override void SetDefaults() + { + projectile.width = 40; + projectile.height = 40; + projectile.aiStyle = 0; + projectile.friendly = true; + projectile.melee = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.usesLocalNPCImmunity = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, 248, 124, 255); - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(255, 248, 124, 255); + } - public override void AI() - { - projectile.ai[0] += 1f; - if (projectile.ai[0] < 42f) - { - projectile.velocity.Y *= 0.9575f; - projectile.rotation += MathHelper.ToRadians(projectile.ai[0] * 0.5f) * projectile.localAI[0]; - } - else if (projectile.ai[0] < 44f) - { - if (projectile.ai[1] < 0f) - { - projectile.Kill(); - return; - } + public override void AI() + { + projectile.ai[0] += 1f; + if (projectile.ai[0] < 42f) + { + projectile.velocity.Y *= 0.9575f; + projectile.rotation += MathHelper.ToRadians(projectile.ai[0] * 0.5f) * projectile.localAI[0]; + } + else if (projectile.ai[0] < 44f) + { + if (projectile.ai[1] < 0f) + { + projectile.Kill(); + return; + } - NPC target = Main.npc[(int)projectile.ai[1]]; - if (!target.CanBeChasedBy(projectile, false) || !target.active) - projectile.Kill(); - else - { - float velConst = 3f; - projectile.velocity = new Vector2((target.Center.X - projectile.Center.X) / velConst, (target.Center.Y - projectile.Center.Y) / velConst); - projectile.rotation += MathHelper.ToRadians(48f) * projectile.localAI[0]; - } - } + NPC target = Main.npc[(int)projectile.ai[1]]; + if (!target.CanBeChasedBy(projectile, false) || !target.active) + projectile.Kill(); + else + { + float velConst = 3f; + projectile.velocity = new Vector2((target.Center.X - projectile.Center.X) / velConst, (target.Center.Y - projectile.Center.Y) / velConst); + projectile.rotation += MathHelper.ToRadians(48f) * projectile.localAI[0]; + } + } - if (Main.rand.NextBool(2)) - { - Vector2 offset = new Vector2(7, 0).RotatedByRandom(MathHelper.ToRadians(360f)); - Vector2 velOffset = new Vector2(3, 0).RotatedBy(offset.ToRotation()); - Dust dust = Dust.NewDustPerfect(new Vector2(projectile.position.X, projectile.position.Y) + offset, DustID.GoldFlame, new Vector2(projectile.velocity.X * 0.2f + velOffset.X, projectile.velocity.Y * 0.2f + velOffset.Y), 100, new Color(255, 245, 198), 2f); - dust.noGravity = true; - } + if (Main.rand.NextBool(2)) + { + Vector2 offset = new Vector2(7, 0).RotatedByRandom(MathHelper.ToRadians(360f)); + Vector2 velOffset = new Vector2(3, 0).RotatedBy(offset.ToRotation()); + Dust dust = Dust.NewDustPerfect(new Vector2(projectile.position.X, projectile.position.Y) + offset, DustID.GoldFlame, new Vector2(projectile.velocity.X * 0.2f + velOffset.X, projectile.velocity.Y * 0.2f + velOffset.Y), 100, new Color(255, 245, 198), 2f); + dust.noGravity = true; + } - if (Main.rand.NextBool(6)) - { - Vector2 offset = new Vector2(7, 0).RotatedByRandom(MathHelper.ToRadians(360f)); - Vector2 velOffset = new Vector2(3, 0).RotatedBy(offset.ToRotation()); - Dust dust = Dust.NewDustPerfect(new Vector2(projectile.position.X, projectile.position.Y) + offset, DustID.GoldFlame, new Vector2(projectile.velocity.X * 0.2f + velOffset.X, projectile.velocity.Y * 0.2f + velOffset.Y), 100, new Color(255, 245, 198), 2f); - dust.noGravity = true; - } - } + if (Main.rand.NextBool(6)) + { + Vector2 offset = new Vector2(7, 0).RotatedByRandom(MathHelper.ToRadians(360f)); + Vector2 velOffset = new Vector2(3, 0).RotatedBy(offset.ToRotation()); + Dust dust = Dust.NewDustPerfect(new Vector2(projectile.position.X, projectile.position.Y) + offset, DustID.GoldFlame, new Vector2(projectile.velocity.X * 0.2f + velOffset.X, projectile.velocity.Y * 0.2f + velOffset.Y), 100, new Color(255, 245, 198), 2f); + dust.noGravity = true; + } + } - public override bool? CanHitNPC(NPC target) - { - if (projectile.ai[0] <= 42f) - return false; - return null; - } + public override bool? CanHitNPC(NPC target) + { + if (projectile.ai[0] <= 42f) + return false; + return null; + } - public override bool CanHitPvp(Player target) => projectile.ai[0] > 42f; + public override bool CanHitPvp(Player target) => projectile.ai[0] > 42f; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - projectile.localAI[0] = target.whoAmI; - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + projectile.localAI[0] = target.whoAmI; + } - public override bool PreKill(int timeLeft) - { - Player player = Main.player[projectile.owner]; + public override bool PreKill(int timeLeft) + { + Player player = Main.player[projectile.owner]; - float numberOfDusts = 32f; - float rotFactor = 360f / numberOfDusts; - for (int i = 0; i < numberOfDusts; i++) - { - float rot = MathHelper.ToRadians(i * rotFactor); - Vector2 offset = new Vector2(15f, 0).RotatedBy(rot); - Vector2 velOffset = new Vector2(12.5f, 0).RotatedBy(rot); - int dust = Dust.NewDust(projectile.position + offset, projectile.width, projectile.height, 269, velOffset.X, velOffset.Y); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity = velOffset; - Main.dust[dust].scale = 2.5f; - } + float numberOfDusts = 32f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(15f, 0).RotatedBy(rot); + Vector2 velOffset = new Vector2(12.5f, 0).RotatedBy(rot); + int dust = Dust.NewDust(projectile.position + offset, projectile.width, projectile.height, 269, velOffset.X, velOffset.Y); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity = velOffset; + Main.dust[dust].scale = 2.5f; + } - float distance = 168f; + float distance = 168f; - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - Vector2 vec = npc.Center - projectile.Center; - float distanceTo = (float)Math.Sqrt(vec.X * vec.X + vec.Y * vec.Y); - if (distanceTo < distance && npc.CanBeChasedBy(projectile, false) && k != projectile.localAI[0]) - { - float alldamage = projectile.damage * 0.5f; - double damage = npc.StrikeNPC((int)alldamage, projectile.knockBack, projectile.velocity.X > 0f ? 1 : -1, true); - player.addDPS((int)damage); - } - } - return false; - } + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + Vector2 vec = npc.Center - projectile.Center; + float distanceTo = (float)Math.Sqrt(vec.X * vec.X + vec.Y * vec.Y); + if (distanceTo < distance && npc.CanBeChasedBy(projectile, false) && k != projectile.localAI[0]) + { + float alldamage = projectile.damage * 0.5f; + double damage = npc.StrikeNPC((int)alldamage, projectile.knockBack, projectile.velocity.X > 0f ? 1 : -1, true); + player.addDPS((int)damage); + } + } + return false; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture = Main.projectileTexture[projectile.type]; - Rectangle sourceRectangle = new Rectangle(0, 0, texture.Width, texture.Height); - Vector2 origin = sourceRectangle.Size() / 2f; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + Texture2D texture = Main.projectileTexture[projectile.type]; + Rectangle sourceRectangle = new Rectangle(0, 0, texture.Width, texture.Height); + Vector2 origin = sourceRectangle.Size() / 2f; - for (int i = 0; i < projectile.oldPos.Length; i++) - { - float rot = MathHelper.ToRadians(22.5f) * Math.Sign(projectile.velocity.X); - Vector2 drawPos = projectile.oldPos[i] - Main.screenPosition + origin + new Vector2(0f, projectile.gfxOffY); - Color color = projectile.GetAlpha(lightColor) * ((projectile.oldPos.Length - i) / (float)projectile.oldPos.Length); - spriteBatch.Draw(texture, drawPos, new Rectangle?(), color, projectile.rotation - i * rot, origin, projectile.scale, spriteEffects, 0f); - } - return false; - } - } + for (int i = 0; i < projectile.oldPos.Length; i++) + { + float rot = MathHelper.ToRadians(22.5f) * Math.Sign(projectile.velocity.X); + Vector2 drawPos = projectile.oldPos[i] - Main.screenPosition + origin + new Vector2(0f, projectile.gfxOffY); + Color color = projectile.GetAlpha(lightColor) * ((projectile.oldPos.Length - i) / (float)projectile.oldPos.Length); + spriteBatch.Draw(texture, drawPos, new Rectangle?(), color, projectile.rotation - i * rot, origin, projectile.scale, spriteEffects, 0f); + } + return false; + } + } } \ No newline at end of file diff --git a/Projectiles/Melee/PwnagehammerProj.cs b/Projectiles/Melee/PwnagehammerProj.cs index c9e603ffae..02a00c8cc1 100644 --- a/Projectiles/Melee/PwnagehammerProj.cs +++ b/Projectiles/Melee/PwnagehammerProj.cs @@ -9,225 +9,225 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class PwnagehammerProj : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Melee/PwnagehammerMelee"; + public class PwnagehammerProj : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/PwnagehammerMelee"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pwnagehammer"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pwnagehammer"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 40; - projectile.friendly = true; - projectile.timeLeft = 3600; - projectile.melee = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 40; + projectile.friendly = true; + projectile.timeLeft = 3600; + projectile.melee = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + } - public override void AI() - { - projectile.direction = projectile.spriteDirection = projectile.velocity.X > 0f ? 1 : -1; - projectile.rotation += MathHelper.ToRadians(22.5f) * projectile.direction; + public override void AI() + { + projectile.direction = projectile.spriteDirection = projectile.velocity.X > 0f ? 1 : -1; + projectile.rotation += MathHelper.ToRadians(22.5f) * projectile.direction; - if (projectile.ai[0] == 1f) - { - float distance = 400f; - if (projectile.ai[1] == -1) - { - // used for finding a target - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false)) - { - Vector2 vec = npc.Center - projectile.Center; - float distanceTo = vec.Length(); - distanceTo -= (float)Math.Sqrt(npc.width * npc.width + npc.height * npc.height) * 0.75f; - if (distanceTo < distance && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) - projectile.ai[1] = i; - } - } - } - else - { - int index = (int)projectile.ai[1]; - float speed = 34f; - float inertia = 15f; + if (projectile.ai[0] == 1f) + { + float distance = 400f; + if (projectile.ai[1] == -1) + { + // used for finding a target + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + Vector2 vec = npc.Center - projectile.Center; + float distanceTo = vec.Length(); + distanceTo -= (float)Math.Sqrt(npc.width * npc.width + npc.height * npc.height) * 0.75f; + if (distanceTo < distance && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + projectile.ai[1] = i; + } + } + } + else + { + int index = (int)projectile.ai[1]; + float speed = 34f; + float inertia = 15f; - if (!Main.npc[index].CanBeChasedBy(projectile, false)) - projectile.ai[1] = -1; + if (!Main.npc[index].CanBeChasedBy(projectile, false)) + projectile.ai[1] = -1; - Vector2 direction = Main.npc[index].Center - projectile.Center; - direction.Normalize(); - direction *= speed; - projectile.velocity = (projectile.velocity * (inertia - 1) + direction) / inertia; - } - } - else - { - projectile.velocity.X *= 0.9711f; - projectile.velocity.Y += 0.426f; - } + Vector2 direction = Main.npc[index].Center - projectile.Center; + direction.Normalize(); + direction *= speed; + projectile.velocity = (projectile.velocity * (inertia - 1) + direction) / inertia; + } + } + else + { + projectile.velocity.X *= 0.9711f; + projectile.velocity.Y += 0.426f; + } - if (Main.rand.NextBool(2)) - { - Vector2 offset = new Vector2(12, 0).RotatedByRandom(MathHelper.ToRadians(360f)); - Vector2 velOffset = new Vector2(4, 0).RotatedBy(offset.ToRotation()); - Dust dust = Dust.NewDustPerfect(new Vector2(projectile.Center.X, projectile.Center.Y) + offset, DustID.GoldFlame, new Vector2(projectile.velocity.X * 0.2f + velOffset.X, projectile.velocity.Y * 0.2f + velOffset.Y), 100, new Color(255, 245, 198), 2f); - dust.noGravity = true; - } + if (Main.rand.NextBool(2)) + { + Vector2 offset = new Vector2(12, 0).RotatedByRandom(MathHelper.ToRadians(360f)); + Vector2 velOffset = new Vector2(4, 0).RotatedBy(offset.ToRotation()); + Dust dust = Dust.NewDustPerfect(new Vector2(projectile.Center.X, projectile.Center.Y) + offset, DustID.GoldFlame, new Vector2(projectile.velocity.X * 0.2f + velOffset.X, projectile.velocity.Y * 0.2f + velOffset.Y), 100, new Color(255, 245, 198), 2f); + dust.noGravity = true; + } - if (Main.rand.NextBool(6)) - { - Vector2 offset = new Vector2(12, 0).RotatedByRandom(MathHelper.ToRadians(360f)); - Vector2 velOffset = new Vector2(4, 0).RotatedBy(offset.ToRotation()); - Dust dust = Dust.NewDustPerfect(new Vector2(projectile.Center.X, projectile.Center.Y) + offset, DustID.GoldFlame, new Vector2(projectile.velocity.X * 0.2f + velOffset.X, projectile.velocity.Y * 0.2f + velOffset.Y), 100, new Color(255, 245, 198), 2f); - dust.noGravity = true; - } - } + if (Main.rand.NextBool(6)) + { + Vector2 offset = new Vector2(12, 0).RotatedByRandom(MathHelper.ToRadians(360f)); + Vector2 velOffset = new Vector2(4, 0).RotatedBy(offset.ToRotation()); + Dust dust = Dust.NewDustPerfect(new Vector2(projectile.Center.X, projectile.Center.Y) + offset, DustID.GoldFlame, new Vector2(projectile.velocity.X * 0.2f + velOffset.X, projectile.velocity.Y * 0.2f + velOffset.Y), 100, new Color(255, 245, 198), 2f); + dust.noGravity = true; + } + } - public override void Kill(int timeLeft) - { - Player player = Main.player[projectile.owner]; - if (projectile.ai[0] == 1f) - { - float numberOfDusts = 40f; - float rotFactor = 360f / numberOfDusts; - for (int i = 0; i < numberOfDusts; i++) - { - float rot = MathHelper.ToRadians(i * rotFactor); - Vector2 offset = new Vector2(15f, 0).RotatedBy(rot); - Vector2 velOffset = new Vector2(10f, 0).RotatedBy(rot); - Dust dust = Dust.NewDustPerfect(projectile.position + offset, 269, new Vector2(velOffset.X, velOffset.Y)); - dust.noGravity = true; - dust.velocity = velOffset; - dust.scale = 2.5f; - if (i % 2 == 0) - { - dust = Dust.NewDustPerfect(projectile.position + offset, 269, new Vector2(velOffset.X, velOffset.Y)); - dust.noGravity = true; - dust.velocity = velOffset * 2f; - dust.scale = 2.5f; - } - if (i % 4 == 0) - { - dust = Dust.NewDustPerfect(projectile.position + offset, 269, new Vector2(velOffset.X, velOffset.Y)); - dust.noGravity = true; - dust.velocity = velOffset / 2f; - dust.scale = 2.5f; - } - } + public override void Kill(int timeLeft) + { + Player player = Main.player[projectile.owner]; + if (projectile.ai[0] == 1f) + { + float numberOfDusts = 40f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(15f, 0).RotatedBy(rot); + Vector2 velOffset = new Vector2(10f, 0).RotatedBy(rot); + Dust dust = Dust.NewDustPerfect(projectile.position + offset, 269, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = true; + dust.velocity = velOffset; + dust.scale = 2.5f; + if (i % 2 == 0) + { + dust = Dust.NewDustPerfect(projectile.position + offset, 269, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = true; + dust.velocity = velOffset * 2f; + dust.scale = 2.5f; + } + if (i % 4 == 0) + { + dust = Dust.NewDustPerfect(projectile.position + offset, 269, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = true; + dust.velocity = velOffset / 2f; + dust.scale = 2.5f; + } + } - float distance = 240f; + float distance = 240f; - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - Vector2 vec = npc.Center - projectile.Center; - float distanceTo = (float)Math.Sqrt(vec.X * vec.X + vec.Y * vec.Y); - distanceTo -= (float)Math.Sqrt(npc.width * npc.width + npc.height * npc.height) * 0.75f; - if (distanceTo < distance && npc.CanBeChasedBy(projectile, false) && k != projectile.localAI[0]) - { - float alldamage = projectile.damage * 1.25f; - double damage = npc.StrikeNPC((int)alldamage, projectile.knockBack, projectile.velocity.X > 0f ? 1 : -1); - player.addDPS((int)damage); - } - } - SoundEffectInstance sound1 = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PwnagehammerHoming"), projectile.Center); - if (sound1 != null) - sound1.Volume = 0.3f; - SoundEffectInstance sound2 = Main.PlaySound(SoundID.Item14, projectile.Center); - if (sound2 != null) - sound2.Volume = 0.22f; - } - else - { - float numberOfDusts = 32f; - float rotFactor = 360f / numberOfDusts; - for (int i = 0; i < numberOfDusts; i++) - { - float rot = MathHelper.ToRadians(i * rotFactor); - Vector2 offset = new Vector2(15f, 0).RotatedBy(rot); - Vector2 velOffset = new Vector2(12.5f, 0).RotatedBy(rot); - Dust dust = Dust.NewDustPerfect(projectile.position + offset, 269, new Vector2(velOffset.X, velOffset.Y)); - dust.noGravity = true; - dust.velocity = velOffset; - dust.scale = 2.5f; - } + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + Vector2 vec = npc.Center - projectile.Center; + float distanceTo = (float)Math.Sqrt(vec.X * vec.X + vec.Y * vec.Y); + distanceTo -= (float)Math.Sqrt(npc.width * npc.width + npc.height * npc.height) * 0.75f; + if (distanceTo < distance && npc.CanBeChasedBy(projectile, false) && k != projectile.localAI[0]) + { + float alldamage = projectile.damage * 1.25f; + double damage = npc.StrikeNPC((int)alldamage, projectile.knockBack, projectile.velocity.X > 0f ? 1 : -1); + player.addDPS((int)damage); + } + } + SoundEffectInstance sound1 = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PwnagehammerHoming"), projectile.Center); + if (sound1 != null) + sound1.Volume = 0.3f; + SoundEffectInstance sound2 = Main.PlaySound(SoundID.Item14, projectile.Center); + if (sound2 != null) + sound2.Volume = 0.22f; + } + else + { + float numberOfDusts = 32f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(15f, 0).RotatedBy(rot); + Vector2 velOffset = new Vector2(12.5f, 0).RotatedBy(rot); + Dust dust = Dust.NewDustPerfect(projectile.position + offset, 269, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = true; + dust.velocity = velOffset; + dust.scale = 2.5f; + } - float distance = 168f; + float distance = 168f; - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - Vector2 vec = npc.Center - projectile.Center; - float distanceTo = (float)Math.Sqrt(vec.X * vec.X + vec.Y * vec.Y); - distanceTo -= (float)Math.Sqrt(npc.width * npc.width + npc.height * npc.height) * 0.75f; - if (distanceTo < distance && npc.CanBeChasedBy(projectile, false) && k != projectile.localAI[0]) - { - float alldamage = projectile.damage * 0.75f; - double damage = npc.StrikeNPC((int)alldamage, projectile.knockBack, projectile.velocity.X > 0f ? 1 : -1); - player.addDPS((int)damage); - } - } - SoundEffectInstance sound1 = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PwnagehammerSound"), projectile.Center); - if (sound1 != null) - { - sound1.Volume = 0.16f; - sound1.Pitch = Main.rand.NextFloat(-0.08f, 0.08f); - } - SoundEffectInstance sound2 = Main.PlaySound(SoundID.Item14, projectile.Center); - if (sound2 != null) - sound2.Volume = 0.11f; - } - } + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + Vector2 vec = npc.Center - projectile.Center; + float distanceTo = (float)Math.Sqrt(vec.X * vec.X + vec.Y * vec.Y); + distanceTo -= (float)Math.Sqrt(npc.width * npc.width + npc.height * npc.height) * 0.75f; + if (distanceTo < distance && npc.CanBeChasedBy(projectile, false) && k != projectile.localAI[0]) + { + float alldamage = projectile.damage * 0.75f; + double damage = npc.StrikeNPC((int)alldamage, projectile.knockBack, projectile.velocity.X > 0f ? 1 : -1); + player.addDPS((int)damage); + } + } + SoundEffectInstance sound1 = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PwnagehammerSound"), projectile.Center); + if (sound1 != null) + { + sound1.Volume = 0.16f; + sound1.Pitch = Main.rand.NextFloat(-0.08f, 0.08f); + } + SoundEffectInstance sound2 = Main.PlaySound(SoundID.Item14, projectile.Center); + if (sound2 != null) + sound2.Volume = 0.11f; + } + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.ai[0] == 1f && Main.myPlayer == projectile.owner) - { - crit = true; - int hammer = Projectile.NewProjectile(projectile.Center, new Vector2(0, -15f), ModContent.ProjectileType(), projectile.damage * 2, projectile.knockBack, projectile.owner, 0f, projectile.ai[1]); - Main.projectile[hammer].localAI[0] = Math.Sign(projectile.velocity.X); - Main.projectile[hammer].netUpdate = true; - } - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (projectile.ai[0] == 1f && Main.myPlayer == projectile.owner) + { + crit = true; + int hammer = Projectile.NewProjectile(projectile.Center, new Vector2(0, -15f), ModContent.ProjectileType(), projectile.damage * 2, projectile.knockBack, projectile.owner, 0f, projectile.ai[1]); + Main.projectile[hammer].localAI[0] = Math.Sign(projectile.velocity.X); + Main.projectile[hammer].netUpdate = true; + } + } - public override void ModifyHitPvp(Player target, ref int damage, ref bool crit) - { - if (projectile.ai[0] == 1f && Main.myPlayer == projectile.owner) - { - int hammer = Projectile.NewProjectile(projectile.Center, new Vector2(0, -15f), ModContent.ProjectileType(), projectile.damage * 2, projectile.knockBack, projectile.owner, 0f, projectile.ai[1]); - Main.projectile[hammer].localAI[0] = Math.Sign(projectile.velocity.X); - Main.projectile[hammer].netUpdate = true; - } - } + public override void ModifyHitPvp(Player target, ref int damage, ref bool crit) + { + if (projectile.ai[0] == 1f && Main.myPlayer == projectile.owner) + { + int hammer = Projectile.NewProjectile(projectile.Center, new Vector2(0, -15f), ModContent.ProjectileType(), projectile.damage * 2, projectile.knockBack, projectile.owner, 0f, projectile.ai[1]); + Main.projectile[hammer].localAI[0] = Math.Sign(projectile.velocity.X); + Main.projectile[hammer].netUpdate = true; + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - projectile.localAI[0] = target.whoAmI; - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + projectile.localAI[0] = target.whoAmI; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Melee/RainBolt.cs b/Projectiles/Melee/RainBolt.cs index f430295a54..10d3cbd221 100644 --- a/Projectiles/Melee/RainBolt.cs +++ b/Projectiles/Melee/RainBolt.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class RainBolt : ModProjectile + public class RainBolt : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,9 +23,9 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { if (projectile.localAI[0] == 0f) { @@ -37,13 +37,13 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num469].noGravity = true; Main.dust[num469].velocity *= 0f; - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); - else - projectile.velocity *= 0.95f; - } + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); + else + projectile.velocity *= 0.95f; + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item60, projectile.Center); for (int k = 0; k < 5; k++) diff --git a/Projectiles/Melee/RainbowBoom.cs b/Projectiles/Melee/RainbowBoom.cs index 32bf60c5d0..32f244db54 100644 --- a/Projectiles/Melee/RainbowBoom.cs +++ b/Projectiles/Melee/RainbowBoom.cs @@ -87,9 +87,9 @@ namespace CalamityMod.Projectiles.Melee } } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - projectile.damage = (int)(projectile.damage * 0.9); - } - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + projectile.damage = (int)(projectile.damage * 0.9); + } + } } diff --git a/Projectiles/Melee/Razorwind.cs b/Projectiles/Melee/Razorwind.cs index e4ec7e0036..5486f450fc 100644 --- a/Projectiles/Melee/Razorwind.cs +++ b/Projectiles/Melee/Razorwind.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class Razorwind : ModProjectile + public class Razorwind : ModProjectile { public override string Texture => "CalamityMod/Projectiles/TornadoProj"; @@ -53,12 +53,12 @@ namespace CalamityMod.Projectiles.Melee } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 12f, 20f); } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { for (int k = 0; k < 10; k++) { diff --git a/Projectiles/Melee/RedtideWhirlpool.cs b/Projectiles/Melee/RedtideWhirlpool.cs index 7afd3c5235..c613d11a32 100644 --- a/Projectiles/Melee/RedtideWhirlpool.cs +++ b/Projectiles/Melee/RedtideWhirlpool.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class RedtideWhirlpool : ModProjectile + public class RedtideWhirlpool : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/BrinyTyphoonBubble"; diff --git a/Projectiles/Melee/RemsRevengeProj.cs b/Projectiles/Melee/RemsRevengeProj.cs index 35e0063c29..32fb3af373 100644 --- a/Projectiles/Melee/RemsRevengeProj.cs +++ b/Projectiles/Melee/RemsRevengeProj.cs @@ -8,146 +8,146 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class RemsRevengeProj : ModProjectile - { - private int hitCounter = 0; + public class RemsRevengeProj : ModProjectile + { + private int hitCounter = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Rem's Revenge"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rem's Revenge"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 26; - projectile.height = 26; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.melee = true; - projectile.alpha = 255; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 15; - projectile.extraUpdates = 1; - projectile.scale = 2f; - projectile.tileCollide = false; - } + public override void SetDefaults() + { + projectile.width = 26; + projectile.height = 26; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.melee = true; + projectile.alpha = 255; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 15; + projectile.extraUpdates = 1; + projectile.scale = 2f; + projectile.tileCollide = false; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - Vector2 projVector = player.Center - projectile.Center; - projectile.rotation = projVector.ToRotation() - MathHelper.PiOver2; - if (player.dead) - { - projectile.Kill(); - return; - } - player.itemAnimation = 10; - player.itemTime = 10; - if (projVector.X < 0f) - { - player.ChangeDir(1); - projectile.direction = 1; - } - else - { - player.ChangeDir(-1); - projectile.direction = -1; - } - player.itemRotation = (projVector * -1f * (float)projectile.direction).ToRotation(); - projectile.spriteDirection = (projVector.X > 0f) ? -1 : 1; - if (projectile.ai[0] == 0f && projVector.Length() > 850f) - { - projectile.ai[0] = 1f; - } - if (projectile.ai[0] == 1f || projectile.ai[0] == 2f) - { - projectile.extraUpdates = 2; - float playerDist = projVector.Length(); - if (playerDist > 1500f) - { - projectile.Kill(); - return; - } - if (playerDist > 1000f) - { - projectile.ai[0] = 2f; - } - projectile.tileCollide = false; - float returnSpeed = 15f; - if (projectile.ai[0] == 2f) - { - returnSpeed = 30f; - } - projectile.velocity = Vector2.Normalize(projVector) * returnSpeed; - if (projVector.Length() < returnSpeed) - { - projectile.Kill(); - return; - } - } - projectile.ai[1] += 1f; - if (projectile.ai[1] > 5f) - { - projectile.alpha = 0; - } - } + public override void AI() + { + Player player = Main.player[projectile.owner]; + Vector2 projVector = player.Center - projectile.Center; + projectile.rotation = projVector.ToRotation() - MathHelper.PiOver2; + if (player.dead) + { + projectile.Kill(); + return; + } + player.itemAnimation = 10; + player.itemTime = 10; + if (projVector.X < 0f) + { + player.ChangeDir(1); + projectile.direction = 1; + } + else + { + player.ChangeDir(-1); + projectile.direction = -1; + } + player.itemRotation = (projVector * -1f * (float)projectile.direction).ToRotation(); + projectile.spriteDirection = (projVector.X > 0f) ? -1 : 1; + if (projectile.ai[0] == 0f && projVector.Length() > 850f) + { + projectile.ai[0] = 1f; + } + if (projectile.ai[0] == 1f || projectile.ai[0] == 2f) + { + projectile.extraUpdates = 2; + float playerDist = projVector.Length(); + if (playerDist > 1500f) + { + projectile.Kill(); + return; + } + if (playerDist > 1000f) + { + projectile.ai[0] = 2f; + } + projectile.tileCollide = false; + float returnSpeed = 15f; + if (projectile.ai[0] == 2f) + { + returnSpeed = 30f; + } + projectile.velocity = Vector2.Normalize(projVector) * returnSpeed; + if (projVector.Length() < returnSpeed) + { + projectile.Kill(); + return; + } + } + projectile.ai[1] += 1f; + if (projectile.ai[1] > 5f) + { + projectile.alpha = 0; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Vector2 mountedCenter = Main.player[projectile.owner].MountedCenter; - Color transparent = Microsoft.Xna.Framework.Color.Transparent; - Texture2D chainTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Chains/RemsRevengeChain"); - Vector2 projCenter = projectile.Center; - Rectangle? sourceRectangle = null; - Vector2 origin = new Vector2((float)chainTexture.Width * 0.5f, (float)chainTexture.Height * 0.5f); - float chainHeight = (float)chainTexture.Height; - Vector2 realCenter = mountedCenter - projCenter; - float rotation = (float)Math.Atan2((double)realCenter.Y, (double)realCenter.X) - MathHelper.PiOver2; - bool canDraw = true; - if (float.IsNaN(projCenter.X) && float.IsNaN(projCenter.Y)) - { - canDraw = false; - } - if (float.IsNaN(realCenter.X) && float.IsNaN(realCenter.Y)) - { - canDraw = false; - } - while (canDraw) - { - if (realCenter.Length() < chainHeight + 1f) - { - canDraw = false; - } - else - { - Vector2 centerDir = realCenter; - centerDir.Normalize(); - projCenter += centerDir * chainHeight; - realCenter = mountedCenter - projCenter; - Color color = Lighting.GetColor((int)projCenter.X / 16, (int)(projCenter.Y / 16f)); - Main.spriteBatch.Draw(chainTexture, projCenter - Main.screenPosition, sourceRectangle, color, rotation, origin, 1f, SpriteEffects.None, 0f); - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Vector2 mountedCenter = Main.player[projectile.owner].MountedCenter; + Color transparent = Microsoft.Xna.Framework.Color.Transparent; + Texture2D chainTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Chains/RemsRevengeChain"); + Vector2 projCenter = projectile.Center; + Rectangle? sourceRectangle = null; + Vector2 origin = new Vector2((float)chainTexture.Width * 0.5f, (float)chainTexture.Height * 0.5f); + float chainHeight = (float)chainTexture.Height; + Vector2 realCenter = mountedCenter - projCenter; + float rotation = (float)Math.Atan2((double)realCenter.Y, (double)realCenter.X) - MathHelper.PiOver2; + bool canDraw = true; + if (float.IsNaN(projCenter.X) && float.IsNaN(projCenter.Y)) + { + canDraw = false; + } + if (float.IsNaN(realCenter.X) && float.IsNaN(realCenter.Y)) + { + canDraw = false; + } + while (canDraw) + { + if (realCenter.Length() < chainHeight + 1f) + { + canDraw = false; + } + else + { + Vector2 centerDir = realCenter; + centerDir.Normalize(); + projCenter += centerDir * chainHeight; + realCenter = mountedCenter - projCenter; + Color color = Lighting.GetColor((int)projCenter.X / 16, (int)(projCenter.Y / 16f)); + Main.spriteBatch.Draw(chainTexture, projCenter - Main.screenPosition, sourceRectangle, color, rotation, origin, 1f, SpriteEffects.None, 0f); + } + } - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); - return false; - } + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 240); - hitCounter++; - if (hitCounter < 6) - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); - if (hitCounter > 3) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 240); + hitCounter++; + if (hitCounter < 6) + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); + if (hitCounter > 3) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } + } + } } diff --git a/Projectiles/Melee/RendingNeedle.cs b/Projectiles/Melee/RendingNeedle.cs index b9dca40ece..2364a7fab7 100644 --- a/Projectiles/Melee/RendingNeedle.cs +++ b/Projectiles/Melee/RendingNeedle.cs @@ -11,7 +11,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class RendingNeedle : ModProjectile + public class RendingNeedle : ModProjectile { internal PrimitiveTrail TrailDrawer; diff --git a/Projectiles/Melee/RoxSlam.cs b/Projectiles/Melee/RoxSlam.cs index 76500fecf4..a810776487 100644 --- a/Projectiles/Melee/RoxSlam.cs +++ b/Projectiles/Melee/RoxSlam.cs @@ -28,18 +28,18 @@ namespace CalamityMod.Projectiles.Melee projectile.Kill(); } //Makes the projectiles track the player - float posX; - float posY = player.Center.Y + 63; - // Makes the projectile follow the proper position on the X axis - if (player.direction == 1) - { - posX = player.Center.X + 6; - } - else - { - posX = player.Center.X - 8; - } - projectile.Center = new Vector2(posX, posY - (player.height / 10f)); + float posX; + float posY = player.Center.Y + 63; + // Makes the projectile follow the proper position on the X axis + if (player.direction == 1) + { + posX = player.Center.X + 6; + } + else + { + posX = player.Center.X - 8; + } + projectile.Center = new Vector2(posX, posY - (player.height / 10f)); } public override bool OnTileCollide(Vector2 oldVelocity) @@ -50,8 +50,8 @@ namespace CalamityMod.Projectiles.Melee Player player = Main.player[projectile.owner]; //Bounce player.velocity.Y = -18f; - //reset player fall damage - player.fallStart = (int)(player.position.Y / 16f); + //reset player fall damage + player.fallStart = (int)(player.position.Y / 16f); //Spawns the shockwave Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 300, 12, projectile.owner); Main.PlaySound(SoundID.Item14, projectile.position); @@ -71,14 +71,14 @@ namespace CalamityMod.Projectiles.Melee { Player player = Main.player[projectile.owner]; player.velocity.Y = -14f; - //reset player fall damage - player.fallStart = (int)(player.position.Y / 16f); + //reset player fall damage + player.fallStart = (int)(player.position.Y / 16f); Main.PlaySound(SoundID.Tink, projectile.position); projectile.Kill(); return false; } - return false; + return false; } } } diff --git a/Projectiles/Melee/SHIV.cs b/Projectiles/Melee/SHIV.cs index 9e6d31841c..408ec8954e 100644 --- a/Projectiles/Melee/SHIV.cs +++ b/Projectiles/Melee/SHIV.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SHIV : ModProjectile + public class SHIV : ModProjectile { public override void SetStaticDefaults() { @@ -25,13 +25,13 @@ namespace CalamityMod.Projectiles.Melee projectile.tileCollide = false; projectile.timeLeft = 600; projectile.aiStyle = 27; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() { - if (projectile.velocity.Length() < 25f && projectile.timeLeft % 2 == 0) - projectile.velocity *= 1.04f; + if (projectile.velocity.Length() < 25f && projectile.timeLeft % 2 == 0) + projectile.velocity *= 1.04f; int rainbow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, (float)(projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); Main.dust[rainbow].noGravity = true; @@ -46,17 +46,17 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 595) - return false; + if (projectile.timeLeft > 595) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } } diff --git a/Projectiles/Melee/SandFire.cs b/Projectiles/Melee/SandFire.cs index 6e7394fa06..46afa9c908 100644 --- a/Projectiles/Melee/SandFire.cs +++ b/Projectiles/Melee/SandFire.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SandFire : ModProjectile + public class SandFire : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Melee } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/ScourgeoftheCosmosMini.cs b/Projectiles/Melee/ScourgeoftheCosmosMini.cs index c9bd03a52c..a34ae71e82 100644 --- a/Projectiles/Melee/ScourgeoftheCosmosMini.cs +++ b/Projectiles/Melee/ScourgeoftheCosmosMini.cs @@ -6,153 +6,153 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ScourgeoftheCosmosMini : ModProjectile - { - private int bounce = 3; + public class ScourgeoftheCosmosMini : ModProjectile + { + private int bounce = 3; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Miniature Cosmic Scourge"); - Main.projFrames[projectile.type] = 2; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Miniature Cosmic Scourge"); + Main.projFrames[projectile.type] = 2; + } - public override void SetDefaults() - { - projectile.width = 16; - projectile.height = 16; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.melee = true; - projectile.alpha = 255; - projectile.penetrate = 1; - projectile.timeLeft = 300; - projectile.extraUpdates = 3; - } + public override void SetDefaults() + { + projectile.width = 16; + projectile.height = 16; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.melee = true; + projectile.alpha = 255; + projectile.penetrate = 1; + projectile.timeLeft = 300; + projectile.extraUpdates = 3; + } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270 && target.CanBeChasedBy(projectile); - public override void AI() - { - if (projectile.alpha > 0) - projectile.alpha -= 50; - else - projectile.extraUpdates = 1; + public override void AI() + { + if (projectile.alpha > 0) + projectile.alpha -= 50; + else + projectile.extraUpdates = 1; - if (projectile.alpha < 0) - projectile.alpha = 0; + if (projectile.alpha < 0) + projectile.alpha = 0; - projectile.frameCounter++; - if (projectile.frameCounter >= 6) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 1) - projectile.frame = 0; + projectile.frameCounter++; + if (projectile.frameCounter >= 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 1) + projectile.frame = 0; - for (int num369 = 0; num369 < 1; num369++) - { - int dustType = Main.rand.NextBool(3) ? 56 : 242; - float num370 = projectile.velocity.X / 3f * num369; - float num371 = projectile.velocity.Y / 3f * num369; - int num372 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num372]; - dust.position.X = projectile.Center.X - num370; - dust.position.Y = projectile.Center.Y - num371; - dust.velocity *= 0f; - dust.scale = 0.5f; - } + for (int num369 = 0; num369 < 1; num369++) + { + int dustType = Main.rand.NextBool(3) ? 56 : 242; + float num370 = projectile.velocity.X / 3f * num369; + float num371 = projectile.velocity.Y / 3f * num369; + int num372 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[num372]; + dust.position.X = projectile.Center.X - num370; + dust.position.Y = projectile.Center.Y - num371; + dust.velocity *= 0f; + dust.scale = 0.5f; + } - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; - float num373 = projectile.position.X; - float num374 = projectile.position.Y; - float num375 = 100000f; - bool flag10 = false; - projectile.ai[0] += 1f; - if (projectile.ai[0] > 30f) - { - projectile.ai[0] = 30f; - for (int num376 = 0; num376 < Main.maxNPCs; num376++) - { - if (Main.npc[num376].CanBeChasedBy(projectile, false)) - { - float num377 = Main.npc[num376].position.X + Main.npc[num376].width / 2; - float num378 = Main.npc[num376].position.Y + Main.npc[num376].height / 2; - float num379 = Math.Abs(projectile.position.X + projectile.width / 2 - num377) + Math.Abs(projectile.position.Y + projectile.height / 2 - num378); - if (num379 < 800f && num379 < num375 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num376].position, Main.npc[num376].width, Main.npc[num376].height)) - { - num375 = num379; - num373 = num377; - num374 = num378; - flag10 = true; - } - } - } - } - if (!flag10) - { - num373 = projectile.position.X + projectile.width / 2 + projectile.velocity.X * 100f; - num374 = projectile.position.Y + projectile.height / 2 + projectile.velocity.Y * 100f; - } + float num373 = projectile.position.X; + float num374 = projectile.position.Y; + float num375 = 100000f; + bool flag10 = false; + projectile.ai[0] += 1f; + if (projectile.ai[0] > 30f) + { + projectile.ai[0] = 30f; + for (int num376 = 0; num376 < Main.maxNPCs; num376++) + { + if (Main.npc[num376].CanBeChasedBy(projectile, false)) + { + float num377 = Main.npc[num376].position.X + Main.npc[num376].width / 2; + float num378 = Main.npc[num376].position.Y + Main.npc[num376].height / 2; + float num379 = Math.Abs(projectile.position.X + projectile.width / 2 - num377) + Math.Abs(projectile.position.Y + projectile.height / 2 - num378); + if (num379 < 800f && num379 < num375 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num376].position, Main.npc[num376].width, Main.npc[num376].height)) + { + num375 = num379; + num373 = num377; + num374 = num378; + flag10 = true; + } + } + } + } + if (!flag10) + { + num373 = projectile.position.X + projectile.width / 2 + projectile.velocity.X * 100f; + num374 = projectile.position.Y + projectile.height / 2 + projectile.velocity.Y * 100f; + } - float num380 = 10f; - float num381 = 0.16f; - Vector2 vector30 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f); - float num382 = num373 - vector30.X; - float num383 = num374 - vector30.Y; - float num384 = (float)Math.Sqrt(num382 * num382 + num383 * num383); - num384 = num380 / num384; - num382 *= num384; - num383 *= num384; - if (projectile.velocity.X < num382) - { - projectile.velocity.X = projectile.velocity.X + num381; - if (projectile.velocity.X < 0f && num382 > 0f) - projectile.velocity.X = projectile.velocity.X + num381 * 2f; - } - else if (projectile.velocity.X > num382) - { - projectile.velocity.X = projectile.velocity.X - num381; - if (projectile.velocity.X > 0f && num382 < 0f) - projectile.velocity.X = projectile.velocity.X - num381 * 2f; - } - if (projectile.velocity.Y < num383) - { - projectile.velocity.Y = projectile.velocity.Y + num381; - if (projectile.velocity.Y < 0f && num383 > 0f) - projectile.velocity.Y = projectile.velocity.Y + num381 * 2f; - } - else if (projectile.velocity.Y > num383) - { - projectile.velocity.Y = projectile.velocity.Y - num381; - if (projectile.velocity.Y > 0f && num383 < 0f) - projectile.velocity.Y = projectile.velocity.Y - num381 * 2f; - } - } + float num380 = 10f; + float num381 = 0.16f; + Vector2 vector30 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f); + float num382 = num373 - vector30.X; + float num383 = num374 - vector30.Y; + float num384 = (float)Math.Sqrt(num382 * num382 + num383 * num383); + num384 = num380 / num384; + num382 *= num384; + num383 *= num384; + if (projectile.velocity.X < num382) + { + projectile.velocity.X = projectile.velocity.X + num381; + if (projectile.velocity.X < 0f && num382 > 0f) + projectile.velocity.X = projectile.velocity.X + num381 * 2f; + } + else if (projectile.velocity.X > num382) + { + projectile.velocity.X = projectile.velocity.X - num381; + if (projectile.velocity.X > 0f && num382 < 0f) + projectile.velocity.X = projectile.velocity.X - num381 * 2f; + } + if (projectile.velocity.Y < num383) + { + projectile.velocity.Y = projectile.velocity.Y + num381; + if (projectile.velocity.Y < 0f && num383 > 0f) + projectile.velocity.Y = projectile.velocity.Y + num381 * 2f; + } + else if (projectile.velocity.Y > num383) + { + projectile.velocity.Y = projectile.velocity.Y - num381; + if (projectile.velocity.Y > 0f && num383 < 0f) + projectile.velocity.Y = projectile.velocity.Y - num381 * 2f; + } + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - bounce--; - if (bounce <= 0) - projectile.Kill(); - else - { - if (projectile.velocity.X != oldVelocity.X) - projectile.velocity.X = -oldVelocity.X; - if (projectile.velocity.Y != oldVelocity.Y) - projectile.velocity.Y = -oldVelocity.Y; - } - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + bounce--; + if (bounce <= 0) + projectile.Kill(); + else + { + if (projectile.velocity.X != oldVelocity.X) + projectile.velocity.X = -oldVelocity.X; + if (projectile.velocity.Y != oldVelocity.Y) + projectile.velocity.Y = -oldVelocity.Y; + } + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture2D13 = Main.projectileTexture[projectile.type]; - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; - int y6 = num214 * projectile.frame; - Vector2 origin = new Vector2(9f, 10f); - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Melee/ScourgeoftheCosmosMiniGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); - } - } + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture2D13 = Main.projectileTexture[projectile.type]; + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int y6 = num214 * projectile.frame; + Vector2 origin = new Vector2(9f, 10f); + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Melee/ScourgeoftheCosmosMiniGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + } + } } diff --git a/Projectiles/Melee/ScourgeoftheCosmosProj.cs b/Projectiles/Melee/ScourgeoftheCosmosProj.cs index 0023f2d0fe..24c3743925 100644 --- a/Projectiles/Melee/ScourgeoftheCosmosProj.cs +++ b/Projectiles/Melee/ScourgeoftheCosmosProj.cs @@ -7,138 +7,138 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ScourgeoftheCosmosProj : ModProjectile - { - private int bounce = 3; + public class ScourgeoftheCosmosProj : ModProjectile + { + private int bounce = 3; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cosmic Scourge"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cosmic Scourge"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 36; - projectile.alpha = 255; - projectile.friendly = true; - projectile.melee = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; - projectile.extraUpdates = 1; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 36; + projectile.alpha = 255; + projectile.friendly = true; + projectile.melee = true; + projectile.ignoreWater = true; + projectile.penetrate = 1; + projectile.extraUpdates = 1; + } - public override void AI() - { - if (projectile.alpha <= 200) - { - int num3; - for (int num20 = 0; num20 < 2; num20 = num3 + 1) - { - int dustType = Main.rand.NextBool(3) ? 56 : 242; - float num21 = projectile.velocity.X / 4f * num20; - float num22 = projectile.velocity.Y / 4f * num20; - int num23 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); - Main.dust[num23].position.X = projectile.Center.X - num21; - Main.dust[num23].position.Y = projectile.Center.Y - num22; - Dust dust = Main.dust[num23]; - dust.velocity *= 0f; - Main.dust[num23].scale = 0.7f; - num3 = num20; - } - } - projectile.alpha -= 50; - if (projectile.alpha < 0) - projectile.alpha = 0; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 0.785f; - projectile.ai[0] += 1f; - if (projectile.ai[0] >= 180f) - { - projectile.velocity.Y = projectile.velocity.Y + 0.4f; - projectile.velocity.X = projectile.velocity.X * 0.97f; - } - if (projectile.velocity.Y > 16f) - projectile.velocity.Y = 16f; - } + public override void AI() + { + if (projectile.alpha <= 200) + { + int num3; + for (int num20 = 0; num20 < 2; num20 = num3 + 1) + { + int dustType = Main.rand.NextBool(3) ? 56 : 242; + float num21 = projectile.velocity.X / 4f * num20; + float num22 = projectile.velocity.Y / 4f * num20; + int num23 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); + Main.dust[num23].position.X = projectile.Center.X - num21; + Main.dust[num23].position.Y = projectile.Center.Y - num22; + Dust dust = Main.dust[num23]; + dust.velocity *= 0f; + Main.dust[num23].scale = 0.7f; + num3 = num20; + } + } + projectile.alpha -= 50; + if (projectile.alpha < 0) + projectile.alpha = 0; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 0.785f; + projectile.ai[0] += 1f; + if (projectile.ai[0] >= 180f) + { + projectile.velocity.Y = projectile.velocity.Y + 0.4f; + projectile.velocity.X = projectile.velocity.X * 0.97f; + } + if (projectile.velocity.Y > 16f) + projectile.velocity.Y = 16f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - bounce--; - if (bounce <= 0) - projectile.Kill(); - else - { - Main.PlaySound(SoundID.NPCHit4, projectile.position); - if (projectile.velocity.X != oldVelocity.X) - projectile.velocity.X = -oldVelocity.X; - if (projectile.velocity.Y != oldVelocity.Y) - projectile.velocity.Y = -oldVelocity.Y; - if (projectile.owner == Main.myPlayer) - { - int num626 = 1; - if (Main.rand.NextBool(10)) - num626++; - int num3; - for (int num627 = 0; num627 < num626; num627 = num3 + 1) - { - float num628 = Main.rand.Next(-35, 36) * 0.02f; - float num629 = Main.rand.Next(-35, 36) * 0.02f; - num628 *= 10f; - num629 *= 10f; - Projectile.NewProjectile(projectile.position.X, projectile.position.Y, num628, num629, ModContent.ProjectileType(), (int)(projectile.damage * 0.7), projectile.knockBack * 0.35f, Main.myPlayer); - num3 = num627; - } - } - } - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + bounce--; + if (bounce <= 0) + projectile.Kill(); + else + { + Main.PlaySound(SoundID.NPCHit4, projectile.position); + if (projectile.velocity.X != oldVelocity.X) + projectile.velocity.X = -oldVelocity.X; + if (projectile.velocity.Y != oldVelocity.Y) + projectile.velocity.Y = -oldVelocity.Y; + if (projectile.owner == Main.myPlayer) + { + int num626 = 1; + if (Main.rand.NextBool(10)) + num626++; + int num3; + for (int num627 = 0; num627 < num626; num627 = num3 + 1) + { + float num628 = Main.rand.Next(-35, 36) * 0.02f; + float num629 = Main.rand.Next(-35, 36) * 0.02f; + num628 *= 10f; + num629 *= 10f; + Projectile.NewProjectile(projectile.position.X, projectile.position.Y, num628, num629, ModContent.ProjectileType(), (int)(projectile.damage * 0.7), projectile.knockBack * 0.35f, Main.myPlayer); + num3 = num627; + } + } + } + return false; + } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.NPCHit4, projectile.position); - int num3; - for (int num622 = 0; num622 < 10; num622 = num3 + 1) - { - int dustType = Main.rand.NextBool(3) ? 56 : 242; - int num623 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num623]; - dust.scale *= 1.1f; - Main.dust[num623].noGravity = true; - num3 = num622; - } - for (int num624 = 0; num624 < 15; num624 = num3 + 1) - { - int dustType = Main.rand.NextBool(3) ? 56 : 242; - int num625 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num625]; - dust.velocity *= 2.5f; - dust = Main.dust[num625]; - dust.scale *= 0.8f; - Main.dust[num625].noGravity = true; - num3 = num624; - } - if (projectile.owner == Main.myPlayer) - { - int num626 = 3; - if (Main.rand.NextBool(10)) - num626++; - for (int num627 = 0; num627 < num626; num627 = num3 + 1) - { - float num628 = Main.rand.Next(-35, 36) * 0.02f; - float num629 = Main.rand.Next(-35, 36) * 0.02f; - num628 *= 10f; - num629 *= 10f; - Projectile.NewProjectile(projectile.position.X, projectile.position.Y, num628, num629, ModContent.ProjectileType(), (int)(projectile.damage * 0.7), projectile.knockBack * 0.35f, Main.myPlayer); - num3 = num627; - } - } - } - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.NPCHit4, projectile.position); + int num3; + for (int num622 = 0; num622 < 10; num622 = num3 + 1) + { + int dustType = Main.rand.NextBool(3) ? 56 : 242; + int num623 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[num623]; + dust.scale *= 1.1f; + Main.dust[num623].noGravity = true; + num3 = num622; + } + for (int num624 = 0; num624 < 15; num624 = num3 + 1) + { + int dustType = Main.rand.NextBool(3) ? 56 : 242; + int num625 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[num625]; + dust.velocity *= 2.5f; + dust = Main.dust[num625]; + dust.scale *= 0.8f; + Main.dust[num625].noGravity = true; + num3 = num624; + } + if (projectile.owner == Main.myPlayer) + { + int num626 = 3; + if (Main.rand.NextBool(10)) + num626++; + for (int num627 = 0; num627 < num626; num627 = num3 + 1) + { + float num628 = Main.rand.Next(-35, 36) * 0.02f; + float num629 = Main.rand.Next(-35, 36) * 0.02f; + num628 *= 10f; + num629 *= 10f; + Projectile.NewProjectile(projectile.position.X, projectile.position.Y, num628, num629, ModContent.ProjectileType(), (int)(projectile.damage * 0.7), projectile.knockBack * 0.35f, Main.myPlayer); + num3 = num627; + } + } + } + } } diff --git a/Projectiles/Melee/ShortBeam.cs b/Projectiles/Melee/ShortBeam.cs index df133f307b..7e498f350e 100644 --- a/Projectiles/Melee/ShortBeam.cs +++ b/Projectiles/Melee/ShortBeam.cs @@ -35,10 +35,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 55) - return false; + if (projectile.timeLeft > 55) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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/Melee/ShortNightBeam.cs b/Projectiles/Melee/ShortNightBeam.cs index b289cca935..637e4c97a8 100644 --- a/Projectiles/Melee/ShortNightBeam.cs +++ b/Projectiles/Melee/ShortNightBeam.cs @@ -35,10 +35,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 55) - return false; + if (projectile.timeLeft > 55) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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/Melee/ShortTerraBeam.cs b/Projectiles/Melee/ShortTerraBeam.cs index d959cc1355..1b02f69623 100644 --- a/Projectiles/Melee/ShortTerraBeam.cs +++ b/Projectiles/Melee/ShortTerraBeam.cs @@ -36,10 +36,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 115) - return false; + if (projectile.timeLeft > 115) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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/Melee/SolarNeedle.cs b/Projectiles/Melee/SolarNeedle.cs index 069113c2be..cfab0be86b 100644 --- a/Projectiles/Melee/SolarNeedle.cs +++ b/Projectiles/Melee/SolarNeedle.cs @@ -12,7 +12,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class SolarNeedle : ModProjectile + public class SolarNeedle : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Melee/SolsticeBeam.cs b/Projectiles/Melee/SolsticeBeam.cs index 0dd6e0c54c..0526bb5abe 100644 --- a/Projectiles/Melee/SolsticeBeam.cs +++ b/Projectiles/Melee/SolsticeBeam.cs @@ -130,10 +130,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 595) - return false; + if (projectile.timeLeft > 595) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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/Melee/SoulScythe.cs b/Projectiles/Melee/SoulScythe.cs index 538f1c3a69..ecdb9b4b4e 100644 --- a/Projectiles/Melee/SoulScythe.cs +++ b/Projectiles/Melee/SoulScythe.cs @@ -40,13 +40,13 @@ namespace CalamityMod.Projectiles.Melee { target.immune[projectile.owner] = 6; target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(BuffID.CursedInferno, 90); - if (target.life <= (target.lifeMax * 0.15f)) + target.AddBuff(BuffID.CursedInferno, 90); + if (target.life <= (target.lifeMax * 0.15f)) { Main.PlaySound(SoundID.Item14, projectile.position); if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(target.Center.X, target.Center.Y, projectile.velocity.X * 0f, projectile.velocity.Y * 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(target.Center.X, target.Center.Y, projectile.velocity.X * 0f, projectile.velocity.Y * 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Melee/SoulScytheExplosion.cs b/Projectiles/Melee/SoulScytheExplosion.cs index 8d274452c9..42f5c6162c 100644 --- a/Projectiles/Melee/SoulScytheExplosion.cs +++ b/Projectiles/Melee/SoulScytheExplosion.cs @@ -6,15 +6,15 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SoulScytheExplosion : ModProjectile + public class SoulScytheExplosion : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Explosion"); - } - + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Explosion"); + } + public override void SetDefaults() { projectile.width = 60; @@ -22,17 +22,17 @@ namespace CalamityMod.Projectiles.Melee projectile.friendly = true; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.melee = true; - projectile.penetrate = -1; + projectile.melee = true; + projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.timeLeft = 5; } - public override void AI() - { - if (projectile.timeLeft == 5) - { + public override void AI() + { + if (projectile.timeLeft == 5) + { for (int num621 = 0; num621 < 30; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); @@ -51,13 +51,13 @@ namespace CalamityMod.Projectiles.Melee num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - } - } + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(BuffID.CursedInferno, 90); - } + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffID.CursedInferno, 90); + } } } \ No newline at end of file diff --git a/Projectiles/Melee/Spark.cs b/Projectiles/Melee/Spark.cs index 1995da51a1..9d14e8a39b 100644 --- a/Projectiles/Melee/Spark.cs +++ b/Projectiles/Melee/Spark.cs @@ -85,6 +85,6 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Melee/SpatialSpear.cs b/Projectiles/Melee/SpatialSpear.cs index 74c889d20b..b9f6f9d3df 100644 --- a/Projectiles/Melee/SpatialSpear.cs +++ b/Projectiles/Melee/SpatialSpear.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SpatialSpear : ModProjectile + public class SpatialSpear : ModProjectile { public override void SetStaticDefaults() { @@ -85,20 +85,20 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 85) - return false; + if (projectile.timeLeft > 85) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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 void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Melee/SpatialSpear2.cs b/Projectiles/Melee/SpatialSpear2.cs index d96930997d..ad71a3ec45 100644 --- a/Projectiles/Melee/SpatialSpear2.cs +++ b/Projectiles/Melee/SpatialSpear2.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SpatialSpear2 : ModProjectile + public class SpatialSpear2 : ModProjectile { public override void SetStaticDefaults() { @@ -74,20 +74,20 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 55) - return false; + if (projectile.timeLeft > 55) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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 void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Melee/SpatialSpear3.cs b/Projectiles/Melee/SpatialSpear3.cs index bfc67e8b6f..67a8389742 100644 --- a/Projectiles/Melee/SpatialSpear3.cs +++ b/Projectiles/Melee/SpatialSpear3.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SpatialSpear3 : ModProjectile + public class SpatialSpear3 : ModProjectile { public override void SetStaticDefaults() { @@ -72,20 +72,20 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 35) - return false; + if (projectile.timeLeft > 35) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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 void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Melee/SpatialSpear4.cs b/Projectiles/Melee/SpatialSpear4.cs index ed06135204..e97cd62ad2 100644 --- a/Projectiles/Melee/SpatialSpear4.cs +++ b/Projectiles/Melee/SpatialSpear4.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SpatialSpear4 : ModProjectile + public class SpatialSpear4 : ModProjectile { public override void SetStaticDefaults() { @@ -57,20 +57,20 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 20) - return false; + if (projectile.timeLeft > 20) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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 void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Melee/Spears/AstralPikeProj.cs b/Projectiles/Melee/Spears/AstralPikeProj.cs index 464a3e7a5b..a0dbd9d3b8 100644 --- a/Projectiles/Melee/Spears/AstralPikeProj.cs +++ b/Projectiles/Melee/Spears/AstralPikeProj.cs @@ -7,7 +7,7 @@ using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee.Spears { - public class AstralPikeProj : BaseSpearProjectile + public class AstralPikeProj : BaseSpearProjectile { public override void SetStaticDefaults() { @@ -49,12 +49,12 @@ namespace CalamityMod.Projectiles.Melee.Spears { if (projectile.owner == Main.myPlayer) { - Projectile star = CalamityUtils.ProjectileBarrage(projectile.Center, target.Center, Main.rand.NextBool(), 800f, 800f, 800f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), 1f, projectile.owner, true); - if (star.whoAmI.WithinBounds(Main.maxProjectiles)) - { - star.Calamity().forceMelee = true; - star.ai[0] = 3f; - } + Projectile star = CalamityUtils.ProjectileBarrage(projectile.Center, target.Center, Main.rand.NextBool(), 800f, 800f, 800f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), 1f, projectile.owner, true); + if (star.whoAmI.WithinBounds(Main.maxProjectiles)) + { + star.Calamity().forceMelee = true; + star.ai[0] = 3f; + } } } diff --git a/Projectiles/Melee/Spears/BrimlanceProj.cs b/Projectiles/Melee/Spears/BrimlanceProj.cs index e256a4389d..d1fa2963a9 100644 --- a/Projectiles/Melee/Spears/BrimlanceProj.cs +++ b/Projectiles/Melee/Spears/BrimlanceProj.cs @@ -41,18 +41,18 @@ namespace CalamityMod.Projectiles.Melee.Spears } } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 7; - if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.65), knockback, Main.myPlayer); - for (int i = 0; i < 3; i++) - { - Vector2 fireVelocity = new Vector2(0f, Main.rand.NextFloat(7f, 10f)).RotatedByRandom(MathHelper.TwoPi); - Projectile.NewProjectile(target.Center, fireVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), 0f, projectile.owner, 0f, 0f); - } - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 7; + if (projectile.owner == Main.myPlayer) + { + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.65), knockback, Main.myPlayer); + for (int i = 0; i < 3; i++) + { + Vector2 fireVelocity = new Vector2(0f, Main.rand.NextFloat(7f, 10f)).RotatedByRandom(MathHelper.TwoPi); + Projectile.NewProjectile(target.Center, fireVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), 0f, projectile.owner, 0f, 0f); + } + } + } } } diff --git a/Projectiles/Melee/Spears/DiseasedPikeSpear.cs b/Projectiles/Melee/Spears/DiseasedPikeSpear.cs index 699b674a07..0a31aa733c 100644 --- a/Projectiles/Melee/Spears/DiseasedPikeSpear.cs +++ b/Projectiles/Melee/Spears/DiseasedPikeSpear.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee.Spears { - public class DiseasedPikeSpear : BaseSpearProjectile + public class DiseasedPikeSpear : BaseSpearProjectile { public override void SetStaticDefaults() { @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Melee.Spears for (int i = 0; i < 4; i++) { int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity * 0.5f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); - Main.projectile[proj].extraUpdates += i; + Main.projectile[proj].extraUpdates += i; } } } diff --git a/Projectiles/Melee/Spears/EarthenPikeSpear.cs b/Projectiles/Melee/Spears/EarthenPikeSpear.cs index 7bb7360f06..2c2ea50d3f 100644 --- a/Projectiles/Melee/Spears/EarthenPikeSpear.cs +++ b/Projectiles/Melee/Spears/EarthenPikeSpear.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.melee = true; //Dictates whether projectile is a melee-class weapon. projectile.timeLeft = 90; projectile.height = 40; //The height of the .png file in pixels divided by 2. - projectile.scale = 1.5f; + projectile.scale = 1.5f; projectile.friendly = true; projectile.hostile = false; projectile.tileCollide = false; @@ -47,8 +47,8 @@ namespace CalamityMod.Projectiles.Melee.Spears velocityY = 0.1f; int proj = Projectile.NewProjectile(projectile.Center.X + projectile.velocity.X, projectile.Center.Y + projectile.velocity.Y, projectile.velocity.X * 1.25f, velocityY, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } } } diff --git a/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs b/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs index 46c7940352..e7c78c7c78 100644 --- a/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs +++ b/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs @@ -7,7 +7,7 @@ using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee.Spears { - public class ExsanguinationLanceProjectile : BaseSpearProjectile + public class ExsanguinationLanceProjectile : BaseSpearProjectile { public override void SetStaticDefaults() { @@ -38,44 +38,44 @@ namespace CalamityMod.Projectiles.Melee.Spears Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.NextBool(3) ? 16 : 127, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); Vector2 goreVec = projectile.Center + projectile.velocity; - if (Main.rand.NextBool(8)) - { - int smoke = Gore.NewGore(goreVec, default, Main.rand.Next(375, 378), 1f); - Main.gore[smoke].behindTiles = true; - } + if (Main.rand.NextBool(8)) + { + int smoke = Gore.NewGore(goreVec, default, Main.rand.Next(375, 378), 1f); + Main.gore[smoke].behindTiles = true; + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.immune[projectile.owner] = 6; - OnHitEffects(target.Center, crit); + OnHitEffects(target.Center, crit); target.AddBuff(BuffID.OnFire, 240); } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(target.Center, crit); + OnHitEffects(target.Center, crit); target.AddBuff(BuffID.OnFire, 240); } - private void OnHitEffects(Vector2 targetPos, bool crit) - { + private void OnHitEffects(Vector2 targetPos, bool crit) + { if (projectile.owner == Main.myPlayer) { int boom = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (boom.WithinBounds(Main.maxProjectiles)) - Main.projectile[boom].Calamity().forceMelee = true; + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceMelee = true; } if (crit) { for (int i = 0; i < 2; i++) { - if (projectile.owner == Main.myPlayer) - { - CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 2f, projectile.owner, true); - } - } - } + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 2f, projectile.owner, true); + } + } + } } } } diff --git a/Projectiles/Melee/Spears/FulgurationHalberdProj.cs b/Projectiles/Melee/Spears/FulgurationHalberdProj.cs index 67a26ee483..af41c624f1 100644 --- a/Projectiles/Melee/Spears/FulgurationHalberdProj.cs +++ b/Projectiles/Melee/Spears/FulgurationHalberdProj.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.melee = true; //Dictates whether projectile is a melee-class weapon. projectile.timeLeft = 90; projectile.height = 40; //The height of the .png file in pixels divided by 2. - projectile.scale = 1.5f; + projectile.scale = 1.5f; projectile.friendly = true; projectile.hostile = false; projectile.tileCollide = false; diff --git a/Projectiles/Melee/Spears/GildedProboscisProj.cs b/Projectiles/Melee/Spears/GildedProboscisProj.cs index e97390c3ff..0576d6d1a2 100644 --- a/Projectiles/Melee/Spears/GildedProboscisProj.cs +++ b/Projectiles/Melee/Spears/GildedProboscisProj.cs @@ -3,7 +3,7 @@ using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee.Spears { - public class GildedProboscisProj : BaseSpearProjectile + public class GildedProboscisProj : BaseSpearProjectile { public override void SetStaticDefaults() { @@ -47,8 +47,8 @@ namespace CalamityMod.Projectiles.Melee.Spears return; Player player = Main.player[projectile.owner]; - player.statLife += 1; - player.HealEffect(1); + player.statLife += 1; + player.HealEffect(1); } } } diff --git a/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs b/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs index b7080ec2c9..cfaf6d0f24 100644 --- a/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs +++ b/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs @@ -37,32 +37,32 @@ namespace CalamityMod.Projectiles.Melee.Spears Projectile.NewProjectile(projectile.Center.X + projectile.velocity.X, projectile.Center.Y + projectile.velocity.Y, projectile.velocity.X * 2.4f, projectile.velocity.Y * 2.4f, ModContent.ProjectileType(), (int)(projectile.damage * 0.65), projectile.knockBack * 0.85f, projectile.owner, 0f, 0f); }; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 8; - OnHitEffects(target.Center, crit); - target.AddBuff(BuffID.Venom, 300); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 8; + OnHitEffects(target.Center, crit); + target.AddBuff(BuffID.Venom, 300); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - OnHitEffects(target.Center, crit); - target.AddBuff(BuffID.Venom, 300); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center, crit); + target.AddBuff(BuffID.Venom, 300); + } - private void OnHitEffects(Vector2 targetPos, bool crit) - { + private void OnHitEffects(Vector2 targetPos, bool crit) + { if (crit) { - if (projectile.owner == Main.myPlayer) - { - Projectile petal = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ProjectileID.FlowerPetal, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, true); - if (petal.whoAmI.WithinBounds(Main.maxProjectiles)) - { - petal.Calamity().forceMelee = true; - petal.localNPCHitCooldown = -1; - } - } + if (projectile.owner == Main.myPlayer) + { + Projectile petal = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ProjectileID.FlowerPetal, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, true); + if (petal.whoAmI.WithinBounds(Main.maxProjectiles)) + { + petal.Calamity().forceMelee = true; + petal.localNPCHitCooldown = -1; + } + } } } } diff --git a/Projectiles/Melee/Spears/NadirSpear.cs b/Projectiles/Melee/Spears/NadirSpear.cs index a750ef7d88..dbef07797b 100644 --- a/Projectiles/Melee/Spears/NadirSpear.cs +++ b/Projectiles/Melee/Spears/NadirSpear.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee.Spears { - public class NadirSpear : BaseSpearProjectile + public class NadirSpear : BaseSpearProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Melee/Spears/SpatialLanceProjectile.cs b/Projectiles/Melee/Spears/SpatialLanceProjectile.cs index 3281021a01..59a817a738 100644 --- a/Projectiles/Melee/Spears/SpatialLanceProjectile.cs +++ b/Projectiles/Melee/Spears/SpatialLanceProjectile.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee.Spears { - public class SpatialLanceProjectile : BaseSpearProjectile + public class SpatialLanceProjectile : BaseSpearProjectile { public override void SetStaticDefaults() { @@ -50,9 +50,9 @@ namespace CalamityMod.Projectiles.Melee.Spears public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(ModContent.BuffType(), 120); + } } } diff --git a/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs b/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs index 1713ccaee7..2e057840d9 100644 --- a/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs +++ b/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs @@ -7,7 +7,7 @@ using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee.Spears { - public class TenebreusTidesProjectile : BaseSpearProjectile + public class TenebreusTidesProjectile : BaseSpearProjectile { public override void SetStaticDefaults() { @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Melee.Spears { target.AddBuff(ModContent.BuffType(), 300); SwordSpam(target.Center); - } + } // Spawns a storm of water projectiles on-hit. public void SwordSpam(Vector2 targetPos) @@ -62,10 +62,10 @@ namespace CalamityMod.Projectiles.Melee.Spears int projAmt = 3; for (int i = 0; i < projAmt; ++i) { - int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); if (projectile.owner == Main.myPlayer) { - CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(25f, 35f), type, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner); + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(25f, 35f), type, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner); } } } diff --git a/Projectiles/Melee/Spears/YateveoBloomSpear.cs b/Projectiles/Melee/Spears/YateveoBloomSpear.cs index 9da2f9ca74..0fecc2edee 100644 --- a/Projectiles/Melee/Spears/YateveoBloomSpear.cs +++ b/Projectiles/Melee/Spears/YateveoBloomSpear.cs @@ -3,7 +3,7 @@ using Terraria.ID; using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee.Spears { - public class YateveoBloomSpear : BaseSpearProjectile + public class YateveoBloomSpear : BaseSpearProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Melee/SpineOfThanatosProjectile.cs b/Projectiles/Melee/SpineOfThanatosProjectile.cs index 2ae22e3951..694936c40a 100644 --- a/Projectiles/Melee/SpineOfThanatosProjectile.cs +++ b/Projectiles/Melee/SpineOfThanatosProjectile.cs @@ -9,215 +9,215 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SpineOfThanatosProjectile : ModProjectile - { - public List WhipPoints = new List(); - public Player Owner => Main.player[projectile.owner]; - public float CurrentBendFactor => MaximumBendFactor * CalamityUtils.Convert01To010(Time / Lifetime); - public Vector2 WhipEnd => projectile.Center + WhipOutwardness; + public class SpineOfThanatosProjectile : ModProjectile + { + public List WhipPoints = new List(); + public Player Owner => Main.player[projectile.owner]; + public float CurrentBendFactor => MaximumBendFactor * CalamityUtils.Convert01To010(Time / Lifetime); + public Vector2 WhipEnd => projectile.Center + WhipOutwardness; - // This wrapper exists solely for clarity as to the definition of velocity in the context of this projectile. - // You may notice that the Center property of this projectile is constantly set to be near the player. However, since - // ShouldUpdatePosition is not overriden to false, it still gains its velocity as usual for 1 frame before being reset again. - public ref Vector2 WhipOutwardness => ref projectile.velocity; - public ref float Time => ref projectile.ai[0]; - public ref float SwingDirection => ref projectile.ai[1]; - public ref float InitialDirectionRotation => ref projectile.localAI[0]; - public const int Lifetime = 125; - public const int FlyBackTime = 40; - public const int FinalWhipRayShootRate = 10; - public const int LaserRayCount = 12; - public const float MaximumBendFactor = 42f; - public override void SetStaticDefaults() => DisplayName.SetDefault("Spine of Thanatos"); + // This wrapper exists solely for clarity as to the definition of velocity in the context of this projectile. + // You may notice that the Center property of this projectile is constantly set to be near the player. However, since + // ShouldUpdatePosition is not overriden to false, it still gains its velocity as usual for 1 frame before being reset again. + public ref Vector2 WhipOutwardness => ref projectile.velocity; + public ref float Time => ref projectile.ai[0]; + public ref float SwingDirection => ref projectile.ai[1]; + public ref float InitialDirectionRotation => ref projectile.localAI[0]; + public const int Lifetime = 125; + public const int FlyBackTime = 40; + public const int FinalWhipRayShootRate = 10; + public const int LaserRayCount = 12; + public const float MaximumBendFactor = 42f; + public override void SetStaticDefaults() => DisplayName.SetDefault("Spine of Thanatos"); - public override void SetDefaults() - { - projectile.width = 58; - projectile.height = 70; - projectile.scale = 0.75f; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.melee = true; - projectile.extraUpdates = 2; - projectile.timeLeft = Lifetime; - projectile.ownerHitCheck = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 22; - } + public override void SetDefaults() + { + projectile.width = 58; + projectile.height = 70; + projectile.scale = 0.75f; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.melee = true; + projectile.extraUpdates = 2; + projectile.timeLeft = Lifetime; + projectile.ownerHitCheck = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 22; + } - public void DetermineWhipPoints() - { - Vector2 startingPosition = Owner.RotatedRelativePoint(Owner.MountedCenter); + public void DetermineWhipPoints() + { + Vector2 startingPosition = Owner.RotatedRelativePoint(Owner.MountedCenter); - List initialPoints = new List() - { - startingPosition - }; - for (int i = 0; i < 12; i++) - { - Vector2 bendOffset = Vector2.UnitX * -SwingDirection; + List initialPoints = new List() + { + startingPosition + }; + for (int i = 0; i < 12; i++) + { + Vector2 bendOffset = Vector2.UnitX * -SwingDirection; - // Make the bend factor depend on how far along the generated positions we are. - // The maximum bend should be halfway across the chain. - bendOffset *= CurrentBendFactor * CalamityUtils.Convert01To010(i / 12f); + // Make the bend factor depend on how far along the generated positions we are. + // The maximum bend should be halfway across the chain. + bendOffset *= CurrentBendFactor * CalamityUtils.Convert01To010(i / 12f); - // Smoothly zero out the bending effects if the current position is near the owner. - bendOffset *= Utils.InverseLerp(0f, 300f, Owner.Distance(Vector2.Lerp(startingPosition, projectile.Center, i / 12f) + bendOffset), true); - initialPoints.Add(Vector2.Lerp(startingPosition, projectile.Center, i / 12f) + bendOffset); - } - initialPoints.Add(projectile.Center); + // Smoothly zero out the bending effects if the current position is near the owner. + bendOffset *= Utils.InverseLerp(0f, 300f, Owner.Distance(Vector2.Lerp(startingPosition, projectile.Center, i / 12f) + bendOffset), true); + initialPoints.Add(Vector2.Lerp(startingPosition, projectile.Center, i / 12f) + bendOffset); + } + initialPoints.Add(projectile.Center); - BezierCurve bezierCurve = new BezierCurve(initialPoints.ToArray()); - int totalChains = (int)(projectile.Distance(startingPosition) / 24f / projectile.scale); - totalChains = (int)MathHelper.Clamp(totalChains, 40f, 440f); + BezierCurve bezierCurve = new BezierCurve(initialPoints.ToArray()); + int totalChains = (int)(projectile.Distance(startingPosition) / 24f / projectile.scale); + totalChains = (int)MathHelper.Clamp(totalChains, 40f, 440f); - WhipPoints = bezierCurve.GetPoints(totalChains); - } + WhipPoints = bezierCurve.GetPoints(totalChains); + } - public override void AI() - { - DetermineWhipPoints(); + public override void AI() + { + DetermineWhipPoints(); - // Determines the owner's position whilst incorporating their fullRotation field. - // It uses vector transformation on a Z rotation matrix based on said rotation under the hood. - // This is essentially just the pure mathematical definition of the RotatedBy method. - Vector2 playerRotatedPosition = Owner.RotatedRelativePoint(Owner.MountedCenter); - if (Main.myPlayer == projectile.owner) - { - if (!Owner.noItems && !Owner.CCed) - HandleChannelMovement(playerRotatedPosition); - else - projectile.Kill(); - } + // Determines the owner's position whilst incorporating their fullRotation field. + // It uses vector transformation on a Z rotation matrix based on said rotation under the hood. + // This is essentially just the pure mathematical definition of the RotatedBy method. + Vector2 playerRotatedPosition = Owner.RotatedRelativePoint(Owner.MountedCenter); + if (Main.myPlayer == projectile.owner) + { + if (!Owner.noItems && !Owner.CCed) + HandleChannelMovement(playerRotatedPosition); + else + projectile.Kill(); + } - ManipulatePlayerValues(); + ManipulatePlayerValues(); - // Create a bunch of prismatic lasers outward from the non-arcing whip right before it comes back - // to its owner. - if (SwingDirection == 0f && projectile.timeLeft == FlyBackTime) - CreateBadassPrismExplosion(); - Time++; - } + // Create a bunch of prismatic lasers outward from the non-arcing whip right before it comes back + // to its owner. + if (SwingDirection == 0f && projectile.timeLeft == FlyBackTime) + CreateBadassPrismExplosion(); + Time++; + } - public void HandleChannelMovement(Vector2 playerRotatedPosition) - { - // Set the initial direction as a base for rotation. - if (InitialDirectionRotation == 0f) - InitialDirectionRotation = WhipOutwardness.ToRotation() - MathHelper.PiOver2; + public void HandleChannelMovement(Vector2 playerRotatedPosition) + { + // Set the initial direction as a base for rotation. + if (InitialDirectionRotation == 0f) + InitialDirectionRotation = WhipOutwardness.ToRotation() - MathHelper.PiOver2; - float attackCompletionRatio = Utils.InverseLerp(Lifetime, FlyBackTime, projectile.timeLeft, true); + float attackCompletionRatio = Utils.InverseLerp(Lifetime, FlyBackTime, projectile.timeLeft, true); - // Normally swing from a "cone" to a collision area that causes both whips to collide. - float baseSwingAngle = MathHelper.Lerp(-1.1f, 1.57f, 1f - attackCompletionRatio); + // Normally swing from a "cone" to a collision area that causes both whips to collide. + float baseSwingAngle = MathHelper.Lerp(-1.1f, 1.57f, 1f - attackCompletionRatio); - Vector2 swingDirection = (SwingDirection * baseSwingAngle + MathHelper.PiOver2).ToRotationVector2(); - swingDirection = swingDirection.RotatedBy(InitialDirectionRotation); + Vector2 swingDirection = (SwingDirection * baseSwingAngle + MathHelper.PiOver2).ToRotationVector2(); + swingDirection = swingDirection.RotatedBy(InitialDirectionRotation); - // If the whip is ready to return to its owner, have its outwardness approach the player again. - if (projectile.timeLeft < FlyBackTime) - WhipOutwardness = Vector2.Lerp(WhipOutwardness, InitialDirectionRotation.ToRotationVector2(), 0.1f); - else - { - // Have acceleration vary based on how much time has passed. - Vector2 swingSpeedIncrement = swingDirection * MathHelper.SmoothStep(3.8f, 13f, (float)Math.Pow(CalamityUtils.Convert01To010(Time / Lifetime), 8f)); - if (SwingDirection == 0f) - swingSpeedIncrement *= 0.84f; - WhipOutwardness += swingSpeedIncrement; - } - projectile.Center = playerRotatedPosition; - projectile.rotation = WhipOutwardness.ToRotation(); - } + // If the whip is ready to return to its owner, have its outwardness approach the player again. + if (projectile.timeLeft < FlyBackTime) + WhipOutwardness = Vector2.Lerp(WhipOutwardness, InitialDirectionRotation.ToRotationVector2(), 0.1f); + else + { + // Have acceleration vary based on how much time has passed. + Vector2 swingSpeedIncrement = swingDirection * MathHelper.SmoothStep(3.8f, 13f, (float)Math.Pow(CalamityUtils.Convert01To010(Time / Lifetime), 8f)); + if (SwingDirection == 0f) + swingSpeedIncrement *= 0.84f; + WhipOutwardness += swingSpeedIncrement; + } + projectile.Center = playerRotatedPosition; + projectile.rotation = WhipOutwardness.ToRotation(); + } - public void ManipulatePlayerValues() - { - Owner.itemTime = 2; - Owner.itemAnimation = 2; - if (SwingDirection == 0f) - { - Owner.itemRotation = WhipOutwardness.ToRotation() * projectile.direction; - Owner.ChangeDir(projectile.direction); - } - } + public void ManipulatePlayerValues() + { + Owner.itemTime = 2; + Owner.itemAnimation = 2; + if (SwingDirection == 0f) + { + Owner.itemRotation = WhipOutwardness.ToRotation() * projectile.direction; + Owner.ChangeDir(projectile.direction); + } + } - public void CreateBadassPrismExplosion() - { - var sound = Main.PlaySound(SoundID.DD2_DarkMageHealImpact, Owner.Center); - if (sound != null) - sound.Pitch = MathHelper.Clamp(sound.Pitch + 0.15f, 0f, 1f); + public void CreateBadassPrismExplosion() + { + var sound = Main.PlaySound(SoundID.DD2_DarkMageHealImpact, Owner.Center); + if (sound != null) + sound.Pitch = MathHelper.Clamp(sound.Pitch + 0.15f, 0f, 1f); - if (Main.myPlayer != projectile.owner) - return; + if (Main.myPlayer != projectile.owner) + return; - Projectile.NewProjectile(WhipEnd, Vector2.Zero, ModContent.ProjectileType(), projectile.damage * 2, 0f, projectile.owner); + Projectile.NewProjectile(WhipEnd, Vector2.Zero, ModContent.ProjectileType(), projectile.damage * 2, 0f, projectile.owner); - // Fire a bunch of rays rays. - int rayDamage = (int)(projectile.damage * 1.5); - NPC potentialTarget = WhipEnd.ClosestNPCAt(700f); - for (int i = 0; i < LaserRayCount; i++) - { - float rayRotation = projectile.rotation + MathHelper.Lerp(-0.57f, 0.57f, i / (float)LaserRayCount); - float targetAimDisparity = 0f; - if (potentialTarget != null) - targetAimDisparity = projectile.rotation.ToRotationVector2().AngleBetween((potentialTarget.Center - projectile.Center).SafeNormalize(Vector2.Zero)); + // Fire a bunch of rays rays. + int rayDamage = (int)(projectile.damage * 1.5); + NPC potentialTarget = WhipEnd.ClosestNPCAt(700f); + for (int i = 0; i < LaserRayCount; i++) + { + float rayRotation = projectile.rotation + MathHelper.Lerp(-0.57f, 0.57f, i / (float)LaserRayCount); + float targetAimDisparity = 0f; + if (potentialTarget != null) + targetAimDisparity = projectile.rotation.ToRotationVector2().AngleBetween((potentialTarget.Center - projectile.Center).SafeNormalize(Vector2.Zero)); - // By default, make the prism rays go outward a good amount based on their rotation - // to give a fan look. - Vector2 prismEndPosition = WhipEnd + rayRotation.ToRotationVector2() * 420f; - - // However, if a potential target is within the general line of sight of the whip, - // fire all lasers at it instead. This results in the entire laser spectrum appearing as one - // brilliant, blazing laser that does great damage. However, it does take some skill to do. - if (potentialTarget != null && targetAimDisparity < MathHelper.Pi * 0.27f) - prismEndPosition = potentialTarget.Center + potentialTarget.velocity * 4f; + // By default, make the prism rays go outward a good amount based on their rotation + // to give a fan look. + Vector2 prismEndPosition = WhipEnd + rayRotation.ToRotationVector2() * 420f; + + // However, if a potential target is within the general line of sight of the whip, + // fire all lasers at it instead. This results in the entire laser spectrum appearing as one + // brilliant, blazing laser that does great damage. However, it does take some skill to do. + if (potentialTarget != null && targetAimDisparity < MathHelper.Pi * 0.27f) + prismEndPosition = potentialTarget.Center + potentialTarget.velocity * 4f; - int prismRay = Projectile.NewProjectile(prismEndPosition, Vector2.Zero, ModContent.ProjectileType(), rayDamage, projectile.knockBack * 0.2f, projectile.owner); - if (Main.projectile.IndexInRange(prismRay)) - { - Main.projectile[prismRay].ModProjectile().RayHue = i / (float)LaserRayCount; - Main.projectile[prismRay].ModProjectile().StartingPosition = WhipEnd; - } - } - } + int prismRay = Projectile.NewProjectile(prismEndPosition, Vector2.Zero, ModContent.ProjectileType(), rayDamage, projectile.knockBack * 0.2f, projectile.owner); + if (Main.projectile.IndexInRange(prismRay)) + { + Main.projectile[prismRay].ModProjectile().RayHue = i / (float)LaserRayCount; + Main.projectile[prismRay].ModProjectile().StartingPosition = WhipEnd; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - for (int i = 0; i < WhipPoints.Count - 1; i++) - { - string whipTexturePath; - if (i == WhipPoints.Count - 2) - whipTexturePath = Texture; - else if (i == 0) - whipTexturePath = "CalamityMod/Projectiles/Melee/SpineOfThanatosTail"; - else - whipTexturePath = $"CalamityMod/Projectiles/Melee/SpineOfThanatosBody{i % 2 + 1}"; - Texture2D whipSegmentTexture = ModContent.GetTexture(whipTexturePath); - Texture2D whipSegmentGlowmaskTexture = ModContent.GetTexture($"{whipTexturePath}Glowmask"); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + for (int i = 0; i < WhipPoints.Count - 1; i++) + { + string whipTexturePath; + if (i == WhipPoints.Count - 2) + whipTexturePath = Texture; + else if (i == 0) + whipTexturePath = "CalamityMod/Projectiles/Melee/SpineOfThanatosTail"; + else + whipTexturePath = $"CalamityMod/Projectiles/Melee/SpineOfThanatosBody{i % 2 + 1}"; + Texture2D whipSegmentTexture = ModContent.GetTexture(whipTexturePath); + Texture2D whipSegmentGlowmaskTexture = ModContent.GetTexture($"{whipTexturePath}Glowmask"); - Vector2 origin = whipSegmentTexture.Size() * 0.5f; - float rotation = (WhipPoints[i + 1] - WhipPoints[i]).ToRotation() + MathHelper.PiOver2; - Vector2 drawPosition = WhipPoints[i] - Main.screenPosition; - Color color = projectile.GetAlpha(Lighting.GetColor((int)WhipPoints[i].X / 16, (int)WhipPoints[i].Y / 16)); - spriteBatch.Draw(whipSegmentTexture, drawPosition, null, color, rotation, origin, projectile.scale, SpriteEffects.None, 0f); - spriteBatch.Draw(whipSegmentGlowmaskTexture, drawPosition, null, Color.White, rotation, origin, projectile.scale, SpriteEffects.None, 0f); - } + Vector2 origin = whipSegmentTexture.Size() * 0.5f; + float rotation = (WhipPoints[i + 1] - WhipPoints[i]).ToRotation() + MathHelper.PiOver2; + Vector2 drawPosition = WhipPoints[i] - Main.screenPosition; + Color color = projectile.GetAlpha(Lighting.GetColor((int)WhipPoints[i].X / 16, (int)WhipPoints[i].Y / 16)); + spriteBatch.Draw(whipSegmentTexture, drawPosition, null, color, rotation, origin, projectile.scale, SpriteEffects.None, 0f); + spriteBatch.Draw(whipSegmentGlowmaskTexture, drawPosition, null, Color.White, rotation, origin, projectile.scale, SpriteEffects.None, 0f); + } - return false; - } + return false; + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (WhipPoints.Count <= 1) - return false; + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (WhipPoints.Count <= 1) + return false; - float width = projectile.scale * 38f; - for (int i = 0; i < WhipPoints.Count - 1; i++) - { - float _ = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), WhipPoints[i], WhipPoints[i + 1], width, ref _)) - return true; - } - return false; - } - } + float width = projectile.scale * 38f; + for (int i = 0; i < WhipPoints.Count - 1; i++) + { + float _ = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), WhipPoints[i], WhipPoints[i + 1], width, ref _)) + return true; + } + return false; + } + } } diff --git a/Projectiles/Melee/StarnightBeam.cs b/Projectiles/Melee/StarnightBeam.cs index 63e0f7aaf9..dea080bc1b 100644 --- a/Projectiles/Melee/StarnightBeam.cs +++ b/Projectiles/Melee/StarnightBeam.cs @@ -32,17 +32,17 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(projectile.Center, 0.4f, 0f, 0.4f); } - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 200, 200, projectile.alpha); - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override Color? GetAlpha(Color lightColor) { - if (projectile.timeLeft > 595) - return false; + return new Color(200, 200, 200, projectile.alpha); + } - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.timeLeft > 595) + return false; + + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } diff --git a/Projectiles/Melee/StellarContemptHammer.cs b/Projectiles/Melee/StellarContemptHammer.cs index 798da1e8a9..38a44f7355 100644 --- a/Projectiles/Melee/StellarContemptHammer.cs +++ b/Projectiles/Melee/StellarContemptHammer.cs @@ -9,213 +9,213 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class StellarContemptHammer : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Melee/StellarContempt"; + public class StellarContemptHammer : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/StellarContempt"; - private static float RotationIncrement = 0.22f; - private static int Lifetime = 240; - private static float ReboundTime = 26f; + private static float RotationIncrement = 0.22f; + private static int Lifetime = 240; + private static float ReboundTime = 26f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Stellar Contempt"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Stellar Contempt"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 44; - projectile.height = 44; - projectile.friendly = true; - projectile.melee = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.timeLeft = Lifetime; - } + public override void SetDefaults() + { + projectile.width = 44; + projectile.height = 44; + projectile.friendly = true; + projectile.melee = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.extraUpdates = 3; + projectile.timeLeft = Lifetime; + } - public override void AI() - { - drawOffsetX = -11; - drawOriginOffsetY = -10; - drawOriginOffsetX = 0; + public override void AI() + { + drawOffsetX = -11; + drawOriginOffsetY = -10; + drawOriginOffsetX = 0; - Lighting.AddLight(projectile.Center, 0.7f, 0.3f, 0.6f); + Lighting.AddLight(projectile.Center, 0.7f, 0.3f, 0.6f); - // The hammer makes sound while flying. - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 8; - Main.PlaySound(SoundID.Item7, (int)projectile.position.X, (int)projectile.position.Y); - } + // The hammer makes sound while flying. + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 8; + Main.PlaySound(SoundID.Item7, (int)projectile.position.X, (int)projectile.position.Y); + } - // ai[0] stores whether the hammer is returning. If 0, it isn't. If 1, it is. - if (projectile.ai[0] == 0f) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] >= ReboundTime) - { - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - } - else - { - projectile.tileCollide = false; - float returnSpeed = StellarContemptMelee.Speed; - float acceleration = 3.2f; - Player owner = Main.player[projectile.owner]; + // ai[0] stores whether the hammer is returning. If 0, it isn't. If 1, it is. + if (projectile.ai[0] == 0f) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] >= ReboundTime) + { + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + } + else + { + projectile.tileCollide = false; + float returnSpeed = StellarContemptMelee.Speed; + float acceleration = 3.2f; + Player owner = Main.player[projectile.owner]; - // Delete the hammer if it's excessively far away. - Vector2 playerCenter = owner.Center; - float xDist = playerCenter.X - projectile.Center.X; - float yDist = playerCenter.Y - projectile.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (dist > 3000f) - projectile.Kill(); + // Delete the hammer if it's excessively far away. + Vector2 playerCenter = owner.Center; + float xDist = playerCenter.X - projectile.Center.X; + float yDist = playerCenter.Y - projectile.Center.Y; + float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); + if (dist > 3000f) + projectile.Kill(); - dist = returnSpeed / dist; - xDist *= dist; - yDist *= dist; + dist = returnSpeed / dist; + xDist *= dist; + yDist *= dist; - // Home back in on the player. - if (projectile.velocity.X < xDist) - { - projectile.velocity.X = projectile.velocity.X + acceleration; - if (projectile.velocity.X < 0f && xDist > 0f) - projectile.velocity.X += acceleration; - } - else if (projectile.velocity.X > xDist) - { - projectile.velocity.X = projectile.velocity.X - acceleration; - if (projectile.velocity.X > 0f && xDist < 0f) - projectile.velocity.X -= acceleration; - } - if (projectile.velocity.Y < yDist) - { - projectile.velocity.Y = projectile.velocity.Y + acceleration; - if (projectile.velocity.Y < 0f && yDist > 0f) - projectile.velocity.Y += acceleration; - } - else if (projectile.velocity.Y > yDist) - { - projectile.velocity.Y = projectile.velocity.Y - acceleration; - if (projectile.velocity.Y > 0f && yDist < 0f) - projectile.velocity.Y -= acceleration; - } + // Home back in on the player. + if (projectile.velocity.X < xDist) + { + projectile.velocity.X = projectile.velocity.X + acceleration; + if (projectile.velocity.X < 0f && xDist > 0f) + projectile.velocity.X += acceleration; + } + else if (projectile.velocity.X > xDist) + { + projectile.velocity.X = projectile.velocity.X - acceleration; + if (projectile.velocity.X > 0f && xDist < 0f) + projectile.velocity.X -= acceleration; + } + if (projectile.velocity.Y < yDist) + { + projectile.velocity.Y = projectile.velocity.Y + acceleration; + if (projectile.velocity.Y < 0f && yDist > 0f) + projectile.velocity.Y += acceleration; + } + else if (projectile.velocity.Y > yDist) + { + projectile.velocity.Y = projectile.velocity.Y - acceleration; + if (projectile.velocity.Y > 0f && yDist < 0f) + projectile.velocity.Y -= acceleration; + } - // Delete the projectile if it touches its owner. - if (Main.myPlayer == projectile.owner) - if (projectile.Hitbox.Intersects(owner.Hitbox)) - projectile.Kill(); - } + // Delete the projectile if it touches its owner. + if (Main.myPlayer == projectile.owner) + if (projectile.Hitbox.Intersects(owner.Hitbox)) + projectile.Kill(); + } - // Rotate the hammer as it flies. - projectile.rotation += RotationIncrement; - } + // Rotate the hammer as it flies. + projectile.rotation += RotationIncrement; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - // Some dust gets produced on impact. - int dustCount = Main.rand.Next(20, 24); - int dustRadius = 6; - Vector2 corner = new Vector2(target.Center.X - dustRadius, target.Center.Y - dustRadius); - for (int i = 0; i < dustCount; ++i) - { - int dustType = 229; - float scale = 0.8f + Main.rand.NextFloat(1.1f); - int idx = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - Main.dust[idx].scale = scale; - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + // Some dust gets produced on impact. + int dustCount = Main.rand.Next(20, 24); + int dustRadius = 6; + Vector2 corner = new Vector2(target.Center.X - dustRadius, target.Center.Y - dustRadius); + for (int i = 0; i < dustCount; ++i) + { + int dustType = 229; + float scale = 0.8f + Main.rand.NextFloat(1.1f); + int idx = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, dustType); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 3f; + Main.dust[idx].scale = scale; + } - // Applies Nightwither on contact at night. - if (!Main.dayTime) - target.AddBuff(ModContent.BuffType(), 240); + // Applies Nightwither on contact at night. + if (!Main.dayTime) + target.AddBuff(ModContent.BuffType(), 240); - SpawnFlares(target.Center, target.width, target.height); - } + SpawnFlares(target.Center, target.width, target.height); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - // Some dust gets produced on impact. - int dustCount = Main.rand.Next(20, 24); - int dustRadius = 6; - Vector2 corner = new Vector2(target.Center.X - dustRadius, target.Center.Y - dustRadius); - for (int i = 0; i < dustCount; ++i) - { - int dustType = 229; - float scale = 0.8f + Main.rand.NextFloat(1.1f); - int idx = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - Main.dust[idx].scale = scale; - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + // Some dust gets produced on impact. + int dustCount = Main.rand.Next(20, 24); + int dustRadius = 6; + Vector2 corner = new Vector2(target.Center.X - dustRadius, target.Center.Y - dustRadius); + for (int i = 0; i < dustCount; ++i) + { + int dustType = 229; + float scale = 0.8f + Main.rand.NextFloat(1.1f); + int idx = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, dustType); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 3f; + Main.dust[idx].scale = scale; + } - // Applies Nightwither on contact at night. - if (!Main.dayTime) - target.AddBuff(ModContent.BuffType(), 240); + // Applies Nightwither on contact at night. + if (!Main.dayTime) + target.AddBuff(ModContent.BuffType(), 240); - SpawnFlares(target.Center, target.width, target.height); - } + SpawnFlares(target.Center, target.width, target.height); + } - private void SpawnFlares(Vector2 targetPos, int width, int height) - { - // Play the Lunar Flare sound centered on the user, not the target (consistent with Lunar Flare and Stellar Striker) - Player user = Main.player[projectile.owner]; - Main.PlaySound(SoundID.Item88, projectile.position); - projectile.netUpdate = true; + private void SpawnFlares(Vector2 targetPos, int width, int height) + { + // Play the Lunar Flare sound centered on the user, not the target (consistent with Lunar Flare and Stellar Striker) + Player user = Main.player[projectile.owner]; + Main.PlaySound(SoundID.Item88, projectile.position); + projectile.netUpdate = true; - int numFlares = 2; - int flareDamage = (int)(0.3f * projectile.damage); - float flareKB = 4f; - for (int i = 0; i < numFlares; ++i) - { - float flareSpeed = Main.rand.NextFloat(8f, 11f); + int numFlares = 2; + int flareDamage = (int)(0.3f * projectile.damage); + float flareKB = 4f; + for (int i = 0; i < numFlares; ++i) + { + float flareSpeed = Main.rand.NextFloat(8f, 11f); - // Flares never come from straight up, there is always at least an 80 pixel horizontal offset - float xDist = Main.rand.NextFloat(80f, 320f) * (Main.rand.NextBool() ? -1f : 1f); - float yDist = Main.rand.NextFloat(1200f, 1440f); - Vector2 startPoint = targetPos + new Vector2(xDist, -yDist); + // Flares never come from straight up, there is always at least an 80 pixel horizontal offset + float xDist = Main.rand.NextFloat(80f, 320f) * (Main.rand.NextBool() ? -1f : 1f); + float yDist = Main.rand.NextFloat(1200f, 1440f); + Vector2 startPoint = targetPos + new Vector2(xDist, -yDist); - // The flare is somewhat inaccurate based on the size of the target. - float xVariance = width / 4f; - if (xVariance < 8f) - xVariance = 8f; - float yVariance = height / 4f; - if (yVariance < 8f) - yVariance = 8f; - float xOffset = Main.rand.NextFloat(-xVariance, xVariance); - float yOffset = Main.rand.NextFloat(-yVariance, yVariance); - Vector2 offsetTarget = targetPos + new Vector2(xOffset, yOffset); + // The flare is somewhat inaccurate based on the size of the target. + float xVariance = width / 4f; + if (xVariance < 8f) + xVariance = 8f; + float yVariance = height / 4f; + if (yVariance < 8f) + yVariance = 8f; + float xOffset = Main.rand.NextFloat(-xVariance, xVariance); + float yOffset = Main.rand.NextFloat(-yVariance, yVariance); + Vector2 offsetTarget = targetPos + new Vector2(xOffset, yOffset); - // Finalize the velocity vector and make sure it's going at the right speed. - Vector2 velocity = offsetTarget - startPoint; - velocity.Normalize(); - velocity *= flareSpeed; + // Finalize the velocity vector and make sure it's going at the right speed. + Vector2 velocity = offsetTarget - startPoint; + velocity.Normalize(); + velocity *= flareSpeed; - float AI1 = Main.rand.Next(3); - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(startPoint, velocity, ProjectileID.LunarFlare, flareDamage, flareKB, Main.myPlayer, 0f, AI1); - if (proj.WithinBounds(Main.maxProjectiles)) - { - CalamityGlobalProjectile cgp = Main.projectile[proj].Calamity(); - cgp.forceMelee = true; - } - } - } - } - } + float AI1 = Main.rand.Next(3); + if (projectile.owner == Main.myPlayer) + { + int proj = Projectile.NewProjectile(startPoint, velocity, ProjectileID.LunarFlare, flareDamage, flareKB, Main.myPlayer, 0f, AI1); + if (proj.WithinBounds(Main.maxProjectiles)) + { + CalamityGlobalProjectile cgp = Main.projectile[proj].Calamity(); + cgp.forceMelee = true; + } + } + } + } + } } diff --git a/Projectiles/Melee/StormBeam.cs b/Projectiles/Melee/StormBeam.cs index e2b58b54fd..9e12201233 100644 --- a/Projectiles/Melee/StormBeam.cs +++ b/Projectiles/Melee/StormBeam.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Melee { Lighting.AddLight(projectile.Center, 0f, 0.25f, 0.25f); - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); - } + CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 200f, 12f, 20f); + } public override void Kill(int timeLeft) { @@ -43,10 +43,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 595) - return false; + if (projectile.timeLeft > 595) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } } diff --git a/Projectiles/Melee/StormRulerProj.cs b/Projectiles/Melee/StormRulerProj.cs index 021a64ac08..4c9633fb8d 100644 --- a/Projectiles/Melee/StormRulerProj.cs +++ b/Projectiles/Melee/StormRulerProj.cs @@ -63,10 +63,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 595) - return false; + if (projectile.timeLeft > 595) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } } diff --git a/Projectiles/Melee/StreamGougePortal.cs b/Projectiles/Melee/StreamGougePortal.cs index b530433292..2f18b23461 100644 --- a/Projectiles/Melee/StreamGougePortal.cs +++ b/Projectiles/Melee/StreamGougePortal.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class StreamGougePortal : ModProjectile + public class StreamGougePortal : ModProjectile { public Vector2 SpearCenter => Vector2.Lerp(projectile.Center + projectile.velocity + projectile.velocity.SafeNormalize(Vector2.Zero) * 42f, projectile.Center, 1f - projectile.scale); public ref float Time => ref projectile.ai[0]; diff --git a/Projectiles/Melee/SulphurousGrabberBubble.cs b/Projectiles/Melee/SulphurousGrabberBubble.cs index 5d21701135..3b2a15a946 100644 --- a/Projectiles/Melee/SulphurousGrabberBubble.cs +++ b/Projectiles/Melee/SulphurousGrabberBubble.cs @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Melee { projectile.velocity.X *= 0.9f; projectile.velocity.Y *= 0.9f; - if (Main.rand.NextBool(5)) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + if (Main.rand.NextBool(5)) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/SulphurousGrabberBubble2.cs b/Projectiles/Melee/SulphurousGrabberBubble2.cs index 65de3db2d5..d2a4433105 100644 --- a/Projectiles/Melee/SulphurousGrabberBubble2.cs +++ b/Projectiles/Melee/SulphurousGrabberBubble2.cs @@ -26,11 +26,11 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - projectile.ai[0]++; + projectile.ai[0]++; projectile.velocity.X *= 0.9f; projectile.velocity.Y *= 0.9f; - if (Main.rand.NextBool(5)) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + if (Main.rand.NextBool(5)) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/SwordsplosionBlue.cs b/Projectiles/Melee/SwordsplosionBlue.cs index a97b31413a..da0668c385 100644 --- a/Projectiles/Melee/SwordsplosionBlue.cs +++ b/Projectiles/Melee/SwordsplosionBlue.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SwordsplosionBlue : ModProjectile + public class SwordsplosionBlue : ModProjectile { public override void SetStaticDefaults() { @@ -48,10 +48,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 195) - return false; + if (projectile.timeLeft > 195) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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; } @@ -67,9 +67,9 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } } } diff --git a/Projectiles/Melee/SwordsplosionGreen.cs b/Projectiles/Melee/SwordsplosionGreen.cs index f26978bd24..52b8ddd669 100644 --- a/Projectiles/Melee/SwordsplosionGreen.cs +++ b/Projectiles/Melee/SwordsplosionGreen.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SwordsplosionGreen : ModProjectile + public class SwordsplosionGreen : ModProjectile { public override void SetStaticDefaults() { @@ -47,10 +47,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 295) - return false; + if (projectile.timeLeft > 295) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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; } @@ -66,9 +66,9 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } } } diff --git a/Projectiles/Melee/SwordsplosionPurple.cs b/Projectiles/Melee/SwordsplosionPurple.cs index 51e4d03007..a32f0f6007 100644 --- a/Projectiles/Melee/SwordsplosionPurple.cs +++ b/Projectiles/Melee/SwordsplosionPurple.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SwordsplosionPurple : ModProjectile + public class SwordsplosionPurple : ModProjectile { public override void SetStaticDefaults() @@ -48,10 +48,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 295) - return false; + if (projectile.timeLeft > 295) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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; } @@ -67,9 +67,9 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } } } diff --git a/Projectiles/Melee/SwordsplosionRed.cs b/Projectiles/Melee/SwordsplosionRed.cs index a82bf926f5..2789d6416c 100644 --- a/Projectiles/Melee/SwordsplosionRed.cs +++ b/Projectiles/Melee/SwordsplosionRed.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class SwordsplosionRed : ModProjectile + public class SwordsplosionRed : ModProjectile { public override void SetStaticDefaults() { @@ -48,10 +48,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 195) - return false; + if (projectile.timeLeft > 195) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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; } @@ -67,9 +67,9 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } } } diff --git a/Projectiles/Melee/TaintedBladeSlasher.cs b/Projectiles/Melee/TaintedBladeSlasher.cs index 2ee223d54a..ef539f833b 100644 --- a/Projectiles/Melee/TaintedBladeSlasher.cs +++ b/Projectiles/Melee/TaintedBladeSlasher.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TaintedBladeSlasher : ModProjectile + public class TaintedBladeSlasher : ModProjectile { internal PrimitiveTrail TrailDrawer = null; public ref float SwordItemID => ref projectile.ai[1]; @@ -118,7 +118,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 90000; projectile.usesLocalNPCImmunity = true; projectile.noEnchantments = true; - projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override void SendExtraAI(BinaryWriter writer) => writer.Write(VerticalOffset); diff --git a/Projectiles/Melee/TemporalFloeNumberTwo.cs b/Projectiles/Melee/TemporalFloeNumberTwo.cs index c1dd8a1907..40e9ebeae3 100644 --- a/Projectiles/Melee/TemporalFloeNumberTwo.cs +++ b/Projectiles/Melee/TemporalFloeNumberTwo.cs @@ -24,10 +24,10 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.penetrate = -1; projectile.timeLeft = 60; - projectile.coldDamage = true; + projectile.coldDamage = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.tileCollide = false; + projectile.tileCollide = false; } public override void AI() @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D tex = Main.projectileTexture[projectile.type]; + 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/Melee/TemporalFloeSwordProjectile.cs b/Projectiles/Melee/TemporalFloeSwordProjectile.cs index 27dea6a23e..596fbfce9e 100644 --- a/Projectiles/Melee/TemporalFloeSwordProjectile.cs +++ b/Projectiles/Melee/TemporalFloeSwordProjectile.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TemporalFloeSwordProjectile : ModProjectile + public class TemporalFloeSwordProjectile : ModProjectile { public override void SetStaticDefaults() { @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.penetrate = 1; projectile.timeLeft = 600; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() @@ -36,10 +36,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 595) - return false; + if (projectile.timeLeft > 595) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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; } @@ -81,24 +81,24 @@ namespace CalamityMod.Projectiles.Melee if (intTime > 12) intTime -= 12; - float projSpeed = 8f; + 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 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; + 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; + 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); + 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/Melee/TenebreusTidesWaterProjectile.cs b/Projectiles/Melee/TenebreusTidesWaterProjectile.cs index af1ceb7004..61166530e7 100644 --- a/Projectiles/Melee/TenebreusTidesWaterProjectile.cs +++ b/Projectiles/Melee/TenebreusTidesWaterProjectile.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TenebreusTidesWaterProjectile : ModProjectile + public class TenebreusTidesWaterProjectile : ModProjectile { public override void SetStaticDefaults() { @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Melee projectile.ignoreWater = true; projectile.usesIDStaticNPCImmunity = true; projectile.idStaticNPCHitCooldown = 10; - projectile.tileCollide = false; + projectile.tileCollide = false; aiType = ProjectileID.LightBeam; } @@ -44,8 +44,8 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft == 300) - return false; + if (projectile.timeLeft == 300) + return false; CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Melee projectile.position.Y -= (float)(projectile.height / 2); for (int dustIndex = 0; dustIndex <= 30; dustIndex++) { - Vector2 dustVel = new Vector2(Main.rand.Next(-10, 11), Main.rand.Next(-10, 11)); + Vector2 dustVel = new Vector2(Main.rand.Next(-10, 11), Main.rand.Next(-10, 11)); float dustSpeed = (float)Main.rand.Next(3, 9); float dist = dustVel.Length(); dist = dustSpeed / dist; @@ -96,10 +96,10 @@ namespace CalamityMod.Projectiles.Melee int projAmt = 3; for (int i = 0; i < projAmt; ++i) { - int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); if (projectile.owner == Main.myPlayer) { - CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(25f, 35f), type, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner); + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(25f, 35f), type, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner); } } } diff --git a/Projectiles/Melee/TenebreusTidesWaterSpear.cs b/Projectiles/Melee/TenebreusTidesWaterSpear.cs index a917e5c6ea..d8c0167d81 100644 --- a/Projectiles/Melee/TenebreusTidesWaterSpear.cs +++ b/Projectiles/Melee/TenebreusTidesWaterSpear.cs @@ -7,13 +7,13 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TenebreusTidesWaterSpear : ModProjectile + public class TenebreusTidesWaterSpear : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Magic/UndinesRetributionSpear"; private int penetrationAmt = 4; - private bool dontDraw = false; - private int drawInt = 0; + private bool dontDraw = false; + private int drawInt = 0; public override void SetStaticDefaults() { @@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 5; - projectile.tileCollide = false; - projectile.ignoreWater = true; - } + projectile.tileCollide = false; + projectile.ignoreWater = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -66,10 +66,10 @@ namespace CalamityMod.Projectiles.Melee projectile.localAI[0] += 1f; if (projectile.localAI[0] > 7f) { - int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); - Main.dust[water].noGravity = true; - Main.dust[water].velocity *= 0.5f; - Main.dust[water].velocity += projectile.velocity * 0.1f; + int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); + Main.dust[water].noGravity = true; + Main.dust[water].velocity *= 0.5f; + Main.dust[water].velocity += projectile.velocity * 0.1f; } float scalar = 0.01f; int alphaAmt = 5; @@ -140,7 +140,7 @@ namespace CalamityMod.Projectiles.Melee projectile.netUpdate = true; projectile.ai[0] += (float)penetrationAmt; projectile.position = targetSpot + ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * 100f - new Vector2((float)projectile.width, (float)projectile.height) / 2f; - dontDraw = true; + dontDraw = true; projectile.velocity = Vector2.Normalize(targetSpot - projectile.Center) * 18f; } else @@ -149,10 +149,10 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.NextBool(3)) { - int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); - Main.dust[water].noGravity = true; - Main.dust[water].velocity *= 0.5f; - Main.dust[water].velocity += projectile.velocity * 0.1f; + int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); + Main.dust[water].noGravity = true; + Main.dust[water].velocity *= 0.5f; + Main.dust[water].velocity += projectile.velocity * 0.1f; } } @@ -181,34 +181,34 @@ namespace CalamityMod.Projectiles.Melee projectile.localAI[0] += 1f; - int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); - Main.dust[water].noGravity = true; - Main.dust[water].velocity *= 0.5f; - Main.dust[water].velocity += projectile.velocity * 0.1f; + int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); + Main.dust[water].noGravity = true; + Main.dust[water].velocity *= 0.5f; + Main.dust[water].velocity += projectile.velocity * 0.1f; } Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, 0f, 0f, (255 - projectile.alpha) * 1f / 255f); - if (dontDraw) - drawInt++; - if (drawInt > 1) - { - drawInt = 0; - dontDraw = false; - } + if (dontDraw) + drawInt++; + if (drawInt > 1) + { + drawInt = 0; + dontDraw = false; + } } public override Color? GetAlpha(Color lightColor) => new Color(50, 50, 255, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (dontDraw) - return false; + if (dontDraw) + return false; Texture2D texture = Main.projectileTexture[projectile.type]; int height = texture.Height / Main.projFrames[projectile.type]; int frameHeight = height * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); return false; } @@ -244,7 +244,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/Melee/TenebreusTidesWaterSword.cs b/Projectiles/Melee/TenebreusTidesWaterSword.cs index e4caa78fcf..ad74619dca 100644 --- a/Projectiles/Melee/TenebreusTidesWaterSword.cs +++ b/Projectiles/Melee/TenebreusTidesWaterSword.cs @@ -7,11 +7,11 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TenebreusTidesWaterSword : ModProjectile + public class TenebreusTidesWaterSword : ModProjectile { private int penetrationAmt = 4; - private bool dontDraw = false; - private int drawInt = 0; + private bool dontDraw = false; + private int drawInt = 0; public override void SetStaticDefaults() { @@ -28,9 +28,9 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 5; - projectile.tileCollide = false; - projectile.ignoreWater = true; - } + projectile.tileCollide = false; + projectile.ignoreWater = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -52,10 +52,10 @@ namespace CalamityMod.Projectiles.Melee projectile.localAI[0] += 1f; if (projectile.localAI[0] > 7f) { - int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); - Main.dust[water].noGravity = true; - Main.dust[water].velocity *= 0.5f; - Main.dust[water].velocity += projectile.velocity * 0.1f; + int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); + Main.dust[water].noGravity = true; + Main.dust[water].velocity *= 0.5f; + Main.dust[water].velocity += projectile.velocity * 0.1f; } float scalar = 0.01f; int alphaAmt = 5; @@ -126,7 +126,7 @@ namespace CalamityMod.Projectiles.Melee projectile.netUpdate = true; projectile.ai[0] += (float)penetrationAmt; projectile.position = targetSpot + ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * 100f - new Vector2((float)projectile.width, (float)projectile.height) / 2f; - dontDraw = true; + dontDraw = true; projectile.velocity = Vector2.Normalize(targetSpot - projectile.Center) * 18f; } else @@ -135,10 +135,10 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.NextBool(3)) { - int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); - Main.dust[water].noGravity = true; - Main.dust[water].velocity *= 0.5f; - Main.dust[water].velocity += projectile.velocity * 0.1f; + int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); + Main.dust[water].noGravity = true; + Main.dust[water].velocity *= 0.5f; + Main.dust[water].velocity += projectile.velocity * 0.1f; } } @@ -167,32 +167,32 @@ namespace CalamityMod.Projectiles.Melee projectile.localAI[0] += 1f; - int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); - Main.dust[water].noGravity = true; - Main.dust[water].velocity *= 0.5f; - Main.dust[water].velocity += projectile.velocity * 0.1f; + int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 0.4f); + Main.dust[water].noGravity = true; + Main.dust[water].velocity *= 0.5f; + Main.dust[water].velocity += projectile.velocity * 0.1f; } Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, 0f, 0f, (255 - projectile.alpha) * 1f / 255f); - if (dontDraw) - drawInt++; - if (drawInt > 1) - { - drawInt = 0; - dontDraw = false; - } + if (dontDraw) + drawInt++; + if (drawInt > 1) + { + drawInt = 0; + dontDraw = false; + } } public override Color? GetAlpha(Color lightColor) => new Color(50, 50, 255, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (dontDraw) - return false; + if (dontDraw) + return false; Texture2D texture = Main.projectileTexture[projectile.type]; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)texture.Height / 2f), projectile.scale, spriteEffects, 0f); return false; } @@ -228,7 +228,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/Melee/TerraSpear.cs b/Projectiles/Melee/TerraSpear.cs index db9072058e..d44ca9fed3 100644 --- a/Projectiles/Melee/TerraSpear.cs +++ b/Projectiles/Melee/TerraSpear.cs @@ -76,10 +76,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 175) - return false; + if (projectile.timeLeft > 175) + return false; - Texture2D tex = Main.projectileTexture[projectile.type]; + 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/Melee/TerracottaExplosion.cs b/Projectiles/Melee/TerracottaExplosion.cs index 9a82fbc045..32732df08f 100644 --- a/Projectiles/Melee/TerracottaExplosion.cs +++ b/Projectiles/Melee/TerracottaExplosion.cs @@ -23,9 +23,9 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.penetrate = -1; projectile.timeLeft = 5; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 10; - } + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 10; + } public override void AI() { diff --git a/Projectiles/Melee/TerratomereProjectile.cs b/Projectiles/Melee/TerratomereProjectile.cs index 9e783bdddc..512fd60f4b 100644 --- a/Projectiles/Melee/TerratomereProjectile.cs +++ b/Projectiles/Melee/TerratomereProjectile.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TerratomereProjectile : ModProjectile + public class TerratomereProjectile : ModProjectile { public override void SetStaticDefaults() { @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); Lighting.AddLight(projectile.Center, 0f, (255 - projectile.alpha) * 0.75f / 255f, 0f); } diff --git a/Projectiles/Melee/ThanatosBoom.cs b/Projectiles/Melee/ThanatosBoom.cs index 0ba6527497..5e1f3c483b 100644 --- a/Projectiles/Melee/ThanatosBoom.cs +++ b/Projectiles/Melee/ThanatosBoom.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ThanatosBoom : ModProjectile + public class ThanatosBoom : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Melee/ThornBase.cs b/Projectiles/Melee/ThornBase.cs index d969aa4c32..5957657200 100644 --- a/Projectiles/Melee/ThornBase.cs +++ b/Projectiles/Melee/ThornBase.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ThornBase : ModProjectile + public class ThornBase : ModProjectile { public override void SetStaticDefaults() { @@ -13,56 +13,56 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { - projectile.width = 28; - projectile.height = 28; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.tileCollide = false; - projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.melee = true; - projectile.aiStyle = 4; + projectile.width = 28; + projectile.height = 28; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.melee = true; + projectile.aiStyle = 4; } - public override void AI() - { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; - if (projectile.ai[0] == 0f) - { - projectile.alpha -= 50; - if (projectile.alpha > 0) - return; - projectile.alpha = 0; - projectile.ai[0] = 1f; - if (projectile.ai[1] == 0f) - { - projectile.ai[1] += 1f; - projectile.position += projectile.velocity * 1f; - } - if (Main.myPlayer == projectile.owner) - { - int type = projectile.type; - if (projectile.ai[1] >= 6f) - type = ModContent.ProjectileType(); - int number = Projectile.NewProjectile(projectile.position.X + projectile.velocity.X + (float)(projectile.width / 2), projectile.position.Y + projectile.velocity.Y + (float)(projectile.height / 2), projectile.velocity.X, projectile.velocity.Y, type, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[number].ai[1] = projectile.ai[1] + 1f; - } - } - else - { - if (projectile.alpha < 170 && projectile.alpha + 5 >= 170) - { - for (int index = 0; index < 3; ++index) - { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 18, projectile.velocity.X * 0.025f, projectile.velocity.Y * 0.025f, 170, new Color(), 1.2f); - } - Dust.NewDust(projectile.position, projectile.width, projectile.height, 14, 0f, 0f, 170, new Color(), 1.1f); - } - projectile.alpha += 3; - if (projectile.alpha < 255) - return; - projectile.Kill(); - } - } + public override void AI() + { + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; + if (projectile.ai[0] == 0f) + { + projectile.alpha -= 50; + if (projectile.alpha > 0) + return; + projectile.alpha = 0; + projectile.ai[0] = 1f; + if (projectile.ai[1] == 0f) + { + projectile.ai[1] += 1f; + projectile.position += projectile.velocity * 1f; + } + if (Main.myPlayer == projectile.owner) + { + int type = projectile.type; + if (projectile.ai[1] >= 6f) + type = ModContent.ProjectileType(); + int number = Projectile.NewProjectile(projectile.position.X + projectile.velocity.X + (float)(projectile.width / 2), projectile.position.Y + projectile.velocity.Y + (float)(projectile.height / 2), projectile.velocity.X, projectile.velocity.Y, type, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Main.projectile[number].ai[1] = projectile.ai[1] + 1f; + } + } + else + { + if (projectile.alpha < 170 && projectile.alpha + 5 >= 170) + { + for (int index = 0; index < 3; ++index) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 18, projectile.velocity.X * 0.025f, projectile.velocity.Y * 0.025f, 170, new Color(), 1.2f); + } + Dust.NewDust(projectile.position, projectile.width, projectile.height, 14, 0f, 0f, 170, new Color(), 1.1f); + } + projectile.alpha += 3; + if (projectile.alpha < 255) + return; + projectile.Kill(); + } + } } } diff --git a/Projectiles/Melee/ThornTip.cs b/Projectiles/Melee/ThornTip.cs index 883c990d6c..8e5a9a060e 100644 --- a/Projectiles/Melee/ThornTip.cs +++ b/Projectiles/Melee/ThornTip.cs @@ -2,7 +2,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class ThornTip : ModProjectile + public class ThornTip : ModProjectile { public override void SetStaticDefaults() { @@ -11,16 +11,16 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { - projectile.width = 28; - projectile.height = 28; - projectile.aiStyle = 4; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.tileCollide = false; - projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.melee = true; - aiType = ProjectileID.VilethornTip; + projectile.width = 28; + projectile.height = 28; + projectile.aiStyle = 4; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.melee = true; + aiType = ProjectileID.VilethornTip; } } } diff --git a/Projectiles/Melee/TinyCrystal.cs b/Projectiles/Melee/TinyCrystal.cs index 7ee1b948b2..f661f764dd 100644 --- a/Projectiles/Melee/TinyCrystal.cs +++ b/Projectiles/Melee/TinyCrystal.cs @@ -25,52 +25,52 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 90; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 75 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 75 && target.CanBeChasedBy(projectile); - public override void AI() - { - int dustType = projectile.ai[0] == 0f ? 56 : 73; - for (int num92 = 0; num92 < 2; num92++) - { - float num93 = projectile.velocity.X / 3f * (float)num92; - 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, dustType, 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; - } + public override void AI() + { + int dustType = projectile.ai[0] == 0f ? 56 : 73; + for (int num92 = 0; num92 < 2; num92++) + { + float num93 = projectile.velocity.X / 3f * (float)num92; + 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, dustType, 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; + } - if (Main.rand.NextBool(10)) - { - int num97 = 4; - int num98 = Dust.NewDust(new Vector2(projectile.position.X + (float)num97, projectile.position.Y + (float)num97), projectile.width - num97 * 2, projectile.height - num97 * 2, dustType, 0f, 0f, 100, default, 0.6f); - Main.dust[num98].velocity *= 0.25f; - Main.dust[num98].velocity += projectile.velocity * 0.5f; - } + if (Main.rand.NextBool(10)) + { + int num97 = 4; + int num98 = Dust.NewDust(new Vector2(projectile.position.X + (float)num97, projectile.position.Y + (float)num97), projectile.width - num97 * 2, projectile.height - num97 * 2, dustType, 0f, 0f, 100, default, 0.6f); + Main.dust[num98].velocity *= 0.25f; + Main.dust[num98].velocity += projectile.velocity * 0.5f; + } - if (projectile.timeLeft < 75) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 9f, 20f); - } + if (projectile.timeLeft < 75) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 9f, 20f); + } public override void Kill(int timeLeft) { - int dustType = projectile.ai[0] == 0f ? 56 : 73; - for (int k = 0; k < 5; k++) + int dustType = projectile.ai[0] == 0f ? 56 : 73; + for (int k = 0; k < 5; k++) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, dustType, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); - } - Main.PlaySound(SoundID.Item10, projectile.position); - } + } + Main.PlaySound(SoundID.Item10, projectile.position); + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - int buffType = projectile.ai[0] == 0f ? BuffID.Frostburn : BuffID.OnFire; - target.AddBuff(buffType, 90); - } + int buffType = projectile.ai[0] == 0f ? BuffID.Frostburn : BuffID.OnFire; + target.AddBuff(buffType, 90); + } } } diff --git a/Projectiles/Melee/TinyFlare.cs b/Projectiles/Melee/TinyFlare.cs index 762acb0030..030222d459 100644 --- a/Projectiles/Melee/TinyFlare.cs +++ b/Projectiles/Melee/TinyFlare.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TinyFlare : ModProjectile + public class TinyFlare : ModProjectile { public override void SetStaticDefaults() { @@ -25,9 +25,9 @@ namespace CalamityMod.Projectiles.Melee projectile.extraUpdates = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { for (int num468 = 0; num468 < 3; num468++) { @@ -36,8 +36,8 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num469].velocity *= 0f; } - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 10f, 20f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 10f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/Tornado.cs b/Projectiles/Melee/Tornado.cs index 2b70ce8b31..54b5c9b37f 100644 --- a/Projectiles/Melee/Tornado.cs +++ b/Projectiles/Melee/Tornado.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class Tornado : ModProjectile + public class Tornado : ModProjectile { public override string Texture => "CalamityMod/Projectiles/TornadoProj"; @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - //only 3 tornado can exist at a time + //only 3 tornado can exist at a time projectile.localAI[1] += 1f; if (projectile.localAI[1] >= 10f) { @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Melee int projType = projectile.type; for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) { - Projectile proj = Main.projectile[projIndex]; + Projectile proj = Main.projectile[projIndex]; if (proj.active && proj.owner == projectile.owner && proj.type == projType && proj.ai[0] < 900f) { projCount++; diff --git a/Projectiles/Melee/TriactisHammerProj.cs b/Projectiles/Melee/TriactisHammerProj.cs index 99d37ebeea..c3c26dbef8 100644 --- a/Projectiles/Melee/TriactisHammerProj.cs +++ b/Projectiles/Melee/TriactisHammerProj.cs @@ -8,155 +8,155 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TriactisHammerProj : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMightMelee"; + public class TriactisHammerProj : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMightMelee"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Triactis' True Paladinian Mage-Hammer of Might"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Triactis' True Paladinian Mage-Hammer of Might"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 160; - projectile.height = 160; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.melee = true; - } + public override void SetDefaults() + { + projectile.width = 160; + projectile.height = 160; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.extraUpdates = 3; + projectile.melee = true; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0f, 0.5f, 0.75f); - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 8; - Main.PlaySound(SoundID.Item7, projectile.position); - } - if (projectile.ai[0] == 0f) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 30f) - { - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - } - else - { - projectile.tileCollide = false; - float num42 = 20f; - float num43 = 5f; - Vector2 vector2 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f); - float num44 = Main.player[projectile.owner].position.X + Main.player[projectile.owner].width / 2 - vector2.X; - float num45 = Main.player[projectile.owner].position.Y + Main.player[projectile.owner].height / 2 - vector2.Y; - float num46 = (float)Math.Sqrt(num44 * num44 + num45 * num45); - if (num46 > 3000f) - projectile.Kill(); - num46 = num42 / num46; - num44 *= num46; - num45 *= num46; - if (projectile.velocity.X < num44) - { - projectile.velocity.X = projectile.velocity.X + num43; - if (projectile.velocity.X < 0f && num44 > 0f) - projectile.velocity.X = projectile.velocity.X + num43; - } - else if (projectile.velocity.X > num44) - { - projectile.velocity.X = projectile.velocity.X - num43; - if (projectile.velocity.X > 0f && num44 < 0f) - projectile.velocity.X = projectile.velocity.X - num43; - } - if (projectile.velocity.Y < num45) - { - projectile.velocity.Y = projectile.velocity.Y + num43; - if (projectile.velocity.Y < 0f && num45 > 0f) - projectile.velocity.Y = projectile.velocity.Y + num43; - } - else if (projectile.velocity.Y > num45) - { - projectile.velocity.Y = projectile.velocity.Y - num43; - if (projectile.velocity.Y > 0f && num45 < 0f) - projectile.velocity.Y = projectile.velocity.Y - num43; - } - if (Main.myPlayer == projectile.owner) - { - Rectangle rectangle = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); - Rectangle value2 = new Rectangle((int)Main.player[projectile.owner].position.X, (int)Main.player[projectile.owner].position.Y, Main.player[projectile.owner].width, Main.player[projectile.owner].height); - if (rectangle.Intersects(value2)) - projectile.Kill(); - } - } - projectile.rotation += 0.5f; - } + public override void AI() + { + Lighting.AddLight(projectile.Center, 0f, 0.5f, 0.75f); + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 8; + Main.PlaySound(SoundID.Item7, projectile.position); + } + if (projectile.ai[0] == 0f) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] >= 30f) + { + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + } + else + { + projectile.tileCollide = false; + float num42 = 20f; + float num43 = 5f; + Vector2 vector2 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f); + float num44 = Main.player[projectile.owner].position.X + Main.player[projectile.owner].width / 2 - vector2.X; + float num45 = Main.player[projectile.owner].position.Y + Main.player[projectile.owner].height / 2 - vector2.Y; + float num46 = (float)Math.Sqrt(num44 * num44 + num45 * num45); + if (num46 > 3000f) + projectile.Kill(); + num46 = num42 / num46; + num44 *= num46; + num45 *= num46; + if (projectile.velocity.X < num44) + { + projectile.velocity.X = projectile.velocity.X + num43; + if (projectile.velocity.X < 0f && num44 > 0f) + projectile.velocity.X = projectile.velocity.X + num43; + } + else if (projectile.velocity.X > num44) + { + projectile.velocity.X = projectile.velocity.X - num43; + if (projectile.velocity.X > 0f && num44 < 0f) + projectile.velocity.X = projectile.velocity.X - num43; + } + if (projectile.velocity.Y < num45) + { + projectile.velocity.Y = projectile.velocity.Y + num43; + if (projectile.velocity.Y < 0f && num45 > 0f) + projectile.velocity.Y = projectile.velocity.Y + num43; + } + else if (projectile.velocity.Y > num45) + { + projectile.velocity.Y = projectile.velocity.Y - num43; + if (projectile.velocity.Y > 0f && num45 < 0f) + projectile.velocity.Y = projectile.velocity.Y - num43; + } + if (Main.myPlayer == projectile.owner) + { + Rectangle rectangle = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); + Rectangle value2 = new Rectangle((int)Main.player[projectile.owner].position.X, (int)Main.player[projectile.owner].position.Y, Main.player[projectile.owner].width, Main.player[projectile.owner].height); + if (rectangle.Intersects(value2)) + projectile.Kill(); + } + } + projectile.rotation += 0.5f; + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 250, 250, 50); - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(250, 250, 250, 50); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (projectile.owner == Main.myPlayer) - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, 0f); - Main.PlaySound(SoundID.Item14, projectile.position); - for (int num621 = 0; num621 < 40; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 70; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (projectile.owner == Main.myPlayer) + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, 0f); + Main.PlaySound(SoundID.Item14, projectile.position); + for (int num621 = 0; num621 < 40; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 70; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - if (projectile.owner == Main.myPlayer) - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, 0f); - Main.PlaySound(SoundID.Item14, projectile.position); - for (int num621 = 0; num621 < 40; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 70; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + if (projectile.owner == Main.myPlayer) + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, 0f); + Main.PlaySound(SoundID.Item14, projectile.position); + for (int num621 = 0; num621 < 40; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 70; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(2) ? 89 : 229, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Melee/TrueAncientBeam.cs b/Projectiles/Melee/TrueAncientBeam.cs index eeae48806c..87e12a8c39 100644 --- a/Projectiles/Melee/TrueAncientBeam.cs +++ b/Projectiles/Melee/TrueAncientBeam.cs @@ -11,7 +11,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class TrueAncientBeam : ModProjectile //The boring plain one + public class TrueAncientBeam : ModProjectile //The boring plain one { public override string Texture => "CalamityMod/Items/Weapons/Melee/TrueArkoftheAncientsGlow"; diff --git a/Projectiles/Melee/TrueAncientBlast.cs b/Projectiles/Melee/TrueAncientBlast.cs index f417c582f9..3fcf5d2d26 100644 --- a/Projectiles/Melee/TrueAncientBlast.cs +++ b/Projectiles/Melee/TrueAncientBlast.cs @@ -11,7 +11,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class TrueAncientBlast : ModProjectile + public class TrueAncientBlast : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs b/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs index d0d12b148c..dbab7d8edd 100644 --- a/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs +++ b/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs @@ -12,7 +12,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class TrueArkoftheAncientsParryHoldout : ModProjectile + public class TrueArkoftheAncientsParryHoldout : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/TrueArkoftheAncients"; diff --git a/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs b/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs index 82873636ea..d8d44f49ed 100644 --- a/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs +++ b/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class TrueArkoftheAncientsSwungBlade : ModProjectile + public class TrueArkoftheAncientsSwungBlade : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/TrueArkoftheAncients"; diff --git a/Projectiles/Melee/TrueBiomeBlade_ChainedMeatHook.cs b/Projectiles/Melee/TrueBiomeBlade_ChainedMeatHook.cs index 8c9b8a81ab..82571a05f3 100644 --- a/Projectiles/Melee/TrueBiomeBlade_ChainedMeatHook.cs +++ b/Projectiles/Melee/TrueBiomeBlade_ChainedMeatHook.cs @@ -12,7 +12,7 @@ using CalamityMod.DataStructures; namespace CalamityMod.Projectiles.Melee { - public class ChainedMeatHook : ModProjectile + public class ChainedMeatHook : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedHook"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/TrueBiomeBlade_GhastlyChain.cs b/Projectiles/Melee/TrueBiomeBlade_GhastlyChain.cs index a738b24b06..b246eb8127 100644 --- a/Projectiles/Melee/TrueBiomeBlade_GhastlyChain.cs +++ b/Projectiles/Melee/TrueBiomeBlade_GhastlyChain.cs @@ -9,7 +9,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class GhastlyChain : ModProjectile + public class GhastlyChain : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedChain"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs b/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs index 902afda9a0..74c3d9c698 100644 --- a/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs +++ b/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs @@ -13,7 +13,7 @@ using CalamityMod.Items.Weapons.Melee; namespace CalamityMod.Projectiles.Melee { - public class LamentationsOfTheChained : ModProjectile + public class LamentationsOfTheChained : ModProjectile { private NPC[] excludedTargets = new NPC[4]; diff --git a/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs b/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs index b3b218df8f..15934e0941 100644 --- a/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs +++ b/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs @@ -13,7 +13,7 @@ using CalamityMod.Particles; namespace CalamityMod.Projectiles.Melee { - public class MercurialTides : ModProjectile + public class MercurialTides : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_MercurialTides"; private bool initialized = false; diff --git a/Projectiles/Melee/TrueBiomeBlade_MercurialTidesMonolith.cs b/Projectiles/Melee/TrueBiomeBlade_MercurialTidesMonolith.cs index cea0fc1878..abc4e7d289 100644 --- a/Projectiles/Melee/TrueBiomeBlade_MercurialTidesMonolith.cs +++ b/Projectiles/Melee/TrueBiomeBlade_MercurialTidesMonolith.cs @@ -13,7 +13,7 @@ using CalamityMod.Items.Weapons.Melee; namespace CalamityMod.Projectiles.Melee { - public class MercurialTidesMonolith : ModProjectile + public class MercurialTidesMonolith : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_MercurialTidesMonolith"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/TrueBiomeBlade_MercurialTidesShockwave.cs b/Projectiles/Melee/TrueBiomeBlade_MercurialTidesShockwave.cs index 82221940ba..a91b2c3671 100644 --- a/Projectiles/Melee/TrueBiomeBlade_MercurialTidesShockwave.cs +++ b/Projectiles/Melee/TrueBiomeBlade_MercurialTidesShockwave.cs @@ -10,7 +10,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { - public class MercurialTidesBlast : ModProjectile + public class MercurialTidesBlast : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_MercurialTidesShockwave"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs b/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs index 2428244abb..cc50223f30 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs @@ -12,7 +12,7 @@ using CalamityMod.Particles; namespace CalamityMod.Projectiles.Melee { - public class SanguineFury : ModProjectile + public class SanguineFury : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_SanguineFury"; private bool initialized = false; diff --git a/Projectiles/Melee/TrueBiomeBlade_SanguineFuryDash.cs b/Projectiles/Melee/TrueBiomeBlade_SanguineFuryDash.cs index 84f6d19d40..9291911a5d 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SanguineFuryDash.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SanguineFuryDash.cs @@ -9,7 +9,7 @@ using CalamityMod.Particles; namespace CalamityMod.Projectiles.Melee { - public class SanguineFuryDash : ModProjectile + public class SanguineFuryDash : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs b/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs index 291b339dd2..c014ba4234 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs @@ -9,7 +9,7 @@ using CalamityMod.Particles; namespace CalamityMod.Projectiles.Melee { - public class SanguineFuryWheel : ModProjectile + public class SanguineFuryWheel : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_SanguineFuryExtra"; private bool initialized = false; diff --git a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs index 62ed3d4258..f3ae3321b2 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs @@ -13,7 +13,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee { - public class SwordsmithsPride : ModProjectile + public class SwordsmithsPride : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride"; private bool initialized = false; diff --git a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideBeam.cs b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideBeam.cs index 91ddd7635b..a6a105d225 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideBeam.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideBeam.cs @@ -11,7 +11,7 @@ using CalamityMod.Buffs.StatDebuffs; namespace CalamityMod.Projectiles.Melee { - public class SwordsmithsPrideBeam : ModProjectile + public class SwordsmithsPrideBeam : ModProjectile { public NPC target; public Player Owner => Main.player[projectile.owner]; diff --git a/Projectiles/Melee/TrueCausticEdgeProjectile.cs b/Projectiles/Melee/TrueCausticEdgeProjectile.cs index b308d92c8b..6c2ce843ca 100644 --- a/Projectiles/Melee/TrueCausticEdgeProjectile.cs +++ b/Projectiles/Melee/TrueCausticEdgeProjectile.cs @@ -35,10 +35,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 595) - return false; + if (projectile.timeLeft > 595) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); return false; } diff --git a/Projectiles/Melee/TyphonsGreedBubble.cs b/Projectiles/Melee/TyphonsGreedBubble.cs index 817cb3b77a..0fab0a8d6f 100644 --- a/Projectiles/Melee/TyphonsGreedBubble.cs +++ b/Projectiles/Melee/TyphonsGreedBubble.cs @@ -46,10 +46,10 @@ namespace CalamityMod.Projectiles.Melee { projectile.spriteDirection = -projectile.direction; } - projectile.rotation = projectile.velocity.ToRotation(); + projectile.rotation = projectile.velocity.ToRotation(); Lighting.AddLight(projectile.Center, 0f, 0.1f, 0.7f); - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (player.active && !player.dead) { if (projectile.Distance(player.Center) > num954) @@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); } public override void Kill(int timeLeft) @@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage /= 2; + projectile.damage /= 2; projectile.Damage(); } } diff --git a/Projectiles/Melee/TyphonsGreedStaff.cs b/Projectiles/Melee/TyphonsGreedStaff.cs index 4c6a257a09..b2d5f6262b 100644 --- a/Projectiles/Melee/TyphonsGreedStaff.cs +++ b/Projectiles/Melee/TyphonsGreedStaff.cs @@ -137,8 +137,8 @@ namespace CalamityMod.Projectiles.Melee { if (projectile.owner == Main.myPlayer) { - Projectile bubble = CalamityUtils.ProjectileBarrage(projectile.Center, player.Center, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, true); - bubble.ai[1] = Main.rand.NextFloat() + 0.5f; + Projectile bubble = CalamityUtils.ProjectileBarrage(projectile.Center, player.Center, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, true); + bubble.ai[1] = Main.rand.NextFloat() + 0.5f; } } } diff --git a/Projectiles/Melee/UltimusCleaverDust.cs b/Projectiles/Melee/UltimusCleaverDust.cs index 6c52362304..11d8f15354 100644 --- a/Projectiles/Melee/UltimusCleaverDust.cs +++ b/Projectiles/Melee/UltimusCleaverDust.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class UltimusCleaverDust : ModProjectile + public class UltimusCleaverDust : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -16,8 +16,8 @@ namespace CalamityMod.Projectiles.Melee projectile.width = 6; projectile.height = 12; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 2; + projectile.ignoreWater = true; + projectile.penetrate = 2; projectile.timeLeft = 90; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; @@ -92,7 +92,7 @@ namespace CalamityMod.Projectiles.Melee projectile.velocity.Y = 16f; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 150f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 150f, 12f, 20f); } } } diff --git a/Projectiles/Melee/UrchinBall.cs b/Projectiles/Melee/UrchinBall.cs index 8517b1ddb8..c28910c676 100644 --- a/Projectiles/Melee/UrchinBall.cs +++ b/Projectiles/Melee/UrchinBall.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; Vector2 vector62 = player.Center - projectile.Center; projectile.rotation = vector62.ToRotation() - 1.57f; if (player.dead) diff --git a/Projectiles/Melee/ViolenceSlashProjectile.cs b/Projectiles/Melee/ViolenceSlashProjectile.cs index 90f645103c..a0e34caf8b 100644 --- a/Projectiles/Melee/ViolenceSlashProjectile.cs +++ b/Projectiles/Melee/ViolenceSlashProjectile.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Melee projectile.extraUpdates = 1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 6; - projectile.tileCollide = false; + projectile.tileCollide = false; } public override void AI() diff --git a/Projectiles/Melee/VoidEssence.cs b/Projectiles/Melee/VoidEssence.cs index f50278f8c4..1aaaf9215b 100644 --- a/Projectiles/Melee/VoidEssence.cs +++ b/Projectiles/Melee/VoidEssence.cs @@ -133,10 +133,10 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 95) - return false; + if (projectile.timeLeft > 95) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } diff --git a/Projectiles/Melee/Waterfall.cs b/Projectiles/Melee/Waterfall.cs index cb2887f311..fa3e1c434b 100644 --- a/Projectiles/Melee/Waterfall.cs +++ b/Projectiles/Melee/Waterfall.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Beam"); - } + } public override void SetDefaults() { @@ -60,12 +60,12 @@ namespace CalamityMod.Projectiles.Melee expr_4815_cp_0.position.Y -= num100; } - projectile.ai[1] += 1f; + projectile.ai[1] += 1f; if (projectile.ai[1] >= 60f) projectile.tileCollide = true; } - public override bool OnTileCollide(Vector2 oldVelocity) + public override bool OnTileCollide(Vector2 oldVelocity) { projectile.penetrate--; if (projectile.penetrate <= 0) diff --git a/Projectiles/Melee/Whiterain.cs b/Projectiles/Melee/Whiterain.cs index 19380e7d0a..b528cc8fbc 100644 --- a/Projectiles/Melee/Whiterain.cs +++ b/Projectiles/Melee/Whiterain.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class Whiterain : ModProjectile + public class Whiterain : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity += projectile.velocity * 0.1f; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); } } } diff --git a/Projectiles/Melee/WhiterainBlah.cs b/Projectiles/Melee/WhiterainBlah.cs index 9848814ddd..00eab5438d 100644 --- a/Projectiles/Melee/WhiterainBlah.cs +++ b/Projectiles/Melee/WhiterainBlah.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class WhiterainBlah : ModProjectile + public class WhiterainBlah : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num458].velocity += projectile.velocity * 0.1f; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); } } } diff --git a/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs b/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs index 6668747b03..f961244035 100644 --- a/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs +++ b/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Yoyos { - public class AirSpinnerYoyo : ModProjectile + public class AirSpinnerYoyo : ModProjectile { public override void SetStaticDefaults() { @@ -29,15 +29,15 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 60f, 5, ModContent.ProjectileType(), 0.25); - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 60f, 5, ModContent.ProjectileType(), 0.25); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/Yoyos/AortaYoyo.cs b/Projectiles/Melee/Yoyos/AortaYoyo.cs index 6d8a19767e..2e07e185d5 100644 --- a/Projectiles/Melee/Yoyos/AortaYoyo.cs +++ b/Projectiles/Melee/Yoyos/AortaYoyo.cs @@ -29,18 +29,18 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } - public override void AI() - { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 240f, 6f, 180f, 3, ModContent.ProjectileType(), 0.25); - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); - } + public override void AI() + { + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 240f, 6f, 180f, 3, ModContent.ProjectileType(), 0.25); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; diff --git a/Projectiles/Melee/Yoyos/AzathothYoyo.cs b/Projectiles/Melee/Yoyos/AzathothYoyo.cs index 05ab6b164a..03489221ca 100644 --- a/Projectiles/Melee/Yoyos/AzathothYoyo.cs +++ b/Projectiles/Melee/Yoyos/AzathothYoyo.cs @@ -40,8 +40,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (projectile.owner == Main.myPlayer) Projectile.NewProjectile(projectile.Center, projectile.velocity * 0.35f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs b/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs index 25811d7f0e..e004843e11 100644 --- a/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs +++ b/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs @@ -30,22 +30,22 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { if (Main.rand.NextBool(5)) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.NextBool(3) ? 16 : 127, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - if (Main.rand.NextBool(8)) - { - int smoke = Gore.NewGore(projectile.position, default, Main.rand.Next(375, 378), 0.5f); - Main.gore[smoke].behindTiles = true; - } - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + if (Main.rand.NextBool(8)) + { + int smoke = Gore.NewGore(projectile.position, default, Main.rand.Next(375, 378), 0.5f); + Main.gore[smoke].behindTiles = true; + } + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -54,8 +54,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (projectile.owner == Main.myPlayer) { int boom = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (boom.WithinBounds(Main.maxProjectiles)) - Main.projectile[boom].Calamity().forceMelee = true; + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceMelee = true; } } diff --git a/Projectiles/Melee/Yoyos/CnidarianYoyo.cs b/Projectiles/Melee/Yoyos/CnidarianYoyo.cs index bf2addb6b9..b3bbaf97d8 100644 --- a/Projectiles/Melee/Yoyos/CnidarianYoyo.cs +++ b/Projectiles/Melee/Yoyos/CnidarianYoyo.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Yoyos { - public class CnidarianYoyo : ModProjectile + public class CnidarianYoyo : ModProjectile { public override void SetStaticDefaults() { @@ -26,16 +26,16 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - } + projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 180f, 5, ModContent.ProjectileType(), 0.75); - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 180f, 5, ModContent.ProjectileType(), 0.75); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs b/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs index e1029e3e4b..33f68226a1 100644 --- a/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs +++ b/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Yoyos { - public class GodsGambitYoyo : ModProjectile + public class GodsGambitYoyo : ModProjectile { public override void SetStaticDefaults() { @@ -25,16 +25,16 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - } + projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 30f, 5, ProjectileID.SlimeGun, 0.75); - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 30f, 5, ProjectileID.SlimeGun, 0.75); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/Yoyos/LaceratorYoyo.cs b/Projectiles/Melee/Yoyos/LaceratorYoyo.cs index 201017c0db..de32042a8d 100644 --- a/Projectiles/Melee/Yoyos/LaceratorYoyo.cs +++ b/Projectiles/Melee/Yoyos/LaceratorYoyo.cs @@ -33,11 +33,11 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.localNPCHitCooldown = 8; } - public override void AI() - { - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); - } + public override void AI() + { + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs b/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs index f0bbfe3267..572ad626cf 100644 --- a/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs +++ b/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Yoyos { - public class ObliteratorYoyo : ModProjectile + public class ObliteratorYoyo : ModProjectile { private const int FramesPerShot = 5; @@ -45,8 +45,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos // localAI[1] counts up to 19 (4 x 5 - 1), then resets back to 0 for a 20-frame cycle. public override void AI() { - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); // Only do stuff once per frame, despite the yoyo's extra updates. extraUpdateCounter = (extraUpdateCounter + 1) % UpdatesPerFrame; @@ -104,8 +104,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(laserSpawnPosition, velocity, ModContent.ProjectileType(), laserDamage, laserKB, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } } } diff --git a/Projectiles/Melee/Yoyos/OblivionYoyo.cs b/Projectiles/Melee/Yoyos/OblivionYoyo.cs index ed5938b300..20786bf122 100644 --- a/Projectiles/Melee/Yoyos/OblivionYoyo.cs +++ b/Projectiles/Melee/Yoyos/OblivionYoyo.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Yoyos { - public class OblivionYoyo : ModProjectile + public class OblivionYoyo : ModProjectile { public override void SetStaticDefaults() { @@ -28,16 +28,16 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - } + projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 48f, 5, ModContent.ProjectileType(), 0.5); - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 48f, 5, ModContent.ProjectileType(), 0.5); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/Yoyos/PandemicYoyo.cs b/Projectiles/Melee/Yoyos/PandemicYoyo.cs index c4000a93f6..e4863483c9 100644 --- a/Projectiles/Melee/Yoyos/PandemicYoyo.cs +++ b/Projectiles/Melee/Yoyos/PandemicYoyo.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Yoyos { - public class PandemicYoyo : ModProjectile + public class PandemicYoyo : ModProjectile { public override void SetStaticDefaults() { @@ -26,16 +26,16 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - } + projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 180f, 5, ModContent.ProjectileType(), 0.75); - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 180f, 5, ModContent.ProjectileType(), 0.75); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/Yoyos/QuagmireYoyo.cs b/Projectiles/Melee/Yoyos/QuagmireYoyo.cs index 77126dd571..da8515ef30 100644 --- a/Projectiles/Melee/Yoyos/QuagmireYoyo.cs +++ b/Projectiles/Melee/Yoyos/QuagmireYoyo.cs @@ -25,14 +25,14 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } public override void AI() { - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); if (Main.rand.NextBool(5)) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 44, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); if (projectile.owner == Main.myPlayer) @@ -41,32 +41,32 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (Main.rand.NextBool(10)) { proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.35f, projectile.velocity.Y * 0.35f, ProjectileID.SporeGas, (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 30; - } + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 30; + } } if (Main.rand.NextBool(30)) { proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, ProjectileID.SporeGas2, (int)(projectile.damage * 0.6), projectile.knockBack, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 30; - } + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 30; + } } if (Main.rand.NextBool(50)) { proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.15f, projectile.velocity.Y * 0.15f, ProjectileID.SporeGas3, (int)(projectile.damage * 0.7), projectile.knockBack, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 30; - } + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 30; + } } } } diff --git a/Projectiles/Melee/Yoyos/RiptideYoyo.cs b/Projectiles/Melee/Yoyos/RiptideYoyo.cs index 5c53857f7f..dc13750757 100644 --- a/Projectiles/Melee/Yoyos/RiptideYoyo.cs +++ b/Projectiles/Melee/Yoyos/RiptideYoyo.cs @@ -24,15 +24,15 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.alpha = 150; projectile.penetrate = -1; - projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - } + projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); if (Main.rand.NextBool(90)) { switch (Main.rand.Next(1, 9)) diff --git a/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs b/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs index bd4b4337bb..c49e9ad5de 100644 --- a/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs +++ b/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Yoyos { - public class ShimmersparkYoyo : ModProjectile + public class ShimmersparkYoyo : ModProjectile { public override void SetStaticDefaults() { @@ -25,16 +25,16 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - } + projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 120f, 5, ProjectileID.HallowStar); - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 120f, 5, ProjectileID.HallowStar); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs b/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs index 951d6954ec..f08fefa735 100644 --- a/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs +++ b/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs @@ -39,8 +39,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos { if (Main.rand.NextBool(5)) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 244, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -49,8 +49,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } } diff --git a/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs b/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs index 4ea86694f0..c61cf9cf20 100644 --- a/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs +++ b/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs @@ -8,12 +8,12 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Yoyos { - public class SulphurousGrabberYoyo : ModProjectile + public class SulphurousGrabberYoyo : ModProjectile { - private int bubbleCounter = 0; - private bool bubbleStronk = false; - private int bubbleStronkCounter = 0; - private float arbitraryTimer = 0f; + private int bubbleCounter = 0; + private bool bubbleStronk = false; + private int bubbleStronkCounter = 0; + private float arbitraryTimer = 0f; public override void SetStaticDefaults() { @@ -35,68 +35,68 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } public override void AI() { - if (projectile.owner == Main.myPlayer) - { - if (bubbleStronk) - { - ProjectileID.Sets.YoyosTopSpeed[projectile.type] = 20f; - projectile.extraUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10 * projectile.extraUpdates; - bubbleStronkCounter++; - } - else - { - ProjectileID.Sets.YoyosTopSpeed[projectile.type] = 16f; - projectile.extraUpdates = 1; - projectile.usesLocalNPCImmunity = false; - bubbleStronkCounter = 0; - } + if (projectile.owner == Main.myPlayer) + { + if (bubbleStronk) + { + ProjectileID.Sets.YoyosTopSpeed[projectile.type] = 20f; + projectile.extraUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10 * projectile.extraUpdates; + bubbleStronkCounter++; + } + else + { + ProjectileID.Sets.YoyosTopSpeed[projectile.type] = 16f; + projectile.extraUpdates = 1; + projectile.usesLocalNPCImmunity = false; + bubbleStronkCounter = 0; + } - if (bubbleStronkCounter >= 240) - bubbleStronk = false; + if (bubbleStronkCounter >= 240) + bubbleStronk = false; - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile proj = Main.projectile[i]; - if (proj.active && proj.type == ModContent.ProjectileType() && proj.ai[0] >= 40f && proj.owner == projectile.owner) - { - if (projectile.Hitbox.Intersects(proj.Hitbox)) - { - proj.Kill(); - bubbleStronk = true; - bubbleStronkCounter = 0; - break; - } - } - } + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.type == ModContent.ProjectileType() && proj.ai[0] >= 40f && proj.owner == projectile.owner) + { + if (projectile.Hitbox.Intersects(proj.Hitbox)) + { + proj.Kill(); + bubbleStronk = true; + bubbleStronkCounter = 0; + break; + } + } + } - arbitraryTimer += bubbleStronk ? 0.5f : 1f; + arbitraryTimer += bubbleStronk ? 0.5f : 1f; - bubbleCounter++; - if (bubbleCounter >= 60) - { - int bubbleAmt = 7; - for (float i = 0; i < bubbleAmt; i++) - { - int projType = ModContent.ProjectileType(); - if (Main.rand.NextBool(10)) - projType = ModContent.ProjectileType(); - float angle = MathHelper.TwoPi / bubbleAmt * i + (float)Math.Sin(arbitraryTimer / 20f) * MathHelper.PiOver2; - Projectile.NewProjectile(projectile.Center, angle.ToRotationVector2() * 8f, projType, projectile.damage / 4, projectile.knockBack / 4, projectile.owner); - } - bubbleCounter = 0; - } - } + bubbleCounter++; + if (bubbleCounter >= 60) + { + int bubbleAmt = 7; + for (float i = 0; i < bubbleAmt; i++) + { + int projType = ModContent.ProjectileType(); + if (Main.rand.NextBool(10)) + projType = ModContent.ProjectileType(); + float angle = MathHelper.TwoPi / bubbleAmt * i + (float)Math.Sin(arbitraryTimer / 20f) * MathHelper.PiOver2; + Projectile.NewProjectile(projectile.Center, angle.ToRotationVector2() * 8f, projType, projectile.damage / 4, projectile.knockBack / 4, projectile.owner); + } + bubbleCounter = 0; + } + } - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -105,7 +105,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); if (bubbleStronk) { - tex = ModContent.GetTexture("CalamityMod/Projectiles/Melee/Yoyos/SulphurousGrabberYoyoBubble"); + tex = ModContent.GetTexture("CalamityMod/Projectiles/Melee/Yoyos/SulphurousGrabberYoyoBubble"); CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1, tex); } return false; diff --git a/Projectiles/Melee/Yoyos/VerdantYoyo.cs b/Projectiles/Melee/Yoyos/VerdantYoyo.cs index 758b45ac1c..92197f6db5 100644 --- a/Projectiles/Melee/Yoyos/VerdantYoyo.cs +++ b/Projectiles/Melee/Yoyos/VerdantYoyo.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Yoyos { - public class VerdantYoyo : ModProjectile + public class VerdantYoyo : ModProjectile { public override void SetStaticDefaults() { @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; + projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 9; } @@ -40,10 +40,10 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (Main.rand.NextBool(5)) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 75, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 12f, 54f, 5, ProjectileID.CrystalLeafShot, 0.8); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 12f, 54f, 5, ProjectileID.CrystalLeafShot, 0.8); - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/Yoyos/YinYoyo.cs b/Projectiles/Melee/Yoyos/YinYoyo.cs index a6cb99b6ae..132277db2d 100644 --- a/Projectiles/Melee/Yoyos/YinYoyo.cs +++ b/Projectiles/Melee/Yoyos/YinYoyo.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Yoyos { - public class YinYoyo : ModProjectile + public class YinYoyo : ModProjectile { public override void SetStaticDefaults() { @@ -25,16 +25,16 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - } + projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 10f, 144f, 5, Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType()); - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 10f, 144f, 5, Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType()); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Pets/Akato.cs b/Projectiles/Pets/Akato.cs index 6aa169688e..13ccc7fabe 100644 --- a/Projectiles/Pets/Akato.cs +++ b/Projectiles/Pets/Akato.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class Akato : ModProjectile + public class Akato : ModProjectile { public override void SetStaticDefaults() { @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - projectile.FloatingPetAI(true, 0.02f); + projectile.FloatingPetAI(true, 0.02f); projectile.frameCounter++; if (projectile.frameCounter > 6) { diff --git a/Projectiles/Pets/BabyGhostBell.cs b/Projectiles/Pets/BabyGhostBell.cs index d85eb5a67f..10798b29e0 100644 --- a/Projectiles/Pets/BabyGhostBell.cs +++ b/Projectiles/Pets/BabyGhostBell.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class BabyGhostBell : ModProjectile + public class BabyGhostBell : ModProjectile { private bool underwater = false; @@ -51,8 +51,8 @@ namespace CalamityMod.Projectiles.Pets else { Lighting.AddLight(projectile.Center, 0.1f, 0.3f, 0.5f); - } - projectile.FloatingPetAI(false, 0.05f, true); + } + projectile.FloatingPetAI(false, 0.05f, true); projectile.frameCounter++; if (projectile.frameCounter > 6) { diff --git a/Projectiles/Pets/BendyPet.cs b/Projectiles/Pets/BendyPet.cs index 62b0184678..c34c5016f1 100644 --- a/Projectiles/Pets/BendyPet.cs +++ b/Projectiles/Pets/BendyPet.cs @@ -32,11 +32,11 @@ namespace CalamityMod.Projectiles.Pets public override void AI() { - //Set up namespaces + //Set up namespaces Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - //If the player dies or something, kill thte projectile + //If the player dies or something, kill thte projectile if (!player.active) { projectile.active = false; @@ -47,13 +47,13 @@ namespace CalamityMod.Projectiles.Pets modPlayer.bendyPet = false; } - //Prevent the projectile from losing its timeLeft + //Prevent the projectile from losing its timeLeft if (modPlayer.bendyPet) { projectile.timeLeft = 2; } - //Update frames + //Update frames projectile.frameCounter++; if (projectile.frameCounter > 6) { @@ -65,25 +65,25 @@ namespace CalamityMod.Projectiles.Pets projectile.frame = 0; } - //Highlight nearby danger sources - player.dangerSense = true; - player.detectCreature = true; + //Highlight nearby danger sources + player.dangerSense = true; + player.detectCreature = true; - //Generate less light if returning to the player - if (projectile.localAI[0] == 0f) - { - Lighting.AddLight(projectile.Center, 0.8118f, 0.2529f, 1.3294f); //138, 43, 226 - } - else - { - Lighting.AddLight(projectile.Center, 0.4329f, 0.1349f, 0.709f); - } + //Generate less light if returning to the player + if (projectile.localAI[0] == 0f) + { + Lighting.AddLight(projectile.Center, 0.8118f, 0.2529f, 1.3294f); //138, 43, 226 + } + else + { + Lighting.AddLight(projectile.Center, 0.4329f, 0.1349f, 0.709f); + } float idleMvt = 0.2f; float projSpeed = 5f; - //Calculate where the pet should reside based on pressed controls - Vector2 projVec = player.Center - projectile.Center; - projVec.Y += player.gfxOffY; + //Calculate where the pet should reside based on pressed controls + Vector2 projVec = player.Center - projectile.Center; + projVec.Y += player.gfxOffY; if (player.controlLeft) { projVec.X -= 120f; @@ -111,16 +111,16 @@ namespace CalamityMod.Projectiles.Pets projectile.position.Y += projVec.Y; } - //Returning to player AI + //Returning to player AI if (projectile.localAI[0] == 1f) { - //If close enough, the player isn't moving too much, and isn't moving vertically, return to normal + //If close enough, the player isn't moving too much, and isn't moving vertically, return to normal if (playerDist < 10f && Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y) < projSpeed && player.velocity.Y == 0f) { projectile.localAI[0] = 0f; } - //Go faster + //Go faster projSpeed = 12f; if (playerDist < projSpeed) { @@ -134,7 +134,7 @@ namespace CalamityMod.Projectiles.Pets projectile.velocity.Y = projVec.Y * playerDist; } - //Set projectile direction and rotation + //Set projectile direction and rotation if (projectile.velocity.X > 0.5f) { projectile.direction = -1; @@ -148,13 +148,13 @@ namespace CalamityMod.Projectiles.Pets return; } - //If too far, return to the player + //If too far, return to the player if (playerDist > 200f) { projectile.localAI[0] = 1f; } - //Set projectile direction and rotation + //Set projectile direction and rotation if (projectile.velocity.X > 0.5f) { projectile.direction = -1; @@ -214,7 +214,7 @@ namespace CalamityMod.Projectiles.Pets } } - //Rotation if moving + //Rotation if moving if (projectile.velocity.X != 0f || projectile.velocity.Y != 0f) { projectile.rotation = projectile.velocity.X * 0.05f; @@ -226,32 +226,32 @@ namespace CalamityMod.Projectiles.Pets Texture2D texture = Main.projectileTexture[projectile.type]; int height = texture.Height / Main.projFrames[projectile.type]; int frameHeight = height * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); return false; } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/BendyPetGlow"); - int height = texture.Height / Main.projFrames[projectile.type]; - int frameHeight = height * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - Color rainbow = CalamityUtils.MulticolorLerp(Main.GlobalTime / 2f % 1f, new Color[] + int height = texture.Height / Main.projFrames[projectile.type]; + int frameHeight = height * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + Color rainbow = CalamityUtils.MulticolorLerp(Main.GlobalTime / 2f % 1f, new Color[] { - new Color(255, 0, 0, 50), //Red - new Color(255, 255, 0, 50), //Yellow - new Color(0, 255, 0, 50), //Green - new Color(0, 255, 255, 50), //Cyan - new Color(0, 0, 255, 50), //Blue - new Color(255, 0, 255, 50), //Fuschia + new Color(255, 0, 0, 50), //Red + new Color(255, 255, 0, 50), //Yellow + new Color(0, 255, 0, 50), //Green + new Color(0, 255, 255, 50), //Cyan + new Color(0, 0, 255, 50), //Blue + new Color(255, 0, 255, 50), //Fuschia }); - spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), rainbow, projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); - } + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), rainbow, projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); + } } } diff --git a/Projectiles/Pets/ChibiiDoggo.cs b/Projectiles/Pets/ChibiiDoggo.cs index b18e585483..04838a9b6e 100644 --- a/Projectiles/Pets/ChibiiDoggo.cs +++ b/Projectiles/Pets/ChibiiDoggo.cs @@ -241,7 +241,7 @@ namespace CalamityMod.Projectiles.Pets } player.RemoveAllIFrames(); - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) SpawnDoggo(); } projectile.netUpdate = true; diff --git a/Projectiles/Pets/FlakPet.cs b/Projectiles/Pets/FlakPet.cs index 1b3e7ce35c..336a41b607 100644 --- a/Projectiles/Pets/FlakPet.cs +++ b/Projectiles/Pets/FlakPet.cs @@ -9,8 +9,8 @@ namespace CalamityMod.Projectiles.Pets { private int playerStill = 0; private bool fly = false; - private int idleTimer = 0; - private bool hiding = false; + private int idleTimer = 0; + private bool hiding = false; public override void SetStaticDefaults() { @@ -116,53 +116,53 @@ namespace CalamityMod.Projectiles.Pets } } } - if (projectile.position.X == projectile.oldPosition.X && projectile.position.Y == projectile.oldPosition.Y && projectile.velocity.X == 0) - { - if (!hiding) - { - idleTimer++; - projectile.frame = 2; - } - if (idleTimer > 300) - { - hiding = true; - if (projectile.frame > 0) - { - projectile.frameCounter++; - if (projectile.frameCounter > 3) - { - projectile.frame--; - projectile.frameCounter = 0; - } - if (projectile.frame < 0) - { - projectile.frame = 0; - } - } - } - } - else if (projectile.velocity.Y > 0.3f && projectile.position.Y != projectile.oldPosition.Y) - { - idleTimer = 0; - hiding = false; - projectile.frame = 2; - projectile.frameCounter = 0; - } - else - { - idleTimer = 0; - hiding = false; - projectile.frameCounter++; - if (projectile.frameCounter > 6) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 5) - { - projectile.frame = 2; - } - } + if (projectile.position.X == projectile.oldPosition.X && projectile.position.Y == projectile.oldPosition.Y && projectile.velocity.X == 0) + { + if (!hiding) + { + idleTimer++; + projectile.frame = 2; + } + if (idleTimer > 300) + { + hiding = true; + if (projectile.frame > 0) + { + projectile.frameCounter++; + if (projectile.frameCounter > 3) + { + projectile.frame--; + projectile.frameCounter = 0; + } + if (projectile.frame < 0) + { + projectile.frame = 0; + } + } + } + } + else if (projectile.velocity.Y > 0.3f && projectile.position.Y != projectile.oldPosition.Y) + { + idleTimer = 0; + hiding = false; + projectile.frame = 2; + projectile.frameCounter = 0; + } + else + { + idleTimer = 0; + hiding = false; + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 5) + { + projectile.frame = 2; + } + } } else if (fly) { @@ -255,10 +255,10 @@ namespace CalamityMod.Projectiles.Pets projectile.velocity.Y = projectile.velocity.Y - num16 * 2f; } } - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * projectile.direction; + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * projectile.direction; projectile.frame = 6; - hiding = false; - idleTimer = 0; + hiding = false; + idleTimer = 0; } if (projectile.velocity.X > 0.25f) { diff --git a/Projectiles/Pets/LadShark.cs b/Projectiles/Pets/LadShark.cs index ca2258bcfd..bed4347013 100644 --- a/Projectiles/Pets/LadShark.cs +++ b/Projectiles/Pets/LadShark.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Pets projectile.friendly = true; projectile.penetrate = -1; projectile.timeLeft *= 5; - projectile.aiStyle = 26; - aiType = ProjectileID.BabySkeletronHead; + projectile.aiStyle = 26; + aiType = ProjectileID.BabySkeletronHead; } public override void AI() @@ -45,45 +45,45 @@ namespace CalamityMod.Projectiles.Pets } projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; - //occasionally burst in hearts - if (Main.rand.NextBool(10000)) - { - if (projectile.owner == Main.myPlayer) - { - int heartCount = Main.rand.Next(20, 31); - for (int i = 0; i < heartCount; i++) - { - Vector2 velocity = new Vector2((float)Main.rand.Next(-10, 11), (float)Main.rand.Next(-10, 11)); - velocity.Normalize(); - velocity.X *= 0.66f; - int heart = Gore.NewGore(projectile.Center, velocity * Main.rand.NextFloat(3f, 5f) * 0.33f, 331, Main.rand.NextFloat(40f, 120f) * 0.01f); - Main.gore[heart].sticky = false; - Main.gore[heart].velocity *= 5f; - } + //occasionally burst in hearts + if (Main.rand.NextBool(10000)) + { + if (projectile.owner == Main.myPlayer) + { + int heartCount = Main.rand.Next(20, 31); + for (int i = 0; i < heartCount; i++) + { + Vector2 velocity = new Vector2((float)Main.rand.Next(-10, 11), (float)Main.rand.Next(-10, 11)); + velocity.Normalize(); + velocity.X *= 0.66f; + int heart = Gore.NewGore(projectile.Center, velocity * Main.rand.NextFloat(3f, 5f) * 0.33f, 331, Main.rand.NextFloat(40f, 120f) * 0.01f); + Main.gore[heart].sticky = false; + Main.gore[heart].velocity *= 5f; + } - Main.PlaySound(SoundID.Zombie, (int)projectile.position.X, (int)projectile.position.Y, 15); //mouse squeak sound + Main.PlaySound(SoundID.Zombie, (int)projectile.position.X, (int)projectile.position.Y, 15); //mouse squeak sound - float radius = 240f; // 15 blocks - for (int j = 0; j < Main.maxNPCs; j++) - { - NPC npc = Main.npc[j]; - if (npc.active && !npc.dontTakeDamage && Vector2.Distance(projectile.Center, npc.Center) <= radius) - { - if (npc.Calamity().ladHearts <= 0) - npc.Calamity().ladHearts = CalamityUtils.SecondsToFrames(9f); - } - } - for (int k = 0; k < Main.maxPlayers; k++) - { - Player players = Main.player[k]; - if (!players.dead && Vector2.Distance(projectile.Center, players.Center) <= radius) - { - if (players.Calamity().ladHearts <= 0) - players.Calamity().ladHearts = CalamityUtils.SecondsToFrames(9f); - } - } - } - } + float radius = 240f; // 15 blocks + for (int j = 0; j < Main.maxNPCs; j++) + { + NPC npc = Main.npc[j]; + if (npc.active && !npc.dontTakeDamage && Vector2.Distance(projectile.Center, npc.Center) <= radius) + { + if (npc.Calamity().ladHearts <= 0) + npc.Calamity().ladHearts = CalamityUtils.SecondsToFrames(9f); + } + } + for (int k = 0; k < Main.maxPlayers; k++) + { + Player players = Main.player[k]; + if (!players.dead && Vector2.Distance(projectile.Center, players.Center) <= radius) + { + if (players.Calamity().ladHearts <= 0) + players.Calamity().ladHearts = CalamityUtils.SecondsToFrames(9f); + } + } + } + } } } } diff --git a/Projectiles/Pets/LeviPet.cs b/Projectiles/Pets/LeviPet.cs index 8a0f51d3f5..53020c9a74 100644 --- a/Projectiles/Pets/LeviPet.cs +++ b/Projectiles/Pets/LeviPet.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class LeviPet : ModProjectile + public class LeviPet : ModProjectile { public override void SetStaticDefaults() { @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - projectile.FloatingPetAI(false, 0.05f); + projectile.FloatingPetAI(false, 0.05f); projectile.frameCounter++; if (projectile.frameCounter > 6) { diff --git a/Projectiles/Pets/LittleLightProj.cs b/Projectiles/Pets/LittleLightProj.cs index 702d2a64cd..949f2c7e4d 100644 --- a/Projectiles/Pets/LittleLightProj.cs +++ b/Projectiles/Pets/LittleLightProj.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class LittleLightProj : ModProjectile + public class LittleLightProj : ModProjectile { public Player Owner => Main.player[projectile.owner]; @@ -65,13 +65,13 @@ namespace CalamityMod.Projectiles.Pets } public void HandleFrames() - { + { projectile.frameCounter++; projectile.frame = projectile.frameCounter / 5 % Main.projFrames[projectile.type]; - } + } public void DoSpinEffect() - { + { // Spin around from time to time. if (projectile.frameCounter % 180f > 150f) projectile.rotation += MathHelper.TwoPi / 30f; @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Pets } public void HoverTowardsOwnersShoulder() - { + { Vector2 destination = Owner.Top; destination.X -= Owner.direction * Owner.width * 1.25f; destination.Y += Owner.height * 0.25f; @@ -95,6 +95,6 @@ namespace CalamityMod.Projectiles.Pets projectile.Center += projectile.SafeDirectionTo(destination) * 4f; projectile.Center = destination; - } - } + } + } } diff --git a/Projectiles/Pets/MiniHiveMind.cs b/Projectiles/Pets/MiniHiveMind.cs index 6b38e662ad..189f06d29e 100644 --- a/Projectiles/Pets/MiniHiveMind.cs +++ b/Projectiles/Pets/MiniHiveMind.cs @@ -6,110 +6,110 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class MiniHiveMind : ModProjectile - { - private int reelBackCooldown = 0; - private int charging = 0; + public class MiniHiveMind : ModProjectile + { + private int reelBackCooldown = 0; + private int charging = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Mini Hive Mind"); - Main.projFrames[projectile.type] = 16; - Main.projPet[projectile.type] = true; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mini Hive Mind"); + Main.projFrames[projectile.type] = 16; + Main.projPet[projectile.type] = true; ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + } - public override void SetDefaults() - { - projectile.netImportant = true; - projectile.width = 38; - projectile.height = 44; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.timeLeft *= 5; - projectile.tileCollide = false; - } + public override void SetDefaults() + { + projectile.netImportant = true; + projectile.width = 38; + projectile.height = 44; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft *= 5; + projectile.tileCollide = false; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); - if (!player.active) - { - projectile.active = false; - return; - } + if (!player.active) + { + projectile.active = false; + return; + } - //Delete the projectile if the player doesnt have the buff - if (!player.HasBuff(ModContent.BuffType())) - { - projectile.Kill(); - } + //Delete the projectile if the player doesnt have the buff + if (!player.HasBuff(ModContent.BuffType())) + { + projectile.Kill(); + } - if (player.dead) - { - modPlayer.hiveMindPet = false; - } - if (modPlayer.hiveMindPet) - { - projectile.timeLeft = 2; - } + if (player.dead) + { + modPlayer.hiveMindPet = false; + } + if (modPlayer.hiveMindPet) + { + projectile.timeLeft = 2; + } - if (charging <= 0) - projectile.FloatingPetAI(true, 0.05f); + if (charging <= 0) + projectile.FloatingPetAI(true, 0.05f); - Vector2 playerVec = player.Center - projectile.Center; - float playerDist = playerVec.Length(); - if (reelBackCooldown > 0) - reelBackCooldown--; - if (charging > 0) - charging--; - if (reelBackCooldown <= 0 && Main.rand.NextBool(500) && playerDist < 100f && charging <= 0) - { - if (Main.myPlayer == projectile.owner) - { - //Do a backwards charge away from the player - reelBackCooldown = 300; - playerVec.Normalize(); - projectile.velocity = playerVec * 8f; - charging = 50; - Main.PlaySound(SoundID.ForceRoar, (int)projectile.Center.X, (int)projectile.Center.Y, -1, 0.5f, 0f); - projectile.netUpdate = true; - } - } - if (charging < 22 && charging > 0) - projectile.alpha += 12; - if (charging == 1) - { - float xOffset = Main.rand.NextFloat(400f, 600f) * (Main.rand.NextBool() ? -1f : 1f); - float yOffset = Main.rand.NextFloat(400f, 600f) * (Main.rand.NextBool() ? -1f : 1f); - Vector2 teleportPos = new Vector2(player.Center.X + xOffset, player.Center.Y + yOffset); + Vector2 playerVec = player.Center - projectile.Center; + float playerDist = playerVec.Length(); + if (reelBackCooldown > 0) + reelBackCooldown--; + if (charging > 0) + charging--; + if (reelBackCooldown <= 0 && Main.rand.NextBool(500) && playerDist < 100f && charging <= 0) + { + if (Main.myPlayer == projectile.owner) + { + //Do a backwards charge away from the player + reelBackCooldown = 300; + playerVec.Normalize(); + projectile.velocity = playerVec * 8f; + charging = 50; + Main.PlaySound(SoundID.ForceRoar, (int)projectile.Center.X, (int)projectile.Center.Y, -1, 0.5f, 0f); + projectile.netUpdate = true; + } + } + if (charging < 22 && charging > 0) + projectile.alpha += 12; + if (charging == 1) + { + float xOffset = Main.rand.NextFloat(400f, 600f) * (Main.rand.NextBool() ? -1f : 1f); + float yOffset = Main.rand.NextFloat(400f, 600f) * (Main.rand.NextBool() ? -1f : 1f); + Vector2 teleportPos = new Vector2(player.Center.X + xOffset, player.Center.Y + yOffset); projectile.Center = teleportPos; - projectile.alpha = 255; + projectile.alpha = 255; projectile.netUpdate = true; - } - if (projectile.alpha > 0 && charging <= 0) - projectile.alpha -= 12; - if (projectile.alpha < 0) - projectile.alpha = 0; - if (projectile.alpha > 255) - projectile.alpha = 255; - if (charging > 0) - { - projectile.rotation.AngleTowards(0f, 0.1f); - } + } + if (projectile.alpha > 0 && charging <= 0) + projectile.alpha -= 12; + if (projectile.alpha < 0) + projectile.alpha = 0; + if (projectile.alpha > 255) + projectile.alpha = 255; + if (charging > 0) + { + projectile.rotation.AngleTowards(0f, 0.1f); + } - //Animation - if (projectile.frameCounter++ % 6 == 0) - { - projectile.frame++; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } - } - } + //Animation + if (projectile.frameCounter++ % 6 == 0) + { + projectile.frame++; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + } + } } diff --git a/Projectiles/Pets/PerforaMini.cs b/Projectiles/Pets/PerforaMini.cs index 41a0dabd19..2afef314b0 100644 --- a/Projectiles/Pets/PerforaMini.cs +++ b/Projectiles/Pets/PerforaMini.cs @@ -5,7 +5,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class PerforaMini : ModProjectile + public class PerforaMini : ModProjectile { public override void SetStaticDefaults() { @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Pets projectile.timeLeft = 2; } - projectile.FloatingPetAI(true, 0.1f); + projectile.FloatingPetAI(true, 0.1f); //Dust if (Main.rand.NextBool(50)) diff --git a/Projectiles/Pets/PineapplePetProj.cs b/Projectiles/Pets/PineapplePetProj.cs index 154a5cb6e8..0bd8650953 100644 --- a/Projectiles/Pets/PineapplePetProj.cs +++ b/Projectiles/Pets/PineapplePetProj.cs @@ -4,117 +4,117 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class PineapplePetProj : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Pineapple"); - Main.projFrames[projectile.type] = 5; - Main.projPet[projectile.type] = true; - } + public class PineapplePetProj : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pineapple"); + Main.projFrames[projectile.type] = 5; + Main.projPet[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.netImportant = true; - projectile.width = 30; - projectile.height = 30; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.timeLeft *= 5; - } + public override void SetDefaults() + { + projectile.netImportant = true; + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft *= 5; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - if (!player.active) - { - projectile.active = false; - return; - } - if (player.dead) - { - modPlayer.pineapplePet = false; - } - if (modPlayer.pineapplePet) - { - projectile.timeLeft = 2; - } + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + if (!player.active) + { + projectile.active = false; + return; + } + if (player.dead) + { + modPlayer.pineapplePet = false; + } + if (modPlayer.pineapplePet) + { + projectile.timeLeft = 2; + } - projectile.frameCounter++; - if (projectile.frameCounter > 6) - { - projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; - projectile.frameCounter = 0; - } + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + projectile.frameCounter = 0; + } - float passiveMvtFloat = 0.1f; - projectile.tileCollide = false; - float range = 200f; - float xDist = player.Center.X - projectile.Center.X - 2f; - float yDist = player.Center.Y - projectile.Center.Y - 60f; - Vector2 playerVector = new Vector2(xDist, yDist); - float playerDist = playerVector.Length(); - float returnSpeed = 7f; - if (playerDist < range && player.velocity.Y == 0f && (projectile.position.Y + projectile.height <= player.position.Y + player.height && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))) - { - projectile.ai[0] = 0f; - if (projectile.velocity.Y < -6f) - projectile.velocity.Y = -6f; - } + float passiveMvtFloat = 0.1f; + projectile.tileCollide = false; + float range = 200f; + float xDist = player.Center.X - projectile.Center.X - 2f; + float yDist = player.Center.Y - projectile.Center.Y - 60f; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + float returnSpeed = 7f; + if (playerDist < range && player.velocity.Y == 0f && (projectile.position.Y + projectile.height <= player.position.Y + player.height && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))) + { + projectile.ai[0] = 0f; + if (projectile.velocity.Y < -6f) + projectile.velocity.Y = -6f; + } - //Teleport to player if too far - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - projectile.width / 2; - projectile.position.Y = player.Center.Y - projectile.height / 2; - projectile.netUpdate = true; - } + //Teleport to player if too far + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - projectile.width / 2; + projectile.position.Y = player.Center.Y - projectile.height / 2; + projectile.netUpdate = true; + } - if (playerDist < 4f) - { - projectile.velocity.X = xDist; - projectile.velocity.Y = yDist; - passiveMvtFloat = 0f; - } - else - { - if (playerDist > 350f) - { - passiveMvtFloat = 0.2f; - returnSpeed = 12f; - } - float speedMult = returnSpeed / playerDist; - xDist *= speedMult; - yDist *= speedMult; - } - if (projectile.velocity.X < xDist) - { - projectile.velocity.X += passiveMvtFloat; - if (projectile.velocity.X < 0f) - projectile.velocity.X += passiveMvtFloat; - } - if (projectile.velocity.X > xDist) - { - projectile.velocity.X -= passiveMvtFloat; - if (projectile.velocity.X > 0f) - projectile.velocity.X -= passiveMvtFloat; - } - if (projectile.velocity.Y < yDist) - { - projectile.velocity.Y += passiveMvtFloat; - if (projectile.velocity.Y < 0f) - projectile.velocity.Y += passiveMvtFloat; - } - if (projectile.velocity.Y > yDist) - { - projectile.velocity.Y -= passiveMvtFloat; - if (projectile.velocity.Y > 0f) - projectile.velocity.Y -= passiveMvtFloat; - } - projectile.direction = -player.direction; - projectile.spriteDirection = 1; - projectile.rotation = projectile.velocity.Y * 0.05f * -projectile.direction; - } - } + if (playerDist < 4f) + { + projectile.velocity.X = xDist; + projectile.velocity.Y = yDist; + passiveMvtFloat = 0f; + } + else + { + if (playerDist > 350f) + { + passiveMvtFloat = 0.2f; + returnSpeed = 12f; + } + float speedMult = returnSpeed / playerDist; + xDist *= speedMult; + yDist *= speedMult; + } + if (projectile.velocity.X < xDist) + { + projectile.velocity.X += passiveMvtFloat; + if (projectile.velocity.X < 0f) + projectile.velocity.X += passiveMvtFloat; + } + if (projectile.velocity.X > xDist) + { + projectile.velocity.X -= passiveMvtFloat; + if (projectile.velocity.X > 0f) + projectile.velocity.X -= passiveMvtFloat; + } + if (projectile.velocity.Y < yDist) + { + projectile.velocity.Y += passiveMvtFloat; + if (projectile.velocity.Y < 0f) + projectile.velocity.Y += passiveMvtFloat; + } + if (projectile.velocity.Y > yDist) + { + projectile.velocity.Y -= passiveMvtFloat; + if (projectile.velocity.Y > 0f) + projectile.velocity.Y -= passiveMvtFloat; + } + projectile.direction = -player.direction; + projectile.spriteDirection = 1; + projectile.rotation = projectile.velocity.Y * 0.05f * -projectile.direction; + } + } } diff --git a/Projectiles/Pets/PlaguebringerBab.cs b/Projectiles/Pets/PlaguebringerBab.cs index 09f00c3a14..a7c711188b 100644 --- a/Projectiles/Pets/PlaguebringerBab.cs +++ b/Projectiles/Pets/PlaguebringerBab.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class PlaguebringerBab : ModProjectile + public class PlaguebringerBab : ModProjectile { public override void SetStaticDefaults() { @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - projectile.FloatingPetAI(false, 0.05f); + projectile.FloatingPetAI(false, 0.05f); projectile.frameCounter++; if (projectile.frameCounter > 6) { diff --git a/Projectiles/Pets/RotomPet.cs b/Projectiles/Pets/RotomPet.cs index c9c30336f8..14d9c52ae6 100644 --- a/Projectiles/Pets/RotomPet.cs +++ b/Projectiles/Pets/RotomPet.cs @@ -5,169 +5,169 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class RotomPet : ModProjectile - { - private bool initialized = false; - private int form = 0; - private const int Normal = 0; - private const int Dex = 1; - private const int Wash = 2; - private const int Heat = 3; - private const int Frost = 4; - private const int Mow = 5; - private const int Fan = 6; + public class RotomPet : ModProjectile + { + private bool initialized = false; + private int form = 0; + private const int Normal = 0; + private const int Dex = 1; + private const int Wash = 2; + private const int Heat = 3; + private const int Frost = 4; + private const int Mow = 5; + private const int Fan = 6; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Rotom"); - Main.projFrames[projectile.type] = 4; - Main.projPet[projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rotom"); + Main.projFrames[projectile.type] = 4; + Main.projPet[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.netImportant = true; - projectile.width = projectile.height = 30; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.timeLeft *= 5; - } + public override void SetDefaults() + { + projectile.netImportant = true; + projectile.width = projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft *= 5; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); - if (!player.active) - { - projectile.active = false; - return; - } - if (player.dead) - { - modPlayer.rotomPet = false; - } - if (modPlayer.rotomPet) - { - projectile.timeLeft = 2; - } + if (!player.active) + { + projectile.active = false; + return; + } + if (player.dead) + { + modPlayer.rotomPet = false; + } + if (modPlayer.rotomPet) + { + projectile.timeLeft = 2; + } - if (!initialized) - { - DustEffects(); - initialized = true; - } + if (!initialized) + { + DustEffects(); + initialized = true; + } - UpdateForm(player); - UpdateFrames(); + UpdateForm(player); + UpdateFrames(); - projectile.FloatingPetAI(true, 0.05f); - } + projectile.FloatingPetAI(true, 0.05f); + } - private void UpdateForm(Player player) - { - if (CalamityPlayer.areThereAnyDamnBosses) - form = Dex; - else if (player.ZoneBeach || player.InSunkenSea() || player.InSulphur() || player.InAbyss()) - form = Wash; - else if (player.ZoneTowerSolar || player.ZoneDesert || player.ZoneUndergroundDesert || player.ZoneUnderworldHeight || player.InCalamity()) - form = Heat; - else if (player.ZoneSnow || Main.snowMoon) - form = Frost; - else if (player.ZoneJungle) - form = Mow; - else if (player.ZoneSkyHeight || player.ZoneMeteor || player.InAstral()) - form = Fan; - else - form = Normal; - } + private void UpdateForm(Player player) + { + if (CalamityPlayer.areThereAnyDamnBosses) + form = Dex; + else if (player.ZoneBeach || player.InSunkenSea() || player.InSulphur() || player.InAbyss()) + form = Wash; + else if (player.ZoneTowerSolar || player.ZoneDesert || player.ZoneUndergroundDesert || player.ZoneUnderworldHeight || player.InCalamity()) + form = Heat; + else if (player.ZoneSnow || Main.snowMoon) + form = Frost; + else if (player.ZoneJungle) + form = Mow; + else if (player.ZoneSkyHeight || player.ZoneMeteor || player.InAstral()) + form = Fan; + else + form = Normal; + } - private void DustEffects() - { - int dustAmt = 25; - for (int i = 0; i < dustAmt; i++) - { - int electric = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 132, 0f, 0f, 0, default, 1f); - Main.dust[electric].velocity *= 2f; - Main.dust[electric].scale *= 1.15f; - } - } + private void DustEffects() + { + int dustAmt = 25; + for (int i = 0; i < dustAmt; i++) + { + int electric = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 132, 0f, 0f, 0, default, 1f); + Main.dust[electric].velocity *= 2f; + Main.dust[electric].scale *= 1.15f; + } + } - private void UpdateFrames() - { - projectile.frameCounter++; + private void UpdateFrames() + { + projectile.frameCounter++; if (projectile.frameCounter > 6) { projectile.frame++; - projectile.frameCounter = 0; + projectile.frameCounter = 0; } - if (projectile.frame >= 4) - { - projectile.frame = 0; - } - } + if (projectile.frame >= 4) + { + projectile.frame = 0; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Drawing(spriteBatch, lightColor, - Main.projectileTexture[projectile.type], - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomDex"), - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomWash"), - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomHeat"), - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFrost"), - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomMow"), - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFan")); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Drawing(spriteBatch, lightColor, + Main.projectileTexture[projectile.type], + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomDex"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomWash"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomHeat"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFrost"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomMow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFan")); + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Drawing(spriteBatch, Color.White, - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomPetGlow"), - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomDexGlow"), - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomWashGlow"), - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomHeatGlow"), - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFrostGlow"), - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomMowGlow"), - ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFanGlow")); - } + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Drawing(spriteBatch, Color.White, + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomPetGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomDexGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomWashGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomHeatGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFrostGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomMowGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFanGlow")); + } - private void Drawing(SpriteBatch spriteBatch, Color color, Texture2D normal, Texture2D dex, Texture2D wash, Texture2D heat, Texture2D frost, Texture2D mow, Texture2D fan) - { - Texture2D texture = normal; - switch (form) - { - case Dex: - texture = dex; - break; - case Wash: - texture = wash; - break; - case Heat: - texture = heat; - break; - case Frost: - texture = frost; - break; - case Mow: - texture = mow; - break; - case Fan: - texture = fan; - break; - default: - break; - } + private void Drawing(SpriteBatch spriteBatch, Color color, Texture2D normal, Texture2D dex, Texture2D wash, Texture2D heat, Texture2D frost, Texture2D mow, Texture2D fan) + { + Texture2D texture = normal; + switch (form) + { + case Dex: + texture = dex; + break; + case Wash: + texture = wash; + break; + case Heat: + texture = heat; + break; + case Frost: + texture = frost; + break; + case Mow: + texture = mow; + break; + case Fan: + texture = fan; + break; + default: + break; + } - int height = texture.Height / Main.projFrames[projectile.type]; - int frameHeight = height * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + int height = texture.Height / Main.projFrames[projectile.type]; + int frameHeight = height * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), color, projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), projectile.scale, spriteEffects, 0f); - } + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), color, projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), projectile.scale, spriteEffects, 0f); + } - public override bool CanDamage() => false; - } + public override bool CanDamage() => false; + } } diff --git a/Projectiles/Pets/SCalPet.cs b/Projectiles/Pets/SCalPet.cs index 52a12fd38f..0dc380c706 100644 --- a/Projectiles/Pets/SCalPet.cs +++ b/Projectiles/Pets/SCalPet.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class SCalPet : ModProjectile + public class SCalPet : ModProjectile { public override void SetStaticDefaults() { @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - projectile.FloatingPetAI(false, 0.05f); + projectile.FloatingPetAI(false, 0.05f); projectile.rotation -= projectile.spriteDirection * MathHelper.PiOver2; projectile.frameCounter++; if (projectile.frameCounter > 6) diff --git a/Projectiles/Pets/SirenYoung.cs b/Projectiles/Pets/SirenYoung.cs index 71814d7109..c72e0fa4e1 100644 --- a/Projectiles/Pets/SirenYoung.cs +++ b/Projectiles/Pets/SirenYoung.cs @@ -6,11 +6,11 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class SirenYoung : ModProjectile + public class SirenYoung : ModProjectile { private bool underwater = false; - private int sleepyTimer = 0; - private int lightLevel = 0; + private int sleepyTimer = 0; + private int lightLevel = 0; public override void SetStaticDefaults() { @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Pets projectile.penetrate = -1; projectile.timeLeft *= 5; projectile.ignoreWater = true; - projectile.tileCollide = false; + projectile.tileCollide = false; } public override void AI() @@ -49,37 +49,37 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - bool sleepy = sleepyTimer >= 180; - if (!sleepy) - { - projectile.frameCounter++; - if (projectile.frameCounter > 6) - { - projectile.frame++; - projectile.frameCounter = 0; - } - } - if (underwater) - { - if (projectile.frame >= 8) - { - projectile.frame = 0; - } - } - else - { - if (projectile.frame >= 16) - { - projectile.frame = sleepy ? 16 : 8; - } - } + bool sleepy = sleepyTimer >= 180; + if (!sleepy) + { + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + } + if (underwater) + { + if (projectile.frame >= 8) + { + projectile.frame = 0; + } + } + else + { + if (projectile.frame >= 16) + { + projectile.frame = sleepy ? 16 : 8; + } + } underwater = player.IsUnderwater(); if (underwater) { - if (projectile.frame == 16) - projectile.frame = 0; - if (sleepyTimer > 0) - sleepyTimer--; + if (projectile.frame == 16) + projectile.frame = 0; + if (sleepyTimer > 0) + sleepyTimer--; if (projectile.localAI[0] == 0f) { lightLevel = 0; @@ -89,36 +89,36 @@ namespace CalamityMod.Projectiles.Pets lightLevel = 1; } } - else - { - if (!sleepy) - { - sleepyTimer++; - lightLevel = 1; - } - else - { - lightLevel = 2; - projectile.frame = 16; - } - } - switch (lightLevel) - { - case 0: - Lighting.AddLight(projectile.Center, 0f, 2f, 2.5f); //4.5 - break; - case 1: - Lighting.AddLight(projectile.Center, 0f, 1.32f, 1.65f); //3 - break; - case 2: - Lighting.AddLight(projectile.Center, 0f, 0.5f, 0.7f); - break; - } - + else + { + if (!sleepy) + { + sleepyTimer++; + lightLevel = 1; + } + else + { + lightLevel = 2; + projectile.frame = 16; + } + } + switch (lightLevel) + { + case 0: + Lighting.AddLight(projectile.Center, 0f, 2f, 2.5f); //4.5 + break; + case 1: + Lighting.AddLight(projectile.Center, 0f, 1.32f, 1.65f); //3 + break; + case 2: + Lighting.AddLight(projectile.Center, 0f, 0.5f, 0.7f); + break; + } + float velAdjustment = 0.2f; float speedLimit = 5f; - Vector2 playerVec = player.Center - projectile.Center; - playerVec.Y += player.gfxOffY; + Vector2 playerVec = player.Center - projectile.Center; + playerVec.Y += player.gfxOffY; if (player.controlLeft && !sleepy) { playerVec.X -= 120f; @@ -229,6 +229,6 @@ namespace CalamityMod.Projectiles.Pets { projectile.rotation = projectile.velocity.X * 0.05f; } - } + } } } diff --git a/Projectiles/Pets/Sparks.cs b/Projectiles/Pets/Sparks.cs index de3b7c231d..aac9c34336 100644 --- a/Projectiles/Pets/Sparks.cs +++ b/Projectiles/Pets/Sparks.cs @@ -8,146 +8,146 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class Sparks : ModProjectile - { - private int color = 0; + public class Sparks : ModProjectile + { + private int color = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Sparks"); - Main.projFrames[projectile.type] = 4; - Main.projPet[projectile.type] = true; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sparks"); + Main.projFrames[projectile.type] = 4; + Main.projPet[projectile.type] = true; ProjectileID.Sets.LightPet[projectile.type] = true; - } + } - public override void SetDefaults() - { - projectile.width = 32; - projectile.height = 44; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.timeLeft *= 5; - projectile.tileCollide = true; - projectile.ignoreWater = true; - } + public override void SetDefaults() + { + projectile.width = 32; + projectile.height = 44; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft *= 5; + projectile.tileCollide = true; + projectile.ignoreWater = true; + } - private void Pickup() - { - int defaultItemGrabRange = 38; - Player player = Main.player[projectile.owner]; + private void Pickup() + { + int defaultItemGrabRange = 38; + Player player = Main.player[projectile.owner]; - for (int itemIndex = 0; itemIndex < Main.maxItems; itemIndex++) - { - Item item = Main.item[itemIndex]; - if (item.active && item.noGrabDelay == 0 && item.owner == projectile.owner && ItemLoader.CanPickup(item, player)) - { - int num = defaultItemGrabRange;//Player.defaultItemGrabRange; + for (int itemIndex = 0; itemIndex < Main.maxItems; itemIndex++) + { + Item item = Main.item[itemIndex]; + if (item.active && item.noGrabDelay == 0 && item.owner == projectile.owner && ItemLoader.CanPickup(item, player)) + { + int num = defaultItemGrabRange;//Player.defaultItemGrabRange; - 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.ActiveItem().type != ItemID.None || player.itemAnimation <= 0)) - { - // TODO, fix this maybe? - if (!ItemLoader.OnPickup(item, player)) - { - Main.item[itemIndex] = new Item(); - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendData(MessageID.SyncItem, -1, -1, null, itemIndex, 0f, 0f, 0f, 0, 0, 0); - } - continue; - } + 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.ActiveItem().type != ItemID.None || player.itemAnimation <= 0)) + { + // TODO, fix this maybe? + if (!ItemLoader.OnPickup(item, player)) + { + Main.item[itemIndex] = new Item(); + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, itemIndex, 0f, 0f, 0f, 0, 0, 0); + } + continue; + } - if (ItemID.Sets.NebulaPickup[item.type]) - { - continue; - //Main.PlaySound(7, (int)player.position.X, (int)player.position.Y, 1); - //int num2 = item.buffType; - //Main.item[itemIndex] = new Item(); - //if (Main.netMode == 1) - //{ - // NetMessage.SendData(102, -1, -1, "", projectile.owner, (float)num2, player.Center.X, player.Center.Y, 0, 0, 0); - // NetMessage.SendData(21, -1, -1, "", itemIndex, 0f, 0f, 0f, 0, 0, 0); - //} - //else - //{ - // player.NebulaLevelup(num2); - //} - } - if (item.type == ItemID.Heart || item.type == ItemID.CandyApple || item.type == ItemID.CandyCane) - { - continue; - //Main.PlaySound(7, (int)player.position.X, (int)player.position.Y, 1); - //player.statLife += 20; - //if (Main.myPlayer == player.whoAmI) - //{ - // player.HealEffect(20, true); - //} - //if (player.statLife > player.statLifeMax2) - //{ - // player.statLife = player.statLifeMax2; - //} - //Main.item[itemIndex] = new Item(); - //if (Main.netMode == 1) - //{ - // NetMessage.SendData(21, -1, -1, "", itemIndex, 0f, 0f, 0f, 0, 0, 0); - //} - } - else if (item.type == ItemID.Star || item.type == ItemID.SoulCake || item.type == ItemID.SugarPlum) - { - continue; - //Main.PlaySound(7, (int)player.position.X, (int)player.position.Y, 1); - //player.statMana += 100; - //if (Main.myPlayer == player.whoAmI) - //{ - // player.ManaEffect(100); - //} - //if (player.statMana > player.statManaMax2) - //{ - // player.statMana = player.statManaMax2; - //} - //Main.item[itemIndex] = new Item(); - //if (Main.netMode == 1) - //{ - // NetMessage.SendData(21, -1, -1, "", itemIndex, 0f, 0f, 0f, 0, 0, 0); - //} - } - else - { - Main.item[itemIndex] = player.GetItem(projectile.owner, item, false, false); - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendData(MessageID.SyncItem, -1, -1, null, itemIndex, 0f, 0f, 0f, 0, 0, 0); - } - } - } - } - } - } + if (ItemID.Sets.NebulaPickup[item.type]) + { + continue; + //Main.PlaySound(7, (int)player.position.X, (int)player.position.Y, 1); + //int num2 = item.buffType; + //Main.item[itemIndex] = new Item(); + //if (Main.netMode == 1) + //{ + // NetMessage.SendData(102, -1, -1, "", projectile.owner, (float)num2, player.Center.X, player.Center.Y, 0, 0, 0); + // NetMessage.SendData(21, -1, -1, "", itemIndex, 0f, 0f, 0f, 0, 0, 0); + //} + //else + //{ + // player.NebulaLevelup(num2); + //} + } + if (item.type == ItemID.Heart || item.type == ItemID.CandyApple || item.type == ItemID.CandyCane) + { + continue; + //Main.PlaySound(7, (int)player.position.X, (int)player.position.Y, 1); + //player.statLife += 20; + //if (Main.myPlayer == player.whoAmI) + //{ + // player.HealEffect(20, true); + //} + //if (player.statLife > player.statLifeMax2) + //{ + // player.statLife = player.statLifeMax2; + //} + //Main.item[itemIndex] = new Item(); + //if (Main.netMode == 1) + //{ + // NetMessage.SendData(21, -1, -1, "", itemIndex, 0f, 0f, 0f, 0, 0, 0); + //} + } + else if (item.type == ItemID.Star || item.type == ItemID.SoulCake || item.type == ItemID.SugarPlum) + { + continue; + //Main.PlaySound(7, (int)player.position.X, (int)player.position.Y, 1); + //player.statMana += 100; + //if (Main.myPlayer == player.whoAmI) + //{ + // player.ManaEffect(100); + //} + //if (player.statMana > player.statManaMax2) + //{ + // player.statMana = player.statManaMax2; + //} + //Main.item[itemIndex] = new Item(); + //if (Main.netMode == 1) + //{ + // NetMessage.SendData(21, -1, -1, "", itemIndex, 0f, 0f, 0f, 0, 0, 0); + //} + } + else + { + Main.item[itemIndex] = player.GetItem(projectile.owner, item, false, false); + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, itemIndex, 0f, 0f, 0f, 0, 0, 0); + } + } + } + } + } + } - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - if (npc.active && (npc.type == NPCID.Butterfly || npc.type == NPCID.GoldButterfly)) - { - if (new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height).Intersects(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height))) - { - npc.life = 0; - npc.active = false; - Main.PlaySound(SoundID.Item2, projectile.position); - npc.netUpdate = true; - } - } - } - } + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + if (npc.active && (npc.type == NPCID.Butterfly || npc.type == NPCID.GoldButterfly)) + { + if (new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height).Intersects(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height))) + { + npc.life = 0; + npc.active = false; + Main.PlaySound(SoundID.Item2, projectile.position); + npc.netUpdate = true; + } + } + } + } - private void PassiveAI() - { - Player player = Main.player[projectile.owner]; + private void PassiveAI() + { + Player player = Main.player[projectile.owner]; float SAImovement = 0.05f; for (int index = 0; index < Main.projectile.Length; index++) { - Projectile proj = Main.projectile[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) { @@ -169,119 +169,119 @@ namespace CalamityMod.Projectiles.Pets } } } - float num16 = 0.5f; - projectile.tileCollide = false; - 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); - xDist += (float)(60 * (float)player.direction); - yDist -= 60f; - float playerDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - float num21 = 18f; - if (playerDist < 160f) - projectile.ai[0] = 0f; - if (playerDist < 100f && player.velocity.Y == 0f && - projectile.position.Y + (float)projectile.height <= player.position.Y + (float)player.height && - !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - if (projectile.velocity.Y < -6f) - { - projectile.velocity.Y = -6f; - } - } - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - if (playerDist < 50f) - { - if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) - { - projectile.velocity *= 0.99f; - } - num16 = 0.01f; - } - else - { - if (playerDist < 100f) - { - num16 = 0.1f; - } - if (playerDist > 300f) - { - num16 = 1f; - } - playerDist = num21 / playerDist; - xDist *= playerDist; - yDist *= playerDist; - } - if (projectile.velocity.X < xDist) - { - projectile.velocity.X = projectile.velocity.X + num16; - if (num16 > 0.05f && projectile.velocity.X < 0f) - { - projectile.velocity.X = projectile.velocity.X + num16; - } - } - if (projectile.velocity.X > xDist) - { - projectile.velocity.X = projectile.velocity.X - num16; - if (num16 > 0.05f && projectile.velocity.X > 0f) - { - projectile.velocity.X = projectile.velocity.X - num16; - } - } - if (projectile.velocity.Y < yDist) - { - projectile.velocity.Y = projectile.velocity.Y + num16; - if (num16 > 0.05f && projectile.velocity.Y < 0f) - { - projectile.velocity.Y = projectile.velocity.Y + num16 * 2f; - } - } - if (projectile.velocity.Y > yDist) - { - projectile.velocity.Y = projectile.velocity.Y - num16; - if (num16 > 0.05f && projectile.velocity.Y > 0f) - { - projectile.velocity.Y = projectile.velocity.Y - num16 * 2f; - } - } - } + float num16 = 0.5f; + projectile.tileCollide = false; + 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); + xDist += (float)(60 * (float)player.direction); + yDist -= 60f; + float playerDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); + float num21 = 18f; + if (playerDist < 160f) + projectile.ai[0] = 0f; + if (playerDist < 100f && player.velocity.Y == 0f && + projectile.position.Y + (float)projectile.height <= player.position.Y + (float)player.height && + !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + if (projectile.velocity.Y < -6f) + { + projectile.velocity.Y = -6f; + } + } + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - (float)(projectile.width / 2); + projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + if (playerDist < 50f) + { + if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) + { + projectile.velocity *= 0.99f; + } + num16 = 0.01f; + } + else + { + if (playerDist < 100f) + { + num16 = 0.1f; + } + if (playerDist > 300f) + { + num16 = 1f; + } + playerDist = num21 / playerDist; + xDist *= playerDist; + yDist *= playerDist; + } + if (projectile.velocity.X < xDist) + { + projectile.velocity.X = projectile.velocity.X + num16; + if (num16 > 0.05f && projectile.velocity.X < 0f) + { + projectile.velocity.X = projectile.velocity.X + num16; + } + } + if (projectile.velocity.X > xDist) + { + projectile.velocity.X = projectile.velocity.X - num16; + if (num16 > 0.05f && projectile.velocity.X > 0f) + { + projectile.velocity.X = projectile.velocity.X - num16; + } + } + if (projectile.velocity.Y < yDist) + { + projectile.velocity.Y = projectile.velocity.Y + num16; + if (num16 > 0.05f && projectile.velocity.Y < 0f) + { + projectile.velocity.Y = projectile.velocity.Y + num16 * 2f; + } + } + if (projectile.velocity.Y > yDist) + { + projectile.velocity.Y = projectile.velocity.Y - num16; + if (num16 > 0.05f && projectile.velocity.Y > 0f) + { + projectile.velocity.Y = projectile.velocity.Y - num16 * 2f; + } + } + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); - //Change color based on health - if (player.statLife >= (int)((double)player.statLifeMax2 * 0.75)) - { - if (Main.myPlayer == projectile.owner) - { - color = 0; //gold - } - } - else if (player.statLife >= (int)((double)player.statLifeMax2 * 0.5)) - { - if (Main.myPlayer == projectile.owner) - { - color = 1; //blue - } - } - else - { - if (Main.myPlayer == projectile.owner) - { - color = 2; //green - } - } + //Change color based on health + if (player.statLife >= (int)((double)player.statLifeMax2 * 0.75)) + { + if (Main.myPlayer == projectile.owner) + { + color = 0; //gold + } + } + else if (player.statLife >= (int)((double)player.statLifeMax2 * 0.5)) + { + if (Main.myPlayer == projectile.owner) + { + color = 1; //blue + } + } + else + { + if (Main.myPlayer == projectile.owner) + { + color = 2; //green + } + } - //give off light based on Dragonfly color + //give off light based on Dragonfly color if (color == 0) //gold { Lighting.AddLight(projectile.Center, 1.5f, 1.5f, 0.1f); @@ -289,13 +289,13 @@ namespace CalamityMod.Projectiles.Pets else if (color == 1) //blue { Lighting.AddLight(projectile.Center, 0.1f, 0.1f, 1.5f); - } + } else //green { Lighting.AddLight(projectile.Center, 0.1f, 1.5f, 0.1f); - } + } - //framing and sprite direction + //framing and sprite direction projectile.spriteDirection = projectile.direction; projectile.rotation = projectile.velocity.X * 0.05f; projectile.frameCounter++; @@ -308,174 +308,174 @@ namespace CalamityMod.Projectiles.Pets { projectile.frame = 0; } - if ((double)projectile.velocity.X >= 0.25) - { - projectile.direction = 1; - } - else if ((double)projectile.velocity.X < -0.25) - { - projectile.direction = -1; - } + if ((double)projectile.velocity.X >= 0.25) + { + projectile.direction = 1; + } + else if ((double)projectile.velocity.X < -0.25) + { + projectile.direction = -1; + } - if (!player.active) - { - projectile.active = false; - return; - } - if (player.dead) - { - modPlayer.sparks = false; - } - if (modPlayer.sparks) - { - projectile.timeLeft = 2; - } + if (!player.active) + { + projectile.active = false; + return; + } + if (player.dead) + { + modPlayer.sparks = false; + } + if (modPlayer.sparks) + { + projectile.timeLeft = 2; + } - Pickup(); //pickup items + Pickup(); //pickup items - bool flag24 = false; - if (projectile.ai[0] == 2f) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] > 30f) - { - projectile.ai[1] = 1f; - projectile.ai[0] = 0f; - projectile.numUpdates = 0; - projectile.netUpdate = true; - } - else - { - flag24 = true; - } - } - if (flag24) - { - return; - } + bool flag24 = false; + if (projectile.ai[0] == 2f) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] > 30f) + { + projectile.ai[1] = 1f; + projectile.ai[0] = 0f; + projectile.numUpdates = 0; + projectile.netUpdate = true; + } + else + { + flag24 = true; + } + } + if (flag24) + { + return; + } - //find a target + //find a target Vector2 targetLocation = projectile.position; - bool foundFood = false; - float range = 160f; //10 block range + bool foundFood = false; + float range = 160f; //10 block range - for (int itemIndex = 0; itemIndex < Main.maxItems; itemIndex++) - { - Item item = Main.item[itemIndex]; - if (item.active && item.noGrabDelay == 0 && item.owner == projectile.owner && ItemLoader.CanPickup(item, Main.player[item.owner]) && Main.player[item.owner].ItemSpace(item)) - { - if (ItemID.Sets.NebulaPickup[item.type]) - { - continue; - } - if (item.type == ItemID.Heart || item.type == ItemID.CandyApple || item.type == ItemID.CandyCane) - { - continue; - } - else if (item.type == ItemID.Star || item.type == ItemID.SoulCake || item.type == ItemID.SugarPlum) - { - continue; - } + for (int itemIndex = 0; itemIndex < Main.maxItems; itemIndex++) + { + Item item = Main.item[itemIndex]; + if (item.active && item.noGrabDelay == 0 && item.owner == projectile.owner && ItemLoader.CanPickup(item, Main.player[item.owner]) && Main.player[item.owner].ItemSpace(item)) + { + if (ItemID.Sets.NebulaPickup[item.type]) + { + continue; + } + if (item.type == ItemID.Heart || item.type == ItemID.CandyApple || item.type == ItemID.CandyCane) + { + continue; + } + else if (item.type == ItemID.Star || item.type == ItemID.SoulCake || item.type == ItemID.SugarPlum) + { + continue; + } float itemDist = Vector2.Distance(item.Center, projectile.Center); - float distanceToPotential = Vector2.Distance(projectile.Center, targetLocation); - if (distanceToPotential < itemDist && itemDist < range) - { - range = itemDist; - targetLocation = item.Center; - foundFood = true; - } - } - } - //prioritize butterflies over items - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - if (npc.active && (npc.type == NPCID.Butterfly || npc.type == NPCID.GoldButterfly)) - { + float distanceToPotential = Vector2.Distance(projectile.Center, targetLocation); + if (distanceToPotential < itemDist && itemDist < range) + { + range = itemDist; + targetLocation = item.Center; + foundFood = true; + } + } + } + //prioritize butterflies over items + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + if (npc.active && (npc.type == NPCID.Butterfly || npc.type == NPCID.GoldButterfly)) + { float npcDist = Vector2.Distance(npc.Center, projectile.Center); - float distanceToPotential = Vector2.Distance(projectile.Center, targetLocation); - if (distanceToPotential < npcDist && npcDist < range) - { - range = npcDist; - targetLocation = npc.Center; - foundFood = true; - } - } - } + float distanceToPotential = Vector2.Distance(projectile.Center, targetLocation); + if (distanceToPotential < npcDist && npcDist < range) + { + range = npcDist; + targetLocation = npc.Center; + foundFood = true; + } + } + } float num647 = 100f; if (foundFood) { num647 = 200f; } - if (Vector2.Distance(player.Center, projectile.Center) > num647) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } - if (foundFood && projectile.ai[0] == 0f) - { - Vector2 vector47 = targetLocation - projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) - { - float scaleFactor2 = 18f; - vector47 *= scaleFactor2; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; - } - else - { - float num649 = 9f; - vector47 *= -num649; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; - } - } - else - { - PassiveAI(); - } - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += (float)Main.rand.Next(1, 3); - } - if (projectile.ai[1] > 30f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - if (projectile.ai[0] == 0f) - { - if (projectile.ai[1] == 0f && foundFood && range < 300f) - { - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - projectile.ai[0] = 2f; - Vector2 value20 = targetLocation - projectile.Center; - value20.Normalize(); - projectile.velocity = value20 * 12f; - projectile.netUpdate = true; - } - } - } - } + if (Vector2.Distance(player.Center, projectile.Center) > num647) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } + if (foundFood && projectile.ai[0] == 0f) + { + Vector2 vector47 = targetLocation - projectile.Center; + float num648 = vector47.Length(); + vector47.Normalize(); + if (num648 > 200f) + { + float scaleFactor2 = 18f; + vector47 *= scaleFactor2; + projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; + } + else + { + float num649 = 9f; + vector47 *= -num649; + projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; + } + } + else + { + PassiveAI(); + } + if (projectile.ai[1] > 0f) + { + projectile.ai[1] += (float)Main.rand.Next(1, 3); + } + if (projectile.ai[1] > 30f) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + if (projectile.ai[0] == 0f) + { + if (projectile.ai[1] == 0f && foundFood && range < 300f) + { + projectile.ai[1] += 1f; + if (Main.myPlayer == projectile.owner) + { + projectile.ai[0] = 2f; + Vector2 value20 = targetLocation - projectile.Center; + value20.Normalize(); + projectile.velocity = value20 * 12f; + projectile.netUpdate = true; + } + } + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; - if (color == 1) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/SparksBlue"); - if (color == 2) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/SparksGreen"); + if (color == 1) + texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/SparksBlue"); + if (color == 2) + texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/SparksGreen"); int height = texture.Height / Main.projFrames[projectile.type]; int frameHeight = height * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); return false; } - } + } } \ No newline at end of file diff --git a/Projectiles/Pets/ThirdSage.cs b/Projectiles/Pets/ThirdSage.cs index af9b8a81ec..f415b455e9 100644 --- a/Projectiles/Pets/ThirdSage.cs +++ b/Projectiles/Pets/ThirdSage.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - projectile.FloatingPetAI(true, 0.1f); + projectile.FloatingPetAI(true, 0.1f); //Animation projectile.frameCounter++; if (projectile.frameCounter > 6) diff --git a/Projectiles/Pets/YharonSonPet.cs b/Projectiles/Pets/YharonSonPet.cs index 940a942be6..17334aac24 100644 --- a/Projectiles/Pets/YharonSonPet.cs +++ b/Projectiles/Pets/YharonSonPet.cs @@ -5,24 +5,24 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { - public class YharonSonPet : ModProjectile + public class YharonSonPet : ModProjectile { public Player player => Main.player[projectile.owner]; - private static int xFrameAmt = 3; - private static int yFrameAmt = 16; + private static int xFrameAmt = 3; + private static int yFrameAmt = 16; - public int frameX = 0; - public int frameY = 0; + public int frameX = 0; + public int frameY = 0; - public int CurrentFrame - { - get => frameX * yFrameAmt + frameY; - set - { - frameX = value / yFrameAmt; - frameY = value % yFrameAmt; - } - } + public int CurrentFrame + { + get => frameX * yFrameAmt + frameY; + set + { + frameX = value / yFrameAmt; + frameY = value % yFrameAmt; + } + } public override void SetStaticDefaults() { @@ -39,66 +39,66 @@ namespace CalamityMod.Projectiles.Pets projectile.penetrate = -1; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.frameCounter <= 1) - return false; - Texture2D texture = Main.projectileTexture[projectile.type]; - Vector2 origin = texture.Size() / new Vector2((float)xFrameAmt, (float)yFrameAmt) * 0.5f; - Rectangle frame = texture.Frame(xFrameAmt, yFrameAmt, frameX, frameY); - SpriteEffects spriteEffects = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, frame, lightColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.frameCounter <= 1) + return false; + Texture2D texture = Main.projectileTexture[projectile.type]; + Vector2 origin = texture.Size() / new Vector2((float)xFrameAmt, (float)yFrameAmt) * 0.5f; + Rectangle frame = texture.Frame(xFrameAmt, yFrameAmt, frameX, frameY); + SpriteEffects spriteEffects = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, frame, lightColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + return false; + } - private bool CurrentlySitting() => CurrentFrame == 0 || CurrentFrame == 3 || CurrentFrame == 4 || CurrentFrame >= 19; - private bool CurrentlyFlying() => CurrentFrame == 1 || CurrentFrame == 2 || CurrentFrame >= 5 && CurrentFrame <= 18; + private bool CurrentlySitting() => CurrentFrame == 0 || CurrentFrame == 3 || CurrentFrame == 4 || CurrentFrame >= 19; + private bool CurrentlyFlying() => CurrentFrame == 1 || CurrentFrame == 2 || CurrentFrame >= 5 && CurrentFrame <= 18; - private void SittingFrames() - { - projectile.frameCounter++; - if (projectile.frameCounter % 6 == 0) - { - if (CurrentlyFlying()) - CurrentFrame = 3; - else if (CurrentFrame == 45) - CurrentFrame = 0; - else if (CurrentFrame != 0) - CurrentFrame++; - if (CurrentFrame == 5) - CurrentFrame = 0; - // Roughly 25.97% chance per second for blinking - if (Main.rand.NextBool(200) && CurrentFrame == 0) - CurrentFrame = 46; - // Roughly 3.9% chance per second for head shaking - if (Main.rand.NextBool(1500) && CurrentFrame == 0) - CurrentFrame = 19; - if (frameX >= xFrameAmt) - CurrentFrame = 0; - } - } + private void SittingFrames() + { + projectile.frameCounter++; + if (projectile.frameCounter % 6 == 0) + { + if (CurrentlyFlying()) + CurrentFrame = 3; + else if (CurrentFrame == 45) + CurrentFrame = 0; + else if (CurrentFrame != 0) + CurrentFrame++; + if (CurrentFrame == 5) + CurrentFrame = 0; + // Roughly 25.97% chance per second for blinking + if (Main.rand.NextBool(200) && CurrentFrame == 0) + CurrentFrame = 46; + // Roughly 3.9% chance per second for head shaking + if (Main.rand.NextBool(1500) && CurrentFrame == 0) + CurrentFrame = 19; + if (frameX >= xFrameAmt) + CurrentFrame = 0; + } + } - private void FlyingFrames() - { - projectile.frameCounter++; - if (projectile.frameCounter % 6 == 0) - { - if (CurrentlySitting()) - CurrentFrame = 1; - else - CurrentFrame++; - if (CurrentFrame == 3) - CurrentFrame = 5; - if (CurrentFrame > 18) - CurrentFrame = 5; - // This should never happen at this stage but just in case - if (frameX >= xFrameAmt) - CurrentFrame = 0; - } - } + private void FlyingFrames() + { + projectile.frameCounter++; + if (projectile.frameCounter % 6 == 0) + { + if (CurrentlySitting()) + CurrentFrame = 1; + else + CurrentFrame++; + if (CurrentFrame == 3) + CurrentFrame = 5; + if (CurrentFrame > 18) + CurrentFrame = 5; + // This should never happen at this stage but just in case + if (frameX >= xFrameAmt) + CurrentFrame = 0; + } + } - private void PetDefaults() - { + private void PetDefaults() + { if (!player.active) { projectile.active = false; @@ -113,298 +113,298 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - } + } public override void AI() { - // Insert generic pet setup - PetDefaults(); + // Insert generic pet setup + PetDefaults(); - // Fly toward the player if they are using Rocket Boots - if (player.rocketDelay2 > 0) - { - projectile.ai[0] = 1f; - } + // Fly toward the player if they are using Rocket Boots + if (player.rocketDelay2 > 0) + { + projectile.ai[0] = 1f; + } - float xDist = player.Center.X - projectile.Center.X; - float yDist = player.Center.Y - projectile.Center.Y; - Vector2 playerVector = new Vector2(xDist, yDist); - float playerDist = playerVector.Length(); + float xDist = player.Center.X - projectile.Center.X; + float yDist = player.Center.Y - projectile.Center.Y; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); - //Teleport to player if too far - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - projectile.width / 2; - projectile.position.Y = player.Center.Y - projectile.height / 2; - projectile.netUpdate = true; - } - // Otherwise, make sure we're not going crazy in the y velocity and try to fly back toward the player - else if (playerDist > (CurrentlySitting() ? 300f : 200f)) - { - if (yDist > 0f && projectile.velocity.Y < 0f) - { - projectile.velocity.Y = 0f; - } - if (yDist < 0f && projectile.velocity.Y > 0f) - { - projectile.velocity.Y = 0f; - } - projectile.ai[0] = 1f; - } + //Teleport to player if too far + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - projectile.width / 2; + projectile.position.Y = player.Center.Y - projectile.height / 2; + projectile.netUpdate = true; + } + // Otherwise, make sure we're not going crazy in the y velocity and try to fly back toward the player + else if (playerDist > (CurrentlySitting() ? 300f : 200f)) + { + if (yDist > 0f && projectile.velocity.Y < 0f) + { + projectile.velocity.Y = 0f; + } + if (yDist < 0f && projectile.velocity.Y > 0f) + { + projectile.velocity.Y = 0f; + } + projectile.ai[0] = 1f; + } - // Fly toward the player - if (projectile.ai[0] != 0f) - { - FlyingPetAI(); - } - // Try and sit down - else - { - SitDownAttempt(); - } - projectile.spriteDirection = projectile.direction; - DontSitInMidair(); - } + // Fly toward the player + if (projectile.ai[0] != 0f) + { + FlyingPetAI(); + } + // Try and sit down + else + { + SitDownAttempt(); + } + projectile.spriteDirection = projectile.direction; + DontSitInMidair(); + } - private void DontSitInMidair() - { - if (CurrentlySitting()) - { - bool noSolidGround = true; - for (int i = (int)projectile.BottomLeft.X / 16; i < (int)projectile.BottomRight.X / 16; i++) - { - Tile tileBelow = CalamityUtils.ParanoidTileRetrieval(i, (int)(projectile.Bottom.Y / 16)); - if (tileBelow.IsTileSolidGround()) - { - noSolidGround = false; - break; - } - } - if (noSolidGround) - projectile.ai[0] = 1f; - } - } + private void DontSitInMidair() + { + if (CurrentlySitting()) + { + bool noSolidGround = true; + for (int i = (int)projectile.BottomLeft.X / 16; i < (int)projectile.BottomRight.X / 16; i++) + { + Tile tileBelow = CalamityUtils.ParanoidTileRetrieval(i, (int)(projectile.Bottom.Y / 16)); + if (tileBelow.IsTileSolidGround()) + { + noSolidGround = false; + break; + } + } + if (noSolidGround) + projectile.ai[0] = 1f; + } + } - private void FlyingPetAI() - { - float passiveMvtFloat = 0.2f; - projectile.tileCollide = false; - float range = 200f; - float xDist = player.Center.X - projectile.Center.X; - float yDist = player.Center.Y - projectile.Center.Y; - yDist += Main.rand.NextFloat(-10, 20); - xDist += Main.rand.NextFloat(-10, 20); - xDist += 60f * -(float)player.direction; - yDist -= 60f; - Vector2 playerVector = new Vector2(xDist, yDist); - float playerDist = playerVector.Length(); - float returnSpeed = 12f; + private void FlyingPetAI() + { + float passiveMvtFloat = 0.2f; + projectile.tileCollide = false; + float range = 200f; + float xDist = player.Center.X - projectile.Center.X; + float yDist = player.Center.Y - projectile.Center.Y; + yDist += Main.rand.NextFloat(-10, 20); + xDist += Main.rand.NextFloat(-10, 20); + xDist += 60f * -(float)player.direction; + yDist -= 60f; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + float returnSpeed = 12f; - //If player is close enough, try and land - if (playerDist < range && player.velocity.Y == 0f && projectile.Bottom.Y <= player.Bottom.Y && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - if (projectile.velocity.Y < -6f) - { - projectile.velocity.Y = -6f; - } - } + //If player is close enough, try and land + if (playerDist < range && player.velocity.Y == 0f && projectile.Bottom.Y <= player.Bottom.Y && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + if (projectile.velocity.Y < -6f) + { + projectile.velocity.Y = -6f; + } + } - if (playerDist < 60f) - { - playerVector.X = projectile.velocity.X; - playerVector.Y = projectile.velocity.Y; - } - else - { - playerDist = returnSpeed / playerDist; - playerVector.X *= playerDist; - playerVector.Y *= playerDist; - } - if (projectile.velocity.X < playerVector.X) - { - projectile.velocity.X += passiveMvtFloat; - if (projectile.velocity.X < 0f) - { - projectile.velocity.X += passiveMvtFloat * 1.5f; - } - } - if (projectile.velocity.X > playerVector.X) - { - projectile.velocity.X -= passiveMvtFloat; - if (projectile.velocity.X > 0f) - { - projectile.velocity.X -= passiveMvtFloat * 1.5f; - } - } - if (projectile.velocity.Y < playerVector.Y) - { - projectile.velocity.Y += passiveMvtFloat; - if (projectile.velocity.Y < 0f) - { - projectile.velocity.Y += passiveMvtFloat * 1.5f; - } - } - if (projectile.velocity.Y > playerVector.Y) - { - projectile.velocity.Y -= passiveMvtFloat; - if (projectile.velocity.Y > 0f) - { - projectile.velocity.Y -= passiveMvtFloat * 1.5f; - } - } - if (projectile.velocity.X >= 0.5f) - { - projectile.direction = -1; - } - else if (projectile.velocity.X < -0.5f) - { - projectile.direction = 1; - } - else if (player.Center.X < projectile.Center.X) - { - projectile.direction = 1; - } - else if (player.Center.X > projectile.Center.X) - { - projectile.direction = -1; - } + if (playerDist < 60f) + { + playerVector.X = projectile.velocity.X; + playerVector.Y = projectile.velocity.Y; + } + else + { + playerDist = returnSpeed / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + } + if (projectile.velocity.X < playerVector.X) + { + projectile.velocity.X += passiveMvtFloat; + if (projectile.velocity.X < 0f) + { + projectile.velocity.X += passiveMvtFloat * 1.5f; + } + } + if (projectile.velocity.X > playerVector.X) + { + projectile.velocity.X -= passiveMvtFloat; + if (projectile.velocity.X > 0f) + { + projectile.velocity.X -= passiveMvtFloat * 1.5f; + } + } + if (projectile.velocity.Y < playerVector.Y) + { + projectile.velocity.Y += passiveMvtFloat; + if (projectile.velocity.Y < 0f) + { + projectile.velocity.Y += passiveMvtFloat * 1.5f; + } + } + if (projectile.velocity.Y > playerVector.Y) + { + projectile.velocity.Y -= passiveMvtFloat; + if (projectile.velocity.Y > 0f) + { + projectile.velocity.Y -= passiveMvtFloat * 1.5f; + } + } + if (projectile.velocity.X >= 0.5f) + { + projectile.direction = -1; + } + else if (projectile.velocity.X < -0.5f) + { + projectile.direction = 1; + } + else if (player.Center.X < projectile.Center.X) + { + projectile.direction = 1; + } + else if (player.Center.X > projectile.Center.X) + { + projectile.direction = -1; + } - //Tilting - projectile.rotation = projectile.velocity.X * 0.075f; + //Tilting + projectile.rotation = projectile.velocity.X * 0.075f; - // Frames while flying - FlyingFrames(); - } + // Frames while flying + FlyingFrames(); + } - private void SitDownAttempt() - { - projectile.tileCollide = true; + private void SitDownAttempt() + { + projectile.tileCollide = true; - bool tooRight = false; - bool tooLeft = false; - bool abovePlayer = false; - float xAdjust = 0.08f; - float xVelMax = 6.5f; + bool tooRight = false; + bool tooLeft = false; + bool abovePlayer = false; + float xAdjust = 0.08f; + float xVelMax = 6.5f; - if (player.Center.X < projectile.Center.X - 85f) - { - tooRight = true; - } - else if (player.Center.X > projectile.Center.X + 85f) - { - tooLeft = true; - } + if (player.Center.X < projectile.Center.X - 85f) + { + tooRight = true; + } + else if (player.Center.X > projectile.Center.X + 85f) + { + tooLeft = true; + } - if (tooRight) - { - if (projectile.velocity.X > -3.5f) - { - projectile.velocity.X -= xAdjust; - } - else - { - projectile.velocity.X -= xAdjust * 0.25f; - } - } - else if (tooLeft) - { - if (projectile.velocity.X < 3.5f) - { - projectile.velocity.X += xAdjust; - } - else - { - projectile.velocity.X += xAdjust * 0.25f; - } - } - else - { - projectile.velocity.X *= 0.9f; - if (projectile.velocity.X >= 0f - xAdjust && projectile.velocity.X <= xAdjust) - { - projectile.velocity.X = 0f; - } - } - projectile.velocity.X *= 0.95f; - if (projectile.velocity.X > -0.1f && projectile.velocity.X < 0.1f) - { - projectile.velocity.X = 0f; - } + if (tooRight) + { + if (projectile.velocity.X > -3.5f) + { + projectile.velocity.X -= xAdjust; + } + else + { + projectile.velocity.X -= xAdjust * 0.25f; + } + } + else if (tooLeft) + { + if (projectile.velocity.X < 3.5f) + { + projectile.velocity.X += xAdjust; + } + else + { + projectile.velocity.X += xAdjust * 0.25f; + } + } + else + { + projectile.velocity.X *= 0.9f; + if (projectile.velocity.X >= 0f - xAdjust && projectile.velocity.X <= xAdjust) + { + projectile.velocity.X = 0f; + } + } + projectile.velocity.X *= 0.95f; + if (projectile.velocity.X > -0.1f && projectile.velocity.X < 0.1f) + { + projectile.velocity.X = 0f; + } - if (player.Bottom.Y - 8f > projectile.Bottom.Y) - { - abovePlayer = true; - } - Collision.StepUp(ref projectile.position, ref projectile.velocity, projectile.width, projectile.height, ref projectile.stepSpeed, ref projectile.gfxOffY); - if (projectile.velocity.Y == 0f) - { - if (!abovePlayer && projectile.velocity.X != 0f) - { - int i = (int)projectile.Center.X / 16; - int j = (int)projectile.Center.Y / 16 + 1; - if (tooRight) - { - i--; - } - if (tooLeft) - { - i++; - } - WorldGen.SolidTile(i, j); - } - } + if (player.Bottom.Y - 8f > projectile.Bottom.Y) + { + abovePlayer = true; + } + Collision.StepUp(ref projectile.position, ref projectile.velocity, projectile.width, projectile.height, ref projectile.stepSpeed, ref projectile.gfxOffY); + if (projectile.velocity.Y == 0f) + { + if (!abovePlayer && projectile.velocity.X != 0f) + { + int i = (int)projectile.Center.X / 16; + int j = (int)projectile.Center.Y / 16 + 1; + if (tooRight) + { + i--; + } + if (tooLeft) + { + i++; + } + WorldGen.SolidTile(i, j); + } + } - // Cap X velocity when attempting to sit - if (projectile.velocity.X > xVelMax) - { - projectile.velocity.X = xVelMax; - } - if (projectile.velocity.X < -xVelMax) - { - projectile.velocity.X = -xVelMax; - } + // Cap X velocity when attempting to sit + if (projectile.velocity.X > xVelMax) + { + projectile.velocity.X = xVelMax; + } + if (projectile.velocity.X < -xVelMax) + { + projectile.velocity.X = -xVelMax; + } - // Handle frames and sitting direction/rotation - bool sitting = projectile.position.X == projectile.oldPosition.X; - if (projectile.velocity.Y == 0f && sitting) - { - if (player.Center.X < projectile.Center.X) - { - projectile.direction = 1; - } - else if (player.Center.X > projectile.Center.X) - { - projectile.direction = -1; - } - projectile.rotation = 0f; - // Frames while sitting - SittingFrames(); - } - else - { - if (projectile.velocity.X >= 0.5f) - { - projectile.direction = -1; - } - else if (projectile.velocity.X < -0.5f) - { - projectile.direction = 1; - } - else if (player.Center.X < projectile.Center.X) - { - projectile.direction = 1; - } - else if (player.Center.X > projectile.Center.X) - { - projectile.direction = -1; - } + // Handle frames and sitting direction/rotation + bool sitting = projectile.position.X == projectile.oldPosition.X; + if (projectile.velocity.Y == 0f && sitting) + { + if (player.Center.X < projectile.Center.X) + { + projectile.direction = 1; + } + else if (player.Center.X > projectile.Center.X) + { + projectile.direction = -1; + } + projectile.rotation = 0f; + // Frames while sitting + SittingFrames(); + } + else + { + if (projectile.velocity.X >= 0.5f) + { + projectile.direction = -1; + } + else if (projectile.velocity.X < -0.5f) + { + projectile.direction = 1; + } + else if (player.Center.X < projectile.Center.X) + { + projectile.direction = 1; + } + else if (player.Center.X > projectile.Center.X) + { + projectile.direction = -1; + } - projectile.rotation = projectile.velocity.X * 0.075f; + projectile.rotation = projectile.velocity.X * 0.075f; - // Frames while flying - FlyingFrames(); - } - } + // Frames while flying + FlyingFrames(); + } + } } } diff --git a/Projectiles/Ranged/AMR2.cs b/Projectiles/Ranged/AMR2.cs index bb2cc8786b..797aeb955a 100644 --- a/Projectiles/Ranged/AMR2.cs +++ b/Projectiles/Ranged/AMR2.cs @@ -27,6 +27,6 @@ namespace CalamityMod.Projectiles.Ranged aiType = ProjectileID.BulletHighVelocity; projectile.penetrate = 1; projectile.timeLeft = 600; - } + } } } diff --git a/Projectiles/Ranged/AMRShot.cs b/Projectiles/Ranged/AMRShot.cs index e623f004d7..b516f2c8a8 100644 --- a/Projectiles/Ranged/AMRShot.cs +++ b/Projectiles/Ranged/AMRShot.cs @@ -27,29 +27,29 @@ namespace CalamityMod.Projectiles.Ranged projectile.ignoreWater = true; projectile.penetrate = 1; projectile.timeLeft = 600; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } - public override void AI() - { - float num107 = (float)Math.Sqrt(projectile.velocity.X * projectile.velocity.X + projectile.velocity.Y * projectile.velocity.Y); - if (projectile.alpha > 0) - projectile.alpha -= (byte)(num107 * 0.9); - if (projectile.alpha < 0) - projectile.alpha = 0; + public override void AI() + { + float num107 = (float)Math.Sqrt(projectile.velocity.X * projectile.velocity.X + projectile.velocity.Y * projectile.velocity.Y); + if (projectile.alpha > 0) + projectile.alpha -= (byte)(num107 * 0.9); + if (projectile.alpha < 0) + projectile.alpha = 0; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - } + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + } - public override Color? GetAlpha(Color lightColor) - { - if (projectile.alpha < 140) - return new Color(255, 255, 255, 100); + public override Color? GetAlpha(Color lightColor) + { + if (projectile.alpha < 140) + return new Color(255, 255, 255, 100); - return Color.Transparent; - } + return Color.Transparent; + } - public override bool OnTileCollide(Vector2 oldVelocity) + public override bool OnTileCollide(Vector2 oldVelocity) { Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); Main.PlaySound(SoundID.Dig, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f); @@ -58,32 +58,32 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(target.Center, crit); + OnHitEffects(target.Center, crit); target.AddBuff(ModContent.BuffType(), 600); - target.Calamity().miscDefenseLoss = 25; - } + target.Calamity().miscDefenseLoss = 25; + } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(target.Center, crit); + OnHitEffects(target.Center, crit); target.AddBuff(ModContent.BuffType(), 600); - } + } - private void OnHitEffects(Vector2 targetPos, bool crit) - { + private void OnHitEffects(Vector2 targetPos, bool crit) + { if (crit) { - int extraProjectileAmt = 8; + int extraProjectileAmt = 8; for (int x = 0; x < extraProjectileAmt; x++) { - if (projectile.owner == Main.myPlayer) - { - bool fromRight = x > 3; - CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, fromRight, 500f, 500f, 0f, 500f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), projectile.knockBack * 0.1f, projectile.owner); - } + if (projectile.owner == Main.myPlayer) + { + bool fromRight = x > 3; + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, fromRight, 500f, 500f, 0f, 500f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), projectile.knockBack * 0.1f, projectile.owner); + } } } } diff --git a/Projectiles/Ranged/AccelerationBulletProj.cs b/Projectiles/Ranged/AccelerationBulletProj.cs index c65b098b39..a2b10b96b0 100644 --- a/Projectiles/Ranged/AccelerationBulletProj.cs +++ b/Projectiles/Ranged/AccelerationBulletProj.cs @@ -26,30 +26,30 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 600; projectile.extraUpdates = 3; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { projectile.velocity *= 1.01f; - if (projectile.velocity.Length() >= 12f) - { - projectile.velocity *= 0.5f; - projectile.extraUpdates++; - projectile.netUpdate = true; - } + if (projectile.velocity.Length() >= 12f) + { + projectile.velocity *= 0.5f; + projectile.extraUpdates++; + projectile.netUpdate = true; + } - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - if (Main.rand.NextBool(3)) - { - int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 91, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; - } - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + if (Main.rand.NextBool(3)) + { + int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 91, 0f, 0f, 0, default, 0.5f); + Main.dust[num137].alpha = projectile.alpha; + Main.dust[num137].velocity *= 0f; + Main.dust[num137].noGravity = true; + } + } } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Ranged/AcidBulletProj.cs b/Projectiles/Ranged/AcidBulletProj.cs index b69324fecc..b299b950ec 100644 --- a/Projectiles/Ranged/AcidBulletProj.cs +++ b/Projectiles/Ranged/AcidBulletProj.cs @@ -27,24 +27,24 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 600; projectile.extraUpdates = 3; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { Lighting.AddLight(projectile.Center, 0f, 0.25f, 0f); - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - if (Main.rand.NextBool(2)) - { - int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 107, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; - } - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + if (Main.rand.NextBool(2)) + { + int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 107, 0f, 0f, 0, default, 0.5f); + Main.dust[num137].alpha = projectile.alpha; + Main.dust[num137].velocity *= 0f; + Main.dust[num137].noGravity = true; + } + } } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Ranged/AquaBlast.cs b/Projectiles/Ranged/AquaBlast.cs index 60812d6a9a..a5f7fd5fe7 100644 --- a/Projectiles/Ranged/AquaBlast.cs +++ b/Projectiles/Ranged/AquaBlast.cs @@ -20,9 +20,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.timeLeft = 600; projectile.ranged = true; - projectile.extraUpdates = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.extraUpdates = 1; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/AquaBlastToxic.cs b/Projectiles/Ranged/AquaBlastToxic.cs index cc2332a97d..f001b8e3a0 100644 --- a/Projectiles/Ranged/AquaBlastToxic.cs +++ b/Projectiles/Ranged/AquaBlastToxic.cs @@ -22,9 +22,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.timeLeft = 600; projectile.ranged = true; - projectile.extraUpdates = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.extraUpdates = 1; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/Aquashard.cs b/Projectiles/Ranged/Aquashard.cs index b0b763a4c5..b7561514f8 100644 --- a/Projectiles/Ranged/Aquashard.cs +++ b/Projectiles/Ranged/Aquashard.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.timeLeft = 300; projectile.aiStyle = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i < projAmt; i++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), 0f, projectile.owner); } } diff --git a/Projectiles/Ranged/AquashardSplit.cs b/Projectiles/Ranged/AquashardSplit.cs index 0ce0ef2bad..c36e5564a4 100644 --- a/Projectiles/Ranged/AquashardSplit.cs +++ b/Projectiles/Ranged/AquashardSplit.cs @@ -24,16 +24,16 @@ namespace CalamityMod.Projectiles.Ranged projectile.aiStyle = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.velocity.X *= 0.9995f; projectile.velocity.Y += 0.01f; - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 6f, 20f); - } + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 6f, 20f); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Ranged/ArcherfishShot.cs b/Projectiles/Ranged/ArcherfishShot.cs index cf8782eeac..bfc9395a66 100644 --- a/Projectiles/Ranged/ArcherfishShot.cs +++ b/Projectiles/Ranged/ArcherfishShot.cs @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.alpha = 255; projectile.timeLeft = 600; projectile.extraUpdates = 2; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/ArcticArrowProj.cs b/Projectiles/Ranged/ArcticArrowProj.cs index 7cf95830e9..bf1aacaae4 100644 --- a/Projectiles/Ranged/ArcticArrowProj.cs +++ b/Projectiles/Ranged/ArcticArrowProj.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class ArcticArrowProj : ModProjectile + public class ArcticArrowProj : ModProjectile { public override string Texture => "CalamityMod/Items/Ammo/ArcticArrow"; @@ -25,9 +25,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.timeLeft = 600; projectile.aiStyle = 1; - projectile.coldDamage = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.coldDamage = true; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/AstralRound.cs b/Projectiles/Ranged/AstralRound.cs index 431920b962..852582ba75 100644 --- a/Projectiles/Ranged/AstralRound.cs +++ b/Projectiles/Ranged/AstralRound.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Projectiles.Ranged { public class AstralRound : ModProjectile { - private float speed = 0f; + private float speed = 0f; public override void SetStaticDefaults() { DisplayName.SetDefault("Astral Round"); @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.light = 0.25f; projectile.extraUpdates = 2; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override bool OnTileCollide(Vector2 oldVelocity) { @@ -50,27 +50,27 @@ namespace CalamityMod.Projectiles.Ranged projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(90f); projectile.spriteDirection = projectile.direction; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - if (Main.rand.NextBool(2)) - { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.DustType(), - ModContent.DustType() - }); - int astral = Dust.NewDust(projectile.position, 1, 1, randomDust, 0f, 0f, 0, default, 0.5f); - Main.dust[astral].alpha = projectile.alpha; - Main.dust[astral].velocity *= 0f; - Main.dust[astral].noGravity = true; - } - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + if (Main.rand.NextBool(2)) + { + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.DustType(), + ModContent.DustType() + }); + int astral = Dust.NewDust(projectile.position, 1, 1, randomDust, 0f, 0f, 0, default, 0.5f); + Main.dust[astral].alpha = projectile.alpha; + Main.dust[astral].velocity *= 0f; + Main.dust[astral].noGravity = true; + } + } - if (speed == 0f) - speed = projectile.velocity.Length(); + if (speed == 0f) + speed = projectile.velocity.Length(); - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, speed, 12f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, speed, 12f); return false; } diff --git a/Projectiles/Ranged/AstralSandgun.cs b/Projectiles/Ranged/AstralSandgun.cs index 805cab0fe6..8698047db5 100644 --- a/Projectiles/Ranged/AstralSandgun.cs +++ b/Projectiles/Ranged/AstralSandgun.cs @@ -18,8 +18,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = -1; base.SetDefaults(); - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Ranged/AstrealArrow.cs b/Projectiles/Ranged/AstrealArrow.cs index a295ff5adb..142292ab27 100644 --- a/Projectiles/Ranged/AstrealArrow.cs +++ b/Projectiles/Ranged/AstrealArrow.cs @@ -21,15 +21,15 @@ namespace CalamityMod.Projectiles.Ranged projectile.width = 18; projectile.height = 18; projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.ranged = true; projectile.arrow = true; projectile.extraUpdates = 1; projectile.penetrate = 1; projectile.timeLeft = 600; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -56,38 +56,38 @@ namespace CalamityMod.Projectiles.Ranged } } - if (projectile.velocity.Length() < 16f) - { - switch ((int)projectile.ai[0]) - { - case 0: - projectile.velocity.X *= 1.02f; - break; - case 1: - projectile.velocity.Y *= 1.02f; - break; - case 2: - projectile.velocity.X += 0.1f; - projectile.velocity.Y *= 1.01f; - break; - case 3: - projectile.velocity.Y += 0.1f; - projectile.velocity.X *= 1.01f; - break; - default: + if (projectile.velocity.Length() < 16f) + { + switch ((int)projectile.ai[0]) + { + case 0: + projectile.velocity.X *= 1.02f; break; - } - } + case 1: + projectile.velocity.Y *= 1.02f; + break; + case 2: + projectile.velocity.X += 0.1f; + projectile.velocity.Y *= 1.01f; + break; + case 3: + projectile.velocity.Y += 0.1f; + projectile.velocity.X *= 1.01f; + break; + default: + break; + } + } if (Main.rand.NextBool(5)) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 173, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - projectile.ai[1] += Main.rand.Next(2) + 1; + projectile.ai[1] += Main.rand.Next(2) + 1; if (projectile.ai[1] >= 135f) { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - if (projectile.owner == Main.myPlayer) + projectile.ai[1] = 0f; + projectile.netUpdate = true; + if (projectile.owner == Main.myPlayer) { Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); } diff --git a/Projectiles/Ranged/AstrealFlame.cs b/Projectiles/Ranged/AstrealFlame.cs index 0bbca59048..79bf2c0859 100644 --- a/Projectiles/Ranged/AstrealFlame.cs +++ b/Projectiles/Ranged/AstrealFlame.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Ranged { - public class AstrealFlame : ModProjectile + public class AstrealFlame : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Healing/EssenceFlame"; @@ -26,9 +26,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.alpha = 255; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.alpha -= 5; @@ -41,8 +41,8 @@ namespace CalamityMod.Projectiles.Ranged if (projectile.frame > 3) projectile.frame = 0; - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/AuralisBullet.cs b/Projectiles/Ranged/AuralisBullet.cs index 2909c31d09..2454c66814 100644 --- a/Projectiles/Ranged/AuralisBullet.cs +++ b/Projectiles/Ranged/AuralisBullet.cs @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.extraUpdates = 10; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -43,25 +43,25 @@ namespace CalamityMod.Projectiles.Ranged dust.noGravity = true; dust.scale = 0.65f; dust.noLight = true; - dust.color = CalamityUtils.ColorSwap(Auralis.blueColor, Auralis.greenColor, 1f); + dust.color = CalamityUtils.ColorSwap(Auralis.blueColor, Auralis.greenColor, 1f); } } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - int duration = 420; - target.AddBuff(ModContent.BuffType(), duration); - target.AddBuff(BuffID.Ichor, duration); - target.AddBuff(BuffID.CursedInferno, duration); + int duration = 420; + target.AddBuff(ModContent.BuffType(), duration); + target.AddBuff(BuffID.Ichor, duration); + target.AddBuff(BuffID.CursedInferno, duration); } public override void OnHitPvp(Player target, int damage, bool crit) { - int duration = 420; - target.AddBuff(ModContent.BuffType(), duration); - target.AddBuff(BuffID.Ichor, duration); - target.AddBuff(BuffID.CursedInferno, duration); + int duration = 420; + target.AddBuff(ModContent.BuffType(), duration); + target.AddBuff(BuffID.Ichor, duration); + target.AddBuff(BuffID.CursedInferno, duration); } } } diff --git a/Projectiles/Ranged/AuroraFire.cs b/Projectiles/Ranged/AuroraFire.cs index 3302549d2b..7aa08245a3 100644 --- a/Projectiles/Ranged/AuroraFire.cs +++ b/Projectiles/Ranged/AuroraFire.cs @@ -7,13 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class AuroraFire : ModProjectile + public class AuroraFire : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private const int framesBeforeTurning = 70; - private bool initialized = false; - private int radianAmt = 0; + private const int framesBeforeTurning = 70; + private bool initialized = false; + private int radianAmt = 0; public override void SetStaticDefaults() { @@ -29,52 +29,52 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = -1; projectile.extraUpdates = 3; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 20; } public override void AI() { - if (projectile.ai[0] % 2 == 0) - projectile.ai[0]++; + if (projectile.ai[0] % 2 == 0) + projectile.ai[0]++; - if (!initialized) - { - int pointCount = (int)projectile.ai[0]; - radianAmt = 180 + (int)(360 / (pointCount * 2)); - projectile.timeLeft = framesBeforeTurning * pointCount - 1; - initialized = true; - } + if (!initialized) + { + int pointCount = (int)projectile.ai[0]; + radianAmt = 180 + (int)(360 / (pointCount * 2)); + projectile.timeLeft = framesBeforeTurning * pointCount - 1; + initialized = true; + } - //Velocity movement - projectile.localAI[1]++; - if (projectile.localAI[1] % framesBeforeTurning == 0) - { - projectile.velocity = projectile.velocity.RotatedBy(MathHelper.ToRadians(radianAmt)); - } + //Velocity movement + projectile.localAI[1]++; + if (projectile.localAI[1] % framesBeforeTurning == 0) + { + projectile.velocity = projectile.velocity.RotatedBy(MathHelper.ToRadians(radianAmt)); + } - //Dust behavior + //Dust behavior projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.DustType(), - ModContent.DustType() - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.DustType(), + ModContent.DustType() + }); for (int i = 0; i < 5; i++) { int astral = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.8f); Dust dust = Main.dust[astral]; dust.noGravity = true; dust.velocity *= 0f; - dust.scale *= Main.rand.NextFloat(); + dust.scale *= Main.rand.NextFloat(); } } - //rotation code for when sproot - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; + //rotation code for when sproot + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/BallistaGreatArrow.cs b/Projectiles/Ranged/BallistaGreatArrow.cs index bb72b60c52..9ec0fdc764 100644 --- a/Projectiles/Ranged/BallistaGreatArrow.cs +++ b/Projectiles/Ranged/BallistaGreatArrow.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 2; projectile.aiStyle = 1; aiType = ProjectileID.WoodenArrowFriendly; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override bool OnTileCollide(Vector2 oldVelocity) { diff --git a/Projectiles/Ranged/BeeRPG.cs b/Projectiles/Ranged/BeeRPG.cs index a271fdec52..def5781353 100644 --- a/Projectiles/Ranged/BeeRPG.cs +++ b/Projectiles/Ranged/BeeRPG.cs @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -108,11 +108,11 @@ namespace CalamityMod.Projectiles.Ranged num518 += projectile.oldVelocity.X / 6f; num519 += projectile.oldVelocity.Y / 6f; int bee = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 4), Main.player[projectile.owner].beeKB(0f), Main.myPlayer); - if (bee.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[bee].penetrate = 2; - Main.projectile[bee].Calamity().forceRanged = true; - } + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 2; + Main.projectile[bee].Calamity().forceRanged = true; + } } } } @@ -135,30 +135,30 @@ namespace CalamityMod.Projectiles.Ranged num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - bool canShoot = true; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); - int blastRadius = 0; - if (projID == ProjectileID.RocketII) - blastRadius = 3; - else if (projID == ProjectileID.RocketIV) - blastRadius = 6; + // Construct a fake item to use with vanilla code for the sake of picking ammo. + if (FalseLauncher is null) + DefineFalseLauncher(); + Player player = Main.player[projectile.owner]; + int projID = ProjectileID.RocketI; + float shootSpeed = 0f; + bool canShoot = true; + int damage = 0; + float kb = 0f; + player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); + int blastRadius = 0; + if (projID == ProjectileID.RocketII) + blastRadius = 3; + else if (projID == ProjectileID.RocketIV) + blastRadius = 6; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); - if (projectile.owner == Main.myPlayer && blastRadius > 0) - { - CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); - } + if (projectile.owner == Main.myPlayer && blastRadius > 0) + { + CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/BigCoral.cs b/Projectiles/Ranged/BigCoral.cs index 44f34218f5..8bd9aa79a2 100644 --- a/Projectiles/Ranged/BigCoral.cs +++ b/Projectiles/Ranged/BigCoral.cs @@ -6,7 +6,7 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Ranged { - public class BigCoral : ModProjectile + public class BigCoral : ModProjectile { public override void SetStaticDefaults() { @@ -21,16 +21,16 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = 1; projectile.aiStyle = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { projectile.velocity.X *= 0.999f; projectile.velocity.Y = projectile.velocity.Y + 0.025f; - projectile.rotation = projectile.velocity.ToRotation(); - if (projectile.direction == -1) - projectile.rotation += MathHelper.Pi; + projectile.rotation = projectile.velocity.ToRotation(); + if (projectile.direction == -1) + projectile.rotation += MathHelper.Pi; } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/BigNuke.cs b/Projectiles/Ranged/BigNuke.cs index 2b3001e9b3..f7f75963af 100644 --- a/Projectiles/Ranged/BigNuke.cs +++ b/Projectiles/Ranged/BigNuke.cs @@ -36,11 +36,11 @@ namespace CalamityMod.Projectiles.Ranged { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(90); - if (projectile.ai[0] == 0f) - { - Main.PlaySound(SoundID.Item11, (int)projectile.Center.X, (int)projectile.Center.Y); - projectile.ai[0] = 1f; - } + if (projectile.ai[0] == 0f) + { + Main.PlaySound(SoundID.Item11, (int)projectile.Center.X, (int)projectile.Center.Y); + projectile.ai[0] = 1f; + } //Animation projectile.frameCounter++; @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num249].velocity *= 0.05f; } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool OnTileCollide(Vector2 oldVelocity) @@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 720); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 720); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -111,25 +111,25 @@ namespace CalamityMod.Projectiles.Ranged num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 9); + CalamityUtils.ExplosionGores(projectile.Center, 9); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - bool canShoot = true; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); + // Construct a fake item to use with vanilla code for the sake of picking ammo. + if (FalseLauncher is null) + DefineFalseLauncher(); + Player player = Main.player[projectile.owner]; + int projID = ProjectileID.RocketI; + float shootSpeed = 0f; + bool canShoot = true; + int damage = 0; + float kb = 0f; + player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 16); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 16); - if (projectile.owner == Main.myPlayer && (projID == ProjectileID.RocketII || projID == ProjectileID.RocketIV)) - { - CalamityUtils.ExplodeandDestroyTiles(projectile, 23, true, new List() { }, new List() { }); - } + if (projectile.owner == Main.myPlayer && (projID == ProjectileID.RocketII || projID == ProjectileID.RocketIV)) + { + CalamityUtils.ExplodeandDestroyTiles(projectile, 23, true, new List() { }, new List() { }); + } } } } diff --git a/Projectiles/Ranged/BloodBoilerFire.cs b/Projectiles/Ranged/BloodBoilerFire.cs index 21b3f5cb12..dc2e121b0f 100644 --- a/Projectiles/Ranged/BloodBoilerFire.cs +++ b/Projectiles/Ranged/BloodBoilerFire.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Projectiles.Ranged { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private bool playedSound = false; + private bool playedSound = false; public override void SetStaticDefaults() { @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Ranged { projectile.width = 6; projectile.height = 6; - projectile.scale = 2f; + projectile.scale = 2f; projectile.friendly = true; projectile.ignoreWater = true; projectile.ranged = true; @@ -35,11 +35,11 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - if (!playedSound) - { + if (!playedSound) + { Main.PlaySound(SoundID.Item34, (int)projectile.position.X, (int)projectile.position.Y); - playedSound = true; - } + playedSound = true; + } if (projectile.scale <= 3f) projectile.scale *= 1.01f; @@ -97,14 +97,14 @@ namespace CalamityMod.Projectiles.Ranged } projectile.rotation += 0.3f * (float)projectile.direction; - if (projectile.timeLeft == 160) - projectile.ai[1] = 1f; + if (projectile.timeLeft == 160) + projectile.ai[1] = 1f; - if (projectile.ai[1] == 1f) - { - projectile.tileCollide = false; + if (projectile.ai[1] == 1f) + { + projectile.tileCollide = false; - projectile.extraUpdates = 2; + projectile.extraUpdates = 2; Player player = Main.player[projectile.owner]; @@ -146,20 +146,20 @@ namespace CalamityMod.Projectiles.Ranged projectile.velocity.Y -= 5f; } - // Delete the projectile if it touches its owner. Has a chance to heal the player again - if (Main.myPlayer == projectile.owner) - { - if (projectile.Hitbox.Intersects(player.Hitbox)) - { - if (Main.rand.NextBool(3) && !Main.player[projectile.owner].moonLeech) - { - player.statLife += 1; - player.HealEffect(1); - } - projectile.Kill(); - } - } - } + // Delete the projectile if it touches its owner. Has a chance to heal the player again + if (Main.myPlayer == projectile.owner) + { + if (projectile.Hitbox.Intersects(player.Hitbox)) + { + if (Main.rand.NextBool(3) && !Main.player[projectile.owner].moonLeech) + { + player.statLife += 1; + player.HealEffect(1); + } + projectile.Kill(); + } + } + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -173,7 +173,7 @@ namespace CalamityMod.Projectiles.Ranged Player player = Main.player[projectile.owner]; if (Main.rand.NextBool(2)) { - int healAmt = Main.rand.Next(1, 4); + int healAmt = Main.rand.Next(1, 4); player.statLife += healAmt; player.HealEffect(healAmt); } diff --git a/Projectiles/Ranged/BloodClotFriendly.cs b/Projectiles/Ranged/BloodClotFriendly.cs index bd6a0b2206..d6d50cc43f 100644 --- a/Projectiles/Ranged/BloodClotFriendly.cs +++ b/Projectiles/Ranged/BloodClotFriendly.cs @@ -11,9 +11,9 @@ namespace CalamityMod.Projectiles.Ranged public override void SetStaticDefaults() { DisplayName.SetDefault("Blood Clot"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { @@ -23,10 +23,10 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = 1; projectile.aiStyle = 1; - projectile.extraUpdates = 3; + projectile.extraUpdates = 3; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -42,17 +42,17 @@ namespace CalamityMod.Projectiles.Ranged } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); + return false; + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); - Main.PlaySound(SoundID.Dig, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f); - return true; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); + Main.PlaySound(SoundID.Dig, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f); + return true; + } + } } diff --git a/Projectiles/Ranged/BloodfireArrowProj.cs b/Projectiles/Ranged/BloodfireArrowProj.cs index 1053b260bf..a369d39e24 100644 --- a/Projectiles/Ranged/BloodfireArrowProj.cs +++ b/Projectiles/Ranged/BloodfireArrowProj.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.arrow = true; projectile.penetrate = 1; projectile.timeLeft = 300; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override bool OnTileCollide(Vector2 oldVelocity) { @@ -60,8 +60,8 @@ namespace CalamityMod.Projectiles.Ranged } } - if (projectile.ai[1] == 80f) //means it's from Arterial Assault's wooden arrow conversion - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + if (projectile.ai[1] == 80f) //means it's from Arterial Assault's wooden arrow conversion + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void Kill(int timeLeft) @@ -93,9 +93,9 @@ namespace CalamityMod.Projectiles.Ranged Player player = Main.player[projectile.owner]; - int chance = 3; - if (player.ActiveItem().type == ModContent.ItemType()) - chance = 6; + int chance = 3; + if (player.ActiveItem().type == ModContent.ItemType()) + chance = 6; if (Main.rand.NextBool(chance)) { diff --git a/Projectiles/Ranged/BloodfireBulletProj.cs b/Projectiles/Ranged/BloodfireBulletProj.cs index 868cd23a15..a22bd17b5a 100644 --- a/Projectiles/Ranged/BloodfireBulletProj.cs +++ b/Projectiles/Ranged/BloodfireBulletProj.cs @@ -6,95 +6,95 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class BloodfireBulletProj : ModProjectile - { - private const int Lifetime = 600; + public class BloodfireBulletProj : ModProjectile + { + private const int Lifetime = 600; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bloodfire Bullet"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bloodfire Bullet"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 4; - projectile.height = 4; - projectile.friendly = true; - projectile.ranged = true; - projectile.extraUpdates = 4; - projectile.timeLeft = Lifetime; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + public override void SetDefaults() + { + projectile.width = 4; + projectile.height = 4; + projectile.friendly = true; + projectile.ranged = true; + projectile.extraUpdates = 4; + projectile.timeLeft = Lifetime; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } - public override void AI() - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - projectile.spriteDirection = projectile.direction; + public override void AI() + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.spriteDirection = projectile.direction; - // Lighting - Lighting.AddLight(projectile.Center, 0.9f, 0f, 0.15f); + // Lighting + Lighting.AddLight(projectile.Center, 0.9f, 0f, 0.15f); - // Dust - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - int dustID = 90; - float scale = Main.rand.NextFloat(0.6f, 0.9f); - Dust d = Dust.NewDustDirect(projectile.Center, 0, 0, dustID); - Vector2 posOffset = projectile.velocity.SafeNormalize(Vector2.Zero) * 12f; - d.position += posOffset - 2f * Vector2.UnitY; - d.noGravity = true; - d.velocity *= 0.6f; - d.velocity += projectile.velocity * 0.15f; - d.scale = scale; - } - } + // Dust + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + int dustID = 90; + float scale = Main.rand.NextFloat(0.6f, 0.9f); + Dust d = Dust.NewDustDirect(projectile.Center, 0, 0, dustID); + Vector2 posOffset = projectile.velocity.SafeNormalize(Vector2.Zero) * 12f; + d.position += posOffset - 2f * Vector2.UnitY; + d.noGravity = true; + d.velocity *= 0.6f; + d.velocity += projectile.velocity * 0.15f; + d.scale = scale; + } + } - // These bullets glow in the dark. - public override Color? GetAlpha(Color lightColor) => new Color(255, 255, 255, 140); + // These bullets glow in the dark. + public override Color? GetAlpha(Color lightColor) => new Color(255, 255, 255, 140); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); + return false; + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) => damage += OnHitEffect(Main.player[projectile.owner]); - public override void ModifyHitPvp(Player target, ref int damage, ref bool crit) => damage += OnHitEffect(Main.player[projectile.owner]); + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) => damage += OnHitEffect(Main.player[projectile.owner]); + public override void ModifyHitPvp(Player target, ref int damage, ref bool crit) => damage += OnHitEffect(Main.player[projectile.owner]); - // Returns the amount of bonus damage that should be dealt. Boosts life regeneration appropriately as a side effect. - private int OnHitEffect(Player owner) - { - // Adds 2 frames to lifeRegenTime on every hit. This increased value is used for the damage calculation. - owner.lifeRegenTime += 2; + // Returns the amount of bonus damage that should be dealt. Boosts life regeneration appropriately as a side effect. + private int OnHitEffect(Player owner) + { + // Adds 2 frames to lifeRegenTime on every hit. This increased value is used for the damage calculation. + owner.lifeRegenTime += 2; - // Deals (1.00 + (0.05 * current lifeRegen))% of current lifeRegenTime as flat bonus damage on hit. - // For example, at 0 life regen, you get 1% of lifeRegenTime as bonus damage. - // At 10 life regen, you get 2%. At 20 life regen, you get 3%. - // Negative life regen does not decrease damage. - int regenForCalc = owner.lifeRegen > 0 ? owner.lifeRegen : 0; - float regenDamageRatio = 0.01f + 0.0005f * regenForCalc; + // Deals (1.00 + (0.05 * current lifeRegen))% of current lifeRegenTime as flat bonus damage on hit. + // For example, at 0 life regen, you get 1% of lifeRegenTime as bonus damage. + // At 10 life regen, you get 2%. At 20 life regen, you get 3%. + // Negative life regen does not decrease damage. + int regenForCalc = owner.lifeRegen > 0 ? owner.lifeRegen : 0; + float regenDamageRatio = 0.01f + 0.0005f * regenForCalc; - // For the sake of bonus damage, life regen time caps at 3600, aka 60 seconds. This is its natural cap in vanilla. - int regenTimeForCalc = (int)MathHelper.Clamp(owner.lifeRegenTime, 0f, 3600f); - return (int)(regenDamageRatio * regenTimeForCalc); - } + // For the sake of bonus damage, life regen time caps at 3600, aka 60 seconds. This is its natural cap in vanilla. + int regenTimeForCalc = (int)MathHelper.Clamp(owner.lifeRegenTime, 0f, 3600f); + return (int)(regenDamageRatio * regenTimeForCalc); + } - public override void Kill(int timeLeft) - { - int dustID = 90; - int dustCount = 3; - for(int i = 0; i < dustCount; ++i) - _ = Dust.NewDust(projectile.Center, 0, 0, dustID, Scale: 1.2f); - } + public override void Kill(int timeLeft) + { + int dustID = 90; + int dustCount = 3; + for(int i = 0; i < dustCount; ++i) + _ = Dust.NewDust(projectile.Center, 0, 0, dustID, Scale: 1.2f); + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); - Main.PlaySound(SoundID.Item10, projectile.Center); - return true; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); + Main.PlaySound(SoundID.Item10, projectile.Center); + return true; + } + } } diff --git a/Projectiles/Ranged/BloodflareSoul.cs b/Projectiles/Ranged/BloodflareSoul.cs index ea6c1e587a..89addc3260 100644 --- a/Projectiles/Ranged/BloodflareSoul.cs +++ b/Projectiles/Ranged/BloodflareSoul.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 11f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 11f, 20f); } else { diff --git a/Projectiles/Ranged/BlueExoArrow2.cs b/Projectiles/Ranged/BlueExoArrow2.cs index b3fab49725..e1b2a0fc1d 100644 --- a/Projectiles/Ranged/BlueExoArrow2.cs +++ b/Projectiles/Ranged/BlueExoArrow2.cs @@ -3,7 +3,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class BlueExoArrow2 : ModProjectile + public class BlueExoArrow2 : ModProjectile { public override string Texture => "CalamityMod/Projectiles/LaserProj"; diff --git a/Projectiles/Ranged/Bolt.cs b/Projectiles/Ranged/Bolt.cs index aaeabe157e..de477a1ebe 100644 --- a/Projectiles/Ranged/Bolt.cs +++ b/Projectiles/Ranged/Bolt.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class Bolt : ModProjectile + public class Bolt : ModProjectile { public override void SetStaticDefaults() { @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.alpha = 255; projectile.penetrate = 1; - projectile.timeLeft = 600; + projectile.timeLeft = 600; } public override void AI() diff --git a/Projectiles/Ranged/BoltArrow.cs b/Projectiles/Ranged/BoltArrow.cs index 7e078b4130..ebb0970a1c 100644 --- a/Projectiles/Ranged/BoltArrow.cs +++ b/Projectiles/Ranged/BoltArrow.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.arrow = true; projectile.penetrate = 1; projectile.timeLeft = 180; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage = (int)(projectile.damage * 0.6f); + projectile.damage = (int)(projectile.damage * 0.6f); projectile.Damage(); Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 92); int num212 = Main.rand.Next(10, 20); diff --git a/Projectiles/Ranged/BouncingShotgunPellet.cs b/Projectiles/Ranged/BouncingShotgunPellet.cs index a7228035d5..5c4e2a90ed 100644 --- a/Projectiles/Ranged/BouncingShotgunPellet.cs +++ b/Projectiles/Ranged/BouncingShotgunPellet.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Projectiles.Ranged public class BouncingShotgunPellet : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Ranged/RealmRavagerBullet"; - private int bounce = 2; + private int bounce = 2; public override void SetStaticDefaults() { DisplayName.SetDefault("Shotgun Pellet"); @@ -24,25 +24,25 @@ namespace CalamityMod.Projectiles.Ranged projectile.aiStyle = 1; aiType = ProjectileID.BulletHighVelocity; projectile.timeLeft = 180; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override bool OnTileCollide(Vector2 oldVelocity) { - bounce--; - if (bounce <= 0) - projectile.Kill(); - else - { - if (projectile.velocity.X != oldVelocity.X) - projectile.velocity.X = -oldVelocity.X; - if (projectile.velocity.Y != oldVelocity.Y) - projectile.velocity.Y = -oldVelocity.Y; + bounce--; + if (bounce <= 0) + projectile.Kill(); + else + { + if (projectile.velocity.X != oldVelocity.X) + projectile.velocity.X = -oldVelocity.X; + if (projectile.velocity.Y != oldVelocity.Y) + projectile.velocity.Y = -oldVelocity.Y; Main.PlaySound(SoundID.Item10, projectile.Center); - projectile.damage /= 2; - } - return false; - } + projectile.damage /= 2; + } + return false; + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => Main.PlaySound(SoundID.Item10, projectile.Center); @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); for (int d = 0; d < 2; d++) { Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1.5f); diff --git a/Projectiles/Ranged/BrimstoneBolt.cs b/Projectiles/Ranged/BrimstoneBolt.cs index 91a19aac79..0a1ef6d594 100644 --- a/Projectiles/Ranged/BrimstoneBolt.cs +++ b/Projectiles/Ranged/BrimstoneBolt.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.extraUpdates = 2; projectile.timeLeft = 300; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; } public override void AI() diff --git a/Projectiles/Ranged/ButcherGun.cs b/Projectiles/Ranged/ButcherGun.cs index 1f1eaeaa5f..7cf00ca114 100644 --- a/Projectiles/Ranged/ButcherGun.cs +++ b/Projectiles/Ranged/ButcherGun.cs @@ -160,6 +160,6 @@ namespace CalamityMod.Projectiles.Ranged player.itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); } - public override bool CanDamage() => false; - } + public override bool CanDamage() => false; + } } diff --git a/Projectiles/Ranged/CardClub.cs b/Projectiles/Ranged/CardClub.cs index 9b53b52ee6..ed72dc9786 100644 --- a/Projectiles/Ranged/CardClub.cs +++ b/Projectiles/Ranged/CardClub.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0f / 255f); - projectile.rotation -= (MathHelper.ToRadians(90) * projectile.direction); - projectile.spriteDirection = projectile.direction; + projectile.rotation -= (MathHelper.ToRadians(90) * projectile.direction); + projectile.spriteDirection = projectile.direction; if (Main.rand.NextBool(2)) { int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); diff --git a/Projectiles/Ranged/CardClubSplit.cs b/Projectiles/Ranged/CardClubSplit.cs index ef61fcab2d..d9e3fdb2e5 100644 --- a/Projectiles/Ranged/CardClubSplit.cs +++ b/Projectiles/Ranged/CardClubSplit.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class CardClubSplit : ModProjectile + public class CardClubSplit : ModProjectile { public override void SetStaticDefaults() { @@ -32,8 +32,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0f / 255f); - projectile.rotation -= (MathHelper.ToRadians(90) * projectile.direction); - projectile.spriteDirection = projectile.direction; + projectile.rotation -= (MathHelper.ToRadians(90) * projectile.direction); + projectile.spriteDirection = projectile.direction; if (Main.rand.NextBool(2)) { int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); @@ -41,10 +41,10 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num137].noGravity = true; } - if (projectile.alpha < 128) - { - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); - } + if (projectile.alpha < 128) + { + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); + } } public override bool OnTileCollide(Vector2 oldVelocity) @@ -73,9 +73,9 @@ namespace CalamityMod.Projectiles.Ranged return false; } - public override bool CanDamage() - { - return projectile.alpha < 128; - } + public override bool CanDamage() + { + return projectile.alpha < 128; + } } } diff --git a/Projectiles/Ranged/CardDiamond.cs b/Projectiles/Ranged/CardDiamond.cs index f86c508a54..982b53758e 100644 --- a/Projectiles/Ranged/CardDiamond.cs +++ b/Projectiles/Ranged/CardDiamond.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0f / 255f); - projectile.rotation -= (MathHelper.ToRadians(90) * projectile.direction); - projectile.spriteDirection = projectile.direction; + projectile.rotation -= (MathHelper.ToRadians(90) * projectile.direction); + projectile.spriteDirection = projectile.direction; if (Main.rand.NextBool(2)) { int num137 = Dust.NewDust(projectile.position, 1, 1, 30, 0f, 0f, 0, default, 0.5f); @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged paper = Dust.NewDust(projectile.position, projectile.width, projectile.height, 30, 0f, 0f, 100, default, 2f); Main.dust[paper].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/CardHeart.cs b/Projectiles/Ranged/CardHeart.cs index 3fa11e9a4e..d0cc0c7579 100644 --- a/Projectiles/Ranged/CardHeart.cs +++ b/Projectiles/Ranged/CardHeart.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0f / 255f); - projectile.rotation -= (MathHelper.ToRadians(90) * projectile.direction); - projectile.spriteDirection = projectile.direction; + projectile.rotation -= (MathHelper.ToRadians(90) * projectile.direction); + projectile.spriteDirection = projectile.direction; if (Main.rand.NextBool(2)) { int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); @@ -65,8 +65,8 @@ namespace CalamityMod.Projectiles.Ranged if (player.moonLeech) return; - player.statLife += 1; - player.HealEffect(1); + player.statLife += 1; + player.HealEffect(1); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Ranged/CardSpade.cs b/Projectiles/Ranged/CardSpade.cs index 990990b822..e1a4292862 100644 --- a/Projectiles/Ranged/CardSpade.cs +++ b/Projectiles/Ranged/CardSpade.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0f / 255f); - projectile.rotation -= (MathHelper.ToRadians(90) * projectile.direction); - projectile.spriteDirection = projectile.direction; + projectile.rotation -= (MathHelper.ToRadians(90) * projectile.direction); + projectile.spriteDirection = projectile.direction; if (Main.rand.NextBool(2)) { int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); diff --git a/Projectiles/Ranged/ChargedBlast.cs b/Projectiles/Ranged/ChargedBlast.cs index 8585178a6d..832f01e52d 100644 --- a/Projectiles/Ranged/ChargedBlast.cs +++ b/Projectiles/Ranged/ChargedBlast.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.extraUpdates = 3; projectile.alpha = 255; projectile.timeLeft = 600; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/ChargedBlast3.cs b/Projectiles/Ranged/ChargedBlast3.cs index 74048584fd..1d798fc029 100644 --- a/Projectiles/Ranged/ChargedBlast3.cs +++ b/Projectiles/Ranged/ChargedBlast3.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.extraUpdates = 3; projectile.alpha = 255; projectile.timeLeft = 300; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/ChargedDartExplosion.cs b/Projectiles/Ranged/ChargedDartExplosion.cs index 8c516e90f2..126fa5d65a 100644 --- a/Projectiles/Ranged/ChargedDartExplosion.cs +++ b/Projectiles/Ranged/ChargedDartExplosion.cs @@ -5,15 +5,15 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class ChargedDartExplosion : ModProjectile + public class ChargedDartExplosion : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Explosion"); - } - + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Explosion"); + } + public override void SetDefaults() { projectile.width = 50; @@ -21,66 +21,66 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.ranged = true; - projectile.penetrate = -1; + projectile.ranged = true; + projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; projectile.timeLeft = 5; } - public override void AI() - { - if (projectile.timeLeft == 5) - { - if (projectile.ai[1] == 0f) //small, on hit npc and tile collide - { - for (int num621 = 0; num621 < 5; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 10; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - else //big, on kill - { - projectile.height = projectile.width = 100; - for (int num621 = 0; num621 < 10; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 20; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - } + public override void AI() + { + if (projectile.timeLeft == 5) + { + if (projectile.ai[1] == 0f) //small, on hit npc and tile collide + { + for (int num621 = 0; num621 < 5; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 10; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + else //big, on kill + { + projectile.height = projectile.width = 100; + for (int num621 = 0; num621 < 10; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 20; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 3f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 160, 0f, 0f, 100, default, 2f); + Main.dust[num624].velocity *= 2f; + } + } + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 240); } } } \ No newline at end of file diff --git a/Projectiles/Ranged/ClamorRifleProj.cs b/Projectiles/Ranged/ClamorRifleProj.cs index b144b352b2..790ac59727 100644 --- a/Projectiles/Ranged/ClamorRifleProj.cs +++ b/Projectiles/Ranged/ClamorRifleProj.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class ClamorRifleProj : ModProjectile + public class ClamorRifleProj : ModProjectile { public override void SetStaticDefaults() { @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.ignoreWater = true; projectile.penetrate = 1; projectile.ranged = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num155].velocity += projectile.velocity * 0.5f; } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 25f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 25f); } /*public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int b = 0; b < bulletAmt; b++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.45), 0f, projectile.owner, 0f, 0f); } } diff --git a/Projectiles/Ranged/ClamorRifleProjSplit.cs b/Projectiles/Ranged/ClamorRifleProjSplit.cs index 1c6bd95dae..7934ddb274 100644 --- a/Projectiles/Ranged/ClamorRifleProjSplit.cs +++ b/Projectiles/Ranged/ClamorRifleProjSplit.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class ClamorRifleProjSplit : ModProjectile + public class ClamorRifleProjSplit : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Ranged/ClamorRifleProj"; @@ -19,14 +19,14 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.ignoreWater = true; projectile.scale = 0.9f; - projectile.timeLeft = 180; + projectile.timeLeft = 180; projectile.penetrate = 1; projectile.ranged = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.rotation += 0.15f; @@ -41,9 +41,9 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num155].velocity += projectile.velocity * 0.5f; } - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 25f); - } + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 25f); + } /* override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Ranged/ClaretCannonProj.cs b/Projectiles/Ranged/ClaretCannonProj.cs index 07356be67e..1ed7557a6d 100644 --- a/Projectiles/Ranged/ClaretCannonProj.cs +++ b/Projectiles/Ranged/ClaretCannonProj.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class ClaretCannonProj : ModProjectile + public class ClaretCannonProj : ModProjectile { public override void SetStaticDefaults() { @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.extraUpdates = 1; projectile.aiStyle = 1; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/ContagionArrow.cs b/Projectiles/Ranged/ContagionArrow.cs index 73b17e8bdd..47d2af4e1f 100644 --- a/Projectiles/Ranged/ContagionArrow.cs +++ b/Projectiles/Ranged/ContagionArrow.cs @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.extraUpdates = 1; projectile.ranged = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/CorrodedShell.cs b/Projectiles/Ranged/CorrodedShell.cs index 5d71414ead..6bd1a5c08b 100644 --- a/Projectiles/Ranged/CorrodedShell.cs +++ b/Projectiles/Ranged/CorrodedShell.cs @@ -22,14 +22,14 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.ranged = true; projectile.arrow = true; - projectile.ignoreWater = true; - projectile.penetrate = 6; + projectile.ignoreWater = true; + projectile.penetrate = 6; projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.aiStyle = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -42,11 +42,11 @@ namespace CalamityMod.Projectiles.Ranged if (projectile.owner == Main.myPlayer) { int aura = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.15), projectile.knockBack, projectile.owner); - if (aura.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[aura].Calamity().forceRanged = true; - Main.projectile[aura].timeLeft = 40; - } + if (aura.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[aura].Calamity().forceRanged = true; + Main.projectile[aura].timeLeft = 40; + } } } } @@ -71,8 +71,8 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 60); - target.AddBuff(ModContent.BuffType(), 30); + target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(ModContent.BuffType(), 30); } } } diff --git a/Projectiles/Ranged/CosmicFire.cs b/Projectiles/Ranged/CosmicFire.cs index f4e95dbe9f..414e851361 100644 --- a/Projectiles/Ranged/CosmicFire.cs +++ b/Projectiles/Ranged/CosmicFire.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class CosmicFire : ModProjectile + public class CosmicFire : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -50,27 +50,27 @@ namespace CalamityMod.Projectiles.Ranged int dustType = Main.rand.NextBool(4) ? 61 : 62; if (Main.rand.NextBool(2)) { - int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[fire]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 3f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= scalar; - dust.velocity += projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[fire]; + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 3f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 1.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= scalar; + dust.velocity += projectile.velocity; + if (!dust.noGravity) + { + dust.velocity *= 0.5f; + } } } else diff --git a/Projectiles/Ranged/DWArrow.cs b/Projectiles/Ranged/DWArrow.cs index 2a6466a623..53d45c27b9 100644 --- a/Projectiles/Ranged/DWArrow.cs +++ b/Projectiles/Ranged/DWArrow.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.arrow = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/DaemonsFlameBow.cs b/Projectiles/Ranged/DaemonsFlameBow.cs index a2aef8c75c..345048f7e8 100644 --- a/Projectiles/Ranged/DaemonsFlameBow.cs +++ b/Projectiles/Ranged/DaemonsFlameBow.cs @@ -152,19 +152,19 @@ namespace CalamityMod.Projectiles.Ranged player.itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture2D13 = Main.projectileTexture[projectile.type]; - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; - int y6 = num214 * projectile.frame; - Vector2 origin = new Vector2(27f, 58f); - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture2D13 = Main.projectileTexture[projectile.type]; + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int y6 = num214 * projectile.frame; + Vector2 origin = new Vector2(27f, 58f); + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Ranged/DaemonsFlameBowGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - } + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Ranged/DaemonsFlameBowGlow"), projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + } - public override bool CanDamage() => false; - } + public override bool CanDamage() => false; + } } diff --git a/Projectiles/Ranged/DesertMark.cs b/Projectiles/Ranged/DesertMark.cs index 7612ca6562..d048b75112 100644 --- a/Projectiles/Ranged/DesertMark.cs +++ b/Projectiles/Ranged/DesertMark.cs @@ -6,7 +6,7 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Ranged { - public class DesertMark : ModProjectile + public class DesertMark : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Ranged/DesertTornado.cs b/Projectiles/Ranged/DesertTornado.cs index a5a84fd003..c4c7ce5e8b 100644 --- a/Projectiles/Ranged/DesertTornado.cs +++ b/Projectiles/Ranged/DesertTornado.cs @@ -6,7 +6,7 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Ranged { - public class DesertTornado : ModProjectile + public class DesertTornado : ModProjectile { public override string Texture => "CalamityMod/Projectiles/TornadoProj"; @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - //only 1 tornado can exist at a time + //only 1 tornado can exist at a time projectile.localAI[1] += 1f; if (projectile.localAI[1] >= 10f) { @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Ranged int projType = projectile.type; for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) { - Projectile proj = Main.projectile[projIndex]; + Projectile proj = Main.projectile[projIndex]; if (proj.active && proj.owner == projectile.owner && proj.type == projType && proj.ai[0] < 900f) { projCount++; diff --git a/Projectiles/Ranged/DrataliornusExoArrow.cs b/Projectiles/Ranged/DrataliornusExoArrow.cs index 0b85db5129..ea6427fefb 100644 --- a/Projectiles/Ranged/DrataliornusExoArrow.cs +++ b/Projectiles/Ranged/DrataliornusExoArrow.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class DrataliornusExoArrow : ModProjectile + public class DrataliornusExoArrow : ModProjectile { public override string Texture => "CalamityMod/Projectiles/LaserProj"; @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 180); - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Ranged target.AddBuff(BuffID.Daybreak, 180); target.AddBuff(ModContent.BuffType(), 180); - target.ExoDebuffs(); + target.ExoDebuffs(); } public override Color? GetAlpha(Color lightColor) => new Color(250, 25, 0, projectile.alpha); diff --git a/Projectiles/Ranged/DrataliornusFlame.cs b/Projectiles/Ranged/DrataliornusFlame.cs index 6e1b2e556f..54ddddc11b 100644 --- a/Projectiles/Ranged/DrataliornusFlame.cs +++ b/Projectiles/Ranged/DrataliornusFlame.cs @@ -204,8 +204,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 0; //should avoid infinite loop if a hit npc calls proj.Kill() projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; projectile.damage /= 3; projectile.Damage(); } diff --git a/Projectiles/Ranged/DrizzlefishFire.cs b/Projectiles/Ranged/DrizzlefishFire.cs index 6097c734fb..3af6b36b9f 100644 --- a/Projectiles/Ranged/DrizzlefishFire.cs +++ b/Projectiles/Ranged/DrizzlefishFire.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Projectiles.Ranged public class DrizzlefishFire : ModProjectile { private int splitTimer = 30; - + public override void SetStaticDefaults() { DisplayName.SetDefault("Drizzlefish Flames"); @@ -43,22 +43,22 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - int dustType = 235; - if (projectile.ai[1] == 1f) - { - if (Main.rand.NextBool(2)) - { - dustType = 35; - } - else - { - dustType = 55; - } - } - else - { - dustType = 235; - } + int dustType = 235; + if (projectile.ai[1] == 1f) + { + if (Main.rand.NextBool(2)) + { + dustType = 35; + } + else + { + dustType = 55; + } + } + else + { + dustType = 235; + } splitTimer--; if (splitTimer <= 0) { @@ -66,22 +66,22 @@ namespace CalamityMod.Projectiles.Ranged float rotation = MathHelper.ToRadians(Main.rand.Next(15,26)); if (projectile.owner == Main.myPlayer) { - if (projectile.ai[1] == 1f) - { - 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(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 1f); - } - } - else - { - 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(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - } - } + if (projectile.ai[1] == 1f) + { + 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(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 1f); + } + } + else + { + 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(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + } + } } projectile.Kill(); } @@ -138,14 +138,14 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.ai[1] == 1f) - { - target.AddBuff(BuffID.OnFire, 180); - } - else - { - target.AddBuff(ModContent.BuffType(), 120); - } + if (projectile.ai[1] == 1f) + { + target.AddBuff(BuffID.OnFire, 180); + } + else + { + target.AddBuff(ModContent.BuffType(), 120); + } } } } diff --git a/Projectiles/Ranged/DrizzlefishFireSplit.cs b/Projectiles/Ranged/DrizzlefishFireSplit.cs index 691bacb50b..c3b38bc083 100644 --- a/Projectiles/Ranged/DrizzlefishFireSplit.cs +++ b/Projectiles/Ranged/DrizzlefishFireSplit.cs @@ -42,22 +42,22 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - int dustType = 235; - if (projectile.ai[1] == 1f) - { - if (Main.rand.NextBool(2)) - { - dustType = 35; - } - else - { - dustType = 55; - } - } - else - { - dustType = 235; - } + int dustType = 235; + if (projectile.ai[1] == 1f) + { + if (Main.rand.NextBool(2)) + { + dustType = 35; + } + else + { + dustType = 55; + } + } + else + { + dustType = 235; + } Lighting.AddLight(projectile.Center, 0.25f, 0f, 0f); if (projectile.timeLeft > 90) { @@ -111,14 +111,14 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.ai[1] == 1f) - { - target.AddBuff(BuffID.OnFire, 120); - } - else - { - target.AddBuff(ModContent.BuffType(), 90); - } + if (projectile.ai[1] == 1f) + { + target.AddBuff(BuffID.OnFire, 120); + } + else + { + target.AddBuff(ModContent.BuffType(), 90); + } } } } diff --git a/Projectiles/Ranged/DrizzlefishFireball.cs b/Projectiles/Ranged/DrizzlefishFireball.cs index f2f4fe2bb3..73a4791e2f 100644 --- a/Projectiles/Ranged/DrizzlefishFireball.cs +++ b/Projectiles/Ranged/DrizzlefishFireball.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class DrizzlefishFireball : ModProjectile + public class DrizzlefishFireball : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -30,22 +30,22 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(projectile.Center, 0.25f, 0f, 0f); - int dustType = 235; - if (projectile.ai[1] == 1f) - { - if (Main.rand.NextBool(2)) - { - dustType = 35; - } - else - { - dustType = 55; - } - } - else - { - dustType = 235; - } + int dustType = 235; + if (projectile.ai[1] == 1f) + { + if (Main.rand.NextBool(2)) + { + dustType = 35; + } + else + { + dustType = 55; + } + } + else + { + dustType = 235; + } projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f) { @@ -66,14 +66,14 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.ai[1] == 1f) - { - target.AddBuff(BuffID.OnFire, 180); - } - else - { - target.AddBuff(ModContent.BuffType(), 120); - } + if (projectile.ai[1] == 1f) + { + target.AddBuff(BuffID.OnFire, 180); + } + else + { + target.AddBuff(ModContent.BuffType(), 120); + } } } } diff --git a/Projectiles/Ranged/DualpoonProj.cs b/Projectiles/Ranged/DualpoonProj.cs index 8f11d8514a..9e389e9cdd 100644 --- a/Projectiles/Ranged/DualpoonProj.cs +++ b/Projectiles/Ranged/DualpoonProj.cs @@ -20,13 +20,13 @@ namespace CalamityMod.Projectiles.Ranged projectile.alpha = 255; projectile.ranged = true; projectile.extraUpdates = 0; - projectile.timeLeft = 300; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.timeLeft = 300; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (player.dead) { projectile.Kill(); @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Ranged { projectile.extraUpdates = 1; } - Vector2 playerVector = player.Center - projectile.Center; + Vector2 playerVector = player.Center - projectile.Center; float playerDist = playerVector.Length(); if (projectile.ai[0] == 0f) { diff --git a/Projectiles/Ranged/ElysianArrowProj.cs b/Projectiles/Ranged/ElysianArrowProj.cs index a33d2efbd0..ce616e9bd2 100644 --- a/Projectiles/Ranged/ElysianArrowProj.cs +++ b/Projectiles/Ranged/ElysianArrowProj.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.timeLeft = 600; projectile.aiStyle = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Ranged num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); float x = projectile.position.X + Main.rand.Next(-400, 400); float y = projectile.position.Y - Main.rand.Next(500, 800); Vector2 vector = new Vector2(x, y); diff --git a/Projectiles/Ranged/EmesisGore.cs b/Projectiles/Ranged/EmesisGore.cs index 5791500a5d..b36f81b394 100644 --- a/Projectiles/Ranged/EmesisGore.cs +++ b/Projectiles/Ranged/EmesisGore.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 10; projectile.timeLeft = 600; projectile.ranged = true; - projectile.ignoreWater = true; - projectile.usesLocalNPCImmunity = true; + projectile.ignoreWater = true; + projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 6; } public override void SendExtraAI(BinaryWriter writer) @@ -87,6 +87,6 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 60); - } + } } } diff --git a/Projectiles/Ranged/EnhancedNanoRoundProj.cs b/Projectiles/Ranged/EnhancedNanoRoundProj.cs index 3ce8fe6181..0ce45e0ab1 100644 --- a/Projectiles/Ranged/EnhancedNanoRoundProj.cs +++ b/Projectiles/Ranged/EnhancedNanoRoundProj.cs @@ -27,24 +27,24 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 600; projectile.extraUpdates = 3; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { Lighting.AddLight(projectile.Center, 0f, 0.25f, 0.25f); - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - if (Main.rand.NextBool(3)) - { - int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 229, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; - } - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + if (Main.rand.NextBool(3)) + { + int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 229, 0f, 0f, 0, default, 0.5f); + Main.dust[num137].alpha = projectile.alpha; + Main.dust[num137].velocity *= 0f; + Main.dust[num137].noGravity = true; + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i < 2; i++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); } } diff --git a/Projectiles/Ranged/ExplodingStake.cs b/Projectiles/Ranged/ExplodingStake.cs index c6d7734c8e..8f50f44d4c 100644 --- a/Projectiles/Ranged/ExplodingStake.cs +++ b/Projectiles/Ranged/ExplodingStake.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.extraUpdates = 3; projectile.aiStyle = 1; aiType = ProjectileID.Stake; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -65,9 +65,9 @@ namespace CalamityMod.Projectiles.Ranged if (projectile.owner == Main.myPlayer) { int boom = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (boom.WithinBounds(Main.maxProjectiles)) - Main.projectile[boom].Calamity().forceRanged = true; - } + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceRanged = true; + } } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) diff --git a/Projectiles/Ranged/FallenStarProj.cs b/Projectiles/Ranged/FallenStarProj.cs index 3635f477d6..ab39d95531 100644 --- a/Projectiles/Ranged/FallenStarProj.cs +++ b/Projectiles/Ranged/FallenStarProj.cs @@ -7,79 +7,79 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class FallenStarProj : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Fallen Star"); - } + public class FallenStarProj : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fallen Star"); + } - public override void SetDefaults() - { - projectile.width = 16; - projectile.height = 16; - projectile.aiStyle = 0; - projectile.friendly = true; - projectile.ranged = true; - projectile.penetrate = -1; - projectile.alpha = 50; - projectile.light = 1f; - projectile.tileCollide = true; - projectile.ignoreWater = false; - projectile.usesLocalNPCImmunity = true; - } + public override void SetDefaults() + { + projectile.width = 16; + projectile.height = 16; + projectile.aiStyle = 0; + projectile.friendly = true; + projectile.ranged = true; + projectile.penetrate = -1; + projectile.alpha = 50; + projectile.light = 1f; + projectile.tileCollide = true; + projectile.ignoreWater = false; + projectile.usesLocalNPCImmunity = true; + } - public override void AI() - { - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 20 + Main.rand.Next(40); - Main.PlaySound(SoundID.Item9, projectile.Center); - } - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; - } - projectile.alpha += (int)(25f * projectile.localAI[0]); - if (projectile.alpha > 200) - { - projectile.alpha = 200; - projectile.localAI[0] = -1f; - } - if (projectile.alpha < 50) - { - projectile.alpha = 50; - projectile.localAI[0] = 1f; - } - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * projectile.direction; - } + public override void AI() + { + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 20 + Main.rand.Next(40); + Main.PlaySound(SoundID.Item9, projectile.Center); + } + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; + } + projectile.alpha += (int)(25f * projectile.localAI[0]); + if (projectile.alpha > 200) + { + projectile.alpha = 200; + projectile.localAI[0] = -1f; + } + if (projectile.alpha < 50) + { + projectile.alpha = 50; + projectile.localAI[0] = 1f; + } + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * projectile.direction; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - float newdamage = projectile.damage * 0.9375f; - projectile.damage = (int)newdamage; - if (projectile.damage < 1) - projectile.damage = 1; - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + float newdamage = projectile.damage * 0.9375f; + projectile.damage = (int)newdamage; + if (projectile.damage < 1) + projectile.damage = 1; + } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item10, projectile.Center); - int dustAmt = 10; - int goreAmt = 6; - for (int i = 0; i < dustAmt; i++) - { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 58, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 150, default, 1.2f); - } - for (int i = 0; i < dustAmt; i++) - { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 57, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 150, default, 1.2f); - } - for (int i = 0; i < goreAmt; i++) - { - Gore.NewGore(projectile.position, projectile.velocity * 0.05f, Main.rand.Next(16, 18), 1f); - } - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item10, projectile.Center); + int dustAmt = 10; + int goreAmt = 6; + for (int i = 0; i < dustAmt; i++) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 58, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 150, default, 1.2f); + } + for (int i = 0; i < dustAmt; i++) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 57, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 150, default, 1.2f); + } + for (int i = 0; i < goreAmt; i++) + { + Gore.NewGore(projectile.position, projectile.velocity * 0.05f, Main.rand.Next(16, 18), 1f); + } + } public override Color? GetAlpha(Color lightColor) { @@ -89,43 +89,43 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D tex = Main.projectileTexture[projectile.type]; - Vector2 offsets = new Vector2(0f, projectile.gfxOffY) - Main.screenPosition; - Color alpha = projectile.GetAlpha(lightColor); - Rectangle spriteRec = new Microsoft.Xna.Framework.Rectangle(0, 0, tex.Width, tex.Height); - Vector2 spriteOrigin = spriteRec.Size() / 2f; - SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 offsets = new Vector2(0f, projectile.gfxOffY) - Main.screenPosition; + Color alpha = projectile.GetAlpha(lightColor); + Rectangle spriteRec = new Microsoft.Xna.Framework.Rectangle(0, 0, tex.Width, tex.Height); + Vector2 spriteOrigin = spriteRec.Size() / 2f; + SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D aura = ModContent.GetTexture("CalamityMod/Projectiles/Ranged/FallenStarAura"); - Vector2 drawStart = projectile.Center + projectile.velocity; - Vector2 drawStart2 = projectile.Center - projectile.velocity * 0.5f; - Vector2 spinPoint = new Vector2(0f, -10f); - float time = Main.player[projectile.owner].miscCounter % 216000f / 60f; - Rectangle auraRec = aura.Frame(); - Color blue = Color.Blue * 0.2f; - Color white = Color.White * 0.5f; - white.A = 0; - blue.A = 0; - Vector2 auraOrigin = new Vector2(auraRec.Width / 2f, 10f); + Texture2D aura = ModContent.GetTexture("CalamityMod/Projectiles/Ranged/FallenStarAura"); + Vector2 drawStart = projectile.Center + projectile.velocity; + Vector2 drawStart2 = projectile.Center - projectile.velocity * 0.5f; + Vector2 spinPoint = new Vector2(0f, -10f); + float time = Main.player[projectile.owner].miscCounter % 216000f / 60f; + Rectangle auraRec = aura.Frame(); + Color blue = Color.Blue * 0.2f; + Color white = Color.White * 0.5f; + white.A = 0; + blue.A = 0; + Vector2 auraOrigin = new Vector2(auraRec.Width / 2f, 10f); - //Draw the aura - spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.5f, SpriteEffects.None, 0); - spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time + MathHelper.TwoPi / 3f), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.1f, SpriteEffects.None, 0); - spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time + MathHelper.Pi * 4f / 3f), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.3f, SpriteEffects.None, 0); - for (float d = 0f; d < 1f; d += 0.5f) - { - float scaleMult = time % 0.5f / 0.5f; - scaleMult = (scaleMult + d) % 1f; - float colorMult = scaleMult * 2f; - if (colorMult > 1f) - { - colorMult = 2f - colorMult; - } - spriteBatch.Draw(aura, drawStart2 + offsets, auraRec, white * colorMult, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 0.3f + scaleMult * 0.5f, SpriteEffects.None, 0); - } + //Draw the aura + spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.5f, SpriteEffects.None, 0); + spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time + MathHelper.TwoPi / 3f), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.1f, SpriteEffects.None, 0); + spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time + MathHelper.Pi * 4f / 3f), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.3f, SpriteEffects.None, 0); + for (float d = 0f; d < 1f; d += 0.5f) + { + float scaleMult = time % 0.5f / 0.5f; + scaleMult = (scaleMult + d) % 1f; + float colorMult = scaleMult * 2f; + if (colorMult > 1f) + { + colorMult = 2f - colorMult; + } + spriteBatch.Draw(aura, drawStart2 + offsets, auraRec, white * colorMult, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 0.3f + scaleMult * 0.5f, SpriteEffects.None, 0); + } - //Draw the actual projectile - spriteBatch.Draw(tex, projectile.Center + offsets, spriteRec, alpha, projectile.rotation, spriteOrigin, projectile.scale + 0.1f, spriteEffects, 0); + //Draw the actual projectile + spriteBatch.Draw(tex, projectile.Center + offsets, spriteRec, alpha, projectile.rotation, spriteOrigin, projectile.scale + 0.1f, spriteEffects, 0); return false; } - } + } } \ No newline at end of file diff --git a/Projectiles/Ranged/FeatherLarge.cs b/Projectiles/Ranged/FeatherLarge.cs index bdafaa3dbe..19578b5fb6 100644 --- a/Projectiles/Ranged/FeatherLarge.cs +++ b/Projectiles/Ranged/FeatherLarge.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = 1; projectile.timeLeft = 300; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/FishronRPG.cs b/Projectiles/Ranged/FishronRPG.cs index 3a7e947ebd..9a55f7a242 100644 --- a/Projectiles/Ranged/FishronRPG.cs +++ b/Projectiles/Ranged/FishronRPG.cs @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Ranged } } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Ranged/FlakKrakenGun.cs b/Projectiles/Ranged/FlakKrakenGun.cs index 25615c922a..926baa6c95 100644 --- a/Projectiles/Ranged/FlakKrakenGun.cs +++ b/Projectiles/Ranged/FlakKrakenGun.cs @@ -130,6 +130,6 @@ namespace CalamityMod.Projectiles.Ranged player.itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); } - public override bool CanDamage() => false; - } + public override bool CanDamage() => false; + } } diff --git a/Projectiles/Ranged/FlamingStake.cs b/Projectiles/Ranged/FlamingStake.cs index 5420428852..113d8dd961 100644 --- a/Projectiles/Ranged/FlamingStake.cs +++ b/Projectiles/Ranged/FlamingStake.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.extraUpdates = 3; projectile.aiStyle = 1; aiType = ProjectileID.Stake; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/FlareBat.cs b/Projectiles/Ranged/FlareBat.cs index e6ad5a58d9..adcb93cb7d 100644 --- a/Projectiles/Ranged/FlareBat.cs +++ b/Projectiles/Ranged/FlareBat.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class FlareBat : ModProjectile + public class FlareBat : ModProjectile { public override void SetStaticDefaults() { @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.light = 0.25f; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/Flash.cs b/Projectiles/Ranged/Flash.cs index 9cb046d88b..954611ad1d 100644 --- a/Projectiles/Ranged/Flash.cs +++ b/Projectiles/Ranged/Flash.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.5f / 255f); - Color dustColor = projectile.ai[1] == 1f ? CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f) : default; + Color dustColor = projectile.ai[1] == 1f ? CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f) : default; bool flag15 = false; bool flag16 = false; if (projectile.velocity.X < 0f && projectile.position.X < projectile.ai[0]) diff --git a/Projectiles/Ranged/FlashBulletProj.cs b/Projectiles/Ranged/FlashBulletProj.cs index b63f939874..0b10be93dc 100644 --- a/Projectiles/Ranged/FlashBulletProj.cs +++ b/Projectiles/Ranged/FlashBulletProj.cs @@ -26,24 +26,24 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 600; projectile.extraUpdates = 3; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { Lighting.AddLight(projectile.Center, 0.1f, 0.1f, 0.1f); - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - if (Main.rand.NextBool(3)) - { - int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 264, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; - } - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + if (Main.rand.NextBool(3)) + { + int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 264, 0f, 0f, 0, default, 0.5f); + Main.dust[num137].alpha = projectile.alpha; + Main.dust[num137].velocity *= 0f; + Main.dust[num137].noGravity = true; + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Ranged/FlurrystormCannonShooting.cs b/Projectiles/Ranged/FlurrystormCannonShooting.cs index f7180c3125..7644e9cfe9 100644 --- a/Projectiles/Ranged/FlurrystormCannonShooting.cs +++ b/Projectiles/Ranged/FlurrystormCannonShooting.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.tileCollide = false; projectile.ranged = true; projectile.ignoreWater = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() @@ -125,34 +125,34 @@ namespace CalamityMod.Projectiles.Ranged } projectile.velocity = speedMult * 0.55f; - Vector2 snowballVel = Vector2.Normalize(projectile.velocity) * speedMult2 * (0.6f + Main.rand.NextFloat(0f, 0.15f)); - if (float.IsNaN(snowballVel.X) || float.IsNaN(snowballVel.Y)) - { - snowballVel = -Vector2.UnitY; - } - Vector2 sourceS = source + Utils.RandomVector2(Main.rand, -5f, 5f); - snowballVel.X += Main.rand.NextFloat(-2.25f, 2.25f); - snowballVel.Y += Main.rand.NextFloat(-2.25f, 2.25f); - int snowball = Projectile.NewProjectile(sourceS, snowballVel, projType, dmg, kBack, projectile.owner); - if (snowball.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[snowball].noDropItem = true; - Main.projectile[snowball].Calamity().forceRanged = true; - Main.projectile[snowball].thrown = false; - Main.projectile[snowball].extraUpdates += Main.rand.Next(0,2); - } + Vector2 snowballVel = Vector2.Normalize(projectile.velocity) * speedMult2 * (0.6f + Main.rand.NextFloat(0f, 0.15f)); + if (float.IsNaN(snowballVel.X) || float.IsNaN(snowballVel.Y)) + { + snowballVel = -Vector2.UnitY; + } + Vector2 sourceS = source + Utils.RandomVector2(Main.rand, -5f, 5f); + snowballVel.X += Main.rand.NextFloat(-2.25f, 2.25f); + snowballVel.Y += Main.rand.NextFloat(-2.25f, 2.25f); + int snowball = Projectile.NewProjectile(sourceS, snowballVel, projType, dmg, kBack, projectile.owner); + if (snowball.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[snowball].noDropItem = true; + Main.projectile[snowball].Calamity().forceRanged = true; + Main.projectile[snowball].thrown = false; + Main.projectile[snowball].extraUpdates += Main.rand.Next(0,2); + } - if (Main.rand.NextBool(5)) //ice chunk - { - Vector2 chunkVel = Vector2.Normalize(projectile.velocity) * speedMult2 * (0.6f + Main.rand.NextFloat() * 0.8f); - if (float.IsNaN(chunkVel.X) || float.IsNaN(chunkVel.Y)) - { - chunkVel = -Vector2.UnitY; - } - Vector2 sourceC = source + Utils.RandomVector2(Main.rand, -15f, 15f); - int iceChunk = Projectile.NewProjectile(sourceC, chunkVel, ModContent.ProjectileType(), (int)(dmg * 1.5), (int)(kBack * 1.5), projectile.owner, 0f, chunkVel.Y); - Main.projectile[iceChunk].extraUpdates += fireRate / 2; //0 to 2 - } + if (Main.rand.NextBool(5)) //ice chunk + { + Vector2 chunkVel = Vector2.Normalize(projectile.velocity) * speedMult2 * (0.6f + Main.rand.NextFloat() * 0.8f); + if (float.IsNaN(chunkVel.X) || float.IsNaN(chunkVel.Y)) + { + chunkVel = -Vector2.UnitY; + } + Vector2 sourceC = source + Utils.RandomVector2(Main.rand, -15f, 15f); + int iceChunk = Projectile.NewProjectile(sourceC, chunkVel, ModContent.ProjectileType(), (int)(dmg * 1.5), (int)(kBack * 1.5), projectile.owner, 0f, chunkVel.Y); + Main.projectile[iceChunk].extraUpdates += fireRate / 2; //0 to 2 + } } else { diff --git a/Projectiles/Ranged/FlurrystormIceChunk.cs b/Projectiles/Ranged/FlurrystormIceChunk.cs index 14b8c202c8..ac60f45d89 100644 --- a/Projectiles/Ranged/FlurrystormIceChunk.cs +++ b/Projectiles/Ranged/FlurrystormIceChunk.cs @@ -5,7 +5,7 @@ using CalamityMod.Buffs.StatDebuffs; namespace CalamityMod.Projectiles.Ranged { - public class FlurrystormIceChunk : ModProjectile + public class FlurrystormIceChunk : ModProjectile { public override void SetStaticDefaults() { @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.coldDamage = true; projectile.penetrate = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -50,26 +50,26 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[index2].velocity *= 1.5f; Main.dust[index2].scale *= 0.9f; } - int split = 0; - while (split < 3) - { - //Calculate the velocity of the projectile - float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); - float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; - //Prevents the projectile speed from being too low - if (shardspeedX < 2f && shardspeedX > -2f) - { - shardspeedX += -projectile.velocity.X; - } - if (shardspeedY > 2f && shardspeedY < 2f) - { - shardspeedY += -projectile.velocity.Y; - } + int split = 0; + while (split < 3) + { + //Calculate the velocity of the projectile + float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); + float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; + //Prevents the projectile speed from being too low + if (shardspeedX < 2f && shardspeedX > -2f) + { + shardspeedX += -projectile.velocity.X; + } + if (shardspeedY > 2f && shardspeedY < 2f) + { + shardspeedY += -projectile.velocity.Y; + } - //Spawn the projectile - Projectile.NewProjectile(projectile.position.X + shardspeedX, projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 2f, projectile.owner); - split += 1; - } + //Spawn the projectile + Projectile.NewProjectile(projectile.position.X + shardspeedX, projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 2f, projectile.owner); + split += 1; + } } } } diff --git a/Projectiles/Ranged/FlurrystormIceShard.cs b/Projectiles/Ranged/FlurrystormIceShard.cs index 7b128c9f18..6f087bfb18 100644 --- a/Projectiles/Ranged/FlurrystormIceShard.cs +++ b/Projectiles/Ranged/FlurrystormIceShard.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.width = 10; projectile.height = 10; projectile.ranged = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Ranged/FossilShard.cs b/Projectiles/Ranged/FossilShard.cs index fc7fb22b7e..4374226565 100644 --- a/Projectiles/Ranged/FossilShard.cs +++ b/Projectiles/Ranged/FossilShard.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - if (projectile.velocity.Y <= 0f) - projectile.velocity.Y = 0.1f; + if (projectile.velocity.Y <= 0f) + projectile.velocity.Y = 0.1f; projectile.rotation += projectile.velocity.Y; projectile.velocity.Y *= 1.05f; } diff --git a/Projectiles/Ranged/FungiOrb.cs b/Projectiles/Ranged/FungiOrb.cs index db8cea8ace..e80949d742 100644 --- a/Projectiles/Ranged/FungiOrb.cs +++ b/Projectiles/Ranged/FungiOrb.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.aiStyle = 1; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int f = 0; f < 3; f++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), 0f, projectile.owner); } } diff --git a/Projectiles/Ranged/FungiOrb2.cs b/Projectiles/Ranged/FungiOrb2.cs index f6a3a5bb8a..656458e47b 100644 --- a/Projectiles/Ranged/FungiOrb2.cs +++ b/Projectiles/Ranged/FungiOrb2.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class FungiOrb2 : ModProjectile + public class FungiOrb2 : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Ranged/FungiOrb"; @@ -21,12 +21,12 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = 1; projectile.aiStyle = 1; - projectile.timeLeft = 180; + projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { //Rotation projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); @@ -46,9 +46,9 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num469].velocity = dspeed; } - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 6f, 20f); - } + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 6f, 20f); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Ranged/GemTechGreenFlechette.cs b/Projectiles/Ranged/GemTechGreenFlechette.cs index 299196596f..099cdcb63e 100644 --- a/Projectiles/Ranged/GemTechGreenFlechette.cs +++ b/Projectiles/Ranged/GemTechGreenFlechette.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 drawPosition = projectile.Center - Main.screenPosition; Vector2 origin = texture.Size() * 0.5f; for (int i = 0; i < afterimageCount; i++) - { + { if (projectile.oldPos[i] == Vector2.Zero) continue; @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Ranged drawColor.A = (byte)(int)MathHelper.Lerp(105f, 0f, i / (float)(afterimageCount - 1f)); drawPosition -= projectile.velocity.SafeNormalize(Vector2.Zero) * scaleFactor * 4.5f; spriteBatch.Draw(texture, drawPosition, null, drawColor, projectile.rotation, origin, projectile.scale * scaleFactor, SpriteEffects.None, 0f); - } + } return false; } } diff --git a/Projectiles/Ranged/GoliathRocket.cs b/Projectiles/Ranged/GoliathRocket.cs index 489e8571b0..4d3101a0cd 100644 --- a/Projectiles/Ranged/GoliathRocket.cs +++ b/Projectiles/Ranged/GoliathRocket.cs @@ -36,43 +36,43 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - if (Math.Abs(projectile.velocity.X) >= 8f || Math.Abs(projectile.velocity.Y) >= 8f) - { - for (int num246 = 0; num246 < 2; num246++) - { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) - { - num247 = projectile.velocity.X * 0.5f; - num248 = projectile.velocity.Y * 0.5f; - } - int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; - } - } - if (Math.Abs(projectile.velocity.X) < 15f && Math.Abs(projectile.velocity.Y) < 15f) - { - projectile.velocity *= 1.1f; - } - else if (Main.rand.NextBool(2)) - { - int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; - Main.rand.Next(2); - num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; - } + if (Math.Abs(projectile.velocity.X) >= 8f || Math.Abs(projectile.velocity.Y) >= 8f) + { + for (int num246 = 0; num246 < 2; num246++) + { + float num247 = 0f; + float num248 = 0f; + if (num246 == 1) + { + num247 = projectile.velocity.X * 0.5f; + num248 = projectile.velocity.Y * 0.5f; + } + int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num249].velocity *= 0.2f; + Main.dust[num249].noGravity = true; + num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num249].velocity *= 0.05f; + } + } + if (Math.Abs(projectile.velocity.X) < 15f && Math.Abs(projectile.velocity.Y) < 15f) + { + projectile.velocity *= 1.1f; + } + else if (Main.rand.NextBool(2)) + { + int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); + Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].noGravity = true; + Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; + Main.rand.Next(2); + num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); + Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].noGravity = true; + Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; + } projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(90); } @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 160); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 160); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -108,11 +108,11 @@ namespace CalamityMod.Projectiles.Ranged num518 += projectile.oldVelocity.X / 6f; num519 += projectile.oldVelocity.Y / 6f; int bee = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage), Main.player[projectile.owner].beeKB(0f), Main.myPlayer); - if (bee.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[bee].penetrate = 2; - Main.projectile[bee].Calamity().forceRanged = true; - } + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 2; + Main.projectile[bee].Calamity().forceRanged = true; + } } } } @@ -135,30 +135,30 @@ namespace CalamityMod.Projectiles.Ranged num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - bool canShoot = true; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); - int blastRadius = 0; - if (projID == ProjectileID.RocketII) - blastRadius = 6; - else if (projID == ProjectileID.RocketIV) - blastRadius = 9; + // Construct a fake item to use with vanilla code for the sake of picking ammo. + if (FalseLauncher is null) + DefineFalseLauncher(); + Player player = Main.player[projectile.owner]; + int projID = ProjectileID.RocketI; + float shootSpeed = 0f; + bool canShoot = true; + int damage = 0; + float kb = 0f; + player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); + int blastRadius = 0; + if (projID == ProjectileID.RocketII) + blastRadius = 6; + else if (projID == ProjectileID.RocketIV) + blastRadius = 9; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); - if (projectile.owner == Main.myPlayer && blastRadius > 0) - { - CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); - } + if (projectile.owner == Main.myPlayer && blastRadius > 0) + { + CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/HalleysComet.cs b/Projectiles/Ranged/HalleysComet.cs index 0c1a2e5276..25d03f014e 100644 --- a/Projectiles/Ranged/HalleysComet.cs +++ b/Projectiles/Ranged/HalleysComet.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class HalleysComet : ModProjectile + public class HalleysComet : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -52,26 +52,26 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 3; i++) { int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 1, default, 1f); - Dust dust = Main.dust[fire]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= dustScaleSize; - dust.velocity += projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } + Dust dust = Main.dust[fire]; + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 1.75f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 0.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= dustScaleSize; + dust.velocity += projectile.velocity; + if (!dust.noGravity) + { + dust.velocity *= 0.5f; + } } } @@ -83,8 +83,8 @@ namespace CalamityMod.Projectiles.Ranged target.AddBuff(ModContent.BuffType(), 240); } - public override void OnHitPvp(Player target, int damage, bool crit) - { + public override void OnHitPvp(Player target, int damage, bool crit) + { target.AddBuff(ModContent.BuffType(), 240); } } diff --git a/Projectiles/Ranged/HighExplosivePeanutShell.cs b/Projectiles/Ranged/HighExplosivePeanutShell.cs index 9f538d6f38..de4687820a 100644 --- a/Projectiles/Ranged/HighExplosivePeanutShell.cs +++ b/Projectiles/Ranged/HighExplosivePeanutShell.cs @@ -6,88 +6,88 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class HighExplosivePeanutShell : ModProjectile - { - private const int Lifetime = 180; + public class HighExplosivePeanutShell : ModProjectile + { + private const int Lifetime = 180; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("High Explosive Peanut Shell"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 9; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("High Explosive Peanut Shell"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 9; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 16; - projectile.height = 16; - projectile.friendly = true; - projectile.ranged = true; - projectile.extraUpdates = 4; - projectile.timeLeft = Lifetime; - } + public override void SetDefaults() + { + projectile.width = 16; + projectile.height = 16; + projectile.friendly = true; + projectile.ranged = true; + projectile.extraUpdates = 4; + projectile.timeLeft = Lifetime; + } - public override void AI() - { - projectile.rotation = projectile.velocity.ToRotation(); - projectile.spriteDirection = 1; + public override void AI() + { + projectile.rotation = projectile.velocity.ToRotation(); + projectile.spriteDirection = 1; - // Lighting - Lighting.AddLight(projectile.Center, 0.75f, 0.65f, 0.08f); + // Lighting + Lighting.AddLight(projectile.Center, 0.75f, 0.65f, 0.08f); - // Dirty dust, done dirt cheap - { - int dustID = 7; // wood flakes - float scale = Main.rand.NextFloat(1f, 1.4f); - Dust d = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, dustID); - d.noGravity = true; - d.scale = scale; + // Dirty dust, done dirt cheap + { + int dustID = 7; // wood flakes + float scale = Main.rand.NextFloat(1f, 1.4f); + Dust d = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, dustID); + d.noGravity = true; + d.scale = scale; - // Dust velocity is a complicated flaking function taken from Holy Fire Bullets - d.velocity *= 0.2f; - float angleDeviation = 0.17f; - float angle = Main.rand.NextFloat(-angleDeviation, angleDeviation); - Vector2 sprayVelocity = projectile.velocity.RotatedBy(angle) * 0.6f; - d.velocity += sprayVelocity; - } - } + // Dust velocity is a complicated flaking function taken from Holy Fire Bullets + d.velocity *= 0.2f; + float angleDeviation = 0.17f; + float angle = Main.rand.NextFloat(-angleDeviation, angleDeviation); + Vector2 sprayVelocity = projectile.velocity.RotatedBy(angle) * 0.6f; + d.velocity += sprayVelocity; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void Kill(int timeLeft) - { - // Grenade Launcher + Lunar Flare sounds for maximum meaty explosion - Main.PlaySound(SoundID.Item62, projectile.Center); - Main.PlaySound(SoundID.Item88, projectile.Center); + public override void Kill(int timeLeft) + { + // Grenade Launcher + Lunar Flare sounds for maximum meaty explosion + Main.PlaySound(SoundID.Item62, projectile.Center); + Main.PlaySound(SoundID.Item88, projectile.Center); - // Massively inflate the projectile's hitbox - projectile.position = projectile.Center; - projectile.width = projectile.height = 140; - projectile.position.X = projectile.position.X - projectile.width / 2; - projectile.position.Y = projectile.position.Y - projectile.height / 2; + // Massively inflate the projectile's hitbox + projectile.position = projectile.Center; + projectile.width = projectile.height = 140; + projectile.position.X = projectile.position.X - projectile.width / 2; + projectile.position.Y = projectile.position.Y - projectile.height / 2; - // Allow infinite piercing and ignoring iframes for this one extra hit - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = -1; + // Allow infinite piercing and ignoring iframes for this one extra hit + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; - // Rocket III type explosion is now a utility for convenience - projectile.LargeFieryExplosion(); + // Rocket III type explosion is now a utility for convenience + projectile.LargeFieryExplosion(); - // Deal damage again. The explosion deals half the damage of the direct hit. - projectile.damage /= 2; - projectile.Damage(); - } + // Deal damage again. The explosion deals half the damage of the direct hit. + projectile.damage /= 2; + projectile.Damage(); + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); - return true; // the projectile does indeed die on collision - } - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); + return true; // the projectile does indeed die on collision + } + } } diff --git a/Projectiles/Ranged/HiveBomb.cs b/Projectiles/Ranged/HiveBomb.cs index 39012fb782..d480af014c 100644 --- a/Projectiles/Ranged/HiveBomb.cs +++ b/Projectiles/Ranged/HiveBomb.cs @@ -36,43 +36,43 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - if (Math.Abs(projectile.velocity.X) >= 8f || Math.Abs(projectile.velocity.Y) >= 8f) - { - for (int num246 = 0; num246 < 2; num246++) - { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) - { - num247 = projectile.velocity.X * 0.5f; - num248 = projectile.velocity.Y * 0.5f; - } - int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; - } - } - if (Math.Abs(projectile.velocity.X) < 15f && Math.Abs(projectile.velocity.Y) < 15f) - { - projectile.velocity *= 1.1f; - } - else if (Main.rand.NextBool(2)) - { - int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; - Main.rand.Next(2); - num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; - } + if (Math.Abs(projectile.velocity.X) >= 8f || Math.Abs(projectile.velocity.Y) >= 8f) + { + for (int num246 = 0; num246 < 2; num246++) + { + float num247 = 0f; + float num248 = 0f; + if (num246 == 1) + { + num247 = projectile.velocity.X * 0.5f; + num248 = projectile.velocity.Y * 0.5f; + } + int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num249].velocity *= 0.2f; + Main.dust[num249].noGravity = true; + num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num249].velocity *= 0.05f; + } + } + if (Math.Abs(projectile.velocity.X) < 15f && Math.Abs(projectile.velocity.Y) < 15f) + { + projectile.velocity *= 1.1f; + } + else if (Main.rand.NextBool(2)) + { + int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); + Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].noGravity = true; + Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; + Main.rand.Next(2); + num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); + Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].noGravity = true; + Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; + } projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(90); } @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 64); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 64); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -108,11 +108,11 @@ namespace CalamityMod.Projectiles.Ranged num518 += projectile.oldVelocity.X / 6f; num519 += projectile.oldVelocity.Y / 6f; int bee = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 3), Main.player[projectile.owner].beeKB(0f), Main.myPlayer); - if (bee.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[bee].penetrate = 2; - Main.projectile[bee].Calamity().forceRanged = true; - } + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 2; + Main.projectile[bee].Calamity().forceRanged = true; + } } } } @@ -135,30 +135,30 @@ namespace CalamityMod.Projectiles.Ranged num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - bool canShoot = true; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); - int blastRadius = 0; - if (projID == ProjectileID.RocketII) - blastRadius = 4; - else if (projID == ProjectileID.RocketIV) - blastRadius = 7; + // Construct a fake item to use with vanilla code for the sake of picking ammo. + if (FalseLauncher is null) + DefineFalseLauncher(); + Player player = Main.player[projectile.owner]; + int projID = ProjectileID.RocketI; + float shootSpeed = 0f; + bool canShoot = true; + int damage = 0; + float kb = 0f; + player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); + int blastRadius = 0; + if (projID == ProjectileID.RocketII) + blastRadius = 4; + else if (projID == ProjectileID.RocketIV) + blastRadius = 7; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); - if (projectile.owner == Main.myPlayer && blastRadius > 0) - { - CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); - } + if (projectile.owner == Main.myPlayer && blastRadius > 0) + { + CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/HiveMissile.cs b/Projectiles/Ranged/HiveMissile.cs index 4dfd296e42..9e257f334b 100644 --- a/Projectiles/Ranged/HiveMissile.cs +++ b/Projectiles/Ranged/HiveMissile.cs @@ -36,43 +36,43 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - if (Math.Abs(projectile.velocity.X) >= 8f || Math.Abs(projectile.velocity.Y) >= 8f) - { - for (int num246 = 0; num246 < 2; num246++) - { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) - { - num247 = projectile.velocity.X * 0.5f; - num248 = projectile.velocity.Y * 0.5f; - } - int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; - } - } - if (Math.Abs(projectile.velocity.X) < 15f && Math.Abs(projectile.velocity.Y) < 15f) - { - projectile.velocity *= 1.5f; - } - else if (Main.rand.NextBool(2)) - { - int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; - Main.rand.Next(2); - num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; - } + if (Math.Abs(projectile.velocity.X) >= 8f || Math.Abs(projectile.velocity.Y) >= 8f) + { + for (int num246 = 0; num246 < 2; num246++) + { + float num247 = 0f; + float num248 = 0f; + if (num246 == 1) + { + num247 = projectile.velocity.X * 0.5f; + num248 = projectile.velocity.Y * 0.5f; + } + int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num249].velocity *= 0.2f; + Main.dust[num249].noGravity = true; + num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num249].velocity *= 0.05f; + } + } + if (Math.Abs(projectile.velocity.X) < 15f && Math.Abs(projectile.velocity.Y) < 15f) + { + projectile.velocity *= 1.5f; + } + else if (Main.rand.NextBool(2)) + { + int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); + Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].noGravity = true; + Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; + Main.rand.Next(2); + num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); + Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].noGravity = true; + Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; + } projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(90); } @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 80); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 80); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -108,11 +108,11 @@ namespace CalamityMod.Projectiles.Ranged num518 += projectile.oldVelocity.X / 6f; num519 += projectile.oldVelocity.Y / 6f; int bee = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 2), Main.player[projectile.owner].beeKB(0f), Main.myPlayer); - if (bee.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[bee].penetrate = 2; - Main.projectile[bee].Calamity().forceRanged = true; - } + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 2; + Main.projectile[bee].Calamity().forceRanged = true; + } } } } @@ -135,30 +135,30 @@ namespace CalamityMod.Projectiles.Ranged num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 90, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - bool canShoot = true; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); - int blastRadius = 0; - if (projID == ProjectileID.RocketII) - blastRadius = 5; - else if (projID == ProjectileID.RocketIV) - blastRadius = 8; + // Construct a fake item to use with vanilla code for the sake of picking ammo. + if (FalseLauncher is null) + DefineFalseLauncher(); + Player player = Main.player[projectile.owner]; + int projID = ProjectileID.RocketI; + float shootSpeed = 0f; + bool canShoot = true; + int damage = 0; + float kb = 0f; + player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); + int blastRadius = 0; + if (projID == ProjectileID.RocketII) + blastRadius = 5; + else if (projID == ProjectileID.RocketIV) + blastRadius = 8; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); - if (projectile.owner == Main.myPlayer && blastRadius > 0) - { - CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); - } + if (projectile.owner == Main.myPlayer && blastRadius > 0) + { + CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); + } } } } diff --git a/Projectiles/Ranged/HyperiusBulletProj.cs b/Projectiles/Ranged/HyperiusBulletProj.cs index 2de850cd35..5d2c64a8ce 100644 --- a/Projectiles/Ranged/HyperiusBulletProj.cs +++ b/Projectiles/Ranged/HyperiusBulletProj.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class HyperiusBulletProj : ModProjectile + public class HyperiusBulletProj : ModProjectile { private Color currentColor = Color.Black; @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 600; projectile.extraUpdates = 3; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -76,20 +76,20 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(target.Center); + OnHitEffects(target.Center); } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(target.Center); + OnHitEffects(target.Center); } - private void OnHitEffects(Vector2 targetPos) - { - if (projectile.owner == Main.myPlayer) - { - CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.6), 1f, projectile.owner, true); - } + private void OnHitEffects(Vector2 targetPos) + { + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.6), 1f, projectile.owner, true); + } } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/IcicleArrowProj.cs b/Projectiles/Ranged/IcicleArrowProj.cs index cf05497fc5..1400f08ae6 100644 --- a/Projectiles/Ranged/IcicleArrowProj.cs +++ b/Projectiles/Ranged/IcicleArrowProj.cs @@ -20,9 +20,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.coldDamage = true; projectile.penetrate = 1; projectile.extraUpdates = 1; - projectile.coldDamage = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.coldDamage = true; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void SetStaticDefaults() { @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Ranged int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 68, projectile.velocity.X, projectile.velocity.Y, 0, default, 1.1f); Main.dust[index2].noGravity = true; } - projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/IcyBulletProj.cs b/Projectiles/Ranged/IcyBulletProj.cs index c895a36cd4..10fcd39736 100644 --- a/Projectiles/Ranged/IcyBulletProj.cs +++ b/Projectiles/Ranged/IcyBulletProj.cs @@ -9,14 +9,14 @@ namespace CalamityMod.Projectiles.Ranged { public class IcyBulletProj : ModProjectile { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Icy Bullet"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Icy Bullet"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() + public override void SetDefaults() { projectile.width = 4; projectile.height = 4; @@ -31,20 +31,20 @@ namespace CalamityMod.Projectiles.Ranged projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 20; projectile.coldDamage = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - if (Main.rand.NextBool(3)) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 88, projectile.velocity.X, projectile.velocity.Y, 0, default, 1f); - Main.dust[index2].noGravity = true; - } - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + if (Main.rand.NextBool(3)) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 88, projectile.velocity.X, projectile.velocity.Y, 0, default, 1f); + Main.dust[index2].noGravity = true; + } + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -53,13 +53,13 @@ namespace CalamityMod.Projectiles.Ranged target.AddBuff(ModContent.BuffType(), 30); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); + return false; + } - public override Color? GetAlpha(Color lightColor) + public override Color? GetAlpha(Color lightColor) { return new Color(200, 200, 200, projectile.alpha); } diff --git a/Projectiles/Ranged/IlluminatedBullet.cs b/Projectiles/Ranged/IlluminatedBullet.cs index 0172c5947f..2916a4a736 100644 --- a/Projectiles/Ranged/IlluminatedBullet.cs +++ b/Projectiles/Ranged/IlluminatedBullet.cs @@ -12,9 +12,9 @@ namespace CalamityMod.Projectiles.Ranged public override void SetStaticDefaults() { DisplayName.SetDefault("Illuminated Bullet"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } public override void SetDefaults() { @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Ranged // Invisible for the first few frames projectile.alpha = 255; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -52,13 +52,13 @@ namespace CalamityMod.Projectiles.Ranged } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Ranged/ImpactRound.cs b/Projectiles/Ranged/ImpactRound.cs index be55a595d3..f974a974ea 100644 --- a/Projectiles/Ranged/ImpactRound.cs +++ b/Projectiles/Ranged/ImpactRound.cs @@ -6,60 +6,60 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class ImpactRound : ModProjectile - { + public class ImpactRound : ModProjectile + { public override string Texture => "CalamityMod/Projectiles/Ranged/AMRShot"; - private bool initialized = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Impact Round"); - } + private bool initialized = false; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Impact Round"); + } - public override void SetDefaults() - { - projectile.width = 4; - projectile.height = 4; - projectile.light = 0.5f; - projectile.alpha = 255; - projectile.extraUpdates = 7; - projectile.scale = 1.18f; - projectile.friendly = true; - projectile.ranged = true; - projectile.ignoreWater = true; - projectile.aiStyle = 1; - aiType = ProjectileID.BulletHighVelocity; - projectile.penetrate = -1; - projectile.timeLeft = 600; - projectile.tileCollide = false; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + public override void SetDefaults() + { + projectile.width = 4; + projectile.height = 4; + projectile.light = 0.5f; + projectile.alpha = 255; + projectile.extraUpdates = 7; + projectile.scale = 1.18f; + projectile.friendly = true; + projectile.ranged = true; + projectile.ignoreWater = true; + projectile.aiStyle = 1; + aiType = ProjectileID.BulletHighVelocity; + projectile.penetrate = -1; + projectile.timeLeft = 600; + projectile.tileCollide = false; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } - public override void AI() - { - if (!initialized && projectile.ranged) //Ranged check prevents quiver splits triggering the sound - { - initialized = true; + public override void AI() + { + if (!initialized && projectile.ranged) //Ranged check prevents quiver splits triggering the sound + { + initialized = true; - if (Main.netMode != NetmodeID.Server) - { - var sound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"); - sound = sound.WithVolume(sound.Volume * 0.45f); - Main.PlaySound(sound, projectile.Center); - } - } - } + if (Main.netMode != NetmodeID.Server) + { + var sound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"); + sound = sound.WithVolume(sound.Volume * 0.45f); + Main.PlaySound(sound, projectile.Center); + } + } + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - double damageMult = 1D; - if (crit) - damageMult += 0.25; - damage = (int)(damage * damageMult); - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + double damageMult = 1D; + if (crit) + damageMult += 0.25; + damage = (int)(damage * damageMult); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.timeLeft < 600; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.timeLeft < 600; + } } diff --git a/Projectiles/Ranged/LeafArrow.cs b/Projectiles/Ranged/LeafArrow.cs index 90bb1ec76a..5288c74bd8 100644 --- a/Projectiles/Ranged/LeafArrow.cs +++ b/Projectiles/Ranged/LeafArrow.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.extraUpdates = 1; projectile.timeLeft = 300; projectile.ranged = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/LunarBolt.cs b/Projectiles/Ranged/LunarBolt.cs index 528e2adf84..ac29dfccb2 100644 --- a/Projectiles/Ranged/LunarBolt.cs +++ b/Projectiles/Ranged/LunarBolt.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.extraUpdates = 1; projectile.timeLeft = 180; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/LunarBolt2.cs b/Projectiles/Ranged/LunarBolt2.cs index 34c4c9a36f..911a6d841c 100644 --- a/Projectiles/Ranged/LunarBolt2.cs +++ b/Projectiles/Ranged/LunarBolt2.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.extraUpdates = 1; projectile.timeLeft = 180; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/LuxorsGiftRanged.cs b/Projectiles/Ranged/LuxorsGiftRanged.cs index 0b7e0f2976..3bf7a34bf8 100644 --- a/Projectiles/Ranged/LuxorsGiftRanged.cs +++ b/Projectiles/Ranged/LuxorsGiftRanged.cs @@ -6,99 +6,99 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class LuxorsGiftRanged : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gift"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public class LuxorsGiftRanged : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gift"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.friendly = true; - projectile.ranged = true; - projectile.penetrate = 1; - projectile.alpha = 255; - projectile.timeLeft = 180; - } + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.friendly = true; + projectile.ranged = true; + projectile.penetrate = 1; + projectile.alpha = 255; + projectile.timeLeft = 180; + } - public override Color? GetAlpha(Color lightColor) - { - if (projectile.timeLeft < 85) - { - byte b2 = (byte)(projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - return new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - return new Color(255, 255, 255, 100); - } + public override Color? GetAlpha(Color lightColor) + { + if (projectile.timeLeft < 85) + { + byte b2 = (byte)(projectile.timeLeft * 3); + byte a2 = (byte)(100f * ((float)b2 / 255f)); + return new Color((int)b2, (int)b2, (int)b2, (int)a2); + } + return new Color(255, 255, 255, 100); + } - public override void AI() - { - if (projectile.localAI[0] == 0f) - { - projectile.scale -= 0.01f; - projectile.alpha += 15; - if (projectile.alpha >= 250) - { - projectile.alpha = 255; - projectile.localAI[0] = 1f; - } - } - else if (projectile.localAI[0] == 1f) - { - projectile.scale += 0.01f; - projectile.alpha -= 15; - if (projectile.alpha <= 0) - { - projectile.alpha = 0; - projectile.localAI[0] = 0f; - } - } - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - projectile.localAI[1] += 1f; - if (projectile.localAI[1] == 3f) - { - for (int l = 0; l < 12; l++) - { - Vector2 offset = Vector2.UnitX * (float)-(float)projectile.width / 2f; - offset += -Vector2.UnitY.RotatedBy((double)(l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); - offset = offset.RotatedBy((double)(projectile.rotation - MathHelper.PiOver2), default); - int electric = Dust.NewDust(projectile.Center, 0, 0, 135, 0f, 0f, 160, default, 1f); - Main.dust[electric].scale = 1.1f; - Main.dust[electric].noGravity = true; - Main.dust[electric].position = projectile.Center + offset; - Main.dust[electric].velocity = projectile.velocity * 0.1f; - Main.dust[electric].velocity = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[electric].position) * 1.25f; - } - } - } + public override void AI() + { + if (projectile.localAI[0] == 0f) + { + projectile.scale -= 0.01f; + projectile.alpha += 15; + if (projectile.alpha >= 250) + { + projectile.alpha = 255; + projectile.localAI[0] = 1f; + } + } + else if (projectile.localAI[0] == 1f) + { + projectile.scale += 0.01f; + projectile.alpha -= 15; + if (projectile.alpha <= 0) + { + projectile.alpha = 0; + projectile.localAI[0] = 0f; + } + } + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.localAI[1] += 1f; + if (projectile.localAI[1] == 3f) + { + for (int l = 0; l < 12; l++) + { + Vector2 offset = Vector2.UnitX * (float)-(float)projectile.width / 2f; + offset += -Vector2.UnitY.RotatedBy((double)(l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); + offset = offset.RotatedBy((double)(projectile.rotation - MathHelper.PiOver2), default); + int electric = Dust.NewDust(projectile.Center, 0, 0, 135, 0f, 0f, 160, default, 1f); + Main.dust[electric].scale = 1.1f; + Main.dust[electric].noGravity = true; + Main.dust[electric].position = projectile.Center + offset; + Main.dust[electric].velocity = projectile.velocity * 0.1f; + Main.dust[electric].velocity = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[electric].position) * 1.25f; + } + } + } - public override void Kill(int timeLeft) - { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 16); - projectile.maxPenetrate = projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); - Main.PlaySound(SoundID.Item92, projectile.position); - int dustAmt = Main.rand.Next(10, 20); - for (int d = 0; d < dustAmt; d++) - { - int electric = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, 135, 0f, 0f, 100, default, 2f); - Main.dust[electric].velocity *= 2f; - Main.dust[electric].noGravity = true; - } - } + public override void Kill(int timeLeft) + { + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 16); + projectile.maxPenetrate = projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + Main.PlaySound(SoundID.Item92, projectile.position); + int dustAmt = Main.rand.Next(10, 20); + for (int d = 0; d < dustAmt; d++) + { + int electric = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, 135, 0f, 0f, 100, default, 2f); + Main.dust[electric].velocity *= 2f; + Main.dust[electric].noGravity = true; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + return false; + } + } } diff --git a/Projectiles/Ranged/MaelstromHoldout.cs b/Projectiles/Ranged/MaelstromHoldout.cs index f0804915c9..ebd0815c62 100644 --- a/Projectiles/Ranged/MaelstromHoldout.cs +++ b/Projectiles/Ranged/MaelstromHoldout.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class MaelstromHoldout : ModProjectile + public class MaelstromHoldout : ModProjectile { private Player Owner => Main.player[projectile.owner]; private bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed; diff --git a/Projectiles/Ranged/MagnaStrike.cs b/Projectiles/Ranged/MagnaStrike.cs index 8731255296..bd8a37854b 100644 --- a/Projectiles/Ranged/MagnaStrike.cs +++ b/Projectiles/Ranged/MagnaStrike.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.timeLeft = 300; projectile.ranged = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/MagnomalyAura.cs b/Projectiles/Ranged/MagnomalyAura.cs index 27c9eacc95..4000a38eea 100644 --- a/Projectiles/Ranged/MagnomalyAura.cs +++ b/Projectiles/Ranged/MagnomalyAura.cs @@ -4,11 +4,11 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class MagnomalyAura : ModProjectile + public class MagnomalyAura : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private int radius = 100; + private int radius = 100; public override void SetStaticDefaults() { @@ -20,44 +20,44 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.usesIDStaticNPCImmunity = true; projectile.idStaticNPCHitCooldown = 10; - projectile.width = 200; - projectile.height = 200; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.timeLeft = 300; + projectile.width = 200; + projectile.height = 200; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.timeLeft = 300; } - public override void AI() - { - Projectile parent = Main.projectile[0]; - bool active = false; - for (int i = 0; i < Main.projectile.Length; i++) - { - Projectile p = Main.projectile[i]; - if (p.identity == projectile.ai[0] && p.active && p.type == ModContent.ProjectileType()) - { - parent = p; - active = true; - } - } + public override void AI() + { + Projectile parent = Main.projectile[0]; + bool active = false; + for (int i = 0; i < Main.projectile.Length; i++) + { + Projectile p = Main.projectile[i]; + if (p.identity == projectile.ai[0] && p.active && p.type == ModContent.ProjectileType()) + { + parent = p; + active = true; + } + } - if (active) - { - projectile.Center = parent.Center; - } - else - { - projectile.Kill(); - } + if (active) + { + projectile.Center = parent.Center; + } + else + { + projectile.Kill(); + } - if (!parent.active) - { - projectile.Kill(); - } - } + if (!parent.active) + { + projectile.Kill(); + } + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, radius, targetHitbox); } diff --git a/Projectiles/Ranged/MagnomalyBeam.cs b/Projectiles/Ranged/MagnomalyBeam.cs index 68dd70b519..1ca66c9841 100644 --- a/Projectiles/Ranged/MagnomalyBeam.cs +++ b/Projectiles/Ranged/MagnomalyBeam.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class MagnomalyBeam : ModProjectile + public class MagnomalyBeam : ModProjectile { public override string Texture => "CalamityMod/Projectiles/LaserProj"; @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.extraUpdates = 5; projectile.timeLeft = 300; projectile.tileCollide = false; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Ranged/MagnomalyExplosion.cs b/Projectiles/Ranged/MagnomalyExplosion.cs index dc923a55e6..3ccbc41224 100644 --- a/Projectiles/Ranged/MagnomalyExplosion.cs +++ b/Projectiles/Ranged/MagnomalyExplosion.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class MagnomalyExplosion : ModProjectile + public class MagnomalyExplosion : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,17 +23,17 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 5; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; - projectile.alpha = 255; + projectile.alpha = 255; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } } } diff --git a/Projectiles/Ranged/MagnomalyRocket.cs b/Projectiles/Ranged/MagnomalyRocket.cs index 286ee8ae84..9a292afb2e 100644 --- a/Projectiles/Ranged/MagnomalyRocket.cs +++ b/Projectiles/Ranged/MagnomalyRocket.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Projectiles.Ranged { public class MagnomalyRocket : ModProjectile { - private bool spawnedAura = false; + private bool spawnedAura = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Nuke"); @@ -24,12 +24,12 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 300; projectile.ranged = true; projectile.tileCollide = false; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { - //Lighting + //Lighting Lighting.AddLight(projectile.Center, Main.DiscoR * 0.25f / 255f, Main.DiscoG * 0.25f / 255f, Main.DiscoB * 0.25f / 255f); //Animation @@ -48,74 +48,74 @@ namespace CalamityMod.Projectiles.Ranged 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 dustType = Main.rand.NextBool(2) ? 107 : 234; - if (Main.rand.NextBool(4)) - { - dustType = 269; - } - if (projectile.owner == Main.myPlayer && !spawnedAura) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), projectile.knockBack * 0.5f, projectile.owner, projectile.identity, 0f); - spawnedAura = true; - } - float dustOffsetX = projectile.velocity.X * 0.5f; - float dustOffsetY = projectile.velocity.Y * 0.5f; - if (Main.rand.NextBool(2)) - { - int exo = Dust.NewDust(new Vector2(projectile.position.X + 3f + dustOffsetX, projectile.position.Y + 3f + dustOffsetY) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, dustType, 0f, 0f, 100, default, 0.5f); - Main.dust[exo].scale *= (float)Main.rand.Next(10) * 0.1f; - Main.dust[exo].velocity *= 0.2f; - Main.dust[exo].noGravity = true; - Main.dust[exo].noLight = true; - } - else - { - int exo = Dust.NewDust(new Vector2(projectile.position.X + 3f + dustOffsetX, projectile.position.Y + 3f + dustOffsetY) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, dustType, 0f, 0f, 100, default, 0.25f); - Main.dust[exo].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[exo].velocity *= 0.05f; - Main.dust[exo].noGravity = true; - Main.dust[exo].noLight = true; - } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + int dustType = Main.rand.NextBool(2) ? 107 : 234; + if (Main.rand.NextBool(4)) + { + dustType = 269; + } + if (projectile.owner == Main.myPlayer && !spawnedAura) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), projectile.knockBack * 0.5f, projectile.owner, projectile.identity, 0f); + spawnedAura = true; + } + float dustOffsetX = projectile.velocity.X * 0.5f; + float dustOffsetY = projectile.velocity.Y * 0.5f; + if (Main.rand.NextBool(2)) + { + int exo = Dust.NewDust(new Vector2(projectile.position.X + 3f + dustOffsetX, projectile.position.Y + 3f + dustOffsetY) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, dustType, 0f, 0f, 100, default, 0.5f); + Main.dust[exo].scale *= (float)Main.rand.Next(10) * 0.1f; + Main.dust[exo].velocity *= 0.2f; + Main.dust[exo].noGravity = true; + Main.dust[exo].noLight = true; + } + else + { + int exo = Dust.NewDust(new Vector2(projectile.position.X + 3f + dustOffsetX, projectile.position.Y + 3f + dustOffsetY) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, dustType, 0f, 0f, 100, default, 0.25f); + Main.dust[exo].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[exo].velocity *= 0.05f; + Main.dust[exo].noGravity = true; + Main.dust[exo].noLight = true; + } + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); } public override void Kill(int timeLeft) { - if (projectile.owner == Main.myPlayer) - { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 192); - Main.PlaySound(SoundID.Item14, projectile.Center); - //DO NOT REMOVE THIS PROJECTILE - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (projectile.owner == Main.myPlayer) + { + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 192); + Main.PlaySound(SoundID.Item14, projectile.Center); + //DO NOT REMOVE THIS PROJECTILE + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - int dustType = Main.rand.NextBool(2) ? 107 : 234; - if (Main.rand.NextBool(4)) - { - dustType = 269; - } - for (int d = 0; d < 30; d++) - { - int exo = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 1f); - Main.dust[exo].velocity *= 3f; - Main.dust[exo].noGravity = true; - Main.dust[exo].noLight = true; - if (Main.rand.NextBool(2)) - { - Main.dust[exo].scale = 0.5f; - Main.dust[exo].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int d = 0; d < 40; d++) - { - int exo = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.5f); - Main.dust[exo].noGravity = true; - Main.dust[exo].noLight = true; - Main.dust[exo].velocity *= 5f; - exo = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.75f); - Main.dust[exo].velocity *= 2f; - } - CalamityUtils.ExplosionGores(projectile.Center, 9); - } + int dustType = Main.rand.NextBool(2) ? 107 : 234; + if (Main.rand.NextBool(4)) + { + dustType = 269; + } + for (int d = 0; d < 30; d++) + { + int exo = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 1f); + Main.dust[exo].velocity *= 3f; + Main.dust[exo].noGravity = true; + Main.dust[exo].noLight = true; + if (Main.rand.NextBool(2)) + { + Main.dust[exo].scale = 0.5f; + Main.dust[exo].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int d = 0; d < 40; d++) + { + int exo = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.5f); + Main.dust[exo].noGravity = true; + Main.dust[exo].noLight = true; + Main.dust[exo].velocity *= 5f; + exo = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.75f); + Main.dust[exo].velocity *= 2f; + } + CalamityUtils.ExplosionGores(projectile.Center, 9); + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -126,31 +126,31 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(); - target.ExoDebuffs(); - } + OnHitEffects(); + target.ExoDebuffs(); + } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(); - target.ExoDebuffs(); - } + OnHitEffects(); + target.ExoDebuffs(); + } private void OnHitEffects() { - if (projectile.owner == Main.myPlayer) - { - float random = Main.rand.Next(30, 90); - float spread = random * 0.0174f; - double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - for (int i = 0; i < 4; i++) - { - double offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - int proj1 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage / 4, projectile.knockBack / 4, projectile.owner, 0f, 1f); - int proj2 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage / 4, projectile.knockBack / 4, projectile.owner, 0f, 1f); - } - } + if (projectile.owner == Main.myPlayer) + { + float random = Main.rand.Next(30, 90); + float spread = random * 0.0174f; + double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; + double deltaAngle = spread / 8f; + for (int i = 0; i < 4; i++) + { + double offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; + int proj1 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage / 4, projectile.knockBack / 4, projectile.owner, 0f, 1f); + int proj2 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage / 4, projectile.knockBack / 4, projectile.owner, 0f, 1f); + } + } } } } diff --git a/Projectiles/Ranged/MechanicalBarracuda.cs b/Projectiles/Ranged/MechanicalBarracuda.cs index e9cc73d9a3..3f9fece03a 100644 --- a/Projectiles/Ranged/MechanicalBarracuda.cs +++ b/Projectiles/Ranged/MechanicalBarracuda.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class MechanicalBarracuda : ModProjectile + public class MechanicalBarracuda : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Ranged/MeowFire.cs b/Projectiles/Ranged/MeowFire.cs index 5bd5f1860b..5ee0befe82 100644 --- a/Projectiles/Ranged/MeowFire.cs +++ b/Projectiles/Ranged/MeowFire.cs @@ -48,26 +48,26 @@ namespace CalamityMod.Projectiles.Ranged 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)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } + Dust dust = Main.dust[num299]; + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 1.75f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 0.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= num296; + dust.velocity += projectile.velocity; + if (!dust.noGravity) + { + dust.velocity *= 0.5f; + } } } else diff --git a/Projectiles/Ranged/MeowFire2.cs b/Projectiles/Ranged/MeowFire2.cs index 8127103975..21dd2d961d 100644 --- a/Projectiles/Ranged/MeowFire2.cs +++ b/Projectiles/Ranged/MeowFire2.cs @@ -48,26 +48,26 @@ namespace CalamityMod.Projectiles.Ranged 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)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } + Dust dust = Main.dust[num299]; + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 1.75f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 0.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= num296; + dust.velocity += projectile.velocity; + if (!dust.noGravity) + { + dust.velocity *= 0.5f; + } } } else diff --git a/Projectiles/Ranged/MiniRocket.cs b/Projectiles/Ranged/MiniRocket.cs index 2bfa42f4fd..6947898475 100644 --- a/Projectiles/Ranged/MiniRocket.cs +++ b/Projectiles/Ranged/MiniRocket.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class MiniRocket : ModProjectile + public class MiniRocket : ModProjectile { public static Item FalseLauncher = null; @@ -36,14 +36,14 @@ namespace CalamityMod.Projectiles.Ranged { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(90); - if (projectile.ai[0] == 0f) - { - Main.PlaySound(SoundID.Item11, (int)projectile.Center.X, (int)projectile.Center.Y); - projectile.ai[0] = 1f; - } + if (projectile.ai[0] == 0f) + { + Main.PlaySound(SoundID.Item11, (int)projectile.Center.X, (int)projectile.Center.Y); + projectile.ai[0] = 1f; + } - //Animation - projectile.frameCounter++; + //Animation + projectile.frameCounter++; if (projectile.frameCounter > 7) { projectile.frame++; @@ -54,32 +54,32 @@ namespace CalamityMod.Projectiles.Ranged projectile.frame = 0; } - if (projectile.velocity.Length() >= 8f) - { - for (int num246 = 0; num246 < 2; num246++) - { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) - { - num247 = projectile.velocity.X * 0.5f; - num248 = projectile.velocity.Y * 0.5f; - } - int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; - } - } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + if (projectile.velocity.Length() >= 8f) + { + for (int num246 = 0; num246 < 2; num246++) + { + float num247 = 0f; + float num248 = 0f; + if (num246 == 1) + { + num247 = projectile.velocity.X * 0.5f; + num248 = projectile.velocity.Y * 0.5f; + } + int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num249].velocity *= 0.2f; + Main.dust[num249].noGravity = true; + num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 31, 0f, 0f, 100, default, 0.5f); + Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num249].velocity *= 0.05f; + } + } + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -104,30 +104,30 @@ namespace CalamityMod.Projectiles.Ranged num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - bool canShoot = true; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); - int blastRadius = 0; - if (projID == ProjectileID.RocketII) - blastRadius = 3; - else if (projID == ProjectileID.RocketIV) - blastRadius = 6; + // Construct a fake item to use with vanilla code for the sake of picking ammo. + if (FalseLauncher is null) + DefineFalseLauncher(); + Player player = Main.player[projectile.owner]; + int projID = ProjectileID.RocketI; + float shootSpeed = 0f; + bool canShoot = true; + int damage = 0; + float kb = 0f; + player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); + int blastRadius = 0; + if (projID == ProjectileID.RocketII) + blastRadius = 3; + else if (projID == ProjectileID.RocketIV) + blastRadius = 6; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); - if (projectile.owner == Main.myPlayer && blastRadius > 0) - { - CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); - } + if (projectile.owner == Main.myPlayer && blastRadius > 0) + { + CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); + } } } } diff --git a/Projectiles/Ranged/MiniSharkron.cs b/Projectiles/Ranged/MiniSharkron.cs index 32d0e16985..449168df30 100644 --- a/Projectiles/Ranged/MiniSharkron.cs +++ b/Projectiles/Ranged/MiniSharkron.cs @@ -4,41 +4,41 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class MiniSharkron : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Mini Sharkron"); - Main.projFrames[projectile.type] = 2; - } + public class MiniSharkron : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mini Sharkron"); + Main.projFrames[projectile.type] = 2; + } - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.aiStyle = 1; - aiType = ProjectileID.MiniSharkron; - projectile.friendly = true; - projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.ranged = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.aiStyle = 1; + aiType = ProjectileID.MiniSharkron; + projectile.friendly = true; + projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.ranged = true; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } - public override void Kill(int timeLeft) - { - for (int d = 0; d < 15; ++d) - { - int idx = Dust.NewDust(projectile.Center - Vector2.One * 10f, 50, 50, DustID.Blood, 0f, -2f, 0, default, 1f); - Dust dust = Main.dust[idx]; - dust.velocity /= 2f; - } - int tail = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, 584, 1f); - Main.gore[tail].timeLeft /= 10; - int body = Gore.NewGore(projectile.Center, projectile.velocity * 0.9f, 585, 1f); - Main.gore[body].timeLeft /= 10; - int head = Gore.NewGore(projectile.Center, projectile.velocity * 1f, 586, 1f); - Main.gore[head].timeLeft /= 10; - } - } + public override void Kill(int timeLeft) + { + for (int d = 0; d < 15; ++d) + { + int idx = Dust.NewDust(projectile.Center - Vector2.One * 10f, 50, 50, DustID.Blood, 0f, -2f, 0, default, 1f); + Dust dust = Main.dust[idx]; + dust.velocity /= 2f; + } + int tail = Gore.NewGore(projectile.Center, projectile.velocity * 0.8f, 584, 1f); + Main.gore[tail].timeLeft /= 10; + int body = Gore.NewGore(projectile.Center, projectile.velocity * 0.9f, 585, 1f); + Main.gore[body].timeLeft /= 10; + int head = Gore.NewGore(projectile.Center, projectile.velocity * 1f, 586, 1f); + Main.gore[head].timeLeft /= 10; + } + } } diff --git a/Projectiles/Ranged/Minibirb.cs b/Projectiles/Ranged/Minibirb.cs index 99d25e0ba9..59220a8b62 100644 --- a/Projectiles/Ranged/Minibirb.cs +++ b/Projectiles/Ranged/Minibirb.cs @@ -37,8 +37,8 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.NPCHit51, projectile.Center); } - public override void AI() - { + public override void AI() + { projectile.frameCounter++; if (projectile.frameCounter > 4) { @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.Pi : 0f); - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 10f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 10f, 20f); } } } diff --git a/Projectiles/Ranged/MistArrow.cs b/Projectiles/Ranged/MistArrow.cs index 43b257c58c..b38118d21b 100644 --- a/Projectiles/Ranged/MistArrow.cs +++ b/Projectiles/Ranged/MistArrow.cs @@ -25,9 +25,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 300; aiType = ProjectileID.WoodenArrowFriendly; projectile.arrow = true; - projectile.coldDamage = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.coldDamage = true; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/MortarRoundProj.cs b/Projectiles/Ranged/MortarRoundProj.cs index 323198fc47..cc87fd4ae5 100644 --- a/Projectiles/Ranged/MortarRoundProj.cs +++ b/Projectiles/Ranged/MortarRoundProj.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class MortarRoundProj : ModProjectile + public class MortarRoundProj : ModProjectile { public override string Texture => "CalamityMod/Items/Ammo/MortarRound"; @@ -31,26 +31,26 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (projectile.velocity.Length() >= 8f) - { - for (int d = 0; d < 2; d++) - { - float xOffset = 0f; - float yOffset = 0f; - if (d == 1) - { - xOffset = projectile.velocity.X * 0.5f; - yOffset = projectile.velocity.Y * 0.5f; - } - int fire = Dust.NewDust(new Vector2(projectile.position.X + 3f + xOffset, projectile.position.Y + 3f + yOffset) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, DustID.Fire, 0f, 0f, 100, default, 1f); - Main.dust[fire].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[fire].velocity *= 0.2f; - Main.dust[fire].noGravity = true; - int smoke = Dust.NewDust(new Vector2(projectile.position.X + 3f + xOffset, projectile.position.Y + 3f + yOffset) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, DustID.Smoke, 0f, 0f, 100, default, 0.5f); - Main.dust[smoke].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[smoke].velocity *= 0.05f; - } - } + if (projectile.velocity.Length() >= 8f) + { + for (int d = 0; d < 2; d++) + { + float xOffset = 0f; + float yOffset = 0f; + if (d == 1) + { + xOffset = projectile.velocity.X * 0.5f; + yOffset = projectile.velocity.Y * 0.5f; + } + int fire = Dust.NewDust(new Vector2(projectile.position.X + 3f + xOffset, projectile.position.Y + 3f + yOffset) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, DustID.Fire, 0f, 0f, 100, default, 1f); + Main.dust[fire].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[fire].velocity *= 0.2f; + Main.dust[fire].noGravity = true; + int smoke = Dust.NewDust(new Vector2(projectile.position.X + 3f + xOffset, projectile.position.Y + 3f + yOffset) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, DustID.Smoke, 0f, 0f, 100, default, 0.5f); + Main.dust[smoke].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[smoke].velocity *= 0.05f; + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -62,11 +62,11 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 200); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 200); projectile.maxPenetrate = projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.knockBack *= 5f; + projectile.knockBack *= 5f; projectile.Damage(); Main.PlaySound(SoundID.Item14, projectile.Center); @@ -88,23 +88,23 @@ namespace CalamityMod.Projectiles.Ranged fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); Main.dust[fire].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); if (projectile.owner == Main.myPlayer) { - CalamityUtils.ExplodeandDestroyTiles(projectile, 5, false, new List() - { - ModContent.TileType(), - ModContent.TileType() - }, - new List() - { - ModContent.WallType(), - ModContent.WallType() - }); - } + CalamityUtils.ExplodeandDestroyTiles(projectile, 5, false, new List() + { + ModContent.TileType(), + ModContent.TileType() + }, + new List() + { + ModContent.WallType(), + ModContent.WallType() + }); + } } } } diff --git a/Projectiles/Ranged/NapalmArrowProj.cs b/Projectiles/Ranged/NapalmArrowProj.cs index 07b84f51e7..cb30a5d787 100644 --- a/Projectiles/Ranged/NapalmArrowProj.cs +++ b/Projectiles/Ranged/NapalmArrowProj.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class NapalmArrowProj : ModProjectile + public class NapalmArrowProj : ModProjectile { public override string Texture => "CalamityMod/Items/Ammo/NapalmArrow"; @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.timeLeft = 600; projectile.aiStyle = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); Main.PlaySound(SoundID.Item14, projectile.position); for (int j = 0; j < 5; j++) { @@ -58,21 +58,21 @@ namespace CalamityMod.Projectiles.Ranged fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); Main.dust[fire].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); if (projectile.owner == Main.myPlayer) { for (int i = 0; i < 3; i++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f, 0.1f); int flames = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, projectile.owner); - if (flames.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[flames].Calamity().forceRanged = true; - Main.projectile[flames].penetrate = 3; - Main.projectile[flames].usesLocalNPCImmunity = false; - Main.projectile[flames].usesIDStaticNPCImmunity = true; - Main.projectile[flames].idStaticNPCHitCooldown = 10; - } + if (flames.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flames].Calamity().forceRanged = true; + Main.projectile[flames].penetrate = 3; + Main.projectile[flames].usesLocalNPCImmunity = false; + Main.projectile[flames].usesIDStaticNPCImmunity = true; + Main.projectile[flames].idStaticNPCHitCooldown = 10; + } } } } diff --git a/Projectiles/Ranged/NorfleetComet.cs b/Projectiles/Ranged/NorfleetComet.cs index f3161f88a2..09eac424c1 100644 --- a/Projectiles/Ranged/NorfleetComet.cs +++ b/Projectiles/Ranged/NorfleetComet.cs @@ -102,7 +102,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), projectile.knockBack * 0.1f, projectile.owner); } Main.PlaySound(SoundID.Item10, projectile.Center); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 144); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 144); for (int d = 0; d < 4; d++) { Dust.NewDust(projectile.position, projectile.width, projectile.height, Main.rand.NextBool(2) ? 221 : 244, 0f, 0f, 50, default, 1.5f); @@ -120,8 +120,8 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft >= 600) - return false; + if (projectile.timeLeft >= 600) + return false; CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } diff --git a/Projectiles/Ranged/NorfleetExplosion.cs b/Projectiles/Ranged/NorfleetExplosion.cs index 9b83f81027..cadda74cf8 100644 --- a/Projectiles/Ranged/NorfleetExplosion.cs +++ b/Projectiles/Ranged/NorfleetExplosion.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class NorfleetExplosion : ModProjectile + public class NorfleetExplosion : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -29,15 +29,15 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.75f / 255f, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.01f / 255f); - Vector2 dustVel = CalamityUtils.RandomVelocity(120f, 36f, 108f, 1f); - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, Main.rand.NextBool(2) ? 221 : 244, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[idx]; - dust.noGravity = true; - dust.position.X = projectile.Center.X; - dust.position.Y = projectile.Center.Y; - dust.position.X += Main.rand.NextFloat(-10f, 10f); - dust.position.Y += Main.rand.NextFloat(-10f, 10f); - dust.velocity = dustVel; + Vector2 dustVel = CalamityUtils.RandomVelocity(120f, 36f, 108f, 1f); + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, Main.rand.NextBool(2) ? 221 : 244, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[idx]; + dust.noGravity = true; + dust.position.X = projectile.Center.X; + dust.position.Y = projectile.Center.Y; + dust.position.X += Main.rand.NextFloat(-10f, 10f); + dust.position.Y += Main.rand.NextFloat(-10f, 10f); + dust.velocity = dustVel; } } } diff --git a/Projectiles/Ranged/Nuke.cs b/Projectiles/Ranged/Nuke.cs index e6154ea2ab..6cdfe88a37 100644 --- a/Projectiles/Ranged/Nuke.cs +++ b/Projectiles/Ranged/Nuke.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.width = 22; projectile.height = 22; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 125; projectile.ranged = true; } @@ -67,24 +67,24 @@ namespace CalamityMod.Projectiles.Ranged } flarePowderTimer = 12; } - if (Math.Abs(projectile.velocity.X) >= 8f || Math.Abs(projectile.velocity.Y) >= 8f) - { - float num247 = projectile.velocity.X * 0.5f; - float num248 = projectile.velocity.Y * 0.5f; - int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; - - } + if (Math.Abs(projectile.velocity.X) >= 8f || Math.Abs(projectile.velocity.Y) >= 8f) + { + float num247 = projectile.velocity.X * 0.5f; + float num248 = projectile.velocity.Y * 0.5f; + int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 1f); + Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num249].velocity *= 0.2f; + Main.dust[num249].noGravity = true; + num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 0.5f); + Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num249].velocity *= 0.05f; + + } } public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 192); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 192); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -109,30 +109,30 @@ namespace CalamityMod.Projectiles.Ranged idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[idx].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 10); + CalamityUtils.ExplosionGores(projectile.Center, 10); - // Construct a fake item to use with vanilla code for the sake of picking ammo. - if (FalseLauncher is null) - DefineFalseLauncher(); - Player player = Main.player[projectile.owner]; - int projID = ProjectileID.RocketI; - float shootSpeed = 0f; - bool canShoot = true; - int damage = 0; - float kb = 0f; - player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); - int blastRadius = 0; - if (projID == ProjectileID.RocketII) - blastRadius = 6; - else if (projID == ProjectileID.RocketIV) - blastRadius = 12; + // Construct a fake item to use with vanilla code for the sake of picking ammo. + if (FalseLauncher is null) + DefineFalseLauncher(); + Player player = Main.player[projectile.owner]; + int projID = ProjectileID.RocketI; + float shootSpeed = 0f; + bool canShoot = true; + int damage = 0; + float kb = 0f; + player.PickAmmo(FalseLauncher, ref projID, ref shootSpeed, ref canShoot, ref damage, ref kb, true); + int blastRadius = 0; + if (projID == ProjectileID.RocketII) + blastRadius = 6; + else if (projID == ProjectileID.RocketIV) + blastRadius = 12; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 22); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 22); - if (projectile.owner == Main.myPlayer && blastRadius > 0) - { - CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); - } + if (projectile.owner == Main.myPlayer && blastRadius > 0) + { + CalamityUtils.ExplodeandDestroyTiles(projectile, blastRadius, true, new List() { }, new List() { }); + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Ranged/NullShot.cs b/Projectiles/Ranged/NullShot.cs index ed961fbbc7..c23190374d 100644 --- a/Projectiles/Ranged/NullShot.cs +++ b/Projectiles/Ranged/NullShot.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.timeLeft = 120; projectile.ranged = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/NullShot2.cs b/Projectiles/Ranged/NullShot2.cs index 845c02b29e..d59f6a7f45 100644 --- a/Projectiles/Ranged/NullShot2.cs +++ b/Projectiles/Ranged/NullShot2.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 120; projectile.ranged = true; projectile.extraUpdates = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/OpalStrike.cs b/Projectiles/Ranged/OpalStrike.cs index bf5640ed6e..1dd3534689 100644 --- a/Projectiles/Ranged/OpalStrike.cs +++ b/Projectiles/Ranged/OpalStrike.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class OpalStrike : ModProjectile + public class OpalStrike : ModProjectile { public override void SetStaticDefaults() { @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.timeLeft = 300; projectile.ranged = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/PhangasmBow.cs b/Projectiles/Ranged/PhangasmBow.cs index e53e218d24..96845ba68d 100644 --- a/Projectiles/Ranged/PhangasmBow.cs +++ b/Projectiles/Ranged/PhangasmBow.cs @@ -131,6 +131,6 @@ namespace CalamityMod.Projectiles.Ranged player.itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); } - public override bool CanDamage() => false; - } + public override bool CanDamage() => false; + } } diff --git a/Projectiles/Ranged/PiercingBullet.cs b/Projectiles/Ranged/PiercingBullet.cs index e916a52489..9f6f1bd7ff 100644 --- a/Projectiles/Ranged/PiercingBullet.cs +++ b/Projectiles/Ranged/PiercingBullet.cs @@ -30,23 +30,23 @@ namespace CalamityMod.Projectiles.Ranged aiType = ProjectileID.BulletHighVelocity; projectile.penetrate = 1; projectile.timeLeft = 600; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - //Avoid touching things that you probably aren't meant to damage - if (target.defense > 999 || target.Calamity().DR >= 0.95f || target.Calamity().unbreakableDR) - return; + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + //Avoid touching things that you probably aren't meant to damage + if (target.defense > 999 || target.Calamity().DR >= 0.95f || target.Calamity().unbreakableDR) + return; - //DR applies after defense, so undo it first - damage = (int)(damage * (1 / (1 - target.Calamity().DR))); + //DR applies after defense, so undo it first + damage = (int)(damage * (1 / (1 - target.Calamity().DR))); - //Then proceed to ignore all defense - int penetratableDefense = Math.Max(target.defense - Main.player[projectile.owner].armorPenetration, 0); - int penetratedDefense = Math.Min(penetratableDefense, target.defense); - damage += (int)(0.5f * penetratedDefense); - } + //Then proceed to ignore all defense + int penetratableDefense = Math.Max(target.defense - Main.player[projectile.owner].armorPenetration, 0); + int penetratedDefense = Math.Min(penetratableDefense, target.defense); + damage += (int)(0.5f * penetratedDefense); + } public override bool OnTileCollide(Vector2 oldVelocity) { @@ -57,27 +57,27 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(target.Center, crit); + OnHitEffects(target.Center, crit); target.AddBuff(ModContent.BuffType(), 600); } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(target.Center, crit); + OnHitEffects(target.Center, crit); target.AddBuff(ModContent.BuffType(), 600); } - private void OnHitEffects(Vector2 targetPos, bool crit) - { + private void OnHitEffects(Vector2 targetPos, bool crit) + { if (crit) { - int bulletCount = 10; + int bulletCount = 10; for (int x = 0; x < bulletCount; x++) { if (projectile.owner == Main.myPlayer) { - CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, x < bulletCount / 2, 500f, 500f, 0f, 500f, 12f, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), projectile.knockBack, projectile.owner); - } + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, x < bulletCount / 2, 500f, 500f, 0f, 500f, 12f, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), projectile.knockBack, projectile.owner); + } } } } diff --git a/Projectiles/Ranged/PlagueArrow.cs b/Projectiles/Ranged/PlagueArrow.cs index dea634e090..b3384f72d6 100644 --- a/Projectiles/Ranged/PlagueArrow.cs +++ b/Projectiles/Ranged/PlagueArrow.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.aiStyle = 1; projectile.timeLeft = 600; aiType = ProjectileID.WoodenArrowFriendly; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void Kill(int timeLeft) { @@ -50,11 +50,11 @@ namespace CalamityMod.Projectiles.Ranged num518 += projectile.oldVelocity.X / 6f; num519 += projectile.oldVelocity.Y / 6f; int bee = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 2), Main.player[projectile.owner].beeKB(0f), Main.myPlayer); - if (bee.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[bee].penetrate = 2; - Main.projectile[bee].Calamity().forceRanged = true; - } + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 2; + Main.projectile[bee].Calamity().forceRanged = true; + } } } } diff --git a/Projectiles/Ranged/PlanarRipperBolt.cs b/Projectiles/Ranged/PlanarRipperBolt.cs index 2d28d1819f..68328b1717 100644 --- a/Projectiles/Ranged/PlanarRipperBolt.cs +++ b/Projectiles/Ranged/PlanarRipperBolt.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class PlanarRipperBolt : ModProjectile + public class PlanarRipperBolt : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Rogue/ShockGrenadeBolt"; @@ -32,8 +32,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.aiStyle = 1; aiType = ProjectileID.BulletHighVelocity; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -51,41 +51,41 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - CalamityPlayer modPlayer = Main.player[projectile.owner].Calamity(); + CalamityPlayer modPlayer = Main.player[projectile.owner].Calamity(); target.AddBuff(BuffID.Electrified, 180); - if (projectile.owner == Main.myPlayer) - { - if (target.life <= 0) - { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (projectile.owner == Main.myPlayer) + { + if (target.life <= 0) + { + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + } + if (crit) + { + if (modPlayer.planarSpeedBoost < 20) + { + modPlayer.planarSpeedBoost++; + } } - if (crit) - { - if (modPlayer.planarSpeedBoost < 20) - { - modPlayer.planarSpeedBoost++; - } - } } } public override void OnHitPvp(Player target, int damage, bool crit) { - CalamityPlayer modPlayer = Main.player[projectile.owner].Calamity(); + CalamityPlayer modPlayer = Main.player[projectile.owner].Calamity(); target.AddBuff(BuffID.Electrified, 180); - if (projectile.owner == Main.myPlayer) - { - if (target.statLife <= 0) - { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (projectile.owner == Main.myPlayer) + { + if (target.statLife <= 0) + { + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + } + if (crit) + { + if (modPlayer.planarSpeedBoost < 20) + { + modPlayer.planarSpeedBoost++; + } } - if (crit) - { - if (modPlayer.planarSpeedBoost < 20) - { - modPlayer.planarSpeedBoost++; - } - } } } @@ -103,7 +103,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); projectile.maxPenetrate = -1; projectile.penetrate = -1; - projectile.damage = (int)(projectile.damage * 0.6f); + projectile.damage = (int)(projectile.damage * 0.6f); projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.Damage(); diff --git a/Projectiles/Ranged/PlanarRipperExplosion.cs b/Projectiles/Ranged/PlanarRipperExplosion.cs index 835ca461c1..1cf889b655 100644 --- a/Projectiles/Ranged/PlanarRipperExplosion.cs +++ b/Projectiles/Ranged/PlanarRipperExplosion.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class PlanarRipperExplosion : ModProjectile + public class PlanarRipperExplosion : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -66,12 +66,12 @@ namespace CalamityMod.Projectiles.Ranged } } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - projectile.damage = (int)(projectile.damage * 0.75); - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + projectile.damage = (int)(projectile.damage * 0.75); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Electrified, 180); } diff --git a/Projectiles/Ranged/PlanetaryAnnihilationProj.cs b/Projectiles/Ranged/PlanetaryAnnihilationProj.cs index 231a40014f..8986ddda26 100644 --- a/Projectiles/Ranged/PlanetaryAnnihilationProj.cs +++ b/Projectiles/Ranged/PlanetaryAnnihilationProj.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class PlanetaryAnnihilationProj : ModProjectile + public class PlanetaryAnnihilationProj : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.extraUpdates = 1; projectile.timeLeft = 600; - projectile.arrow = true; + projectile.arrow = true; } public override void AI() @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num469].noGravity = true; Main.dust[num469].velocity *= 0f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void Kill(int timeLeft) @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage /= 2; + projectile.damage /= 2; projectile.Damage(); int num3; for (int num53 = 0; num53 < 20; num53 = num3 + 1) diff --git a/Projectiles/Ranged/PolarStar.cs b/Projectiles/Ranged/PolarStar.cs index 1a1ad3f71b..862e4a7419 100644 --- a/Projectiles/Ranged/PolarStar.cs +++ b/Projectiles/Ranged/PolarStar.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Ranged } if (projectile.ai[1] == 2f) //Boost three { - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } else if (projectile.ai[1] == 1f) //Boost two { @@ -163,7 +163,7 @@ namespace CalamityMod.Projectiles.Ranged } if (projectile.ai[1] == 2f) //Boost three { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 150); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 150); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Ranged/PrecisionBolt.cs b/Projectiles/Ranged/PrecisionBolt.cs index 6c075f0275..2f6b826d7c 100644 --- a/Projectiles/Ranged/PrecisionBolt.cs +++ b/Projectiles/Ranged/PrecisionBolt.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class PrecisionBolt : ModProjectile + public class PrecisionBolt : ModProjectile { NPC potentialTarget = null; public override void SetStaticDefaults() diff --git a/Projectiles/Ranged/PrismComet.cs b/Projectiles/Ranged/PrismComet.cs index 4cd6c32fe0..e6d35db890 100644 --- a/Projectiles/Ranged/PrismComet.cs +++ b/Projectiles/Ranged/PrismComet.cs @@ -57,8 +57,8 @@ namespace CalamityMod.Projectiles.Ranged Time++; } - public void ReleaseIdleDust() - { + public void ReleaseIdleDust() + { if (Main.dedServ) return; @@ -81,11 +81,11 @@ namespace CalamityMod.Projectiles.Ranged } public override Color? GetAlpha(Color lightColor) - { + { Color color = Color.Honeydew * projectile.Opacity; color.A = 0; return color; - } + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Ranged/PrismEnergyBullet.cs b/Projectiles/Ranged/PrismEnergyBullet.cs index dbd228c778..bc97bfa811 100644 --- a/Projectiles/Ranged/PrismEnergyBullet.cs +++ b/Projectiles/Ranged/PrismEnergyBullet.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class PrismEnergyBullet : ModProjectile + public class PrismEnergyBullet : ModProjectile { public ref float CurrentLaserLength => ref projectile.ai[0]; public ref float Time => ref projectile.ai[1]; @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Ranged } public override void AI() - { + { if (projectile.timeLeft == 300) Main.PlaySound(SoundID.Item14, projectile.Center); @@ -39,25 +39,25 @@ namespace CalamityMod.Projectiles.Ranged Time++; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { if (Main.myPlayer != projectile.owner) return; for (int i = 0; i < 3; i++) - { + { Vector2 shootVelocity = projectile.velocity.RotatedBy(MathHelper.Lerp(-0.3f, 0.3f, i / 2f)) * 0.4f; Projectile.NewProjectile(projectile.Center, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - } - } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { Texture2D texture = Main.projectileTexture[projectile.type]; Vector2 origin = texture.Size() * 0.5f; Vector2 currentDirection = projectile.velocity.SafeNormalize(Vector2.Zero); for (int i = 0; i < CurrentLaserLength; i++) - { + { float scale = MathHelper.Lerp(1f, 0.2f, i / CurrentLaserLength) * projectile.scale; Vector2 drawPosition = projectile.Center - currentDirection * i * 4f - Main.screenPosition; Color drawColor = Color.Lerp(Color.Lime, Color.YellowGreen, (float)Math.Cos(i / CurrentLaserLength * 2.1f - Main.GlobalTime * 2.5f) * 0.5f + 0.5f); @@ -68,6 +68,6 @@ namespace CalamityMod.Projectiles.Ranged spriteBatch.Draw(texture, drawPosition, null, drawColor, projectile.rotation, origin, scale, SpriteEffects.None, 0f); } return false; - } - } + } + } } diff --git a/Projectiles/Ranged/PrismExplosionLarge.cs b/Projectiles/Ranged/PrismExplosionLarge.cs index 0ba7cb62bd..75d968045f 100644 --- a/Projectiles/Ranged/PrismExplosionLarge.cs +++ b/Projectiles/Ranged/PrismExplosionLarge.cs @@ -37,8 +37,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.Opacity = Utils.InverseLerp(5f, 36f, projectile.timeLeft, true); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { Texture2D texture = Main.projectileTexture[projectile.type]; Texture2D lightTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/PhotovisceratorLight"); Rectangle frame = texture.Frame(3, 6, projectile.frame / 6, projectile.frame % 6); @@ -55,6 +55,6 @@ namespace CalamityMod.Projectiles.Ranged } spriteBatch.Draw(texture, drawPosition, frame, Color.White, 0f, origin, 1.6f, SpriteEffects.None, 0f); return false; - } - } + } + } } diff --git a/Projectiles/Ranged/PrismExplosionSmall.cs b/Projectiles/Ranged/PrismExplosionSmall.cs index d1398625c0..9deb548cfd 100644 --- a/Projectiles/Ranged/PrismExplosionSmall.cs +++ b/Projectiles/Ranged/PrismExplosionSmall.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Projectiles.Ranged public class PrismExplosionSmall : ModProjectile { public override void SetStaticDefaults() - { + { DisplayName.SetDefault("Explosion"); Main.projFrames[projectile.type] = 7; } @@ -41,8 +41,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.Opacity = Utils.InverseLerp(5f, 36f, projectile.timeLeft, true); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { Texture2D texture = Main.projectileTexture[projectile.type]; Texture2D lightTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/PhotovisceratorLight"); Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); @@ -51,6 +51,6 @@ namespace CalamityMod.Projectiles.Ranged spriteBatch.Draw(texture, drawPosition, frame, Color.White, 0f, origin, 1f, SpriteEffects.None, 0f); return false; - } - } + } + } } diff --git a/Projectiles/Ranged/PrismaticEnergyBlast.cs b/Projectiles/Ranged/PrismaticEnergyBlast.cs index d138a69f38..8dd15b9ecf 100644 --- a/Projectiles/Ranged/PrismaticEnergyBlast.cs +++ b/Projectiles/Ranged/PrismaticEnergyBlast.cs @@ -6,15 +6,15 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class PrismaticEnergyBlast : BaseLaserbeamProjectile + public class PrismaticEnergyBlast : BaseLaserbeamProjectile { public bool ExplodedYet - { + { get => projectile.ai[1] == 1f; set => projectile.ai[1] = value.ToInt(); - } - public override string Texture => "CalamityMod/ExtraTextures/Lasers/PrismLaserStart"; - public override float MaxScale => 1f; + } + public override string Texture => "CalamityMod/ExtraTextures/Lasers/PrismLaserStart"; + public override float MaxScale => 1f; public override float MaxLaserLength => 2700f; public override float Lifetime => 50f; public override Color LaserOverlayColor => Color.White; @@ -23,13 +23,13 @@ namespace CalamityMod.Projectiles.Ranged public override Texture2D LaserMiddleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/PrismLaserMid"); public override Texture2D LaserEndTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/PrismLaserEnd"); - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Energy Blast"); Main.projFrames[projectile.type] = 5; } - public override void SetDefaults() + public override void SetDefaults() { projectile.width = projectile.height = 14; projectile.friendly = true; @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 450; } - public override bool PreAI() + public override bool PreAI() { projectile.frameCounter++; if (projectile.frameCounter % 5 == 4) @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Ranged } public override float DetermineLaserLength() - { + { if (projectile.penetrate == 100) return DetermineLaserLength_CollideWithTiles(8); return LaserLength; @@ -75,19 +75,19 @@ namespace CalamityMod.Projectiles.Ranged public override bool CanDamage() => projectile.penetrate == 100; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { LaserLength = projectile.Distance(target.Center); CreateExplosion(target.Center); } - public override void Kill(int timeLeft) - { + public override void Kill(int timeLeft) + { Vector2 laserEnd = projectile.Center + projectile.velocity * LaserLength; CreateExplosion(laserEnd); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { // Start texture drawing. Rectangle beginFrame = LaserBeginTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); @@ -141,6 +141,6 @@ namespace CalamityMod.Projectiles.Ranged SpriteEffects.None, 0f); return false; - } - } + } + } } diff --git a/Projectiles/Ranged/PristineFire.cs b/Projectiles/Ranged/PristineFire.cs index 6c9b831859..e922328e20 100644 --- a/Projectiles/Ranged/PristineFire.cs +++ b/Projectiles/Ranged/PristineFire.cs @@ -6,12 +6,12 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class PristineFire : ModProjectile + public class PristineFire : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private int dust1 = (int)CalamityDusts.ProfanedFire; - private int dust2 = ModContent.DustType(); + private int dust1 = (int)CalamityDusts.ProfanedFire; + private int dust2 = ModContent.DustType(); public override void SetStaticDefaults() { @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; Main.dust[num448].velocity *= 0.2f; Main.dust[num448].noLight = true; - Main.dust[num448].color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + Main.dust[num448].color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); } projectile.ai[0] += 1f; if (projectile.ai[0] == 48f) @@ -84,8 +84,8 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num42].noGravity = true; Main.dust[num42].position = projectile.Center + value8; Main.dust[num42].velocity = projectile.velocity; - Main.dust[num42].noLight = true; - Main.dust[num42].color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + Main.dust[num42].noLight = true; + Main.dust[num42].color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); } } } @@ -98,11 +98,11 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - dust1, - dust2 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + dust1, + dust2 + }); int height = 50; float num50 = 1.7f; float num51 = 0.8f; @@ -125,14 +125,14 @@ namespace CalamityMod.Projectiles.Ranged dust.noGravity = true; dust.velocity *= 3f; dust.velocity += value4 * Main.rand.NextFloat(); - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, num51); dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * (float)projectile.width / 2f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.velocity += value4 * Main.rand.NextFloat(); - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); } for (int num55 = 0; num55 < 20; num55++) { @@ -142,7 +142,7 @@ namespace CalamityMod.Projectiles.Ranged dust.noGravity = true; dust.velocity *= 0.5f; dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); } } } diff --git a/Projectiles/Ranged/PristineSecondary.cs b/Projectiles/Ranged/PristineSecondary.cs index 24a112e1c1..f42d4753b8 100644 --- a/Projectiles/Ranged/PristineSecondary.cs +++ b/Projectiles/Ranged/PristineSecondary.cs @@ -6,18 +6,18 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class PristineSecondary : ModProjectile + public class PristineSecondary : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private int dust1 = (int)CalamityDusts.ProfanedFire; - private int dust2 = ModContent.DustType(); + private int dust1 = (int)CalamityDusts.ProfanedFire; + private int dust2 = ModContent.DustType(); - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Fire"); - } - + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fire"); + } + public override void SetDefaults() { projectile.width = 50; @@ -25,21 +25,21 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.ranged = true; - projectile.penetrate = -1; + projectile.ranged = true; + projectile.penetrate = -1; projectile.usesIDStaticNPCImmunity = true; projectile.idStaticNPCHitCooldown = 3; projectile.timeLeft = 150; } - public override void AI() - { - projectile.velocity *= 0.98f; - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - dust1, - dust2 - }); + public override void AI() + { + projectile.velocity *= 0.98f; + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + dust1, + dust2 + }); Lighting.AddLight(projectile.Center, 1f, 1f, 0.25f); if (projectile.ai[0] > 7f) { @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Ranged dust.velocity.Y *= 1.2f; dust.scale *= num296; dust.noLight = true; - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); } } } diff --git a/Projectiles/Ranged/ProBolt.cs b/Projectiles/Ranged/ProBolt.cs index 053fcd12c6..5f1f1b79e8 100644 --- a/Projectiles/Ranged/ProBolt.cs +++ b/Projectiles/Ranged/ProBolt.cs @@ -11,9 +11,9 @@ namespace CalamityMod.Projectiles.Ranged public override void SetStaticDefaults() { DisplayName.SetDefault("Bolt"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { @@ -23,9 +23,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = 3; projectile.timeLeft = 600; - projectile.extraUpdates = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.extraUpdates = 1; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -35,28 +35,28 @@ namespace CalamityMod.Projectiles.Ranged Lighting.AddLight(projectile.Center, new Vector3(158, 240, 240) * (1.5f / 255)); - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - Vector2 dspeed = -projectile.velocity * 0.8f; - float x = projectile.Center.X - projectile.velocity.X / 10f; - float y = projectile.Center.Y - projectile.velocity.Y / 10f; - int num135 = Dust.NewDust(new Vector2(x, y), 1, 1, 160, 0f, 0f, 0, default, 1.25f); - Main.dust[num135].alpha = projectile.alpha; - Main.dust[num135].position.X = x; - Main.dust[num135].position.Y = y; - Main.dust[num135].velocity = dspeed; - Main.dust[num135].noGravity = true; - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + Vector2 dspeed = -projectile.velocity * 0.8f; + float x = projectile.Center.X - projectile.velocity.X / 10f; + float y = projectile.Center.Y - projectile.velocity.Y / 10f; + int num135 = Dust.NewDust(new Vector2(x, y), 1, 1, 160, 0f, 0f, 0, default, 1.25f); + Main.dust[num135].alpha = projectile.alpha; + Main.dust[num135].position.X = x; + Main.dust[num135].position.Y = y; + Main.dust[num135].velocity = dspeed; + Main.dust[num135].noGravity = true; + } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); + return false; + } - public override bool OnTileCollide(Vector2 oldVelocity) + public override bool OnTileCollide(Vector2 oldVelocity) { projectile.penetrate--; if (projectile.penetrate <= 0) diff --git a/Projectiles/Ranged/PumplerGrenade.cs b/Projectiles/Ranged/PumplerGrenade.cs index 6ef7c2e7b7..b1d615941c 100644 --- a/Projectiles/Ranged/PumplerGrenade.cs +++ b/Projectiles/Ranged/PumplerGrenade.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Ranged { - public class PumplerGrenade : ModProjectile + public class PumplerGrenade : ModProjectile { public override void SetStaticDefaults() { @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.ranged = true; projectile.ignoreWater = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; } public override string Texture => "CalamityMod/Projectiles/Ranged/PumplerGrenade"; diff --git a/Projectiles/Ranged/PumplerGrenadeExplosion.cs b/Projectiles/Ranged/PumplerGrenadeExplosion.cs index 43bf7f581e..2996df1e70 100644 --- a/Projectiles/Ranged/PumplerGrenadeExplosion.cs +++ b/Projectiles/Ranged/PumplerGrenadeExplosion.cs @@ -6,7 +6,7 @@ using CalamityMod.Particles; namespace CalamityMod.Projectiles.Ranged { - public class PumplerGrenadeExplosion : ModProjectile + public class PumplerGrenadeExplosion : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Ranged/PumplerHoldout.cs b/Projectiles/Ranged/PumplerHoldout.cs index 3615a5d0ac..8d73e44e51 100644 --- a/Projectiles/Ranged/PumplerHoldout.cs +++ b/Projectiles/Ranged/PumplerHoldout.cs @@ -14,7 +14,7 @@ using CalamityMod.Particles; namespace CalamityMod.Projectiles.Ranged { - public class PumplerHoldout : ModProjectile + public class PumplerHoldout : ModProjectile { public override void SetStaticDefaults() diff --git a/Projectiles/Ranged/RainbowBlast.cs b/Projectiles/Ranged/RainbowBlast.cs index acc33dabb0..b99b48f9d6 100644 --- a/Projectiles/Ranged/RainbowBlast.cs +++ b/Projectiles/Ranged/RainbowBlast.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class RainbowBlast : ModProjectile + public class RainbowBlast : ModProjectile { public override void SetStaticDefaults() { @@ -43,15 +43,15 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num469].velocity = dspeed; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } public override Color? GetAlpha(Color lightColor) { diff --git a/Projectiles/Ranged/RainbowFront.cs b/Projectiles/Ranged/RainbowFront.cs index a012c74477..bbe5250ec2 100644 --- a/Projectiles/Ranged/RainbowFront.cs +++ b/Projectiles/Ranged/RainbowFront.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class RainbowFront : ModProjectile + public class RainbowFront : ModProjectile { public override void SetStaticDefaults() { @@ -13,54 +13,54 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - projectile.width = 12; - projectile.height = 12; - projectile.penetrate = -1; - projectile.ranged = true; - projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.scale = 1.25f; + projectile.width = 12; + projectile.height = 12; + projectile.penetrate = -1; + projectile.ranged = true; + projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.scale = 1.25f; } - public override void AI() - { - int num1 = 1200; - if (projectile.owner == Main.myPlayer) - { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - projectile.localAI[0] = 3f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * (1f / 1000f), projectile.velocity.Y * (1f / 1000f), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - } - if (projectile.timeLeft > num1) - projectile.timeLeft = num1; - } - float num2 = 1f; - if (projectile.velocity.Y < 0f) - num2 -= projectile.velocity.Y / 3f; - projectile.ai[0] += num2; - if (projectile.ai[0] > 30f) - { - projectile.velocity.Y += 0.5f; - if (projectile.velocity.Y > 0f) - { - projectile.velocity.X *= 0.95f; - } - else - { - projectile.velocity.X *= 1.05f; - } - } - float x = projectile.velocity.X; - float y = projectile.velocity.Y; - float num3 = 15.95f * projectile.scale / (float)Math.Sqrt((double)x * (double)x + (double)y * (double)y); - float num4 = x * num3; - float num5 = y * num3; - projectile.velocity.X = num4; - projectile.velocity.Y = num5; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) - MathHelper.PiOver2; - } + public override void AI() + { + int num1 = 1200; + if (projectile.owner == Main.myPlayer) + { + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + projectile.localAI[0] = 3f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * (1f / 1000f), projectile.velocity.Y * (1f / 1000f), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + } + if (projectile.timeLeft > num1) + projectile.timeLeft = num1; + } + float num2 = 1f; + if (projectile.velocity.Y < 0f) + num2 -= projectile.velocity.Y / 3f; + projectile.ai[0] += num2; + if (projectile.ai[0] > 30f) + { + projectile.velocity.Y += 0.5f; + if (projectile.velocity.Y > 0f) + { + projectile.velocity.X *= 0.95f; + } + else + { + projectile.velocity.X *= 1.05f; + } + } + float x = projectile.velocity.X; + float y = projectile.velocity.Y; + float num3 = 15.95f * projectile.scale / (float)Math.Sqrt((double)x * (double)x + (double)y * (double)y); + float num4 = x * num3; + float num5 = y * num3; + projectile.velocity.X = num4; + projectile.velocity.Y = num5; + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) - MathHelper.PiOver2; + } public override Color? GetAlpha(Color lightColor) => Color.Transparent; } diff --git a/Projectiles/Ranged/RainbowTrail.cs b/Projectiles/Ranged/RainbowTrail.cs index 7ccdfbafdf..6840176d84 100644 --- a/Projectiles/Ranged/RainbowTrail.cs +++ b/Projectiles/Ranged/RainbowTrail.cs @@ -2,7 +2,7 @@ using Microsoft.Xna.Framework; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class RainbowTrail : ModProjectile + public class RainbowTrail : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Ranged/RainbowFront"; @@ -13,17 +13,17 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 46; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.ranged = true; - projectile.alpha = 255; - projectile.light = 0.3f; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.scale = 1.25f; + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 46; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.ranged = true; + projectile.alpha = 255; + projectile.light = 0.3f; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.scale = 1.25f; } public override Color? GetAlpha(Color lightColor) => new Color(255 - projectile.alpha, 255 - projectile.alpha, 255 - projectile.alpha, 0); diff --git a/Projectiles/Ranged/RealmRavagerBullet.cs b/Projectiles/Ranged/RealmRavagerBullet.cs index b8b4a9d23a..ccfd9c632e 100644 --- a/Projectiles/Ranged/RealmRavagerBullet.cs +++ b/Projectiles/Ranged/RealmRavagerBullet.cs @@ -11,9 +11,9 @@ namespace CalamityMod.Projectiles.Ranged public override void SetStaticDefaults() { DisplayName.SetDefault("Explosive Bullet"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { @@ -26,22 +26,22 @@ namespace CalamityMod.Projectiles.Ranged projectile.ignoreWater = true; projectile.aiStyle = 1; aiType = ProjectileID.BulletHighVelocity; - projectile.extraUpdates = 3; + projectile.extraUpdates = 3; projectile.penetrate = 1; projectile.timeLeft = 90; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); + return false; + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.Center); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); for (int d = 0; d < 2; d++) { Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1.5f); @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage /= 2; + projectile.damage /= 2; projectile.Damage(); } } diff --git a/Projectiles/Ranged/RocketFire.cs b/Projectiles/Ranged/RocketFire.cs index 063a20553e..d3d52ed2b9 100644 --- a/Projectiles/Ranged/RocketFire.cs +++ b/Projectiles/Ranged/RocketFire.cs @@ -6,10 +6,10 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class RocketFire : ModProjectile + public class RocketFire : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Rogue/TotalityFire"; - private bool initialized = false; + private bool initialized = false; public override void SetStaticDefaults() { @@ -29,28 +29,28 @@ namespace CalamityMod.Projectiles.Ranged projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; projectile.ranged = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { - //make it face the way it's going - if (projectile.ai[1] > 0f) - { - projectile.rotation = -projectile.velocity.X * 0.05f + MathHelper.PiOver2; - } - else - { - projectile.rotation = projectile.velocity.ToRotation(); - } - projectile.ai[1]--; + //make it face the way it's going + if (projectile.ai[1] > 0f) + { + projectile.rotation = -projectile.velocity.X * 0.05f + MathHelper.PiOver2; + } + else + { + projectile.rotation = projectile.velocity.ToRotation(); + } + projectile.ai[1]--; - //frames - if (!initialized) - { - initialized = true; - projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); - } + //frames + if (!initialized) + { + initialized = true; + projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); + } projectile.frameCounter++; if (projectile.frameCounter > 6) { @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.frame = 0; } - //movement + //movement if (projectile.velocity.X != projectile.velocity.X) { projectile.velocity.X *= -0.1f; @@ -99,17 +99,17 @@ namespace CalamityMod.Projectiles.Ranged projectile.velocity.Y = 16f; } - //dust - if (Main.rand.NextBool(4)) - { - int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[fire]; - dust.position.X -= 2f; - dust.position.Y += 2f; - dust.scale += (float)Main.rand.Next(50) * 0.01f; - dust.noGravity = true; - dust.velocity.Y -= 2f; - } + //dust + if (Main.rand.NextBool(4)) + { + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[fire]; + dust.position.X -= 2f; + dust.position.Y += 2f; + dust.scale += (float)Main.rand.Next(50) * 0.01f; + dust.noGravity = true; + dust.velocity.Y -= 2f; + } if (Main.rand.NextBool(10)) { int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f); @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Ranged public override bool OnTileCollide(Vector2 oldVelocity) { - projectile.ai[1] = 10f; + projectile.ai[1] = 10f; return false; } diff --git a/Projectiles/Ranged/RubberMortarRoundProj.cs b/Projectiles/Ranged/RubberMortarRoundProj.cs index 313ab69876..7738d447c8 100644 --- a/Projectiles/Ranged/RubberMortarRoundProj.cs +++ b/Projectiles/Ranged/RubberMortarRoundProj.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class RubberMortarRoundProj : ModProjectile + public class RubberMortarRoundProj : ModProjectile { public override string Texture => "CalamityMod/Items/Ammo/RubberMortarRound"; @@ -33,26 +33,26 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (projectile.velocity.Length() >= 8f) - { - for (int d = 0; d < 2; d++) - { - float xOffset = 0f; - float yOffset = 0f; - if (d == 1) - { - xOffset = projectile.velocity.X * 0.5f; - yOffset = projectile.velocity.Y * 0.5f; - } - int fire = Dust.NewDust(new Vector2(projectile.position.X + 3f + xOffset, projectile.position.Y + 3f + yOffset) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, DustID.Fire, 0f, 0f, 100, default, 1f); - Main.dust[fire].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[fire].velocity *= 0.2f; - Main.dust[fire].noGravity = true; - int smoke = Dust.NewDust(new Vector2(projectile.position.X + 3f + xOffset, projectile.position.Y + 3f + yOffset) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, DustID.Smoke, 0f, 0f, 100, default, 0.5f); - Main.dust[smoke].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[smoke].velocity *= 0.05f; - } - } + if (projectile.velocity.Length() >= 8f) + { + for (int d = 0; d < 2; d++) + { + float xOffset = 0f; + float yOffset = 0f; + if (d == 1) + { + xOffset = projectile.velocity.X * 0.5f; + yOffset = projectile.velocity.Y * 0.5f; + } + int fire = Dust.NewDust(new Vector2(projectile.position.X + 3f + xOffset, projectile.position.Y + 3f + yOffset) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, DustID.Fire, 0f, 0f, 100, default, 1f); + Main.dust[fire].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[fire].velocity *= 0.2f; + Main.dust[fire].noGravity = true; + int smoke = Dust.NewDust(new Vector2(projectile.position.X + 3f + xOffset, projectile.position.Y + 3f + yOffset) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, DustID.Smoke, 0f, 0f, 100, default, 0.5f); + Main.dust[smoke].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[smoke].velocity *= 0.05f; + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -64,24 +64,24 @@ namespace CalamityMod.Projectiles.Ranged public override bool OnTileCollide(Vector2 oldVelocity) { - int penetrateAmt = projectile.penetrate; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 200); + int penetrateAmt = projectile.penetrate; + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 200); projectile.maxPenetrate = projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.Damage(); Main.PlaySound(SoundID.Item14, projectile.Center); - projectile.penetrate = penetrateAmt; + projectile.penetrate = penetrateAmt; - SpawnDust(); - CalamityUtils.ExplosionGores(projectile.Center, 3); + SpawnDust(); + CalamityUtils.ExplosionGores(projectile.Center, 3); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); if (projectile.owner == Main.myPlayer) { - DestroyTiles(); - } + DestroyTiles(); + } projectile.penetrate--; if (projectile.penetrate <= 0) @@ -106,27 +106,27 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 200); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 200); projectile.maxPenetrate = projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.knockBack *= 5f; + projectile.knockBack *= 5f; projectile.Damage(); Main.PlaySound(SoundID.Item14, projectile.Center); - SpawnDust(); - CalamityUtils.ExplosionGores(projectile.Center, 3); + SpawnDust(); + CalamityUtils.ExplosionGores(projectile.Center, 3); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 14); if (projectile.owner == Main.myPlayer) { - DestroyTiles(); - } - } + DestroyTiles(); + } + } - private void SpawnDust() - { + private void SpawnDust() + { for (int d = 0; d < 40; d++) { int smoke = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 2f); @@ -145,20 +145,20 @@ namespace CalamityMod.Projectiles.Ranged fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); Main.dust[fire].velocity *= 2f; } - } + } - private void DestroyTiles() - { - CalamityUtils.ExplodeandDestroyTiles(projectile, 5, false, new List() - { - ModContent.TileType(), - ModContent.TileType() - }, - new List() - { - ModContent.WallType(), - ModContent.WallType() - }); - } + private void DestroyTiles() + { + CalamityUtils.ExplodeandDestroyTiles(projectile, 5, false, new List() + { + ModContent.TileType(), + ModContent.TileType() + }, + new List() + { + ModContent.WallType(), + ModContent.WallType() + }); + } } } diff --git a/Projectiles/Ranged/SandstormBullet.cs b/Projectiles/Ranged/SandstormBullet.cs index cd29b7fbd2..a70e79cd7f 100644 --- a/Projectiles/Ranged/SandstormBullet.cs +++ b/Projectiles/Ranged/SandstormBullet.cs @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.extraUpdates = 1; projectile.aiStyle = 1; projectile.alpha = 255; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/SandyWaifuShark.cs b/Projectiles/Ranged/SandyWaifuShark.cs index 33c2e01724..e7ded77f15 100644 --- a/Projectiles/Ranged/SandyWaifuShark.cs +++ b/Projectiles/Ranged/SandyWaifuShark.cs @@ -25,9 +25,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 240; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 210 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 210 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { int num192 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 32, 0f, 0f, 0, default, 0.5f); Main.dust[num192].noGravity = true; @@ -54,9 +54,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X); } - if (projectile.timeLeft < 210) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 8f, 20f); - } + if (projectile.timeLeft < 210) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 8f, 20f); + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Ranged/ScorchedEarthClusterBomb.cs b/Projectiles/Ranged/ScorchedEarthClusterBomb.cs index db41830fcf..69cb9daaa7 100644 --- a/Projectiles/Ranged/ScorchedEarthClusterBomb.cs +++ b/Projectiles/Ranged/ScorchedEarthClusterBomb.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class ScorchedEarthClusterBomb : ModProjectile + public class ScorchedEarthClusterBomb : ModProjectile { public override void SetStaticDefaults() { @@ -19,32 +19,32 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = -1; projectile.timeLeft = 120; - projectile.ignoreWater = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = -2; - } + projectile.ignoreWater = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -2; + } public override void AI() { projectile.rotation = projectile.velocity.ToRotation(); - projectile.velocity *= 0.95f; - if (projectile.velocity.Length() < 0.5f && projectile.timeLeft > 10) - projectile.timeLeft = 10; - } + projectile.velocity *= 0.95f; + if (projectile.velocity.Length() < 0.5f && projectile.timeLeft > 10) + projectile.timeLeft = 10; + } public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.position); for (int i = 0; i < 10; i++) { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 0, default, 1f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 0, default, 1f); } int projAmt = Main.rand.Next(2, 4); if (projectile.owner == Main.myPlayer) { for (int k = 0; k < projAmt; k++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner); } } diff --git a/Projectiles/Ranged/ScorchedEarthRocket.cs b/Projectiles/Ranged/ScorchedEarthRocket.cs index e9a5330f6c..c5db2ebe63 100644 --- a/Projectiles/Ranged/ScorchedEarthRocket.cs +++ b/Projectiles/Ranged/ScorchedEarthRocket.cs @@ -5,83 +5,83 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class ScorchedEarthRocket : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Rocket"); - Main.projFrames[projectile.type] = 10; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public class ScorchedEarthRocket : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rocket"); + Main.projFrames[projectile.type] = 10; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 22; - projectile.height = 22; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; - projectile.timeLeft = 300; - projectile.ranged = true; - projectile.tileCollide = false; - projectile.extraUpdates = 1; - } + public override void SetDefaults() + { + projectile.width = 22; + projectile.height = 22; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = 1; + projectile.timeLeft = 300; + projectile.ranged = true; + projectile.tileCollide = false; + projectile.extraUpdates = 1; + } - public override void AI() - { - //Lighting + public override void AI() + { + //Lighting Lighting.AddLight(projectile.Center, 1f, 0.79f, 0.3f); - //Animation - projectile.frameCounter++; - if (projectile.frameCounter > (projectile.frame == 1 ? 10 : 7)) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 6; - } + //Animation + projectile.frameCounter++; + if (projectile.frameCounter > (projectile.frame == 1 ? 10 : 7)) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 6; + } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 400f, 5f, 30f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 400f, 5f, 30f); - //Rotation - projectile.rotation = projectile.velocity.ToRotation(); + //Rotation + projectile.rotation = projectile.velocity.ToRotation(); - float xVel = projectile.velocity.X * 0.5f; - float yVel = projectile.velocity.Y * 0.5f; - int d = Dust.NewDust(new Vector2(projectile.position.X + 3f + xVel, projectile.position.Y + 3f + yVel) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 1f); - Main.dust[d].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[d].velocity *= 0.2f; - Main.dust[d].noGravity = true; - d = Dust.NewDust(new Vector2(projectile.position.X + 3f + xVel, projectile.position.Y + 3f + yVel) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 0.5f); - Main.dust[d].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[d].velocity *= 0.05f; - } + float xVel = projectile.velocity.X * 0.5f; + float yVel = projectile.velocity.Y * 0.5f; + int d = Dust.NewDust(new Vector2(projectile.position.X + 3f + xVel, projectile.position.Y + 3f + yVel) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 1f); + Main.dust[d].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[d].velocity *= 0.2f; + Main.dust[d].noGravity = true; + d = Dust.NewDust(new Vector2(projectile.position.X + 3f + xVel, projectile.position.Y + 3f + yVel) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 0.5f); + Main.dust[d].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[d].velocity *= 0.05f; + } - public override void Kill(int timeLeft) - { - if (projectile.owner == Main.myPlayer) - { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 300); - Main.PlaySound(SoundID.Item14, projectile.position); - CalamityUtils.ExplosionGores(projectile.Center, 10); + public override void Kill(int timeLeft) + { + if (projectile.owner == Main.myPlayer) + { + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 300); + Main.PlaySound(SoundID.Item14, projectile.position); + CalamityUtils.ExplosionGores(projectile.Center, 10); - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack * 2f, projectile.owner); - for (int j = 0; j < 5; j++) - { - Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(8f, 10f); - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); - } - } - } + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack * 2f, projectile.owner); + for (int j = 0; j < 5; j++) + { + Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(8f, 10f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Ranged/SeaDragonRocket.cs b/Projectiles/Ranged/SeaDragonRocket.cs index 1bde49c9d7..911a178010 100644 --- a/Projectiles/Ranged/SeaDragonRocket.cs +++ b/Projectiles/Ranged/SeaDragonRocket.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class SeaDragonRocket : ModProjectile + public class SeaDragonRocket : ModProjectile { public override void SetStaticDefaults() { @@ -76,12 +76,12 @@ namespace CalamityMod.Projectiles.Ranged } } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 192); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 192); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -111,7 +111,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int k = 0; k < projAmt; k++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.33), 0f, projectile.owner); } } diff --git a/Projectiles/Ranged/SeasSearingBubble.cs b/Projectiles/Ranged/SeasSearingBubble.cs index 1ec52257ae..a62dfe9e2a 100644 --- a/Projectiles/Ranged/SeasSearingBubble.cs +++ b/Projectiles/Ranged/SeasSearingBubble.cs @@ -7,7 +7,7 @@ using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Ranged { - public class SeasSearingBubble : ModProjectile + public class SeasSearingBubble : ModProjectile { public override void SetStaticDefaults() { @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 2; projectile.timeLeft = 480; projectile.ranged = true; - projectile.extraUpdates = 2; + projectile.extraUpdates = 2; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } @@ -39,29 +39,29 @@ namespace CalamityMod.Projectiles.Ranged if (projectile.alpha < 0) projectile.alpha = 0; } - if (projectile.timeLeft < 475) - { - for (int num105 = 0; num105 < 2; num105++) - { - float num99 = projectile.velocity.X / 3f * (float)num105; - float num100 = projectile.velocity.Y / 3f * (float)num105; - int num101 = 4; - int num102 = Dust.NewDust(new Vector2(projectile.position.X + (float)num101, projectile.position.Y + (float)num101), projectile.width - num101 * 2, projectile.height - num101 * 2, 202, 0f, 0f, 150, new Color(60, Main.DiscoG, 190), 1.2f); - Dust dust = Main.dust[num102]; - dust.noGravity = true; - dust.velocity *= 0.1f; - dust.velocity += projectile.velocity * 0.1f; - dust.position.X -= num99; - dust.position.Y -= num100; - } - if (Main.rand.NextBool(10)) - { - int num103 = 4; - int num104 = Dust.NewDust(new Vector2(projectile.position.X + (float)num103, projectile.position.Y + (float)num103), projectile.width - num103 * 2, projectile.height - num103 * 2, 202, 0f, 0f, 150, new Color(60, Main.DiscoG, 190), 0.6f); - Main.dust[num104].velocity *= 0.25f; - Main.dust[num104].velocity += projectile.velocity * 0.5f; - } - } + if (projectile.timeLeft < 475) + { + for (int num105 = 0; num105 < 2; num105++) + { + float num99 = projectile.velocity.X / 3f * (float)num105; + float num100 = projectile.velocity.Y / 3f * (float)num105; + int num101 = 4; + int num102 = Dust.NewDust(new Vector2(projectile.position.X + (float)num101, projectile.position.Y + (float)num101), projectile.width - num101 * 2, projectile.height - num101 * 2, 202, 0f, 0f, 150, new Color(60, Main.DiscoG, 190), 1.2f); + Dust dust = Main.dust[num102]; + dust.noGravity = true; + dust.velocity *= 0.1f; + dust.velocity += projectile.velocity * 0.1f; + dust.position.X -= num99; + dust.position.Y -= num100; + } + if (Main.rand.NextBool(10)) + { + int num103 = 4; + int num104 = Dust.NewDust(new Vector2(projectile.position.X + (float)num103, projectile.position.Y + (float)num103), projectile.width - num103 * 2, projectile.height - num103 * 2, 202, 0f, 0f, 150, new Color(60, Main.DiscoG, 190), 0.6f); + Main.dust[num104].velocity *= 0.25f; + Main.dust[num104].velocity += projectile.velocity * 0.5f; + } + } } public override Color? GetAlpha(Color lightColor) @@ -76,46 +76,46 @@ namespace CalamityMod.Projectiles.Ranged } public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item96, projectile.position); - for (int k = 0; k < 5; k++) + { + Main.PlaySound(SoundID.Item96, projectile.position); + for (int k = 0; k < 5; k++) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 202, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f, 0, new Color(60, Main.DiscoG, 190)); } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - OnHitEffects(target.Center); - target.AddBuff(BuffID.Wet, 300); + { + OnHitEffects(target.Center); + target.AddBuff(BuffID.Wet, 300); target.AddBuff(ModContent.BuffType(), 180); } public override void OnHitPvp(Player target, int damage, bool crit) - { - OnHitEffects(target.Center); - target.AddBuff(BuffID.Wet, 300); + { + OnHitEffects(target.Center); + target.AddBuff(BuffID.Wet, 300); target.AddBuff(ModContent.BuffType(), 180); } - private void OnHitEffects(Vector2 targetPos) - { - Main.PlaySound(SoundID.Item96, projectile.Center); - if (projectile.ai[0] == 1f) - { - for (int x = 0; x < 2; x++) - { - if (projectile.owner == Main.myPlayer) - { - float angle = Main.rand.NextFloat(MathHelper.TwoPi); - Projectile bubble = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(20f, 25f), ModContent.ProjectileType(), projectile.damage / 2, 1f, projectile.owner); - bubble.rotation = angle; - bubble.tileCollide = false; - bubble.usesLocalNPCImmunity = true; - bubble.localNPCHitCooldown = -1; - } - } - } + private void OnHitEffects(Vector2 targetPos) + { + Main.PlaySound(SoundID.Item96, projectile.Center); + if (projectile.ai[0] == 1f) + { + for (int x = 0; x < 2; x++) + { + if (projectile.owner == Main.myPlayer) + { + float angle = Main.rand.NextFloat(MathHelper.TwoPi); + Projectile bubble = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(20f, 25f), ModContent.ProjectileType(), projectile.damage / 2, 1f, projectile.owner); + bubble.rotation = angle; + bubble.tileCollide = false; + bubble.usesLocalNPCImmunity = true; + bubble.localNPCHitCooldown = -1; + } + } + } } } } diff --git a/Projectiles/Ranged/SeasSearingSecondary.cs b/Projectiles/Ranged/SeasSearingSecondary.cs index 455e49176b..b86e4e4683 100644 --- a/Projectiles/Ranged/SeasSearingSecondary.cs +++ b/Projectiles/Ranged/SeasSearingSecondary.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class SeasSearingSecondary : ModProjectile + public class SeasSearingSecondary : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Ranged if (projectile.owner == Main.myPlayer) { int endoftime = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[endoftime].localAI[1] = 1f; + Main.projectile[endoftime].localAI[1] = 1f; } } diff --git a/Projectiles/Ranged/SepticSkewerBacteria.cs b/Projectiles/Ranged/SepticSkewerBacteria.cs index bbe41f7b58..eb14a1914e 100644 --- a/Projectiles/Ranged/SepticSkewerBacteria.cs +++ b/Projectiles/Ranged/SepticSkewerBacteria.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class SepticSkewerBacteria : ModProjectile + public class SepticSkewerBacteria : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -24,18 +24,18 @@ namespace CalamityMod.Projectiles.Ranged projectile.tileCollide = false; projectile.ignoreWater = true; projectile.timeLeft = 300; - projectile.ranged = true; + projectile.ranged = true; } public override void AI() { - int num297 = 171; + int num297 = 171; if (Main.rand.Next(3) == 0) { num297 = 46; } - int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, 0f, 0f, 100, default, 2f); - Main.dust[num469].noGravity = true; + int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, 0f, 0f, 100, default, 2f); + Main.dust[num469].noGravity = true; float num944 = 1f - (float)projectile.alpha / 255f; num944 *= projectile.scale; projectile.localAI[0] += 1f; diff --git a/Projectiles/Ranged/SepticSkewerHarpoon.cs b/Projectiles/Ranged/SepticSkewerHarpoon.cs index 9511dc54b2..3be3bfc2bd 100644 --- a/Projectiles/Ranged/SepticSkewerHarpoon.cs +++ b/Projectiles/Ranged/SepticSkewerHarpoon.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Ranged { - public class SepticSkewerHarpoon : ModProjectile + public class SepticSkewerHarpoon : ModProjectile { public override void SetStaticDefaults() { @@ -19,18 +19,18 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.penetrate = -1; projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.ranged = true; + projectile.ignoreWater = true; + projectile.ranged = true; projectile.extraUpdates = 1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 8; - projectile.timeLeft = 900; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.timeLeft = 900; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (Main.rand.NextBool(5)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 171, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); diff --git a/Projectiles/Ranged/Shell.cs b/Projectiles/Ranged/Shell.cs index acccef7873..4036c27298 100644 --- a/Projectiles/Ranged/Shell.cs +++ b/Projectiles/Ranged/Shell.cs @@ -15,15 +15,15 @@ namespace CalamityMod.Projectiles.Ranged { projectile.width = 34; projectile.height = 18; - projectile.ignoreWater = true; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.ranged = true; projectile.penetrate = 5; projectile.aiStyle = 1; - projectile.arrow = true; + projectile.arrow = true; projectile.timeLeft = 600; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/Shockblast.cs b/Projectiles/Ranged/Shockblast.cs index 1ac0485097..a3d9b5b2c8 100644 --- a/Projectiles/Ranged/Shockblast.cs +++ b/Projectiles/Ranged/Shockblast.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Ranged int num462 = 0; while (num462 < num461) { - float sizeMultiplier = (projectile.ai[1] * 0.5f) + 1f; + float sizeMultiplier = (projectile.ai[1] * 0.5f) + 1f; float num463 = Main.rand.Next(-10, 11) * sizeMultiplier; float num464 = Main.rand.Next(-10, 11) * sizeMultiplier; float num465 = Main.rand.Next(3, 9) * sizeMultiplier; @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Ranged num464 *= num466; int num467 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 185); Dust dust = Main.dust[num467]; - dust.scale = sizeMultiplier; + dust.scale = sizeMultiplier; dust.noGravity = true; dust.position.X = projectile.Center.X; dust.position.Y = projectile.Center.Y; diff --git a/Projectiles/Ranged/ShockblastRound.cs b/Projectiles/Ranged/ShockblastRound.cs index 49454ec0c2..c6d3dc2f40 100644 --- a/Projectiles/Ranged/ShockblastRound.cs +++ b/Projectiles/Ranged/ShockblastRound.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class ShockblastRound : ModProjectile + public class ShockblastRound : ModProjectile { public override void SetStaticDefaults() { @@ -28,16 +28,16 @@ namespace CalamityMod.Projectiles.Ranged projectile.light = 0.5f; projectile.extraUpdates = 3; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override bool OnTileCollide(Vector2 oldVelocity) { - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, projectile.ai[1]); - Main.projectile[proj].scale = (projectile.ai[1] * 0.5f) + 1f; - } + if (projectile.owner == Main.myPlayer) + { + int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, projectile.ai[1]); + Main.projectile[proj].scale = (projectile.ai[1] * 0.5f) + 1f; + } return true; } @@ -53,33 +53,33 @@ namespace CalamityMod.Projectiles.Ranged 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; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - for (int num136 = 0; num136 < 2; num136++) - { - Vector2 dspeed = -projectile.velocity * Main.rand.NextFloat(0.5f, 0.7f); - float x2 = projectile.Center.X - projectile.velocity.X / 10f * num136; - float y2 = projectile.Center.Y - projectile.velocity.Y / 10f * num136; - int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 185, 0f, 0f, 0, default, 1f); - Main.dust[num137].alpha = projectile.alpha; - Main.dust[num137].position.X = x2; - Main.dust[num137].position.Y = y2; - Main.dust[num137].velocity = dspeed; - Main.dust[num137].noGravity = true; - } - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + for (int num136 = 0; num136 < 2; num136++) + { + Vector2 dspeed = -projectile.velocity * Main.rand.NextFloat(0.5f, 0.7f); + float x2 = projectile.Center.X - projectile.velocity.X / 10f * num136; + float y2 = projectile.Center.Y - projectile.velocity.Y / 10f * num136; + int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 185, 0f, 0f, 0, default, 1f); + Main.dust[num137].alpha = projectile.alpha; + Main.dust[num137].position.X = x2; + Main.dust[num137].position.Y = y2; + Main.dust[num137].velocity = dspeed; + Main.dust[num137].noGravity = true; + } + } return false; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, projectile.ai[1]); - Main.projectile[proj].scale = (projectile.ai[1] * 0.5f) + 1f; - } + if (projectile.owner == Main.myPlayer) + { + int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, projectile.ai[1]); + Main.projectile[proj].scale = (projectile.ai[1] * 0.5f) + 1f; + } if (Main.player[projectile.owner].moonLeech) return; @@ -91,10 +91,10 @@ namespace CalamityMod.Projectiles.Ranged if (Main.player[Main.myPlayer].lifeSteal <= 0f) return; - if (healAmt > CalamityMod.lifeStealCap) - healAmt = CalamityMod.lifeStealCap; + if (healAmt > CalamityMod.lifeStealCap) + healAmt = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); } } } diff --git a/Projectiles/Ranged/Shroom.cs b/Projectiles/Ranged/Shroom.cs index af7968804e..af2a730d4f 100644 --- a/Projectiles/Ranged/Shroom.cs +++ b/Projectiles/Ranged/Shroom.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class Shroom : ModProjectile + public class Shroom : ModProjectile { public override void SetStaticDefaults() { @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Ranged { Lighting.AddLight(projectile.Center, 0f, 0.2f, 0.6f); projectile.rotation += 1f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/SicknessRound.cs b/Projectiles/Ranged/SicknessRound.cs index 7d2e791664..9938e6d6c1 100644 --- a/Projectiles/Ranged/SicknessRound.cs +++ b/Projectiles/Ranged/SicknessRound.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class SicknessRound : ModProjectile + public class SicknessRound : ModProjectile { public override void SetStaticDefaults() { @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.light = 0.25f; projectile.extraUpdates = 4; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -38,19 +38,19 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreAI() { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - Vector2 dspeed = -projectile.velocity * 0.5f; - float x2 = projectile.Center.X - projectile.velocity.X / 10f; - float y2 = projectile.Center.Y - projectile.velocity.Y / 10f; - int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 107, dspeed.X, dspeed.Y, 0, default, 1f); - Main.dust[num137].alpha = projectile.alpha; - Main.dust[num137].position.X = x2; - Main.dust[num137].position.Y = y2; - Main.dust[num137].velocity = dspeed; - Main.dust[num137].noGravity = true; - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + Vector2 dspeed = -projectile.velocity * 0.5f; + float x2 = projectile.Center.X - projectile.velocity.X / 10f; + float y2 = projectile.Center.Y - projectile.velocity.Y / 10f; + int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 107, dspeed.X, dspeed.Y, 0, default, 1f); + Main.dust[num137].alpha = projectile.alpha; + Main.dust[num137].position.X = x2; + Main.dust[num137].position.Y = y2; + Main.dust[num137].velocity = dspeed; + Main.dust[num137].noGravity = true; + } //Rotation projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); diff --git a/Projectiles/Ranged/SicknessRound2.cs b/Projectiles/Ranged/SicknessRound2.cs index 7873f805f4..77a3174d5b 100644 --- a/Projectiles/Ranged/SicknessRound2.cs +++ b/Projectiles/Ranged/SicknessRound2.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class SicknessRound2 : ModProjectile + public class SicknessRound2 : ModProjectile { public override void SetStaticDefaults() { @@ -29,9 +29,9 @@ namespace CalamityMod.Projectiles.Ranged aiType = ProjectileID.WoodenArrowFriendly; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; @@ -53,10 +53,10 @@ namespace CalamityMod.Projectiles.Ranged 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; - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 25f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 25f); - return false; + return false; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/SlagRound.cs b/Projectiles/Ranged/SlagRound.cs index 7f6f4603d7..c077e904de 100644 --- a/Projectiles/Ranged/SlagRound.cs +++ b/Projectiles/Ranged/SlagRound.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Projectiles.Ranged public override void SetStaticDefaults() { DisplayName.SetDefault("Round"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } public override void SetDefaults() { @@ -25,30 +25,30 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = 1; projectile.aiStyle = 1; - projectile.extraUpdates = 3; + projectile.extraUpdates = 3; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - Vector2 dspeed = -projectile.velocity * 0.7f; - int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 32, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity = dspeed; - } + if (projectile.localAI[0] > 4f) + { + Vector2 dspeed = -projectile.velocity * 0.7f; + int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 32, 0f, 0f, 100, default, 1f); + Main.dust[num469].noGravity = true; + Main.dust[num469].velocity = dspeed; + } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Ranged/SmallCoral.cs b/Projectiles/Ranged/SmallCoral.cs index f8350d0b1b..0bddc359e4 100644 --- a/Projectiles/Ranged/SmallCoral.cs +++ b/Projectiles/Ranged/SmallCoral.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class SmallCoral : ModProjectile + public class SmallCoral : ModProjectile { public override void SetStaticDefaults() { @@ -19,16 +19,16 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = 1; projectile.aiStyle = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { projectile.velocity.X *= 0.9995f; projectile.velocity.Y = projectile.velocity.Y + 0.01f; - projectile.rotation = projectile.velocity.ToRotation(); - if (projectile.direction == -1) - projectile.rotation += MathHelper.Pi; + projectile.rotation = projectile.velocity.ToRotation(); + if (projectile.direction == -1) + projectile.rotation += MathHelper.Pi; } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/SparkSpreaderFire.cs b/Projectiles/Ranged/SparkSpreaderFire.cs index 426d91b0ff..cb5409c373 100644 --- a/Projectiles/Ranged/SparkSpreaderFire.cs +++ b/Projectiles/Ranged/SparkSpreaderFire.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class SparkSpreaderFire : ModProjectile + public class SparkSpreaderFire : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -57,26 +57,26 @@ namespace CalamityMod.Projectiles.Ranged } projectile.ai[0] += 1f; int dustType = DustID.Fire; - for (int i = 0; i < 2; i++) - { - int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 10, default, 0.75f); - Dust dust = Main.dust[fire]; - if (Main.rand.Next(3) == 0) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.noGravity = true; - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= dustScaleSize; - dust.velocity += projectile.velocity; + for (int i = 0; i < 2; i++) + { + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 10, default, 0.75f); + Dust dust = Main.dust[fire]; + if (Main.rand.Next(3) == 0) + { + dust.noGravity = true; + dust.scale *= 1.75f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.noGravity = true; + dust.scale *= 0.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= dustScaleSize; + dust.velocity += projectile.velocity; } } @@ -88,8 +88,8 @@ namespace CalamityMod.Projectiles.Ranged target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); } - public override void OnHitPvp(Player target, int damage, bool crit) - { + public override void OnHitPvp(Player target, int damage, bool crit) + { target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); } } diff --git a/Projectiles/Ranged/SporeBomb.cs b/Projectiles/Ranged/SporeBomb.cs index e31407c09b..fe01e47791 100644 --- a/Projectiles/Ranged/SporeBomb.cs +++ b/Projectiles/Ranged/SporeBomb.cs @@ -84,14 +84,14 @@ namespace CalamityMod.Projectiles.Ranged { for (int s = 0; s < sporeAmt; s++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int proj = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.SporeGas + Main.rand.Next(3), (int)(projectile.damage * 0.25), 0f, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().forceRanged = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 30; - } + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceRanged = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 30; + } } } } diff --git a/Projectiles/Ranged/SputterCometBig.cs b/Projectiles/Ranged/SputterCometBig.cs index c5df85cf7c..29b9ef17d2 100644 --- a/Projectiles/Ranged/SputterCometBig.cs +++ b/Projectiles/Ranged/SputterCometBig.cs @@ -8,7 +8,7 @@ using CalamityMod.Dusts; namespace CalamityMod.Projectiles.Ranged { - public class SputterCometBig : ModProjectile + public class SputterCometBig : ModProjectile { public override void SetStaticDefaults() { @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = 1; projectile.timeLeft = 600; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; aiType = ProjectileID.Bullet; } @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item9, projectile.position); } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 150f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -68,8 +68,8 @@ namespace CalamityMod.Projectiles.Ranged if (projectile.owner == Main.myPlayer) { int flash = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); - Main.projectile[flash].usesLocalNPCImmunity = true; - Main.projectile[flash].localNPCHitCooldown = 10; + Main.projectile[flash].usesLocalNPCImmunity = true; + Main.projectile[flash].localNPCHitCooldown = 10; } for (int k = 0; k < 5; k++) { diff --git a/Projectiles/Ranged/SpykerProj.cs b/Projectiles/Ranged/SpykerProj.cs index c483466e74..8839bfb3b4 100644 --- a/Projectiles/Ranged/SpykerProj.cs +++ b/Projectiles/Ranged/SpykerProj.cs @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int p = 0; p < 3; p++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, projectile.owner); } } diff --git a/Projectiles/Ranged/StarfleetMK2Gun.cs b/Projectiles/Ranged/StarfleetMK2Gun.cs index 81183bda4e..ce44e99b01 100644 --- a/Projectiles/Ranged/StarfleetMK2Gun.cs +++ b/Projectiles/Ranged/StarfleetMK2Gun.cs @@ -99,22 +99,22 @@ namespace CalamityMod.Projectiles.Ranged float variation = (1f + projectile.localAI[0]) * 3f; Vector2 position = playerPosition + Utils.RandomVector2(Main.rand, -variation, variation); Vector2 speed = projectile.velocity * shootSpeed * Main.rand.NextFloat(0.6f, 1.2f); - type = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ProjectileID.Starfury - }); + type = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ProjectileID.Starfury + }); int star = Projectile.NewProjectile(position, speed, type, damage, knockBack, projectile.owner); - if (star.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[star].penetrate = 1; - Main.projectile[star].timeLeft = 300; - Main.projectile[star].Calamity().forceRanged = true; - Main.projectile[star].netUpdate = true; - } + if (star.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[star].penetrate = 1; + Main.projectile[star].timeLeft = 300; + Main.projectile[star].Calamity().forceRanged = true; + Main.projectile[star].netUpdate = true; + } projectile.netUpdate = true; } } diff --git a/Projectiles/Ranged/SuperballBulletProj.cs b/Projectiles/Ranged/SuperballBulletProj.cs index 51d6be2175..2799dfd6cc 100644 --- a/Projectiles/Ranged/SuperballBulletProj.cs +++ b/Projectiles/Ranged/SuperballBulletProj.cs @@ -26,22 +26,22 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 600; projectile.extraUpdates = 1; aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - if (Main.rand.NextBool(3)) - { - int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 87, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; - } - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + if (Main.rand.NextBool(3)) + { + int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 87, 0f, 0f, 0, default, 0.5f); + Main.dust[num137].alpha = projectile.alpha; + Main.dust[num137].velocity *= 0f; + Main.dust[num137].noGravity = true; + } + } } public override bool OnTileCollide(Vector2 oldVelocity) @@ -58,8 +58,8 @@ namespace CalamityMod.Projectiles.Ranged if (projectile.velocity.Y != oldVelocity.Y) projectile.velocity.Y = -oldVelocity.Y; - if (projectile.extraUpdates < 5) - projectile.extraUpdates++; + if (projectile.extraUpdates < 5) + projectile.extraUpdates++; Main.PlaySound(SoundID.Item10, projectile.position); } diff --git a/Projectiles/Ranged/SurgeDriverHoldout.cs b/Projectiles/Ranged/SurgeDriverHoldout.cs index 31a82bbe48..463423cf42 100644 --- a/Projectiles/Ranged/SurgeDriverHoldout.cs +++ b/Projectiles/Ranged/SurgeDriverHoldout.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class SurgeDriverHoldout : ModProjectile + public class SurgeDriverHoldout : ModProjectile { public Player Owner => Main.player[projectile.owner]; public bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed; @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Ranged } public void ShootProjectiles(Vector2 armPosition) - { + { if (Main.myPlayer != projectile.owner) return; @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Ranged } public void ManipulatePlayerVariables() - { + { Owner.ChangeDir(projectile.direction); Owner.heldProj = projectile.whoAmI; Owner.itemTime = 2; diff --git a/Projectiles/Ranged/TelluricGlareArrow.cs b/Projectiles/Ranged/TelluricGlareArrow.cs index 7644f7eff0..523307b605 100644 --- a/Projectiles/Ranged/TelluricGlareArrow.cs +++ b/Projectiles/Ranged/TelluricGlareArrow.cs @@ -41,8 +41,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 2; // Can hit up to two enemies. Will explode extremely soon after hitting the first, though. projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override bool CanDamage() => projectile.timeLeft < Lifetime - 4; diff --git a/Projectiles/Ranged/TerraArrowMain.cs b/Projectiles/Ranged/TerraArrowMain.cs index 566a8b1df1..4d7d18cab1 100644 --- a/Projectiles/Ranged/TerraArrowMain.cs +++ b/Projectiles/Ranged/TerraArrowMain.cs @@ -4,11 +4,11 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class TerraArrowMain : ModProjectile + public class TerraArrowMain : ModProjectile { public override string Texture => "CalamityMod/Items/Ammo/TerraArrow"; - private bool initialized = false; + private bool initialized = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Arrow"); @@ -23,31 +23,31 @@ namespace CalamityMod.Projectiles.Ranged projectile.arrow = true; projectile.penetrate = 1; projectile.timeLeft = 600; - projectile.extraUpdates = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.extraUpdates = 1; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { - if (!initialized) - { - projectile.velocity *= 0.5f; - initialized = true; - } - if (projectile.FinalExtraUpdate() && initialized) - { - projectile.velocity *= 1.003f; - if (projectile.velocity.Length() >= 22f) - { - projectile.Kill(); - } - } + if (!initialized) + { + projectile.velocity *= 0.5f; + initialized = true; + } + if (projectile.FinalExtraUpdate() && initialized) + { + projectile.velocity *= 1.003f; + if (projectile.velocity.Length() >= 22f) + { + projectile.Kill(); + } + } projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; } public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); Main.PlaySound(SoundID.Item60, projectile.Center); for (int d = 0; d < 3; d++) { @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int a = 0; a < 2; a++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); } } diff --git a/Projectiles/Ranged/TerraArrowSplit.cs b/Projectiles/Ranged/TerraArrowSplit.cs index 6f55da4f09..87ed765170 100644 --- a/Projectiles/Ranged/TerraArrowSplit.cs +++ b/Projectiles/Ranged/TerraArrowSplit.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class TerraArrowSplit : ModProjectile + public class TerraArrowSplit : ModProjectile { public override string Texture => "CalamityMod/Items/Ammo/TerraArrow"; @@ -26,15 +26,15 @@ namespace CalamityMod.Projectiles.Ranged projectile.aiStyle = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.alpha -= 5; projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; - if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 20f); + if (projectile.timeLeft < 90) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/TerraBulletMain.cs b/Projectiles/Ranged/TerraBulletMain.cs index 5a5ab84689..db8117a890 100644 --- a/Projectiles/Ranged/TerraBulletMain.cs +++ b/Projectiles/Ranged/TerraBulletMain.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class TerraBulletMain : ModProjectile + public class TerraBulletMain : ModProjectile { public override void SetStaticDefaults() { @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 600; projectile.alpha = 255; projectile.extraUpdates = 3; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/TerraBulletSplit.cs b/Projectiles/Ranged/TerraBulletSplit.cs index a18dda526c..729253a2e8 100644 --- a/Projectiles/Ranged/TerraBulletSplit.cs +++ b/Projectiles/Ranged/TerraBulletSplit.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Projectiles.Ranged { public class TerraBulletSplit : ModProjectile { - private float speed = 0f; + private float speed = 0f; public override void SetStaticDefaults() { DisplayName.SetDefault("Bullet"); @@ -31,15 +31,15 @@ namespace CalamityMod.Projectiles.Ranged aiType = ProjectileID.Bullet; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); + return false; + } - public override void AI() + public override void AI() { projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; if (projectile.alpha > 0) @@ -55,11 +55,11 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[num137].velocity *= 0f; Main.dust[num137].noGravity = true; - if (speed == 0f) - speed = projectile.velocity.Length(); + if (speed == 0f) + speed = projectile.velocity.Length(); - if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, speed, 12f); - } + if (projectile.timeLeft < 90) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, speed, 12f); + } } } diff --git a/Projectiles/Ranged/TerraFireGreen2.cs b/Projectiles/Ranged/TerraFireGreen2.cs index 93089801ea..8b502dc371 100644 --- a/Projectiles/Ranged/TerraFireGreen2.cs +++ b/Projectiles/Ranged/TerraFireGreen2.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class TerraFireGreen2 : ModProjectile + public class TerraFireGreen2 : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Ranged/ThePackMinissile.cs b/Projectiles/Ranged/ThePackMinissile.cs index 13726bb8e2..f05dfe1431 100644 --- a/Projectiles/Ranged/ThePackMinissile.cs +++ b/Projectiles/Ranged/ThePackMinissile.cs @@ -21,13 +21,13 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = 1; projectile.timeLeft = 300; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 15f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 15f); projectile.frameCounter++; if (projectile.frameCounter > 3) { diff --git a/Projectiles/Ranged/ThePackMissile.cs b/Projectiles/Ranged/ThePackMissile.cs index bf1b72900d..6d59abf800 100644 --- a/Projectiles/Ranged/ThePackMissile.cs +++ b/Projectiles/Ranged/ThePackMissile.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.ranged = true; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; diff --git a/Projectiles/Ranged/TorrentialArrow.cs b/Projectiles/Ranged/TorrentialArrow.cs index 4ca8bb805d..e248f291a1 100644 --- a/Projectiles/Ranged/TorrentialArrow.cs +++ b/Projectiles/Ranged/TorrentialArrow.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.arrow = true; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/ToxicArrow.cs b/Projectiles/Ranged/ToxicArrow.cs index 301b12fc77..0ad3ea756e 100644 --- a/Projectiles/Ranged/ToxicArrow.cs +++ b/Projectiles/Ranged/ToxicArrow.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.arrow = true; projectile.penetrate = 1; projectile.timeLeft = 240; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage /= 2; + projectile.damage /= 2; projectile.Damage(); Main.PlaySound(SoundID.Item92, projectile.position); int count = Main.rand.Next(6, 15); @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/Ranged/ToxicannonDrop.cs b/Projectiles/Ranged/ToxicannonDrop.cs index d86a12b2a0..11d33e414c 100644 --- a/Projectiles/Ranged/ToxicannonDrop.cs +++ b/Projectiles/Ranged/ToxicannonDrop.cs @@ -53,9 +53,9 @@ namespace CalamityMod.Projectiles.Ranged return true; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Ranged/ToxicannonShot.cs b/Projectiles/Ranged/ToxicannonShot.cs index efe305cda5..99d9e78d04 100644 --- a/Projectiles/Ranged/ToxicannonShot.cs +++ b/Projectiles/Ranged/ToxicannonShot.cs @@ -45,13 +45,13 @@ namespace CalamityMod.Projectiles.Ranged } } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 240); } public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 180); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 180); projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.damage /= 2; diff --git a/Projectiles/Ranged/TriploonProj.cs b/Projectiles/Ranged/TriploonProj.cs index 878a4b1c23..1f13c758a4 100644 --- a/Projectiles/Ranged/TriploonProj.cs +++ b/Projectiles/Ranged/TriploonProj.cs @@ -20,13 +20,13 @@ namespace CalamityMod.Projectiles.Ranged projectile.alpha = 255; projectile.ranged = true; projectile.extraUpdates = 0; - projectile.timeLeft = 300; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.timeLeft = 300; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (player.dead) { projectile.Kill(); @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Ranged { projectile.extraUpdates = 1; } - Vector2 playerVector = player.Center - projectile.Center; + Vector2 playerVector = player.Center - projectile.Center; float playerDist = playerVector.Length(); if (projectile.ai[0] == 0f) { diff --git a/Projectiles/Ranged/TyphoonArrow.cs b/Projectiles/Ranged/TyphoonArrow.cs index 4f0b0b9f22..91321016d3 100644 --- a/Projectiles/Ranged/TyphoonArrow.cs +++ b/Projectiles/Ranged/TyphoonArrow.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.aiStyle = 1; projectile.timeLeft = 600; aiType = ProjectileID.WoodenArrowFriendly; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Ranged/TyphoonBubble.cs b/Projectiles/Ranged/TyphoonBubble.cs index 781f1215e0..b8a7482aba 100644 --- a/Projectiles/Ranged/TyphoonBubble.cs +++ b/Projectiles/Ranged/TyphoonBubble.cs @@ -112,16 +112,16 @@ namespace CalamityMod.Projectiles.Ranged { if (projectile.ai[1] < 1f) { - if (projectile.localAI[1] == 1f) - { - int num230 = Projectile.NewProjectile(projectile.Center.X - (float)(projectile.direction * 30), projectile.Center.Y - 4f, (float)-(float)projectile.direction * 0.01f, 0f, ModContent.ProjectileType(), projectile.damage, 3f, projectile.owner, 16f, 8f); - Main.projectile[num230].netUpdate = true; - } - else - { - int num230 = Projectile.NewProjectile(projectile.Center.X - (float)(projectile.direction * 30), projectile.Center.Y - 4f, (float)-(float)projectile.direction * 0.01f, 0f, ModContent.ProjectileType(), projectile.damage, 3f, projectile.owner, 16f, 8f); - Main.projectile[num230].netUpdate = true; - } + if (projectile.localAI[1] == 1f) + { + int num230 = Projectile.NewProjectile(projectile.Center.X - (float)(projectile.direction * 30), projectile.Center.Y - 4f, (float)-(float)projectile.direction * 0.01f, 0f, ModContent.ProjectileType(), projectile.damage, 3f, projectile.owner, 16f, 8f); + Main.projectile[num230].netUpdate = true; + } + else + { + int num230 = Projectile.NewProjectile(projectile.Center.X - (float)(projectile.direction * 30), projectile.Center.Y - 4f, (float)-(float)projectile.direction * 0.01f, 0f, ModContent.ProjectileType(), projectile.damage, 3f, projectile.owner, 16f, 8f); + Main.projectile[num230].netUpdate = true; + } } } } diff --git a/Projectiles/Ranged/UltimaBolt.cs b/Projectiles/Ranged/UltimaBolt.cs index cc4ac59014..fc8b096d84 100644 --- a/Projectiles/Ranged/UltimaBolt.cs +++ b/Projectiles/Ranged/UltimaBolt.cs @@ -31,8 +31,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.arrow = true; projectile.penetrate = 1; projectile.timeLeft = 300; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/UniversalGenesisStar.cs b/Projectiles/Ranged/UniversalGenesisStar.cs index 87e6131f5c..1ab855b0d1 100644 --- a/Projectiles/Ranged/UniversalGenesisStar.cs +++ b/Projectiles/Ranged/UniversalGenesisStar.cs @@ -8,136 +8,136 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class UniversalGenesisStar : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Star"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public class UniversalGenesisStar : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Star"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 22; - projectile.height = 20; - projectile.friendly = true; - projectile.ranged = true; - projectile.alpha = 50; - projectile.tileCollide = false; - projectile.penetrate = 5; - projectile.timeLeft = 180; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - } + public override void SetDefaults() + { + projectile.width = 22; + projectile.height = 20; + projectile.friendly = true; + projectile.ranged = true; + projectile.alpha = 50; + projectile.tileCollide = false; + projectile.penetrate = 5; + projectile.timeLeft = 180; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } - public override void AI() - { - if (projectile.soundDelay == 0 && projectile.ai[0] == 0f) - { - projectile.soundDelay = 20 + Main.rand.Next(40); - if (Main.rand.NextBool(5)) - { - Main.PlaySound(SoundID.Item9, projectile.position); - } - } - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * projectile.direction; - if (Main.rand.NextBool(48)) - { - int idx = Gore.NewGore(projectile.Center, projectile.velocity * 0.2f, 16, 1f); - Main.gore[idx].velocity *= 0.66f; - Main.gore[idx].velocity += projectile.velocity * 0.3f; - } - if (Main.rand.NextBool(10)) - { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 173, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 150, default, 1.2f); - } - if (Main.rand.NextBool(20)) - { - Gore.NewGore(projectile.position, new Vector2(projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f), Main.rand.Next(16, 18), 1f); - } - } + public override void AI() + { + if (projectile.soundDelay == 0 && projectile.ai[0] == 0f) + { + projectile.soundDelay = 20 + Main.rand.Next(40); + if (Main.rand.NextBool(5)) + { + Main.PlaySound(SoundID.Item9, projectile.position); + } + } + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * projectile.direction; + if (Main.rand.NextBool(48)) + { + int idx = Gore.NewGore(projectile.Center, projectile.velocity * 0.2f, 16, 1f); + Main.gore[idx].velocity *= 0.66f; + Main.gore[idx].velocity += projectile.velocity * 0.3f; + } + if (Main.rand.NextBool(10)) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 173, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 150, default, 1.2f); + } + if (Main.rand.NextBool(20)) + { + Gore.NewGore(projectile.position, new Vector2(projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f), Main.rand.Next(16, 18), 1f); + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 200, 200, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(200, 200, 200, projectile.alpha); + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.ai[1] == 1f) - { - Texture2D tex = Main.projectileTexture[projectile.type]; - Vector2 offsets = new Vector2(0f, projectile.gfxOffY) - Main.screenPosition; - Color alpha = projectile.GetAlpha(lightColor); - Rectangle spriteRec = new Microsoft.Xna.Framework.Rectangle(0, 0, tex.Width, tex.Height); - Vector2 spriteOrigin = spriteRec.Size() / 2f; - SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + if (projectile.ai[1] == 1f) + { + Texture2D tex = Main.projectileTexture[projectile.type]; + Vector2 offsets = new Vector2(0f, projectile.gfxOffY) - Main.screenPosition; + Color alpha = projectile.GetAlpha(lightColor); + Rectangle spriteRec = new Microsoft.Xna.Framework.Rectangle(0, 0, tex.Width, tex.Height); + Vector2 spriteOrigin = spriteRec.Size() / 2f; + SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D aura = ModContent.GetTexture("CalamityMod/Projectiles/Ranged/FallenStarAura"); - Vector2 drawStart = projectile.Center + projectile.velocity; - Vector2 drawStart2 = projectile.Center - projectile.velocity * 0.5f; - Vector2 spinPoint = new Vector2(0f, -10f); - float time = Main.player[projectile.owner].miscCounter % 216000f / 60f; - Rectangle auraRec = aura.Frame(); - Color blue = Color.Blue * 0.2f; - Color white = Color.White * 0.5f; - white.A = 0; - blue.A = 0; - Vector2 auraOrigin = new Vector2(auraRec.Width / 2f, 10f); + Texture2D aura = ModContent.GetTexture("CalamityMod/Projectiles/Ranged/FallenStarAura"); + Vector2 drawStart = projectile.Center + projectile.velocity; + Vector2 drawStart2 = projectile.Center - projectile.velocity * 0.5f; + Vector2 spinPoint = new Vector2(0f, -10f); + float time = Main.player[projectile.owner].miscCounter % 216000f / 60f; + Rectangle auraRec = aura.Frame(); + Color blue = Color.Blue * 0.2f; + Color white = Color.White * 0.5f; + white.A = 0; + blue.A = 0; + Vector2 auraOrigin = new Vector2(auraRec.Width / 2f, 10f); - //Draw the aura - spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.5f, SpriteEffects.None, 0); - spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time + MathHelper.TwoPi / 3f), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.1f, SpriteEffects.None, 0); - spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time + MathHelper.Pi * 4f / 3f), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.3f, SpriteEffects.None, 0); - for (float d = 0f; d < 1f; d += 0.5f) - { - float scaleMult = time % 0.5f / 0.5f; - scaleMult = (scaleMult + d) % 1f; - float colorMult = scaleMult * 2f; - if (colorMult > 1f) - { - colorMult = 2f - colorMult; - } - spriteBatch.Draw(aura, drawStart2 + offsets, auraRec, white * colorMult, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 0.3f + scaleMult * 0.5f, SpriteEffects.None, 0); - } - } + //Draw the aura + spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.5f, SpriteEffects.None, 0); + spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time + MathHelper.TwoPi / 3f), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.1f, SpriteEffects.None, 0); + spriteBatch.Draw(aura, drawStart + offsets + spinPoint.RotatedBy(MathHelper.TwoPi * time + MathHelper.Pi * 4f / 3f), auraRec, blue, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 1.3f, SpriteEffects.None, 0); + for (float d = 0f; d < 1f; d += 0.5f) + { + float scaleMult = time % 0.5f / 0.5f; + scaleMult = (scaleMult + d) % 1f; + float colorMult = scaleMult * 2f; + if (colorMult > 1f) + { + colorMult = 2f - colorMult; + } + spriteBatch.Draw(aura, drawStart2 + offsets, auraRec, white * colorMult, projectile.velocity.ToRotation() + MathHelper.PiOver2, auraOrigin, 0.3f + scaleMult * 0.5f, SpriteEffects.None, 0); + } + } - //Draw the actual projectile - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + //Draw the actual projectile + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } - public override void Kill(int timeLeft) - { - projectile.position += projectile.Size; - projectile.width = 50; - projectile.height = 50; - projectile.position -= projectile.Size; - for (int i = 0; i < 5; i++) - { - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 16, 0f, 0f, 100, default, 1.2f); - Main.dust[idx].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[idx].scale = 0.5f; - Main.dust[idx].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int i = 0; i < 3; i++) - { - Gore.NewGore(projectile.position, projectile.velocity * 0.05f, Main.rand.Next(16, 18), 1f); - } - } - } + public override void Kill(int timeLeft) + { + projectile.position += projectile.Size; + projectile.width = 50; + projectile.height = 50; + projectile.position -= projectile.Size; + for (int i = 0; i < 5; i++) + { + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 16, 0f, 0f, 100, default, 1.2f); + Main.dust[idx].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[idx].scale = 0.5f; + Main.dust[idx].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int i = 0; i < 3; i++) + { + Gore.NewGore(projectile.position, projectile.velocity * 0.05f, Main.rand.Next(16, 18), 1f); + } + } + } } diff --git a/Projectiles/Ranged/UniversalGenesisStarcaller.cs b/Projectiles/Ranged/UniversalGenesisStarcaller.cs index 991b92addc..386054613a 100644 --- a/Projectiles/Ranged/UniversalGenesisStarcaller.cs +++ b/Projectiles/Ranged/UniversalGenesisStarcaller.cs @@ -6,129 +6,129 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class UniversalGenesisStarcaller : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Starcaller Shot"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public class UniversalGenesisStarcaller : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Starcaller Shot"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 18; - projectile.height = 18; - projectile.aiStyle = 1; - projectile.friendly = true; - projectile.ranged = true; - projectile.timeLeft = 600; - projectile.extraUpdates = 1; - aiType = ProjectileID.Bullet; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + public override void SetDefaults() + { + projectile.width = 18; + projectile.height = 18; + projectile.aiStyle = 1; + projectile.friendly = true; + projectile.ranged = true; + projectile.timeLeft = 600; + projectile.extraUpdates = 1; + aiType = ProjectileID.Bullet; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0.23f, 0.19f, 0.25f); + public override void AI() + { + Lighting.AddLight(projectile.Center, 0.23f, 0.19f, 0.25f); - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - if (Main.rand.NextBool(2)) - { - int idx = Dust.NewDust(projectile.position, 1, 1, 173, 0f, 0f, 0, default, 0.5f); - Main.dust[idx].alpha = projectile.alpha; - Main.dust[idx].velocity *= 0f; - Main.dust[idx].noGravity = true; - } - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + if (Main.rand.NextBool(2)) + { + int idx = Dust.NewDust(projectile.position, 1, 1, 173, 0f, 0f, 0, default, 0.5f); + Main.dust[idx].alpha = projectile.alpha; + Main.dust[idx].velocity *= 0f; + Main.dust[idx].noGravity = true; + } + } - projectile.rotation = projectile.velocity.ToRotation(); + projectile.rotation = projectile.velocity.ToRotation(); - projectile.frameCounter++; - if (projectile.frameCounter > 3) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } - } + projectile.frameCounter++; + if (projectile.frameCounter > 3) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); - Main.PlaySound(SoundID.Item11.WithPitchVariance(0.05f), projectile.Center); - return true; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); + Main.PlaySound(SoundID.Item11.WithPitchVariance(0.05f), projectile.Center); + return true; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); + return false; + } - // This projectile is always fullbright. - public override Color? GetAlpha(Color lightColor) => new Color(1f, 1f, 1f, 0f); + // This projectile is always fullbright. + public override Color? GetAlpha(Color lightColor) => new Color(1f, 1f, 1f, 0f); - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.Frostburn, 300); - SpawnStars(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Frostburn, 300); + SpawnStars(); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.Frostburn, 300); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Frostburn, 300); + } - private void SpawnStars() - { - // The patron said 10 blocks, but 10 blocks is like nothing... I'm sure they won't mind. - int maxDistance = 480; // 30 blocks - bool bossFound = false; - int life = 0; - Vector2 targetVec = projectile.Center; - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (bossFound && !npc.IsABoss()) - continue; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - if (targetDist < (maxDistance + extraDist) && (npc.IsABoss() || npc.life > life)) - { - if (npc.IsABoss()) - bossFound = true; - life = npc.life; - targetVec = npc.Center; - } - } - } - for (int n = 0; n < 2; n++) - { - Projectile star = CalamityUtils.ProjectileRain(targetVec, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack, projectile.owner); - star.ai[0] = n; - } - } + private void SpawnStars() + { + // The patron said 10 blocks, but 10 blocks is like nothing... I'm sure they won't mind. + int maxDistance = 480; // 30 blocks + bool bossFound = false; + int life = 0; + Vector2 targetVec = projectile.Center; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (bossFound && !npc.IsABoss()) + continue; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + //Calculate distance between target and the projectile to know if it's too far or not + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (targetDist < (maxDistance + extraDist) && (npc.IsABoss() || npc.life > life)) + { + if (npc.IsABoss()) + bossFound = true; + life = npc.life; + targetVec = npc.Center; + } + } + } + for (int n = 0; n < 2; n++) + { + Projectile star = CalamityUtils.ProjectileRain(targetVec, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack, projectile.owner); + star.ai[0] = n; + } + } - public override void Kill(int timeLeft) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 173, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); - } - for (int g = 0; g < 3; g++) - { - Gore.NewGore(projectile.position, new Vector2(projectile.velocity.X * 0.05f, projectile.velocity.Y * 0.05f), Main.rand.Next(16, 18), 1f); - } - } - } + public override void Kill(int timeLeft) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 173, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); + } + for (int g = 0; g < 3; g++) + { + Gore.NewGore(projectile.position, new Vector2(projectile.velocity.X * 0.05f, projectile.velocity.Y * 0.05f), Main.rand.Next(16, 18), 1f); + } + } + } } diff --git a/Projectiles/Ranged/VanquisherArrowMain.cs b/Projectiles/Ranged/VanquisherArrowMain.cs index e47b3b3c46..87cf532b57 100644 --- a/Projectiles/Ranged/VanquisherArrowMain.cs +++ b/Projectiles/Ranged/VanquisherArrowMain.cs @@ -6,7 +6,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class VanquisherArrowMain : ModProjectile + public class VanquisherArrowMain : ModProjectile { public override string Texture => "CalamityMod/Items/Ammo/VanquisherArrow"; @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 1; projectile.timeLeft = 90; projectile.extraUpdates = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/VeriumBulletProj.cs b/Projectiles/Ranged/VeriumBulletProj.cs index 8a2b121bb2..63855af248 100644 --- a/Projectiles/Ranged/VeriumBulletProj.cs +++ b/Projectiles/Ranged/VeriumBulletProj.cs @@ -6,137 +6,137 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class VeriumBulletProj : ModProjectile - { - private float speed = 0f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Verium Bullet"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public class VeriumBulletProj : ModProjectile + { + private float speed = 0f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Verium Bullet"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 4; - projectile.height = 4; - projectile.aiStyle = 1; - projectile.friendly = true; - projectile.ranged = true; - projectile.penetrate = 2; - projectile.timeLeft = 600; - projectile.extraUpdates = 1; - aiType = ProjectileID.Bullet; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + public override void SetDefaults() + { + projectile.width = 4; + projectile.height = 4; + projectile.aiStyle = 1; + projectile.friendly = true; + projectile.ranged = true; + projectile.penetrate = 2; + projectile.timeLeft = 600; + projectile.extraUpdates = 1; + aiType = ProjectileID.Bullet; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); + return false; + } - public override bool PreAI() - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(90f); - projectile.spriteDirection = projectile.direction; + public override bool PreAI() + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(90f); + projectile.spriteDirection = projectile.direction; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - if (Main.rand.NextBool(2)) - { - int purple = Dust.NewDust(projectile.position, 1, 1, 70, 0f, 0f, 0, default, 0.5f); - Main.dust[purple].alpha = projectile.alpha; - Main.dust[purple].velocity *= 0f; - Main.dust[purple].noGravity = true; - } - } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > 4f) + { + if (Main.rand.NextBool(2)) + { + int purple = Dust.NewDust(projectile.position, 1, 1, 70, 0f, 0f, 0, default, 0.5f); + Main.dust[purple].alpha = projectile.alpha; + Main.dust[purple].velocity *= 0f; + Main.dust[purple].noGravity = true; + } + } - if (projectile.ai[0] > 0f) - projectile.ai[0]--; - if (speed == 0f) - speed = projectile.velocity.Length(); - if (projectile.penetrate == 1 && projectile.ai[0] <= 0f) - { - float inertia = 15f; - Vector2 center = projectile.Center; - float maxDistance = 300f; - bool homeIn = false; + if (projectile.ai[0] > 0f) + projectile.ai[0]--; + if (speed == 0f) + speed = projectile.velocity.Length(); + if (projectile.penetrate == 1 && projectile.ai[0] <= 0f) + { + float inertia = 15f; + Vector2 center = projectile.Center; + float maxDistance = 300f; + bool homeIn = false; - int targetIndex = (int)projectile.ai[1]; - NPC target = Main.npc[targetIndex]; - if (target.CanBeChasedBy(projectile, false)) - { - float extraDistance = (target.width / 2) + (target.height / 2); + int targetIndex = (int)projectile.ai[1]; + NPC target = Main.npc[targetIndex]; + if (target.CanBeChasedBy(projectile, false)) + { + float extraDistance = (target.width / 2) + (target.height / 2); - bool canHit = true; - if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, target.Center, 1, 1); + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, target.Center, 1, 1); - if (Vector2.Distance(target.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) - { - center = target.Center; - homeIn = true; - } - } + if (Vector2.Distance(target.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + { + center = target.Center; + homeIn = true; + } + } - if (!homeIn) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDistance = (npc.width / 2) + (npc.height / 2); + if (!homeIn) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); - bool canHit = true; - if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) - { - center = npc.Center; - homeIn = true; - break; - } - } - } - } + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + { + center = npc.Center; + homeIn = true; + break; + } + } + } + } - if (!projectile.friendly) - { - homeIn = false; - } + if (!projectile.friendly) + { + homeIn = false; + } - if (homeIn) - { - Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * inertia + moveDirection * speed) / (inertia + 1f); - } - return false; - } - return true; - } + if (homeIn) + { + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * inertia + moveDirection * speed) / (inertia + 1f); + } + return false; + } + return true; + } - public override bool? CanHitNPC(NPC target) => projectile.ai[0] <= 0f && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.ai[0] <= 0f && target.CanBeChasedBy(projectile); - public override bool CanHitPvp(Player target) => projectile.ai[0] <= 0f; + public override bool CanHitPvp(Player target) => projectile.ai[0] <= 0f; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - projectile.ai[0] = 10f; - projectile.damage /= 2; - if (target.life > 0) - projectile.ai[1] = target.whoAmI; - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + projectile.ai[0] = 10f; + projectile.damage /= 2; + if (target.life > 0) + projectile.ai[1] = target.whoAmI; + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - projectile.ai[0] = 10f; - projectile.damage /= 2; - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + projectile.ai[0] = 10f; + projectile.damage /= 2; + } + } } diff --git a/Projectiles/Ranged/VoidragonTentacle.cs b/Projectiles/Ranged/VoidragonTentacle.cs index b1c295ec0c..a8f34e1e8c 100644 --- a/Projectiles/Ranged/VoidragonTentacle.cs +++ b/Projectiles/Ranged/VoidragonTentacle.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class VoidragonTentacle : ModProjectile + public class VoidragonTentacle : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -26,9 +26,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.localNPCHitCooldown = 5; projectile.MaxUpdates = 3; projectile.ranged = true; - projectile.extraUpdates = 1; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; - } + projectile.extraUpdates = 1; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + } public override void AI() { diff --git a/Projectiles/Ranged/WaterSpout.cs b/Projectiles/Ranged/WaterSpout.cs index 40327e0c42..7d1e4ad356 100644 --- a/Projectiles/Ranged/WaterSpout.cs +++ b/Projectiles/Ranged/WaterSpout.cs @@ -25,9 +25,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = -1; projectile.alpha = 255; projectile.timeLeft = 60; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 10; - } + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 10; + } public override void AI() { diff --git a/Projectiles/Rogue/AbyssalMirrorProjectile.cs b/Projectiles/Rogue/AbyssalMirrorProjectile.cs index 0ca8a7e093..baa3ab48dd 100644 --- a/Projectiles/Rogue/AbyssalMirrorProjectile.cs +++ b/Projectiles/Rogue/AbyssalMirrorProjectile.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class AbyssalMirrorProjectile : ModProjectile + public class AbyssalMirrorProjectile : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Rogue/AccretionDisk2.cs b/Projectiles/Rogue/AccretionDisk2.cs index 8e667e716a..895b3f0cf6 100644 --- a/Projectiles/Rogue/AccretionDisk2.cs +++ b/Projectiles/Rogue/AccretionDisk2.cs @@ -7,60 +7,60 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class AccretionDisk2 : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/AccretionDisk"; + public class AccretionDisk2 : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/AccretionDisk"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Accretion Disk"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Accretion Disk"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 56; - projectile.height = 56; - projectile.alpha = 120; - projectile.ignoreWater = true; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.aiStyle = 3; - projectile.timeLeft = 60; - aiType = ProjectileID.WoodenBoomerang; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 56; + projectile.height = 56; + projectile.alpha = 120; + projectile.ignoreWater = true; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.aiStyle = 3; + projectile.timeLeft = 60; + aiType = ProjectileID.WoodenBoomerang; + projectile.Calamity().rogue = true; + } - public override void AI() - { - if (Main.rand.NextBool(10)) - { - int num250 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, projectile.direction * 2, 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.5f); - Main.dust[num250].noGravity = true; - Main.dust[num250].velocity *= 0f; - } - } + public override void AI() + { + if (Main.rand.NextBool(10)) + { + int num250 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, projectile.direction * 2, 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.5f); + Main.dust[num250].noGravity = true; + Main.dust[num250].velocity *= 0f; + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + return false; + } + } } diff --git a/Projectiles/Rogue/AccretionDiskProj.cs b/Projectiles/Rogue/AccretionDiskProj.cs index cf79c7d5b8..e2ebc3645a 100644 --- a/Projectiles/Rogue/AccretionDiskProj.cs +++ b/Projectiles/Rogue/AccretionDiskProj.cs @@ -8,44 +8,44 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class AccretionDiskProj : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/AccretionDisk"; + public class AccretionDiskProj : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/AccretionDisk"; private int Lifetime = 400; private int ReboundTime = 30; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Elemental Disk"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Elemental Disk"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 56; - projectile.height = 56; - projectile.ignoreWater = true; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 6; - projectile.penetrate = -1; - projectile.timeLeft = Lifetime; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 56; + projectile.height = 56; + projectile.ignoreWater = true; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + projectile.penetrate = -1; + projectile.timeLeft = Lifetime; + projectile.Calamity().rogue = true; + } - public override void AI() - { - SpawnProjectilesNearEnemies(); - BoomerangAI(); - LightingAndDust(); - } + public override void AI() + { + SpawnProjectilesNearEnemies(); + BoomerangAI(); + LightingAndDust(); + } - private void BoomerangAI() - { + private void BoomerangAI() + { // Boomerang rotation - projectile.rotation += 0.4f * projectile.direction; + projectile.rotation += 0.4f * projectile.direction; // Boomerang sound if (projectile.soundDelay == 0) @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Rogue } // Returns after some number of frames in the air - int timeMult = projectile.Calamity().stealthStrike ? 3 : 1; + int timeMult = projectile.Calamity().stealthStrike ? 3 : 1; if (projectile.timeLeft < Lifetime * timeMult - ReboundTime * timeMult) projectile.ai[0] = 1f; @@ -64,15 +64,15 @@ namespace CalamityMod.Projectiles.Rogue Player player = Main.player[projectile.owner]; float returnSpeed = 9f; float acceleration = 0.4f; - Vector2 playerVec = player.Center - projectile.Center; + Vector2 playerVec = player.Center - projectile.Center; float dist = playerVec.Length(); // Delete the projectile if it's excessively far away. if (dist > 3000f) projectile.Kill(); - playerVec.Normalize(); - playerVec *= returnSpeed; + playerVec.Normalize(); + playerVec *= returnSpeed; // Home back in on the player. if (projectile.velocity.X < playerVec.X) @@ -105,98 +105,98 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.Hitbox.Intersects(player.Hitbox)) projectile.Kill(); } - } + } - private void SpawnProjectilesNearEnemies() - { - if (!projectile.friendly) - return; + private void SpawnProjectilesNearEnemies() + { + if (!projectile.friendly) + return; - float maxDistance = 300f; - bool homeIn = false; + float maxDistance = 300f; + bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDistance = npc.width / 2 + npc.height / 2; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = npc.width / 2 + npc.height / 2; - bool canHit = true; - if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (Vector2.Distance(npc.Center, projectile.Center) < maxDistance + extraDistance && canHit) - { - homeIn = true; - break; - } - } - } + if (Vector2.Distance(npc.Center, projectile.Center) < maxDistance + extraDistance && canHit) + { + homeIn = true; + break; + } + } + } - if (homeIn) - { - int counter = projectile.Calamity().stealthStrike ? 35 : 50; - if (Main.player[projectile.owner].miscCounter % counter == 0) - { - int splitProj = ModContent.ProjectileType(); - if (projectile.owner == Main.myPlayer && Main.player[projectile.owner].ownedProjectileCounts[splitProj] < 25) - { - float spread = 45f * 0.0174f; - double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - double offsetAngle; - for (int i = 0; i < 4; i++) - { - offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - int disk = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage, projectile.knockBack, projectile.owner); - int disk2 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage, projectile.knockBack, projectile.owner); - if (projectile.Calamity().stealthStrike) - { - Main.projectile[disk].idStaticNPCHitCooldown = Main.projectile[disk2].idStaticNPCHitCooldown = 6; - Main.projectile[disk].usesIDStaticNPCImmunity = Main.projectile[disk2].usesIDStaticNPCImmunity = true; - Main.projectile[disk].timeLeft = Main.projectile[disk2].timeLeft = 90; - } - } - } - } - } - } + if (homeIn) + { + int counter = projectile.Calamity().stealthStrike ? 35 : 50; + if (Main.player[projectile.owner].miscCounter % counter == 0) + { + int splitProj = ModContent.ProjectileType(); + if (projectile.owner == Main.myPlayer && Main.player[projectile.owner].ownedProjectileCounts[splitProj] < 25) + { + float spread = 45f * 0.0174f; + double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; + double deltaAngle = spread / 8f; + double offsetAngle; + for (int i = 0; i < 4; i++) + { + offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; + int disk = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage, projectile.knockBack, projectile.owner); + int disk2 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage, projectile.knockBack, projectile.owner); + if (projectile.Calamity().stealthStrike) + { + Main.projectile[disk].idStaticNPCHitCooldown = Main.projectile[disk2].idStaticNPCHitCooldown = 6; + Main.projectile[disk].usesIDStaticNPCImmunity = Main.projectile[disk2].usesIDStaticNPCImmunity = true; + Main.projectile[disk].timeLeft = Main.projectile[disk2].timeLeft = 90; + } + } + } + } + } + } - private void LightingAndDust() - { - if (Main.rand.NextBool(3)) - { - int rainbow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, projectile.direction * 2, 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[rainbow].noGravity = true; - Main.dust[rainbow].velocity *= 0f; - } + private void LightingAndDust() + { + if (Main.rand.NextBool(3)) + { + int rainbow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, projectile.direction * 2, 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].velocity *= 0f; + } - Lighting.AddLight(projectile.Center, 0.15f, 1f, 0.25f); - } + Lighting.AddLight(projectile.Center, 0.15f, 1f, 0.25f); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - if (!projectile.Calamity().stealthStrike) - projectile.ai[0] = 1f; - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + if (!projectile.Calamity().stealthStrike) + projectile.ai[0] = 1f; + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - if (!projectile.Calamity().stealthStrike) - projectile.ai[0] = 1f; - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + if (!projectile.Calamity().stealthStrike) + projectile.ai[0] = 1f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + return false; + } + } } diff --git a/Projectiles/Rogue/AcidBarrelDrop.cs b/Projectiles/Rogue/AcidBarrelDrop.cs index 0c0dc8024e..3047ed8062 100644 --- a/Projectiles/Rogue/AcidBarrelDrop.cs +++ b/Projectiles/Rogue/AcidBarrelDrop.cs @@ -7,7 +7,7 @@ using CalamityMod.Buffs.StatDebuffs; namespace CalamityMod.Projectiles.Rogue { - public class AcidBarrelDrop : ModProjectile + public class AcidBarrelDrop : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Environment/AcidDrop"; @@ -53,9 +53,9 @@ namespace CalamityMod.Projectiles.Rogue return true; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/AcidShrapnel.cs b/Projectiles/Rogue/AcidShrapnel.cs index 38983e6a21..8863bf7e1e 100644 --- a/Projectiles/Rogue/AcidShrapnel.cs +++ b/Projectiles/Rogue/AcidShrapnel.cs @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 160; projectile.tileCollide = true; projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { projectile.ai[0] += 1f; diff --git a/Projectiles/Rogue/AdamantiteThrowingAxeProjectile.cs b/Projectiles/Rogue/AdamantiteThrowingAxeProjectile.cs index 054adaa258..e619388163 100644 --- a/Projectiles/Rogue/AdamantiteThrowingAxeProjectile.cs +++ b/Projectiles/Rogue/AdamantiteThrowingAxeProjectile.cs @@ -45,24 +45,24 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(); - } + OnHitEffects(); + } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(); - } + OnHitEffects(); + } - private void OnHitEffects() - { - if (projectile.Calamity().stealthStrike && Main.myPlayer == projectile.owner) - { - for (int n = 0; n < 3; n++) - { - Projectile lightning = CalamityUtils.ProjectileRain(projectile.Center, 400f, 100f, -800f, -500f, 8f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - lightning.ai[0] = Main.rand.Next(2); - } - } - } + private void OnHitEffects() + { + if (projectile.Calamity().stealthStrike && Main.myPlayer == projectile.owner) + { + for (int n = 0; n < 3; n++) + { + Projectile lightning = CalamityUtils.ProjectileRain(projectile.Center, 400f, 100f, -800f, -500f, 8f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + lightning.ai[0] = Main.rand.Next(2); + } + } + } } } diff --git a/Projectiles/Rogue/AlphaSeeker.cs b/Projectiles/Rogue/AlphaSeeker.cs index c28829ac38..bcdae6038a 100644 --- a/Projectiles/Rogue/AlphaSeeker.cs +++ b/Projectiles/Rogue/AlphaSeeker.cs @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 8; projectile.height = 8; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = lifetime; projectile.Calamity().rogue = true; projectile.extraUpdates = 1; diff --git a/Projectiles/Rogue/AlphaVirusProjectile.cs b/Projectiles/Rogue/AlphaVirusProjectile.cs index 31b137ca72..bfb35ea9f7 100644 --- a/Projectiles/Rogue/AlphaVirusProjectile.cs +++ b/Projectiles/Rogue/AlphaVirusProjectile.cs @@ -8,7 +8,7 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Rogue { - public class AlphaVirusProjectile : ModProjectile + public class AlphaVirusProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/AlphaVirus"; @@ -27,13 +27,13 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 5; + projectile.ignoreWater = true; + projectile.penetrate = 5; projectile.timeLeft = lifetime; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 15; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() @@ -113,7 +113,7 @@ namespace CalamityMod.Projectiles.Rogue public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - if (target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType()) + if (target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType()) { damage /= 5; } @@ -221,5 +221,5 @@ namespace CalamityMod.Projectiles.Rogue } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, radius, targetHitbox); - } + } } diff --git a/Projectiles/Rogue/AntumbraShardProjectile.cs b/Projectiles/Rogue/AntumbraShardProjectile.cs index 889fc5caa5..b576d4106c 100644 --- a/Projectiles/Rogue/AntumbraShardProjectile.cs +++ b/Projectiles/Rogue/AntumbraShardProjectile.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class AntumbraShardProjectile : ModProjectile + public class AntumbraShardProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/XerocPitchfork"; @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.extraUpdates = 1; projectile.aiStyle = 113; projectile.timeLeft = 600; @@ -43,17 +43,17 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 62, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - if (projectile.timeLeft % 12 == 0) - { - if (projectile.owner == Main.myPlayer) - { - if (projectile.Calamity().stealthStrike) - { - int star = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[star].Calamity().rogue = true; - } - } - } + if (projectile.timeLeft % 12 == 0) + { + if (projectile.owner == Main.myPlayer) + { + if (projectile.Calamity().stealthStrike) + { + int star = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); + Main.projectile[star].Calamity().rogue = true; + } + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/ApoctolithProj.cs b/Projectiles/Rogue/ApoctolithProj.cs index c2d6663cc7..0f82af6a13 100644 --- a/Projectiles/Rogue/ApoctolithProj.cs +++ b/Projectiles/Rogue/ApoctolithProj.cs @@ -9,110 +9,110 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Rogue { - public class ApoctolithProj : ModProjectile - { + public class ApoctolithProj : ModProjectile + { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Apoctolith"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Apoctolith"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Apoctolith"); + } - public override void SetDefaults() - { - projectile.width = 30; - projectile.height = 30; - projectile.friendly = true; - projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - } + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.Calamity().rogue = true; + projectile.ignoreWater = true; + } - public override void AI() - { - //Constant rotation and gravity - projectile.rotation += 0.4f * projectile.direction; - projectile.velocity.Y += 0.3f; - if (projectile.velocity.Y > 16f) - { - projectile.velocity.Y = 16f; - } - //Dust trail - if (Main.rand.NextBool(13)) - { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 180, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 150, default, 0.9f); - } - } + public override void AI() + { + //Constant rotation and gravity + projectile.rotation += 0.4f * projectile.direction; + projectile.velocity.Y += 0.3f; + if (projectile.velocity.Y > 16f) + { + projectile.velocity.Y = 16f; + } + //Dust trail + if (Main.rand.NextBool(13)) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 180, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 150, default, 0.9f); + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 240); + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 240); - if (crit) - target.Calamity().miscDefenseLoss = Math.Min(target.defense, 15); + if (crit) + target.Calamity().miscDefenseLoss = Math.Min(target.defense, 15); - if (projectile.Calamity().stealthStrike) - target.AddBuff(ModContent.BuffType(), 120); - } + if (projectile.Calamity().stealthStrike) + target.AddBuff(ModContent.BuffType(), 120); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 240); - if (projectile.Calamity().stealthStrike) - { - target.AddBuff(ModContent.BuffType(), 120); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 240); + if (projectile.Calamity().stealthStrike) + { + target.AddBuff(ModContent.BuffType(), 120); + } + } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Tink, (int)projectile.position.X, (int)projectile.position.Y); - //Dust on impact - int dust_splash = 0; - while (dust_splash < 9) - { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 180, -projectile.velocity.X * 0.15f, -projectile.velocity.Y * 0.15f, 120, default, 1.5f); - dust_splash += 1; - } - // This only triggers if stealth is full - if (projectile.Calamity().stealthStrike) - { - int split = 0; - while (split < 5) - { - //Calculate the velocity of the projectile - float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); - float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; - //Prevents the projectile speed from being too low - if (shardspeedX < 2f && shardspeedX > -2f) - { - shardspeedX += -projectile.velocity.X; - } - if (shardspeedY > 2f && shardspeedY < 2f) - { - shardspeedY += -projectile.velocity.Y; - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Tink, (int)projectile.position.X, (int)projectile.position.Y); + //Dust on impact + int dust_splash = 0; + while (dust_splash < 9) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 180, -projectile.velocity.X * 0.15f, -projectile.velocity.Y * 0.15f, 120, default, 1.5f); + dust_splash += 1; + } + // This only triggers if stealth is full + if (projectile.Calamity().stealthStrike) + { + int split = 0; + while (split < 5) + { + //Calculate the velocity of the projectile + float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); + float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; + //Prevents the projectile speed from being too low + if (shardspeedX < 2f && shardspeedX > -2f) + { + shardspeedX += -projectile.velocity.X; + } + if (shardspeedY > 2f && shardspeedY < 2f) + { + shardspeedY += -projectile.velocity.Y; + } - //Spawn the projectile - int shard = Projectile.NewProjectile(projectile.position.X + shardspeedX, projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack / 2f, projectile.owner); - Main.projectile[shard].frame = Main.rand.Next(3); - split += 1; - } - } - } + //Spawn the projectile + int shard = Projectile.NewProjectile(projectile.position.X + shardspeedX, projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack / 2f, projectile.owner); + Main.projectile[shard].frame = Main.rand.Next(3); + split += 1; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D tex = Main.projectileTexture[projectile.type]; - Vector2 origin = new Vector2(32f, 33f); - spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = Main.projectileTexture[projectile.type]; + Vector2 origin = new Vector2(32f, 33f); + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D tex = ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/ApoctolithGlow"); - Vector2 origin = new Vector2(32f, 33f); - spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); - } - } + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/ApoctolithGlow"); + Vector2 origin = new Vector2(32f, 33f); + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + } + } } diff --git a/Projectiles/Rogue/ApoctolithShard.cs b/Projectiles/Rogue/ApoctolithShard.cs index 5282d9a24a..ab0381a4f3 100644 --- a/Projectiles/Rogue/ApoctolithShard.cs +++ b/Projectiles/Rogue/ApoctolithShard.cs @@ -5,54 +5,54 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Rogue { - public class ApoctolithShard : ModProjectile - { + public class ApoctolithShard : ModProjectile + { public override string Texture => "CalamityMod/Projectiles/Rogue/AbyssalMirrorProjectile"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Apoctolith Shard"); - Main.projFrames[projectile.type] = 3; - } - public override void SetDefaults() - { - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.width = 13; - projectile.height = 13; - projectile.Calamity().rogue = true; - } - public override void AI() - { - //Rotation and gravity - projectile.rotation += 0.6f * projectile.direction; - projectile.velocity.Y += 0.27f; - if (projectile.velocity.Y > 16f) - { - projectile.velocity.Y = 16f; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Apoctolith Shard"); + Main.projFrames[projectile.type] = 3; + } + public override void SetDefaults() + { + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.width = 13; + projectile.height = 13; + projectile.Calamity().rogue = true; + } + public override void AI() + { + //Rotation and gravity + projectile.rotation += 0.6f * projectile.direction; + projectile.velocity.Y += 0.27f; + if (projectile.velocity.Y > 16f) + { + projectile.velocity.Y = 16f; + } - } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Dig, (int)projectile.position.X, (int)projectile.position.Y); - //Dust effect - int splash = 0; - while (splash < 4) - { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 67, -projectile.velocity.X * 0.15f, -projectile.velocity.Y * 0.10f, 150, default, 0.9f); - splash += 1; - } - } + } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Dig, (int)projectile.position.X, (int)projectile.position.Y); + //Dust effect + int splash = 0; + while (splash < 4) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 67, -projectile.velocity.X * 0.15f, -projectile.velocity.Y * 0.10f, 150, default, 0.9f); + splash += 1; + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 120); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 120); + } + } } diff --git a/Projectiles/Rogue/AuroradicalSplitter.cs b/Projectiles/Rogue/AuroradicalSplitter.cs index 89ef71f1f2..eea1537cf5 100644 --- a/Projectiles/Rogue/AuroradicalSplitter.cs +++ b/Projectiles/Rogue/AuroradicalSplitter.cs @@ -8,13 +8,13 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class AuroradicalSplitter : ModProjectile + public class AuroradicalSplitter : ModProjectile { - public int[] dustTypes = new int[] - { - ModContent.DustType(), - ModContent.DustType() - }; + public int[] dustTypes = new int[] + { + ModContent.DustType(), + ModContent.DustType() + }; public override string Texture => "CalamityMod/Projectiles/Rogue/AuroradicalStar"; @@ -35,20 +35,20 @@ namespace CalamityMod.Projectiles.Rogue projectile.alpha = 100; projectile.penetrate = -1; projectile.timeLeft = 50; - projectile.Calamity().rogue = true; - projectile.localNPCHitCooldown = 10; - projectile.usesLocalNPCImmunity = true; + projectile.Calamity().rogue = true; + projectile.localNPCHitCooldown = 10; + projectile.usesLocalNPCImmunity = true; } public override void AI() { - //Rotation + //Rotation projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; - //Lighting + //Lighting Lighting.AddLight(projectile.Center, 0.3f, 0.5f, 0.1f); - //sound effects + //sound effects if (projectile.soundDelay == 0) { projectile.soundDelay = 20 + Main.rand.Next(40); @@ -58,12 +58,12 @@ namespace CalamityMod.Projectiles.Rogue } } - //Change the scale size a little bit to make it pulse in and out + //Change the scale size a little bit to make it pulse in and out float scaleAmt = (float)Main.mouseTextColor / 200f - 0.35f; scaleAmt *= 0.2f; projectile.scale = scaleAmt + 0.95f; - //Spawn dust + //Spawn dust projectile.ai[0] += 1f; if (projectile.ai[0] > 15f) { @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Rogue Main.dust[astral].noGravity = true; Main.dust[astral].velocity *= 0f; } - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -93,14 +93,14 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - if (Main.myPlayer != projectile.owner) - return; + if (Main.myPlayer != projectile.owner) + return; Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 9, 1f, 0f); for (float i = 0; i < 5; i++) { float angle = MathHelper.TwoPi / 5f * i; int star = Projectile.NewProjectile(projectile.Center, angle.ToRotationVector2() * 5f, ModContent.ProjectileType(), (int)(projectile.damage * 0.87), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[star].Calamity().stealthStrike = projectile.Calamity().stealthStrike; + Main.projectile[star].Calamity().stealthStrike = projectile.Calamity().stealthStrike; } projectile.position = projectile.Center; projectile.width = projectile.height = 96; diff --git a/Projectiles/Rogue/AuroradicalStar.cs b/Projectiles/Rogue/AuroradicalStar.cs index bfe32f872c..4d1d93238f 100644 --- a/Projectiles/Rogue/AuroradicalStar.cs +++ b/Projectiles/Rogue/AuroradicalStar.cs @@ -11,11 +11,11 @@ namespace CalamityMod.Projectiles.Rogue { public class AuroradicalStar : ModProjectile { - public int[] dustTypes = new int[] - { - ModContent.DustType(), - ModContent.DustType() - }; + public int[] dustTypes = new int[] + { + ModContent.DustType(), + ModContent.DustType() + }; public override void SetStaticDefaults() { @@ -34,18 +34,18 @@ namespace CalamityMod.Projectiles.Rogue projectile.alpha = 100; projectile.penetrate = 1; projectile.timeLeft = 485; - projectile.Calamity().rogue = true; + projectile.Calamity().rogue = true; } public override void AI() { - //Rotation + //Rotation projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; - //Lighting + //Lighting Lighting.AddLight(projectile.Center, 0.3f, 0.5f, 0.1f); - //sound effects + //sound effects if (projectile.soundDelay == 0) { projectile.soundDelay = 20 + Main.rand.Next(40); @@ -55,12 +55,12 @@ namespace CalamityMod.Projectiles.Rogue } } - //Change the scale size a little bit to make it pulse in and out + //Change the scale size a little bit to make it pulse in and out float scaleAmt = (float)Main.mouseTextColor / 200f - 0.35f; scaleAmt *= 0.2f; projectile.scale = scaleAmt + 0.95f; - //Spawn dust + //Spawn dust projectile.ai[0] += 1f; if (projectile.ai[0] > 15f) { @@ -69,50 +69,50 @@ namespace CalamityMod.Projectiles.Rogue Main.dust[astral].velocity *= 0f; } - //Home in - float maxDistance = 500f; - int targetIndex = -1; - int i; - for (i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false)) - { - float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); + //Home in + float maxDistance = 500f; + int targetIndex = -1; + int i; + for (i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance)) - { - targetIndex = i; - break; - } - } - } - if (targetIndex != -1) - { - Vector2 targetVec = Main.npc[i].Center - projectile.Center; - if (targetVec.Length() < 60f) - { - projectile.Kill(); - return; - } - if (projectile.ai[0] >= 120f) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] < 120f) - { - float speedMult = 25f; - targetVec.Normalize(); - targetVec *= speedMult; - projectile.velocity = (projectile.velocity * 15f + targetVec) / 16f; - projectile.velocity.Normalize(); - projectile.velocity *= speedMult; - } - else if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < 18f) - { - projectile.velocity.X *= 1.01f; - projectile.velocity.Y *= 1.01f; - } - } - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance)) + { + targetIndex = i; + break; + } + } + } + if (targetIndex != -1) + { + Vector2 targetVec = Main.npc[i].Center - projectile.Center; + if (targetVec.Length() < 60f) + { + projectile.Kill(); + return; + } + if (projectile.ai[0] >= 120f) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] < 120f) + { + float speedMult = 25f; + targetVec.Normalize(); + targetVec *= speedMult; + projectile.velocity = (projectile.velocity * 15f + targetVec) / 16f; + projectile.velocity.Normalize(); + projectile.velocity *= speedMult; + } + else if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < 18f) + { + projectile.velocity.X *= 1.01f; + projectile.velocity.Y *= 1.01f; + } + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -126,38 +126,38 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 180); - OnHitEffect(target.Center, target.width); - } + OnHitEffect(target.Center, target.width); + } - private void OnHitEffect(Vector2 targetPos, int width) - { - if (projectile.Calamity().stealthStrike && Main.myPlayer == projectile.owner) - { - Vector2 pos = new Vector2(targetPos.X + width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); - Vector2 velocity = (targetPos - pos) / 40f; - int dmg = projectile.damage / 2; - int comet = Projectile.NewProjectile(pos, velocity, ModContent.ProjectileType(), dmg, projectile.knockBack, projectile.owner); - if (comet.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[comet].Calamity().forceRogue = true; - Main.projectile[comet].Calamity().lineColor = Main.rand.Next(3); - } - } + private void OnHitEffect(Vector2 targetPos, int width) + { + if (projectile.Calamity().stealthStrike && Main.myPlayer == projectile.owner) + { + Vector2 pos = new Vector2(targetPos.X + width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 velocity = (targetPos - pos) / 40f; + int dmg = projectile.damage / 2; + int comet = Projectile.NewProjectile(pos, velocity, ModContent.ProjectileType(), dmg, projectile.knockBack, projectile.owner); + if (comet.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[comet].Calamity().forceRogue = true; + Main.projectile[comet].Calamity().lineColor = Main.rand.Next(3); + } + } } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 180); - OnHitEffect(target.Center, target.width); + OnHitEffect(target.Center, target.width); } public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 9, 1f, 0f); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 96); - projectile.localNPCHitCooldown = 10; - projectile.usesLocalNPCImmunity = true; - projectile.Damage(); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 96); + projectile.localNPCHitCooldown = 10; + projectile.usesLocalNPCImmunity = true; + projectile.Damage(); for (int d = 0; d < 2; d++) { Dust.NewDust(projectile.position, projectile.width, projectile.height, Main.rand.Next(dustTypes), 0f, 0f, 50, default, 1f); diff --git a/Projectiles/Rogue/BallisticPoisonBombProj.cs b/Projectiles/Rogue/BallisticPoisonBombProj.cs index ea1dde6f45..b03de6897f 100644 --- a/Projectiles/Rogue/BallisticPoisonBombProj.cs +++ b/Projectiles/Rogue/BallisticPoisonBombProj.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 200; projectile.tileCollide = false; projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { @@ -32,13 +32,13 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 14, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - projectile.StickToTiles(true, false); + projectile.StickToTiles(true, false); if (projectile.owner == Main.myPlayer && projectile.timeLeft <= 3) { projectile.tileCollide = false; projectile.ai[1] = 0f; projectile.alpha = 255; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 128); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 128); } projectile.ai[0] += 1f; if (projectile.ai[0] > 10f) @@ -60,20 +60,20 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 128); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 128); Main.PlaySound(SoundID.Item14, projectile.Center); int projAmt = Main.rand.Next(3, 5); if (projectile.owner == Main.myPlayer) { for (int s = 0; s < projAmt; s++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); } int cloudAmt = Main.rand.Next(8, 13); for (int c = 0; c < cloudAmt; c++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 1f, projectile.owner, 0f, (float)Main.rand.Next(-45, 1)); } } @@ -95,7 +95,7 @@ namespace CalamityMod.Projectiles.Rogue fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); Main.dust[fire].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Rogue/BarrelShrapnel.cs b/Projectiles/Rogue/BarrelShrapnel.cs index 7f79178e03..29658ceac8 100644 --- a/Projectiles/Rogue/BarrelShrapnel.cs +++ b/Projectiles/Rogue/BarrelShrapnel.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class BarrelShrapnel : ModProjectile + public class BarrelShrapnel : ModProjectile { public bool hitTile = false; public override void SetStaticDefaults() @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 160; projectile.tileCollide = true; projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { projectile.ai[0] += 1f; diff --git a/Projectiles/Rogue/BettyExplosion.cs b/Projectiles/Rogue/BettyExplosion.cs index 458b8b6ca5..e83c29160e 100644 --- a/Projectiles/Rogue/BettyExplosion.cs +++ b/Projectiles/Rogue/BettyExplosion.cs @@ -4,7 +4,7 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Projectiles.Rogue { - public class BettyExplosion : ModProjectile + public class BettyExplosion : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Rogue } // Smoke, which counts as a Gore - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } diff --git a/Projectiles/Rogue/BileExplosion.cs b/Projectiles/Rogue/BileExplosion.cs index e831a44646..de12e88bd6 100644 --- a/Projectiles/Rogue/BileExplosion.cs +++ b/Projectiles/Rogue/BileExplosion.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - //projectile.ai[0] == 1f means spawned by Skyfin Bombers SS + //projectile.ai[0] == 1f means spawned by Skyfin Bombers SS projectile.position = projectile.Center; if (projectile.Calamity().stealthStrike || projectile.ai[0] == 1f) projectile.width = projectile.height = 120; @@ -45,10 +45,10 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.ai[0] != 1f) - { - target.immune[projectile.owner] = 9; - } + if (projectile.ai[0] != 1f) + { + target.immune[projectile.owner] = 9; + } target.AddBuff(ModContent.BuffType(), 180); } diff --git a/Projectiles/Rogue/BlastBarrelProjectile.cs b/Projectiles/Rogue/BlastBarrelProjectile.cs index 6d635d9efd..fc6b0ab545 100644 --- a/Projectiles/Rogue/BlastBarrelProjectile.cs +++ b/Projectiles/Rogue/BlastBarrelProjectile.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class BlastBarrelProjectile : ModProjectile + public class BlastBarrelProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/BlastBarrel"; @@ -32,8 +32,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 48; projectile.friendly = true; projectile.penetrate = -1; - projectile.ignoreWater = true; - projectile.timeLeft = 480; + projectile.ignoreWater = true; + projectile.timeLeft = 480; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; projectile.Calamity().rogue = true; @@ -67,24 +67,24 @@ namespace CalamityMod.Projectiles.Rogue { projectileCount += 4; // More shit the closer we are to death } - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < projectileCount; i++) - { - if (Main.rand.NextBool(3)) - { - Vector2 shrapnelVelocity = (Vector2.UnitY * Main.rand.NextFloat(-19f, -4f)).RotatedByRandom(MathHelper.ToRadians(30f)); - Projectile.NewProjectile(projectile.Center, projectile.velocity + shrapnelVelocity, ModContent.ProjectileType(), projectile.damage, 3f, projectile.owner); - } - else - { - Vector2 fireVelocity = (Vector2.UnitY * Main.rand.NextFloat(-19f, -4f)).RotatedByRandom(MathHelper.ToRadians(40f)); - Projectile fire = Projectile.NewProjectileDirect(projectile.Center, projectile.velocity + fireVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75f), 1f, projectile.owner); - fire.timeLeft = 300; - fire.penetrate = 3; - } - } - } + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < projectileCount; i++) + { + if (Main.rand.NextBool(3)) + { + Vector2 shrapnelVelocity = (Vector2.UnitY * Main.rand.NextFloat(-19f, -4f)).RotatedByRandom(MathHelper.ToRadians(30f)); + Projectile.NewProjectile(projectile.Center, projectile.velocity + shrapnelVelocity, ModContent.ProjectileType(), projectile.damage, 3f, projectile.owner); + } + else + { + Vector2 fireVelocity = (Vector2.UnitY * Main.rand.NextFloat(-19f, -4f)).RotatedByRandom(MathHelper.ToRadians(40f)); + Projectile fire = Projectile.NewProjectileDirect(projectile.Center, projectile.velocity + fireVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75f), 1f, projectile.owner); + fire.timeLeft = 300; + fire.penetrate = 3; + } + } + } RemainingBounces--; BounceEffectCooldown = 15; if (RemainingBounces <= 0) diff --git a/Projectiles/Rogue/BlazingStarProj.cs b/Projectiles/Rogue/BlazingStarProj.cs index 7a2f5cdb35..222280fc47 100644 --- a/Projectiles/Rogue/BlazingStarProj.cs +++ b/Projectiles/Rogue/BlazingStarProj.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class BlazingStarProj : ModProjectile + public class BlazingStarProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/BlazingStar"; @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 32; projectile.friendly = true; projectile.tileCollide = true; - projectile.ignoreWater = true; - projectile.penetrate = 5; + projectile.ignoreWater = true; + projectile.penetrate = 5; projectile.timeLeft = Lifetime; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/BloodsoakedCrashax.cs b/Projectiles/Rogue/BloodsoakedCrashax.cs index 07fd8ae449..033ee89ef7 100644 --- a/Projectiles/Rogue/BloodsoakedCrashax.cs +++ b/Projectiles/Rogue/BloodsoakedCrashax.cs @@ -7,126 +7,126 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class BloodsoakedCrashax : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/BloodsoakedCrasher"; + public class BloodsoakedCrashax : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/BloodsoakedCrasher"; - private int bounce = 3; //number of times it bounces - private int grind = 0; //used to know when to slow down - private const float MaxSpeed = 14f; + private int bounce = 3; //number of times it bounces + private int grind = 0; //used to know when to slow down + private const float MaxSpeed = 14f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bloodsoaked Crasher"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bloodsoaked Crasher"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 30; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 6; - projectile.timeLeft = 600; //10 seconds and counting (but not actually because extra updates) - projectile.Calamity().rogue = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 8; - projectile.extraUpdates = 1; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 30; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = 6; + projectile.timeLeft = 600; //10 seconds and counting (but not actually because extra updates) + projectile.Calamity().rogue = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 8; + projectile.extraUpdates = 1; + } - public override void AI() - { - float speed = projectile.velocity.Length(); - if (grind > 0) - { - grind--; - // Suddenly stop when on top of enemies. - projectile.velocity.X *= 0.75f; - projectile.velocity.Y *= 0.75f; - } - else - { - // Gravity - projectile.velocity.Y += 0.11f; + public override void AI() + { + float speed = projectile.velocity.Length(); + if (grind > 0) + { + grind--; + // Suddenly stop when on top of enemies. + projectile.velocity.X *= 0.75f; + projectile.velocity.Y *= 0.75f; + } + else + { + // Gravity + projectile.velocity.Y += 0.11f; - // Cap velocity. - speed = projectile.velocity.Length(); - if (speed > MaxSpeed) - projectile.velocity *= MaxSpeed / speed; - } + // Cap velocity. + speed = projectile.velocity.Length(); + if (speed > MaxSpeed) + projectile.velocity *= MaxSpeed / speed; + } - // Spin constantly, but even faster when grinding or going fast - float spinRate = grind > 0 ? 0.28f : 0.09f; - if (grind <= 0) - spinRate += speed * 0.005f; - projectile.rotation += spinRate * projectile.direction; - } + // Spin constantly, but even faster when grinding or going fast + float spinRate = grind > 0 ? 0.28f : 0.09f; + if (grind <= 0) + spinRate += speed * 0.005f; + projectile.rotation += spinRate * projectile.direction; + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - bounce--; - if (bounce <= 0) - { - projectile.Kill(); //you can only bounce so much 'til death - } - else - { - if (projectile.velocity.X != oldVelocity.X) - { - projectile.velocity.X = -oldVelocity.X; - } - if (projectile.velocity.Y != oldVelocity.Y) - { - projectile.velocity.Y = -oldVelocity.Y; - } - } - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + bounce--; + if (bounce <= 0) + { + projectile.Kill(); //you can only bounce so much 'til death + } + else + { + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y; + } + } + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - OnHitEffects(!target.canGhostHeal || Main.player[projectile.owner].moonLeech); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + OnHitEffects(!target.canGhostHeal || Main.player[projectile.owner].moonLeech); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - OnHitEffects(Main.player[projectile.owner].moonLeech); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + OnHitEffects(Main.player[projectile.owner].moonLeech); + } - private void OnHitEffects(bool cannotLifesteal) - { - grind += 5; //THE GRIND NEVER STOPS - if (grind > 15) - grind = 15; // except when it's too much + private void OnHitEffects(bool cannotLifesteal) + { + grind += 5; //THE GRIND NEVER STOPS + if (grind > 15) + grind = 15; // except when it's too much - if (projectile.Calamity().stealthStrike && projectile.owner == Main.myPlayer) //stealth strike attack - { - int projID = ModContent.ProjectileType(); - int bloodDamage = projectile.damage; - float bloodKB = 1f; - int stealth = Projectile.NewProjectile(projectile.Center, Vector2.Zero, projID, bloodDamage, bloodKB, projectile.owner, 1f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (stealth.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[stealth].Calamity().forceRogue = true; - Main.projectile[stealth].extraUpdates = 1; - } - } + if (projectile.Calamity().stealthStrike && projectile.owner == Main.myPlayer) //stealth strike attack + { + int projID = ModContent.ProjectileType(); + int bloodDamage = projectile.damage; + float bloodKB = 1f; + int stealth = Projectile.NewProjectile(projectile.Center, Vector2.Zero, projID, bloodDamage, bloodKB, projectile.owner, 1f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().forceRogue = true; + Main.projectile[stealth].extraUpdates = 1; + } + } - if (cannotLifesteal || Main.rand.NextBool(2)) //canGhostHeal be like lol - return; + if (cannotLifesteal || Main.rand.NextBool(2)) //canGhostHeal be like lol + return; - Player player = Main.player[projectile.owner]; - player.statLife += 1; - player.HealEffect(1); - } + Player player = Main.player[projectile.owner]; + player.statLife += 1; + player.HealEffect(1); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) //afterimages - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) //afterimages + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Rogue/BlueFlamePillar.cs b/Projectiles/Rogue/BlueFlamePillar.cs index 3acc0df2da..5cab04db5b 100644 --- a/Projectiles/Rogue/BlueFlamePillar.cs +++ b/Projectiles/Rogue/BlueFlamePillar.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Rogue } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D tex = Main.projectileTexture[projectile.type]; + Texture2D tex = Main.projectileTexture[projectile.type]; Rectangle frame = new Rectangle(frameX * 80, frameY * 322, 80, 322); spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, frame, Color.White, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); return false; diff --git a/Projectiles/Rogue/BlunderBoosterLightning.cs b/Projectiles/Rogue/BlunderBoosterLightning.cs index 3096335aa5..957c4c6bd3 100644 --- a/Projectiles/Rogue/BlunderBoosterLightning.cs +++ b/Projectiles/Rogue/BlunderBoosterLightning.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class BlunderBoosterLightning : ModProjectile + public class BlunderBoosterLightning : ModProjectile { public static int frameWidth = 12; public static int frameHeight = 26; @@ -51,39 +51,39 @@ namespace CalamityMod.Projectiles.Rogue projectile.tileCollide = true; } - projectile.ai[1]++; - if (projectile.ai[1] >= 15f) - { - float minDist = 999f; - int index = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false)) - { - float dist = (projectile.Center - npc.Center).Length(); - if (dist < minDist) - { - minDist = dist; - index = i; - } - } - } + projectile.ai[1]++; + if (projectile.ai[1] >= 15f) + { + float minDist = 999f; + int index = -1; + for (int i = 0; i < Main.npc.Length; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float dist = (projectile.Center - npc.Center).Length(); + if (dist < minDist) + { + minDist = dist; + index = i; + } + } + } - Vector2 velocityNew; - if (minDist < 999f && index != -1) - { - velocityNew = Main.npc[index].Center - projectile.Center; - velocityNew.Normalize(); - velocityNew *= 2f; - projectile.velocity += velocityNew; - if (projectile.velocity.Length() > 10f) - { - projectile.velocity.Normalize(); - projectile.velocity *= 10f; - } - } - } + Vector2 velocityNew; + if (minDist < 999f && index != -1) + { + velocityNew = Main.npc[index].Center - projectile.Center; + velocityNew.Normalize(); + velocityNew *= 2f; + projectile.velocity += velocityNew; + if (projectile.velocity.Length() > 10f) + { + projectile.velocity.Normalize(); + projectile.velocity *= 10f; + } + } + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Rogue/BouncingBettyProjectile.cs b/Projectiles/Rogue/BouncingBettyProjectile.cs index a28e30e317..4a4bbd31b9 100644 --- a/Projectiles/Rogue/BouncingBettyProjectile.cs +++ b/Projectiles/Rogue/BouncingBettyProjectile.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class BouncingBettyProjectile : ModProjectile + public class BouncingBettyProjectile : ModProjectile { public override void SetStaticDefaults() { @@ -19,33 +19,33 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 600; projectile.penetrate = 3; projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } private void Explode() { Main.PlaySound(SoundID.Item14, projectile.Center); - if (Main.myPlayer == projectile.owner) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 8f, projectile.owner); - if (projectile.Calamity().stealthStrike) - { - int projectileCount = 12; - for (int i = 0; i < projectileCount; i++) - { - if (Main.rand.NextBool(2)) - { - Vector2 shrapnelVelocity = (Vector2.UnitY * Main.rand.NextFloat(-12f, -4f)).RotatedByRandom(MathHelper.ToRadians(30f)); - Projectile.NewProjectile(projectile.Center, projectile.velocity + shrapnelVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), 3f, projectile.owner); - } - else - { - Vector2 fireVelocity = (Vector2.UnitY * Main.rand.NextFloat(-12f, -4f)).RotatedByRandom(MathHelper.ToRadians(40f)); - Projectile fire = Projectile.NewProjectileDirect(projectile.Center, projectile.velocity + fireVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.6f), 1f, projectile.owner); - fire.localNPCHitCooldown = 9; - fire.timeLeft = 240; - } - } - } + if (Main.myPlayer == projectile.owner) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 8f, projectile.owner); + if (projectile.Calamity().stealthStrike) + { + int projectileCount = 12; + for (int i = 0; i < projectileCount; i++) + { + if (Main.rand.NextBool(2)) + { + Vector2 shrapnelVelocity = (Vector2.UnitY * Main.rand.NextFloat(-12f, -4f)).RotatedByRandom(MathHelper.ToRadians(30f)); + Projectile.NewProjectile(projectile.Center, projectile.velocity + shrapnelVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), 3f, projectile.owner); + } + else + { + Vector2 fireVelocity = (Vector2.UnitY * Main.rand.NextFloat(-12f, -4f)).RotatedByRandom(MathHelper.ToRadians(40f)); + Projectile fire = Projectile.NewProjectileDirect(projectile.Center, projectile.velocity + fireVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.6f), 1f, projectile.owner); + fire.localNPCHitCooldown = 9; + fire.timeLeft = 240; + } + } + } } } public override void AI() diff --git a/Projectiles/Rogue/BouncyBol.cs b/Projectiles/Rogue/BouncyBol.cs index 5849a54cc5..66c23446b1 100644 --- a/Projectiles/Rogue/BouncyBol.cs +++ b/Projectiles/Rogue/BouncyBol.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class BouncyBol : ModProjectile + public class BouncyBol : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/BouncySpikyBall"; @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = 8; projectile.timeLeft = 600; projectile.Calamity().rogue = true; - projectile.aiStyle = 14; + projectile.aiStyle = 14; } public override void AI() @@ -84,10 +84,10 @@ namespace CalamityMod.Projectiles.Rogue { projectile.damage = (int)(projectile.damage * 1.5f); } - else - { - projectile.damage = (int)(projectile.damage * 1.1f); - } + else + { + projectile.damage = (int)(projectile.damage * 1.1f); + } hasHitEnemy = true; targetNPC = index; velocityNew = Main.npc[index].Center - projectile.Center; @@ -99,14 +99,14 @@ namespace CalamityMod.Projectiles.Rogue public override bool OnTileCollide(Vector2 oldVelocity) { - if (projectile.velocity.X != oldVelocity.X) - { - projectile.velocity.X = -oldVelocity.X * 1.001f; - } - if (projectile.velocity.Y != oldVelocity.Y) - { - projectile.velocity.Y = -oldVelocity.Y * 1.001f; - } + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X * 1.001f; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y * 1.001f; + } return false; } } diff --git a/Projectiles/Rogue/BrackishFlaskProj.cs b/Projectiles/Rogue/BrackishFlaskProj.cs index 0f4a4a5108..f7b03493e5 100644 --- a/Projectiles/Rogue/BrackishFlaskProj.cs +++ b/Projectiles/Rogue/BrackishFlaskProj.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 180; aiType = ProjectileID.ThrowingKnife; projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void Kill(int timeLeft) { @@ -46,10 +46,10 @@ namespace CalamityMod.Projectiles.Rogue double offsetAngle; if (projectile.owner == Main.myPlayer) { - if (projectile.Calamity().stealthStrike) - { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, -32f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - } + if (projectile.Calamity().stealthStrike) + { + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, -32f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + } Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); diff --git a/Projectiles/Rogue/BrackishSpear.cs b/Projectiles/Rogue/BrackishSpear.cs index b26cf32b26..6629949215 100644 --- a/Projectiles/Rogue/BrackishSpear.cs +++ b/Projectiles/Rogue/BrackishSpear.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Projectiles.Rogue { public class BrackishSpear : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/Magic/AtlantisSpear"; + public override string Texture => "CalamityMod/Projectiles/Magic/AtlantisSpear"; public override void SetStaticDefaults() { @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 52; projectile.aiStyle = 4; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/BrackishSpear2.cs b/Projectiles/Rogue/BrackishSpear2.cs index b100731e97..210476b71c 100644 --- a/Projectiles/Rogue/BrackishSpear2.cs +++ b/Projectiles/Rogue/BrackishSpear2.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Projectiles.Rogue { public class BrackishSpear2 : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/Magic/AtlantisSpear"; + public override string Texture => "CalamityMod/Projectiles/Magic/AtlantisSpear"; public override void SetStaticDefaults() { diff --git a/Projectiles/Rogue/BrackishWater.cs b/Projectiles/Rogue/BrackishWater.cs index 96301c6171..3fcbc0e0f0 100644 --- a/Projectiles/Rogue/BrackishWater.cs +++ b/Projectiles/Rogue/BrackishWater.cs @@ -31,18 +31,18 @@ namespace CalamityMod.Projectiles.Rogue Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 21); projectile.localAI[0] += 1f; } - if (projectile.timeLeft % 2 == 0) - { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 33, - 89 - }); - int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDust, 0f, 0f, 100, default, 1.2f); - Main.dust[water].noGravity = true; - Main.dust[water].velocity *= 0.5f; - Main.dust[water].velocity += projectile.velocity * 0.1f; - } + if (projectile.timeLeft % 2 == 0) + { + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 33, + 89 + }); + int water = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDust, 0f, 0f, 100, default, 1.2f); + Main.dust[water].noGravity = true; + Main.dust[water].velocity *= 0.5f; + Main.dust[water].velocity += projectile.velocity * 0.1f; + } } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/BrackishWaterBlast.cs b/Projectiles/Rogue/BrackishWaterBlast.cs index bcb4fa4183..92c6c9d34e 100644 --- a/Projectiles/Rogue/BrackishWaterBlast.cs +++ b/Projectiles/Rogue/BrackishWaterBlast.cs @@ -30,11 +30,11 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.75f / 255f); - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 33, - 89 - }); + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 33, + 89 + }); if (projectile.localAI[0] == 0f) { Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 21); diff --git a/Projectiles/Rogue/Brimblade2.cs b/Projectiles/Rogue/Brimblade2.cs index 5d3775b415..4e84c91d56 100644 --- a/Projectiles/Rogue/Brimblade2.cs +++ b/Projectiles/Rogue/Brimblade2.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 26; projectile.height = 26; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 3; projectile.timeLeft = 180; aiType = ProjectileID.WoodenBoomerang; diff --git a/Projectiles/Rogue/BrimbladeProj.cs b/Projectiles/Rogue/BrimbladeProj.cs index 59075b32d9..32df2efb70 100644 --- a/Projectiles/Rogue/BrimbladeProj.cs +++ b/Projectiles/Rogue/BrimbladeProj.cs @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 26; projectile.height = 26; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.aiStyle = 3; projectile.timeLeft = 180; aiType = ProjectileID.WoodenBoomerang; diff --git a/Projectiles/Rogue/BurningStrifeProj.cs b/Projectiles/Rogue/BurningStrifeProj.cs index a827763f13..66b69d470f 100644 --- a/Projectiles/Rogue/BurningStrifeProj.cs +++ b/Projectiles/Rogue/BurningStrifeProj.cs @@ -18,8 +18,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 14; projectile.height = 14; projectile.timeLeft = 720; - projectile.ignoreWater = true; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.extraUpdates = 1; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Rogue/ButcherKnife.cs b/Projectiles/Rogue/ButcherKnife.cs index 17b634a6d0..984c6ac6ba 100644 --- a/Projectiles/Rogue/ButcherKnife.cs +++ b/Projectiles/Rogue/ButcherKnife.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 14; projectile.height = 14; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = 300; projectile.Calamity().rogue = true; projectile.extraUpdates = 1; diff --git a/Projectiles/Rogue/CarvingFork.cs b/Projectiles/Rogue/CarvingFork.cs index cecdf33481..d89b5aba0c 100644 --- a/Projectiles/Rogue/CarvingFork.cs +++ b/Projectiles/Rogue/CarvingFork.cs @@ -20,16 +20,16 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 10; projectile.height = 10; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 30; - projectile.extraUpdates = 1; - } + projectile.extraUpdates = 1; + } public override void AI() { diff --git a/Projectiles/Rogue/CelestialReaperAfterimage.cs b/Projectiles/Rogue/CelestialReaperAfterimage.cs index b661d820db..350e07218b 100644 --- a/Projectiles/Rogue/CelestialReaperAfterimage.cs +++ b/Projectiles/Rogue/CelestialReaperAfterimage.cs @@ -17,26 +17,26 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 66; projectile.height = 76; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 51; projectile.tileCollide = false; projectile.Calamity().rogue = true; projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.rotation += MathHelper.ToRadians(30f); // Buzzsaw scythe. - if (projectile.timeLeft < 150) - { - NPC target = projectile.Center.ClosestNPCAt(640f); - if (target != null) - projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(target.Center) * 20f) / 21f; - } + if (projectile.timeLeft < 150) + { + NPC target = projectile.Center.ClosestNPCAt(640f); + if (target != null) + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(target.Center) * 20f) / 21f; + } projectile.alpha += 5; } diff --git a/Projectiles/Rogue/CelestialReaperProjectile.cs b/Projectiles/Rogue/CelestialReaperProjectile.cs index 65135370c5..2fda751e12 100644 --- a/Projectiles/Rogue/CelestialReaperProjectile.cs +++ b/Projectiles/Rogue/CelestialReaperProjectile.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 66; projectile.height = 76; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 6; + projectile.ignoreWater = true; + projectile.penetrate = 6; projectile.tileCollide = false; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Rogue/Celestus2.cs b/Projectiles/Rogue/Celestus2.cs index 8794a470a3..7c4f63f305 100644 --- a/Projectiles/Rogue/Celestus2.cs +++ b/Projectiles/Rogue/Celestus2.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 48; projectile.friendly = true; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.extraUpdates = 4; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 40; @@ -51,12 +51,12 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/CelestusBoomerang.cs b/Projectiles/Rogue/CelestusBoomerang.cs index 9dd6075380..d5adfe1b27 100644 --- a/Projectiles/Rogue/CelestusBoomerang.cs +++ b/Projectiles/Rogue/CelestusBoomerang.cs @@ -7,168 +7,168 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CelestusBoomerang : ModProjectile - { + public class CelestusBoomerang : ModProjectile + { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Celestus"; - private bool initialized = false; - private float speed = 25f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Celestus"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + private bool initialized = false; + private float speed = 25f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Celestus"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 94; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 30; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 94; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.extraUpdates = 3; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 30; + projectile.Calamity().rogue = true; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; + public override void AI() + { + Player player = Main.player[projectile.owner]; - if (!initialized) - { - speed = projectile.velocity.Length(); - initialized = true; - } + if (!initialized) + { + speed = projectile.velocity.Length(); + initialized = true; + } - Lighting.AddLight(projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f); - projectile.rotation += 1f; + Lighting.AddLight(projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f); + projectile.rotation += 1f; - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 8; - Main.PlaySound(SoundID.Item7, projectile.position); - } + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 8; + Main.PlaySound(SoundID.Item7, projectile.position); + } - switch (projectile.ai[0]) - { - case 0f: - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 40f) - { - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - break; - case 1f: - float returnSpeed = 25f; - float acceleration = 5f; - Vector2 playerVec = player.Center - projectile.Center; - if (playerVec.Length() > 4000f) - { - projectile.Kill(); - } - playerVec.Normalize(); - playerVec *= returnSpeed; - if (projectile.velocity.X < playerVec.X) - { - projectile.velocity.X += acceleration; - if (projectile.velocity.X < 0f && playerVec.X > 0f) - { - projectile.velocity.X += acceleration; - } - } - else if (projectile.velocity.X > playerVec.X) - { - projectile.velocity.X -= acceleration; - if (projectile.velocity.X > 0f && playerVec.X < 0f) - { - projectile.velocity.X -= acceleration; - } - } - if (projectile.velocity.Y < playerVec.Y) - { - projectile.velocity.Y += acceleration; - if (projectile.velocity.Y < 0f && playerVec.Y > 0f) - { - projectile.velocity.Y += acceleration; - } - } - else if (projectile.velocity.Y > playerVec.Y) - { - projectile.velocity.Y -= acceleration; - if (projectile.velocity.Y > 0f && playerVec.Y < 0f) - { - projectile.velocity.Y -= acceleration; - } - } - if (Main.myPlayer == projectile.owner) - { - Rectangle projHitbox = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); - Rectangle playerHitbox = new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height); - if (projHitbox.Intersects(playerHitbox)) - { - if (projectile.Calamity().stealthStrike) - { - projectile.velocity *= -1f; - projectile.timeLeft = 600; - projectile.penetrate = 1; - projectile.localNPCHitCooldown = -1; - projectile.ai[0] = 2f; - projectile.netUpdate = true; - } - else - projectile.Kill(); - } - } - break; - case 2f: - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, speed, 20f); - break; - default: - break; - } - } + switch (projectile.ai[0]) + { + case 0f: + projectile.ai[1] += 1f; + if (projectile.ai[1] >= 40f) + { + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + break; + case 1f: + float returnSpeed = 25f; + float acceleration = 5f; + Vector2 playerVec = player.Center - projectile.Center; + if (playerVec.Length() > 4000f) + { + projectile.Kill(); + } + playerVec.Normalize(); + playerVec *= returnSpeed; + if (projectile.velocity.X < playerVec.X) + { + projectile.velocity.X += acceleration; + if (projectile.velocity.X < 0f && playerVec.X > 0f) + { + projectile.velocity.X += acceleration; + } + } + else if (projectile.velocity.X > playerVec.X) + { + projectile.velocity.X -= acceleration; + if (projectile.velocity.X > 0f && playerVec.X < 0f) + { + projectile.velocity.X -= acceleration; + } + } + if (projectile.velocity.Y < playerVec.Y) + { + projectile.velocity.Y += acceleration; + if (projectile.velocity.Y < 0f && playerVec.Y > 0f) + { + projectile.velocity.Y += acceleration; + } + } + else if (projectile.velocity.Y > playerVec.Y) + { + projectile.velocity.Y -= acceleration; + if (projectile.velocity.Y > 0f && playerVec.Y < 0f) + { + projectile.velocity.Y -= acceleration; + } + } + if (Main.myPlayer == projectile.owner) + { + Rectangle projHitbox = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); + Rectangle playerHitbox = new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height); + if (projHitbox.Intersects(playerHitbox)) + { + if (projectile.Calamity().stealthStrike) + { + projectile.velocity *= -1f; + projectile.timeLeft = 600; + projectile.penetrate = 1; + projectile.localNPCHitCooldown = -1; + projectile.ai[0] = 2f; + projectile.netUpdate = true; + } + else + projectile.Kill(); + } + } + break; + case 2f: + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, speed, 20f); + break; + default: + break; + } + } - public override Color? GetAlpha(Color lightColor) => new Color(250, 250, 250, 50); + public override Color? GetAlpha(Color lightColor) => new Color(250, 250, 250, 50); - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.ExoDebuffs(); - OnHitEffects(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.ExoDebuffs(); + OnHitEffects(); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.ExoDebuffs(); - OnHitEffects(); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); + OnHitEffects(); + } - private void OnHitEffects() - { - if (projectile.owner == Main.myPlayer) - { - float spread = 45f * 0.0174f; - double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - double offsetAngle; - for (int 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) * 2f), (float)(Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)(projectile.damage * 0.7), projectile.knockBack, projectile.owner); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 2f), (float)(-Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)(projectile.damage * 0.7), projectile.knockBack, projectile.owner); - } - } - Main.PlaySound(SoundID.Item122, projectile.Center); - } + private void OnHitEffects() + { + if (projectile.owner == Main.myPlayer) + { + float spread = 45f * 0.0174f; + double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; + double deltaAngle = spread / 8f; + double offsetAngle; + for (int 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) * 2f), (float)(Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)(projectile.damage * 0.7), projectile.knockBack, projectile.owner); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 2f), (float)(-Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)(projectile.damage * 0.7), projectile.knockBack, projectile.owner); + } + } + Main.PlaySound(SoundID.Item122, projectile.Center); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Rogue/CinquedeaProj.cs b/Projectiles/Rogue/CinquedeaProj.cs index d2bbf85c04..94ed686c48 100644 --- a/Projectiles/Rogue/CinquedeaProj.cs +++ b/Projectiles/Rogue/CinquedeaProj.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CinquedeaProj : ModProjectile + public class CinquedeaProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Cinquedea"; @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Rogue //Stealth strike if (stealthstrike) { - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 7f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 7f, 20f); } //Gravity code else diff --git a/Projectiles/Rogue/CircletMark.cs b/Projectiles/Rogue/CircletMark.cs index 55e30a1c2f..b43061a3f6 100644 --- a/Projectiles/Rogue/CircletMark.cs +++ b/Projectiles/Rogue/CircletMark.cs @@ -6,7 +6,7 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Rogue { - public class CircletMark : ModProjectile + public class CircletMark : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 900; projectile.ignoreWater = true; projectile.alpha = 255; - projectile.Calamity().rogue = true; + projectile.Calamity().rogue = true; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; diff --git a/Projectiles/Rogue/CircletTornado.cs b/Projectiles/Rogue/CircletTornado.cs index 08eaaa892e..1b305392db 100644 --- a/Projectiles/Rogue/CircletTornado.cs +++ b/Projectiles/Rogue/CircletTornado.cs @@ -6,7 +6,7 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Rogue { - public class CircletTornado : ModProjectile + public class CircletTornado : ModProjectile { public override string Texture => "CalamityMod/Projectiles/TornadoProj"; @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - //only 1 tornado can exist at a time + //only 1 tornado can exist at a time projectile.localAI[1] += 1f; if (projectile.localAI[1] >= 10f) { @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Rogue int projType = projectile.type; for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) { - Projectile proj = Main.projectile[projIndex]; + Projectile proj = Main.projectile[projIndex]; if (proj.active && proj.owner == projectile.owner && proj.type == projType && proj.ai[0] < 900f) { projCount++; diff --git a/Projectiles/Rogue/CobaltEnergy.cs b/Projectiles/Rogue/CobaltEnergy.cs index 3d8a030cb1..832918c7b9 100644 --- a/Projectiles/Rogue/CobaltEnergy.cs +++ b/Projectiles/Rogue/CobaltEnergy.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CobaltEnergy : ModProjectile + public class CobaltEnergy : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -34,17 +34,17 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - for (int index = 0; index < 2; ++index) - { - int ruby = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 88, projectile.velocity.X, projectile.velocity.Y, 90, new Color(), 1.2f); - Dust dust = Main.dust[ruby]; - dust.noGravity = true; - dust.velocity *= 0.3f; - } + for (int index = 0; index < 2; ++index) + { + int ruby = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 88, projectile.velocity.X, projectile.velocity.Y, 90, new Color(), 1.2f); + Dust dust = Main.dust[ruby]; + dust.noGravity = true; + dust.velocity *= 0.3f; + } if (!hasHitEnemy && projectile.timeLeft < 575) { - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } else if (hasHitEnemy) { @@ -118,15 +118,15 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Dig, (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, 88, 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; - } - } + Main.PlaySound(SoundID.Dig, (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, 88, 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; + } + } } } diff --git a/Projectiles/Rogue/ConsecratedWaterProjectile.cs b/Projectiles/Rogue/ConsecratedWaterProjectile.cs index e6cd90256e..b9ea5aae91 100644 --- a/Projectiles/Rogue/ConsecratedWaterProjectile.cs +++ b/Projectiles/Rogue/ConsecratedWaterProjectile.cs @@ -6,7 +6,7 @@ using Terraria.World.Generation; namespace CalamityMod.Projectiles.Rogue { - public class ConsecratedWaterProjectile : ModProjectile + public class ConsecratedWaterProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/ConsecratedWater"; @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = 1; projectile.timeLeft = 200; projectile.tileCollide = true; - projectile.ignoreWater = true; - projectile.alpha = 0; + projectile.ignoreWater = true; + projectile.alpha = 0; projectile.Calamity().rogue = true; } public override void AI() diff --git a/Projectiles/Rogue/ContaminatedBileFlask.cs b/Projectiles/Rogue/ContaminatedBileFlask.cs index 3a6cb5381c..7d92eabebd 100644 --- a/Projectiles/Rogue/ContaminatedBileFlask.cs +++ b/Projectiles/Rogue/ContaminatedBileFlask.cs @@ -39,11 +39,11 @@ namespace CalamityMod.Projectiles.Rogue { Main.PlaySound(SoundID.Item107, projectile.Bottom); Projectile explosion = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); - if (explosion.whoAmI.WithinBounds(Main.maxProjectiles)) - { - explosion.Calamity().stealthStrike = projectile.Calamity().stealthStrike; - explosion.timeLeft = explosion.Calamity().stealthStrike ? 60 : 20; - } + if (explosion.whoAmI.WithinBounds(Main.maxProjectiles)) + { + explosion.Calamity().stealthStrike = projectile.Calamity().stealthStrike; + explosion.timeLeft = explosion.Calamity().stealthStrike ? 60 : 20; + } } } } diff --git a/Projectiles/Rogue/CorpusAvertorClone.cs b/Projectiles/Rogue/CorpusAvertorClone.cs index 89415d34e6..4d92ce9aa3 100644 --- a/Projectiles/Rogue/CorpusAvertorClone.cs +++ b/Projectiles/Rogue/CorpusAvertorClone.cs @@ -7,96 +7,96 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CorpusAvertorClone : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/CorpusAvertor"; + public class CorpusAvertorClone : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/CorpusAvertor"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Corpus Avertor"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Corpus Avertor"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 24; - projectile.height = 24; - projectile.ignoreWater = true; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.timeLeft = 180; - projectile.tileCollide = false; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 24; + projectile.height = 24; + projectile.ignoreWater = true; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.timeLeft = 180; + projectile.tileCollide = false; + projectile.Calamity().rogue = true; + } - public override void AI() - { - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.04f; + public override void AI() + { + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.04f; - projectile.velocity.X *= 1.005f; - projectile.velocity.Y *= 1.005f; + projectile.velocity.X *= 1.005f; + projectile.velocity.Y *= 1.005f; - switch ((int)projectile.ai[0]) - { - case 20: - projectile.scale = 0.7f; - break; - case 40: - projectile.scale = 0.8f; - break; - case 60: - projectile.scale = 0.9f; - break; - default: - break; - } - projectile.width = projectile.height = (int)(24f * projectile.scale); + switch ((int)projectile.ai[0]) + { + case 20: + projectile.scale = 0.7f; + break; + case 40: + projectile.scale = 0.8f; + break; + case 60: + projectile.scale = 0.9f; + break; + default: + break; + } + projectile.width = projectile.height = (int)(24f * projectile.scale); - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 150f, 12f, 20f); - } + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 150f, 12f, 20f); + } - public override Color? GetAlpha(Color lightColor) - { - if (projectile.timeLeft < 85) - return new Color((int)(150f * (projectile.timeLeft / 85f)), 0, 0, projectile.timeLeft / 5 * 3); - return new Color(150, 0, 0, 50); - } + public override Color? GetAlpha(Color lightColor) + { + if (projectile.timeLeft < 85) + return new Color((int)(150f * (projectile.timeLeft / 85f)), 0, 0, projectile.timeLeft / 5 * 3); + return new Color(150, 0, 0, 50); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - float heal = damage * 0.05f; - if ((int)heal == 0) - return; + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + float heal = damage * 0.05f; + if ((int)heal == 0) + return; - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - return; + if (Main.player[Main.myPlayer].lifeSteal <= 0f) + return; - if (heal > CalamityMod.lifeStealCap) - heal = CalamityMod.lifeStealCap; + if (heal > CalamityMod.lifeStealCap) + heal = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 3f); - } + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 3f); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - float heal = damage * 0.05f; - if ((int)heal == 0) - return; + public override void OnHitPvp(Player target, int damage, bool crit) + { + float heal = damage * 0.05f; + if ((int)heal == 0) + return; - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - return; + if (Main.player[Main.myPlayer].lifeSteal <= 0f) + return; - if (heal > CalamityMod.lifeStealCap) - heal = CalamityMod.lifeStealCap; + if (heal > CalamityMod.lifeStealCap) + heal = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 3f); - } - } + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 3f); + } + } } diff --git a/Projectiles/Rogue/CorpusAvertorProj.cs b/Projectiles/Rogue/CorpusAvertorProj.cs index 78a2c22f0b..1bd5bece27 100644 --- a/Projectiles/Rogue/CorpusAvertorProj.cs +++ b/Projectiles/Rogue/CorpusAvertorProj.cs @@ -7,103 +7,103 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CorpusAvertorProj : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/CorpusAvertor"; + public class CorpusAvertorProj : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/CorpusAvertor"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Corpus Avertor"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Corpus Avertor"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 24; - projectile.height = 24; - projectile.ignoreWater = true; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.timeLeft = 300; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 24; + projectile.height = 24; + projectile.ignoreWater = true; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.timeLeft = 300; + projectile.Calamity().rogue = true; + } - public override void AI() - { - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.02f; + public override void AI() + { + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.02f; - if (projectile.ai[0] < 120f) - projectile.ai[0] += 1f; + if (projectile.ai[0] < 120f) + projectile.ai[0] += 1f; - if (projectile.ai[0] < 61f) - { - if (projectile.ai[0] % 20f == 0f) - { - Vector2 velocity = new Vector2(projectile.velocity.X, projectile.velocity.Y); - float mult = projectile.ai[0] / 80f; // Ranges from 0.25 to 0.5 to 0.75 - velocity *= mult; + if (projectile.ai[0] < 61f) + { + if (projectile.ai[0] % 20f == 0f) + { + Vector2 velocity = new Vector2(projectile.velocity.X, projectile.velocity.Y); + float mult = projectile.ai[0] / 80f; // Ranges from 0.25 to 0.5 to 0.75 + velocity *= mult; - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), - (int)(projectile.damage * mult), projectile.knockBack * mult, projectile.owner, projectile.ai[0]); - } - } - else - { - projectile.velocity.X *= 1.01f; - projectile.velocity.Y *= 1.01f; + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), + (int)(projectile.damage * mult), projectile.knockBack * mult, projectile.owner, projectile.ai[0]); + } + } + else + { + projectile.velocity.X *= 1.01f; + projectile.velocity.Y *= 1.01f; - int scale = (int)((projectile.ai[0] - 60f) * 4.25f); - int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 5, 0f, 0f, 100, new Color(scale, 0, 0, 50), 2f); - Main.dust[dust].velocity *= 0f; - Main.dust[dust].noGravity = true; - } - } + int scale = (int)((projectile.ai[0] - 60f) * 4.25f); + int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 5, 0f, 0f, 100, new Color(scale, 0, 0, 50), 2f); + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; + } + } - public override Color? GetAlpha(Color lightColor) - { - if (projectile.ai[0] >= 61f) - { - int scale = (int)((projectile.ai[0] - 60f) * 4.25f); - return new Color(scale, 0, 0, 50); - } - return new Color(0, 0, 0, 50); - } + public override Color? GetAlpha(Color lightColor) + { + if (projectile.ai[0] >= 61f) + { + int scale = (int)((projectile.ai[0] - 60f) * 4.25f); + return new Color(scale, 0, 0, 50); + } + return new Color(0, 0, 0, 50); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - float heal = damage * 0.05f; - if ((int)heal == 0) - return; + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + float heal = damage * 0.05f; + if ((int)heal == 0) + return; - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - return; + if (Main.player[Main.myPlayer].lifeSteal <= 0f) + return; - if (heal > CalamityMod.lifeStealCap) - heal = CalamityMod.lifeStealCap; + if (heal > CalamityMod.lifeStealCap) + heal = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 3f); - } + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 3f); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - float heal = damage * 0.05f; - if ((int)heal == 0) - return; + public override void OnHitPvp(Player target, int damage, bool crit) + { + float heal = damage * 0.05f; + if ((int)heal == 0) + return; - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - return; + if (Main.player[Main.myPlayer].lifeSteal <= 0f) + return; - if (heal > CalamityMod.lifeStealCap) - heal = CalamityMod.lifeStealCap; + if (heal > CalamityMod.lifeStealCap) + heal = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 3f); - } - } + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], heal, ProjectileID.VampireHeal, 1200f, 3f); + } + } } diff --git a/Projectiles/Rogue/CorpusAvertorStealth.cs b/Projectiles/Rogue/CorpusAvertorStealth.cs index 29708977e0..3dba9b4f44 100644 --- a/Projectiles/Rogue/CorpusAvertorStealth.cs +++ b/Projectiles/Rogue/CorpusAvertorStealth.cs @@ -9,90 +9,90 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CorpusAvertorStealth : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/CorpusAvertor"; + public class CorpusAvertorStealth : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/CorpusAvertor"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Corpus Avertor"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Corpus Avertor"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 24; - projectile.height = 24; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.timeLeft = 300; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 24; + projectile.height = 24; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.timeLeft = 300; + projectile.Calamity().rogue = true; + } - public override void AI() - { - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.02f; + public override void AI() + { + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.02f; - if (projectile.ai[0] < 120f) - projectile.ai[0] += 1f; + if (projectile.ai[0] < 120f) + projectile.ai[0] += 1f; - projectile.velocity.X *= 1.01f; - projectile.velocity.Y *= 1.01f; + projectile.velocity.X *= 1.01f; + projectile.velocity.Y *= 1.01f; - int scale = (int)((projectile.ai[0] - 60f) * 4.25f); - int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 5, 0f, 0f, 100, new Color(scale, 0, 0, 50), 2f); - Main.dust[dust].velocity *= 0f; - Main.dust[dust].noGravity = true; - } + int scale = (int)((projectile.ai[0] - 60f) * 4.25f); + int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 5, 0f, 0f, 100, new Color(scale, 0, 0, 50), 2f); + Main.dust[dust].velocity *= 0f; + Main.dust[dust].noGravity = true; + } - public override Color? GetAlpha(Color lightColor) => new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, projectile.alpha); + public override Color? GetAlpha(Color lightColor) => new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, projectile.alpha); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - OnHitEffects(damage); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + OnHitEffects(damage); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - OnHitEffects(damage); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(damage); + } - private void OnHitEffects(int damage) - { - Player player = Main.player[projectile.owner]; - if (Main.rand.NextBool(7)) - { - int lifeLossAmt = (int)Math.Ceiling(player.statLife * 0.5); - player.statLife -= lifeLossAmt; - if (Main.myPlayer == player.whoAmI) - player.HealEffect(-lifeLossAmt, true); - if (player.statLife <= 0) - player.KillMe(PlayerDeathReason.ByCustomReason(player.name + " became the blood god's sacrifice."), 1000.0, 0, false); - } - else if (Main.LocalPlayer.team == player.team && player.team != 0) - { - Main.LocalPlayer.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(20f), true); - player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(20f), true); + private void OnHitEffects(int damage) + { + Player player = Main.player[projectile.owner]; + if (Main.rand.NextBool(7)) + { + int lifeLossAmt = (int)Math.Ceiling(player.statLife * 0.5); + player.statLife -= lifeLossAmt; + if (Main.myPlayer == player.whoAmI) + player.HealEffect(-lifeLossAmt, true); + if (player.statLife <= 0) + player.KillMe(PlayerDeathReason.ByCustomReason(player.name + " became the blood god's sacrifice."), 1000.0, 0, false); + } + else if (Main.LocalPlayer.team == player.team && player.team != 0) + { + Main.LocalPlayer.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(20f), true); + player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(20f), true); - float heal = damage * 0.025f; - if ((int)heal == 0) - return; + float heal = damage * 0.025f; + if ((int)heal == 0) + return; - if (Main.player[Main.myPlayer].lifeSteal <= 0f) - return; + if (Main.player[Main.myPlayer].lifeSteal <= 0f) + return; - if (heal > CalamityMod.lifeStealCap) - heal = CalamityMod.lifeStealCap; + if (heal > CalamityMod.lifeStealCap) + heal = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, player, heal, ProjectileID.VampireHeal, 1200f, 3f); - } - } - } + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, player, heal, ProjectileID.VampireHeal, 1200f, 3f); + } + } + } } diff --git a/Projectiles/Rogue/CosmicKunaiProj.cs b/Projectiles/Rogue/CosmicKunaiProj.cs index 6adceeef0f..d807736053 100644 --- a/Projectiles/Rogue/CosmicKunaiProj.cs +++ b/Projectiles/Rogue/CosmicKunaiProj.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CosmicKunaiProj : ModProjectile + public class CosmicKunaiProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/CosmicKunai"; @@ -18,8 +18,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 24; projectile.friendly = true; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.Calamity().rogue = true; } @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.Kill(); } Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.5f / 255f); - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); } } } diff --git a/Projectiles/Rogue/CosmicScythe.cs b/Projectiles/Rogue/CosmicScythe.cs index feb9d89443..9263cc7522 100644 --- a/Projectiles/Rogue/CosmicScythe.cs +++ b/Projectiles/Rogue/CosmicScythe.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CosmicScythe : ModProjectile + public class CosmicScythe : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Boss/SignusScythe"; @@ -51,14 +51,14 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.timeLeft > 350) projectile.velocity *= 1.06f; projectile.damage = (int)(originalDamage * 1.25); - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - int buffType = projectile.ai[0] == 1f ? BuffID.ShadowFlame : ModContent.BuffType(); - target.AddBuff(buffType, 60, false); + int buffType = projectile.ai[0] == 1f ? BuffID.ShadowFlame : ModContent.BuffType(); + target.AddBuff(buffType, 60, false); projectile.Kill(); } @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.Center); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 50); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 50); for (int d = 0; d < 4; d++) { int shadow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 27, 0f, 0f, 100, default, 2f); diff --git a/Projectiles/Rogue/CraniumSMASH.cs b/Projectiles/Rogue/CraniumSMASH.cs index 9cf4c5ae0d..ad709787d8 100644 --- a/Projectiles/Rogue/CraniumSMASH.cs +++ b/Projectiles/Rogue/CraniumSMASH.cs @@ -4,47 +4,47 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Rogue { - public class CraniumSMASH : ModProjectile - { + public class CraniumSMASH : ModProjectile + { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cranium SMASH"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cranium SMASH"); + } - public override void SetDefaults() - { - projectile.width = 192; - projectile.height = 192; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.timeLeft = 10; - projectile.Calamity().rogue = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = -2; - } + public override void SetDefaults() + { + projectile.width = 192; + projectile.height = 192; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = 10; + projectile.Calamity().rogue = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -2; + } - public override void AI() - { - if (projectile.ai[0] == 0f) - SpawnExplosionDust(); - if (projectile.ai[0] <= 1f) - projectile.ai[0]++; - } + public override void AI() + { + if (projectile.ai[0] == 0f) + SpawnExplosionDust(); + if (projectile.ai[0] <= 1f) + projectile.ai[0]++; + } - void SpawnExplosionDust() - { - Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 14); - CalamityUtils.ExplosionGores(projectile.Center, 3); - for (int num194 = 0; num194 < 25; num194++) - { - int num195 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0f, 0f, 100, default, 2f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 0f; - } - } - } + void SpawnExplosionDust() + { + Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 14); + CalamityUtils.ExplosionGores(projectile.Center, 3); + for (int num194 = 0; num194 < 25; num194++) + { + int num195 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0f, 0f, 100, default, 2f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 0f; + } + } + } } diff --git a/Projectiles/Rogue/CraniumSmasherExplosive.cs b/Projectiles/Rogue/CraniumSmasherExplosive.cs index 9d5bb94423..e318c6ae94 100644 --- a/Projectiles/Rogue/CraniumSmasherExplosive.cs +++ b/Projectiles/Rogue/CraniumSmasherExplosive.cs @@ -3,7 +3,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CraniumSmasherExplosive : ModProjectile + public class CraniumSmasherExplosive : ModProjectile { public override void SetStaticDefaults() { @@ -15,8 +15,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 50; projectile.height = 50; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 300; projectile.localNPCHitCooldown = 15; projectile.tileCollide = false; diff --git a/Projectiles/Rogue/CraniumSmasherProj.cs b/Projectiles/Rogue/CraniumSmasherProj.cs index 71fe67556d..0ac5521c1f 100644 --- a/Projectiles/Rogue/CraniumSmasherProj.cs +++ b/Projectiles/Rogue/CraniumSmasherProj.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 50; projectile.height = 50; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 5; + projectile.ignoreWater = true; + projectile.penetrate = 5; projectile.timeLeft = 300; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 15; @@ -47,6 +47,6 @@ namespace CalamityMod.Projectiles.Rogue } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Rogue/CraniumSmasherStealth.cs b/Projectiles/Rogue/CraniumSmasherStealth.cs index 1aa7596445..1418a6e304 100644 --- a/Projectiles/Rogue/CraniumSmasherStealth.cs +++ b/Projectiles/Rogue/CraniumSmasherStealth.cs @@ -6,84 +6,84 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Rogue { - public class CraniumSmasherStealth : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/Rogue/CraniumSmasherExplosive"; + public class CraniumSmasherStealth : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Rogue/CraniumSmasherExplosive"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Stealthy Cranium Smasher"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Stealthy Cranium Smasher"); + } - public override void SetDefaults() - { - projectile.width = 50; - projectile.height = 50; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 5; - projectile.timeLeft = 300; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 15; - projectile.tileCollide = false; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 50; + projectile.height = 50; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = 5; + projectile.timeLeft = 300; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 15; + projectile.tileCollide = false; + projectile.Calamity().rogue = true; + } - public override void AI() - { - projectile.ai[0] += 1f; - if (projectile.ai[0] >= 5f) - { - projectile.tileCollide = true; - } - projectile.rotation += projectile.velocity.X * 0.02f; - projectile.velocity.Y = projectile.velocity.Y + 0.085f; - projectile.velocity.X = projectile.velocity.X * 0.99f; - } + public override void AI() + { + projectile.ai[0] += 1f; + if (projectile.ai[0] >= 5f) + { + projectile.tileCollide = true; + } + projectile.rotation += projectile.velocity.X * 0.02f; + projectile.velocity.Y = projectile.velocity.Y + 0.085f; + projectile.velocity.X = projectile.velocity.X * 0.99f; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (projectile.owner == Main.myPlayer) - { - int smash = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[smash].Center = projectile.Center; - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (projectile.owner == Main.myPlayer) + { + int smash = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); + Main.projectile[smash].Center = projectile.Center; + } + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - if (projectile.owner == Main.myPlayer) - { - int smash = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[smash].Center = projectile.Center; - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + if (projectile.owner == Main.myPlayer) + { + int smash = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); + Main.projectile[smash].Center = projectile.Center; + } + } - public override void Kill(int timeLeft) - { - projectile.position = projectile.Center; - projectile.width = projectile.height = 192; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); - Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 14); - CalamityUtils.ExplosionGores(projectile.Center, 3); - for (int num194 = 0; num194 < 25; num194++) - { - int num195 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0f, 0f, 100, default, 2f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 0f; - } - } + public override void Kill(int timeLeft) + { + projectile.position = projectile.Center; + projectile.width = projectile.height = 192; + projectile.position.X = projectile.position.X - (float)(projectile.width / 2); + projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 14); + CalamityUtils.ExplosionGores(projectile.Center, 3); + for (int num194 = 0; num194 < 25; num194++) + { + int num195 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0f, 0f, 100, default, 2f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 0f; + } + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D tex = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/CraniumSmasherGlow"); - spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); - } - } + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/CraniumSmasherGlow"); + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); + } + } } diff --git a/Projectiles/Rogue/Crushax.cs b/Projectiles/Rogue/Crushax.cs index de3e149bb8..d7f125a72d 100644 --- a/Projectiles/Rogue/Crushax.cs +++ b/Projectiles/Rogue/Crushax.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class Crushax : ModProjectile + public class Crushax : ModProjectile { public override void SetStaticDefaults() { @@ -18,8 +18,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 2; + projectile.ignoreWater = true; + projectile.penetrate = 2; projectile.aiStyle = 2; projectile.timeLeft = 300; projectile.usesLocalNPCImmunity = true; @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Rogue/CrystalPiercerProjectile.cs b/Projectiles/Rogue/CrystalPiercerProjectile.cs index 749438d507..b42a436a09 100644 --- a/Projectiles/Rogue/CrystalPiercerProjectile.cs +++ b/Projectiles/Rogue/CrystalPiercerProjectile.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CrystalPiercerProjectile : ModProjectile + public class CrystalPiercerProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/CrystalPiercer"; @@ -40,16 +40,16 @@ namespace CalamityMod.Projectiles.Rogue projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); projectile.rotation += projectile.spriteDirection * MathHelper.ToRadians(45f); - if (projectile.Calamity().stealthStrike) - { - if (projectile.timeLeft % 4 == 0) - { - if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-15f, 15f), projectile.Center.Y + Main.rand.NextFloat(-15f, 15f), projectile.velocity.X, projectile.velocity.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), projectile.knockBack * 0.4f, projectile.owner, 0f, 0f); - } + if (projectile.Calamity().stealthStrike) + { + if (projectile.timeLeft % 4 == 0) + { + if (projectile.owner == Main.myPlayer) + { + Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-15f, 15f), projectile.Center.Y + Main.rand.NextFloat(-15f, 15f), projectile.velocity.X, projectile.velocity.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), projectile.knockBack * 0.4f, projectile.owner, 0f, 0f); + } } - } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -58,14 +58,14 @@ namespace CalamityMod.Projectiles.Rogue return false; } - //glowmask effect if stealth strike + //glowmask effect if stealth strike public override Color? GetAlpha(Color lightColor) - { - if (projectile.Calamity().stealthStrike) - return new Color(200, 200, 200, 200); - else - return null; - } + { + if (projectile.Calamity().stealthStrike) + return new Color(200, 200, 200, 200); + else + return null; + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Rogue/CrystalPiercerShard.cs b/Projectiles/Rogue/CrystalPiercerShard.cs index 28d362c497..55a466a5fe 100644 --- a/Projectiles/Rogue/CrystalPiercerShard.cs +++ b/Projectiles/Rogue/CrystalPiercerShard.cs @@ -4,14 +4,14 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CrystalPiercerShard : ModProjectile + public class CrystalPiercerShard : ModProjectile { - private bool initialized = false; + private bool initialized = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Crystal Shard"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Crystal Shard"); + } public override void SetDefaults() { @@ -21,20 +21,20 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = 1; projectile.timeLeft = 120; projectile.Calamity().rogue = true; - } + } - public override void AI() + public override void AI() { projectile.rotation += projectile.direction * 0.05f; - if (!initialized) - { - projectile.scale = Main.rand.NextFloat(0.85f, 1.15f); - initialized = true; - } - } + if (!initialized) + { + projectile.scale = Main.rand.NextFloat(0.85f, 1.15f); + initialized = true; + } + } - //glowmask effect + //glowmask effect public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); } } diff --git a/Projectiles/Rogue/Crystalline2.cs b/Projectiles/Rogue/Crystalline2.cs index c12dfbcdbb..830a5a9c1b 100644 --- a/Projectiles/Rogue/Crystalline2.cs +++ b/Projectiles/Rogue/Crystalline2.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class Crystalline2 : ModProjectile + public class Crystalline2 : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Crystalline"; @@ -48,8 +48,8 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft == (projectile.ai[1] == 2f ? 20 : 30)) - return false; + if (projectile.timeLeft == (projectile.ai[1] == 2f ? 20 : 30)) + return false; 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; @@ -66,9 +66,9 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < 3; i++) { Vector2 projspeed = new Vector2(Main.rand.NextFloat(-8f, 8f), Main.rand.NextFloat(-8f, 8f)); - int shard = Projectile.NewProjectile(projectile.Center, projspeed, ProjectileID.CrystalShard, (int)(projectile.damage * 0.4f), 2f, projectile.owner); - if (shard.WithinBounds(Main.maxProjectiles)) - Main.projectile[shard].Calamity().forceRogue = true; + int shard = Projectile.NewProjectile(projectile.Center, projspeed, ProjectileID.CrystalShard, (int)(projectile.damage * 0.4f), 2f, projectile.owner); + if (shard.WithinBounds(Main.maxProjectiles)) + Main.projectile[shard].Calamity().forceRogue = true; } } } diff --git a/Projectiles/Rogue/CrystallineProj.cs b/Projectiles/Rogue/CrystallineProj.cs index 2becb03508..dd051895c6 100644 --- a/Projectiles/Rogue/CrystallineProj.cs +++ b/Projectiles/Rogue/CrystallineProj.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class CrystallineProj : ModProjectile + public class CrystallineProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Crystalline"; diff --git a/Projectiles/Rogue/CursedDaggerProj.cs b/Projectiles/Rogue/CursedDaggerProj.cs index bdddc72975..5f537e3d3c 100644 --- a/Projectiles/Rogue/CursedDaggerProj.cs +++ b/Projectiles/Rogue/CursedDaggerProj.cs @@ -36,23 +36,23 @@ namespace CalamityMod.Projectiles.Rogue Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - if (projectile.Calamity().stealthStrike) - { - if (projectile.timeLeft % 8 == 0) - { - if (projectile.owner == Main.myPlayer) - { - Vector2 velocity = new Vector2(Main.rand.NextFloat(-14f, 14f), Main.rand.NextFloat(-14f, 14f)); - int flame = Projectile.NewProjectile(projectile.Center, velocity, Main.rand.NextBool(2) ? ProjectileID.CursedFlameFriendly : ProjectileID.CursedDartFlame, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); - if (flame.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[flame].Calamity().forceRogue = true; - Main.projectile[flame].usesLocalNPCImmunity = true; - Main.projectile[flame].localNPCHitCooldown = 10; - } - } + if (projectile.Calamity().stealthStrike) + { + if (projectile.timeLeft % 8 == 0) + { + if (projectile.owner == Main.myPlayer) + { + Vector2 velocity = new Vector2(Main.rand.NextFloat(-14f, 14f), Main.rand.NextFloat(-14f, 14f)); + int flame = Projectile.NewProjectile(projectile.Center, velocity, Main.rand.NextBool(2) ? ProjectileID.CursedFlameFriendly : ProjectileID.CursedDartFlame, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); + if (flame.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flame].Calamity().forceRogue = true; + Main.projectile[flame].usesLocalNPCImmunity = true; + Main.projectile[flame].localNPCHitCooldown = 10; + } + } } - } + } } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/DeepSeaDumbbell2.cs b/Projectiles/Rogue/DeepSeaDumbbell2.cs index 5ec4bd319d..c765cb9cd4 100644 --- a/Projectiles/Rogue/DeepSeaDumbbell2.cs +++ b/Projectiles/Rogue/DeepSeaDumbbell2.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.ai[0] += 1f; else { - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); } projectile.rotation += Math.Abs(projectile.velocity.X) * 0.01f * (float)projectile.direction; diff --git a/Projectiles/Rogue/DeepSeaDumbbell3.cs b/Projectiles/Rogue/DeepSeaDumbbell3.cs index d357d40a45..931a572a3c 100644 --- a/Projectiles/Rogue/DeepSeaDumbbell3.cs +++ b/Projectiles/Rogue/DeepSeaDumbbell3.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.ai[0] += 1f; else { - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 12f, 20f); } projectile.rotation += Math.Abs(projectile.velocity.X) * 0.01f * (float)projectile.direction; diff --git a/Projectiles/Rogue/DeepWounderProjectile.cs b/Projectiles/Rogue/DeepWounderProjectile.cs index 2b36d2babc..5654ab22dd 100644 --- a/Projectiles/Rogue/DeepWounderProjectile.cs +++ b/Projectiles/Rogue/DeepWounderProjectile.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = 600; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/DeepWounderWater.cs b/Projectiles/Rogue/DeepWounderWater.cs index 844854db19..5b853c4049 100644 --- a/Projectiles/Rogue/DeepWounderWater.cs +++ b/Projectiles/Rogue/DeepWounderWater.cs @@ -18,8 +18,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 50; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/DeificThunderboltProj.cs b/Projectiles/Rogue/DeificThunderboltProj.cs index dbdb3fec53..77cf8dda89 100644 --- a/Projectiles/Rogue/DeificThunderboltProj.cs +++ b/Projectiles/Rogue/DeificThunderboltProj.cs @@ -6,9 +6,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class DeificThunderboltProj : ModProjectile + public class DeificThunderboltProj : ModProjectile { - private bool playedSound = false; + private bool playedSound = false; public override void SetStaticDefaults() { @@ -43,11 +43,11 @@ namespace CalamityMod.Projectiles.Rogue { projectile.frame = 0; } - if (!playedSound) - { - Main.PlaySound(SoundID.Item92, (int)projectile.position.X, (int)projectile.position.Y); //electrosphere launcher fire sound - playedSound = true; - } + if (!playedSound) + { + Main.PlaySound(SoundID.Item92, (int)projectile.position.X, (int)projectile.position.Y); //electrosphere launcher fire sound + playedSound = true; + } if (Main.rand.NextBool(8)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 132, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); @@ -73,33 +73,33 @@ namespace CalamityMod.Projectiles.Rogue Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 132, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } - if (Main.myPlayer == projectile.owner) - { - bool stealthStrike = projectile.Calamity().stealthStrike; - if (stealthStrike) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)projectile.position.X, (int)projectile.position.Y); - } - int amt = stealthStrike ? 5 : 1; - float damageMult = stealthStrike ? 0.5f : 1f; - for (int n = 0; n < amt; n++) - { - Vector2 spawnPoint = new Vector2(projectile.Center.X + (float)Main.rand.Next(-100, 101), projectile.Center.Y - (float)Main.rand.Next(700, 801)); - float randomVelocity = Main.rand.NextFloat() - 0.5f; - Vector2 fireTo = new Vector2(spawnPoint.X + 100f * randomVelocity, spawnPoint.Y + 900); - Vector2 ai0 = fireTo - spawnPoint; - float ai = (float)Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(0.78539818525314331)) * 9f; - int proj = Projectile.NewProjectile(spawnPoint.X, spawnPoint.Y, velocity.X, velocity.Y, ProjectileID.CultistBossLightningOrbArc, (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner, ai0.ToRotation(), ai); - Main.projectile[proj].extraUpdates += 9; - //Does not force to Rogue because lightning is extremely abusable with Moonstone Crown - Main.projectile[proj].friendly = true; - Main.projectile[proj].hostile = false; - Main.projectile[proj].penetrate = -1; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = -1; - } - } + if (Main.myPlayer == projectile.owner) + { + bool stealthStrike = projectile.Calamity().stealthStrike; + if (stealthStrike) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)projectile.position.X, (int)projectile.position.Y); + } + int amt = stealthStrike ? 5 : 1; + float damageMult = stealthStrike ? 0.5f : 1f; + for (int n = 0; n < amt; n++) + { + Vector2 spawnPoint = new Vector2(projectile.Center.X + (float)Main.rand.Next(-100, 101), projectile.Center.Y - (float)Main.rand.Next(700, 801)); + float randomVelocity = Main.rand.NextFloat() - 0.5f; + Vector2 fireTo = new Vector2(spawnPoint.X + 100f * randomVelocity, spawnPoint.Y + 900); + Vector2 ai0 = fireTo - spawnPoint; + float ai = (float)Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(0.78539818525314331)) * 9f; + int proj = Projectile.NewProjectile(spawnPoint.X, spawnPoint.Y, velocity.X, velocity.Y, ProjectileID.CultistBossLightningOrbArc, (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner, ai0.ToRotation(), ai); + Main.projectile[proj].extraUpdates += 9; + //Does not force to Rogue because lightning is extremely abusable with Moonstone Crown + Main.projectile[proj].friendly = true; + Main.projectile[proj].hostile = false; + Main.projectile[proj].penetrate = -1; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = -1; + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/DesecratedBubble.cs b/Projectiles/Rogue/DesecratedBubble.cs index 2f484f2f17..eeaca57c0c 100644 --- a/Projectiles/Rogue/DesecratedBubble.cs +++ b/Projectiles/Rogue/DesecratedBubble.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class DesecratedBubble : ModProjectile + public class DesecratedBubble : ModProjectile { public override void SetStaticDefaults() { @@ -34,22 +34,22 @@ namespace CalamityMod.Projectiles.Rogue { projectile.alpha -= 20; } - if (projectile.timeLeft <= 100) - { - projectile.ai[1] = 0f; - } - else - { - projectile.velocity *= 0.995f; - } + if (projectile.timeLeft <= 100) + { + projectile.ai[1] = 0f; + } + else + { + projectile.velocity *= 0.995f; + } if (Main.player[projectile.owner].active && !Main.player[projectile.owner].dead) { - if (projectile.ai[1] == 0f) - { - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 8f, 20f); - } + if (projectile.ai[1] == 0f) + { + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 8f, 20f); + } } - } + } public override void Kill(int timeLeft) { @@ -66,32 +66,32 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.ai[0] == 1f) - { - target.AddBuff(BuffID.Ichor, 180); - target.AddBuff(BuffID.CursedInferno, 180); - } + if (projectile.ai[0] == 1f) + { + target.AddBuff(BuffID.Ichor, 180); + target.AddBuff(BuffID.CursedInferno, 180); + } } public override void OnHitPvp(Player target, int damage, bool crit) { - if (projectile.ai[0] == 1f) - { - target.AddBuff(BuffID.Ichor, 180); - target.AddBuff(BuffID.CursedInferno, 180); - } + if (projectile.ai[0] == 1f) + { + target.AddBuff(BuffID.Ichor, 180); + target.AddBuff(BuffID.CursedInferno, 180); + } } - // Cannot deal damage for the first several frames of existence. + // Cannot deal damage for the first several frames of existence. public override bool? CanHitNPC(NPC target) - { - if (projectile.timeLeft >= 100) - { - return false; - } - return null; - } + { + if (projectile.timeLeft >= 100) + { + return false; + } + return null; + } - public override bool CanHitPvp(Player target) => projectile.timeLeft < 100; + public override bool CanHitPvp(Player target) => projectile.timeLeft < 100; } } \ No newline at end of file diff --git a/Projectiles/Rogue/DesecratedWaterProj.cs b/Projectiles/Rogue/DesecratedWaterProj.cs index 0120c37d0d..24d2cd420b 100644 --- a/Projectiles/Rogue/DesecratedWaterProj.cs +++ b/Projectiles/Rogue/DesecratedWaterProj.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 25; projectile.height = 25; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 2; projectile.timeLeft = 300; aiType = ProjectileID.ThrowingKnife; @@ -29,20 +29,20 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Shatter, (int) projectile.position.X, (int) projectile.position.Y, 1, 1f, 0.0f); - Vector2 vector2 = new Vector2(20f, 20f); - for (int index = 0; index < 10; ++index) - Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 191, 0.0f, 0.0f); - for (int index1 = 0; index1 < 20; ++index1) - { - int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 179, 0.0f, 0.0f, 100, new Color(), 2.5f); - Main.dust[index2].noGravity = true; - Dust dust1 = Main.dust[index2]; - dust1.velocity = dust1.velocity * 5f; - int index3 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 179, 0.0f, 0.0f, 100, new Color(), 1.5f); - Dust dust2 = Main.dust[index3]; - dust2.velocity = dust2.velocity * 3f; - } + Main.PlaySound(SoundID.Shatter, (int) projectile.position.X, (int) projectile.position.Y, 1, 1f, 0.0f); + Vector2 vector2 = new Vector2(20f, 20f); + for (int index = 0; index < 10; ++index) + Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 191, 0.0f, 0.0f); + for (int index1 = 0; index1 < 20; ++index1) + { + int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 179, 0.0f, 0.0f, 100, new Color(), 2.5f); + Main.dust[index2].noGravity = true; + Dust dust1 = Main.dust[index2]; + dust1.velocity = dust1.velocity * 5f; + int index3 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 179, 0.0f, 0.0f, 100, new Color(), 1.5f); + Dust dust2 = Main.dust[index3]; + dust2.velocity = dust2.velocity * 3f; + } int num220 = (projectile.Calamity().stealthStrike ? Main.rand.Next(10, 16) : Main.rand.Next(5, 11)); if (projectile.owner == Main.myPlayer) { diff --git a/Projectiles/Rogue/DestructionBolt.cs b/Projectiles/Rogue/DestructionBolt.cs index f467af26f8..5e93e241e4 100644 --- a/Projectiles/Rogue/DestructionBolt.cs +++ b/Projectiles/Rogue/DestructionBolt.cs @@ -8,13 +8,13 @@ namespace CalamityMod.Projectiles.Rogue { public class DestructionBolt : ModProjectile { - public int dustType = 191; + public int dustType = 191; public override void SetStaticDefaults() { DisplayName.SetDefault("Destruction Bolt"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } public override void SetDefaults() { @@ -24,120 +24,120 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = 1; projectile.extraUpdates = 1; projectile.alpha = 255; - projectile.timeLeft = 300; - projectile.Calamity().rogue = true; - projectile.tileCollide = false; - } + projectile.timeLeft = 300; + projectile.Calamity().rogue = true; + projectile.tileCollide = false; + } - public override void AI() - { + public override void AI() + { if (Main.rand.Next(8) == 0) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - if (projectile.alpha > 0) - projectile.alpha -= 8; + if (projectile.alpha > 0) + projectile.alpha -= 8; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - float num29 = 5f; - float num30 = 300f; - float scaleFactor = 6f; - Vector2 value7 = new Vector2(10f, 20f); - int num32 = 3 * projectile.MaxUpdates; - if (projectile.ai[1] == 0f) - { - projectile.ai[1] = 1f; - projectile.localAI[0] = (float)-(float)Main.rand.Next(48); - } - else if (projectile.ai[1] == 1f && projectile.owner == Main.myPlayer) - { - if (projectile.alpha < 128) - { - int num35 = -1; - float num36 = num30; - for (int num37 = 0; num37 < Main.maxNPCs; num37++) - { - if (Main.npc[num37].active && Main.npc[num37].CanBeChasedBy(projectile, false)) - { - Vector2 center3 = Main.npc[num37].Center; - float num38 = Vector2.Distance(center3, projectile.Center); - if (num38 < num36 && num35 == -1 && Collision.CanHitLine(projectile.Center, 1, 1, center3, 1, 1)) - { - num36 = num38; - num35 = num37; - } - } - } - if (num36 < 4f) - { - projectile.Kill(); - return; - } - if (num35 != -1) - { - projectile.ai[1] = num29 + 1f; - projectile.ai[0] = (float)num35; - projectile.netUpdate = true; - } - } - } - else if (projectile.ai[1] > num29) - { - projectile.ai[1] += 1f; - int num39 = (int)projectile.ai[0]; - if (!Main.npc[num39].active || !Main.npc[num39].CanBeChasedBy(projectile, false)) - { - projectile.ai[1] = 1f; - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - else - { - projectile.velocity.ToRotation(); - Vector2 vector6 = Main.npc[num39].Center - projectile.Center; - if (vector6.Length() < 10f) - { - projectile.Kill(); - return; - } - if (vector6 != Vector2.Zero) - { - vector6.Normalize(); - vector6 *= scaleFactor; - } - float num40 = 30f; - projectile.velocity = (projectile.velocity * (num40 - 1f) + vector6) / num40; - } - } - if (projectile.ai[1] >= 1f && projectile.ai[1] < num29) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] == num29) - { - projectile.ai[1] = 1f; - } - } - projectile.localAI[0] += 1f; - if (projectile.localAI[0] == 48f) - { - projectile.localAI[0] = 0f; - } - } + float num29 = 5f; + float num30 = 300f; + float scaleFactor = 6f; + Vector2 value7 = new Vector2(10f, 20f); + int num32 = 3 * projectile.MaxUpdates; + if (projectile.ai[1] == 0f) + { + projectile.ai[1] = 1f; + projectile.localAI[0] = (float)-(float)Main.rand.Next(48); + } + else if (projectile.ai[1] == 1f && projectile.owner == Main.myPlayer) + { + if (projectile.alpha < 128) + { + int num35 = -1; + float num36 = num30; + for (int num37 = 0; num37 < Main.maxNPCs; num37++) + { + if (Main.npc[num37].active && Main.npc[num37].CanBeChasedBy(projectile, false)) + { + Vector2 center3 = Main.npc[num37].Center; + float num38 = Vector2.Distance(center3, projectile.Center); + if (num38 < num36 && num35 == -1 && Collision.CanHitLine(projectile.Center, 1, 1, center3, 1, 1)) + { + num36 = num38; + num35 = num37; + } + } + } + if (num36 < 4f) + { + projectile.Kill(); + return; + } + if (num35 != -1) + { + projectile.ai[1] = num29 + 1f; + projectile.ai[0] = (float)num35; + projectile.netUpdate = true; + } + } + } + else if (projectile.ai[1] > num29) + { + projectile.ai[1] += 1f; + int num39 = (int)projectile.ai[0]; + if (!Main.npc[num39].active || !Main.npc[num39].CanBeChasedBy(projectile, false)) + { + projectile.ai[1] = 1f; + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + else + { + projectile.velocity.ToRotation(); + Vector2 vector6 = Main.npc[num39].Center - projectile.Center; + if (vector6.Length() < 10f) + { + projectile.Kill(); + return; + } + if (vector6 != Vector2.Zero) + { + vector6.Normalize(); + vector6 *= scaleFactor; + } + float num40 = 30f; + projectile.velocity = (projectile.velocity * (num40 - 1f) + vector6) / num40; + } + } + if (projectile.ai[1] >= 1f && projectile.ai[1] < num29) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] == num29) + { + projectile.ai[1] = 1f; + } + } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] == 48f) + { + projectile.localAI[0] = 0f; + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); - return false; + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + return false; } - public override bool CanDamage() - { - return projectile.alpha < 128; - } + public override bool CanDamage() + { + return projectile.alpha < 128; + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { projectile.position = projectile.Center; projectile.width = projectile.height = 50; @@ -148,8 +148,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.Damage(); - Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); - for (int num621 = 0; num621 < 20; num621++) + Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); + for (int num621 = 0; num621 < 20; num621++) { int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; @@ -167,7 +167,7 @@ namespace CalamityMod.Projectiles.Rogue num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 9); + CalamityUtils.ExplosionGores(projectile.Center, 9); } } } diff --git a/Projectiles/Rogue/DestructionStar.cs b/Projectiles/Rogue/DestructionStar.cs index 34645562d9..6084870689 100644 --- a/Projectiles/Rogue/DestructionStar.cs +++ b/Projectiles/Rogue/DestructionStar.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Projectiles.Rogue { public override string Texture => "CalamityMod/Items/Weapons/Rogue/StarofDestruction"; - public int hitCount = 0; + public int hitCount = 0; private static float Radius = 47f; public override void SetStaticDefaults() @@ -40,8 +40,8 @@ namespace CalamityMod.Projectiles.Rogue Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 191, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } projectile.rotation += Math.Sign(projectile.velocity.X) * MathHelper.ToRadians(8f); - if (projectile.Calamity().stealthStrike || hitCount > 16) - hitCount = 16; + if (projectile.Calamity().stealthStrike || hitCount > 16) + hitCount = 16; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -67,20 +67,20 @@ namespace CalamityMod.Projectiles.Rogue { Main.PlaySound(SoundID.Item14, projectile.Center); Vector2 vector2 = new Vector2(20f, 20f); - for (int index1 = 0; index1 < 10; ++index1) - { - int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); - Dust dust = Main.dust[index2]; - dust.velocity = dust.velocity * 1.4f; - } + for (int index1 = 0; index1 < 10; ++index1) + { + int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); + Dust dust = Main.dust[index2]; + dust.velocity = dust.velocity * 1.4f; + } if (projectile.owner == Main.myPlayer) { - for (int i = 0; i < hitCount; i++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + for (int i = 0; i < hitCount; i++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, Main.myPlayer, 0f, 0f); } - } - } + } + } } } diff --git a/Projectiles/Rogue/DragonShit.cs b/Projectiles/Rogue/DragonShit.cs index 73117aab85..ead922e7ba 100644 --- a/Projectiles/Rogue/DragonShit.cs +++ b/Projectiles/Rogue/DragonShit.cs @@ -27,12 +27,12 @@ namespace CalamityMod.Projectiles.Rogue projectile.tileCollide = false; projectile.penetrate = 1; projectile.timeLeft = 420; - projectile.Calamity().rogue = true; - } + projectile.Calamity().rogue = true; + } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 380 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 380 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { target = projectile.Center.ClosestNPCAt(1200f); if (projectile.localAI[0] == 0f) @@ -50,38 +50,38 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.frame >= Main.projFrames[projectile.type]) projectile.frame = 0; - if (projectile.timeLeft >= 380) - { - projectile.velocity *= 1.07f; - } - else if (target != null) - { - projectile.velocity = (projectile.velocity * 23f + projectile.SafeDirectionTo(target.Center) * 14.975f) / 24f; - } - else - { - projectile.timeLeft = Math.Min(projectile.timeLeft, 15); - projectile.alpha += 17; - projectile.velocity = rotationVector; - rotationVector = rotationVector.RotatedBy(MathHelper.ToRadians(14.975f * projectile.ai[0])); - } + if (projectile.timeLeft >= 380) + { + projectile.velocity *= 1.07f; + } + else if (target != null) + { + projectile.velocity = (projectile.velocity * 23f + projectile.SafeDirectionTo(target.Center) * 14.975f) / 24f; + } + else + { + projectile.timeLeft = Math.Min(projectile.timeLeft, 15); + projectile.alpha += 17; + projectile.velocity = rotationVector; + rotationVector = rotationVector.RotatedBy(MathHelper.ToRadians(14.975f * projectile.ai[0])); + } } - // Reduce damage of projectiles if more than the cap are active - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; - int cap = 5; - int oldDamage = damage; - if (projectileCount > cap) - { - damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); - if (damage < 1) - damage = 1; - } - } + // Reduce damage of projectiles if more than the cap are active + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; + int cap = 5; + int oldDamage = damage; + if (projectileCount > cap) + { + damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); + if (damage < 1) + damage = 1; + } + } - public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -95,7 +95,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.Center); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 80); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 80); for (int d = 0; d < 5; d++) { int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); @@ -114,7 +114,7 @@ namespace CalamityMod.Projectiles.Rogue idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[idx].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Rogue/DukesDecapitatorBubble.cs b/Projectiles/Rogue/DukesDecapitatorBubble.cs index 77347524df..2d1f6e59e9 100644 --- a/Projectiles/Rogue/DukesDecapitatorBubble.cs +++ b/Projectiles/Rogue/DukesDecapitatorBubble.cs @@ -5,24 +5,24 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class DukesDecapitatorBubble : ModProjectile + public class DukesDecapitatorBubble : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Typeless/CoralBubble"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bubble"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bubble"); + } public override void SetDefaults() { projectile.width = 30; projectile.height = 30; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.alpha = 255; projectile.penetrate = 1; - projectile.timeLeft = 300; + projectile.timeLeft = 300; } public override void AI() @@ -69,14 +69,14 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item54, projectile.position); - int num190 = Main.rand.Next(5, 9); - for (int num191 = 0; num191 < num190; num191++) - { - int num192 = Dust.NewDust(projectile.Center, 0, 0, 206, 0f, 0f, 100, default, 1.4f); - Main.dust[num192].velocity *= 0.8f; - Main.dust[num192].position = Vector2.Lerp(Main.dust[num192].position, projectile.Center, 0.5f); - Main.dust[num192].noGravity = true; - } + int num190 = Main.rand.Next(5, 9); + for (int num191 = 0; num191 < num190; num191++) + { + int num192 = Dust.NewDust(projectile.Center, 0, 0, 206, 0f, 0f, 100, default, 1.4f); + Main.dust[num192].velocity *= 0.8f; + Main.dust[num192].position = Vector2.Lerp(Main.dust[num192].position, projectile.Center, 0.5f); + Main.dust[num192].noGravity = true; + } } } } diff --git a/Projectiles/Rogue/DukesDecapitatorProj.cs b/Projectiles/Rogue/DukesDecapitatorProj.cs index 2162902ecd..f2315a16f0 100644 --- a/Projectiles/Rogue/DukesDecapitatorProj.cs +++ b/Projectiles/Rogue/DukesDecapitatorProj.cs @@ -7,70 +7,70 @@ using CalamityMod.CalPlayer; namespace CalamityMod.Projectiles.Rogue { - public class DukesDecapitatorProj : ModProjectile - { - float rotationAmount = 1.5f; - public override string Texture => "CalamityMod/Items/Weapons/Rogue/DukesDecapitator"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Decapitator"); + public class DukesDecapitatorProj : ModProjectile + { + float rotationAmount = 1.5f; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/DukesDecapitator"; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Decapitator"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + } public override void SetDefaults() { projectile.width = 30; projectile.height = 30; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = 600; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - projectile.tileCollide = false; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + projectile.tileCollide = false; projectile.Calamity().rogue = true; - } + } - public override void AI() + public override void AI() { CalamityPlayer modPlayer = Main.player[projectile.owner].Calamity(); - if (projectile.velocity.X != 0 || projectile.velocity.Y != 0) - { - projectile.velocity *= 0.99f; - } - projectile.ai[0] += 1f; - if (projectile.ai[0] == 5f) - projectile.tileCollide = true; + if (projectile.velocity.X != 0 || projectile.velocity.Y != 0) + { + projectile.velocity *= 0.99f; + } + projectile.ai[0] += 1f; + if (projectile.ai[0] == 5f) + projectile.tileCollide = true; - if ((projectile.ai[0] % 15f) == 0f && rotationAmount > 0) - { - rotationAmount -= 0.05f; - if (projectile.Calamity().stealthStrike && projectile.owner == Main.myPlayer) - { - float velocityX = Main.rand.NextFloat(-0.8f, 0.8f); - float velocityY = Main.rand.NextFloat(-0.8f, -0.8f); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, velocityX, velocityY, ModContent.ProjectileType(), (int)(projectile.damage * 0.8), projectile.knockBack, projectile.owner); - } - } - if (rotationAmount <= 0f) - projectile.Kill(); + if ((projectile.ai[0] % 15f) == 0f && rotationAmount > 0) + { + rotationAmount -= 0.05f; + if (projectile.Calamity().stealthStrike && projectile.owner == Main.myPlayer) + { + float velocityX = Main.rand.NextFloat(-0.8f, 0.8f); + float velocityY = Main.rand.NextFloat(-0.8f, -0.8f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, velocityX, velocityY, ModContent.ProjectileType(), (int)(projectile.damage * 0.8), projectile.knockBack, projectile.owner); + } + } + if (rotationAmount <= 0f) + projectile.Kill(); - projectile.rotation += rotationAmount; - } + projectile.rotation += rotationAmount; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - projectile.velocity = Vector2.Zero; - rotationAmount -= 0.05f; - } + projectile.velocity = Vector2.Zero; + rotationAmount -= 0.05f; + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { - for (int i = 0; i < 20; i++) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 49, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 0, new Color(255, 255, 255), 0.75f); - } + for (int i = 0; i < 20; i++) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 49, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 0, new Color(255, 255, 255), 0.75f); + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/DuneHopperProjectile.cs b/Projectiles/Rogue/DuneHopperProjectile.cs index f125b854f2..bcc9338f29 100644 --- a/Projectiles/Rogue/DuneHopperProjectile.cs +++ b/Projectiles/Rogue/DuneHopperProjectile.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class DuneHopperProjectile : ModProjectile + public class DuneHopperProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/DuneHopper"; diff --git a/Projectiles/Rogue/DuststormCloud.cs b/Projectiles/Rogue/DuststormCloud.cs index a488447d8a..b175832205 100644 --- a/Projectiles/Rogue/DuststormCloud.cs +++ b/Projectiles/Rogue/DuststormCloud.cs @@ -2,66 +2,66 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class DuststormCloud : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cloud"); - Main.projFrames[projectile.type] = 4; - } + public class DuststormCloud : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cloud"); + Main.projFrames[projectile.type] = 4; + } - public override void SetDefaults() - { - projectile.width = 38; - projectile.height = 14; - projectile.friendly = true; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 3600; - projectile.Calamity().rogue = true; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 5; - } + public override void SetDefaults() + { + projectile.width = 38; + projectile.height = 14; + projectile.friendly = true; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 3600; + projectile.Calamity().rogue = true; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 5; + } - public override void AI() - { - projectile.frameCounter++; - if (projectile.frameCounter > 6) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } - projectile.velocity *= 0.995f; - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 120f) - { - if (projectile.alpha < 255) - { - projectile.alpha += 5; - if (projectile.alpha > 255) - { - projectile.alpha = 255; - } - } - else if (projectile.owner == Main.myPlayer) - { - projectile.Kill(); - } - } - else if (projectile.alpha > 80) - { - projectile.alpha -= 30; - if (projectile.alpha < 80) - { - projectile.alpha = 80; - } - } - } - } + public override void AI() + { + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + projectile.velocity *= 0.995f; + projectile.ai[1] += 1f; + if (projectile.ai[1] >= 120f) + { + if (projectile.alpha < 255) + { + projectile.alpha += 5; + if (projectile.alpha > 255) + { + projectile.alpha = 255; + } + } + else if (projectile.owner == Main.myPlayer) + { + projectile.Kill(); + } + } + else if (projectile.alpha > 80) + { + projectile.alpha -= 30; + if (projectile.alpha < 80) + { + projectile.alpha = 80; + } + } + } + } } diff --git a/Projectiles/Rogue/DuststormCloudStealth.cs b/Projectiles/Rogue/DuststormCloudStealth.cs index 396252143f..3a092f808b 100644 --- a/Projectiles/Rogue/DuststormCloudStealth.cs +++ b/Projectiles/Rogue/DuststormCloudStealth.cs @@ -2,68 +2,68 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class DuststormCloudStealth : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/Rogue/DuststormCloud"; + public class DuststormCloudStealth : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Rogue/DuststormCloud"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cloud"); - Main.projFrames[projectile.type] = 4; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cloud"); + Main.projFrames[projectile.type] = 4; + } - public override void SetDefaults() - { - projectile.width = 38; - projectile.height = 14; - projectile.friendly = true; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 3600; - projectile.Calamity().rogue = true; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 4; - } + public override void SetDefaults() + { + projectile.width = 38; + projectile.height = 14; + projectile.friendly = true; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 3600; + projectile.Calamity().rogue = true; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 4; + } - public override void AI() - { - projectile.frameCounter++; - if (projectile.frameCounter > 6) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } - projectile.velocity *= 0.998f; - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 120f) - { - if (projectile.alpha < 255) - { - projectile.alpha += 3; - if (projectile.alpha > 255) - { - projectile.alpha = 255; - } - } - else if (projectile.owner == Main.myPlayer) - { - projectile.Kill(); - } - } - else if (projectile.alpha > 80) - { - projectile.alpha -= 30; - if (projectile.alpha < 80) - { - projectile.alpha = 80; - } - } - } - } + public override void AI() + { + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + projectile.velocity *= 0.998f; + projectile.ai[1] += 1f; + if (projectile.ai[1] >= 120f) + { + if (projectile.alpha < 255) + { + projectile.alpha += 3; + if (projectile.alpha > 255) + { + projectile.alpha = 255; + } + } + else if (projectile.owner == Main.myPlayer) + { + projectile.Kill(); + } + } + else if (projectile.alpha > 80) + { + projectile.alpha -= 30; + if (projectile.alpha < 80) + { + projectile.alpha = 80; + } + } + } + } } diff --git a/Projectiles/Rogue/DuststormInABottleProj.cs b/Projectiles/Rogue/DuststormInABottleProj.cs index f03be7d21f..12770aa971 100644 --- a/Projectiles/Rogue/DuststormInABottleProj.cs +++ b/Projectiles/Rogue/DuststormInABottleProj.cs @@ -4,48 +4,48 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class DuststormInABottleProj : ModProjectile - { + public class DuststormInABottleProj : ModProjectile + { public override string Texture => "CalamityMod/Items/Weapons/Rogue/DuststormInABottle"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Duststorm"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Duststorm"); + } - public override void SetDefaults() - { - projectile.width = 20; - projectile.height = 20; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; - projectile.aiStyle = 2; - projectile.timeLeft = 180; - aiType = ProjectileID.ThrowingKnife; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 20; + projectile.height = 20; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = 1; + projectile.aiStyle = 2; + projectile.timeLeft = 180; + aiType = ProjectileID.ThrowingKnife; + projectile.Calamity().rogue = true; + } - public override void Kill(int timeLeft) - { - bool stealth = projectile.Calamity().stealthStrike; - Main.PlaySound(SoundID.Item107, projectile.Center); - for (int k = 0; k < 15; k++) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 85, projectile.oldVelocity.X, projectile.oldVelocity.Y); - } - int cloudAmt = Main.rand.Next(20, 31); - if (stealth) - cloudAmt *= 2; - int projType = stealth ? ModContent.ProjectileType() : ModContent.ProjectileType(); - if (projectile.owner == Main.myPlayer) - { - for (int index = 0; index < cloudAmt; index++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); - Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, projectile.knockBack * 0.5f, projectile.owner, stealth ? 1f : 0f, (float)Main.rand.Next(-45, 1)); - } - } - } - } + public override void Kill(int timeLeft) + { + bool stealth = projectile.Calamity().stealthStrike; + Main.PlaySound(SoundID.Item107, projectile.Center); + for (int k = 0; k < 15; k++) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 85, projectile.oldVelocity.X, projectile.oldVelocity.Y); + } + int cloudAmt = Main.rand.Next(20, 31); + if (stealth) + cloudAmt *= 2; + int projType = stealth ? ModContent.ProjectileType() : ModContent.ProjectileType(); + if (projectile.owner == Main.myPlayer) + { + for (int index = 0; index < cloudAmt; index++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); + Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, projectile.knockBack * 0.5f, projectile.owner, stealth ? 1f : 0f, (float)Main.rand.Next(-45, 1)); + } + } + } + } } diff --git a/Projectiles/Rogue/EclipseMirrorBurst.cs b/Projectiles/Rogue/EclipseMirrorBurst.cs index 05f3f06686..1f3cd76a55 100644 --- a/Projectiles/Rogue/EclipseMirrorBurst.cs +++ b/Projectiles/Rogue/EclipseMirrorBurst.cs @@ -59,12 +59,12 @@ namespace CalamityMod.Projectiles.Rogue new Rectangle(frameX * 752, frameY * 752, 752, 752), Color.White, projectile.rotation, - projectile.Size / 2f, + projectile.Size / 2f, projectile.scale, SpriteEffects.None, 0f ); - return false; + return false; } } } diff --git a/Projectiles/Rogue/EclipsesFallMain.cs b/Projectiles/Rogue/EclipsesFallMain.cs index e690167c0e..3c8f29984b 100644 --- a/Projectiles/Rogue/EclipsesFallMain.cs +++ b/Projectiles/Rogue/EclipsesFallMain.cs @@ -6,66 +6,66 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class EclipsesFallMain : ModProjectile - { + public class EclipsesFallMain : ModProjectile + { public override string Texture => "CalamityMod/Items/Weapons/Rogue/EclipsesFall"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Eclipse's Fall"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eclipse's Fall"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 26; - projectile.height = 26; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.extraUpdates = 1; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.timeLeft = 300; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 26; + projectile.height = 26; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.extraUpdates = 1; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.timeLeft = 300; + projectile.Calamity().rogue = true; + } - public override void AI() - { - if (Main.rand.NextBool(8)) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 138, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; - } + public override void AI() + { + if (Main.rand.NextBool(8)) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 138, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - SpawnSpears(target.Center); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + SpawnSpears(target.Center); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - SpawnSpears(target.Center); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + SpawnSpears(target.Center); + } - private void SpawnSpears(Vector2 targetPos) - { - int spearAmt = Main.rand.Next(3, 6); //3 to 5 spears - for (int n = 0; n < spearAmt; n++) - { - float dmgMult = 0.08f * Main.rand.NextFloat(4f, 7f); - float kBMult = 0.1f * Main.rand.NextFloat(7f, 10f); - CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(projectile.damage * dmgMult), projectile.knockBack * kBMult, projectile.owner); - } - } + private void SpawnSpears(Vector2 targetPos) + { + int spearAmt = Main.rand.Next(3, 6); //3 to 5 spears + for (int n = 0; n < spearAmt; n++) + { + float dmgMult = 0.08f * Main.rand.NextFloat(4f, 7f); + float kBMult = 0.1f * Main.rand.NextFloat(7f, 10f); + CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(projectile.damage * dmgMult), projectile.knockBack * kBMult, projectile.owner); + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Rogue/EclipsesSmol.cs b/Projectiles/Rogue/EclipsesSmol.cs index 25b669f162..b47d23e22e 100644 --- a/Projectiles/Rogue/EclipsesSmol.cs +++ b/Projectiles/Rogue/EclipsesSmol.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class EclipsesSmol : ModProjectile + public class EclipsesSmol : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Rogue/EclipsesStealth.cs b/Projectiles/Rogue/EclipsesStealth.cs index 7aa3f2efd9..9d39d5088e 100644 --- a/Projectiles/Rogue/EclipsesStealth.cs +++ b/Projectiles/Rogue/EclipsesStealth.cs @@ -6,115 +6,115 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class EclipsesStealth : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/EclipsesFall"; + public class EclipsesStealth : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/EclipsesFall"; - // For more consistent DPS, always alternates between spawning 1 and 2 spears instead of picking randomly - private bool spawnTwoSpears = true; - private bool changedTimeLeft = false; + // For more consistent DPS, always alternates between spawning 1 and 2 spears instead of picking randomly + private bool spawnTwoSpears = true; + private bool changedTimeLeft = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Eclipse's Fall"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eclipse's Fall"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 25; - projectile.height = 25; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.timeLeft = 300; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = -1; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 25; + projectile.height = 25; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft = 300; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; + projectile.Calamity().rogue = true; + } - // Uses localAI[1] to decide how many frames until the next spear drops. - public override void AI() - { - // Behavior when not sticking to anything - if (projectile.ai[0] == 0f) - { - // Keep the spear oriented in the correct direction - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; + // Uses localAI[1] to decide how many frames until the next spear drops. + public override void AI() + { + // Behavior when not sticking to anything + if (projectile.ai[0] == 0f) + { + // Keep the spear oriented in the correct direction + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; - // Spawn dust while flying - if (Main.rand.NextBool(8)) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 138, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } + // Spawn dust while flying + if (Main.rand.NextBool(8)) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 138, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } - // Behavior when having impaled a target - else - { - // Eclipse's Fall is guaranteed to impale for 10 seconds, no more, no less - if (!changedTimeLeft) - { - projectile.timeLeft = 600; - changedTimeLeft = true; - } + // Behavior when having impaled a target + else + { + // Eclipse's Fall is guaranteed to impale for 10 seconds, no more, no less + if (!changedTimeLeft) + { + projectile.timeLeft = 600; + changedTimeLeft = true; + } - // Spawn spears. As this uses local AI, it's done client-side only. - if (projectile.owner == Main.myPlayer) - { - projectile.localAI[1] -= 1f; + // Spawn spears. As this uses local AI, it's done client-side only. + if (projectile.owner == Main.myPlayer) + { + projectile.localAI[1] -= 1f; - if (projectile.localAI[1] <= 0f) - { - // Set up the spear counter for next time. Used to be every 5 frames there was a 50% chance; now it's more reliable but slower. - projectile.localAI[1] = Main.rand.Next(8, 14); // 8 to 13 frames between each spearfall + if (projectile.localAI[1] <= 0f) + { + // Set up the spear counter for next time. Used to be every 5 frames there was a 50% chance; now it's more reliable but slower. + projectile.localAI[1] = Main.rand.Next(8, 14); // 8 to 13 frames between each spearfall - int type = ModContent.ProjectileType(); - int smolDamage = (int)(projectile.damage * 0.22f); - float smolKB = 3f; - // Used to be a 50% chance each spearfall for 1 or 2. Now is consistent. - int numSpears = spawnTwoSpears ? 2 : 1; - spawnTwoSpears = !spawnTwoSpears; - for (int i = 0; i < numSpears; ++i) - CalamityUtils.ProjectileRain(projectile.Center, 400f, 100f, 500f, 800f, 29f, type, smolDamage, smolKB, projectile.owner); - } - } - } + int type = ModContent.ProjectileType(); + int smolDamage = (int)(projectile.damage * 0.22f); + float smolKB = 3f; + // Used to be a 50% chance each spearfall for 1 or 2. Now is consistent. + int numSpears = spawnTwoSpears ? 2 : 1; + spawnTwoSpears = !spawnTwoSpears; + for (int i = 0; i < numSpears; ++i) + CalamityUtils.ProjectileRain(projectile.Center, 400f, 100f, 500f, 800f, 29f, type, smolDamage, smolKB, projectile.owner); + } + } + } - // Sticky behavior. Lets the projectile impale enemies and sticks to its impaled enemy automatically. - projectile.StickyProjAI(10); - } + // Sticky behavior. Lets the projectile impale enemies and sticks to its impaled enemy automatically. + projectile.StickyProjAI(10); + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - // Impale the enemy on contact ("sticky behavior"). - projectile.ModifyHitNPCSticky(1, true); - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + // Impale the enemy on contact ("sticky behavior"). + projectile.ModifyHitNPCSticky(1, true); + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (targetHitbox.Width > 8 && targetHitbox.Height > 8) - { - targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8); - } - return null; - } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (targetHitbox.Width > 8 && targetHitbox.Height > 8) + { + targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8); + } + return null; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } public override bool? CanHitNPC(NPC target) - { - if (projectile.ai[0] == 1f) - { - return false; - } - return null; - } + { + if (projectile.ai[0] == 1f) + { + return false; + } + return null; + } - public override bool CanHitPvp(Player target) => projectile.ai[0] != 1f; - } + public override bool CanHitPvp(Player target) => projectile.ai[0] != 1f; + } } diff --git a/Projectiles/Rogue/EpidemicShredderProjectile.cs b/Projectiles/Rogue/EpidemicShredderProjectile.cs index a759ac4d0b..c348432cdb 100644 --- a/Projectiles/Rogue/EpidemicShredderProjectile.cs +++ b/Projectiles/Rogue/EpidemicShredderProjectile.cs @@ -7,7 +7,7 @@ using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Rogue { - public class EpidemicShredderProjectile : ModProjectile + public class EpidemicShredderProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/EpidemicShredder"; @@ -45,8 +45,8 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.timeLeft % 5 == 0 && projectile.Calamity().stealthStrike) { int projIndex2 = Projectile.NewProjectile(projectile.Center, (projectile.velocity * -1f).RotatedByRandom(MathHelper.ToRadians(15f)), ModContent.ProjectileType(), (int)(projectile.damage * 0.25f), 2f, projectile.owner); - if (projIndex2.WithinBounds(Main.maxProjectiles)) - Main.projectile[projIndex2].Calamity().forceRogue = true; + if (projIndex2.WithinBounds(Main.maxProjectiles)) + Main.projectile[projIndex2].Calamity().forceRogue = true; } } @@ -65,8 +65,8 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.ai[0] == 0f) { int projIndex1 = Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25f), 2f, projectile.owner); - if (projIndex1.WithinBounds(Main.maxProjectiles)) - Main.projectile[projIndex1].Calamity().forceRogue = true; + if (projIndex1.WithinBounds(Main.maxProjectiles)) + Main.projectile[projIndex1].Calamity().forceRogue = true; projectile.ai[0] = 12f; //0.2th of a second cooldown } projectile.penetrate--; @@ -82,8 +82,8 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.ai[0] == 0f) { int projectileIndex = Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25f), 2f, projectile.owner); - if (projectileIndex.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectileIndex].Calamity().forceRogue = true; + if (projectileIndex.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectileIndex].Calamity().forceRogue = true; projectile.ai[0] = 12f; //0.2th of a second cooldown } target.AddBuff(ModContent.BuffType(), 240); @@ -94,8 +94,8 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.ai[0] == 0f) { int projectileIndex = Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25f), 2f, projectile.owner); - if (projectileIndex.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectileIndex].Calamity().forceRogue = true; + if (projectileIndex.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectileIndex].Calamity().forceRogue = true; projectile.ai[0] = 12f; //0.2th of a second cooldown } target.AddBuff(ModContent.BuffType(), 240); diff --git a/Projectiles/Rogue/EquanimityDarkShard.cs b/Projectiles/Rogue/EquanimityDarkShard.cs index 3603af26f3..5ad573c28d 100644 --- a/Projectiles/Rogue/EquanimityDarkShard.cs +++ b/Projectiles/Rogue/EquanimityDarkShard.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 14; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.alpha = 0; + projectile.ignoreWater = true; + projectile.alpha = 0; projectile.penetrate = 1; projectile.tileCollide = true; projectile.timeLeft = 120; diff --git a/Projectiles/Rogue/EquanimityLightShard.cs b/Projectiles/Rogue/EquanimityLightShard.cs index bec2451479..8bd6302beb 100644 --- a/Projectiles/Rogue/EquanimityLightShard.cs +++ b/Projectiles/Rogue/EquanimityLightShard.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 14; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.alpha = 0; + projectile.ignoreWater = true; + projectile.alpha = 0; projectile.penetrate = 3; projectile.tileCollide = true; projectile.timeLeft = 120; diff --git a/Projectiles/Rogue/EquanimityProj.cs b/Projectiles/Rogue/EquanimityProj.cs index 3cfb24208c..10629ad8c3 100644 --- a/Projectiles/Rogue/EquanimityProj.cs +++ b/Projectiles/Rogue/EquanimityProj.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 28; projectile.height = 36; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 15; diff --git a/Projectiles/Rogue/EradicatorProjectile.cs b/Projectiles/Rogue/EradicatorProjectile.cs index 065cb92350..77b6181a0b 100644 --- a/Projectiles/Rogue/EradicatorProjectile.cs +++ b/Projectiles/Rogue/EradicatorProjectile.cs @@ -9,207 +9,207 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class EradicatorProjectile : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/Eradicator"; - private const float RotationIncrement = 0.09f; - private const int Lifetime = 350; - public const int StealthExtraLifetime = 240; // 1 extra update means this is double what you'd expect for 2 seconds - private const float ReboundTime = 40f; + public class EradicatorProjectile : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/Eradicator"; + private const float RotationIncrement = 0.09f; + private const int Lifetime = 350; + public const int StealthExtraLifetime = 240; // 1 extra update means this is double what you'd expect for 2 seconds + private const float ReboundTime = 40f; - private float randomLaserCharge = 0f; + private float randomLaserCharge = 0f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Eradicator"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 2; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eradicator"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 58; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.MaxUpdates = 2; - projectile.timeLeft = Lifetime; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 18; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 58; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.MaxUpdates = 2; + projectile.timeLeft = Lifetime; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 18; + projectile.Calamity().rogue = true; + } - public override void AI() - { - // - // Boomerang AI copied from Nanoblack Reaper - // - - // On the frame the disc begins returning, send a net update. - if (projectile.timeLeft == Lifetime - ReboundTime) - projectile.netUpdate = true; + public override void AI() + { + // + // Boomerang AI copied from Nanoblack Reaper + // + + // On the frame the disc begins returning, send a net update. + if (projectile.timeLeft == Lifetime - ReboundTime) + projectile.netUpdate = true; - // The disc runs its returning AI if it has existed longer than ReboundTime frames. - if (projectile.timeLeft <= Lifetime - ReboundTime) - { - float returnSpeed = Eradicator.Speed * 1.3f; - float acceleration = 0.25f; - Player owner = Main.player[projectile.owner]; + // The disc runs its returning AI if it has existed longer than ReboundTime frames. + if (projectile.timeLeft <= Lifetime - ReboundTime) + { + float returnSpeed = Eradicator.Speed * 1.3f; + float acceleration = 0.25f; + Player owner = Main.player[projectile.owner]; - // Delete the disc if it's excessively far away. - Vector2 playerCenter = owner.Center; - float xDist = playerCenter.X - projectile.Center.X; - float yDist = playerCenter.Y - projectile.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (dist > 3000f) - projectile.Kill(); + // Delete the disc if it's excessively far away. + Vector2 playerCenter = owner.Center; + float xDist = playerCenter.X - projectile.Center.X; + float yDist = playerCenter.Y - projectile.Center.Y; + float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); + if (dist > 3000f) + projectile.Kill(); - dist = returnSpeed / dist; - xDist *= dist; - yDist *= dist; + dist = returnSpeed / dist; + xDist *= dist; + yDist *= dist; - // Home back in on the player. - if (projectile.velocity.X < xDist) - { - projectile.velocity.X = projectile.velocity.X + acceleration; - if (projectile.velocity.X < 0f && xDist > 0f) - projectile.velocity.X += acceleration; - } - else if (projectile.velocity.X > xDist) - { - projectile.velocity.X = projectile.velocity.X - acceleration; - if (projectile.velocity.X > 0f && xDist < 0f) - projectile.velocity.X -= acceleration; - } - if (projectile.velocity.Y < yDist) - { - projectile.velocity.Y = projectile.velocity.Y + acceleration; - if (projectile.velocity.Y < 0f && yDist > 0f) - projectile.velocity.Y += acceleration; - } - else if (projectile.velocity.Y > yDist) - { - projectile.velocity.Y = projectile.velocity.Y - acceleration; - if (projectile.velocity.Y > 0f && yDist < 0f) - projectile.velocity.Y -= acceleration; - } + // Home back in on the player. + if (projectile.velocity.X < xDist) + { + projectile.velocity.X = projectile.velocity.X + acceleration; + if (projectile.velocity.X < 0f && xDist > 0f) + projectile.velocity.X += acceleration; + } + else if (projectile.velocity.X > xDist) + { + projectile.velocity.X = projectile.velocity.X - acceleration; + if (projectile.velocity.X > 0f && xDist < 0f) + projectile.velocity.X -= acceleration; + } + if (projectile.velocity.Y < yDist) + { + projectile.velocity.Y = projectile.velocity.Y + acceleration; + if (projectile.velocity.Y < 0f && yDist > 0f) + projectile.velocity.Y += acceleration; + } + else if (projectile.velocity.Y > yDist) + { + projectile.velocity.Y = projectile.velocity.Y - acceleration; + if (projectile.velocity.Y > 0f && yDist < 0f) + projectile.velocity.Y -= acceleration; + } - // Delete the projectile if it touches its owner. - if (Main.myPlayer == projectile.owner) - if (projectile.Hitbox.Intersects(owner.Hitbox)) - projectile.Kill(); - } + // Delete the projectile if it touches its owner. + if (Main.myPlayer == projectile.owner) + if (projectile.Hitbox.Intersects(owner.Hitbox)) + projectile.Kill(); + } - // Lighting. - Lighting.AddLight(projectile.Center, 0.35f, 0f, 0.25f); + // Lighting. + Lighting.AddLight(projectile.Center, 0.35f, 0f, 0.25f); - // Rotate the disc as it flies. - float spin = projectile.direction <= 0 ? -1f : 1f; - projectile.rotation += spin * RotationIncrement; + // Rotate the disc as it flies. + float spin = projectile.direction <= 0 ? -1f : 1f; + projectile.rotation += spin * RotationIncrement; - // If attached to something (this only occurs for stealth strikes), do the buzzsaw grind and spam lasers everywhere. - if (projectile.ai[0] == 1f) - StealthStrikeGrind(spin); - else - { - // Fire lasers at up to 2 nearby targets every 8 frames for 40% damage. - // Stealth strike lasers have an intentionally lower ratio of 12%. - double laserDamageRatio = projectile.Calamity().stealthStrike ? 0.12D : 0.4D; - float laserFrames = projectile.MaxUpdates * 8f; - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, laserFrames, 2, ModContent.ProjectileType(), laserDamageRatio, true); - } - } + // If attached to something (this only occurs for stealth strikes), do the buzzsaw grind and spam lasers everywhere. + if (projectile.ai[0] == 1f) + StealthStrikeGrind(spin); + else + { + // Fire lasers at up to 2 nearby targets every 8 frames for 40% damage. + // Stealth strike lasers have an intentionally lower ratio of 12%. + double laserDamageRatio = projectile.Calamity().stealthStrike ? 0.12D : 0.4D; + float laserFrames = projectile.MaxUpdates * 8f; + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, laserFrames, 2, ModContent.ProjectileType(), laserDamageRatio, true); + } + } - private void StealthStrikeGrind(float spinDir) - { - // Spin extra fast to visually shred the enemy. - projectile.rotation += spinDir * RotationIncrement * 0.8f; + private void StealthStrikeGrind(float spinDir) + { + // Spin extra fast to visually shred the enemy. + projectile.rotation += spinDir * RotationIncrement * 0.8f; - // Randomly fire lasers while grinding. Each laser only does 12% damage. - randomLaserCharge += Main.rand.NextFloat(0.09f, 0.14f); - if (randomLaserCharge >= 1f) - { - randomLaserCharge -= 1f; - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + // Randomly fire lasers while grinding. Each laser only does 12% damage. + randomLaserCharge += Main.rand.NextFloat(0.09f, 0.14f); + if (randomLaserCharge >= 1f) + { + randomLaserCharge -= 1f; + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int laserDamage = (int)(projectile.damage * 0.12D); - Projectile laser = Projectile.NewProjectileDirect(projectile.Center, velocity, ModContent.ProjectileType(), laserDamage, 0f, projectile.owner); - if (laser.whoAmI.WithinBounds(Main.maxProjectiles)) - { - laser.Calamity().forceRogue = true; - laser.aiStyle = Main.rand.NextBool() ? 1 : -1; - laser.penetrate = -1; - laser.usesLocalNPCImmunity = true; + int laserDamage = (int)(projectile.damage * 0.12D); + Projectile laser = Projectile.NewProjectileDirect(projectile.Center, velocity, ModContent.ProjectileType(), laserDamage, 0f, projectile.owner); + if (laser.whoAmI.WithinBounds(Main.maxProjectiles)) + { + laser.Calamity().forceRogue = true; + laser.aiStyle = Main.rand.NextBool() ? 1 : -1; + laser.penetrate = -1; + laser.usesLocalNPCImmunity = true; - // This projectile has a hefty amount of extra updates, which will influence the hit cooldown. - laser.localNPCHitCooldown = 120; - } - } + // This projectile has a hefty amount of extra updates, which will influence the hit cooldown. + laser.localNPCHitCooldown = 120; + } + } - // Stay stuck to the target. - projectile.StickyProjAI(6, true); + // Stay stuck to the target. + projectile.StickyProjAI(6, true); - // If still attached to a target, do nothing. - if (projectile.ai[0] != 0f) - return; + // If still attached to a target, do nothing. + if (projectile.ai[0] != 0f) + return; - // If the target died, look for a new one. - const float turnSpeed = 30f; - const float speedMult = 5f; - const float homingRange = 600f; - NPC uDie = projectile.Center.ClosestNPCAt(homingRange, true, true); - if (uDie != null) - { - Vector2 distNorm = (uDie.Center - projectile.Center).SafeNormalize(Vector2.UnitX); - projectile.velocity = (projectile.velocity * (turnSpeed - 1f) + distNorm * speedMult) / turnSpeed; - } - } + // If the target died, look for a new one. + const float turnSpeed = 30f; + const float speedMult = 5f; + const float homingRange = 600f; + NPC uDie = projectile.Center.ClosestNPCAt(homingRange, true, true); + if (uDie != null) + { + Vector2 distNorm = (uDie.Center - projectile.Center).SafeNormalize(Vector2.UnitX); + projectile.velocity = (projectile.velocity * (turnSpeed - 1f) + distNorm * speedMult) / turnSpeed; + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.OnFire, 180); - target.AddBuff(BuffID.Frostburn, 90); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.Frostburn, 90); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.OnFire, 180); - target.AddBuff(BuffID.Frostburn, 90); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.Frostburn, 90); + } - public override void ModifyHitPvp(Player target, ref int damage, ref bool crit) => OnHit(); - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) => OnHit(); + public override void ModifyHitPvp(Player target, ref int damage, ref bool crit) => OnHit(); + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) => OnHit(); - private void OnHit() - { - // Non-stealth strikes do nothing special on hit. - if (!projectile.Calamity().stealthStrike) - return; + private void OnHit() + { + // Non-stealth strikes do nothing special on hit. + if (!projectile.Calamity().stealthStrike) + return; - // On the first frame of impact, slow down massively so it'll effectively stay stuck to an enemy. - if (projectile.ai[0] == 0f && projectile.ai[1] == 0f) - { - projectile.velocity *= 0.1f; + // On the first frame of impact, slow down massively so it'll effectively stay stuck to an enemy. + if (projectile.ai[0] == 0f && projectile.ai[1] == 0f) + { + projectile.velocity *= 0.1f; - // Provide a fixed amount of grind time so that DPS can't vary wildly. - projectile.timeLeft = 90; - } + // Provide a fixed amount of grind time so that DPS can't vary wildly. + projectile.timeLeft = 90; + } - // Apply sticky AI. - projectile.ModifyHitNPCSticky(3, true); - } + // Apply sticky AI. + projectile.ModifyHitNPCSticky(3, true); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Vector2 origin = new Vector2(31f, 29f); - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/EradicatorGlow"), projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, origin, 1f, SpriteEffects.None, 0f); - } - } + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Vector2 origin = new Vector2(31f, 29f); + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/EradicatorGlow"), projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, origin, 1f, SpriteEffects.None, 0f); + } + } } diff --git a/Projectiles/Rogue/ExecutionersBladeProj.cs b/Projectiles/Rogue/ExecutionersBladeProj.cs index 9aac47c77e..90aefc3a5f 100644 --- a/Projectiles/Rogue/ExecutionersBladeProj.cs +++ b/Projectiles/Rogue/ExecutionersBladeProj.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class ExecutionersBladeProj : ModProjectile + public class ExecutionersBladeProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/ExecutionersBlade"; @@ -15,11 +15,11 @@ namespace CalamityMod.Projectiles.Rogue { if (Main.myPlayer == projectile.owner) { - Main.PlaySound(SoundID.Item73, projectile.Center); - for (int i = 0; i < 20; i++) - { - Projectile.NewProjectile(new Vector2(position.X + (-600 + i * 60), position.Y - 800), new Vector2(0f, 2.5f), ModContent.ProjectileType(), (int)(projectile.damage * 1.2f), projectile.knockBack, projectile.owner); - } + Main.PlaySound(SoundID.Item73, projectile.Center); + for (int i = 0; i < 20; i++) + { + Projectile.NewProjectile(new Vector2(position.X + (-600 + i * 60), position.Y - 800), new Vector2(0f, 2.5f), ModContent.ProjectileType(), (int)(projectile.damage * 1.2f), projectile.knockBack, projectile.owner); + } } } @@ -36,8 +36,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 64; projectile.friendly = true; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 2; projectile.timeLeft = 240; aiType = ProjectileID.ThrowingKnife; @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 173, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 250f, 12f, 20f); } public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 128); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 128); Main.PlaySound(SoundID.Item74, (int)projectile.position.X, (int)projectile.position.Y); for (int num621 = 0; num621 < 3; num621++) { diff --git a/Projectiles/Rogue/ExecutionersBladeStealthProj.cs b/Projectiles/Rogue/ExecutionersBladeStealthProj.cs index 055c2d6a5e..2d7f36af76 100644 --- a/Projectiles/Rogue/ExecutionersBladeStealthProj.cs +++ b/Projectiles/Rogue/ExecutionersBladeStealthProj.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = 1; projectile.timeLeft = 200; projectile.Calamity().rogue = true; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 128); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 128); Main.PlaySound(SoundID.Item74, (int)projectile.position.X, (int)projectile.position.Y); for (int num621 = 0; num621 < 3; num621++) { diff --git a/Projectiles/Rogue/ExorcismProj.cs b/Projectiles/Rogue/ExorcismProj.cs index 4a59aa156b..6acf91c60d 100644 --- a/Projectiles/Rogue/ExorcismProj.cs +++ b/Projectiles/Rogue/ExorcismProj.cs @@ -20,13 +20,13 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.alpha = 0; + projectile.ignoreWater = true; + projectile.alpha = 0; projectile.penetrate = 1; projectile.tileCollide = true; projectile.timeLeft = 600; projectile.Calamity().rogue = true; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() diff --git a/Projectiles/Rogue/ExplosiveSun.cs b/Projectiles/Rogue/ExplosiveSun.cs index 44a2f1b27a..18e0a6e938 100644 --- a/Projectiles/Rogue/ExplosiveSun.cs +++ b/Projectiles/Rogue/ExplosiveSun.cs @@ -15,26 +15,26 @@ namespace CalamityMod.Projectiles.Rogue } public override void SetDefaults() - { - projectile.width = 22; - projectile.height = 22; - //projectile.aiStyle = 115; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; - projectile.light = 0.5f; - projectile.alpha = 50; - projectile.scale = 1.2f; - projectile.timeLeft = 60; - projectile.tileCollide = false; + { + projectile.width = 22; + projectile.height = 22; + //projectile.aiStyle = 115; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = 1; + projectile.light = 0.5f; + projectile.alpha = 50; + projectile.scale = 1.2f; + projectile.timeLeft = 60; + projectile.tileCollide = false; projectile.Calamity().rogue = true; } public override void AI() { projectile.velocity.X *= 0.985f; - projectile.velocity.Y *= 0.985f; - } + projectile.velocity.Y *= 0.985f; + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -74,12 +74,12 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage /= 2; + projectile.damage /= 2; projectile.Damage(); - if (Main.rand.NextBool(3)) + if (Main.rand.NextBool(3)) { - Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 14, 0.5f); - } + Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 14, 0.5f); + } for (int num621 = 0; num621 < 5; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); diff --git a/Projectiles/Rogue/FantasyTalismanProj.cs b/Projectiles/Rogue/FantasyTalismanProj.cs index e4b844b00d..692fc8642c 100644 --- a/Projectiles/Rogue/FantasyTalismanProj.cs +++ b/Projectiles/Rogue/FantasyTalismanProj.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class FantasyTalismanProj : ModProjectile + public class FantasyTalismanProj : ModProjectile { public override void SetStaticDefaults() { @@ -41,21 +41,21 @@ namespace CalamityMod.Projectiles.Rogue projectile.StickyProjAI(4); if (projectile.ai[0] == 1f) { - if (projectile.timeLeft % 10 == 0) - { - if (Main.rand.NextBool(2)) - { - int spiritDamage = projectile.damage / 2; - Projectile ghost = CalamityGlobalProjectile.SpawnOrb(projectile, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); - if (ghost.whoAmI.WithinBounds(Main.maxProjectiles)) - { - ghost.Calamity().forceRogue = true; - ghost.penetrate = 1; - } - } - } + if (projectile.timeLeft % 10 == 0) + { + if (Main.rand.NextBool(2)) + { + int spiritDamage = projectile.damage / 2; + Projectile ghost = CalamityGlobalProjectile.SpawnOrb(projectile, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); + if (ghost.whoAmI.WithinBounds(Main.maxProjectiles)) + { + ghost.Calamity().forceRogue = true; + ghost.penetrate = 1; + } + } + } } - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Rogue/FantasyTalismanStealth.cs b/Projectiles/Rogue/FantasyTalismanStealth.cs index df306f6eff..b81fcd9a69 100644 --- a/Projectiles/Rogue/FantasyTalismanStealth.cs +++ b/Projectiles/Rogue/FantasyTalismanStealth.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class FantasyTalismanStealth : ModProjectile + public class FantasyTalismanStealth : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Rogue/FantasyTalismanProj"; @@ -40,37 +40,37 @@ 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); } - if (projectile.ai[0] != 1f) - { - if (projectile.timeLeft % 10 == 0) - { - if (projectile.owner == Main.myPlayer) + if (projectile.ai[0] != 1f) + { + if (projectile.timeLeft % 10 == 0) + { + if (projectile.owner == Main.myPlayer) { // Use a tiny velocity to ensure that rotation works correctly. // The speed should be so low that it will make no meaningful mechanical difference. Vector2 soulVelocity = projectile.velocity.SafeNormalize(Vector2.Zero) * 0.0001f; Projectile.NewProjectile(projectile.Center, soulVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - } - } - } + } + } + } projectile.StickyProjAI(4); if (projectile.ai[0] == 1f) { - if (projectile.timeLeft % 4 == 0) - { - if (Main.rand.NextBool(2)) - { - int spiritDamage = projectile.damage / 2; - Projectile ghost = CalamityGlobalProjectile.SpawnOrb(projectile, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); - if (ghost.whoAmI.WithinBounds(Main.maxProjectiles)) - { - ghost.Calamity().forceRogue = true; - ghost.penetrate = 1; - } - } - } + if (projectile.timeLeft % 4 == 0) + { + if (Main.rand.NextBool(2)) + { + int spiritDamage = projectile.damage / 2; + Projectile ghost = CalamityGlobalProjectile.SpawnOrb(projectile, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); + if (ghost.whoAmI.WithinBounds(Main.maxProjectiles)) + { + ghost.Calamity().forceRogue = true; + ghost.penetrate = 1; + } + } + } } - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Rogue/FeatherKnifeProjectile.cs b/Projectiles/Rogue/FeatherKnifeProjectile.cs index 986aad93c0..2b26425dc2 100644 --- a/Projectiles/Rogue/FeatherKnifeProjectile.cs +++ b/Projectiles/Rogue/FeatherKnifeProjectile.cs @@ -41,8 +41,8 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(projectile.position, new Vector2(projectile.velocity.X / 20, 2), ModContent.ProjectileType(), (int)(projectile.damage * 0.4), projectile.knockBack, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceRogue = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceRogue = true; } } } @@ -50,8 +50,8 @@ namespace CalamityMod.Projectiles.Rogue 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)(projectile.damage * 0.69), projectile.knockBack, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceRogue = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceRogue = true; } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/FinalDawnFireSlash.cs b/Projectiles/Rogue/FinalDawnFireSlash.cs index b765aba3db..320dc77293 100644 --- a/Projectiles/Rogue/FinalDawnFireSlash.cs +++ b/Projectiles/Rogue/FinalDawnFireSlash.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Projectiles.Rogue public bool HasRegeneratedStealth = false; public const float StealthReturnRatio = 0.25f; public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Final Dawn"); + { + DisplayName.SetDefault("The Final Dawn"); Main.projFrames[projectile.type] = 11; } public override void SetDefaults() @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 300; projectile.height = 398; projectile.friendly = false; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.tileCollide = false; projectile.Calamity().rogue = true; projectile.ownerHitCheck = true; @@ -34,8 +34,8 @@ namespace CalamityMod.Projectiles.Rogue { Player player = Main.player[projectile.owner]; - if (player is null || player.dead) - projectile.Kill(); + if (player is null || player.dead) + projectile.Kill(); player.direction = projectile.direction; player.heldProj = projectile.whoAmI; diff --git a/Projectiles/Rogue/FinalDawnFireball.cs b/Projectiles/Rogue/FinalDawnFireball.cs index 22ed0cc454..c1b55a2186 100644 --- a/Projectiles/Rogue/FinalDawnFireball.cs +++ b/Projectiles/Rogue/FinalDawnFireball.cs @@ -12,8 +12,8 @@ namespace CalamityMod.Projectiles.Rogue public const float DesiredSpeed = 30; public const float InterpolationTime = 10; public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Final Dawn"); + { + DisplayName.SetDefault("The Final Dawn"); Main.projFrames[projectile.type] = 4; } public override void SetDefaults() @@ -31,25 +31,25 @@ namespace CalamityMod.Projectiles.Rogue } public override void AI() { - NPC chargeAt = Main.npc[(int)projectile.ai[1]]; - if(!chargeAt.active) - projectile.Kill(); + NPC chargeAt = Main.npc[(int)projectile.ai[1]]; + if(!chargeAt.active) + projectile.Kill(); - int idx = Dust.NewDust(projectile.position, projectile.width , projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 1.0f); - Main.dust[idx].velocity = projectile.velocity * 0.5f; - Main.dust[idx].noGravity = true; - Main.dust[idx].noLight = true; + int idx = Dust.NewDust(projectile.position, projectile.width , projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 1.0f); + Main.dust[idx].velocity = projectile.velocity * 0.5f; + Main.dust[idx].noGravity = true; + Main.dust[idx].noLight = true; - projectile.ai[0]++; - if (projectile.ai[0] >= 20) - { + projectile.ai[0]++; + if (projectile.ai[0] >= 20) + { projectile.friendly = true; - NPC npc = Main.npc[(int)projectile.ai[1]]; - Vector2 desiredVelocity = projectile.SafeDirectionTo(npc.Center) * DesiredSpeed; - projectile.velocity = Vector2.Lerp(projectile.velocity, desiredVelocity, 1f / InterpolationTime); - if(!npc.active) - projectile.Kill(); - } + NPC npc = Main.npc[(int)projectile.ai[1]]; + Vector2 desiredVelocity = projectile.SafeDirectionTo(npc.Center) * DesiredSpeed; + projectile.velocity = Vector2.Lerp(projectile.velocity, desiredVelocity, 1f / InterpolationTime); + if(!npc.active) + projectile.Kill(); + } projectile.frameCounter++; if (projectile.frameCounter >= 5) @@ -60,16 +60,16 @@ namespace CalamityMod.Projectiles.Rogue projectile.frame = 0; } } - public override void Kill(int timeLeft) - { + public override void Kill(int timeLeft) + { if (Main.myPlayer == projectile.owner) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D glowmask = Main.projectileTexture[projectile.type]; + Texture2D glowmask = Main.projectileTexture[projectile.type]; int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int yStart = height * projectile.frame; Main.spriteBatch.Draw(glowmask, @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Rogue new Vector2(glowmask.Width / 2f, height / 2f), projectile.scale, projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); - return false; + return false; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Rogue/FinalDawnFlame.cs b/Projectiles/Rogue/FinalDawnFlame.cs index 9b9fd0a695..f79beb5073 100644 --- a/Projectiles/Rogue/FinalDawnFlame.cs +++ b/Projectiles/Rogue/FinalDawnFlame.cs @@ -25,13 +25,13 @@ namespace CalamityMod.Projectiles.Rogue private Flame[] Flames; public const int TotalFlames = 120; public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Final Dawn"); + { + DisplayName.SetDefault("The Final Dawn"); Main.projFrames[projectile.type] = 8; } public override void SetDefaults() { - projectile.scale = 1f; + projectile.scale = 1f; projectile.width = 1000; projectile.height = 100; projectile.penetrate = -1; diff --git a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs index 9d6e0fc63c..6680ce4b72 100644 --- a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs +++ b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs @@ -9,9 +9,9 @@ namespace CalamityMod.Projectiles.Rogue { public class FinalDawnHorizontalSlash : ModProjectile { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Final Dawn"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("The Final Dawn"); Main.projFrames[projectile.type] = 9; } public override void SetDefaults() @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 600; projectile.height = 156; projectile.friendly = false; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.tileCollide = false; projectile.Calamity().rogue = true; projectile.ownerHitCheck = true; @@ -29,10 +29,10 @@ namespace CalamityMod.Projectiles.Rogue } public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; - if (player is null || player.dead) - projectile.Kill(); + if (player is null || player.dead) + projectile.Kill(); projectile.Center = player.Center; player.heldProj = projectile.whoAmI; diff --git a/Projectiles/Rogue/FinalDawnProjectile.cs b/Projectiles/Rogue/FinalDawnProjectile.cs index 75c454860b..bf1075525f 100644 --- a/Projectiles/Rogue/FinalDawnProjectile.cs +++ b/Projectiles/Rogue/FinalDawnProjectile.cs @@ -7,178 +7,178 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class FinalDawnProjectile : ModProjectile - { - public const float MaxChargeTime = 20f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Final Dawn"); - Main.projFrames[projectile.type] = 2; - } - public override void SetDefaults() - { - projectile.width = 16; - projectile.height = 16; - projectile.friendly = false; - projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - //projectile.extraUpdates = 2; - } - public override bool ShouldUpdatePosition() => false; - public override void AI() - { - Player player = Main.player[projectile.owner]; + public class FinalDawnProjectile : ModProjectile + { + public const float MaxChargeTime = 20f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("The Final Dawn"); + Main.projFrames[projectile.type] = 2; + } + public override void SetDefaults() + { + projectile.width = 16; + projectile.height = 16; + projectile.friendly = false; + projectile.Calamity().rogue = true; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + //projectile.extraUpdates = 2; + } + public override bool ShouldUpdatePosition() => false; + public override void AI() + { + Player player = Main.player[projectile.owner]; - if (player is null || player.dead) - projectile.Kill(); + if (player is null || player.dead) + projectile.Kill(); - if (Main.myPlayer == player.whoAmI) - { - projectile.velocity = Main.MouseWorld - player.Center; - projectile.velocity.Normalize(); - } - player.direction = projectile.direction; - player.heldProj = projectile.whoAmI; - projectile.Center = player.Center; - projectile.position.Y -= 44; - projectile.position.X -= 46 * player.direction; - player.bodyFrame.Y = player.bodyFrame.Height; + if (Main.myPlayer == player.whoAmI) + { + projectile.velocity = Main.MouseWorld - player.Center; + projectile.velocity.Normalize(); + } + player.direction = projectile.direction; + player.heldProj = projectile.whoAmI; + projectile.Center = player.Center; + projectile.position.Y -= 44; + projectile.position.X -= 46 * player.direction; + player.bodyFrame.Y = player.bodyFrame.Height; - if (projectile.ai[0] < MaxChargeTime) - { - // Charging dust - Vector2 dustCenter = new Vector2(projectile.Center.X, projectile.Center.Y - 40); - int flame = Dust.NewDust(dustCenter, projectile.width, projectile.height, ModContent.DustType(), 0, 0, 100, default, 2f); - Main.dust[flame].noGravity = true; - Main.dust[flame].fadeIn = 1.5f; - Main.dust[flame].scale = 1.4f; - Vector2 offsetVector = Utils.NextVector2CircularEdge(Main.rand, 100f, 100f); - Main.dust[flame].position = dustCenter - offsetVector; - Vector2 newVelocity = dustCenter - Main.dust[flame].position; - Main.dust[flame].velocity = newVelocity * 0.1f; - } - if (projectile.ai[0] == MaxChargeTime) - { - int dustCount = 36; - for (int i = 0; i < dustCount; i++) - { - Vector2 startingPosition = projectile.Center + new Vector2(0, -40); - Vector2 offset = Vector2.UnitX * projectile.width * 0.1875f; - offset = offset.RotatedBy((i - (dustCount / 2 - 1)) * MathHelper.TwoPi / dustCount); - int dustIdx = Dust.NewDust(startingPosition + offset, 0, 0, ModContent.DustType(), offset.X * 2f, offset.Y * 2f, 100, default, 3.4f); - Main.dust[dustIdx].noGravity = true; - Main.dust[dustIdx].noLight = true; - Main.dust[dustIdx].velocity = Vector2.Normalize(offset) * 5f; - } - projectile.frame = 1; - } - projectile.ai[0]++; + if (projectile.ai[0] < MaxChargeTime) + { + // Charging dust + Vector2 dustCenter = new Vector2(projectile.Center.X, projectile.Center.Y - 40); + int flame = Dust.NewDust(dustCenter, projectile.width, projectile.height, ModContent.DustType(), 0, 0, 100, default, 2f); + Main.dust[flame].noGravity = true; + Main.dust[flame].fadeIn = 1.5f; + Main.dust[flame].scale = 1.4f; + Vector2 offsetVector = Utils.NextVector2CircularEdge(Main.rand, 100f, 100f); + Main.dust[flame].position = dustCenter - offsetVector; + Vector2 newVelocity = dustCenter - Main.dust[flame].position; + Main.dust[flame].velocity = newVelocity * 0.1f; + } + if (projectile.ai[0] == MaxChargeTime) + { + int dustCount = 36; + for (int i = 0; i < dustCount; i++) + { + Vector2 startingPosition = projectile.Center + new Vector2(0, -40); + Vector2 offset = Vector2.UnitX * projectile.width * 0.1875f; + offset = offset.RotatedBy((i - (dustCount / 2 - 1)) * MathHelper.TwoPi / dustCount); + int dustIdx = Dust.NewDust(startingPosition + offset, 0, 0, ModContent.DustType(), offset.X * 2f, offset.Y * 2f, 100, default, 3.4f); + Main.dust[dustIdx].noGravity = true; + Main.dust[dustIdx].noLight = true; + Main.dust[dustIdx].velocity = Vector2.Normalize(offset) * 5f; + } + projectile.frame = 1; + } + projectile.ai[0]++; - projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt(); - if (Main.myPlayer == projectile.owner) - { - if (!player.channel || player.noItems || player.CCed) - { - AttemptExecuteAttacks(player); - projectile.Kill(); - } - } - } + if (Main.myPlayer == projectile.owner) + { + if (!player.channel || player.noItems || player.CCed) + { + AttemptExecuteAttacks(player); + projectile.Kill(); + } + } + } - public void AttemptExecuteAttacks(Player player) - { - //projectile.ai[1] == 1f if spawned via Venerated Locket - if (projectile.ai[0] >= MaxChargeTime && !player.noItems && !player.CCed) - { - // Far range attack - if (player.controlUp) - { - // Stealth Strike - if (player.Calamity().StealthStrikeAvailable() && projectile.ai[1] != 1f) - { - int stealth = Projectile.NewProjectile(player.Center, - player.SafeDirectionTo(Main.MouseWorld) * 38f, - ModContent.ProjectileType(), - (int)(projectile.damage * 1.05f), - projectile.knockBack, - projectile.owner); - Main.projectile[stealth].Calamity().stealthStrike = true; - player.Calamity().ConsumeStealthByAttacking(); - } - else - { - Projectile.NewProjectile(projectile.Center, - projectile.SafeDirectionTo(Main.MouseWorld) * 38f, - ModContent.ProjectileType(), projectile.damage, - projectile.knockBack, projectile.owner); - if (projectile.ai[1] != 1f) - player.Calamity().ConsumeStealthByAttacking(); - } - } - // Close range attack - else - { - // Stealth - if (player.Calamity().StealthStrikeAvailable() && projectile.ai[1] != 1f) - { - int stealth = Projectile.NewProjectile(projectile.Center, - projectile.velocity, - ModContent.ProjectileType(), - (int)(projectile.damage * 1.275f), - projectile.knockBack, - projectile.owner); - Main.projectile[stealth].Calamity().stealthStrike = true; - player.Calamity().ConsumeStealthByAttacking(); - } - else - { - //This one doesn't consume stealth since it replenishes stealth on hits - Projectile.NewProjectile(projectile.Center, - projectile.velocity, - ModContent.ProjectileType(), - projectile.damage, - projectile.knockBack, - projectile.owner); - } - } - } - else - player.Calamity().ConsumeStealthByAttacking(); - } + public void AttemptExecuteAttacks(Player player) + { + //projectile.ai[1] == 1f if spawned via Venerated Locket + if (projectile.ai[0] >= MaxChargeTime && !player.noItems && !player.CCed) + { + // Far range attack + if (player.controlUp) + { + // Stealth Strike + if (player.Calamity().StealthStrikeAvailable() && projectile.ai[1] != 1f) + { + int stealth = Projectile.NewProjectile(player.Center, + player.SafeDirectionTo(Main.MouseWorld) * 38f, + ModContent.ProjectileType(), + (int)(projectile.damage * 1.05f), + projectile.knockBack, + projectile.owner); + Main.projectile[stealth].Calamity().stealthStrike = true; + player.Calamity().ConsumeStealthByAttacking(); + } + else + { + Projectile.NewProjectile(projectile.Center, + projectile.SafeDirectionTo(Main.MouseWorld) * 38f, + ModContent.ProjectileType(), projectile.damage, + projectile.knockBack, projectile.owner); + if (projectile.ai[1] != 1f) + player.Calamity().ConsumeStealthByAttacking(); + } + } + // Close range attack + else + { + // Stealth + if (player.Calamity().StealthStrikeAvailable() && projectile.ai[1] != 1f) + { + int stealth = Projectile.NewProjectile(projectile.Center, + projectile.velocity, + ModContent.ProjectileType(), + (int)(projectile.damage * 1.275f), + projectile.knockBack, + projectile.owner); + Main.projectile[stealth].Calamity().stealthStrike = true; + player.Calamity().ConsumeStealthByAttacking(); + } + else + { + //This one doesn't consume stealth since it replenishes stealth on hits + Projectile.NewProjectile(projectile.Center, + projectile.velocity, + ModContent.ProjectileType(), + projectile.damage, + projectile.knockBack, + projectile.owner); + } + } + } + else + player.Calamity().ConsumeStealthByAttacking(); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D scytheTexture = Main.projectileTexture[projectile.type]; - Texture2D glowmask = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/FinalDawnProjectile_Glow"); - int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; - int yStart = height * projectile.frame; - Main.spriteBatch.Draw(scytheTexture, - projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, - new Rectangle?(new Rectangle(0, yStart, scytheTexture.Width, height)), - projectile.GetAlpha(lightColor), - projectile.rotation, - new Vector2(scytheTexture.Width / 2f, height / 2f), - projectile.scale, - projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, - 0f); - Main.spriteBatch.Draw(glowmask, - projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, - new Rectangle?(new Rectangle(0, yStart, scytheTexture.Width, height)), - projectile.GetAlpha(Color.White), - projectile.rotation, - new Vector2(scytheTexture.Width / 2f, height / 2f), - projectile.scale, - projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, - 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D scytheTexture = Main.projectileTexture[projectile.type]; + Texture2D glowmask = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/FinalDawnProjectile_Glow"); + int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int yStart = height * projectile.frame; + Main.spriteBatch.Draw(scytheTexture, + projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, + new Rectangle?(new Rectangle(0, yStart, scytheTexture.Width, height)), + projectile.GetAlpha(lightColor), + projectile.rotation, + new Vector2(scytheTexture.Width / 2f, height / 2f), + projectile.scale, + projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, + 0f); + Main.spriteBatch.Draw(glowmask, + projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, + new Rectangle?(new Rectangle(0, yStart, scytheTexture.Width, height)), + projectile.GetAlpha(Color.White), + projectile.rotation, + new Vector2(scytheTexture.Width / 2f, height / 2f), + projectile.scale, + projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, + 0f); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + } + } } \ No newline at end of file diff --git a/Projectiles/Rogue/FinalDawnReticle.cs b/Projectiles/Rogue/FinalDawnReticle.cs index a2c4fc0de4..eda259e199 100644 --- a/Projectiles/Rogue/FinalDawnReticle.cs +++ b/Projectiles/Rogue/FinalDawnReticle.cs @@ -8,10 +8,10 @@ namespace CalamityMod.Projectiles.Rogue { public class FinalDawnReticle : ModProjectile { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Final Dawn"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("The Final Dawn"); + } public override void SetDefaults() { projectile.scale = 1.5f; @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Rogue } public override void AI() { - if (projectile.ai[1] == 0) - projectile.ai[1] = 1; + if (projectile.ai[1] == 0) + projectile.ai[1] = 1; if (projectile.ai[0] == 0) { int dustCount = 36; @@ -47,16 +47,16 @@ namespace CalamityMod.Projectiles.Rogue } projectile.ai[0] = 1; } - projectile.alpha += 8; - projectile.scale *= 0.98f; - projectile.ai[1] *= 1.01f; - if(projectile.alpha >= 255) - projectile.Kill(); + projectile.alpha += 8; + projectile.scale *= 0.98f; + projectile.ai[1] *= 1.01f; + if(projectile.alpha >= 255) + projectile.Kill(); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D ring = Main.projectileTexture[projectile.type]; - Texture2D symbol = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/FinalDawnReticleSymbol"); + Texture2D symbol = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/FinalDawnReticleSymbol"); spriteBatch.Draw(symbol, projectile.Center - Main.screenPosition, null, diff --git a/Projectiles/Rogue/FinalDawnThrow.cs b/Projectiles/Rogue/FinalDawnThrow.cs index ea116ef7f5..cd1c302c00 100644 --- a/Projectiles/Rogue/FinalDawnThrow.cs +++ b/Projectiles/Rogue/FinalDawnThrow.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Projectiles.Rogue public const float DesiredSpeed = 38; public const float InterpolationTime = 15; public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Final Dawn"); + { + DisplayName.SetDefault("The Final Dawn"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; ProjectileID.Sets.TrailingMode[projectile.type] = 0; } @@ -24,20 +24,20 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 80; projectile.friendly = true; projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.light = 0.0f; projectile.extraUpdates = 2; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } - public override void AI() - { - Player player = Main.player[projectile.owner]; + public override void AI() + { + Player player = Main.player[projectile.owner]; - if (player is null || player.dead) - projectile.Kill(); + if (player is null || player.dead) + projectile.Kill(); if (projectile.localAI[0] == 0) { @@ -49,23 +49,23 @@ namespace CalamityMod.Projectiles.Rogue projectile.rotation += 0.25f * projectile.direction; projectile.ai[0]++; - if (projectile.ai[0] >= 30) - { - Vector2 desiredVelocity = projectile.SafeDirectionTo(player.Center) * DesiredSpeed; - projectile.velocity = Vector2.Lerp(projectile.velocity, desiredVelocity, 1f / InterpolationTime); - - float distance = projectile.Distance(player.Center); - if (distance < 64) - projectile.Kill(); - } + if (projectile.ai[0] >= 30) + { + Vector2 desiredVelocity = projectile.SafeDirectionTo(player.Center) * DesiredSpeed; + projectile.velocity = Vector2.Lerp(projectile.velocity, desiredVelocity, 1f / InterpolationTime); + + float distance = projectile.Distance(player.Center); + if (distance < 64) + projectile.Kill(); + } - int idx = Dust.NewDust(projectile.position, projectile.width , projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 0.5f); + int idx = Dust.NewDust(projectile.position, projectile.width , projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 0.5f); Main.dust[idx].velocity *= 0.5f; Main.dust[idx].velocity += projectile.velocity * 0.5f; Main.dust[idx].noGravity = true; Main.dust[idx].noLight = false; Main.dust[idx].scale = 1.0f; - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D scytheTexture = Main.projectileTexture[projectile.type]; diff --git a/Projectiles/Rogue/FinalDawnThrow2.cs b/Projectiles/Rogue/FinalDawnThrow2.cs index ffdd609549..b7be669383 100644 --- a/Projectiles/Rogue/FinalDawnThrow2.cs +++ b/Projectiles/Rogue/FinalDawnThrow2.cs @@ -7,12 +7,12 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class FinalDawnThrow2 : ModProjectile + public class FinalDawnThrow2 : ModProjectile { bool HasHitEnemy = false; public override void SetStaticDefaults() - { - DisplayName.SetDefault("The Final Dawn"); + { + DisplayName.SetDefault("The Final Dawn"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; ProjectileID.Sets.TrailingMode[projectile.type] = 0; } @@ -22,11 +22,11 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 200; projectile.friendly = true; projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.light = 0.0f; projectile.extraUpdates = 1; - projectile.tileCollide = true; // We don't want people getting stuck in walls right + projectile.tileCollide = true; // We don't want people getting stuck in walls right projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = projectile.MaxUpdates * 13; } @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Rogue return true; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { + { // Spawn homing flames that chase the HIT enemy only. This is also limited to one burst if (Main.myPlayer == projectile.owner && !HasHitEnemy) { @@ -53,12 +53,12 @@ namespace CalamityMod.Projectiles.Rogue HasHitEnemy = true; } } - public override void AI() - { - Player player = Main.player[projectile.owner]; + public override void AI() + { + Player player = Main.player[projectile.owner]; - if (player is null || player.dead) - projectile.Kill(); + if (player is null || player.dead) + projectile.Kill(); if (projectile.localAI[0] == 0) { @@ -95,16 +95,16 @@ namespace CalamityMod.Projectiles.Rogue bool worldEdge = projectile.Center.X < 1000 || projectile.Center.Y < 1000 || projectile.Center.X > Main.maxTilesX * 16 - 1000 || projectile.Center.Y > Main.maxTilesY * 16 - 1000; projectile.ai[0]++; - if(projectile.ai[0] >= 60 || worldEdge) - { - projectile.Kill(); - } + if(projectile.ai[0] >= 60 || worldEdge) + { + projectile.Kill(); + } - int idx = Dust.NewDust(projectile.position, projectile.width , projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 2.5f); + int idx = Dust.NewDust(projectile.position, projectile.width , projectile.height, ModContent.DustType(), 0f, 0f, 0, default, 2.5f); Main.dust[idx].velocity = projectile.velocity * -0.5f; Main.dust[idx].noGravity = true; Main.dust[idx].noLight = false; - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Player player = Main.player[projectile.owner]; diff --git a/Projectiles/Rogue/FlameScytheProjectile.cs b/Projectiles/Rogue/FlameScytheProjectile.cs index 4f1a77703e..9e4ad4970f 100644 --- a/Projectiles/Rogue/FlameScytheProjectile.cs +++ b/Projectiles/Rogue/FlameScytheProjectile.cs @@ -8,82 +8,82 @@ using Terraria.World.Generation; namespace CalamityMod.Projectiles.Rogue { - public class FlameScytheProjectile : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/FlameScythe"; + public class FlameScytheProjectile : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/FlameScythe"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Scythe"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Scythe"); + } - public override void SetDefaults() - { - projectile.width = 30; - projectile.height = 30; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.aiStyle = 3; - projectile.extraUpdates = 1; - projectile.timeLeft = 600; - projectile.alpha = 55; - aiType = ProjectileID.WoodenBoomerang; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.aiStyle = 3; + projectile.extraUpdates = 1; + projectile.timeLeft = 600; + projectile.alpha = 55; + aiType = ProjectileID.WoodenBoomerang; + projectile.Calamity().rogue = true; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0.25f, 0.15f, 0f); - if (Main.rand.NextBool(5)) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.NextBool(3) ? 16 : 127, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - Vector2 goreVec = new Vector2(projectile.position.X + projectile.width / 2 + projectile.velocity.X, projectile.position.Y + projectile.height / 2 + projectile.velocity.Y); - if (Main.rand.NextBool(8)) - { - int smoke = Gore.NewGore(goreVec, default, Main.rand.Next(375, 378), 0.75f); - Main.gore[smoke].behindTiles = true; - } - if (projectile.localAI[0] > 0f) - projectile.localAI[0]--; - } + public override void AI() + { + Lighting.AddLight(projectile.Center, 0.25f, 0.15f, 0f); + if (Main.rand.NextBool(5)) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.NextBool(3) ? 16 : 127, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + Vector2 goreVec = new Vector2(projectile.position.X + projectile.width / 2 + projectile.velocity.X, projectile.position.Y + projectile.height / 2 + projectile.velocity.Y); + if (Main.rand.NextBool(8)) + { + int smoke = Gore.NewGore(goreVec, default, Main.rand.Next(375, 378), 0.75f); + Main.gore[smoke].behindTiles = true; + } + if (projectile.localAI[0] > 0f) + projectile.localAI[0]--; + } - 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 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 void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 6; - target.AddBuff(BuffID.OnFire, 240); - OnHitEffects(target.Center); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 6; + target.AddBuff(BuffID.OnFire, 240); + OnHitEffects(target.Center); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.OnFire, 240); - OnHitEffects(target.Center); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.OnFire, 240); + OnHitEffects(target.Center); + } - private void OnHitEffects(Vector2 position) - { - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceRogue = true; - if (projectile.Calamity().stealthStrike && projectile.localAI[0] <= 0f) - { - Point result; - if (WorldUtils.Find(projectile.Top.ToTileCoordinates(), Searches.Chain((GenSearch)new Searches.Down(80), (GenCondition)new Conditions.IsSolid()), out result)) - { - Projectile.NewProjectile(result.ToVector2() * 16f, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 1.5f), 2f, projectile.owner, 1f); - projectile.localAI[0] = 30f; - } - } - } - } - } + private void OnHitEffects(Vector2 position) + { + if (projectile.owner == Main.myPlayer) + { + int proj = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceRogue = true; + if (projectile.Calamity().stealthStrike && projectile.localAI[0] <= 0f) + { + Point result; + if (WorldUtils.Find(projectile.Top.ToTileCoordinates(), Searches.Chain((GenSearch)new Searches.Down(80), (GenCondition)new Conditions.IsSolid()), out result)) + { + Projectile.NewProjectile(result.ToVector2() * 16f, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 1.5f), 2f, projectile.owner, 1f); + projectile.localAI[0] = 30f; + } + } + } + } + } } diff --git a/Projectiles/Rogue/Fork.cs b/Projectiles/Rogue/Fork.cs index 90ee825079..6d33bbc15f 100644 --- a/Projectiles/Rogue/Fork.cs +++ b/Projectiles/Rogue/Fork.cs @@ -20,13 +20,13 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 14; projectile.height = 14; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; projectile.Calamity().rogue = true; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() diff --git a/Projectiles/Rogue/FrostShardFriendly.cs b/Projectiles/Rogue/FrostShardFriendly.cs index c48e26e7bd..91fd036264 100644 --- a/Projectiles/Rogue/FrostShardFriendly.cs +++ b/Projectiles/Rogue/FrostShardFriendly.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.friendly = true; projectile.penetrate = 1; projectile.Calamity().rogue = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void SetStaticDefaults() @@ -67,8 +67,8 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - if (projectile.ai[0] != 1f || Main.rand.NextBool(20)) - Main.PlaySound(SoundID.Item27, projectile.position); + if (projectile.ai[0] != 1f || Main.rand.NextBool(20)) + Main.PlaySound(SoundID.Item27, projectile.position); for (int index1 = 0; index1 < 3; ++index1) { int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 76); diff --git a/Projectiles/Rogue/FrostyFlareProj.cs b/Projectiles/Rogue/FrostyFlareProj.cs index 6fa0d7c8ad..fe2ec03a04 100644 --- a/Projectiles/Rogue/FrostyFlareProj.cs +++ b/Projectiles/Rogue/FrostyFlareProj.cs @@ -6,127 +6,127 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class FrostyFlareProj : ModProjectile - { + public class FrostyFlareProj : ModProjectile + { public override string Texture => "CalamityMod/Items/Weapons/Rogue/FrostyFlare"; - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.coldDamage = true; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.timeLeft = 300; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.coldDamage = true; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft = 300; + projectile.Calamity().rogue = true; + } - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Frosty Flare"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Frosty Flare"); + } - public override void AI() - { - if (projectile.owner != Main.myPlayer) - return; + public override void AI() + { + if (projectile.owner != Main.myPlayer) + return; - bool shoot = false; - if (projectile.timeLeft % 30f == 0f) - { - if (projectile.owner == Main.myPlayer) - shoot = true; - } + bool shoot = false; + if (projectile.timeLeft % 30f == 0f) + { + if (projectile.owner == Main.myPlayer) + shoot = true; + } - if (projectile.ai[0] == 0f) - { - projectile.velocity.X *= 0.99f; - projectile.velocity.Y += 0.25f; - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + if (projectile.ai[0] == 0f) + { + projectile.velocity.X *= 0.99f; + projectile.velocity.Y += 0.25f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (shoot) - { - Vector2 vel = new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 801)); - Vector2 pos = projectile.Center - vel; - vel.X += Main.rand.Next(-50, 51); - vel.Normalize(); - vel *= 30f; - int shard = Projectile.NewProjectile(pos, vel + projectile.velocity / 4f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - Main.projectile[shard].alpha = projectile.alpha; - } + if (shoot) + { + Vector2 vel = new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 801)); + Vector2 pos = projectile.Center - vel; + vel.X += Main.rand.Next(-50, 51); + vel.Normalize(); + vel *= 30f; + int shard = Projectile.NewProjectile(pos, vel + projectile.velocity / 4f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + Main.projectile[shard].alpha = projectile.alpha; + } - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 172); - Main.dust[index2].noGravity = true; - } - else - { - projectile.ignoreWater = true; - projectile.tileCollide = false; - int id = (int)projectile.ai[1]; - if (id >= 0 && id < Main.maxNPCs && Main.npc[id].active && !Main.npc[id].dontTakeDamage) - { - projectile.Center = Main.npc[id].Center - projectile.velocity * 2f; - projectile.gfxOffY = Main.npc[id].gfxOffY; + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 172); + Main.dust[index2].noGravity = true; + } + else + { + projectile.ignoreWater = true; + projectile.tileCollide = false; + int id = (int)projectile.ai[1]; + if (id >= 0 && id < Main.maxNPCs && Main.npc[id].active && !Main.npc[id].dontTakeDamage) + { + projectile.Center = Main.npc[id].Center - projectile.velocity * 2f; + projectile.gfxOffY = Main.npc[id].gfxOffY; - if (shoot) - { - Vector2 vel = new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 801)); - Vector2 pos = Main.npc[id].Center - vel; - vel.X += Main.rand.Next(-50, 51); - vel.Normalize(); - vel *= 30f; - int shard = Projectile.NewProjectile(pos, vel + Main.npc[id].velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - Main.projectile[shard].alpha = projectile.alpha; - } - } - else - { - projectile.Kill(); - } - } - } + if (shoot) + { + Vector2 vel = new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 801)); + Vector2 pos = Main.npc[id].Center - vel; + vel.X += Main.rand.Next(-50, 51); + vel.Normalize(); + vel *= 30f; + int shard = Projectile.NewProjectile(pos, vel + Main.npc[id].velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + Main.projectile[shard].alpha = projectile.alpha; + } + } + else + { + projectile.Kill(); + } + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.Frostburn, 180); - target.AddBuff(ModContent.BuffType(), 30); - target.immune[projectile.owner] = 0; - projectile.ai[0] = 1f; - projectile.ai[1] = target.whoAmI; - projectile.velocity = target.Center - projectile.Center; - projectile.velocity *= 0.75f; - projectile.netUpdate = true; + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Frostburn, 180); + target.AddBuff(ModContent.BuffType(), 30); + target.immune[projectile.owner] = 0; + projectile.ai[0] = 1f; + projectile.ai[1] = target.whoAmI; + projectile.velocity = target.Center - projectile.Center; + projectile.velocity *= 0.75f; + projectile.netUpdate = true; - const int maxFlares = 5; - int flaresFound = 0; - int oldestFlare = -1; - int oldestFlareTimeLeft = 300; - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == projectile.type && i != projectile.whoAmI && Main.projectile[i].ai[1] == target.whoAmI) - { - flaresFound++; - if (Main.projectile[i].timeLeft < oldestFlareTimeLeft) - { - oldestFlareTimeLeft = Main.projectile[i].timeLeft; - oldestFlare = Main.projectile[i].whoAmI; - } - if (flaresFound >= maxFlares) - break; - } - } - if (flaresFound >= maxFlares && oldestFlare >= 0) - { - Main.projectile[oldestFlare].Kill(); - } - } + const int maxFlares = 5; + int flaresFound = 0; + int oldestFlare = -1; + int oldestFlareTimeLeft = 300; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == projectile.type && i != projectile.whoAmI && Main.projectile[i].ai[1] == target.whoAmI) + { + flaresFound++; + if (Main.projectile[i].timeLeft < oldestFlareTimeLeft) + { + oldestFlareTimeLeft = Main.projectile[i].timeLeft; + oldestFlare = Main.projectile[i].whoAmI; + } + if (flaresFound >= maxFlares) + break; + } + } + if (flaresFound >= maxFlares && oldestFlare >= 0) + { + Main.projectile[oldestFlare].Kill(); + } + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.Frostburn, 180); - target.AddBuff(ModContent.BuffType(), 30); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Frostburn, 180); + target.AddBuff(ModContent.BuffType(), 30); + } - public override bool CanDamage() => projectile.ai[0] == 0f; - } + public override bool CanDamage() => projectile.ai[0] == 0f; + } } diff --git a/Projectiles/Rogue/FrostyFlareStealth.cs b/Projectiles/Rogue/FrostyFlareStealth.cs index 5ac15e5028..30ef3bbc1e 100644 --- a/Projectiles/Rogue/FrostyFlareStealth.cs +++ b/Projectiles/Rogue/FrostyFlareStealth.cs @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - if (projectile.owner != Main.myPlayer) - return; + if (projectile.owner != Main.myPlayer) + return; bool shoot = false; if (projectile.timeLeft % 30f == 0f) @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Rogue { projectile.velocity.X *= 0.99f; projectile.velocity.Y += 0.25f; - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; if (shoot) { @@ -52,17 +52,17 @@ namespace CalamityMod.Projectiles.Rogue vel.Normalize(); vel *= 30f; int flare = Projectile.NewProjectile(pos, vel + projectile.velocity / 4f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - Main.projectile[flare].alpha = 150; + Main.projectile[flare].alpha = 150; + } + if (projectile.timeLeft % 10 == 0) + { + int snowflake = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, projectile.velocity.Y * 0f, ProjectileID.NorthPoleSnowflake, (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, Main.rand.Next(3)); + if (snowflake.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[snowflake].Calamity().forceRogue = true; + Main.projectile[snowflake].timeLeft = 300; + } } - if (projectile.timeLeft % 10 == 0) - { - int snowflake = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, projectile.velocity.Y * 0f, ProjectileID.NorthPoleSnowflake, (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, Main.rand.Next(3)); - if (snowflake.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[snowflake].Calamity().forceRogue = true; - Main.projectile[snowflake].timeLeft = 300; - } - } int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 172); Main.dust[index2].noGravity = true; @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Rogue vel.Normalize(); vel *= 30f; int flare = Projectile.NewProjectile(pos, vel + Main.npc[id].velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - Main.projectile[flare].alpha = 150; + Main.projectile[flare].alpha = 150; } } else diff --git a/Projectiles/Rogue/GacruxianHome.cs b/Projectiles/Rogue/GacruxianHome.cs index 27f8ae3d03..8c9e1e9aa7 100644 --- a/Projectiles/Rogue/GacruxianHome.cs +++ b/Projectiles/Rogue/GacruxianHome.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class GacruxianHome : ModProjectile + public class GacruxianHome : ModProjectile { public override string Texture => "CalamityMod/Items/Fishing/AstralCatches/GacruxianMollusk"; @@ -40,10 +40,10 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.timeLeft % 30 == 0 && projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceRogue = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceRogue = true; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 12f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/GacruxianProj.cs b/Projectiles/Rogue/GacruxianProj.cs index a066ee27ce..2414c07299 100644 --- a/Projectiles/Rogue/GacruxianProj.cs +++ b/Projectiles/Rogue/GacruxianProj.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; @@ -44,8 +44,8 @@ namespace CalamityMod.Projectiles.Rogue else { int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceRogue = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceRogue = true; } } } diff --git a/Projectiles/Rogue/GelDartProjectile.cs b/Projectiles/Rogue/GelDartProjectile.cs index 6ee65ee71f..21cafb3185 100644 --- a/Projectiles/Rogue/GelDartProjectile.cs +++ b/Projectiles/Rogue/GelDartProjectile.cs @@ -28,24 +28,24 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; } - public override void AI() - { - if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) - { - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; - if (projectile.timeLeft % 8 == 0) - { - Vector2 velocity = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f)); - int slime = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.SlimeGun, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); - if (slime.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[slime].Calamity().forceRogue = true; - Main.projectile[slime].usesLocalNPCImmunity = true; - Main.projectile[slime].localNPCHitCooldown = 10; - } + public override void AI() + { + if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) + { + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction; + if (projectile.timeLeft % 8 == 0) + { + Vector2 velocity = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f)); + int slime = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.SlimeGun, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); + if (slime.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[slime].Calamity().forceRogue = true; + Main.projectile[slime].usesLocalNPCImmunity = true; + Main.projectile[slime].localNPCHitCooldown = 10; + } } - } - } + } + } public override bool OnTileCollide(Vector2 oldVelocity) { @@ -56,25 +56,25 @@ namespace CalamityMod.Projectiles.Rogue } else { - if (projectile.Calamity().stealthStrike) - { - if (projectile.velocity != oldVelocity) - { - projectile.velocity = Main.rand.NextFloat(-1.15f, -0.85f) * oldVelocity * 1.35f; + if (projectile.Calamity().stealthStrike) + { + if (projectile.velocity != oldVelocity) + { + projectile.velocity = Main.rand.NextFloat(-1.15f, -0.85f) * oldVelocity * 1.35f; Main.PlaySound(SoundID.Item56, projectile.position); // Minecart bumper sound - } - } - else - { - if (projectile.velocity.X != oldVelocity.X) - { - projectile.velocity.X = -oldVelocity.X; - } - if (projectile.velocity.Y != oldVelocity.Y) - { - projectile.velocity.Y = -oldVelocity.Y; - } - } + } + } + else + { + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y; + } + } } return false; } @@ -97,15 +97,15 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Slimed, 120); - if (projectile.Calamity().stealthStrike) - target.AddBuff(BuffID.Slow, 120); + if (projectile.Calamity().stealthStrike) + target.AddBuff(BuffID.Slow, 120); } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(BuffID.Slimed, 120); - if (projectile.Calamity().stealthStrike) - target.AddBuff(BuffID.Slow, 120); + if (projectile.Calamity().stealthStrike) + target.AddBuff(BuffID.Slow, 120); } } } diff --git a/Projectiles/Rogue/GildedDaggerProj.cs b/Projectiles/Rogue/GildedDaggerProj.cs index 0f5a501fac..62bde3f9b5 100644 --- a/Projectiles/Rogue/GildedDaggerProj.cs +++ b/Projectiles/Rogue/GildedDaggerProj.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class GildedDaggerProj : ModProjectile + public class GildedDaggerProj : ModProjectile { private bool hasHitEnemy = false; private int targetNPC = -1; @@ -40,8 +40,8 @@ namespace CalamityMod.Projectiles.Rogue } else { - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.PiOver2); + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.PiOver2); //Rotating 90 degrees if shooting right if (projectile.spriteDirection == 1) { @@ -138,6 +138,6 @@ namespace CalamityMod.Projectiles.Rogue int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.GoldCoin, 0f, 0f, 100, default, 1f); Main.dust[num622].velocity *= 1f; } - } + } } } diff --git a/Projectiles/Rogue/GleamingDaggerProj.cs b/Projectiles/Rogue/GleamingDaggerProj.cs index c3b21e498f..88de665009 100644 --- a/Projectiles/Rogue/GleamingDaggerProj.cs +++ b/Projectiles/Rogue/GleamingDaggerProj.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class GleamingDaggerProj : ModProjectile + public class GleamingDaggerProj : ModProjectile { private bool hasHitEnemy = false; private int targetNPC = -1; @@ -40,8 +40,8 @@ namespace CalamityMod.Projectiles.Rogue } else { - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.PiOver2); + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.PiOver2); //Rotating 90 degrees if shooting right if (projectile.spriteDirection == 1) { @@ -138,6 +138,6 @@ namespace CalamityMod.Projectiles.Rogue int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.PlatinumCoin, 0f, 0f, 100, default, 1f); Main.dust[num622].velocity *= 1f; } - } + } } } diff --git a/Projectiles/Rogue/GodsParanoiaDart.cs b/Projectiles/Rogue/GodsParanoiaDart.cs index e7092419f6..ae4fdd426a 100644 --- a/Projectiles/Rogue/GodsParanoiaDart.cs +++ b/Projectiles/Rogue/GodsParanoiaDart.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class GodsParanoiaDart : ModProjectile + public class GodsParanoiaDart : ModProjectile { public override void SetStaticDefaults() { @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = 10; projectile.height = 10; - projectile.ignoreWater = true; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.Calamity().rogue = true; projectile.penetrate = 1; projectile.tileCollide = false; @@ -35,14 +35,14 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.X *= 1.025f; projectile.velocity.Y *= 1.025f; - if (projectile.velocity.X > 12f) - { - projectile.velocity.X = 12f; - } - if (projectile.velocity.Y > 12f) - { - projectile.velocity.Y = 12f; - } + if (projectile.velocity.X > 12f) + { + projectile.velocity.X = 12f; + } + if (projectile.velocity.Y > 12f) + { + projectile.velocity.Y = 12f; + } if (Main.rand.NextBool(3)) { @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; - projectile.damage /= 2; + projectile.damage /= 2; projectile.Damage(); for (int i = 0; i < 2; i++) { @@ -92,10 +92,10 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 595) - return false; + if (projectile.timeLeft > 595) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } } diff --git a/Projectiles/Rogue/GodsParanoiaProj.cs b/Projectiles/Rogue/GodsParanoiaProj.cs index 21811f8cb8..0994734fb4 100644 --- a/Projectiles/Rogue/GodsParanoiaProj.cs +++ b/Projectiles/Rogue/GodsParanoiaProj.cs @@ -8,11 +8,11 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class GodsParanoiaProj : ModProjectile + public class GodsParanoiaProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/GodsParanoia"; - public int kunaiStabbing = 12; + public int kunaiStabbing = 12; public override void SetStaticDefaults() { @@ -25,9 +25,9 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = 15; projectile.height = 15; - projectile.ignoreWater = true; - projectile.friendly = true; - projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.friendly = true; + projectile.tileCollide = false; projectile.Calamity().rogue = true; projectile.penetrate = -1; projectile.timeLeft = 600; @@ -36,8 +36,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.localNPCHitCooldown = -1; } - public override void AI() - { + public override void AI() + { Lighting.AddLight(projectile.Center, 0.35f, 0f, 0.25f); if (Main.rand.NextBool(2)) { @@ -54,51 +54,51 @@ namespace CalamityMod.Projectiles.Rogue kunaiStabbing++; if (kunaiStabbing >= 20) { - kunaiStabbing = 0; - float startOffsetX = Main.rand.NextFloat(100f, 200f) * (Main.rand.NextBool() ? -1f : 1f); - float startOffsetY = Main.rand.NextFloat(100f, 200f) * (Main.rand.NextBool() ? -1f : 1f); - Vector2 startPos = new Vector2(projectile.position.X + startOffsetX, projectile.position.Y + startOffsetY); - float dx = projectile.position.X - startPos.X; - float dy = projectile.position.Y - startPos.Y; + kunaiStabbing = 0; + float startOffsetX = Main.rand.NextFloat(100f, 200f) * (Main.rand.NextBool() ? -1f : 1f); + float startOffsetY = Main.rand.NextFloat(100f, 200f) * (Main.rand.NextBool() ? -1f : 1f); + Vector2 startPos = new Vector2(projectile.position.X + startOffsetX, projectile.position.Y + startOffsetY); + float dx = projectile.position.X - startPos.X; + float dy = projectile.position.Y - startPos.Y; - // Add some randomness / inaccuracy - dx += Main.rand.NextFloat(-5f, 5f); - dy += Main.rand.NextFloat(-5f, 5f); - float speed = Main.rand.NextFloat(20f, 25f); - float dist = (float)Math.Sqrt((double)(dx * dx + dy * dy)); - dist = speed / dist; - dx *= dist; - dy *= dist; - Vector2 kunaiSp = new Vector2(dx, dy); - float angle = Main.rand.NextFloat(MathHelper.TwoPi); - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < 3; i++) - { - int idx = Projectile.NewProjectile(startPos, kunaiSp, ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack / 2f, projectile.owner, 0f, 0f); - Main.projectile[idx].rotation = angle; - } - } - } - } - else - { - projectile.rotation += 0.2f * (float)projectile.direction; - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, projectile.Calamity().stealthStrike ? 12f : 7f, 20f); - } + // Add some randomness / inaccuracy + dx += Main.rand.NextFloat(-5f, 5f); + dy += Main.rand.NextFloat(-5f, 5f); + float speed = Main.rand.NextFloat(20f, 25f); + float dist = (float)Math.Sqrt((double)(dx * dx + dy * dy)); + dist = speed / dist; + dx *= dist; + dy *= dist; + Vector2 kunaiSp = new Vector2(dx, dy); + float angle = Main.rand.NextFloat(MathHelper.TwoPi); + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < 3; i++) + { + int idx = Projectile.NewProjectile(startPos, kunaiSp, ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack / 2f, projectile.owner, 0f, 0f); + Main.projectile[idx].rotation = angle; + } + } + } + } + else + { + projectile.rotation += 0.2f * (float)projectile.direction; + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, projectile.Calamity().stealthStrike ? 12f : 7f, 20f); + } Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.killSpikyBalls == true) - { - projectile.active = false; - projectile.netUpdate = true; - } - } + if (modPlayer.killSpikyBalls == true) + { + projectile.active = false; + projectile.netUpdate = true; + } + } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - projectile.ModifyHitNPCSticky(10, true); + projectile.ModifyHitNPCSticky(10, true); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) diff --git a/Projectiles/Rogue/GreenDonkeyKongReference.cs b/Projectiles/Rogue/GreenDonkeyKongReference.cs index eddc4eb933..052ec8a90d 100644 --- a/Projectiles/Rogue/GreenDonkeyKongReference.cs +++ b/Projectiles/Rogue/GreenDonkeyKongReference.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class GreenDonkeyKongReference : ModProjectile + public class GreenDonkeyKongReference : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/AcidicRainBarrel"; @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 48; projectile.height = 48; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = 480; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; @@ -84,13 +84,13 @@ namespace CalamityMod.Projectiles.Rogue int acidIndex = Projectile.NewProjectile(projectile.Center, projectile.velocity + acidVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75f), 1f, projectile.owner); - if (acidIndex.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[acidIndex].Calamity().forceRogue = true; - Main.projectile[acidIndex].timeLeft = 300; - Main.projectile[acidIndex].usesLocalNPCImmunity = true; - Main.projectile[acidIndex].localNPCHitCooldown = -1; - } + if (acidIndex.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[acidIndex].Calamity().forceRogue = true; + Main.projectile[acidIndex].timeLeft = 300; + Main.projectile[acidIndex].usesLocalNPCImmunity = true; + Main.projectile[acidIndex].localNPCHitCooldown = -1; + } } } @@ -102,11 +102,11 @@ namespace CalamityMod.Projectiles.Rogue int acidIndex = Projectile.NewProjectile(projectile.Center, projectile.velocity + acidVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.667f), 1f, projectile.owner); - if (acidIndex.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[acidIndex].Calamity().forceRogue = true; - Main.projectile[acidIndex].timeLeft = 420; - } + if (acidIndex.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[acidIndex].Calamity().forceRogue = true; + Main.projectile[acidIndex].timeLeft = 420; + } } } diff --git a/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs b/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs index 9223aa5cf1..bae95d4c4f 100644 --- a/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs +++ b/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs @@ -37,22 +37,22 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; - if (projectile.Calamity().stealthStrike) - { - if (projectile.timeLeft % 5f == 0f) //every 5 ticks - { - if (Main.rand.NextBool(2)) - { - int energyAmt = Main.rand.Next(1, 4); //1 to 3 energy - for (int n = 0; n < energyAmt; n++) - { - CalamityUtils.ProjectileRain(projectile.Center, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), projectile.knockBack * 0.4f, projectile.owner); - } - } - } - } + if (projectile.Calamity().stealthStrike) + { + if (projectile.timeLeft % 5f == 0f) //every 5 ticks + { + if (Main.rand.NextBool(2)) + { + int energyAmt = Main.rand.Next(1, 4); //1 to 3 energy + for (int n = 0; n < energyAmt; n++) + { + CalamityUtils.ProjectileRain(projectile.Center, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), projectile.knockBack * 0.4f, projectile.owner); + } + } + } + } if (projectile.alpha > 0) { @@ -167,7 +167,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; Main.PlaySound(SoundID.Item10, projectile.position); for (int i = 0; i < 10; i++) diff --git a/Projectiles/Rogue/HellsSunProj.cs b/Projectiles/Rogue/HellsSunProj.cs index 4fecd260cd..87ec17701b 100644 --- a/Projectiles/Rogue/HellsSunProj.cs +++ b/Projectiles/Rogue/HellsSunProj.cs @@ -6,7 +6,7 @@ using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Rogue { - public class HellsSunProj : ModProjectile + public class HellsSunProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/HellsSun"; @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.friendly = true; projectile.Calamity().rogue = true; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = 20; + projectile.ignoreWater = true; + projectile.penetrate = 20; projectile.timeLeft = 1200; projectile.usesLocalNPCImmunity = true; @@ -38,52 +38,52 @@ namespace CalamityMod.Projectiles.Rogue { projectile.velocity.X *= 0.96f; projectile.velocity.Y *= 0.96f; - projectile.localAI[1]++; - if (projectile.Calamity().stealthStrike) - { - if (projectile.localAI[1] >= 30f) - { - Vector2 velocity = projectile.velocity; - Vector2 vector2_1 = new Vector2((float) Main.rand.Next(-100, 101), (float) Main.rand.Next(-100, 101)); - vector2_1.Normalize(); - Vector2 vector2_2 = vector2_1 * ((float) Main.rand.Next(10, 41) * 0.1f); - if (Main.rand.Next(3) == 0) - vector2_2 *= 2f; - Vector2 vector2_3 = velocity * 0.25f + vector2_2; - Vector2 vector2_5 = vector2_3 * 0.8f; - Projectile.NewProjectile(projectile.Center.X - vector2_5.X, projectile.Center.Y - vector2_5.Y, vector2_5.X, vector2_5.Y, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, Main.rand.Next(3), 0.0f); - projectile.localAI[1] = 0.0f; - } - } - else - { - if (projectile.localAI[1] >= 60f) - { - Vector2 velocity = projectile.velocity; - Vector2 vector2_1 = new Vector2((float) Main.rand.Next(-100, 101), (float) Main.rand.Next(-100, 101)); - vector2_1.Normalize(); - Vector2 vector2_2 = vector2_1 * ((float) Main.rand.Next(10, 41) * 0.1f); - if (Main.rand.Next(3) == 0) - vector2_2 *= 2f; - Vector2 vector2_3 = velocity * 0.25f + vector2_2; - Vector2 vector2_5 = vector2_3 * 0.8f; - Projectile.NewProjectile(projectile.Center.X - vector2_5.X, projectile.Center.Y - vector2_5.Y, vector2_5.X, vector2_5.Y, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, Main.rand.Next(3), 0.0f); - projectile.localAI[1] = 0.0f; - } - } + projectile.localAI[1]++; + if (projectile.Calamity().stealthStrike) + { + if (projectile.localAI[1] >= 30f) + { + Vector2 velocity = projectile.velocity; + Vector2 vector2_1 = new Vector2((float) Main.rand.Next(-100, 101), (float) Main.rand.Next(-100, 101)); + vector2_1.Normalize(); + Vector2 vector2_2 = vector2_1 * ((float) Main.rand.Next(10, 41) * 0.1f); + if (Main.rand.Next(3) == 0) + vector2_2 *= 2f; + Vector2 vector2_3 = velocity * 0.25f + vector2_2; + Vector2 vector2_5 = vector2_3 * 0.8f; + Projectile.NewProjectile(projectile.Center.X - vector2_5.X, projectile.Center.Y - vector2_5.Y, vector2_5.X, vector2_5.Y, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, Main.rand.Next(3), 0.0f); + projectile.localAI[1] = 0.0f; + } + } + else + { + if (projectile.localAI[1] >= 60f) + { + Vector2 velocity = projectile.velocity; + Vector2 vector2_1 = new Vector2((float) Main.rand.Next(-100, 101), (float) Main.rand.Next(-100, 101)); + vector2_1.Normalize(); + Vector2 vector2_2 = vector2_1 * ((float) Main.rand.Next(10, 41) * 0.1f); + if (Main.rand.Next(3) == 0) + vector2_2 *= 2f; + Vector2 vector2_3 = velocity * 0.25f + vector2_2; + Vector2 vector2_5 = vector2_3 * 0.8f; + Projectile.NewProjectile(projectile.Center.X - vector2_5.X, projectile.Center.Y - vector2_5.Y, vector2_5.X, vector2_5.Y, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, Main.rand.Next(3), 0.0f); + projectile.localAI[1] = 0.0f; + } + } + } + else + { + projectile.rotation += 0.3f * (float)projectile.direction; } - else - { - projectile.rotation += 0.3f * (float)projectile.direction; - } Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.killSpikyBalls == true) - { - projectile.active = false; - projectile.netUpdate = true; - } + if (modPlayer.killSpikyBalls == true) + { + projectile.active = false; + projectile.netUpdate = true; + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Rogue/Honeycomb.cs b/Projectiles/Rogue/Honeycomb.cs index a174b4e99b..f528ae0636 100644 --- a/Projectiles/Rogue/Honeycomb.cs +++ b/Projectiles/Rogue/Honeycomb.cs @@ -7,7 +7,7 @@ using CalamityMod.Items.Weapons.Rogue; namespace CalamityMod.Projectiles.Rogue { - public class Honeycomb : ModProjectile + public class Honeycomb : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/HardenedHoneycomb"; @@ -36,32 +36,32 @@ namespace CalamityMod.Projectiles.Rogue Vector2 posDiff = player.Center - projectile.Center; if (posDiff.Length() <= radius) { - player.AddBuff(BuffID.Honey, 300); + player.AddBuff(BuffID.Honey, 300); } } public override bool OnTileCollide(Vector2 oldVelocity) { - int split = 0; - while (split < 3) - { - //Calculate the velocity of the projectile - float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); - float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; - //Prevents the projectile speed from being too low - if (shardspeedX < 2f && shardspeedX > -2f) - { - shardspeedX += -projectile.velocity.X; - } - if (shardspeedY > 2f && shardspeedY < 2f) - { - shardspeedY += -projectile.velocity.Y; - } + int split = 0; + while (split < 3) + { + //Calculate the velocity of the projectile + float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); + float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; + //Prevents the projectile speed from being too low + if (shardspeedX < 2f && shardspeedX > -2f) + { + shardspeedX += -projectile.velocity.X; + } + if (shardspeedY > 2f && shardspeedY < 2f) + { + shardspeedY += -projectile.velocity.Y; + } - //Spawn the projectile - Projectile.NewProjectile(projectile.position.X + shardspeedX, projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 2f, projectile.owner, Main.rand.Next(3), 0f); - split += 1; - } + //Spawn the projectile + Projectile.NewProjectile(projectile.position.X + shardspeedX, projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 2f, projectile.owner, Main.rand.Next(3), 0f); + split += 1; + } projectile.penetrate--; if (projectile.penetrate <= 0) { @@ -83,54 +83,54 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - projectile.velocity.X = -projectile.velocity.X; - projectile.velocity.Y = -projectile.velocity.Y; - int split = 0; - while (split < 3) - { - //Calculate the velocity of the projectile - float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); - float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; - //Prevents the projectile speed from being too low - if (shardspeedX < 2f && shardspeedX > -2f) - { - shardspeedX += -projectile.velocity.X; - } - if (shardspeedY > 2f && shardspeedY < 2f) - { - shardspeedY += -projectile.velocity.Y; - } + projectile.velocity.X = -projectile.velocity.X; + projectile.velocity.Y = -projectile.velocity.Y; + int split = 0; + while (split < 3) + { + //Calculate the velocity of the projectile + float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); + float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; + //Prevents the projectile speed from being too low + if (shardspeedX < 2f && shardspeedX > -2f) + { + shardspeedX += -projectile.velocity.X; + } + if (shardspeedY > 2f && shardspeedY < 2f) + { + shardspeedY += -projectile.velocity.Y; + } - //Spawn the projectile - Projectile.NewProjectile(projectile.position.X + shardspeedX, projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 2f, projectile.owner, Main.rand.Next(3), 0f); - split += 1; - } + //Spawn the projectile + Projectile.NewProjectile(projectile.position.X + shardspeedX, projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 2f, projectile.owner, Main.rand.Next(3), 0f); + split += 1; + } } public override void OnHitPvp(Player target, int damage, bool crit) { - projectile.velocity.X = -projectile.velocity.X; - projectile.velocity.Y = -projectile.velocity.Y; - int split = 0; - while (split < 3) - { - //Calculate the velocity of the projectile - float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); - float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; - //Prevents the projectile speed from being too low - if (shardspeedX < 2f && shardspeedX > -2f) - { - shardspeedX += -projectile.velocity.X; - } - if (shardspeedY > 2f && shardspeedY < 2f) - { - shardspeedY += -projectile.velocity.Y; - } + projectile.velocity.X = -projectile.velocity.X; + projectile.velocity.Y = -projectile.velocity.Y; + int split = 0; + while (split < 3) + { + //Calculate the velocity of the projectile + float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); + float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; + //Prevents the projectile speed from being too low + if (shardspeedX < 2f && shardspeedX > -2f) + { + shardspeedX += -projectile.velocity.X; + } + if (shardspeedY > 2f && shardspeedY < 2f) + { + shardspeedY += -projectile.velocity.Y; + } - //Spawn the projectile - Projectile.NewProjectile(projectile.position.X + shardspeedX, projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 2f, projectile.owner, Main.rand.Next(3), 0f); - split += 1; - } + //Spawn the projectile + Projectile.NewProjectile(projectile.position.X + shardspeedX, projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 2f, projectile.owner, Main.rand.Next(3), 0f); + split += 1; + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/HoneycombFragment.cs b/Projectiles/Rogue/HoneycombFragment.cs index 76793b5595..2d7d1320eb 100644 --- a/Projectiles/Rogue/HoneycombFragment.cs +++ b/Projectiles/Rogue/HoneycombFragment.cs @@ -5,7 +5,7 @@ using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Projectiles.Rogue { - public class HoneycombFragment : ModProjectile + public class HoneycombFragment : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Rogue/IceStarProjectile.cs b/Projectiles/Rogue/IceStarProjectile.cs index a86c008cc6..55d98f0e14 100644 --- a/Projectiles/Rogue/IceStarProjectile.cs +++ b/Projectiles/Rogue/IceStarProjectile.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 280; aiType = ProjectileID.ThrowingKnife; projectile.Calamity().rogue = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() @@ -49,30 +49,30 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 67, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - Vector2 center = projectile.Center; - float maxDistance = projectile.Calamity().stealthStrike ? 800f : 400f; - bool homeIn = false; + Vector2 center = projectile.Center; + float maxDistance = projectile.Calamity().stealthStrike ? 800f : 400f; + 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) + (float)(Main.npc[i].height / 2); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) - { - center = Main.npc[i].Center; - homeIn = true; - break; - } - } - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + { + center = Main.npc[i].Center; + homeIn = true; + break; + } + } + } - if (homeIn) - { - Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * 20f + moveDirection * 14f) / (21f); - } + if (homeIn) + { + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 20f + moveDirection * 14f) / (21f); + } projectile.velocity = initStealth && !homeIn ? initialVelocity : projectile.velocity; } diff --git a/Projectiles/Rogue/IcebreakerHammer.cs b/Projectiles/Rogue/IcebreakerHammer.cs index d9a2a00b04..f619891510 100644 --- a/Projectiles/Rogue/IcebreakerHammer.cs +++ b/Projectiles/Rogue/IcebreakerHammer.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Projectiles.Rogue { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Icebreaker"; - private int explosionCount = 0; + private int explosionCount = 0; public override void SetStaticDefaults() { @@ -23,14 +23,14 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = 30; projectile.height = 30; - projectile.ignoreWater = true; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.Calamity().rogue = true; projectile.penetrate = -1; projectile.aiStyle = 3; projectile.timeLeft = 120; aiType = ProjectileID.WoodenBoomerang; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() @@ -50,64 +50,64 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.owner == Main.myPlayer) - { - target.AddBuff(BuffID.Frostburn, 180); + if (projectile.owner == Main.myPlayer) + { + target.AddBuff(BuffID.Frostburn, 180); - if (projectile.Calamity().stealthStrike) - { - if (explosionCount < 3) //max amount of explosions to prevent worm memes - { - int ice = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 1.5), projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (ice.WithinBounds(Main.maxProjectiles)) - Main.projectile[ice].Calamity().forceRogue = true; - explosionCount++; - } + if (projectile.Calamity().stealthStrike) + { + if (explosionCount < 3) //max amount of explosions to prevent worm memes + { + int ice = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 1.5), projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (ice.WithinBounds(Main.maxProjectiles)) + Main.projectile[ice].Calamity().forceRogue = true; + explosionCount++; + } - int buffType = ModContent.BuffType(); - float radius = 112f; // 7 blocks + int buffType = ModContent.BuffType(); + float radius = 112f; // 7 blocks - 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) <= radius) - { - if (nPC.FindBuffIndex(buffType) == -1) - nPC.AddBuff(buffType, 60, false); - } - } - } - } + 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) <= radius) + { + if (nPC.FindBuffIndex(buffType) == -1) + nPC.AddBuff(buffType, 60, false); + } + } + } + } } public override void OnHitPvp(Player target, int damage, bool crit) { - if (projectile.owner == Main.myPlayer) - { - target.AddBuff(BuffID.Frostburn, 180); + if (projectile.owner == Main.myPlayer) + { + target.AddBuff(BuffID.Frostburn, 180); - if (projectile.Calamity().stealthStrike) - { - //no explosion count cap in pvp - int ice = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 1.5), projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (ice.WithinBounds(Main.maxProjectiles)) - Main.projectile[ice].Calamity().forceRogue = true; + if (projectile.Calamity().stealthStrike) + { + //no explosion count cap in pvp + int ice = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 1.5), projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (ice.WithinBounds(Main.maxProjectiles)) + Main.projectile[ice].Calamity().forceRogue = true; - int buffType = ModContent.BuffType(); - float radius = 112f; // 7 blocks + int buffType = ModContent.BuffType(); + float radius = 112f; // 7 blocks - for (int i = 0; i < Main.maxPlayers; i++) - { - Player owner = Main.player[projectile.owner]; - Player player = Main.player[i]; - if ((owner.team != player.team || player.team == 0) && player.hostile && owner.hostile && !player.dead && !player.buffImmune[buffType] && Vector2.Distance(projectile.Center, player.Center) <= radius) - { - if (player.FindBuffIndex(buffType) == -1) - player.AddBuff(buffType, 60, false); - } - } - } - } + for (int i = 0; i < Main.maxPlayers; i++) + { + Player owner = Main.player[projectile.owner]; + Player player = Main.player[i]; + if ((owner.team != player.team || player.team == 0) && player.hostile && owner.hostile && !player.dead && !player.buffImmune[buffType] && Vector2.Distance(projectile.Center, player.Center) <= radius) + { + if (player.FindBuffIndex(buffType) == -1) + player.AddBuff(buffType, 60, false); + } + } + } + } } } } diff --git a/Projectiles/Rogue/IchorSpearProj.cs b/Projectiles/Rogue/IchorSpearProj.cs index 36897eb7d5..05b67b8837 100644 --- a/Projectiles/Rogue/IchorSpearProj.cs +++ b/Projectiles/Rogue/IchorSpearProj.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 2; + projectile.ignoreWater = true; + projectile.penetrate = 2; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; @@ -36,30 +36,30 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 246, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; if (projectile.spriteDirection == -1) { projectile.rotation -= 1.57f; } - if (projectile.Calamity().stealthStrike) - { - if (projectile.timeLeft % 8 == 0) - { - if (projectile.owner == Main.myPlayer) - { - Vector2 velocity = new Vector2(Main.rand.NextFloat(-14f, 14f), Main.rand.NextFloat(-14f, 14f)); - int ichor = Projectile.NewProjectile(projectile.Center, velocity, Main.rand.NextBool(2) ? ProjectileID.GoldenShowerFriendly : ProjectileID.IchorSplash, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); - if (ichor.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[ichor].Calamity().forceRogue = true; - Main.projectile[ichor].usesLocalNPCImmunity = true; - Main.projectile[ichor].localNPCHitCooldown = 10; - Main.projectile[ichor].extraUpdates = 2; - } - } + if (projectile.Calamity().stealthStrike) + { + if (projectile.timeLeft % 8 == 0) + { + if (projectile.owner == Main.myPlayer) + { + Vector2 velocity = new Vector2(Main.rand.NextFloat(-14f, 14f), Main.rand.NextFloat(-14f, 14f)); + int ichor = Projectile.NewProjectile(projectile.Center, velocity, Main.rand.NextBool(2) ? ProjectileID.GoldenShowerFriendly : ProjectileID.IchorSplash, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); + if (ichor.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[ichor].Calamity().forceRogue = true; + Main.projectile[ichor].usesLocalNPCImmunity = true; + Main.projectile[ichor].localNPCHitCooldown = 10; + Main.projectile[ichor].extraUpdates = 2; + } + } } - } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/InfernalKrisProjectile.cs b/Projectiles/Rogue/InfernalKrisProjectile.cs index 1df55c9f15..5f0fb57abc 100644 --- a/Projectiles/Rogue/InfernalKrisProjectile.cs +++ b/Projectiles/Rogue/InfernalKrisProjectile.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - int debuffTime = 60 * (projectile.Calamity().stealthStrike ? Main.rand.Next(4,8) : Main.rand.Next(3,6)); + int debuffTime = 60 * (projectile.Calamity().stealthStrike ? Main.rand.Next(4,8) : Main.rand.Next(3,6)); target.AddBuff(BuffID.OnFire, debuffTime); if (projectile.Calamity().stealthStrike) @@ -87,7 +87,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPvp(Player target, int damage, bool crit) { - int debuffTime = 60 * (projectile.Calamity().stealthStrike ? Main.rand.Next(4,8) : Main.rand.Next(3,6)); + int debuffTime = 60 * (projectile.Calamity().stealthStrike ? Main.rand.Next(4,8) : Main.rand.Next(3,6)); target.AddBuff(BuffID.OnFire, debuffTime); if (projectile.Calamity().stealthStrike) diff --git a/Projectiles/Rogue/InkBombProjectile.cs b/Projectiles/Rogue/InkBombProjectile.cs index dcef0a1e9a..0ee41dcc15 100644 --- a/Projectiles/Rogue/InkBombProjectile.cs +++ b/Projectiles/Rogue/InkBombProjectile.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Rogue private void CreateInk() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; Main.PlaySound(SoundID.Item14, projectile.position); for (int i = 0; i < 20; i++) { diff --git a/Projectiles/Rogue/JawsProjectile.cs b/Projectiles/Rogue/JawsProjectile.cs index 7922b8c41f..bb7feb64cb 100644 --- a/Projectiles/Rogue/JawsProjectile.cs +++ b/Projectiles/Rogue/JawsProjectile.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class JawsProjectile : ModProjectile + public class JawsProjectile : ModProjectile { public override void SetStaticDefaults() { @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 10; projectile.height = 10; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = 600; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; @@ -38,13 +38,13 @@ namespace CalamityMod.Projectiles.Rogue projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; if (projectile.Calamity().stealthStrike) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 33, - 101, - 111, - 180 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 33, + 101, + 111, + 180 + }); int dust = Dust.NewDust(projectile.Center, 1, 1, dustType, projectile.velocity.X, projectile.velocity.Y, 0, default, 1.5f); Main.dust[dust].noGravity = true; @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; target.AddBuff(BuffID.Venom, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPvp(Player target, int damage, bool crit) { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; target.AddBuff(BuffID.Venom, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); @@ -103,13 +103,13 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < 5; i++) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 33, - 101, - 111, - 180 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 33, + 101, + 111, + 180 + }); int dust = Dust.NewDust(projectile.Center, 1, 1, dustType, 0, 0, 0, default, 1.5f); Main.dust[dust].noGravity = true; diff --git a/Projectiles/Rogue/JewelSpike.cs b/Projectiles/Rogue/JewelSpike.cs index dc87dd67ab..81b2d10b46 100644 --- a/Projectiles/Rogue/JewelSpike.cs +++ b/Projectiles/Rogue/JewelSpike.cs @@ -19,19 +19,19 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = -1; projectile.tileCollide = false; projectile.timeLeft = 40; - projectile.Calamity().rogue = true; - projectile.usesLocalNPCImmunity = true; + projectile.Calamity().rogue = true; + projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } public override void AI() { - projectile.velocity *= 0f; + projectile.velocity *= 0f; if (Main.rand.NextBool(5) && projectile.frame < 3) { int crystalDust = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 87, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - Main.dust[crystalDust].noGravity = true; + Main.dust[crystalDust].noGravity = true; } projectile.frameCounter++; diff --git a/Projectiles/Rogue/KelvinCatalystBoomerang.cs b/Projectiles/Rogue/KelvinCatalystBoomerang.cs index b3db6fa438..66b1d7d66d 100644 --- a/Projectiles/Rogue/KelvinCatalystBoomerang.cs +++ b/Projectiles/Rogue/KelvinCatalystBoomerang.cs @@ -9,192 +9,192 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class KelvinCatalystBoomerang : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/KelvinCatalyst"; - public int AIState = 0; + public class KelvinCatalystBoomerang : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/KelvinCatalyst"; + public int AIState = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Kelvin Catalyst"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 12; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Kelvin Catalyst"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 12; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 30; - projectile.height = 30; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.extraUpdates = 1; - projectile.Calamity().rogue = true; - projectile.coldDamage = true; - } + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.extraUpdates = 1; + projectile.Calamity().rogue = true; + projectile.coldDamage = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - writer.Write(AIState); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + writer.Write(AIState); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - AIState = reader.ReadInt32(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + AIState = reader.ReadInt32(); + } - public override void AI() - { - VisualAudioEffects(); - BoomerangAI(); - } + public override void AI() + { + VisualAudioEffects(); + BoomerangAI(); + } - private void BoomerangAI() - { - switch (AIState) - { - case 0: - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 75f) - { - ResetStats(projectile.Calamity().stealthStrike); - } - break; - case 1: - ReturnToPlayer(); - break; - case 2: - // Will target the targetted NPC that minions use btw - projectile.ChargingMinionAI(1200f, 1500f, 2200f, 150f, 0, 40f, 9f, 4f, new Vector2(0f, -60f), 40f, 9f, true, true); - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 120) - { - ResetStats(false); - } - break; - } - } + private void BoomerangAI() + { + switch (AIState) + { + case 0: + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= 75f) + { + ResetStats(projectile.Calamity().stealthStrike); + } + break; + case 1: + ReturnToPlayer(); + break; + case 2: + // Will target the targetted NPC that minions use btw + projectile.ChargingMinionAI(1200f, 1500f, 2200f, 150f, 0, 40f, 9f, 4f, new Vector2(0f, -60f), 40f, 9f, true, true); + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= 120) + { + ResetStats(false); + } + break; + } + } - private void ReturnToPlayer() - { - Player player = Main.player[projectile.owner]; - float returnSpeed = 20f; - float acceleration = 2f; - Vector2 playerVec = player.Center - projectile.Center; - float dist = playerVec.Length(); + private void ReturnToPlayer() + { + Player player = Main.player[projectile.owner]; + float returnSpeed = 20f; + float acceleration = 2f; + Vector2 playerVec = player.Center - projectile.Center; + float dist = playerVec.Length(); - // Delete the projectile if it's excessively far away. - if (dist > 3000f) - projectile.Kill(); + // Delete the projectile if it's excessively far away. + if (dist > 3000f) + projectile.Kill(); - playerVec.Normalize(); - playerVec *= returnSpeed; + playerVec.Normalize(); + playerVec *= returnSpeed; - // Home back in on the player. - if (projectile.velocity.X < playerVec.X) - { - projectile.velocity.X += acceleration; - if (projectile.velocity.X < 0f && playerVec.X > 0f) - projectile.velocity.X += acceleration; - } - else if (projectile.velocity.X > playerVec.X) - { - projectile.velocity.X -= acceleration; - if (projectile.velocity.X > 0f && playerVec.X < 0f) - projectile.velocity.X -= acceleration; - } - if (projectile.velocity.Y < playerVec.Y) - { - projectile.velocity.Y += acceleration; - if (projectile.velocity.Y < 0f && playerVec.Y > 0f) - projectile.velocity.Y += acceleration; - } - else if (projectile.velocity.Y > playerVec.Y) - { - projectile.velocity.Y -= acceleration; - if (projectile.velocity.Y > 0f && playerVec.Y < 0f) - projectile.velocity.Y -= acceleration; - } - if (Main.myPlayer == projectile.owner) - if (projectile.Hitbox.Intersects(player.Hitbox)) - projectile.Kill(); - } + // Home back in on the player. + if (projectile.velocity.X < playerVec.X) + { + projectile.velocity.X += acceleration; + if (projectile.velocity.X < 0f && playerVec.X > 0f) + projectile.velocity.X += acceleration; + } + else if (projectile.velocity.X > playerVec.X) + { + projectile.velocity.X -= acceleration; + if (projectile.velocity.X > 0f && playerVec.X < 0f) + projectile.velocity.X -= acceleration; + } + if (projectile.velocity.Y < playerVec.Y) + { + projectile.velocity.Y += acceleration; + if (projectile.velocity.Y < 0f && playerVec.Y > 0f) + projectile.velocity.Y += acceleration; + } + else if (projectile.velocity.Y > playerVec.Y) + { + projectile.velocity.Y -= acceleration; + if (projectile.velocity.Y > 0f && playerVec.Y < 0f) + projectile.velocity.Y -= acceleration; + } + if (Main.myPlayer == projectile.owner) + if (projectile.Hitbox.Intersects(player.Hitbox)) + projectile.Kill(); + } - private void VisualAudioEffects() - { - Lighting.AddLight(projectile.Center, Main.DiscoR * 0.3f / 255f, Main.DiscoR * 0.4f / 255f, Main.DiscoR * 0.5f / 255f); + private void VisualAudioEffects() + { + Lighting.AddLight(projectile.Center, Main.DiscoR * 0.3f / 255f, Main.DiscoR * 0.4f / 255f, Main.DiscoR * 0.5f / 255f); - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 8; - Main.PlaySound(SoundID.Item7, projectile.position); - } + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 8; + Main.PlaySound(SoundID.Item7, projectile.position); + } - int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 67, 0f, 0f, 100, default, 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0f; + int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 67, 0f, 0f, 100, default, 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; - projectile.rotation += 0.25f; - } + projectile.rotation += 0.25f; + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - ResetStats(projectile.Calamity().stealthStrike); - if (projectile.velocity.X != oldVelocity.X) - projectile.velocity.X = -oldVelocity.X; - if (projectile.velocity.Y != oldVelocity.Y) - projectile.velocity.Y = -oldVelocity.Y; - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + ResetStats(projectile.Calamity().stealthStrike); + if (projectile.velocity.X != oldVelocity.X) + projectile.velocity.X = -oldVelocity.X; + if (projectile.velocity.Y != oldVelocity.Y) + projectile.velocity.Y = -oldVelocity.Y; + return false; + } - private void ResetStats(bool chaseEnemies) - { - AIState = chaseEnemies ? 2 : 1; - projectile.localAI[0] = 0f; - projectile.width = projectile.height = 60; - projectile.tileCollide = false; - projectile.netUpdate = true; - } + private void ResetStats(bool chaseEnemies) + { + AIState = chaseEnemies ? 2 : 1; + projectile.localAI[0] = 0f; + projectile.width = projectile.height = 60; + projectile.tileCollide = false; + projectile.netUpdate = true; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.Frostburn, 240); - OnHitEffects(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Frostburn, 240); + OnHitEffects(); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.Frostburn, 240); - OnHitEffects(); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Frostburn, 240); + OnHitEffects(); + } - private void OnHitEffects() - { - int projType = ModContent.ProjectileType(); - if (projectile.owner == Main.myPlayer && Main.player[projectile.owner].ownedProjectileCounts[projType] < 25) - { - float spread = 45f * 0.0174f; - double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - double offsetAngle; - for (int i = 0; i < 4; i++) - { - offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; + private void OnHitEffects() + { + int projType = ModContent.ProjectileType(); + if (projectile.owner == Main.myPlayer && Main.player[projectile.owner].ownedProjectileCounts[projType] < 25) + { + float spread = 45f * 0.0174f; + double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; + double deltaAngle = spread / 8f; + double offsetAngle; + for (int 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) * 4f), (float)(Math.Cos(offsetAngle) * 4f), projType, projectile.damage / 6, projectile.knockBack * 0.5f, projectile.owner); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 4f), (float)(Math.Cos(offsetAngle) * 4f), projType, projectile.damage / 6, projectile.knockBack * 0.5f, projectile.owner); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 4f), (float)(-Math.Cos(offsetAngle) * 4f), projType, projectile.damage / 6, projectile.knockBack * 0.5f, projectile.owner); - } - } - Main.PlaySound(SoundID.Item30, projectile.position); - } + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 4f), (float)(-Math.Cos(offsetAngle) * 4f), projType, projectile.damage / 6, projectile.knockBack * 0.5f, projectile.owner); + } + } + Main.PlaySound(SoundID.Item30, projectile.position); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + return false; + } + } } diff --git a/Projectiles/Rogue/Knife.cs b/Projectiles/Rogue/Knife.cs index d150b12b1e..1c79033992 100644 --- a/Projectiles/Rogue/Knife.cs +++ b/Projectiles/Rogue/Knife.cs @@ -20,14 +20,14 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; projectile.Calamity().rogue = true; - projectile.extraUpdates = 1; - } + projectile.extraUpdates = 1; + } public override void AI() { diff --git a/Projectiles/Rogue/LatcherMineProjectile.cs b/Projectiles/Rogue/LatcherMineProjectile.cs index 68c4cd1c37..f22f4b8f43 100644 --- a/Projectiles/Rogue/LatcherMineProjectile.cs +++ b/Projectiles/Rogue/LatcherMineProjectile.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class LatcherMineProjectile : ModProjectile + public class LatcherMineProjectile : ModProjectile { private int projdmg = 0; public override void SetStaticDefaults() @@ -114,7 +114,7 @@ namespace CalamityMod.Projectiles.Rogue } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - projdmg = projectile.damage; + projdmg = projectile.damage; projectile.ModifyHitNPCSticky(6, false); } diff --git a/Projectiles/Rogue/LeonidCometBig.cs b/Projectiles/Rogue/LeonidCometBig.cs index 6db0867151..b8f9cc9748 100644 --- a/Projectiles/Rogue/LeonidCometBig.cs +++ b/Projectiles/Rogue/LeonidCometBig.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class LeonidCometBig : ModProjectile + public class LeonidCometBig : ModProjectile { public override void SetStaticDefaults() { @@ -18,15 +18,15 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - projectile.width = 50; - projectile.height = 42; - projectile.aiStyle = 1; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.Calamity().rogue = true; - projectile.tileCollide = false; - projectile.extraUpdates = 2; - aiType = ProjectileID.Meteor1; + projectile.width = 50; + projectile.height = 42; + projectile.aiStyle = 1; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.Calamity().rogue = true; + projectile.tileCollide = false; + projectile.extraUpdates = 2; + aiType = ProjectileID.Meteor1; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -45,58 +45,58 @@ namespace CalamityMod.Projectiles.Rogue return false; } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D tex = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/LeonidCometBigGlow"); - spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); - } + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/LeonidCometBigGlow"); + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); + } public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Item89, projectile.position); - projectile.position.X += (float)(projectile.width / 2); - projectile.position.Y += (float)(projectile.height / 2); - projectile.width = (int)(128f * projectile.scale); - projectile.height = (int)(128f * projectile.scale); - projectile.position.X -= (float)(projectile.width / 2); - projectile.position.Y -= (float)(projectile.height / 2); - for (int index = 0; index < 8; ++index) - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0.0f, 0.0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.5f); - for (int index1 = 0; index1 < 32; ++index1) - { - int index2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 2.5f); - Dust dust1 = Main.dust[index2]; - dust1.noGravity = true; - dust1.velocity *= 3f; - int index3 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.5f); - Dust dust2 = Main.dust[index3]; - dust2.velocity *= 2f; - dust2.noGravity = true; - } - for (int index1 = 0; index1 < 2; ++index1) - { - int index2 = Gore.NewGore(projectile.position + new Vector2((float) (projectile.width * Main.rand.Next(100)) / 100f, (float) (projectile.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, new Vector2(), Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[index2]; - gore.velocity *= 0.3f; - gore.velocity.X += (float) Main.rand.Next(-10, 11) * 0.05f; - gore.velocity.Y += (float) Main.rand.Next(-10, 11) * 0.05f; - } - if (projectile.owner == Main.myPlayer) - { - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.localAI[1] = -1f; - projectile.maxPenetrate = 0; - projectile.Damage(); - } - for (int index1 = 0; index1 < 5; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, Utils.SelectRandom(Main.rand, new int[3]{ DustID.Fire, 259, 158 }), 2.5f * (float) projectile.direction, -2.5f, 0, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1f); - Dust dust1 = Main.dust[index2]; - dust1.alpha = 200; - dust1.velocity *= 2.4f; - dust1.scale += Main.rand.NextFloat(); - } + Main.PlaySound(SoundID.Item89, projectile.position); + projectile.position.X += (float)(projectile.width / 2); + projectile.position.Y += (float)(projectile.height / 2); + projectile.width = (int)(128f * projectile.scale); + projectile.height = (int)(128f * projectile.scale); + projectile.position.X -= (float)(projectile.width / 2); + projectile.position.Y -= (float)(projectile.height / 2); + for (int index = 0; index < 8; ++index) + Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0.0f, 0.0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.5f); + for (int index1 = 0; index1 < 32; ++index1) + { + int index2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 2.5f); + Dust dust1 = Main.dust[index2]; + dust1.noGravity = true; + dust1.velocity *= 3f; + int index3 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.5f); + Dust dust2 = Main.dust[index3]; + dust2.velocity *= 2f; + dust2.noGravity = true; + } + for (int index1 = 0; index1 < 2; ++index1) + { + int index2 = Gore.NewGore(projectile.position + new Vector2((float) (projectile.width * Main.rand.Next(100)) / 100f, (float) (projectile.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, new Vector2(), Main.rand.Next(61, 64), 1f); + Gore gore = Main.gore[index2]; + gore.velocity *= 0.3f; + gore.velocity.X += (float) Main.rand.Next(-10, 11) * 0.05f; + gore.velocity.Y += (float) Main.rand.Next(-10, 11) * 0.05f; + } + if (projectile.owner == Main.myPlayer) + { + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.localAI[1] = -1f; + projectile.maxPenetrate = 0; + projectile.Damage(); + } + for (int index1 = 0; index1 < 5; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, Utils.SelectRandom(Main.rand, new int[3]{ DustID.Fire, 259, 158 }), 2.5f * (float) projectile.direction, -2.5f, 0, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1f); + Dust dust1 = Main.dust[index2]; + dust1.alpha = 200; + dust1.velocity *= 2.4f; + dust1.scale += Main.rand.NextFloat(); + } } } } diff --git a/Projectiles/Rogue/LeonidCometSmall.cs b/Projectiles/Rogue/LeonidCometSmall.cs index 3296513a2a..3c27e8176a 100644 --- a/Projectiles/Rogue/LeonidCometSmall.cs +++ b/Projectiles/Rogue/LeonidCometSmall.cs @@ -21,110 +21,110 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 28; projectile.height = 28; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.Calamity().rogue = true; + projectile.ignoreWater = true; + projectile.Calamity().rogue = true; projectile.penetrate = 1; projectile.timeLeft = 300; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; - projectile.alpha = 255; + projectile.alpha = 255; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D tex = Main.projectileTexture[projectile.type]; - spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = Main.projectileTexture[projectile.type]; + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D tex = ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/LeonidProgenitorGlow"); - spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); - } + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/LeonidProgenitorGlow"); + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); + } public override void AI() { - projectile.alpha -= 25; - if (projectile.alpha < 0) - projectile.alpha = 0; - if (Main.rand.NextBool(4)) - { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.DustType(), - ModContent.DustType() - }); - if (Main.rand.NextBool(2)) - { - int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, randomDust, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.6f); - Main.dust[index].noGravity = true; - } - if (Main.rand.NextBool(2)) - { - int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.6f); - Main.dust[index].noGravity = true; - } - int index1 = Dust.NewDust(projectile.position, projectile.width, projectile.height, randomDust, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.2f); - Main.dust[index1].noGravity = true; - Main.dust[index1].velocity *= 2f; - Main.dust[index1].velocity += projectile.velocity; - Main.dust[index1].fadeIn = projectile.ai[1] != -1f ? 1.22f : 1.5f; - } + projectile.alpha -= 25; + if (projectile.alpha < 0) + projectile.alpha = 0; + if (Main.rand.NextBool(4)) + { + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.DustType(), + ModContent.DustType() + }); + if (Main.rand.NextBool(2)) + { + int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, randomDust, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.6f); + Main.dust[index].noGravity = true; + } + if (Main.rand.NextBool(2)) + { + int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.6f); + Main.dust[index].noGravity = true; + } + int index1 = Dust.NewDust(projectile.position, projectile.width, projectile.height, randomDust, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.2f); + Main.dust[index1].noGravity = true; + Main.dust[index1].velocity *= 2f; + Main.dust[index1].velocity += projectile.velocity; + Main.dust[index1].fadeIn = projectile.ai[1] != -1f ? 1.22f : 1.5f; + } if (projectile.ai[0] >= 0f) { - ++projectile.ai[0]; - if (projectile.ai[0] >= 20f) - { - projectile.velocity.Y += 0.2f; - if (projectile.velocity.Y > 0f) - projectile.velocity.X *= 0.98f; - if (projectile.velocity.Y > 12f) - projectile.velocity.Y = 12f; - } + ++projectile.ai[0]; + if (projectile.ai[0] >= 20f) + { + projectile.velocity.Y += 0.2f; + if (projectile.velocity.Y > 0f) + projectile.velocity.X *= 0.98f; + if (projectile.velocity.Y > 12f) + projectile.velocity.Y = 12f; + } } projectile.rotation += projectile.velocity.X * 0.1f; } public override void Kill(int timeLeft) { - if (projectile.owner != Main.myPlayer) - return; - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner); - projectile.ai[1] = -1f; - projectile.position = projectile.Center; - projectile.width = projectile.height = 40; - projectile.Center = projectile.position; - projectile.Damage(); - Main.PlaySound(SoundID.Item89, projectile.position); - for (int index1 = 0; index1 < 2; ++index1) - { - int index2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.5f); - Dust dust = Main.dust[index2]; - dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * Main.rand.NextFloat() * projectile.width / 2f; - } - for (int index1 = 0; index1 < 10; ++index1) - { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.DustType(), - ModContent.DustType() - }); - int index2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDust, 0f, 0f, 0, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 2.5f); - Dust dust = Main.dust[index2]; - dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * Main.rand.NextFloat() * projectile.width / 2f; - dust.noGravity = true; - dust.velocity *= 2f; - } - for (int index1 = 0; index1 < 5; ++index1) - { - int index2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 0, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.5f); - Dust dust = Main.dust[index2]; - dust.position = projectile.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2()) * projectile.width / 2f; - dust.noGravity = true; - dust.velocity *= 2f; - } + if (projectile.owner != Main.myPlayer) + return; + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner); + projectile.ai[1] = -1f; + projectile.position = projectile.Center; + projectile.width = projectile.height = 40; + projectile.Center = projectile.position; + projectile.Damage(); + Main.PlaySound(SoundID.Item89, projectile.position); + for (int index1 = 0; index1 < 2; ++index1) + { + int index2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.5f); + Dust dust = Main.dust[index2]; + dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * Main.rand.NextFloat() * projectile.width / 2f; + } + for (int index1 = 0; index1 < 10; ++index1) + { + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.DustType(), + ModContent.DustType() + }); + int index2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDust, 0f, 0f, 0, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 2.5f); + Dust dust = Main.dust[index2]; + dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * Main.rand.NextFloat() * projectile.width / 2f; + dust.noGravity = true; + dust.velocity *= 2f; + } + for (int index1 = 0; index1 < 5; ++index1) + { + int index2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 0, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.5f); + Dust dust = Main.dust[index2]; + dust.position = projectile.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2()) * projectile.width / 2f; + dust.noGravity = true; + dust.velocity *= 2f; + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Rogue/LeonidProgenitorBombshell.cs b/Projectiles/Rogue/LeonidProgenitorBombshell.cs index 1ffe3d6aaa..894c5b53d0 100644 --- a/Projectiles/Rogue/LeonidProgenitorBombshell.cs +++ b/Projectiles/Rogue/LeonidProgenitorBombshell.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class LeonidProgenitorBombshell : ModProjectile + public class LeonidProgenitorBombshell : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/LeonidProgenitor"; @@ -24,22 +24,22 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 32; projectile.height = 32; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 180; projectile.Calamity().rogue = true; } - public override void AI() - { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.DustType(), - ModContent.DustType() - }); - int astral = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDust, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 0.8f); - Main.dust[astral].noGravity = true; - Main.dust[astral].velocity *= 0f; + public override void AI() + { + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.DustType(), + ModContent.DustType() + }); + int astral = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDust, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 0.8f); + Main.dust[astral].noGravity = true; + Main.dust[astral].velocity *= 0f; projectile.ai[0] += 1f; if (projectile.ai[0] > 10f) @@ -57,71 +57,71 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.Y += 0.2f; } projectile.rotation += projectile.velocity.X * 0.1f; - } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D tex = Main.projectileTexture[projectile.type]; - spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, lightColor, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = Main.projectileTexture[projectile.type]; + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, lightColor, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); + return false; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D tex = ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/LeonidProgenitorGlow"); - spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); - } + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/LeonidProgenitorGlow"); + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); + } public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Item62, projectile.position); - if (Main.myPlayer == projectile.owner) - { + Main.PlaySound(SoundID.Item62, projectile.position); + if (Main.myPlayer == projectile.owner) + { int flash = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, 1f); - if (flash.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[flash].Calamity().forceRogue = true; - Main.projectile[flash].usesLocalNPCImmunity = true; - Main.projectile[flash].localNPCHitCooldown = 10; - } + if (flash.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flash].Calamity().forceRogue = true; + Main.projectile[flash].usesLocalNPCImmunity = true; + Main.projectile[flash].localNPCHitCooldown = 10; + } - Vector2 pos = new Vector2(projectile.Center.X + projectile.width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); - Vector2 velocity = (projectile.Center - pos) / 40f; - int dmg = projectile.damage / 2; - Projectile.NewProjectile(pos, velocity, ModContent.ProjectileType(), dmg, projectile.knockBack, projectile.owner, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); - } + Vector2 pos = new Vector2(projectile.Center.X + projectile.width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 velocity = (projectile.Center - pos) / 40f; + int dmg = projectile.damage / 2; + Projectile.NewProjectile(pos, velocity, ModContent.ProjectileType(), dmg, projectile.knockBack, projectile.owner, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 240); - StealthStrikeEffect(); - } + StealthStrikeEffect(); + } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 240); - StealthStrikeEffect(); + StealthStrikeEffect(); } - private void StealthStrikeEffect() - { - if (!projectile.Calamity().stealthStrike || Main.myPlayer != projectile.owner) - return; + private void StealthStrikeEffect() + { + if (!projectile.Calamity().stealthStrike || Main.myPlayer != projectile.owner) + return; - Vector2 spinningpoint = new Vector2(0f, 6f); - float num1 = MathHelper.ToRadians(45f); - int cometAmt = 5; - float num3 = -(num1 * 2f) / (cometAmt - 1f); - for (int projIndex = 0; projIndex < cometAmt; ++projIndex) - { - int index2 = Projectile.NewProjectile(projectile.Center, spinningpoint.RotatedBy((double)num1 + (double)num3 * (double)projIndex, new Vector2()), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, -1f); - Projectile proj = Main.projectile[index2]; - for (int index3 = 0; index3 < projectile.localNPCImmunity.Length; ++index3) - { - proj.localNPCImmunity[index3] = projectile.localNPCImmunity[index3]; - } - } + Vector2 spinningpoint = new Vector2(0f, 6f); + float num1 = MathHelper.ToRadians(45f); + int cometAmt = 5; + float num3 = -(num1 * 2f) / (cometAmt - 1f); + for (int projIndex = 0; projIndex < cometAmt; ++projIndex) + { + int index2 = Projectile.NewProjectile(projectile.Center, spinningpoint.RotatedBy((double)num1 + (double)num3 * (double)projIndex, new Vector2()), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, -1f); + Projectile proj = Main.projectile[index2]; + for (int index3 = 0; index3 < projectile.localNPCImmunity.Length; ++index3) + { + proj.localNPCImmunity[index3] = projectile.localNPCImmunity[index3]; + } + } } } } diff --git a/Projectiles/Rogue/LeonidStar.cs b/Projectiles/Rogue/LeonidStar.cs index e5af3c688f..2d4624a422 100644 --- a/Projectiles/Rogue/LeonidStar.cs +++ b/Projectiles/Rogue/LeonidStar.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Projectiles.Rogue { public class LeonidStar : ModProjectile { - private bool hasHit = false; - private bool initialized = false; + private bool hasHit = false; + private bool initialized = false; public override void SetStaticDefaults() { @@ -25,33 +25,33 @@ namespace CalamityMod.Projectiles.Rogue projectile.friendly = true; projectile.penetrate = -1; projectile.Calamity().rogue = true; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -2; } public override void AI() { - if (!initialized) - { - projectile.rotation += Main.rand.NextFloat(); - initialized = true; - } - projectile.ai[0]++; - if (projectile.ai[0] > 120f) - { - projectile.scale *= 0.98f; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, projectile.scale); - if (projectile.scale <= 0.05f) - projectile.Kill(); - } + if (!initialized) + { + projectile.rotation += Main.rand.NextFloat(); + initialized = true; + } + projectile.ai[0]++; + if (projectile.ai[0] > 120f) + { + projectile.scale *= 0.98f; + CalamityGlobalProjectile.ExpandHitboxBy(projectile, projectile.scale); + if (projectile.scale <= 0.05f) + projectile.Kill(); + } projectile.rotation += projectile.direction * 0.05f; if (projectile.soundDelay == 0) { projectile.soundDelay = 20 + Main.rand.Next(40); if (Main.rand.NextBool(9)) { - Main.PlaySound(SoundID.Item9, projectile.position); + Main.PlaySound(SoundID.Item9, projectile.position); } } } @@ -59,16 +59,16 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - hasHit = true; + hasHit = true; } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - hasHit = true; + hasHit = true; } - public override bool CanDamage() => !hasHit; + public override bool CanDamage() => !hasHit; public override Color? GetAlpha(Color lightColor) => CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 2.5f); @@ -76,20 +76,20 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < 5; i++) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.DustType(), - ModContent.DustType() - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.DustType(), + ModContent.DustType() + }); int dust = Dust.NewDust(projectile.Center, 1, 1, dustType, projectile.velocity.X, projectile.velocity.Y, 0, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.5f); Main.dust[dust].noGravity = true; } for (int num480 = 0; num480 < 3; num480++) { - Vector2 velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - velocity.SafeNormalize(default); - velocity *= Main.rand.Next(1, 6) * 0.01f; + Vector2 velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + velocity.SafeNormalize(default); + velocity *= Main.rand.Next(1, 6) * 0.01f; Gore.NewGore(projectile.position, velocity, Main.rand.Next(16, 18), 1f); } } diff --git a/Projectiles/Rogue/LeviathanTooth.cs b/Projectiles/Rogue/LeviathanTooth.cs index 08b2874c6a..4600c80119 100644 --- a/Projectiles/Rogue/LeviathanTooth.cs +++ b/Projectiles/Rogue/LeviathanTooth.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class LeviathanTooth : ModProjectile + public class LeviathanTooth : ModProjectile { public override void SetStaticDefaults() { @@ -65,10 +65,10 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D tex = Main.projectileTexture[projectile.type]; - if (projectile.Calamity().lineColor == 1) - tex = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/LeviathanTooth2"); - if (projectile.Calamity().lineColor == 2) - tex = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/LeviathanTooth3"); + if (projectile.Calamity().lineColor == 1) + tex = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/LeviathanTooth2"); + if (projectile.Calamity().lineColor == 2) + tex = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/LeviathanTooth3"); spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); if (projectile.Calamity().stealthStrike) diff --git a/Projectiles/Rogue/LionfishProj.cs b/Projectiles/Rogue/LionfishProj.cs index e020e9dcc9..95091f5d87 100644 --- a/Projectiles/Rogue/LionfishProj.cs +++ b/Projectiles/Rogue/LionfishProj.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = -1; projectile.alpha = 255; projectile.Calamity().rogue = true; - projectile.timeLeft = CalamityUtils.SecondsToFrames(20f); + projectile.timeLeft = CalamityUtils.SecondsToFrames(20f); } public override void AI() @@ -41,8 +41,8 @@ namespace CalamityMod.Projectiles.Rogue } if (projectile.ai[0] == 0f) { - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); projectile.ai[1] += 1f; if (projectile.ai[1] >= 45f) { @@ -51,18 +51,18 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.X *= horizontalMult; projectile.velocity.Y += fallSpeed; } - if (projectile.Calamity().stealthStrike) - { - if (projectile.timeLeft % 8 == 0 && projectile.owner == Main.myPlayer) - { - Vector2 velocity = projectile.DirectionFrom(Main.player[projectile.owner].Center); - velocity *= Main.rand.NextFloat(4.5f, 6.5f); - velocity = velocity.RotatedBy((Main.rand.NextDouble() - 0.5) * Math.PI * 0.5, default); - int spike = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, -10f, 0f); - if (spike.WithinBounds(Main.maxProjectiles)) - Main.projectile[spike].Calamity().forceRogue = true; - } - } + if (projectile.Calamity().stealthStrike) + { + if (projectile.timeLeft % 8 == 0 && projectile.owner == Main.myPlayer) + { + Vector2 velocity = projectile.DirectionFrom(Main.player[projectile.owner].Center); + velocity *= Main.rand.NextFloat(4.5f, 6.5f); + velocity = velocity.RotatedBy((Main.rand.NextDouble() - 0.5) * Math.PI * 0.5, default); + int spike = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, -10f, 0f); + if (spike.WithinBounds(Main.maxProjectiles)) + Main.projectile[spike].Calamity().forceRogue = true; + } + } } //Sticky Behaviour projectile.StickyProjAI(15); @@ -95,7 +95,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Dig, projectile.position); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 72); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 72); for (int d = 0; d < 3; d++) { Dust.NewDust(projectile.position, projectile.width, projectile.height, 14, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); diff --git a/Projectiles/Rogue/LostSoulFriendly.cs b/Projectiles/Rogue/LostSoulFriendly.cs index c10ed1cd31..1995f545e3 100644 --- a/Projectiles/Rogue/LostSoulFriendly.cs +++ b/Projectiles/Rogue/LostSoulFriendly.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class LostSoulFriendly : ModProjectile + public class LostSoulFriendly : ModProjectile { public override void SetStaticDefaults() { @@ -23,15 +23,15 @@ namespace CalamityMod.Projectiles.Rogue projectile.ignoreWater = true; projectile.penetrate = 1; projectile.timeLeft = 240; - projectile.Calamity().rogue = true; - projectile.extraUpdates = 1; - projectile.alpha = 150; - projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; + projectile.Calamity().rogue = true; + projectile.extraUpdates = 1; + projectile.alpha = 150; + projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; } - public override bool? CanHitNPC(NPC target) => (projectile.timeLeft < 210 || projectile.ai[0] == 2f) && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => (projectile.timeLeft < 210 || projectile.ai[0] == 2f) && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.frameCounter++; if (projectile.frameCounter > 8) @@ -46,28 +46,28 @@ namespace CalamityMod.Projectiles.Rogue projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - if (projectile.ai[0] != 1f && (projectile.timeLeft < 210 || projectile.ai[0] == 2f)) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); + if (projectile.ai[0] != 1f && (projectile.timeLeft < 210 || projectile.ai[0] == 2f)) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } - // Reduce damage of projectiles if more than the cap are active - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (!projectile.Calamity().rogue) - { - int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; - int cap = 5; - int oldDamage = damage; - if (projectileCount > cap) - { - damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); - if (damage < 1) - damage = 1; - } - } - } + // Reduce damage of projectiles if more than the cap are active + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (!projectile.Calamity().rogue) + { + int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; + int cap = 5; + int oldDamage = damage; + if (projectileCount > cap) + { + damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); + if (damage < 1) + damage = 1; + } + } + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { for (int j = 0; j <= 10; j++) { diff --git a/Projectiles/Rogue/LuminousShard.cs b/Projectiles/Rogue/LuminousShard.cs index a11ed1bb26..fe2613d7a2 100644 --- a/Projectiles/Rogue/LuminousShard.cs +++ b/Projectiles/Rogue/LuminousShard.cs @@ -5,54 +5,54 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class LuminousShard : ModProjectile + public class LuminousShard : ModProjectile { - bool gravity = false; + bool gravity = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Stardust Shard"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Stardust Shard"); + } public override void SetDefaults() { projectile.width = 10; projectile.height = 18; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 120; projectile.Calamity().rogue = true; - } + } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 90 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { - if (projectile.ai[0] == 0f && projectile.velocity.X == 0f && projectile.velocity.Y == -2f) - gravity = true; + if (projectile.ai[0] == 0f && projectile.velocity.X == 0f && projectile.velocity.Y == -2f) + gravity = true; - projectile.ai[0] = 1f; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + projectile.ai[0] = 1f; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - if (gravity) - projectile.velocity.Y *= 1.05f; + if (gravity) + projectile.velocity.Y *= 1.05f; - if (projectile.timeLeft < 90) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 10f, 20f); - } + if (projectile.timeLeft < 90) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 10f, 20f); + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { - for (int i = 0; i <= 2; i++) - { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 176, projectile.oldVelocity.X / 4, projectile.oldVelocity.Y / 4, 0, default, 0.75f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 177, projectile.oldVelocity.X / 4, projectile.oldVelocity.Y / 4, 0, default, 0.75f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - } - } + for (int i = 0; i <= 2; i++) + { + int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 176, projectile.oldVelocity.X / 4, projectile.oldVelocity.Y / 4, 0, default, 0.75f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 177, projectile.oldVelocity.X / 4, projectile.oldVelocity.Y / 4, 0, default, 0.75f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + } + } } } diff --git a/Projectiles/Rogue/LuminousStrikerProj.cs b/Projectiles/Rogue/LuminousStrikerProj.cs index e530343d40..95bdd05980 100644 --- a/Projectiles/Rogue/LuminousStrikerProj.cs +++ b/Projectiles/Rogue/LuminousStrikerProj.cs @@ -7,55 +7,55 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class LuminousStrikerProj : ModProjectile + public class LuminousStrikerProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/LuminousStriker"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Luminous Striker"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Luminous Striker"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + } - public override void SetDefaults() - { - projectile.width = 30; - projectile.height = 30; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 4; - projectile.localNPCHitCooldown = 13; - projectile.usesLocalNPCImmunity = true; - projectile.timeLeft = 120; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = 4; + projectile.localNPCHitCooldown = 13; + projectile.usesLocalNPCImmunity = true; + projectile.timeLeft = 120; + projectile.Calamity().rogue = true; + } public override void AI() { - if (projectile.ai[0] == 0f && projectile.Calamity().stealthStrike) - { - projectile.timeLeft = 600; - projectile.ai[0] = 1f; - } + if (projectile.ai[0] == 0f && projectile.Calamity().stealthStrike) + { + projectile.timeLeft = 600; + projectile.ai[0] = 1f; + } - if (Main.rand.NextBool(4)) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 176, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + if (Main.rand.NextBool(4)) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 176, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver4; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver4; - if (projectile.timeLeft % 4 == 0) - { - if (projectile.owner == Main.myPlayer) - { - if (projectile.Calamity().stealthStrike) - { - Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-15f, 15f), projectile.Center.Y + Main.rand.NextFloat(-15f, 15f), projectile.velocity.X, projectile.velocity.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); - } - else - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, -2f, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); + if (projectile.timeLeft % 4 == 0) + { + if (projectile.owner == Main.myPlayer) + { + if (projectile.Calamity().stealthStrike) + { + Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-15f, 15f), projectile.Center.Y + Main.rand.NextFloat(-15f, 15f), projectile.velocity.X, projectile.velocity.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); + } + else + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, -2f, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); } - } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -64,48 +64,48 @@ namespace CalamityMod.Projectiles.Rogue return false; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < 7; i++) - { - Vector2 speed = new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); - while (speed.X == 0f && speed.Y == 0f) - { - speed = new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); - } - speed.Normalize(); - speed *= Main.rand.Next(30, 61) * 0.1f * 2f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); - } - } - } + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < 7; i++) + { + Vector2 speed = new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); + while (speed.X == 0f && speed.Y == 0f) + { + speed = new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); + } + speed.Normalize(); + speed *= Main.rand.Next(30, 61) * 0.1f * 2f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); + } + } + } - public override void OnHitPvp(Player target, int damage, bool crit) + public override void OnHitPvp(Player target, int damage, bool crit) { - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < 7; i++) - { - Vector2 speed = new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); - while (speed.X == 0f && speed.Y == 0f) - { - speed = new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); - } - speed.Normalize(); - speed *= Main.rand.Next(30, 61) * 0.1f * 2f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); - } - } - } + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < 7; i++) + { + Vector2 speed = new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); + while (speed.X == 0f && speed.Y == 0f) + { + speed = new Vector2(Main.rand.Next(-50, 51), Main.rand.Next(-50, 51)); + } + speed.Normalize(); + speed *= Main.rand.Next(30, 61) * 0.1f * 2f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); + } + } + } public override void Kill(int timeLeft) { - for (int i = 0; i <= 10; i++) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 176, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); - } + for (int i = 0; i <= 10; i++) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 176, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); + } } } } diff --git a/Projectiles/Rogue/LunarKunaiProj.cs b/Projectiles/Rogue/LunarKunaiProj.cs index 91f93e8086..df1e154e9c 100644 --- a/Projectiles/Rogue/LunarKunaiProj.cs +++ b/Projectiles/Rogue/LunarKunaiProj.cs @@ -8,82 +8,82 @@ using CalamityMod.CalPlayer; namespace CalamityMod.Projectiles.Rogue { - public class LunarKunaiProj : ModProjectile + public class LunarKunaiProj : ModProjectile { - bool lunarEnhance = false; + bool lunarEnhance = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Kunai"); - Main.projFrames[projectile.type] = 2; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Kunai"); + Main.projFrames[projectile.type] = 2; ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + } public override void SetDefaults() { projectile.width = 14; projectile.height = 14; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 300; projectile.Calamity().rogue = true; - } + } public override void AI() { CalamityPlayer modPlayer = Main.player[projectile.owner].Calamity(); - projectile.ai[0] += 1f; - if(projectile.ai[0] == 1f && modPlayer.StealthStrikeAvailable()) - lunarEnhance = true; - else if (projectile.ai[0] >= 50f) - lunarEnhance = true; + projectile.ai[0] += 1f; + if(projectile.ai[0] == 1f && modPlayer.StealthStrikeAvailable()) + lunarEnhance = true; + else if (projectile.ai[0] >= 50f) + lunarEnhance = true; - if (lunarEnhance) - projectile.frame = 1; - else - projectile.frame = 0; + if (lunarEnhance) + projectile.frame = 1; + else + projectile.frame = 0; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, lunarEnhance ? 300f : 150f, lunarEnhance ? 12f : 8f, 20f); + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, lunarEnhance ? 300f : 150f, lunarEnhance ? 12f : 8f, 20f); if (Main.rand.Next(6) == 0 && lunarEnhance) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 229, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 229, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } public override void Kill(int timeLeft) { - if (lunarEnhance) - { - Main.PlaySound(SoundID.Item14, projectile.Center); - projectile.position = projectile.Center; - projectile.width = projectile.height = 28; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - projectile.damage /= 4; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - for (int num194 = 0; num194 < 10; num194++) - { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 229, 0f, 0f, 0, default, 1.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 229, 0f, 0f, 100, default, 1f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } - projectile.Damage(); - } - else - { - for (int i = 0; i < 5; i++) - { - int num304 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 265, 0f, 0f, 100, default, 1f); - Main.dust[num304].noGravity = true; - Main.dust[num304].velocity *= 1.2f; - Main.dust[num304].velocity -= projectile.oldVelocity * 0.3f; - } - } + if (lunarEnhance) + { + Main.PlaySound(SoundID.Item14, projectile.Center); + projectile.position = projectile.Center; + projectile.width = projectile.height = 28; + projectile.position.X = projectile.position.X - (float)(projectile.width / 2); + projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + projectile.damage /= 4; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + for (int num194 = 0; num194 < 10; num194++) + { + int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 229, 0f, 0f, 0, default, 1.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 229, 0f, 0f, 100, default, 1f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + projectile.Damage(); + } + else + { + for (int i = 0; i < 5; i++) + { + int num304 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 265, 0f, 0f, 100, default, 1f); + Main.dust[num304].noGravity = true; + Main.dust[num304].velocity *= 1.2f; + Main.dust[num304].velocity -= projectile.oldVelocity * 0.3f; + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/MalachiteBolt.cs b/Projectiles/Rogue/MalachiteBolt.cs index 67e00d910e..82c6e781f8 100644 --- a/Projectiles/Rogue/MalachiteBolt.cs +++ b/Projectiles/Rogue/MalachiteBolt.cs @@ -7,148 +7,148 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class MalachiteBolt : ModProjectile - { + public class MalachiteBolt : ModProjectile + { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Malachite"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Malachite"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Malachite"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 12; - projectile.height = 12; - projectile.alpha = 255; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 2; - projectile.alpha = 255; - projectile.extraUpdates = 10; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 12; + projectile.height = 12; + projectile.alpha = 255; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = 2; + projectile.alpha = 255; + projectile.extraUpdates = 10; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Calamity().rogue = true; + } - public override void AI() - { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; - projectile.alpha -= 3; - if (projectile.alpha < 100) - { - projectile.alpha = 100; - } - projectile.localAI[1] += 1f; - if (projectile.localAI[1] > 4f) - { - for (int num468 = 0; num468 < 3; num468++) - { - int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; - } - } - } + public override void AI() + { + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; + projectile.alpha -= 3; + if (projectile.alpha < 100) + { + projectile.alpha = 100; + } + projectile.localAI[1] += 1f; + if (projectile.localAI[1] > 4f) + { + for (int num468 = 0; num468 < 3; num468++) + { + int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); + Main.dust[num469].noGravity = true; + Main.dust[num469].velocity *= 0f; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override Color? GetAlpha(Color lightColor) => new Color(Main.DiscoR, 203, 103, projectile.alpha); + public override Color? GetAlpha(Color lightColor) => new Color(Main.DiscoR, 203, 103, projectile.alpha); - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (projectile.penetrate <= 1) - { - projectile.position = projectile.Center; - projectile.width = projectile.height = 160; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); - for (int num621 = 0; num621 < 70; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 40; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; - } - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (projectile.penetrate <= 1) + { + projectile.position = projectile.Center; + projectile.width = projectile.height = 160; + projectile.position.X = projectile.position.X - (float)(projectile.width / 2); + projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + for (int num621 = 0; num621 < 70; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 40; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[num624].velocity *= 2f; + } + } + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - if (projectile.penetrate <= 1) - { - projectile.position = projectile.Center; - projectile.width = projectile.height = 160; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); - for (int num621 = 0; num621 < 70; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 40; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; - } - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + if (projectile.penetrate <= 1) + { + projectile.position = projectile.Center; + projectile.width = projectile.height = 160; + projectile.position.X = projectile.position.X - (float)(projectile.width / 2); + projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + for (int num621 = 0; num621 < 70; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 40; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[num624].velocity *= 2f; + } + } + } - public override void Kill(int timeLeft) - { - projectile.position = projectile.Center; - projectile.width = projectile.height = 16; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - for (int num621 = 0; num621 < 7; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 3; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; - } - } - } + public override void Kill(int timeLeft) + { + projectile.position = projectile.Center; + projectile.width = projectile.height = 16; + projectile.position.X = projectile.position.X - (float)(projectile.width / 2); + projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + for (int num621 = 0; num621 < 7; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 3; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[num624].velocity *= 2f; + } + } + } } diff --git a/Projectiles/Rogue/MalachiteProj.cs b/Projectiles/Rogue/MalachiteProj.cs index 9055fd8faa..ad2aa19365 100644 --- a/Projectiles/Rogue/MalachiteProj.cs +++ b/Projectiles/Rogue/MalachiteProj.cs @@ -6,85 +6,85 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class MalachiteProj : ModProjectile - { + public class MalachiteProj : ModProjectile + { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Malachite"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Malachite"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Malachite"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 12; - projectile.height = 12; - projectile.alpha = 255; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 3; - projectile.alpha = 255; - projectile.extraUpdates = 3; - projectile.aiStyle = 93; - aiType = ProjectileID.NailFriendly; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 1; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 12; + projectile.height = 12; + projectile.alpha = 255; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = 3; + projectile.alpha = 255; + projectile.extraUpdates = 3; + projectile.aiStyle = 93; + aiType = ProjectileID.NailFriendly; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 1; + projectile.Calamity().rogue = true; + } - public override void AI() - { - projectile.alpha -= 3; - if (projectile.alpha < 30) - { - projectile.alpha = 30; - } - projectile.localAI[1] += 1f; - if (projectile.localAI[1] > 4f) - { - for (int num468 = 0; num468 < 3; num468++) - { - int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; - } - } - } + public override void AI() + { + projectile.alpha -= 3; + if (projectile.alpha < 30) + { + projectile.alpha = 30; + } + projectile.localAI[1] += 1f; + if (projectile.localAI[1] > 4f) + { + for (int num468 = 0; num468 < 3; num468++) + { + int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); + Main.dust[num469].noGravity = true; + Main.dust[num469].velocity *= 0f; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override Color? GetAlpha(Color lightColor) => new Color(Main.DiscoR, 203, 103, projectile.alpha); + public override Color? GetAlpha(Color lightColor) => new Color(Main.DiscoR, 203, 103, projectile.alpha); - public override void Kill(int timeLeft) - { - projectile.position = projectile.Center; - projectile.width = projectile.height = 48; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - for (int num621 = 0; num621 < 7; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 15; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num624].velocity *= 2f; - } - } - } + public override void Kill(int timeLeft) + { + projectile.position = projectile.Center; + projectile.width = projectile.height = 48; + projectile.position.X = projectile.position.X - (float)(projectile.width / 2); + projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + for (int num621 = 0; num621 < 7; num621++) + { + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[num622].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[num622].scale = 0.5f; + Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int num623 = 0; num623 < 15; num623++) + { + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[num624].noGravity = true; + Main.dust[num624].velocity *= 5f; + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[num624].velocity *= 2f; + } + } + } } diff --git a/Projectiles/Rogue/MalachiteStealth.cs b/Projectiles/Rogue/MalachiteStealth.cs index 2eceb4faaf..ab22d5a024 100644 --- a/Projectiles/Rogue/MalachiteStealth.cs +++ b/Projectiles/Rogue/MalachiteStealth.cs @@ -6,141 +6,141 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class MalachiteStealth : ModProjectile - { - private const int lifeSpan = 300; + public class MalachiteStealth : ModProjectile + { + private const int lifeSpan = 300; public override string Texture => "CalamityMod/Items/Weapons/Rogue/Malachite"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Malachite"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Malachite"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 12; - projectile.height = 12; - projectile.alpha = 255; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.alpha = 255; - projectile.Calamity().rogue = true; - projectile.tileCollide = false; - projectile.timeLeft = lifeSpan; - projectile.extraUpdates = 2; - } + public override void SetDefaults() + { + projectile.width = 12; + projectile.height = 12; + projectile.alpha = 255; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.alpha = 255; + projectile.Calamity().rogue = true; + projectile.tileCollide = false; + projectile.timeLeft = lifeSpan; + projectile.extraUpdates = 2; + } - public override void AI() - { - if (projectile.ai[0] == 0f) - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 10f, 25f); - projectile.localAI[1] += 1f; - if (projectile.localAI[1] > 4f) - { - for (int num468 = 0; num468 < 3; num468++) - { - int num469 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; - } - } - } - else - { - int id = (int)projectile.ai[1]; - if (id.WithinBounds(Main.maxNPCs) && Main.npc[id].active && !Main.npc[id].dontTakeDamage) - { - projectile.Center = Main.npc[id].Center - projectile.velocity * 2f; - projectile.gfxOffY = Main.npc[id].gfxOffY; - } - else - { - projectile.Kill(); - } - } + public override void AI() + { + if (projectile.ai[0] == 0f) + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 10f, 25f); + projectile.localAI[1] += 1f; + if (projectile.localAI[1] > 4f) + { + for (int num468 = 0; num468 < 3; num468++) + { + int num469 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); + Main.dust[num469].noGravity = true; + Main.dust[num469].velocity *= 0f; + } + } + } + else + { + int id = (int)projectile.ai[1]; + if (id.WithinBounds(Main.maxNPCs) && Main.npc[id].active && !Main.npc[id].dontTakeDamage) + { + projectile.Center = Main.npc[id].Center - projectile.velocity * 2f; + projectile.gfxOffY = Main.npc[id].gfxOffY; + } + else + { + projectile.Kill(); + } + } - projectile.alpha -= 3; - if (projectile.alpha < 30) - { - projectile.alpha = 30; - } - } + projectile.alpha -= 3; + if (projectile.alpha < 30) + { + projectile.alpha = 30; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override Color? GetAlpha(Color lightColor) => new Color(Main.DiscoR, 203, 103, projectile.alpha); + public override Color? GetAlpha(Color lightColor) => new Color(Main.DiscoR, 203, 103, projectile.alpha); - public override void Kill(int timeLeft) - { - projectile.ai[0] = 2f; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 112); - Main.PlaySound(SoundID.Item14, projectile.position); - for (int i = 0; i < 7; i++) - { - int dusty = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); - Main.dust[dusty].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[dusty].scale = 0.5f; - Main.dust[dusty].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 15; j++) - { - int green = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); - Main.dust[green].noGravity = true; - Main.dust[green].velocity *= 5f; - green = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[green].velocity *= 2f; - } - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); - } + public override void Kill(int timeLeft) + { + projectile.ai[0] = 2f; + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 112); + Main.PlaySound(SoundID.Item14, projectile.position); + for (int i = 0; i < 7; i++) + { + int dusty = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + Main.dust[dusty].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[dusty].scale = 0.5f; + Main.dust[dusty].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int j = 0; j < 15; j++) + { + int green = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + Main.dust[green].noGravity = true; + Main.dust[green].velocity *= 5f; + green = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[green].velocity *= 2f; + } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 0; - projectile.extraUpdates = 0; - projectile.ai[0] = 1f; - projectile.ai[1] = target.whoAmI; - projectile.velocity = target.Center - projectile.Center; - projectile.velocity *= 0.75f; - projectile.netUpdate = true; + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 0; + projectile.extraUpdates = 0; + projectile.ai[0] = 1f; + projectile.ai[1] = target.whoAmI; + projectile.velocity = target.Center - projectile.Center; + projectile.velocity *= 0.75f; + projectile.netUpdate = true; - const int maxKunai = 3; - int kunaiFound = 0; - int oldestKunai = -1; - int oldestKunaiTimeLeft = lifeSpan; - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == projectile.type && i != projectile.whoAmI && Main.projectile[i].ai[1] == target.whoAmI) - { - kunaiFound++; - if (Main.projectile[i].timeLeft < oldestKunaiTimeLeft) - { - oldestKunaiTimeLeft = Main.projectile[i].timeLeft; - oldestKunai = Main.projectile[i].whoAmI; - } - if (kunaiFound >= maxKunai) - break; - } - } - if (kunaiFound >= maxKunai && oldestKunai >= 0) - { - Main.projectile[oldestKunai].Kill(); - } - } + const int maxKunai = 3; + int kunaiFound = 0; + int oldestKunai = -1; + int oldestKunaiTimeLeft = lifeSpan; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == projectile.type && i != projectile.whoAmI && Main.projectile[i].ai[1] == target.whoAmI) + { + kunaiFound++; + if (Main.projectile[i].timeLeft < oldestKunaiTimeLeft) + { + oldestKunaiTimeLeft = Main.projectile[i].timeLeft; + oldestKunai = Main.projectile[i].whoAmI; + } + if (kunaiFound >= maxKunai) + break; + } + } + if (kunaiFound >= maxKunai && oldestKunai >= 0) + { + Main.projectile[oldestKunai].Kill(); + } + } - public override bool CanDamage() => projectile.ai[0] != 1f; - } + public override bool CanDamage() => projectile.ai[0] != 1f; + } } diff --git a/Projectiles/Rogue/MangroveChakramFlower.cs b/Projectiles/Rogue/MangroveChakramFlower.cs index 95669b68fc..9c9b091948 100644 --- a/Projectiles/Rogue/MangroveChakramFlower.cs +++ b/Projectiles/Rogue/MangroveChakramFlower.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class MangroveChakramFlower : ModProjectile + public class MangroveChakramFlower : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Magic/BeamingBolt"; @@ -31,12 +31,12 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.Y *= 0.985f; for (int dust = 0; dust < 2; dust++) { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 164, - 58, - 204 - }); + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 164, + 58, + 204 + }); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } } @@ -45,12 +45,12 @@ namespace CalamityMod.Projectiles.Rogue { for (int k = 0; k < 6; k++) { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 164, - 58, - 204 - }); + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 164, + 58, + 204 + }); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, randomDust, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } Main.PlaySound(SoundID.Item105, projectile.position); diff --git a/Projectiles/Rogue/MangroveChakramProjectile.cs b/Projectiles/Rogue/MangroveChakramProjectile.cs index 2bbb51de92..f91ce93c55 100644 --- a/Projectiles/Rogue/MangroveChakramProjectile.cs +++ b/Projectiles/Rogue/MangroveChakramProjectile.cs @@ -6,66 +6,66 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class MangroveChakramProjectile : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/MangroveChakram"; + public class MangroveChakramProjectile : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/MangroveChakram"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Mangrove Chakram"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mangrove Chakram"); + } - public override void SetDefaults() - { - projectile.width = 30; - projectile.height = 30; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.aiStyle = 3; - projectile.timeLeft = 600; - aiType = ProjectileID.WoodenBoomerang; + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.aiStyle = 3; + projectile.timeLeft = 600; + aiType = ProjectileID.WoodenBoomerang; projectile.Calamity().rogue = true; } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0f, 0.25f, 0f); - if (Main.rand.NextBool(5)) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 44, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + public override void AI() + { + Lighting.AddLight(projectile.Center, 0f, 0.25f, 0f); + if (Main.rand.NextBool(5)) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 44, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); if (projectile.Calamity().stealthStrike) { - // Die early. - if (projectile.timeLeft < 240) - projectile.Kill(); + // Die early. + if (projectile.timeLeft < 240) + projectile.Kill(); - projectile.localAI[0] += Main.rand.Next(0,3); - if (projectile.localAI[0] >= 10f) - { - projectile.localAI[0] = 0f; - Vector2 flowerSpawnPosition = projectile.Center + Main.rand.NextVector2Square(-10f, 10f); - Vector2 flowerShootVelocity = projectile.velocity.RotatedByRandom(0.1f) * 0.25f; - Projectile.NewProjectile(flowerSpawnPosition, flowerShootVelocity, ModContent.ProjectileType(), projectile.damage / 4, 0f, projectile.owner); - } + projectile.localAI[0] += Main.rand.Next(0,3); + if (projectile.localAI[0] >= 10f) + { + projectile.localAI[0] = 0f; + Vector2 flowerSpawnPosition = projectile.Center + Main.rand.NextVector2Square(-10f, 10f); + Vector2 flowerShootVelocity = projectile.velocity.RotatedByRandom(0.1f) * 0.25f; + Projectile.NewProjectile(flowerSpawnPosition, flowerShootVelocity, ModContent.ProjectileType(), projectile.damage / 4, 0f, projectile.owner); + } } - } + } - 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 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 void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 6; - target.AddBuff(BuffID.CursedInferno, 120); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 6; + target.AddBuff(BuffID.CursedInferno, 120); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.CursedInferno, 120); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.CursedInferno, 120); + } + } } diff --git a/Projectiles/Rogue/MetalShard.cs b/Projectiles/Rogue/MetalShard.cs index ecbab2f436..503e36eb4b 100644 --- a/Projectiles/Rogue/MetalShard.cs +++ b/Projectiles/Rogue/MetalShard.cs @@ -7,7 +7,7 @@ using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Projectiles.Rogue { - public class MetalShard : ModProjectile + public class MetalShard : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Rogue/MeteorFistProj.cs b/Projectiles/Rogue/MeteorFistProj.cs index 54fa70d1bd..823898ff73 100644 --- a/Projectiles/Rogue/MeteorFistProj.cs +++ b/Projectiles/Rogue/MeteorFistProj.cs @@ -19,49 +19,49 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 20; projectile.friendly = true; projectile.penetrate = 1; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; projectile.timeLeft = 360; projectile.Calamity().rogue = true; } public override void AI() { - if (projectile.velocity.Length() >= 4f) - { - for (int num246 = 0; num246 < 2; num246++) - { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) - { - num247 = projectile.velocity.X * 0.5f; - num248 = projectile.velocity.Y * 0.5f; - } - int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - } - } + if (projectile.velocity.Length() >= 4f) + { + for (int num246 = 0; num246 < 2; num246++) + { + float num247 = 0f; + float num248 = 0f; + if (num246 == 1) + { + num247 = projectile.velocity.X * 0.5f; + num248 = projectile.velocity.Y * 0.5f; + } + int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 0.5f); + Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num249].velocity *= 0.2f; + Main.dust[num249].noGravity = true; + } + } - // Almost instantly accelerate to very high speed - if (projectile.velocity.Length() < 12f) - { - projectile.velocity *= 1.25f; - } - else if (Main.rand.NextBool(2)) - { - int num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 0.5f); - Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; - Main.rand.Next(2); - num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 0.5f); - Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; - } + // Almost instantly accelerate to very high speed + if (projectile.velocity.Length() < 12f) + { + projectile.velocity *= 1.25f; + } + else if (Main.rand.NextBool(2)) + { + int num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 0.5f); + Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].noGravity = true; + Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; + Main.rand.Next(2); + num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 0.5f); + Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[num252].noGravity = true; + Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; + } projectile.ai[0] += 1f; projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); projectile.maxPenetrate = projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; @@ -109,7 +109,7 @@ namespace CalamityMod.Projectiles.Rogue num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Rogue/MoltenAmputatorProj.cs b/Projectiles/Rogue/MoltenAmputatorProj.cs index aee58752e0..6ac60a44ee 100644 --- a/Projectiles/Rogue/MoltenAmputatorProj.cs +++ b/Projectiles/Rogue/MoltenAmputatorProj.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 74; projectile.friendly = true; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 4; projectile.timeLeft = 180; diff --git a/Projectiles/Rogue/MoltenBlobThrown.cs b/Projectiles/Rogue/MoltenBlobThrown.cs index 91ed97f076..e022e00f39 100644 --- a/Projectiles/Rogue/MoltenBlobThrown.cs +++ b/Projectiles/Rogue/MoltenBlobThrown.cs @@ -57,9 +57,9 @@ namespace CalamityMod.Projectiles.Rogue return true; } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override Color? GetAlpha(Color lightColor) + public override Color? GetAlpha(Color lightColor) { return new Color(250, 150, 0, projectile.alpha); } diff --git a/Projectiles/Rogue/MoonSigil.cs b/Projectiles/Rogue/MoonSigil.cs index 81138074a9..e185d0e8c8 100644 --- a/Projectiles/Rogue/MoonSigil.cs +++ b/Projectiles/Rogue/MoonSigil.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class MoonSigil : ModProjectile + public class MoonSigil : ModProjectile { public override void SetStaticDefaults() { @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 250; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.Calamity().rogue = true; - } + projectile.Calamity().rogue = true; + } public override void AI() { @@ -38,24 +38,24 @@ namespace CalamityMod.Projectiles.Rogue return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 8f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 8f, 20f); } - // Reduce damage of projectiles if more than the cap are active - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; - int cap = 5; - int oldDamage = damage; - if (projectileCount > cap) - { - damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); - if (damage < 1) - damage = 1; - } - } + // Reduce damage of projectiles if more than the cap are active + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; + int cap = 5; + int oldDamage = damage; + if (projectileCount > cap) + { + damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); + if (damage < 1) + damage = 1; + } + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { float dustSp = 0.2f; int dustD = 0; diff --git a/Projectiles/Rogue/MythrilKnifeProjectile.cs b/Projectiles/Rogue/MythrilKnifeProjectile.cs index e5b7103e3e..4683ef7795 100644 --- a/Projectiles/Rogue/MythrilKnifeProjectile.cs +++ b/Projectiles/Rogue/MythrilKnifeProjectile.cs @@ -67,8 +67,8 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (!projectile.Calamity().stealthStrike) - return; + if (!projectile.Calamity().stealthStrike) + return; target.AddBuff(BuffID.CursedInferno, 300); target.AddBuff(BuffID.Venom, 300); @@ -79,8 +79,8 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPvp(Player target, int damage, bool crit) { - if (!projectile.Calamity().stealthStrike) - return; + if (!projectile.Calamity().stealthStrike) + return; target.AddBuff(BuffID.CursedInferno, 300); target.AddBuff(BuffID.Venom, 300); diff --git a/Projectiles/Rogue/NanoblackMain.cs b/Projectiles/Rogue/NanoblackMain.cs index 5625ed2ac3..de14c579d4 100644 --- a/Projectiles/Rogue/NanoblackMain.cs +++ b/Projectiles/Rogue/NanoblackMain.cs @@ -8,176 +8,176 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class NanoblackMain : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/NanoblackReaperRogue"; + public class NanoblackMain : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/NanoblackReaperRogue"; - private const float RotationIncrement = 0.22f; - private const int Lifetime = 240; - private const float ReboundTime = 50f; - private const int MinBladeTimer = 13; + private const float RotationIncrement = 0.22f; + private const int Lifetime = 240; + private const float ReboundTime = 50f; + private const int MinBladeTimer = 13; private const int MaxBladeTimer = 18; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Nanoblack Reaper"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 7; - ProjectileID.Sets.TrailingMode[projectile.type] = 2; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Nanoblack Reaper"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 7; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } - public override void SetDefaults() - { - projectile.width = 56; - projectile.height = 56; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.extraUpdates = 2; - projectile.timeLeft = Lifetime; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 8; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 56; + projectile.height = 56; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.extraUpdates = 2; + projectile.timeLeft = Lifetime; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 8; + projectile.Calamity().rogue = true; + } - public override void AI() - { - drawOffsetX = -11; - drawOriginOffsetY = -4; - drawOriginOffsetX = 0; + public override void AI() + { + drawOffsetX = -11; + drawOriginOffsetY = -4; + drawOriginOffsetX = 0; - // Initialize the frame counter and random blade delay on the very first frame. - if (projectile.timeLeft == Lifetime) - projectile.ai[1] = projectile.Calamity().stealthStrike ? 4f : GetBladeDelay(); + // Initialize the frame counter and random blade delay on the very first frame. + if (projectile.timeLeft == Lifetime) + projectile.ai[1] = projectile.Calamity().stealthStrike ? 4f : GetBladeDelay(); - // Produces electricity and green firework sparks constantly while in flight. - if (Main.rand.NextBool(3)) - { - int dustType = Main.rand.NextBool(5) ? 226 : 220; - float scale = 0.8f + Main.rand.NextFloat(0.3f); - float velocityMult = Main.rand.NextFloat(0.3f, 0.6f); - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity = velocityMult * projectile.velocity; - Main.dust[idx].scale = scale; - } + // Produces electricity and green firework sparks constantly while in flight. + if (Main.rand.NextBool(3)) + { + int dustType = Main.rand.NextBool(5) ? 226 : 220; + float scale = 0.8f + Main.rand.NextFloat(0.3f); + float velocityMult = Main.rand.NextFloat(0.3f, 0.6f); + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity = velocityMult * projectile.velocity; + Main.dust[idx].scale = scale; + } - // ai[0] is a frame counter. ai[1] is a countdown to spawning the next nanoblack energy blade. - projectile.ai[0] += 1f; - projectile.ai[1] -= 1f; + // ai[0] is a frame counter. ai[1] is a countdown to spawning the next nanoblack energy blade. + projectile.ai[0] += 1f; + projectile.ai[1] -= 1f; - // On the frame the scythe begins returning, send a net update. - if (projectile.ai[0] == ReboundTime) - projectile.netUpdate = true; + // On the frame the scythe begins returning, send a net update. + if (projectile.ai[0] == ReboundTime) + projectile.netUpdate = true; - // The scythe runs its returning AI if the frame counter is greater than ReboundTime. - if (projectile.ai[0] >= ReboundTime) - { - float returnSpeed = NanoblackReaperRogue.Speed; - float acceleration = 2.4f; - Player owner = Main.player[projectile.owner]; + // The scythe runs its returning AI if the frame counter is greater than ReboundTime. + if (projectile.ai[0] >= ReboundTime) + { + float returnSpeed = NanoblackReaperRogue.Speed; + float acceleration = 2.4f; + Player owner = Main.player[projectile.owner]; - // Delete the scythe if it's excessively far away. - Vector2 playerCenter = owner.Center; - float xDist = playerCenter.X - projectile.Center.X; - float yDist = playerCenter.Y - projectile.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (dist > 3000f) - projectile.Kill(); + // Delete the scythe if it's excessively far away. + Vector2 playerCenter = owner.Center; + float xDist = playerCenter.X - projectile.Center.X; + float yDist = playerCenter.Y - projectile.Center.Y; + float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); + if (dist > 3000f) + projectile.Kill(); - dist = returnSpeed / dist; - xDist *= dist; - yDist *= dist; + dist = returnSpeed / dist; + xDist *= dist; + yDist *= dist; - // Home back in on the player. - if (projectile.velocity.X < xDist) - { - projectile.velocity.X = projectile.velocity.X + acceleration; - if (projectile.velocity.X < 0f && xDist > 0f) - projectile.velocity.X += acceleration; - } - else if (projectile.velocity.X > xDist) - { - projectile.velocity.X = projectile.velocity.X - acceleration; - if (projectile.velocity.X > 0f && xDist < 0f) - projectile.velocity.X -= acceleration; - } - if (projectile.velocity.Y < yDist) - { - projectile.velocity.Y = projectile.velocity.Y + acceleration; - if (projectile.velocity.Y < 0f && yDist > 0f) - projectile.velocity.Y += acceleration; - } - else if (projectile.velocity.Y > yDist) - { - projectile.velocity.Y = projectile.velocity.Y - acceleration; - if (projectile.velocity.Y > 0f && yDist < 0f) - projectile.velocity.Y -= acceleration; - } + // Home back in on the player. + if (projectile.velocity.X < xDist) + { + projectile.velocity.X = projectile.velocity.X + acceleration; + if (projectile.velocity.X < 0f && xDist > 0f) + projectile.velocity.X += acceleration; + } + else if (projectile.velocity.X > xDist) + { + projectile.velocity.X = projectile.velocity.X - acceleration; + if (projectile.velocity.X > 0f && xDist < 0f) + projectile.velocity.X -= acceleration; + } + if (projectile.velocity.Y < yDist) + { + projectile.velocity.Y = projectile.velocity.Y + acceleration; + if (projectile.velocity.Y < 0f && yDist > 0f) + projectile.velocity.Y += acceleration; + } + else if (projectile.velocity.Y > yDist) + { + projectile.velocity.Y = projectile.velocity.Y - acceleration; + if (projectile.velocity.Y > 0f && yDist < 0f) + projectile.velocity.Y -= acceleration; + } - // Delete the projectile if it touches its owner. - if (Main.myPlayer == projectile.owner) - if (projectile.Hitbox.Intersects(owner.Hitbox)) - projectile.Kill(); - } + // Delete the projectile if it touches its owner. + if (Main.myPlayer == projectile.owner) + if (projectile.Hitbox.Intersects(owner.Hitbox)) + projectile.Kill(); + } - // Create nanoblack energy blades at a somewhat-random rate while in flight. (or full-sized scythes afterimages if stealth strike) - if (projectile.ai[1] <= 0f) - { - if (projectile.Calamity().stealthStrike) - { - SpawnScytheAfterimage(); - projectile.ai[1] = 4f; - } - else - { - SpawnEnergyBlade(); - projectile.ai[1] = GetBladeDelay(); - } - } + // Create nanoblack energy blades at a somewhat-random rate while in flight. (or full-sized scythes afterimages if stealth strike) + if (projectile.ai[1] <= 0f) + { + if (projectile.Calamity().stealthStrike) + { + SpawnScytheAfterimage(); + projectile.ai[1] = 4f; + } + else + { + SpawnEnergyBlade(); + projectile.ai[1] = GetBladeDelay(); + } + } - // Rotate the scythe as it flies. - float spin = projectile.direction <= 0 ? -1f : 1f; - projectile.rotation += spin * RotationIncrement; - } + // Rotate the scythe as it flies. + float spin = projectile.direction <= 0 ? -1f : 1f; + projectile.rotation += spin * RotationIncrement; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - private int GetBladeDelay() - { - return Main.rand.Next(MinBladeTimer, MaxBladeTimer + 1); - } + private int GetBladeDelay() + { + return Main.rand.Next(MinBladeTimer, MaxBladeTimer + 1); + } - private void SpawnEnergyBlade() - { - int bladeID = ModContent.ProjectileType(); - int bladeDamage = projectile.damage / 3; - float bladeKB = 3f; - float spin = projectile.direction <= 0 ? -1f : 1f; - float d = 16f; - float velocityMult = 0.9f; - Vector2 directOffset = new Vector2(Main.rand.NextFloat(-d, d), Main.rand.NextFloat(-d, d)); - Vector2 velocityOffset = Main.rand.NextFloat(-velocityMult, velocityMult) * projectile.velocity; - Vector2 pos = projectile.Center + directOffset + velocityOffset; - if (projectile.owner == Main.myPlayer) - Projectile.NewProjectile(pos, Vector2.Zero, bladeID, bladeDamage, bladeKB, projectile.owner, 0f, spin); - } + private void SpawnEnergyBlade() + { + int bladeID = ModContent.ProjectileType(); + int bladeDamage = projectile.damage / 3; + float bladeKB = 3f; + float spin = projectile.direction <= 0 ? -1f : 1f; + float d = 16f; + float velocityMult = 0.9f; + Vector2 directOffset = new Vector2(Main.rand.NextFloat(-d, d), Main.rand.NextFloat(-d, d)); + Vector2 velocityOffset = Main.rand.NextFloat(-velocityMult, velocityMult) * projectile.velocity; + Vector2 pos = projectile.Center + directOffset + velocityOffset; + if (projectile.owner == Main.myPlayer) + Projectile.NewProjectile(pos, Vector2.Zero, bladeID, bladeDamage, bladeKB, projectile.owner, 0f, spin); + } - private void SpawnScytheAfterimage() - { - int bladeID = ModContent.ProjectileType(); - int bladeDamage = projectile.damage / 2; - float bladeKB = 4f; - float spin = projectile.direction <= 0 ? -1f : 1f; - float d = 16f; - float velocityMult = 0.9f; - if (projectile.owner == Main.myPlayer) - Projectile.NewProjectile(projectile.Center, Vector2.Zero, bladeID, bladeDamage, bladeKB, projectile.owner, 0f, spin); - } - } + private void SpawnScytheAfterimage() + { + int bladeID = ModContent.ProjectileType(); + int bladeDamage = projectile.damage / 2; + float bladeKB = 4f; + float spin = projectile.direction <= 0 ? -1f : 1f; + float d = 16f; + float velocityMult = 0.9f; + if (projectile.owner == Main.myPlayer) + Projectile.NewProjectile(projectile.Center, Vector2.Zero, bladeID, bladeDamage, bladeKB, projectile.owner, 0f, spin); + } + } } diff --git a/Projectiles/Rogue/NanoblackSplit.cs b/Projectiles/Rogue/NanoblackSplit.cs index cb09ac1599..73fb8e60f2 100644 --- a/Projectiles/Rogue/NanoblackSplit.cs +++ b/Projectiles/Rogue/NanoblackSplit.cs @@ -7,207 +7,207 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class NanoblackSplit : ModProjectile - { - private static int SpriteWidth = 52; - private static int Lifetime = 90; - private static float MaxRotationSpeed = 0.25f; - private static float MaxSpeed = 22f; + public class NanoblackSplit : ModProjectile + { + private static int SpriteWidth = 52; + private static int Lifetime = 90; + private static float MaxRotationSpeed = 0.25f; + private static float MaxSpeed = 22f; - private static float HomingStartRange = 600f; - private static float HomingBreakRange = 1000f; - private static float HomingBonusRangeCap = 200f; - private static float BaseHomingFactor = 1.6f; - private static float MaxHomingFactor = 6.6f; + private static float HomingStartRange = 600f; + private static float HomingBreakRange = 1000f; + private static float HomingBonusRangeCap = 200f; + private static float BaseHomingFactor = 1.6f; + private static float MaxHomingFactor = 6.6f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Nanoblack Blade"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Nanoblack Blade"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 32; - projectile.height = 32; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = 4; - projectile.extraUpdates = 1; - projectile.timeLeft = Lifetime; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 8; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 32; + projectile.height = 32; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = 4; + projectile.extraUpdates = 1; + projectile.timeLeft = Lifetime; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 8; + projectile.Calamity().rogue = true; + } - // ai[0] = Index of current NPC target. If 0 or negative, the projectile has no target - // ai[1] = Current spin speed. Negative speeds are also allowed. - public override void AI() - { - drawOffsetX = -10; - drawOriginOffsetY = 0; - drawOriginOffsetX = 0; + // ai[0] = Index of current NPC target. If 0 or negative, the projectile has no target + // ai[1] = Current spin speed. Negative speeds are also allowed. + public override void AI() + { + drawOffsetX = -10; + drawOriginOffsetY = 0; + drawOriginOffsetX = 0; - // On the very first frame, clear any invalid starting target variable and create some dust. - // Also grab the damage type based on ai[0]. - if (projectile.timeLeft == Lifetime) - SpawnDust(); + // On the very first frame, clear any invalid starting target variable and create some dust. + // Also grab the damage type based on ai[0]. + if (projectile.timeLeft == Lifetime) + SpawnDust(); - // Spin in the specified starting direction and slow down spin over time - // Loses 1.66% of current speed every frame - // Also update current orientation to reflect current spin direction - float currentSpin = projectile.ai[1]; - projectile.direction = currentSpin <= 0f ? 1 : -1; - projectile.spriteDirection = projectile.direction; - projectile.rotation += currentSpin * MaxRotationSpeed; - float spinReduction = 0.0166f * currentSpin; - projectile.ai[1] -= spinReduction; + // Spin in the specified starting direction and slow down spin over time + // Loses 1.66% of current speed every frame + // Also update current orientation to reflect current spin direction + float currentSpin = projectile.ai[1]; + projectile.direction = currentSpin <= 0f ? 1 : -1; + projectile.spriteDirection = projectile.direction; + projectile.rotation += currentSpin * MaxRotationSpeed; + float spinReduction = 0.0166f * currentSpin; + projectile.ai[1] -= spinReduction; - // If about to disappear, shrink by 8% every frame - if (projectile.timeLeft < 15) - projectile.scale *= 0.92f; + // If about to disappear, shrink by 8% every frame + if (projectile.timeLeft < 15) + projectile.scale *= 0.92f; - // Search for and home in on nearby targets - HomingAI(); - } + // Search for and home in on nearby targets + HomingAI(); + } - private void HomingAI() - { - // If we don't currently have a target, go try and get one! - int targetID = (int)projectile.ai[0] - 1; - if (targetID < 0) - targetID = AcquireTarget(); + private void HomingAI() + { + // If we don't currently have a target, go try and get one! + int targetID = (int)projectile.ai[0] - 1; + if (targetID < 0) + targetID = AcquireTarget(); - // Save the target, whether we have one or not. - projectile.ai[0] = targetID + 1f; + // Save the target, whether we have one or not. + projectile.ai[0] = targetID + 1f; - // If we don't have a target, then just slow down a bit. - if (targetID < 0) - { - projectile.velocity *= 0.94f; - return; - } + // If we don't have a target, then just slow down a bit. + if (targetID < 0) + { + projectile.velocity *= 0.94f; + return; + } - // Homing behavior depends on how far the blade is from its target. - NPC target = Main.npc[targetID]; - float xDist = projectile.Center.X - target.Center.X; - float yDist = projectile.Center.Y - target.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); + // Homing behavior depends on how far the blade is from its target. + NPC target = Main.npc[targetID]; + float xDist = projectile.Center.X - target.Center.X; + float yDist = projectile.Center.Y - target.Center.Y; + float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - // If the target is too far away, stop homing in on it. - if (dist > HomingBreakRange) - { - projectile.ai[0] = 0f; - return; - } + // If the target is too far away, stop homing in on it. + if (dist > HomingBreakRange) + { + projectile.ai[0] = 0f; + return; + } - // Adds a multiple of the towards-target vector to its velocity every frame. - float homingFactor = CalcHomingFactor(dist); - Vector2 posDiff = target.Center - projectile.Center; - posDiff = posDiff.SafeNormalize(Vector2.Zero); - posDiff *= homingFactor; - Vector2 newVelocity = projectile.velocity += posDiff; + // Adds a multiple of the towards-target vector to its velocity every frame. + float homingFactor = CalcHomingFactor(dist); + Vector2 posDiff = target.Center - projectile.Center; + posDiff = posDiff.SafeNormalize(Vector2.Zero); + posDiff *= homingFactor; + Vector2 newVelocity = projectile.velocity += posDiff; - // Caps speed to make sure it doesn't go too fast. - if (newVelocity.Length() >= MaxSpeed) - { - newVelocity = newVelocity.SafeNormalize(Vector2.Zero); - newVelocity *= MaxSpeed; - } + // Caps speed to make sure it doesn't go too fast. + if (newVelocity.Length() >= MaxSpeed) + { + newVelocity = newVelocity.SafeNormalize(Vector2.Zero); + newVelocity *= MaxSpeed; + } - projectile.velocity = newVelocity; - } + projectile.velocity = newVelocity; + } - // Returns the ID of the NPC to be targeted by this energy blade. - // It chooses the closest target which can be chased, ignoring invulnerable NPCs. - // Nanoblack Blades prefer to target bosses whenever possible. - private int AcquireTarget() - { - bool bossFound = false; - int target = -1; - float minDist = HomingStartRange; - for (int i = 0; i < 200; ++i) - { - NPC npc = Main.npc[i]; - if (!npc.active || npc.type == NPCID.TargetDummy) - continue; + // Returns the ID of the NPC to be targeted by this energy blade. + // It chooses the closest target which can be chased, ignoring invulnerable NPCs. + // Nanoblack Blades prefer to target bosses whenever possible. + private int AcquireTarget() + { + bool bossFound = false; + int target = -1; + float minDist = HomingStartRange; + for (int i = 0; i < 200; ++i) + { + NPC npc = Main.npc[i]; + if (!npc.active || npc.type == NPCID.TargetDummy) + continue; - // If we've found a valid boss target, ignore ALL targets which aren't bosses. - if (bossFound && !npc.boss) - continue; + // If we've found a valid boss target, ignore ALL targets which aren't bosses. + if (bossFound && !npc.boss) + continue; - if (npc.CanBeChasedBy(projectile, false)) - { - float xDist = projectile.Center.X - npc.Center.X; - float yDist = projectile.Center.Y - npc.Center.Y; - float distToNPC = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (distToNPC < minDist) - { - // If this target within range is a boss, set the boss found flag. - if (npc.boss) - bossFound = true; - minDist = distToNPC; - target = i; - } - } - } - return target; - } + if (npc.CanBeChasedBy(projectile, false)) + { + float xDist = projectile.Center.X - npc.Center.X; + float yDist = projectile.Center.Y - npc.Center.Y; + float distToNPC = (float)Math.Sqrt(xDist * xDist + yDist * yDist); + if (distToNPC < minDist) + { + // If this target within range is a boss, set the boss found flag. + if (npc.boss) + bossFound = true; + minDist = distToNPC; + target = i; + } + } + } + return target; + } - // Energy blades home even more aggressively if they are very close to their target. - private float CalcHomingFactor(float dist) - { - float baseFactor = BaseHomingFactor; - float bonus = (MaxHomingFactor - BaseHomingFactor) * (1f - dist / HomingBonusRangeCap); - if (bonus < 0f) - bonus = 0f; - return baseFactor + bonus; - } + // Energy blades home even more aggressively if they are very close to their target. + private float CalcHomingFactor(float dist) + { + float baseFactor = BaseHomingFactor; + float bonus = (MaxHomingFactor - BaseHomingFactor) * (1f - dist / HomingBonusRangeCap); + if (bonus < 0f) + bonus = 0f; + return baseFactor + bonus; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - // Draws the energy blade's glowmask. - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - float fWidthOverTwo = SpriteWidth / 2f; - float fHeightOverTwo = projectile.height / 2f; + // Draws the energy blade's glowmask. + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + float fWidthOverTwo = SpriteWidth / 2f; + float fHeightOverTwo = projectile.height / 2f; - // Make sure the glowmask matches the blade's own orientation - SpriteEffects eff = SpriteEffects.None; - if (projectile.spriteDirection == -1) - eff = SpriteEffects.FlipHorizontally; - Vector2 origin = new Vector2(fWidthOverTwo, fHeightOverTwo); - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Rogue/NanoblackSplitGlow"), - projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, - origin, projectile.scale, eff, 0f); - } + // Make sure the glowmask matches the blade's own orientation + SpriteEffects eff = SpriteEffects.None; + if (projectile.spriteDirection == -1) + eff = SpriteEffects.FlipHorizontally; + Vector2 origin = new Vector2(fWidthOverTwo, fHeightOverTwo); + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Rogue/NanoblackSplitGlow"), + projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, + origin, projectile.scale, eff, 0f); + } - // Spawns a tiny bit of dust when the energy blade vanishes. - public override void Kill(int timeLeft) - { - SpawnDust(); - } + // Spawns a tiny bit of dust when the energy blade vanishes. + public override void Kill(int timeLeft) + { + SpawnDust(); + } - // Spawns a small bit of Luminite themed dust. - private void SpawnDust() - { - int dustCount = Main.rand.Next(3, 6); - Vector2 corner = projectile.position; - for (int i = 0; i < dustCount; ++i) - { - int dustType = 229; - float scale = 0.6f + Main.rand.NextFloat(0.4f); - int idx = Dust.NewDust(corner, projectile.width, projectile.height, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - Main.dust[idx].scale = scale; - } - } - } + // Spawns a small bit of Luminite themed dust. + private void SpawnDust() + { + int dustCount = Main.rand.Next(3, 6); + Vector2 corner = projectile.position; + for (int i = 0; i < dustCount; ++i) + { + int dustType = 229; + float scale = 0.6f + Main.rand.NextFloat(0.4f); + int idx = Dust.NewDust(corner, projectile.width, projectile.height, dustType); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 3f; + Main.dust[idx].scale = scale; + } + } + } } diff --git a/Projectiles/Rogue/NanoblackStealthSplit.cs b/Projectiles/Rogue/NanoblackStealthSplit.cs index 829bb5bc61..23cca9a85e 100644 --- a/Projectiles/Rogue/NanoblackStealthSplit.cs +++ b/Projectiles/Rogue/NanoblackStealthSplit.cs @@ -7,202 +7,202 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class NanoblackStealthSplit : ModProjectile - { + public class NanoblackStealthSplit : ModProjectile + { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/NanoblackReaperRogue"; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/NanoblackReaperRogue"; - private static int Lifetime = 300; - private static float MaxSpeed = 40f; - private static float MaxRotationSpeed = 0.25f; + private static int Lifetime = 300; + private static float MaxSpeed = 40f; + private static float MaxRotationSpeed = 0.25f; - private static float HomingStartRange = 4000f; - private static float HomingBreakRange = 6000f; - private static float HomingBonusRangeCap = 2000f; - private static float BaseHomingFactor = 2.6f; - private static float MaxHomingFactor = 8.6f; + private static float HomingStartRange = 4000f; + private static float HomingBreakRange = 6000f; + private static float HomingBonusRangeCap = 2000f; + private static float BaseHomingFactor = 2.6f; + private static float MaxHomingFactor = 8.6f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Nanoblack Afterimage"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 7; - ProjectileID.Sets.TrailingMode[projectile.type] = 2; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Nanoblack Afterimage"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 7; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } - public override void SetDefaults() - { - projectile.width = 56; - projectile.height = 56; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = 12; - projectile.extraUpdates = 1; - projectile.timeLeft = Lifetime; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 8; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 56; + projectile.height = 56; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = 12; + projectile.extraUpdates = 1; + projectile.timeLeft = Lifetime; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 8; + projectile.Calamity().rogue = true; + } - // ai[0] = Index of current NPC target. If 0 or negative, the projectile has no target - // ai[1] = Current spin speed. When it reaches 0, starts homing into enemies. Negative speeds are also allowed. - public override void AI() - { + // ai[0] = Index of current NPC target. If 0 or negative, the projectile has no target + // ai[1] = Current spin speed. When it reaches 0, starts homing into enemies. Negative speeds are also allowed. + public override void AI() + { - // Produces electricity and green firework sparks constantly while in flight. (Like the main projectile) - if (Main.rand.NextBool(3)) - { - int dustType = Main.rand.NextBool(5) ? 226 : 220; - float scale = 0.8f + Main.rand.NextFloat(0.3f); - float velocityMult = Main.rand.NextFloat(0.3f, 0.6f); - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity = velocityMult * projectile.velocity; - Main.dust[idx].scale = scale; - } + // Produces electricity and green firework sparks constantly while in flight. (Like the main projectile) + if (Main.rand.NextBool(3)) + { + int dustType = Main.rand.NextBool(5) ? 226 : 220; + float scale = 0.8f + Main.rand.NextFloat(0.3f); + float velocityMult = Main.rand.NextFloat(0.3f, 0.6f); + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity = velocityMult * projectile.velocity; + Main.dust[idx].scale = scale; + } - // Spin in the specified starting direction and slow down spin over time - // Loses 1.66% of current speed every frame - // Also update current orientation to reflect current spin direction - if (projectile.timeLeft > 200) - { - float currentSpin = projectile.ai[1]; - projectile.direction = currentSpin <= 0f ? -1 : 1; - projectile.spriteDirection = projectile.direction; - projectile.rotation += currentSpin * MaxRotationSpeed; - float spinReduction = 0.0166f * currentSpin; - projectile.ai[1] -= spinReduction; - } - // Search for and home in on nearby targets after the given time, and stops spinning - else - { - projectile.rotation = 0f; - HomingAI(); - } - } + // Spin in the specified starting direction and slow down spin over time + // Loses 1.66% of current speed every frame + // Also update current orientation to reflect current spin direction + if (projectile.timeLeft > 200) + { + float currentSpin = projectile.ai[1]; + projectile.direction = currentSpin <= 0f ? -1 : 1; + projectile.spriteDirection = projectile.direction; + projectile.rotation += currentSpin * MaxRotationSpeed; + float spinReduction = 0.0166f * currentSpin; + projectile.ai[1] -= spinReduction; + } + // Search for and home in on nearby targets after the given time, and stops spinning + else + { + projectile.rotation = 0f; + HomingAI(); + } + } - private void HomingAI() - { - // If we don't currently have a target, go try and get one! - int targetID = (int)projectile.ai[0] - 1; - if (targetID < 0) - targetID = AcquireTarget(); + private void HomingAI() + { + // If we don't currently have a target, go try and get one! + int targetID = (int)projectile.ai[0] - 1; + if (targetID < 0) + targetID = AcquireTarget(); - // Save the target, whether we have one or not. - projectile.ai[0] = targetID + 1f; + // Save the target, whether we have one or not. + projectile.ai[0] = targetID + 1f; - // If we don't have a target, then just slow down a bit. - if (targetID < 0) - { - projectile.velocity *= 0.94f; - return; - } + // If we don't have a target, then just slow down a bit. + if (targetID < 0) + { + projectile.velocity *= 0.94f; + return; + } - // Homing behavior depends on how far the blade is from its target. - NPC target = Main.npc[targetID]; - float xDist = projectile.Center.X - target.Center.X; - float yDist = projectile.Center.Y - target.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); + // Homing behavior depends on how far the blade is from its target. + NPC target = Main.npc[targetID]; + float xDist = projectile.Center.X - target.Center.X; + float yDist = projectile.Center.Y - target.Center.Y; + float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - // If the target is too far away, stop homing in on it. - if (dist > HomingBreakRange) - { - projectile.ai[0] = 0f; - return; - } + // If the target is too far away, stop homing in on it. + if (dist > HomingBreakRange) + { + projectile.ai[0] = 0f; + return; + } - // Adds a multiple of the towards-target vector to its velocity every frame. - float homingFactor = CalcHomingFactor(dist); - Vector2 posDiff = target.Center - projectile.Center; - posDiff = posDiff.SafeNormalize(Vector2.Zero); - posDiff *= homingFactor; - Vector2 newVelocity = projectile.velocity += posDiff; + // Adds a multiple of the towards-target vector to its velocity every frame. + float homingFactor = CalcHomingFactor(dist); + Vector2 posDiff = target.Center - projectile.Center; + posDiff = posDiff.SafeNormalize(Vector2.Zero); + posDiff *= homingFactor; + Vector2 newVelocity = projectile.velocity += posDiff; - // Caps speed to make sure it doesn't go too fast. - if (newVelocity.Length() >= MaxSpeed) - { - newVelocity = newVelocity.SafeNormalize(Vector2.Zero); - newVelocity *= MaxSpeed; - } + // Caps speed to make sure it doesn't go too fast. + if (newVelocity.Length() >= MaxSpeed) + { + newVelocity = newVelocity.SafeNormalize(Vector2.Zero); + newVelocity *= MaxSpeed; + } - projectile.velocity = newVelocity; + projectile.velocity = newVelocity; - //The afterimage's blade always tries to face its target - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); - } + //The afterimage's blade always tries to face its target + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); + } - // Returns the ID of the NPC to be targeted by this energy blade. - // It chooses the closest target which can be chased, ignoring invulnerable NPCs. - // Nanoblack Afterimages prefer to target bosses whenever possible. - private int AcquireTarget() - { - bool bossFound = false; - int target = -1; - float minDist = HomingStartRange; - for (int i = 0; i < 200; ++i) - { - NPC npc = Main.npc[i]; - if (!npc.active || npc.type == NPCID.TargetDummy) - continue; + // Returns the ID of the NPC to be targeted by this energy blade. + // It chooses the closest target which can be chased, ignoring invulnerable NPCs. + // Nanoblack Afterimages prefer to target bosses whenever possible. + private int AcquireTarget() + { + bool bossFound = false; + int target = -1; + float minDist = HomingStartRange; + for (int i = 0; i < 200; ++i) + { + NPC npc = Main.npc[i]; + if (!npc.active || npc.type == NPCID.TargetDummy) + continue; - // If we've found a valid boss target, ignore ALL targets which aren't bosses. - if (bossFound && !npc.boss) - continue; + // If we've found a valid boss target, ignore ALL targets which aren't bosses. + if (bossFound && !npc.boss) + continue; - if (npc.CanBeChasedBy(projectile, false)) - { - float xDist = projectile.Center.X - npc.Center.X; - float yDist = projectile.Center.Y - npc.Center.Y; - float distToNPC = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (distToNPC < minDist) - { - // If this target within range is a boss, set the boss found flag. - if (npc.boss) - bossFound = true; - minDist = distToNPC; - target = i; - } - } - } - return target; - } + if (npc.CanBeChasedBy(projectile, false)) + { + float xDist = projectile.Center.X - npc.Center.X; + float yDist = projectile.Center.Y - npc.Center.Y; + float distToNPC = (float)Math.Sqrt(xDist * xDist + yDist * yDist); + if (distToNPC < minDist) + { + // If this target within range is a boss, set the boss found flag. + if (npc.boss) + bossFound = true; + minDist = distToNPC; + target = i; + } + } + } + return target; + } - // Afterimages home even more aggressively if they are very close to their target. - private float CalcHomingFactor(float dist) - { - float baseFactor = BaseHomingFactor; - float bonus = (MaxHomingFactor - BaseHomingFactor) * (1f - dist / HomingBonusRangeCap); - if (bonus < 0f) - bonus = 0f; - return baseFactor + bonus; - } + // Afterimages home even more aggressively if they are very close to their target. + private float CalcHomingFactor(float dist) + { + float baseFactor = BaseHomingFactor; + float bonus = (MaxHomingFactor - BaseHomingFactor) * (1f - dist / HomingBonusRangeCap); + if (bonus < 0f) + bonus = 0f; + return baseFactor + bonus; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - // Spawns a tiny bit of dust when the afterimage vanishes. - public override void Kill(int timeLeft) - { - SpawnDust(); - } + // Spawns a tiny bit of dust when the afterimage vanishes. + public override void Kill(int timeLeft) + { + SpawnDust(); + } - // Spawns a small bit of Luminite themed dust. - private void SpawnDust() - { - int dustCount = Main.rand.Next(3, 6); - Vector2 corner = projectile.position; - for (int i = 0; i < dustCount; ++i) - { - int dustType = 229; - float scale = 0.6f + Main.rand.NextFloat(0.4f); - int idx = Dust.NewDust(corner, projectile.width, projectile.height, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - Main.dust[idx].scale = scale; - } - } - } + // Spawns a small bit of Luminite themed dust. + private void SpawnDust() + { + int dustCount = Main.rand.Next(3, 6); + Vector2 corner = projectile.position; + for (int i = 0; i < dustCount; ++i) + { + int dustType = 229; + float scale = 0.6f + Main.rand.NextFloat(0.4f); + int idx = Dust.NewDust(corner, projectile.width, projectile.height, dustType); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 3f; + Main.dust[idx].scale = scale; + } + } + } } \ No newline at end of file diff --git a/Projectiles/Rogue/NastyChollaBol.cs b/Projectiles/Rogue/NastyChollaBol.cs index a9c9546e96..d82e56b36b 100644 --- a/Projectiles/Rogue/NastyChollaBol.cs +++ b/Projectiles/Rogue/NastyChollaBol.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class NastyChollaBol : ModProjectile + public class NastyChollaBol : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/NastyCholla"; @@ -31,29 +31,29 @@ namespace CalamityMod.Projectiles.Rogue if (Main.rand.NextBool(12)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 157, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } + } //Sticky Behaviour projectile.StickyProjAI(15); - if (projectile.ai[0] != 1f) - { - projectile.StickToTiles(true, false); - projectile.localAI[1] += 1f; - if (projectile.localAI[1] > 10f) - { - projectile.localAI[1] = 10f; - if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) - { - projectile.velocity.X *= 0.97f; - if (Math.Abs(projectile.velocity.X) < 0.01f) - { - projectile.velocity.X = 0f; - projectile.netUpdate = true; - } - } - projectile.velocity.Y += 0.2f; - } - projectile.rotation += projectile.velocity.X * 0.1f; - } + if (projectile.ai[0] != 1f) + { + projectile.StickToTiles(true, false); + projectile.localAI[1] += 1f; + if (projectile.localAI[1] > 10f) + { + projectile.localAI[1] = 10f; + if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) + { + projectile.velocity.X *= 0.97f; + if (Math.Abs(projectile.velocity.X) < 0.01f) + { + projectile.velocity.X = 0f; + projectile.netUpdate = true; + } + } + projectile.velocity.Y += 0.2f; + } + projectile.rotation += projectile.velocity.X * 0.1f; + } } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) @@ -70,28 +70,28 @@ namespace CalamityMod.Projectiles.Rogue return null; } - //So you can stick a bol up the Guide's ass + //So you can stick a bol up the Guide's ass public override bool? CanHitNPC(NPC target) - { - if (target.townNPC) - { - return true; - } - return null; - } + { + if (target.townNPC) + { + return true; + } + return null; + } public override void Kill(int timeLeft) { - Player player = Main.player[projectile.owner]; - int needleAmt = Main.rand.Next(2, 4); - if (projectile.owner == Main.myPlayer) - { - for (int n = 0; n < needleAmt; n++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)((NastyCholla.BaseDamage/4) * player.RogueDamage()), 0f, projectile.owner, 0f, 0f); - } - } - } + Player player = Main.player[projectile.owner]; + int needleAmt = Main.rand.Next(2, 4); + if (projectile.owner == Main.myPlayer) + { + for (int n = 0; n < needleAmt; n++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)((NastyCholla.BaseDamage/4) * player.RogueDamage()), 0f, projectile.owner, 0f, 0f); + } + } + } } } diff --git a/Projectiles/Rogue/NastyChollaNeedle.cs b/Projectiles/Rogue/NastyChollaNeedle.cs index 7842d97452..252945baa3 100644 --- a/Projectiles/Rogue/NastyChollaNeedle.cs +++ b/Projectiles/Rogue/NastyChollaNeedle.cs @@ -5,7 +5,7 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Projectiles.Rogue { - public class NastyChollaNeedle : ModProjectile + public class NastyChollaNeedle : ModProjectile { public override void SetStaticDefaults() { @@ -27,23 +27,23 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - //Rotating 45 degrees if shooting right - if (projectile.spriteDirection == 1) - { - projectile.rotation += MathHelper.ToRadians(45f); - } - //Rotating 45 degrees if shooting right - if (projectile.spriteDirection == -1) - { - projectile.rotation -= MathHelper.ToRadians(45f); - } + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); + //Rotating 45 degrees if shooting right + if (projectile.spriteDirection == 1) + { + projectile.rotation += MathHelper.ToRadians(45f); + } + //Rotating 45 degrees if shooting right + if (projectile.spriteDirection == -1) + { + projectile.rotation -= MathHelper.ToRadians(45f); + } projectile.velocity.X *= 0.9995f; projectile.velocity.Y = projectile.velocity.Y + 0.01f; } - //So you can stick a needle up the Tinkerer's ass + //So you can stick a needle up the Tinkerer's ass public override bool? CanHitNPC(NPC target) => target.type != NPCID.DD2EterniaCrystal && !target.immortal && !target.dontTakeDamage; } } diff --git a/Projectiles/Rogue/NiceCock.cs b/Projectiles/Rogue/NiceCock.cs index b88b807127..d0ea4236c1 100644 --- a/Projectiles/Rogue/NiceCock.cs +++ b/Projectiles/Rogue/NiceCock.cs @@ -6,12 +6,12 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - // The file name is a specific request from the patron - public class NiceCock : ModProjectile + // The file name is a specific request from the patron + public class NiceCock : ModProjectile { public bool homing = false; public int Timer = 0; - private bool initialized = false; + private bool initialized = false; private Color[] colors = new Color[] { new Color(255, 0, 0, 50), //Red @@ -49,36 +49,36 @@ namespace CalamityMod.Projectiles.Rogue public override void ReceiveExtraAI(BinaryReader reader) => homing = reader.ReadBoolean(); - public override bool? CanHitNPC(NPC target) - { - // Do not deal damage before fully opaque - if (projectile.alpha >= 10) - return false; - int index = (int)projectile.ai[1]; - if (Main.npc[index] is null || !Main.npc[index].active || Main.npc[index].life < 0) - return false; - // Do not deal damage to any NPC that isn't the specified target - if (index != target.whoAmI) - return false; - return null; - } - - public override void AI() + public override bool? CanHitNPC(NPC target) { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - // Fireballs disappear if you can't stealth strike - if (!modPlayer.wearingRogueArmor || modPlayer.rogueStealthMax <= 0) - projectile.Kill(); + // Do not deal damage before fully opaque + if (projectile.alpha >= 10) + return false; + int index = (int)projectile.ai[1]; + if (Main.npc[index] is null || !Main.npc[index].active || Main.npc[index].life < 0) + return false; + // Do not deal damage to any NPC that isn't the specified target + if (index != target.whoAmI) + return false; + return null; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + // Fireballs disappear if you can't stealth strike + if (!modPlayer.wearingRogueArmor || modPlayer.rogueStealthMax <= 0) + projectile.Kill(); projectile.alpha -= 5; - if (!initialized) - { - // Pick a random frame to start on - projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); - initialized = true; - } + if (!initialized) + { + // Pick a random frame to start on + projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); + initialized = true; + } projectile.frameCounter++; if (projectile.frameCounter > 8) @@ -89,50 +89,50 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.frame >= Main.projFrames[projectile.type]) projectile.frame = 0; - int index = (int)projectile.ai[1]; + int index = (int)projectile.ai[1]; - // If the target doesn't exist or is dead, spontaneously combust - if (Main.npc[index] is null || !Main.npc[index].active || Main.npc[index].life < 0) - projectile.Kill(); + // If the target doesn't exist or is dead, spontaneously combust + if (Main.npc[index] is null || !Main.npc[index].active || Main.npc[index].life < 0) + projectile.Kill(); - // Decrement the timer. This should last a second as stealth strikes will initialize this at 61. - if (Timer > 1) - Timer --; - if (Timer == 1) - homing = true; + // Decrement the timer. This should last a second as stealth strikes will initialize this at 61. + if (Timer > 1) + Timer --; + if (Timer == 1) + homing = true; - NPC target = Main.npc[index]; + NPC target = Main.npc[index]; - if (homing) - { - // Home in on the target - Vector2 moveDirection = projectile.SafeDirectionTo(target.Center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * 20f + moveDirection * 15f) / 21f; - } - else - { - // Circle around the target counter-clockwise at 4 radians per frame + if (homing) + { + // Home in on the target + Vector2 moveDirection = projectile.SafeDirectionTo(target.Center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 20f + moveDirection * 15f) / 21f; + } + else + { + // Circle around the target counter-clockwise at 4 radians per frame float height = target.getRect().Height; float width = target.getRect().Width; float circleDist = MathHelper.Min((height > width ? height : width) * 3f, (Main.LogicCheckScreenWidth * Main.LogicCheckScreenHeight) / 2); if (circleDist > Main.LogicCheckScreenWidth / 3) circleDist = Main.LogicCheckScreenWidth / 3; - projectile.Center = target.Center + projectile.ai[0].ToRotationVector2() * circleDist; - projectile.ai[0] -= MathHelper.ToRadians(4f); - } + projectile.Center = target.Center + projectile.ai[0].ToRotationVector2() * circleDist; + projectile.ai[0] -= MathHelper.ToRadians(4f); + } } public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item74, projectile.Center); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 50); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 50); - // Create into some rainbow-colored dust when dead + // Create into some rainbow-colored dust when dead for (int d = 0; d < 5; d++) { int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 267, 0f, 0f, 150, Main.rand.Next(colors), 2f); Main.dust[idx].velocity *= 3f; - Main.dust[idx].noGravity = true; + Main.dust[idx].noGravity = true; if (Main.rand.NextBool(2)) { Main.dust[idx].scale = 0.5f; @@ -146,7 +146,7 @@ namespace CalamityMod.Projectiles.Rogue Main.dust[idx].velocity *= 5f; idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 267, 0f, 0f, 150, Main.rand.Next(colors), 2f); Main.dust[idx].velocity *= 2f; - Main.dust[idx].noGravity = true; + Main.dust[idx].noGravity = true; } } } diff --git a/Projectiles/Rogue/NightsGazeProjectile.cs b/Projectiles/Rogue/NightsGazeProjectile.cs index 401e5d904a..5f2ca54d5c 100644 --- a/Projectiles/Rogue/NightsGazeProjectile.cs +++ b/Projectiles/Rogue/NightsGazeProjectile.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 300; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/NightsGazeSpark.cs b/Projectiles/Rogue/NightsGazeSpark.cs index a01662ee66..3ba90aa841 100644 --- a/Projectiles/Rogue/NightsGazeSpark.cs +++ b/Projectiles/Rogue/NightsGazeSpark.cs @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 6; projectile.height = 6; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 5; + projectile.ignoreWater = true; + projectile.penetrate = 5; projectile.timeLeft = lifetime; projectile.Calamity().rogue = true; projectile.localAI[0] = 10f; diff --git a/Projectiles/Rogue/NightsGazeStar.cs b/Projectiles/Rogue/NightsGazeStar.cs index c9e67b2132..c1fb4de6bd 100644 --- a/Projectiles/Rogue/NightsGazeStar.cs +++ b/Projectiles/Rogue/NightsGazeStar.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 10; projectile.height = 10; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 5; + projectile.ignoreWater = true; + projectile.penetrate = 5; projectile.timeLeft = lifetime; projectile.Calamity().rogue = true; projectile.localAI[0] = 10f; @@ -48,12 +48,12 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < 3; i++) { float dustVelocity = Main.rand.NextFloat(0f, 0.5f); - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 109, - 111, - 132 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 109, + 111, + 132 + }); int dust = Dust.NewDust(projectile.Center, 1, 1, dustType, projectile.velocity.X, projectile.velocity.Y, 0, default, 1.5f); Main.dust[dust].noGravity = true; @@ -124,12 +124,12 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < 5; i++) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 109, - 111, - 132 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 109, + 111, + 132 + }); int dust = Dust.NewDust(projectile.Center, 1, 1, dustType, projectile.velocity.X, projectile.velocity.Y, 0, default, 1.5f); Main.dust[dust].noGravity = true; diff --git a/Projectiles/Rogue/NychthemeronOrb.cs b/Projectiles/Rogue/NychthemeronOrb.cs index d4af22a7bf..9014c542a7 100644 --- a/Projectiles/Rogue/NychthemeronOrb.cs +++ b/Projectiles/Rogue/NychthemeronOrb.cs @@ -63,8 +63,8 @@ namespace CalamityMod.Projectiles.Rogue } else if (projectile.localAI[0] == 1f) { - if (projectile.timeLeft > 240 && projectile.Calamity().lineColor == 1) - projectile.timeLeft = 240; + if (projectile.timeLeft > 240 && projectile.Calamity().lineColor == 1) + projectile.timeLeft = 240; // Follow Enemy float minDist = 999f; int index = 0; diff --git a/Projectiles/Rogue/NychthemeronProjectile.cs b/Projectiles/Rogue/NychthemeronProjectile.cs index c9af0188a7..b301d3e83d 100644 --- a/Projectiles/Rogue/NychthemeronProjectile.cs +++ b/Projectiles/Rogue/NychthemeronProjectile.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 10; projectile.height = 10; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 4; + projectile.ignoreWater = true; + projectile.penetrate = 4; projectile.timeLeft = lifetime; projectile.Calamity().rogue = true; } @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity = toPlayer; projectile.ai[0] += 0.5f; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; if (projectile.ai[0] > 20f) { projectile.ai[0] = 20f; diff --git a/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs b/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs index d9368777f3..a22541246b 100644 --- a/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs +++ b/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs @@ -56,38 +56,38 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffect(target.Center); - } + OnHitEffect(target.Center); + } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffect(target.Center); - } + OnHitEffect(target.Center); + } - private void OnHitEffect(Vector2 targetPos) - { - if (Main.myPlayer != projectile.owner || !projectile.Calamity().stealthStrike) - return; + private void OnHitEffect(Vector2 targetPos) + { + if (Main.myPlayer != projectile.owner || !projectile.Calamity().stealthStrike) + return; - for (int i = 0; i < 2; i++) - { - int direction = Main.player[projectile.owner].direction; - float xStart = Main.screenPosition.X; - if (direction < 0) - xStart += Main.screenWidth; - float yStart = Main.screenPosition.Y + Main.rand.Next(Main.screenHeight); - Vector2 startPos = new Vector2(xStart, yStart); - Vector2 pathToTravel = targetPos - startPos; - pathToTravel.X += Main.rand.NextFloat(-50f, 50f) * 0.1f; - pathToTravel.Y += Main.rand.NextFloat(-50f, 50f) * 0.1f; - float speedMult = 24f / pathToTravel.Length(); - pathToTravel.X *= speedMult; - pathToTravel.Y *= speedMult; - int petal = Projectile.NewProjectile(startPos, pathToTravel, ProjectileID.FlowerPetal, projectile.damage, 0f, projectile.owner); - if (petal.WithinBounds(Main.maxProjectiles)) - Main.projectile[petal].Calamity().forceRogue = true; - } - } + for (int i = 0; i < 2; i++) + { + int direction = Main.player[projectile.owner].direction; + float xStart = Main.screenPosition.X; + if (direction < 0) + xStart += Main.screenWidth; + float yStart = Main.screenPosition.Y + Main.rand.Next(Main.screenHeight); + Vector2 startPos = new Vector2(xStart, yStart); + Vector2 pathToTravel = targetPos - startPos; + pathToTravel.X += Main.rand.NextFloat(-50f, 50f) * 0.1f; + pathToTravel.Y += Main.rand.NextFloat(-50f, 50f) * 0.1f; + float speedMult = 24f / pathToTravel.Length(); + pathToTravel.X *= speedMult; + pathToTravel.Y *= speedMult; + int petal = Projectile.NewProjectile(startPos, pathToTravel, ProjectileID.FlowerPetal, projectile.damage, 0f, projectile.owner); + if (petal.WithinBounds(Main.maxProjectiles)) + Main.projectile[petal].Calamity().forceRogue = true; + } + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Rogue/PalladiumJavelinProjectile.cs b/Projectiles/Rogue/PalladiumJavelinProjectile.cs index 765e9f7e23..dc9f70033d 100644 --- a/Projectiles/Rogue/PalladiumJavelinProjectile.cs +++ b/Projectiles/Rogue/PalladiumJavelinProjectile.cs @@ -34,38 +34,38 @@ namespace CalamityMod.Projectiles.Rogue { projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; - //Stealth strike behavior - if (!projectile.Calamity().stealthStrike || projectile.owner != Main.myPlayer || projectile.Calamity().lineColor >= 2) - return; - projectile.localAI[0]++; - if (projectile.localAI[0] >= 30f) - { - Vector2 vector2 = new Vector2(20f, 20f); - for (int index1 = 0; index1 < 10; ++index1) - { - int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 87, 0f, 0f, 100, new Color(), 1.5f); - Dust dust = Main.dust[index2]; - dust.velocity *= 1.4f; - } - for (int index1 = 0; index1 < 5; ++index1) - { - Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 144, 0f, 0f, 0, default, 1f); - } + //Stealth strike behavior + if (!projectile.Calamity().stealthStrike || projectile.owner != Main.myPlayer || projectile.Calamity().lineColor >= 2) + return; + projectile.localAI[0]++; + if (projectile.localAI[0] >= 30f) + { + Vector2 vector2 = new Vector2(20f, 20f); + for (int index1 = 0; index1 < 10; ++index1) + { + int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 87, 0f, 0f, 100, new Color(), 1.5f); + Dust dust = Main.dust[index2]; + dust.velocity *= 1.4f; + } + for (int index1 = 0; index1 < 5; ++index1) + { + Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 144, 0f, 0f, 0, default, 1f); + } - int javelin = Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(MathHelper.ToRadians(5f)), projectile.type, projectile.damage, projectile.knockBack, projectile.owner); - int javelin2 = Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(MathHelper.ToRadians(-5f)), projectile.type, projectile.damage, projectile.knockBack, projectile.owner); - if (javelin.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[javelin].Calamity().lineColor = projectile.Calamity().lineColor + 1; - Main.projectile[javelin].Calamity().stealthStrike = true; - } - if (javelin2.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[javelin2].Calamity().lineColor = projectile.Calamity().lineColor + 1; - Main.projectile[javelin2].Calamity().stealthStrike = true; - } - projectile.Kill(); - } + int javelin = Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(MathHelper.ToRadians(5f)), projectile.type, projectile.damage, projectile.knockBack, projectile.owner); + int javelin2 = Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(MathHelper.ToRadians(-5f)), projectile.type, projectile.damage, projectile.knockBack, projectile.owner); + if (javelin.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[javelin].Calamity().lineColor = projectile.Calamity().lineColor + 1; + Main.projectile[javelin].Calamity().stealthStrike = true; + } + if (javelin2.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[javelin2].Calamity().lineColor = projectile.Calamity().lineColor + 1; + Main.projectile[javelin2].Calamity().stealthStrike = true; + } + projectile.Kill(); + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/PanSpark.cs b/Projectiles/Rogue/PanSpark.cs index 285fcc21ba..dda22194a0 100644 --- a/Projectiles/Rogue/PanSpark.cs +++ b/Projectiles/Rogue/PanSpark.cs @@ -6,9 +6,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class PanSpark : ModProjectile + public class PanSpark : ModProjectile { - private bool initialized = false; + private bool initialized = false; public override void SetStaticDefaults() { @@ -28,28 +28,28 @@ namespace CalamityMod.Projectiles.Rogue projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { - //make it face the way it's going - if (projectile.ai[1] > 0f) - { - projectile.rotation = -projectile.velocity.X * 0.05f + MathHelper.PiOver2; - } - else - { - projectile.rotation = projectile.velocity.ToRotation(); - } - projectile.ai[1]--; + //make it face the way it's going + if (projectile.ai[1] > 0f) + { + projectile.rotation = -projectile.velocity.X * 0.05f + MathHelper.PiOver2; + } + else + { + projectile.rotation = projectile.velocity.ToRotation(); + } + projectile.ai[1]--; - //frames - if (!initialized) - { - initialized = true; - projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); - } + //frames + if (!initialized) + { + initialized = true; + projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); + } projectile.frameCounter++; if (projectile.frameCounter > 6) { @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.frame = 0; } - //movement + //movement if (projectile.velocity.X != projectile.velocity.X) { projectile.velocity.X *= -0.1f; @@ -98,17 +98,17 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.Y = 16f; } - //dust - if (Main.rand.NextBool(4)) - { - int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[fire]; - dust.position.X -= 2f; - dust.position.Y += 2f; - dust.scale += (float)Main.rand.Next(50) * 0.01f; - dust.noGravity = true; - dust.velocity.Y -= 2f; - } + //dust + if (Main.rand.NextBool(4)) + { + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[fire]; + dust.position.X -= 2f; + dust.position.Y += 2f; + dust.scale += (float)Main.rand.Next(50) * 0.01f; + dust.noGravity = true; + dust.velocity.Y -= 2f; + } if (Main.rand.NextBool(10)) { int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f); @@ -123,7 +123,7 @@ namespace CalamityMod.Projectiles.Rogue public override bool OnTileCollide(Vector2 oldVelocity) { - projectile.ai[1] = 10f; + projectile.ai[1] = 10f; return false; } diff --git a/Projectiles/Rogue/PartisanExplosion.cs b/Projectiles/Rogue/PartisanExplosion.cs index 68047213d2..8861ec9548 100644 --- a/Projectiles/Rogue/PartisanExplosion.cs +++ b/Projectiles/Rogue/PartisanExplosion.cs @@ -5,14 +5,14 @@ using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Rogue { - public class PartisanExplosion : ModProjectile + public class PartisanExplosion : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Profaned Explosion"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Profaned Explosion"); + } public override void SetDefaults() { diff --git a/Projectiles/Rogue/PenumbraBomb.cs b/Projectiles/Rogue/PenumbraBomb.cs index d4736abf63..832fc402c3 100644 --- a/Projectiles/Rogue/PenumbraBomb.cs +++ b/Projectiles/Rogue/PenumbraBomb.cs @@ -6,7 +6,7 @@ using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Projectiles.Rogue { - public class PenumbraBomb : ModProjectile + public class PenumbraBomb : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Penumbra"; @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Rogue { //Dark soul projectiles int ad = projectile.Calamity().stealthStrike ? 40 : 60; - float dmgMult = projectile.Calamity().stealthStrike ? 0.08f : 0.15f; + float dmgMult = projectile.Calamity().stealthStrike ? 0.08f : 0.15f; int randrot = Main.rand.Next(-30,31); for (int i = 0; i < 360; i += ad) { @@ -99,7 +99,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage /= 2; + projectile.damage /= 2; projectile.Damage(); } diff --git a/Projectiles/Rogue/PenumbraSoul.cs b/Projectiles/Rogue/PenumbraSoul.cs index 3f57c5d8dd..228ac4aa36 100644 --- a/Projectiles/Rogue/PenumbraSoul.cs +++ b/Projectiles/Rogue/PenumbraSoul.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.friendly = true; projectile.tileCollide = false; projectile.ignoreWater = true; - projectile.Calamity().rogue = true; - projectile.alpha = 80; + projectile.Calamity().rogue = true; + projectile.alpha = 80; projectile.penetrate = 2; projectile.usesLocalNPCImmunity = true; @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Rogue private void HomingAI() { - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, Penumbra.ShootSpeed * 1.5f, 35f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, Penumbra.ShootSpeed * 1.5f, 35f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/PhantasmalRuinGhost.cs b/Projectiles/Rogue/PhantasmalRuinGhost.cs index 005cdb97b1..8cf7e7528e 100644 --- a/Projectiles/Rogue/PhantasmalRuinGhost.cs +++ b/Projectiles/Rogue/PhantasmalRuinGhost.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class PhantasmalRuinGhost : ModProjectile + public class PhantasmalRuinGhost : ModProjectile { public override void SetStaticDefaults() { @@ -17,8 +17,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.tileCollide = false; projectile.timeLeft = 240; projectile.extraUpdates = 1; diff --git a/Projectiles/Rogue/PhantasmalRuinProj.cs b/Projectiles/Rogue/PhantasmalRuinProj.cs index 764da0c0ad..faebe8b40c 100644 --- a/Projectiles/Rogue/PhantasmalRuinProj.cs +++ b/Projectiles/Rogue/PhantasmalRuinProj.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.tileCollide = false; projectile.timeLeft = Lifetime; projectile.extraUpdates = 1; diff --git a/Projectiles/Rogue/PhantasmalSoul.cs b/Projectiles/Rogue/PhantasmalSoul.cs index 352fdb98ea..72646d448f 100644 --- a/Projectiles/Rogue/PhantasmalSoul.cs +++ b/Projectiles/Rogue/PhantasmalSoul.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = Lifetime; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < Lifetime - NoHomingFrames && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < Lifetime - NoHomingFrames && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { // Handle animation projectile.frameCounter++; diff --git a/Projectiles/Rogue/PhantomLanceProj.cs b/Projectiles/Rogue/PhantomLanceProj.cs index fd1af57801..c48abd7612 100644 --- a/Projectiles/Rogue/PhantomLanceProj.cs +++ b/Projectiles/Rogue/PhantomLanceProj.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class PhantomLanceProj : ModProjectile + public class PhantomLanceProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/PhantomLance"; @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.tileCollide = false; projectile.timeLeft = 300; projectile.extraUpdates = 1; @@ -39,36 +39,36 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - if (!projectile.Calamity().stealthStrike) - { - if (projectile.timeLeft <= 255) - projectile.alpha += 1; - if (projectile.timeLeft >= 75) - { - projectile.velocity.X *= 0.995f; - projectile.velocity.Y *= 0.995f; - } - } + if (!projectile.Calamity().stealthStrike) + { + if (projectile.timeLeft <= 255) + projectile.alpha += 1; + if (projectile.timeLeft >= 75) + { + projectile.velocity.X *= 0.995f; + projectile.velocity.Y *= 0.995f; + } + } projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 175, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 0, default, 0.85f); - projectile.ai[0]++; - if (projectile.ai[0] % 18f == 0f) - { - if (projectile.owner == Main.myPlayer) - { - float damageMult = projectile.timeLeft * 0.7f / 300f; - if (projectile.Calamity().stealthStrike) + projectile.ai[0]++; + if (projectile.ai[0] % 18f == 0f) + { + if (projectile.owner == Main.myPlayer) + { + float damageMult = projectile.timeLeft * 0.7f / 300f; + if (projectile.Calamity().stealthStrike) damageMult = 0.7f; - int soulDamage = (int)(projectile.damage * damageMult); - int soul = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), soulDamage, projectile.knockBack, projectile.owner); - if (soul.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[soul].Calamity().forceRogue = true; - Main.projectile[soul].usesLocalNPCImmunity = true; - Main.projectile[soul].localNPCHitCooldown = -2; - } - } - } + int soulDamage = (int)(projectile.damage * damageMult); + int soul = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), soulDamage, projectile.knockBack, projectile.owner); + if (soul.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[soul].Calamity().forceRogue = true; + Main.projectile[soul].usesLocalNPCImmunity = true; + Main.projectile[soul].localNPCHitCooldown = -2; + } + } + } } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/PlaguedFuelPackCloud.cs b/Projectiles/Rogue/PlaguedFuelPackCloud.cs index 5dd5b0965f..29ad9f3c6b 100644 --- a/Projectiles/Rogue/PlaguedFuelPackCloud.cs +++ b/Projectiles/Rogue/PlaguedFuelPackCloud.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class PlaguedFuelPackCloud : ModProjectile + public class PlaguedFuelPackCloud : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Rogue/PlaguenadeBee.cs b/Projectiles/Rogue/PlaguenadeBee.cs index 6436ca5e4a..c13f84ec0c 100644 --- a/Projectiles/Rogue/PlaguenadeBee.cs +++ b/Projectiles/Rogue/PlaguenadeBee.cs @@ -6,160 +6,160 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class PlaguenadeBee : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Plague Bee"); - Main.projFrames[projectile.type] = 4; - } + public class PlaguenadeBee : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plague Bee"); + Main.projFrames[projectile.type] = 4; + } - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.friendly = true; - projectile.penetrate = 2; - projectile.timeLeft = 240; - projectile.ignoreWater = true; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.friendly = true; + projectile.penetrate = 2; + projectile.timeLeft = 240; + projectile.ignoreWater = true; + projectile.Calamity().rogue = true; + } - public override void AI() - { - if (projectile.owner != Main.myPlayer) - projectile.Kill(); + public override void AI() + { + if (projectile.owner != Main.myPlayer) + projectile.Kill(); projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); projectile.rotation += projectile.spriteDirection * MathHelper.ToRadians(45f); - projectile.frameCounter++; - if (projectile.frameCounter >= 3) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } + projectile.frameCounter++; + if (projectile.frameCounter >= 3) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } - Vector2 center = projectile.Center; - float maxDistance = 800f; - bool homeIn = false; - projectile.ai[0] += 1f; - if (projectile.ai[0] > 30f) - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - if (npc.CanBeChasedBy(projectile, false) && !npc.wet) - { - float extraDistance = (npc.width / 2) + (npc.height / 2); + Vector2 center = projectile.Center; + float maxDistance = 800f; + bool homeIn = false; + projectile.ai[0] += 1f; + if (projectile.ai[0] > 30f) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy(projectile, false) && !npc.wet) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); - bool canHit = true; - if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) - { - center = npc.Center; - homeIn = true; - break; - } - } - } - } - if (!homeIn) - { - center.X = projectile.Center.X + projectile.velocity.X * 100f; - center.Y = projectile.Center.Y + projectile.velocity.Y * 100f; - } - float speed = 10f; - float velocityTweak = 0.14f; - Vector2 projPos = projectile.Center; - Vector2 velocity = center - projPos; - float targetDist = velocity.Length(); - targetDist = speed / targetDist; - velocity.X *= targetDist; - velocity.Y *= targetDist; - if (projectile.velocity.X < velocity.X) - { - projectile.velocity.X += velocityTweak; - if (projectile.velocity.X < 0f && velocity.X > 0f) - { - projectile.velocity.X += velocityTweak * 2f; - } - } - else if (projectile.velocity.X > velocity.X) - { - projectile.velocity.X -= velocityTweak; - if (projectile.velocity.X > 0f && velocity.X < 0f) - { - projectile.velocity.X -= velocityTweak * 2f; - } - } - if (projectile.velocity.Y < velocity.Y) - { - projectile.velocity.Y += velocityTweak; - if (projectile.velocity.Y < 0f && velocity.Y > 0f) - { - projectile.velocity.Y += velocityTweak * 2f; - } - } - else if (projectile.velocity.Y > velocity.Y) - { - projectile.velocity.Y -= velocityTweak; - if (projectile.velocity.Y > 0f && velocity.Y < 0f) - { - projectile.velocity.Y -= velocityTweak * 2f; - } - } - } + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + { + center = npc.Center; + homeIn = true; + break; + } + } + } + } + if (!homeIn) + { + center.X = projectile.Center.X + projectile.velocity.X * 100f; + center.Y = projectile.Center.Y + projectile.velocity.Y * 100f; + } + float speed = 10f; + float velocityTweak = 0.14f; + Vector2 projPos = projectile.Center; + Vector2 velocity = center - projPos; + float targetDist = velocity.Length(); + targetDist = speed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; + if (projectile.velocity.X < velocity.X) + { + projectile.velocity.X += velocityTweak; + if (projectile.velocity.X < 0f && velocity.X > 0f) + { + projectile.velocity.X += velocityTweak * 2f; + } + } + else if (projectile.velocity.X > velocity.X) + { + projectile.velocity.X -= velocityTweak; + if (projectile.velocity.X > 0f && velocity.X < 0f) + { + projectile.velocity.X -= velocityTweak * 2f; + } + } + if (projectile.velocity.Y < velocity.Y) + { + projectile.velocity.Y += velocityTweak; + if (projectile.velocity.Y < 0f && velocity.Y > 0f) + { + projectile.velocity.Y += velocityTweak * 2f; + } + } + else if (projectile.velocity.Y > velocity.Y) + { + projectile.velocity.Y -= velocityTweak; + if (projectile.velocity.Y > 0f && velocity.Y < 0f) + { + projectile.velocity.Y -= velocityTweak * 2f; + } + } + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.velocity.X != oldVelocity.X) - { - projectile.velocity.X = -oldVelocity.X; - } - if (projectile.velocity.Y != oldVelocity.Y) - { - projectile.velocity.Y = -oldVelocity.Y; - } - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y; + } + return false; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int frameHeight = texture.Height / Main.projFrames[projectile.type]; - int drawStart = frameHeight * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)frameHeight / 2f), projectile.scale, spriteEffects, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int frameHeight = texture.Height / Main.projFrames[projectile.type]; + int drawStart = frameHeight * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)frameHeight / 2f), projectile.scale, spriteEffects, 0f); + return false; + } - public override void Kill(int timeLeft) - { - for (int i = 0; i < 2; i++) - { - int plague = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, projectile.velocity.X, projectile.velocity.Y, 50, default, 1f); - Main.dust[plague].noGravity = true; - } - } + public override void Kill(int timeLeft) + { + for (int i = 0; i < 2; i++) + { + int plague = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, projectile.velocity.X, projectile.velocity.Y, 50, default, 1f); + Main.dust[plague].noGravity = true; + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } + } } diff --git a/Projectiles/Rogue/PlaguenadeProj.cs b/Projectiles/Rogue/PlaguenadeProj.cs index 149c3c2701..d5844af734 100644 --- a/Projectiles/Rogue/PlaguenadeProj.cs +++ b/Projectiles/Rogue/PlaguenadeProj.cs @@ -74,46 +74,46 @@ namespace CalamityMod.Projectiles.Rogue { if (projectile.owner == Main.myPlayer) { - Player player = Main.player[projectile.owner]; - int projAmt = projectile.Calamity().stealthStrike ? 28 : 20; + Player player = Main.player[projectile.owner]; + int projAmt = projectile.Calamity().stealthStrike ? 28 : 20; for (int projIndex = 0; projIndex < projAmt; projIndex++) { float speedX = (float)Main.rand.Next(-35, 36) * 0.02f; float speedY = (float)Main.rand.Next(-35, 36) * 0.02f; Projectile.NewProjectile(projectile.position.X, projectile.position.Y, speedX, speedY, ModContent.ProjectileType(), player.beeDamage(projectile.damage), player.beeKB(0f), projectile.owner, 0f, 0f); } - Main.PlaySound(SoundID.Item14, projectile.position); - if (projectile.Calamity().stealthStrike) - { - projectile.position = projectile.Center; - projectile.width = projectile.height = 75; - } - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); - for (int i = 0; i < 10; i++) - { - int smoke = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[smoke].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[smoke].scale = 0.5f; - Main.dust[smoke].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 15; j++) - { - int plague = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 3f); - Main.dust[plague].noGravity = true; - Main.dust[plague].velocity *= 5f; - int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); - Main.dust[fire].velocity *= 2f; - } - CalamityUtils.ExplosionGores(projectile.Center, 3); + Main.PlaySound(SoundID.Item14, projectile.position); + if (projectile.Calamity().stealthStrike) + { + projectile.position = projectile.Center; + projectile.width = projectile.height = 75; + } + projectile.position.X = projectile.position.X - (float)(projectile.width / 2); + projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + for (int i = 0; i < 10; i++) + { + int smoke = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[smoke].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[smoke].scale = 0.5f; + Main.dust[smoke].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int j = 0; j < 15; j++) + { + int plague = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 3f); + Main.dust[plague].noGravity = true; + Main.dust[plague].velocity *= 5f; + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); + Main.dust[fire].velocity *= 2f; + } + CalamityUtils.ExplosionGores(projectile.Center, 3); } } diff --git a/Projectiles/Rogue/PoisonBol.cs b/Projectiles/Rogue/PoisonBol.cs index 31bb6eb1f3..f77b06b409 100644 --- a/Projectiles/Rogue/PoisonBol.cs +++ b/Projectiles/Rogue/PoisonBol.cs @@ -23,9 +23,9 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = 5; projectile.timeLeft = 1200; projectile.Calamity().rogue = true; - projectile.aiStyle = 14; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 45; + projectile.aiStyle = 14; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 45; } public override void AI() @@ -33,47 +33,47 @@ namespace CalamityMod.Projectiles.Rogue if (Main.rand.NextBool(20)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 44, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } + } - if (projectile.timeLeft < 20) - projectile.alpha += 13; - if (projectile.Calamity().stealthStrike) - { - projectile.localAI[1]++; - if (projectile.localAI[1] % 35f == 0f) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 20f); - if (Main.rand.NextBool(3)) - velocity *= 2f; - velocity += projectile.velocity * 0.25f; - velocity *= 0.8f; - int proj = Projectile.NewProjectile(projectile.Center - velocity, velocity, Main.rand.Next(569,572), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].Calamity().forceRogue = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 45; - } - } + if (projectile.timeLeft < 20) + projectile.alpha += 13; + if (projectile.Calamity().stealthStrike) + { + projectile.localAI[1]++; + if (projectile.localAI[1] % 35f == 0f) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 20f); + if (Main.rand.NextBool(3)) + velocity *= 2f; + velocity += projectile.velocity * 0.25f; + velocity *= 0.8f; + int proj = Projectile.NewProjectile(projectile.Center - velocity, velocity, Main.rand.Next(569,572), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceRogue = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 45; + } + } } Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.killSpikyBalls) - { - projectile.active = false; - projectile.netUpdate = true; - } - } + if (modPlayer.killSpikyBalls) + { + projectile.active = false; + projectile.netUpdate = true; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(BuffID.Poisoned, 240); + target.AddBuff(BuffID.Poisoned, 240); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(BuffID.Poisoned, 240); + target.AddBuff(BuffID.Poisoned, 240); } } } diff --git a/Projectiles/Rogue/PrismRocket.cs b/Projectiles/Rogue/PrismRocket.cs index 25e8598ab3..6c6e4e339b 100644 --- a/Projectiles/Rogue/PrismRocket.cs +++ b/Projectiles/Rogue/PrismRocket.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class PrismRocket : ModProjectile + public class PrismRocket : ModProjectile { public float ExponentialAccelerationFactor => projectile.Calamity().stealthStrike ? 1.027f : 1.015f; public float MaxHomingSpeed => projectile.Calamity().stealthStrike ? 26f : 21f; @@ -32,17 +32,17 @@ namespace CalamityMod.Projectiles.Rogue } public override void AI() - { + { NPC potentialTarget = projectile.Center.ClosestNPCAt(800f, true); if (potentialTarget != null) AttackTarget(potentialTarget); projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; EmitDust(); - } + } public void AttackTarget(NPC target) - { + { float newSpeed = projectile.velocity.Length() * ExponentialAccelerationFactor; if (newSpeed > MaxHomingSpeed) newSpeed = MaxHomingSpeed; @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity = (projectile.velocity * 5f + projectile.SafeDirectionTo(target.Center) * newSpeed) / 6f; projectile.velocity = projectile.velocity.ToRotation().AngleTowards(projectile.AngleTo(target.Center), 0.15f).ToRotationVector2() * newSpeed; } - } + } public void EmitDust() { @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Rogue return; for (int i = 0; i < 2; i++) - { + { if (!Main.rand.NextBool(3)) continue; @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Rogue dust.velocity = Main.rand.NextVector2Unit(); dust.scale = Main.rand.NextFloat(0.75f, 1.05f); dust.noGravity = true; - } + } } } } diff --git a/Projectiles/Rogue/PrismShurikenBlade.cs b/Projectiles/Rogue/PrismShurikenBlade.cs index 7ac5b498b5..ed08abf2ec 100644 --- a/Projectiles/Rogue/PrismShurikenBlade.cs +++ b/Projectiles/Rogue/PrismShurikenBlade.cs @@ -6,49 +6,49 @@ using Terraria.ID; namespace CalamityMod.Projectiles.Rogue { - public class PrismShurikenBlade : ModProjectile + public class PrismShurikenBlade : ModProjectile { - public override void SetStaticDefaults() => DisplayName.SetDefault("Blade"); + public override void SetStaticDefaults() => DisplayName.SetDefault("Blade"); - public override void SetDefaults() + public override void SetDefaults() { projectile.width = projectile.height = 22; projectile.friendly = true; projectile.ignoreWater = true; projectile.Calamity().rogue = true; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; projectile.timeLeft = projectile.MaxUpdates * 300; } public override void AI() - { - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 850f, 19f, 30f); - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - } + { + CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 850f, 19f, 30f); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } - public override void Kill(int timeLeft) - { - if (Main.dedServ) - return; + public override void Kill(int timeLeft) + { + if (Main.dedServ) + return; - for (int i = 0; i < 15; i++) - { - Vector2 circularOffsetDirection = (MathHelper.TwoPi * i / 15f).ToRotationVector2().RotatedBy(projectile.velocity.ToRotation() - MathHelper.PiOver2); - Vector2 spawnPosition = projectile.Center - (projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * projectile.height * 1.25f; - spawnPosition += circularOffsetDirection * new Vector2(12f, 7f); + for (int i = 0; i < 15; i++) + { + Vector2 circularOffsetDirection = (MathHelper.TwoPi * i / 15f).ToRotationVector2().RotatedBy(projectile.velocity.ToRotation() - MathHelper.PiOver2); + Vector2 spawnPosition = projectile.Center - (projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * projectile.height * 1.25f; + spawnPosition += circularOffsetDirection * new Vector2(12f, 7f); - Dust energy = Dust.NewDustPerfect(spawnPosition, 261); - energy.velocity = circularOffsetDirection * new Vector2(3f, 2f); - energy.color = Color.Cyan; - energy.scale = 0.7f; - energy.noGravity = true; - } - } + Dust energy = Dust.NewDustPerfect(spawnPosition, 261); + energy.velocity = circularOffsetDirection * new Vector2(3f, 2f); + energy.color = Color.Cyan; + energy.scale = 0.7f; + energy.noGravity = true; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); - return false; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; } } } diff --git a/Projectiles/Rogue/Prismalline2.cs b/Projectiles/Rogue/Prismalline2.cs index d08f6041e0..73e3fa99ba 100644 --- a/Projectiles/Rogue/Prismalline2.cs +++ b/Projectiles/Rogue/Prismalline2.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class Prismalline2 : ModProjectile + public class Prismalline2 : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Prismalline"; @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 113; projectile.timeLeft = 60; aiType = ProjectileID.BoneJavelin; diff --git a/Projectiles/Rogue/Prismalline3.cs b/Projectiles/Rogue/Prismalline3.cs index b98b91e106..cb326fd890 100644 --- a/Projectiles/Rogue/Prismalline3.cs +++ b/Projectiles/Rogue/Prismalline3.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; using CalamityMod.Projectiles.Ranged; namespace CalamityMod.Projectiles.Rogue { - public class Prismalline3 : ModProjectile + public class Prismalline3 : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Prismalline"; @@ -19,20 +19,20 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 180; projectile.Calamity().rogue = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 20f); + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -48,20 +48,20 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 154, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } - if (projectile.ai[0] == 1f) - { - int shardCount = Main.rand.Next(1,4); - for (int s = 0; s < shardCount; s++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner); - if (shard.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[shard].Calamity().forceRogue = true; - Main.projectile[shard].penetrate = 1; - } - } - } + if (projectile.ai[0] == 1f) + { + int shardCount = Main.rand.Next(1,4); + for (int s = 0; s < shardCount; s++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner); + if (shard.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[shard].Calamity().forceRogue = true; + Main.projectile[shard].penetrate = 1; + } + } + } } } } diff --git a/Projectiles/Rogue/PrismallineProj.cs b/Projectiles/Rogue/PrismallineProj.cs index 90da209a37..f00a522091 100644 --- a/Projectiles/Rogue/PrismallineProj.cs +++ b/Projectiles/Rogue/PrismallineProj.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class PrismallineProj : ModProjectile + public class PrismallineProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Prismalline"; @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 2; + projectile.ignoreWater = true; + projectile.penetrate = 2; projectile.aiStyle = 113; projectile.timeLeft = 180; aiType = ProjectileID.BoneJavelin; @@ -42,42 +42,42 @@ namespace CalamityMod.Projectiles.Rogue float rotation = MathHelper.ToRadians(50); if (projectile.owner == Main.myPlayer) { - if (!projectile.Calamity().stealthStrike) - { - for (int i = 0; i < numProj + 1; i++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f, 0.2f); - if (numSpecProj < 2 && !hitEnemy) - { - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 1.1), projectile.knockBack, projectile.owner, 0f, 0f); - ++numSpecProj; - } - else - { - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); - } - } - } - else //stealth strike - { - int shardCount = Main.rand.Next(2,5); - for (int num252 = 0; num252 < shardCount; num252++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); - if (shard.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[shard].Calamity().forceRogue = true; - Main.projectile[shard].usesLocalNPCImmunity = true; - Main.projectile[shard].localNPCHitCooldown = 10; - } - } - for (int i = 0; i < numProj + 1; i++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f, 0.2f); - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 1.15), projectile.knockBack, projectile.owner, 1f, 0f); - } - } + if (!projectile.Calamity().stealthStrike) + { + for (int i = 0; i < numProj + 1; i++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f, 0.2f); + if (numSpecProj < 2 && !hitEnemy) + { + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 1.1), projectile.knockBack, projectile.owner, 0f, 0f); + ++numSpecProj; + } + else + { + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); + } + } + } + else //stealth strike + { + int shardCount = Main.rand.Next(2,5); + for (int num252 = 0; num252 < shardCount; num252++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); + if (shard.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[shard].Calamity().forceRogue = true; + Main.projectile[shard].usesLocalNPCImmunity = true; + Main.projectile[shard].localNPCHitCooldown = 10; + } + } + for (int i = 0; i < numProj + 1; i++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f, 0.2f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 1.15), projectile.knockBack, projectile.owner, 1f, 0f); + } + } } } } @@ -90,40 +90,40 @@ namespace CalamityMod.Projectiles.Rogue } public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item27, projectile.position); - for (int k = 0; k < 5; k++) + { + Main.PlaySound(SoundID.Item27, projectile.position); + for (int k = 0; k < 5; k++) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 154, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } - if (projectile.Calamity().stealthStrike) - { - int shardCount = Main.rand.Next(1,4); - for (int s = 0; s < shardCount; s++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); - if (shard.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[shard].Calamity().forceRogue = true; - Main.projectile[shard].penetrate = 1; - } - } - } + if (projectile.Calamity().stealthStrike) + { + int shardCount = Main.rand.Next(1,4); + for (int s = 0; s < shardCount; s++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); + if (shard.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[shard].Calamity().forceRogue = true; + Main.projectile[shard].penetrate = 1; + } + } + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { hitEnemy = true; - if (projectile.Calamity().stealthStrike) - target.AddBuff(ModContent.BuffType(), 30); + if (projectile.Calamity().stealthStrike) + target.AddBuff(ModContent.BuffType(), 30); } public override void OnHitPvp(Player target, int damage, bool crit) { hitEnemy = true; - if (projectile.Calamity().stealthStrike) - target.AddBuff(ModContent.BuffType(), 30); + if (projectile.Calamity().stealthStrike) + target.AddBuff(ModContent.BuffType(), 30); } } } diff --git a/Projectiles/Rogue/ProfanedPartisanSpear.cs b/Projectiles/Rogue/ProfanedPartisanSpear.cs index 461b48f047..6c9d6d0812 100644 --- a/Projectiles/Rogue/ProfanedPartisanSpear.cs +++ b/Projectiles/Rogue/ProfanedPartisanSpear.cs @@ -6,14 +6,14 @@ using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Rogue { - public class ProfanedPartisanSpear : ModProjectile + public class ProfanedPartisanSpear : ModProjectile { - public int timer = 0; + public int timer = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Profaned Spear"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Profaned Spear"); + } public override void SetDefaults() { @@ -31,64 +31,64 @@ namespace CalamityMod.Projectiles.Rogue public override bool OnTileCollide(Vector2 oldVelocity) { - if (projectile.ai[1] != 1f) - { - if (projectile.velocity.X != oldVelocity.X) - { - projectile.velocity.X = -oldVelocity.X; - } - if (projectile.velocity.Y != oldVelocity.Y) - { - projectile.velocity.Y = -oldVelocity.Y; - } - projectile.ai[1] = 1f; - projectile.ai[0] = 1f; - projectile.extraUpdates = 2; - if (projectile.timeLeft > 280) - projectile.timeLeft = 280; - } + if (projectile.ai[1] != 1f) + { + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y; + } + projectile.ai[1] = 1f; + projectile.ai[0] = 1f; + projectile.extraUpdates = 2; + if (projectile.timeLeft > 280) + projectile.timeLeft = 280; + } return false; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 180); - OnHitEffects(); + OnHitEffects(); } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 180); - OnHitEffects(); + OnHitEffects(); } - private void OnHitEffects() - { - if (projectile.ai[1] != 1f) - { - projectile.velocity.X *= -1f; - projectile.velocity.Y *= -1f; - projectile.ai[1] = 1f; - projectile.ai[0] = 1f; - projectile.extraUpdates = 2; - if (projectile.timeLeft > 280) - projectile.timeLeft = 280; - } - } + private void OnHitEffects() + { + if (projectile.ai[1] != 1f) + { + projectile.velocity.X *= -1f; + projectile.velocity.Y *= -1f; + projectile.ai[1] = 1f; + projectile.ai[0] = 1f; + projectile.extraUpdates = 2; + if (projectile.timeLeft > 280) + projectile.timeLeft = 280; + } + } public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (projectile.ai[0] == 1f) - timer++; - if (timer >= 5) - projectile.penetrate = 1; - if (timer >= 10) - { - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 7f, 20f); - } - } + if (projectile.ai[0] == 1f) + timer++; + if (timer >= 5) + projectile.penetrate = 1; + if (timer >= 10) + { + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 300f, 7f, 20f); + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Rogue/RadiantExplosion.cs b/Projectiles/Rogue/RadiantExplosion.cs index 18c04f5bb6..f455306aaf 100644 --- a/Projectiles/Rogue/RadiantExplosion.cs +++ b/Projectiles/Rogue/RadiantExplosion.cs @@ -58,70 +58,70 @@ namespace CalamityMod.Projectiles.Rogue } } - if (projectile.Calamity().stealthStrike) - { - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - for (int num475 = 0; num475 < Main.maxNPCs; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) - { - float npcCenterX = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float npcCenterY = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - npcCenterX) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - npcCenterY); - if (num478 < num474) - { - if (Main.npc[num475].position.X < num472) - { - Main.npc[num475].velocity.X += 0.25f; - } - else - { - Main.npc[num475].velocity.X -= 0.25f; - } - if (Main.npc[num475].position.Y < num473) - { - Main.npc[num475].velocity.Y += 0.25f; - } - else - { - Main.npc[num475].velocity.Y -= 0.25f; - } - } - } - } - } + if (projectile.Calamity().stealthStrike) + { + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float num474 = 600f; + for (int num475 = 0; num475 < Main.maxNPCs; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) + { + float npcCenterX = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); + float npcCenterY = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); + float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - npcCenterX) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - npcCenterY); + if (num478 < num474) + { + if (Main.npc[num475].position.X < num472) + { + Main.npc[num475].velocity.X += 0.25f; + } + else + { + Main.npc[num475].velocity.X -= 0.25f; + } + if (Main.npc[num475].position.Y < num473) + { + Main.npc[num475].velocity.Y += 0.25f; + } + else + { + Main.npc[num475].velocity.Y -= 0.25f; + } + } + } + } + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - OnHitEffect(target.Center); - } + OnHitEffect(target.Center); + } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - OnHitEffect(target.Center); + OnHitEffect(target.Center); } - private void OnHitEffect(Vector2 targetPos) - { + private void OnHitEffect(Vector2 targetPos) + { for (int n = 0; n < 3; n++) { - int projType = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), - ProjectileID.HallowStar, - ModContent.ProjectileType() - }); - Projectile star = CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 25f, projType, (int)(projectile.damage * 0.75), 5f, projectile.owner); - if (star.whoAmI.WithinBounds(Main.maxProjectiles)) - { - star.Calamity().forceRogue = true; - star.ai[0] = 2f; - } + int projType = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ProjectileID.HallowStar, + ModContent.ProjectileType() + }); + Projectile star = CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 25f, projType, (int)(projectile.damage * 0.75), 5f, projectile.owner); + if (star.whoAmI.WithinBounds(Main.maxProjectiles)) + { + star.Calamity().forceRogue = true; + star.ai[0] = 2f; + } } } } diff --git a/Projectiles/Rogue/RadiantStar2.cs b/Projectiles/Rogue/RadiantStar2.cs index 427d04dfd6..c6b31572e1 100644 --- a/Projectiles/Rogue/RadiantStar2.cs +++ b/Projectiles/Rogue/RadiantStar2.cs @@ -26,15 +26,15 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 24; projectile.height = 24; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 300; projectile.Calamity().rogue = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 270 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); if (projectile.ai[0] == 1f) @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Rogue } } else if (projectile.timeLeft < 270) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, projectile.Calamity().stealthStrike ? 900f : 450f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, projectile.Calamity().stealthStrike ? 900f : 450f, 12f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Rogue/RadiantStarKnife.cs b/Projectiles/Rogue/RadiantStarKnife.cs index 9bc04e7e11..7b5f4ae3f2 100644 --- a/Projectiles/Rogue/RadiantStarKnife.cs +++ b/Projectiles/Rogue/RadiantStarKnife.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 24; projectile.height = 24; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 4; + projectile.ignoreWater = true; + projectile.penetrate = 4; projectile.timeLeft = 300; projectile.Calamity().rogue = true; } @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Rogue float homingSpeed = 0.25f; for (int num475 = 0; num475 < Main.npc.Length; num475++) { - NPC npc = Main.npc[num475]; + NPC npc = Main.npc[num475]; if (npc.CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1) && !npc.boss) { float num476 = npc.position.X + (float)(npc.width / 2); @@ -92,13 +92,13 @@ namespace CalamityMod.Projectiles.Rogue } Main.PlaySound(SoundID.Item14, projectile.position); int boomer = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.75f), projectile.knockBack, projectile.owner); - if (projectile.Calamity().stealthStrike && boomer.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[boomer].Calamity().stealthStrike = true; - Main.projectile[boomer].height = 300; - Main.projectile[boomer].width = 300; - } - Main.projectile[boomer].Center = projectile.Center; + if (projectile.Calamity().stealthStrike && boomer.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[boomer].Calamity().stealthStrike = true; + Main.projectile[boomer].height = 300; + Main.projectile[boomer].width = 300; + } + Main.projectile[boomer].Center = projectile.Center; projectile.active = false; } } diff --git a/Projectiles/Rogue/ReaperProjectile.cs b/Projectiles/Rogue/ReaperProjectile.cs index bb929d8735..b9db841d80 100644 --- a/Projectiles/Rogue/ReaperProjectile.cs +++ b/Projectiles/Rogue/ReaperProjectile.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 70; projectile.friendly = true; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.extraUpdates = 3; projectile.timeLeft = projectile.MaxUpdates * 90; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Rogue/RefractionRotorProjectile.cs b/Projectiles/Rogue/RefractionRotorProjectile.cs index 54eba6c84e..c4390ac034 100644 --- a/Projectiles/Rogue/RefractionRotorProjectile.cs +++ b/Projectiles/Rogue/RefractionRotorProjectile.cs @@ -41,18 +41,18 @@ namespace CalamityMod.Projectiles.Rogue public override bool CanDamage() => projectile.alpha <= 128; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { if (projectile.timeLeft > 20) projectile.timeLeft = 20; - } + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { // Release a puff of rainbow dust and some blades. // If this projectile is a stealth strike, don't create the blades as a gore-- create them as a projectile instead. if (!Main.dedServ) - { + { for (int i = 0; i < 15; i++) { Dust rainbowBurst = Dust.NewDustPerfect(projectile.Center, 267); @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Rogue Gore.NewGorePerfect(spawnPosition, projectile.velocity * 0.5f + shootDirection * 7f, goreType, projectile.scale); } } - } + } int shootType = ModContent.ProjectileType(); if (Main.myPlayer != projectile.owner) @@ -103,14 +103,14 @@ namespace CalamityMod.Projectiles.Rogue Vector2 shootVelocity = (MathHelper.TwoPi * i / EnergyShotCount + baseDirectionRotation).ToRotationVector2() * 9f; Projectile.NewProjectile(projectile.Center + shootVelocity, shootVelocity, shootType, energyDamage, projectile.knockBack, projectile.owner); } - } + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { Texture2D glowmask = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/RefractionRotorGlowmask"); Vector2 drawPosition = projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY; Vector2 origin = glowmask.Size() * 0.5f; spriteBatch.Draw(glowmask, drawPosition, null, projectile.GetAlpha(Color.White), projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); } - } + } } diff --git a/Projectiles/Rogue/RegulusEnergy.cs b/Projectiles/Rogue/RegulusEnergy.cs index 63af8ba324..d3ab22ae4a 100644 --- a/Projectiles/Rogue/RegulusEnergy.cs +++ b/Projectiles/Rogue/RegulusEnergy.cs @@ -6,7 +6,7 @@ using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Rogue { - public class RegulusEnergy : ModProjectile + public class RegulusEnergy : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -19,11 +19,11 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = 8; projectile.height = 8; - projectile.ignoreWater = true; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.penetrate = 1; projectile.tileCollide = false; - projectile.Calamity().rogue = true; + projectile.Calamity().rogue = true; } public override void AI() @@ -54,30 +54,30 @@ namespace CalamityMod.Projectiles.Rogue { projectile.extraUpdates = 1; - Vector2 center = projectile.Center; - float maxDistance = 500f; - bool homeIn = false; + Vector2 center = projectile.Center; + float maxDistance = 500f; + 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) + (float)(Main.npc[i].height / 2); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) - { - center = Main.npc[i].Center; - homeIn = true; - break; - } - } - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + { + center = Main.npc[i].Center; + homeIn = true; + break; + } + } + } - if (homeIn) + if (homeIn) { Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); projectile.velocity = (projectile.velocity * 20f + moveDirection * 12f) / (21f); - } + } else projectile.Kill(); } diff --git a/Projectiles/Rogue/RegulusRiotProj.cs b/Projectiles/Rogue/RegulusRiotProj.cs index 01ed9fc1b6..155ed117a4 100644 --- a/Projectiles/Rogue/RegulusRiotProj.cs +++ b/Projectiles/Rogue/RegulusRiotProj.cs @@ -47,10 +47,10 @@ namespace CalamityMod.Projectiles.Rogue } int blueDust = Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType(), 0f, 0f, 100); - Main.dust[blueDust].noGravity = true; + Main.dust[blueDust].noGravity = true; Main.dust[blueDust].velocity = Vector2.Zero; int orangeDust = Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType(), 0f, 0f, 100); - Main.dust[orangeDust].noGravity = true; + Main.dust[orangeDust].noGravity = true; Main.dust[orangeDust].velocity = Vector2.Zero; projectile.ai[0] += 1f; @@ -65,7 +65,7 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.ai[0] >= 30f) { - projectile.extraUpdates = 2; + projectile.extraUpdates = 2; projectile.velocity *= 0.98f; projectile.rotation -= 0.0174532924f; } @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.Normalize(); projectile.velocity *= 4f; projectile.ai[0] = 0f; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } } else if (behaviorInt == 1) @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Rogue { for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { - NPC npc = Main.npc[npcIndex]; + NPC npc = Main.npc[npcIndex]; if (npc.CanBeChasedBy(projectile, false)) { Vector2 npcCenter = npc.Center; @@ -98,7 +98,7 @@ namespace CalamityMod.Projectiles.Rogue targetCenter = npcCenter; homeIn = true; targetIndex = npcIndex; - break; + break; } } } @@ -115,7 +115,7 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.ai[1] != 0f) { int npcIndex2 = (int)(projectile.ai[1] - 1f); - NPC npc2 = Main.npc[npcIndex2]; + NPC npc2 = Main.npc[npcIndex2]; if (npc2.active && npc2.CanBeChasedBy(projectile, true) && projectile.Distance(npc2.Center) < 1000f) { homeIn = true; @@ -178,8 +178,8 @@ namespace CalamityMod.Projectiles.Rogue Main.dust[orangeDust].noGravity = true; Main.dust[orangeDust].velocity = Vector2.Zero; } - if (projectile.Calamity().stealthStrike) - { + if (projectile.Calamity().stealthStrike) + { if (projectile.owner == Main.myPlayer) { float spread = 60f * 0.0174f; @@ -193,7 +193,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 2f), (float)(-Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)(projectile.damage * 0.4), projectile.knockBack, projectile.owner, 0f, 0f); } } - } + } } } } diff --git a/Projectiles/Rogue/RotBallProjectile.cs b/Projectiles/Rogue/RotBallProjectile.cs index b167091dd8..504554f809 100644 --- a/Projectiles/Rogue/RotBallProjectile.cs +++ b/Projectiles/Rogue/RotBallProjectile.cs @@ -45,10 +45,10 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) - { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, -10f, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner, 0f, 0f); - } + if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) + { + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, -10f, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner, 0f, 0f); + } } } } diff --git a/Projectiles/Rogue/SandDollarStealth.cs b/Projectiles/Rogue/SandDollarStealth.cs index 98e134d66f..36d7019211 100644 --- a/Projectiles/Rogue/SandDollarStealth.cs +++ b/Projectiles/Rogue/SandDollarStealth.cs @@ -24,33 +24,33 @@ namespace CalamityMod.Projectiles.Rogue projectile.aiStyle = 3; projectile.timeLeft = 300; aiType = ProjectileID.Bananarang; - projectile.usesLocalNPCImmunity = true; + projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(); - } + OnHitEffects(); + } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(); - } + OnHitEffects(); + } - private void OnHitEffects() - { - int coralAmt = Main.rand.Next(1, 4); - if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) - { - for (int coralCount = 0; coralCount < coralAmt; coralCount++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int coral = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner); - if (coral.WithinBounds(Main.maxProjectiles)) - Main.projectile[coral].Calamity().forceRogue = true; - } - } + private void OnHitEffects() + { + int coralAmt = Main.rand.Next(1, 4); + if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) + { + for (int coralCount = 0; coralCount < coralAmt; coralCount++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int coral = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner); + if (coral.WithinBounds(Main.maxProjectiles)) + Main.projectile[coral].Calamity().forceRogue = true; + } + } } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Rogue/SandslasherProj.cs b/Projectiles/Rogue/SandslasherProj.cs index 4869517c5f..a1047a5066 100644 --- a/Projectiles/Rogue/SandslasherProj.cs +++ b/Projectiles/Rogue/SandslasherProj.cs @@ -6,49 +6,49 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SandslasherProj : ModProjectile + public class SandslasherProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Sandslasher"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Sandslasher"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sandslasher"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + } public override void SetDefaults() { projectile.width = 40; projectile.height = 40; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 3; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 16; + projectile.ignoreWater = true; + projectile.penetrate = 3; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 16; projectile.Calamity().rogue = true; - projectile.timeLeft = 600; - } + projectile.timeLeft = 600; + } public override void AI() { - projectile.ai[0] += 1f; + projectile.ai[0] += 1f; projectile.ai[1] += 1f; - if (projectile.ai[0] == 3f) - projectile.tileCollide = true; - if(projectile.velocity.X < 0f) - { - projectile.velocity.X -= 0.07f; - if ((projectile.ai[0] %= 30f) == 0f) - projectile.damage -= (int)(projectile.velocity.X * 2f); - } - else if(projectile.velocity.X > 0f) - { - projectile.velocity.X += 0.07f; - if ((projectile.ai[0] %= 30f) == 0f) - projectile.damage += (int)(projectile.velocity.X * 2f); - } - projectile.rotation += 0.1f * projectile.direction + (projectile.velocity.X /85); + if (projectile.ai[0] == 3f) + projectile.tileCollide = true; + if(projectile.velocity.X < 0f) + { + projectile.velocity.X -= 0.07f; + if ((projectile.ai[0] %= 30f) == 0f) + projectile.damage -= (int)(projectile.velocity.X * 2f); + } + else if(projectile.velocity.X > 0f) + { + projectile.velocity.X += 0.07f; + if ((projectile.ai[0] %= 30f) == 0f) + projectile.damage += (int)(projectile.velocity.X * 2f); + } + projectile.rotation += 0.1f * projectile.direction + (projectile.velocity.X /85); if(projectile.Calamity().stealthStrike && projectile.ai[1] >= 5f) { Vector2 speed = new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f)); @@ -57,12 +57,12 @@ namespace CalamityMod.Projectiles.Rogue } } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { - for (int i = 0; i < 15; i++) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 85, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 0, default, 1f); - } + for (int i = 0; i < 15; i++) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 85, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 0, default, 1f); + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/ScarletDevilBullet.cs b/Projectiles/Rogue/ScarletDevilBullet.cs index dd5420ca52..1394dda647 100644 --- a/Projectiles/Rogue/ScarletDevilBullet.cs +++ b/Projectiles/Rogue/ScarletDevilBullet.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class ScarletDevilBullet : ModProjectile + public class ScarletDevilBullet : ModProjectile { public override void SetStaticDefaults() { @@ -30,30 +30,30 @@ namespace CalamityMod.Projectiles.Rogue } else { - Vector2 center = projectile.Center; - float maxDistance = 1000f; - bool homeIn = false; + Vector2 center = projectile.Center; + 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) + (float)(Main.npc[i].height / 2); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance)) - { - center = Main.npc[i].Center; - homeIn = true; - break; - } - } - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = Main.npc[i].Center; + homeIn = true; + break; + } + } + } - if (homeIn) + if (homeIn) { Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); projectile.velocity = (projectile.velocity * 10f + moveDirection * 30f) / (11f); - } + } else { projectile.velocity.X = 0f; diff --git a/Projectiles/Rogue/ScarletDevilProjectile.cs b/Projectiles/Rogue/ScarletDevilProjectile.cs index 92bb51458e..438966d732 100644 --- a/Projectiles/Rogue/ScarletDevilProjectile.cs +++ b/Projectiles/Rogue/ScarletDevilProjectile.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class ScarletDevilProjectile : ModProjectile + public class ScarletDevilProjectile : ModProjectile { internal PrimitiveTrail TrailDrawer; public ref float ShootTimer => ref projectile.ai[0]; @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 108; projectile.height = 108; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.tileCollide = false; projectile.timeLeft = 300; projectile.extraUpdates = 1; diff --git a/Projectiles/Rogue/ScourgeVenomCloud.cs b/Projectiles/Rogue/ScourgeVenomCloud.cs index 0ea4748165..f3072c440d 100644 --- a/Projectiles/Rogue/ScourgeVenomCloud.cs +++ b/Projectiles/Rogue/ScourgeVenomCloud.cs @@ -38,17 +38,17 @@ namespace CalamityMod.Projectiles.Rogue projectile.frame++; projectile.frameCounter = 0; } - if (projectile.ai[0] < 219f) //255 - frameCounter tick * number of disippation frames - { - if (projectile.frame >= 4) - { - projectile.frame = 0; - } - } - else if (projectile.owner == Main.myPlayer && projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.Kill(); - } + if (projectile.ai[0] < 219f) //255 - frameCounter tick * number of disippation frames + { + if (projectile.frame >= 4) + { + projectile.frame = 0; + } + } + else if (projectile.owner == Main.myPlayer && projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.Kill(); + } projectile.velocity *= 0.98f; if (projectile.alpha > 110) { @@ -69,8 +69,8 @@ namespace CalamityMod.Projectiles.Rogue target.AddBuff(BuffID.Venom, 120); if (projectile.ai[1] == 1f && projectile.owner == Main.myPlayer) //stealth strike attack { - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 120); + } } public override void OnHitPvp(Player target, int damage, bool crit) @@ -78,8 +78,8 @@ namespace CalamityMod.Projectiles.Rogue target.AddBuff(BuffID.Venom, 120); if (projectile.ai[1] == 1f && projectile.owner == Main.myPlayer) //stealth strike attack { - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 120); + } } } } diff --git a/Projectiles/Rogue/ScourgeoftheSeasProjectile.cs b/Projectiles/Rogue/ScourgeoftheSeasProjectile.cs index e9206c982c..c4acefef7e 100644 --- a/Projectiles/Rogue/ScourgeoftheSeasProjectile.cs +++ b/Projectiles/Rogue/ScourgeoftheSeasProjectile.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 26; projectile.height = 26; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.aiStyle = 113; + projectile.ignoreWater = true; + projectile.aiStyle = 113; aiType = ProjectileID.BoneJavelin; projectile.penetrate = 1; projectile.extraUpdates = 1; @@ -42,8 +42,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; projectile.velocity.X *= 1.015f; projectile.velocity.Y *= 1.015f; - projectile.velocity.X = Math.Min(16f, projectile.velocity.X); - projectile.velocity.Y = Math.Min(16f, projectile.velocity.Y); + projectile.velocity.X = Math.Min(16f, projectile.velocity.X); + projectile.velocity.Y = Math.Min(16f, projectile.velocity.Y); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -51,8 +51,8 @@ namespace CalamityMod.Projectiles.Rogue target.AddBuff(BuffID.Venom, 180); if (projectile.Calamity().stealthStrike) //stealth strike attack { - target.AddBuff(ModContent.BuffType(), 180); - } + target.AddBuff(ModContent.BuffType(), 180); + } } public override void OnHitPvp(Player target, int damage, bool crit) @@ -60,8 +60,8 @@ namespace CalamityMod.Projectiles.Rogue target.AddBuff(BuffID.Venom, 180); if (projectile.Calamity().stealthStrike) //stealth strike attack { - target.AddBuff(ModContent.BuffType(), 180); - } + target.AddBuff(ModContent.BuffType(), 180); + } } public override void Kill(int timeLeft) @@ -74,12 +74,12 @@ namespace CalamityMod.Projectiles.Rogue } if (projectile.owner == Main.myPlayer) { - int cloudNumber = Main.rand.Next(2, 6); - for (int cloudIndex = 0; cloudIndex < cloudNumber; cloudIndex++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 1f, projectile.owner, 0f, projectile.Calamity().stealthStrike ? 1f : 0f); - } + int cloudNumber = Main.rand.Next(2, 6); + for (int cloudIndex = 0; cloudIndex < cloudNumber; cloudIndex++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 1f, projectile.owner, 0f, projectile.Calamity().stealthStrike ? 1f : 0f); + } } } diff --git a/Projectiles/Rogue/SeafoamBombProj.cs b/Projectiles/Rogue/SeafoamBombProj.cs index f2b34c0c49..24c28fb284 100644 --- a/Projectiles/Rogue/SeafoamBombProj.cs +++ b/Projectiles/Rogue/SeafoamBombProj.cs @@ -3,7 +3,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SeafoamBombProj : ModProjectile + public class SeafoamBombProj : ModProjectile { public override void SetStaticDefaults() { @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.NewProjectile(posX, posY, 0f, 0f, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.4), 0f, projectile.owner, 0f, 0f); } - CalamityUtils.ExplosionGores(projectile.Center, (projectile.Calamity().stealthStrike ? 6 : 3)); + CalamityUtils.ExplosionGores(projectile.Center, (projectile.Calamity().stealthStrike ? 6 : 3)); } } } diff --git a/Projectiles/Rogue/SealedSingularityBlackhole.cs b/Projectiles/Rogue/SealedSingularityBlackhole.cs index be879c0e2c..c607d5d36a 100644 --- a/Projectiles/Rogue/SealedSingularityBlackhole.cs +++ b/Projectiles/Rogue/SealedSingularityBlackhole.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SealedSingularityBlackhole : ModProjectile + public class SealedSingularityBlackhole : ModProjectile { public override void SetStaticDefaults() { @@ -28,77 +28,77 @@ namespace CalamityMod.Projectiles.Rogue projectile.idStaticNPCHitCooldown = 10; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; + } - public override void AI() - { - // Update animation - if (projectile.timeLeft % 5 == 0) - { - projectile.frame++; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } + public override void AI() + { + // Update animation + if (projectile.timeLeft % 5 == 0) + { + projectile.frame++; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } - //Succcc + //Succcc float projCenX = projectile.Center.X; float projCenY = projectile.Center.Y; - float maxDistance = projectile.Calamity().stealthStrike ? 1000f : 500f; - float succPower = projectile.Calamity().stealthStrike ? 0.25f : 0.1f; - for (int index = 0; index < Main.maxNPCs; index++) - { - NPC npc = Main.npc[index]; - if (npc.CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1)) - { - if (CalamityGlobalNPC.ShouldAffectNPC(npc) || npc.type == ModContent.NPCType()) - { - float extraDistance = (npc.width / 2) + (npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - if (npc.position.X < projCenX) - { - npc.velocity.X += succPower; - } - else - { - npc.velocity.X -= succPower; - } - if (npc.position.Y < projCenY) - { - npc.velocity.Y += succPower; - } - else - { - npc.velocity.Y -= succPower; - } - } - } - } - } + float maxDistance = projectile.Calamity().stealthStrike ? 1000f : 500f; + float succPower = projectile.Calamity().stealthStrike ? 0.25f : 0.1f; + for (int index = 0; index < Main.maxNPCs; index++) + { + NPC npc = Main.npc[index]; + if (npc.CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1)) + { + if (CalamityGlobalNPC.ShouldAffectNPC(npc) || npc.type == ModContent.NPCType()) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + if (npc.position.X < projCenX) + { + npc.velocity.X += succPower; + } + else + { + npc.velocity.X -= succPower; + } + if (npc.position.Y < projCenY) + { + npc.velocity.Y += succPower; + } + else + { + npc.velocity.Y -= succPower; + } + } + } + } + } - projectile.ai[0]++; - if (projectile.ai[0] > 300f) - { - projectile.scale *= 0.95f; - projectile.Opacity *= 0.95f; - projectile.height = (int)(projectile.height * projectile.scale); - projectile.width = (int)(projectile.width * projectile.scale); - } - if (projectile.scale <= 0.05f) - { - projectile.Kill(); - } - } + projectile.ai[0]++; + if (projectile.ai[0] > 300f) + { + projectile.scale *= 0.95f; + projectile.Opacity *= 0.95f; + projectile.height = (int)(projectile.height * projectile.scale); + projectile.width = (int)(projectile.width * projectile.scale); + } + if (projectile.scale <= 0.05f) + { + projectile.Kill(); + } + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.Blackout, 300); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Blackout, 300); + } + } } diff --git a/Projectiles/Rogue/SealedSingularityGore.cs b/Projectiles/Rogue/SealedSingularityGore.cs index d8c74334a6..25641ec174 100644 --- a/Projectiles/Rogue/SealedSingularityGore.cs +++ b/Projectiles/Rogue/SealedSingularityGore.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.friendly = true; projectile.width = projectile.height = 25; projectile.Calamity().rogue = true; - projectile.timeLeft = 300; + projectile.timeLeft = 300; } public override void AI() diff --git a/Projectiles/Rogue/SealedSingularityProj.cs b/Projectiles/Rogue/SealedSingularityProj.cs index 62b3b1bb44..87fb24df73 100644 --- a/Projectiles/Rogue/SealedSingularityProj.cs +++ b/Projectiles/Rogue/SealedSingularityProj.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SealedSingularityProj : ModProjectile + public class SealedSingularityProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/SealedSingularity"; @@ -32,33 +32,33 @@ namespace CalamityMod.Projectiles.Rogue { projectile.velocity *= 0.96f; } - else - { - projectile.rotation += 0.3f * (float)projectile.direction; - } + else + { + projectile.rotation += 0.3f * (float)projectile.direction; + } } - public override void Kill (int timeLeft) - { - if (projectile.owner != Main.myPlayer) - return; + public override void Kill (int timeLeft) + { + if (projectile.owner != Main.myPlayer) + return; - //glass-pot break sound - Main.PlaySound(SoundID.Shatter, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f); + //glass-pot break sound + Main.PlaySound(SoundID.Shatter, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f); int blackhole = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, projectile.Calamity().stealthStrike ? -180f : 0f, 0f); - if (blackhole.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[blackhole].Center = projectile.Center; - Main.projectile[blackhole].Calamity().stealthStrike = projectile.Calamity().stealthStrike; - } + if (blackhole.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[blackhole].Center = projectile.Center; + Main.projectile[blackhole].Calamity().stealthStrike = projectile.Calamity().stealthStrike; + } - for (int index = 0; index < 3; ++index) - { - float SpeedX = -projectile.velocity.X * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f; - float SpeedY = -projectile.velocity.Y * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f; - Projectile.NewProjectile(projectile.Center.X + SpeedX, projectile.Center.Y + SpeedY, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 0f, projectile.owner, index, 0f); - } - } + for (int index = 0; index < 3; ++index) + { + float SpeedX = -projectile.velocity.X * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f; + float SpeedY = -projectile.velocity.Y * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f; + Projectile.NewProjectile(projectile.Center.X + SpeedX, projectile.Center.Y + SpeedY, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 0f, projectile.owner, index, 0f); + } + } } } diff --git a/Projectiles/Rogue/SearedPanProjectile.cs b/Projectiles/Rogue/SearedPanProjectile.cs index 0a5e76f5a2..50cd1c9ba5 100644 --- a/Projectiles/Rogue/SearedPanProjectile.cs +++ b/Projectiles/Rogue/SearedPanProjectile.cs @@ -35,10 +35,10 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; + projectile.ignoreWater = true; projectile.timeLeft = 420; projectile.Calamity().rogue = true; - projectile.extraUpdates = 2; + projectile.extraUpdates = 2; } public override void AI() @@ -54,148 +54,148 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 180); - // Don't increment the Seared Pan counter when hitting dummies + // Don't increment the Seared Pan counter when hitting dummies bool dummy = target.type != NPCID.TargetDummy && target.type != ModContent.NPCType(); - OnHitEffects(target.whoAmI, target.life, dummy); + OnHitEffects(target.whoAmI, target.life, dummy); } public override void OnHitPvp(Player target, int damage, bool crit) { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; target.AddBuff(BuffID.Bleeding, 300); target.AddBuff(ModContent.BuffType(), 180); - OnHitEffects(-1, target.statLife, true); + OnHitEffects(-1, target.statLife, true); } - private void OnHitEffects(int targetIndex, int health, bool specialEffects) - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + private void OnHitEffects(int targetIndex, int health, bool specialEffects) + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); - // Don't spawn fireballs or increment the special effects counter if you can't even stealth strike - bool playerCanStealthStrike = modPlayer.wearingRogueArmor && modPlayer.rogueStealthMax > 0; - if (!playerCanStealthStrike) - return; + // Don't spawn fireballs or increment the special effects counter if you can't even stealth strike + bool playerCanStealthStrike = modPlayer.wearingRogueArmor && modPlayer.rogueStealthMax > 0; + if (!playerCanStealthStrike) + return; - // Increment the seared pan counter. Pans summoned via the Venerated Locket shouldn't increment the counter. - // See CalamityPlayerMiscEffects.cs for code that resets the counter after 40 frames - modPlayer.searedPanTimer = 0; - if (specialEffects && PanType != SearedPanTypes.VenLocket) - modPlayer.searedPanCounter++; + // Increment the seared pan counter. Pans summoned via the Venerated Locket shouldn't increment the counter. + // See CalamityPlayerMiscEffects.cs for code that resets the counter after 40 frames + modPlayer.searedPanTimer = 0; + if (specialEffects && PanType != SearedPanTypes.VenLocket) + modPlayer.searedPanCounter++; - // Pans summoned via the Venerated Locket have zero special effects - if (PanType == SearedPanTypes.StealthStrike) - { - modPlayer.searedPanCounter = 0; - // Stealth strikes spawn four golden sparks on hit - for (int t = 0; t < 4; t++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), 0f, projectile.owner); - } - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/SearedPanSmash"), (int)projectile.position.X, (int)projectile.position.Y); - // Stealth strikes also cause any existing fireballs to home in on their targets - FireballStuff(true); + // Pans summoned via the Venerated Locket have zero special effects + if (PanType == SearedPanTypes.StealthStrike) + { + modPlayer.searedPanCounter = 0; + // Stealth strikes spawn four golden sparks on hit + for (int t = 0; t < 4; t++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), 0f, projectile.owner); + } + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/SearedPanSmash"), (int)projectile.position.X, (int)projectile.position.Y); + // Stealth strikes also cause any existing fireballs to home in on their targets + FireballStuff(true); - if (!specialEffects) - return; - // Stealth strikes then summon five fireballs to circle the hit enemy, they will home in on their own after a second. - for (int t = 0; t < 5; t++) - { - int i = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), 0f, projectile.owner, 0f, targetIndex); - Main.projectile[i].ModProjectile().Timer = 61; - } - FireballPositions(targetIndex); - } - else if (PanType == SearedPanTypes.Golden) - { - modPlayer.searedPanCounter = 0; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/SearedPanSmash"), (int)projectile.position.X, (int)projectile.position.Y); - // Golden pans simply cause all fireballs to home in on their targets - FireballStuff(true); - } - else if (PanType == SearedPanTypes.Normal && targetIndex != -1 && health > 0 && specialEffects) - { - // Summon three fireballs to circle the hit enemy - for (int t = 0; t < 3; t++) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), 0f, projectile.owner, 0f, targetIndex); - } - FireballPositions(targetIndex); - } - } + if (!specialEffects) + return; + // Stealth strikes then summon five fireballs to circle the hit enemy, they will home in on their own after a second. + for (int t = 0; t < 5; t++) + { + int i = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), 0f, projectile.owner, 0f, targetIndex); + Main.projectile[i].ModProjectile().Timer = 61; + } + FireballPositions(targetIndex); + } + else if (PanType == SearedPanTypes.Golden) + { + modPlayer.searedPanCounter = 0; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/SearedPanSmash"), (int)projectile.position.X, (int)projectile.position.Y); + // Golden pans simply cause all fireballs to home in on their targets + FireballStuff(true); + } + else if (PanType == SearedPanTypes.Normal && targetIndex != -1 && health > 0 && specialEffects) + { + // Summon three fireballs to circle the hit enemy + for (int t = 0; t < 3; t++) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), 0f, projectile.owner, 0f, targetIndex); + } + FireballPositions(targetIndex); + } + } - private void FireballStuff(bool activate) - { - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (!Main.projectile[i].active || Main.projectile[i].owner != projectile.owner) - continue; - if (Main.projectile[i].modProjectile is NiceCock) - { - if (!activate) - Main.projectile[i].Kill(); - else - { - Main.projectile[i].ModProjectile().homing = true; - Main.projectile[i].extraUpdates += 2; - } - } - } - } - } + private void FireballStuff(bool activate) + { + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (!Main.projectile[i].active || Main.projectile[i].owner != projectile.owner) + continue; + if (Main.projectile[i].modProjectile is NiceCock) + { + if (!activate) + Main.projectile[i].Kill(); + else + { + Main.projectile[i].ModProjectile().homing = true; + Main.projectile[i].extraUpdates += 2; + } + } + } + } + } - private void FireballPositions(int targetIndex) - { - int fireballCount = 0; - // Count how many fireballs exist already around the given target - for (int i = 0; i < Main.maxProjectiles; i++) - { - // Keep the loop as short as possible - if (!Main.projectile[i].active || Main.projectile[i].owner != projectile.owner || !Main.projectile[i].Calamity().rogue || targetIndex != (int)Main.projectile[i].ai[1]) - continue; - if (Main.projectile[i].modProjectile is NiceCock) - { - if (Main.projectile[i].ModProjectile().homing) - continue; - fireballCount++; - } - } - // Adjust the angle of the existing fireballs around a target - float angleVariance = MathHelper.TwoPi / fireballCount; - float angle = 0f; - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (!Main.projectile[i].active || Main.projectile[i].owner != projectile.owner || !Main.projectile[i].Calamity().rogue || targetIndex != (int)Main.projectile[i].ai[1]) - continue; - if (Main.projectile[i].modProjectile is NiceCock) - { - if (Main.projectile[i].ModProjectile().homing) - continue; - Main.projectile[i].ai[0] = angle; - Main.projectile[i].netUpdate = true; - angle += angleVariance; - } - } - } + private void FireballPositions(int targetIndex) + { + int fireballCount = 0; + // Count how many fireballs exist already around the given target + for (int i = 0; i < Main.maxProjectiles; i++) + { + // Keep the loop as short as possible + if (!Main.projectile[i].active || Main.projectile[i].owner != projectile.owner || !Main.projectile[i].Calamity().rogue || targetIndex != (int)Main.projectile[i].ai[1]) + continue; + if (Main.projectile[i].modProjectile is NiceCock) + { + if (Main.projectile[i].ModProjectile().homing) + continue; + fireballCount++; + } + } + // Adjust the angle of the existing fireballs around a target + float angleVariance = MathHelper.TwoPi / fireballCount; + float angle = 0f; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (!Main.projectile[i].active || Main.projectile[i].owner != projectile.owner || !Main.projectile[i].Calamity().rogue || targetIndex != (int)Main.projectile[i].ai[1]) + continue; + if (Main.projectile[i].modProjectile is NiceCock) + { + if (Main.projectile[i].ModProjectile().homing) + continue; + Main.projectile[i].ai[0] = angle; + Main.projectile[i].netUpdate = true; + angle += angleVariance; + } + } + } public override bool OnTileCollide(Vector2 oldVelocity) { - // Kill all fireballs if you miss a stealth strike or golden pan - if (PanType == SearedPanTypes.Golden || PanType == SearedPanTypes.StealthStrike) - FireballStuff(false); + // Kill all fireballs if you miss a stealth strike or golden pan + if (PanType == SearedPanTypes.Golden || PanType == SearedPanTypes.StealthStrike) + FireballStuff(false); return true; } public override Color? GetAlpha(Color lightColor) - { - // Stealth strikes and golden pans are golden colored - if (PanType == SearedPanTypes.Golden || PanType == SearedPanTypes.StealthStrike) - return new Color(255, 222, 0); - return null; - } + { + // Stealth strikes and golden pans are golden colored + if (PanType == SearedPanTypes.Golden || PanType == SearedPanTypes.StealthStrike) + return new Color(255, 222, 0); + return null; + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Rogue/SeashellBoomerangProjectile.cs b/Projectiles/Rogue/SeashellBoomerangProjectile.cs index d1b861742b..67bcbfed44 100644 --- a/Projectiles/Rogue/SeashellBoomerangProjectile.cs +++ b/Projectiles/Rogue/SeashellBoomerangProjectile.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SeashellBoomerangProjectile : ModProjectile + public class SeashellBoomerangProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/SeashellBoomerang"; @@ -22,13 +22,13 @@ namespace CalamityMod.Projectiles.Rogue projectile.aiStyle = 3; projectile.timeLeft = 240; aiType = ProjectileID.WoodenBoomerang; - projectile.Calamity().rogue = true; + projectile.Calamity().rogue = true; } public override void AI() { - if (projectile.Calamity().stealthStrike) - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 10f, 20f, 5, ModContent.ProjectileType()); + if (projectile.Calamity().stealthStrike) + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 10f, 20f, 5, ModContent.ProjectileType()); } } } diff --git a/Projectiles/Rogue/ShadowBlackhole.cs b/Projectiles/Rogue/ShadowBlackhole.cs index 96f618b100..c7ccc69dd0 100644 --- a/Projectiles/Rogue/ShadowBlackhole.cs +++ b/Projectiles/Rogue/ShadowBlackhole.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class ShadowBlackhole : ModProjectile + public class ShadowBlackhole : ModProjectile { public override void SetStaticDefaults() { @@ -26,40 +26,40 @@ namespace CalamityMod.Projectiles.Rogue projectile.idStaticNPCHitCooldown = 20; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; + } - public override void AI() - { - // Update animation - if (projectile.timeLeft % 5 == 0) - { - projectile.frame++; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } + public override void AI() + { + // Update animation + if (projectile.timeLeft % 5 == 0) + { + projectile.frame++; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } - projectile.ai[0]++; - if (projectile.ai[0] > 120f) - { - projectile.scale *= 0.95f; - projectile.Opacity *= 0.95f; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, projectile.scale); - } - if (projectile.scale <= 0.05f) - { - projectile.Kill(); - } - } + projectile.ai[0]++; + if (projectile.ai[0] > 120f) + { + projectile.scale *= 0.95f; + projectile.Opacity *= 0.95f; + CalamityGlobalProjectile.ExpandHitboxBy(projectile, projectile.scale); + } + if (projectile.scale <= 0.05f) + { + projectile.Kill(); + } + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.Blackout, 300); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Blackout, 300); + } + } } diff --git a/Projectiles/Rogue/ShatteredSunKnife.cs b/Projectiles/Rogue/ShatteredSunKnife.cs index 1fcc3d127d..8dd51fe6f9 100644 --- a/Projectiles/Rogue/ShatteredSunKnife.cs +++ b/Projectiles/Rogue/ShatteredSunKnife.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 56; projectile.height = 56; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 4; + projectile.ignoreWater = true; + projectile.penetrate = 4; projectile.timeLeft = 300; projectile.alpha = 255; projectile.tileCollide = false; @@ -86,41 +86,41 @@ namespace CalamityMod.Projectiles.Rogue } } - if (projectile.Calamity().stealthStrike) - { - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - for (int num475 = 0; num475 < Main.maxNPCs; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) - { - float npcCenterX = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float npcCenterY = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - npcCenterX) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - npcCenterY); - if (num478 < num474) - { - if (Main.npc[num475].position.X < num472) - { - Main.npc[num475].velocity.X += 0.25f; - } - else - { - Main.npc[num475].velocity.X -= 0.25f; - } - if (Main.npc[num475].position.Y < num473) - { - Main.npc[num475].velocity.Y += 0.25f; - } - else - { - Main.npc[num475].velocity.Y -= 0.25f; - } - } - } - } - } - } + if (projectile.Calamity().stealthStrike) + { + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float num474 = 600f; + for (int num475 = 0; num475 < Main.maxNPCs; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) + { + float npcCenterX = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); + float npcCenterY = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); + float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - npcCenterX) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - npcCenterY); + if (num478 < num474) + { + if (Main.npc[num475].position.X < num472) + { + Main.npc[num475].velocity.X += 0.25f; + } + else + { + Main.npc[num475].velocity.X -= 0.25f; + } + if (Main.npc[num475].position.Y < num473) + { + Main.npc[num475].velocity.Y += 0.25f; + } + else + { + Main.npc[num475].velocity.Y -= 0.25f; + } + } + } + } + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Rogue/ShatteredSunScorchedBlade.cs b/Projectiles/Rogue/ShatteredSunScorchedBlade.cs index 0f58f7371a..dcb93ac967 100644 --- a/Projectiles/Rogue/ShatteredSunScorchedBlade.cs +++ b/Projectiles/Rogue/ShatteredSunScorchedBlade.cs @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Rogue } Lighting.AddLight(projectile.Center, 0.7f, 0.3f, 0f); - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); float num633; Vector2 vector46 = projectile.position; bool flag25 = false; @@ -113,41 +113,41 @@ namespace CalamityMod.Projectiles.Rogue } } - if (projectile.Calamity().stealthStrike) - { - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 600f; - for (int num475 = 0; num475 < Main.maxNPCs; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) - { - float npcCenterX = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float npcCenterY = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - npcCenterX) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - npcCenterY); - if (num478 < num474) - { - if (Main.npc[num475].position.X < num472) - { - Main.npc[num475].velocity.X += 0.25f; - } - else - { - Main.npc[num475].velocity.X -= 0.25f; - } - if (Main.npc[num475].position.Y < num473) - { - Main.npc[num475].velocity.Y += 0.25f; - } - else - { - Main.npc[num475].velocity.Y -= 0.25f; - } - } - } - } - } - } + if (projectile.Calamity().stealthStrike) + { + float num472 = projectile.Center.X; + float num473 = projectile.Center.Y; + float num474 = 600f; + for (int num475 = 0; num475 < Main.maxNPCs; num475++) + { + if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) + { + float npcCenterX = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); + float npcCenterY = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); + float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - npcCenterX) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - npcCenterY); + if (num478 < num474) + { + if (Main.npc[num475].position.X < num472) + { + Main.npc[num475].velocity.X += 0.25f; + } + else + { + Main.npc[num475].velocity.X -= 0.25f; + } + if (Main.npc[num475].position.Y < num473) + { + Main.npc[num475].velocity.Y += 0.25f; + } + else + { + Main.npc[num475].velocity.Y -= 0.25f; + } + } + } + } + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -236,7 +236,7 @@ namespace CalamityMod.Projectiles.Rogue Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Rogue/ShinobiBladeProjectile.cs b/Projectiles/Rogue/ShinobiBladeProjectile.cs index 9e43321131..f3e7f1b93c 100644 --- a/Projectiles/Rogue/ShinobiBladeProjectile.cs +++ b/Projectiles/Rogue/ShinobiBladeProjectile.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class ShinobiBladeProjectile : ModProjectile + public class ShinobiBladeProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/ShinobiBlade"; @@ -56,13 +56,13 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { if (target.life <= 0) - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], 10, ModContent.ProjectileType(), 1200f, 0f); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], 10, ModContent.ProjectileType(), 1200f, 0f); } public override void OnHitPvp(Player target, int damage, bool crit) { if (target.statLife <= 0) - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], 10, ModContent.ProjectileType(), 1200f, 0f); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], 10, ModContent.ProjectileType(), 1200f, 0f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/ShockGrenadeBolt.cs b/Projectiles/Rogue/ShockGrenadeBolt.cs index 355e5d9bad..8e00b12f5d 100644 --- a/Projectiles/Rogue/ShockGrenadeBolt.cs +++ b/Projectiles/Rogue/ShockGrenadeBolt.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class ShockGrenadeBolt : ModProjectile + public class ShockGrenadeBolt : ModProjectile { public static int frameWidth = 12; public static int frameHeight = 26; diff --git a/Projectiles/Rogue/ShockGrenadeExplosion.cs b/Projectiles/Rogue/ShockGrenadeExplosion.cs index 1e9749a2c1..12ca8eb4c2 100644 --- a/Projectiles/Rogue/ShockGrenadeExplosion.cs +++ b/Projectiles/Rogue/ShockGrenadeExplosion.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class ShockGrenadeExplosion : ModProjectile + public class ShockGrenadeExplosion : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Rogue/ShockTeslaAura.cs b/Projectiles/Rogue/ShockTeslaAura.cs index e73800e7ef..d7f18a9747 100644 --- a/Projectiles/Rogue/ShockTeslaAura.cs +++ b/Projectiles/Rogue/ShockTeslaAura.cs @@ -96,8 +96,8 @@ namespace CalamityMod.Projectiles.Rogue { target.AddBuff(BuffID.Electrified, 180); - if (target.knockBackResist <= 0f) - return; + if (target.knockBackResist <= 0f) + return; if (CalamityGlobalNPC.ShouldAffectNPC(target)) { diff --git a/Projectiles/Rogue/ShroomerangProj.cs b/Projectiles/Rogue/ShroomerangProj.cs index de06c11ebb..8881987183 100644 --- a/Projectiles/Rogue/ShroomerangProj.cs +++ b/Projectiles/Rogue/ShroomerangProj.cs @@ -35,18 +35,18 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 56, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - if (projectile.Calamity().stealthStrike) - { - if (projectile.timeLeft % 15 == 0 && projectile.owner == Main.myPlayer) - { - Vector2 vector62 = Main.player[projectile.owner].Center - projectile.Center; - Vector2 vector63 = vector62 * -1f; - vector63.Normalize(); - vector63 *= (float)Main.rand.Next(45, 65) * 0.1f; - vector63 = vector63.RotatedBy((Main.rand.NextDouble() - 0.5) * 1.5707963705062866, default); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vector63.X, vector63.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), projectile.knockBack * 0.2f, projectile.owner, -10f, 0f); - } - } + if (projectile.Calamity().stealthStrike) + { + if (projectile.timeLeft % 15 == 0 && projectile.owner == Main.myPlayer) + { + Vector2 vector62 = Main.player[projectile.owner].Center - projectile.Center; + Vector2 vector63 = vector62 * -1f; + vector63.Normalize(); + vector63 *= (float)Main.rand.Next(45, 65) * 0.1f; + vector63 = vector63.RotatedBy((Main.rand.NextDouble() - 0.5) * 1.5707963705062866, default); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vector63.X, vector63.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), projectile.knockBack * 0.2f, projectile.owner, -10f, 0f); + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -59,15 +59,15 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { Player player = Main.player[projectile.owner]; - if (projectile.Calamity().stealthStrike) - player.AddBuff(ModContent.BuffType(), 720); + if (projectile.Calamity().stealthStrike) + player.AddBuff(ModContent.BuffType(), 720); } public override void OnHitPvp(Player target, int damage, bool crit) { Player player = Main.player[projectile.owner]; - if (projectile.Calamity().stealthStrike) - player.AddBuff(ModContent.BuffType(), 720); + if (projectile.Calamity().stealthStrike) + player.AddBuff(ModContent.BuffType(), 720); } } } diff --git a/Projectiles/Rogue/SkyBomberGas.cs b/Projectiles/Rogue/SkyBomberGas.cs index 379d6623b5..23cccb4571 100644 --- a/Projectiles/Rogue/SkyBomberGas.cs +++ b/Projectiles/Rogue/SkyBomberGas.cs @@ -5,7 +5,7 @@ using CalamityMod.Buffs.StatDebuffs; namespace CalamityMod.Projectiles.Rogue { - public class SkyBomberGas : ModProjectile + public class SkyBomberGas : ModProjectile { public override void SetStaticDefaults() { @@ -32,10 +32,10 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.timeLeft < 50) projectile.alpha += 5; if (projectile.timeLeft < 75) - { + { projectile.velocity *= 0.95f; - projectile.scale += 0.002f; - } + projectile.scale += 0.002f; + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Rogue/SkyStabberProj.cs b/Projectiles/Rogue/SkyStabberProj.cs index 4d20754712..81ab639c8b 100644 --- a/Projectiles/Rogue/SkyStabberProj.cs +++ b/Projectiles/Rogue/SkyStabberProj.cs @@ -6,7 +6,7 @@ using CalamityMod.CalPlayer; namespace CalamityMod.Projectiles.Rogue { - public class SkyStabberProj : ModProjectile + public class SkyStabberProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/SkyStabber"; @@ -40,18 +40,18 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.X *= 0.98f; projectile.velocity.Y *= 0.98f; } - else - { - projectile.rotation += 0.3f * (float)projectile.direction; - } + else + { + projectile.rotation += 0.3f * (float)projectile.direction; + } Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.killSpikyBalls) - { - projectile.active = false; - projectile.netUpdate = true; - } + if (modPlayer.killSpikyBalls) + { + projectile.active = false; + projectile.netUpdate = true; + } } // Makes the projectile bounce infinitely, as it stops mid-air anyway. @@ -71,25 +71,25 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(target.Center); - } + OnHitEffects(target.Center); + } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(target.Center); + OnHitEffects(target.Center); } - private void OnHitEffects(Vector2 targetPos) - { - if (projectile.Calamity().stealthStrike) - { - for (int n = 0; n < 4; n++) - { - Projectile feather = CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 20f, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); - if (feather.whoAmI.WithinBounds(Main.maxProjectiles)) - feather.Calamity().forceRogue = true; - } - } + private void OnHitEffects(Vector2 targetPos) + { + if (projectile.Calamity().stealthStrike) + { + for (int n = 0; n < 4; n++) + { + Projectile feather = CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 20f, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); + if (feather.whoAmI.WithinBounds(Main.maxProjectiles)) + feather.Calamity().forceRogue = true; + } + } } } } diff --git a/Projectiles/Rogue/SkyfinNuke.cs b/Projectiles/Rogue/SkyfinNuke.cs index f8ce36f5f3..3535322c3a 100644 --- a/Projectiles/Rogue/SkyfinNuke.cs +++ b/Projectiles/Rogue/SkyfinNuke.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SkyfinNuke : ModProjectile + public class SkyfinNuke : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/SkyfinBombers"; @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 720; projectile.alpha = 0; projectile.Calamity().rogue = true; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() @@ -33,40 +33,40 @@ namespace CalamityMod.Projectiles.Rogue projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - const float turnSpeed = 20f; - float speedMult = projectile.Calamity().stealthStrike ? 9f : 12f; - const float homingRange = 300f; - if (!projectile.Calamity().stealthStrike) //normal attack - { - projectile.ai[0]++; - if (projectile.ai[0] > 30f) //0.5 seconds - { - NPC target = projectile.Center.ClosestNPCAt(homingRange); - // Ignore targets above the nuke - if (target != null) - { - if (target.Bottom.Y < projectile.Top.Y) - { - target = null; - } - } - if (target != null) - { - Vector2 distNorm = (target.Center - projectile.Center).SafeNormalize(Vector2.UnitX); - projectile.velocity = (projectile.velocity * (turnSpeed - 1f) + distNorm * speedMult) / turnSpeed; - } - } - } - else - { - //More range - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, homingRange, speedMult, turnSpeed); - } + const float turnSpeed = 20f; + float speedMult = projectile.Calamity().stealthStrike ? 9f : 12f; + const float homingRange = 300f; + if (!projectile.Calamity().stealthStrike) //normal attack + { + projectile.ai[0]++; + if (projectile.ai[0] > 30f) //0.5 seconds + { + NPC target = projectile.Center.ClosestNPCAt(homingRange); + // Ignore targets above the nuke + if (target != null) + { + if (target.Bottom.Y < projectile.Top.Y) + { + target = null; + } + } + if (target != null) + { + Vector2 distNorm = (target.Center - projectile.Center).SafeNormalize(Vector2.UnitX); + projectile.velocity = (projectile.velocity * (turnSpeed - 1f) + distNorm * speedMult) / turnSpeed; + } + } + } + else + { + //More range + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, homingRange, speedMult, turnSpeed); + } } public override void Kill(int timeLeft) { - projectile.extraUpdates = 0; + projectile.extraUpdates = 0; //Dust for (int i = 0; i < 30;i++) { @@ -75,22 +75,22 @@ namespace CalamityMod.Projectiles.Rogue } projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.Damage(); + projectile.Damage(); int cloudAmt = Main.rand.Next(2, 5); if (projectile.owner == Main.myPlayer) { for (int c = 0; c < cloudAmt; c++) { - Vector2 velocity = CalamityUtils.RandomVelocity(50f, 10f, 50f, 0.01f); + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 10f, 50f, 0.01f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), projectile.knockBack * 0.4f, projectile.owner); } - if (projectile.Calamity().stealthStrike) - { - int explode = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), projectile.knockBack * 0.4f, projectile.owner, 1f); - Main.projectile[explode].usesLocalNPCImmunity = true; - Main.projectile[explode].localNPCHitCooldown = 30; - } + if (projectile.Calamity().stealthStrike) + { + int explode = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), projectile.knockBack * 0.4f, projectile.owner, 1f); + Main.projectile[explode].usesLocalNPCImmunity = true; + Main.projectile[explode].localNPCHitCooldown = 30; + } } Main.PlaySound(SoundID.Item14, projectile.Bottom); diff --git a/Projectiles/Rogue/SlickCaneProjectile.cs b/Projectiles/Rogue/SlickCaneProjectile.cs index f5ad45c0aa..7f44e21d59 100644 --- a/Projectiles/Rogue/SlickCaneProjectile.cs +++ b/Projectiles/Rogue/SlickCaneProjectile.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Projectiles.Rogue { public override string Texture => "CalamityMod/Items/Weapons/Rogue/SlickCane"; - private bool initialized = false; + private bool initialized = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Slick Cane"); @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Rogue // Initialization. Using the AI hook would override the base spear's code, and we don't want that. if (!initialized) { - Main.player[projectile.owner].Calamity().ConsumeStealthByAttacking(); + Main.player[projectile.owner].Calamity().ConsumeStealthByAttacking(); initialized = true; } return true; @@ -78,61 +78,61 @@ namespace CalamityMod.Projectiles.Rogue Player player = Main.player[projectile.owner]; if ((target.damage > 5 || target.boss) && player.whoAmI == Main.myPlayer && !target.SpawnedFromStatue) { - float moneyValueToDrop = target.value / Main.rand.NextFloat(15f, 35f); + float moneyValueToDrop = target.value / Main.rand.NextFloat(15f, 35f); // Maximum of 50 silver, not counting steath strikes moneyValueToDrop = (int)MathHelper.Clamp(moneyValueToDrop, 0, 5000f); if (projectile.Calamity().stealthStrike && Main.rand.NextBool(15)) - { - moneyValueToDrop += Item.buyPrice(0, Main.rand.Next(1, 4), Main.rand.Next(0, 100), Main.rand.Next(0, 100)); - } + { + moneyValueToDrop += Item.buyPrice(0, Main.rand.Next(1, 4), Main.rand.Next(0, 100), Main.rand.Next(0, 100)); + } while (moneyValueToDrop > 10000f) - { - int modifiedMoneyValue = (int)(moneyValueToDrop / 10000f); - if (modifiedMoneyValue > 50 && Main.rand.Next(5) == 0) - { - modifiedMoneyValue /= Main.rand.Next(3) + 1; - } - if (Main.rand.Next(5) == 0) - { - modifiedMoneyValue /= Main.rand.Next(3) + 1; - } - moneyValueToDrop -= 10000 * modifiedMoneyValue; - DropHelper.DropItem(target, ItemID.GoldCoin, modifiedMoneyValue); - } + { + int modifiedMoneyValue = (int)(moneyValueToDrop / 10000f); + if (modifiedMoneyValue > 50 && Main.rand.Next(5) == 0) + { + modifiedMoneyValue /= Main.rand.Next(3) + 1; + } + if (Main.rand.Next(5) == 0) + { + modifiedMoneyValue /= Main.rand.Next(3) + 1; + } + moneyValueToDrop -= 10000 * modifiedMoneyValue; + DropHelper.DropItem(target, ItemID.GoldCoin, modifiedMoneyValue); + } while (moneyValueToDrop > 100f) - { - int modifiedMoneyValue = (int)(moneyValueToDrop / 100f); - if (modifiedMoneyValue > 50 && Main.rand.Next(5) == 0) - { - modifiedMoneyValue /= Main.rand.Next(3) + 1; - } - if (Main.rand.Next(5) == 0) - { - modifiedMoneyValue /= Main.rand.Next(3) + 1; - } - moneyValueToDrop -= 100 * modifiedMoneyValue; - DropHelper.DropItem(target, ItemID.SilverCoin, modifiedMoneyValue); - } + { + int modifiedMoneyValue = (int)(moneyValueToDrop / 100f); + if (modifiedMoneyValue > 50 && Main.rand.Next(5) == 0) + { + modifiedMoneyValue /= Main.rand.Next(3) + 1; + } + if (Main.rand.Next(5) == 0) + { + modifiedMoneyValue /= Main.rand.Next(3) + 1; + } + moneyValueToDrop -= 100 * modifiedMoneyValue; + DropHelper.DropItem(target, ItemID.SilverCoin, modifiedMoneyValue); + } while (moneyValueToDrop > 0f) { - int modifiedMoneyValue = (int)moneyValueToDrop; - if (modifiedMoneyValue > 50 && Main.rand.Next(5) == 0) - { - modifiedMoneyValue /= Main.rand.Next(3) + 1; - } - if (Main.rand.Next(5) == 0) - { - modifiedMoneyValue /= Main.rand.Next(4) + 1; - } - if (modifiedMoneyValue < 1) - { - modifiedMoneyValue = 1; - } - moneyValueToDrop -= modifiedMoneyValue; - DropHelper.DropItem(target, ItemID.CopperCoin, modifiedMoneyValue); - } - } + int modifiedMoneyValue = (int)moneyValueToDrop; + if (modifiedMoneyValue > 50 && Main.rand.Next(5) == 0) + { + modifiedMoneyValue /= Main.rand.Next(3) + 1; + } + if (Main.rand.Next(5) == 0) + { + modifiedMoneyValue /= Main.rand.Next(4) + 1; + } + if (modifiedMoneyValue < 1) + { + modifiedMoneyValue = 1; + } + moneyValueToDrop -= modifiedMoneyValue; + DropHelper.DropItem(target, ItemID.CopperCoin, modifiedMoneyValue); + } + } } } } diff --git a/Projectiles/Rogue/SludgeSplotchProj1.cs b/Projectiles/Rogue/SludgeSplotchProj1.cs index 04357ae2a8..0c5507a798 100644 --- a/Projectiles/Rogue/SludgeSplotchProj1.cs +++ b/Projectiles/Rogue/SludgeSplotchProj1.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SludgeSplotchProj1 : ModProjectile + public class SludgeSplotchProj1 : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Rogue/SludgeSplotchProj2.cs b/Projectiles/Rogue/SludgeSplotchProj2.cs index 592d16d382..4a833a2ca4 100644 --- a/Projectiles/Rogue/SludgeSplotchProj2.cs +++ b/Projectiles/Rogue/SludgeSplotchProj2.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SludgeSplotchProj2 : ModProjectile + public class SludgeSplotchProj2 : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Rogue/SnapClamProj.cs b/Projectiles/Rogue/SnapClamProj.cs index 74731836aa..c1b629a4c9 100644 --- a/Projectiles/Rogue/SnapClamProj.cs +++ b/Projectiles/Rogue/SnapClamProj.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Rogue if (openClam) { onEnemy = true; - projectile.ModifyHitNPCSticky(2, false); + projectile.ModifyHitNPCSticky(2, false); } } diff --git a/Projectiles/Rogue/SnapClamStealth.cs b/Projectiles/Rogue/SnapClamStealth.cs index 7b1fc44adf..130d518944 100644 --- a/Projectiles/Rogue/SnapClamStealth.cs +++ b/Projectiles/Rogue/SnapClamStealth.cs @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; projectile.ignoreWater = true; projectile.penetrate = -1; - projectile.localNPCHitCooldown = 10; - projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.usesLocalNPCImmunity = true; } public override void AI() @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Rogue if (openClam) { onEnemy = true; - projectile.ModifyHitNPCSticky(5, false); + projectile.ModifyHitNPCSticky(5, false); } } diff --git a/Projectiles/Rogue/SpearofDestinyProjectile.cs b/Projectiles/Rogue/SpearofDestinyProjectile.cs index f4774a7ed6..fd41f568b1 100644 --- a/Projectiles/Rogue/SpearofDestinyProjectile.cs +++ b/Projectiles/Rogue/SpearofDestinyProjectile.cs @@ -6,11 +6,11 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SpearofDestinyProjectile : ModProjectile + public class SpearofDestinyProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/SpearofDestiny"; - private bool initialized = false; + private bool initialized = false; public override void SetStaticDefaults() { @@ -24,59 +24,59 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 2; + projectile.ignoreWater = true; + projectile.penetrate = 2; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; projectile.Calamity().rogue = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; } public override void AI() { - if (!initialized) - { - if (projectile.Calamity().stealthStrike) - { - projectile.penetrate++; - projectile.tileCollide = false; - } - initialized = true; - } + if (!initialized) + { + if (projectile.Calamity().stealthStrike) + { + projectile.penetrate++; + projectile.tileCollide = false; + } + initialized = true; + } if (Main.rand.NextBool(4)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 246, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; - Vector2 center = projectile.Center; - float maxDistance = 300f; - bool homeIn = false; + Vector2 center = projectile.Center; + float maxDistance = 300f; + 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) + (float)(Main.npc[i].height / 2); - bool canHit = projectile.Calamity().stealthStrike || Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); + bool canHit = projectile.Calamity().stealthStrike || Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && canHit) - { - center = Main.npc[i].Center; - homeIn = true; - break; - } - } - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + { + center = Main.npc[i].Center; + homeIn = true; + break; + } + } + } - if (homeIn) - { + if (homeIn) + { projectile.extraUpdates = 2; Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); projectile.velocity = (projectile.velocity * 20f + moveDirection * 12f) / (21f); - } + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -103,13 +103,13 @@ namespace CalamityMod.Projectiles.Rogue target.AddBuff(BuffID.Ichor, 120); } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.Calamity().stealthStrike) - { - Texture2D tex = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/SpearofDestinyGlow"); - spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); - } - } + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.Calamity().stealthStrike) + { + Texture2D tex = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/SpearofDestinyGlow"); + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex.Size() / 2, projectile.scale, SpriteEffects.None, 0f); + } + } } } diff --git a/Projectiles/Rogue/SpearofPaleolithProj.cs b/Projectiles/Rogue/SpearofPaleolithProj.cs index d058b138a3..727ffcd88b 100644 --- a/Projectiles/Rogue/SpearofPaleolithProj.cs +++ b/Projectiles/Rogue/SpearofPaleolithProj.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SpearofPaleolithProj : ModProjectile + public class SpearofPaleolithProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/SpearofPaleolith"; @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; diff --git a/Projectiles/Rogue/SpentFuelContainerProjectile.cs b/Projectiles/Rogue/SpentFuelContainerProjectile.cs index fc16d6867d..f95b7d6ed0 100644 --- a/Projectiles/Rogue/SpentFuelContainerProjectile.cs +++ b/Projectiles/Rogue/SpentFuelContainerProjectile.cs @@ -7,7 +7,7 @@ using Terraria.World.Generation; namespace CalamityMod.Projectiles.Rogue { - public class SpentFuelContainerProjectile : ModProjectile + public class SpentFuelContainerProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/SpentFuelContainer"; @@ -53,8 +53,8 @@ namespace CalamityMod.Projectiles.Rogue if (WorldUtils.Find(projectile.Top.ToTileCoordinates(), Searches.Chain((GenSearch)new Searches.Down(80), (GenCondition)new Conditions.IsSolid()), out result)) { int proj = Projectile.NewProjectile(result.ToVector2() * 16f, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 2f, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = projectile.Calamity().stealthStrike; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = projectile.Calamity().stealthStrike; } } } diff --git a/Projectiles/Rogue/SphereBladed.cs b/Projectiles/Rogue/SphereBladed.cs index fb62eab57a..81eb07df18 100644 --- a/Projectiles/Rogue/SphereBladed.cs +++ b/Projectiles/Rogue/SphereBladed.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 20; projectile.friendly = true; projectile.tileCollide = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.extraUpdates = 1; projectile.Calamity().rogue = true; projectile.usesIDStaticNPCImmunity = true; diff --git a/Projectiles/Rogue/SphereBlue.cs b/Projectiles/Rogue/SphereBlue.cs index d7d2d5ef8d..ad819d5181 100644 --- a/Projectiles/Rogue/SphereBlue.cs +++ b/Projectiles/Rogue/SphereBlue.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SphereBlue : ModProjectile + public class SphereBlue : ModProjectile { public override void SetStaticDefaults() { @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 300; projectile.tileCollide = false; projectile.Calamity().rogue = true; @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.rotation += projectile.velocity.X * 0.02f; projectile.velocity.Y = projectile.velocity.Y + 0.085f; projectile.velocity.X = projectile.velocity.X * 0.99f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); } public override void Kill(int timeLeft) @@ -68,17 +68,17 @@ namespace CalamityMod.Projectiles.Rogue { scaleFactor10 = 1f; } - int defectiveBruh = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(660, 662), 1f); - Main.gore[defectiveBruh].velocity *= scaleFactor10; - Main.gore[defectiveBruh].velocity += projectile.velocity; + int defectiveBruh = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(660, 662), 1f); + Main.gore[defectiveBruh].velocity *= scaleFactor10; + Main.gore[defectiveBruh].velocity += projectile.velocity; } for (int num194 = 0; num194 < 25; num194++) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 226, - 229 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 226, + 229 + }); int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 1f); Main.dust[num195].noGravity = true; Main.dust[num195].velocity *= 0f; diff --git a/Projectiles/Rogue/SphereSpiked.cs b/Projectiles/Rogue/SphereSpiked.cs index 4bab34e09a..2d535ab9ce 100644 --- a/Projectiles/Rogue/SphereSpiked.cs +++ b/Projectiles/Rogue/SphereSpiked.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 20; projectile.friendly = true; projectile.penetrate = -1; - projectile.ignoreWater = true; - projectile.aiStyle = 3; + projectile.ignoreWater = true; + projectile.aiStyle = 3; projectile.timeLeft = 300; aiType = ProjectileID.WoodenBoomerang; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/SphereYellow.cs b/Projectiles/Rogue/SphereYellow.cs index e3d5a194d2..dde9d8b65b 100644 --- a/Projectiles/Rogue/SphereYellow.cs +++ b/Projectiles/Rogue/SphereYellow.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.aiStyle = 3; projectile.timeLeft = 300; aiType = ProjectileID.WoodenBoomerang; @@ -34,22 +34,22 @@ 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; - } - } + if (projectile.ai[0] == 1f) + { + projectile.extraUpdates = 1; + } + } public override bool OnTileCollide(Vector2 oldVelocity) { - if (projectile.velocity.X != oldVelocity.X) - { - projectile.velocity.X = -oldVelocity.X; - } - if (projectile.velocity.Y != oldVelocity.Y) - { - projectile.velocity.Y = -oldVelocity.Y; - } + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y; + } return false; } diff --git a/Projectiles/Rogue/StealthNimbus.cs b/Projectiles/Rogue/StealthNimbus.cs index 9cc72ef8cd..b449c4f5a2 100644 --- a/Projectiles/Rogue/StealthNimbus.cs +++ b/Projectiles/Rogue/StealthNimbus.cs @@ -27,13 +27,13 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; - if (projectile.ai[0] == 1f) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/StealthNimbus2"); + if (projectile.ai[0] == 1f) + texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/StealthNimbus2"); int height = texture.Height / Main.projFrames[projectile.type]; int frameHeight = height * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); return false; } @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Rogue int projType = projectile.type; for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) { - Projectile proj = Main.projectile[projIndex]; + Projectile proj = Main.projectile[projIndex]; if (proj.active && proj.owner == projectile.owner && proj.type == projType && proj.ai[1] < 3600f) { projCount++; diff --git a/Projectiles/Rogue/StealthNimbusCloud.cs b/Projectiles/Rogue/StealthNimbusCloud.cs index f0db307733..7ef01ba50c 100644 --- a/Projectiles/Rogue/StealthNimbusCloud.cs +++ b/Projectiles/Rogue/StealthNimbusCloud.cs @@ -20,20 +20,20 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 28; projectile.netImportant = true; projectile.penetrate = -1; - projectile.timeLeft = 25; + projectile.timeLeft = 25; projectile.Calamity().rogue = true; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; - if (projectile.ai[0] == 1f) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/StealthNimbusCloud2"); + if (projectile.ai[0] == 1f) + texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/StealthNimbusCloud2"); int height = texture.Height / Main.projFrames[projectile.type]; int frameHeight = height * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); return false; } diff --git a/Projectiles/Rogue/StealthRain.cs b/Projectiles/Rogue/StealthRain.cs index 456630b624..5a2d27617c 100644 --- a/Projectiles/Rogue/StealthRain.cs +++ b/Projectiles/Rogue/StealthRain.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - int dustType = projectile.ai[0] == 0f ? 14 : 114; + int dustType = projectile.ai[0] == 0f ? 14 : 114; int num310 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + (float)projectile.height - 2f), 2, 2, dustType, 0f, 0f, 0, default, 1f); Dust dust = Main.dust[num310]; @@ -61,8 +61,8 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - int buffType = projectile.ai[0] == 0f ? BuffID.CursedInferno : ModContent.BuffType(); + int buffType = projectile.ai[0] == 0f ? BuffID.CursedInferno : ModContent.BuffType(); target.AddBuff(buffType, 90); - } + } } } diff --git a/Projectiles/Rogue/StellarKnifeProj.cs b/Projectiles/Rogue/StellarKnifeProj.cs index abb99c69f6..59356e616b 100644 --- a/Projectiles/Rogue/StellarKnifeProj.cs +++ b/Projectiles/Rogue/StellarKnifeProj.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class StellarKnifeProj : ModProjectile + public class StellarKnifeProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/StellarKnife"; @@ -25,29 +25,29 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 32; projectile.height = 34; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 600; projectile.tileCollide = true; projectile.Calamity().rogue = true; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[1]); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[1]); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[1] = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[1] = reader.ReadSingle(); + } public override void AI() { - //synthesized timeLeft - projectile.localAI[1]++; - if (projectile.localAI[1] > 600f) - projectile.Kill(); + //synthesized timeLeft + projectile.localAI[1]++; + if (projectile.localAI[1] > 600f) + projectile.Kill(); if (projectile.ai[0] == 1f) { @@ -66,37 +66,37 @@ namespace CalamityMod.Projectiles.Rogue { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); - Vector2 center = projectile.Center; - float maxDistance = 600f; - bool homeIn = false; + Vector2 center = projectile.Center; + float maxDistance = 600f; + bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) - { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + { + float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance)) - { - center = Main.npc[i].Center; - homeIn = true; - break; - } - } - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = Main.npc[i].Center; + homeIn = true; + break; + } + } + } - if (homeIn) - { - projectile.timeLeft = 600; //when homing in, the projectile cannot run out of timeLeft, but synthesized timeLeft still runs + if (homeIn) + { + projectile.timeLeft = 600; //when homing in, the projectile cannot run out of timeLeft, but synthesized timeLeft still runs Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); projectile.velocity = (projectile.velocity * 10f + moveDirection * 30f) / (10f + 1f); - } + } else { - //shorten knife lifespan if it hasn't found a target - if (projectile.timeLeft > 60) - projectile.timeLeft = 60; + //shorten knife lifespan if it hasn't found a target + if (projectile.timeLeft > 60) + projectile.timeLeft = 60; projectile.velocity.X *= 0.92f; projectile.velocity.Y *= 0.92f; } diff --git a/Projectiles/Rogue/StickyBol.cs b/Projectiles/Rogue/StickyBol.cs index 5a31871b96..4a8f2a86b5 100644 --- a/Projectiles/Rogue/StickyBol.cs +++ b/Projectiles/Rogue/StickyBol.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class StickyBol : ModProjectile + public class StickyBol : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/StickySpikyBall"; @@ -30,33 +30,33 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - Color color = new Color(0, 80, 255, 100); - if (Main.rand.NextBool(12)) - { - Dust.NewDust(projectile.position + Vector2.One * 6f, projectile.width - 12, projectile.height - 12, 4, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 175, color, 1.2f); - } + Color color = new Color(0, 80, 255, 100); + if (Main.rand.NextBool(12)) + { + Dust.NewDust(projectile.position + Vector2.One * 6f, projectile.width - 12, projectile.height - 12, 4, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 175, color, 1.2f); + } //Sticky Behaviour projectile.StickyProjAI(10); - if (projectile.ai[0] != 1f) - { - projectile.StickToTiles(true, false); - projectile.localAI[1] += 1f; - if (projectile.localAI[1] > 10f) - { - projectile.localAI[1] = 10f; - if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) - { - projectile.velocity.X *= 0.97f; - if (Math.Abs(projectile.velocity.X) < 0.01f) - { - projectile.velocity.X = 0f; - projectile.netUpdate = true; - } - } - projectile.velocity.Y += 0.2f; - } - projectile.rotation += projectile.velocity.X * 0.1f; - } + if (projectile.ai[0] != 1f) + { + projectile.StickToTiles(true, false); + projectile.localAI[1] += 1f; + if (projectile.localAI[1] > 10f) + { + projectile.localAI[1] = 10f; + if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) + { + projectile.velocity.X *= 0.97f; + if (Math.Abs(projectile.velocity.X) < 0.01f) + { + projectile.velocity.X = 0f; + projectile.netUpdate = true; + } + } + projectile.velocity.Y += 0.2f; + } + projectile.rotation += projectile.velocity.X * 0.1f; + } } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) diff --git a/Projectiles/Rogue/StormfrontRazorProjectile.cs b/Projectiles/Rogue/StormfrontRazorProjectile.cs index 069c716ae9..68fc49e27d 100644 --- a/Projectiles/Rogue/StormfrontRazorProjectile.cs +++ b/Projectiles/Rogue/StormfrontRazorProjectile.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 5; + projectile.ignoreWater = true; + projectile.penetrate = 5; projectile.timeLeft = 300; projectile.extraUpdates = 1; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/Stormfrontspark.cs b/Projectiles/Rogue/Stormfrontspark.cs index b78b5d5a14..3a345d2a88 100644 --- a/Projectiles/Rogue/Stormfrontspark.cs +++ b/Projectiles/Rogue/Stormfrontspark.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { projectile.friendly = true; - projectile.ignoreWater = true; - projectile.width = 6; + projectile.ignoreWater = true; + projectile.width = 6; projectile.height = 12; projectile.timeLeft = 240; projectile.penetrate = -1; @@ -55,6 +55,6 @@ namespace CalamityMod.Projectiles.Rogue } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Rogue/SubductionFlameburst.cs b/Projectiles/Rogue/SubductionFlameburst.cs index 24668bc952..ac094f54f2 100644 --- a/Projectiles/Rogue/SubductionFlameburst.cs +++ b/Projectiles/Rogue/SubductionFlameburst.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.tileCollide = false; projectile.alpha = 255; projectile.Calamity().rogue = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; } public override void AI() @@ -55,21 +55,21 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D tex = Main.projectileTexture[projectile.type]; + Texture2D tex = Main.projectileTexture[projectile.type]; Rectangle frame = new Rectangle(frameX * projectile.width, frameY * projectile.height, projectile.width, projectile.height); spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, frame, Color.White, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); return false; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.OnFire, 240); - target.AddBuff(BuffID.Daybreak, 120); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.OnFire, 240); + target.AddBuff(BuffID.Daybreak, 120); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.OnFire, 300); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.OnFire, 300); + } } } diff --git a/Projectiles/Rogue/SulphuricNukesplosion.cs b/Projectiles/Rogue/SulphuricNukesplosion.cs index ecf7cb95b5..e75ad3f627 100644 --- a/Projectiles/Rogue/SulphuricNukesplosion.cs +++ b/Projectiles/Rogue/SulphuricNukesplosion.cs @@ -8,7 +8,7 @@ using CalamityMod.Dusts; namespace CalamityMod.Projectiles.Rogue { - public class SulphuricNukesplosion : ModProjectile + public class SulphuricNukesplosion : ModProjectile { public int frameX = 0; public int frameY = 0; diff --git a/Projectiles/Rogue/SupernovaBomb.cs b/Projectiles/Rogue/SupernovaBomb.cs index 65ac1883c8..ada3d30ed5 100644 --- a/Projectiles/Rogue/SupernovaBomb.cs +++ b/Projectiles/Rogue/SupernovaBomb.cs @@ -31,19 +31,19 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - //dust and lighting - int num298 = Main.rand.NextBool(2) ? 107 : 234; - if (Main.rand.NextBool(4)) - { - num298 = 269; - } + //dust and lighting + int num298 = Main.rand.NextBool(2) ? 107 : 234; + if (Main.rand.NextBool(4)) + { + num298 = 269; + } if (Main.rand.NextBool(6)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, num298, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } Lighting.AddLight(projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f); - //velocity + //velocity projectile.ai[0] += 1f; if (projectile.ai[0] > 10f) { @@ -60,10 +60,10 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.Y += 0.2f; } - //rotation + //rotation projectile.rotation += projectile.velocity.X * 0.1f; - //stealth strike + //stealth strike if (projectile.Calamity().stealthStrike && projectile.timeLeft % 8 == 0 && projectile.owner == Main.myPlayer) Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 2f, ModContent.ProjectileType(), (int)(projectile.damage * 0.48), projectile.knockBack, projectile.owner, 0f, 0f); } @@ -80,30 +80,30 @@ namespace CalamityMod.Projectiles.Rogue int projAmt = Main.rand.Next(3, 5); if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); for (int i = 0; i < projAmt; i++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.6), 0f, projectile.owner, 0f, 0f); } - float spread = MathHelper.Pi / 3f; - double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 6f; - double offsetAngle; - for (int i = 0; i < 3; i++) - { - offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 2f), (float)(Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 2f), (float)(-Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); - } + float spread = MathHelper.Pi / 3f; + double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; + double deltaAngle = spread / 6f; + double offsetAngle; + for (int i = 0; i < 3; i++) + { + offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 2f), (float)(Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 2f), (float)(-Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); + } } - //dust effects - int dustType = Main.rand.NextBool(2) ? 107 : 234; - if (Main.rand.NextBool(4)) - { - dustType = 269; - } + //dust effects + int dustType = Main.rand.NextBool(2) ? 107 : 234; + if (Main.rand.NextBool(4)) + { + dustType = 269; + } for (int d = 0; d < 5; d++) { int exo = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); @@ -123,18 +123,18 @@ namespace CalamityMod.Projectiles.Rogue Main.dust[fire].velocity *= 2f; } - //gore cloud effects - CalamityUtils.ExplosionGores(projectile.Center, 3); + //gore cloud effects + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/SupernovaBoom.cs b/Projectiles/Rogue/SupernovaBoom.cs index c3e53949f0..aac5065876 100644 --- a/Projectiles/Rogue/SupernovaBoom.cs +++ b/Projectiles/Rogue/SupernovaBoom.cs @@ -4,92 +4,92 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SupernovaBoom : ModProjectile - { - public int frameX = 0; - public int frameY = 0; - private const int horizontalFrames = 5; - private const int verticalFrames = 4; - private const int frameLength = 4; - private const float radius = 204.5f; + public class SupernovaBoom : ModProjectile + { + public int frameX = 0; + public int frameY = 0; + private const int horizontalFrames = 5; + private const int verticalFrames = 4; + private const int frameLength = 4; + private const float radius = 204.5f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Explosion"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Explosion"); + } - public override void SetDefaults() - { - projectile.width = 408; - projectile.height = 410; - projectile.scale = 2f; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.Calamity().rogue = true; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = frameLength * horizontalFrames * verticalFrames / 5; - } + public override void SetDefaults() + { + projectile.width = 408; + projectile.height = 410; + projectile.scale = 2f; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.Calamity().rogue = true; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = frameLength * horizontalFrames * verticalFrames / 5; + } - public override void AI() - { - projectile.frameCounter++; - if (projectile.frameCounter % frameLength == frameLength - 1) - { - frameY++; - if (frameY >= verticalFrames) - { - frameX++; - frameY = 0; - } - if (frameX >= horizontalFrames) - { - projectile.Kill(); - } - } + public override void AI() + { + projectile.frameCounter++; + if (projectile.frameCounter % frameLength == frameLength - 1) + { + frameY++; + if (frameY >= verticalFrames) + { + frameX++; + frameY = 0; + } + if (frameX >= horizontalFrames) + { + projectile.Kill(); + } + } - Lighting.AddLight(projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f); + Lighting.AddLight(projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f); - /*float dustSpeed = (float)Main.rand.Next(12, 36); - Vector2 dustVel = CalamityUtils.RandomVelocity(40f, dustSpeed, dustSpeed, 1f); - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 107, - 234, - 269 - }); - int rainbow = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[rainbow]; - dust.noGravity = true; - dust.position = projectile.Center; - dust.position.X += (float)Main.rand.Next(-10, 11); - dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity = dustVel;*/ - } + /*float dustSpeed = (float)Main.rand.Next(12, 36); + Vector2 dustVel = CalamityUtils.RandomVelocity(40f, dustSpeed, dustSpeed, 1f); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 107, + 234, + 269 + }); + int rainbow = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[rainbow]; + dust.noGravity = true; + dust.position = projectile.Center; + dust.position.X += (float)Main.rand.Next(-10, 11); + dust.position.Y += (float)Main.rand.Next(-10, 11); + dust.velocity = dustVel;*/ + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, radius, targetHitbox); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int length = texture.Width / horizontalFrames; - int height = texture.Height / verticalFrames; - Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - Rectangle frame = new Rectangle(frameX * length, frameY * height, length, height); - Vector2 origin = new Vector2(length / 2f, height / 2f); - spriteBatch.Draw(texture, drawPos, frame, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int length = texture.Width / horizontalFrames; + int height = texture.Height / verticalFrames; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Rectangle frame = new Rectangle(frameX * length, frameY * height, length, height); + Vector2 origin = new Vector2(length / 2f, height / 2f); + spriteBatch.Draw(texture, drawPos, frame, Color.White, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.ExoDebuffs(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.ExoDebuffs(); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.ExoDebuffs(); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); + } + } } diff --git a/Projectiles/Rogue/SupernovaHoming.cs b/Projectiles/Rogue/SupernovaHoming.cs index b7708e3b87..4dd8871b0e 100644 --- a/Projectiles/Rogue/SupernovaHoming.cs +++ b/Projectiles/Rogue/SupernovaHoming.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SupernovaHoming : ModProjectile + public class SupernovaHoming : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -20,17 +20,17 @@ namespace CalamityMod.Projectiles.Rogue projectile.friendly = true; projectile.penetrate = 1; projectile.tileCollide = false; - projectile.Calamity().rogue = true; + projectile.Calamity().rogue = true; } public override void AI() { int num154 = 14; - int num298 = Main.rand.NextBool(2) ? 107 : 234; - if (Main.rand.NextBool(4)) - { - num298 = 269; - } + int num298 = Main.rand.NextBool(2) ? 107 : 234; + if (Main.rand.NextBool(4)) + { + num298 = 269; + } projectile.ai[0] += 1; if (projectile.ai[0] % 2 == 0) { @@ -47,30 +47,30 @@ namespace CalamityMod.Projectiles.Rogue { projectile.extraUpdates = 1; - Vector2 center = projectile.Center; - float maxDistance = 500f; - bool homeIn = false; + Vector2 center = projectile.Center; + float maxDistance = 500f; + 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) + (float)(Main.npc[i].height / 2); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) - { - center = Main.npc[i].Center; - homeIn = true; - break; - } - } - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + { + center = Main.npc[i].Center; + homeIn = true; + break; + } + } + } - if (homeIn) + if (homeIn) { Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); projectile.velocity = (projectile.velocity * 20f + moveDirection * 12f) / (21f); - } + } else projectile.Kill(); } @@ -102,12 +102,12 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } } } diff --git a/Projectiles/Rogue/SupernovaSpike.cs b/Projectiles/Rogue/SupernovaSpike.cs index 7fa6d3ede1..2044f9a597 100644 --- a/Projectiles/Rogue/SupernovaSpike.cs +++ b/Projectiles/Rogue/SupernovaSpike.cs @@ -40,11 +40,11 @@ namespace CalamityMod.Projectiles.Rogue { projectile.alpha = 0; } - int num298 = Main.rand.NextBool(2) ? 107 : 234; - if (Main.rand.NextBool(4)) - { - num298 = 269; - } + int num298 = Main.rand.NextBool(2) ? 107 : 234; + if (Main.rand.NextBool(4)) + { + num298 = 269; + } projectile.localAI[1] += 1f; if (projectile.localAI[1] > 4f) { @@ -63,12 +63,12 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } internal static void Visuals(Projectile projectile, ref Color c) @@ -103,11 +103,11 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = projectile.height = 32; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - int num298 = Main.rand.NextBool(2) ? 107 : 234; - if (Main.rand.NextBool(4)) - { - num298 = 269; - } + int num298 = Main.rand.NextBool(2) ? 107 : 234; + if (Main.rand.NextBool(4)) + { + num298 = 269; + } for (int num621 = 0; num621 < 2; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num298, 0f, 0f, 100, default, 1.2f); diff --git a/Projectiles/Rogue/SylvanSlash.cs b/Projectiles/Rogue/SylvanSlash.cs index 141448cb15..85c0ed115e 100644 --- a/Projectiles/Rogue/SylvanSlash.cs +++ b/Projectiles/Rogue/SylvanSlash.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class SylvanSlash : ModProjectile + public class SylvanSlash : ModProjectile { public override void SetStaticDefaults() { @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 200; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.tileCollide = false; + projectile.tileCollide = false; } public override void AI() @@ -49,10 +49,10 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 195) - return false; + if (projectile.timeLeft > 195) + return false; - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); return false; } diff --git a/Projectiles/Rogue/SylvanSlashAttack.cs b/Projectiles/Rogue/SylvanSlashAttack.cs index 12186cdbdf..cdedb3c3d5 100644 --- a/Projectiles/Rogue/SylvanSlashAttack.cs +++ b/Projectiles/Rogue/SylvanSlashAttack.cs @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 68; projectile.height = 68; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.tileCollide = false; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - if (Main.myPlayer != projectile.owner) - return; + if (Main.myPlayer != projectile.owner) + return; Player player = Main.player[projectile.owner]; float num = 0f; @@ -50,30 +50,30 @@ namespace CalamityMod.Projectiles.Rogue Main.PlaySound(SoundID.Item15, projectile.Center); projectile.soundDelay = 24; } - 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(); - } + 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)) @@ -92,68 +92,68 @@ namespace CalamityMod.Projectiles.Rogue player.itemAnimation = 2; player.itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); - if (projectile.ai[0] > 0) - projectile.ai[0]--; + if (projectile.ai[0] > 0) + projectile.ai[0]--; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (projectile.owner == Main.myPlayer) - { - if (projectile.ai[0] <= 0f) - { - if ((target.damage > 5 || target.boss) && !target.SpawnedFromStatue) - { - if (modPlayer.wearingRogueArmor && modPlayer.rogueStealthMax != 0) - { - if (modPlayer.rogueStealth < modPlayer.rogueStealthMax) - { - modPlayer.rogueStealth += 0.05f; - projectile.ai[0] = 3f; - if (modPlayer.rogueStealth > modPlayer.rogueStealthMax) - modPlayer.rogueStealth = modPlayer.rogueStealthMax; - } - } - } - } - if (Main.rand.NextBool(8)) - { - float speedMult = Main.rand.NextFloat(3,6); + if (projectile.owner == Main.myPlayer) + { + if (projectile.ai[0] <= 0f) + { + if ((target.damage > 5 || target.boss) && !target.SpawnedFromStatue) + { + if (modPlayer.wearingRogueArmor && modPlayer.rogueStealthMax != 0) + { + if (modPlayer.rogueStealth < modPlayer.rogueStealthMax) + { + modPlayer.rogueStealth += 0.05f; + projectile.ai[0] = 3f; + if (modPlayer.rogueStealth > modPlayer.rogueStealthMax) + modPlayer.rogueStealth = modPlayer.rogueStealthMax; + } + } + } + } + if (Main.rand.NextBool(8)) + { + float speedMult = Main.rand.NextFloat(3,6); Vector2 vector1 = new Vector2(projectile.Center.X - player.Center.X, projectile.Center.Y - player.Center.Y); vector1.Normalize(); - Projectile.NewProjectile(player.Center.X, player.Center.Y, -vector1.X * speedMult, -vector1.Y * speedMult, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); - } - } - } + Projectile.NewProjectile(player.Center.X, player.Center.Y, -vector1.X * speedMult, -vector1.Y * speedMult, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); + } + } + } - public override void OnHitPvp(Player target, int damage, bool crit) + public override void OnHitPvp(Player target, int damage, bool crit) { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (projectile.owner == Main.myPlayer) - { - if (projectile.ai[0] <= 0f) - { - if (modPlayer.wearingRogueArmor && modPlayer.rogueStealthMax != 0) - { - if (modPlayer.rogueStealth < modPlayer.rogueStealthMax) - { - modPlayer.rogueStealth += 0.05f; - if (modPlayer.rogueStealth > modPlayer.rogueStealthMax) - modPlayer.rogueStealth = modPlayer.rogueStealthMax; - } - } - } - if (Main.rand.NextBool(8)) - { - float speedMult = Main.rand.NextFloat(3,6); + if (projectile.owner == Main.myPlayer) + { + if (projectile.ai[0] <= 0f) + { + if (modPlayer.wearingRogueArmor && modPlayer.rogueStealthMax != 0) + { + if (modPlayer.rogueStealth < modPlayer.rogueStealthMax) + { + modPlayer.rogueStealth += 0.05f; + if (modPlayer.rogueStealth > modPlayer.rogueStealthMax) + modPlayer.rogueStealth = modPlayer.rogueStealthMax; + } + } + } + if (Main.rand.NextBool(8)) + { + float speedMult = Main.rand.NextFloat(3,6); Vector2 vector1 = new Vector2(projectile.Center.X - player.Center.X, projectile.Center.Y - player.Center.Y); vector1.Normalize(); - Projectile.NewProjectile(player.Center.X, player.Center.Y, -vector1.X * speedMult, -vector1.Y * speedMult, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); - } - } - } + Projectile.NewProjectile(player.Center.X, player.Center.Y, -vector1.X * speedMult, -vector1.Y * speedMult, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); + } + } + } } } diff --git a/Projectiles/Rogue/TalonLargeProj.cs b/Projectiles/Rogue/TalonLargeProj.cs index 1de7c63a9b..4851f42e86 100644 --- a/Projectiles/Rogue/TalonLargeProj.cs +++ b/Projectiles/Rogue/TalonLargeProj.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class TalonLargeProj : ModProjectile + public class TalonLargeProj : ModProjectile { public override void SetStaticDefaults() { @@ -20,12 +20,12 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 10; + projectile.ignoreWater = true; + projectile.penetrate = 10; projectile.tileCollide = false; projectile.timeLeft = 180; projectile.Calamity().rogue = true; - projectile.extraUpdates = 2; + projectile.extraUpdates = 2; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } diff --git a/Projectiles/Rogue/TalonSmallProj.cs b/Projectiles/Rogue/TalonSmallProj.cs index 9287484d4f..8229349373 100644 --- a/Projectiles/Rogue/TalonSmallProj.cs +++ b/Projectiles/Rogue/TalonSmallProj.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.friendly = true; projectile.penetrate = 1; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 600; + projectile.ignoreWater = true; + projectile.timeLeft = 600; projectile.Calamity().rogue = true; SineFrequency = 0.15f; diff --git a/Projectiles/Rogue/TarraThornRight.cs b/Projectiles/Rogue/TarraThornRight.cs index 80883ed70a..375ba43b03 100644 --- a/Projectiles/Rogue/TarraThornRight.cs +++ b/Projectiles/Rogue/TarraThornRight.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class TarraThornRight : ModProjectile + public class TarraThornRight : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Magic/NettleRight"; @@ -15,60 +15,60 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - projectile.width = 28; - projectile.height = 28; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.Calamity().rogue = true; + projectile.width = 28; + projectile.height = 28; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.Calamity().rogue = true; projectile.usesIDStaticNPCImmunity = true; projectile.idStaticNPCHitCooldown = 10; - projectile.aiStyle = 4; + projectile.aiStyle = 4; } - public override void AI() - { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; - if (projectile.ai[0] == 0f) - { - projectile.alpha -= 50; - if (projectile.alpha > 0) - return; - projectile.alpha = 0; - projectile.ai[0] = 1f; - if (projectile.ai[1] == 0f) - { - projectile.ai[1] += 1f; - projectile.position += projectile.velocity * 1f; - } - if (Main.myPlayer == projectile.owner) - { - int type = projectile.type; - if (projectile.ai[1] >= 10f) - type = ModContent.ProjectileType(); - int number = Projectile.NewProjectile(projectile.position.X + projectile.velocity.X + (float)(projectile.width / 2), projectile.position.Y + projectile.velocity.Y + (float)(projectile.height / 2), projectile.velocity.X, projectile.velocity.Y, type, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[number].ai[1] = projectile.ai[1] + 1f; - } - } - else - { - if (projectile.alpha < 170 && projectile.alpha + 5 >= 170) - { - for (int index1 = 0; index1 < 8; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 7, projectile.velocity.X * 0.025f, projectile.velocity.Y * 0.025f, 200, new Color(), 1.3f); - Dust dust = Main.dust[index2]; - dust.noGravity = true; - dust.velocity *= 0.5f; - } - } - projectile.alpha += 3; - if (projectile.alpha < 255) - return; - projectile.Kill(); - } - } + public override void AI() + { + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; + if (projectile.ai[0] == 0f) + { + projectile.alpha -= 50; + if (projectile.alpha > 0) + return; + projectile.alpha = 0; + projectile.ai[0] = 1f; + if (projectile.ai[1] == 0f) + { + projectile.ai[1] += 1f; + projectile.position += projectile.velocity * 1f; + } + if (Main.myPlayer == projectile.owner) + { + int type = projectile.type; + if (projectile.ai[1] >= 10f) + type = ModContent.ProjectileType(); + int number = Projectile.NewProjectile(projectile.position.X + projectile.velocity.X + (float)(projectile.width / 2), projectile.position.Y + projectile.velocity.Y + (float)(projectile.height / 2), projectile.velocity.X, projectile.velocity.Y, type, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Main.projectile[number].ai[1] = projectile.ai[1] + 1f; + } + } + else + { + if (projectile.alpha < 170 && projectile.alpha + 5 >= 170) + { + for (int index1 = 0; index1 < 8; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 7, projectile.velocity.X * 0.025f, projectile.velocity.Y * 0.025f, 200, new Color(), 1.3f); + Dust dust = Main.dust[index2]; + dust.noGravity = true; + dust.velocity *= 0.5f; + } + } + projectile.alpha += 3; + if (projectile.alpha < 255) + return; + projectile.Kill(); + } + } } } diff --git a/Projectiles/Rogue/TarraThornTip.cs b/Projectiles/Rogue/TarraThornTip.cs index 60d4e4bfc8..1f8efc7925 100644 --- a/Projectiles/Rogue/TarraThornTip.cs +++ b/Projectiles/Rogue/TarraThornTip.cs @@ -2,7 +2,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class TarraThornTip : ModProjectile + public class TarraThornTip : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Magic/NettleTip"; @@ -13,18 +13,18 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - projectile.width = 28; - projectile.height = 28; - projectile.aiStyle = 4; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.Calamity().rogue = true; + projectile.width = 28; + projectile.height = 28; + projectile.aiStyle = 4; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - aiType = ProjectileID.NettleBurstEnd; + aiType = ProjectileID.NettleBurstEnd; } } } diff --git a/Projectiles/Rogue/TarragonThrowingDartProjectile.cs b/Projectiles/Rogue/TarragonThrowingDartProjectile.cs index 6407eb637f..c3dd9b8259 100644 --- a/Projectiles/Rogue/TarragonThrowingDartProjectile.cs +++ b/Projectiles/Rogue/TarragonThrowingDartProjectile.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 6; + projectile.ignoreWater = true; + projectile.penetrate = 6; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; diff --git a/Projectiles/Rogue/TerraDiskProjectile.cs b/Projectiles/Rogue/TerraDiskProjectile.cs index 40cf6c04ae..f93ca3955f 100644 --- a/Projectiles/Rogue/TerraDiskProjectile.cs +++ b/Projectiles/Rogue/TerraDiskProjectile.cs @@ -7,55 +7,55 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class TerraDiskProjectile : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/TerraDisk"; + public class TerraDiskProjectile : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/TerraDisk"; - private bool initialized = false; + private bool initialized = false; private int Lifetime = 180; private int ReboundTime = 45; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Terra Disk"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Terra Disk"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 46; - projectile.ignoreWater = true; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.penetrate = -1; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 46; + projectile.ignoreWater = true; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.penetrate = -1; + projectile.Calamity().rogue = true; + } - public override void AI() - { - Initialize(); - BoomerangAI(); - StealthStrikeAI(); - SpawnProjectilesNearEnemies(); - LightingandDust(); - } + public override void AI() + { + Initialize(); + BoomerangAI(); + StealthStrikeAI(); + SpawnProjectilesNearEnemies(); + LightingandDust(); + } - private void Initialize() - { - if (initialized) - return; + private void Initialize() + { + if (initialized) + return; - Lifetime = projectile.Calamity().stealthStrike ? 360 : 180; - ReboundTime = projectile.Calamity().stealthStrike ? 90 : 45; - projectile.timeLeft = Lifetime; - initialized = true; - } + Lifetime = projectile.Calamity().stealthStrike ? 360 : 180; + ReboundTime = projectile.Calamity().stealthStrike ? 90 : 45; + projectile.timeLeft = Lifetime; + initialized = true; + } - private void BoomerangAI() - { + private void BoomerangAI() + { // Boomerang rotation projectile.rotation += 0.4f * projectile.direction; @@ -72,22 +72,22 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.ai[0] == 1f) { - //Ignore tiles and fly faster + //Ignore tiles and fly faster projectile.tileCollide = false; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; Player player = Main.player[projectile.owner]; float returnSpeed = 16f; float acceleration = 1.4f; - Vector2 playerVec = player.Center - projectile.Center; + Vector2 playerVec = player.Center - projectile.Center; float dist = playerVec.Length(); // Delete the projectile if it's excessively far away. if (dist > 3000f) projectile.Kill(); - playerVec.Normalize(); - playerVec *= returnSpeed; + playerVec.Normalize(); + playerVec *= returnSpeed; // Home back in on the player. if (projectile.velocity.X < playerVec.X) @@ -120,92 +120,92 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.Hitbox.Intersects(player.Hitbox)) projectile.Kill(); } - } + } - private void StealthStrikeAI() - { - if (!projectile.Calamity().stealthStrike) - return; + private void StealthStrikeAI() + { + if (!projectile.Calamity().stealthStrike) + return; - if (projectile.timeLeft % 8f == 0f && Main.myPlayer == projectile.owner) - { - int disk = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 4, projectile.knockBack / 4f, projectile.owner, projectile.identity, Main.rand.NextFloat(0.02f, 0.1f)); - Main.projectile[disk].timeLeft *= 2; - Main.projectile[disk].idStaticNPCHitCooldown = 8; - Main.projectile[disk].usesIDStaticNPCImmunity = true; - Main.projectile[disk].aiStyle = -1; - } - } + if (projectile.timeLeft % 8f == 0f && Main.myPlayer == projectile.owner) + { + int disk = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 4, projectile.knockBack / 4f, projectile.owner, projectile.identity, Main.rand.NextFloat(0.02f, 0.1f)); + Main.projectile[disk].timeLeft *= 2; + Main.projectile[disk].idStaticNPCHitCooldown = 8; + Main.projectile[disk].usesIDStaticNPCImmunity = true; + Main.projectile[disk].aiStyle = -1; + } + } - private void SpawnProjectilesNearEnemies() - { - if (!projectile.friendly) - return; + private void SpawnProjectilesNearEnemies() + { + if (!projectile.friendly) + return; - const float maxDistance = 300f; - bool homeIn = false; + const float maxDistance = 300f; + bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDistance = npc.width / 2 + npc.height / 2; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = npc.width / 2 + npc.height / 2; - bool canHit = true; - if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (Vector2.Distance(npc.Center, projectile.Center) < maxDistance + extraDistance && canHit) - { - homeIn = true; - break; - } - } - } + if (Vector2.Distance(npc.Center, projectile.Center) < maxDistance + extraDistance && canHit) + { + homeIn = true; + break; + } + } + } - if (homeIn) - { - if (Main.player[projectile.owner].miscCounter % 50 == 0) - { - int splitProj = ModContent.ProjectileType(); - if (projectile.owner == Main.myPlayer) - { - float spread = 60f * 0.0174f; - double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; - double deltaAngle = spread / 6f; - double offsetAngle; - for (int i = 0; i < 3; 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), splitProj, projectile.damage / 2, projectile.knockBack / 2f, projectile.owner); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage / 2, projectile.knockBack / 2f, projectile.owner); - } - } - } - } - } + if (homeIn) + { + if (Main.player[projectile.owner].miscCounter % 50 == 0) + { + int splitProj = ModContent.ProjectileType(); + if (projectile.owner == Main.myPlayer) + { + float spread = 60f * 0.0174f; + double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; + double deltaAngle = spread / 6f; + double offsetAngle; + for (int i = 0; i < 3; 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), splitProj, projectile.damage / 2, projectile.knockBack / 2f, projectile.owner); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage / 2, projectile.knockBack / 2f, projectile.owner); + } + } + } + } + } - private void LightingandDust() - { - Lighting.AddLight(projectile.Center, 0f, 0.75f, 0f); - if (!Main.rand.NextBool(5)) - return; - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107, projectile.velocity.X, projectile.velocity.Y); - } + private void LightingandDust() + { + Lighting.AddLight(projectile.Center, 0f, 0.75f, 0f); + if (!Main.rand.NextBool(5)) + return; + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107, projectile.velocity.X, projectile.velocity.Y); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + return false; + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { // Return to the player after striking an enemy. Stealth strikes don't return immediately. - if (!projectile.Calamity().stealthStrike || projectile.ai[1] > 3) - projectile.ai[0] = 1f; - projectile.ai[1]++; + if (!projectile.Calamity().stealthStrike || projectile.ai[1] > 3) + projectile.ai[0] = 1f; + projectile.ai[1]++; } // Make it bounce on tiles. @@ -226,5 +226,5 @@ namespace CalamityMod.Projectiles.Rogue projectile.ai[0] = 1f; return false; } - } + } } diff --git a/Projectiles/Rogue/TerraDiskProjectile2.cs b/Projectiles/Rogue/TerraDiskProjectile2.cs index a87f3ff0c8..838816955d 100644 --- a/Projectiles/Rogue/TerraDiskProjectile2.cs +++ b/Projectiles/Rogue/TerraDiskProjectile2.cs @@ -6,92 +6,92 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class TerraDiskProjectile2 : ModProjectile - { + public class TerraDiskProjectile2 : ModProjectile + { private double rotation = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Terra Disk"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Terra Disk"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } - public override void SetDefaults() - { - projectile.width = 40; - projectile.height = 40; - projectile.alpha = 75; - projectile.ignoreWater = true; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.aiStyle = 3; - projectile.timeLeft = 60; - aiType = ProjectileID.WoodenBoomerang; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 40; + projectile.height = 40; + projectile.alpha = 75; + projectile.ignoreWater = true; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.aiStyle = 3; + projectile.timeLeft = 60; + aiType = ProjectileID.WoodenBoomerang; + projectile.Calamity().rogue = true; + } - public override void AI() - { - StealthStrikeAI(); - LightingandDust(); - } + public override void AI() + { + StealthStrikeAI(); + LightingandDust(); + } - private void StealthStrikeAI() - { - if (projectile.aiStyle == 3) - return; + private void StealthStrikeAI() + { + if (projectile.aiStyle == 3) + return; projectile.rotation += 0.4f * projectile.direction; - Projectile parent = Main.projectile[0]; - bool active = false; - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile p = Main.projectile[i]; - if (p.identity == projectile.ai[0] && p.active && p.type == ModContent.ProjectileType()) - { - parent = p; - active = true; - break; - } - } + Projectile parent = Main.projectile[0]; + bool active = false; + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile p = Main.projectile[i]; + if (p.identity == projectile.ai[0] && p.active && p.type == ModContent.ProjectileType()) + { + parent = p; + active = true; + break; + } + } - if (active) - { - Vector2 vector = parent.Center - projectile.Center; - projectile.Center = parent.Center + new Vector2(80, 0).RotatedBy(rotation); - double rotateAmt = (double)projectile.ai[1]; - rotation += rotateAmt; - if (rotation >= 360) - { - rotation = 0; - } - projectile.velocity.X = (vector.X > 0f) ? -0.000001f : 0f; - } - else - { - projectile.Kill(); - } + if (active) + { + Vector2 vector = parent.Center - projectile.Center; + projectile.Center = parent.Center + new Vector2(80, 0).RotatedBy(rotation); + double rotateAmt = (double)projectile.ai[1]; + rotation += rotateAmt; + if (rotation >= 360) + { + rotation = 0; + } + projectile.velocity.X = (vector.X > 0f) ? -0.000001f : 0f; + } + else + { + projectile.Kill(); + } - if (!parent.active) - { - projectile.Kill(); - } - } + if (!parent.active) + { + projectile.Kill(); + } + } - private void LightingandDust() - { - Lighting.AddLight(projectile.Center, 0f, 0.75f, 0f); - if (!Main.rand.NextBool(5)) - return; - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107, projectile.velocity.X, projectile.velocity.Y); - } + private void LightingandDust() + { + Lighting.AddLight(projectile.Center, 0f, 0.75f, 0f); + if (!Main.rand.NextBool(5)) + return; + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107, projectile.velocity.X, projectile.velocity.Y); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + return false; + } + } } diff --git a/Projectiles/Rogue/TheSyringeCinder.cs b/Projectiles/Rogue/TheSyringeCinder.cs index 40df8407c9..4e32884777 100644 --- a/Projectiles/Rogue/TheSyringeCinder.cs +++ b/Projectiles/Rogue/TheSyringeCinder.cs @@ -24,24 +24,24 @@ namespace CalamityMod.Projectiles.Rogue projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.Calamity().rogue = true; - projectile.alpha = 100; + projectile.alpha = 100; } public override void AI() { - //make it face the way it's going - if (projectile.ai[1] == 1f) - { - projectile.rotation += projectile.velocity.X * 0.1f; - projectile.rotation = -projectile.velocity.X * 0.05f; - } - else - { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + ((3 * MathHelper.Pi) / 2); - projectile.spriteDirection = ((projectile.velocity.X > 0f) ? -1 : 1); - } + //make it face the way it's going + if (projectile.ai[1] == 1f) + { + projectile.rotation += projectile.velocity.X * 0.1f; + projectile.rotation = -projectile.velocity.X * 0.05f; + } + else + { + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + ((3 * MathHelper.Pi) / 2); + projectile.spriteDirection = ((projectile.velocity.X > 0f) ? -1 : 1); + } - //frames + //frames projectile.frameCounter++; if (projectile.frameCounter > 6) { @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.frame = 0; } - //movement + //movement if (projectile.velocity.X != projectile.velocity.X) { projectile.velocity.X = projectile.velocity.X * -0.1f; @@ -81,16 +81,16 @@ namespace CalamityMod.Projectiles.Rogue } projectile.velocity.Y = projectile.velocity.Y + 0.2f; } - if (Main.rand.NextBool(4)) - { - int num199 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 1f); - 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 -= 2f; - } + if (Main.rand.NextBool(4)) + { + int num199 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 1f); + 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 -= 2f; + } if (Main.rand.NextBool(10)) { int num200 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 1f); @@ -113,7 +113,7 @@ namespace CalamityMod.Projectiles.Rogue public override bool OnTileCollide(Vector2 oldVelocity) { - projectile.ai[1] = 1f; + projectile.ai[1] = 1f; return false; } diff --git a/Projectiles/Rogue/TheSyringeProj.cs b/Projectiles/Rogue/TheSyringeProj.cs index 442c6567f3..e1f5559b5a 100644 --- a/Projectiles/Rogue/TheSyringeProj.cs +++ b/Projectiles/Rogue/TheSyringeProj.cs @@ -14,8 +14,8 @@ namespace CalamityMod.Projectiles.Rogue public override void SetStaticDefaults() { DisplayName.SetDefault("Syringe"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; } public override void SetDefaults() @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Rogue Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.Next(2) == 1 ? 107 : 89, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); projectile.damage += projectile.Calamity().defDamage / 200; - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 100); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 100); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Rogue { for (int f = 0; f < fireAmt; f++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, Main.myPlayer); } for (int s = 0; s < 2; ++s) @@ -92,9 +92,9 @@ namespace CalamityMod.Projectiles.Rogue float speedX = Main.rand.NextFloat(-0.7f, 0.7f); float speedY = Main.rand.NextFloat(-0.7f, 0.7f); int bee = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speedX, speedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, Main.myPlayer); - Main.projectile[bee].penetrate = 1; + Main.projectile[bee].penetrate = 1; } } - } + } } } diff --git a/Projectiles/Rogue/TheSyringeS1.cs b/Projectiles/Rogue/TheSyringeS1.cs index a3eb0bb390..3d622fc888 100644 --- a/Projectiles/Rogue/TheSyringeS1.cs +++ b/Projectiles/Rogue/TheSyringeS1.cs @@ -6,63 +6,63 @@ using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Rogue { - public class TheSyringeS1 : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shrapnel"); - Main.projFrames[projectile.type] = 3; - } + public class TheSyringeS1 : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shrapnel"); + Main.projFrames[projectile.type] = 3; + } - public override void SetDefaults() - { - projectile.width = 6; - projectile.height = 6; - projectile.aiStyle = 24; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.light = 0.5f; - projectile.alpha = 50; - projectile.scale = 1.2f; - projectile.timeLeft = 180; - projectile.tileCollide = false; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 6; + projectile.height = 6; + projectile.aiStyle = 24; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.light = 0.5f; + projectile.alpha = 50; + projectile.scale = 1.2f; + projectile.timeLeft = 180; + projectile.tileCollide = false; + projectile.Calamity().rogue = true; + } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void PostAI() - { - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 10f, 20f); - } + public override void PostAI() + { + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 10f, 20f); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - //Changes the texture of the projectile - if (projectile.ai[0] == 1f) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/TheSyringeS2"); - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, 6)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, 20 / 2f), projectile.scale, SpriteEffects.None, 0f); - return false; - } - if (projectile.ai[0] == 2f) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/TheSyringeS3"); - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, 6)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, 20 / 2f), projectile.scale, SpriteEffects.None, 0f); - return false; - } - return true; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + //Changes the texture of the projectile + if (projectile.ai[0] == 1f) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/TheSyringeS2"); + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, 6)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, 20 / 2f), projectile.scale, SpriteEffects.None, 0f); + return false; + } + if (projectile.ai[0] == 2f) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/TheSyringeS3"); + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, 6)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, 20 / 2f), projectile.scale, SpriteEffects.None, 0f); + return false; + } + return true; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 120); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 120); + } + } } diff --git a/Projectiles/Rogue/TimeBoltKnife.cs b/Projectiles/Rogue/TimeBoltKnife.cs index 0d9804ebc2..db619c1434 100644 --- a/Projectiles/Rogue/TimeBoltKnife.cs +++ b/Projectiles/Rogue/TimeBoltKnife.cs @@ -12,9 +12,9 @@ namespace CalamityMod.Projectiles.Rogue { public override string Texture => "CalamityMod/Items/Weapons/Rogue/TimeBolt"; - private int maxPenetrate = 6; + private int maxPenetrate = 6; private int penetrationAmt = 6; - private bool initialized = false; + private bool initialized = false; public override void SetStaticDefaults() { @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 28; projectile.height = 28; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = penetrationAmt; + projectile.ignoreWater = true; + projectile.penetrate = penetrationAmt; projectile.timeLeft = 600; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; @@ -48,15 +48,15 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - if (!initialized) - { - if (projectile.Calamity().stealthStrike) - { - maxPenetrate = 11; - penetrationAmt = maxPenetrate; - } - initialized = true; - } + if (!initialized) + { + if (projectile.Calamity().stealthStrike) + { + maxPenetrate = 11; + penetrationAmt = maxPenetrate; + } + initialized = true; + } projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.03f; @@ -289,10 +289,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) @@ -317,8 +317,8 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.Calamity().stealthStrike) - target.AddBuff(ModContent.BuffType(), 120); + if (projectile.Calamity().stealthStrike) + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/Rogue/TitaniumClone.cs b/Projectiles/Rogue/TitaniumClone.cs index 6692827311..6cf49362b3 100644 --- a/Projectiles/Rogue/TitaniumClone.cs +++ b/Projectiles/Rogue/TitaniumClone.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class TitaniumClone : ModProjectile + public class TitaniumClone : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/TitaniumShuriken"; @@ -27,18 +27,18 @@ namespace CalamityMod.Projectiles.Rogue projectile.tileCollide = false; projectile.timeLeft = 200; projectile.Calamity().rogue = true; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() { - projectile.rotation += RotationIncrement; + projectile.rotation += RotationIncrement; projectile.ai[0] += 1f; if (projectile.ai[0] > 30f) { - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); - } - } + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + } + } public override bool CanDamage() => projectile.ai[0] >= 30f; diff --git a/Projectiles/Rogue/TitaniumShurikenProjectile.cs b/Projectiles/Rogue/TitaniumShurikenProjectile.cs index 0fcbacdff2..5bc0f36384 100644 --- a/Projectiles/Rogue/TitaniumShurikenProjectile.cs +++ b/Projectiles/Rogue/TitaniumShurikenProjectile.cs @@ -38,96 +38,96 @@ namespace CalamityMod.Projectiles.Rogue { if (projectile.Calamity().stealthStrike) { - drawOffsetX = -11; - drawOriginOffsetY = -10; - drawOriginOffsetX = 0; + drawOffsetX = -11; + drawOriginOffsetY = -10; + drawOriginOffsetX = 0; - // ai[0] stores whether the knife is returning. If 0, it isn't. If 1, it is. - if (projectile.ai[0] == 0f) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] >= ReboundTime) - { - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - } - else - { - projectile.tileCollide = false; - float returnSpeed = 16f; - float acceleration = 3.2f; - Player owner = Main.player[projectile.owner]; + // ai[0] stores whether the knife is returning. If 0, it isn't. If 1, it is. + if (projectile.ai[0] == 0f) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] >= ReboundTime) + { + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + } + else + { + projectile.tileCollide = false; + float returnSpeed = 16f; + float acceleration = 3.2f; + Player owner = Main.player[projectile.owner]; - // Delete the shuriken if it's excessively far away. - Vector2 playerCenter = owner.Center; - float xDist = playerCenter.X - projectile.Center.X; - float yDist = playerCenter.Y - projectile.Center.Y; - float dist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - if (dist > 3000f) - projectile.Kill(); + // Delete the shuriken if it's excessively far away. + Vector2 playerCenter = owner.Center; + float xDist = playerCenter.X - projectile.Center.X; + float yDist = playerCenter.Y - projectile.Center.Y; + float dist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); + if (dist > 3000f) + projectile.Kill(); - dist = returnSpeed / dist; - xDist *= dist; - yDist *= dist; + dist = returnSpeed / dist; + xDist *= dist; + yDist *= dist; - // Home back in on the player. - if (projectile.velocity.X < xDist) - { - projectile.velocity.X = projectile.velocity.X + acceleration; - if (projectile.velocity.X < 0f && xDist > 0f) - projectile.velocity.X += acceleration; - } - else if (projectile.velocity.X > xDist) - { - projectile.velocity.X = projectile.velocity.X - acceleration; - if (projectile.velocity.X > 0f && xDist < 0f) - projectile.velocity.X -= acceleration; - } - if (projectile.velocity.Y < yDist) - { - projectile.velocity.Y = projectile.velocity.Y + acceleration; - if (projectile.velocity.Y < 0f && yDist > 0f) - projectile.velocity.Y += acceleration; - } - else if (projectile.velocity.Y > yDist) - { - projectile.velocity.Y = projectile.velocity.Y - acceleration; - if (projectile.velocity.Y > 0f && yDist < 0f) - projectile.velocity.Y -= acceleration; - } + // Home back in on the player. + if (projectile.velocity.X < xDist) + { + projectile.velocity.X = projectile.velocity.X + acceleration; + if (projectile.velocity.X < 0f && xDist > 0f) + projectile.velocity.X += acceleration; + } + else if (projectile.velocity.X > xDist) + { + projectile.velocity.X = projectile.velocity.X - acceleration; + if (projectile.velocity.X > 0f && xDist < 0f) + projectile.velocity.X -= acceleration; + } + if (projectile.velocity.Y < yDist) + { + projectile.velocity.Y = projectile.velocity.Y + acceleration; + if (projectile.velocity.Y < 0f && yDist > 0f) + projectile.velocity.Y += acceleration; + } + else if (projectile.velocity.Y > yDist) + { + projectile.velocity.Y = projectile.velocity.Y - acceleration; + if (projectile.velocity.Y > 0f && yDist < 0f) + projectile.velocity.Y -= acceleration; + } - // Delete the projectile if it touches its owner. - if (Main.myPlayer == projectile.owner) - if (projectile.Hitbox.Intersects(owner.Hitbox)) - { - projectile.Kill(); //boomerangs return to you so you get a refund - Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, ModContent.ItemType()); - } - } + // Delete the projectile if it touches its owner. + if (Main.myPlayer == projectile.owner) + if (projectile.Hitbox.Intersects(owner.Hitbox)) + { + projectile.Kill(); //boomerangs return to you so you get a refund + Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, ModContent.ItemType()); + } + } - // Rotate the shuriken as it flies. - projectile.rotation += RotationIncrement; - return; - } + // Rotate the shuriken as it flies. + projectile.rotation += RotationIncrement; + return; + } } public override bool OnTileCollide(Vector2 oldVelocity) { - if (projectile.Calamity().stealthStrike) - { - if (projectile.velocity.X != oldVelocity.X) - { - projectile.velocity.X = -oldVelocity.X; - } - if (projectile.velocity.Y != oldVelocity.Y) - { - projectile.velocity.Y = -oldVelocity.Y; - } - return false; - } - return true; + if (projectile.Calamity().stealthStrike) + { + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y; + } + return false; + } + return true; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -137,10 +137,10 @@ namespace CalamityMod.Projectiles.Rogue { CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); } - else - { - spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); - } + else + { + spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + } return false; } @@ -154,34 +154,34 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) - { - int projNumber = Main.rand.Next(1,3); - for (int index2 = 0; index2 < projNumber; index2++) - { - float xVector = (float)Main.rand.Next(-35, 36) * 0.02f; - float yVector = (float)Main.rand.Next(-35, 36) * 0.02f; - xVector *= 10f; - yVector *= 10f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - } - } + if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) + { + int projNumber = Main.rand.Next(1,3); + for (int index2 = 0; index2 < projNumber; index2++) + { + float xVector = (float)Main.rand.Next(-35, 36) * 0.02f; + float yVector = (float)Main.rand.Next(-35, 36) * 0.02f; + xVector *= 10f; + yVector *= 10f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + } + } } public override void OnHitPvp(Player target, int damage, bool crit) { - if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) - { - int projNumber = Main.rand.Next(1,3); - for (int index2 = 0; index2 < projNumber; index2++) - { - float xVector = (float)Main.rand.Next(-35, 36) * 0.02f; - float yVector = (float)Main.rand.Next(-35, 36) * 0.02f; - xVector *= 10f; - yVector *= 10f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - } - } + if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) + { + int projNumber = Main.rand.Next(1,3); + for (int index2 = 0; index2 < projNumber; index2++) + { + float xVector = (float)Main.rand.Next(-35, 36) * 0.02f; + float yVector = (float)Main.rand.Next(-35, 36) * 0.02f; + xVector *= 10f; + yVector *= 10f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + } + } } } } diff --git a/Projectiles/Rogue/ToothBallProjectile.cs b/Projectiles/Rogue/ToothBallProjectile.cs index 7714c27ed4..54337eb7ce 100644 --- a/Projectiles/Rogue/ToothBallProjectile.cs +++ b/Projectiles/Rogue/ToothBallProjectile.cs @@ -45,10 +45,10 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) - { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, -10f, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner, 1f, 0f); - } + if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) + { + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, -10f, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner, 1f, 0f); + } } } } diff --git a/Projectiles/Rogue/TotalMeltdown.cs b/Projectiles/Rogue/TotalMeltdown.cs index d1dca2b04a..86af54f637 100644 --- a/Projectiles/Rogue/TotalMeltdown.cs +++ b/Projectiles/Rogue/TotalMeltdown.cs @@ -3,7 +3,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class TotalMeltdown : ModProjectile + public class TotalMeltdown : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Rogue/TotalityFire.cs b/Projectiles/Rogue/TotalityFire.cs index 4c76946b7a..4d9a445f15 100644 --- a/Projectiles/Rogue/TotalityFire.cs +++ b/Projectiles/Rogue/TotalityFire.cs @@ -6,9 +6,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class TotalityFire : ModProjectile + public class TotalityFire : ModProjectile { - private bool initialized = false; + private bool initialized = false; public override void SetStaticDefaults() { @@ -28,28 +28,28 @@ namespace CalamityMod.Projectiles.Rogue projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; projectile.Calamity().rogue = true; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } public override void AI() { - //make it face the way it's going - if (projectile.ai[1] > 0f) - { - projectile.rotation = -projectile.velocity.X * 0.05f + MathHelper.PiOver2; - } - else - { - projectile.rotation = projectile.velocity.ToRotation(); - } - projectile.ai[1]--; + //make it face the way it's going + if (projectile.ai[1] > 0f) + { + projectile.rotation = -projectile.velocity.X * 0.05f + MathHelper.PiOver2; + } + else + { + projectile.rotation = projectile.velocity.ToRotation(); + } + projectile.ai[1]--; - //frames - if (!initialized) - { - initialized = true; - projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); - } + //frames + if (!initialized) + { + initialized = true; + projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); + } projectile.frameCounter++; if (projectile.frameCounter > 6) { @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.frame = 0; } - //movement + //movement if (projectile.velocity.X != projectile.velocity.X) { projectile.velocity.X *= -0.1f; @@ -98,17 +98,17 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.Y = 16f; } - //dust - if (Main.rand.NextBool(4)) - { - int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[fire]; - dust.position.X -= 2f; - dust.position.Y += 2f; - dust.scale += (float)Main.rand.Next(50) * 0.01f; - dust.noGravity = true; - dust.velocity.Y -= 2f; - } + //dust + if (Main.rand.NextBool(4)) + { + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[fire]; + dust.position.X -= 2f; + dust.position.Y += 2f; + dust.scale += (float)Main.rand.Next(50) * 0.01f; + dust.noGravity = true; + dust.velocity.Y -= 2f; + } if (Main.rand.NextBool(10)) { int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f); @@ -123,7 +123,7 @@ namespace CalamityMod.Projectiles.Rogue public override bool OnTileCollide(Vector2 oldVelocity) { - projectile.ai[1] = 10f; + projectile.ai[1] = 10f; return false; } diff --git a/Projectiles/Rogue/TotalityFlask.cs b/Projectiles/Rogue/TotalityFlask.cs index 80b6cde1d2..d4a47fd807 100644 --- a/Projectiles/Rogue/TotalityFlask.cs +++ b/Projectiles/Rogue/TotalityFlask.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class TotalityFlask : ModProjectile + public class TotalityFlask : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/TotalityBreakers"; @@ -29,65 +29,65 @@ namespace CalamityMod.Projectiles.Rogue { if (projectile.Calamity().stealthStrike) { - if (projectile.timeLeft % 10 == 0) - { - if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.6), projectile.knockBack, projectile.owner, 0f, 0f); - } - } + if (projectile.timeLeft % 10 == 0) + { + if (projectile.owner == Main.myPlayer) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.6), projectile.knockBack, projectile.owner, 0f, 0f); + } + } } Vector2 spinningpoint = new Vector2(4f, -8f); float rotation = projectile.rotation; if (projectile.direction == -1) - spinningpoint.X = -4f; + spinningpoint.X = -4f; Vector2 vector2 = spinningpoint.RotatedBy((double)rotation, new Vector2()); for (int index1 = 0; index1 < 1; ++index1) { - int index2 = Dust.NewDust(projectile.Center + vector2 - Vector2.One * 5f, 4, 4, 6, 0.0f, 0.0f, 0, new Color(), 1f); - Main.dust[index2].scale = 1.5f; - Main.dust[index2].noGravity = true; - Main.dust[index2].velocity = Main.dust[index2].velocity * 0.25f + Vector2.Normalize(vector2) * 1f; - Main.dust[index2].velocity = Main.dust[index2].velocity.RotatedBy(-MathHelper.PiOver2 * (double)projectile.direction, new Vector2()); + int index2 = Dust.NewDust(projectile.Center + vector2 - Vector2.One * 5f, 4, 4, 6, 0.0f, 0.0f, 0, new Color(), 1f); + Main.dust[index2].scale = 1.5f; + Main.dust[index2].noGravity = true; + Main.dust[index2].velocity = Main.dust[index2].velocity * 0.25f + Vector2.Normalize(vector2) * 1f; + Main.dust[index2].velocity = Main.dust[index2].velocity.RotatedBy(-MathHelper.PiOver2 * (double)projectile.direction, new Vector2()); } - } + } public override void Kill(int timeLeft) { - if (projectile.owner != Main.myPlayer) - return; + if (projectile.owner != Main.myPlayer) + return; - //glass-pot break sound - Main.PlaySound(SoundID.Shatter, (int) projectile.position.X, (int) projectile.position.Y, 1, 1f, 0f); + //glass-pot break sound + Main.PlaySound(SoundID.Shatter, (int) projectile.position.X, (int) projectile.position.Y, 1, 1f, 0f); int meltdown = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[meltdown].Center = projectile.Center; //makes it centered because it's not without this + Main.projectile[meltdown].Center = projectile.Center; //makes it centered because it's not without this - Vector2 vector2 = new Vector2(20f, 20f); - for (int d = 0; d < 5; ++d) - Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 191, 0.0f, 0.0f, 0, Color.Red, 1f); - for (int d = 0; d < 10; ++d) - { - int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); - Dust dust = Main.dust[index2]; - dust.velocity *= 1.4f; - } - for (int d = 0; d < 20; ++d) - { - int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 2.5f); - Dust dust1 = Main.dust[index2]; - dust1.noGravity = true; - dust1.velocity *= 5f; - int index3 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 1.5f); - Dust dust2 = Main.dust[index3]; - dust2.velocity *= 3f; - } + Vector2 vector2 = new Vector2(20f, 20f); + for (int d = 0; d < 5; ++d) + Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 191, 0.0f, 0.0f, 0, Color.Red, 1f); + for (int d = 0; d < 10; ++d) + { + int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); + Dust dust = Main.dust[index2]; + dust.velocity *= 1.4f; + } + for (int d = 0; d < 20; ++d) + { + int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 2.5f); + Dust dust1 = Main.dust[index2]; + dust1.noGravity = true; + dust1.velocity *= 5f; + int index3 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 1.5f); + Dust dust2 = Main.dust[index3]; + dust2.velocity *= 3f; + } int tarAmt = Main.rand.Next(2, 4); - for (int t = 0; t < tarAmt; t++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, Main.myPlayer, 0f, 0f); - } + for (int t = 0; t < tarAmt; t++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, Main.myPlayer, 0f, 0f); + } } } } diff --git a/Projectiles/Rogue/TotalityTar.cs b/Projectiles/Rogue/TotalityTar.cs index 6e6d7fa30d..d7de8480bf 100644 --- a/Projectiles/Rogue/TotalityTar.cs +++ b/Projectiles/Rogue/TotalityTar.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class TotalityTar : ModProjectile + public class TotalityTar : ModProjectile { public override void SetStaticDefaults() { @@ -85,33 +85,33 @@ namespace CalamityMod.Projectiles.Rogue { Main.PlaySound(SoundID.Item74, projectile.position); Vector2 vector2 = new Vector2(20f, 20f); - for (int index = 0; index < 3; ++index) - Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 191, 0.0f, 0.0f, 0, Color.Red, 1f); - for (int index1 = 0; index1 < 5; ++index1) - { - int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); - Dust dust = Main.dust[index2]; - dust.velocity *= 1.4f; - } - for (int index1 = 0; index1 < 10; ++index1) - { - int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 2.5f); - Dust dust1 = Main.dust[index2]; - dust1.noGravity = true; - dust1.velocity *= 5f; - int index3 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 1.5f); - Dust dust2 = Main.dust[index3]; - dust2.velocity *= 3f; - } + for (int index = 0; index < 3; ++index) + Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 191, 0.0f, 0.0f, 0, Color.Red, 1f); + for (int index1 = 0; index1 < 5; ++index1) + { + int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); + Dust dust = Main.dust[index2]; + dust.velocity *= 1.4f; + } + for (int index1 = 0; index1 < 10; ++index1) + { + int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 2.5f); + Dust dust1 = Main.dust[index2]; + dust1.noGravity = true; + dust1.velocity *= 5f; + int index3 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 1.5f); + Dust dust2 = Main.dust[index3]; + dust2.velocity *= 3f; + } int fireAmt = Main.rand.Next(2, 4); if (projectile.owner == Main.myPlayer) { for (int f = 0; f < fireAmt; f++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage, 1f, Main.myPlayer, 0f, 0f); } - } + } } } } diff --git a/Projectiles/Rogue/ToxicantTwisterDust.cs b/Projectiles/Rogue/ToxicantTwisterDust.cs index 624343bb77..e71505255f 100644 --- a/Projectiles/Rogue/ToxicantTwisterDust.cs +++ b/Projectiles/Rogue/ToxicantTwisterDust.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 6; projectile.friendly = true; projectile.tileCollide = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 180; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs b/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs index d5c4121646..7a2884100c 100644 --- a/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs +++ b/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs @@ -7,12 +7,12 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class ToxicantTwisterTwoPointZero : ModProjectile + public class ToxicantTwisterTwoPointZero : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/ToxicantTwister"; - private int lifeTime = 300; - private int targetIndex = -1; + private int lifeTime = 300; + private int targetIndex = -1; public override void SetStaticDefaults() { @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 46; projectile.friendly = true; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = lifeTime; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Rogue Main.PlaySound(SoundID.Item7, projectile.position); } - projectile.ai[1]++; + projectile.ai[1]++; if (projectile.ai[0] != 0f) { float returnSpeed = 30f; @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Rogue Player owner = Main.player[projectile.owner]; // Delete the projectile if it's excessively far away. - Vector2 projVector = owner.Center - projectile.Center; + Vector2 projVector = owner.Center - projectile.Center; float dist = projVector.Length(); if (dist > 3000f) projectile.Kill(); @@ -104,38 +104,38 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.Hitbox.Intersects(owner.Hitbox)) projectile.Kill(); } - else if (projectile.ai[1] > 40f) - { - NPC closestTarget = projectile.Center.ClosestNPCAt(1769f, true, true); - if (closestTarget != null) - { - projectile.extraUpdates = 1; - targetIndex = closestTarget.whoAmI; - float inertia = 20f; - float homingVelocity = projectile.Calamity().stealthStrike ? 30f : 20f; + else if (projectile.ai[1] > 40f) + { + NPC closestTarget = projectile.Center.ClosestNPCAt(1769f, true, true); + if (closestTarget != null) + { + projectile.extraUpdates = 1; + targetIndex = closestTarget.whoAmI; + float inertia = 20f; + float homingVelocity = projectile.Calamity().stealthStrike ? 30f : 20f; Vector2 moveDirection = projectile.SafeDirectionTo(closestTarget.Center, Vector2.UnitY); projectile.velocity = (projectile.velocity * inertia + moveDirection * homingVelocity) / (inertia + 1f); - } - } - else - { + } + } + else + { projectile.velocity *= 0.985f; - } + } } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.ai[1] <= 40f && projectile.ai[0] != 1f) - { - damage /= 3; - } - } + { + if (projectile.ai[1] <= 40f && projectile.ai[0] != 1f) + { + damage /= 3; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (targetIndex == target.whoAmI) - projectile.ai[0] = 1f; + if (targetIndex == target.whoAmI) + projectile.ai[0] = 1f; target.AddBuff(ModContent.BuffType(), 180); Main.PlaySound(SoundID.Item20, projectile.position); @@ -145,7 +145,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPvp(Player target, int damage, bool crit) { - projectile.ai[0] = 1f; + projectile.ai[0] = 1f; target.AddBuff(ModContent.BuffType(), 180); Main.PlaySound(SoundID.Item20, projectile.position); for (int k = 0; k < 10; k++) diff --git a/Projectiles/Rogue/TurbulanceProjectile.cs b/Projectiles/Rogue/TurbulanceProjectile.cs index e9f7ab7c3b..67fc92639f 100644 --- a/Projectiles/Rogue/TurbulanceProjectile.cs +++ b/Projectiles/Rogue/TurbulanceProjectile.cs @@ -6,16 +6,16 @@ using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Projectiles.Rogue { - public class TurbulanceProjectile : ModProjectile + public class TurbulanceProjectile : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/Turbulance"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Turbulance"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Turbulance"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + } public override void SetDefaults() { @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - projectile.ai[0]++; - projectile.tileCollide = projectile.ai[0] >= 2f; + projectile.ai[0]++; + projectile.tileCollide = projectile.ai[0] >= 2f; projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); @@ -45,12 +45,12 @@ namespace CalamityMod.Projectiles.Rogue } if (projectile.Calamity().stealthStrike) //Stealth strike - { - if (projectile.timeLeft % 14 == 0) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack / 2, projectile.owner, 1f, 1f); - } - } + { + if (projectile.timeLeft % 14 == 0) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack / 2, projectile.owner, 1f, 1f); + } + } } public override void Kill(int timeLeft) @@ -63,31 +63,31 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(crit); - } + OnHitEffects(crit); + } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(crit); - } + OnHitEffects(crit); + } public override bool OnTileCollide(Vector2 oldVelocity) { - OnHitEffects(false); - return true; - } + OnHitEffects(false); + return true; + } - private void OnHitEffects(bool homeIn) - { + private void OnHitEffects(bool homeIn) + { if (projectile.owner == Main.myPlayer) { - for (int w = 0; w < 4; w++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, projectile.knockBack / 3, Main.myPlayer, 0f, homeIn ? 1f : 0f); - } - } - } + for (int w = 0; w < 4; w++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, projectile.knockBack / 3, Main.myPlayer, 0f, homeIn ? 1f : 0f); + } + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Rogue/TurbulanceWindSlash.cs b/Projectiles/Rogue/TurbulanceWindSlash.cs index c04ae62df1..feef78d42b 100644 --- a/Projectiles/Rogue/TurbulanceWindSlash.cs +++ b/Projectiles/Rogue/TurbulanceWindSlash.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class TurbulanceWindSlash : ModProjectile + public class TurbulanceWindSlash : ModProjectile { public override void SetStaticDefaults() { @@ -25,12 +25,12 @@ namespace CalamityMod.Projectiles.Rogue projectile.alpha = 255; projectile.ignoreWater = true; projectile.Calamity().rogue = true; - projectile.timeLeft = 180; + projectile.timeLeft = 180; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.velocity *= 0.99f; if (projectile.localAI[0] == 0f) @@ -55,14 +55,14 @@ namespace CalamityMod.Projectiles.Rogue projectile.frame = 0; } } - if (projectile.ai[0] == 1f) //stealth strike - { - projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; - } - if (projectile.ai[1] == 1f) - { - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, projectile.ai[0] == 1f ? 900f : 450f, 8f, 20f); - } + if (projectile.ai[0] == 1f) //stealth strike + { + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + } + if (projectile.ai[1] == 1f) + { + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, projectile.ai[0] == 1f ? 900f : 450f, 8f, 20f); + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/UmbraphileBoom.cs b/Projectiles/Rogue/UmbraphileBoom.cs index 972b3d8891..0540edc568 100644 --- a/Projectiles/Rogue/UmbraphileBoom.cs +++ b/Projectiles/Rogue/UmbraphileBoom.cs @@ -6,58 +6,58 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class UmbraphileBoom : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public class UmbraphileBoom : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Umbra Blast"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Umbra Blast"); + } - public override void SetDefaults() - { - projectile.width = 60; - projectile.height = 60; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.timeLeft = 5; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = -1; - } + public override void SetDefaults() + { + projectile.width = 60; + projectile.height = 60; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = 5; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; + } - public override void Kill(int timeLeft) - { - for (int s = 0; s < 20; s++) - { - int dustType = Main.rand.NextBool() ? 246 : 176; - float dustSpeed = Main.rand.NextFloat(3f, 9f); - Vector2 dustVel = CalamityUtils.RandomVelocity(10f, dustSpeed, dustSpeed, 1f); - int boom = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[boom]; - dust.noGravity = true; - dust.position = projectile.Center; - dust.position.X += (float)Main.rand.Next(-10, 11); - dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity = dustVel; - } - } + public override void Kill(int timeLeft) + { + for (int s = 0; s < 20; s++) + { + int dustType = Main.rand.NextBool() ? 246 : 176; + float dustSpeed = Main.rand.NextFloat(3f, 9f); + Vector2 dustVel = CalamityUtils.RandomVelocity(10f, dustSpeed, dustSpeed, 1f); + int boom = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[boom]; + dust.noGravity = true; + dust.position = projectile.Center; + dust.position.X += (float)Main.rand.Next(-10, 11); + dust.position.Y += (float)Main.rand.Next(-10, 11); + dust.velocity = dustVel; + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (Main.dayTime || Main.rand.NextBool(3)) //100% during day, 33.33% chance at night - target.AddBuff(BuffID.Daybreak, 60); + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (Main.dayTime || Main.rand.NextBool(3)) //100% during day, 33.33% chance at night + target.AddBuff(BuffID.Daybreak, 60); - if (!Main.dayTime || Main.rand.NextBool(3)) //100% at night, 33.33% chance during day - target.AddBuff(ModContent.BuffType(), 60); - } + if (!Main.dayTime || Main.rand.NextBool(3)) //100% at night, 33.33% chance during day + target.AddBuff(ModContent.BuffType(), 60); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - if (!Main.dayTime || Main.rand.NextBool(3)) //100% at night, 33.33% chance during day - target.AddBuff(ModContent.BuffType(), 60); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + if (!Main.dayTime || Main.rand.NextBool(3)) //100% at night, 33.33% chance during day + target.AddBuff(ModContent.BuffType(), 60); + } + } } diff --git a/Projectiles/Rogue/UrchinStingerProj.cs b/Projectiles/Rogue/UrchinStingerProj.cs index 0df5c4214f..a6e02c0866 100644 --- a/Projectiles/Rogue/UrchinStingerProj.cs +++ b/Projectiles/Rogue/UrchinStingerProj.cs @@ -53,8 +53,8 @@ namespace CalamityMod.Projectiles.Rogue { Vector2 projspeed = new Vector2(Main.rand.NextFloat(-4f, 4f), Main.rand.NextFloat(-4f, 4f)); int proj = Projectile.NewProjectile(projectile.Center, projspeed, ModContent.ProjectileType(), (int)(projdmg * 0.5f), 1f, projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceRogue = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceRogue = true; } return false; } diff --git a/Projectiles/Rogue/ValariBoomerang.cs b/Projectiles/Rogue/ValariBoomerang.cs index 988514ad4d..6c0e4f79cb 100644 --- a/Projectiles/Rogue/ValariBoomerang.cs +++ b/Projectiles/Rogue/ValariBoomerang.cs @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 40; projectile.penetrate = -1; projectile.timeLeft = 360; - projectile.ignoreWater = true; - projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 15; projectile.coldDamage = true; @@ -133,32 +133,32 @@ namespace CalamityMod.Projectiles.Rogue //Start homing at player if you hit an enemy projectile.ai[0] = 1; - int icicleAmt = Main.rand.Next(2, 4); - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < icicleAmt; i++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int shard = Projectile.NewProjectile(projectile.Center, velocity, Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner); - } - } - } + int icicleAmt = Main.rand.Next(2, 4); + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < icicleAmt; i++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner); + } + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - OnHitEffects(); + OnHitEffects(); target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 30); + target.AddBuff(ModContent.BuffType(), 30); } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(); + OnHitEffects(); target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 30); + target.AddBuff(ModContent.BuffType(), 30); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Rogue/Valaricicle.cs b/Projectiles/Rogue/Valaricicle.cs index 4cf1eef705..a180a909e9 100644 --- a/Projectiles/Rogue/Valaricicle.cs +++ b/Projectiles/Rogue/Valaricicle.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class Valaricicle : ModProjectile + public class Valaricicle : ModProjectile { public override void SetStaticDefaults() { @@ -20,19 +20,19 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = 1; projectile.timeLeft = 180; projectile.aiStyle = 1; - projectile.coldDamage = true; + projectile.coldDamage = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.velocity.X *= 0.9995f; projectile.velocity.Y += 0.01f; - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 8f, 20f); - } + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 8f, 20f); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Rogue/Valaricicle2.cs b/Projectiles/Rogue/Valaricicle2.cs index 3627bbe3da..331d31c893 100644 --- a/Projectiles/Rogue/Valaricicle2.cs +++ b/Projectiles/Rogue/Valaricicle2.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class Valaricicle2 : ModProjectile + public class Valaricicle2 : ModProjectile { public override void SetStaticDefaults() { @@ -20,19 +20,19 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = 1; projectile.timeLeft = 180; projectile.aiStyle = 1; - projectile.coldDamage = true; + projectile.coldDamage = true; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 150 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.velocity.X *= 0.9995f; projectile.velocity.Y += 0.01f; - if (projectile.timeLeft < 150) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 8f, 20f); - } + if (projectile.timeLeft < 150) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 8f, 20f); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Rogue/ValedictionBoomerang.cs b/Projectiles/Rogue/ValedictionBoomerang.cs index 5b7bc41bc5..7c8bdd5c32 100644 --- a/Projectiles/Rogue/ValedictionBoomerang.cs +++ b/Projectiles/Rogue/ValedictionBoomerang.cs @@ -8,179 +8,179 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class ValedictionBoomerang : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/Valediction"; + public class ValedictionBoomerang : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/Valediction"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Valediction"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Valediction"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 70; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 15; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 70; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.extraUpdates = 3; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 15; + projectile.Calamity().rogue = true; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 8; - Main.PlaySound(SoundID.Item7, projectile.position); - } - if (projectile.ai[0] == 0f) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 60f) - { - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - else - { - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); - } - } - else - { - float returnSpeed = 30f; - float acceleration = 5f; - Vector2 projVector = player.Center - projectile.Center; - float playerDist = projVector.Length(); - if (playerDist > 3000f) - { - projectile.Kill(); - } - playerDist = returnSpeed / playerDist; - projVector.X *= playerDist; - projVector.Y *= playerDist; - if (projectile.velocity.X < projVector.X) - { - projectile.velocity.X += acceleration; - if (projectile.velocity.X < 0f && projVector.X > 0f) - { - projectile.velocity.X += acceleration; - } - } - else if (projectile.velocity.X > projVector.X) - { - projectile.velocity.X -= acceleration; - if (projectile.velocity.X > 0f && projVector.X < 0f) - { - projectile.velocity.X -= acceleration; - } - } - if (projectile.velocity.Y < projVector.Y) - { - projectile.velocity.Y += acceleration; - if (projectile.velocity.Y < 0f && projVector.Y > 0f) - { - projectile.velocity.Y += acceleration; - } - } - else if (projectile.velocity.Y > projVector.Y) - { - projectile.velocity.Y -= acceleration; - if (projectile.velocity.Y > 0f && projVector.Y < 0f) - { - projectile.velocity.Y -= acceleration; - } - } - if (Main.myPlayer == projectile.owner) - { - Rectangle projHitbox = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); - Rectangle playerHitbox = new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height); - if (projHitbox.Intersects(playerHitbox)) - { - projectile.Kill(); - } - } - } - projectile.rotation += 0.5f; - } + public override void AI() + { + Player player = Main.player[projectile.owner]; + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 8; + Main.PlaySound(SoundID.Item7, projectile.position); + } + if (projectile.ai[0] == 0f) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] >= 60f) + { + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + else + { + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + } + } + else + { + float returnSpeed = 30f; + float acceleration = 5f; + Vector2 projVector = player.Center - projectile.Center; + float playerDist = projVector.Length(); + if (playerDist > 3000f) + { + projectile.Kill(); + } + playerDist = returnSpeed / playerDist; + projVector.X *= playerDist; + projVector.Y *= playerDist; + if (projectile.velocity.X < projVector.X) + { + projectile.velocity.X += acceleration; + if (projectile.velocity.X < 0f && projVector.X > 0f) + { + projectile.velocity.X += acceleration; + } + } + else if (projectile.velocity.X > projVector.X) + { + projectile.velocity.X -= acceleration; + if (projectile.velocity.X > 0f && projVector.X < 0f) + { + projectile.velocity.X -= acceleration; + } + } + if (projectile.velocity.Y < projVector.Y) + { + projectile.velocity.Y += acceleration; + if (projectile.velocity.Y < 0f && projVector.Y > 0f) + { + projectile.velocity.Y += acceleration; + } + } + else if (projectile.velocity.Y > projVector.Y) + { + projectile.velocity.Y -= acceleration; + if (projectile.velocity.Y > 0f && projVector.Y < 0f) + { + projectile.velocity.Y -= acceleration; + } + } + if (Main.myPlayer == projectile.owner) + { + Rectangle projHitbox = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); + Rectangle playerHitbox = new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height); + if (projHitbox.Intersects(playerHitbox)) + { + projectile.Kill(); + } + } + } + projectile.rotation += 0.5f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - OnHitEffects(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + OnHitEffects(); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - OnHitEffects(); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + OnHitEffects(); + } - private void OnHitEffects() - { - int typhoonAmt = 3; - int typhoonDamage = (int)(projectile.damage * 0.3f); - if (projectile.owner == Main.myPlayer && projectile.numHits < 1 && projectile.Calamity().stealthStrike) - { - Main.PlaySound(SoundID.Item84, projectile.position); - for (int typhoonCount = 0; typhoonCount < typhoonAmt; typhoonCount++) - { - Vector2 velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (velocity.X == 0f && velocity.Y == 0f) - { - velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - velocity.Normalize(); - velocity *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile typhoon = Projectile.NewProjectileDirect(projectile.Center, velocity, ModContent.ProjectileType(), typhoonDamage, 0f, projectile.owner); - if (typhoon.whoAmI.WithinBounds(Main.maxProjectiles)) - { - typhoon.Calamity().forceRogue = true; - typhoon.usesLocalNPCImmunity = true; - typhoon.localNPCHitCooldown = 10; - } - } - } - } + private void OnHitEffects() + { + int typhoonAmt = 3; + int typhoonDamage = (int)(projectile.damage * 0.3f); + if (projectile.owner == Main.myPlayer && projectile.numHits < 1 && projectile.Calamity().stealthStrike) + { + Main.PlaySound(SoundID.Item84, projectile.position); + for (int typhoonCount = 0; typhoonCount < typhoonAmt; typhoonCount++) + { + Vector2 velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + while (velocity.X == 0f && velocity.Y == 0f) + { + velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + } + velocity.Normalize(); + velocity *= (float)Main.rand.Next(70, 101) * 0.1f; + Projectile typhoon = Projectile.NewProjectileDirect(projectile.Center, velocity, ModContent.ProjectileType(), typhoonDamage, 0f, projectile.owner); + if (typhoon.whoAmI.WithinBounds(Main.maxProjectiles)) + { + typhoon.Calamity().forceRogue = true; + typhoon.usesLocalNPCImmunity = true; + typhoon.localNPCHitCooldown = 10; + } + } + } + } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item21, projectile.position); - projectile.position = projectile.Center; - projectile.width = projectile.height = 100; - projectile.Center = projectile.position; - for (int d = 0; d < 5; d++) - { - int water = Dust.NewDust(projectile.position, projectile.width, projectile.height, 33, 0f, 0f, 100, default, 2f); - Main.dust[water].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[water].scale = 0.5f; - Main.dust[water].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int d = 0; d < 8; d++) - { - int water = Dust.NewDust(projectile.position, projectile.width, projectile.height, 33, 0f, 0f, 100, default, 3f); - Main.dust[water].noGravity = true; - Main.dust[water].velocity *= 5f; - water = Dust.NewDust(projectile.position, projectile.width, projectile.height, 33, 0f, 0f, 100, default, 2f); - Main.dust[water].velocity *= 2f; - } - } - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item21, projectile.position); + projectile.position = projectile.Center; + projectile.width = projectile.height = 100; + projectile.Center = projectile.position; + for (int d = 0; d < 5; d++) + { + int water = Dust.NewDust(projectile.position, projectile.width, projectile.height, 33, 0f, 0f, 100, default, 2f); + Main.dust[water].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[water].scale = 0.5f; + Main.dust[water].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int d = 0; d < 8; d++) + { + int water = Dust.NewDust(projectile.position, projectile.width, projectile.height, 33, 0f, 0f, 100, default, 3f); + Main.dust[water].noGravity = true; + Main.dust[water].velocity *= 5f; + water = Dust.NewDust(projectile.position, projectile.width, projectile.height, 33, 0f, 0f, 100, default, 2f); + Main.dust[water].velocity *= 2f; + } + } + } } diff --git a/Projectiles/Rogue/VeneratedKnife.cs b/Projectiles/Rogue/VeneratedKnife.cs index d5c0ca0c2c..f2d8b77e1b 100644 --- a/Projectiles/Rogue/VeneratedKnife.cs +++ b/Projectiles/Rogue/VeneratedKnife.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class VeneratedKnife : ModProjectile + public class VeneratedKnife : ModProjectile { int lifetime = 150; diff --git a/Projectiles/Rogue/WebBallBol.cs b/Projectiles/Rogue/WebBallBol.cs index 042d9fae3d..81aeb2f3c8 100644 --- a/Projectiles/Rogue/WebBallBol.cs +++ b/Projectiles/Rogue/WebBallBol.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class WebBallBol : ModProjectile + public class WebBallBol : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Rogue/WebBall"; @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = 3; projectile.timeLeft = 300; projectile.Calamity().rogue = true; - projectile.aiStyle = 14; + projectile.aiStyle = 14; } public override void AI() @@ -29,31 +29,31 @@ namespace CalamityMod.Projectiles.Rogue if (Main.rand.NextBool(12)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 30, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } - } + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.Calamity().stealthStrike) - { - target.AddBuff(BuffID.Webbed, 120); - } - else - { - target.AddBuff(BuffID.Webbed, 60); - } + if (projectile.Calamity().stealthStrike) + { + target.AddBuff(BuffID.Webbed, 120); + } + else + { + target.AddBuff(BuffID.Webbed, 60); + } } public override void OnHitPvp(Player target, int damage, bool crit) { - if (projectile.Calamity().stealthStrike) - { - target.AddBuff(BuffID.Webbed, 120); - } - else - { - target.AddBuff(BuffID.Webbed, 60); - } + if (projectile.Calamity().stealthStrike) + { + target.AddBuff(BuffID.Webbed, 120); + } + else + { + target.AddBuff(BuffID.Webbed, 60); + } } } } diff --git a/Projectiles/Summon/AndromedaDeathRay.cs b/Projectiles/Summon/AndromedaDeathRay.cs index 46c12ba6ce..129ec11556 100644 --- a/Projectiles/Summon/AndromedaDeathRay.cs +++ b/Projectiles/Summon/AndromedaDeathRay.cs @@ -8,7 +8,7 @@ using Terraria.Enums; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class AndromedaDeathRay : ModProjectile + public class AndromedaDeathRay : ModProjectile { // How long this laser can exist before it is deleted. public const int TrueTimeLeft = 25; diff --git a/Projectiles/Summon/AndromedaRegislash.cs b/Projectiles/Summon/AndromedaRegislash.cs index 80946f58a3..a40f89821a 100644 --- a/Projectiles/Summon/AndromedaRegislash.cs +++ b/Projectiles/Summon/AndromedaRegislash.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.width = 582; projectile.height = 304; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.friendly = true; projectile.minion = true; projectile.minionSlots = 0f; @@ -29,8 +29,8 @@ namespace CalamityMod.Projectiles.Summon projectile.localNPCHitCooldown = 5; } - public override void AI() - { + public override void AI() + { Player player = Main.player[projectile.owner]; if (projectile.localAI[0] == 0f) { @@ -54,18 +54,18 @@ namespace CalamityMod.Projectiles.Summon { projectile.frame++; } - if (projectile.frame >= Main.projFrames[projectile.type]) - { + if (projectile.frame >= Main.projFrames[projectile.type]) + { projectile.Kill(); - } - projectile.direction = ((player.Center.X - projectile.Center.X) < 0).ToDirectionInt(); - projectile.spriteDirection = projectile.direction; - } + } + projectile.direction = ((player.Center.X - projectile.Center.X) < 0).ToDirectionInt(); + projectile.spriteDirection = projectile.direction; + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; - Vector2 startPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Vector2 startPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); int frameHeight = texture.Height / Main.projFrames[projectile.type]; int frameY = frameHeight * projectile.frame; Rectangle rectangle = new Rectangle(0, frameY, texture.Width, frameHeight); @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Summon if (projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipVertically; - Main.spriteBatch.Draw(texture, startPos, rectangle, projectile.GetAlpha(lightColor), rotation, origin, scale, spriteEffects, 0f); + Main.spriteBatch.Draw(texture, startPos, rectangle, projectile.GetAlpha(lightColor), rotation, origin, scale, spriteEffects, 0f); return false; } } diff --git a/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.cs b/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.cs index c291945ba9..caa74a719f 100644 --- a/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.cs +++ b/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon.AndromedaUI { - public class AndromedaUI_Background : ModProjectile + public class AndromedaUI_Background : ModProjectile { public int FadeoutTime = -1; public Vector2 PlayerOffset = Vector2.Zero; @@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Summon.AndromedaUI } public override void AI() - { + { // Death fade-out effect if (FadeoutTime > 0) { @@ -111,15 +111,15 @@ namespace CalamityMod.Projectiles.Summon.AndromedaUI } // Adjust the position of the UI. - if (Main.myPlayer == projectile.owner) - { + if (Main.myPlayer == projectile.owner) + { if (PlayerOffset == Vector2.Zero) { PlayerOffset = Main.player[projectile.owner].Center - projectile.Center; } projectile.Center = Main.player[projectile.owner].Center - PlayerOffset; } - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Summon/AngelBolt.cs b/Projectiles/Summon/AngelBolt.cs index bdf49b3d65..56c16d7570 100644 --- a/Projectiles/Summon/AngelBolt.cs +++ b/Projectiles/Summon/AngelBolt.cs @@ -25,23 +25,23 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 45; projectile.minion = true; projectile.minionSlots = 0f; - projectile.ignoreWater = true; - } + projectile.ignoreWater = true; + } - public override void AI() - { - if (projectile.timeLeft % 2f == 0f) - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, (int)CalamityDusts.ProfanedFire, 0f, 0f, 0, default, 1.25f); - Main.dust[num448].position = vector33; - Main.dust[num448].noGravity = true; - Main.dust[num448].noLight = true; - Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; - } - } + public override void AI() + { + if (projectile.timeLeft % 2f == 0f) + { + Vector2 vector33 = projectile.position; + vector33 -= projectile.velocity * 0.25f; + int num448 = Dust.NewDust(vector33, 1, 1, (int)CalamityDusts.ProfanedFire, 0f, 0f, 0, default, 1.25f); + Main.dust[num448].position = vector33; + Main.dust[num448].noGravity = true; + Main.dust[num448].noLight = true; + Main.dust[num448].scale = Main.rand.Next(70, 110) * 0.013f; + Main.dust[num448].velocity *= 0.1f; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(ModContent.BuffType(), 300); diff --git a/Projectiles/Summon/AngelOrb.cs b/Projectiles/Summon/AngelOrb.cs index 88ecd5876b..d35127d0b9 100644 --- a/Projectiles/Summon/AngelOrb.cs +++ b/Projectiles/Summon/AngelOrb.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class AngelOrb : ModProjectile + public class AngelOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Summon projectile.width = 14; projectile.height = 14; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 30; projectile.minion = true; @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 150f, 3f, 6f, 2, ModContent.ProjectileType(), 1D, true); + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 150f, 3f, 6f, 2, ModContent.ProjectileType(), 1D, true); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(ModContent.BuffType(), 300); diff --git a/Projectiles/Summon/AngelRay.cs b/Projectiles/Summon/AngelRay.cs index 360214a776..ea79495d8c 100644 --- a/Projectiles/Summon/AngelRay.cs +++ b/Projectiles/Summon/AngelRay.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Summon projectile.friendly = true; projectile.minion = true; projectile.minionSlots = 0f; - projectile.ignoreWater = true; - projectile.penetrate = 10; + projectile.ignoreWater = true; + projectile.penetrate = 10; projectile.extraUpdates = 200; projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; @@ -42,13 +42,13 @@ namespace CalamityMod.Projectiles.Summon if (projectile.ai[0] > 16f && projectile.ai[0] % 2f == 0f) { - Vector2 source = projectile.position; - int pink = Dust.NewDust(source, 1, 1, (int)CalamityDusts.ProfanedFire, 0f, 0f, 0, default, 1.25f); - Main.dust[pink].noGravity = true; - Main.dust[pink].noLight = true; - Main.dust[pink].position = source; - Main.dust[pink].scale = Main.rand.Next(70, 110) * 0.013f; - Main.dust[pink].velocity *= 0.1f; + Vector2 source = projectile.position; + int pink = Dust.NewDust(source, 1, 1, (int)CalamityDusts.ProfanedFire, 0f, 0f, 0, default, 1.25f); + Main.dust[pink].noGravity = true; + Main.dust[pink].noLight = true; + Main.dust[pink].position = source; + Main.dust[pink].scale = Main.rand.Next(70, 110) * 0.013f; + Main.dust[pink].velocity *= 0.1f; } } diff --git a/Projectiles/Summon/AngelicAllianceArchangel.cs b/Projectiles/Summon/AngelicAllianceArchangel.cs index 1ea3632efa..4391434742 100644 --- a/Projectiles/Summon/AngelicAllianceArchangel.cs +++ b/Projectiles/Summon/AngelicAllianceArchangel.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Projectiles.Summon { public class AngelicAllianceArchangel : ModProjectile { - private int lifeSpan = 900; + private int lifeSpan = 900; public override void SetStaticDefaults() { DisplayName.SetDefault("Archangel"); @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Summon projectile.minionSlots = 0f; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void SendExtraAI(BinaryWriter writer) => writer.Write(lifeSpan); @@ -44,12 +44,12 @@ namespace CalamityMod.Projectiles.Summon Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (!modPlayer.divineBless || player.dead || !player.active) - { - lifeSpan = 0; - } + if (!modPlayer.divineBless || player.dead || !player.active) + { + lifeSpan = 0; + } - // Initialization and dust + // Initialization and dust if (projectile.localAI[0] == 0f) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Summon projectile.damage = damage2; } - // Rotate around the player + // Rotate around the player double deg = projectile.ai[1]; double rad = deg * (Math.PI / 180); double dist = 300; @@ -76,71 +76,71 @@ namespace CalamityMod.Projectiles.Summon projectile.position.Y = player.Center.Y - (int)(Math.Sin(rad) * dist) - projectile.height / 2; projectile.ai[1] += 1f; - if (!projectile.FinalExtraUpdate()) - return; + if (!projectile.FinalExtraUpdate()) + return; - lifeSpan--; - if (lifeSpan <= 0) - { - projectile.alpha += 30; - if (projectile.alpha >= 255) - { - projectile.Kill(); - return; - } - } + lifeSpan--; + if (lifeSpan <= 0) + { + projectile.alpha += 30; + if (projectile.alpha >= 255) + { + projectile.Kill(); + return; + } + } - // Give off some light + // Give off some light float lightScalar = Main.rand.NextFloat(0.9f, 1.1f) * Main.essScale; Lighting.AddLight(projectile.Center, 0.3f * lightScalar, 0.26f * lightScalar, 0.15f * lightScalar); - // Get a target - NPC target = projectile.Center.MinionHoming(2000f, player, false, true); + // Get a target + NPC target = projectile.Center.MinionHoming(2000f, player, false, true); - // Shoot the target - if (target != null) - { - Vector2 direction = target.Center - projectile.Center; - direction.Normalize(); - direction *= 6f; - if (direction.X >= 0.25f) - { - projectile.direction = -1; - } - else if (direction.X < -0.25f) - { - projectile.direction = 1; - } - projectile.ai[0]++; - int timerLimit = 120; - if (projectile.ai[0] > timerLimit && projectile.alpha < 50) - { - if (Main.myPlayer == projectile.owner) - { - int type = ModContent.ProjectileType(); - Projectile.NewProjectile(projectile.Center, direction * 0.5f, type, projectile.damage, projectile.knockBack, projectile.owner); - } - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - } - else + // Shoot the target + if (target != null) { - Vector2 direction = player.Center - projectile.Center; - direction.Normalize(); - direction *= 6f; - if (direction.X >= 0.25f) - { - projectile.direction = -1; - } - else if (direction.X < -0.25f) - { - projectile.direction = 1; - } + Vector2 direction = target.Center - projectile.Center; + direction.Normalize(); + direction *= 6f; + if (direction.X >= 0.25f) + { + projectile.direction = -1; + } + else if (direction.X < -0.25f) + { + projectile.direction = 1; + } + projectile.ai[0]++; + int timerLimit = 120; + if (projectile.ai[0] > timerLimit && projectile.alpha < 50) + { + if (Main.myPlayer == projectile.owner) + { + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(projectile.Center, direction * 0.5f, type, projectile.damage, projectile.knockBack, projectile.owner); + } + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } } - projectile.spriteDirection = projectile.direction; + else + { + Vector2 direction = player.Center - projectile.Center; + direction.Normalize(); + direction *= 6f; + if (direction.X >= 0.25f) + { + projectile.direction = -1; + } + else if (direction.X < -0.25f) + { + projectile.direction = 1; + } + } + projectile.spriteDirection = projectile.direction; - // Frames + // Frames projectile.frameCounter++; if (projectile.frameCounter > 7) { diff --git a/Projectiles/Summon/ApexShark.cs b/Projectiles/Summon/ApexShark.cs index 5d58c3f89c..723d4203f0 100644 --- a/Projectiles/Summon/ApexShark.cs +++ b/Projectiles/Summon/ApexShark.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class ApexShark : ModProjectile + public class ApexShark : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Ranged/SandyWaifuShark"; @@ -95,7 +95,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); bool flag24 = false; if (projectile.ai[0] == 2f) { diff --git a/Projectiles/Summon/ApparatusExplosion.cs b/Projectiles/Summon/ApparatusExplosion.cs index 26930ec5f2..b2bcd87820 100644 --- a/Projectiles/Summon/ApparatusExplosion.cs +++ b/Projectiles/Summon/ApparatusExplosion.cs @@ -3,7 +3,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class ApparatusExplosion : ModProjectile + public class ApparatusExplosion : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Summon/AquaticStarMinion.cs b/Projectiles/Summon/AquaticStarMinion.cs index 9febfeb7b3..78f6446e7e 100644 --- a/Projectiles/Summon/AquaticStarMinion.cs +++ b/Projectiles/Summon/AquaticStarMinion.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class AquaticStarMinion : ModProjectile + public class AquaticStarMinion : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Summon/AstrageldonLaser.cs b/Projectiles/Summon/AstrageldonLaser.cs index 44bdf30d64..19816759e5 100644 --- a/Projectiles/Summon/AstrageldonLaser.cs +++ b/Projectiles/Summon/AstrageldonLaser.cs @@ -23,14 +23,14 @@ namespace CalamityMod.Projectiles.Summon projectile.width = 10; projectile.height = 10; projectile.friendly = true; - projectile.minion = true; + projectile.minion = true; projectile.ignoreWater = true; projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -2; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() diff --git a/Projectiles/Summon/AstrageldonSummon.cs b/Projectiles/Summon/AstrageldonSummon.cs index 07996c0071..d0ad679617 100644 --- a/Projectiles/Summon/AstrageldonSummon.cs +++ b/Projectiles/Summon/AstrageldonSummon.cs @@ -11,230 +11,230 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class AstrageldonSummon : ModProjectile - { - public bool dust = false; - private int attackCounter = 1; - private int teleportCounter = 400; + public class AstrageldonSummon : ModProjectile + { + public bool dust = false; + private int attackCounter = 1; + private int teleportCounter = 400; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Astrageldon"); - Main.projFrames[projectile.type] = 6; - ProjectileID.Sets.MinionSacrificable[projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astrageldon"); + Main.projFrames[projectile.type] = 6; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = 64; - projectile.height = 62; - projectile.netImportant = true; - projectile.friendly = true; - projectile.minionSlots = 1; - projectile.alpha = 75; - projectile.timeLeft = 18000; - projectile.penetrate = -1; - projectile.timeLeft *= 5; - projectile.minion = true; - projectile.tileCollide = false; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.aiStyle = 26; - aiType = ProjectileID.BabySlime; - } + public override void SetDefaults() + { + projectile.width = 64; + projectile.height = 62; + projectile.netImportant = true; + projectile.friendly = true; + projectile.minionSlots = 1; + projectile.alpha = 75; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + projectile.timeLeft *= 5; + projectile.minion = true; + projectile.tileCollide = false; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.aiStyle = 26; + aiType = ProjectileID.BabySlime; + } - public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) - { - //for platform collision? - fallThrough = false; - return true; - } + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) + { + //for platform collision? + fallThrough = false; + return true; + } - public override void AI() - { - Player player = Main.player[projectile.owner];; - CalamityPlayer modPlayer = player.Calamity(); - CalamityGlobalProjectile modProj = projectile.Calamity(); + public override void AI() + { + Player player = Main.player[projectile.owner];; + CalamityPlayer modPlayer = player.Calamity(); + CalamityGlobalProjectile modProj = projectile.Calamity(); - //hitbox size scaling - float scale = (float)Math.Log(projectile.minionSlots, 10f) + 1f; - if (projectile.scale != scale) - projectile.scale = scale; - projectile.width = (int)(64f * projectile.scale); - projectile.height = (int)(62f * projectile.scale); + //hitbox size scaling + float scale = (float)Math.Log(projectile.minionSlots, 10f) + 1f; + if (projectile.scale != scale) + projectile.scale = scale; + projectile.width = (int)(64f * projectile.scale); + projectile.height = (int)(62f * projectile.scale); - //on spawn effects and flexible minions - if (!dust) - { - modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); - modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage; - int dustAmt = 16; - for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) - { - Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; - Vector2 vector7 = vector6 - projectile.Center; - int dusty = Dust.NewDust(vector6 + vector7, 0, 0, ModContent.DustType(), vector7.X * 1f, vector7.Y * 1f, 100, default, 1.1f); - Main.dust[dusty].noGravity = true; - Main.dust[dusty].noLight = true; - Main.dust[dusty].velocity = vector7; - } + //on spawn effects and flexible minions + if (!dust) + { + modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); + modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage; + int dustAmt = 16; + for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) + { + Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; + vector6 = vector6.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; + Vector2 vector7 = vector6 - projectile.Center; + int dusty = Dust.NewDust(vector6 + vector7, 0, 0, ModContent.DustType(), vector7.X * 1f, vector7.Y * 1f, 100, default, 1.1f); + Main.dust[dusty].noGravity = true; + Main.dust[dusty].noLight = true; + Main.dust[dusty].velocity = vector7; + } - dust = true; - } - if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue) - { - int damage2 = (int)((float)modProj.spawnedPlayerMinionProjectileDamageValue / - modProj.spawnedPlayerMinionDamageValue * - player.MinionDamage()); - projectile.damage = damage2; - } + dust = true; + } + if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue) + { + int damage2 = (int)((float)modProj.spawnedPlayerMinionProjectileDamageValue / + modProj.spawnedPlayerMinionDamageValue * + player.MinionDamage()); + projectile.damage = damage2; + } - //Bool setup - bool flag64 = projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) - { - if (player.dead) - { - modPlayer.aSlime = false; - } - if (modPlayer.aSlime) - { - projectile.timeLeft = 2; - } - } + //Bool setup + bool flag64 = projectile.type == ModContent.ProjectileType(); + player.AddBuff(ModContent.BuffType(), 3600); + if (flag64) + { + if (player.dead) + { + modPlayer.aSlime = false; + } + if (modPlayer.aSlime) + { + projectile.timeLeft = 2; + } + } - if (projectile.frame == 0 || projectile.frame == 1) - { - float mindistance = 1000f; - float longdistance = 2000f; - float longestdistance = 3000f; - Vector2 objectivepos = projectile.position; - bool gotoenemy = false; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - bool lineOfSight = Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); - float disttoobjective = Vector2.Distance(npc.Center, projectile.Center); - if ((!gotoenemy && disttoobjective < mindistance) && lineOfSight) - { - - mindistance = disttoobjective; - objectivepos = npc.Center; - gotoenemy = true; - } - } - } - else - { - for (int num645 = 0; num645 < Main.npc.Length; num645++) - { - NPC npc = Main.npc[num645]; - if (npc.CanBeChasedBy(projectile, false)) - { - bool lineOfSight = Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); - float disttoobjective = Vector2.Distance(npc.Center, projectile.Center); - if ((!gotoenemy && disttoobjective < mindistance) && lineOfSight) - { - - mindistance = disttoobjective; - objectivepos = npc.Center; - gotoenemy = true; - } - } - } - } - float maxdisttoenemy = longdistance; - if (gotoenemy) - { - maxdisttoenemy = longestdistance; - } - if (gotoenemy) - { - float teleportRange = objectivepos.Length(); - float scaleAddition = projectile.scale * 5f; - if (teleportCounter <= 0 && teleportRange >= 800f) - { - float num461 = 50f; - int num462 = 0; - while ((float)num462 < num461) - { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.DustType(), - ModContent.DustType() - }); - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num467]; - dust.noGravity = true; - dust.position.X = projectile.Center.X; - dust.position.Y = projectile.Center.Y; - dust.position.X += (float)Main.rand.Next(-10, 11); - dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = num463; - dust.velocity.Y = num464; - num462++; - } - projectile.position.X = objectivepos.X - (float)(projectile.width / 2) + Main.rand.NextFloat(-100f, 100f); - projectile.position.Y = objectivepos.Y - (float)(projectile.height / 2) - Main.rand.NextFloat(0f + scaleAddition, 200f + scaleAddition); - projectile.netUpdate = true; - teleportCounter = 600; - } - if (teleportCounter > 0) - teleportCounter -= Main.rand.Next(1, 4); - } + if (projectile.frame == 0 || projectile.frame == 1) + { + float mindistance = 1000f; + float longdistance = 2000f; + float longestdistance = 3000f; + Vector2 objectivepos = projectile.position; + bool gotoenemy = false; + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + bool lineOfSight = Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); + float disttoobjective = Vector2.Distance(npc.Center, projectile.Center); + if ((!gotoenemy && disttoobjective < mindistance) && lineOfSight) + { + + mindistance = disttoobjective; + objectivepos = npc.Center; + gotoenemy = true; + } + } + } + else + { + for (int num645 = 0; num645 < Main.npc.Length; num645++) + { + NPC npc = Main.npc[num645]; + if (npc.CanBeChasedBy(projectile, false)) + { + bool lineOfSight = Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); + float disttoobjective = Vector2.Distance(npc.Center, projectile.Center); + if ((!gotoenemy && disttoobjective < mindistance) && lineOfSight) + { + + mindistance = disttoobjective; + objectivepos = npc.Center; + gotoenemy = true; + } + } + } + } + float maxdisttoenemy = longdistance; + if (gotoenemy) + { + maxdisttoenemy = longestdistance; + } + if (gotoenemy) + { + float teleportRange = objectivepos.Length(); + float scaleAddition = projectile.scale * 5f; + if (teleportCounter <= 0 && teleportRange >= 800f) + { + float num461 = 50f; + int num462 = 0; + while ((float)num462 < num461) + { + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.DustType(), + ModContent.DustType() + }); + float num463 = (float)Main.rand.Next(-10, 11); + float num464 = (float)Main.rand.Next(-10, 11); + float num465 = (float)Main.rand.Next(3, 9); + float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); + num466 = num465 / num466; + num463 *= num466; + num464 *= num466; + int num467 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[num467]; + dust.noGravity = true; + dust.position.X = projectile.Center.X; + dust.position.Y = projectile.Center.Y; + dust.position.X += (float)Main.rand.Next(-10, 11); + dust.position.Y += (float)Main.rand.Next(-10, 11); + dust.velocity.X = num463; + dust.velocity.Y = num464; + num462++; + } + projectile.position.X = objectivepos.X - (float)(projectile.width / 2) + Main.rand.NextFloat(-100f, 100f); + projectile.position.Y = objectivepos.Y - (float)(projectile.height / 2) - Main.rand.NextFloat(0f + scaleAddition, 200f + scaleAddition); + projectile.netUpdate = true; + teleportCounter = 600; + } + if (teleportCounter > 0) + teleportCounter -= Main.rand.Next(1, 4); + } - if (attackCounter > 0) - { - attackCounter += Main.rand.Next(1, 4); - } - if (attackCounter > 300) - { - attackCounter = 0; - projectile.netUpdate = true; - } - float scaleFactor3 = 6f; - int projType = ModContent.ProjectileType(); - if (gotoenemy && attackCounter == 0) - { - attackCounter += 2; - if (Main.myPlayer == projectile.owner) - { - Vector2 laserVel = objectivepos - projectile.Center; - laserVel.Normalize(); - laserVel *= scaleFactor3; - int laser = Projectile.NewProjectile(projectile.Center, laserVel, projType, projectile.damage, 0f, projectile.owner); - projectile.netUpdate = true; - } - } - } - } + if (attackCounter > 0) + { + attackCounter += Main.rand.Next(1, 4); + } + if (attackCounter > 300) + { + attackCounter = 0; + projectile.netUpdate = true; + } + float scaleFactor3 = 6f; + int projType = ModContent.ProjectileType(); + if (gotoenemy && attackCounter == 0) + { + attackCounter += 2; + if (Main.myPlayer == projectile.owner) + { + Vector2 laserVel = objectivepos - projectile.Center; + laserVel.Normalize(); + laserVel *= scaleFactor3; + int laser = Projectile.NewProjectile(projectile.Center, laserVel, projType, projectile.damage, 0f, projectile.owner); + projectile.netUpdate = true; + } + } + } + } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 120); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int height = texture.Height / Main.projFrames[projectile.type]; - int y6 = height * projectile.frame; - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, SpriteEffects.None, 0f); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int y6 = height * projectile.frame; + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, SpriteEffects.None, 0f); + return false; + } + } } diff --git a/Projectiles/Summon/AstralProbeRound.cs b/Projectiles/Summon/AstralProbeRound.cs index 33942aa106..55c348a9dc 100644 --- a/Projectiles/Summon/AstralProbeRound.cs +++ b/Projectiles/Summon/AstralProbeRound.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class AstralProbeRound : ModProjectile + public class AstralProbeRound : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Ranged/AstralRound"; @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; projectile.penetrate = 1; projectile.timeLeft = 300; - projectile.extraUpdates = 2; + projectile.extraUpdates = 2; } public override void AI() @@ -40,9 +40,9 @@ namespace CalamityMod.Projectiles.Summon if (Main.rand.NextBool(3)) { int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.DustType(), - ModContent.DustType() + { + ModContent.DustType(), + ModContent.DustType() }); int astral = Dust.NewDust(projectile.position, 1, 1, randomDust, 0f, 0f, 0, default, 0.5f); Main.dust[astral].alpha = projectile.alpha; diff --git a/Projectiles/Summon/AstralProbeSummon.cs b/Projectiles/Summon/AstralProbeSummon.cs index 82c54cf7f3..e711e56a5a 100644 --- a/Projectiles/Summon/AstralProbeSummon.cs +++ b/Projectiles/Summon/AstralProbeSummon.cs @@ -8,10 +8,10 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class AstralProbeSummon : ModProjectile + public class AstralProbeSummon : ModProjectile { private double rotation = 0; - private double rotationVariation = 0; + private double rotationVariation = 0; public override void SetStaticDefaults() { @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Summon projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - rotationVariation = Main.rand.NextDouble() * 0.015; + rotationVariation = Main.rand.NextDouble() * 0.015; int dustAmt = 36; for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) @@ -76,18 +76,18 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - NPC target = projectile.Center.MinionHoming(1000f, player, true, true); + NPC target = projectile.Center.MinionHoming(1000f, player, true, true); Vector2 vector = player.Center - projectile.Center; if (target != null) { - projectile.spriteDirection = projectile.direction = ((target.Center.X - projectile.Center.X) > 0).ToDirectionInt(); + projectile.spriteDirection = projectile.direction = ((target.Center.X - projectile.Center.X) > 0).ToDirectionInt(); projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(target.Center) + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi), 0.1f); } - else - { - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + else + { + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.rotation.AngleLerp(vector.ToRotation() - (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi * projectile.direction), 0.1f); - } + } projectile.Center = player.Center + new Vector2(80, 0).RotatedBy(rotation); rotation += 0.03 + rotationVariation; if (rotation >= 360) @@ -105,21 +105,21 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[1] = 0f; projectile.netUpdate = true; } - float speedMult = 6f; - int projType = ModContent.ProjectileType(); - if (target != null && projectile.ai[1] == 0f) - { - Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 12, 0.5f, 0f); - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - Vector2 velocity = target.Center - projectile.Center; - velocity.Normalize(); - velocity *= speedMult; - Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, projectile.owner, target.whoAmI, 0f); - projectile.netUpdate = true; - } - } + float speedMult = 6f; + int projType = ModContent.ProjectileType(); + if (target != null && projectile.ai[1] == 0f) + { + Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 12, 0.5f, 0f); + projectile.ai[1] += 1f; + if (Main.myPlayer == projectile.owner) + { + Vector2 velocity = target.Center - projectile.Center; + velocity.Normalize(); + velocity *= speedMult; + Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, projectile.owner, target.whoAmI, 0f); + projectile.netUpdate = true; + } + } } public override bool CanDamage() => false; diff --git a/Projectiles/Summon/AureusBomber.cs b/Projectiles/Summon/AureusBomber.cs index d2a4885906..7860c6622c 100644 --- a/Projectiles/Summon/AureusBomber.cs +++ b/Projectiles/Summon/AureusBomber.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class AureusBomber : ModProjectile + public class AureusBomber : ModProjectile { public override void SetStaticDefaults() { @@ -37,13 +37,13 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { Player player = Main.player[projectile.owner]; - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.DustType(), - ModContent.DustType() - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.DustType(), + ModContent.DustType() + }); - //on spawn effects && minion flexibility + //on spawn effects && minion flexibility if (projectile.localAI[0] == 0f) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -69,28 +69,28 @@ namespace CalamityMod.Projectiles.Summon projectile.damage = damage2; } - //anti sticking movement - projectile.MinionAntiClump(); + //anti sticking movement + projectile.MinionAntiClump(); - //get in a line - Vector2 idlePosition = player.Center; - idlePosition.Y -= 48f; - float minionPositionOffsetX = (10 + projectile.minionPos * 40) * -player.direction; - idlePosition.X += minionPositionOffsetX; + //get in a line + Vector2 idlePosition = player.Center; + idlePosition.Y -= 48f; + float minionPositionOffsetX = (10 + projectile.minionPos * 40) * -player.direction; + idlePosition.X += minionPositionOffsetX; - Vector2 vectorToIdlePosition = idlePosition - projectile.Center; - float idleDistance = vectorToIdlePosition.Length(); + Vector2 vectorToIdlePosition = idlePosition - projectile.Center; + float idleDistance = vectorToIdlePosition.Length(); - //dust effects - if (Main.rand.NextBool(10)) - { - int index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0.0f, 0.0f, 100, Color.Transparent, 2f); - Main.dust[index].velocity *= 0.3f; - Main.dust[index].noGravity = true; - Main.dust[index].noLight = true; - } + //dust effects + if (Main.rand.NextBool(10)) + { + int index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0.0f, 0.0f, 100, Color.Transparent, 2f); + Main.dust[index].velocity *= 0.3f; + Main.dust[index].noGravity = true; + Main.dust[index].noLight = true; + } - //frames + //frames projectile.frameCounter++; if (projectile.frameCounter > 6) { @@ -102,67 +102,67 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - //direction - if (projectile.velocity.X > 0f) - projectile.spriteDirection = projectile.direction = -1; - else if (projectile.velocity.X < 0f) - projectile.spriteDirection = projectile.direction = 1; - - //tile collision - projectile.tileCollide = true; - if (projectile.ai[0] == 1f) - projectile.tileCollide = false; + //direction + if (projectile.velocity.X > 0f) + projectile.spriteDirection = projectile.direction = -1; + else if (projectile.velocity.X < 0f) + projectile.spriteDirection = projectile.direction = 1; + + //tile collision + projectile.tileCollide = true; + if (projectile.ai[0] == 1f) + projectile.tileCollide = false; - //find nearby NPCs - Vector2 objectivePos = projectile.position; - float minDist = 400f; - bool enemyFound = false; - int npcIndex = -1; - NPC targetedNPC = projectile.OwnerMinionAttackTargetNPC; - if (targetedNPC != null && targetedNPC.CanBeChasedBy((object) projectile, false)) - { - float distToEnemy = Vector2.Distance(targetedNPC.Center, projectile.Center); - if (((double) Vector2.Distance(projectile.Center, objectivePos) > (double) distToEnemy && (double) distToEnemy < (double) minDist || !enemyFound) && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, targetedNPC.position, targetedNPC.width, targetedNPC.height)) - { - minDist = distToEnemy; - objectivePos = targetedNPC.Center; - enemyFound = true; - npcIndex = targetedNPC.whoAmI; - } - } - if (!enemyFound) - { - for (int index = 0; index < Main.npc.Length; ++index) - { - NPC npc = Main.npc[index]; - if (npc.CanBeChasedBy((object) projectile, false)) - { - float distToEnemy = Vector2.Distance(npc.Center, projectile.Center); - if (((double) Vector2.Distance(projectile.Center, objectivePos) > (double) distToEnemy && (double) distToEnemy < (double) minDist || !enemyFound) && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) - { - minDist = distToEnemy; - objectivePos = npc.Center; - enemyFound = true; - npcIndex = index; - } - } - } - } + //find nearby NPCs + Vector2 objectivePos = projectile.position; + float minDist = 400f; + bool enemyFound = false; + int npcIndex = -1; + NPC targetedNPC = projectile.OwnerMinionAttackTargetNPC; + if (targetedNPC != null && targetedNPC.CanBeChasedBy((object) projectile, false)) + { + float distToEnemy = Vector2.Distance(targetedNPC.Center, projectile.Center); + if (((double) Vector2.Distance(projectile.Center, objectivePos) > (double) distToEnemy && (double) distToEnemy < (double) minDist || !enemyFound) && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, targetedNPC.position, targetedNPC.width, targetedNPC.height)) + { + minDist = distToEnemy; + objectivePos = targetedNPC.Center; + enemyFound = true; + npcIndex = targetedNPC.whoAmI; + } + } + if (!enemyFound) + { + for (int index = 0; index < Main.npc.Length; ++index) + { + NPC npc = Main.npc[index]; + if (npc.CanBeChasedBy((object) projectile, false)) + { + float distToEnemy = Vector2.Distance(npc.Center, projectile.Center); + if (((double) Vector2.Distance(projectile.Center, objectivePos) > (double) distToEnemy && (double) distToEnemy < (double) minDist || !enemyFound) && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + minDist = distToEnemy; + objectivePos = npc.Center; + enemyFound = true; + npcIndex = index; + } + } + } + } - int maxDistToEnemy = 500; - if (enemyFound) - maxDistToEnemy = 1000; + int maxDistToEnemy = 500; + if (enemyFound) + maxDistToEnemy = 1000; - //if too far, return to the player - if ((double) Vector2.Distance(player.Center, projectile.Center) > (double) maxDistToEnemy) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } + //if too far, return to the player + if ((double) Vector2.Distance(player.Center, projectile.Center) > (double) maxDistToEnemy) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } - //movement if NPC found - if (enemyFound && projectile.ai[0] == 0f) - { + //movement if NPC found + if (enemyFound && projectile.ai[0] == 0f) + { float homingStrength = 15f; Vector2 projPos = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); float distX = objectivePos.X - projPos.X; @@ -173,66 +173,66 @@ namespace CalamityMod.Projectiles.Summon distY *= distToTarget; projectile.velocity.X = (projectile.velocity.X * 20f + distX) / 21f; projectile.velocity.Y = (projectile.velocity.Y * 20f + distY) / 21f; - } - else - { - //if player not in line of sight, go through tiles - if (!Collision.CanHitLine(projectile.Center, 1, 1, player.Center, 1, 1)) - projectile.ai[0] = 1f; + } + else + { + //if player not in line of sight, go through tiles + if (!Collision.CanHitLine(projectile.Center, 1, 1, player.Center, 1, 1)) + projectile.ai[0] = 1f; - float speedToPlayer = 6f; - if (projectile.ai[0] == 1f) - speedToPlayer = 15f; + float speedToPlayer = 6f; + if (projectile.ai[0] == 1f) + speedToPlayer = 15f; - Vector2 center = projectile.Center; - Vector2 playerPos = player.Center - center + new Vector2(0.0f, -60f); - playerPos = player.Center - center; - float distToPlayer = playerPos.Length(); - if (distToPlayer > 200f && speedToPlayer < 9f) - speedToPlayer = 9f; - speedToPlayer *= 0.75f; + Vector2 center = projectile.Center; + Vector2 playerPos = player.Center - center + new Vector2(0.0f, -60f); + playerPos = player.Center - center; + float distToPlayer = playerPos.Length(); + if (distToPlayer > 200f && speedToPlayer < 9f) + speedToPlayer = 9f; + speedToPlayer *= 0.75f; - //idle distance - if (distToPlayer < idleDistance && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } + //idle distance + if (distToPlayer < idleDistance && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } - //way too far so teleport memes - if (distToPlayer > 2000f) - { - projectile.position.X = player.Center.X - (float) (projectile.width / 2); - projectile.position.Y = player.Center.Y - (float) (projectile.width / 2); - } + //way too far so teleport memes + if (distToPlayer > 2000f) + { + projectile.position.X = player.Center.X - (float) (projectile.width / 2); + projectile.position.Y = player.Center.Y - (float) (projectile.width / 2); + } - if (distToPlayer > 10f) - { - playerPos.Normalize(); - if (distToPlayer < 50f) - speedToPlayer /= 2f; - projectile.velocity = (projectile.velocity * 20f + playerPos * speedToPlayer) / 21f; - } - else - { - projectile.direction = player.direction; - projectile.velocity = projectile.velocity * 0.9f; - } - } + if (distToPlayer > 10f) + { + playerPos.Normalize(); + if (distToPlayer < 50f) + speedToPlayer /= 2f; + projectile.velocity = (projectile.velocity * 20f + playerPos * speedToPlayer) / 21f; + } + else + { + projectile.direction = player.direction; + projectile.velocity = projectile.velocity * 0.9f; + } + } - //stop if you trying to return to the player - if (projectile.ai[0] != 0f) - return; + //stop if you trying to return to the player + if (projectile.ai[0] != 0f) + return; - //stop if you didn't find an enemy - if (!enemyFound) - return; + //stop if you didn't find an enemy + if (!enemyFound) + return; - //face said enemy - if ((objectivePos - projectile.Center).X > 0f) - projectile.spriteDirection = projectile.direction = -1; - else if ((objectivePos - projectile.Center).X < 0f) - projectile.spriteDirection = projectile.direction = 1; + //face said enemy + if ((objectivePos - projectile.Center).X > 0f) + projectile.spriteDirection = projectile.direction = -1; + else if ((objectivePos - projectile.Center).X < 0f) + projectile.spriteDirection = projectile.direction = 1; } public override void Kill(int timeLeft) @@ -262,9 +262,9 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; diff --git a/Projectiles/Summon/BabyBloodCrawler.cs b/Projectiles/Summon/BabyBloodCrawler.cs index b47022906d..953adbb198 100644 --- a/Projectiles/Summon/BabyBloodCrawler.cs +++ b/Projectiles/Summon/BabyBloodCrawler.cs @@ -6,11 +6,11 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class BabyBloodCrawler : ModProjectile + public class BabyBloodCrawler : ModProjectile { public float dust = 0f; - public int spiderCount = 0; - public bool countedAlready = false; + public int spiderCount = 0; + public bool countedAlready = false; public override void SetStaticDefaults() { @@ -47,18 +47,18 @@ namespace CalamityMod.Projectiles.Summon Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - for (int j = 0; j < Main.maxProjectiles; j++) - { + for (int j = 0; j < Main.maxProjectiles; j++) + { Projectile proj = Main.projectile[j]; - // Short circuits to make the loop as fast as possible - if (!proj.active || proj.owner != projectile.owner || !proj.minion || proj.Calamity().lineColor != 0) - continue; - if (proj.type == projectile.type) - { - spiderCount += (int)proj.minionSlots; - proj.Calamity().lineColor = 1; - } - } + // Short circuits to make the loop as fast as possible + if (!proj.active || proj.owner != projectile.owner || !proj.minion || proj.Calamity().lineColor != 0) + continue; + if (proj.type == projectile.type) + { + spiderCount += (int)proj.minionSlots; + proj.Calamity().lineColor = 1; + } + } if (dust == 0f) { @@ -99,34 +99,34 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - //1 spider = 15 frames, 5 spiders, 10 frames - int immuneTime = 16 - spiderCount; - if (immuneTime < 5) - immuneTime = 5; //cap to prevent potential insanity + //1 spider = 15 frames, 5 spiders, 10 frames + int immuneTime = 16 - spiderCount; + if (immuneTime < 5) + immuneTime = 5; //cap to prevent potential insanity target.immune[projectile.owner] = immuneTime; - OnHitEffects(target.Center); - } + OnHitEffects(target.Center); + } public override void OnHitPvp(Player target, int damage, bool crit) { - OnHitEffects(target.Center); + OnHitEffects(target.Center); } - private void OnHitEffects(Vector2 targetPos) - { - if (Main.rand.NextBool(2)) - { - int projAmt = Main.rand.Next(1, 3); - for (int n = 0; n < projAmt; n++) - { - CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(projectile.damage * Main.rand.NextFloat(0.7f, 1f)), projectile.knockBack * Main.rand.NextFloat(0.7f, 1f), projectile.owner); - } - } + private void OnHitEffects(Vector2 targetPos) + { + if (Main.rand.NextBool(2)) + { + int projAmt = Main.rand.Next(1, 3); + for (int n = 0; n < projAmt; n++) + { + CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(projectile.damage * Main.rand.NextFloat(0.7f, 1f)), projectile.knockBack * Main.rand.NextFloat(0.7f, 1f), projectile.owner); + } + } } } } diff --git a/Projectiles/Summon/BabyPlaguebringer.cs b/Projectiles/Summon/BabyPlaguebringer.cs index fa7555bd2d..378f172aa9 100644 --- a/Projectiles/Summon/BabyPlaguebringer.cs +++ b/Projectiles/Summon/BabyPlaguebringer.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Summon float num635 = 3000f; float num636 = 500f; - //lighting + //lighting float num = (float)Main.rand.Next(90, 111) * 0.01f; num *= Main.essScale; Lighting.AddLight(projectile.Center, 0f * num, 0.75f * num, 0f * num); @@ -226,10 +226,10 @@ namespace CalamityMod.Projectiles.Summon } } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.NPCHit4, projectile.position); - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.NPCHit4, projectile.position); + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Summon/BelladonnaSpirit.cs b/Projectiles/Summon/BelladonnaSpirit.cs index 7905a16228..5af2942018 100644 --- a/Projectiles/Summon/BelladonnaSpirit.cs +++ b/Projectiles/Summon/BelladonnaSpirit.cs @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Summon { TargetNPC(potentialTarget); } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); } public void Initialize(Player player) { diff --git a/Projectiles/Summon/BlackHawkSummon.cs b/Projectiles/Summon/BlackHawkSummon.cs index b926535cfd..52761b8bc9 100644 --- a/Projectiles/Summon/BlackHawkSummon.cs +++ b/Projectiles/Summon/BlackHawkSummon.cs @@ -7,289 +7,289 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class BlackHawkSummon : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Black Hawk"); - ProjectileID.Sets.MinionSacrificable[projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; - Main.projFrames[projectile.type] = 3; - } + public class BlackHawkSummon : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Black Hawk"); + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + Main.projFrames[projectile.type] = 3; + } - public override void SetDefaults() - { - projectile.width = 36; - projectile.height = 36; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.aiStyle = 66; - projectile.minionSlots = 1f; - projectile.timeLeft = 18000; - projectile.penetrate = -1; - projectile.tileCollide = true; - projectile.timeLeft *= 5; - projectile.minion = true; - } + public override void SetDefaults() + { + projectile.width = 36; + projectile.height = 36; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.aiStyle = 66; + projectile.minionSlots = 1f; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + projectile.tileCollide = true; + projectile.timeLeft *= 5; + projectile.minion = true; + } - public override void AI() - { - //Set namespaces - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - CalamityGlobalProjectile modProj = projectile.Calamity(); + public override void AI() + { + //Set namespaces + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + CalamityGlobalProjectile modProj = projectile.Calamity(); - //On spawn effects - if (projectile.localAI[0] == 0f) - { - //Set constants - modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); - modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage; - //Spawn dust - int dustAmt = 36; - for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) - { - Vector2 direction = Vector2.Normalize(projectile.velocity) * new Vector2(projectile.width / 2f, projectile.height) * 0.75f; - direction = direction.RotatedBy((double)((dustIndex - (dustAmt / 2f - 1f)) * MathHelper.TwoPi / dustAmt), default) + projectile.Center; - Vector2 dustVel = direction - projectile.Center; - int fire = Dust.NewDust(direction + dustVel, 0, 0, 258, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); - Main.dust[fire].noGravity = true; - Main.dust[fire].velocity = dustVel; - } - projectile.localAI[0] += 1f; - } + //On spawn effects + if (projectile.localAI[0] == 0f) + { + //Set constants + modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); + modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage; + //Spawn dust + int dustAmt = 36; + for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) + { + Vector2 direction = Vector2.Normalize(projectile.velocity) * new Vector2(projectile.width / 2f, projectile.height) * 0.75f; + direction = direction.RotatedBy((double)((dustIndex - (dustAmt / 2f - 1f)) * MathHelper.TwoPi / dustAmt), default) + projectile.Center; + Vector2 dustVel = direction - projectile.Center; + int fire = Dust.NewDust(direction + dustVel, 0, 0, 258, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); + Main.dust[fire].noGravity = true; + Main.dust[fire].velocity = dustVel; + } + projectile.localAI[0] += 1f; + } - //Flexible minion damage update - if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue) - { - int damage2 = (int)((float)modProj.spawnedPlayerMinionProjectileDamageValue / - modProj.spawnedPlayerMinionDamageValue * player.MinionDamage()); - projectile.damage = damage2; - } + //Flexible minion damage update + if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue) + { + int damage2 = (int)((float)modProj.spawnedPlayerMinionProjectileDamageValue / + modProj.spawnedPlayerMinionDamageValue * player.MinionDamage()); + projectile.damage = damage2; + } - //Update frames - projectile.frameCounter++; - if (projectile.frameCounter >= 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } + //Update frames + projectile.frameCounter++; + if (projectile.frameCounter >= 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } - //Set up buff and timeLeft - bool correctMinion = projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (correctMinion) - { - if (player.dead) - { - modPlayer.blackhawk = false; - } - if (modPlayer.blackhawk) - { - projectile.timeLeft = 2; - } - } + //Set up buff and timeLeft + bool correctMinion = projectile.type == ModContent.ProjectileType(); + player.AddBuff(ModContent.BuffType(), 3600); + if (correctMinion) + { + if (player.dead) + { + modPlayer.blackhawk = false; + } + if (modPlayer.blackhawk) + { + projectile.timeLeft = 2; + } + } - //Anti sticky movement to prevent overlapping minions - projectile.MinionAntiClump(); + //Anti sticky movement to prevent overlapping minions + projectile.MinionAntiClump(); - float maxDistance = 700f; - Vector2 targetVec = projectile.position; - bool foundTarget = false; - //If targeting something, prioritize that enemy - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && targetDist < (maxDistance + extraDist)) - { - maxDistance = targetDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - if (!foundTarget) - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && targetDist < (maxDistance + extraDist)) - { - maxDistance = targetDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - } + float maxDistance = 700f; + Vector2 targetVec = projectile.position; + bool foundTarget = false; + //If targeting something, prioritize that enemy + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + //Calculate distance between target and the projectile to know if it's too far or not + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < (maxDistance + extraDist)) + { + maxDistance = targetDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + if (!foundTarget) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + //Calculate distance between target and the projectile to know if it's too far or not + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < (maxDistance + extraDist)) + { + maxDistance = targetDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + } - //If too far, make the minion start returning to the player. - float separationAnxietyDist = 1300f; - if (foundTarget) - { - //Max travel distance increases if targeting something - separationAnxietyDist = 2600f; - } - if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } + //If too far, make the minion start returning to the player. + float separationAnxietyDist = 1300f; + if (foundTarget) + { + //Max travel distance increases if targeting something + separationAnxietyDist = 2600f; + } + if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } - //If a target is found, move toward it - if (foundTarget && projectile.ai[0] == 0f) - { - Vector2 vecToTarget = targetVec - projectile.Center; - float targetDist = vecToTarget.Length(); - vecToTarget.Normalize(); - //If farther than 200 pixels, move toward it - if (targetDist > 200f) - { - float speedMult = 18f; - vecToTarget *= speedMult; - projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; - } - //Otherwise, back it up slowly - else - { - float speedMult = -9f; - vecToTarget *= speedMult; - projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; - } - } + //If a target is found, move toward it + if (foundTarget && projectile.ai[0] == 0f) + { + Vector2 vecToTarget = targetVec - projectile.Center; + float targetDist = vecToTarget.Length(); + vecToTarget.Normalize(); + //If farther than 200 pixels, move toward it + if (targetDist > 200f) + { + float speedMult = 18f; + vecToTarget *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; + } + //Otherwise, back it up slowly + else + { + float speedMult = -9f; + vecToTarget *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; + } + } - //If not targeting something, act passively - else - { - bool returningToPlayer = false; - if (!returningToPlayer) - { - returningToPlayer = projectile.ai[0] == 1f; - } - //Move faster if actively returning to the player - float speedMult = 12f; - if (returningToPlayer) - { - speedMult = 30f; - } - Vector2 vecToPlayer = player.Center - projectile.Center + new Vector2(0f, -120f); - float playerDist = vecToPlayer.Length(); - //Speed up if near the player - if (playerDist < 200f && speedMult < 16f) - { - speedMult = 16f; - } - //If close enough to the player, return to normal - if (playerDist < 600f && returningToPlayer) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - //If abnormally far, teleport to the player - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - //Move toward player if more than 70 pixels away - if (playerDist > 70f) - { - vecToPlayer.Normalize(); - vecToPlayer *= speedMult; - projectile.velocity = (projectile.velocity * 40f + vecToPlayer) / 41f; - } - //Move if still - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - } + //If not targeting something, act passively + else + { + bool returningToPlayer = false; + if (!returningToPlayer) + { + returningToPlayer = projectile.ai[0] == 1f; + } + //Move faster if actively returning to the player + float speedMult = 12f; + if (returningToPlayer) + { + speedMult = 30f; + } + Vector2 vecToPlayer = player.Center - projectile.Center + new Vector2(0f, -120f); + float playerDist = vecToPlayer.Length(); + //Speed up if near the player + if (playerDist < 200f && speedMult < 16f) + { + speedMult = 16f; + } + //If close enough to the player, return to normal + if (playerDist < 600f && returningToPlayer) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + //If abnormally far, teleport to the player + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - (float)(projectile.width / 2); + projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + //Move toward player if more than 70 pixels away + if (playerDist > 70f) + { + vecToPlayer.Normalize(); + vecToPlayer *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToPlayer) / 41f; + } + //Move if still + else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.15f; + projectile.velocity.Y = -0.05f; + } + } - //Update rotation - if (foundTarget) - { - projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + MathHelper.Pi, 0.1f); - } - else - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; - } + //Update rotation + if (foundTarget) + { + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + MathHelper.Pi, 0.1f); + } + else + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; + } - //Increment attack cooldown - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += Main.rand.Next(1, 4); - } - //Set the minion to be ready for attack - if (projectile.ai[1] > 130f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } + //Increment attack cooldown + if (projectile.ai[1] > 0f) + { + projectile.ai[1] += Main.rand.Next(1, 4); + } + //Set the minion to be ready for attack + if (projectile.ai[1] > 130f) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } - //Return if on attack cooldown, has no target, or returning to the player - if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f) - return; + //Return if on attack cooldown, has no target, or returning to the player + if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f) + return; - //Shoot a bullet - if (Main.myPlayer == projectile.owner) - { - float projSpeed = 6f; - int projType = ModContent.ProjectileType(); - Main.PlaySound(SoundID.Item20, projectile.Center); - projectile.ai[1] += 2f; - Vector2 velocity = targetVec - projectile.Center; - velocity.Normalize(); - velocity *= projSpeed; - Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, projectile.knockBack, projectile.owner); - projectile.netUpdate = true; - } - } + //Shoot a bullet + if (Main.myPlayer == projectile.owner) + { + float projSpeed = 6f; + int projType = ModContent.ProjectileType(); + Main.PlaySound(SoundID.Item20, projectile.Center); + projectile.ai[1] += 2f; + Vector2 velocity = targetVec - projectile.Center; + velocity.Normalize(); + velocity *= projSpeed; + Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, projectile.knockBack, projectile.owner); + projectile.netUpdate = true; + } + } - //Does no contact damage - public override bool CanDamage() => false; + //Does no contact damage + public override bool CanDamage() => false; - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int frameHeight = texture.Height / Main.projFrames[projectile.type]; - int y6 = frameHeight * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int frameHeight = texture.Height / Main.projFrames[projectile.type]; + int y6 = frameHeight * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + 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(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f); - return false; - } + 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; + } - //Pretty glowmask - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/BlackHawkGlow"); - int frameHeight = texture.Height / Main.projFrames[projectile.type]; - int y6 = frameHeight * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + //Pretty glowmask + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/BlackHawkGlow"); + int frameHeight = texture.Height / Main.projFrames[projectile.type]; + int y6 = frameHeight * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + 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)), Color.White, projectile.rotation, new Vector2(texture.Width / 2f, 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)), Color.White, projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f); + } + } } diff --git a/Projectiles/Summon/BloodBreath.cs b/Projectiles/Summon/BloodBreath.cs index c92d72f7d9..c33db801fd 100644 --- a/Projectiles/Summon/BloodBreath.cs +++ b/Projectiles/Summon/BloodBreath.cs @@ -3,7 +3,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class BloodBreath : ModProjectile + public class BloodBreath : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Summon/BloodClotMinion.cs b/Projectiles/Summon/BloodClotMinion.cs index 122ab949fa..ae4a14a663 100644 --- a/Projectiles/Summon/BloodClotMinion.cs +++ b/Projectiles/Summon/BloodClotMinion.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); float num535 = projectile.position.X; float num536 = projectile.position.Y; float num537 = 1300f; diff --git a/Projectiles/Summon/BloodRain.cs b/Projectiles/Summon/BloodRain.cs index ecb50a9fd6..deeb0d98b0 100644 --- a/Projectiles/Summon/BloodRain.cs +++ b/Projectiles/Summon/BloodRain.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - int blood = Dust.NewDust(projectile.position, projectile.width, projectile.height, 5, projectile.velocity.X, projectile.velocity.Y, 100, default, 1f); + int blood = Dust.NewDust(projectile.position, projectile.width, projectile.height, 5, projectile.velocity.X, projectile.velocity.Y, 100, default, 1f); Dust dust = Main.dust[blood]; dust.velocity = Vector2.Zero; dust.position -= projectile.velocity / 5f; diff --git a/Projectiles/Summon/BoneMatter.cs b/Projectiles/Summon/BoneMatter.cs index 7b3f2832ea..fe8d9dcd88 100644 --- a/Projectiles/Summon/BoneMatter.cs +++ b/Projectiles/Summon/BoneMatter.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Projectiles.Summon projectile.width = 26; projectile.height = 32; projectile.friendly = true; - projectile.minion = true; + projectile.minion = true; projectile.tileCollide = true; projectile.penetrate = 1; } diff --git a/Projectiles/Summon/BoneMatter2.cs b/Projectiles/Summon/BoneMatter2.cs index cec5eec8ad..d483457b2c 100644 --- a/Projectiles/Summon/BoneMatter2.cs +++ b/Projectiles/Summon/BoneMatter2.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Projectiles.Summon projectile.width = 26; projectile.height = 28; projectile.friendly = true; - projectile.minion = true; + projectile.minion = true; projectile.tileCollide = true; projectile.penetrate = 1; } diff --git a/Projectiles/Summon/BrimstoneDartMinion.cs b/Projectiles/Summon/BrimstoneDartMinion.cs index 796438b59d..3b30f1771c 100644 --- a/Projectiles/Summon/BrimstoneDartMinion.cs +++ b/Projectiles/Summon/BrimstoneDartMinion.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.alpha = 255; + projectile.alpha = 255; } public override void AI() diff --git a/Projectiles/Summon/BrimstoneDartSummon.cs b/Projectiles/Summon/BrimstoneDartSummon.cs index 509c98a1ff..a4ac6a0e12 100644 --- a/Projectiles/Summon/BrimstoneDartSummon.cs +++ b/Projectiles/Summon/BrimstoneDartSummon.cs @@ -7,14 +7,14 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class BrimstoneDartSummon : ModProjectile + public class BrimstoneDartSummon : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/Boss/BrimstoneBarrage"; - public override void SetStaticDefaults() + public override string Texture => "CalamityMod/Projectiles/Boss/BrimstoneBarrage"; + public override void SetStaticDefaults() { DisplayName.SetDefault("Brimstone Dart"); Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.MinionShot[projectile.type] = true; + ProjectileID.Sets.MinionShot[projectile.type] = true; ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; ProjectileID.Sets.TrailingMode[projectile.type] = 0; } @@ -25,28 +25,28 @@ namespace CalamityMod.Projectiles.Summon projectile.friendly = true; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.minion = true; - projectile.minionSlots = 0f; + projectile.minion = true; + projectile.minionSlots = 0f; projectile.penetrate = 1; projectile.timeLeft = 120; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 8; } - public override void AI() + public override void AI() { - if (projectile.velocity.Length() < 21f) - projectile.velocity *= 1.02f; + if (projectile.velocity.Length() < 21f) + projectile.velocity *= 1.02f; - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - projectile.frameCounter++; + projectile.frameCounter++; if (projectile.frameCounter % 5 == 4) projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; projectile.Opacity = Utils.InverseLerp(0f, 40f, projectile.timeLeft, true); - Lighting.AddLight(projectile.Center, 0.75f, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.75f, 0f, 0f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -71,8 +71,8 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - lightColor.R = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + lightColor.R = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } } diff --git a/Projectiles/Summon/BrimstoneElementalMinion.cs b/Projectiles/Summon/BrimstoneElementalMinion.cs index 46e4c3ad40..89f59cf552 100644 --- a/Projectiles/Summon/BrimstoneElementalMinion.cs +++ b/Projectiles/Summon/BrimstoneElementalMinion.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class BrimstoneElementalMinion : ModProjectile + public class BrimstoneElementalMinion : ModProjectile { public int dust = 3; @@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Summon } float num633 = 700f; float num636 = 400f; //150 - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); Vector2 vector46 = projectile.position; bool flag25 = false; if (projectile.ai[0] != 1f) diff --git a/Projectiles/Summon/BrimstoneExplosionMinion.cs b/Projectiles/Summon/BrimstoneExplosionMinion.cs index 9ac7df0474..bb026dec76 100644 --- a/Projectiles/Summon/BrimstoneExplosionMinion.cs +++ b/Projectiles/Summon/BrimstoneExplosionMinion.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { DisplayName.SetDefault("Explosion"); - ProjectileID.Sets.MinionShot[projectile.type] = true; + ProjectileID.Sets.MinionShot[projectile.type] = true; } public override void SetDefaults() @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 180; - projectile.minion = true; + projectile.minion = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } diff --git a/Projectiles/Summon/BrimstoneFireSummon.cs b/Projectiles/Summon/BrimstoneFireSummon.cs index 95a5126d88..a04d83c75d 100644 --- a/Projectiles/Summon/BrimstoneFireSummon.cs +++ b/Projectiles/Summon/BrimstoneFireSummon.cs @@ -53,22 +53,22 @@ namespace CalamityMod.Projectiles.Summon int dustType = (int)CalamityDusts.Brimstone; if (Main.rand.NextBool(2)) { - int brim = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[brim]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 3f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= scalar; + int brim = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[brim]; + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 3f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 1.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= scalar; } } else diff --git a/Projectiles/Summon/BrimstoneFireballMinion.cs b/Projectiles/Summon/BrimstoneFireballMinion.cs index 06e430fc20..882cc555ae 100644 --- a/Projectiles/Summon/BrimstoneFireballMinion.cs +++ b/Projectiles/Summon/BrimstoneFireballMinion.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { DisplayName.SetDefault("Brimfire"); - ProjectileID.Sets.MinionShot[projectile.type] = true; + ProjectileID.Sets.MinionShot[projectile.type] = true; Main.projFrames[projectile.type] = 6; ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; ProjectileID.Sets.TrailingMode[projectile.type] = 0; @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.alpha = 255; + projectile.alpha = 255; } public override void AI() @@ -55,8 +55,8 @@ namespace CalamityMod.Projectiles.Summon if (projectile.alpha < 5) projectile.alpha = 5; - //Rotation - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + //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); diff --git a/Projectiles/Summon/BrimstoneLaserSummon.cs b/Projectiles/Summon/BrimstoneLaserSummon.cs index 73776f0b47..7ad564cf6f 100644 --- a/Projectiles/Summon/BrimstoneLaserSummon.cs +++ b/Projectiles/Summon/BrimstoneLaserSummon.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class BrimstoneLaserSummon : ModProjectile + public class BrimstoneLaserSummon : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/BrimstoneLaser"; diff --git a/Projectiles/Summon/BrittleStarMinion.cs b/Projectiles/Summon/BrittleStarMinion.cs index 899b8230eb..8e618a66bd 100644 --- a/Projectiles/Summon/BrittleStarMinion.cs +++ b/Projectiles/Summon/BrittleStarMinion.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class BrittleStarMinion : ModProjectile + public class BrittleStarMinion : ModProjectile { public override void SetStaticDefaults() { @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Summon } projectile.rotation += projectile.velocity.X * 0.04f; - projectile.ChargingMinionAI(600f, 800f, 1200f, 150f, 0, 40f, 8f, 4f, new Vector2(0f, -60f), 40f, 9.5f, false, false); + projectile.ChargingMinionAI(600f, 800f, 1200f, 150f, 0, 40f, 8f, 4f, new Vector2(0f, -60f), 40f, 9.5f, false, false); } public override bool OnTileCollide(Vector2 oldVelocity) => false; diff --git a/Projectiles/Summon/CalamariInk.cs b/Projectiles/Summon/CalamariInk.cs index b5082e3455..c5da704bc7 100644 --- a/Projectiles/Summon/CalamariInk.cs +++ b/Projectiles/Summon/CalamariInk.cs @@ -60,8 +60,8 @@ namespace CalamityMod.Projectiles.Summon } } } - else if (Main.npc[(int)projectile.ai[0]].active && projectile.ai[0] != -1f) - { + else if (Main.npc[(int)projectile.ai[0]].active && projectile.ai[0] != -1f) + { NPC npc = Main.npc[(int)projectile.ai[0]]; if (npc.CanBeChasedBy(projectile, false)) { @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Summon hasHomingTarget = true; } } - } + } if (!hasHomingTarget) { for (int i = 0; i < Main.npc.Length; ++i) diff --git a/Projectiles/Summon/CalamariMinion.cs b/Projectiles/Summon/CalamariMinion.cs index 296c2c322d..bf9b70ff0b 100644 --- a/Projectiles/Summon/CalamariMinion.cs +++ b/Projectiles/Summon/CalamariMinion.cs @@ -134,14 +134,14 @@ namespace CalamityMod.Projectiles.Summon { projectile.localAI[0] -= 1f; } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); Vector2 vector = projectile.position; float num10 = 3000f; bool flag = false; Vector2 center = player.Center; Vector2 value = new Vector2(0.5f); value.Y = 0f; - int targetIndex = -1; + int targetIndex = -1; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; @@ -153,7 +153,7 @@ namespace CalamityMod.Projectiles.Summon { vector = vector2; flag = true; - targetIndex = npc.whoAmI; + targetIndex = npc.whoAmI; } } } @@ -171,7 +171,7 @@ namespace CalamityMod.Projectiles.Summon num10 = num13; vector = vector3; flag = true; - targetIndex = k; + targetIndex = k; } } } @@ -247,11 +247,11 @@ namespace CalamityMod.Projectiles.Summon } else { - if (!Collision.CanHitLine(projectile.Center, 1, 1, Main.player[projectile.owner].Center, 1, 1)) - { - projectile.ai[0] = 1f; - } - float num21 = 12f; //6 + if (!Collision.CanHitLine(projectile.Center, 1, 1, Main.player[projectile.owner].Center, 1, 1)) + { + projectile.ai[0] = 1f; + } + float num21 = 12f; //6 if (projectile.ai[0] == 1f) { num21 = 18f; //15 diff --git a/Projectiles/Summon/Calamitamini.cs b/Projectiles/Summon/Calamitamini.cs index d0db982c7f..2cf59e15e3 100644 --- a/Projectiles/Summon/Calamitamini.cs +++ b/Projectiles/Summon/Calamitamini.cs @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Summon } } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); projectile.frameCounter++; if (projectile.frameCounter > 3) @@ -101,13 +101,13 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float extraDist = (npc.width / 2) + (npc.height / 2); - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - bool canHit = true; - if (extraDist < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) - { + float extraDist = (npc.width / 2) + (npc.height / 2); + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + bool canHit = true; + if (extraDist < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) + { targetVec = npc.Center; foundTarget = true; } @@ -120,13 +120,13 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[index]; if (npc.CanBeChasedBy(projectile, false)) { - float extraDist = (npc.width / 2) + (npc.height / 2); - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - bool canHit = true; - if (extraDist < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) - { + float extraDist = (npc.width / 2) + (npc.height / 2); + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + bool canHit = true; + if (extraDist < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) + { targetVec = npc.Center; foundTarget = true; } @@ -204,15 +204,15 @@ namespace CalamityMod.Projectiles.Summon } } - //Update rotation - if (foundTarget) - { - projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + MathHelper.Pi, 0.1f); - } - else - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; - } + //Update rotation + if (foundTarget) + { + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + MathHelper.Pi, 0.1f); + } + else + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; + } if (projectile.ai[1] > 0f) { diff --git a/Projectiles/Summon/Cataclymini.cs b/Projectiles/Summon/Cataclymini.cs index 38567f87fd..ea1bc68287 100644 --- a/Projectiles/Summon/Cataclymini.cs +++ b/Projectiles/Summon/Cataclymini.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class Cataclymini : ModProjectile + public class Cataclymini : ModProjectile { public override void SetStaticDefaults() { @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Summon } } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); projectile.frameCounter++; if (projectile.frameCounter > 3) @@ -94,13 +94,13 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float extraDist = (npc.width / 2) + (npc.height / 2); - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - bool canHit = true; - if (extraDist < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) - { + float extraDist = (npc.width / 2) + (npc.height / 2); + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + bool canHit = true; + if (extraDist < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) + { targetVec = npc.Center; foundTarget = true; } @@ -113,13 +113,13 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[index]; if (npc.CanBeChasedBy(projectile, false)) { - float extraDist = (npc.width / 2) + (npc.height / 2); - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - bool canHit = true; - if (extraDist < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) - { + float extraDist = (npc.width / 2) + (npc.height / 2); + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + bool canHit = true; + if (extraDist < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) + { targetVec = npc.Center; foundTarget = true; } @@ -197,15 +197,15 @@ namespace CalamityMod.Projectiles.Summon } } - //Update rotation - if (foundTarget) - { - projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + MathHelper.Pi, 0.1f); - } - else - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; - } + //Update rotation + if (foundTarget) + { + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + MathHelper.Pi, 0.1f); + } + else + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; + } if (projectile.ai[1] > 0f) { diff --git a/Projectiles/Summon/Catastromini.cs b/Projectiles/Summon/Catastromini.cs index 12db82931d..fc898f8a4f 100644 --- a/Projectiles/Summon/Catastromini.cs +++ b/Projectiles/Summon/Catastromini.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class Catastromini : ModProjectile + public class Catastromini : ModProjectile { public override void SetStaticDefaults() { @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - projectile.ChargingMinionAI(Calamitamini.Range, Calamitamini.SeparationAnxietyMin, Calamitamini.SeparationAnxietyMax, Calamitamini.SafeDist, 0, 40f, 8f, 4f, new Vector2(0f, -60f), 40f, 8f, false, true); + projectile.ChargingMinionAI(Calamitamini.Range, Calamitamini.SeparationAnxietyMin, Calamitamini.SeparationAnxietyMax, Calamitamini.SafeDist, 0, 40f, 8f, 4f, new Vector2(0f, -60f), 40f, 8f, false, true); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Summon/CatastropheSummon.cs b/Projectiles/Summon/CatastropheSummon.cs index 5f4fdb4e48..b56241a327 100644 --- a/Projectiles/Summon/CatastropheSummon.cs +++ b/Projectiles/Summon/CatastropheSummon.cs @@ -67,9 +67,9 @@ namespace CalamityMod.Projectiles.Summon SpriteEffects direction = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, direction, 0f); return false; - } + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) => damage = 70; + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) => damage = 70; public override bool CanDamage() => projectile.Opacity >= 1f; } diff --git a/Projectiles/Summon/CausticStaffProjectile.cs b/Projectiles/Summon/CausticStaffProjectile.cs index 3bd98c8397..e19a77c21f 100644 --- a/Projectiles/Summon/CausticStaffProjectile.cs +++ b/Projectiles/Summon/CausticStaffProjectile.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 360; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.extraUpdates = 1; - projectile.tileCollide = false; + projectile.extraUpdates = 1; + projectile.tileCollide = false; } public override void AI() { @@ -52,43 +52,43 @@ namespace CalamityMod.Projectiles.Summon } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - Player player = Main.player[projectile.owner]; - 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) - { - int duration = Main.rand.Next(60, 181); // Anywhere between 1 and 3 seconds - switch ((int)projectile.ai[0]) - { - case 0: - if (target.Calamity().marked <= 0) - target.AddBuff(ModContent.BuffType(), duration); - break; - case 1: - if (!target.ichor) - target.AddBuff(BuffID.Ichor, duration); - break; - case 2: - if (!target.venom) - target.AddBuff(BuffID.Venom, duration); - break; - case 3: - if (!target.onFire2) - target.AddBuff(BuffID.CursedInferno, duration); - break; - case 4: - if (!target.onFire) - target.AddBuff(BuffID.OnFire, duration); - break; - default: - break; - } - } + Player player = Main.player[projectile.owner]; + 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) + { + int duration = Main.rand.Next(60, 181); // Anywhere between 1 and 3 seconds + switch ((int)projectile.ai[0]) + { + case 0: + if (target.Calamity().marked <= 0) + target.AddBuff(ModContent.BuffType(), duration); + break; + case 1: + if (!target.ichor) + target.AddBuff(BuffID.Ichor, duration); + break; + case 2: + if (!target.venom) + target.AddBuff(BuffID.Venom, duration); + break; + case 3: + if (!target.onFire2) + target.AddBuff(BuffID.CursedInferno, duration); + break; + case 4: + if (!target.onFire) + target.AddBuff(BuffID.OnFire, duration); + break; + default: + break; + } + } } } } diff --git a/Projectiles/Summon/CausticStaffSummon.cs b/Projectiles/Summon/CausticStaffSummon.cs index a5e6a90ab8..2708a44b10 100644 --- a/Projectiles/Summon/CausticStaffSummon.cs +++ b/Projectiles/Summon/CausticStaffSummon.cs @@ -6,10 +6,10 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class CausticStaffSummon : ModProjectile + public class CausticStaffSummon : ModProjectile { public bool initialized = false; - private float debuffToInflict = 0f; + private float debuffToInflict = 0f; public override void SetStaticDefaults() { @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Summon Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - //Spawn dust and record initial damage values + //Spawn dust and record initial damage values if (!initialized) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Summon initialized = true; } - //if minion damage changes, update it + //if minion damage changes, update it if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Summon projectile.damage = damage2; } - //If the correct minion, set bools and apply buffs + //If the correct minion, set bools and apply buffs bool correctMinion = projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); if (correctMinion) @@ -81,149 +81,149 @@ namespace CalamityMod.Projectiles.Summon } } - //Anti sticky movement to prevent minions from stacking - projectile.MinionAntiClump(); + //Anti sticky movement to prevent minions from stacking + projectile.MinionAntiClump(); - //Set tile collision for only when trying to return to the player - projectile.tileCollide = projectile.ai[0] != 1f; + //Set tile collision for only when trying to return to the player + projectile.tileCollide = projectile.ai[0] != 1f; - //Find an enemy - Vector2 targetPos = projectile.position; - float maxRange = 900f; - bool foundEnemy = false; - int targetIndex = -1; - //If the player has targetted an enemy, choose that one - NPC target = projectile.OwnerMinionAttackTargetNPC; - if (target != null && target.CanBeChasedBy(projectile, false)) - { - float targetDist = Vector2.Distance(target.Center, projectile.Center); - if (!foundEnemy && targetDist < maxRange && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, target.position, target.width, target.height)) - { - maxRange = targetDist; - targetPos = target.Center; - foundEnemy = true; - targetIndex = target.whoAmI; - } - } - //else, search through all available NPCs - if (!foundEnemy) - { - for (int index = 0; index < Main.maxNPCs; ++index) - { - NPC npc = Main.npc[index]; - if (npc.CanBeChasedBy(projectile, false)) - { - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundEnemy && targetDist < maxRange && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) - { - maxRange = targetDist; - targetPos = npc.Center; - foundEnemy = true; - targetIndex = index; - } - } - } - } + //Find an enemy + Vector2 targetPos = projectile.position; + float maxRange = 900f; + bool foundEnemy = false; + int targetIndex = -1; + //If the player has targetted an enemy, choose that one + NPC target = projectile.OwnerMinionAttackTargetNPC; + if (target != null && target.CanBeChasedBy(projectile, false)) + { + float targetDist = Vector2.Distance(target.Center, projectile.Center); + if (!foundEnemy && targetDist < maxRange && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, target.position, target.width, target.height)) + { + maxRange = targetDist; + targetPos = target.Center; + foundEnemy = true; + targetIndex = target.whoAmI; + } + } + //else, search through all available NPCs + if (!foundEnemy) + { + for (int index = 0; index < Main.maxNPCs; ++index) + { + NPC npc = Main.npc[index]; + if (npc.CanBeChasedBy(projectile, false)) + { + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundEnemy && targetDist < maxRange && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + maxRange = targetDist; + targetPos = npc.Center; + foundEnemy = true; + targetIndex = index; + } + } + } + } - //If the minion is too far away, return to the player. Max distance increases while attacking - float maxDistanceFromPlayer = 1300f; - if (foundEnemy) - maxDistanceFromPlayer = 1600f; - if (Vector2.Distance(player.Center, projectile.Center) > maxDistanceFromPlayer && projectile.ai[0] != 1f) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } + //If the minion is too far away, return to the player. Max distance increases while attacking + float maxDistanceFromPlayer = 1300f; + if (foundEnemy) + maxDistanceFromPlayer = 1600f; + if (Vector2.Distance(player.Center, projectile.Center) > maxDistanceFromPlayer && projectile.ai[0] != 1f) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } - //Move toward an enemy if one has been found - if (foundEnemy && projectile.ai[0] == 0f) - { - Vector2 homeInVector = targetPos - projectile.Center; - float targetDist = homeInVector.Length(); - homeInVector.Normalize(); - if (targetDist > 200f) - { - float velocity = 6f; - projectile.velocity = (projectile.velocity * 40f + homeInVector * velocity) / 41f; - } - else - { - if (targetDist < 150f) - { - float velocity = -4f; - projectile.velocity = (projectile.velocity * 40f + homeInVector * velocity) / 41f; - } - else - projectile.velocity *= 0.97f; - } - } - else - { - //Return to the player if you can't see the player - if (!Collision.CanHitLine(projectile.Center, 1, 1, player.Center, 1, 1)) - projectile.ai[0] = 1f; + //Move toward an enemy if one has been found + if (foundEnemy && projectile.ai[0] == 0f) + { + Vector2 homeInVector = targetPos - projectile.Center; + float targetDist = homeInVector.Length(); + homeInVector.Normalize(); + if (targetDist > 200f) + { + float velocity = 6f; + projectile.velocity = (projectile.velocity * 40f + homeInVector * velocity) / 41f; + } + else + { + if (targetDist < 150f) + { + float velocity = -4f; + projectile.velocity = (projectile.velocity * 40f + homeInVector * velocity) / 41f; + } + else + projectile.velocity *= 0.97f; + } + } + else + { + //Return to the player if you can't see the player + if (!Collision.CanHitLine(projectile.Center, 1, 1, player.Center, 1, 1)) + projectile.ai[0] = 1f; - //Set speed to home in on the player. If returning to the player, go faster - float speed = 9f; - if (projectile.ai[0] == 1f) - speed = 22f; + //Set speed to home in on the player. If returning to the player, go faster + float speed = 9f; + if (projectile.ai[0] == 1f) + speed = 22f; - //Find the player and align accordingly. Get in a line if there's more than one. - Vector2 playerPos = player.Center - projectile.Center; - projectile.netUpdate = true; - int minionPosition = 1; - for (int index = 0; index < projectile.whoAmI; ++index) - { - Projectile proj = Main.projectile[index]; + //Find the player and align accordingly. Get in a line if there's more than one. + Vector2 playerPos = player.Center - projectile.Center; + projectile.netUpdate = true; + int minionPosition = 1; + for (int index = 0; index < projectile.whoAmI; ++index) + { + Projectile proj = Main.projectile[index]; - // Short circuits to make the loop as fast as possible - if (!proj.active || proj.owner != projectile.owner || !proj.minion) - continue; + // Short circuits to make the loop as fast as possible + if (!proj.active || proj.owner != projectile.owner || !proj.minion) + continue; - if (proj.type == projectile.type) - ++minionPosition; - } - playerPos.X -= 10f * player.direction; - playerPos.X -= minionPosition * 40f * player.direction; - playerPos.Y -= 10f; + if (proj.type == projectile.type) + ++minionPosition; + } + playerPos.X -= 10f * player.direction; + playerPos.X -= minionPosition * 40f * player.direction; + playerPos.Y -= 10f; - //Calculate player distance - float playerDist = playerPos.Length(); - //If too far, increase speed - if (playerDist > 200f && speed < 15f) - speed = 15f; - //If you were trying to chase the player but are close enough now, return to normal - if (playerDist < 100f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - //Teleport to the player if really, really far - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - projectile.width / 2f; - projectile.position.Y = player.Center.Y - projectile.width / 2f; - projectile.netUpdate = true; - } - //Home in on the player - if (playerDist > 10f) - { - playerPos.Normalize(); - if (playerDist < 50f) - speed /= 2f; - projectile.velocity = (projectile.velocity * 20f + playerPos * speed) / 21f; - } - else - { - projectile.direction = player.direction; - projectile.velocity *= 0.9f; - } - } + //Calculate player distance + float playerDist = playerPos.Length(); + //If too far, increase speed + if (playerDist > 200f && speed < 15f) + speed = 15f; + //If you were trying to chase the player but are close enough now, return to normal + if (playerDist < 100f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + //Teleport to the player if really, really far + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - projectile.width / 2f; + projectile.position.Y = player.Center.Y - projectile.width / 2f; + projectile.netUpdate = true; + } + //Home in on the player + if (playerDist > 10f) + { + playerPos.Normalize(); + if (playerDist < 50f) + speed /= 2f; + projectile.velocity = (projectile.velocity * 20f + playerPos * speed) / 21f; + } + else + { + projectile.direction = player.direction; + projectile.velocity *= 0.9f; + } + } - //Rotation - projectile.rotation = projectile.velocity.X * 0.05f; + //Rotation + projectile.rotation = projectile.velocity.X * 0.05f; - //Cycle through animation + //Cycle through animation projectile.frameCounter++; if (projectile.frameCounter >= 6) { @@ -235,64 +235,64 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - //Occasionally spawn fiery dust - if (Main.rand.NextBool(6)) - { - int fire = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, new Color(), 2f); - Main.dust[fire].velocity *= 0.3f; - Main.dust[fire].noGravity = true; - Main.dust[fire].noLight = true; - } + //Occasionally spawn fiery dust + if (Main.rand.NextBool(6)) + { + int fire = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, new Color(), 2f); + Main.dust[fire].velocity *= 0.3f; + Main.dust[fire].noGravity = true; + Main.dust[fire].noLight = true; + } - //Set projectile direction based on its movement - if (projectile.velocity.X > 0f) - projectile.spriteDirection = projectile.direction = -1; - else if (projectile.velocity.X < 0f) - projectile.spriteDirection = projectile.direction = 1; + //Set projectile direction based on its movement + if (projectile.velocity.X > 0f) + projectile.spriteDirection = projectile.direction = -1; + else if (projectile.velocity.X < 0f) + projectile.spriteDirection = projectile.direction = 1; - //Increment firing cooldown - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += Main.rand.Next(1,4); - if (Main.rand.NextBool(3)) - ++projectile.ai[1]; - } - //Determine if it should shoot - if (projectile.ai[1] > 90f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } + //Increment firing cooldown + if (projectile.ai[1] > 0f) + { + projectile.ai[1] += Main.rand.Next(1,4); + if (Main.rand.NextBool(3)) + ++projectile.ai[1]; + } + //Determine if it should shoot + if (projectile.ai[1] > 90f) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } - //Return if trying to return to the player or no enemy has been found - if (projectile.ai[0] != 0f || !foundEnemy) - return; + //Return if trying to return to the player or no enemy has been found + if (projectile.ai[0] != 0f || !foundEnemy) + return; - //Set projectile direction based on target location - Vector2 targetVec = targetPos - projectile.Center; - if (targetVec.X > 0f) - projectile.spriteDirection = projectile.direction = -1; - else if (targetVec.X < 0f) - projectile.spriteDirection = projectile.direction = 1; + //Set projectile direction based on target location + Vector2 targetVec = targetPos - projectile.Center; + if (targetVec.X > 0f) + projectile.spriteDirection = projectile.direction = -1; + else if (targetVec.X < 0f) + projectile.spriteDirection = projectile.direction = 1; - //Return if firing cooldown isn't perfect - if (projectile.ai[1] != 0f) - return; - ++projectile.ai[1]; - if (Main.myPlayer != projectile.owner) - return; + //Return if firing cooldown isn't perfect + if (projectile.ai[1] != 0f) + return; + ++projectile.ai[1]; + if (Main.myPlayer != projectile.owner) + return; - //Fire projectile - float speedMult = 16f; - targetVec.Normalize(); - targetVec *= speedMult; - int spike = Projectile.NewProjectile(projectile.Center, targetVec, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, debuffToInflict, 0f); - debuffToInflict++; - if (debuffToInflict >= 5f) - debuffToInflict = 0f; - Main.projectile[spike].netUpdate = true; - projectile.netUpdate = true; - } + //Fire projectile + float speedMult = 16f; + targetVec.Normalize(); + targetVec *= speedMult; + int spike = Projectile.NewProjectile(projectile.Center, targetVec, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, debuffToInflict, 0f); + debuffToInflict++; + if (debuffToInflict >= 5f) + debuffToInflict = 0f; + Main.projectile[spike].netUpdate = true; + projectile.netUpdate = true; + } public override bool OnTileCollide(Vector2 oldVelocity) => false; diff --git a/Projectiles/Summon/ChaosFlame.cs b/Projectiles/Summon/ChaosFlame.cs index 29a9379eb4..1724d57d05 100644 --- a/Projectiles/Summon/ChaosFlame.cs +++ b/Projectiles/Summon/ChaosFlame.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Summon Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.25f / 255f, (255 - projectile.alpha) * 0f / 255f); if (projectile.localAI[0] == 0f) { - projectile.scale = 1f - Main.rand.NextFloat() * 0.5f; + projectile.scale = 1f - Main.rand.NextFloat() * 0.5f; projectile.localAI[0] += 1f; } if (Main.rand.NextBool(4)) @@ -63,8 +63,8 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft == 300) - return false; + if (projectile.timeLeft == 300) + return false; CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); return false; diff --git a/Projectiles/Summon/ChaosSpirit.cs b/Projectiles/Summon/ChaosSpirit.cs index 2193bcc7b5..f200ec5bf8 100644 --- a/Projectiles/Summon/ChaosSpirit.cs +++ b/Projectiles/Summon/ChaosSpirit.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class ChaosSpirit : ModProjectile + public class ChaosSpirit : ModProjectile { public int dust = 3; @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.frame = 0; } - bool reversedGravity = player.gravDir == -1f; + bool reversedGravity = player.gravDir == -1f; projectile.position.X = player.Center.X - (float)(projectile.width / 2); projectile.position.Y = player.Center.Y - (float)(projectile.height / 2) + player.gfxOffY - 60f; if (reversedGravity) @@ -108,89 +108,89 @@ namespace CalamityMod.Projectiles.Summon return; } bool foundTarget = false; - Vector2 targetVec = projectile.Center; - Vector2 half = new Vector2(0.5f); + Vector2 targetVec = projectile.Center; + Vector2 half = new Vector2(0.5f); float range = 1000f; - int targetIndex = -1; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - Vector2 sizeCheck = npc.position + npc.Size * half; - float npcDist = Vector2.Distance(sizeCheck, targetVec); - if (npcDist < range && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) - { - range = npcDist; - targetVec = sizeCheck; - foundTarget = true; - targetIndex = npc.whoAmI; - } - } - } - if (!foundTarget) - { - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC npc = Main.npc[k]; - if (npc.CanBeChasedBy(projectile, false)) - { - Vector2 sizeCheck = npc.position + npc.Size * half; - float npcDist = Vector2.Distance(sizeCheck, targetVec); - if (npcDist < range && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) - { - range = npcDist; - targetVec = sizeCheck; - foundTarget = true; - targetIndex = k; - } - } - } - } - float yAdjust = player.gravDir == -1f ? 0f : 10f; + int targetIndex = -1; + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + Vector2 sizeCheck = npc.position + npc.Size * half; + float npcDist = Vector2.Distance(sizeCheck, targetVec); + if (npcDist < range && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + range = npcDist; + targetVec = sizeCheck; + foundTarget = true; + targetIndex = npc.whoAmI; + } + } + } + if (!foundTarget) + { + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC npc = Main.npc[k]; + if (npc.CanBeChasedBy(projectile, false)) + { + Vector2 sizeCheck = npc.position + npc.Size * half; + float npcDist = Vector2.Distance(sizeCheck, targetVec); + if (npcDist < range && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + range = npcDist; + targetVec = sizeCheck; + foundTarget = true; + targetIndex = k; + } + } + } + } + float yAdjust = player.gravDir == -1f ? 0f : 10f; if (foundTarget && targetIndex != -1) { - int projectileType = ModContent.ProjectileType(); - //If the target is above the minion, fire directly at it at double speed - if (reversedGravity ? (Main.npc[targetIndex].Bottom.Y > projectile.Top.Y) : (Main.npc[targetIndex].Bottom.Y < projectile.Top.Y)) - { - Vector2 source = new Vector2(projectile.Center.X - 4f, projectile.Center.Y - yAdjust); - float speed = Main.rand.Next(14, 19); //modify the speed the projectile are shot. Lower number = slower projectile. - Vector2 velocity = targetVec - projectile.Center; - float targetDist = velocity.Length(); - targetDist = speed / targetDist; - velocity.X *= targetDist; - velocity.Y *= targetDist; - Projectile.NewProjectile(source, velocity, projectileType, projectile.damage, 5f, projectile.owner, 0f, 0f); - Main.PlaySound(SoundID.Item20, projectile.position); - projectile.ai[0] = 10f; - } - //Otherwise, fire away like a volcano - else - { - int amount = Main.rand.Next(2, 4); //2 to 3 - for (int i = 0; i < amount; i++) - { - float velocityX = Main.rand.NextFloat(-10f, 10f); - float velocityY = Main.rand.NextFloat(-10f, -7f); - if (reversedGravity) - velocityY *= -1f; - int flame = Projectile.NewProjectile(projectile.oldPosition.X + (projectile.width / 2), projectile.oldPosition.Y + (projectile.height / 2), velocityX, velocityY, projectileType, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[flame].aiStyle = 1; - } - Main.PlaySound(SoundID.Item20, projectile.position); - projectile.ai[0] = 20f; - } + int projectileType = ModContent.ProjectileType(); + //If the target is above the minion, fire directly at it at double speed + if (reversedGravity ? (Main.npc[targetIndex].Bottom.Y > projectile.Top.Y) : (Main.npc[targetIndex].Bottom.Y < projectile.Top.Y)) + { + Vector2 source = new Vector2(projectile.Center.X - 4f, projectile.Center.Y - yAdjust); + float speed = Main.rand.Next(14, 19); //modify the speed the projectile are shot. Lower number = slower projectile. + Vector2 velocity = targetVec - projectile.Center; + float targetDist = velocity.Length(); + targetDist = speed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; + Projectile.NewProjectile(source, velocity, projectileType, projectile.damage, 5f, projectile.owner, 0f, 0f); + Main.PlaySound(SoundID.Item20, projectile.position); + projectile.ai[0] = 10f; + } + //Otherwise, fire away like a volcano + else + { + int amount = Main.rand.Next(2, 4); //2 to 3 + for (int i = 0; i < amount; i++) + { + float velocityX = Main.rand.NextFloat(-10f, 10f); + float velocityY = Main.rand.NextFloat(-10f, -7f); + if (reversedGravity) + velocityY *= -1f; + int flame = Projectile.NewProjectile(projectile.oldPosition.X + (projectile.width / 2), projectile.oldPosition.Y + (projectile.height / 2), velocityX, velocityY, projectileType, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Main.projectile[flame].aiStyle = 1; + } + Main.PlaySound(SoundID.Item20, projectile.position); + projectile.ai[0] = 20f; + } } - //doesn't look good - /*Vector2 goreVec = new Vector2(projectile.Center.X, projectile.Center.Y - yAdjust - 10f); - Vector2 goreVec = new Vector2(projectile.Center.X + projectile.velocity.X, projectile.Center.Y + projectile.velocity.Y); - if (Main.rand.NextBool(8)) - { - int smoke = Gore.NewGore(goreVec, default, Main.rand.Next(375, 378), 0.5f); - Main.gore[smoke].behindTiles = true; - }*/ + //doesn't look good + /*Vector2 goreVec = new Vector2(projectile.Center.X, projectile.Center.Y - yAdjust - 10f); + Vector2 goreVec = new Vector2(projectile.Center.X + projectile.velocity.X, projectile.Center.Y + projectile.velocity.Y); + if (Main.rand.NextBool(8)) + { + int smoke = Gore.NewGore(goreVec, default, Main.rand.Next(375, 378), 0.5f); + Main.gore[smoke].behindTiles = true; + }*/ } } diff --git a/Projectiles/Summon/Cinder.cs b/Projectiles/Summon/Cinder.cs index 11c74f713b..2ed4c226a8 100644 --- a/Projectiles/Summon/Cinder.cs +++ b/Projectiles/Summon/Cinder.cs @@ -89,6 +89,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/CinderBlossom.cs b/Projectiles/Summon/CinderBlossom.cs index 91ae28461b..9c206dc57b 100644 --- a/Projectiles/Summon/CinderBlossom.cs +++ b/Projectiles/Summon/CinderBlossom.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class CinderBlossom : ModProjectile + public class CinderBlossom : ModProjectile { public float Time { diff --git a/Projectiles/Summon/CloudElementalMinion.cs b/Projectiles/Summon/CloudElementalMinion.cs index 04ab0ae8b0..3040bb5632 100644 --- a/Projectiles/Summon/CloudElementalMinion.cs +++ b/Projectiles/Summon/CloudElementalMinion.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class CloudElementalMinion : ModProjectile + public class CloudElementalMinion : ModProjectile { public int dust = 3; @@ -84,18 +84,18 @@ namespace CalamityMod.Projectiles.Summon lightScalar *= Main.essScale; Lighting.AddLight(projectile.Center, 0.25f * lightScalar, 0.55f * lightScalar, 0.75f * lightScalar); - projectile.frameCounter++; - if (projectile.frameCounter > 16) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 7) - { - projectile.frame = 0; - } + projectile.frameCounter++; + if (projectile.frameCounter > 16) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 7) + { + projectile.frame = 0; + } - projectile.ChargingMinionAI(500f, 800f, 1200f, 400f, 0, 30f, 8f, 4f, new Vector2(500f, -60f), 40f, 8f, false, true, 1); + projectile.ChargingMinionAI(500f, 800f, 1200f, 400f, 0, 30f, 8f, 4f, new Vector2(500f, -60f), 40f, 8f, false, true, 1); } } } diff --git a/Projectiles/Summon/ColdDivinityPointyThing.cs b/Projectiles/Summon/ColdDivinityPointyThing.cs index a5754a4c60..fd9778f624 100644 --- a/Projectiles/Summon/ColdDivinityPointyThing.cs +++ b/Projectiles/Summon/ColdDivinityPointyThing.cs @@ -114,21 +114,21 @@ namespace CalamityMod.Projectiles.Summon else if (projectile.ai[1] >= 2f && projectile.timeLeft > 900) { target = CalamityUtils.MinionHoming(projectile.Center, 1000f, Main.player[projectile.owner]); - if (target != null) - { - projectile.timeLeft = 669; - projectile.ai[1]++; - circlingPlayer = false; - float height = target.getRect().Height; - float width = target.getRect().Width; - floatyDistance = MathHelper.Min((height > width ? height : width) * 3f, (Main.LogicCheckScreenWidth * Main.LogicCheckScreenHeight) / 2); - if (floatyDistance > Main.LogicCheckScreenWidth / 3) - floatyDistance = Main.LogicCheckScreenWidth / 3; - projectile.penetrate = -1; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 4; - projectile.netUpdate = true; - } + if (target != null) + { + projectile.timeLeft = 669; + projectile.ai[1]++; + circlingPlayer = false; + float height = target.getRect().Height; + float width = target.getRect().Width; + floatyDistance = MathHelper.Min((height > width ? height : width) * 3f, (Main.LogicCheckScreenWidth * Main.LogicCheckScreenHeight) / 2); + if (floatyDistance > Main.LogicCheckScreenWidth / 3) + floatyDistance = Main.LogicCheckScreenWidth / 3; + projectile.penetrate = -1; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 4; + projectile.netUpdate = true; + } } if (circlingPlayer) { diff --git a/Projectiles/Summon/CorroslimeMinion.cs b/Projectiles/Summon/CorroslimeMinion.cs index 3b1c0b2dce..d1228d80ce 100644 --- a/Projectiles/Summon/CorroslimeMinion.cs +++ b/Projectiles/Summon/CorroslimeMinion.cs @@ -97,6 +97,6 @@ namespace CalamityMod.Projectiles.Summon return false; } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/CorruptionSlimeGodMinion.cs b/Projectiles/Summon/CorruptionSlimeGodMinion.cs index ada310e94e..5bd9b0ac92 100644 --- a/Projectiles/Summon/CorruptionSlimeGodMinion.cs +++ b/Projectiles/Summon/CorruptionSlimeGodMinion.cs @@ -91,6 +91,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/CosmicBlast.cs b/Projectiles/Summon/CosmicBlast.cs index 1567ae2320..f784cc45b1 100644 --- a/Projectiles/Summon/CosmicBlast.cs +++ b/Projectiles/Summon/CosmicBlast.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class CosmicBlast : ModProjectile + public class CosmicBlast : ModProjectile { public override void SetStaticDefaults() { @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; projectile.frameCounter++; if (projectile.frameCounter > 4) @@ -61,12 +61,12 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Summon/CosmicBlastBig.cs b/Projectiles/Summon/CosmicBlastBig.cs index f8eda30ca8..97bb83f0d7 100644 --- a/Projectiles/Summon/CosmicBlastBig.cs +++ b/Projectiles/Summon/CosmicBlastBig.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (projectile.soundDelay == 0) { projectile.soundDelay = 20 + Main.rand.Next(40); @@ -76,12 +76,12 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.ExoDebuffs(); + target.ExoDebuffs(); } public override void Kill(int timeLeft) diff --git a/Projectiles/Summon/CosmicEnergySpiral.cs b/Projectiles/Summon/CosmicEnergySpiral.cs index 3ee918c8bb..2c6e3ba78a 100644 --- a/Projectiles/Summon/CosmicEnergySpiral.cs +++ b/Projectiles/Summon/CosmicEnergySpiral.cs @@ -217,7 +217,7 @@ namespace CalamityMod.Projectiles.Summon int blastAmt = Main.rand.Next(5, 8); for (int b = 0; b < blastAmt; b++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 2f, projectile.owner, (float)target, 0f); } float speed = 15f; diff --git a/Projectiles/Summon/CosmicViperConcussionMissile.cs b/Projectiles/Summon/CosmicViperConcussionMissile.cs index 5a49cb0e35..7d2be62372 100644 --- a/Projectiles/Summon/CosmicViperConcussionMissile.cs +++ b/Projectiles/Summon/CosmicViperConcussionMissile.cs @@ -35,8 +35,8 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; } - public override void AI() - { + public override void AI() + { 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); @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.frame = 0; } - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.Summon Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; + Main.dust[num622].scale = 0.5f; } if (Main.rand.NextBool(2)) { diff --git a/Projectiles/Summon/CosmicViperHomingRocket.cs b/Projectiles/Summon/CosmicViperHomingRocket.cs index b21cc6d9df..104614b612 100644 --- a/Projectiles/Summon/CosmicViperHomingRocket.cs +++ b/Projectiles/Summon/CosmicViperHomingRocket.cs @@ -53,64 +53,64 @@ namespace CalamityMod.Projectiles.Summon Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, 1f * colorScale, 0.1f * colorScale, 1f * colorScale); Player player = Main.player[projectile.owner]; - Vector2 center = projectile.Center; - float maxDistance = 800f; - bool homeIn = false; + Vector2 center = projectile.Center; + float maxDistance = 800f; + bool homeIn = false; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); + float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - center = npc.Center; - homeIn = true; - } + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = npc.Center; + homeIn = true; + } } } - else if (Main.npc[(int)projectile.ai[0]].active && projectile.ai[0] != -1f) - { + else if (Main.npc[(int)projectile.ai[0]].active && projectile.ai[0] != -1f) + { NPC npc = Main.npc[(int)projectile.ai[0]]; if (npc.CanBeChasedBy(projectile, false)) { - float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); + float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - center = npc.Center; - homeIn = true; - } + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = npc.Center; + homeIn = true; + } } - } - if (!homeIn) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false)) - { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); + } + if (!homeIn) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance)) - { - center = Main.npc[i].Center; - homeIn = true; - break; - } - } - } - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = Main.npc[i].Center; + homeIn = true; + break; + } + } + } + } - if (homeIn) - { - Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + if (homeIn) + { + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); float homingInertia = 20f; float homingVelocity = 20f; - projectile.velocity = (projectile.velocity * homingInertia + moveDirection * homingVelocity) / (homingInertia + 1f); - } + projectile.velocity = (projectile.velocity * homingInertia + moveDirection * homingVelocity) / (homingInertia + 1f); + } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -147,7 +147,7 @@ namespace CalamityMod.Projectiles.Summon Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; + Main.dust[num622].scale = 0.5f; } if (Main.rand.NextBool(2)) { diff --git a/Projectiles/Summon/CosmicViperSplitRocket1.cs b/Projectiles/Summon/CosmicViperSplitRocket1.cs index fa5f9d017d..7b1c8ca2dd 100644 --- a/Projectiles/Summon/CosmicViperSplitRocket1.cs +++ b/Projectiles/Summon/CosmicViperSplitRocket1.cs @@ -30,11 +30,11 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; } - public override void AI() - { + public override void AI() + { 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); - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Summon/CosmicViperSplittingRocket.cs b/Projectiles/Summon/CosmicViperSplittingRocket.cs index f37d463d44..1c7644420f 100644 --- a/Projectiles/Summon/CosmicViperSplittingRocket.cs +++ b/Projectiles/Summon/CosmicViperSplittingRocket.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class CosmicViperSplittingRocket : ModProjectile + public class CosmicViperSplittingRocket : ModProjectile { public override void SetStaticDefaults() { @@ -35,128 +35,128 @@ namespace CalamityMod.Projectiles.Summon projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; 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); - Vector2 center = projectile.Center; + Vector2 center = projectile.Center; float maxDistance = 800f; float explode = 16f; bool homeIn = false; - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); + float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (explode + extraDistance)) - { - int numProj = 4; - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < numProj; i++) - { - Vector2 speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - while (speed.X == 0f && speed.Y == 0f) - { - speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - } - speed.Normalize(); - speed *= (float)Main.rand.Next(30, 61) * 0.1f * 2f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, 0f); - } + if (Vector2.Distance(npc.Center, projectile.Center) < (explode + extraDistance)) + { + int numProj = 4; + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < numProj; i++) + { + Vector2 speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + while (speed.X == 0f && speed.Y == 0f) + { + speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + } + speed.Normalize(); + speed *= (float)Main.rand.Next(30, 61) * 0.1f * 2f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, 0f); + } } Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); projectile.Kill(); - return; - } - else if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - center = npc.Center; - homeIn = true; - } + return; + } + else if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = npc.Center; + homeIn = true; + } } } - else if (Main.npc[(int)projectile.ai[0]].active && projectile.ai[0] != -1f) - { + else if (Main.npc[(int)projectile.ai[0]].active && projectile.ai[0] != -1f) + { NPC npc = Main.npc[(int)projectile.ai[0]]; if (npc.CanBeChasedBy(projectile, false)) { - float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); + float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (explode + extraDistance)) - { - int numProj = 4; - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < numProj; i++) - { - Vector2 speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - while (speed.X == 0f && speed.Y == 0f) - { - speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - } - speed.Normalize(); - speed *= (float)Main.rand.Next(30, 61) * 0.1f * 2f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, 0f); - } + if (Vector2.Distance(npc.Center, projectile.Center) < (explode + extraDistance)) + { + int numProj = 4; + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < numProj; i++) + { + Vector2 speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + while (speed.X == 0f && speed.Y == 0f) + { + speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + } + speed.Normalize(); + speed *= (float)Main.rand.Next(30, 61) * 0.1f * 2f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, 0f); + } } Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); projectile.Kill(); - return; - } - else if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - center = npc.Center; - homeIn = true; - } + return; + } + else if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = npc.Center; + homeIn = true; + } } - } - if (!homeIn) - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); + } + if (!homeIn) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (explode + extraDistance)) - { - int numProj = 4; - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < numProj; i++) - { - Vector2 speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - while (speed.X == 0f && speed.Y == 0f) - { - speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - } - speed.Normalize(); - speed *= (float)Main.rand.Next(30, 61) * 0.1f * 2f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25f), projectile.knockBack, projectile.owner, Main.rand.Next(2), 0f); - } + if (Vector2.Distance(npc.Center, projectile.Center) < (explode + extraDistance)) + { + int numProj = 4; + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < numProj; i++) + { + Vector2 speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + while (speed.X == 0f && speed.Y == 0f) + { + speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + } + speed.Normalize(); + speed *= (float)Main.rand.Next(30, 61) * 0.1f * 2f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25f), projectile.knockBack, projectile.owner, Main.rand.Next(2), 0f); + } } Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); projectile.Kill(); - return; - } - else if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - center = npc.Center; - homeIn = true; - } - } - } - } - if (homeIn) - { + return; + } + else if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = npc.Center; + homeIn = true; + } + } + } + } + if (homeIn) + { Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); float homingInertia = 15f; float homingVelocity = 30f; - projectile.velocity = (projectile.velocity * homingInertia + moveDirection * homingVelocity) / (homingInertia + 1f); - } + projectile.velocity = (projectile.velocity * homingInertia + moveDirection * homingVelocity) / (homingInertia + 1f); + } projectile.frameCounter++; if (projectile.frameCounter > 3) { @@ -186,7 +186,7 @@ namespace CalamityMod.Projectiles.Summon Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; + Main.dust[num622].scale = 0.5f; } if (Main.rand.NextBool(2)) { diff --git a/Projectiles/Summon/CosmicViperSummon.cs b/Projectiles/Summon/CosmicViperSummon.cs index de6dd3bd2a..a7c3e8f96f 100644 --- a/Projectiles/Summon/CosmicViperSummon.cs +++ b/Projectiles/Summon/CosmicViperSummon.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class CosmicViperSummon : ModProjectile + public class CosmicViperSummon : ModProjectile { public override void SetStaticDefaults() { @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Summon int dustAmt = 36; for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) { - int dustType = Main.rand.NextBool(3) ? 56 : 242; + 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)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; Vector2 vector7 = vector6 - projectile.Center; @@ -91,26 +91,26 @@ 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); - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); float detectRange = 1100f; Vector2 targetVec = projectile.position; bool foundTarget = false; - int targetIndex = -1; + int targetIndex = -1; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && targetDist < (detectRange + extraDist)) - { + float extraDist = (npc.width / 2) + (npc.height / 2); + //Calculate distance between target and the projectile to know if it's too far or not + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < (detectRange + extraDist)) + { detectRange = targetDist; targetVec = npc.Center; foundTarget = true; - targetIndex = npc.whoAmI; + targetIndex = npc.whoAmI; } } } @@ -121,15 +121,15 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[npcIndex]; if (npc.CanBeChasedBy(projectile, false)) { - float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && targetDist < (detectRange + extraDist)) - { + float extraDist = (npc.width / 2) + (npc.height / 2); + //Calculate distance between target and the projectile to know if it's too far or not + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < (detectRange + extraDist)) + { detectRange = targetDist; targetVec = npc.Center; foundTarget = true; - targetIndex = npcIndex; + targetIndex = npcIndex; } } } @@ -163,7 +163,7 @@ namespace CalamityMod.Projectiles.Summon } else { - float safeDist = 600f; + float safeDist = 600f; bool returnToPlayer = false; if (!returnToPlayer) { @@ -187,7 +187,7 @@ namespace CalamityMod.Projectiles.Summon } if (playerDist > 2000f) { - projectile.Center = player.Center; + projectile.Center = player.Center; projectile.netUpdate = true; } if (playerDist > 70f) @@ -204,20 +204,20 @@ namespace CalamityMod.Projectiles.Summon } if (foundTarget) { - projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + MathHelper.Pi, 0.1f); + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + MathHelper.Pi, 0.1f); } else { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; - int dustType = Main.rand.NextBool(3) ? 56 : 242; - float xVelOffset = projectile.velocity.X / 3f; - float yVelOffset = projectile.velocity.Y / 3f; - int trail = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[trail]; - dust.position.X = projectile.Center.X - xVelOffset; - dust.position.Y = projectile.Center.Y - yVelOffset; - dust.velocity *= 0f; - dust.scale = 0.5f; + int dustType = Main.rand.NextBool(3) ? 56 : 242; + float xVelOffset = projectile.velocity.X / 3f; + float yVelOffset = projectile.velocity.Y / 3f; + int trail = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[trail]; + dust.position.X = projectile.Center.X - xVelOffset; + dust.position.Y = projectile.Center.Y - yVelOffset; + dust.velocity *= 0f; + dust.scale = 0.5f; } if (projectile.ai[1] > 0f) { @@ -238,31 +238,31 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[1] += 2f; if (Main.myPlayer == projectile.owner) { - int projType; - float dmgMult; - if (Main.rand.NextBool(5)) - { - projType = ModContent.ProjectileType(); - dmgMult = 0.75f; - } - else if (Main.rand.NextBool(3)) - { - projType = ModContent.ProjectileType(); - dmgMult = 1f; - } - else - { - projType = ModContent.ProjectileType(); - dmgMult = 1.5f; - } + int projType; + float dmgMult; + if (Main.rand.NextBool(5)) + { + projType = ModContent.ProjectileType(); + dmgMult = 0.75f; + } + else if (Main.rand.NextBool(3)) + { + projType = ModContent.ProjectileType(); + dmgMult = 1f; + } + else + { + projType = ModContent.ProjectileType(); + dmgMult = 1.5f; + } Vector2 velocity = targetVec - projectile.Center; velocity.Normalize(); velocity *= speedMult; - //add some inaccuracy - velocity.Y += Main.rand.NextFloat(-30f, 30f) * 0.05f; - velocity.X += Main.rand.NextFloat(-30f, 30f) * 0.05f; + //add some inaccuracy + velocity.Y += Main.rand.NextFloat(-30f, 30f) * 0.05f; + velocity.X += Main.rand.NextFloat(-30f, 30f) * 0.05f; Projectile.NewProjectile(projectile.Center, velocity, projType, (int)(projectile.damage * dmgMult), projectile.knockBack, projectile.owner, targetIndex, 0f); projectile.netUpdate = true; @@ -271,31 +271,31 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool CanDamage() => false; + public override bool CanDamage() => false; - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int frameHeight = texture.Height / Main.projFrames[projectile.type]; - int y6 = frameHeight * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int frameHeight = texture.Height / Main.projFrames[projectile.type]; + int y6 = frameHeight * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + 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(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f); - return false; - } + 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; + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/CosmicViperGlow"); - int frameHeight = texture.Height / Main.projFrames[projectile.type]; - int y6 = frameHeight * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/CosmicViperGlow"); + int frameHeight = texture.Height / Main.projFrames[projectile.type]; + int y6 = frameHeight * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + 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)), Color.White, projectile.rotation, new Vector2(texture.Width / 2f, 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)), Color.White, projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f); + } } } diff --git a/Projectiles/Summon/CosmilampMinion.cs b/Projectiles/Summon/CosmilampMinion.cs index 58ac452d02..bfafc8355c 100644 --- a/Projectiles/Summon/CosmilampMinion.cs +++ b/Projectiles/Summon/CosmilampMinion.cs @@ -98,7 +98,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); float num535 = projectile.position.X; float num536 = projectile.position.Y; float num537 = 3000f; diff --git a/Projectiles/Summon/CrimslimeMinion.cs b/Projectiles/Summon/CrimslimeMinion.cs index c08d48f1bc..0d682163fd 100644 --- a/Projectiles/Summon/CrimslimeMinion.cs +++ b/Projectiles/Summon/CrimslimeMinion.cs @@ -97,6 +97,6 @@ namespace CalamityMod.Projectiles.Summon return false; } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/CrimsonSlimeGodMinion.cs b/Projectiles/Summon/CrimsonSlimeGodMinion.cs index f3b9591cd3..bab1788060 100644 --- a/Projectiles/Summon/CrimsonSlimeGodMinion.cs +++ b/Projectiles/Summon/CrimsonSlimeGodMinion.cs @@ -91,6 +91,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/DaedalusGolem.cs b/Projectiles/Summon/DaedalusGolem.cs index 640be72d60..2da90b6e5c 100644 --- a/Projectiles/Summon/DaedalusGolem.cs +++ b/Projectiles/Summon/DaedalusGolem.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Summon } public override void ReceiveExtraAI(BinaryReader reader) - { + { AttackTimer = reader.ReadInt32(); UsingChargedLaserAttack = reader.ReadBoolean(); } @@ -82,15 +82,15 @@ namespace CalamityMod.Projectiles.Summon NPC potentialTarget = projectile.Center.MinionHoming(900f, Owner); if (potentialTarget is null) destination = Owner.Center - Vector2.UnitX * (80f + (projectile.identity * 28f) % 560f) * Owner.direction; - else - { - Vector2 destA = potentialTarget.Center + Vector2.UnitX * (130f + (projectile.identity * 28f) % 560f); - Vector2 destB = potentialTarget.Center - Vector2.UnitX * (130f + (projectile.identity * 28f) % 560f); - if ((projectile.Center - destA).Length() < (projectile.Center - destB).Length()) - destination = destA; - else - destination = destB; - } + else + { + Vector2 destA = potentialTarget.Center + Vector2.UnitX * (130f + (projectile.identity * 28f) % 560f); + Vector2 destB = potentialTarget.Center - Vector2.UnitX * (130f + (projectile.identity * 28f) % 560f); + if ((projectile.Center - destA).Length() < (projectile.Center - destB).Length()) + destination = destA; + else + destination = destB; + } // Go upwards, and check down again to discover any height differences before deciding where to move. // There's a chance that this will encounter a null tile. If it us, just skip this step. @@ -106,16 +106,16 @@ namespace CalamityMod.Projectiles.Summon StuckWalkThroughWallsTimer = Utils.Clamp(StuckWalkThroughWallsTimer, 0, 160); if (projectile.Distance(Owner.Center) > 3500f) - { + { projectile.Center = Owner.Center; StuckWalkThroughWallsTimer = 0; projectile.netImportant = true; } if ((MoveToDestination(destination) || AttackTimer > 0) && potentialTarget != null) - { + { AttackTimer++; if (AttackTimer == 1) - { + { UsingChargedLaserAttack = Main.rand.NextBool(7); projectile.netUpdate = true; } @@ -278,7 +278,7 @@ namespace CalamityMod.Projectiles.Summon } public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { + { int startingWalkFrame = 6; int endingWalkFrame = 10; @@ -300,26 +300,26 @@ namespace CalamityMod.Projectiles.Summon { if (UsingChargedLaserAttack) projectile.frame = (int)MathHelper.Lerp(startingBeamFrame, endingBeamFrame + 1, Utils.InverseLerp(0f, ChargedLaserAttackTime, AttackTimer, true)); - else + else projectile.frame = (int)MathHelper.Lerp(startingPelletFrame, endingPelletFrame + 1, Utils.InverseLerp(0f, ChargedPelletAttackTime, AttackTimer, true)); } else if (Math.Abs(projectile.velocity.X) > 5f && Math.Abs(projectile.velocity.Y) < 2f && tileBelow.IsTileSolidGround()) - { + { if (projectile.frameCounter >= Utils.Clamp(2, 6, (int)Math.Abs(projectile.velocity.X * 0.8))) - { + { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame >= endingWalkFrame) projectile.frame = startingWalkFrame; } projectile.frame = Utils.Clamp(projectile.frame, startingWalkFrame, endingWalkFrame); - } + } else if (Math.Abs(projectile.velocity.X) <= 1f) { projectile.frame = 0; } - } + } - public override bool CanDamage() => false; + public override bool CanDamage() => false; } } diff --git a/Projectiles/Summon/DaedalusLightning.cs b/Projectiles/Summon/DaedalusLightning.cs index 056a522d17..b5fbd0c13b 100644 --- a/Projectiles/Summon/DaedalusLightning.cs +++ b/Projectiles/Summon/DaedalusLightning.cs @@ -9,142 +9,142 @@ using Terraria.ModLoader; using Terraria.Utilities; namespace CalamityMod.Projectiles.Summon { - public class DaedalusLightning : ModProjectile - { - internal PrimitiveTrail LightningDrawer; + public class DaedalusLightning : ModProjectile + { + internal PrimitiveTrail LightningDrawer; - public const int MaximumBranchingIterations = 3; - public const float LightningTurnRandomnessFactor = 1.7f; - public ref float InitialVelocityAngle => ref projectile.ai[0]; - // Technically not a ratio, and more of a seed, but it is used in a 0-2pi squash - // later in the code to get an arbitrary unit vector (which is then checked). - public ref float BaseTurnAngleRatio => ref projectile.ai[1]; - public ref float AccumulatedXMovementSpeeds => ref projectile.localAI[0]; - public ref float BranchingIteration => ref projectile.localAI[1]; + public const int MaximumBranchingIterations = 3; + public const float LightningTurnRandomnessFactor = 1.7f; + public ref float InitialVelocityAngle => ref projectile.ai[0]; + // Technically not a ratio, and more of a seed, but it is used in a 0-2pi squash + // later in the code to get an arbitrary unit vector (which is then checked). + public ref float BaseTurnAngleRatio => ref projectile.ai[1]; + public ref float AccumulatedXMovementSpeeds => ref projectile.localAI[0]; + public ref float BranchingIteration => ref projectile.localAI[1]; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Daedalus Lightning"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 100; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + ProjectileID.Sets.MinionShot[projectile.type] = true; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 100; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } public override void SetDefaults() { projectile.width = 14; projectile.height = 14; projectile.friendly = true; - projectile.minion = true; + projectile.minion = true; projectile.alpha = 255; projectile.penetrate = 2; - projectile.ignoreWater = true; + projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.extraUpdates = 20; + projectile.extraUpdates = 20; projectile.timeLeft = 45 * projectile.extraUpdates; - // Readjust the velocity magnitude the moment this projectile is created - // to make velocity setting outside the scope of this projectile less irritating - // to consider alongside extraUpdate multipliers. - // Also set the initial angle. - if (projectile.velocity != Vector2.Zero) - { - projectile.velocity /= projectile.extraUpdates; - } - } + // Readjust the velocity magnitude the moment this projectile is created + // to make velocity setting outside the scope of this projectile less irritating + // to consider alongside extraUpdate multipliers. + // Also set the initial angle. + if (projectile.velocity != Vector2.Zero) + { + projectile.velocity /= projectile.extraUpdates; + } + } public override void SendExtraAI(BinaryWriter writer) { writer.Write(AccumulatedXMovementSpeeds); - writer.Write(BranchingIteration); - } + writer.Write(BranchingIteration); + } public override void ReceiveExtraAI(BinaryReader reader) { - AccumulatedXMovementSpeeds = reader.ReadSingle(); - BranchingIteration = reader.ReadSingle(); - } + AccumulatedXMovementSpeeds = reader.ReadSingle(); + BranchingIteration = reader.ReadSingle(); + } public override void AI() { - // frameCounter in this context is really just an arbitrary timer - // which allows random turning to occur. - projectile.frameCounter++; + // frameCounter in this context is really just an arbitrary timer + // which allows random turning to occur. + projectile.frameCounter++; - projectile.scale = (float)Math.Sin(MathHelper.Pi * projectile.timeLeft / (45f * (projectile.MaxUpdates - 1))) * 4f; - if (projectile.scale > 1f) - projectile.scale = 1f; + projectile.scale = (float)Math.Sin(MathHelper.Pi * projectile.timeLeft / (45f * (projectile.MaxUpdates - 1))) * 4f; + if (projectile.scale > 1f) + projectile.scale = 1f; - Lighting.AddLight(projectile.Center, Color.Pink.ToVector3()); - if (projectile.frameCounter >= projectile.extraUpdates * 2) - { - projectile.frameCounter = 0; + Lighting.AddLight(projectile.Center, Color.Pink.ToVector3()); + if (projectile.frameCounter >= projectile.extraUpdates * 2) + { + projectile.frameCounter = 0; - float originalSpeed = MathHelper.Min(6f, projectile.velocity.Length()); - UnifiedRandom unifiedRandom = new UnifiedRandom((int)BaseTurnAngleRatio); - int turnTries = 0; - Vector2 newBaseDirection = -Vector2.UnitY; - Vector2 potentialBaseDirection; + float originalSpeed = MathHelper.Min(6f, projectile.velocity.Length()); + UnifiedRandom unifiedRandom = new UnifiedRandom((int)BaseTurnAngleRatio); + int turnTries = 0; + Vector2 newBaseDirection = -Vector2.UnitY; + Vector2 potentialBaseDirection; - do - { - BaseTurnAngleRatio = unifiedRandom.Next() % 100; - potentialBaseDirection = (BaseTurnAngleRatio / 100f * MathHelper.TwoPi).ToRotationVector2(); + do + { + BaseTurnAngleRatio = unifiedRandom.Next() % 100; + potentialBaseDirection = (BaseTurnAngleRatio / 100f * MathHelper.TwoPi).ToRotationVector2(); - // Ensure that the new potential direction base is always moving upwards (this is supposed to be somewhat similar to a -UnitY + RotatedBy). - potentialBaseDirection.Y = -Math.Abs(potentialBaseDirection.Y); + // Ensure that the new potential direction base is always moving upwards (this is supposed to be somewhat similar to a -UnitY + RotatedBy). + potentialBaseDirection.Y = -Math.Abs(potentialBaseDirection.Y); - bool canChangeLightningDirection = true; + bool canChangeLightningDirection = true; - // Potential directions with very little Y speed should not be considered, because this - // consequentially means that the X speed would be quite large. - if (potentialBaseDirection.Y > -0.02f) - canChangeLightningDirection = false; + // Potential directions with very little Y speed should not be considered, because this + // consequentially means that the X speed would be quite large. + if (potentialBaseDirection.Y > -0.02f) + canChangeLightningDirection = false; - // This mess of math basically encourages movement at the ends of an extraUpdate cycle, - // discourages super frequenent randomness as the accumulated X speed changes get larger, - // or if the original speed is quite large. - if (Math.Abs(potentialBaseDirection.X * (projectile.extraUpdates + 1) * 2f * originalSpeed + AccumulatedXMovementSpeeds) > projectile.MaxUpdates * LightningTurnRandomnessFactor) - { - canChangeLightningDirection = false; - } + // This mess of math basically encourages movement at the ends of an extraUpdate cycle, + // discourages super frequenent randomness as the accumulated X speed changes get larger, + // or if the original speed is quite large. + if (Math.Abs(potentialBaseDirection.X * (projectile.extraUpdates + 1) * 2f * originalSpeed + AccumulatedXMovementSpeeds) > projectile.MaxUpdates * LightningTurnRandomnessFactor) + { + canChangeLightningDirection = false; + } - // If the above checks were all passed, redefine the base direction of the lightning. - if (canChangeLightningDirection) - newBaseDirection = potentialBaseDirection; + // If the above checks were all passed, redefine the base direction of the lightning. + if (canChangeLightningDirection) + newBaseDirection = potentialBaseDirection; - turnTries++; - } - while (turnTries < 100); + turnTries++; + } + while (turnTries < 100); - if (projectile.velocity != Vector2.Zero) - { - AccumulatedXMovementSpeeds += newBaseDirection.X * (projectile.extraUpdates + 1) * 2f * originalSpeed; - projectile.velocity = newBaseDirection.RotatedBy(InitialVelocityAngle + MathHelper.PiOver2) * originalSpeed; - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - } - } - } - - #region Drawing - internal float WidthFunction(float completionRatio) - { - float baseWidth = MathHelper.Lerp(2f, 6f, (float)Math.Sin(MathHelper.Pi * 4f * completionRatio) * 0.5f + 0.5f) * projectile.scale; - return baseWidth * (float)Math.Sin(MathHelper.Pi * completionRatio); - } - internal Color ColorFunction(float completionRatio) - { - Color baseColor = Color.Lerp(Color.Pink, Color.HotPink, (float)Math.Sin(MathHelper.TwoPi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f); - return Color.Lerp(baseColor, Color.Red, ((float)Math.Sin(MathHelper.Pi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f) * 0.8f); - } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (LightningDrawer is null) - LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); - - LightningDrawer.Draw(projectile.oldPos.Where(oldPos => oldPos != Vector2.Zero), projectile.Size * 0.5f - Main.screenPosition, 300); - return false; + if (projectile.velocity != Vector2.Zero) + { + AccumulatedXMovementSpeeds += newBaseDirection.X * (projectile.extraUpdates + 1) * 2f * originalSpeed; + projectile.velocity = newBaseDirection.RotatedBy(InitialVelocityAngle + MathHelper.PiOver2) * originalSpeed; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + } } - #endregion - } + + #region Drawing + internal float WidthFunction(float completionRatio) + { + float baseWidth = MathHelper.Lerp(2f, 6f, (float)Math.Sin(MathHelper.Pi * 4f * completionRatio) * 0.5f + 0.5f) * projectile.scale; + return baseWidth * (float)Math.Sin(MathHelper.Pi * completionRatio); + } + internal Color ColorFunction(float completionRatio) + { + Color baseColor = Color.Lerp(Color.Pink, Color.HotPink, (float)Math.Sin(MathHelper.TwoPi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f); + return Color.Lerp(baseColor, Color.Red, ((float)Math.Sin(MathHelper.Pi * completionRatio + Main.GlobalTime * 4f) * 0.5f + 0.5f) * 0.8f); + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (LightningDrawer is null) + LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); + + LightningDrawer.Draw(projectile.oldPos.Where(oldPos => oldPos != Vector2.Zero), projectile.Size * 0.5f - Main.screenPosition, 300); + return false; + } + #endregion + } } diff --git a/Projectiles/Summon/DaedalusPellet.cs b/Projectiles/Summon/DaedalusPellet.cs index 99d908f1dd..065202b6a3 100644 --- a/Projectiles/Summon/DaedalusPellet.cs +++ b/Projectiles/Summon/DaedalusPellet.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Summon projectile.width = 10; projectile.height = 10; projectile.friendly = true; - projectile.minion = true; + projectile.minion = true; projectile.ignoreWater = true; projectile.tileCollide = false; projectile.alpha = 255; diff --git a/Projectiles/Summon/DankCreeperMinion.cs b/Projectiles/Summon/DankCreeperMinion.cs index e90f537e7e..8581d100c5 100644 --- a/Projectiles/Summon/DankCreeperMinion.cs +++ b/Projectiles/Summon/DankCreeperMinion.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); float num535 = projectile.position.X; float num536 = projectile.position.Y; float num537 = 1300f; diff --git a/Projectiles/Summon/DeathstareBeam.cs b/Projectiles/Summon/DeathstareBeam.cs index 288794fe43..19cbb4f8b5 100644 --- a/Projectiles/Summon/DeathstareBeam.cs +++ b/Projectiles/Summon/DeathstareBeam.cs @@ -30,10 +30,10 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { if (!Main.projectile.IndexInRange((int)OwnerUUID)) - { + { projectile.Kill(); return; - } + } projectile.Opacity = Utils.InverseLerp(1f, 0f, 1f - projectile.timeLeft / 10f, true); projectile.Center = Main.projectile[(int)OwnerUUID].Center - projectile.velocity; diff --git a/Projectiles/Summon/DeathstareEyeball.cs b/Projectiles/Summon/DeathstareEyeball.cs index b138a8b980..db84de3491 100644 --- a/Projectiles/Summon/DeathstareEyeball.cs +++ b/Projectiles/Summon/DeathstareEyeball.cs @@ -8,7 +8,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class DeathstareEyeball : ModProjectile + public class DeathstareEyeball : ModProjectile { // This does not need to be synced. It is used solely for drawcode/visuals and is intended to be local. public float PupilScale = 1f; @@ -39,8 +39,8 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; } - #region AI - public override void AI() + #region AI + public override void AI() { Lighting.AddLight(projectile.Center, Color.Blue.ToVector3()); @@ -94,16 +94,16 @@ namespace CalamityMod.Projectiles.Summon } public void DoHoveringAI() - { + { // Roll the pupil around if there's little movement from the eye and player. if (Time % 180f > 120f && Math.Abs(projectile.rotation) < 0.03f) - { + { float idealAngle = Utils.InverseLerp(120f, 180f, Time % 180f, true) * MathHelper.TwoPi; PupilAngle = PupilAngle.AngleTowards(idealAngle, MathHelper.ToRadians(12f)); PupilOutwardness = MathHelper.Lerp(PupilOutwardness, 4f, 0.2f); } - else + else { float idealOutwardness = MathHelper.Clamp(Owner.velocity.Length() * 0.5f, 0f, 5f); float idealAngle = Owner.velocity.ToRotation(); @@ -111,16 +111,16 @@ namespace CalamityMod.Projectiles.Summon PupilOutwardness = MathHelper.Lerp(PupilOutwardness, idealOutwardness, 0.2f); PupilAngle = PupilAngle.AngleTowards(idealAngle, MathHelper.ToRadians(12f)); } - } + } public void DoAttackingAI(NPC target) - { + { PupilOutwardness = MathHelper.Lerp(PupilOutwardness, 4f, 0.25f); if (Time % BeamFireRate == BeamFireRate - 20) - { + { if (Main.myPlayer == projectile.owner) - { + { Vector2 velocity = (target.Center - projectile.Center) / 15f; int beam = Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); Main.projectile[beam].ai[0] = Projectile.GetByUUID(projectile.owner, projectile.whoAmI); @@ -131,11 +131,11 @@ namespace CalamityMod.Projectiles.Summon // After firing, have the pupil retract a bit. if (Time % BeamFireRate > BeamFireRate - 20) - { + { PupilScale = MathHelper.Lerp(PupilScale, 0.7f, 0.15f); } - // Otherwise, have it behave like normal. - else + // Otherwise, have it behave like normal. + else { PupilScale = MathHelper.Lerp(PupilScale, 1f, 0.175f); PupilAngle = PupilAngle.AngleTowards(projectile.AngleTo(target.Center), MathHelper.ToRadians(15f)); @@ -158,10 +158,10 @@ namespace CalamityMod.Projectiles.Summon } } - #endregion + #endregion - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { Texture2D eyeTexture = Main.projectileTexture[projectile.type]; Rectangle frame = eyeTexture.Frame(1, 4, 0, projectile.frame); Vector2 origin = frame.Size() * 0.5f; @@ -174,8 +174,8 @@ namespace CalamityMod.Projectiles.Summon pupilDrawPosition -= Vector2.UnitY * 4f; spriteBatch.Draw(pupilTexture, pupilDrawPosition, null, projectile.GetAlpha(lightColor), PupilAngle, pupilTexture.Size() * 0.5f, PupilScale, spriteEffects, 0f); return false; - } + } - public override bool CanDamage() => false; + public override bool CanDamage() => false; } } diff --git a/Projectiles/Summon/DormantBrimseekerSummoner.cs b/Projectiles/Summon/DormantBrimseekerSummoner.cs index 5f19f5b6d6..ab0aacee88 100644 --- a/Projectiles/Summon/DormantBrimseekerSummoner.cs +++ b/Projectiles/Summon/DormantBrimseekerSummoner.cs @@ -49,11 +49,11 @@ namespace CalamityMod.Projectiles.Summon { projectile.Kill(); } - } + } public override void Kill(int timeLeft) { - Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 7f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - } + Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 7f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + } } } diff --git a/Projectiles/Summon/Dreadmine.cs b/Projectiles/Summon/Dreadmine.cs index 3f1566d0e4..8fd9fbe546 100644 --- a/Projectiles/Summon/Dreadmine.cs +++ b/Projectiles/Summon/Dreadmine.cs @@ -129,34 +129,34 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[Main.player[projectile.owner].MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float num950 = npc.position.X + (float)(npc.width / 2); - float num951 = npc.position.Y + (float)(npc.height / 2); - float num952 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num950) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num951); - if (num952 < num948) - { - num948 = num952; - center12 = npc.Center; - flag49 = true; - } - } - } - if (!flag49) - { - for (int num949 = 0; num949 < Main.npc.Length; num949++) - { - if (Main.npc[num949].CanBeChasedBy(projectile, false)) - { - float num950 = Main.npc[num949].position.X + (float)(Main.npc[num949].width / 2); - float num951 = Main.npc[num949].position.Y + (float)(Main.npc[num949].height / 2); - float num952 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num950) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num951); - if (num952 < num948) - { - num948 = num952; - center12 = Main.npc[num949].Center; - flag49 = true; - } - } - } + float num950 = npc.position.X + (float)(npc.width / 2); + float num951 = npc.position.Y + (float)(npc.height / 2); + float num952 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num950) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num951); + if (num952 < num948) + { + num948 = num952; + center12 = npc.Center; + flag49 = true; + } + } + } + if (!flag49) + { + for (int num949 = 0; num949 < Main.npc.Length; num949++) + { + if (Main.npc[num949].CanBeChasedBy(projectile, false)) + { + float num950 = Main.npc[num949].position.X + (float)(Main.npc[num949].width / 2); + float num951 = Main.npc[num949].position.Y + (float)(Main.npc[num949].height / 2); + float num952 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num950) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num951); + if (num952 < num948) + { + num948 = num952; + center12 = Main.npc[num949].Center; + flag49 = true; + } + } + } } if (flag49) { @@ -202,7 +202,7 @@ namespace CalamityMod.Projectiles.Summon num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Summon/DreadmineTurret.cs b/Projectiles/Summon/DreadmineTurret.cs index efe4bb76c8..d8f41a1015 100644 --- a/Projectiles/Summon/DreadmineTurret.cs +++ b/Projectiles/Summon/DreadmineTurret.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (projectile.localAI[0] == 0f) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); diff --git a/Projectiles/Summon/EXPLODINGFROG.cs b/Projectiles/Summon/EXPLODINGFROG.cs index 7352e8b006..1e4bf05127 100644 --- a/Projectiles/Summon/EXPLODINGFROG.cs +++ b/Projectiles/Summon/EXPLODINGFROG.cs @@ -96,7 +96,7 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity.Y = 10f; } - projectile.StickToTiles(false, false); + projectile.StickToTiles(false, false); } public override bool CanDamage() => false; diff --git a/Projectiles/Summon/ElementalAxeMinion.cs b/Projectiles/Summon/ElementalAxeMinion.cs index 272a011013..acb92d9971 100644 --- a/Projectiles/Summon/ElementalAxeMinion.cs +++ b/Projectiles/Summon/ElementalAxeMinion.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class ElementalAxeMinion : ModProjectile + public class ElementalAxeMinion : ModProjectile { public override void SetStaticDefaults() { @@ -57,18 +57,18 @@ namespace CalamityMod.Projectiles.Summon player.AddBuff(ModContent.BuffType(), 3600); if (flag64) { - if (player.dead) - { - modPlayer.eAxe = false; - } - if (modPlayer.eAxe) + if (player.dead) + { + modPlayer.eAxe = false; + } + if (modPlayer.eAxe) { projectile.timeLeft = 2; } } projectile.rotation += 0.075f; - projectile.ChargingMinionAI(1600f, 1800f, 2500f, 400f, 1, 30f, 24f, 12f, new Vector2(0f, -60f), 30f, 16f, true, true); + projectile.ChargingMinionAI(1600f, 1800f, 2500f, 400f, 1, 30f, 24f, 12f, new Vector2(0f, -60f), 30f, 16f, true, true); } public override Color? GetAlpha(Color lightColor) @@ -85,9 +85,9 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } } } diff --git a/Projectiles/Summon/EndoCooperBody.cs b/Projectiles/Summon/EndoCooperBody.cs index 9f3cf7381d..9b1c3bf2c7 100644 --- a/Projectiles/Summon/EndoCooperBody.cs +++ b/Projectiles/Summon/EndoCooperBody.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class EndoCooperBody : ModProjectile + public class EndoCooperBody : ModProjectile { private int AttackMode = 0; private int LimbID = 0; @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Summon projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.extraUpdates = 1; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() @@ -139,7 +139,7 @@ namespace CalamityMod.Projectiles.Summon if (limbs.type != ModContent.ProjectileType() || !limbs.active) projectile.Kill(); - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); bool flag24 = false; if (projectile.ai[0] == 2f) { diff --git a/Projectiles/Summon/EndoCooperLimbs.cs b/Projectiles/Summon/EndoCooperLimbs.cs index 3e95b267c3..43f7be98bb 100644 --- a/Projectiles/Summon/EndoCooperLimbs.cs +++ b/Projectiles/Summon/EndoCooperLimbs.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class EndoCooperLimbs : ModProjectile + public class EndoCooperLimbs : ModProjectile { private int AttackMode = 0; public override void SetStaticDefaults() @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Summon projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.extraUpdates = 1; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Summon/EndoFire.cs b/Projectiles/Summon/EndoFire.cs index d88bab58f6..272aa4e452 100644 --- a/Projectiles/Summon/EndoFire.cs +++ b/Projectiles/Summon/EndoFire.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class EndoFire : ModProjectile + public class EndoFire : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Summon projectile.idStaticNPCHitCooldown = 5; projectile.timeLeft = 300; projectile.tileCollide = false; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Summon/EndoHydraBody.cs b/Projectiles/Summon/EndoHydraBody.cs index a994ea7fec..6b48673ee7 100644 --- a/Projectiles/Summon/EndoHydraBody.cs +++ b/Projectiles/Summon/EndoHydraBody.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; projectile.timeLeft *= 5; projectile.minion = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Summon projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; projectile.localAI[0] = 1f; - } + } if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / diff --git a/Projectiles/Summon/EndoHydraHead.cs b/Projectiles/Summon/EndoHydraHead.cs index b04daf0058..c8b4671ab4 100644 --- a/Projectiles/Summon/EndoHydraHead.cs +++ b/Projectiles/Summon/EndoHydraHead.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class EndoHydraHead : ModProjectile + public class EndoHydraHead : ModProjectile { public Vector2 DeltaPosition; public Vector2 DeltaPositionMoving; @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; projectile.timeLeft *= 5; projectile.minion = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void ReceiveExtraAI(BinaryReader reader) { @@ -92,8 +92,8 @@ namespace CalamityMod.Projectiles.Summon } } - projectile.localAI[0] = 1f; - } + projectile.localAI[0] = 1f; + } if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / diff --git a/Projectiles/Summon/EndoIceShard.cs b/Projectiles/Summon/EndoIceShard.cs index 023186e28b..c7c8d3599f 100644 --- a/Projectiles/Summon/EndoIceShard.cs +++ b/Projectiles/Summon/EndoIceShard.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Summon projectile.extraUpdates = 1; projectile.alpha = 255; projectile.timeLeft = 240; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Summon/EndoRay.cs b/Projectiles/Summon/EndoRay.cs index b21267c6e3..ffe7483e57 100644 --- a/Projectiles/Summon/EndoRay.cs +++ b/Projectiles/Summon/EndoRay.cs @@ -23,10 +23,10 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = 10; projectile.extraUpdates = 100; projectile.timeLeft = 265; - projectile.coldDamage = true; + projectile.coldDamage = true; projectile.tileCollide = false; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 100; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 100; } public override void AI() @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Summon int idx = Dust.NewDust(spawnPosition, 1, 1, 113, 0f, 0f, 0, default, 1.25f); Main.dust[idx].position = spawnPosition; Main.dust[idx].scale = Main.rand.NextFloat(0.71f, 0.93f); - Main.dust[idx].velocity *= 0.1f; + Main.dust[idx].velocity *= 0.1f; Main.dust[idx].noGravity = true; } } diff --git a/Projectiles/Summon/EnergyOrb.cs b/Projectiles/Summon/EnergyOrb.cs index 3775dacebe..8975ba564f 100644 --- a/Projectiles/Summon/EnergyOrb.cs +++ b/Projectiles/Summon/EnergyOrb.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class EnergyOrb : ModProjectile + public class EnergyOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Magic/BlueBubble"; @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = 1; projectile.tileCollide = false; projectile.timeLeft = 200; - projectile.minion = true; + projectile.minion = true; } public override void AI() @@ -30,10 +30,10 @@ namespace CalamityMod.Projectiles.Summon projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f) { - int num469 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 132, 0f, 0f, 100, default, 1f); - if (Main.rand.Next(6) != 0) - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int num469 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 132, 0f, 0f, 100, default, 1f); + if (Main.rand.Next(6) != 0) + Main.dust[num469].noGravity = true; + Main.dust[num469].velocity *= 0f; } NPC potentialTarget = projectile.Center.MinionHoming(400f, Main.player[projectile.owner]); if (potentialTarget != null) diff --git a/Projectiles/Summon/EyeOfNightSummon.cs b/Projectiles/Summon/EyeOfNightSummon.cs index 4725423c7a..817adc2756 100644 --- a/Projectiles/Summon/EyeOfNightSummon.cs +++ b/Projectiles/Summon/EyeOfNightSummon.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class EyeOfNightSummon : ModProjectile + public class EyeOfNightSummon : ModProjectile { public Player Owner => Main.player[projectile.owner]; public ref float HoverTime => ref projectile.ai[0]; @@ -133,6 +133,6 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity = (destination - projectile.Center).SafeNormalize(Vector2.Zero) * flySpeed; } - public override bool CanDamage() => false; + public override bool CanDamage() => false; } } \ No newline at end of file diff --git a/Projectiles/Summon/FlameBlast.cs b/Projectiles/Summon/FlameBlast.cs index 7687b67491..1e9146bfe1 100644 --- a/Projectiles/Summon/FlameBlast.cs +++ b/Projectiles/Summon/FlameBlast.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class FlameBlast : ModProjectile + public class FlameBlast : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (count == 0f) { Main.PlaySound(SoundID.Item73, projectile.position); diff --git a/Projectiles/Summon/FlameBurst.cs b/Projectiles/Summon/FlameBurst.cs index 18807090be..29678996d2 100644 --- a/Projectiles/Summon/FlameBurst.cs +++ b/Projectiles/Summon/FlameBurst.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class FlameBurst : ModProjectile + public class FlameBurst : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (count == 0f) { Main.PlaySound(SoundID.Item73, projectile.position); diff --git a/Projectiles/Summon/FleshBallMinion.cs b/Projectiles/Summon/FleshBallMinion.cs index d8b4758582..57a813b4c6 100644 --- a/Projectiles/Summon/FleshBallMinion.cs +++ b/Projectiles/Summon/FleshBallMinion.cs @@ -7,157 +7,157 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class FleshBallMinion : ModProjectile - { - public Player Owner => Main.player[projectile.owner]; - public bool SittingOnGround => Math.Abs(projectile.velocity.X) < 1.55f && projectile.velocity.Y == 0f; - public ref float HopTimer => ref projectile.ai[0]; - public ref float HopAmount => ref projectile.ai[1]; - public const float Gravity = 0.25f; - public const float MaxFallSpeed = 12f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Flesh Ball"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.MinionSacrificable[projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; - } + public class FleshBallMinion : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public bool SittingOnGround => Math.Abs(projectile.velocity.X) < 1.55f && projectile.velocity.Y == 0f; + public ref float HopTimer => ref projectile.ai[0]; + public ref float HopAmount => ref projectile.ai[1]; + public const float Gravity = 0.25f; + public const float MaxFallSpeed = 12f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Flesh Ball"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 32; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.minionSlots = 1f; - projectile.timeLeft = 90000; - projectile.penetrate = -1; - projectile.extraUpdates = 1; - projectile.tileCollide = false; - projectile.minion = true; + public override void SetDefaults() + { + projectile.width = projectile.height = 32; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 1f; + projectile.timeLeft = 90000; + projectile.penetrate = -1; + projectile.extraUpdates = 1; + projectile.tileCollide = false; + projectile.minion = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 60; - } + } - public override void AI() - { - ProvidePlayerMinionBuffs(); - DetermineFrames(); - GenerateVisuals(); + public override void AI() + { + ProvidePlayerMinionBuffs(); + DetermineFrames(); + GenerateVisuals(); - HopTimer++; - SufferFromSeparationAnxiety(); - NPC potentialTarget = projectile.Center.MinionHoming(950f, Owner, false); - if (potentialTarget is null) - GoNearOwner(); - else - AttackTarget(potentialTarget); - EnforceGravity(); - } + HopTimer++; + SufferFromSeparationAnxiety(); + NPC potentialTarget = projectile.Center.MinionHoming(950f, Owner, false); + if (potentialTarget is null) + GoNearOwner(); + else + AttackTarget(potentialTarget); + EnforceGravity(); + } - internal void ProvidePlayerMinionBuffs() - { - Owner.AddBuff(ModContent.BuffType(), 3600); + internal void ProvidePlayerMinionBuffs() + { + Owner.AddBuff(ModContent.BuffType(), 3600); - // Verify player/minion state integrity. The minion cannot stay alive if the - // owner is dead or if the caller of the AI is invalid. - if (projectile.type != ModContent.ProjectileType()) - return; + // Verify player/minion state integrity. The minion cannot stay alive if the + // owner is dead or if the caller of the AI is invalid. + if (projectile.type != ModContent.ProjectileType()) + return; - if (Owner.dead) - Owner.Calamity().fleshBall = false; - if (Owner.Calamity().fleshBall) - projectile.timeLeft = 2; - } + if (Owner.dead) + Owner.Calamity().fleshBall = false; + if (Owner.Calamity().fleshBall) + projectile.timeLeft = 2; + } - internal void DetermineFrames() - { - projectile.frameCounter++; - if (projectile.frameCounter % 5 == 4) - projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; - } + internal void DetermineFrames() + { + projectile.frameCounter++; + if (projectile.frameCounter % 5 == 4) + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + } - internal void EnforceGravity() - { - if (projectile.velocity.Y < MaxFallSpeed) - projectile.velocity.Y += Gravity; - } + internal void EnforceGravity() + { + if (projectile.velocity.Y < MaxFallSpeed) + projectile.velocity.Y += Gravity; + } - internal void GenerateVisuals() - { - // All code within this method is visual. There is no need to waste resources executing it on the server. - if (Main.dedServ) - return; + internal void GenerateVisuals() + { + // All code within this method is visual. There is no need to waste resources executing it on the server. + if (Main.dedServ) + return; - projectile.rotation += projectile.velocity.X * 0.05f; + projectile.rotation += projectile.velocity.X * 0.05f; - Vector2 shootOffsetDirection = -Vector2.UnitY.RotatedBy(projectile.rotation + projectile.direction * 0.2f); - Dust blood = Dust.NewDustDirect(projectile.Center + shootOffsetDirection * 10f - new Vector2(4f), 0, 0, DustID.Blood, newColor: Color.Transparent); - blood.velocity = shootOffsetDirection.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 4f); - blood.noGravity = true; - } + Vector2 shootOffsetDirection = -Vector2.UnitY.RotatedBy(projectile.rotation + projectile.direction * 0.2f); + Dust blood = Dust.NewDustDirect(projectile.Center + shootOffsetDirection * 10f - new Vector2(4f), 0, 0, DustID.Blood, newColor: Color.Transparent); + blood.velocity = shootOffsetDirection.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 4f); + blood.noGravity = true; + } - internal void SufferFromSeparationAnxiety() - { - float teleportPromptDistance = Collision.CanHitLine(projectile.Center, 1, 1, Owner.Center, 1, 1) ? 1900f : 805f; - if (Main.myPlayer == projectile.owner && !projectile.WithinRange(Owner.Center, teleportPromptDistance)) - { - projectile.Center = Owner.Center; - projectile.netUpdate = true; - } - } + internal void SufferFromSeparationAnxiety() + { + float teleportPromptDistance = Collision.CanHitLine(projectile.Center, 1, 1, Owner.Center, 1, 1) ? 1900f : 805f; + if (Main.myPlayer == projectile.owner && !projectile.WithinRange(Owner.Center, teleportPromptDistance)) + { + projectile.Center = Owner.Center; + projectile.netUpdate = true; + } + } - internal void GoNearOwner() - { - projectile.tileCollide = true; + internal void GoNearOwner() + { + projectile.tileCollide = true; - bool closeToPlayer = projectile.WithinRange(Owner.Center, 150f); - if (!closeToPlayer && SittingOnGround && HopTimer % 30f == 29f) - { - projectile.velocity = projectile.SafeDirectionTo(Owner.Center) * 9f + new Vector2(Math.Sign(projectile.velocity.X) * 2f, -9f); + bool closeToPlayer = projectile.WithinRange(Owner.Center, 150f); + if (!closeToPlayer && SittingOnGround && HopTimer % 30f == 29f) + { + projectile.velocity = projectile.SafeDirectionTo(Owner.Center) * 9f + new Vector2(Math.Sign(projectile.velocity.X) * 2f, -9f); - // Don't collide with tiles for 1 frame, to prevent slopes from being a nuisance. - projectile.tileCollide = false; - projectile.netUpdate = true; - } - } + // Don't collide with tiles for 1 frame, to prevent slopes from being a nuisance. + projectile.tileCollide = false; + projectile.netUpdate = true; + } + } - internal void AttackTarget(NPC target) - { - projectile.tileCollide = true; + internal void AttackTarget(NPC target) + { + projectile.tileCollide = true; - if (SittingOnGround && HopTimer % 20f == 19f) - { - projectile.velocity = projectile.SafeDirectionTo(target.Center) * 6f + new Vector2(Math.Sign(projectile.velocity.X) * 2f, -7f); - HopAmount++; + if (SittingOnGround && HopTimer % 20f == 19f) + { + projectile.velocity = projectile.SafeDirectionTo(target.Center) * 6f + new Vector2(Math.Sign(projectile.velocity.X) * 2f, -7f); + HopAmount++; - // Release a bunch of blood. - if (Main.myPlayer == projectile.owner && HopAmount % 3f == 2f) - { - for (int i = 0; i < 2; i++) - { - Vector2 shootVelocity = -Vector2.UnitY.RotatedByRandom(0.3f) * Main.rand.NextFloat(6f, 11f); - int blood = Projectile.NewProjectile(projectile.Top, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - } - } + // Release a bunch of blood. + if (Main.myPlayer == projectile.owner && HopAmount % 3f == 2f) + { + for (int i = 0; i < 2; i++) + { + Vector2 shootVelocity = -Vector2.UnitY.RotatedByRandom(0.3f) * Main.rand.NextFloat(6f, 11f); + int blood = Projectile.NewProjectile(projectile.Top, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + } + } - // Don't collide with tiles for 1 frame, to prevent slopes from being a nuisance. - projectile.tileCollide = false; - projectile.netUpdate = true; - } - } + // Don't collide with tiles for 1 frame, to prevent slopes from being a nuisance. + projectile.tileCollide = false; + projectile.netUpdate = true; + } + } // Prevent immediate death on tile collision, and slow down on tile collision. public override bool OnTileCollide(Vector2 oldVelocity) - { - projectile.velocity.X *= 0.9f; - return false; - } + { + projectile.velocity.X *= 0.9f; + return false; + } - public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) - { - fallThrough = projectile.Bottom.Y < Owner.Top.Y; - return true; - } - } + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) + { + fallThrough = projectile.Bottom.Y < Owner.Top.Y; + return true; + } + } } diff --git a/Projectiles/Summon/FleshBlood.cs b/Projectiles/Summon/FleshBlood.cs index 594d5c9a11..bf7af39283 100644 --- a/Projectiles/Summon/FleshBlood.cs +++ b/Projectiles/Summon/FleshBlood.cs @@ -3,10 +3,10 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class FleshBlood : ModProjectile + public class FleshBlood : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public const int LifeTime = 300; + public const int LifeTime = 300; public override void SetStaticDefaults() { @@ -24,9 +24,9 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = LifeTime; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < LifeTime - 30 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < LifeTime - 30 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f) @@ -39,8 +39,8 @@ namespace CalamityMod.Projectiles.Summon } } - if (projectile.timeLeft < LifeTime - 30) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 6f, 20f); + if (projectile.timeLeft < LifeTime - 30) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 6f, 20f); } } } diff --git a/Projectiles/Summon/FlyingOrthocera.cs b/Projectiles/Summon/FlyingOrthocera.cs index f77650b307..d57903de9b 100644 --- a/Projectiles/Summon/FlyingOrthocera.cs +++ b/Projectiles/Summon/FlyingOrthocera.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class FlyingOrthocera : ModProjectile + public class FlyingOrthocera : ModProjectile { public const float SearchDistance = 850f; @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (projectile.localAI[0] == 0f) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); diff --git a/Projectiles/Summon/FlyingOrthoceraStream.cs b/Projectiles/Summon/FlyingOrthoceraStream.cs index 2fd36060e7..edebdd27e9 100644 --- a/Projectiles/Summon/FlyingOrthoceraStream.cs +++ b/Projectiles/Summon/FlyingOrthoceraStream.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class FlyingOrthoceraStream : ModProjectile + public class FlyingOrthoceraStream : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Summon/ForbiddenCircletEater.cs b/Projectiles/Summon/ForbiddenCircletEater.cs index 90ef9f9969..5b7c2b3d12 100644 --- a/Projectiles/Summon/ForbiddenCircletEater.cs +++ b/Projectiles/Summon/ForbiddenCircletEater.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class ForbiddenCircletEater : ModProjectile + public class ForbiddenCircletEater : ModProjectile { private int bounce = 3; @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (projectile.alpha > 0) { projectile.alpha -= 50; @@ -71,11 +71,11 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[0] += 1f; if (projectile.ai[0] > 30f) { - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { float num377 = npc.position.X + (float)(npc.width / 2); float num378 = npc.position.Y + (float)(npc.height / 2); float num379 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num377) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num378); @@ -86,28 +86,28 @@ namespace CalamityMod.Projectiles.Summon num374 = num378; flag10 = true; } - } - } - if (!flag10) - { - for (int num376 = 0; num376 < Main.maxNPCs; num376++) - { - NPC npc = Main.npc[num376]; - if (npc.CanBeChasedBy(projectile, false)) - { - float num377 = npc.position.X + (float)(npc.width / 2); - float num378 = npc.position.Y + (float)(npc.height / 2); - float num379 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num377) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num378); - if (num379 < 640f && num379 < num375 && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) - { - num375 = num379; - num373 = num377; - num374 = num378; - flag10 = true; - } - } - } - } + } + } + if (!flag10) + { + for (int num376 = 0; num376 < Main.maxNPCs; num376++) + { + NPC npc = Main.npc[num376]; + if (npc.CanBeChasedBy(projectile, false)) + { + float num377 = npc.position.X + (float)(npc.width / 2); + float num378 = npc.position.Y + (float)(npc.height / 2); + float num379 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num377) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num378); + if (num379 < 640f && num379 < num375 && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + num375 = num379; + num373 = num377; + num374 = num378; + flag10 = true; + } + } + } + } } if (!flag10) { @@ -166,7 +166,7 @@ namespace CalamityMod.Projectiles.Summon } else { - projectile.ai[0] += 15f; + projectile.ai[0] += 15f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Summon/FrogGore1.cs b/Projectiles/Summon/FrogGore1.cs index 566a576086..0eaee31999 100644 --- a/Projectiles/Summon/FrogGore1.cs +++ b/Projectiles/Summon/FrogGore1.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Summon } projectile.velocity.Y += 0.2f; projectile.rotation += projectile.velocity.X * 0.03f; - } + } public override void Kill(int timeLeft) { for (int i = 0; i < Main.rand.Next(4, 8 + 1); i++) diff --git a/Projectiles/Summon/FrogGore2.cs b/Projectiles/Summon/FrogGore2.cs index 1e375ffd82..02e664f585 100644 --- a/Projectiles/Summon/FrogGore2.cs +++ b/Projectiles/Summon/FrogGore2.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Summon } projectile.velocity.Y += 0.2f; projectile.rotation += projectile.velocity.X * 0.03f; - } + } public override void Kill(int timeLeft) { for (int i = 0; i < Main.rand.Next(4, 8 + 1); i++) diff --git a/Projectiles/Summon/FrogGore3.cs b/Projectiles/Summon/FrogGore3.cs index dbe53db248..b1376fd67e 100644 --- a/Projectiles/Summon/FrogGore3.cs +++ b/Projectiles/Summon/FrogGore3.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Summon } projectile.velocity.Y += 0.2f; projectile.rotation += projectile.velocity.X * 0.03f; - } + } public override void Kill(int timeLeft) { for (int i = 0; i < Main.rand.Next(4, 8 + 1); i++) diff --git a/Projectiles/Summon/FrogGore4.cs b/Projectiles/Summon/FrogGore4.cs index 1179192a9e..31a83ff00a 100644 --- a/Projectiles/Summon/FrogGore4.cs +++ b/Projectiles/Summon/FrogGore4.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Summon } projectile.velocity.Y += 0.2f; projectile.rotation += projectile.velocity.X * 0.03f; - } + } public override void Kill(int timeLeft) { for (int i = 0; i < Main.rand.Next(4, 8 + 1); i++) diff --git a/Projectiles/Summon/FrogGore5.cs b/Projectiles/Summon/FrogGore5.cs index 6363b6cbcb..3afc0756ba 100644 --- a/Projectiles/Summon/FrogGore5.cs +++ b/Projectiles/Summon/FrogGore5.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Summon } projectile.velocity.Y += 0.2f; projectile.rotation += projectile.velocity.X * 0.03f; - } + } public override void Kill(int timeLeft) { for (int i = 0; i < Main.rand.Next(4, 8 + 1); i++) diff --git a/Projectiles/Summon/FrostBeam.cs b/Projectiles/Summon/FrostBeam.cs index 29f69f7504..295cf25546 100644 --- a/Projectiles/Summon/FrostBeam.cs +++ b/Projectiles/Summon/FrostBeam.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = 1; projectile.extraUpdates = 220; projectile.timeLeft = 200; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage /= 3; + projectile.damage /= 3; projectile.Damage(); int flowerPetalCount = Main.rand.Next(3, 5 + 1); float thetaDelta = projectile.velocity.ToRotation(); diff --git a/Projectiles/Summon/FrostBlossom.cs b/Projectiles/Summon/FrostBlossom.cs index 53a6441b6d..136db27df0 100644 --- a/Projectiles/Summon/FrostBlossom.cs +++ b/Projectiles/Summon/FrostBlossom.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; projectile.timeLeft *= 5; projectile.minion = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Summon/FrostMistFriendly.cs b/Projectiles/Summon/FrostMistFriendly.cs index 2742d3a92d..db615e5ab6 100644 --- a/Projectiles/Summon/FrostMistFriendly.cs +++ b/Projectiles/Summon/FrostMistFriendly.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = 1; projectile.timeLeft = 300; projectile.alpha = 255; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Summon/FungalClumpMinion.cs b/Projectiles/Summon/FungalClumpMinion.cs index 7243f9112a..bfbf6adda8 100644 --- a/Projectiles/Summon/FungalClumpMinion.cs +++ b/Projectiles/Summon/FungalClumpMinion.cs @@ -8,9 +8,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class FungalClumpMinion : ModProjectile + public class FungalClumpMinion : ModProjectile { - private bool returnToPlayer = false; + private bool returnToPlayer = false; public override void SetStaticDefaults() { @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Summon } } - //Initializing dust and damage + //Initializing dust and damage if (projectile.localAI[0] == 0f) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Summon projectile.localAI[0] += 1f; } - //Flexible damage correction + //Flexible damage correction if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / @@ -86,145 +86,145 @@ namespace CalamityMod.Projectiles.Summon projectile.damage = damage2; } - //Periodically create dust + //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 - projectile.MinionAntiClump(); + //Anti-sticky movement failsafe + projectile.MinionAntiClump(); - //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 = 1400f; - if (Math.Abs(projectile.Center.X - player.Center.X) + Math.Abs(projectile.Center.Y - player.Center.Y) > playerRange) - returnToPlayer = true; + //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 = 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 targetVec = projectile.Center; - float range = 900f; - bool npcFound = false; + //Find an npc to target, or if minion targetting is used, choose that npc + Vector2 targetVec = projectile.Center; + float range = 900f; + bool npcFound = false; Vector2 half = new Vector2(0.5f); - if (!returnToPlayer) - { - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - //Check the size of the target to make it easier to hit fat targets like Levi - Vector2 sizeCheck = npc.position + npc.Size * half; - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - //Some minions will ignore tiles when choosing a target like Ice Claspers, others will not - bool canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); - if (!npcFound && targetDist < range && canHit) - { - range = targetDist; - targetVec = sizeCheck; - npcFound = true; - } - } - } - //If no npc is specifically targetted, check through the entire array - if (!npcFound) - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - if (npc.CanBeChasedBy(projectile, false)) - { - Vector2 sizeCheck = npc.position + npc.Size * half; - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - bool canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); - if (!npcFound && targetDist < range && canHit) - { - range = targetDist; - targetVec = sizeCheck; - npcFound = true; - } - } - } - } - } + if (!returnToPlayer) + { + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + //Check the size of the target to make it easier to hit fat targets like Levi + Vector2 sizeCheck = npc.position + npc.Size * half; + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + //Some minions will ignore tiles when choosing a target like Ice Claspers, others will not + bool canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); + if (!npcFound && targetDist < range && canHit) + { + range = targetDist; + targetVec = sizeCheck; + npcFound = true; + } + } + } + //If no npc is specifically targetted, check through the entire array + if (!npcFound) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy(projectile, false)) + { + Vector2 sizeCheck = npc.position + npc.Size * half; + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + bool canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); + if (!npcFound && targetDist < range && canHit) + { + range = targetDist; + targetVec = sizeCheck; + npcFound = true; + } + } + } + } + } - //Tile collision depends on if returning to the player or not - projectile.tileCollide = !returnToPlayer; + //Tile collision depends on if returning to the player or not + projectile.tileCollide = !returnToPlayer; - if (!npcFound) - { - projectile.friendly = true; - float homingSpeed = 8f; - float turnSpeed = 20f; - if (returnToPlayer) //move faster if returning to the player - homingSpeed = 12f; - Vector2 playerVector = player.Center - projectile.Center; - playerVector.Y -= 60f; - float playerDist = playerVector.Length(); - if (playerDist < 100f && returnToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - returnToPlayer = false; - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - projectile.width / 2; - projectile.position.Y = player.Center.Y - projectile.width / 2; - } - //If more than 70 pixels away, move toward the player + if (!npcFound) + { + projectile.friendly = true; + float homingSpeed = 8f; + float turnSpeed = 20f; + if (returnToPlayer) //move faster if returning to the player + homingSpeed = 12f; + Vector2 playerVector = player.Center - projectile.Center; + playerVector.Y -= 60f; + float playerDist = playerVector.Length(); + if (playerDist < 100f && returnToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + returnToPlayer = false; + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - projectile.width / 2; + projectile.position.Y = player.Center.Y - projectile.width / 2; + } + //If more than 70 pixels away, move toward the player if (playerDist > 70f) { playerVector.Normalize(); playerVector *= homingSpeed; projectile.velocity = (projectile.velocity * turnSpeed + playerVector) / (turnSpeed + 1f); } - //Minions never stay still + //Minions never stay still else { - if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - projectile.velocity *= 1.01f; + 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 = 8f; - float turnSpeed = 14f; - float targetDist = projectile.Distance(targetVec); - if (targetDist < 100f) - minionSpeed = 10f; + 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 = 8f; + float turnSpeed = 14f; + float targetDist = projectile.Distance(targetVec); + if (targetDist < 100f) + minionSpeed = 10f; - Vector2 homingVelocity = projectile.SafeDirectionTo(targetVec) * minionSpeed; + Vector2 homingVelocity = projectile.SafeDirectionTo(targetVec) * minionSpeed; projectile.velocity = (projectile.velocity * turnSpeed + homingVelocity) / (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; - } - } + } + 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) { @@ -238,10 +238,10 @@ namespace CalamityMod.Projectiles.Summon if (Main.player[Main.myPlayer].lifeSteal <= 0f) return; - if (healAmt > CalamityMod.lifeStealCap) - healAmt = CalamityMod.lifeStealCap; + if (healAmt > CalamityMod.lifeStealCap) + healAmt = CalamityMod.lifeStealCap; - CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 3f); } public override bool OnTileCollide(Vector2 oldVelocity) => false; diff --git a/Projectiles/Summon/GammaHead.cs b/Projectiles/Summon/GammaHead.cs index 0574ead5ae..165ba7267f 100644 --- a/Projectiles/Summon/GammaHead.cs +++ b/Projectiles/Summon/GammaHead.cs @@ -12,7 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class GammaHead : ModProjectile + public class GammaHead : ModProjectile { public Vector2 CurrentPositionOffset; public Vector2 IdealPositionOffset; diff --git a/Projectiles/Summon/GastricBelcher.cs b/Projectiles/Summon/GastricBelcher.cs index 850829f92d..3a16a6977f 100644 --- a/Projectiles/Summon/GastricBelcher.cs +++ b/Projectiles/Summon/GastricBelcher.cs @@ -8,319 +8,319 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class GastricBelcher : ModProjectile - { - private bool initialized = false; - private int bubbleCounter = 0; + public class GastricBelcher : ModProjectile + { + private bool initialized = false; + private int bubbleCounter = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gastric Belcher"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.MinionSacrificable[projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gastric Belcher"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = 40; - projectile.height = 40; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.minionSlots = 1f; - projectile.timeLeft = 18000; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.timeLeft *= 5; - projectile.minion = true; - } + public override void SetDefaults() + { + projectile.width = 40; + projectile.height = 40; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 1f; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft *= 5; + projectile.minion = true; + } - public override void AI() - { - //Set namespaces - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - CalamityGlobalProjectile modProj = projectile.Calamity(); + public override void AI() + { + //Set namespaces + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + CalamityGlobalProjectile modProj = projectile.Calamity(); - //On spawn effects - if (!initialized) - { - //Set constants - modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); - modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage; - //Spawn dust - int dustAmt = 36; - for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) - { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 33, - 89 - }); - Vector2 direction = Vector2.Normalize(projectile.velocity) * new Vector2(projectile.width / 2f, projectile.height) * 0.75f; - direction = direction.RotatedBy((double)((dustIndex - (dustAmt / 2f - 1f)) * MathHelper.TwoPi / dustAmt), default) + projectile.Center; - Vector2 dustVel = direction - projectile.Center; - int water = Dust.NewDust(direction + dustVel, 0, 0, randomDust, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); - Main.dust[water].noGravity = true; - Main.dust[water].velocity = dustVel; - } - initialized = true; - } + //On spawn effects + if (!initialized) + { + //Set constants + modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); + modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage; + //Spawn dust + int dustAmt = 36; + for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) + { + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + 33, + 89 + }); + Vector2 direction = Vector2.Normalize(projectile.velocity) * new Vector2(projectile.width / 2f, projectile.height) * 0.75f; + direction = direction.RotatedBy((double)((dustIndex - (dustAmt / 2f - 1f)) * MathHelper.TwoPi / dustAmt), default) + projectile.Center; + Vector2 dustVel = direction - projectile.Center; + int water = Dust.NewDust(direction + dustVel, 0, 0, randomDust, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); + Main.dust[water].noGravity = true; + Main.dust[water].velocity = dustVel; + } + initialized = true; + } - //Flexible minion damage update - if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue) - { - int damage2 = (int)(modProj.spawnedPlayerMinionProjectileDamageValue / - modProj.spawnedPlayerMinionDamageValue * player.MinionDamage()); - projectile.damage = damage2; - } + //Flexible minion damage update + if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue) + { + int damage2 = (int)(modProj.spawnedPlayerMinionProjectileDamageValue / + modProj.spawnedPlayerMinionDamageValue * player.MinionDamage()); + projectile.damage = damage2; + } - //Update frames - if (projectile.frameCounter++ % 6 == 0) - { - projectile.frame++; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } + //Update frames + if (projectile.frameCounter++ % 6 == 0) + { + projectile.frame++; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } - //Set up buff and timeLeft - bool typeCheck = projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (typeCheck) - { - if (player.dead) - { - modPlayer.gastricBelcher = false; - } - if (modPlayer.gastricBelcher) - { - projectile.timeLeft = 2; - } - } + //Set up buff and timeLeft + bool typeCheck = projectile.type == ModContent.ProjectileType(); + player.AddBuff(ModContent.BuffType(), 3600); + if (typeCheck) + { + if (player.dead) + { + modPlayer.gastricBelcher = false; + } + if (modPlayer.gastricBelcher) + { + projectile.timeLeft = 2; + } + } - //Anti sticky movement to prevent overlapping minions - projectile.MinionAntiClump(); + //Anti sticky movement to prevent overlapping minions + projectile.MinionAntiClump(); - //Find a target - float maxDistance = 700f; - Vector2 targetVec = projectile.position; - bool foundTarget = false; - //If targeting something, prioritize that enemy - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - bool canHit = true; - if (extraDist < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) - { - maxDistance = targetDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - if (!foundTarget) - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - bool canHit = true; - if (extraDist < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) - { - maxDistance = targetDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - } + //Find a target + float maxDistance = 700f; + Vector2 targetVec = projectile.position; + bool foundTarget = false; + //If targeting something, prioritize that enemy + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + bool canHit = true; + if (extraDist < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) + { + maxDistance = targetDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + if (!foundTarget) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + bool canHit = true; + if (extraDist < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + if (!foundTarget && targetDist < (maxDistance + extraDist) && canHit) + { + maxDistance = targetDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + } - //If too far, make the minion start returning to the player. - float returnDist = 1000f; - if (foundTarget) - { - //Max travel distance increases if targeting something - returnDist = 2200f; - } - if (Vector2.Distance(player.Center, projectile.Center) > returnDist) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } - - //If a target is found, move toward it - if (foundTarget && projectile.ai[0] == 0f) - { - Vector2 vecToTarget = targetVec - projectile.Center; - float targetDist = vecToTarget.Length(); - vecToTarget.Normalize(); - //If farther than 200 pixels, move toward it - if (targetDist > 200f) - { - float speedMult = (targetDist > 400f) ? 12f : (targetDist > 250) ? 6f : 3f; - vecToTarget *= speedMult; - projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; - } - //Otherwise, back it up slowly - else - { - float speedMult = -3f; - vecToTarget *= speedMult; - projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; - } - } - - //If not targeting something, act passively - else - { - bool returningToPlayer = false; - if (!returningToPlayer) - { - returningToPlayer = projectile.ai[0] == 1f; - } - //Move faster if actively returning to the player - float speedMult = 10f; - if (returningToPlayer) - { - speedMult = 21f; - } - Vector2 vecToPlayer = player.Center - projectile.Center + new Vector2(0f, -60f); - float playerDist = vecToPlayer.Length(); - //Slow down if near the player - if (playerDist < 200f && speedMult > 8f) - { - speedMult = 1f; - } - //If close enough to the player, return to normal - if (playerDist < 150f && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - //If abnormally far, teleport to the player - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - (projectile.width / 2f); - projectile.position.Y = player.Center.Y - (projectile.height / 2f); - projectile.netUpdate = true; - } - //Move toward player if more than 70 pixels away - if (playerDist > 70f) - { - vecToPlayer.Normalize(); - vecToPlayer *= speedMult; - projectile.velocity = (projectile.velocity * 40f + vecToPlayer) / 41f; - } - //Move if still - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - } - - //Update sprite direction and rotation + //If too far, make the minion start returning to the player. + float returnDist = 1000f; if (foundTarget) { - projectile.spriteDirection = projectile.direction = ((targetVec.X - projectile.Center.X) > 0).ToDirectionInt(); + //Max travel distance increases if targeting something + returnDist = 2200f; + } + if (Vector2.Distance(player.Center, projectile.Center) > returnDist) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } + + //If a target is found, move toward it + if (foundTarget && projectile.ai[0] == 0f) + { + Vector2 vecToTarget = targetVec - projectile.Center; + float targetDist = vecToTarget.Length(); + vecToTarget.Normalize(); + //If farther than 200 pixels, move toward it + if (targetDist > 200f) + { + float speedMult = (targetDist > 400f) ? 12f : (targetDist > 250) ? 6f : 3f; + vecToTarget *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; + } + //Otherwise, back it up slowly + else + { + float speedMult = -3f; + vecToTarget *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; + } + } + + //If not targeting something, act passively + else + { + bool returningToPlayer = false; + if (!returningToPlayer) + { + returningToPlayer = projectile.ai[0] == 1f; + } + //Move faster if actively returning to the player + float speedMult = 10f; + if (returningToPlayer) + { + speedMult = 21f; + } + Vector2 vecToPlayer = player.Center - projectile.Center + new Vector2(0f, -60f); + float playerDist = vecToPlayer.Length(); + //Slow down if near the player + if (playerDist < 200f && speedMult > 8f) + { + speedMult = 1f; + } + //If close enough to the player, return to normal + if (playerDist < 150f && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + //If abnormally far, teleport to the player + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - (projectile.width / 2f); + projectile.position.Y = player.Center.Y - (projectile.height / 2f); + projectile.netUpdate = true; + } + //Move toward player if more than 70 pixels away + if (playerDist > 70f) + { + vecToPlayer.Normalize(); + vecToPlayer *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToPlayer) / 41f; + } + //Move if still + else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.15f; + projectile.velocity.Y = -0.05f; + } + } + + //Update sprite direction and rotation + if (foundTarget) + { + projectile.spriteDirection = projectile.direction = ((targetVec.X - projectile.Center.X) > 0).ToDirectionInt(); projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi), 0.1f); } - else - { - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - } + else + { + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); + } - //Increment attack cooldown - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += Main.rand.Next(1, 4); - } - //Set the minion to be ready for attack - if (projectile.ai[1] > 90f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } + //Increment attack cooldown + if (projectile.ai[1] > 0f) + { + projectile.ai[1] += Main.rand.Next(1, 4); + } + //Set the minion to be ready for attack + if (projectile.ai[1] > 90f) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } - //Return if on attack cooldown, has no target, or returning to the player - if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f) - return; + //Return if on attack cooldown, has no target, or returning to the player + if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f) + return; - if (Main.myPlayer == projectile.owner) - { - //Play vomit sound - if (modPlayer.soundCooldown <= 0) - { - Main.PlaySound(SoundID.NPCKilled, (int)projectile.Center.X, (int)projectile.Center.Y, 13, 0.5f, 0f); - modPlayer.soundCooldown = Main.rand.Next(120, 180); - } + if (Main.myPlayer == projectile.owner) + { + //Play vomit sound + if (modPlayer.soundCooldown <= 0) + { + Main.PlaySound(SoundID.NPCKilled, (int)projectile.Center.X, (int)projectile.Center.Y, 13, 0.5f, 0f); + modPlayer.soundCooldown = Main.rand.Next(120, 180); + } - //Increment the attack counter - projectile.ai[1]++; + //Increment the attack counter + projectile.ai[1]++; - int projType = ModContent.ProjectileType(); + int projType = ModContent.ProjectileType(); - //Calculate the general velocity - Vector2 velocity = targetVec - projectile.Center; - velocity.Normalize(); + //Calculate the general velocity + Vector2 velocity = targetVec - projectile.Center; + velocity.Normalize(); - //Add some inaccuracy for the vomit projectiles - float vomitSpeedMult = 16f; - Vector2 vomitVel = velocity * vomitSpeedMult; - vomitVel.Y += Main.rand.NextFloat(-30f, 30f) * 0.05f; - vomitVel.X += Main.rand.NextFloat(-30f, 30f) * 0.05f; + //Add some inaccuracy for the vomit projectiles + float vomitSpeedMult = 16f; + Vector2 vomitVel = velocity * vomitSpeedMult; + vomitVel.Y += Main.rand.NextFloat(-30f, 30f) * 0.05f; + vomitVel.X += Main.rand.NextFloat(-30f, 30f) * 0.05f; - //Fire the vomit projectile - Projectile.NewProjectile(projectile.Center, vomitVel, projType, projectile.damage, projectile.knockBack, projectile.owner, Main.rand.Next(3), 0f); + //Fire the vomit projectile + Projectile.NewProjectile(projectile.Center, vomitVel, projType, projectile.damage, projectile.knockBack, projectile.owner, Main.rand.Next(3), 0f); - //Fire 5 bubbles for every three attacks - if (bubbleCounter++ % 3 == 2) - { - for (int projCount = 0; projCount < 5; projCount++) - { - //Add a shotgun spread to the bubbles - float bubbleSpeedMult = 14f; - Vector2 bubbleVel = velocity * bubbleSpeedMult; - bubbleVel.Y += Main.rand.NextFloat(-50f, 50f) * 0.05f; - bubbleVel.X += Main.rand.NextFloat(-50f, 50f) * 0.05f; + //Fire 5 bubbles for every three attacks + if (bubbleCounter++ % 3 == 2) + { + for (int projCount = 0; projCount < 5; projCount++) + { + //Add a shotgun spread to the bubbles + float bubbleSpeedMult = 14f; + Vector2 bubbleVel = velocity * bubbleSpeedMult; + bubbleVel.Y += Main.rand.NextFloat(-50f, 50f) * 0.05f; + bubbleVel.X += Main.rand.NextFloat(-50f, 50f) * 0.05f; - Projectile.NewProjectile(projectile.Center, bubbleVel, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - } - } + Projectile.NewProjectile(projectile.Center, bubbleVel, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + } + } - projectile.netUpdate = true; - } - } + projectile.netUpdate = true; + } + } - //This minion does no contact damage - public override bool CanDamage() => false; + //This minion does no contact damage + public override bool CanDamage() => false; public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D texture = Main.projectileTexture[projectile.type]; - int frameHeight = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; - int y6 = frameHeight * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + Texture2D texture = Main.projectileTexture[projectile.type]; + int frameHeight = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int y6 = frameHeight * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + 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(texture.Width / 2f, 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/GastricBelcherBubble.cs b/Projectiles/Summon/GastricBelcherBubble.cs index 6e3b29ba4c..cd61259846 100644 --- a/Projectiles/Summon/GastricBelcherBubble.cs +++ b/Projectiles/Summon/GastricBelcherBubble.cs @@ -4,40 +4,40 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class GastricBelcherBubble : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gastric Bubble"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - } + public class GastricBelcherBubble : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gastric Bubble"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.friendly = true; - projectile.width = projectile.height = 18; - projectile.minion = true; - projectile.timeLeft = 180; - projectile.aiStyle = 72; - } + public override void SetDefaults() + { + projectile.friendly = true; + projectile.width = projectile.height = 18; + projectile.minion = true; + projectile.timeLeft = 180; + projectile.aiStyle = 72; + } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item54, projectile.position); - Vector2 center = projectile.Center; - for (int dustIndex = 0; dustIndex < 10; ++dustIndex) - { - int scalar = (int)(10 * projectile.ai[1]); - int bubble = Dust.NewDust(projectile.Center - Vector2.One * scalar, scalar * 2, scalar * 2, 212, 0.0f, 0.0f, 0, new Color(), 1f); - Dust dust = Main.dust[bubble]; - Vector2 dustVec = Vector2.Normalize(dust.position - projectile.Center); - dust.position = projectile.Center + dustVec * scalar * projectile.scale; - dust.velocity = dustIndex >= 30 ? dustVec * Main.rand.Next(45, 91) / 10f : dustVec * dust.velocity.Length(); - dust.color = Main.hslToRgb(0.4f + Main.rand.NextFloat() * 0.2f, 0.9f, 0.5f); - dust.color = Color.Lerp(dust.color, Color.White, 0.3f); - dust.noGravity = true; - dust.scale = 0.7f; - } - } - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item54, projectile.position); + Vector2 center = projectile.Center; + for (int dustIndex = 0; dustIndex < 10; ++dustIndex) + { + int scalar = (int)(10 * projectile.ai[1]); + int bubble = Dust.NewDust(projectile.Center - Vector2.One * scalar, scalar * 2, scalar * 2, 212, 0.0f, 0.0f, 0, new Color(), 1f); + Dust dust = Main.dust[bubble]; + Vector2 dustVec = Vector2.Normalize(dust.position - projectile.Center); + dust.position = projectile.Center + dustVec * scalar * projectile.scale; + dust.velocity = dustIndex >= 30 ? dustVec * Main.rand.Next(45, 91) / 10f : dustVec * dust.velocity.Length(); + dust.color = Main.hslToRgb(0.4f + Main.rand.NextFloat() * 0.2f, 0.9f, 0.5f); + dust.color = Color.Lerp(dust.color, Color.White, 0.3f); + dust.noGravity = true; + dust.scale = 0.7f; + } + } + } } diff --git a/Projectiles/Summon/GastricBelcherVomit.cs b/Projectiles/Summon/GastricBelcherVomit.cs index b83a6033c4..d1d414ab32 100644 --- a/Projectiles/Summon/GastricBelcherVomit.cs +++ b/Projectiles/Summon/GastricBelcherVomit.cs @@ -5,62 +5,62 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class GastricBelcherVomit : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gastric Vomit"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - } + public class GastricBelcherVomit : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gastric Vomit"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.friendly = true; - projectile.width = projectile.height = 18; - projectile.minion = true; - projectile.timeLeft = 300; - projectile.penetrate = 3; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 10; - } + public override void SetDefaults() + { + projectile.friendly = true; + projectile.width = projectile.height = 18; + projectile.minion = true; + projectile.timeLeft = 300; + projectile.penetrate = 3; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 10; + } - public override void AI() - { - //Rotation and gravity - projectile.rotation += 0.6f * projectile.direction; - projectile.velocity.Y += 0.27f; - if (projectile.velocity.Y > 16f) - { - projectile.velocity.Y = 16f; - } - } + public override void AI() + { + //Rotation and gravity + projectile.rotation += 0.6f * projectile.direction; + projectile.velocity.Y += 0.27f; + if (projectile.velocity.Y > 16f) + { + projectile.velocity.Y = 16f; + } + } - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Dig, (int)projectile.position.X, (int)projectile.position.Y); - //Dust effect - int splash = 0; - while (splash < 4) - { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 233, -projectile.velocity.X * 0.15f, -projectile.velocity.Y * 0.10f, 150, default, 0.9f); - splash += 1; - } - } + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Dig, (int)projectile.position.X, (int)projectile.position.Y); + //Dust effect + int splash = 0; + while (splash < 4) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 233, -projectile.velocity.X * 0.15f, -projectile.velocity.Y * 0.10f, 150, default, 0.9f); + splash += 1; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture; - switch (projectile.ai[0]) - { - case 1f: texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/GastricBelcherVomit2"); - break; - case 2f: texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/GastricBelcherVomit3"); - break; - default: texture = Main.projectileTexture[projectile.type]; - break; - } - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, texture.Height / 2f), projectile.scale, SpriteEffects.None, 0f); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture; + switch (projectile.ai[0]) + { + case 1f: texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/GastricBelcherVomit2"); + break; + case 2f: texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/GastricBelcherVomit3"); + break; + default: texture = Main.projectileTexture[projectile.type]; + break; + } + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, texture.Height / 2f), projectile.scale, SpriteEffects.None, 0f); + return false; + } + } } diff --git a/Projectiles/Summon/GhostlyMine.cs b/Projectiles/Summon/GhostlyMine.cs index 1a4ab6437e..7305f3e90d 100644 --- a/Projectiles/Summon/GhostlyMine.cs +++ b/Projectiles/Summon/GhostlyMine.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (start) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); diff --git a/Projectiles/Summon/GiantIbanRobotOfDoom.cs b/Projectiles/Summon/GiantIbanRobotOfDoom.cs index 01b23712c0..15730810f1 100644 --- a/Projectiles/Summon/GiantIbanRobotOfDoom.cs +++ b/Projectiles/Summon/GiantIbanRobotOfDoom.cs @@ -10,7 +10,7 @@ using System; namespace CalamityMod.Projectiles.Summon { - public class AndromedaHead : EquipTexture + public class AndromedaHead : EquipTexture { public override bool DrawHead() => false; } diff --git a/Projectiles/Summon/HallowedStarSummon.cs b/Projectiles/Summon/HallowedStarSummon.cs index 325b33ddb3..c4a78e6523 100644 --- a/Projectiles/Summon/HallowedStarSummon.cs +++ b/Projectiles/Summon/HallowedStarSummon.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Summon projectile.width = 24; projectile.height = 24; projectile.friendly = true; - projectile.minion = true; - projectile.minionSlots = 0f; + projectile.minion = true; + projectile.minionSlots = 0f; projectile.alpha = 50; projectile.penetrate = 1; projectile.tileCollide = false; diff --git a/Projectiles/Summon/HauntedDishes.cs b/Projectiles/Summon/HauntedDishes.cs index b1608eb3f9..518a44adea 100644 --- a/Projectiles/Summon/HauntedDishes.cs +++ b/Projectiles/Summon/HauntedDishes.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class HauntedDishes : ModProjectile + public class HauntedDishes : ModProjectile { public float dust = 0f; @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - CalamityGlobalProjectile modProj = projectile.Calamity(); + CalamityGlobalProjectile modProj = projectile.Calamity(); if (dust == 0f) { modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -76,508 +76,508 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - bool flag1 = false; - bool flag2 = false; - bool flag3 = false; - bool flag4 = false; - int num1 = 60 + 30 * projectile.minionPos; - if (projectile.lavaWet) - { - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - } - int num2 = 10; - int num3 = 40 * (projectile.minionPos + 1) * player.direction; - if (player.position.X + (float) (player.width / 2) < projectile.position.X + (float) (projectile.width / 2) - (float) num2 + (float) num3) - flag1 = true; - else if (player.position.X + (float) (player.width / 2) > projectile.position.X + (float) (projectile.width / 2) + (float) num2 + (float) num3) - flag2 = true; + bool flag1 = false; + bool flag2 = false; + bool flag3 = false; + bool flag4 = false; + int num1 = 60 + 30 * projectile.minionPos; + if (projectile.lavaWet) + { + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + } + int num2 = 10; + int num3 = 40 * (projectile.minionPos + 1) * player.direction; + if (player.position.X + (float) (player.width / 2) < projectile.position.X + (float) (projectile.width / 2) - (float) num2 + (float) num3) + flag1 = true; + else if (player.position.X + (float) (player.width / 2) > projectile.position.X + (float) (projectile.width / 2) + (float) num2 + (float) num3) + flag2 = true; - if (projectile.ai[1] == 0f) - { - int conflict1 = 500; - conflict1 += 40 * projectile.minionPos; - if (projectile.localAI[0] > 0f) - conflict1 += 500; - Vector2 vector2 = new Vector2(projectile.position.X + (float) projectile.width * 0.5f, projectile.position.Y + (float) projectile.height * 0.5f); - float playerX = player.position.X + (float) (player.width / 2) - vector2.X; - float playerY = player.position.Y + (float) (player.height / 2) - vector2.Y; - float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); - if (playerDist > 1500f) - { - projectile.ai[0] = 1f; - } - if (playerDist > 2000f) //teleport to player if too far - { - projectile.position.X = player.position.X + (float) (player.width / 2) - (float) (projectile.width / 2); - projectile.position.Y = player.position.Y + (float) (player.height / 2) - (float) (projectile.height / 2); - } - } - if (projectile.ai[0] != 0f) //flying back to the player - { - projectile.tileCollide = false; - float npcDetectRange = 1200f; - bool npcFound = false; - int num6 = -1; - for (int index = 0; index < Main.maxNPCs; ++index) - { - NPC npc2 = Main.npc[index]; - if (npc2.CanBeChasedBy((object) projectile, false)) - { - float npcX = npc2.position.X + (float) (npc2.width / 2); - float npcY = npc2.position.Y + (float) (npc2.height / 2); - float npcDist = (float) Math.Abs(player.position.X + (float) (player.width / 2) - npcX) + (float) Math.Abs(player.position.Y + (float) (player.height / 2) - npcY); - if (npcDist < npcDetectRange) - { - if (Collision.CanHit(projectile.position, projectile.width, projectile.height, npc2.position, npc2.width, npc2.height)) - num6 = index; - npcFound = true; - break; - } - } - } + if (projectile.ai[1] == 0f) + { + int conflict1 = 500; + conflict1 += 40 * projectile.minionPos; + if (projectile.localAI[0] > 0f) + conflict1 += 500; + Vector2 vector2 = new Vector2(projectile.position.X + (float) projectile.width * 0.5f, projectile.position.Y + (float) projectile.height * 0.5f); + float playerX = player.position.X + (float) (player.width / 2) - vector2.X; + float playerY = player.position.Y + (float) (player.height / 2) - vector2.Y; + float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); + if (playerDist > 1500f) + { + projectile.ai[0] = 1f; + } + if (playerDist > 2000f) //teleport to player if too far + { + projectile.position.X = player.position.X + (float) (player.width / 2) - (float) (projectile.width / 2); + projectile.position.Y = player.position.Y + (float) (player.height / 2) - (float) (projectile.height / 2); + } + } + if (projectile.ai[0] != 0f) //flying back to the player + { + projectile.tileCollide = false; + float npcDetectRange = 1200f; + bool npcFound = false; + int num6 = -1; + for (int index = 0; index < Main.maxNPCs; ++index) + { + NPC npc2 = Main.npc[index]; + if (npc2.CanBeChasedBy((object) projectile, false)) + { + float npcX = npc2.position.X + (float) (npc2.width / 2); + float npcY = npc2.position.Y + (float) (npc2.height / 2); + float npcDist = (float) Math.Abs(player.position.X + (float) (player.width / 2) - npcX) + (float) Math.Abs(player.position.Y + (float) (player.height / 2) - npcY); + if (npcDist < npcDetectRange) + { + if (Collision.CanHit(projectile.position, projectile.width, projectile.height, npc2.position, npc2.width, npc2.height)) + num6 = index; + npcFound = true; + break; + } + } + } - //return to normal if npc found - if (npcFound && num6 >= 0) - projectile.ai[0] = 0f; + //return to normal if npc found + if (npcFound && num6 >= 0) + projectile.ai[0] = 0f; - Vector2 vector2 = 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) - vector2.X; - xDist -= (float) (40 * player.direction); - if (!npcFound) - xDist -= (float) (40 * projectile.minionPos * player.direction); - float yDist = player.position.Y + (float) (player.height / 2) - vector2.Y; - yDist -= 60f; - float playerDist2 = (float) Math.Sqrt(xDist * xDist + yDist * yDist); - float num11 = 12f; - float num12 = playerDist2; - float conflict2 = 0.4f; - if (num11 < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - num11 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + Vector2 vector2 = 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) - vector2.X; + xDist -= (float) (40 * player.direction); + if (!npcFound) + xDist -= (float) (40 * projectile.minionPos * player.direction); + float yDist = player.position.Y + (float) (player.height / 2) - vector2.Y; + yDist -= 60f; + float playerDist2 = (float) Math.Sqrt(xDist * xDist + yDist * yDist); + float num11 = 12f; + float num12 = playerDist2; + float conflict2 = 0.4f; + if (num11 < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + num11 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - //if close enough to the player and has tile to stand on, return to normal - if (playerDist2 < 100f && player.velocity.Y == 0f && (projectile.position.Y + (float) projectile.height <= player.position.Y + (float) player.height && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))) - { - projectile.ai[0] = 0f; - if (projectile.velocity.Y < -6f) - projectile.velocity.Y = -6f; - } - if (playerDist2 > 2000f) - { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - if (playerDist2 < 50f) - { - if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) - { - projectile.velocity *= 0.99f; - } - conflict2 = 0.01f; - } - else - { - if (playerDist2 < 100f) - { - conflict2 = 0.1f; - } - if (playerDist2 > 300f) - { - conflict2 = 1f; - } - playerDist2 = num12 / playerDist2; - xDist *= playerDist2; - yDist *= playerDist2; - } - if (projectile.velocity.X < xDist) - { - projectile.velocity.X = projectile.velocity.X + conflict2; - if (conflict2 > 0.05f && projectile.velocity.X < 0f) - { - projectile.velocity.X = projectile.velocity.X + conflict2; - } - } - if (projectile.velocity.X > xDist) - { - projectile.velocity.X = projectile.velocity.X - conflict2; - if (conflict2 > 0.05f && projectile.velocity.X > 0f) - { - projectile.velocity.X = projectile.velocity.X - conflict2; - } - } - if (projectile.velocity.Y < yDist) - { - projectile.velocity.Y = projectile.velocity.Y + conflict2; - if (conflict2> 0.05f && projectile.velocity.Y < 0f) - { - projectile.velocity.Y = projectile.velocity.Y + conflict2 * 2f; - } - } - if (projectile.velocity.Y > yDist) - { - projectile.velocity.Y = projectile.velocity.Y - conflict2; - if (conflict2 > 0.05f && projectile.velocity.Y > 0f) - { - projectile.velocity.Y = projectile.velocity.Y - conflict2 * 2f; - } - } - if (projectile.frame < 15) - { - projectile.frame = 15; - } - else - { - projectile.frameCounter++; - if (projectile.frameCounter > 3) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= 19) - { - projectile.frame = 15; - } - } - 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 - { - float conflict3 = (float) (40 * projectile.minionPos); - float attackCooldown = 30f; - int num4 = 60; - --projectile.localAI[0]; - if (projectile.localAI[0] < 0f) - projectile.localAI[0] = 0f; - if (projectile.ai[1] > 0f) - { - --projectile.ai[1]; - } - else - { - float num5 = projectile.position.X; - float num6 = projectile.position.Y; - float num7 = 100000f; - float num8 = num7; - int num9 = -1; - NPC minionAttackTargetNpc = projectile.OwnerMinionAttackTargetNPC; - if (minionAttackTargetNpc != null && minionAttackTargetNpc.CanBeChasedBy((object) projectile, false)) - { - float num10 = minionAttackTargetNpc.position.X + (float) (minionAttackTargetNpc.width / 2); - float num11 = minionAttackTargetNpc.position.Y + (float) (minionAttackTargetNpc.height / 2); - float num12 = Math.Abs(projectile.position.X + (float) (projectile.width / 2) - num10) + Math.Abs(projectile.position.Y + (float) (projectile.height / 2) - num11); - if (num12 < num7) - { - if (num9 == -1 && num12 <= num8) - { - num8 = num12; - num5 = num10; - num6 = num11; - } - if (Collision.CanHit(projectile.position, projectile.width, projectile.height, minionAttackTargetNpc.position, minionAttackTargetNpc.width, minionAttackTargetNpc.height)) - { - num7 = num12; - num5 = num10; - num6 = num11; - num9 = minionAttackTargetNpc.whoAmI; - } - } - } - if (num9 == -1) - { - for (int index = 0; index < Main.maxNPCs; ++index) - { - if (Main.npc[index].CanBeChasedBy((object) projectile, false)) - { - float num10 = Main.npc[index].position.X + (float) (Main.npc[index].width / 2); - float num11 = Main.npc[index].position.Y + (float) (Main.npc[index].height / 2); - float num12 = Math.Abs(projectile.position.X + (float) (projectile.width / 2) - num10) + Math.Abs(projectile.position.Y + (float) (projectile.height / 2) - num11); - if (num12 < num7) - { - if (num9 == -1 && num12 <= num8) - { - num8 = num12; - num5 = num10; - num6 = num11; - } - if (Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height)) - { - num7 = num12; - num5 = num10; - num6 = num11; - num9 = index; - } - } - } - } - } - if (num9 == -1 && num8 < num7) - num7 = num8; - float num13 = 400f; - if ((double) projectile.position.Y > Main.worldSurface * 16.0) - num13 = 200f; - if (num7 < num13 + conflict3 && num9 == -1) - { - float num10 = num5 - (projectile.position.X + (float) (projectile.width / 2)); - if (num10 < -5f) - { - flag1 = true; - flag2 = false; - } - else if (num10 > 5f) - { - flag2 = true; - flag1 = false; - } - } - else if (num9 >= 0 && num7 < 800f + conflict3) - { - projectile.localAI[0] = (float) num4; - float num10 = num5 - (projectile.position.X + (float) (projectile.width / 2)); - if (num10 > 300f || num10 < -300f) - { - if (num10 < -50f) - { - flag1 = true; - flag2 = false; - } - else if (num10 > 50f) - { - flag2 = true; - flag1 = false; - } - } - else if (projectile.owner == Main.myPlayer) - { - projectile.ai[1] = attackCooldown; - double num11 = 12.0; - Vector2 vector2 = new Vector2(projectile.Center.X, projectile.Center.Y - 8f); - float num12 = num5 - vector2.X + Main.rand.NextFloat(-6f, 6f); - float num14 = (float) ((double) (Math.Abs(num12) * 0.1f) * (double) Main.rand.Next(0, 100) * (1.0 / 1000.0)); - float num15 = num6 - vector2.Y + Main.rand.NextFloat(-6f, 6f) - num14; - double num16 = Math.Sqrt((double) num12 * (double) num12 + (double) num15 * (double) num15); - float num17 = (float) (num11 / num16); - float SpeedX = num12 * num17; - float SpeedY = num15 * num17; - int damage = projectile.damage; - int Type = ModContent.ProjectileType(); - int index = Projectile.NewProjectile(vector2.X, vector2.Y, SpeedX * 2f, SpeedY * 2f, Type, damage, projectile.knockBack, projectile.owner, 0f, 0f); - if (SpeedX < 0f) - projectile.direction = -1; - if (SpeedX > 0f) - projectile.direction = 1; - projectile.netUpdate = true; - } - } - } - Vector2 vector2_1 = Vector2.Zero; - bool flag7 = false; - if (projectile.ai[1] != 0f) - { - flag1 = false; - flag2 = false; - } - else if (projectile.localAI[0] == 0f) - projectile.direction = player.direction; - if (!flag7) - projectile.rotation = 0f; - projectile.tileCollide = true; - float num18 = 0.08f; - float num19 = 6.5f; - num19 = 6f; - num18 = 0.2f; - if (num19 < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - { - num19 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - num18 = 0.3f; - } - if (flag1) - { - if (projectile.velocity.X > -3.5f) - projectile.velocity.X -= num18; - else - projectile.velocity.X -= num18 * 0.25f; - } - else if (flag2) - { - if (projectile.velocity.X < 3.5f) - projectile.velocity.X += num18; - else - projectile.velocity.X += num18 * 0.25f; - } - else - { - projectile.velocity.X *= 0.9f; - if (projectile.velocity.X >= -num18 && projectile.velocity.X <= num18) - projectile.velocity.X = 0f; - } - if (flag1 | flag2) - { - int conflict4 = (int) ((double) projectile.position.X + (double) (projectile.width / 2)) / 16; - int j = (int) ((double) projectile.position.Y + (double) (projectile.height / 2)) / 16; - if (flag1) - --conflict4; - if (flag2) - ++conflict4; - if (WorldGen.SolidTile(conflict4 + (int) projectile.velocity.X, j)) - flag4 = true; - } - if (player.position.Y + player.height - 8f > projectile.position.Y + projectile.height) - flag3 = true; - Collision.StepUp(ref projectile.position, ref projectile.velocity, projectile.width, projectile.height, ref projectile.stepSpeed, ref projectile.gfxOffY, 1, false, 0); - if (projectile.velocity.Y == 0f) - { - if (!flag3 && ((double) projectile.velocity.X < 0.0 || (double) projectile.velocity.X > 0.0)) - { - int i = (int) ((double) projectile.position.X + (double) (projectile.width / 2)) / 16; - int j = (int) ((double) projectile.position.Y + (double) (projectile.height / 2)) / 16 + 1; - if (flag1) - --i; - if (flag2) - ++i; - WorldGen.SolidTile(i, j); - } - if (flag4) - { - int i1 = (int) ((double) projectile.position.X + (double) (projectile.width / 2)) / 16; - int j = (int) ((double) projectile.position.Y + (double) projectile.height) / 16 + 1; - if (WorldGen.SolidTile(i1, j) || Main.tile[i1, j].halfBrick() || ((int) Main.tile[i1, j].slope() > 0 || projectile.type == 200)) - { - if (projectile.type == 200) - { - projectile.velocity.Y = -3.1f; - } - else - { - try - { - int conflict5 = (int) ((double) projectile.position.X + (double) (projectile.width / 2)) / 16; - int conflict7 = (int) ((double) projectile.position.Y + (double) (projectile.height / 2)) / 16; - if (flag1) - --conflict5; - if (flag2) - ++conflict5; - int i2 = conflict5 + (int) projectile.velocity.X; - if (!WorldGen.SolidTile(i2, conflict7 - 1) && !WorldGen.SolidTile(i2, conflict7 - 2)) - projectile.velocity.Y = -5.1f; - else if (!WorldGen.SolidTile(i2, conflict7 - 2)) - projectile.velocity.Y = -7.1f; - else if (WorldGen.SolidTile(i2, conflict7 - 5)) - projectile.velocity.Y = -11.1f; - else if (WorldGen.SolidTile(i2, conflict7 - 4)) - projectile.velocity.Y = -10.1f; - else - projectile.velocity.Y = -9.1f; - } - catch - { - projectile.velocity.Y = -9.1f; - } - } - } - } - else if (projectile.type == 266 && flag1 | flag2) - projectile.velocity.Y -= 6f; - } - if (projectile.velocity.X > num19) - projectile.velocity.X = num19; - if (projectile.velocity.X < -num19) - projectile.velocity.X = -num19; - if (projectile.velocity.X < 0f) - projectile.direction = -1; - if (projectile.velocity.X > 0f) - projectile.direction = 1; - if (projectile.velocity.X > num18 & flag2) - projectile.direction = 1; - if (projectile.velocity.X < -num18 & flag1) - projectile.direction = -1; - if (projectile.direction == -1) - projectile.spriteDirection = -1; - if (projectile.direction == 1) - projectile.spriteDirection = 1; - if (projectile.ai[1] > 0f) - { - if (projectile.localAI[1] == 0f) - { - projectile.localAI[1] = 1f; - projectile.frame = 9; - } - if (projectile.frame >= 9 && projectile.frame <= 14) - { - projectile.frameCounter++; - if (projectile.frameCounter > 8) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame == 14) - projectile.frame = 9; - } - } - else if (projectile.velocity.Y == 0f) - { - projectile.localAI[1] = 0f; - if (projectile.velocity.X == 0f) - { - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= 3) - { - projectile.frame = 0; - } - } - else if (projectile.velocity.X < -0.8f || projectile.velocity.X > 0.8f) - { - projectile.frameCounter = projectile.frameCounter + (int) Math.Abs(projectile.velocity.X); - projectile.frameCounter++; - if (projectile.frameCounter > 20) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame < 4) - projectile.frame = 3; - if (projectile.frame >= 9) - projectile.frame = 3; - } - else - { - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= 3) - { - projectile.frame = 0; - } - } - } - else if (projectile.velocity.Y < 0f) - { - projectile.frameCounter = 0; - projectile.frame = 3; - } - else if (projectile.velocity.Y > 0f) - { - projectile.frameCounter = 0; - projectile.frame = 3; - } - projectile.velocity.Y += 0.4f; - if (projectile.velocity.Y > 10f) - projectile.velocity.Y = 10f; - Vector2 velocity = projectile.velocity; - } - } + //if close enough to the player and has tile to stand on, return to normal + if (playerDist2 < 100f && player.velocity.Y == 0f && (projectile.position.Y + (float) projectile.height <= player.position.Y + (float) player.height && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))) + { + projectile.ai[0] = 0f; + if (projectile.velocity.Y < -6f) + projectile.velocity.Y = -6f; + } + if (playerDist2 > 2000f) + { + projectile.position.X = player.Center.X - (float)(projectile.width / 2); + projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + if (playerDist2 < 50f) + { + if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) + { + projectile.velocity *= 0.99f; + } + conflict2 = 0.01f; + } + else + { + if (playerDist2 < 100f) + { + conflict2 = 0.1f; + } + if (playerDist2 > 300f) + { + conflict2 = 1f; + } + playerDist2 = num12 / playerDist2; + xDist *= playerDist2; + yDist *= playerDist2; + } + if (projectile.velocity.X < xDist) + { + projectile.velocity.X = projectile.velocity.X + conflict2; + if (conflict2 > 0.05f && projectile.velocity.X < 0f) + { + projectile.velocity.X = projectile.velocity.X + conflict2; + } + } + if (projectile.velocity.X > xDist) + { + projectile.velocity.X = projectile.velocity.X - conflict2; + if (conflict2 > 0.05f && projectile.velocity.X > 0f) + { + projectile.velocity.X = projectile.velocity.X - conflict2; + } + } + if (projectile.velocity.Y < yDist) + { + projectile.velocity.Y = projectile.velocity.Y + conflict2; + if (conflict2> 0.05f && projectile.velocity.Y < 0f) + { + projectile.velocity.Y = projectile.velocity.Y + conflict2 * 2f; + } + } + if (projectile.velocity.Y > yDist) + { + projectile.velocity.Y = projectile.velocity.Y - conflict2; + if (conflict2 > 0.05f && projectile.velocity.Y > 0f) + { + projectile.velocity.Y = projectile.velocity.Y - conflict2 * 2f; + } + } + if (projectile.frame < 15) + { + projectile.frame = 15; + } + else + { + projectile.frameCounter++; + if (projectile.frameCounter > 3) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 19) + { + projectile.frame = 15; + } + } + 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 + { + float conflict3 = (float) (40 * projectile.minionPos); + float attackCooldown = 30f; + int num4 = 60; + --projectile.localAI[0]; + if (projectile.localAI[0] < 0f) + projectile.localAI[0] = 0f; + if (projectile.ai[1] > 0f) + { + --projectile.ai[1]; + } + else + { + float num5 = projectile.position.X; + float num6 = projectile.position.Y; + float num7 = 100000f; + float num8 = num7; + int num9 = -1; + NPC minionAttackTargetNpc = projectile.OwnerMinionAttackTargetNPC; + if (minionAttackTargetNpc != null && minionAttackTargetNpc.CanBeChasedBy((object) projectile, false)) + { + float num10 = minionAttackTargetNpc.position.X + (float) (minionAttackTargetNpc.width / 2); + float num11 = minionAttackTargetNpc.position.Y + (float) (minionAttackTargetNpc.height / 2); + float num12 = Math.Abs(projectile.position.X + (float) (projectile.width / 2) - num10) + Math.Abs(projectile.position.Y + (float) (projectile.height / 2) - num11); + if (num12 < num7) + { + if (num9 == -1 && num12 <= num8) + { + num8 = num12; + num5 = num10; + num6 = num11; + } + if (Collision.CanHit(projectile.position, projectile.width, projectile.height, minionAttackTargetNpc.position, minionAttackTargetNpc.width, minionAttackTargetNpc.height)) + { + num7 = num12; + num5 = num10; + num6 = num11; + num9 = minionAttackTargetNpc.whoAmI; + } + } + } + if (num9 == -1) + { + for (int index = 0; index < Main.maxNPCs; ++index) + { + if (Main.npc[index].CanBeChasedBy((object) projectile, false)) + { + float num10 = Main.npc[index].position.X + (float) (Main.npc[index].width / 2); + float num11 = Main.npc[index].position.Y + (float) (Main.npc[index].height / 2); + float num12 = Math.Abs(projectile.position.X + (float) (projectile.width / 2) - num10) + Math.Abs(projectile.position.Y + (float) (projectile.height / 2) - num11); + if (num12 < num7) + { + if (num9 == -1 && num12 <= num8) + { + num8 = num12; + num5 = num10; + num6 = num11; + } + if (Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height)) + { + num7 = num12; + num5 = num10; + num6 = num11; + num9 = index; + } + } + } + } + } + if (num9 == -1 && num8 < num7) + num7 = num8; + float num13 = 400f; + if ((double) projectile.position.Y > Main.worldSurface * 16.0) + num13 = 200f; + if (num7 < num13 + conflict3 && num9 == -1) + { + float num10 = num5 - (projectile.position.X + (float) (projectile.width / 2)); + if (num10 < -5f) + { + flag1 = true; + flag2 = false; + } + else if (num10 > 5f) + { + flag2 = true; + flag1 = false; + } + } + else if (num9 >= 0 && num7 < 800f + conflict3) + { + projectile.localAI[0] = (float) num4; + float num10 = num5 - (projectile.position.X + (float) (projectile.width / 2)); + if (num10 > 300f || num10 < -300f) + { + if (num10 < -50f) + { + flag1 = true; + flag2 = false; + } + else if (num10 > 50f) + { + flag2 = true; + flag1 = false; + } + } + else if (projectile.owner == Main.myPlayer) + { + projectile.ai[1] = attackCooldown; + double num11 = 12.0; + Vector2 vector2 = new Vector2(projectile.Center.X, projectile.Center.Y - 8f); + float num12 = num5 - vector2.X + Main.rand.NextFloat(-6f, 6f); + float num14 = (float) ((double) (Math.Abs(num12) * 0.1f) * (double) Main.rand.Next(0, 100) * (1.0 / 1000.0)); + float num15 = num6 - vector2.Y + Main.rand.NextFloat(-6f, 6f) - num14; + double num16 = Math.Sqrt((double) num12 * (double) num12 + (double) num15 * (double) num15); + float num17 = (float) (num11 / num16); + float SpeedX = num12 * num17; + float SpeedY = num15 * num17; + int damage = projectile.damage; + int Type = ModContent.ProjectileType(); + int index = Projectile.NewProjectile(vector2.X, vector2.Y, SpeedX * 2f, SpeedY * 2f, Type, damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (SpeedX < 0f) + projectile.direction = -1; + if (SpeedX > 0f) + projectile.direction = 1; + projectile.netUpdate = true; + } + } + } + Vector2 vector2_1 = Vector2.Zero; + bool flag7 = false; + if (projectile.ai[1] != 0f) + { + flag1 = false; + flag2 = false; + } + else if (projectile.localAI[0] == 0f) + projectile.direction = player.direction; + if (!flag7) + projectile.rotation = 0f; + projectile.tileCollide = true; + float num18 = 0.08f; + float num19 = 6.5f; + num19 = 6f; + num18 = 0.2f; + if (num19 < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + { + num19 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + num18 = 0.3f; + } + if (flag1) + { + if (projectile.velocity.X > -3.5f) + projectile.velocity.X -= num18; + else + projectile.velocity.X -= num18 * 0.25f; + } + else if (flag2) + { + if (projectile.velocity.X < 3.5f) + projectile.velocity.X += num18; + else + projectile.velocity.X += num18 * 0.25f; + } + else + { + projectile.velocity.X *= 0.9f; + if (projectile.velocity.X >= -num18 && projectile.velocity.X <= num18) + projectile.velocity.X = 0f; + } + if (flag1 | flag2) + { + int conflict4 = (int) ((double) projectile.position.X + (double) (projectile.width / 2)) / 16; + int j = (int) ((double) projectile.position.Y + (double) (projectile.height / 2)) / 16; + if (flag1) + --conflict4; + if (flag2) + ++conflict4; + if (WorldGen.SolidTile(conflict4 + (int) projectile.velocity.X, j)) + flag4 = true; + } + if (player.position.Y + player.height - 8f > projectile.position.Y + projectile.height) + flag3 = true; + Collision.StepUp(ref projectile.position, ref projectile.velocity, projectile.width, projectile.height, ref projectile.stepSpeed, ref projectile.gfxOffY, 1, false, 0); + if (projectile.velocity.Y == 0f) + { + if (!flag3 && ((double) projectile.velocity.X < 0.0 || (double) projectile.velocity.X > 0.0)) + { + int i = (int) ((double) projectile.position.X + (double) (projectile.width / 2)) / 16; + int j = (int) ((double) projectile.position.Y + (double) (projectile.height / 2)) / 16 + 1; + if (flag1) + --i; + if (flag2) + ++i; + WorldGen.SolidTile(i, j); + } + if (flag4) + { + int i1 = (int) ((double) projectile.position.X + (double) (projectile.width / 2)) / 16; + int j = (int) ((double) projectile.position.Y + (double) projectile.height) / 16 + 1; + if (WorldGen.SolidTile(i1, j) || Main.tile[i1, j].halfBrick() || ((int) Main.tile[i1, j].slope() > 0 || projectile.type == 200)) + { + if (projectile.type == 200) + { + projectile.velocity.Y = -3.1f; + } + else + { + try + { + int conflict5 = (int) ((double) projectile.position.X + (double) (projectile.width / 2)) / 16; + int conflict7 = (int) ((double) projectile.position.Y + (double) (projectile.height / 2)) / 16; + if (flag1) + --conflict5; + if (flag2) + ++conflict5; + int i2 = conflict5 + (int) projectile.velocity.X; + if (!WorldGen.SolidTile(i2, conflict7 - 1) && !WorldGen.SolidTile(i2, conflict7 - 2)) + projectile.velocity.Y = -5.1f; + else if (!WorldGen.SolidTile(i2, conflict7 - 2)) + projectile.velocity.Y = -7.1f; + else if (WorldGen.SolidTile(i2, conflict7 - 5)) + projectile.velocity.Y = -11.1f; + else if (WorldGen.SolidTile(i2, conflict7 - 4)) + projectile.velocity.Y = -10.1f; + else + projectile.velocity.Y = -9.1f; + } + catch + { + projectile.velocity.Y = -9.1f; + } + } + } + } + else if (projectile.type == 266 && flag1 | flag2) + projectile.velocity.Y -= 6f; + } + if (projectile.velocity.X > num19) + projectile.velocity.X = num19; + if (projectile.velocity.X < -num19) + projectile.velocity.X = -num19; + if (projectile.velocity.X < 0f) + projectile.direction = -1; + if (projectile.velocity.X > 0f) + projectile.direction = 1; + if (projectile.velocity.X > num18 & flag2) + projectile.direction = 1; + if (projectile.velocity.X < -num18 & flag1) + projectile.direction = -1; + if (projectile.direction == -1) + projectile.spriteDirection = -1; + if (projectile.direction == 1) + projectile.spriteDirection = 1; + if (projectile.ai[1] > 0f) + { + if (projectile.localAI[1] == 0f) + { + projectile.localAI[1] = 1f; + projectile.frame = 9; + } + if (projectile.frame >= 9 && projectile.frame <= 14) + { + projectile.frameCounter++; + if (projectile.frameCounter > 8) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame == 14) + projectile.frame = 9; + } + } + else if (projectile.velocity.Y == 0f) + { + projectile.localAI[1] = 0f; + if (projectile.velocity.X == 0f) + { + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 3) + { + projectile.frame = 0; + } + } + else if (projectile.velocity.X < -0.8f || projectile.velocity.X > 0.8f) + { + projectile.frameCounter = projectile.frameCounter + (int) Math.Abs(projectile.velocity.X); + projectile.frameCounter++; + if (projectile.frameCounter > 20) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame < 4) + projectile.frame = 3; + if (projectile.frame >= 9) + projectile.frame = 3; + } + else + { + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 3) + { + projectile.frame = 0; + } + } + } + else if (projectile.velocity.Y < 0f) + { + projectile.frameCounter = 0; + projectile.frame = 3; + } + else if (projectile.velocity.Y > 0f) + { + projectile.frameCounter = 0; + projectile.frame = 3; + } + projectile.velocity.Y += 0.4f; + if (projectile.velocity.Y > 10f) + projectile.velocity.Y = 10f; + Vector2 velocity = projectile.velocity; + } + } public override bool CanDamage() { @@ -590,12 +590,12 @@ namespace CalamityMod.Projectiles.Summon return true; } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { - int index = Gore.NewGore(new Vector2(projectile.position.X - (float) (projectile.width / 2), projectile.position.Y - (float) (projectile.height / 2)), new Vector2(0.0f, 0.0f), Main.rand.Next(61, 64), projectile.scale); - Main.gore[index].velocity *= 0.1f; + int index = Gore.NewGore(new Vector2(projectile.position.X - (float) (projectile.width / 2), projectile.position.Y - (float) (projectile.height / 2)), new Vector2(0.0f, 0.0f), Main.rand.Next(61, 64), projectile.scale); + Main.gore[index].velocity *= 0.1f; } } } diff --git a/Projectiles/Summon/HermitCrabMinion.cs b/Projectiles/Summon/HermitCrabMinion.cs index b9501c9d4a..e1191f4b32 100644 --- a/Projectiles/Summon/HermitCrabMinion.cs +++ b/Projectiles/Summon/HermitCrabMinion.cs @@ -93,10 +93,10 @@ namespace CalamityMod.Projectiles.Summon { projectile.frameCounter++; } - else - { - projectile.frame = 0; - } + else + { + projectile.frame = 0; + } if (projectile.frameCounter > 4) { projectile.frame++; @@ -109,38 +109,38 @@ namespace CalamityMod.Projectiles.Summon float num633 = 600f; bool chaseNPC = false; float npcPositionX = 0f; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - float num646 = Vector2.Distance(npc.Center, projectile.Center); - if (!chaseNPC && num646 < num633) - { - num633 = num646; - vector46 = npc.Center; - npcPositionX = npc.position.X; - chaseNPC = true; - } - } - } + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float num646 = Vector2.Distance(npc.Center, projectile.Center); + if (!chaseNPC && num646 < num633) + { + num633 = num646; + vector46 = npc.Center; + npcPositionX = npc.position.X; + chaseNPC = true; + } + } + } if (!chaseNPC) - { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) - { - NPC npcTarget = Main.npc[num645]; - if (npcTarget.CanBeChasedBy(projectile, false)) - { - float num646 = Vector2.Distance(npcTarget.Center, projectile.Center); - if (!chaseNPC && num646 < num633) - { - num633 = num646; - vector46 = npcTarget.Center; - npcPositionX = npcTarget.position.X; - chaseNPC = true; - } - } - } + { + for (int num645 = 0; num645 < Main.maxNPCs; num645++) + { + NPC npcTarget = Main.npc[num645]; + if (npcTarget.CanBeChasedBy(projectile, false)) + { + float num646 = Vector2.Distance(npcTarget.Center, projectile.Center); + if (!chaseNPC && num646 < num633) + { + num633 = num646; + vector46 = npcTarget.Center; + npcPositionX = npcTarget.position.X; + chaseNPC = true; + } + } + } } if (chaseNPC) { @@ -185,7 +185,7 @@ namespace CalamityMod.Projectiles.Summon if (playerDistance > 1000f) { fly = true; - chaseNPC = false; + chaseNPC = false; projectile.velocity.X = 0f; projectile.velocity.Y = 0f; projectile.tileCollide = false; @@ -369,6 +369,6 @@ namespace CalamityMod.Projectiles.Summon return true; } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/HerringMinion.cs b/Projectiles/Summon/HerringMinion.cs index 6046ea0c94..b03fd470d5 100644 --- a/Projectiles/Summon/HerringMinion.cs +++ b/Projectiles/Summon/HerringMinion.cs @@ -93,7 +93,7 @@ namespace CalamityMod.Projectiles.Summon } } - projectile.ChargingMinionAI(600f, 800f, 1200f, 150f, 0, 40f, 8f, 4f, new Vector2(0f, -60f), 40f, 7f, false, true); + projectile.ChargingMinionAI(600f, 800f, 1200f, 150f, 0, 40f, 8f, 4f, new Vector2(0f, -60f), 40f, 7f, false, true); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Summon/Hive.cs b/Projectiles/Summon/Hive.cs index c122b9efe2..a92daff5e8 100644 --- a/Projectiles/Summon/Hive.cs +++ b/Projectiles/Summon/Hive.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (projectile.localAI[0] == 0f) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity.Y = 10f; } - projectile.StickToTiles(false, false); + projectile.StickToTiles(false, false); int target = 0; float num633 = 800f; diff --git a/Projectiles/Summon/Hiveling.cs b/Projectiles/Summon/Hiveling.cs index 28558c85a3..f80a3d4193 100644 --- a/Projectiles/Summon/Hiveling.cs +++ b/Projectiles/Summon/Hiveling.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class Hiveling : ModProjectile + public class Hiveling : ModProjectile { public override string Texture => "CalamityMod/NPCs/Astral/Hiveling"; @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; projectile.frameCounter++; if (projectile.frameCounter > 3) { diff --git a/Projectiles/Summon/HowlsHeartCalcifer.cs b/Projectiles/Summon/HowlsHeartCalcifer.cs index 6d63b2ab11..4fc4e568d8 100644 --- a/Projectiles/Summon/HowlsHeartCalcifer.cs +++ b/Projectiles/Summon/HowlsHeartCalcifer.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class HowlsHeartCalcifer : ModProjectile + public class HowlsHeartCalcifer : ModProjectile { public override void SetStaticDefaults() { @@ -45,9 +45,9 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - if (!modPlayer.howlsHeartVanity) - Lighting.AddLight(projectile.Center, 0.75f, 0.485f, 0f); - projectile.FloatingPetAI(false, 0.04f, true); + if (!modPlayer.howlsHeartVanity) + Lighting.AddLight(projectile.Center, 0.75f, 0.485f, 0f); + projectile.FloatingPetAI(false, 0.04f, true); projectile.frameCounter++; if (projectile.frameCounter > 6) { diff --git a/Projectiles/Summon/HowlsHeartFireball.cs b/Projectiles/Summon/HowlsHeartFireball.cs index bea3cb6f03..b0fdc6d846 100644 --- a/Projectiles/Summon/HowlsHeartFireball.cs +++ b/Projectiles/Summon/HowlsHeartFireball.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class HowlsHeartFireball : ModProjectile + public class HowlsHeartFireball : ModProjectile { public override void SetStaticDefaults() { @@ -28,9 +28,9 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; - //Cycle through animation + //Cycle through animation projectile.frameCounter++; if (projectile.frameCounter >= 6) { @@ -42,9 +42,9 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - Vector2 center = projectile.Center; - float maxDistance = 500f; - bool homeIn = false; + Vector2 center = projectile.Center; + float maxDistance = 500f; + bool homeIn = false; int target = (int)projectile.ai[0]; if (player.HasMinionAttackTargetNPC) @@ -52,63 +52,63 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float extraDistance = (npc.width / 2) + (npc.height / 2); + float extraDistance = (npc.width / 2) + (npc.height / 2); - bool canHit = true; - if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) - { - center = npc.Center; - homeIn = true; - } + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + { + center = npc.Center; + homeIn = true; + } } - } - else if (Main.npc[target].CanBeChasedBy(projectile, false)) - { - NPC npc = Main.npc[target]; - - float extraDistance = (npc.width / 2) + (npc.height / 2); - - bool canHit = true; - if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) - { - center = npc.Center; - homeIn = true; - } } - if (!homeIn) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDistance = (npc.width / 2) + (npc.height / 2); + else if (Main.npc[target].CanBeChasedBy(projectile, false)) + { + NPC npc = Main.npc[target]; - bool canHit = true; - if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + float extraDistance = (npc.width / 2) + (npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) - { - center = npc.Center; - homeIn = true; - break; - } - } - } - } + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (homeIn) - { - Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * 20f + moveDirection * 21f) / (21f); - } + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + { + center = npc.Center; + homeIn = true; + } + } + if (!homeIn) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); + + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + { + center = npc.Center; + homeIn = true; + break; + } + } + } + } + + if (homeIn) + { + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 20f + moveDirection * 21f) / (21f); + } int blueT = Dust.NewDust(projectile.position, projectile.width, projectile.height, 59, 0f, 0f, 100, default, 0.6f); Main.dust[blueT].noGravity = true; diff --git a/Projectiles/Summon/HowlsHeartHowl.cs b/Projectiles/Summon/HowlsHeartHowl.cs index 71132422a0..2417727c94 100644 --- a/Projectiles/Summon/HowlsHeartHowl.cs +++ b/Projectiles/Summon/HowlsHeartHowl.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class HowlsHeartHowl : ModProjectile + public class HowlsHeartHowl : ModProjectile { public bool initialized = false; @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Summon Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - //Spawn dust and record initial damage values + //Spawn dust and record initial damage values if (!initialized) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Summon initialized = true; } - //if minion damage changes, update it + //if minion damage changes, update it if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Summon projectile.damage = damage2; } - //If the correct minion, set bools + //If the correct minion, set bools bool correctMinion = projectile.type == ModContent.ProjectileType(); if (!modPlayer.howlsHeart && !modPlayer.howlsHeartVanity || !player.active) { @@ -83,143 +83,143 @@ namespace CalamityMod.Projectiles.Summon } } - //Anti sticky movement although there should only be one + //Anti sticky movement although there should only be one - //Set tile collision for only when trying to return to the player - projectile.tileCollide = projectile.ai[0] != 1f; + //Set tile collision for only when trying to return to the player + projectile.tileCollide = projectile.ai[0] != 1f; - //Find an enemy - Vector2 targetPos = projectile.position; - float maxRange = 900f; - bool foundEnemy = false; - int targetIndex = -1; - //If the player has targetted an enemy, choose that one - NPC target = projectile.OwnerMinionAttackTargetNPC; - if (target != null && target.CanBeChasedBy(projectile, false) && !modPlayer.howlsHeartVanity) - { - float targetDist = Vector2.Distance(target.Center, projectile.Center); - if (!foundEnemy && targetDist < maxRange && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, target.position, target.width, target.height)) - { - maxRange = targetDist; - targetPos = target.Center; - foundEnemy = true; - targetIndex = target.whoAmI; - } - } - //else, search through all available NPCs - if (!foundEnemy && !modPlayer.howlsHeartVanity) - { - for (int index = 0; index < Main.maxNPCs; ++index) - { - NPC npc = Main.npc[index]; - if (npc.CanBeChasedBy(projectile, false)) - { - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundEnemy && targetDist < maxRange && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) - { - maxRange = targetDist; - targetPos = npc.Center; - foundEnemy = true; - targetIndex = index; - } - } - } - } + //Find an enemy + Vector2 targetPos = projectile.position; + float maxRange = 900f; + bool foundEnemy = false; + int targetIndex = -1; + //If the player has targetted an enemy, choose that one + NPC target = projectile.OwnerMinionAttackTargetNPC; + if (target != null && target.CanBeChasedBy(projectile, false) && !modPlayer.howlsHeartVanity) + { + float targetDist = Vector2.Distance(target.Center, projectile.Center); + if (!foundEnemy && targetDist < maxRange && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, target.position, target.width, target.height)) + { + maxRange = targetDist; + targetPos = target.Center; + foundEnemy = true; + targetIndex = target.whoAmI; + } + } + //else, search through all available NPCs + if (!foundEnemy && !modPlayer.howlsHeartVanity) + { + for (int index = 0; index < Main.maxNPCs; ++index) + { + NPC npc = Main.npc[index]; + if (npc.CanBeChasedBy(projectile, false)) + { + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundEnemy && targetDist < maxRange && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + maxRange = targetDist; + targetPos = npc.Center; + foundEnemy = true; + targetIndex = index; + } + } + } + } - //If the minion is too far away, return to the player. Max distance increases while attacking - float maxDistanceFromPlayer = 1300f; - if (foundEnemy) - maxDistanceFromPlayer = 1600f; - if (Vector2.Distance(player.Center, projectile.Center) > maxDistanceFromPlayer && projectile.ai[0] != 1f) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } + //If the minion is too far away, return to the player. Max distance increases while attacking + float maxDistanceFromPlayer = 1300f; + if (foundEnemy) + maxDistanceFromPlayer = 1600f; + if (Vector2.Distance(player.Center, projectile.Center) > maxDistanceFromPlayer && projectile.ai[0] != 1f) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } - //Move toward an enemy if one has been found - if (foundEnemy && projectile.ai[0] == 0f) - { - Vector2 homeInVector = targetPos - projectile.Center; - float targetDist = homeInVector.Length(); - homeInVector.Normalize(); - if (targetDist > 200f) - { - float velocity = 6f; - projectile.velocity = (projectile.velocity * 40f + homeInVector * velocity) / 41f; - } - else - { - if (targetDist < 150f) - { - float velocity = -4f; - projectile.velocity = (projectile.velocity * 40f + homeInVector * velocity) / 41f; - } - else - projectile.velocity *= 0.97f; - } - } - else - { - //Return to the player if you can't see the player - if (!Collision.CanHitLine(projectile.Center, 1, 1, player.Center, 1, 1)) - projectile.ai[0] = 1f; + //Move toward an enemy if one has been found + if (foundEnemy && projectile.ai[0] == 0f) + { + Vector2 homeInVector = targetPos - projectile.Center; + float targetDist = homeInVector.Length(); + homeInVector.Normalize(); + if (targetDist > 200f) + { + float velocity = 6f; + projectile.velocity = (projectile.velocity * 40f + homeInVector * velocity) / 41f; + } + else + { + if (targetDist < 150f) + { + float velocity = -4f; + projectile.velocity = (projectile.velocity * 40f + homeInVector * velocity) / 41f; + } + else + projectile.velocity *= 0.97f; + } + } + else + { + //Return to the player if you can't see the player + if (!Collision.CanHitLine(projectile.Center, 1, 1, player.Center, 1, 1)) + projectile.ai[0] = 1f; - //Set speed to home in on the player. If returning to the player, go faster - float speed = 9f; - if (projectile.ai[0] == 1f) - speed = 22f; + //Set speed to home in on the player. If returning to the player, go faster + float speed = 9f; + if (projectile.ai[0] == 1f) + speed = 22f; - //Find the player and align accordingly. Get in a line if there's more than one. - Vector2 playerPos = player.Center - projectile.Center; - projectile.netUpdate = true; - int minionPosition = 1; - for (int index = 0; index < projectile.whoAmI; ++index) - { - Projectile proj = Main.projectile[index]; - if (proj.active && proj.owner == projectile.owner && proj.type == projectile.type) - ++minionPosition; - } - playerPos.X -= 10f * player.direction; - playerPos.X -= minionPosition * 60f * player.direction; - playerPos.Y -= 10f; + //Find the player and align accordingly. Get in a line if there's more than one. + Vector2 playerPos = player.Center - projectile.Center; + projectile.netUpdate = true; + int minionPosition = 1; + for (int index = 0; index < projectile.whoAmI; ++index) + { + Projectile proj = Main.projectile[index]; + if (proj.active && proj.owner == projectile.owner && proj.type == projectile.type) + ++minionPosition; + } + playerPos.X -= 10f * player.direction; + playerPos.X -= minionPosition * 60f * player.direction; + playerPos.Y -= 10f; - //Calculate player distance - float playerDist = playerPos.Length(); - //If too far, increase speed - if (playerDist > 200f && speed < 15f) - speed = 15f; - //If you were trying to chase the player but are close enough now, return to normal - if (playerDist < 100f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - //Teleport to the player if really, really far - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - projectile.width / 2f; - projectile.position.Y = player.Center.Y - projectile.width / 2f; - projectile.netUpdate = true; - } - //Home in on the player - if (playerDist > 10f) - { - playerPos.Normalize(); - if (playerDist < 50f) - speed /= 2f; - projectile.velocity = (projectile.velocity * 20f + playerPos * speed) / 21f; - } - else - { - projectile.direction = -player.direction; - projectile.velocity *= 0.9f; - } - } + //Calculate player distance + float playerDist = playerPos.Length(); + //If too far, increase speed + if (playerDist > 200f && speed < 15f) + speed = 15f; + //If you were trying to chase the player but are close enough now, return to normal + if (playerDist < 100f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + //Teleport to the player if really, really far + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - projectile.width / 2f; + projectile.position.Y = player.Center.Y - projectile.width / 2f; + projectile.netUpdate = true; + } + //Home in on the player + if (playerDist > 10f) + { + playerPos.Normalize(); + if (playerDist < 50f) + speed /= 2f; + projectile.velocity = (projectile.velocity * 20f + playerPos * speed) / 21f; + } + else + { + projectile.direction = -player.direction; + projectile.velocity *= 0.9f; + } + } - //Rotation - projectile.rotation = projectile.velocity.X * 0.05f; + //Rotation + projectile.rotation = projectile.velocity.X * 0.05f; - //Cycle through animation + //Cycle through animation projectile.frameCounter++; if (projectile.frameCounter >= 6) { @@ -231,54 +231,54 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - //Set projectile direction based on its movement - if (projectile.velocity.X > 0f) - projectile.spriteDirection = projectile.direction = -1; - else if (projectile.velocity.X < 0f) - projectile.spriteDirection = projectile.direction = 1; + //Set projectile direction based on its movement + if (projectile.velocity.X > 0f) + projectile.spriteDirection = projectile.direction = -1; + else if (projectile.velocity.X < 0f) + projectile.spriteDirection = projectile.direction = 1; - //Increment firing cooldown - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += Main.rand.Next(1,4); - if (Main.rand.NextBool(3)) - ++projectile.ai[1]; - } - //Determine if it should shoot - if (projectile.ai[1] > 90f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } + //Increment firing cooldown + if (projectile.ai[1] > 0f) + { + projectile.ai[1] += Main.rand.Next(1,4); + if (Main.rand.NextBool(3)) + ++projectile.ai[1]; + } + //Determine if it should shoot + if (projectile.ai[1] > 90f) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } - //Return if trying to return to the player or no enemy has been found - if (projectile.ai[0] != 0f || !foundEnemy) - return; + //Return if trying to return to the player or no enemy has been found + if (projectile.ai[0] != 0f || !foundEnemy) + return; - //Set projectile direction based on target location - Vector2 targetVec = targetPos - projectile.Center; - if (targetVec.X > 0f) - projectile.spriteDirection = projectile.direction = -1; - else if (targetVec.X < 0f) - projectile.spriteDirection = projectile.direction = 1; + //Set projectile direction based on target location + Vector2 targetVec = targetPos - projectile.Center; + if (targetVec.X > 0f) + projectile.spriteDirection = projectile.direction = -1; + else if (targetVec.X < 0f) + projectile.spriteDirection = projectile.direction = 1; - //Return if firing cooldown isn't perfect - if (projectile.ai[1] != 0f) - return; - ++projectile.ai[1]; - if (Main.myPlayer != projectile.owner) - return; + //Return if firing cooldown isn't perfect + if (projectile.ai[1] != 0f) + return; + ++projectile.ai[1]; + if (Main.myPlayer != projectile.owner) + return; - //Fire projectile - float speedMult = 16f; - targetVec.Normalize(); - targetVec *= speedMult; + //Fire projectile + float speedMult = 16f; + targetVec.Normalize(); + targetVec *= speedMult; Main.PlaySound(SoundID.Item20, projectile.position); - int fireball = Projectile.NewProjectile(projectile.Center, targetVec, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, targetIndex, 0f); - Main.projectile[fireball].netUpdate = true; - Main.projectile[fireball].frame = Main.rand.Next(4); - projectile.netUpdate = true; - } + int fireball = Projectile.NewProjectile(projectile.Center, targetVec, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, targetIndex, 0f); + Main.projectile[fireball].netUpdate = true; + Main.projectile[fireball].frame = Main.rand.Next(4); + projectile.netUpdate = true; + } public override bool OnTileCollide(Vector2 oldVelocity) => false; diff --git a/Projectiles/Summon/HowlsHeartTurnipHead.cs b/Projectiles/Summon/HowlsHeartTurnipHead.cs index 260d41e73c..397b32046c 100644 --- a/Projectiles/Summon/HowlsHeartTurnipHead.cs +++ b/Projectiles/Summon/HowlsHeartTurnipHead.cs @@ -39,9 +39,9 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + CalamityPlayer modPlayer = player.Calamity(); - //If the correct minion, set bools + //If the correct minion, set bools bool correctMinion = projectile.type == ModContent.ProjectileType(); if (!modPlayer.howlsHeart && !modPlayer.howlsHeartVanity || !player.active) { @@ -59,26 +59,26 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.frameCounter++; - if (projectile.frameCounter > 6) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } Vector2 vector46 = projectile.position; if (!fly) { projectile.rotation = 0; Vector2 playerVec = player.Center - projectile.Center; float playerDistance = playerVec.Length(); - if (projectile.velocity.Y == 0f) - { - projectile.velocity.Y = -3f; - } + if (projectile.velocity.Y == 0f) + { + projectile.velocity.Y = -3f; + } projectile.velocity.Y += 0.2f; if (projectile.velocity.Y > 7f) { @@ -129,11 +129,11 @@ namespace CalamityMod.Projectiles.Summon } else if (fly) { - //still hopping - if (projectile.velocity.Y == 0f) - { - projectile.velocity.Y = -3f; - } + //still hopping + if (projectile.velocity.Y == 0f) + { + projectile.velocity.Y = -3f; + } projectile.velocity.Y += 0.2f; if (projectile.velocity.Y > 7f) { diff --git a/Projectiles/Summon/IceClasperMinion.cs b/Projectiles/Summon/IceClasperMinion.cs index dbd04ace63..e4cdac2a8e 100644 --- a/Projectiles/Summon/IceClasperMinion.cs +++ b/Projectiles/Summon/IceClasperMinion.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class IceClasperMinion : ModProjectile + public class IceClasperMinion : ModProjectile { private int dust = 3; @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; projectile.timeLeft *= 5; projectile.minion = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Summon } } - projectile.ChargingMinionAI(1200f, 1500f, 2200f, 150f, 0, 40f, 9f, 4f, new Vector2(0f, -60f), 40f, 9f, true, true); + projectile.ChargingMinionAI(1200f, 1500f, 2200f, 150f, 0, 40f, 9f, 4f, new Vector2(0f, -60f), 40f, 9f, true, true); projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; } diff --git a/Projectiles/Summon/IceSentry.cs b/Projectiles/Summon/IceSentry.cs index d118f88681..9e99f338d8 100644 --- a/Projectiles/Summon/IceSentry.cs +++ b/Projectiles/Summon/IceSentry.cs @@ -24,12 +24,12 @@ namespace CalamityMod.Projectiles.Summon projectile.ignoreWater = true; projectile.tileCollide = false; projectile.sentry = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (setDamage) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); diff --git a/Projectiles/Summon/IceSentryFrostBolt.cs b/Projectiles/Summon/IceSentryFrostBolt.cs index ba44de76e8..7b3cd1078d 100644 --- a/Projectiles/Summon/IceSentryFrostBolt.cs +++ b/Projectiles/Summon/IceSentryFrostBolt.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Projectiles.Summon DisplayName.SetDefault("Ball"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; ProjectileID.Sets.TrailingMode[projectile.type] = 0; - ProjectileID.Sets.SentryShot[projectile.type] = true; + ProjectileID.Sets.SentryShot[projectile.type] = true; } public override void SetDefaults() @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = 2; projectile.timeLeft = 480; projectile.minion = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Summon/IceSentryShard.cs b/Projectiles/Summon/IceSentryShard.cs index 2857ee4dbe..ca3d5b3553 100644 --- a/Projectiles/Summon/IceSentryShard.cs +++ b/Projectiles/Summon/IceSentryShard.cs @@ -18,13 +18,13 @@ namespace CalamityMod.Projectiles.Summon projectile.friendly = true; projectile.minion = true; projectile.penetrate = 1; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void SetStaticDefaults() { DisplayName.SetDefault("Frost Shard"); - ProjectileID.Sets.SentryShot[projectile.type] = true; + ProjectileID.Sets.SentryShot[projectile.type] = true; } public override void AI() diff --git a/Projectiles/Summon/IgneousBlade.cs b/Projectiles/Summon/IgneousBlade.cs index 4f16f3ef5f..5b860b747d 100644 --- a/Projectiles/Summon/IgneousBlade.cs +++ b/Projectiles/Summon/IgneousBlade.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class IgneousBlade : ModProjectile + public class IgneousBlade : ModProjectile { public bool Firing = false; public override void SetStaticDefaults() @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Summon projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; projectile.localAI[0] = 1f; - } + } if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / @@ -84,8 +84,8 @@ namespace CalamityMod.Projectiles.Summon } else { - if (projectile.penetrate == -1) //limit penetration for worm memes - projectile.penetrate = 3; + if (projectile.penetrate == -1) //limit penetration for worm memes + projectile.penetrate = 3; projectile.ai[0]--; if (projectile.ai[0] == 1) diff --git a/Projectiles/Summon/IgneousBladeStrike.cs b/Projectiles/Summon/IgneousBladeStrike.cs index 51b5798e38..aad255f129 100644 --- a/Projectiles/Summon/IgneousBladeStrike.cs +++ b/Projectiles/Summon/IgneousBladeStrike.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2 + MathHelper.PiOver4; - } + } public override void Kill(int timeLeft) { for (int i = 0; i < Main.rand.Next(28, 41); i++) diff --git a/Projectiles/Summon/IrradiatedAura.cs b/Projectiles/Summon/IrradiatedAura.cs index 273cf7a271..6bf6e0ff40 100644 --- a/Projectiles/Summon/IrradiatedAura.cs +++ b/Projectiles/Summon/IrradiatedAura.cs @@ -6,7 +6,7 @@ using CalamityMod.Dusts; namespace CalamityMod.Projectiles.Summon { - public class IrradiatedAura : ModProjectile + public class IrradiatedAura : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Summon/LanternFlame.cs b/Projectiles/Summon/LanternFlame.cs index d1b724d2f5..d045da9492 100644 --- a/Projectiles/Summon/LanternFlame.cs +++ b/Projectiles/Summon/LanternFlame.cs @@ -5,9 +5,9 @@ using Terraria.ModLoader; using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Summon { - public class LanternFlame : ModProjectile + public class LanternFlame : ModProjectile { - private bool playSound = true; + private bool playSound = true; public override void SetStaticDefaults() { @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = 1; projectile.timeLeft = 600; projectile.alpha = 255; - projectile.tileCollide = false; + projectile.tileCollide = false; } public override void AI() @@ -42,12 +42,12 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - if (projectile.alpha > 0) - { - projectile.alpha -= 10; - } - if (projectile.alpha <= 25) - { + if (projectile.alpha > 0) + { + projectile.alpha -= 10; + } + if (projectile.alpha <= 25) + { NPC potentialTarget = projectile.Center.MinionHoming(700f, Main.player[projectile.owner]); if (potentialTarget != null) projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(potentialTarget.Center) * 16f) / 21f; @@ -88,11 +88,11 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 180); - if (playSound) + if (playSound) { Main.PlaySound(SoundID.Item74, projectile.position); } - playSound = false; - } + playSound = false; + } } } diff --git a/Projectiles/Summon/LanternSoul.cs b/Projectiles/Summon/LanternSoul.cs index 77bf181500..165621e808 100644 --- a/Projectiles/Summon/LanternSoul.cs +++ b/Projectiles/Summon/LanternSoul.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (count == 0f) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -64,30 +64,30 @@ namespace CalamityMod.Projectiles.Summon projectile.netUpdate = true; } - int num = 0; - for (int i = 0; i < Main.projectile.Length; i++) - { - if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == ModContent.ProjectileType()) - { - num++; - } - } - if (num < 20) - { - projectile.ai[1] += (float)Main.rand.Next(2,6) + 1f; - if (projectile.ai[1] >= 75f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - if (projectile.owner == Main.myPlayer) - { - float startOffsetX = Main.rand.NextFloat(15f, 200f) * (Main.rand.NextBool() ? -1f : 1f); - float startOffsetY = Main.rand.NextFloat(15f, 200f) * (Main.rand.NextBool() ? -1f : 1f); - Vector2 startPos = new Vector2(projectile.position.X + startOffsetX, projectile.position.Y + startOffsetY); - Vector2 speed = new Vector2(0f, 0f); - Projectile.NewProjectile(startPos, speed, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - } - } + int num = 0; + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == ModContent.ProjectileType()) + { + num++; + } + } + if (num < 20) + { + projectile.ai[1] += (float)Main.rand.Next(2,6) + 1f; + if (projectile.ai[1] >= 75f) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + if (projectile.owner == Main.myPlayer) + { + float startOffsetX = Main.rand.NextFloat(15f, 200f) * (Main.rand.NextBool() ? -1f : 1f); + float startOffsetY = Main.rand.NextFloat(15f, 200f) * (Main.rand.NextBool() ? -1f : 1f); + Vector2 startPos = new Vector2(projectile.position.X + startOffsetX, projectile.position.Y + startOffsetY); + Vector2 speed = new Vector2(0f, 0f); + Projectile.NewProjectile(startPos, speed, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + } + } } } diff --git a/Projectiles/Summon/LostSoulGiant.cs b/Projectiles/Summon/LostSoulGiant.cs index ba043fe6dd..02d6004070 100644 --- a/Projectiles/Summon/LostSoulGiant.cs +++ b/Projectiles/Summon/LostSoulGiant.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class LostSoulGiant : ModProjectile + public class LostSoulGiant : ModProjectile { public ref float Time => ref projectile.ai[0]; public override void SetStaticDefaults() diff --git a/Projectiles/Summon/LostSoulGold.cs b/Projectiles/Summon/LostSoulGold.cs index bd21a7662f..c89cdc565e 100644 --- a/Projectiles/Summon/LostSoulGold.cs +++ b/Projectiles/Summon/LostSoulGold.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class LostSoulGold : ModProjectile + public class LostSoulGold : ModProjectile { public ref float Time => ref projectile.ai[0]; public override void SetStaticDefaults() diff --git a/Projectiles/Summon/LostSoulLarge.cs b/Projectiles/Summon/LostSoulLarge.cs index 204733a066..aab781fe8f 100644 --- a/Projectiles/Summon/LostSoulLarge.cs +++ b/Projectiles/Summon/LostSoulLarge.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class LostSoulLarge : ModProjectile + public class LostSoulLarge : ModProjectile { public ref float Time => ref projectile.ai[0]; public override void SetStaticDefaults() diff --git a/Projectiles/Summon/LostSoulSmall.cs b/Projectiles/Summon/LostSoulSmall.cs index 0bc2e93403..06b23fbd9b 100644 --- a/Projectiles/Summon/LostSoulSmall.cs +++ b/Projectiles/Summon/LostSoulSmall.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class LostSoulSmall : ModProjectile + public class LostSoulSmall : ModProjectile { public ref float Time => ref projectile.ai[0]; public override void SetStaticDefaults() diff --git a/Projectiles/Summon/LuxorsGiftSummon.cs b/Projectiles/Summon/LuxorsGiftSummon.cs index 85aef3c2f0..06b1cc6a62 100644 --- a/Projectiles/Summon/LuxorsGiftSummon.cs +++ b/Projectiles/Summon/LuxorsGiftSummon.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class LuxorsGiftSummon : ModProjectile + public class LuxorsGiftSummon : ModProjectile { private int dust = 3; @@ -93,7 +93,7 @@ namespace CalamityMod.Projectiles.Summon } } - projectile.ChargingMinionAI(700f, 1000f, 2200f, 150f, 0, 40f, 9f, 4f, new Vector2(0f, -60f), 40f, 9f, true, true); + projectile.ChargingMinionAI(700f, 1000f, 2200f, 150f, 0, 40f, 9f, 4f, new Vector2(0f, -60f), 40f, 9f, true, true); projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; } diff --git a/Projectiles/Summon/MK2FlaskSummon.cs b/Projectiles/Summon/MK2FlaskSummon.cs index 8590b9a481..0e3cbe02f3 100644 --- a/Projectiles/Summon/MK2FlaskSummon.cs +++ b/Projectiles/Summon/MK2FlaskSummon.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.velocity.Y += 0.2f; projectile.rotation += 0.1f * (projectile.velocity.X > 0).ToDirectionInt(); - } + } public override void Kill(int timeLeft) { if (Main.myPlayer == projectile.owner) diff --git a/Projectiles/Summon/MK2RocketHoming.cs b/Projectiles/Summon/MK2RocketHoming.cs index 3472cab2ef..b4785a598d 100644 --- a/Projectiles/Summon/MK2RocketHoming.cs +++ b/Projectiles/Summon/MK2RocketHoming.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Projectiles.Summon projectile.width = 14; projectile.height = 14; projectile.extraUpdates = 1; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.friendly = true; projectile.minion = true; projectile.minionSlots = 0f; @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 600; } - public override void AI() + public override void AI() { Player player = Main.player[projectile.owner]; NPC potentialTarget = projectile.Center.MinionHoming(1000f, player); @@ -44,11 +44,11 @@ namespace CalamityMod.Projectiles.Summon projectile.frame++; projectile.frameCounter = 0; } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } - } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { @@ -62,9 +62,9 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 599) - return false; - return true; - } + if (projectile.timeLeft > 599) + return false; + return true; + } } } diff --git a/Projectiles/Summon/MK2RocketNormal.cs b/Projectiles/Summon/MK2RocketNormal.cs index 0babae7582..c15caefb8c 100644 --- a/Projectiles/Summon/MK2RocketNormal.cs +++ b/Projectiles/Summon/MK2RocketNormal.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Summon projectile.height = 14; projectile.light = 0.5f; projectile.extraUpdates = 1; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.friendly = true; projectile.minion = true; projectile.minionSlots = 0f; @@ -30,17 +30,17 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 600; } - public override void AI() - { + public override void AI() + { projectile.frameCounter++; if (projectile.frameCounter > 8) { projectile.frame++; projectile.frameCounter = 0; } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; } projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; } @@ -57,9 +57,9 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft > 599) - return false; - return true; - } + if (projectile.timeLeft > 599) + return false; + return true; + } } } diff --git a/Projectiles/Summon/MagicAxe.cs b/Projectiles/Summon/MagicAxe.cs index 4b9d3259db..36f9fc8cf2 100644 --- a/Projectiles/Summon/MagicAxe.cs +++ b/Projectiles/Summon/MagicAxe.cs @@ -7,9 +7,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class MagicAxe : ModProjectile + public class MagicAxe : ModProjectile { - private int counter = 0; + private int counter = 0; public override void SetStaticDefaults() { DisplayName.SetDefault("Axe"); @@ -33,24 +33,24 @@ namespace CalamityMod.Projectiles.Summon projectile.extraUpdates = 1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 8; - projectile.alpha = 255; + projectile.alpha = 255; } public override void AI() { projectile.rotation += 0.075f; - projectile.alpha -= 50; - counter++; - if (counter == 30) - { - projectile.netUpdate = true; - } - else if (counter < 30) - { - return; - } + projectile.alpha -= 50; + counter++; + if (counter == 30) + { + projectile.netUpdate = true; + } + else if (counter < 30) + { + return; + } - projectile.ChargingMinionAI(MagicHat.Range, 1200f, 2500f, 400f, 1, 30f, 24f, 12f, new Vector2(0f, -60f), 30f, 16f, true, true, 3); + projectile.ChargingMinionAI(MagicHat.Range, 1200f, 2500f, 400f, 1, 30f, 24f, 12f, new Vector2(0f, -60f), 30f, 16f, true, true, 3); } public override Color? GetAlpha(Color lightColor) => new Color(0, 255, 111, projectile.alpha); @@ -63,17 +63,17 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Summon/MagicBat.cs b/Projectiles/Summon/MagicBat.cs index e17bc59c31..84dd3d0e15 100644 --- a/Projectiles/Summon/MagicBat.cs +++ b/Projectiles/Summon/MagicBat.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class MagicBat : ModProjectile + public class MagicBat : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Summon/MagicBird.cs b/Projectiles/Summon/MagicBird.cs index 5f1eb4a8e0..0db80b7445 100644 --- a/Projectiles/Summon/MagicBird.cs +++ b/Projectiles/Summon/MagicBird.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class MagicBird : ModProjectile + public class MagicBird : ModProjectile { public override void SetStaticDefaults() { @@ -36,11 +36,11 @@ namespace CalamityMod.Projectiles.Summon projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - projectile.frameCounter++; + projectile.frameCounter++; if (projectile.frameCounter > 6) { projectile.frame++; - projectile.frameCounter = 0; + projectile.frameCounter = 0; } if (projectile.frame >= 7) { diff --git a/Projectiles/Summon/MagicBullet.cs b/Projectiles/Summon/MagicBullet.cs index 15985b3adb..378790cdb8 100644 --- a/Projectiles/Summon/MagicBullet.cs +++ b/Projectiles/Summon/MagicBullet.cs @@ -6,64 +6,64 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class MagicBullet : ModProjectile - { + public class MagicBullet : ModProjectile + { public override string Texture => "CalamityMod/Projectiles/Ranged/BloodClotFriendly"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bullet"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bullet"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = 4; - projectile.height = 4; - projectile.light = 0.5f; - projectile.alpha = 255; - projectile.extraUpdates = 7; - projectile.scale = 1.18f; - projectile.friendly = true; - projectile.minion = true; - projectile.ignoreWater = true; - projectile.aiStyle = 1; - aiType = ProjectileID.BulletHighVelocity; - projectile.penetrate = 1; - projectile.timeLeft = 600; - projectile.tileCollide = false; - } + public override void SetDefaults() + { + projectile.width = 4; + projectile.height = 4; + projectile.light = 0.5f; + projectile.alpha = 255; + projectile.extraUpdates = 7; + projectile.scale = 1.18f; + projectile.friendly = true; + projectile.minion = true; + projectile.ignoreWater = true; + projectile.aiStyle = 1; + aiType = ProjectileID.BulletHighVelocity; + projectile.penetrate = 1; + projectile.timeLeft = 600; + projectile.tileCollide = false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (!target.betsysCurse) - target.AddBuff(BuffID.BetsysCurse, 180); - if (!target.ichor) - target.AddBuff(BuffID.Ichor, 180); - if (target.Calamity().marked <= 0) - target.AddBuff(ModContent.BuffType(), 180); - if (target.Calamity().aCrunch <= 0) - target.AddBuff(ModContent.BuffType(), 180); - if (target.Calamity().wCleave <= 0) - target.AddBuff(ModContent.BuffType(), 180); - if (target.Calamity().wDeath <= 0) - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (!target.betsysCurse) + target.AddBuff(BuffID.BetsysCurse, 180); + if (!target.ichor) + target.AddBuff(BuffID.Ichor, 180); + if (target.Calamity().marked <= 0) + target.AddBuff(ModContent.BuffType(), 180); + if (target.Calamity().aCrunch <= 0) + target.AddBuff(ModContent.BuffType(), 180); + if (target.Calamity().wCleave <= 0) + target.AddBuff(ModContent.BuffType(), 180); + if (target.Calamity().wDeath <= 0) + target.AddBuff(ModContent.BuffType(), 180); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.Ichor, 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Ichor, 180); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(189, 51, 164, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(189, 51, 164, projectile.alpha); + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.timeLeft < 600; - } + } } diff --git a/Projectiles/Summon/MagicHammer.cs b/Projectiles/Summon/MagicHammer.cs index c3ff28d797..2378e7d723 100644 --- a/Projectiles/Summon/MagicHammer.cs +++ b/Projectiles/Summon/MagicHammer.cs @@ -6,9 +6,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class MagicHammer : ModProjectile + public class MagicHammer : ModProjectile { - private int counter = 0; + private int counter = 0; public override void SetStaticDefaults() { DisplayName.SetDefault("Hammer"); @@ -47,15 +47,15 @@ namespace CalamityMod.Projectiles.Summon projectile.rotation += 0.075f; - counter++; - if (counter == 30) - { - projectile.netUpdate = true; - } - else if (counter < 30) - { - return; - } + counter++; + if (counter == 30) + { + projectile.netUpdate = true; + } + else if (counter < 30) + { + return; + } int targetIndex = -1; Vector2 targetVec = projectile.Center; @@ -64,38 +64,38 @@ namespace CalamityMod.Projectiles.Summon { projectile.localAI[0] -= 1f; } - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (projectile.ai[0] == 0f && projectile.localAI[0] == 0f) { - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == player.MinionAttackTargetNPC + 1f)) - { - float targetDist = Vector2.Distance(npc.Center, targetVec); - if (targetDist < maxDistance) - { - targetVec = npc.Center; - targetIndex = player.MinionAttackTargetNPC; - } - } - } - else - { - for (int i = 0; i < Main.npc.Length; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == i + 1f)) - { - float targetDist = Vector2.Distance(npc.Center, targetVec); - if (targetDist < maxDistance) - { - targetVec = npc.Center; - targetIndex = i; - } - } - } - } + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == player.MinionAttackTargetNPC + 1f)) + { + float targetDist = Vector2.Distance(npc.Center, targetVec); + if (targetDist < maxDistance) + { + targetVec = npc.Center; + targetIndex = player.MinionAttackTargetNPC; + } + } + } + else + { + for (int i = 0; i < Main.npc.Length; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == i + 1f)) + { + float targetDist = Vector2.Distance(npc.Center, targetVec); + if (targetDist < maxDistance) + { + targetVec = npc.Center; + targetIndex = i; + } + } + } + } if (targetIndex >= 0) { projectile.ai[0] = targetIndex + 1f; @@ -110,10 +110,10 @@ namespace CalamityMod.Projectiles.Summon if (projectile.ai[0] != 0f) { int target = (int)(projectile.ai[0] - 1f); - NPC npc = Main.npc[target]; + NPC npc = Main.npc[target]; if (npc.CanBeChasedBy(projectile, false) && npc.immune[projectile.owner] == 0) { - float targetDist = Vector2.Distance(npc.Center, targetVec); + float targetDist = Vector2.Distance(npc.Center, targetVec); if (targetDist < maxDistance * 1.25f) { canHome = true; diff --git a/Projectiles/Summon/MagicHat.cs b/Projectiles/Summon/MagicHat.cs index 9dea9aea62..172d361f24 100644 --- a/Projectiles/Summon/MagicHat.cs +++ b/Projectiles/Summon/MagicHat.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class MagicHat : ModProjectile + public class MagicHat : ModProjectile { public const float Range = 1500.0001f; @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); CalamityGlobalProjectile modProj = projectile.Calamity(); - //set up minion buffs and bools + //set up minion buffs and bools bool hatExists = projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); if (hatExists) @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Summon } } - //projectile movement + //projectile movement projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); if (player.gravDir == -1f) { @@ -69,12 +69,12 @@ namespace CalamityMod.Projectiles.Summon projectile.position.X = (int)projectile.position.X; projectile.position.Y = (int)projectile.position.Y; - //Change the summons scale size a little bit to make it pulse in and out + //Change the summons scale size a little bit to make it pulse in and out float scalar = (float)Main.mouseTextColor / 200f - 0.35f; scalar *= 0.2f; projectile.scale = scalar + 0.95f; - //on summon dust and flexible damage + //on summon dust and flexible damage if (projectile.localAI[0] == 0f) { int dustAmt = 50; @@ -95,55 +95,55 @@ namespace CalamityMod.Projectiles.Summon projectile.damage = damage2; } - //finding an enemy, then shooting projectiles if it's detected + //finding an enemy, then shooting projectiles if it's detected if (projectile.owner == Main.myPlayer) { float detectionRange = Range; bool enemyDetected = false; - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDistance = (npc.width / 2) + (npc.height / 2); + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (detectionRange + extraDistance)) - { - enemyDetected = true; - break; - } - } - } + if (Vector2.Distance(npc.Center, projectile.Center) < (detectionRange + extraDistance)) + { + enemyDetected = true; + break; + } + } + } if (enemyDetected) { - projectile.ai[1] += 1f; - if (projectile.ai[1] % 5f == 0f) - { - int amount = Main.rand.Next(1, 2); - for (int i = 0; i < amount; i++) - { - int projType = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType() - }); - 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, projType, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - } - } + projectile.ai[1] += 1f; + if (projectile.ai[1] % 5f == 0f) + { + int amount = Main.rand.Next(1, 2); + for (int i = 0; i < amount; i++) + { + int projType = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() + }); + 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, projType, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + } + } } } } - //glowmask effect + //glowmask effect public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); - //no contact damage + //no contact damage public override bool CanDamage() => false; } } diff --git a/Projectiles/Summon/MagicRifle.cs b/Projectiles/Summon/MagicRifle.cs index 4eba7c04ec..e47813df0d 100644 --- a/Projectiles/Summon/MagicRifle.cs +++ b/Projectiles/Summon/MagicRifle.cs @@ -5,234 +5,234 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class MagicRifle : ModProjectile - { - private int counter = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Rifle"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - } + public class MagicRifle : ModProjectile + { + private int counter = 0; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rifle"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = 30; - projectile.height = 30; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.minionSlots = 0f; - projectile.timeLeft = 180; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.minion = true; - } + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 0f; + projectile.timeLeft = 180; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.minion = true; + } - public override void AI() - { - //Set player namespace - Player player = Main.player[projectile.owner]; + public override void AI() + { + //Set player namespace + Player player = Main.player[projectile.owner]; - //Anti sticky movement to prevent overlapping minions - projectile.MinionAntiClump(); + //Anti sticky movement to prevent overlapping minions + projectile.MinionAntiClump(); - //Try not to do anything at first - counter++; - if (counter == 30) - { - projectile.netUpdate = true; - } - else if (counter < 30) - { - return; - } + //Try not to do anything at first + counter++; + if (counter == 30) + { + projectile.netUpdate = true; + } + else if (counter < 30) + { + return; + } - float homingRange = MagicHat.Range; - Vector2 targetVec = projectile.position; - bool foundTarget = false; - //If targeting something, prioritize that enemy - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && targetDist < (homingRange + extraDist)) - { - homingRange = targetDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - if (!foundTarget) - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && targetDist < (homingRange + extraDist)) - { - homingRange = targetDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - } + float homingRange = MagicHat.Range; + Vector2 targetVec = projectile.position; + bool foundTarget = false; + //If targeting something, prioritize that enemy + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + //Calculate distance between target and the projectile to know if it's too far or not + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < (homingRange + extraDist)) + { + homingRange = targetDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + if (!foundTarget) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + //Calculate distance between target and the projectile to know if it's too far or not + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < (homingRange + extraDist)) + { + homingRange = targetDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + } - //If too far, make the minion start returning to the player. - float separationAnxietyDist = 1600f; - if (foundTarget) - { - //Max travel distance increases if targeting something - separationAnxietyDist = 2600f; - } - if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } + //If too far, make the minion start returning to the player. + float separationAnxietyDist = 1600f; + if (foundTarget) + { + //Max travel distance increases if targeting something + separationAnxietyDist = 2600f; + } + if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } - //If a target is found, move toward it - if (foundTarget && projectile.ai[0] == 0f) - { - Vector2 vecToTarget = targetVec - projectile.Center; - float targetDist = vecToTarget.Length(); - vecToTarget.Normalize(); - //If farther than 200 pixels, move toward it - if (targetDist > 200f) - { - float speedMult = 18f; //12 - vecToTarget *= speedMult; - projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; - } - //Otherwise, back it up slowly - else - { - float speedMult = -9f; - vecToTarget *= speedMult; - projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; - } - } + //If a target is found, move toward it + if (foundTarget && projectile.ai[0] == 0f) + { + Vector2 vecToTarget = targetVec - projectile.Center; + float targetDist = vecToTarget.Length(); + vecToTarget.Normalize(); + //If farther than 200 pixels, move toward it + if (targetDist > 200f) + { + float speedMult = 18f; //12 + vecToTarget *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; + } + //Otherwise, back it up slowly + else + { + float speedMult = -9f; + vecToTarget *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; + } + } - //If not targeting something, act passively - else - { - bool returningToPlayer = false; - if (!returningToPlayer) - { - returningToPlayer = projectile.ai[0] == 1f; - } - //Move faster if actively returning to the player - float speedMult = 12f; - if (returningToPlayer) - { - speedMult = 30f; - } - Vector2 vecToPlayer = player.Center - projectile.Center + new Vector2(0f, -120f); - float playerDist = vecToPlayer.Length(); - //Speed up if near the player - if (playerDist < 200f && speedMult < 16f) - { - speedMult = 16f; - } - //If close enough to the player, return to normal - if (playerDist < 600f && returningToPlayer) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - //If abnormally far, teleport to the player - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - //Move toward player if more than 70 pixels away - if (playerDist > 70f) - { - vecToPlayer.Normalize(); - vecToPlayer *= speedMult; - projectile.velocity = (projectile.velocity * 40f + vecToPlayer) / 41f; - } - //Move if still - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - } + //If not targeting something, act passively + else + { + bool returningToPlayer = false; + if (!returningToPlayer) + { + returningToPlayer = projectile.ai[0] == 1f; + } + //Move faster if actively returning to the player + float speedMult = 12f; + if (returningToPlayer) + { + speedMult = 30f; + } + Vector2 vecToPlayer = player.Center - projectile.Center + new Vector2(0f, -120f); + float playerDist = vecToPlayer.Length(); + //Speed up if near the player + if (playerDist < 200f && speedMult < 16f) + { + speedMult = 16f; + } + //If close enough to the player, return to normal + if (playerDist < 600f && returningToPlayer) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + //If abnormally far, teleport to the player + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - (float)(projectile.width / 2); + projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + //Move toward player if more than 70 pixels away + if (playerDist > 70f) + { + vecToPlayer.Normalize(); + vecToPlayer *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToPlayer) / 41f; + } + //Move if still + else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.15f; + projectile.velocity.Y = -0.05f; + } + } - //Update rotation - if (foundTarget) - { - projectile.spriteDirection = projectile.direction = ((targetVec.X - projectile.Center.X) > 0).ToDirectionInt(); - projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(45) : MathHelper.ToRadians(135)), 0.1f); - } - else - { - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(45) : MathHelper.ToRadians(135)); - } + //Update rotation + if (foundTarget) + { + projectile.spriteDirection = projectile.direction = ((targetVec.X - projectile.Center.X) > 0).ToDirectionInt(); + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(45) : MathHelper.ToRadians(135)), 0.1f); + } + else + { + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(45) : MathHelper.ToRadians(135)); + } - //Increment attack cooldown - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += Main.rand.Next(1, 4); - } - //Set the minion to be ready for attack - if (projectile.ai[1] > 90f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } + //Increment attack cooldown + if (projectile.ai[1] > 0f) + { + projectile.ai[1] += Main.rand.Next(1, 4); + } + //Set the minion to be ready for attack + if (projectile.ai[1] > 90f) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } - //Return if on attack cooldown, has no target, or returning to the player - if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f) - return; + //Return if on attack cooldown, has no target, or returning to the player + if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f) + return; - //Shoot a bullet - if (Main.myPlayer == projectile.owner) - { - float projSpeed = 6f; - int projType = ModContent.ProjectileType(); - if (Main.rand.NextBool(6)) - { - Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 20, 0.1f); - } - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - Vector2 velocity = targetVec - projectile.Center; - velocity.Normalize(); - velocity *= projSpeed; - Main.PlaySound(SoundID.Item40, projectile.position); - Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, projectile.owner); - projectile.netUpdate = true; - } - } - } + //Shoot a bullet + if (Main.myPlayer == projectile.owner) + { + float projSpeed = 6f; + int projType = ModContent.ProjectileType(); + if (Main.rand.NextBool(6)) + { + Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 20, 0.1f); + } + projectile.ai[1] += 1f; + if (Main.myPlayer == projectile.owner) + { + Vector2 velocity = targetVec - projectile.Center; + velocity.Normalize(); + velocity *= projSpeed; + Main.PlaySound(SoundID.Item40, projectile.position); + Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, projectile.owner); + projectile.netUpdate = true; + } + } + } - public override Color? GetAlpha(Color lightColor) => new Color(148, 0, 211, projectile.alpha); + public override Color? GetAlpha(Color lightColor) => new Color(148, 0, 211, projectile.alpha); - public override bool CanDamage() => false; + public override bool CanDamage() => false; - public override void Kill(int timeLeft) - { - for (int i = 0; i < 10; i++) - { - Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f)); - int dust = Dust.NewDust(projectile.Center, 1, 1, 66, dspeed.X, dspeed.Y, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f); - Main.dust[dust].noGravity = true; - } - } - } + public override void Kill(int timeLeft) + { + for (int i = 0; i < 10; i++) + { + Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f)); + int dust = Dust.NewDust(projectile.Center, 1, 1, 66, dspeed.X, dspeed.Y, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f); + Main.dust[dust].noGravity = true; + } + } + } } diff --git a/Projectiles/Summon/MagicUmbrella.cs b/Projectiles/Summon/MagicUmbrella.cs index 1ffd4063b4..e3e5a930e2 100644 --- a/Projectiles/Summon/MagicUmbrella.cs +++ b/Projectiles/Summon/MagicUmbrella.cs @@ -6,9 +6,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class MagicUmbrella : ModProjectile + public class MagicUmbrella : ModProjectile { - private int counter = 0; + private int counter = 0; public override void SetStaticDefaults() { DisplayName.SetDefault("Umbrella"); @@ -31,24 +31,24 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.alpha = 255; + projectile.alpha = 255; } public override void AI() { projectile.rotation += 0.075f; - projectile.alpha -= 50; - counter++; - if (counter == 30) - { - projectile.netUpdate = true; - } - else if (counter < 30) - { - return; - } + projectile.alpha -= 50; + counter++; + if (counter == 30) + { + projectile.netUpdate = true; + } + else if (counter < 30) + { + return; + } - projectile.ChargingMinionAI(MagicHat.Range, 1600f, 2200f, 150f, 0, 40f, 9f, 4f, new Vector2(0f, -60f), 40f, 9f, true, true); + projectile.ChargingMinionAI(MagicHat.Range, 1600f, 2200f, 150f, 0, 40f, 9f, 4f, new Vector2(0f, -60f), 40f, 9f, true, true); } public override Color? GetAlpha(Color lightColor) => new Color(75, 255, 255, projectile.alpha); @@ -71,28 +71,28 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (Main.rand.NextBool(4)) - { - SpawnBaseballBats(target.Center); - } + if (Main.rand.NextBool(4)) + { + SpawnBaseballBats(target.Center); + } } public override void OnHitPvp(Player target, int damage, bool crit) { - if (Main.rand.NextBool(4)) - { - SpawnBaseballBats(target.Center); - } + if (Main.rand.NextBool(4)) + { + SpawnBaseballBats(target.Center); + } } - private void SpawnBaseballBats(Vector2 targetPos) - { + private void SpawnBaseballBats(Vector2 targetPos) + { for (int n = 0; n < Main.rand.Next(1, 3); n++) //1 to 2 baseball bats { float x = targetPos.X + Main.rand.Next(-400, 401); float y = targetPos.Y - Main.rand.Next(500, 801); Vector2 source = new Vector2(x, y); - Vector2 velocity = targetPos - source; + Vector2 velocity = targetPos - source; velocity.X += Main.rand.Next(-100, 101); float speed = 29f; float targetDist = velocity.Length(); @@ -101,6 +101,6 @@ namespace CalamityMod.Projectiles.Summon velocity.Y *= targetDist; Projectile.NewProjectile(source, velocity, ModContent.ProjectileType(), (int)(projectile.damage * Main.rand.NextFloat(0.3f, 0.6f)), projectile.knockBack * Main.rand.NextFloat(0.7f, 1f), projectile.owner, 0f, 0f); } - } + } } } diff --git a/Projectiles/Summon/MechwormTeleportRift.cs b/Projectiles/Summon/MechwormTeleportRift.cs index f8c8eb02d3..dbc46cb77d 100644 --- a/Projectiles/Summon/MechwormTeleportRift.cs +++ b/Projectiles/Summon/MechwormTeleportRift.cs @@ -11,89 +11,89 @@ namespace CalamityMod.Projectiles.Summon { public override string Texture => "CalamityMod/Projectiles/StarProj"; - public ref float GeneralRotationalOffset => ref projectile.ai[0]; + public ref float GeneralRotationalOffset => ref projectile.ai[0]; public override void SetStaticDefaults() { DisplayName.SetDefault("Rift"); - ProjectileID.Sets.NeedsUUID[projectile.type] = true; + ProjectileID.Sets.NeedsUUID[projectile.type] = true; } public override void SetDefaults() { projectile.width = projectile.height = 170; - projectile.scale = 0.25f; + projectile.scale = 0.25f; projectile.friendly = true; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.Opacity = 0f; + projectile.Opacity = 0f; projectile.penetrate = -1; projectile.timeLeft = 45; - projectile.netImportant = true; + projectile.netImportant = true; } public override void AI() { - if (projectile.ai[0] == 0f) - projectile.ai[0] = 45f; + if (projectile.ai[0] == 0f) + projectile.ai[0] = 45f; - GeneralRotationalOffset += MathHelper.Pi / 8f; - projectile.Opacity = MathHelper.Clamp(GeneralRotationalOffset, 0f, 1f); + GeneralRotationalOffset += MathHelper.Pi / 8f; + projectile.Opacity = MathHelper.Clamp(GeneralRotationalOffset, 0f, 1f); - if (projectile.Opacity == 1f && Main.rand.NextBool(15)) - { - Dust dust = Dust.NewDustDirect(projectile.Center, 0, 0, 267, 0f, 0f, 100, new Color(150, 100, 255, 255), 1f); - dust.velocity.X = 0f; - dust.noGravity = true; - dust.position = projectile.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(4f, 20f); - dust.fadeIn = 1f; - dust.scale = 0.5f; - } - } + if (projectile.Opacity == 1f && Main.rand.NextBool(15)) + { + Dust dust = Dust.NewDustDirect(projectile.Center, 0, 0, 267, 0f, 0f, 100, new Color(150, 100, 255, 255), 1f); + dust.velocity.X = 0f; + dust.noGravity = true; + dust.position = projectile.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(4f, 20f); + dust.fadeIn = 1f; + dust.scale = 0.5f; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - float currentFade = Utils.InverseLerp(0f, 5f, projectile.timeLeft, true) * Utils.InverseLerp(projectile.ai[0], projectile.ai[0] - 5f, projectile.timeLeft, true); - currentFade *= (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f * MathHelper.Pi * 3f)) * 0.8f; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + float currentFade = Utils.InverseLerp(0f, 5f, projectile.timeLeft, true) * Utils.InverseLerp(projectile.ai[0], projectile.ai[0] - 5f, projectile.timeLeft, true); + currentFade *= (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f * MathHelper.Pi * 3f)) * 0.8f; - Texture2D texture = Main.projectileTexture[projectile.type]; - Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - Color baseColor = new Color(150, 100, 255, 255) * projectile.Opacity; - baseColor *= 0.5f; - baseColor.A = 0; - Color colorA = baseColor; - Color colorB = baseColor * 0.5f; - colorA *= currentFade; - colorB *= currentFade; - Vector2 origin = texture.Size() / 2f; - Vector2 scale = new Vector2(3f, 7f) * projectile.Opacity * projectile.scale * currentFade; + Texture2D texture = Main.projectileTexture[projectile.type]; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Color baseColor = new Color(150, 100, 255, 255) * projectile.Opacity; + baseColor *= 0.5f; + baseColor.A = 0; + Color colorA = baseColor; + Color colorB = baseColor * 0.5f; + colorA *= currentFade; + colorB *= currentFade; + Vector2 origin = texture.Size() / 2f; + Vector2 scale = new Vector2(3f, 7f) * projectile.Opacity * projectile.scale * currentFade; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, 0f, origin, scale, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver2, origin, scale * 0.8f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, 0f, origin, scale * 0.8f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, 0f, origin, scale, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver2, origin, scale * 0.8f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, 0f, origin, scale * 0.8f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2 + GeneralRotationalOffset * 0.25f, origin, scale, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, GeneralRotationalOffset * 0.25f, origin, scale, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver2 + GeneralRotationalOffset * 0.5f, origin, scale * 0.8f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, GeneralRotationalOffset * 0.5f, origin, scale * 0.8f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2 + GeneralRotationalOffset * 0.25f, origin, scale, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, GeneralRotationalOffset * 0.25f, origin, scale, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver2 + GeneralRotationalOffset * 0.5f, origin, scale * 0.8f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, GeneralRotationalOffset * 0.5f, origin, scale * 0.8f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4, origin, scale * 0.6f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f, origin, scale * 0.6f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4, origin, scale * 0.4f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f, origin, scale * 0.4f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4, origin, scale * 0.4f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f, origin, scale * 0.4f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 + GeneralRotationalOffset * 0.75f, origin, scale * 0.6f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f + GeneralRotationalOffset * 0.75f, origin, scale * 0.6f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 + GeneralRotationalOffset, origin, scale * 0.4f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f + GeneralRotationalOffset, origin, scale * 0.4f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 + GeneralRotationalOffset * 0.75f, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f + GeneralRotationalOffset * 0.75f, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 + GeneralRotationalOffset, origin, scale * 0.4f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f + GeneralRotationalOffset, origin, scale * 0.4f, spriteEffects, 0); - return false; - } + return false; + } - public override bool CanDamage() => false; - } + public override bool CanDamage() => false; + } } diff --git a/Projectiles/Summon/MiniGuardianAttack.cs b/Projectiles/Summon/MiniGuardianAttack.cs index e7f860c9ff..99078e2af6 100644 --- a/Projectiles/Summon/MiniGuardianAttack.cs +++ b/Projectiles/Summon/MiniGuardianAttack.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class MiniGuardianAttack : ModProjectile + public class MiniGuardianAttack : ModProjectile { private int ai = 3; private void updateDamage(int type) @@ -242,7 +242,7 @@ namespace CalamityMod.Projectiles.Summon projectile.active = false; return; } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); float num535 = projectile.position.X; float num536 = projectile.position.Y; float num537 = 3000f; @@ -324,15 +324,15 @@ namespace CalamityMod.Projectiles.Summon } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (Main.player[projectile.owner].Calamity().angelicAlliance) - target.AddBuff(ModContent.BuffType(), 300); - } + { + if (Main.player[projectile.owner].Calamity().angelicAlliance) + target.AddBuff(ModContent.BuffType(), 300); + } public override void OnHitPvp(Player target, int damage, bool crit) - { - if (Main.player[projectile.owner].Calamity().angelicAlliance) - target.AddBuff(ModContent.BuffType(), 300); - } + { + if (Main.player[projectile.owner].Calamity().angelicAlliance) + target.AddBuff(ModContent.BuffType(), 300); + } } } diff --git a/Projectiles/Summon/MiniGuardianDefense.cs b/Projectiles/Summon/MiniGuardianDefense.cs index 3a1109a361..77fba7a6ca 100644 --- a/Projectiles/Summon/MiniGuardianDefense.cs +++ b/Projectiles/Summon/MiniGuardianDefense.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class MiniGuardianDefense : ModProjectile + public class MiniGuardianDefense : ModProjectile { private int ai = 3; private void updateDamage(int type) @@ -212,7 +212,7 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { if (Main.player[projectile.owner].Calamity().profanedCrystalBuffs && !Main.player[projectile.owner].Calamity().endoCooper) - { + { CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } @@ -241,7 +241,7 @@ namespace CalamityMod.Projectiles.Summon projectile.active = false; return; } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); float num535 = projectile.position.X; float num536 = projectile.position.Y; float num537 = 3000f; @@ -321,15 +321,15 @@ namespace CalamityMod.Projectiles.Summon } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (Main.player[projectile.owner].Calamity().angelicAlliance) - target.AddBuff(ModContent.BuffType(), 300); - } + { + if (Main.player[projectile.owner].Calamity().angelicAlliance) + target.AddBuff(ModContent.BuffType(), 300); + } public override void OnHitPvp(Player target, int damage, bool crit) - { - if (Main.player[projectile.owner].Calamity().angelicAlliance) - target.AddBuff(ModContent.BuffType(), 300); - } + { + if (Main.player[projectile.owner].Calamity().angelicAlliance) + target.AddBuff(ModContent.BuffType(), 300); + } } } diff --git a/Projectiles/Summon/MiniGuardianHealer.cs b/Projectiles/Summon/MiniGuardianHealer.cs index 35577702b1..5a0348f571 100644 --- a/Projectiles/Summon/MiniGuardianHealer.cs +++ b/Projectiles/Summon/MiniGuardianHealer.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Summon projectile.active = false; return; } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); Player projOwner = Main.player[projectile.owner]; float num16 = 0.5f; projectile.tileCollide = false; diff --git a/Projectiles/Summon/MiniSandShark.cs b/Projectiles/Summon/MiniSandShark.cs index a48187bf90..5c50869d16 100644 --- a/Projectiles/Summon/MiniSandShark.cs +++ b/Projectiles/Summon/MiniSandShark.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Summon projectile.alpha = 255; projectile.minionSlots = 0f; projectile.extraUpdates = 1; - projectile.timeLeft = 300; + projectile.timeLeft = 300; } public override void AI() @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage /= 2; + projectile.damage /= 2; projectile.Damage(); Main.PlaySound(SoundID.Item14, projectile.position); int num226 = 36; diff --git a/Projectiles/Summon/MortalityBeam.cs b/Projectiles/Summon/MortalityBeam.cs index 3c31886965..9e9cef2f94 100644 --- a/Projectiles/Summon/MortalityBeam.cs +++ b/Projectiles/Summon/MortalityBeam.cs @@ -58,10 +58,10 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Summon/MortalityBolt.cs b/Projectiles/Summon/MortalityBolt.cs index 8ab4edc3c0..4deacbba47 100644 --- a/Projectiles/Summon/MortalityBolt.cs +++ b/Projectiles/Summon/MortalityBolt.cs @@ -45,10 +45,10 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(BuffID.Frostburn, 90); - target.AddBuff(ModContent.BuffType(), 90); - } + target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 90); + target.AddBuff(ModContent.BuffType(), 90); + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Summon/OldDukeHeadCorpse.cs b/Projectiles/Summon/OldDukeHeadCorpse.cs index 4dc831be45..ddd06e2ad9 100644 --- a/Projectiles/Summon/OldDukeHeadCorpse.cs +++ b/Projectiles/Summon/OldDukeHeadCorpse.cs @@ -72,7 +72,7 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity.Y = 10f; } - projectile.StickToTiles(false, false); + projectile.StickToTiles(false, false); } public override bool CanDamage() => false; diff --git a/Projectiles/Summon/OldDukeSharkVomit.cs b/Projectiles/Summon/OldDukeSharkVomit.cs index 83bb554838..314695da1a 100644 --- a/Projectiles/Summon/OldDukeSharkVomit.cs +++ b/Projectiles/Summon/OldDukeSharkVomit.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Summon //Homing if (projectile.ai[0] > 20f) HomingAI(); - } + } private void HomingAI() { diff --git a/Projectiles/Summon/PerditionBeacon.cs b/Projectiles/Summon/PerditionBeacon.cs index 1b0756a967..67c4dce427 100644 --- a/Projectiles/Summon/PerditionBeacon.cs +++ b/Projectiles/Summon/PerditionBeacon.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (projectile.localAI[0] == 0f) { diff --git a/Projectiles/Summon/PhantomGuy.cs b/Projectiles/Summon/PhantomGuy.cs index 42a83663f5..d7c8f9e9b5 100644 --- a/Projectiles/Summon/PhantomGuy.cs +++ b/Projectiles/Summon/PhantomGuy.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PhantomGuy : ModProjectile + public class PhantomGuy : ModProjectile { public override string Texture => "CalamityMod/NPCs/Polterghast/PhantomFuckYou"; @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; projectile.timeLeft *= 5; projectile.minion = true; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); float num633 = 3000f; float num634 = 3500f; float num635 = 4000f; @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Summon float num646 = Vector2.Distance(npc.Center, projectile.Center); if (!flag25 && num646 < num633) { - num633 = num646; + num633 = num646; vector46 = npc.Center; flag25 = true; } @@ -184,7 +184,7 @@ namespace CalamityMod.Projectiles.Summon } if (flag25) { - projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(vector46), 0.1f); + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(vector46), 0.1f); } else { diff --git a/Projectiles/Summon/PhantomicDagger.cs b/Projectiles/Summon/PhantomicDagger.cs index 9743ca8ffd..37539e4138 100644 --- a/Projectiles/Summon/PhantomicDagger.cs +++ b/Projectiles/Summon/PhantomicDagger.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = 1; projectile.tileCollide = false; projectile.alpha = 200; - projectile.minion = true; - } + projectile.minion = true; + } public override bool? CanHitNPC(NPC target) { @@ -50,26 +50,26 @@ namespace CalamityMod.Projectiles.Summon homing = reader.ReadBoolean(); } - // Reduce damage of projectiles if more than the cap are active - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - // Avoid touching things that you probably aren't meant to damage - if (target.defense > 999 || target.Calamity().DR >= 0.95f || target.Calamity().unbreakableDR) - return; + // Reduce damage of projectiles if more than the cap are active + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + // Avoid touching things that you probably aren't meant to damage + if (target.defense > 999 || target.Calamity().DR >= 0.95f || target.Calamity().unbreakableDR) + return; - int cap = (int)(damage * 1.05f); // Capped at 5% dr ignoring - damage = Math.Min((int)(damage * (1 / (1 - target.Calamity().DR))), cap); + int cap = (int)(damage * 1.05f); // Capped at 5% dr ignoring + damage = Math.Min((int)(damage * (1 / (1 - target.Calamity().DR))), cap); - int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; - int cap2 = 3; - int oldDamage = damage; - if (projectileCount > cap2) - { - damage -= (int)(oldDamage * ((projectileCount - cap2) * 0.05)); - if (damage < 1) - damage = 1; - } - } + int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; + int cap2 = 3; + int oldDamage = damage; + if (projectileCount > cap2) + { + damage -= (int)(oldDamage * ((projectileCount - cap2) * 0.05)); + if (damage < 1) + damage = 1; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Summon/PhantomicShield.cs b/Projectiles/Summon/PhantomicShield.cs index 5403573b15..438f62126f 100644 --- a/Projectiles/Summon/PhantomicShield.cs +++ b/Projectiles/Summon/PhantomicShield.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - class PhantomicShield : ModProjectile + class PhantomicShield : ModProjectile { public const float floatDist = 50f; diff --git a/Projectiles/Summon/PinkButterfly.cs b/Projectiles/Summon/PinkButterfly.cs index 190eff0efb..1e9334a775 100644 --- a/Projectiles/Summon/PinkButterfly.cs +++ b/Projectiles/Summon/PinkButterfly.cs @@ -92,7 +92,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); bool flag24 = false; if (flag24) { @@ -100,7 +100,7 @@ namespace CalamityMod.Projectiles.Summon } Vector2 vector46 = projectile.position; bool flag25 = false; - int targetIndex = -1; + int targetIndex = -1; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; @@ -111,7 +111,7 @@ namespace CalamityMod.Projectiles.Summon { vector46 = npc.Center; flag25 = true; - targetIndex = npc.whoAmI; + targetIndex = npc.whoAmI; } } } @@ -128,7 +128,7 @@ namespace CalamityMod.Projectiles.Summon num633 = num646; vector46 = nPC2.Center; flag25 = true; - targetIndex = num645; + targetIndex = num645; } } } diff --git a/Projectiles/Summon/PlagueBeeSmall.cs b/Projectiles/Summon/PlagueBeeSmall.cs index c288b07283..276915a556 100644 --- a/Projectiles/Summon/PlagueBeeSmall.cs +++ b/Projectiles/Summon/PlagueBeeSmall.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PlagueBeeSmall : ModProjectile + public class PlagueBeeSmall : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Rogue/PlaguenadeBee"; @@ -27,120 +27,120 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; } - public override void AI() - { - if (projectile.owner != Main.myPlayer) - projectile.Kill(); + public override void AI() + { + if (projectile.owner != Main.myPlayer) + projectile.Kill(); projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); projectile.rotation += projectile.spriteDirection * MathHelper.ToRadians(45f); - projectile.frameCounter++; - if (projectile.frameCounter >= 3) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } + projectile.frameCounter++; + if (projectile.frameCounter >= 3) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } - Vector2 center = projectile.Center; - float maxDistance = 800f; - bool homeIn = false; - projectile.ai[0] += 1f; - if (projectile.ai[0] > 30f) - { - Player player = Main.player[projectile.owner]; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false) && !npc.wet) - { - float extraDistance = (npc.width / 2) + (npc.height / 2); + Vector2 center = projectile.Center; + float maxDistance = 800f; + bool homeIn = false; + projectile.ai[0] += 1f; + if (projectile.ai[0] > 30f) + { + Player player = Main.player[projectile.owner]; + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false) && !npc.wet) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); - bool canHit = true; - if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) - { - center = npc.Center; - homeIn = true; - } - } - } - else - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - if (npc.CanBeChasedBy(projectile, false) && !npc.wet) - { - float extraDistance = (npc.width / 2) + (npc.height / 2); + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + { + center = npc.Center; + homeIn = true; + } + } + } + else + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy(projectile, false) && !npc.wet) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); - bool canHit = true; - if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) - { - center = npc.Center; - homeIn = true; - break; - } - } - } - } - } - if (!homeIn) - { - center.X = projectile.Center.X + projectile.velocity.X * 100f; - center.Y = projectile.Center.Y + projectile.velocity.Y * 100f; - } - float speed = 10f; - float velocityTweak = 0.14f; - Vector2 projPos = projectile.Center; - Vector2 velocity = center - projPos; - float targetDist = velocity.Length(); - targetDist = speed / targetDist; - velocity.X *= targetDist; - velocity.Y *= targetDist; - if (projectile.velocity.X < velocity.X) - { - projectile.velocity.X += velocityTweak; - if (projectile.velocity.X < 0f && velocity.X > 0f) - { - projectile.velocity.X += velocityTweak * 2f; - } - } - else if (projectile.velocity.X > velocity.X) - { - projectile.velocity.X -= velocityTweak; - if (projectile.velocity.X > 0f && velocity.X < 0f) - { - projectile.velocity.X -= velocityTweak * 2f; - } - } - if (projectile.velocity.Y < velocity.Y) - { - projectile.velocity.Y += velocityTweak; - if (projectile.velocity.Y < 0f && velocity.Y > 0f) - { - projectile.velocity.Y += velocityTweak * 2f; - } - } - else if (projectile.velocity.Y > velocity.Y) - { - projectile.velocity.Y -= velocityTweak; - if (projectile.velocity.Y > 0f && velocity.Y < 0f) - { - projectile.velocity.Y -= velocityTweak * 2f; - } - } - } + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + { + center = npc.Center; + homeIn = true; + break; + } + } + } + } + } + if (!homeIn) + { + center.X = projectile.Center.X + projectile.velocity.X * 100f; + center.Y = projectile.Center.Y + projectile.velocity.Y * 100f; + } + float speed = 10f; + float velocityTweak = 0.14f; + Vector2 projPos = projectile.Center; + Vector2 velocity = center - projPos; + float targetDist = velocity.Length(); + targetDist = speed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; + if (projectile.velocity.X < velocity.X) + { + projectile.velocity.X += velocityTweak; + if (projectile.velocity.X < 0f && velocity.X > 0f) + { + projectile.velocity.X += velocityTweak * 2f; + } + } + else if (projectile.velocity.X > velocity.X) + { + projectile.velocity.X -= velocityTweak; + if (projectile.velocity.X > 0f && velocity.X < 0f) + { + projectile.velocity.X -= velocityTweak * 2f; + } + } + if (projectile.velocity.Y < velocity.Y) + { + projectile.velocity.Y += velocityTweak; + if (projectile.velocity.Y < 0f && velocity.Y > 0f) + { + projectile.velocity.Y += velocityTweak * 2f; + } + } + else if (projectile.velocity.Y > velocity.Y) + { + projectile.velocity.Y -= velocityTweak; + if (projectile.velocity.Y > 0f && velocity.Y < 0f) + { + projectile.velocity.Y -= velocityTweak * 2f; + } + } + } public override bool OnTileCollide(Vector2 oldVelocity) { @@ -155,26 +155,26 @@ namespace CalamityMod.Projectiles.Summon return false; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - int frameHeight = texture.Height / Main.projFrames[projectile.type]; - int drawStart = frameHeight * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)frameHeight / 2f), projectile.scale, spriteEffects, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int frameHeight = texture.Height / Main.projFrames[projectile.type]; + int drawStart = frameHeight * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)frameHeight / 2f), projectile.scale, spriteEffects, 0f); + return false; + } - public override void Kill(int timeLeft) - { - for (int i = 0; i < 2; i++) - { - int plague = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, projectile.velocity.X, projectile.velocity.Y, 50, default, 1f); - Main.dust[plague].noGravity = true; - } - } + public override void Kill(int timeLeft) + { + for (int i = 0; i < 2; i++) + { + int plague = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, projectile.velocity.X, projectile.velocity.Y, 50, default, 1f); + Main.dust[plague].noGravity = true; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Summon/PlaguePrincess.cs b/Projectiles/Summon/PlaguePrincess.cs index 3217086e3b..bd686586fa 100644 --- a/Projectiles/Summon/PlaguePrincess.cs +++ b/Projectiles/Summon/PlaguePrincess.cs @@ -12,9 +12,9 @@ namespace CalamityMod.Projectiles.Summon public class PlaguePrincess : ModProjectile { private bool dust = true; - private int mode = 0; //0 missiles, 1 mini bees, 2 charging - private int modeCounter = 0; - private int AIint = 0; + private int mode = 0; //0 missiles, 1 mini bees, 2 charging + private int modeCounter = 0; + private int AIint = 0; public override void SetStaticDefaults() { @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.tileCollide = false; + projectile.tileCollide = false; } public override void AI() @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Summon projectile.minionSlots = projectile.ai[0]; - //bools and crap + //bools and crap bool correctMinion = projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); if (correctMinion) @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Summon } } - //dust and flexible damage + //dust and flexible damage if (dust) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Summon Main.dust[num503].velocity *= 2f; Main.dust[num503].scale *= 1.15f; } - dust = false; + dust = false; } if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { @@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.Summon projectile.damage = damage2; } - //framing + //framing projectile.frameCounter++; if (projectile.frameCounter > 6) { @@ -98,83 +98,83 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - //direction + //direction if ((double)Math.Abs(projectile.velocity.X) > 0.2) { projectile.spriteDirection = -projectile.direction; } - //Lighting + //Lighting float num = (float)Main.rand.Next(90, 111) * 0.01f; num *= Main.essScale; Lighting.AddLight(projectile.Center, 0f * num, 1.25f * num, 0f * num); - //change modes every 10 seconds - modeCounter++; - if (modeCounter >= 600) - { - modeCounter = 0; - mode++; - if (mode > 2) - mode = 0; - } + //change modes every 10 seconds + modeCounter++; + if (modeCounter >= 600) + { + modeCounter = 0; + mode++; + if (mode > 2) + mode = 0; + } - //anti sticking movement - projectile.MinionAntiClump(); - //anti-sticking also applies to the player + //anti sticking movement + projectile.MinionAntiClump(); + //anti-sticking also applies to the player float antiStickFloat = 0.05f; - if (projectile.position.X < player.position.X) - { - projectile.velocity.X -= antiStickFloat; - } - else - { - projectile.velocity.X += antiStickFloat; - } - if (projectile.position.Y < player.position.Y) - { - projectile.velocity.Y -= antiStickFloat; - } - else - { - projectile.velocity.Y += antiStickFloat; - } + if (projectile.position.X < player.position.X) + { + projectile.velocity.X -= antiStickFloat; + } + else + { + projectile.velocity.X += antiStickFloat; + } + if (projectile.position.Y < player.position.Y) + { + projectile.velocity.Y -= antiStickFloat; + } + else + { + projectile.velocity.Y += antiStickFloat; + } bool cancelAttack = false; - if (mode == 2) - { - if (AIint == 2) - { - projectile.ai[1] += 1f; - projectile.extraUpdates = 2; - if (projectile.ai[1] > 30f) - { - projectile.ai[1] = 1f; - AIint = 0; - projectile.extraUpdates = 1; - projectile.numUpdates = 0; - projectile.netUpdate = true; - } - else - { - cancelAttack = true; - } - } - else - { - projectile.extraUpdates = 1; - } - if (cancelAttack) - { - return; - } - } - if (mode == 0 || mode == 1) - { - projectile.extraUpdates = 1; - if (AIint == 2) - AIint = 0; - } + if (mode == 2) + { + if (AIint == 2) + { + projectile.ai[1] += 1f; + projectile.extraUpdates = 2; + if (projectile.ai[1] > 30f) + { + projectile.ai[1] = 1f; + AIint = 0; + projectile.extraUpdates = 1; + projectile.numUpdates = 0; + projectile.netUpdate = true; + } + else + { + cancelAttack = true; + } + } + else + { + projectile.extraUpdates = 1; + } + if (cancelAttack) + { + return; + } + } + if (mode == 0 || mode == 1) + { + projectile.extraUpdates = 1; + if (AIint == 2) + AIint = 0; + } float num633 = 1040f; float num636 = 400f; //150 @@ -212,7 +212,7 @@ namespace CalamityMod.Projectiles.Summon } } - //head back to player if too far + //head back to player if too far if (Vector2.Distance(player.Center, projectile.Center) > 1200f) { AIint = 1; @@ -236,62 +236,62 @@ namespace CalamityMod.Projectiles.Summon targetVector *= -scaleFactor3; projectile.velocity = (projectile.velocity * 40f + targetVector) / 41f; } - else if (projectile.velocity.Y > -1f) - projectile.velocity.Y -= 0.1f; + else if (projectile.velocity.Y > -1f) + projectile.velocity.Y -= 0.1f; } else //idle movement { - bool returningToPlayer = false; - if (!returningToPlayer) - { - returningToPlayer = AIint == 1; - } + bool returningToPlayer = false; + if (!returningToPlayer) + { + returningToPlayer = AIint == 1; + } - //set minion speed - float speedFloat = 5f; //6 - if (returningToPlayer) - { - speedFloat = 12f; //15 - } - Vector2 projVector = projectile.Center; - Vector2 playerVector = player.Center - projVector + new Vector2(0, -60f); //-60 - float playerDist = playerVector.Length(); - if (playerDist > 200f && speedFloat < 6.5f) //200 and 8 - { - speedFloat = 6.5f; //8 - } - if (playerDist < num636 && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - AIint = 0; - projectile.netUpdate = true; - } - if (playerDist > 2000f) //if too far, teleport to player - { - projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2); - projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - if (playerDist > 70f) - { - playerVector.Normalize(); - playerVector *= speedFloat; - projectile.velocity = (projectile.velocity * 40f + playerVector) / 41f; - } - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.18f; - projectile.velocity.Y = -0.08f; - } - } + //set minion speed + float speedFloat = 5f; //6 + if (returningToPlayer) + { + speedFloat = 12f; //15 + } + Vector2 projVector = projectile.Center; + Vector2 playerVector = player.Center - projVector + new Vector2(0, -60f); //-60 + float playerDist = playerVector.Length(); + if (playerDist > 200f && speedFloat < 6.5f) //200 and 8 + { + speedFloat = 6.5f; //8 + } + if (playerDist < num636 && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + AIint = 0; + projectile.netUpdate = true; + } + if (playerDist > 2000f) //if too far, teleport to player + { + projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2); + projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + if (playerDist > 70f) + { + playerVector.Normalize(); + playerVector *= speedFloat; + projectile.velocity = (projectile.velocity * 40f + playerVector) / 41f; + } + else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.18f; + projectile.velocity.Y = -0.08f; + } + } - //increment attack cooldown - float cooldown = 100f; - if (mode == 0) - cooldown = 200f; - else if (mode == 1) - cooldown = 110f; - else if (mode == 2) - cooldown = 80f; + //increment attack cooldown + float cooldown = 100f; + if (mode == 0) + cooldown = 200f; + else if (mode == 1) + cooldown = 110f; + else if (mode == 2) + cooldown = 80f; if (projectile.ai[1] > 0f) { @@ -304,66 +304,66 @@ namespace CalamityMod.Projectiles.Summon } if (AIint == 0) { - if (mode == 0) - { - if (targetFound && projectile.ai[1] == 0f) - { - projectile.ai[1] += 1f; - float scaleFactor4 = 14f; - int projType = ModContent.ProjectileType(); - if (Main.myPlayer == projectile.owner && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, targetLocation, 0, 0)) - { - Vector2 projVect = targetLocation - projectile.Center; - projVect.Normalize(); - projVect *= scaleFactor4; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projVect.X, projVect.Y, projType, (int)(projectile.damage * 0.6f), 0f, Main.myPlayer, 0f, 0f); - projectile.netUpdate = true; - } - } - } - else if (mode == 1) - { - if (targetFound && projectile.ai[1] == 0f) - { - projectile.ai[1] += 1f; - int smallBee = ModContent.ProjectileType(); - int bigBee = ModContent.ProjectileType(); - int projType = smallBee; - if (player.ownedProjectileCounts[bigBee] < 1 && Main.rand.NextBool(3)) - projType = bigBee; - if (Main.myPlayer == projectile.owner && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, targetLocation, 0, 0)) - { - for (int beeIndex = 0; beeIndex < (projType == bigBee ? 1 : Main.rand.Next(1,5)); beeIndex++) - { - Vector2 projVect2 = targetLocation - projectile.Center; - projVect2.Normalize(); - float SpeedX = projVect2.X + (float)Main.rand.Next(-30, 31) * 0.05f; - float SpeedY = projVect2.Y + (float)Main.rand.Next(-30, 31) * 0.05f; - int bee = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, SpeedX, SpeedY, projType, (int)(projectile.damage * 0.8f), 0f, Main.myPlayer, 0f, 0f); - if (projType == bigBee) - { - Main.projectile[bee].frame = 2; - } - projectile.netUpdate = true; - } - } - } - } - else if (mode == 2) - { - if (projectile.ai[1] == 0f && targetFound && num633 < 500f) - { - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - AIint = 2; - Vector2 targetVect = targetLocation - projectile.Center; - targetVect.Normalize(); - projectile.velocity = targetVect * 8f; - projectile.netUpdate = true; - } - } - } + if (mode == 0) + { + if (targetFound && projectile.ai[1] == 0f) + { + projectile.ai[1] += 1f; + float scaleFactor4 = 14f; + int projType = ModContent.ProjectileType(); + if (Main.myPlayer == projectile.owner && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, targetLocation, 0, 0)) + { + Vector2 projVect = targetLocation - projectile.Center; + projVect.Normalize(); + projVect *= scaleFactor4; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projVect.X, projVect.Y, projType, (int)(projectile.damage * 0.6f), 0f, Main.myPlayer, 0f, 0f); + projectile.netUpdate = true; + } + } + } + else if (mode == 1) + { + if (targetFound && projectile.ai[1] == 0f) + { + projectile.ai[1] += 1f; + int smallBee = ModContent.ProjectileType(); + int bigBee = ModContent.ProjectileType(); + int projType = smallBee; + if (player.ownedProjectileCounts[bigBee] < 1 && Main.rand.NextBool(3)) + projType = bigBee; + if (Main.myPlayer == projectile.owner && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, targetLocation, 0, 0)) + { + for (int beeIndex = 0; beeIndex < (projType == bigBee ? 1 : Main.rand.Next(1,5)); beeIndex++) + { + Vector2 projVect2 = targetLocation - projectile.Center; + projVect2.Normalize(); + float SpeedX = projVect2.X + (float)Main.rand.Next(-30, 31) * 0.05f; + float SpeedY = projVect2.Y + (float)Main.rand.Next(-30, 31) * 0.05f; + int bee = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, SpeedX, SpeedY, projType, (int)(projectile.damage * 0.8f), 0f, Main.myPlayer, 0f, 0f); + if (projType == bigBee) + { + Main.projectile[bee].frame = 2; + } + projectile.netUpdate = true; + } + } + } + } + else if (mode == 2) + { + if (projectile.ai[1] == 0f && targetFound && num633 < 500f) + { + projectile.ai[1] += 1f; + if (Main.myPlayer == projectile.owner) + { + AIint = 2; + Vector2 targetVect = targetLocation - projectile.Center; + targetVect.Normalize(); + projectile.velocity = targetVect * 8f; + projectile.netUpdate = true; + } + } + } } } diff --git a/Projectiles/Summon/PlaguebringerMK2.cs b/Projectiles/Summon/PlaguebringerMK2.cs index 77a5bf8b73..4f11fb197f 100644 --- a/Projectiles/Summon/PlaguebringerMK2.cs +++ b/Projectiles/Summon/PlaguebringerMK2.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Summon projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; projectile.localAI[0] = 1f; - } + } if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / diff --git a/Projectiles/Summon/PlaguebringerSummon.cs b/Projectiles/Summon/PlaguebringerSummon.cs index ebe12c499e..862809757a 100644 --- a/Projectiles/Summon/PlaguebringerSummon.cs +++ b/Projectiles/Summon/PlaguebringerSummon.cs @@ -10,10 +10,10 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PlaguebringerSummon : ModProjectile + public class PlaguebringerSummon : ModProjectile { - public const float auraRange = 960f; - private int auraCounter = 0; + public const float auraRange = 960f; + private int auraCounter = 0; public override void SetStaticDefaults() { DisplayName.SetDefault("Lil' Plaguebringer"); @@ -79,10 +79,10 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - if (!modPlayer.plaguebringerPatronSet) - projectile.Kill(); + if (!modPlayer.plaguebringerPatronSet) + projectile.Kill(); - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); int buffType = ModContent.BuffType(); float range = auraRange; @@ -90,23 +90,23 @@ namespace CalamityMod.Projectiles.Summon int dmg = projectile.damage; if (projectile.owner == Main.myPlayer) { - 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[buffType] && Vector2.Distance(projectile.Center, npc.Center) <= range) - { - if (npc.FindBuffIndex(buffType) == -1) - { - npc.AddBuff(buffType, 120, false); - } - if (dealDamage) - { - Projectile aura = Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, ModContent.ProjectileType(), dmg, 0f, projectile.owner, l); - if (aura.whoAmI.WithinBounds(Main.maxProjectiles)) - aura.Calamity().forceMinion = true; - } - } - } + 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[buffType] && Vector2.Distance(projectile.Center, npc.Center) <= range) + { + if (npc.FindBuffIndex(buffType) == -1) + { + npc.AddBuff(buffType, 120, false); + } + if (dealDamage) + { + Projectile aura = Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, ModContent.ProjectileType(), dmg, 0f, projectile.owner, l); + if (aura.whoAmI.WithinBounds(Main.maxProjectiles)) + aura.Calamity().forceMinion = true; + } + } + } } float passiveMvtFloat = 0.5f; @@ -118,11 +118,11 @@ namespace CalamityMod.Projectiles.Summon yDist += Main.rand.NextFloat(-10f, 20f); xDist += Main.rand.NextFloat(-10f, 20f); yDist -= 70f; - Vector2 playerVector = new Vector2(xDist, yDist); + 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 < safeDist && player.velocity.Y == 0f && projectile.position.Y + projectile.height <= player.position.Y + player.height && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) @@ -133,7 +133,7 @@ namespace CalamityMod.Projectiles.Summon } } - //Teleport to player if too far + //Teleport to player if too far if (playerDist > 2000f) { projectile.position.X = player.Center.X - projectile.width / 2; @@ -195,18 +195,18 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity.Y -= passiveMvtFloat * 2f; } } - if (projectile.velocity.X >= 0.25f) - { - projectile.direction = -1; - } - else if (projectile.velocity.X < -0.25f) - { - projectile.direction = 1; - } - //Tilting and change directions - projectile.spriteDirection = projectile.direction; - projectile.rotation = projectile.velocity.X * 0.01f; - } + if (projectile.velocity.X >= 0.25f) + { + projectile.direction = -1; + } + else if (projectile.velocity.X < -0.25f) + { + projectile.direction = 1; + } + //Tilting and change directions + projectile.spriteDirection = projectile.direction; + projectile.rotation = projectile.velocity.X * 0.01f; + } public override bool OnTileCollide(Vector2 oldVelocity) => false; diff --git a/Projectiles/Summon/PlantSeed.cs b/Projectiles/Summon/PlantSeed.cs index 590e7b5078..899f0f581d 100644 --- a/Projectiles/Summon/PlantSeed.cs +++ b/Projectiles/Summon/PlantSeed.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Summon projectile.light = 0.5f; projectile.alpha = 255; projectile.extraUpdates = 2; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.friendly = true; projectile.minion = true; projectile.minionSlots = 0f; @@ -32,19 +32,19 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 600; } - public override void AI() - { + public override void AI() + { projectile.frameCounter++; if (projectile.frameCounter > 8) { projectile.frame++; projectile.frameCounter = 0; } - if (projectile.frame >= 2) - { - projectile.frame = 0; - } - } + if (projectile.frame >= 2) + { + projectile.frame = 0; + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Summon/PlantSeedGreen.cs b/Projectiles/Summon/PlantSeedGreen.cs index 3dc4ecf87f..448873644e 100644 --- a/Projectiles/Summon/PlantSeedGreen.cs +++ b/Projectiles/Summon/PlantSeedGreen.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Summon projectile.light = 0.5f; projectile.alpha = 255; projectile.extraUpdates = 3; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.friendly = true; projectile.minion = true; projectile.minionSlots = 0f; @@ -32,19 +32,19 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 600; } - public override void AI() - { + public override void AI() + { projectile.frameCounter++; if (projectile.frameCounter > 8) { projectile.frame++; projectile.frameCounter = 0; } - if (projectile.frame >= 2) - { - projectile.frame = 0; - } - } + if (projectile.frame >= 2) + { + projectile.frame = 0; + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -55,15 +55,15 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Poisoned, 180); - if (projectile.ai[1] == 1f) - target.AddBuff(BuffID.Venom, 90); + if (projectile.ai[1] == 1f) + target.AddBuff(BuffID.Venom, 90); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(BuffID.Poisoned, 180); - if (projectile.ai[1] == 1f) - target.AddBuff(BuffID.Venom, 90); + target.AddBuff(BuffID.Poisoned, 180); + if (projectile.ai[1] == 1f) + target.AddBuff(BuffID.Venom, 90); } } } diff --git a/Projectiles/Summon/PlantSporeCloud.cs b/Projectiles/Summon/PlantSporeCloud.cs index e260a8449c..a2585bc352 100644 --- a/Projectiles/Summon/PlantSporeCloud.cs +++ b/Projectiles/Summon/PlantSporeCloud.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Projectiles.Summon { public class PlantSporeCloud : ModProjectile { - private int counter = 0; + private int counter = 0; public override void SetStaticDefaults() { @@ -35,23 +35,23 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity.Y *= 0.985f; projectile.rotation += projectile.direction * 0.05f; - if (counter % 5 == 0) - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + if (counter % 5 == 0) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - counter++; - if (counter > 300) - projectile.alpha += 5; - if (projectile.alpha >= 255) - projectile.Kill(); + counter++; + if (counter > 300) + projectile.alpha += 5; + if (projectile.alpha >= 255) + projectile.Kill(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D tex = Main.projectileTexture[projectile.type]; - if (projectile.ai[0] == 1f) - tex = ModContent.GetTexture("CalamityMod/Projectiles/Summon/PlantSporeCloud2"); - if (projectile.ai[0] == 2f) - tex = ModContent.GetTexture("CalamityMod/Projectiles/Summon/PlantSporeCloud3"); + if (projectile.ai[0] == 1f) + tex = ModContent.GetTexture("CalamityMod/Projectiles/Summon/PlantSporeCloud2"); + if (projectile.ai[0] == 2f) + tex = ModContent.GetTexture("CalamityMod/Projectiles/Summon/PlantSporeCloud3"); spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); return false; @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(BuffID.Poisoned, 180); + target.AddBuff(BuffID.Poisoned, 180); } } } diff --git a/Projectiles/Summon/PlantSummon.cs b/Projectiles/Summon/PlantSummon.cs index e2668482c8..fc807e99f6 100644 --- a/Projectiles/Summon/PlantSummon.cs +++ b/Projectiles/Summon/PlantSummon.cs @@ -8,14 +8,14 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PlantSummon : ModProjectile + public class PlantSummon : ModProjectile { - private bool initialized = false; - private bool enraged = false; - private int pinkSeed = ModContent.ProjectileType(); - private int greenSeed = ModContent.ProjectileType(); - private int thornBall = ModContent.ProjectileType(); - private int sporeClouds = ModContent.ProjectileType(); + private bool initialized = false; + private bool enraged = false; + private int pinkSeed = ModContent.ProjectileType(); + private int greenSeed = ModContent.ProjectileType(); + private int thornBall = ModContent.ProjectileType(); + private int sporeClouds = ModContent.ProjectileType(); public override void SetStaticDefaults() { @@ -41,36 +41,36 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 12; - projectile.extraUpdates = 0; + projectile.extraUpdates = 0; } public override void AI() { Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - CalamityGlobalProjectile modProj = projectile.Calamity(); + CalamityGlobalProjectile modProj = projectile.Calamity(); - if (player.statLife <= (int)(player.statLifeMax2 * 0.75)) - { - if (Main.myPlayer == projectile.owner) - { - enraged = true; - } - } - else - { - enraged = false; - projectile.extraUpdates = 0; - } + if (player.statLife <= (int)(player.statLifeMax2 * 0.75)) + { + if (Main.myPlayer == projectile.owner) + { + enraged = true; + } + } + else + { + enraged = false; + projectile.extraUpdates = 0; + } - Framing(); + Framing(); if (!initialized) { modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage; - SpawnDust(); - SpawnTentacles(); + SpawnDust(); + SpawnTentacles(); initialized = true; } if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue) @@ -96,390 +96,390 @@ namespace CalamityMod.Projectiles.Summon float range = 1000f; - //shouldn't need anti clump because there can only be one + //shouldn't need anti clump because there can only be one - if (!enraged) - { - if (projectile.ai[0] >= 2f) - projectile.ai[0] = 0f; - Vector2 targetVec = projectile.position; - bool foundTarget = false; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not - float npcDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && npcDist < (range + extraDist)) - { - range = npcDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - else - { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not - float npcDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && npcDist < (range + extraDist)) - { - range = npcDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - } + if (!enraged) + { + if (projectile.ai[0] >= 2f) + projectile.ai[0] = 0f; + Vector2 targetVec = projectile.position; + bool foundTarget = false; + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + //Calculate distance between target and the projectile to know if it's too far or not + float npcDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && npcDist < (range + extraDist)) + { + range = npcDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + else + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + //Calculate distance between target and the projectile to know if it's too far or not + float npcDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && npcDist < (range + extraDist)) + { + range = npcDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + } - CheckIfShouldReturnToPlayer(foundTarget); + CheckIfShouldReturnToPlayer(foundTarget); - if (foundTarget && projectile.ai[0] == 0f) - { - StayCertainDistFromTarget(targetVec); - } - else - { - PassiveAI(); - } + if (foundTarget && projectile.ai[0] == 0f) + { + StayCertainDistFromTarget(targetVec); + } + else + { + PassiveAI(); + } - HandleRotation(foundTarget, targetVec); + HandleRotation(foundTarget, targetVec); - IncrementAttackCounter(); - if (projectile.ai[0] == 0f) - { - float projSpeed = 6f; - int projType = Main.rand.NextBool(2) ? greenSeed : pinkSeed; - int projDmg = (int)(projectile.damage * 0.7f); - float speedMult = 1f; - if (Main.rand.NextBool(4)) - { - projType = thornBall; - } - if (projType == thornBall) - { - speedMult = 2f; - projDmg = (int)(projectile.damage * 1.2f); - } - if (projectile.ai[1] == 0f && foundTarget && range < 500f) - { - Main.PlaySound(SoundID.Item20, projectile.position); - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - Vector2 velocity = targetVec - projectile.Center; - if (projType != thornBall && Main.rand.NextBool(3)) - { - FireShotgun(velocity, 0.7f); - } - else - { - velocity.Normalize(); - velocity *= projSpeed; - velocity *= speedMult; - Projectile.NewProjectile(projectile.Center, velocity, projType, projDmg, projectile.knockBack, projectile.owner, 0f, 0f); - } - projectile.netUpdate = true; - } - } - } - } - else //enraged - { - bool charging = false; - if (projectile.ai[0] == 2f) - { - projectile.ai[1] += 1f; - projectile.extraUpdates = 1; - if (projectile.ai[1] > 30f) - { - projectile.ai[1] = 1f; - projectile.ai[0] = 0f; - projectile.extraUpdates = 0; - projectile.numUpdates = 0; - projectile.netUpdate = true; - } - else - { - charging = true; - } - } - if (charging) - { - return; - } - Vector2 targetVec = projectile.position; - bool foundTarget = false; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not - float npcDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && npcDist < (range + extraDist)) - { - range = npcDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - if (!foundTarget) - { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) - { - NPC npc = Main.npc[num645]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not - float npcDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && npcDist < (range + extraDist)) - { - range = npcDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - } + IncrementAttackCounter(); + if (projectile.ai[0] == 0f) + { + float projSpeed = 6f; + int projType = Main.rand.NextBool(2) ? greenSeed : pinkSeed; + int projDmg = (int)(projectile.damage * 0.7f); + float speedMult = 1f; + if (Main.rand.NextBool(4)) + { + projType = thornBall; + } + if (projType == thornBall) + { + speedMult = 2f; + projDmg = (int)(projectile.damage * 1.2f); + } + if (projectile.ai[1] == 0f && foundTarget && range < 500f) + { + Main.PlaySound(SoundID.Item20, projectile.position); + projectile.ai[1] += 1f; + if (Main.myPlayer == projectile.owner) + { + Vector2 velocity = targetVec - projectile.Center; + if (projType != thornBall && Main.rand.NextBool(3)) + { + FireShotgun(velocity, 0.7f); + } + else + { + velocity.Normalize(); + velocity *= projSpeed; + velocity *= speedMult; + Projectile.NewProjectile(projectile.Center, velocity, projType, projDmg, projectile.knockBack, projectile.owner, 0f, 0f); + } + projectile.netUpdate = true; + } + } + } + } + else //enraged + { + bool charging = false; + if (projectile.ai[0] == 2f) + { + projectile.ai[1] += 1f; + projectile.extraUpdates = 1; + if (projectile.ai[1] > 30f) + { + projectile.ai[1] = 1f; + projectile.ai[0] = 0f; + projectile.extraUpdates = 0; + projectile.numUpdates = 0; + projectile.netUpdate = true; + } + else + { + charging = true; + } + } + if (charging) + { + return; + } + Vector2 targetVec = projectile.position; + bool foundTarget = false; + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + //Calculate distance between target and the projectile to know if it's too far or not + float npcDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && npcDist < (range + extraDist)) + { + range = npcDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + if (!foundTarget) + { + for (int num645 = 0; num645 < Main.maxNPCs; num645++) + { + NPC npc = Main.npc[num645]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + //Calculate distance between target and the projectile to know if it's too far or not + float npcDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && npcDist < (range + extraDist)) + { + range = npcDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + } - HandleRotation(foundTarget, targetVec); + HandleRotation(foundTarget, targetVec); - CheckIfShouldReturnToPlayer(foundTarget); + CheckIfShouldReturnToPlayer(foundTarget); - if (foundTarget && projectile.ai[0] == 0f) - { - StayCertainDistFromTarget(targetVec); - } - else - { - PassiveAI(); - } - IncrementAttackCounter(); - if (projectile.ai[0] == 0f) - { - if (projectile.ai[1] == 0f && foundTarget && range < 500f) - { - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - projectile.ai[0] = 2f; - Vector2 whereIsTarget = targetVec - projectile.Center; - whereIsTarget.Normalize(); - int projType = thornBall; - if (Main.rand.NextBool(2)) - { - Vector2 projVelocity = whereIsTarget * 2f; - int projDmg = (int)(projectile.damage * 1.5f); - Projectile.NewProjectile(projectile.Center, projVelocity, projType, projDmg, projectile.knockBack, projectile.owner, 0f, 1f); - } - if (Main.rand.NextBool(3)) - { - FireShotgun(whereIsTarget, 0.8f); - } - float chargeSpeed = 8f; - projectile.velocity = whereIsTarget * chargeSpeed; - projectile.netUpdate = true; - } - } - } - } + if (foundTarget && projectile.ai[0] == 0f) + { + StayCertainDistFromTarget(targetVec); + } + else + { + PassiveAI(); + } + IncrementAttackCounter(); + if (projectile.ai[0] == 0f) + { + if (projectile.ai[1] == 0f && foundTarget && range < 500f) + { + projectile.ai[1] += 1f; + if (Main.myPlayer == projectile.owner) + { + projectile.ai[0] = 2f; + Vector2 whereIsTarget = targetVec - projectile.Center; + whereIsTarget.Normalize(); + int projType = thornBall; + if (Main.rand.NextBool(2)) + { + Vector2 projVelocity = whereIsTarget * 2f; + int projDmg = (int)(projectile.damage * 1.5f); + Projectile.NewProjectile(projectile.Center, projVelocity, projType, projDmg, projectile.knockBack, projectile.owner, 0f, 1f); + } + if (Main.rand.NextBool(3)) + { + FireShotgun(whereIsTarget, 0.8f); + } + float chargeSpeed = 8f; + projectile.velocity = whereIsTarget * chargeSpeed; + projectile.netUpdate = true; + } + } + } + } } - private void CheckIfShouldReturnToPlayer(bool targetLocated) - { - Player player = Main.player[projectile.owner]; - float separationAnxietyDist = 1300f; - if (targetLocated) - { - separationAnxietyDist = 2600f; - } - if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } - } + private void CheckIfShouldReturnToPlayer(bool targetLocated) + { + Player player = Main.player[projectile.owner]; + float separationAnxietyDist = 1300f; + if (targetLocated) + { + separationAnxietyDist = 2600f; + } + if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } + } - private void StayCertainDistFromTarget(Vector2 whereIsTarget) - { - Vector2 targetPos = whereIsTarget - projectile.Center; - float targetDist = targetPos.Length(); - targetPos.Normalize(); - if (targetDist > 200f) - { - float speedMult = 8f; - targetPos *= speedMult; - projectile.velocity = (projectile.velocity * 40f + targetPos) / 41f; - } - else - { - float reverseSpeedMult = 4f; - targetPos *= -reverseSpeedMult; - projectile.velocity = (projectile.velocity * 40f + targetPos) / 41f; - } - } + private void StayCertainDistFromTarget(Vector2 whereIsTarget) + { + Vector2 targetPos = whereIsTarget - projectile.Center; + float targetDist = targetPos.Length(); + targetPos.Normalize(); + if (targetDist > 200f) + { + float speedMult = 8f; + targetPos *= speedMult; + projectile.velocity = (projectile.velocity * 40f + targetPos) / 41f; + } + else + { + float reverseSpeedMult = 4f; + targetPos *= -reverseSpeedMult; + projectile.velocity = (projectile.velocity * 40f + targetPos) / 41f; + } + } - private void PassiveAI() - { - Player player = Main.player[projectile.owner]; - bool returningToPlayer = false; - if (!returningToPlayer) - { - returningToPlayer = projectile.ai[0] == 1f; - } - float returnSpeed = 12f; - if (returningToPlayer) - { - returnSpeed = 30f; - } - Vector2 playerVec = player.Center - projectile.Center + new Vector2(0f, -120f); - float playerDist = playerVec.Length(); - if (playerDist > 200f && returnSpeed < 16f) - { - returnSpeed = 16f; - } - if (playerDist < 600f && returningToPlayer) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - if (playerDist > 70f) - { - playerVec.Normalize(); - playerVec *= returnSpeed; - projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f; - } - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - } + private void PassiveAI() + { + Player player = Main.player[projectile.owner]; + bool returningToPlayer = false; + if (!returningToPlayer) + { + returningToPlayer = projectile.ai[0] == 1f; + } + float returnSpeed = 12f; + if (returningToPlayer) + { + returnSpeed = 30f; + } + Vector2 playerVec = player.Center - projectile.Center + new Vector2(0f, -120f); + float playerDist = playerVec.Length(); + if (playerDist > 200f && returnSpeed < 16f) + { + returnSpeed = 16f; + } + if (playerDist < 600f && returningToPlayer) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - (float)(projectile.width / 2); + projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + if (playerDist > 70f) + { + playerVec.Normalize(); + playerVec *= returnSpeed; + projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f; + } + else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.15f; + projectile.velocity.Y = -0.05f; + } + } - private void IncrementAttackCounter() - { - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += (float)Main.rand.Next(1, 4); - } - if (projectile.ai[1] > 40f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - } + private void IncrementAttackCounter() + { + if (projectile.ai[1] > 0f) + { + projectile.ai[1] += (float)Main.rand.Next(1, 4); + } + if (projectile.ai[1] > 40f) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + } - private void FireShotgun(Vector2 whereIsTarget, float attackMult) - { - whereIsTarget.Normalize(); - float projSpeedMult = 3f; - int projType = pinkSeed; - if (Main.rand.NextBool(2) && CalamityUtils.CountProjectiles(sporeClouds) < 9) - { - projType = sporeClouds; - projSpeedMult = 10f; - } - else - { - projType = Main.rand.NextBool(2) ? greenSeed : pinkSeed; - } - int projDmg = (int)(projectile.damage * attackMult); - Vector2 projVelocity = whereIsTarget * projSpeedMult; - for (int i = -8; i <= 8; i += 8) - { - Vector2 perturbedSpeed = projVelocity.RotatedBy(MathHelper.ToRadians(i)); - Projectile.NewProjectile(projectile.Center, perturbedSpeed, projType, projDmg, projectile.knockBack * attackMult, projectile.owner, Main.rand.Next(3), 1f); - } - } + private void FireShotgun(Vector2 whereIsTarget, float attackMult) + { + whereIsTarget.Normalize(); + float projSpeedMult = 3f; + int projType = pinkSeed; + if (Main.rand.NextBool(2) && CalamityUtils.CountProjectiles(sporeClouds) < 9) + { + projType = sporeClouds; + projSpeedMult = 10f; + } + else + { + projType = Main.rand.NextBool(2) ? greenSeed : pinkSeed; + } + int projDmg = (int)(projectile.damage * attackMult); + Vector2 projVelocity = whereIsTarget * projSpeedMult; + for (int i = -8; i <= 8; i += 8) + { + Vector2 perturbedSpeed = projVelocity.RotatedBy(MathHelper.ToRadians(i)); + Projectile.NewProjectile(projectile.Center, perturbedSpeed, projType, projDmg, projectile.knockBack * attackMult, projectile.owner, Main.rand.Next(3), 1f); + } + } - private void HandleRotation(bool targetFound, Vector2 whereIsTarget) - { - if (targetFound && !enraged) - { - projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(whereIsTarget) + MathHelper.Pi, 0.1f); - } - else - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; - } - } + private void HandleRotation(bool targetFound, Vector2 whereIsTarget) + { + if (targetFound && !enraged) + { + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(whereIsTarget) + MathHelper.Pi, 0.1f); + } + else + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; + } + } - private void Framing() - { + private void Framing() + { if (projectile.frameCounter++ % 8 == 7) { projectile.frame++; } - if (!enraged) - { - if (projectile.frame >= 4) - { - projectile.frame = 0; - } - } - else - { - if (projectile.frame >= 8) - { - projectile.frame = 4; - } - } - } + if (!enraged) + { + if (projectile.frame >= 4) + { + projectile.frame = 0; + } + } + else + { + if (projectile.frame >= 8) + { + projectile.frame = 4; + } + } + } - private void SpawnDust() - { - int dustAmt = 36; - for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) - { - Vector2 source = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; - source = source.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; - Vector2 dustVel = source - projectile.Center; - int terra = Dust.NewDust(source + dustVel, 0, 0, 107, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); - Main.dust[terra].noGravity = true; - Main.dust[terra].velocity = dustVel; - } - } + private void SpawnDust() + { + int dustAmt = 36; + for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) + { + Vector2 source = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; + source = source.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; + Vector2 dustVel = source - projectile.Center; + int terra = Dust.NewDust(source + dustVel, 0, 0, 107, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); + Main.dust[terra].noGravity = true; + Main.dust[terra].velocity = dustVel; + } + } - private void SpawnTentacles() - { - if (projectile.owner == Main.myPlayer) - { - int tentacleAmt = 6; - for (int tentacleIndex = 0; tentacleIndex < tentacleAmt; tentacleIndex++) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, tentacleIndex, Projectile.GetByUUID(projectile.owner, projectile.whoAmI)); - } - } - } + private void SpawnTentacles() + { + if (projectile.owner == Main.myPlayer) + { + int tentacleAmt = 6; + for (int tentacleIndex = 0; tentacleIndex < tentacleAmt; tentacleIndex++) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, tentacleIndex, Projectile.GetByUUID(projectile.owner, projectile.whoAmI)); + } + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Poisoned, 180); - target.AddBuff(BuffID.Venom, 90); + target.AddBuff(BuffID.Venom, 90); } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(BuffID.Poisoned, 180); - target.AddBuff(BuffID.Venom, 90); + target.AddBuff(BuffID.Venom, 90); } public override bool CanDamage() => enraged; @@ -489,12 +489,12 @@ namespace CalamityMod.Projectiles.Summon Texture2D texture = Main.projectileTexture[projectile.type]; int height = texture.Height / Main.projFrames[projectile.type]; int frameHeight = height * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); - return false; + return false; } } } diff --git a/Projectiles/Summon/PlantTentacle.cs b/Projectiles/Summon/PlantTentacle.cs index 6b34985a44..82b94dc403 100644 --- a/Projectiles/Summon/PlantTentacle.cs +++ b/Projectiles/Summon/PlantTentacle.cs @@ -7,11 +7,11 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PlantTentacle : ModProjectile + public class PlantTentacle : ModProjectile { - private bool initialized = false; - private int counter = 0; - private float desiredDistance = 150f; + private bool initialized = false; + private int counter = 0; + private float desiredDistance = 150f; public override void SetStaticDefaults() { @@ -67,8 +67,8 @@ namespace CalamityMod.Projectiles.Summon { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - initialized = true; - } + initialized = true; + } if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / @@ -76,73 +76,73 @@ namespace CalamityMod.Projectiles.Summon projectile.damage = trueDamage; } - if (player.Calamity().plantera) - { - projectile.timeLeft = 2; - } + if (player.Calamity().plantera) + { + projectile.timeLeft = 2; + } - projectile.rotation = (projectile.Center - hostPlant.Center).ToRotation() + MathHelper.Pi; + projectile.rotation = (projectile.Center - hostPlant.Center).ToRotation() + MathHelper.Pi; - projectile.MinionAntiClump(1f); + projectile.MinionAntiClump(1f); - counter++; - if (counter % 30 == 0) //changes every half second - { - desiredDistance = Main.rand.NextFloat(175f, 225f); - } - Vector2 targetPos = hostPlant.Center - projectile.Center; - float targetDist = targetPos.Length(); - targetPos.Normalize(); - if (targetDist > desiredDistance) - { - float speedMult = 10f; - speedMult += (targetDist - desiredDistance) * 0.2f; //+0.2f for every 1f away from the desired distance - targetPos *= speedMult; - projectile.velocity = (projectile.velocity * 40f + targetPos) / 41f; - } - else - { - float reverseSpeedMult = 5f; - targetPos *= -reverseSpeedMult; - projectile.velocity = (projectile.velocity * 40f + targetPos) / 41f; - } + counter++; + if (counter % 30 == 0) //changes every half second + { + desiredDistance = Main.rand.NextFloat(175f, 225f); + } + Vector2 targetPos = hostPlant.Center - projectile.Center; + float targetDist = targetPos.Length(); + targetPos.Normalize(); + if (targetDist > desiredDistance) + { + float speedMult = 10f; + speedMult += (targetDist - desiredDistance) * 0.2f; //+0.2f for every 1f away from the desired distance + targetPos *= speedMult; + projectile.velocity = (projectile.velocity * 40f + targetPos) / 41f; + } + else + { + float reverseSpeedMult = 5f; + targetPos *= -reverseSpeedMult; + projectile.velocity = (projectile.velocity * 40f + targetPos) / 41f; + } - if (targetDist > 2000f) - { - projectile.position.X = hostPlant.Center.X - (float)(projectile.width / 2); - projectile.position.Y = hostPlant.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } + if (targetDist > 2000f) + { + projectile.position.X = hostPlant.Center.X - (float)(projectile.width / 2); + projectile.position.Y = hostPlant.Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } - if (projectile.ai[0] >= 3f) - { - if (hostPlant.Center.X - projectile.Center.X > 0) - { - projectile.velocity.X += 0.05f; - } - } - else - { - if (hostPlant.Center.X - projectile.Center.X < 0) - { - projectile.velocity.X -= 0.05f; - } - } + if (projectile.ai[0] >= 3f) + { + if (hostPlant.Center.X - projectile.Center.X > 0) + { + projectile.velocity.X += 0.05f; + } + } + else + { + if (hostPlant.Center.X - projectile.Center.X < 0) + { + projectile.velocity.X -= 0.05f; + } + } - if (projectile.ai[0] % 2f == 0f) - { - if (hostPlant.Center.Y - projectile.Center.Y > 0) - { - projectile.velocity.Y += 0.05f; - } - } - else - { - if (hostPlant.Center.Y - projectile.Center.Y < 0) - { - projectile.velocity.Y -= 0.05f; - } - } + if (projectile.ai[0] % 2f == 0f) + { + if (hostPlant.Center.Y - projectile.Center.Y > 0) + { + projectile.velocity.Y += 0.05f; + } + } + else + { + if (hostPlant.Center.Y - projectile.Center.Y < 0) + { + projectile.velocity.Y -= 0.05f; + } + } } public override void Kill(int timeLeft) @@ -203,10 +203,10 @@ namespace CalamityMod.Projectiles.Summon return true; } - //It draws the host plant in here in order to have it draw over the tentacles + //It draws the host plant in here in order to have it draw over the tentacles public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) { - //Only 1 tentacle needs to draw this, the last one spawned because it's latest in the projectile array. + //Only 1 tentacle needs to draw this, the last one spawned because it's latest in the projectile array. if (projectile.ai[0] < 5) { return; @@ -227,10 +227,10 @@ namespace CalamityMod.Projectiles.Summon Texture2D texture = Main.projectileTexture[hostPlant.type]; int height = texture.Height / Main.projFrames[hostPlant.type]; int frameHeight = height * hostPlant.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (hostPlant.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - Color color = Lighting.GetColor((int)hostPlant.Center.X / 16, (int)(hostPlant.Center.Y / 16f)); + SpriteEffects spriteEffects = SpriteEffects.None; + if (hostPlant.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + Color color = Lighting.GetColor((int)hostPlant.Center.X / 16, (int)(hostPlant.Center.Y / 16f)); Main.spriteBatch.Draw(texture, hostPlant.Center - Main.screenPosition + new Vector2(0f, hostPlant.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), color, hostPlant.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), hostPlant.scale, spriteEffects, 0f); } @@ -238,13 +238,13 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Poisoned, 120); - target.AddBuff(BuffID.Venom, 60); + target.AddBuff(BuffID.Venom, 60); } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(BuffID.Poisoned, 120); - target.AddBuff(BuffID.Venom, 60); + target.AddBuff(BuffID.Venom, 60); } } } diff --git a/Projectiles/Summon/PlantThornBall.cs b/Projectiles/Summon/PlantThornBall.cs index ea3d551358..6008721bce 100644 --- a/Projectiles/Summon/PlantThornBall.cs +++ b/Projectiles/Summon/PlantThornBall.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PlantThornBall : ModProjectile + public class PlantThornBall : ModProjectile { public override void SetStaticDefaults() { @@ -21,10 +21,10 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = 3; projectile.timeLeft = 300; projectile.minion = true; - projectile.aiStyle = 14; + projectile.aiStyle = 14; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; } public override void AI() @@ -32,34 +32,34 @@ namespace CalamityMod.Projectiles.Summon if (Main.rand.NextBool(12)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 44, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } - } + } + } public override bool OnTileCollide(Vector2 oldVelocity) { - if (projectile.velocity.X != oldVelocity.X) - { - projectile.velocity.X = -oldVelocity.X * 1.001f; - } - if (projectile.velocity.Y != oldVelocity.Y) - { - projectile.velocity.Y = -oldVelocity.Y * 1.001f; - } + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X * 1.001f; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y * 1.001f; + } return false; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(BuffID.Poisoned, 180); - if (projectile.ai[1] == 1f) - target.AddBuff(BuffID.Venom, 90); + target.AddBuff(BuffID.Poisoned, 180); + if (projectile.ai[1] == 1f) + target.AddBuff(BuffID.Venom, 90); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(BuffID.Poisoned, 180); - if (projectile.ai[1] == 1f) - target.AddBuff(BuffID.Venom, 90); + target.AddBuff(BuffID.Poisoned, 180); + if (projectile.ai[1] == 1f) + target.AddBuff(BuffID.Venom, 90); } } } diff --git a/Projectiles/Summon/PlateProjectile.cs b/Projectiles/Summon/PlateProjectile.cs index 27f4332fd2..47685f3aec 100644 --- a/Projectiles/Summon/PlateProjectile.cs +++ b/Projectiles/Summon/PlateProjectile.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; using Microsoft.Xna.Framework; namespace CalamityMod.Projectiles.Summon { - public class PlateProjectile : ModProjectile + public class PlateProjectile : ModProjectile { public override void SetStaticDefaults() { @@ -29,16 +29,16 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity.X *= 0.9995f; projectile.velocity.Y = projectile.velocity.Y + 0.01f; projectile.rotation -= MathHelper.ToRadians(90) * projectile.direction; - projectile.frameCounter++; - if (projectile.frameCounter > 3) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= 5) - { - projectile.frame = 0; - } + projectile.frameCounter++; + if (projectile.frameCounter > 3) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 5) + { + projectile.frame = 0; + } } public override void Kill(int timeLeft) @@ -51,8 +51,8 @@ namespace CalamityMod.Projectiles.Summon float SpeedX = -projectile.velocity.X * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f; float SpeedY = -projectile.velocity.Y * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f; int shard = Projectile.NewProjectile(projectile.Center.X + SpeedX, projectile.Center.Y + SpeedY, SpeedX, SpeedY, ProjectileID.CrystalShard, projectile.damage / 2, 0f, projectile.owner); - if (shard.WithinBounds(Main.maxProjectiles)) - Main.projectile[shard].Calamity().forceMinion = true; + if (shard.WithinBounds(Main.maxProjectiles)) + Main.projectile[shard].Calamity().forceMinion = true; } } } diff --git a/Projectiles/Summon/PolypLauncherProjectile.cs b/Projectiles/Summon/PolypLauncherProjectile.cs index 5d4456adbb..7bdf0668b6 100644 --- a/Projectiles/Summon/PolypLauncherProjectile.cs +++ b/Projectiles/Summon/PolypLauncherProjectile.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PolypLauncherProjectile : ModProjectile + public class PolypLauncherProjectile : ModProjectile { public const float Gravity = 0.4f; public override void SetStaticDefaults() @@ -39,41 +39,41 @@ namespace CalamityMod.Projectiles.Summon { projectile.alpha = (int)MathHelper.Lerp(255, 0, projectile.ai[0] / 10f); } - projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.1f * projectile.direction; + projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.1f * projectile.direction; } public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Item10, projectile.Center); - //Dust on impact - int dust_splash = 0; - while (dust_splash < 9) - { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 225, -projectile.velocity.X * 0.15f, -projectile.velocity.Y * 0.15f, 120, default, 1f); - dust_splash += 1; - } - int split = 0; - int shardAmt = Main.rand.Next(1,5); - while (split < shardAmt) - { - //Calculate the velocity of the projectile - float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); - float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; - //Prevents the projectile speed from being too low - if (shardspeedX < 2f && shardspeedX > -2f) - { - shardspeedX += -projectile.velocity.X; - } - if (shardspeedY > 2f && shardspeedY < 2f) - { - shardspeedY += -projectile.velocity.Y; - } - Vector2 shardSpeed = new Vector2(shardspeedX, shardspeedY); + Main.PlaySound(SoundID.Item10, projectile.Center); + //Dust on impact + int dust_splash = 0; + while (dust_splash < 9) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 225, -projectile.velocity.X * 0.15f, -projectile.velocity.Y * 0.15f, 120, default, 1f); + dust_splash += 1; + } + int split = 0; + int shardAmt = Main.rand.Next(1,5); + while (split < shardAmt) + { + //Calculate the velocity of the projectile + float shardspeedX = -projectile.velocity.X * Main.rand.NextFloat(.5f, .7f) + Main.rand.NextFloat(-3f, 3f); + float shardspeedY = -projectile.velocity.Y * Main.rand.Next(50, 70) * 0.01f + Main.rand.Next(-8, 9) * 0.2f; + //Prevents the projectile speed from being too low + if (shardspeedX < 2f && shardspeedX > -2f) + { + shardspeedX += -projectile.velocity.X; + } + if (shardspeedY > 2f && shardspeedY < 2f) + { + shardspeedY += -projectile.velocity.Y; + } + Vector2 shardSpeed = new Vector2(shardspeedX, shardspeedY); - //Spawn the projectile - int shard = Projectile.NewProjectile(projectile.Center + shardSpeed, shardSpeed, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack / 2f, projectile.owner, Main.rand.Next(3)); - split += 1; - } - } + //Spawn the projectile + int shard = Projectile.NewProjectile(projectile.Center + shardSpeed, shardSpeed, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack / 2f, projectile.owner, Main.rand.Next(3)); + split += 1; + } + } } } diff --git a/Projectiles/Summon/PolypLauncherSentry.cs b/Projectiles/Summon/PolypLauncherSentry.cs index 88b104c1c1..0d01eff6a8 100644 --- a/Projectiles/Summon/PolypLauncherSentry.cs +++ b/Projectiles/Summon/PolypLauncherSentry.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PolypLauncherSentry : ModProjectile + public class PolypLauncherSentry : ModProjectile { public override void SetStaticDefaults() { @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (projectile.localAI[0] == 0f) { @@ -60,22 +60,22 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity.Y = 10f; } - projectile.StickToTiles(false, false); + projectile.StickToTiles(false, false); - if (projectile.ai[0] > 0f) - { - projectile.ai[0] -= 1f; - return; - } - projectile.ai[1] += Main.rand.Next(1,3); + if (projectile.ai[0] > 0f) + { + projectile.ai[0] -= 1f; + return; + } + projectile.ai[1] += Main.rand.Next(1,3); - NPC potentialTarget = projectile.Center.MinionHoming(800f, player, false); + NPC potentialTarget = projectile.Center.MinionHoming(800f, player, false); - if (projectile.owner == Main.myPlayer && potentialTarget != null) + if (projectile.owner == Main.myPlayer && potentialTarget != null) { if (projectile.ai[1] > 40f) { - Vector2 spawnPosition = new Vector2(projectile.oldPosition.X + (projectile.width / 2), projectile.oldPosition.Y + (projectile.height / 2)); + Vector2 spawnPosition = new Vector2(projectile.oldPosition.X + (projectile.width / 2), projectile.oldPosition.Y + (projectile.height / 2)); float shootSpeed = 16f; float gravity = -PolypLauncherProjectile.Gravity; @@ -85,9 +85,9 @@ namespace CalamityMod.Projectiles.Summon Vector2 velocity = new Vector2(0f, -shootSpeed).RotatedBy(angle).RotatedByRandom(0.1f); velocity.X *= (potentialTarget.Center.X - projectile.Center.X < 0).ToDirectionInt(); - Projectile.NewProjectile(spawnPosition, velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - projectile.ai[1] = 0f; - projectile.netUpdate = true; + Projectile.NewProjectile(spawnPosition, velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + projectile.ai[1] = 0f; + projectile.netUpdate = true; } } } diff --git a/Projectiles/Summon/PolypLauncherShrapnel.cs b/Projectiles/Summon/PolypLauncherShrapnel.cs index 69dff708fe..ccaf5e6282 100644 --- a/Projectiles/Summon/PolypLauncherShrapnel.cs +++ b/Projectiles/Summon/PolypLauncherShrapnel.cs @@ -5,46 +5,46 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PolypLauncherShrapnel : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Polyp Shrapnel"); + public class PolypLauncherShrapnel : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Polyp Shrapnel"); ProjectileID.Sets.SentryShot[projectile.type] = true; - } + } - public override void SetDefaults() - { - projectile.friendly = true; - projectile.width = 13; - projectile.height = 13; + public override void SetDefaults() + { + projectile.friendly = true; + projectile.width = 13; + projectile.height = 13; projectile.ignoreWater = true; projectile.timeLeft = 120; - projectile.minion = true; + projectile.minion = true; projectile.minionSlots = 0f; - } + } - public override void AI() - { - //Rotation and gravity - projectile.rotation += 0.6f * projectile.direction; - projectile.velocity.Y += 0.27f; - if (projectile.velocity.Y > 16f) - { - projectile.velocity.Y = 16f; - } - } + public override void AI() + { + //Rotation and gravity + projectile.rotation += 0.6f * projectile.direction; + projectile.velocity.Y += 0.27f; + if (projectile.velocity.Y > 16f) + { + projectile.velocity.Y = 16f; + } + } - public override void Kill(int timeLeft) - { - //Dust effect - int splash = 0; - while (splash < 4) - { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 225, -projectile.velocity.X * 0.15f, -projectile.velocity.Y * 0.10f, 150, default, 0.7f); - splash += 1; - } - } + public override void Kill(int timeLeft) + { + //Dust effect + int splash = 0; + while (splash < 4) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 225, -projectile.velocity.X * 0.15f, -projectile.velocity.Y * 0.10f, 150, default, 0.7f); + splash += 1; + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -58,8 +58,8 @@ namespace CalamityMod.Projectiles.Summon { texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/PolypLauncherShrapnel3"); } - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), projectile.GetAlpha(lightColor), projectile.rotation, texture.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); - return false; + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), projectile.GetAlpha(lightColor), projectile.rotation, texture.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + return false; } - } + } } diff --git a/Projectiles/Summon/PowerfulRaven.cs b/Projectiles/Summon/PowerfulRaven.cs index d946a9477b..835a9ec8e8 100644 --- a/Projectiles/Summon/PowerfulRaven.cs +++ b/Projectiles/Summon/PowerfulRaven.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PowerfulRaven : ModProjectile + public class PowerfulRaven : ModProjectile { public const float DistanceToCheck = 3200f; public const float TeleportDistance = 2700f; diff --git a/Projectiles/Summon/PrincessMissile.cs b/Projectiles/Summon/PrincessMissile.cs index 35f75c92bd..5861282d0f 100644 --- a/Projectiles/Summon/PrincessMissile.cs +++ b/Projectiles/Summon/PrincessMissile.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Summon projectile.width = 14; projectile.height = 14; projectile.friendly = true; - projectile.minion = true; + projectile.minion = true; projectile.tileCollide = true; projectile.penetrate = 1; } @@ -116,7 +116,7 @@ namespace CalamityMod.Projectiles.Summon num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Summon/ProfanedEnergy.cs b/Projectiles/Summon/ProfanedEnergy.cs index 8c72742204..db25d4e5a1 100644 --- a/Projectiles/Summon/ProfanedEnergy.cs +++ b/Projectiles/Summon/ProfanedEnergy.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; projectile.frameCounter++; if (projectile.frameCounter > 5) { @@ -142,11 +142,11 @@ namespace CalamityMod.Projectiles.Summon { projectile.spriteDirection = -1; } - int projectileType = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), - ModContent.ProjectileType() - }); + int projectileType = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType() + }); float speed = 25f; Vector2 vector29 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); float num404 = num516 - vector29.X; diff --git a/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs b/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs index 8046898623..b09a59c935 100644 --- a/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs +++ b/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs @@ -10,10 +10,10 @@ using Terraria.Audio; namespace CalamityMod.Projectiles.Summon { - #region Mage Projectiles + #region Mage Projectiles - #region Main Fireball - public class ProfanedCrystalMageFireball : ModProjectile + #region Main Fireball + public class ProfanedCrystalMageFireball : ModProjectile { public override void SetStaticDefaults() { @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Summon velocity.Normalize(); velocity *= 8f; int proj = Projectile.NewProjectile(projectile.Center + outerPosVec, velocity, ModContent.ProjectileType(), damage, projectile.knockBack, projectile.owner, 0f, 0f); - if (proj.WithinBounds(Main.maxProjectiles)) + if (proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].Calamity().forceMinion = true; if (innerSplits > 0) //only runs if there's still inner splits to create { @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Summon velocity.Normalize(); velocity *= 5f; proj = Projectile.NewProjectile(projectile.Center + innerPosVec, velocity, ModContent.ProjectileType(), damage, projectile.knockBack, projectile.owner, 0f, 0f); - if (proj.WithinBounds(Main.maxProjectiles)) + if (proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].Calamity().forceMinion = true; } innerSplits--; @@ -625,8 +625,8 @@ namespace CalamityMod.Projectiles.Summon correctedVelocity.Normalize(); correctedVelocity *= 25f; int proj = Projectile.NewProjectile(pos, correctedVelocity, ModContent.ProjectileType(), (int)((double)projectile.damage * 1.5f), projectile.knockBack, projectile.owner, 2); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().forceMinion = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMinion = true; ((ProfanedCrystalRangedHuges)Main.projectile[proj].modProjectile).boomerSwarm = true; } } diff --git a/Projectiles/Summon/PurpleButterfly.cs b/Projectiles/Summon/PurpleButterfly.cs index 9b0449f328..c786e6fc15 100644 --- a/Projectiles/Summon/PurpleButterfly.cs +++ b/Projectiles/Summon/PurpleButterfly.cs @@ -8,104 +8,104 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PurpleButterfly : ModProjectile - { - public int dust = 3; + public class PurpleButterfly : ModProjectile + { + public int dust = 3; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Purple Butterfly"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.MinionSacrificable[projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Purple Butterfly"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = 30; - projectile.height = 30; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.minionSlots = 0.5f; - projectile.timeLeft = 18000; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.timeLeft *= 5; - projectile.minion = true; - } + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 0.5f; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft *= 5; + projectile.minion = true; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - if (dust > 0) - { - projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); - projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) - { - Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.5f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center; - Vector2 vector7 = vector6 - projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 173, vector7.X, vector7.Y, 100, default, 1.8f); - Main.dust[num228].noGravity = true; - } - dust--; - } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) - { - int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / - projectile.Calamity().spawnedPlayerMinionDamageValue * - player.MinionDamage()); - projectile.damage = damage2; - } - if (Math.Abs(projectile.velocity.X) > 0.2f) - { - projectile.spriteDirection = -projectile.direction; - } - projectile.rotation = projectile.velocity.X * 0.02f; - projectile.frameCounter++; - if (projectile.frameCounter > 6) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; - } - Lighting.AddLight(projectile.Center, 0.3f, 0f, 0.5f); - projectile.ChargingMinionAI(1200f, 1500f, 2400f, 150f, 0, 30f, 18f, 9f, new Vector2(0f, -60f), 30f, 12f, true, true); - bool flag64 = projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) - { - if (player.dead) - { - modPlayer.resButterfly = false; - } - if (modPlayer.resButterfly) - { - projectile.timeLeft = 2; - } - } - } + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + if (dust > 0) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + int num226 = 36; + for (int num227 = 0; num227 < num226; num227++) + { + Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.5f; + vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center; + Vector2 vector7 = vector6 - projectile.Center; + int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 173, vector7.X, vector7.Y, 100, default, 1.8f); + Main.dust[num228].noGravity = true; + } + dust--; + } + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + player.MinionDamage()); + projectile.damage = damage2; + } + if (Math.Abs(projectile.velocity.X) > 0.2f) + { + projectile.spriteDirection = -projectile.direction; + } + projectile.rotation = projectile.velocity.X * 0.02f; + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + { + projectile.frame = 0; + } + Lighting.AddLight(projectile.Center, 0.3f, 0f, 0.5f); + projectile.ChargingMinionAI(1200f, 1500f, 2400f, 150f, 0, 30f, 18f, 9f, new Vector2(0f, -60f), 30f, 12f, true, true); + bool flag64 = projectile.type == ModContent.ProjectileType(); + player.AddBuff(ModContent.BuffType(), 3600); + if (flag64) + { + if (player.dead) + { + modPlayer.resButterfly = false; + } + if (modPlayer.resButterfly) + { + projectile.timeLeft = 2; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D texture2D13 = Main.projectileTexture[projectile.type]; - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; - int y6 = num214 * projectile.frame; - Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D texture2D13 = Main.projectileTexture[projectile.type]; + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int y6 = num214 * projectile.frame; + Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 8; - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 8; + } + } } diff --git a/Projectiles/Summon/RadiantResolutionAura.cs b/Projectiles/Summon/RadiantResolutionAura.cs index cf8c704f84..963925a66c 100644 --- a/Projectiles/Summon/RadiantResolutionAura.cs +++ b/Projectiles/Summon/RadiantResolutionAura.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class RadiantResolutionAura : ModProjectile + public class RadiantResolutionAura : ModProjectile { public Player Owner => Main.player[projectile.owner]; public ref float AllocatedSlots => ref projectile.ai[0]; @@ -56,11 +56,11 @@ namespace CalamityMod.Projectiles.Summon projectile.Center = Owner.Center - Vector2.UnitY * 16f; projectile.rotation += MathHelper.ToRadians(AllocatedSlots * 0.85f + 3f); - float damageMultiplier = (float)Math.Log(AllocatedSlots, 3D) + 1f; + float damageMultiplier = (float)Math.Log(AllocatedSlots, 3D) + 1f; - // Softcap the multiplier after it has exceeded 3x the base value. - float softcappedDamageMultiplier = damageMultiplier; - if (softcappedDamageMultiplier > 3f) + // Softcap the multiplier after it has exceeded 3x the base value. + float softcappedDamageMultiplier = damageMultiplier; + if (softcappedDamageMultiplier > 3f) softcappedDamageMultiplier = ((damageMultiplier - 3f) * 0.1f) + 3f; int radiantOrbDamage = (int)(projectile.damage * softcappedDamageMultiplier); diff --git a/Projectiles/Summon/RadiantResolutionFire.cs b/Projectiles/Summon/RadiantResolutionFire.cs index 78487162b3..9a3183fe0a 100644 --- a/Projectiles/Summon/RadiantResolutionFire.cs +++ b/Projectiles/Summon/RadiantResolutionFire.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Projectiles.Summon projectile.friendly = true; projectile.light = 1f; projectile.timeLeft = 300; - projectile.minion = true; - projectile.tileCollide = false; + projectile.minion = true; + projectile.tileCollide = false; } public override void AI() @@ -38,11 +38,11 @@ namespace CalamityMod.Projectiles.Summon public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 60); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 60); projectile.maxPenetrate = projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.damage /= 3; + projectile.damage /= 3; projectile.Damage(); Main.PlaySound(SoundID.Item14, projectile.Center); for (int i = 0; i < 20; i++) diff --git a/Projectiles/Summon/RadiantResolutionOrb.cs b/Projectiles/Summon/RadiantResolutionOrb.cs index a511f4f07b..bb7ab99e98 100644 --- a/Projectiles/Summon/RadiantResolutionOrb.cs +++ b/Projectiles/Summon/RadiantResolutionOrb.cs @@ -3,7 +3,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class RadiantResolutionOrb : ModProjectile + public class RadiantResolutionOrb : ModProjectile { public override void SetStaticDefaults() { @@ -16,7 +16,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.width = 62; projectile.height = 64; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.friendly = true; projectile.minion = true; projectile.minionSlots = 0f; @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Summon projectile.localNPCHitCooldown = 4; } - public override void AI() - { + public override void AI() + { if (projectile.alpha > 0) { projectile.alpha -= 9; @@ -43,10 +43,10 @@ namespace CalamityMod.Projectiles.Summon projectile.frame++; projectile.frameCounter = 0; } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } if (projectile.ai[0]++ < 30f) { projectile.velocity *= 1.01f; @@ -57,6 +57,6 @@ namespace CalamityMod.Projectiles.Summon if (potentialTarget != null) projectile.velocity = (projectile.velocity * 7f + projectile.SafeDirectionTo(potentialTarget.Center) * 19f) / 8f; } - } + } } } diff --git a/Projectiles/Summon/RustyDrone.cs b/Projectiles/Summon/RustyDrone.cs index 1cdc716486..60b4db1241 100644 --- a/Projectiles/Summon/RustyDrone.cs +++ b/Projectiles/Summon/RustyDrone.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class RustyDrone : ModProjectile + public class RustyDrone : ModProjectile { public const float PlayerHomingInertia = 32f; public const float PlayerHomingSpeed = 11f; diff --git a/Projectiles/Summon/RustyDroneTargetIndicator.cs b/Projectiles/Summon/RustyDroneTargetIndicator.cs index a8df127740..90a1e8da8d 100644 --- a/Projectiles/Summon/RustyDroneTargetIndicator.cs +++ b/Projectiles/Summon/RustyDroneTargetIndicator.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.width = 34; projectile.height = 34; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.friendly = true; projectile.minion = true; projectile.minionSlots = 0f; @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Summon DeltaPositionRelativetoTarget = reader.ReadVector2(); } public override void AI() - { + { if (projectile.ai[0] < 0 || projectile.ai[0] >= Main.projectile.Length || projectile.ai[1] < 0 || projectile.ai[1] >= Main.npc.Length) { projectile.Kill(); diff --git a/Projectiles/Summon/SageNeedle.cs b/Projectiles/Summon/SageNeedle.cs index 959ddbe7c3..22fe90c8a1 100644 --- a/Projectiles/Summon/SageNeedle.cs +++ b/Projectiles/Summon/SageNeedle.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity.Y += 0.16f; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { int totalSageSpirits = Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()]; @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Summon target.Calamity().sagePoisonDamage = sagePoisonDamage; } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { if (Main.dedServ) return; diff --git a/Projectiles/Summon/SageSpirit.cs b/Projectiles/Summon/SageSpirit.cs index e8b31cf92b..ad51088f75 100644 --- a/Projectiles/Summon/SageSpirit.cs +++ b/Projectiles/Summon/SageSpirit.cs @@ -8,190 +8,190 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SageSpirit : ModProjectile - { - internal Player Owner => Main.player[projectile.owner]; - internal ref float AttackTimer => ref projectile.ai[0]; - internal ref float PlayerFlyTime => ref projectile.ai[1]; - internal ref float SageSpiritIndex => ref projectile.localAI[0]; - internal ref float GeneralTime => ref projectile.localAI[1]; - internal bool Initialized = false; - internal Vector2 PlayerFlyStart; - internal Vector2 PlayerFlyOffsetAtEnds; - internal Vector2 PlayerFlyDestination; + public class SageSpirit : ModProjectile + { + internal Player Owner => Main.player[projectile.owner]; + internal ref float AttackTimer => ref projectile.ai[0]; + internal ref float PlayerFlyTime => ref projectile.ai[1]; + internal ref float SageSpiritIndex => ref projectile.localAI[0]; + internal ref float GeneralTime => ref projectile.localAI[1]; + internal bool Initialized = false; + internal Vector2 PlayerFlyStart; + internal Vector2 PlayerFlyOffsetAtEnds; + internal Vector2 PlayerFlyDestination; - internal const int ShootRate = 40; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Sage Spirit"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.MinionSacrificable[projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; - } + internal const int ShootRate = 40; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sage Spirit"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = 48; - projectile.height = 72; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.minionSlots = 1f; - projectile.timeLeft = 90000; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.minion = true; - } + public override void SetDefaults() + { + projectile.width = 48; + projectile.height = 72; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 1f; + projectile.timeLeft = 90000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.minion = true; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(Initialized); - writer.Write(SageSpiritIndex); - writer.Write(GeneralTime); - writer.WritePackedVector2(PlayerFlyStart); - writer.WritePackedVector2(PlayerFlyOffsetAtEnds); - writer.WritePackedVector2(PlayerFlyDestination); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Initialized); + writer.Write(SageSpiritIndex); + writer.Write(GeneralTime); + writer.WritePackedVector2(PlayerFlyStart); + writer.WritePackedVector2(PlayerFlyOffsetAtEnds); + writer.WritePackedVector2(PlayerFlyDestination); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - Initialized = reader.ReadBoolean(); - SageSpiritIndex = reader.ReadSingle(); - GeneralTime = reader.ReadSingle(); - PlayerFlyStart = reader.ReadPackedVector2(); - PlayerFlyOffsetAtEnds = reader.ReadPackedVector2(); - PlayerFlyDestination = reader.ReadPackedVector2(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + Initialized = reader.ReadBoolean(); + SageSpiritIndex = reader.ReadSingle(); + GeneralTime = reader.ReadSingle(); + PlayerFlyStart = reader.ReadPackedVector2(); + PlayerFlyOffsetAtEnds = reader.ReadPackedVector2(); + PlayerFlyDestination = reader.ReadPackedVector2(); + } - public override void AI() - { - GeneralTime++; - ProvidePlayerMinionBuffs(); - Initialize(); - DetermineFrames(); - NPC potentialTarget = projectile.Center.MinionHoming(750f, Owner); - if (potentialTarget is null) - FlyNearOwner(); - else - { - ResetOwnerFlyValues(); - AttackTarget(potentialTarget); - } - } + public override void AI() + { + GeneralTime++; + ProvidePlayerMinionBuffs(); + Initialize(); + DetermineFrames(); + NPC potentialTarget = projectile.Center.MinionHoming(750f, Owner); + if (potentialTarget is null) + FlyNearOwner(); + else + { + ResetOwnerFlyValues(); + AttackTarget(potentialTarget); + } + } - internal void ProvidePlayerMinionBuffs() - { - Owner.AddBuff(ModContent.BuffType(), 3600); + internal void ProvidePlayerMinionBuffs() + { + Owner.AddBuff(ModContent.BuffType(), 3600); - // Verify player/minion state integrity. The minion cannot stay alive if the - // owner is dead or if the caller of the AI is invalid. - if (projectile.type != ModContent.ProjectileType()) - return; + // Verify player/minion state integrity. The minion cannot stay alive if the + // owner is dead or if the caller of the AI is invalid. + if (projectile.type != ModContent.ProjectileType()) + return; - if (Owner.dead) - Owner.Calamity().sageSpirit = false; - if (Owner.Calamity().sageSpirit) - projectile.timeLeft = 2; - } + if (Owner.dead) + Owner.Calamity().sageSpirit = false; + if (Owner.Calamity().sageSpirit) + projectile.timeLeft = 2; + } - internal void Initialize() - { - if (Initialized) - return; + internal void Initialize() + { + if (Initialized) + return; - Initialized = true; - PlayerFlyTime = 1f; - PlayerFlyOffsetAtEnds = Vector2.UnitY; - PlayerFlyStart = projectile.Center; - PlayerFlyDestination = projectile.Center - Vector2.UnitY * 10f; - projectile.netUpdate = true; - } + Initialized = true; + PlayerFlyTime = 1f; + PlayerFlyOffsetAtEnds = Vector2.UnitY; + PlayerFlyStart = projectile.Center; + PlayerFlyDestination = projectile.Center - Vector2.UnitY * 10f; + projectile.netUpdate = true; + } - internal void DetermineFrames() - { - projectile.frameCounter++; - if (projectile.frameCounter % 5 == 4) - projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; - } + internal void DetermineFrames() + { + projectile.frameCounter++; + if (projectile.frameCounter % 5 == 4) + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + } - internal void ResetOwnerFlyValues() - { - PlayerFlyTime = 0f; - PlayerFlyOffsetAtEnds = Vector2.Zero; - PlayerFlyStart = PlayerFlyDestination = -Vector2.One; - projectile.netUpdate = true; - } + internal void ResetOwnerFlyValues() + { + PlayerFlyTime = 0f; + PlayerFlyOffsetAtEnds = Vector2.Zero; + PlayerFlyStart = PlayerFlyDestination = -Vector2.One; + projectile.netUpdate = true; + } - internal void FlyNearOwner() - { - Vector2 destination = Owner.Center + Vector2.UnitX * Owner.width * 1.6f * Owner.direction; + internal void FlyNearOwner() + { + Vector2 destination = Owner.Center + Vector2.UnitX * Owner.width * 1.6f * Owner.direction; - int totalSageSpirits = Owner.ownedProjectileCounts[projectile.type]; - destination += (SageSpiritIndex * MathHelper.TwoPi / totalSageSpirits).ToRotationVector2() * 70f; - if (PlayerFlyTime >= 1f) - { - projectile.Center = PlayerFlyDestination; - ResetOwnerFlyValues(); - return; - } + int totalSageSpirits = Owner.ownedProjectileCounts[projectile.type]; + destination += (SageSpiritIndex * MathHelper.TwoPi / totalSageSpirits).ToRotationVector2() * 70f; + if (PlayerFlyTime >= 1f) + { + projectile.Center = PlayerFlyDestination; + ResetOwnerFlyValues(); + return; + } - float distanceFromDestination = projectile.Distance(destination); - if (float.IsNaN(distanceFromDestination)) - distanceFromDestination = 0f; + float distanceFromDestination = projectile.Distance(destination); + if (float.IsNaN(distanceFromDestination)) + distanceFromDestination = 0f; - // Determine owner values if they are still in the air. - if (PlayerFlyTime <= 0f) - { - PlayerFlyStart = projectile.Center; - PlayerFlyOffsetAtEnds = Vector2.UnitY * distanceFromDestination; - PlayerFlyDestination = destination; - projectile.netUpdate = true; - PlayerFlyTime = 0.01f; - return; - } + // Determine owner values if they are still in the air. + if (PlayerFlyTime <= 0f) + { + PlayerFlyStart = projectile.Center; + PlayerFlyOffsetAtEnds = Vector2.UnitY * distanceFromDestination; + PlayerFlyDestination = destination; + projectile.netUpdate = true; + PlayerFlyTime = 0.01f; + return; + } - projectile.position.Y += (float)Math.Cos(GeneralTime / 60f * MathHelper.TwoPi + projectile.identity * 1.1f) * 0.5f; + projectile.position.Y += (float)Math.Cos(GeneralTime / 60f * MathHelper.TwoPi + projectile.identity * 1.1f) * 0.5f; - if (distanceFromDestination < 160f && PlayerFlyTime <= 0f) - return; + if (distanceFromDestination < 160f && PlayerFlyTime <= 0f) + return; - // A catmull-rom spline attempts to find a smooth arc of two points based on a 0-1 interpolant. - // Its results are always within the bounds of the second and third term. They are intended to be the "middle" of the spline. - // The other 2 points at the ends are intended to be used to determine how the resulting curve should arc. - // In this context, since the offset at the start is down, it'll actually go up because it's starting at the bottom - // and then going up, bending between the 2 middle points. - projectile.Center = Vector2.CatmullRom( - PlayerFlyStart + PlayerFlyOffsetAtEnds, - PlayerFlyStart, - PlayerFlyDestination, - PlayerFlyDestination + PlayerFlyOffsetAtEnds, - PlayerFlyTime); + // A catmull-rom spline attempts to find a smooth arc of two points based on a 0-1 interpolant. + // Its results are always within the bounds of the second and third term. They are intended to be the "middle" of the spline. + // The other 2 points at the ends are intended to be used to determine how the resulting curve should arc. + // In this context, since the offset at the start is down, it'll actually go up because it's starting at the bottom + // and then going up, bending between the 2 middle points. + projectile.Center = Vector2.CatmullRom( + PlayerFlyStart + PlayerFlyOffsetAtEnds, + PlayerFlyStart, + PlayerFlyDestination, + PlayerFlyDestination + PlayerFlyOffsetAtEnds, + PlayerFlyTime); - PlayerFlyTime = MathHelper.Clamp(PlayerFlyTime + 0.03f, 0f, 1f); - } + PlayerFlyTime = MathHelper.Clamp(PlayerFlyTime + 0.03f, 0f, 1f); + } - internal void AttackTarget(NPC target) - { - AttackTimer++; + internal void AttackTarget(NPC target) + { + AttackTimer++; - int totalSageSpirits = Owner.ownedProjectileCounts[projectile.type]; - Vector2 destinationOffsetFactor = Vector2.Max(target.Size, new Vector2(160f)) * new Vector2(0.6f, 0.37f); - Vector2 destination = target.Center + (AttackTimer / 12f).ToRotationVector2() * destinationOffsetFactor; - destination += (SageSpiritIndex * MathHelper.TwoPi / totalSageSpirits).ToRotationVector2() * 130f; - projectile.Center = Vector2.Lerp(projectile.Center, destination, 0.1f); + int totalSageSpirits = Owner.ownedProjectileCounts[projectile.type]; + Vector2 destinationOffsetFactor = Vector2.Max(target.Size, new Vector2(160f)) * new Vector2(0.6f, 0.37f); + Vector2 destination = target.Center + (AttackTimer / 12f).ToRotationVector2() * destinationOffsetFactor; + destination += (SageSpiritIndex * MathHelper.TwoPi / totalSageSpirits).ToRotationVector2() * 130f; + projectile.Center = Vector2.Lerp(projectile.Center, destination, 0.1f); - // Frequently release a bunch of spikes. - if (projectile.owner == Main.myPlayer && AttackTimer % ShootRate == ShootRate - 1) - { - for (int i = 0; i < 3; i++) - { - Vector2 spikeVelocity = -Vector2.UnitY.RotatedBy(MathHelper.Lerp(-0.43f, 0.43f, i / 3f)) * 6f; - Projectile.NewProjectile(projectile.Top, spikeVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - } - } - } + // Frequently release a bunch of spikes. + if (projectile.owner == Main.myPlayer && AttackTimer % ShootRate == ShootRate - 1) + { + for (int i = 0; i < 3; i++) + { + Vector2 spikeVelocity = -Vector2.UnitY.RotatedBy(MathHelper.Lerp(-0.43f, 0.43f, i / 3f)) * 6f; + Projectile.NewProjectile(projectile.Top, spikeVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + } + } + } - // The spirit itself should not do direct damage. - public override bool CanDamage() => false; - } + // The spirit itself should not do direct damage. + public override bool CanDamage() => false; + } } diff --git a/Projectiles/Summon/SakuraBullet.cs b/Projectiles/Summon/SakuraBullet.cs index 5e68028f20..249d687eb8 100644 --- a/Projectiles/Summon/SakuraBullet.cs +++ b/Projectiles/Summon/SakuraBullet.cs @@ -30,65 +30,65 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.02f; - Vector2 center = projectile.Center; - float maxDistance = 400f; - bool homeIn = false; + Vector2 center = projectile.Center; + float maxDistance = 400f; + bool homeIn = false; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if ((npc.CanBeChasedBy(projectile, false) || npc.type == NPCID.DukeFishron) && npc.active) { - float extraDistance = (npc.width / 2) + (npc.height / 2); + float extraDistance = (npc.width / 2) + (npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - center = npc.Center; - homeIn = true; - } + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = npc.Center; + homeIn = true; + } } - } + } else if (projectile.ai[0] != -1f) { NPC npc = Main.npc[(int)projectile.ai[0]]; if ((npc.CanBeChasedBy(projectile, false) || npc.type == NPCID.DukeFishron) && npc.active) { - float extraDistance = (npc.width / 2) + (npc.height / 2); + float extraDistance = (npc.width / 2) + (npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - center = npc.Center; - homeIn = true; - } + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = npc.Center; + homeIn = true; + } } - } - if (!homeIn) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if ((npc.CanBeChasedBy(projectile, false) || (npc.type == NPCID.DukeFishron && (!npc.dontTakeDamage || npc.ai[0] > 9f))) && npc.active) - { - float extraDistance = (npc.width / 2) + (npc.height / 2); + } + if (!homeIn) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if ((npc.CanBeChasedBy(projectile, false) || (npc.type == NPCID.DukeFishron && (!npc.dontTakeDamage || npc.ai[0] > 9f))) && npc.active) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - center = npc.Center; - homeIn = true; - break; - } - } - } - } + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = npc.Center; + homeIn = true; + break; + } + } + } + } - if (homeIn) - { - Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * 20f + moveDirection * 11f) / (21f); - } + if (homeIn) + { + Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); + projectile.velocity = (projectile.velocity * 20f + moveDirection * 11f) / (21f); + } int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 73, 0f, 0f, 100, default, 0.6f); Main.dust[num458].noGravity = true; diff --git a/Projectiles/Summon/SandBolt.cs b/Projectiles/Summon/SandBolt.cs index 2f435e2922..8178a6a414 100644 --- a/Projectiles/Summon/SandBolt.cs +++ b/Projectiles/Summon/SandBolt.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = 1; projectile.light = 1f; projectile.timeLeft = 300; - projectile.minion = true; + projectile.minion = true; } public override void AI() diff --git a/Projectiles/Summon/SandElementalHealer.cs b/Projectiles/Summon/SandElementalHealer.cs index 3b407797dd..e3b028fad9 100644 --- a/Projectiles/Summon/SandElementalHealer.cs +++ b/Projectiles/Summon/SandElementalHealer.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SandElementalHealer : ModProjectile + public class SandElementalHealer : ModProjectile { public int dust = 3; @@ -102,7 +102,7 @@ namespace CalamityMod.Projectiles.Summon lightScalar *= Main.essScale; Lighting.AddLight(projectile.Center, 0.7f * lightScalar, 0.6f * lightScalar, 0f * lightScalar); - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); if (Vector2.Distance(player.Center, projectile.Center) > 400f) { diff --git a/Projectiles/Summon/SandElementalMinion.cs b/Projectiles/Summon/SandElementalMinion.cs index 526aa5b11e..8546336614 100644 --- a/Projectiles/Summon/SandElementalMinion.cs +++ b/Projectiles/Summon/SandElementalMinion.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SandElementalMinion : ModProjectile + public class SandElementalMinion : ModProjectile { public int dust = 3; @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Summon float num = (float)Main.rand.Next(90, 111) * 0.01f; num *= Main.essScale; Lighting.AddLight(projectile.Center, 0.7f * num, 0.6f * num, 0f * num); - projectile.MinionAntiClump(); + projectile.MinionAntiClump(); Vector2 vector46 = projectile.position; bool flag25 = false; if (projectile.ai[0] != 1f) diff --git a/Projectiles/Summon/SandMark.cs b/Projectiles/Summon/SandMark.cs index 36992636c5..c6949bf53d 100644 --- a/Projectiles/Summon/SandMark.cs +++ b/Projectiles/Summon/SandMark.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SandMark : ModProjectile + public class SandMark : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 900; projectile.ignoreWater = true; projectile.alpha = 255; - projectile.minion = true; + projectile.minion = true; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 30; diff --git a/Projectiles/Summon/SandTornado.cs b/Projectiles/Summon/SandTornado.cs index f30fb5b519..aae22d47cd 100644 --- a/Projectiles/Summon/SandTornado.cs +++ b/Projectiles/Summon/SandTornado.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SandTornado : ModProjectile + public class SandTornado : ModProjectile { public override string Texture => "CalamityMod/Projectiles/TornadoProj"; diff --git a/Projectiles/Summon/SandnadoMinion.cs b/Projectiles/Summon/SandnadoMinion.cs index fc39ac0728..1b287fb674 100644 --- a/Projectiles/Summon/SandnadoMinion.cs +++ b/Projectiles/Summon/SandnadoMinion.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.MinionAntiClump(0.1f); + projectile.MinionAntiClump(0.1f); if (Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) { projectile.alpha += 20; @@ -184,7 +184,7 @@ namespace CalamityMod.Projectiles.Summon if (playerDist > 2000f) { projectile.position = player.position; - projectile.netUpdate = true; + projectile.netUpdate = true; } if (Math.Abs(playerVec.X) > 40f || Math.Abs(playerVec.Y) > 10f) { diff --git a/Projectiles/Summon/SeekerSummonProj.cs b/Projectiles/Summon/SeekerSummonProj.cs index 1b53b08cfa..17ced5dca6 100644 --- a/Projectiles/Summon/SeekerSummonProj.cs +++ b/Projectiles/Summon/SeekerSummonProj.cs @@ -6,146 +6,146 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SeekerSummonProj : ModProjectile - { - public Player Owner => Main.player[projectile.owner]; - public ref float CircleAngleRatio => ref projectile.ai[0]; - public ref float Time => ref projectile.ai[1]; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Soul Seeker"); - Main.projFrames[projectile.type] = 5; - ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; - ProjectileID.Sets.MinionSacrificable[projectile.type] = true; - } + public class SeekerSummonProj : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public ref float CircleAngleRatio => ref projectile.ai[0]; + public ref float Time => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Soul Seeker"); + Main.projFrames[projectile.type] = 5; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 84; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.minionSlots = 1f; - projectile.timeLeft = 90000; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.minion = true; - projectile.extraUpdates = 1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = projectile.MaxUpdates * 8; - projectile.alpha = 255; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 84; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 1f; + projectile.timeLeft = 90000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.minion = true; + projectile.extraUpdates = 1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = projectile.MaxUpdates * 8; + projectile.alpha = 255; + } - public override void AI() - { - if (projectile.localAI[0] == 0f) - { - DoInitializationEffects(); - projectile.localAI[0] = 1f; - } + public override void AI() + { + if (projectile.localAI[0] == 0f) + { + DoInitializationEffects(); + projectile.localAI[0] = 1f; + } - ProvidePlayerMinionBuffs(); - DetermineFrames(); + ProvidePlayerMinionBuffs(); + DetermineFrames(); - projectile.alpha = Utils.Clamp(projectile.alpha - 15, 0, 255); - NPC potentialTarget = projectile.Center.MinionHoming(2050f, Owner); - if (potentialTarget is null) - FlyNearOwner(); - else - AttackTarget(potentialTarget); - Time++; - } + projectile.alpha = Utils.Clamp(projectile.alpha - 15, 0, 255); + NPC potentialTarget = projectile.Center.MinionHoming(2050f, Owner); + if (potentialTarget is null) + FlyNearOwner(); + else + AttackTarget(potentialTarget); + Time++; + } - internal void DoInitializationEffects() - { - if (Main.dedServ) - return; + internal void DoInitializationEffects() + { + if (Main.dedServ) + return; - for (int i = 0; i < 40; i++) - { - Dust brimstoneFire = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(50f, 50f), DustID.Fireworks); - brimstoneFire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 5f); - brimstoneFire.scale = 1f + brimstoneFire.velocity.Length() * 0.1f; - brimstoneFire.color = Color.Lerp(Color.White, Color.OrangeRed, Main.rand.NextFloat()); - brimstoneFire.noGravity = true; - } - } + for (int i = 0; i < 40; i++) + { + Dust brimstoneFire = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(50f, 50f), DustID.Fireworks); + brimstoneFire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 5f); + brimstoneFire.scale = 1f + brimstoneFire.velocity.Length() * 0.1f; + brimstoneFire.color = Color.Lerp(Color.White, Color.OrangeRed, Main.rand.NextFloat()); + brimstoneFire.noGravity = true; + } + } - internal void ProvidePlayerMinionBuffs() - { - Owner.AddBuff(ModContent.BuffType(), 3600); + internal void ProvidePlayerMinionBuffs() + { + Owner.AddBuff(ModContent.BuffType(), 3600); - // Verify player/minion state integrity. The minion cannot stay alive if the - // owner is dead or if the caller of the AI is invalid. - if (projectile.type != ModContent.ProjectileType()) - return; + // Verify player/minion state integrity. The minion cannot stay alive if the + // owner is dead or if the caller of the AI is invalid. + if (projectile.type != ModContent.ProjectileType()) + return; - if (Owner.dead) - Owner.Calamity().soulSeeker = false; - if (Owner.Calamity().soulSeeker) - projectile.timeLeft = 2; - } + if (Owner.dead) + Owner.Calamity().soulSeeker = false; + if (Owner.Calamity().soulSeeker) + projectile.timeLeft = 2; + } - internal void DetermineFrames() - { - projectile.frameCounter++; - if (projectile.frameCounter % 5 == 4) - projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; - } + internal void DetermineFrames() + { + projectile.frameCounter++; + if (projectile.frameCounter % 5 == 4) + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + } - internal void FlyNearOwner() - { - // Make an imp laugh sound every so often. - if (Main.rand.NextBool(1600)) - Main.PlaySound(SoundID.DD2_KoboldFlyerHurt); + internal void FlyNearOwner() + { + // Make an imp laugh sound every so often. + if (Main.rand.NextBool(1600)) + Main.PlaySound(SoundID.DD2_KoboldFlyerHurt); - Vector2 destination = Owner.Center + (MathHelper.TwoPi * CircleAngleRatio - MathHelper.PiOver2).ToRotationVector2() * 310f; - projectile.Center = Vector2.Lerp(projectile.Center, destination, 0.03f); + Vector2 destination = Owner.Center + (MathHelper.TwoPi * CircleAngleRatio - MathHelper.PiOver2).ToRotationVector2() * 310f; + projectile.Center = Vector2.Lerp(projectile.Center, destination, 0.03f); - if (!projectile.WithinRange(destination, 20f)) - projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(destination) * 16f) / 21f; + if (!projectile.WithinRange(destination, 20f)) + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(destination) * 16f) / 21f; - if (!projectile.WithinRange(Owner.Center, 1800f)) - { - projectile.Center = Owner.Center; - projectile.velocity = -Vector2.UnitY * 4f; - projectile.netUpdate = true; - } + if (!projectile.WithinRange(Owner.Center, 1800f)) + { + projectile.Center = Owner.Center; + projectile.velocity = -Vector2.UnitY * 4f; + projectile.netUpdate = true; + } - projectile.spriteDirection = (destination.X - projectile.Center.X > 0f).ToDirectionInt(); - } + projectile.spriteDirection = (destination.X - projectile.Center.X > 0f).ToDirectionInt(); + } - internal void AttackTarget(NPC target) - { - // Slow down and release a bunch of darts at the enemy for a short interval. - if (Time % 90f > 45f) - { - // Make an imp scream sound every so often. - if (Main.rand.NextBool(400)) - Main.PlaySound(SoundID.DD2_KoboldFlyerChargeScream); + internal void AttackTarget(NPC target) + { + // Slow down and release a bunch of darts at the enemy for a short interval. + if (Time % 90f > 45f) + { + // Make an imp scream sound every so often. + if (Main.rand.NextBool(400)) + Main.PlaySound(SoundID.DD2_KoboldFlyerChargeScream); - projectile.velocity *= 0.9f; - if (Time % 16f == 15f) - { - float shootSpeed = 23f; - Vector2 eyePosition = projectile.Center + new Vector2(projectile.spriteDirection * 22f, -12f); - Vector2 aheadAim = (target.Center - eyePosition) / target.velocity.Length() / shootSpeed; - Vector2 shootVelocity = (target.Center + aheadAim - eyePosition).SafeNormalize(Vector2.UnitX * projectile.spriteDirection) * shootSpeed; - projectile.spriteDirection = (shootVelocity.X > 0f).ToDirectionInt(); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(eyePosition, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - } - } - return; - } + projectile.velocity *= 0.9f; + if (Time % 16f == 15f) + { + float shootSpeed = 23f; + Vector2 eyePosition = projectile.Center + new Vector2(projectile.spriteDirection * 22f, -12f); + Vector2 aheadAim = (target.Center - eyePosition) / target.velocity.Length() / shootSpeed; + Vector2 shootVelocity = (target.Center + aheadAim - eyePosition).SafeNormalize(Vector2.UnitX * projectile.spriteDirection) * shootSpeed; + projectile.spriteDirection = (shootVelocity.X > 0f).ToDirectionInt(); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(eyePosition, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + } + } + return; + } - projectile.spriteDirection = (projectile.velocity.X > 0f).ToDirectionInt(); - if (!projectile.WithinRange(target.Center, 400f)) - projectile.velocity = (projectile.velocity * 10f + projectile.SafeDirectionTo(target.Center) * 22f) / 11f; - else if (projectile.velocity.Length() < 28f) - projectile.velocity = projectile.SafeDirectionTo(target.Center) * 29f; - } - } + projectile.spriteDirection = (projectile.velocity.X > 0f).ToDirectionInt(); + if (!projectile.WithinRange(target.Center, 400f)) + projectile.velocity = (projectile.velocity * 10f + projectile.SafeDirectionTo(target.Center) * 22f) / 11f; + else if (projectile.velocity.Length() < 28f) + projectile.velocity = projectile.SafeDirectionTo(target.Center) * 29f; + } + } } diff --git a/Projectiles/Summon/Shellfish.cs b/Projectiles/Summon/Shellfish.cs index 597c02229e..2df69616c2 100644 --- a/Projectiles/Summon/Shellfish.cs +++ b/Projectiles/Summon/Shellfish.cs @@ -8,7 +8,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class Shellfish : ModProjectile + public class Shellfish : ModProjectile { private int playerStill = 0; private bool fly = false; @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - CalamityGlobalProjectile modProj = projectile.Calamity(); + CalamityGlobalProjectile modProj = projectile.Calamity(); if (spawnDust) { modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -61,12 +61,12 @@ namespace CalamityMod.Projectiles.Summon } spawnDust = false; } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) - { - int damage2 = (int)((float)modProj.spawnedPlayerMinionProjectileDamageValue / - modProj.spawnedPlayerMinionDamageValue * player.MinionDamage()); - projectile.damage = damage2; - } + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int damage2 = (int)((float)modProj.spawnedPlayerMinionProjectileDamageValue / + modProj.spawnedPlayerMinionDamageValue * player.MinionDamage()); + projectile.damage = damage2; + } bool correctMinion = projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); @@ -103,57 +103,57 @@ namespace CalamityMod.Projectiles.Summon float playerDistance = playerVec.Length(); if (projectile.velocity.Y == 0f && (projectile.velocity.X != 0f || playerDistance > 200f)) { - float jumpHeight = Utils.SelectRandom(Main.rand, new float[] - { - 5f, - 7.5f, - 10f - }); - projectile.velocity.Y -= jumpHeight; + float jumpHeight = Utils.SelectRandom(Main.rand, new float[] + { + 5f, + 7.5f, + 10f + }); + projectile.velocity.Y -= jumpHeight; } projectile.velocity.Y += 0.3f; float maxDistance = 1000f; bool chaseNPC = false; float npcPositionX = 0f; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - float npcDist = Vector2.Distance(npc.Center, projectile.Center); - if (!chaseNPC && npcDist < maxDistance) - { - npcPositionX = npc.Center.X; - chaseNPC = true; - } - } - } - if (!chaseNPC) - { - for (int index = 0; index < Main.maxNPCs; index++) - { - NPC npc = Main.npc[index]; - if (npc.CanBeChasedBy(projectile, false)) - { - float npcDist = Vector2.Distance(npc.Center, projectile.Center); - if (!chaseNPC && npcDist < maxDistance) - { - npcPositionX = npc.Center.X; - chaseNPC = true; - } - } - } - } + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float npcDist = Vector2.Distance(npc.Center, projectile.Center); + if (!chaseNPC && npcDist < maxDistance) + { + npcPositionX = npc.Center.X; + chaseNPC = true; + } + } + } + if (!chaseNPC) + { + for (int index = 0; index < Main.maxNPCs; index++) + { + NPC npc = Main.npc[index]; + if (npc.CanBeChasedBy(projectile, false)) + { + float npcDist = Vector2.Distance(npc.Center, projectile.Center); + if (!chaseNPC && npcDist < maxDistance) + { + npcPositionX = npc.Center.X; + chaseNPC = true; + } + } + } + } if (chaseNPC) { if (npcPositionX - projectile.position.X > 0f) { - float rightDist = Utils.SelectRandom(Main.rand, new float[] - { - 0.15f, - 0.2f - }); - projectile.velocity.X += rightDist; + float rightDist = Utils.SelectRandom(Main.rand, new float[] + { + 0.15f, + 0.2f + }); + projectile.velocity.X += rightDist; if (projectile.velocity.X > 8f) { @@ -162,12 +162,12 @@ namespace CalamityMod.Projectiles.Summon } else { - float leftDist = Utils.SelectRandom(Main.rand, new float[] - { - 0.15f, - 0.2f - }); - projectile.velocity.X -= leftDist; + float leftDist = Utils.SelectRandom(Main.rand, new float[] + { + 0.15f, + 0.2f + }); + projectile.velocity.X -= leftDist; if (projectile.velocity.X < -8f) { @@ -188,13 +188,13 @@ namespace CalamityMod.Projectiles.Summon { if (player.position.X - projectile.position.X > 0f) { - float rightDist = Utils.SelectRandom(Main.rand, new float[] - { - 0.05f, - 0.1f, - 0.15f - }); - projectile.velocity.X += rightDist; + float rightDist = Utils.SelectRandom(Main.rand, new float[] + { + 0.05f, + 0.1f, + 0.15f + }); + projectile.velocity.X += rightDist; if (projectile.velocity.X > 6f) { @@ -203,13 +203,13 @@ namespace CalamityMod.Projectiles.Summon } else { - float leftDist = Utils.SelectRandom(Main.rand, new float[] - { - 0.05f, - 0.1f, - 0.15f - }); - projectile.velocity.X -= leftDist; + float leftDist = Utils.SelectRandom(Main.rand, new float[] + { + 0.05f, + 0.1f, + 0.15f + }); + projectile.velocity.X -= leftDist; if (projectile.velocity.X < -6f) { @@ -223,23 +223,23 @@ namespace CalamityMod.Projectiles.Summon { if (projectile.velocity.X > 0.5f) { - float leftDist = Utils.SelectRandom(Main.rand, new float[] - { - 0.05f, - 0.1f, - 0.15f - }); - projectile.velocity.X -= leftDist; + float leftDist = Utils.SelectRandom(Main.rand, new float[] + { + 0.05f, + 0.1f, + 0.15f + }); + projectile.velocity.X -= leftDist; } else if (projectile.velocity.X < -0.5f) { - float rightDist = Utils.SelectRandom(Main.rand, new float[] - { - 0.05f, - 0.1f, - 0.15f - }); - projectile.velocity.X += rightDist; + float rightDist = Utils.SelectRandom(Main.rand, new float[] + { + 0.05f, + 0.1f, + 0.15f + }); + projectile.velocity.X += rightDist; } else if (Math.Abs(projectile.velocity.X) < 0.5f) { @@ -260,7 +260,7 @@ namespace CalamityMod.Projectiles.Summon projectile.rotation = projectile.velocity.X * 0.03f; if (playerDistance > 1500f) { - projectile.Center = player.Center; + projectile.Center = player.Center; projectile.netUpdate = true; } if (playerDistance < 100f) @@ -303,8 +303,8 @@ namespace CalamityMod.Projectiles.Summon { spawnDust = true; } - int npcIndex = (int)projectile.ai[1]; - NPC host = Main.npc[npcIndex]; + int npcIndex = (int)projectile.ai[1]; + NPC host = Main.npc[npcIndex]; if (projectile.localAI[0] >= 600000f) //tryna make it stay on there "forever" without glitching { breakAway = true; @@ -329,7 +329,7 @@ namespace CalamityMod.Projectiles.Summon if (breakAway) { projectile.ai[0] = 0f; - projectile.localAI[0] = 0f; + projectile.localAI[0] = 0f; projectile.velocity.X = 0f; projectile.velocity.Y = 0f; } @@ -338,15 +338,15 @@ namespace CalamityMod.Projectiles.Summon public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); if (projectile.owner == Main.myPlayer) { for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { - NPC npc = Main.npc[npcIndex]; - //covers most edge cases like voodoo dolls + NPC npc = Main.npc[npcIndex]; + //covers most edge cases like voodoo dolls if (npc.active && !npc.dontTakeDamage && npc.defense < 9999 && npc.Calamity().DR < 0.99f && ((projectile.friendly && (!npc.friendly || (npc.type == NPCID.Guide && projectile.owner < Main.maxPlayers && player.killGuide) || (npc.type == NPCID.Clothier && projectile.owner < Main.maxPlayers && player.killClothier))) || (projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles)) && (projectile.owner < 0 || npc.immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) @@ -354,7 +354,7 @@ namespace CalamityMod.Projectiles.Summon if (npc.noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(npc)) { bool stickingToNPC; - //Solar Crawltipede tail has special collision + //Solar Crawltipede tail has special collision if (npc.type == NPCID.SolarCrawltipedeTail) { Rectangle rect = npc.getRect(); @@ -371,28 +371,28 @@ namespace CalamityMod.Projectiles.Summon } if (stickingToNPC) { - //reflect projectile if the npc can reflect it (like Selenians) + //reflect projectile if the npc can reflect it (like Selenians) if (npc.reflectingProjectiles && projectile.CanReflect()) { npc.ReflectProjectile(projectile.whoAmI); return; } - //let the projectile know it is sticking and the npc it is sticking too + //let the projectile know it is sticking and the npc it is sticking too projectile.ai[0] = 1f; projectile.ai[1] = npcIndex; - //follow the NPC + //follow the NPC projectile.velocity = (npc.Center - projectile.Center) * 0.75f; projectile.netUpdate = true; - //Count how many projectiles are attached, delete as necessary + //Count how many projectiles are attached, delete as necessary Point[] array2 = new Point[10]; int projCount = 0; for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) { - Projectile proj = Main.projectile[projIndex]; + Projectile proj = Main.projectile[projIndex]; if (projIndex != projectile.whoAmI && proj.active && proj.owner == Main.myPlayer && proj.type == projectile.type && proj.ai[0] == 1f && proj.ai[1] == (float)npcIndex) { array2[projCount++] = new Point(projIndex, proj.timeLeft); diff --git a/Projectiles/Summon/SilvaCrystalExplosion.cs b/Projectiles/Summon/SilvaCrystalExplosion.cs index d1ab495e5b..3a153b26ba 100644 --- a/Projectiles/Summon/SilvaCrystalExplosion.cs +++ b/Projectiles/Summon/SilvaCrystalExplosion.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; projectile.ignoreWater = true; projectile.timeLeft = 900; - projectile.minion = true; + projectile.minion = true; } public override void AI() diff --git a/Projectiles/Summon/SiriusBeam.cs b/Projectiles/Summon/SiriusBeam.cs index ec62334050..9237b21737 100644 --- a/Projectiles/Summon/SiriusBeam.cs +++ b/Projectiles/Summon/SiriusBeam.cs @@ -25,9 +25,9 @@ namespace CalamityMod.Projectiles.Summon projectile.minionSlots = 0f; projectile.extraUpdates = 220; projectile.timeLeft = 1000; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 110; - projectile.tileCollide = false; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 110; + projectile.tileCollide = false; } public override void AI() @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Summon { target.AddBuff(ModContent.BuffType(), 180); float x4 = Main.rgbToHsl(new Color(103, 203, Main.DiscoB)).X; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, x4, (float)projectile.whoAmI); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, x4, (float)projectile.whoAmI); } } } diff --git a/Projectiles/Summon/SiriusExplosion.cs b/Projectiles/Summon/SiriusExplosion.cs index 55109a69b2..57f5e5abfb 100644 --- a/Projectiles/Summon/SiriusExplosion.cs +++ b/Projectiles/Summon/SiriusExplosion.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; projectile.ignoreWater = true; projectile.timeLeft = 900; - projectile.minion = true; + projectile.minion = true; } public override void AI() diff --git a/Projectiles/Summon/SiriusMinion.cs b/Projectiles/Summon/SiriusMinion.cs index a90ae92670..608636d846 100644 --- a/Projectiles/Summon/SiriusMinion.cs +++ b/Projectiles/Summon/SiriusMinion.cs @@ -7,149 +7,149 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SiriusMinion : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Sirius"); - ProjectileID.Sets.MinionSacrificable[projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; - } + public class SiriusMinion : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sirius"); + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = 38; - projectile.height = 48; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.minionSlots = 1f; - projectile.timeLeft = 18000; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.timeLeft *= 5; - projectile.minion = true; - } + public override void SetDefaults() + { + projectile.width = 38; + projectile.height = 48; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 1f; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft *= 5; + projectile.minion = true; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); - bool correctMinion = projectile.type == ModContent.ProjectileType(); - if (correctMinion) - { - if (player.dead) - { - modPlayer.sirius = false; - } - if (modPlayer.sirius) - { - projectile.timeLeft = 2; - } - } - player.AddBuff(ModContent.BuffType(), 3600); + bool correctMinion = projectile.type == ModContent.ProjectileType(); + if (correctMinion) + { + if (player.dead) + { + modPlayer.sirius = false; + } + if (modPlayer.sirius) + { + projectile.timeLeft = 2; + } + } + player.AddBuff(ModContent.BuffType(), 3600); - projectile.minionSlots = projectile.ai[0]; - Lighting.AddLight(projectile.Center, 1f, 0.5f, 5f); + projectile.minionSlots = projectile.ai[0]; + Lighting.AddLight(projectile.Center, 1f, 0.5f, 5f); - projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); - if (player.gravDir == -1f) - { - projectile.position.Y += 120f; - projectile.rotation = MathHelper.Pi; - } - else - { - projectile.rotation = 0f; - } - projectile.position.X = (int)projectile.position.X; - projectile.position.Y = (int)projectile.position.Y; + projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); + if (player.gravDir == -1f) + { + projectile.position.Y += 120f; + projectile.rotation = MathHelper.Pi; + } + else + { + projectile.rotation = 0f; + } + projectile.position.X = (int)projectile.position.X; + projectile.position.Y = (int)projectile.position.Y; - float scalar = (float)Main.mouseTextColor / 200f - 0.35f; - scalar *= 0.2f; - projectile.scale = scalar + 0.95f; + float scalar = (float)Main.mouseTextColor / 200f - 0.35f; + scalar *= 0.2f; + projectile.scale = scalar + 0.95f; - if (projectile.localAI[0] == 0f) - { - projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); - projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - int dustAmt = 50; - for (int d = 0; d < dustAmt; d++) - { - int sirius = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 20, 0f, 0f, 0, default, 1f); - Main.dust[sirius].velocity *= 2f; - Main.dust[sirius].scale *= 1.15f; - } - projectile.localAI[0] += 1f; - } + if (projectile.localAI[0] == 0f) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + int dustAmt = 50; + for (int d = 0; d < dustAmt; d++) + { + int sirius = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 20, 0f, 0f, 0, default, 1f); + Main.dust[sirius].velocity *= 2f; + Main.dust[sirius].scale *= 1.15f; + } + projectile.localAI[0] += 1f; + } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) - { - int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / - projectile.Calamity().spawnedPlayerMinionDamageValue * player.MinionDamage()); - projectile.damage = damage2; - } - if (projectile.owner == Main.myPlayer) - { - if (projectile.ai[1] != 0f) - { - projectile.ai[1] -= 1f; - return; - } - Vector2 targetVec = projectile.position; - float maxDistance = 7000f; - bool hasTarget = false; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDistance = (npc.width / 2) + (npc.height / 2); + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * player.MinionDamage()); + projectile.damage = damage2; + } + if (projectile.owner == Main.myPlayer) + { + if (projectile.ai[1] != 0f) + { + projectile.ai[1] -= 1f; + return; + } + Vector2 targetVec = projectile.position; + float maxDistance = 7000f; + bool hasTarget = false; + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - targetVec = npc.Center; - hasTarget = true; - } - } - } - if (!hasTarget) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDistance = (npc.width / 2) + (npc.height / 2); + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + targetVec = npc.Center; + hasTarget = true; + } + } + } + if (!hasTarget) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - targetVec = npc.Center; - hasTarget = true; - } - } - } - } - if (hasTarget) - { - float projSpeed = 15f; - Vector2 source = new Vector2(projectile.Center.X - 4f, projectile.Center.Y); - Vector2 velocity = targetVec - projectile.Center; - float targetDist = velocity.Length(); - targetDist = projSpeed / targetDist; - velocity.X *= targetDist; - velocity.Y *= targetDist; - float damageMult = ((float)Math.Log(projectile.ai[0], MathHelper.E)) + 1f; - int beam = Projectile.NewProjectile(source, velocity, ModContent.ProjectileType(), (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner); - Main.projectile[beam].penetrate = (int)projectile.ai[0]; - projectile.ai[1] = 30f; - } - } - } + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + targetVec = npc.Center; + hasTarget = true; + } + } + } + } + if (hasTarget) + { + float projSpeed = 15f; + Vector2 source = new Vector2(projectile.Center.X - 4f, projectile.Center.Y); + Vector2 velocity = targetVec - projectile.Center; + float targetDist = velocity.Length(); + targetDist = projSpeed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; + float damageMult = ((float)Math.Log(projectile.ai[0], MathHelper.E)) + 1f; + int beam = Projectile.NewProjectile(source, velocity, ModContent.ProjectileType(), (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner); + Main.projectile[beam].penetrate = (int)projectile.ai[0]; + projectile.ai[1] = 30f; + } + } + } - public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); - public override bool CanDamage() => false; - } + public override bool CanDamage() => false; + } } diff --git a/Projectiles/Summon/SkeletalDragonChild.cs b/Projectiles/Summon/SkeletalDragonChild.cs index 248134b6c1..675b973d63 100644 --- a/Projectiles/Summon/SkeletalDragonChild.cs +++ b/Projectiles/Summon/SkeletalDragonChild.cs @@ -5,7 +5,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SkeletalDragonChild : ModProjectile + public class SkeletalDragonChild : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Summon/SkeletalDragonMother.cs b/Projectiles/Summon/SkeletalDragonMother.cs index 094a4c4d8a..fd431dbd68 100644 --- a/Projectiles/Summon/SkeletalDragonMother.cs +++ b/Projectiles/Summon/SkeletalDragonMother.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SkeletalDragonMother : ModProjectile + public class SkeletalDragonMother : ModProjectile { public const float DistanceToCheck = 1100f; public override void SetStaticDefaults() @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Summon if (target != null) { - projectile.extraUpdates = 1; + projectile.extraUpdates = 1; projectile.ai[0]++; // Arc towards enemy every 60 frames for 30 frames. @@ -112,7 +112,7 @@ namespace CalamityMod.Projectiles.Summon } else if (projectile.Distance(player.Center) > 175f) { - projectile.extraUpdates = 0; + projectile.extraUpdates = 0; projectile.ai[1] = 0f; projectile.velocity = (projectile.velocity * 24f + projectile.SafeDirectionTo(player.Center) * 16f) / 25f; if (projectile.Distance(player.Center) > 3250f) diff --git a/Projectiles/Summon/SlimePuppet.cs b/Projectiles/Summon/SlimePuppet.cs index 62d2d5c841..727d75bca2 100644 --- a/Projectiles/Summon/SlimePuppet.cs +++ b/Projectiles/Summon/SlimePuppet.cs @@ -7,9 +7,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SlimePuppet : ModProjectile + public class SlimePuppet : ModProjectile { - public Player Owner => Main.player[projectile.owner]; + public Player Owner => Main.player[projectile.owner]; public override void SetStaticDefaults() { DisplayName.SetDefault("Slime Puppet"); @@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Summon public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 100); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 100); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -110,7 +110,7 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Summon/SolarGod.cs b/Projectiles/Summon/SolarGod.cs index ff132c7b41..f2f935691f 100644 --- a/Projectiles/Summon/SolarGod.cs +++ b/Projectiles/Summon/SolarGod.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SolarGod : ModProjectile + public class SolarGod : ModProjectile { public override void SetStaticDefaults() { @@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[0] -= 1f; return; } - Vector2 targetPos = projectile.position; + Vector2 targetPos = projectile.position; float maxDistance = 700f; bool foundTarget = false; if (player.HasMinionAttackTargetNPC) @@ -98,7 +98,7 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float npcDist = Vector2.Distance(projectile.Center, npc.Center); + float npcDist = Vector2.Distance(projectile.Center, npc.Center); if (npcDist < maxDistance && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) { targetPos = npc.Center; @@ -110,14 +110,14 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < Main.maxNPCs; i++) { - NPC npc = Main.npc[i]; + NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(projectile, false)) { - float npcDist = Vector2.Distance(projectile.Center, npc.Center); + float npcDist = Vector2.Distance(projectile.Center, npc.Center); if (npcDist < maxDistance && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) { maxDistance = npcDist; - targetPos = npc.Center; + targetPos = npc.Center; foundTarget = true; } } @@ -127,9 +127,9 @@ namespace CalamityMod.Projectiles.Summon { float shootSpeed = 15f; Vector2 source = projectile.Center; - Vector2 velocity = targetPos - source; - velocity.Normalize(); - velocity *= shootSpeed; + Vector2 velocity = targetPos - source; + velocity.Normalize(); + velocity *= shootSpeed; Projectile.NewProjectile(source, velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); projectile.ai[0] = 20f; } diff --git a/Projectiles/Summon/SolarPixie.cs b/Projectiles/Summon/SolarPixie.cs index f55f3291c6..f5dfacf2fa 100644 --- a/Projectiles/Summon/SolarPixie.cs +++ b/Projectiles/Summon/SolarPixie.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SolarPixie : ModProjectile + public class SolarPixie : ModProjectile { public override void SetStaticDefaults() { @@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[0] -= 1f; return; } - Vector2 targetPos = projectile.position; + Vector2 targetPos = projectile.position; float maxDistance = 700f; bool foundTarget = false; if (player.HasMinionAttackTargetNPC) @@ -98,7 +98,7 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float npcDist = Vector2.Distance(projectile.Center, npc.Center); + float npcDist = Vector2.Distance(projectile.Center, npc.Center); if (npcDist < maxDistance && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) { targetPos = npc.Center; @@ -110,14 +110,14 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < Main.maxNPCs; i++) { - NPC npc = Main.npc[i]; + NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(projectile, false)) { - float npcDist = Vector2.Distance(projectile.Center, npc.Center); + float npcDist = Vector2.Distance(projectile.Center, npc.Center); if (npcDist < maxDistance && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) { maxDistance = npcDist; - targetPos = npc.Center; + targetPos = npc.Center; foundTarget = true; } } @@ -127,12 +127,12 @@ namespace CalamityMod.Projectiles.Summon { float shootSpeed = 30f; Vector2 source = projectile.Center; - Vector2 velocity = targetPos - source; - velocity.Normalize(); - velocity *= shootSpeed; + Vector2 velocity = targetPos - source; + velocity.Normalize(); + velocity *= shootSpeed; int beam = Projectile.NewProjectile(source, velocity, ProjectileID.HeatRay, projectile.damage, projectile.knockBack, projectile.owner); - if (beam.WithinBounds(Main.maxProjectiles)) - Main.projectile[beam].Calamity().forceMinion = true; + if (beam.WithinBounds(Main.maxProjectiles)) + Main.projectile[beam].Calamity().forceMinion = true; projectile.ai[0] = 50f; } } diff --git a/Projectiles/Summon/SonOfYharon.cs b/Projectiles/Summon/SonOfYharon.cs index 190118c38d..fd50005f50 100644 --- a/Projectiles/Summon/SonOfYharon.cs +++ b/Projectiles/Summon/SonOfYharon.cs @@ -74,24 +74,24 @@ namespace CalamityMod.Projectiles.Summon { projectile.frame++; } - if (RamCountdown > 0f || RamReboundCountdown > 0f) - { - if (projectile.frame < 6) - { - projectile.frame = 6; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 6; - } - } - else - { - if (projectile.frame >= 6) - { - projectile.frame = 0; - } - } + if (RamCountdown > 0f || RamReboundCountdown > 0f) + { + if (projectile.frame < 6) + { + projectile.frame = 6; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 6; + } + } + else + { + if (projectile.frame >= 6) + { + projectile.frame = 0; + } + } NPC potentialTarget = projectile.Center.MinionHoming(2000f, Owner); diff --git a/Projectiles/Summon/Spikecrag.cs b/Projectiles/Summon/Spikecrag.cs index 2d0a91b2c3..920a9c290e 100644 --- a/Projectiles/Summon/Spikecrag.cs +++ b/Projectiles/Summon/Spikecrag.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class Spikecrag : ModProjectile + public class Spikecrag : ModProjectile { public override void SetStaticDefaults() @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (projectile.localAI[0] == 0f) { @@ -60,32 +60,32 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity.Y = 10f; } - projectile.StickToTiles(false, false); + projectile.StickToTiles(false, false); - if (projectile.ai[0] > 0f) - { - projectile.ai[0] -= 1f; - return; - } + if (projectile.ai[0] > 0f) + { + projectile.ai[0] -= 1f; + return; + } - float maxDistance = 1000f; - bool homeIn = false; + 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); + 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) && Collision.CanHit(projectile.Center, projectile.width, projectile.height, Main.npc[i].Center, Main.npc[i].width, Main.npc[i].height)) - { - homeIn = true; - break; - } - } - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(projectile.Center, projectile.width, projectile.height, Main.npc[i].Center, Main.npc[i].width, Main.npc[i].height)) + { + homeIn = true; + break; + } + } + } - if (projectile.owner == Main.myPlayer && homeIn) + if (projectile.owner == Main.myPlayer && homeIn) { projectile.ai[1] += 1f; if ((projectile.ai[1] % 10f) == 0f) diff --git a/Projectiles/Summon/SquirrelSquireAcorn.cs b/Projectiles/Summon/SquirrelSquireAcorn.cs index 244818d328..d8dbfa6510 100644 --- a/Projectiles/Summon/SquirrelSquireAcorn.cs +++ b/Projectiles/Summon/SquirrelSquireAcorn.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SquirrelSquireAcorn : ModProjectile + public class SquirrelSquireAcorn : ModProjectile { public const float Gravity = 0.5f; public override void SetStaticDefaults() diff --git a/Projectiles/Summon/SquirrelSquireMinion.cs b/Projectiles/Summon/SquirrelSquireMinion.cs index a395dc7733..b86684a4af 100644 --- a/Projectiles/Summon/SquirrelSquireMinion.cs +++ b/Projectiles/Summon/SquirrelSquireMinion.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SquirrelSquireMinion : ModProjectile + public class SquirrelSquireMinion : ModProjectile { public ref float AttackTimer => ref projectile.ai[1]; public bool Attacking diff --git a/Projectiles/Summon/StormMarkSummon.cs b/Projectiles/Summon/StormMarkSummon.cs index df439b84aa..837269884e 100644 --- a/Projectiles/Summon/StormMarkSummon.cs +++ b/Projectiles/Summon/StormMarkSummon.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class StormMarkSummon : ModProjectile + public class StormMarkSummon : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Summon/StormjawBaby.cs b/Projectiles/Summon/StormjawBaby.cs index 599c805dc4..bd8c7240a2 100644 --- a/Projectiles/Summon/StormjawBaby.cs +++ b/Projectiles/Summon/StormjawBaby.cs @@ -8,12 +8,12 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class StormjawBaby : ModProjectile + public class StormjawBaby : ModProjectile { public float dust = 0f; - private int sparkCounter = 0; - private int targetIndex = -1; - private Vector2 idlePos = Vector2.Zero; + private int sparkCounter = 0; + private int targetIndex = -1; + private Vector2 idlePos = Vector2.Zero; public Player player => Main.player[projectile.owner]; public override void SetStaticDefaults() @@ -41,23 +41,23 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - OnSpawn(); - SummonChecks(); + OnSpawn(); + SummonChecks(); - idlePos = player.Center; - idlePos.X -= (15f + player.width / 2f) * player.direction; - idlePos.X -= projectile.minionPos * 40f * player.direction; + idlePos = player.Center; + idlePos.X -= (15f + player.width / 2f) * player.direction; + idlePos.X -= projectile.minionPos * 40f * player.direction; - FindTarget(); - FlyBackToPlayer(); - AttackTarget(); - GoToTarget(); - IdleBehavior(); - } + FindTarget(); + FlyBackToPlayer(); + AttackTarget(); + GoToTarget(); + IdleBehavior(); + } - private void OnSpawn() - { - // Handle stuff on spawn & variable damage + private void OnSpawn() + { + // Handle stuff on spawn & variable damage if (dust == 0f) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -75,10 +75,10 @@ namespace CalamityMod.Projectiles.Summon } dust += 1f; } - } + } - private void SummonChecks() - { + private void SummonChecks() + { if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / @@ -99,480 +99,480 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - } + } - private void FindTarget() - { - targetIndex = -1; - float maxDistance = 800f; - if (projectile.ai[0] == 0f) //find target - { - NPC targetedNPC = projectile.OwnerMinionAttackTargetNPC; - if (targetedNPC != null && targetedNPC.CanBeChasedBy(projectile, false)) - { - float num1 = (targetedNPC.Center - projectile.Center).Length(); - if (num1 < maxDistance) - { - targetIndex = targetedNPC.whoAmI; - maxDistance = num1; - } - } - if (targetIndex < 0) - { - for (int i = 0; i < Main.maxNPCs; ++i) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false)) - { - float num1 = (npc.Center - projectile.Center).Length(); - if (num1 < maxDistance) - { - targetIndex = i; - maxDistance = num1; - } - } - } - } - } - } + private void FindTarget() + { + targetIndex = -1; + float maxDistance = 800f; + if (projectile.ai[0] == 0f) //find target + { + NPC targetedNPC = projectile.OwnerMinionAttackTargetNPC; + if (targetedNPC != null && targetedNPC.CanBeChasedBy(projectile, false)) + { + float num1 = (targetedNPC.Center - projectile.Center).Length(); + if (num1 < maxDistance) + { + targetIndex = targetedNPC.whoAmI; + maxDistance = num1; + } + } + if (targetIndex < 0) + { + for (int i = 0; i < Main.maxNPCs; ++i) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float num1 = (npc.Center - projectile.Center).Length(); + if (num1 < maxDistance) + { + targetIndex = i; + maxDistance = num1; + } + } + } + } + } + } - private void FlyBackToPlayer() - { - if (projectile.ai[0] == 1f) //returning to player - { - projectile.tileCollide = false; - Vector2 returnPos = player.Center - projectile.Center; - returnPos.X -= (float) (40 * player.direction); - returnPos.X -= (float) (40 * projectile.minionPos * player.direction); - returnPos.Y -= 60f; - float playerDist = returnPos.Length(); - float returnSpeed = 12f; - float acceleration = 0.4f; - if (returnSpeed < projectile.velocity.Length()) - returnSpeed = projectile.velocity.Length(); + private void FlyBackToPlayer() + { + if (projectile.ai[0] == 1f) //returning to player + { + projectile.tileCollide = false; + Vector2 returnPos = player.Center - projectile.Center; + returnPos.X -= (float) (40 * player.direction); + returnPos.X -= (float) (40 * projectile.minionPos * player.direction); + returnPos.Y -= 60f; + float playerDist = returnPos.Length(); + float returnSpeed = 12f; + float acceleration = 0.4f; + if (returnSpeed < projectile.velocity.Length()) + returnSpeed = projectile.velocity.Length(); - //if close enough to the player and has tile to stand on, return to normal - if (playerDist < 100f && player.velocity.Y == 0f && (projectile.Bottom.Y <= player.Bottom.Y && !Collision.SolidCollision(projectile.Center, projectile.width, projectile.height))) - { - projectile.ai[0] = 0f; - if (projectile.velocity.Y < -6f) - projectile.velocity.Y = -6f; - } - if (playerDist > 2000f) - { - projectile.position = player.Center - projectile.Size / 2f; - projectile.netUpdate = true; - } - if (playerDist < 50f) - { - if (projectile.velocity.Length() > 2f) - { - projectile.velocity *= 0.99f; - } - acceleration = 0.01f; - } - else - { - if (playerDist < 100f) - { - acceleration = 0.1f; - } - if (playerDist > 300f) - { - acceleration = 1f; - } - playerDist = returnSpeed / playerDist; - returnPos *= playerDist; - } - if (projectile.velocity.X < returnPos.X) - { - projectile.velocity.X += acceleration; - if (acceleration > 0.05f && projectile.velocity.X < 0f) - { - projectile.velocity.X += acceleration; - } - } - if (projectile.velocity.X > returnPos.X) - { - projectile.velocity.X -= acceleration; - if (acceleration > 0.05f && projectile.velocity.X > 0f) - { - projectile.velocity.X -= acceleration; - } - } - if (projectile.velocity.Y < returnPos.Y) - { - projectile.velocity.Y += acceleration; - if (acceleration > 0.05f && projectile.velocity.Y < 0f) - { - projectile.velocity.Y += acceleration * 2f; - } - } - if (projectile.velocity.Y > returnPos.Y) - { - projectile.velocity.Y -= acceleration; - if (acceleration > 0.05f && projectile.velocity.Y > 0f) - { - projectile.velocity.Y -= acceleration * 2f; - } - } - if (projectile.frame < 6 || projectile.frame > 9) - { - projectile.frame = 6; - } - else - { - projectile.frameCounter++; - if (projectile.frameCounter > 3) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= 10) - { - projectile.frame = 6; - } - } - if (projectile.velocity.X > 0.5f) - projectile.spriteDirection = 1; - else if (projectile.velocity.X < -0.5f) - projectile.spriteDirection = -1; - projectile.rotation = projectile.velocity.ToRotation() + projectile.spriteDirection != 1 ? MathHelper.Pi : 0f; - } - } + //if close enough to the player and has tile to stand on, return to normal + if (playerDist < 100f && player.velocity.Y == 0f && (projectile.Bottom.Y <= player.Bottom.Y && !Collision.SolidCollision(projectile.Center, projectile.width, projectile.height))) + { + projectile.ai[0] = 0f; + if (projectile.velocity.Y < -6f) + projectile.velocity.Y = -6f; + } + if (playerDist > 2000f) + { + projectile.position = player.Center - projectile.Size / 2f; + projectile.netUpdate = true; + } + if (playerDist < 50f) + { + if (projectile.velocity.Length() > 2f) + { + projectile.velocity *= 0.99f; + } + acceleration = 0.01f; + } + else + { + if (playerDist < 100f) + { + acceleration = 0.1f; + } + if (playerDist > 300f) + { + acceleration = 1f; + } + playerDist = returnSpeed / playerDist; + returnPos *= playerDist; + } + if (projectile.velocity.X < returnPos.X) + { + projectile.velocity.X += acceleration; + if (acceleration > 0.05f && projectile.velocity.X < 0f) + { + projectile.velocity.X += acceleration; + } + } + if (projectile.velocity.X > returnPos.X) + { + projectile.velocity.X -= acceleration; + if (acceleration > 0.05f && projectile.velocity.X > 0f) + { + projectile.velocity.X -= acceleration; + } + } + if (projectile.velocity.Y < returnPos.Y) + { + projectile.velocity.Y += acceleration; + if (acceleration > 0.05f && projectile.velocity.Y < 0f) + { + projectile.velocity.Y += acceleration * 2f; + } + } + if (projectile.velocity.Y > returnPos.Y) + { + projectile.velocity.Y -= acceleration; + if (acceleration > 0.05f && projectile.velocity.Y > 0f) + { + projectile.velocity.Y -= acceleration * 2f; + } + } + if (projectile.frame < 6 || projectile.frame > 9) + { + projectile.frame = 6; + } + else + { + projectile.frameCounter++; + if (projectile.frameCounter > 3) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 10) + { + projectile.frame = 6; + } + } + if (projectile.velocity.X > 0.5f) + projectile.spriteDirection = 1; + else if (projectile.velocity.X < -0.5f) + projectile.spriteDirection = -1; + projectile.rotation = projectile.velocity.ToRotation() + projectile.spriteDirection != 1 ? MathHelper.Pi : 0f; + } + } - private void AttackTarget() - { - if (projectile.ai[0] == 2f) //attack target - { - projectile.spriteDirection = -projectile.direction; - projectile.rotation = 0f; - if (projectile.velocity.Y == 0f) - { - if (projectile.velocity.X == 0f) - { - projectile.frame = 0; - projectile.frameCounter = 0; - } - else if (Math.Abs(projectile.velocity.X) >= 0.5f) - { - projectile.frameCounter += (int)Math.Abs(projectile.velocity.X); - projectile.frameCounter += 1; - if (projectile.frameCounter > 10) - { - projectile.frame += 1; - projectile.frameCounter = 0; - } - if (projectile.frame >= 6) - projectile.frame = 0; - } - else - { - projectile.frame = 0; - projectile.frameCounter = 0; - } - } - else if (projectile.velocity.Y != 0f) - { - projectile.frameCounter = 0; - projectile.frame = 0; - } - projectile.velocity.Y += 0.4f; - if (projectile.velocity.Y > 10f) - projectile.velocity.Y = 10f; + private void AttackTarget() + { + if (projectile.ai[0] == 2f) //attack target + { + projectile.spriteDirection = -projectile.direction; + projectile.rotation = 0f; + if (projectile.velocity.Y == 0f) + { + if (projectile.velocity.X == 0f) + { + projectile.frame = 0; + projectile.frameCounter = 0; + } + else if (Math.Abs(projectile.velocity.X) >= 0.5f) + { + projectile.frameCounter += (int)Math.Abs(projectile.velocity.X); + projectile.frameCounter += 1; + if (projectile.frameCounter > 10) + { + projectile.frame += 1; + projectile.frameCounter = 0; + } + if (projectile.frame >= 6) + projectile.frame = 0; + } + else + { + projectile.frame = 0; + projectile.frameCounter = 0; + } + } + else if (projectile.velocity.Y != 0f) + { + projectile.frameCounter = 0; + projectile.frame = 0; + } + projectile.velocity.Y += 0.4f; + if (projectile.velocity.Y > 10f) + projectile.velocity.Y = 10f; - sparkCounter += Main.rand.Next(1,4); - if (sparkCounter >= 20) - { - if (Main.myPlayer == projectile.owner) - { + sparkCounter += Main.rand.Next(1,4); + if (sparkCounter >= 20) + { + if (Main.myPlayer == projectile.owner) + { for (int i = 0; i < Main.rand.Next(1,4); i++) { - Vector2 sparkS = new Vector2(Main.rand.NextFloat(-5f, 5f), Main.rand.NextFloat(-5f, 5f)); - int spark = Projectile.NewProjectile(projectile.Center, sparkS, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - if (spark.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[spark].Calamity().forceMinion = true; - Main.projectile[spark].timeLeft = 120; - Main.projectile[spark].penetrate = 3; - Main.projectile[spark].usesIDStaticNPCImmunity = true; - Main.projectile[spark].idStaticNPCHitCooldown = 10; - Main.projectile[spark].usesLocalNPCImmunity = false; - } - } - sparkCounter = 0; - } - } + Vector2 sparkS = new Vector2(Main.rand.NextFloat(-5f, 5f), Main.rand.NextFloat(-5f, 5f)); + int spark = Projectile.NewProjectile(projectile.Center, sparkS, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + if (spark.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[spark].Calamity().forceMinion = true; + Main.projectile[spark].timeLeft = 120; + Main.projectile[spark].penetrate = 3; + Main.projectile[spark].usesIDStaticNPCImmunity = true; + Main.projectile[spark].idStaticNPCHitCooldown = 10; + Main.projectile[spark].usesLocalNPCImmunity = false; + } + } + sparkCounter = 0; + } + } - projectile.ai[1] -= 1f; - if (projectile.ai[1] <= 0f) - { - projectile.ai[1] = 0f; - projectile.ai[0] = 0f; - projectile.netUpdate = true; - return; - } - } - else - { + projectile.ai[1] -= 1f; + if (projectile.ai[1] <= 0f) + { + projectile.ai[1] = 0f; + projectile.ai[0] = 0f; + projectile.netUpdate = true; + return; + } + } + else + { 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++) { - NPC npc = Main.npc[i]; + NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(projectile, false) && npc.immune[projectile.owner] <= 0) { Rectangle rect = npc.getRect(); if (rectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) { - sparkCounter += Main.rand.Next(1,3); - if (sparkCounter >= 20) - { - if (Main.myPlayer == projectile.owner) - { - for (int j = 0; j < Main.rand.Next(1,4); j++) - { - Vector2 sparkS = new Vector2(Main.rand.NextFloat(-5f, 5f), Main.rand.NextFloat(-5f, 5f)); - int spark = Projectile.NewProjectile(projectile.Center, sparkS, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - if (spark.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[spark].Calamity().forceMinion = true; - Main.projectile[spark].timeLeft = 120; - Main.projectile[spark].penetrate = 3; - Main.projectile[spark].usesIDStaticNPCImmunity = true; - Main.projectile[spark].idStaticNPCHitCooldown = 10; - Main.projectile[spark].usesLocalNPCImmunity = false; - } - } - sparkCounter = 0; - } - } + sparkCounter += Main.rand.Next(1,3); + if (sparkCounter >= 20) + { + if (Main.myPlayer == projectile.owner) + { + for (int j = 0; j < Main.rand.Next(1,4); j++) + { + Vector2 sparkS = new Vector2(Main.rand.NextFloat(-5f, 5f), Main.rand.NextFloat(-5f, 5f)); + int spark = Projectile.NewProjectile(projectile.Center, sparkS, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + if (spark.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[spark].Calamity().forceMinion = true; + Main.projectile[spark].timeLeft = 120; + Main.projectile[spark].penetrate = 3; + Main.projectile[spark].usesIDStaticNPCImmunity = true; + Main.projectile[spark].idStaticNPCHitCooldown = 10; + Main.projectile[spark].usesLocalNPCImmunity = false; + } + } + sparkCounter = 0; + } + } } } } - } - } + } + } - private void GoToTarget() - { - if (targetIndex >= 0) //go to target - { - float rangeofSight = 700f; - float attackZone = 20f; - if (projectile.position.Y > Main.worldSurface * 16f) - rangeofSight *= 0.7f; - NPC npc = Main.npc[targetIndex]; - float targetDist = (npc.Center - projectile.Center).Length(); - Collision.CanHit(projectile.Center, projectile.width, projectile.height, npc.Center, npc.width, npc.height); - if (targetDist < rangeofSight) - { - idlePos = npc.Center; - if (npc.Center.Y < projectile.Center.Y - 30f && projectile.velocity.Y == 0f) - { - float targetYDist = Math.Abs(npc.Center.Y - projectile.Center.Y); - if (targetYDist < 120f) - projectile.velocity.Y = -10f; - else if (targetYDist < 210f) - projectile.velocity.Y = -13f; - else if (targetYDist < 270f) - projectile.velocity.Y = -15f; - else if (targetYDist < 310f) - projectile.velocity.Y = -17f; - else if (targetYDist < 380f) - projectile.velocity.Y = -18f; - } - } - if (targetDist < attackZone) - { - projectile.ai[0] = 2f; - projectile.ai[1] = 15f; - projectile.netUpdate = true; - } - } - } + private void GoToTarget() + { + if (targetIndex >= 0) //go to target + { + float rangeofSight = 700f; + float attackZone = 20f; + if (projectile.position.Y > Main.worldSurface * 16f) + rangeofSight *= 0.7f; + NPC npc = Main.npc[targetIndex]; + float targetDist = (npc.Center - projectile.Center).Length(); + Collision.CanHit(projectile.Center, projectile.width, projectile.height, npc.Center, npc.width, npc.height); + if (targetDist < rangeofSight) + { + idlePos = npc.Center; + if (npc.Center.Y < projectile.Center.Y - 30f && projectile.velocity.Y == 0f) + { + float targetYDist = Math.Abs(npc.Center.Y - projectile.Center.Y); + if (targetYDist < 120f) + projectile.velocity.Y = -10f; + else if (targetYDist < 210f) + projectile.velocity.Y = -13f; + else if (targetYDist < 270f) + projectile.velocity.Y = -15f; + else if (targetYDist < 310f) + projectile.velocity.Y = -17f; + else if (targetYDist < 380f) + projectile.velocity.Y = -18f; + } + } + if (targetDist < attackZone) + { + projectile.ai[0] = 2f; + projectile.ai[1] = 15f; + projectile.netUpdate = true; + } + } + } - private void IdleBehavior() - { - if (projectile.ai[0] == 0f && targetIndex < 0) //passive AI - { - if (sparkCounter > 0) - sparkCounter--; - if (sparkCounter < 0) - sparkCounter = 0; + private void IdleBehavior() + { + if (projectile.ai[0] == 0f && targetIndex < 0) //passive AI + { + if (sparkCounter > 0) + sparkCounter--; + if (sparkCounter < 0) + sparkCounter = 0; - float sepAnxietyDist = 500f; - Vector2 playerDist = player.Center - projectile.Center; - // Teleport to the player if too far - if (playerDist.Length() > 2000f) - projectile.position = player.Center - projectile.Size / 2f; - // Fly back if too far from the player - else if (playerDist.Length() > sepAnxietyDist || Math.Abs(playerDist.Y) > 300f) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - if (projectile.velocity.Y > 0f && playerDist.Y < 0f) - projectile.velocity.Y = 0f; - if (projectile.velocity.Y < 0f && playerDist.Y > 0f) - projectile.velocity.Y = 0f; - } - } + float sepAnxietyDist = 500f; + Vector2 playerDist = player.Center - projectile.Center; + // Teleport to the player if too far + if (playerDist.Length() > 2000f) + projectile.position = player.Center - projectile.Size / 2f; + // Fly back if too far from the player + else if (playerDist.Length() > sepAnxietyDist || Math.Abs(playerDist.Y) > 300f) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + if (projectile.velocity.Y > 0f && playerDist.Y < 0f) + projectile.velocity.Y = 0f; + if (projectile.velocity.Y < 0f && playerDist.Y > 0f) + projectile.velocity.Y = 0f; + } + } - if (projectile.ai[0] == 0f) - { - projectile.tileCollide = true; - float accelFast = 0.5f; - float maxSpeed = 4f; - float xVel = 4f; - float accelSlow = 0.1f; - if (xVel < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - { - xVel = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - accelFast = 0.7f; - } - int direction = 0; - bool flag3 = false; - float idleDist = idlePos.X - projectile.Center.X; - if (Math.Abs(idleDist) > 5f) - { - if (idleDist < 0f) - { - direction = -1; - if (projectile.velocity.X > -maxSpeed) - { - projectile.velocity.X -= accelFast; - } - else - { - projectile.velocity.X -= accelSlow; - } - } - else - { - direction = 1; - if (projectile.velocity.X < maxSpeed) - { - projectile.velocity.X += accelFast; - } - else - { - projectile.velocity.X += accelSlow; - } - } - } - else - { - projectile.velocity.X *= 0.9f; - if (Math.Abs(projectile.velocity.X) < accelFast * 2f) - projectile.velocity.X = 0.0f; - } - if (direction != 0) - { - int xPos = (int)projectile.Center.X / 16; - int yPos = (int)projectile.position.Y / 16; - int x = xPos + direction + (int) projectile.velocity.X; - for (int y = yPos; y < yPos + projectile.height / 16 + 1; ++y) - { - if (WorldGen.SolidTile(x, y)) - flag3 = true; - } - } - Collision.StepUp(ref projectile.position, ref projectile.velocity, projectile.width, projectile.height, ref projectile.stepSpeed, ref projectile.gfxOffY, 1, false, 0); - if (projectile.velocity.Y == 0f && flag3) - { - for (int i = 0; i < 3; ++i) - { - int x = (int)projectile.Center.X / 16; - if (i == 0) - x = (int)projectile.Left.X / 16; - if (i == 2) - x = (int)projectile.Right.X / 16; - int y = (int)projectile.Bottom.Y / 16; - Tile tile = Main.tile[x, y]; - if (WorldGen.SolidTile(x, y) || tile.halfBrick() || tile.slope() > 0 || TileID.Sets.Platforms[tile.type] && tile.active() && !tile.inActive()) - { - try - { - int xPos = (int)projectile.Center.X / 16; - int yPos = (int)projectile.Center.Y / 16; - int i2 = xPos + direction + (int)projectile.velocity.X; - if (!WorldGen.SolidTile(i2, yPos - 1) && !WorldGen.SolidTile(i2, yPos - 2)) - projectile.velocity.Y = -5.1f; - else if (!WorldGen.SolidTile(i2, yPos - 2)) - projectile.velocity.Y = -7.1f; - else if (WorldGen.SolidTile(i2, yPos - 5)) - projectile.velocity.Y = -11.1f; - else if (WorldGen.SolidTile(i2, yPos - 4)) - projectile.velocity.Y = -10.1f; - else - projectile.velocity.Y = -9.1f; - } - catch - { - projectile.velocity.Y = -9.1f; - } - } - } - } - if (projectile.velocity.X > xVel) - projectile.velocity.X = xVel; - if (projectile.velocity.X < -xVel) - projectile.velocity.X = -xVel; - if (projectile.velocity.X < 0f) - projectile.direction = -1; - if (projectile.velocity.X > 0f) - projectile.direction = 1; - if (projectile.velocity.X > accelFast && direction == 1) - projectile.direction = 1; - if (projectile.velocity.X < -accelFast && direction == -1) - projectile.direction = -1; - projectile.spriteDirection = -projectile.direction; - projectile.rotation = 0f; - if (projectile.velocity.Y == 0f) - { - if (projectile.velocity.X == 0f) - { - projectile.frame = 0; - projectile.frameCounter = 0; - float xDist = player.Center.X - projectile.Center.X; - xDist -= 40f * player.direction; - xDist -= 40f * projectile.minionPos * player.direction; - if (xDist > 0) - projectile.spriteDirection = projectile.direction; - } - else if (Math.Abs(projectile.velocity.X) >= 0.5f) - { - projectile.frameCounter += (int)Math.Abs(projectile.velocity.X); - projectile.frameCounter += 1; - if (projectile.frameCounter > 10) - { - projectile.frame += 1; - projectile.frameCounter = 0; - } - if (projectile.frame >= 6) - projectile.frame = 0; - } - else - { - projectile.frame = 0; - projectile.frameCounter = 0; - } - } - else if (projectile.velocity.Y != 0f) - { - projectile.frameCounter = 0; - projectile.frame = 0; - } - projectile.velocity.Y += 0.4f; - if (projectile.velocity.Y > 10f) - projectile.velocity.Y = 10f; - } - } + if (projectile.ai[0] == 0f) + { + projectile.tileCollide = true; + float accelFast = 0.5f; + float maxSpeed = 4f; + float xVel = 4f; + float accelSlow = 0.1f; + if (xVel < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + { + xVel = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + accelFast = 0.7f; + } + int direction = 0; + bool flag3 = false; + float idleDist = idlePos.X - projectile.Center.X; + if (Math.Abs(idleDist) > 5f) + { + if (idleDist < 0f) + { + direction = -1; + if (projectile.velocity.X > -maxSpeed) + { + projectile.velocity.X -= accelFast; + } + else + { + projectile.velocity.X -= accelSlow; + } + } + else + { + direction = 1; + if (projectile.velocity.X < maxSpeed) + { + projectile.velocity.X += accelFast; + } + else + { + projectile.velocity.X += accelSlow; + } + } + } + else + { + projectile.velocity.X *= 0.9f; + if (Math.Abs(projectile.velocity.X) < accelFast * 2f) + projectile.velocity.X = 0.0f; + } + if (direction != 0) + { + int xPos = (int)projectile.Center.X / 16; + int yPos = (int)projectile.position.Y / 16; + int x = xPos + direction + (int) projectile.velocity.X; + for (int y = yPos; y < yPos + projectile.height / 16 + 1; ++y) + { + if (WorldGen.SolidTile(x, y)) + flag3 = true; + } + } + Collision.StepUp(ref projectile.position, ref projectile.velocity, projectile.width, projectile.height, ref projectile.stepSpeed, ref projectile.gfxOffY, 1, false, 0); + if (projectile.velocity.Y == 0f && flag3) + { + for (int i = 0; i < 3; ++i) + { + int x = (int)projectile.Center.X / 16; + if (i == 0) + x = (int)projectile.Left.X / 16; + if (i == 2) + x = (int)projectile.Right.X / 16; + int y = (int)projectile.Bottom.Y / 16; + Tile tile = Main.tile[x, y]; + if (WorldGen.SolidTile(x, y) || tile.halfBrick() || tile.slope() > 0 || TileID.Sets.Platforms[tile.type] && tile.active() && !tile.inActive()) + { + try + { + int xPos = (int)projectile.Center.X / 16; + int yPos = (int)projectile.Center.Y / 16; + int i2 = xPos + direction + (int)projectile.velocity.X; + if (!WorldGen.SolidTile(i2, yPos - 1) && !WorldGen.SolidTile(i2, yPos - 2)) + projectile.velocity.Y = -5.1f; + else if (!WorldGen.SolidTile(i2, yPos - 2)) + projectile.velocity.Y = -7.1f; + else if (WorldGen.SolidTile(i2, yPos - 5)) + projectile.velocity.Y = -11.1f; + else if (WorldGen.SolidTile(i2, yPos - 4)) + projectile.velocity.Y = -10.1f; + else + projectile.velocity.Y = -9.1f; + } + catch + { + projectile.velocity.Y = -9.1f; + } + } + } + } + if (projectile.velocity.X > xVel) + projectile.velocity.X = xVel; + if (projectile.velocity.X < -xVel) + projectile.velocity.X = -xVel; + if (projectile.velocity.X < 0f) + projectile.direction = -1; + if (projectile.velocity.X > 0f) + projectile.direction = 1; + if (projectile.velocity.X > accelFast && direction == 1) + projectile.direction = 1; + if (projectile.velocity.X < -accelFast && direction == -1) + projectile.direction = -1; + projectile.spriteDirection = -projectile.direction; + projectile.rotation = 0f; + if (projectile.velocity.Y == 0f) + { + if (projectile.velocity.X == 0f) + { + projectile.frame = 0; + projectile.frameCounter = 0; + float xDist = player.Center.X - projectile.Center.X; + xDist -= 40f * player.direction; + xDist -= 40f * projectile.minionPos * player.direction; + if (xDist > 0) + projectile.spriteDirection = projectile.direction; + } + else if (Math.Abs(projectile.velocity.X) >= 0.5f) + { + projectile.frameCounter += (int)Math.Abs(projectile.velocity.X); + projectile.frameCounter += 1; + if (projectile.frameCounter > 10) + { + projectile.frame += 1; + projectile.frameCounter = 0; + } + if (projectile.frame >= 6) + projectile.frame = 0; + } + else + { + projectile.frame = 0; + projectile.frameCounter = 0; + } + } + else if (projectile.velocity.Y != 0f) + { + projectile.frameCounter = 0; + projectile.frame = 0; + } + projectile.velocity.Y += 0.4f; + if (projectile.velocity.Y > 10f) + projectile.velocity.Y = 10f; + } + } public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) { - if (targetIndex < 0) - fallThrough = projectile.Bottom.Y < player.Top.Y; - else - fallThrough = projectile.Bottom.Y < Main.npc[targetIndex].Top.Y; + if (targetIndex < 0) + fallThrough = projectile.Bottom.Y < player.Top.Y; + else + fallThrough = projectile.Bottom.Y < Main.npc[targetIndex].Top.Y; return true; } @@ -580,8 +580,8 @@ namespace CalamityMod.Projectiles.Summon public override void Kill(int timeLeft) { - int index = Gore.NewGore(projectile.Center, new Vector2(0f, 0f), Main.rand.Next(61, 64), projectile.scale); - Main.gore[index].velocity *= 0.1f; + int index = Gore.NewGore(projectile.Center, new Vector2(0f, 0f), Main.rand.Next(61, 64), projectile.scale); + Main.gore[index].velocity *= 0.1f; } public override bool CanDamage() => false; diff --git a/Projectiles/Summon/SummonAstralExplosion.cs b/Projectiles/Summon/SummonAstralExplosion.cs index f647791e2b..6367f246c9 100644 --- a/Projectiles/Summon/SummonAstralExplosion.cs +++ b/Projectiles/Summon/SummonAstralExplosion.cs @@ -3,7 +3,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SummonAstralExplosion : ModProjectile + public class SummonAstralExplosion : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Summon/SummonBrimstoneExplosion.cs b/Projectiles/Summon/SummonBrimstoneExplosion.cs index 0c4eb00e90..12bcd894bc 100644 --- a/Projectiles/Summon/SummonBrimstoneExplosion.cs +++ b/Projectiles/Summon/SummonBrimstoneExplosion.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SummonBrimstoneExplosion : ModProjectile + public class SummonBrimstoneExplosion : ModProjectile { public override void SetStaticDefaults() { @@ -30,10 +30,10 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { if (projectile.localAI[0] == 0f) - { + { CreateInitialDust(); projectile.localAI[0] = 1f; - } + } // Emit crimson light. Lighting.AddLight(projectile.Center, Color.Red.ToVector3() * 1.1f); @@ -42,11 +42,11 @@ namespace CalamityMod.Projectiles.Summon } public void CreateInitialDust() - { + { float randomnessSmoothness = 3f; for (int i = 0; i < 10; i++) { - randomnessSmoothness += i; + randomnessSmoothness += i; int offsetVariance = (int)(randomnessSmoothness * 4f); for (int j = 0; j < 30; j++) @@ -63,10 +63,10 @@ namespace CalamityMod.Projectiles.Summon CalamityGlobalProjectile.ExpandHitboxBy(projectile, 48); } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { // Prevent absurd quantities of damage to the player. damage = (int)(damage * 0.018); } - } + } } diff --git a/Projectiles/Summon/SummonBrimstoneExplosionSmall.cs b/Projectiles/Summon/SummonBrimstoneExplosionSmall.cs index 24b4b6de0e..592d27ef65 100644 --- a/Projectiles/Summon/SummonBrimstoneExplosionSmall.cs +++ b/Projectiles/Summon/SummonBrimstoneExplosionSmall.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SummonBrimstoneExplosionSmall : ModProjectile + public class SummonBrimstoneExplosionSmall : ModProjectile { public override void SetStaticDefaults() { @@ -30,10 +30,10 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { if (projectile.localAI[0] == 0f) - { + { CreateInitialDust(); projectile.localAI[0] = 1f; - } + } // Emit crimson light. Lighting.AddLight(projectile.Center, Color.Red.ToVector3() * 1.1f); @@ -42,11 +42,11 @@ namespace CalamityMod.Projectiles.Summon } public void CreateInitialDust() - { + { float randomnessSmoothness = 3f; for (int i = 0; i < 6; i++) { - randomnessSmoothness += i * 0.36f; + randomnessSmoothness += i * 0.36f; for (int j = 0; j < 30; j++) { @@ -60,5 +60,5 @@ namespace CalamityMod.Projectiles.Summon projectile.Damage(); } - } + } } diff --git a/Projectiles/Summon/TacticalPlagueJet.cs b/Projectiles/Summon/TacticalPlagueJet.cs index c131a1e9e2..480bfb6c90 100644 --- a/Projectiles/Summon/TacticalPlagueJet.cs +++ b/Projectiles/Summon/TacticalPlagueJet.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class TacticalPlagueJet : ModProjectile + public class TacticalPlagueJet : ModProjectile { public static Item FalseGun = null; diff --git a/Projectiles/Summon/TundraFlameBlossom.cs b/Projectiles/Summon/TundraFlameBlossom.cs index d591e44bc9..cf1a25a257 100644 --- a/Projectiles/Summon/TundraFlameBlossom.cs +++ b/Projectiles/Summon/TundraFlameBlossom.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; projectile.timeLeft *= 5; projectile.minion = true; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() diff --git a/Projectiles/Summon/UniverseSplitterField.cs b/Projectiles/Summon/UniverseSplitterField.cs index 6c0c76b10a..2715b0c256 100644 --- a/Projectiles/Summon/UniverseSplitterField.cs +++ b/Projectiles/Summon/UniverseSplitterField.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class UniverseSplitterField : ModProjectile + public class UniverseSplitterField : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Summon/UniverseSplitterSmallBeam.cs b/Projectiles/Summon/UniverseSplitterSmallBeam.cs index 7680ddd089..9c392560b5 100644 --- a/Projectiles/Summon/UniverseSplitterSmallBeam.cs +++ b/Projectiles/Summon/UniverseSplitterSmallBeam.cs @@ -8,7 +8,7 @@ using Terraria.Enums; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class UniverseSplitterSmallBeam : ModProjectile + public class UniverseSplitterSmallBeam : ModProjectile { // Pretty self explanatory public const int FadeinTime = 25; diff --git a/Projectiles/Summon/Urchin.cs b/Projectiles/Summon/Urchin.cs index 65ae8b0cf4..de969af346 100644 --- a/Projectiles/Summon/Urchin.cs +++ b/Projectiles/Summon/Urchin.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class Urchin : ModProjectile + public class Urchin : ModProjectile { public int dust = 3; @@ -98,13 +98,13 @@ namespace CalamityMod.Projectiles.Summon float maxDist = 300f; for (int i = 0; i < Main.maxNPCs; i++) { - NPC npc = Main.npc[i]; + NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(projectile, false)) { if (Vector2.Distance(projectile.Center, npc.Center) < maxDist && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) { foundTarget = true; - break; + break; } } } @@ -113,8 +113,8 @@ namespace CalamityMod.Projectiles.Summon int projAmt = Main.rand.Next(3, 7); for (int u = 0; u < projAmt; u++) { - Vector2 source = new Vector2(projectile.Center.X - 4f, projectile.Center.Y); - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 source = new Vector2(projectile.Center.X - 4f, projectile.Center.Y); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int spore = Projectile.NewProjectile(source, velocity, ModContent.ProjectileType(), projectile.damage, 1f, projectile.owner, 0f, 0f); Main.projectile[spore].minion = true; Main.projectile[spore].minionSlots = 0f; diff --git a/Projectiles/Summon/Valkyrie.cs b/Projectiles/Summon/Valkyrie.cs index 2a6fd28357..4f2216a485 100644 --- a/Projectiles/Summon/Valkyrie.cs +++ b/Projectiles/Summon/Valkyrie.cs @@ -77,20 +77,20 @@ namespace CalamityMod.Projectiles.Summon projectile.damage = damage2; } - //Adjust sprite direction so it faces correctly + //Adjust sprite direction so it faces correctly if (Math.Abs(projectile.velocity.X) > 0.2f) { projectile.spriteDirection = -projectile.direction; } - projectile.ChargingMinionAI(700f, 800f, 1200f, 150f, 0, 40f, 8f, 4f, new Vector2(0f, -60f), 40f, 8f, false, true); + projectile.ChargingMinionAI(700f, 800f, 1200f, 150f, 0, 40f, 8f, 4f, new Vector2(0f, -60f), 40f, 8f, false, true); - //Give off some light + //Give off some light float lightScalar = (float)Main.rand.Next(90, 111) * 0.01f; lightScalar *= Main.essScale; Lighting.AddLight(projectile.Center, 0f * lightScalar, 0.2f * lightScalar, 0.45f * lightScalar); - //Frames + //Frames projectile.frameCounter++; if (projectile.frameCounter > 7) { diff --git a/Projectiles/Summon/VileFeederProjectile.cs b/Projectiles/Summon/VileFeederProjectile.cs index 320bb5d722..d56dd50985 100644 --- a/Projectiles/Summon/VileFeederProjectile.cs +++ b/Projectiles/Summon/VileFeederProjectile.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class VileFeederProjectile : ModProjectile + public class VileFeederProjectile : ModProjectile { private int bounce = 3; @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; + Player player = Main.player[projectile.owner]; if (projectile.alpha > 0) { projectile.alpha -= 50; @@ -71,11 +71,11 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[0] += 1f; if (projectile.ai[0] > 30f) { - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { float num377 = npc.position.X + (float)(npc.width / 2); float num378 = npc.position.Y + (float)(npc.height / 2); float num379 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num377) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num378); @@ -86,28 +86,28 @@ namespace CalamityMod.Projectiles.Summon num374 = num378; flag10 = true; } - } - } - if (!flag10) - { - for (int num376 = 0; num376 < Main.maxNPCs; num376++) - { - NPC npc = Main.npc[num376]; - if (npc.CanBeChasedBy(projectile, false)) - { - float num377 = npc.position.X + (float)(npc.width / 2); - float num378 = npc.position.Y + (float)(npc.height / 2); - float num379 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num377) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num378); - if (num379 < 640f && num379 < num375 && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) - { - num375 = num379; - num373 = num377; - num374 = num378; - flag10 = true; - } - } - } - } + } + } + if (!flag10) + { + for (int num376 = 0; num376 < Main.maxNPCs; num376++) + { + NPC npc = Main.npc[num376]; + if (npc.CanBeChasedBy(projectile, false)) + { + float num377 = npc.position.X + (float)(npc.width / 2); + float num378 = npc.position.Y + (float)(npc.height / 2); + float num379 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num377) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num378); + if (num379 < 640f && num379 < num375 && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + num375 = num379; + num373 = num377; + num374 = num378; + flag10 = true; + } + } + } + } } if (!flag10) { @@ -166,7 +166,7 @@ namespace CalamityMod.Projectiles.Summon } else { - projectile.ai[0] += 15f; + projectile.ai[0] += 15f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Summon/VileFeederSummon.cs b/Projectiles/Summon/VileFeederSummon.cs index d3a8e5f144..e2279f5eb4 100644 --- a/Projectiles/Summon/VileFeederSummon.cs +++ b/Projectiles/Summon/VileFeederSummon.cs @@ -9,32 +9,32 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class VileFeederSummon : ModProjectile - { - private bool spawnDust = true; - private int eaterCooldown = 0; + public class VileFeederSummon : ModProjectile + { + private bool spawnDust = true; + private int eaterCooldown = 0; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Baby Eater"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.MinionSacrificable[projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Baby Eater"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 30; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.minionSlots = 1f; - projectile.timeLeft = 18000; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.timeLeft *= 5; - projectile.minion = true; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 30; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 1f; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft *= 5; + projectile.minion = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -46,242 +46,242 @@ namespace CalamityMod.Projectiles.Summon projectile.Calamity().lineColor = reader.ReadInt32(); } - public override void AI() - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); - if (spawnDust) - { - projectile.Calamity().lineColor = -1; - projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); - projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - int dustAmt = 36; - for (int d = 0; d < dustAmt; d++) - { - Vector2 source = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; - source = source.RotatedBy((double)((float)(d - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; - Vector2 dustVel = source - projectile.Center; - int num228 = Dust.NewDust(source + dustVel, 0, 0, 7, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].velocity = dustVel; - } - spawnDust = false; - } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) - { - int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / - projectile.Calamity().spawnedPlayerMinionDamageValue * - player.MinionDamage()); - projectile.damage = damage2; - } + if (spawnDust) + { + projectile.Calamity().lineColor = -1; + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + int dustAmt = 36; + for (int d = 0; d < dustAmt; d++) + { + Vector2 source = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; + source = source.RotatedBy((double)((float)(d - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; + Vector2 dustVel = source - projectile.Center; + int num228 = Dust.NewDust(source + dustVel, 0, 0, 7, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); + Main.dust[num228].noGravity = true; + Main.dust[num228].velocity = dustVel; + } + spawnDust = false; + } + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + player.MinionDamage()); + projectile.damage = damage2; + } - bool correctMinion = projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (correctMinion) - { - if (player.dead) - { - modPlayer.vileFeeder = false; - } - if (modPlayer.vileFeeder) - { - projectile.timeLeft = 2; - } - } + bool correctMinion = projectile.type == ModContent.ProjectileType(); + player.AddBuff(ModContent.BuffType(), 3600); + if (correctMinion) + { + if (player.dead) + { + modPlayer.vileFeeder = false; + } + if (modPlayer.vileFeeder) + { + projectile.timeLeft = 2; + } + } - if (eaterCooldown < 0) - eaterCooldown = 0; + if (eaterCooldown < 0) + eaterCooldown = 0; - if (projectile.ai[0] != 3f) - { - if (eaterCooldown > 0) - eaterCooldown--; - projectile.ChargingMinionAI(640f, 1100f, 2400f, 150f, 0, 40f, 8f, 4f, new Vector2(0f, -60f), 40f, 8f, false, false); - projectile.frameCounter++; - if (projectile.frameCounter > 3) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= 4) - { - projectile.frame = 0; - } - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(270); - } - else - { - projectile.frame = 0; - projectile.extraUpdates = 0; - bool breakAway = false; - bool spawnDust = false; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] % 30f == 0f) - { - spawnDust = true; - } - int npcIndex = projectile.Calamity().lineColor; - if (projectile.localAI[0] >= 600000f) //tryna make it stay on there "forever" without glitching - { - breakAway = true; - } - else if (!npcIndex.WithinBounds(Main.maxNPCs)) - { - breakAway = true; - } - else if (Main.npc[npcIndex].active && !Main.npc[npcIndex].dontTakeDamage && Main.npc[npcIndex].defense < 9999) - { - projectile.Center = Main.npc[npcIndex].Center - projectile.velocity * 2f; - projectile.gfxOffY = Main.npc[npcIndex].gfxOffY; - if (spawnDust) - { - Main.npc[npcIndex].HitEffect(0, 1.0); - } - } - else - { - breakAway = true; - } - if (breakAway) - { - projectile.ai[0] = 0f; - projectile.velocity.X = 0f; - projectile.velocity.Y = 0f; - } - if (projectile.owner == Main.myPlayer) - { - if (eaterCooldown > 0) - eaterCooldown -= Main.rand.Next(1,3); + if (projectile.ai[0] != 3f) + { + if (eaterCooldown > 0) + eaterCooldown--; + projectile.ChargingMinionAI(640f, 1100f, 2400f, 150f, 0, 40f, 8f, 4f, new Vector2(0f, -60f), 40f, 8f, false, false); + projectile.frameCounter++; + if (projectile.frameCounter > 3) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 4) + { + projectile.frame = 0; + } + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(270); + } + else + { + projectile.frame = 0; + projectile.extraUpdates = 0; + bool breakAway = false; + bool spawnDust = false; + projectile.localAI[0] += 1f; + if (projectile.localAI[0] % 30f == 0f) + { + spawnDust = true; + } + int npcIndex = projectile.Calamity().lineColor; + if (projectile.localAI[0] >= 600000f) //tryna make it stay on there "forever" without glitching + { + breakAway = true; + } + else if (!npcIndex.WithinBounds(Main.maxNPCs)) + { + breakAway = true; + } + else if (Main.npc[npcIndex].active && !Main.npc[npcIndex].dontTakeDamage && Main.npc[npcIndex].defense < 9999) + { + projectile.Center = Main.npc[npcIndex].Center - projectile.velocity * 2f; + projectile.gfxOffY = Main.npc[npcIndex].gfxOffY; + if (spawnDust) + { + Main.npc[npcIndex].HitEffect(0, 1.0); + } + } + else + { + breakAway = true; + } + if (breakAway) + { + projectile.ai[0] = 0f; + projectile.velocity.X = 0f; + projectile.velocity.Y = 0f; + } + if (projectile.owner == Main.myPlayer) + { + if (eaterCooldown > 0) + eaterCooldown -= Main.rand.Next(1,3); - if (eaterCooldown <= 0) - { - int projNumber = Main.rand.Next(1,3); - for (int index2 = 0; index2 < projNumber; index2++) - { - float xVector = (float)Main.rand.Next(-35, 36) * 0.02f; - float yVector = (float)Main.rand.Next(-35, 36) * 0.02f; - xVector *= 10f; - yVector *= 10f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ModContent.ProjectileType(), (int)(projectile.damage * 1.25f), projectile.knockBack, projectile.owner, 0f, 0f); - } - eaterCooldown = 80; - } - } - } - } + if (eaterCooldown <= 0) + { + int projNumber = Main.rand.Next(1,3); + for (int index2 = 0; index2 < projNumber; index2++) + { + float xVector = (float)Main.rand.Next(-35, 36) * 0.02f; + float yVector = (float)Main.rand.Next(-35, 36) * 0.02f; + xVector *= 10f; + yVector *= 10f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ModContent.ProjectileType(), (int)(projectile.damage * 1.25f), projectile.knockBack, projectile.owner, 0f, 0f); + } + eaterCooldown = 80; + } + } + } + } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - Player player = Main.player[projectile.owner]; - Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + Player player = Main.player[projectile.owner]; + Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); - if (projectile.owner == Main.myPlayer) - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - //covers most edge cases like voodoo dolls - if (npc.active && !npc.dontTakeDamage && npc.defense < 9999 && npc.Calamity().DR < 0.99f && - ((projectile.friendly && (!npc.friendly || (npc.type == NPCID.Guide && projectile.owner < Main.maxPlayers && player.killGuide) || (npc.type == NPCID.Clothier && projectile.owner < Main.maxPlayers && player.killClothier))) || - (projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles)) && (projectile.owner < 0 || npc.immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) - { - if (npc.noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(npc)) - { - bool stickingToNPC; - //Solar Crawltipede tail has special collision - if (npc.type == NPCID.SolarCrawltipedeTail) - { - Rectangle rect = npc.getRect(); - int num5 = 8; - rect.X -= num5; - rect.Y -= num5; - rect.Width += num5 * 2; - rect.Height += num5 * 2; - stickingToNPC = projectile.Colliding(myRect, rect); - } - else - { - stickingToNPC = projectile.Colliding(myRect, npc.getRect()); - } - if (stickingToNPC) - { - //reflect projectile if the npc can reflect it (like Selenians) - if (npc.reflectingProjectiles && projectile.CanReflect()) - { - npc.ReflectProjectile(projectile.whoAmI); - return; - } + if (projectile.owner == Main.myPlayer) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + //covers most edge cases like voodoo dolls + if (npc.active && !npc.dontTakeDamage && npc.defense < 9999 && npc.Calamity().DR < 0.99f && + ((projectile.friendly && (!npc.friendly || (npc.type == NPCID.Guide && projectile.owner < Main.maxPlayers && player.killGuide) || (npc.type == NPCID.Clothier && projectile.owner < Main.maxPlayers && player.killClothier))) || + (projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles)) && (projectile.owner < 0 || npc.immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) + { + if (npc.noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(npc)) + { + bool stickingToNPC; + //Solar Crawltipede tail has special collision + if (npc.type == NPCID.SolarCrawltipedeTail) + { + Rectangle rect = npc.getRect(); + int num5 = 8; + rect.X -= num5; + rect.Y -= num5; + rect.Width += num5 * 2; + rect.Height += num5 * 2; + stickingToNPC = projectile.Colliding(myRect, rect); + } + else + { + stickingToNPC = projectile.Colliding(myRect, npc.getRect()); + } + if (stickingToNPC) + { + //reflect projectile if the npc can reflect it (like Selenians) + if (npc.reflectingProjectiles && projectile.CanReflect()) + { + npc.ReflectProjectile(projectile.whoAmI); + return; + } - //let the projectile know it is sticking and the npc it is sticking too - projectile.ai[0] = 3f; - projectile.Calamity().lineColor = npcIndex; + //let the projectile know it is sticking and the npc it is sticking too + projectile.ai[0] = 3f; + projectile.Calamity().lineColor = npcIndex; - //follow the NPC - projectile.velocity = (npc.Center - projectile.Center) * 0.75f; + //follow the NPC + projectile.velocity = (npc.Center - projectile.Center) * 0.75f; - projectile.netUpdate = true; + projectile.netUpdate = true; - //Count how many projectiles are attached, delete as necessary - Point[] array2 = new Point[10]; - int projCount = 0; - for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) - { - Projectile proj = Main.projectile[projIndex]; - if (projIndex != projectile.whoAmI && proj.active && proj.owner == Main.myPlayer && proj.type == projectile.type && proj.ai[0] == 3f && proj.Calamity().lineColor == npcIndex) - { - array2[projCount++] = new Point(projIndex, proj.timeLeft); - if (projCount >= array2.Length) - { - break; - } - } - } - if (projCount >= 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(); - } - } - } - } - } - } - } + //Count how many projectiles are attached, delete as necessary + Point[] array2 = new Point[10]; + int projCount = 0; + for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) + { + Projectile proj = Main.projectile[projIndex]; + if (projIndex != projectile.whoAmI && proj.active && proj.owner == Main.myPlayer && proj.type == projectile.type && proj.ai[0] == 3f && proj.Calamity().lineColor == npcIndex) + { + array2[projCount++] = new Point(projIndex, proj.timeLeft); + if (projCount >= array2.Length) + { + break; + } + } + } + if (projCount >= 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(); + } + } + } + } + } + } + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (targetHitbox.Width > 8 && targetHitbox.Height > 8) - { - targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8); - } - return null; - } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (targetHitbox.Width > 8 && targetHitbox.Height > 8) + { + targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8); + } + return null; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D texture = Main.projectileTexture[projectile.type]; - int num214 = texture.Height / Main.projFrames[projectile.type]; - int y6 = num214 * projectile.frame; - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D texture = Main.projectileTexture[projectile.type]; + int num214 = texture.Height / Main.projFrames[projectile.type]; + int y6 = num214 * projectile.frame; + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 0; - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 0; + } - public override bool CanDamage() => projectile.ai[0] != 3f; + public override bool CanDamage() => projectile.ai[0] != 3f; public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + } } diff --git a/Projectiles/Summon/ViridVanguardBlade.cs b/Projectiles/Summon/ViridVanguardBlade.cs index cd54fd1fa3..3f28c80982 100644 --- a/Projectiles/Summon/ViridVanguardBlade.cs +++ b/Projectiles/Summon/ViridVanguardBlade.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Summon projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; projectile.localAI[0] = 1f; - } + } if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / diff --git a/Projectiles/Summon/VoidConcentrationAura.cs b/Projectiles/Summon/VoidConcentrationAura.cs index 2ef677567b..9010ea6a39 100644 --- a/Projectiles/Summon/VoidConcentrationAura.cs +++ b/Projectiles/Summon/VoidConcentrationAura.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - class VoidConcentrationAura : ModProjectile + class VoidConcentrationAura : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public int timer = 0; @@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Summon } timer = -1; } - projectile.ai[0] = 1f; + projectile.ai[0] = 1f; if (timer > 50 && timer % 4 == 0) return; timer++; diff --git a/Projectiles/Summon/VoidConcentrationBlackhole.cs b/Projectiles/Summon/VoidConcentrationBlackhole.cs index 323b0d613d..019d5e8e8d 100644 --- a/Projectiles/Summon/VoidConcentrationBlackhole.cs +++ b/Projectiles/Summon/VoidConcentrationBlackhole.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - class VoidConcentrationBlackhole : ModProjectile + class VoidConcentrationBlackhole : ModProjectile { private int damage = 0; diff --git a/Projectiles/Summon/WaterElementalMinion.cs b/Projectiles/Summon/WaterElementalMinion.cs index eb5b6d05b0..5a32d33a0a 100644 --- a/Projectiles/Summon/WaterElementalMinion.cs +++ b/Projectiles/Summon/WaterElementalMinion.cs @@ -99,9 +99,9 @@ namespace CalamityMod.Projectiles.Summon projectile.position.Y = (int)projectile.position.Y; if (projectile.owner == Main.myPlayer) { - // Prevent firing immediately - if (projectile.localAI[0] < 120f) - projectile.localAI[0] += 1f; + // Prevent firing immediately + if (projectile.localAI[0] < 120f) + projectile.localAI[0] += 1f; if (projectile.ai[0] != 0f) { diff --git a/Projectiles/Summon/WitherBolt.cs b/Projectiles/Summon/WitherBolt.cs index 3ce674b07d..4cd24edad6 100644 --- a/Projectiles/Summon/WitherBolt.cs +++ b/Projectiles/Summon/WitherBolt.cs @@ -7,7 +7,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class WitherBolt : ModProjectile + public class WitherBolt : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Summon/WulfrumDroid.cs b/Projectiles/Summon/WulfrumDroid.cs index 07fd751800..f6def8fff0 100644 --- a/Projectiles/Summon/WulfrumDroid.cs +++ b/Projectiles/Summon/WulfrumDroid.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class WulfrumDroid : ModProjectile + public class WulfrumDroid : ModProjectile { public float dust = 0f; @@ -84,131 +84,131 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.MinionAntiClump(); - Vector2 targetVector = projectile.position; - float range = 450f; - bool foundTarget = false; - int targetIndex = -1; - if (player.HasMinionAttackTargetNPC) + projectile.MinionAntiClump(); + Vector2 targetVector = projectile.position; + float range = 450f; + bool foundTarget = false; + int targetIndex = -1; + if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy((object) this, false)) - { - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - if ((!foundTarget && targetDist < range) && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) - { - range = targetDist; - targetVector = npc.Center; - foundTarget = true; - targetIndex = npc.whoAmI; - } - } - } - if (!foundTarget) - { - for (int npcIndex = 0; npcIndex < Main.npc.Length; ++npcIndex) - { - NPC npc = Main.npc[npcIndex]; - if (npc.CanBeChasedBy((object) this, false)) - { - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - if ((!foundTarget && targetDist < range) && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) - { - range = targetDist; - targetVector = npc.Center; - foundTarget = true; - targetIndex = npcIndex; - } - } - } - } - float separationAnxietyDist = 500f; - if (foundTarget) - separationAnxietyDist = 1000f; - if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } - if (projectile.ai[0] == 1f) - projectile.tileCollide = false; - if (foundTarget && projectile.ai[0] == 0f) - { - Vector2 targetPos = targetVector - projectile.Center; - float targetDist = targetPos.Length(); - targetPos.Normalize(); - if (targetDist > 200f) - { - float speed = 6f; - Vector2 goToTarget = targetPos * speed; - projectile.velocity.X = (projectile.velocity.X * 40f + goToTarget.X) / 41f; - projectile.velocity.Y = (projectile.velocity.Y * 40f + goToTarget.Y) / 41f; - } - else if (projectile.velocity.Y > -1f) - projectile.velocity.Y -= 0.1f; - } - else - { - if (!Collision.CanHitLine(projectile.Center, 1, 1, player.Center, 1, 1)) - projectile.ai[0] = 1f; - float returnSpeed = 6f; - if (projectile.ai[0] == 1f) - returnSpeed = 15f; - Vector2 playerVec = player.Center - projectile.Center + new Vector2(0f, -60f); - float playerDist = playerVec.Length(); - if (playerDist > 200f && returnSpeed < 9f) - returnSpeed = 9f; - if (playerDist < 100f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - (float) (projectile.width / 2); - projectile.position.Y = player.Center.Y - (float) (projectile.width / 2); - projectile.netUpdate = true; - } - else if (playerDist > 70f) - { - playerVec.Normalize(); - projectile.velocity = (projectile.velocity * 20f + playerVec * returnSpeed) / 21f; - } - 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.rotation = projectile.velocity.X * 0.05f; - if (projectile.velocity.X > 0f) - projectile.spriteDirection = projectile.direction = 1; - else if (projectile.velocity.X < 0f) - projectile.spriteDirection = projectile.direction = -1; - if (projectile.ai[1] > 0f) - projectile.ai[1] += (float) Main.rand.Next(1, 4); - if (projectile.ai[1] > 90f) - { - projectile.ai[1] = 0.0f; - projectile.netUpdate = true; - } - if (projectile.ai[1] != 0f) - return; - ++projectile.ai[1]; - if (Main.myPlayer != projectile.owner) - return; - if (!foundTarget) - return; - Vector2 velocity = targetVector - projectile.Center; - velocity.Normalize(); - velocity *= 10f; - int bolt = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - Main.projectile[bolt].netUpdate = true; - projectile.netUpdate = true; + if (npc.CanBeChasedBy((object) this, false)) + { + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if ((!foundTarget && targetDist < range) && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + range = targetDist; + targetVector = npc.Center; + foundTarget = true; + targetIndex = npc.whoAmI; + } + } + } + if (!foundTarget) + { + for (int npcIndex = 0; npcIndex < Main.npc.Length; ++npcIndex) + { + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy((object) this, false)) + { + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if ((!foundTarget && targetDist < range) && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + range = targetDist; + targetVector = npc.Center; + foundTarget = true; + targetIndex = npcIndex; + } + } + } + } + float separationAnxietyDist = 500f; + if (foundTarget) + separationAnxietyDist = 1000f; + if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } + if (projectile.ai[0] == 1f) + projectile.tileCollide = false; + if (foundTarget && projectile.ai[0] == 0f) + { + Vector2 targetPos = targetVector - projectile.Center; + float targetDist = targetPos.Length(); + targetPos.Normalize(); + if (targetDist > 200f) + { + float speed = 6f; + Vector2 goToTarget = targetPos * speed; + projectile.velocity.X = (projectile.velocity.X * 40f + goToTarget.X) / 41f; + projectile.velocity.Y = (projectile.velocity.Y * 40f + goToTarget.Y) / 41f; + } + else if (projectile.velocity.Y > -1f) + projectile.velocity.Y -= 0.1f; + } + else + { + if (!Collision.CanHitLine(projectile.Center, 1, 1, player.Center, 1, 1)) + projectile.ai[0] = 1f; + float returnSpeed = 6f; + if (projectile.ai[0] == 1f) + returnSpeed = 15f; + Vector2 playerVec = player.Center - projectile.Center + new Vector2(0f, -60f); + float playerDist = playerVec.Length(); + if (playerDist > 200f && returnSpeed < 9f) + returnSpeed = 9f; + if (playerDist < 100f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - (float) (projectile.width / 2); + projectile.position.Y = player.Center.Y - (float) (projectile.width / 2); + projectile.netUpdate = true; + } + else if (playerDist > 70f) + { + playerVec.Normalize(); + projectile.velocity = (projectile.velocity * 20f + playerVec * returnSpeed) / 21f; + } + 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.rotation = projectile.velocity.X * 0.05f; + if (projectile.velocity.X > 0f) + projectile.spriteDirection = projectile.direction = 1; + else if (projectile.velocity.X < 0f) + projectile.spriteDirection = projectile.direction = -1; + if (projectile.ai[1] > 0f) + projectile.ai[1] += (float) Main.rand.Next(1, 4); + if (projectile.ai[1] > 90f) + { + projectile.ai[1] = 0.0f; + projectile.netUpdate = true; + } + if (projectile.ai[1] != 0f) + return; + ++projectile.ai[1]; + if (Main.myPlayer != projectile.owner) + return; + if (!foundTarget) + return; + Vector2 velocity = targetVector - projectile.Center; + velocity.Normalize(); + velocity *= 10f; + int bolt = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + Main.projectile[bolt].netUpdate = true; + projectile.netUpdate = true; } public override bool CanDamage() => false; diff --git a/Projectiles/Summon/YoungDuke.cs b/Projectiles/Summon/YoungDuke.cs index 1cb73ca6aa..c349a3861c 100644 --- a/Projectiles/Summon/YoungDuke.cs +++ b/Projectiles/Summon/YoungDuke.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class YoungDuke : ModProjectile + public class YoungDuke : ModProjectile { public const float DistanceBeforeCharge = 420f; diff --git a/Projectiles/Typeless/AeroExplosive.cs b/Projectiles/Typeless/AeroExplosive.cs index 0c78675702..e5b2b262f8 100644 --- a/Projectiles/Typeless/AeroExplosive.cs +++ b/Projectiles/Typeless/AeroExplosive.cs @@ -7,114 +7,114 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class AeroExplosive : ModProjectile - { + public class AeroExplosive : ModProjectile + { public override string Texture => "CalamityMod/Items/Weapons/Typeless/AeroDynamite"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Aeroboom"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Aeroboom"); + } - public override void SetDefaults() - { - projectile.width = 15; - projectile.height = 15; - projectile.friendly = true; - projectile.tileCollide = true; - projectile.penetrate = -1; - projectile.timeLeft = 300; + public override void SetDefaults() + { + projectile.width = 15; + projectile.height = 15; + projectile.friendly = true; + projectile.tileCollide = true; + projectile.penetrate = -1; + projectile.timeLeft = 300; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } - public override void AI() - { - if (projectile.timeLeft < 2) - { - projectile.damage = AeroDynamite.Damage; // Like most explosives, not boosted by damage boosts - projectile.knockBack = AeroDynamite.Knockback; - } + public override void AI() + { + if (projectile.timeLeft < 2) + { + projectile.damage = AeroDynamite.Damage; // Like most explosives, not boosted by damage boosts + projectile.knockBack = AeroDynamite.Knockback; + } - if (projectile.timeLeft % 4 == 0 && projectile.timeLeft < 270) - projectile.ai[0]++; - projectile.velocity *= 0.999f - projectile.ai[0] * Main.rand.NextFloat(0.00075f, 0.00125f); - projectile.rotation += projectile.velocity.Length() * 0.09f * projectile.direction; + if (projectile.timeLeft % 4 == 0 && projectile.timeLeft < 270) + projectile.ai[0]++; + projectile.velocity *= 0.999f - projectile.ai[0] * Main.rand.NextFloat(0.00075f, 0.00125f); + projectile.rotation += projectile.velocity.Length() * 0.09f * projectile.direction; - if (Main.rand.NextBool(5)) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 187, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 100, new Color(53, Main.DiscoG, 255)); - } - if (Main.rand.NextBool(5)) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 16, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } + if (Main.rand.NextBool(5)) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 187, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 100, new Color(53, Main.DiscoG, 255)); + } + if (Main.rand.NextBool(5)) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 16, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } - if (Main.rand.NextBool()) - { - int smoke = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1f); - Main.dust[smoke].scale = 0.1f + Main.rand.NextFloat(0f, 0.5f); - Main.dust[smoke].fadeIn = 1.5f + Main.rand.NextFloat(0f, 0.5f); - Main.dust[smoke].noGravity = true; - Main.dust[smoke].position = projectile.Center + new Vector2(0f, -projectile.height / 2f).RotatedBy(projectile.rotation, default) * 1.1f; - int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f); - Main.dust[fire].scale = 1f + Main.rand.NextFloat(0f, 0.5f); - Main.dust[fire].noGravity = true; - Main.dust[fire].position = projectile.Center + new Vector2(0f, -projectile.height / 2f).RotatedBy(projectile.rotation, default) * 1.1f; - } - } + if (Main.rand.NextBool()) + { + int smoke = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1f); + Main.dust[smoke].scale = 0.1f + Main.rand.NextFloat(0f, 0.5f); + Main.dust[smoke].fadeIn = 1.5f + Main.rand.NextFloat(0f, 0.5f); + Main.dust[smoke].noGravity = true; + Main.dust[smoke].position = projectile.Center + new Vector2(0f, -projectile.height / 2f).RotatedBy(projectile.rotation, default) * 1.1f; + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1f); + Main.dust[fire].scale = 1f + Main.rand.NextFloat(0f, 0.5f); + Main.dust[fire].noGravity = true; + Main.dust[fire].position = projectile.Center + new Vector2(0f, -projectile.height / 2f).RotatedBy(projectile.rotation, default) * 1.1f; + } + } - // Makes the projectile bounce infinitely, but lose a ton of speed on bounce. - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(projectile.position + projectile.velocity, projectile.velocity, projectile.width, projectile.height); - if (projectile.velocity.X != oldVelocity.X) - { - projectile.velocity.X = -oldVelocity.X * 0.1f; - } - if (projectile.velocity.Y != oldVelocity.Y) - { - projectile.velocity.Y = -oldVelocity.Y * 0.1f; - } - return false; - } + // Makes the projectile bounce infinitely, but lose a ton of speed on bounce. + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(projectile.position + projectile.velocity, projectile.velocity, projectile.width, projectile.height); + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X * 0.1f; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y * 0.1f; + } + return false; + } - public override void Kill(int timeLeft) - { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 200); - projectile.maxPenetrate = projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); - Main.PlaySound(SoundID.Item14, projectile.Center); + public override void Kill(int timeLeft) + { + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 200); + projectile.maxPenetrate = projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + Main.PlaySound(SoundID.Item14, projectile.Center); - for (int d = 0; d < 40; d++) - { - int smoke = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 2f); - Main.dust[smoke].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[smoke].scale = 0.5f; - Main.dust[smoke].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int d = 0; d < 70; d++) - { - int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 3f); - Main.dust[fire].noGravity = true; - Main.dust[fire].velocity *= 5f; - fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); - Main.dust[fire].velocity *= 2f; - } - CalamityUtils.ExplosionGores(projectile.Center, 3); + for (int d = 0; d < 40; d++) + { + int smoke = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 2f); + Main.dust[smoke].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[smoke].scale = 0.5f; + Main.dust[smoke].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int d = 0; d < 70; d++) + { + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 3f); + Main.dust[fire].noGravity = true; + Main.dust[fire].velocity *= 5f; + fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); + Main.dust[fire].velocity *= 2f; + } + CalamityUtils.ExplosionGores(projectile.Center, 3); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 15); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 15); - if (projectile.owner == Main.myPlayer) - { - CalamityUtils.ExplodeandDestroyTiles(projectile, 7, true, new List() { }, new List() { }); - } - } - } + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ExplodeandDestroyTiles(projectile, 7, true, new List() { }, new List() { }); + } + } + } } diff --git a/Projectiles/Typeless/AllianceTriangle.cs b/Projectiles/Typeless/AllianceTriangle.cs index 3e6a8e2077..086161f55e 100644 --- a/Projectiles/Typeless/AllianceTriangle.cs +++ b/Projectiles/Typeless/AllianceTriangle.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class AllianceTriangle : ModProjectile + public class AllianceTriangle : ModProjectile { public override void SetStaticDefaults() { @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.tileCollide = false; projectile.friendly = true; projectile.penetrate = -1; - projectile.alpha = 254; + projectile.alpha = 254; } public override void AI() @@ -28,32 +28,32 @@ namespace CalamityMod.Projectiles.Typeless Lighting.AddLight(projectile.Center, new Vector3(240, 185, 7) * (3f / 255)); projectile.Center = player.Center; - projectile.ai[0]++; - if (projectile.ai[0] <= 5f) - { - projectile.alpha -= 75; - if (projectile.alpha < 0) - projectile.alpha = 0; - } - else - { - projectile.scale *= 1.06f; - projectile.alpha += 10; - } + projectile.ai[0]++; + if (projectile.ai[0] <= 5f) + { + projectile.alpha -= 75; + if (projectile.alpha < 0) + projectile.alpha = 0; + } + else + { + projectile.scale *= 1.06f; + projectile.alpha += 10; + } - if (projectile.alpha >= 255 || player is null || player.dead) - { - projectile.Kill(); - } + if (projectile.alpha >= 255 || player is null || player.dead) + { + projectile.Kill(); + } } - public override Color? GetAlpha(Color lightColor) - { - if (projectile.alpha <= 0) - return new Color(200, 200, 200, 200); - return null; - } + public override Color? GetAlpha(Color lightColor) + { + if (projectile.alpha <= 0) + return new Color(200, 200, 200, 200); + return null; + } - public override bool CanDamage() => false; + public override bool CanDamage() => false; } } diff --git a/Projectiles/Typeless/AstralSpray.cs b/Projectiles/Typeless/AstralSpray.cs index 6fa635f4d3..eab7a3aa49 100644 --- a/Projectiles/Typeless/AstralSpray.cs +++ b/Projectiles/Typeless/AstralSpray.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class AstralSpray : ModProjectile + public class AstralSpray : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Typeless/AstralStar.cs b/Projectiles/Typeless/AstralStar.cs index 36d8fe419b..8257b38b32 100644 --- a/Projectiles/Typeless/AstralStar.cs +++ b/Projectiles/Typeless/AstralStar.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - if (projectile.ai[0] == 3f) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20); + if (projectile.ai[0] == 3f) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20); if (projectile.ai[0] == 2f) { diff --git a/Projectiles/Typeless/AtaxiaOrb.cs b/Projectiles/Typeless/AtaxiaOrb.cs index 91acb97cde..39346646d2 100644 --- a/Projectiles/Typeless/AtaxiaOrb.cs +++ b/Projectiles/Typeless/AtaxiaOrb.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class AtaxiaOrb : ModProjectile + public class AtaxiaOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -25,16 +25,16 @@ namespace CalamityMod.Projectiles.Typeless projectile.timeLeft = 200; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 170 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 170 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { Dust fire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 127, 0f, 0f, 100, default, 2f); fire.noGravity = true; fire.velocity = Vector2.Zero; - if (projectile.timeLeft < 170) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 9f, 20f); + if (projectile.timeLeft < 170) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 9f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Typeless/BallisticPoisonCloud.cs b/Projectiles/Typeless/BallisticPoisonCloud.cs index 3f59823b41..eb20f4d4f2 100644 --- a/Projectiles/Typeless/BallisticPoisonCloud.cs +++ b/Projectiles/Typeless/BallisticPoisonCloud.cs @@ -36,17 +36,17 @@ namespace CalamityMod.Projectiles.Typeless projectile.frame++; projectile.frameCounter = 0; } - if (projectile.ai[0] < 219f) //255 - frameCounter tick * number of disippation frames - { - if (projectile.frame >= 4) - { - projectile.frame = 0; - } - } - else if (projectile.owner == Main.myPlayer && projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.Kill(); - } + if (projectile.ai[0] < 219f) //255 - frameCounter tick * number of disippation frames + { + if (projectile.frame >= 4) + { + projectile.frame = 0; + } + } + else if (projectile.owner == Main.myPlayer && projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.Kill(); + } projectile.velocity *= 0.98f; if (projectile.alpha > 80) { diff --git a/Projectiles/Typeless/BlazingSun.cs b/Projectiles/Typeless/BlazingSun.cs index 43e9f34d17..3562543342 100644 --- a/Projectiles/Typeless/BlazingSun.cs +++ b/Projectiles/Typeless/BlazingSun.cs @@ -7,7 +7,7 @@ using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Typeless { - public class BlazingSun : ModProjectile + public class BlazingSun : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Typeless/BlazingSun2.cs b/Projectiles/Typeless/BlazingSun2.cs index a2ab4860ea..b20e96dd01 100644 --- a/Projectiles/Typeless/BlazingSun2.cs +++ b/Projectiles/Typeless/BlazingSun2.cs @@ -2,7 +2,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class BlazingSun2 : ModProjectile + public class BlazingSun2 : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Typeless/BlunderBoosterAura.cs b/Projectiles/Typeless/BlunderBoosterAura.cs index 412ed3d514..5424027daf 100644 --- a/Projectiles/Typeless/BlunderBoosterAura.cs +++ b/Projectiles/Typeless/BlunderBoosterAura.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class BlunderBoosterAura : ModProjectile + public class BlunderBoosterAura : ModProjectile { private const float radius = 98f; private const int framesX = 3; @@ -37,9 +37,9 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - //Protect against other mod projectile reflection like emode Granite Golems - projectile.friendly = true; - projectile.hostile = false; + //Protect against other mod projectile reflection like emode Granite Golems + projectile.friendly = true; + projectile.hostile = false; projectile.frameCounter++; if (projectile.frameCounter > 3) @@ -59,19 +59,19 @@ namespace CalamityMod.Projectiles.Typeless Player player = Main.player[projectile.owner]; Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.15f / 255f, (255 - projectile.alpha) * 0.15f / 255f, (255 - projectile.alpha) * 0.01f / 255f); projectile.Center = player.Center; - if (player is null || player.dead) - { - player.Calamity().blunderBooster = false; - projectile.Kill(); - } + if (player is null || player.dead) + { + player.Calamity().blunderBooster = false; + projectile.Kill(); + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Electrified, 180); - if (target.knockBackResist <= 0f) - return; + if (target.knockBackResist <= 0f) + return; if (CalamityGlobalNPC.ShouldAffectNPC(target)) { @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(BuffID.Electrified, 180); - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -133,12 +133,12 @@ namespace CalamityMod.Projectiles.Typeless public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, radius, targetHitbox); public override bool? CanHitNPC(NPC target) - { - if (target.catchItem != 0 && target.type != ModContent.NPCType()) - { - return false; - } - return null; - } + { + if (target.catchItem != 0 && target.type != ModContent.NPCType()) + { + return false; + } + return null; + } } } diff --git a/Projectiles/Typeless/BobbitHead.cs b/Projectiles/Typeless/BobbitHead.cs index 7ac1093342..a92519919a 100644 --- a/Projectiles/Typeless/BobbitHead.cs +++ b/Projectiles/Typeless/BobbitHead.cs @@ -7,73 +7,73 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Typeless { - public class BobbitHead : ModProjectile - { - public const float PullSpeed = 24f; - public const float ReelbackSpeed = 28f; - public const float LaunchSpeed = 25f; - public const float GrappleRangInTiles = 40f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bobbit Head"); - } + public class BobbitHead : ModProjectile + { + public const float PullSpeed = 24f; + public const float ReelbackSpeed = 28f; + public const float LaunchSpeed = 25f; + public const float GrappleRangInTiles = 40f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bobbit Head"); + } - public override void SetDefaults() - { - projectile.CloneDefaults(ProjectileID.GemHookAmethyst); - } + public override void SetDefaults() + { + projectile.CloneDefaults(ProjectileID.GemHookAmethyst); + } - // Use this hook for hooks that can have multiple hooks mid-flight: Dual Hook, Web Slinger, Fish Hook, Static Hook, Lunar Hook - public override bool? CanUseGrapple(Player player) - { - int hooksOut = 0; - for (int l = 0; l < Main.maxProjectiles; l++) - { - if (Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == projectile.type) - { - hooksOut++; - } - } - if (hooksOut > 1) // This hook can have 2 hooks out. - { - return false; - } - return true; - } + // Use this hook for hooks that can have multiple hooks mid-flight: Dual Hook, Web Slinger, Fish Hook, Static Hook, Lunar Hook + public override bool? CanUseGrapple(Player player) + { + int hooksOut = 0; + for (int l = 0; l < Main.maxProjectiles; l++) + { + if (Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == projectile.type) + { + hooksOut++; + } + } + if (hooksOut > 1) // This hook can have 2 hooks out. + { + return false; + } + return true; + } - // Amethyst Hook is 300, Static Hook is 600, 16f = 1 tile - public override float GrappleRange() => GrappleRangInTiles * 16f; + // Amethyst Hook is 300, Static Hook is 600, 16f = 1 tile + public override float GrappleRange() => GrappleRangInTiles * 16f; - public override void NumGrappleHooks(Player player, ref int numHooks) - { - numHooks = 1; - } + public override void NumGrappleHooks(Player player, ref int numHooks) + { + numHooks = 1; + } - // default is 11, Lunar is 24 - public override void GrappleRetreatSpeed(Player player, ref float speed) - { - speed = ReelbackSpeed; - } + // default is 11, Lunar is 24 + public override void GrappleRetreatSpeed(Player player, ref float speed) + { + speed = ReelbackSpeed; + } - public override void GrapplePullSpeed(Player player, ref float speed) - { - speed = PullSpeed; - } + public override void GrapplePullSpeed(Player player, ref float speed) + { + speed = PullSpeed; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityUtils.DrawHook(projectile, GetTexture("CalamityMod/ExtraTextures/Chains/BobbitHookChain")); - return true; - } + return true; + } public override void AI() { projectile.spriteDirection = -projectile.direction; - if (projectile.ai[0] == 2f) - projectile.extraUpdates = 1; - else - projectile.extraUpdates = 0; + if (projectile.ai[0] == 2f) + projectile.extraUpdates = 1; + else + projectile.extraUpdates = 0; } } } diff --git a/Projectiles/Typeless/BossRushEffectThing.cs b/Projectiles/Typeless/BossRushEffectThing.cs index 1319934af3..a3d353f3e4 100644 --- a/Projectiles/Typeless/BossRushEffectThing.cs +++ b/Projectiles/Typeless/BossRushEffectThing.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class BossRushEffectThing : ModProjectile + public class BossRushEffectThing : ModProjectile { public Player Owner => Main.player[projectile.owner]; public ref float Time => ref projectile.ai[0]; @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Typeless projectile.penetrate = -1; } - public override void AI() - { + public override void AI() + { projectile.Center = Owner.Center; if (Time >= 70f) MoonlordDeathDrama.RequestLight(Utils.InverseLerp(70f, 85f, Time, true), Main.LocalPlayer.Center); @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Typeless } public override void Kill(int timeLeft) - { + { BossRushEvent.SyncStartTimer(BossRushEvent.StartEffectTotalTime); for (int doom = 0; doom < 200; doom++) { @@ -71,5 +71,5 @@ namespace CalamityMod.Projectiles.Typeless netMessage.Send(); } } - } + } } diff --git a/Projectiles/Typeless/BossRushEndEffectThing.cs b/Projectiles/Typeless/BossRushEndEffectThing.cs index c9abc03b68..acccecce51 100644 --- a/Projectiles/Typeless/BossRushEndEffectThing.cs +++ b/Projectiles/Typeless/BossRushEndEffectThing.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Typeless projectile.penetrate = -1; } - public override void AI() - { + public override void AI() + { if (Time == 25f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/BossRushEnd"), Main.LocalPlayer.Center); @@ -40,10 +40,10 @@ namespace CalamityMod.Projectiles.Typeless } public override void Kill(int timeLeft) - { + { BossRushEvent.End(); DropHelper.DropItem(Main.LocalPlayer, ModContent.ItemType()); CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.BossRushTierFiveEndText", BossRushEvent.XerocTextColor); } - } + } } diff --git a/Projectiles/Typeless/BossRushFailureEffectThing.cs b/Projectiles/Typeless/BossRushFailureEffectThing.cs index 757058889b..26a7ce475f 100644 --- a/Projectiles/Typeless/BossRushFailureEffectThing.cs +++ b/Projectiles/Typeless/BossRushFailureEffectThing.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class BossRushFailureEffectThing : ModProjectile + public class BossRushFailureEffectThing : ModProjectile { public Player Owner => Main.player[projectile.owner]; public ref float Time => ref projectile.ai[0]; @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Typeless projectile.penetrate = -1; } - public override void AI() - { + public override void AI() + { MoonlordDeathDrama.RequestLight(Utils.InverseLerp(0f, 8f, Time, true), Main.LocalPlayer.Center); if (Time >= 45f) { @@ -33,5 +33,5 @@ namespace CalamityMod.Projectiles.Typeless } Time++; } - } + } } diff --git a/Projectiles/Typeless/BrimstoneHellfireballFriendly2.cs b/Projectiles/Typeless/BrimstoneHellfireballFriendly2.cs index 7b3467295c..a1f250d65d 100644 --- a/Projectiles/Typeless/BrimstoneHellfireballFriendly2.cs +++ b/Projectiles/Typeless/BrimstoneHellfireballFriendly2.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.height = 12; projectile.friendly = true; projectile.ignoreWater = true; - projectile.tileCollide = false; + projectile.tileCollide = false; projectile.timeLeft = 50; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Typeless/ChaosFlare.cs b/Projectiles/Typeless/ChaosFlare.cs index 396ffd0ac2..79d43e3bfb 100644 --- a/Projectiles/Typeless/ChaosFlare.cs +++ b/Projectiles/Typeless/ChaosFlare.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class ChaosFlare : ModProjectile + public class ChaosFlare : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -24,9 +24,9 @@ namespace CalamityMod.Projectiles.Typeless projectile.extraUpdates = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 105 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 105 && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); @@ -44,8 +44,8 @@ namespace CalamityMod.Projectiles.Typeless Main.dust[d].velocity += projectile.velocity * 0.1f; } - if (projectile.timeLeft < 105) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 20f); + if (projectile.timeLeft < 105) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 450f, 12f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(BuffID.OnFire, 180); - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 90); } } } diff --git a/Projectiles/Typeless/ChaosFlare2.cs b/Projectiles/Typeless/ChaosFlare2.cs index e29148c81b..ddd4e28198 100644 --- a/Projectiles/Typeless/ChaosFlare2.cs +++ b/Projectiles/Typeless/ChaosFlare2.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class ChaosFlare2 : ModProjectile + public class ChaosFlare2 : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -24,20 +24,20 @@ namespace CalamityMod.Projectiles.Typeless projectile.extraUpdates = 2; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 285 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 285 && target.CanBeChasedBy(projectile); - public override void AI() - { - Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); + public override void AI() + { + Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); - int d = Dust.NewDust(projectile.position, projectile.width, projectile.height, 127, 0f, 0f, 100, default, 2f); - Main.dust[d].noGravity = true; - Main.dust[d].velocity *= 0.5f; - Main.dust[d].velocity += projectile.velocity * 0.1f; + int d = Dust.NewDust(projectile.position, projectile.width, projectile.height, 127, 0f, 0f, 100, default, 2f); + Main.dust[d].noGravity = true; + Main.dust[d].velocity *= 0.5f; + Main.dust[d].velocity += projectile.velocity * 0.1f; - if (projectile.timeLeft < 285) - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 11f, 20f); - } + if (projectile.timeLeft < 285) + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 11f, 20f); + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Typeless/ChaosGeyser.cs b/Projectiles/Typeless/ChaosGeyser.cs index 1fe2138a9a..aa433eb911 100644 --- a/Projectiles/Typeless/ChaosGeyser.cs +++ b/Projectiles/Typeless/ChaosGeyser.cs @@ -25,21 +25,21 @@ namespace CalamityMod.Projectiles.Typeless projectile.localNPCHitCooldown = 6; } - // Reduce damage of projectiles if more than the cap are active - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; - int cap = 3; - int oldDamage = damage; - if (projectileCount > cap) - { - damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); - if (damage < 1) - damage = 1; - } - } + // Reduce damage of projectiles if more than the cap are active + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; + int cap = 3; + int oldDamage = damage; + if (projectileCount > cap) + { + damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); + if (damage < 1) + damage = 1; + } + } - public override void AI() + public override void AI() { if (projectile.velocity.X != projectile.velocity.X) { @@ -102,9 +102,9 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.OnFire, 180); } diff --git a/Projectiles/Typeless/ChaoticSpreadBobber.cs b/Projectiles/Typeless/ChaoticSpreadBobber.cs index 97688c44f7..ba7effc6ef 100644 --- a/Projectiles/Typeless/ChaoticSpreadBobber.cs +++ b/Projectiles/Typeless/ChaoticSpreadBobber.cs @@ -5,48 +5,48 @@ using Terraria.ModLoader; using CalamityMod.Items.Fishing.FishingRods; namespace CalamityMod.Projectiles.Typeless { - public class ChaoticSpreadBobber : ModProjectile - { - private bool initialized = false; - private Color fishingLineColor; - public Color[] PossibleLineColors = new Color[] - { - new Color(255, 165, 0, 100), //an orange color - new Color(0, 206, 209, 100) // a blue color - }; + public class ChaoticSpreadBobber : ModProjectile + { + private bool initialized = false; + private Color fishingLineColor; + public Color[] PossibleLineColors = new Color[] + { + new Color(255, 165, 0, 100), //an orange color + new Color(0, 206, 209, 100) // a blue color + }; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Chaotic Bobber"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Chaotic Bobber"); + } - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 61; - projectile.bobber = true; - projectile.penetrate = -1; - } + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 61; + projectile.bobber = true; + projectile.penetrate = -1; + } - //What if we want to randomize the line color - public override void AI() - { - if (!initialized) - { - //Decide color of the pole by randomizing the array - fishingLineColor = Main.rand.Next(PossibleLineColors); - initialized = true; - } - } + //What if we want to randomize the line color + public override void AI() + { + if (!initialized) + { + //Decide color of the pole by randomizing the array + fishingLineColor = Main.rand.Next(PossibleLineColors); + initialized = true; + } + } - public override bool PreDrawExtras(SpriteBatch spriteBatch) - { - if (fishingLineColor == PossibleLineColors[0]) - Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); - else - Lighting.AddLight(projectile.Center, 0f, 0.45f, 0.46f); - return projectile.DrawFishingLine(ModContent.ItemType(), fishingLineColor, 65, 30f); - } - } + public override bool PreDrawExtras(SpriteBatch spriteBatch) + { + if (fishingLineColor == PossibleLineColors[0]) + Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); + else + Lighting.AddLight(projectile.Center, 0f, 0.45f, 0.46f); + return projectile.DrawFishingLine(ModContent.ItemType(), fishingLineColor, 65, 30f); + } + } } diff --git a/Projectiles/Typeless/CursorProj.cs b/Projectiles/Typeless/CursorProj.cs index 2fd585b01b..662197aac7 100644 --- a/Projectiles/Typeless/CursorProj.cs +++ b/Projectiles/Typeless/CursorProj.cs @@ -12,9 +12,9 @@ namespace CalamityMod.Projectiles.Typeless public override void SetStaticDefaults() { DisplayName.SetDefault("Aestheticus Crystal"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } public override void SetDefaults() { @@ -24,169 +24,169 @@ namespace CalamityMod.Projectiles.Typeless projectile.penetrate = 1; projectile.extraUpdates = 1; projectile.alpha = 255; - projectile.timeLeft = 300; + projectile.timeLeft = 300; } - public override void AI() - { - if (projectile.alpha > 0) - projectile.alpha -= 15; + public override void AI() + { + if (projectile.alpha > 0) + projectile.alpha -= 15; - 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) + 1.57f; - if (projectile.timeLeft > 285) - return; + if (projectile.timeLeft > 285) + return; - float num29 = 5f; - float num30 = 300f; - float scaleFactor = 6f; - Vector2 value7 = new Vector2(10f, 20f); - //float num31 = 1f; - int num32 = 3 * projectile.MaxUpdates; - int num33 = Utils.SelectRandom(Main.rand, new int[] - { - 246, - 242, - 229, - 226, - 247 - }); - int num34 = 255; - if (projectile.ai[1] == 0f) - { - projectile.ai[1] = 1f; - projectile.localAI[0] = (float)-(float)Main.rand.Next(48); - } - else if (projectile.ai[1] == 1f && projectile.owner == Main.myPlayer) - { - int num35 = -1; - float num36 = num30; - for (int num37 = 0; num37 < 200; num37++) - { - if (Main.npc[num37].active && Main.npc[num37].CanBeChasedBy(projectile, false)) - { - Vector2 center3 = Main.npc[num37].Center; - float num38 = Vector2.Distance(center3, projectile.Center); - if (num38 < num36 && num35 == -1 && Collision.CanHitLine(projectile.Center, 1, 1, center3, 1, 1)) - { - num36 = num38; - num35 = num37; - } - } - } - if (num36 < 4f) - { - projectile.Kill(); - return; - } - if (num35 != -1) - { - projectile.ai[1] = num29 + 1f; - projectile.ai[0] = (float)num35; - projectile.netUpdate = true; - } - } - else if (projectile.ai[1] > num29) - { - projectile.ai[1] += 1f; - int num39 = (int)projectile.ai[0]; - if (!Main.npc[num39].active || !Main.npc[num39].CanBeChasedBy(projectile, false)) - { - projectile.ai[1] = 1f; - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - else - { - projectile.velocity.ToRotation(); - Vector2 vector6 = Main.npc[num39].Center - projectile.Center; - if (vector6.Length() < 10f) - { - projectile.Kill(); - return; - } - if (vector6 != Vector2.Zero) - { - vector6.Normalize(); - vector6 *= scaleFactor; - } - float num40 = 30f; - projectile.velocity = (projectile.velocity * (num40 - 1f) + vector6) / num40; - } - } - if (projectile.ai[1] >= 1f && projectile.ai[1] < num29) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] == num29) - { - projectile.ai[1] = 1f; - } - } - projectile.localAI[0] += 1f; - if (projectile.localAI[0] == 48f) - { - projectile.localAI[0] = 0f; - } - if (Main.rand.NextBool(12)) - { - Vector2 value9 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)projectile.velocity.ToRotation(), default); - int num44 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num34, 0f, 0f, 160, default, 1f); - Main.dust[num44].velocity *= 0.1f; - Main.dust[num44].position = projectile.Center + value9 * (float)projectile.width / 2f + projectile.velocity * 2f; - Main.dust[num44].fadeIn = 0.9f; - } - if (Main.rand.NextBool(18)) - { - Vector2 value10 = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)projectile.velocity.ToRotation(), default); - int num46 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 155, default, 0.8f); - Main.dust[num46].velocity *= 0.3f; - Main.dust[num46].position = projectile.Center + value10 * (float)projectile.width / 2f; - if (Main.rand.NextBool(2)) - { - Main.dust[num46].fadeIn = 1.4f; - } - } - if (Main.rand.NextBool(8)) - { - Vector2 value11 = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy((double)projectile.velocity.ToRotation(), default); - int num48 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num33, 0f, 0f, 0, default, 1f); - Main.dust[num48].velocity *= 0.3f; - Main.dust[num48].noGravity = true; - Main.dust[num48].position = projectile.Center + value11 * (float)projectile.width / 2f; - if (Main.rand.NextBool(2)) - { - Main.dust[num48].fadeIn = 1.4f; - } - } - if (Main.rand.NextBool(6)) - { - Vector2 value13 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)projectile.velocity.ToRotation(), default); - int num50 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num34, 0f, 0f, 100, default, 1f); - Main.dust[num50].velocity *= 0.3f; - Main.dust[num50].position = projectile.Center + value13 * (float)projectile.width / 2f; - Main.dust[num50].fadeIn = 1.2f; - Main.dust[num50].scale = 1.5f; - Main.dust[num50].noGravity = true; - } - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f); - int num154 = 14; - int num155 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num154 * 2, projectile.height - num154 * 2, 234, 0f, 0f, 100, default, 0.8f); - Main.dust[num155].velocity *= 0.1f; - Main.dust[num155].velocity += projectile.velocity * 0.5f; - Main.dust[num155].noGravity = true; - if (Main.rand.NextBool(12)) - { - int num156 = 16; - int num157 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num156 * 2, projectile.height - num156 * 2, 159, 0f, 0f, 100, default, 1f); - Main.dust[num157].velocity *= 0.25f; - Main.dust[num157].velocity += projectile.velocity * 0.5f; - } - } + float num29 = 5f; + float num30 = 300f; + float scaleFactor = 6f; + Vector2 value7 = new Vector2(10f, 20f); + //float num31 = 1f; + int num32 = 3 * projectile.MaxUpdates; + int num33 = Utils.SelectRandom(Main.rand, new int[] + { + 246, + 242, + 229, + 226, + 247 + }); + int num34 = 255; + if (projectile.ai[1] == 0f) + { + projectile.ai[1] = 1f; + projectile.localAI[0] = (float)-(float)Main.rand.Next(48); + } + else if (projectile.ai[1] == 1f && projectile.owner == Main.myPlayer) + { + int num35 = -1; + float num36 = num30; + for (int num37 = 0; num37 < 200; num37++) + { + if (Main.npc[num37].active && Main.npc[num37].CanBeChasedBy(projectile, false)) + { + Vector2 center3 = Main.npc[num37].Center; + float num38 = Vector2.Distance(center3, projectile.Center); + if (num38 < num36 && num35 == -1 && Collision.CanHitLine(projectile.Center, 1, 1, center3, 1, 1)) + { + num36 = num38; + num35 = num37; + } + } + } + if (num36 < 4f) + { + projectile.Kill(); + return; + } + if (num35 != -1) + { + projectile.ai[1] = num29 + 1f; + projectile.ai[0] = (float)num35; + projectile.netUpdate = true; + } + } + else if (projectile.ai[1] > num29) + { + projectile.ai[1] += 1f; + int num39 = (int)projectile.ai[0]; + if (!Main.npc[num39].active || !Main.npc[num39].CanBeChasedBy(projectile, false)) + { + projectile.ai[1] = 1f; + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + else + { + projectile.velocity.ToRotation(); + Vector2 vector6 = Main.npc[num39].Center - projectile.Center; + if (vector6.Length() < 10f) + { + projectile.Kill(); + return; + } + if (vector6 != Vector2.Zero) + { + vector6.Normalize(); + vector6 *= scaleFactor; + } + float num40 = 30f; + projectile.velocity = (projectile.velocity * (num40 - 1f) + vector6) / num40; + } + } + if (projectile.ai[1] >= 1f && projectile.ai[1] < num29) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] == num29) + { + projectile.ai[1] = 1f; + } + } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] == 48f) + { + projectile.localAI[0] = 0f; + } + if (Main.rand.NextBool(12)) + { + Vector2 value9 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)projectile.velocity.ToRotation(), default); + int num44 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num34, 0f, 0f, 160, default, 1f); + Main.dust[num44].velocity *= 0.1f; + Main.dust[num44].position = projectile.Center + value9 * (float)projectile.width / 2f + projectile.velocity * 2f; + Main.dust[num44].fadeIn = 0.9f; + } + if (Main.rand.NextBool(18)) + { + Vector2 value10 = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)projectile.velocity.ToRotation(), default); + int num46 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 155, default, 0.8f); + Main.dust[num46].velocity *= 0.3f; + Main.dust[num46].position = projectile.Center + value10 * (float)projectile.width / 2f; + if (Main.rand.NextBool(2)) + { + Main.dust[num46].fadeIn = 1.4f; + } + } + if (Main.rand.NextBool(8)) + { + Vector2 value11 = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy((double)projectile.velocity.ToRotation(), default); + int num48 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num33, 0f, 0f, 0, default, 1f); + Main.dust[num48].velocity *= 0.3f; + Main.dust[num48].noGravity = true; + Main.dust[num48].position = projectile.Center + value11 * (float)projectile.width / 2f; + if (Main.rand.NextBool(2)) + { + Main.dust[num48].fadeIn = 1.4f; + } + } + if (Main.rand.NextBool(6)) + { + Vector2 value13 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)projectile.velocity.ToRotation(), default); + int num50 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num34, 0f, 0f, 100, default, 1f); + Main.dust[num50].velocity *= 0.3f; + Main.dust[num50].position = projectile.Center + value13 * (float)projectile.width / 2f; + Main.dust[num50].fadeIn = 1.2f; + Main.dust[num50].scale = 1.5f; + Main.dust[num50].noGravity = true; + } + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f); + int num154 = 14; + int num155 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num154 * 2, projectile.height - num154 * 2, 234, 0f, 0f, 100, default, 0.8f); + Main.dust[num155].velocity *= 0.1f; + Main.dust[num155].velocity += projectile.velocity * 0.5f; + Main.dust[num155].noGravity = true; + if (Main.rand.NextBool(12)) + { + int num156 = 16; + int num157 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num156 * 2, projectile.height - num156 * 2, 159, 0f, 0f, 100, default, 1f); + Main.dust[num157].velocity *= 0.25f; + Main.dust[num157].velocity += projectile.velocity * 0.5f; + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); - return false; + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + return false; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -201,24 +201,24 @@ namespace CalamityMod.Projectiles.Typeless public override void Kill(int timeLeft) { - Vector2 velocity = projectile.velocity; - velocity.Normalize(); - velocity *= 4f; + Vector2 velocity = projectile.velocity; + velocity.Normalize(); + velocity *= 4f; - int spread = 45; - int numProj = 4; - float rotation = MathHelper.ToRadians(spread); - float baseSpeed = (float)Math.Sqrt(velocity.X * velocity.X + velocity.Y * velocity.Y); - double startAngle = Math.Atan2(velocity.X, velocity.Y) - rotation / 2; - double deltaAngle = rotation / (float)numProj; - double offsetAngle; + int spread = 45; + int numProj = 4; + float rotation = MathHelper.ToRadians(spread); + float baseSpeed = (float)Math.Sqrt(velocity.X * velocity.X + velocity.Y * velocity.Y); + double startAngle = Math.Atan2(velocity.X, velocity.Y) - rotation / 2; + double deltaAngle = rotation / (float)numProj; + double offsetAngle; - for (int i = 0; i < numProj; i++) - { - offsetAngle = startAngle + deltaAngle * i; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), - ModContent.ProjectileType(), projectile.damage / 3, projectile.knockBack * 0.33f, projectile.owner, 0f, 0f); - } + for (int i = 0; i < numProj; i++) + { + offsetAngle = startAngle + deltaAngle * i; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), + ModContent.ProjectileType(), projectile.damage / 3, projectile.knockBack * 0.33f, projectile.owner, 0f, 0f); + } Main.PlaySound(SoundID.Item110, projectile.Center); } diff --git a/Projectiles/Typeless/CursorProjSplit.cs b/Projectiles/Typeless/CursorProjSplit.cs index 28d1320458..c6e064a96e 100644 --- a/Projectiles/Typeless/CursorProjSplit.cs +++ b/Projectiles/Typeless/CursorProjSplit.cs @@ -14,9 +14,9 @@ namespace CalamityMod.Projectiles.Typeless public override void SetStaticDefaults() { DisplayName.SetDefault("Aestheticus Crystal"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; - ProjectileID.Sets.TrailingMode[projectile.type] = 1; - } + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + } public override void SetDefaults() { @@ -26,169 +26,169 @@ namespace CalamityMod.Projectiles.Typeless projectile.penetrate = 1; projectile.extraUpdates = 1; projectile.alpha = 255; - projectile.timeLeft = 300; - } + projectile.timeLeft = 300; + } - public override void AI() - { - if (projectile.alpha > 0) - projectile.alpha -= 3; + public override void AI() + { + if (projectile.alpha > 0) + projectile.alpha -= 3; - 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) + 1.57f; - float num29 = 5f; - float num30 = 300f; - float scaleFactor = 6f; - Vector2 value7 = new Vector2(10f, 20f); - //float num31 = 1f; - int num32 = 3 * projectile.MaxUpdates; - int num33 = Utils.SelectRandom(Main.rand, new int[] - { - 246, - 242, - 229, - 226, - 247 - }); - int num34 = 255; - if (projectile.ai[1] == 0f) - { - projectile.ai[1] = 1f; - projectile.localAI[0] = (float)-(float)Main.rand.Next(48); - } - else if (projectile.ai[1] == 1f && projectile.owner == Main.myPlayer) - { - if (projectile.alpha < 128) - { - int num35 = -1; - float num36 = num30; - for (int num37 = 0; num37 < 200; num37++) - { - if (Main.npc[num37].active && Main.npc[num37].CanBeChasedBy(projectile, false)) - { - Vector2 center3 = Main.npc[num37].Center; - float num38 = Vector2.Distance(center3, projectile.Center); - if (num38 < num36 && num35 == -1 && Collision.CanHitLine(projectile.Center, 1, 1, center3, 1, 1)) - { - num36 = num38; - num35 = num37; - } - } - } - if (num36 < 4f) - { - projectile.Kill(); - return; - } - if (num35 != -1) - { - projectile.ai[1] = num29 + 1f; - projectile.ai[0] = (float)num35; - projectile.netUpdate = true; - } - } - } - else if (projectile.ai[1] > num29) - { - projectile.ai[1] += 1f; - int num39 = (int)projectile.ai[0]; - if (!Main.npc[num39].active || !Main.npc[num39].CanBeChasedBy(projectile, false)) - { - projectile.ai[1] = 1f; - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - else - { - projectile.velocity.ToRotation(); - Vector2 vector6 = Main.npc[num39].Center - projectile.Center; - if (vector6.Length() < 10f) - { - projectile.Kill(); - return; - } - if (vector6 != Vector2.Zero) - { - vector6.Normalize(); - vector6 *= scaleFactor; - } - float num40 = 30f; - projectile.velocity = (projectile.velocity * (num40 - 1f) + vector6) / num40; - } - } - if (projectile.ai[1] >= 1f && projectile.ai[1] < num29) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] == num29) - { - projectile.ai[1] = 1f; - } - } - projectile.localAI[0] += 1f; - if (projectile.localAI[0] == 48f) - { - projectile.localAI[0] = 0f; - } - if (Main.rand.NextBool(12)) - { - Vector2 value9 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)projectile.velocity.ToRotation(), default); - int num44 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num34, 0f, 0f, 100, default, 1f); - Main.dust[num44].velocity *= 0.1f; - Main.dust[num44].position = projectile.Center + value9 * (float)projectile.width / 2f + projectile.velocity * 2f; - Main.dust[num44].fadeIn = 0.9f; - } - if (Main.rand.NextBool(18)) - { - Vector2 value10 = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)projectile.velocity.ToRotation(), default); - int num46 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 155, default, 0.8f); - Main.dust[num46].velocity *= 0.3f; - Main.dust[num46].position = projectile.Center + value10 * (float)projectile.width / 2f; - if (Main.rand.NextBool(2)) - { - Main.dust[num46].fadeIn = 1.4f; - } - } - if (Main.rand.NextBool(8)) - { - Vector2 value11 = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy((double)projectile.velocity.ToRotation(), default); - int num48 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num33, 0f, 0f, 0, default, 1f); - Main.dust[num48].velocity *= 0.3f; - Main.dust[num48].noGravity = true; - Main.dust[num48].position = projectile.Center + value11 * (float)projectile.width / 2f; - if (Main.rand.NextBool(2)) - { - Main.dust[num48].fadeIn = 1.4f; - } - } - if (Main.rand.NextBool(6)) - { - Vector2 value13 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)projectile.velocity.ToRotation(), default); - int num50 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num34, 0f, 0f, 100, default, 1f); - Main.dust[num50].velocity *= 0.3f; - Main.dust[num50].position = projectile.Center + value13 * (float)projectile.width / 2f; - Main.dust[num50].fadeIn = 1.2f; - Main.dust[num50].scale = 1.5f; - Main.dust[num50].noGravity = true; - } - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f); - int num154 = 14; - int num155 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num154 * 2, projectile.height - num154 * 2, 234, 0f, 0f, 100, default, 0.8f); - Main.dust[num155].velocity *= 0.1f; - Main.dust[num155].velocity += projectile.velocity * 0.5f; - Main.dust[num155].noGravity = true; - if (Main.rand.NextBool(12)) - { - int num156 = 16; - int num157 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num156 * 2, projectile.height - num156 * 2, 159, 0f, 0f, 100, default, 1f); - Main.dust[num157].velocity *= 0.25f; - Main.dust[num157].velocity += projectile.velocity * 0.5f; - } - } + float num29 = 5f; + float num30 = 300f; + float scaleFactor = 6f; + Vector2 value7 = new Vector2(10f, 20f); + //float num31 = 1f; + int num32 = 3 * projectile.MaxUpdates; + int num33 = Utils.SelectRandom(Main.rand, new int[] + { + 246, + 242, + 229, + 226, + 247 + }); + int num34 = 255; + if (projectile.ai[1] == 0f) + { + projectile.ai[1] = 1f; + projectile.localAI[0] = (float)-(float)Main.rand.Next(48); + } + else if (projectile.ai[1] == 1f && projectile.owner == Main.myPlayer) + { + if (projectile.alpha < 128) + { + int num35 = -1; + float num36 = num30; + for (int num37 = 0; num37 < 200; num37++) + { + if (Main.npc[num37].active && Main.npc[num37].CanBeChasedBy(projectile, false)) + { + Vector2 center3 = Main.npc[num37].Center; + float num38 = Vector2.Distance(center3, projectile.Center); + if (num38 < num36 && num35 == -1 && Collision.CanHitLine(projectile.Center, 1, 1, center3, 1, 1)) + { + num36 = num38; + num35 = num37; + } + } + } + if (num36 < 4f) + { + projectile.Kill(); + return; + } + if (num35 != -1) + { + projectile.ai[1] = num29 + 1f; + projectile.ai[0] = (float)num35; + projectile.netUpdate = true; + } + } + } + else if (projectile.ai[1] > num29) + { + projectile.ai[1] += 1f; + int num39 = (int)projectile.ai[0]; + if (!Main.npc[num39].active || !Main.npc[num39].CanBeChasedBy(projectile, false)) + { + projectile.ai[1] = 1f; + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + else + { + projectile.velocity.ToRotation(); + Vector2 vector6 = Main.npc[num39].Center - projectile.Center; + if (vector6.Length() < 10f) + { + projectile.Kill(); + return; + } + if (vector6 != Vector2.Zero) + { + vector6.Normalize(); + vector6 *= scaleFactor; + } + float num40 = 30f; + projectile.velocity = (projectile.velocity * (num40 - 1f) + vector6) / num40; + } + } + if (projectile.ai[1] >= 1f && projectile.ai[1] < num29) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] == num29) + { + projectile.ai[1] = 1f; + } + } + projectile.localAI[0] += 1f; + if (projectile.localAI[0] == 48f) + { + projectile.localAI[0] = 0f; + } + if (Main.rand.NextBool(12)) + { + Vector2 value9 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)projectile.velocity.ToRotation(), default); + int num44 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num34, 0f, 0f, 100, default, 1f); + Main.dust[num44].velocity *= 0.1f; + Main.dust[num44].position = projectile.Center + value9 * (float)projectile.width / 2f + projectile.velocity * 2f; + Main.dust[num44].fadeIn = 0.9f; + } + if (Main.rand.NextBool(18)) + { + Vector2 value10 = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)projectile.velocity.ToRotation(), default); + int num46 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 155, default, 0.8f); + Main.dust[num46].velocity *= 0.3f; + Main.dust[num46].position = projectile.Center + value10 * (float)projectile.width / 2f; + if (Main.rand.NextBool(2)) + { + Main.dust[num46].fadeIn = 1.4f; + } + } + if (Main.rand.NextBool(8)) + { + Vector2 value11 = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy((double)projectile.velocity.ToRotation(), default); + int num48 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num33, 0f, 0f, 0, default, 1f); + Main.dust[num48].velocity *= 0.3f; + Main.dust[num48].noGravity = true; + Main.dust[num48].position = projectile.Center + value11 * (float)projectile.width / 2f; + if (Main.rand.NextBool(2)) + { + Main.dust[num48].fadeIn = 1.4f; + } + } + if (Main.rand.NextBool(6)) + { + Vector2 value13 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)projectile.velocity.ToRotation(), default); + int num50 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num34, 0f, 0f, 100, default, 1f); + Main.dust[num50].velocity *= 0.3f; + Main.dust[num50].position = projectile.Center + value13 * (float)projectile.width / 2f; + Main.dust[num50].fadeIn = 1.2f; + Main.dust[num50].scale = 1.5f; + Main.dust[num50].noGravity = true; + } + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f); + int num154 = 14; + int num155 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num154 * 2, projectile.height - num154 * 2, 234, 0f, 0f, 100, default, 0.8f); + Main.dust[num155].velocity *= 0.1f; + Main.dust[num155].velocity += projectile.velocity * 0.5f; + Main.dust[num155].noGravity = true; + if (Main.rand.NextBool(12)) + { + int num156 = 16; + int num157 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num156 * 2, projectile.height - num156 * 2, 159, 0f, 0f, 100, default, 1f); + Main.dust[num157].velocity *= 0.25f; + Main.dust[num157].velocity += projectile.velocity * 0.5f; + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); - return false; + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2); + return false; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -202,26 +202,26 @@ namespace CalamityMod.Projectiles.Typeless } public override bool? CanHitNPC(NPC target) - { - if (projectile.alpha >= 128) - { - return false; - } - return null; - } - - public override bool CanHitPvp(Player target) => projectile.alpha < 128; - - public override void Kill(int timeLeft) { - int num47 = Utils.SelectRandom(Main.rand, new int[] + if (projectile.alpha >= 128) { - 246, - 242, - 229, - 226, - 247 - }); + return false; + } + return null; + } + + public override bool CanHitPvp(Player target) => projectile.alpha < 128; + + public override void Kill(int timeLeft) + { + int num47 = Utils.SelectRandom(Main.rand, new int[] + { + 246, + 242, + 229, + 226, + 247 + }); int num48 = 187; int num49 = 234; @@ -242,13 +242,13 @@ namespace CalamityMod.Projectiles.Typeless Dust dust = Main.dust[num54]; dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)projectile.width / 2f; dust.noGravity = true; - dust.velocity.Y -= 6f; - dust.velocity *= 3f; + dust.velocity.Y -= 6f; + dust.velocity *= 3f; dust.velocity += value4 * Main.rand.NextFloat(); num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num48, 0f, 0f, 100, default, num51); dust.position = projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)projectile.width / 2f; - dust.velocity.Y -= 6f; - dust.velocity *= 2f; + dust.velocity.Y -= 6f; + dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Cyan * 0.5f; @@ -261,9 +261,9 @@ namespace CalamityMod.Projectiles.Typeless int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num49, 0f, 0f, 0, default, num52); Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)projectile.velocity.ToRotation(), default) * (float)projectile.width / 3f; Dust dust = Main.dust[num56]; - dust.noGravity = true; - dust.velocity.Y -= 6f; - dust.velocity *= 0.5f; + dust.noGravity = true; + dust.velocity.Y -= 6f; + dust.velocity *= 0.5f; dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); num3 = num55; } diff --git a/Projectiles/Typeless/DarkIce.cs b/Projectiles/Typeless/DarkIce.cs index 1559335df8..0574a74c27 100644 --- a/Projectiles/Typeless/DarkIce.cs +++ b/Projectiles/Typeless/DarkIce.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.ignoreWater = true; projectile.extraUpdates = 1; projectile.coldDamage = true; - projectile.npcProj = true; + projectile.npcProj = true; } public override void SetStaticDefaults() diff --git a/Projectiles/Typeless/DemonshadeRedDevil.cs b/Projectiles/Typeless/DemonshadeRedDevil.cs index b3c5540d7a..9c347a1b4d 100644 --- a/Projectiles/Typeless/DemonshadeRedDevil.cs +++ b/Projectiles/Typeless/DemonshadeRedDevil.cs @@ -140,7 +140,7 @@ namespace CalamityMod.Projectiles.Typeless float num646 = Vector2.Distance(npc.Center, projectile.Center); if (!flag25 && num646 < num633) { - num633 = num646; + num633 = num646; vector46 = npc.Center; flag25 = true; } @@ -256,13 +256,13 @@ namespace CalamityMod.Projectiles.Typeless velocity.Normalize(); velocity *= speed; int trident = Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, Main.myPlayer); - if (trident.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[trident].timeLeft = 300; - Main.projectile[trident].usesLocalNPCImmunity = true; - Main.projectile[trident].localNPCHitCooldown = 10; - Main.projectile[trident].Calamity().forceTypeless = true; //typeless - } + if (trident.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[trident].timeLeft = 300; + Main.projectile[trident].usesLocalNPCImmunity = true; + Main.projectile[trident].localNPCHitCooldown = 10; + Main.projectile[trident].Calamity().forceTypeless = true; //typeless + } projectile.netUpdate = true; } } diff --git a/Projectiles/Typeless/DevourerofCodsBobber.cs b/Projectiles/Typeless/DevourerofCodsBobber.cs index 3597647f95..46a47b7caf 100644 --- a/Projectiles/Typeless/DevourerofCodsBobber.cs +++ b/Projectiles/Typeless/DevourerofCodsBobber.cs @@ -6,64 +6,64 @@ using CalamityMod.Items.Fishing.FishingRods; namespace CalamityMod.Projectiles.Typeless { - public class DevourerofCodsBobber : ModProjectile - { - private bool initialized = false; - private Color fishingLineColor; - public Color[] PossibleLineColors = new Color[] - { - new Color(252, 109, 202, 100), //a pink color - new Color(39, 151, 171, 100) // a blue color - }; + public class DevourerofCodsBobber : ModProjectile + { + private bool initialized = false; + private Color fishingLineColor; + public Color[] PossibleLineColors = new Color[] + { + new Color(252, 109, 202, 100), //a pink color + new Color(39, 151, 171, 100) // a blue color + }; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Devourer of Cods Bobber"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Devourer of Cods Bobber"); + } - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 61; - projectile.bobber = true; - projectile.penetrate = -1; - } + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 61; + projectile.bobber = true; + projectile.penetrate = -1; + } - //What if we want to randomize the line color - public override void AI() - { - if (!initialized) - { - //Decide color of the pole by randomizing the array - fishingLineColor = Main.rand.Next(PossibleLineColors); - initialized = true; - } - } + //What if we want to randomize the line color + public override void AI() + { + if (!initialized) + { + //Decide color of the pole by randomizing the array + fishingLineColor = Main.rand.Next(PossibleLineColors); + initialized = true; + } + } - //fuck glowmasks btw - //i second this notion -Dominic - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D glowmask = ModContent.GetTexture("CalamityMod/Projectiles/Typeless/DevourerofCodsGlow"); - float xOffset = (glowmask.Width - projectile.width) * 0.5f + projectile.width * 0.5f; - Vector2 drawPos = projectile.position - Main.screenPosition; - drawPos.X += xOffset; - drawPos.Y += projectile.height / 2f + projectile.gfxOffY; - Rectangle frame = new Microsoft.Xna.Framework.Rectangle(0, 0, glowmask.Width, glowmask.Height); - Vector2 origin = new Vector2(xOffset, projectile.height / 2f); - SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + //fuck glowmasks btw + //i second this notion -Dominic + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D glowmask = ModContent.GetTexture("CalamityMod/Projectiles/Typeless/DevourerofCodsGlow"); + float xOffset = (glowmask.Width - projectile.width) * 0.5f + projectile.width * 0.5f; + Vector2 drawPos = projectile.position - Main.screenPosition; + drawPos.X += xOffset; + drawPos.Y += projectile.height / 2f + projectile.gfxOffY; + Rectangle frame = new Microsoft.Xna.Framework.Rectangle(0, 0, glowmask.Width, glowmask.Height); + Vector2 origin = new Vector2(xOffset, projectile.height / 2f); + SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - if (projectile.ai[0] <= 1f) - { - Main.spriteBatch.Draw(glowmask, drawPos, frame, Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - } - } + if (projectile.ai[0] <= 1f) + { + Main.spriteBatch.Draw(glowmask, drawPos, frame, Color.White, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + } + } - public override bool PreDrawExtras(SpriteBatch spriteBatch) - { - Lighting.AddLight(projectile.Center, 0.35f, 0f, 0.25f); - return projectile.DrawFishingLine(ModContent.ItemType(), fishingLineColor); - } - } + public override bool PreDrawExtras(SpriteBatch spriteBatch) + { + Lighting.AddLight(projectile.Center, 0.35f, 0f, 0.25f); + return projectile.DrawFishingLine(ModContent.ItemType(), fishingLineColor); + } + } } diff --git a/Projectiles/Typeless/EarlyBloomBobber.cs b/Projectiles/Typeless/EarlyBloomBobber.cs index 4dfa30dc6f..6eefb384f1 100644 --- a/Projectiles/Typeless/EarlyBloomBobber.cs +++ b/Projectiles/Typeless/EarlyBloomBobber.cs @@ -5,26 +5,26 @@ using Terraria.ModLoader; using CalamityMod.Items.Fishing.FishingRods; namespace CalamityMod.Projectiles.Typeless { - public class EarlyBloomBobber : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Early Bloom Bobber"); - } + public class EarlyBloomBobber : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Early Bloom Bobber"); + } - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 61; - projectile.bobber = true; - projectile.penetrate = -1; - } + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 61; + projectile.bobber = true; + projectile.penetrate = -1; + } - public override bool PreDrawExtras(SpriteBatch spriteBatch) - { - Lighting.AddLight(projectile.Center, 0.1f, 0.5f, 0.15f); - return projectile.DrawFishingLine(ModContent.ItemType(), new Color(190, 140, 69, 100)); - } - } + public override bool PreDrawExtras(SpriteBatch spriteBatch) + { + Lighting.AddLight(projectile.Center, 0.1f, 0.5f, 0.15f); + return projectile.DrawFishingLine(ModContent.ItemType(), new Color(190, 140, 69, 100)); + } + } } diff --git a/Projectiles/Typeless/FeralDoubleBobber.cs b/Projectiles/Typeless/FeralDoubleBobber.cs index 9b0b04d9fb..b565b20ce7 100644 --- a/Projectiles/Typeless/FeralDoubleBobber.cs +++ b/Projectiles/Typeless/FeralDoubleBobber.cs @@ -5,26 +5,26 @@ using Terraria.ModLoader; using CalamityMod.Items.Fishing.FishingRods; namespace CalamityMod.Projectiles.Typeless { - public class FeralDoubleBobber : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Feral Bobber"); - } + public class FeralDoubleBobber : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Feral Bobber"); + } - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 61; - projectile.bobber = true; - projectile.penetrate = -1; - } + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 61; + projectile.bobber = true; + projectile.penetrate = -1; + } - public override bool PreDrawExtras(SpriteBatch spriteBatch) - { - Lighting.AddLight(projectile.Center, 0f, 0.25f, 0f); - return projectile.DrawFishingLine(ModContent.ItemType(), new Color(220, 20, 60, 100)); - } - } + public override bool PreDrawExtras(SpriteBatch spriteBatch) + { + Lighting.AddLight(projectile.Center, 0f, 0.25f, 0f); + return projectile.DrawFishingLine(ModContent.ItemType(), new Color(220, 20, 60, 100)); + } + } } diff --git a/Projectiles/Typeless/FiniteUse/ExplosiveShotgunShell.cs b/Projectiles/Typeless/FiniteUse/ExplosiveShotgunShell.cs index 7fe4af21be..260d4d8f5a 100644 --- a/Projectiles/Typeless/FiniteUse/ExplosiveShotgunShell.cs +++ b/Projectiles/Typeless/FiniteUse/ExplosiveShotgunShell.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless.FiniteUse { - public class ExplosiveShotgunShell : ModProjectile + public class ExplosiveShotgunShell : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Typeless/FiniteUse/GrenadeRound.cs b/Projectiles/Typeless/FiniteUse/GrenadeRound.cs index c4d7aa3fb9..c2f5c24a06 100644 --- a/Projectiles/Typeless/FiniteUse/GrenadeRound.cs +++ b/Projectiles/Typeless/FiniteUse/GrenadeRound.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless.FiniteUse { - public class GrenadeRound : ModProjectile + public class GrenadeRound : ModProjectile { public override void SetStaticDefaults() { diff --git a/Projectiles/Typeless/GladiatorSword2.cs b/Projectiles/Typeless/GladiatorSword2.cs index d4dc29f631..54c2e3598a 100644 --- a/Projectiles/Typeless/GladiatorSword2.cs +++ b/Projectiles/Typeless/GladiatorSword2.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.Center = player.Center + new Vector2(80, 0).RotatedBy(rotation); - // Values are slightly different from the other sword to make this sword marginally slower so the intersection point isn't always at the same spot + // Values are slightly different from the other sword to make this sword marginally slower so the intersection point isn't always at the same spot rotation -= 0.09; if (rotation <= 0D) rotation = 360D; diff --git a/Projectiles/Typeless/GodKiller.cs b/Projectiles/Typeless/GodKiller.cs index 95510d4dbf..acc7c30e62 100644 --- a/Projectiles/Typeless/GodKiller.cs +++ b/Projectiles/Typeless/GodKiller.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - if (projectile.alpha > 0) - projectile.alpha -= 5; + if (projectile.alpha > 0) + projectile.alpha -= 5; projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; if (projectile.owner == Main.myPlayer && projectile.timeLeft <= 3) @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Typeless } } } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); } public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Typeless/GodSlayerOrb.cs b/Projectiles/Typeless/GodSlayerOrb.cs index 1416b20eea..1b0368b394 100644 --- a/Projectiles/Typeless/GodSlayerOrb.cs +++ b/Projectiles/Typeless/GodSlayerOrb.cs @@ -4,7 +4,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class GodSlayerOrb : ModProjectile + public class GodSlayerOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Typeless int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 173, 0f, 0f, 100, default, 2f); Main.dust[num469].noGravity = true; Main.dust[num469].velocity *= 0f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Typeless/GodSlayerPhantom.cs b/Projectiles/Typeless/GodSlayerPhantom.cs index 8b33031370..96331c011d 100644 --- a/Projectiles/Typeless/GodSlayerPhantom.cs +++ b/Projectiles/Typeless/GodSlayerPhantom.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.velocity = (projectile.velocity * (num953 - 1f) + moveDirection * scaleFactor12) / num953; return; } - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } else { diff --git a/Projectiles/Typeless/GodSlayerShrapnel.cs b/Projectiles/Typeless/GodSlayerShrapnel.cs index 2323a36ea4..7d80e8cf30 100644 --- a/Projectiles/Typeless/GodSlayerShrapnel.cs +++ b/Projectiles/Typeless/GodSlayerShrapnel.cs @@ -85,6 +85,6 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Typeless/GodSlayerShrapnelRound.cs b/Projectiles/Typeless/GodSlayerShrapnelRound.cs index 0e7fdf26de..b50c2eecb4 100644 --- a/Projectiles/Typeless/GodSlayerShrapnelRound.cs +++ b/Projectiles/Typeless/GodSlayerShrapnelRound.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Typeless int shrapnelAmt = Main.rand.Next(4, 7); for (int s = 0; s < shrapnelAmt; s++) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); } } diff --git a/Projectiles/Typeless/HeronBobber.cs b/Projectiles/Typeless/HeronBobber.cs index 80de1b556b..feb17f2640 100644 --- a/Projectiles/Typeless/HeronBobber.cs +++ b/Projectiles/Typeless/HeronBobber.cs @@ -4,25 +4,25 @@ using Terraria.ModLoader; using CalamityMod.Items.Fishing.FishingRods; namespace CalamityMod.Projectiles.Typeless { - public class HeronBobber : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Heron Bobber"); - } + public class HeronBobber : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Heron Bobber"); + } - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 61; - projectile.bobber = true; - projectile.penetrate = -1; - } + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 61; + projectile.bobber = true; + projectile.penetrate = -1; + } - public override bool PreDrawExtras(SpriteBatch spriteBatch) - { - return projectile.DrawFishingLine(ModContent.ItemType(), new Color(101, 149, 154, 100)); - } - } + public override bool PreDrawExtras(SpriteBatch spriteBatch) + { + return projectile.DrawFishingLine(ModContent.ItemType(), new Color(101, 149, 154, 100)); + } + } } diff --git a/Projectiles/Typeless/HolyEruption.cs b/Projectiles/Typeless/HolyEruption.cs index 4f33ed3a03..71355595c8 100644 --- a/Projectiles/Typeless/HolyEruption.cs +++ b/Projectiles/Typeless/HolyEruption.cs @@ -82,9 +82,9 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 240); } diff --git a/Projectiles/Typeless/HydrothermalSmoke.cs b/Projectiles/Typeless/HydrothermalSmoke.cs index c84877dc68..ccd86b50ba 100644 --- a/Projectiles/Typeless/HydrothermalSmoke.cs +++ b/Projectiles/Typeless/HydrothermalSmoke.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class HydrothermalSmoke : ModProjectile + public class HydrothermalSmoke : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -26,8 +26,8 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - if (projectile.timeLeft == 6) - projectile.Center = Main.player[projectile.owner].Center; + if (projectile.timeLeft == 6) + projectile.Center = Main.player[projectile.owner].Center; int randomDust = Main.rand.Next(4); if (randomDust == 3) @@ -38,22 +38,22 @@ namespace CalamityMod.Projectiles.Typeless { randomDust = 127; } - if (Main.rand.NextBool(4)) - { - int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDust, 0f, 0f, 100, default, 1f); - if (Main.rand.NextBool(4)) - { - Main.dust[num469].scale *= 0.35f; - } - Main.dust[num469].velocity *= 0f; - } + if (Main.rand.NextBool(4)) + { + int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDust, 0f, 0f, 100, default, 1f); + if (Main.rand.NextBool(4)) + { + Main.dust[num469].scale *= 0.35f; + } + Main.dust[num469].velocity *= 0f; + } - Vector2 goreVec = new Vector2(projectile.position.X, projectile.position.Y); - if (Main.rand.NextBool(8)) - { - int smoke = Gore.NewGore(goreVec, default, Main.rand.Next(375, 378), 0.75f); - Main.gore[smoke].behindTiles = true; - } + Vector2 goreVec = new Vector2(projectile.position.X, projectile.position.Y); + if (Main.rand.NextBool(8)) + { + int smoke = Gore.NewGore(goreVec, default, Main.rand.Next(375, 378), 0.75f); + Main.gore[smoke].behindTiles = true; + } } public override bool CanDamage() diff --git a/Projectiles/Typeless/KelvinCatalystStar.cs b/Projectiles/Typeless/KelvinCatalystStar.cs index 329b2af531..d417ceec92 100644 --- a/Projectiles/Typeless/KelvinCatalystStar.cs +++ b/Projectiles/Typeless/KelvinCatalystStar.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class KelvinCatalystStar : ModProjectile + public class KelvinCatalystStar : ModProjectile { public override void SetStaticDefaults() { @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.friendly = true; projectile.penetrate = 1; projectile.tileCollide = false; - projectile.coldDamage = true; + projectile.coldDamage = true; } public override void AI() @@ -37,30 +37,30 @@ namespace CalamityMod.Projectiles.Typeless { projectile.extraUpdates = 1; - Vector2 center = projectile.Center; - float maxDistance = 500f; - bool homeIn = false; + Vector2 center = projectile.Center; + float maxDistance = 500f; + 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) + (float)(Main.npc[i].height / 2); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) - { - center = Main.npc[i].Center; - homeIn = true; - break; - } - } - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + { + center = Main.npc[i].Center; + homeIn = true; + break; + } + } + } - if (homeIn) - { + if (homeIn) + { Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); projectile.velocity = (projectile.velocity * 20f + moveDirection * 12f) / (21f); - } + } else projectile.Kill(); } @@ -91,7 +91,7 @@ namespace CalamityMod.Projectiles.Typeless public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item27, projectile.position); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 24); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 24); int num226 = 36; for (int num227 = 0; num227 < num226; num227++) { diff --git a/Projectiles/Typeless/Nanotech.cs b/Projectiles/Typeless/Nanotech.cs index 48d5a76213..9dd489e27d 100644 --- a/Projectiles/Typeless/Nanotech.cs +++ b/Projectiles/Typeless/Nanotech.cs @@ -21,9 +21,9 @@ namespace CalamityMod.Projectiles.Typeless projectile.penetrate = 1; } - public override bool? CanHitNPC(NPC target) => projectile.ai[1] >= 30f && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.ai[1] >= 30f && target.CanBeChasedBy(projectile); - public override void AI() + public override void AI() { Lighting.AddLight(projectile.Center, new Vector3(0.075f, 0.4f, 0.15f)); @@ -45,25 +45,25 @@ namespace CalamityMod.Projectiles.Typeless } } - if (projectile.ai[1] >= 30f) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + if (projectile.ai[1] >= 30f) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); } - // Reduce damage of projectiles if more than the cap are active - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; - int cap = 5; - int oldDamage = damage; - if (projectileCount > cap) - { - damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); - if (damage < 1) - damage = 1; - } - } + // Reduce damage of projectiles if more than the cap are active + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; + int cap = 5; + int oldDamage = damage; + if (projectileCount > cap) + { + damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); + if (damage < 1) + damage = 1; + } + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { int num3; for (int num191 = 0; num191 < 2; num191 = num3 + 1) diff --git a/Projectiles/Typeless/NavyBobber.cs b/Projectiles/Typeless/NavyBobber.cs index f92ee13080..a0bf92df88 100644 --- a/Projectiles/Typeless/NavyBobber.cs +++ b/Projectiles/Typeless/NavyBobber.cs @@ -5,26 +5,26 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class NavyBobber : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Navy Bobber"); - } + public class NavyBobber : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Navy Bobber"); + } - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 61; - projectile.bobber = true; - projectile.penetrate = -1; - } + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 61; + projectile.bobber = true; + projectile.penetrate = -1; + } - public override bool PreDrawExtras(SpriteBatch spriteBatch) - { - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.25f / 255f, (255 - projectile.alpha) * 0.25f / 255f); - return projectile.DrawFishingLine(ModContent.ItemType(), new Color(36, 61, 111, 100), 55, 33f); - } - } + public override bool PreDrawExtras(SpriteBatch spriteBatch) + { + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.25f / 255f, (255 - projectile.alpha) * 0.25f / 255f); + return projectile.DrawFishingLine(ModContent.ItemType(), new Color(36, 61, 111, 100), 55, 33f); + } + } } diff --git a/Projectiles/Typeless/NebulaDust.cs b/Projectiles/Typeless/NebulaDust.cs index 0bf74e90ad..654dcb2fc2 100644 --- a/Projectiles/Typeless/NebulaDust.cs +++ b/Projectiles/Typeless/NebulaDust.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Projectiles.Typeless projectile.width = 32; projectile.height = 32; projectile.friendly = true; - projectile.Opacity = 0f; - projectile.penetrate = -1; + projectile.Opacity = 0f; + projectile.penetrate = -1; projectile.tileCollide = false; projectile.ignoreWater = true; projectile.timeLeft = 3600; @@ -59,13 +59,13 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - lightColor.R = (byte)(255 * projectile.Opacity); - lightColor.G = (byte)(255 * projectile.Opacity); - lightColor.B = (byte)(255 * projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + lightColor.R = (byte)(255 * projectile.Opacity); + lightColor.G = (byte)(255 * projectile.Opacity); + lightColor.B = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } } diff --git a/Projectiles/Typeless/PendantProjectile1.cs b/Projectiles/Typeless/PendantProjectile1.cs index 3e63e4d649..e5d765f52c 100644 --- a/Projectiles/Typeless/PendantProjectile1.cs +++ b/Projectiles/Typeless/PendantProjectile1.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.ignoreWater = true; projectile.timeLeft = 220; projectile.penetrate = 1; - projectile.tileCollide = false; + projectile.tileCollide = false; } public override void AI() diff --git a/Projectiles/Typeless/PendantProjectile2.cs b/Projectiles/Typeless/PendantProjectile2.cs index fc81792b6e..d6f84e322d 100644 --- a/Projectiles/Typeless/PendantProjectile2.cs +++ b/Projectiles/Typeless/PendantProjectile2.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.ignoreWater = true; projectile.timeLeft = 220; projectile.penetrate = 1; - projectile.tileCollide = false; + projectile.tileCollide = false; } public override void AI() diff --git a/Projectiles/Typeless/PendantProjectile3.cs b/Projectiles/Typeless/PendantProjectile3.cs index 433215f277..2fbc91ac0b 100644 --- a/Projectiles/Typeless/PendantProjectile3.cs +++ b/Projectiles/Typeless/PendantProjectile3.cs @@ -19,12 +19,12 @@ namespace CalamityMod.Projectiles.Typeless projectile.ignoreWater = true; projectile.timeLeft = 220; projectile.penetrate = 1; - projectile.tileCollide = false; + projectile.tileCollide = false; } public override void AI() { - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 10f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 10f, 20f); Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.2f / 255f); projectile.rotation += projectile.velocity.X * 1.25f; diff --git a/Projectiles/Typeless/ReaverOrb.cs b/Projectiles/Typeless/ReaverOrb.cs index c20a77b1c8..ac8a57100c 100644 --- a/Projectiles/Typeless/ReaverOrb.cs +++ b/Projectiles/Typeless/ReaverOrb.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class ReaverOrb : ModProjectile + public class ReaverOrb : ModProjectile { public int dust = 3; @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Typeless } projectile.position.X = (int)projectile.position.X; projectile.position.Y = (int)projectile.position.Y; - } + } public override bool CanDamage() => false; } diff --git a/Projectiles/Typeless/ReaverThornBase.cs b/Projectiles/Typeless/ReaverThornBase.cs index c88e2741cb..384835f987 100644 --- a/Projectiles/Typeless/ReaverThornBase.cs +++ b/Projectiles/Typeless/ReaverThornBase.cs @@ -3,7 +3,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class ReaverThornBase : ModProjectile + public class ReaverThornBase : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/ThornBase"; @@ -14,57 +14,57 @@ namespace CalamityMod.Projectiles.Typeless public override void SetDefaults() { - projectile.width = 28; - projectile.height = 28; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.alpha = 255; - projectile.ignoreWater = true; - projectile.aiStyle = 4; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 10; + projectile.width = 28; + projectile.height = 28; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.aiStyle = 4; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 10; } - public override void AI() - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (projectile.ai[0] == 0f) - { - projectile.alpha -= 50; - if (projectile.alpha > 0) - return; - projectile.alpha = 0; - projectile.ai[0] = 1f; - if (projectile.ai[1] == 0f) - { - projectile.ai[1] += 1f; - projectile.position += projectile.velocity * 1f; - } - if (Main.myPlayer == projectile.owner) - { - int type = projectile.type; - if (projectile.ai[1] >= 6f) - type = ModContent.ProjectileType(); - int thorn = Projectile.NewProjectile(projectile.Center + projectile.velocity, projectile.velocity, type, projectile.damage, projectile.knockBack, projectile.owner); - Main.projectile[thorn].ai[1] = projectile.ai[1] + 1f; - } - } - else - { - if (projectile.alpha < 170 && projectile.alpha + 5 >= 170) - { - for (int index = 0; index < 3; ++index) - { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 18, projectile.velocity.X * 0.025f, projectile.velocity.Y * 0.025f, 170, new Color(), 1.2f); - } - Dust.NewDust(projectile.position, projectile.width, projectile.height, 14, 0f, 0f, 170, new Color(), 1.1f); - } - projectile.alpha += 3; - if (projectile.alpha < 255) - return; - projectile.Kill(); - } - } + public override void AI() + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + if (projectile.ai[0] == 0f) + { + projectile.alpha -= 50; + if (projectile.alpha > 0) + return; + projectile.alpha = 0; + projectile.ai[0] = 1f; + if (projectile.ai[1] == 0f) + { + projectile.ai[1] += 1f; + projectile.position += projectile.velocity * 1f; + } + if (Main.myPlayer == projectile.owner) + { + int type = projectile.type; + if (projectile.ai[1] >= 6f) + type = ModContent.ProjectileType(); + int thorn = Projectile.NewProjectile(projectile.Center + projectile.velocity, projectile.velocity, type, projectile.damage, projectile.knockBack, projectile.owner); + Main.projectile[thorn].ai[1] = projectile.ai[1] + 1f; + } + } + else + { + if (projectile.alpha < 170 && projectile.alpha + 5 >= 170) + { + for (int index = 0; index < 3; ++index) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 18, projectile.velocity.X * 0.025f, projectile.velocity.Y * 0.025f, 170, new Color(), 1.2f); + } + Dust.NewDust(projectile.position, projectile.width, projectile.height, 14, 0f, 0f, 170, new Color(), 1.1f); + } + projectile.alpha += 3; + if (projectile.alpha < 255) + return; + projectile.Kill(); + } + } } } diff --git a/Projectiles/Typeless/ReaverThornTip.cs b/Projectiles/Typeless/ReaverThornTip.cs index 44e1a51c56..b22dea3d7f 100644 --- a/Projectiles/Typeless/ReaverThornTip.cs +++ b/Projectiles/Typeless/ReaverThornTip.cs @@ -2,7 +2,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class ReaverThornTip : ModProjectile + public class ReaverThornTip : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Melee/ThornTip"; @@ -13,17 +13,17 @@ namespace CalamityMod.Projectiles.Typeless public override void SetDefaults() { - projectile.width = 28; - projectile.height = 28; - projectile.aiStyle = 4; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.alpha = 255; - projectile.ignoreWater = true; - aiType = ProjectileID.VilethornTip; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 10; + projectile.width = 28; + projectile.height = 28; + projectile.aiStyle = 4; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.ignoreWater = true; + aiType = ProjectileID.VilethornTip; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 10; } } } diff --git a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs index 6d80a8659b..e42d530209 100644 --- a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs +++ b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class RelicOfDeliveranceSpear : ModProjectile + public class RelicOfDeliveranceSpear : ModProjectile { public Vector2 IdealVelocity = -Vector2.UnitY * MinChargeSpeed; public const int MaxCharges = 3; diff --git a/Projectiles/Typeless/SabatonBoom.cs b/Projectiles/Typeless/SabatonBoom.cs index f54a48a75e..8f2e88e3a6 100644 --- a/Projectiles/Typeless/SabatonBoom.cs +++ b/Projectiles/Typeless/SabatonBoom.cs @@ -15,19 +15,19 @@ namespace CalamityMod.Projectiles.Typeless projectile.friendly = true; projectile.tileCollide = false; projectile.timeLeft = 40; - projectile.usesLocalNPCImmunity = true; + projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; } - public override void AI() - { - if (projectile.ai[0] == 1f) - { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 100); //Not really an expansion - projectile.timeLeft /= 2; - projectile.ai[0] = 0f; - } - } + public override void AI() + { + if (projectile.ai[0] == 1f) + { + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 100); //Not really an expansion + projectile.timeLeft /= 2; + projectile.ai[0] = 0f; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Typeless/SabatonSlam.cs b/Projectiles/Typeless/SabatonSlam.cs index 4b9f90d58a..35d66da747 100644 --- a/Projectiles/Typeless/SabatonSlam.cs +++ b/Projectiles/Typeless/SabatonSlam.cs @@ -34,23 +34,23 @@ namespace CalamityMod.Projectiles.Typeless public override bool OnTileCollide(Vector2 oldVelocity) { Player player = Main.player[projectile.owner]; - //Spawns the shockwave - if (Main.myPlayer == projectile.owner) - { - Projectile.NewProjectile(projectile.position.X + 25, projectile.position.Y + 25, 0f, 0f, ModContent.ProjectileType(), (int)(300 * player.AverageDamage()), 12, projectile.owner); - Main.PlaySound(SoundID.Item14, projectile.position); - player.Calamity().gSabatonFall = 0; - projectile.Kill(); - } - //Pretty things - for (int dustexplode = 0; dustexplode < 360; dustexplode++) - { - Vector2 dustd = new Vector2(17f, 17f).RotatedBy(MathHelper.ToRadians(dustexplode)); - int d = Dust.NewDust(projectile.Center, projectile.width, projectile.height, Main.rand.NextBool(2) ? ModContent.DustType() : ModContent.DustType(), dustd.X, dustd.Y, 100, default, 3f); - Main.dust[d].noGravity = true; - Main.dust[d].position = projectile.Center; - } - return false; + //Spawns the shockwave + if (Main.myPlayer == projectile.owner) + { + Projectile.NewProjectile(projectile.position.X + 25, projectile.position.Y + 25, 0f, 0f, ModContent.ProjectileType(), (int)(300 * player.AverageDamage()), 12, projectile.owner); + Main.PlaySound(SoundID.Item14, projectile.position); + player.Calamity().gSabatonFall = 0; + projectile.Kill(); + } + //Pretty things + for (int dustexplode = 0; dustexplode < 360; dustexplode++) + { + Vector2 dustd = new Vector2(17f, 17f).RotatedBy(MathHelper.ToRadians(dustexplode)); + int d = Dust.NewDust(projectile.Center, projectile.width, projectile.height, Main.rand.NextBool(2) ? ModContent.DustType() : ModContent.DustType(), dustd.X, dustd.Y, 100, default, 3f); + Main.dust[d].noGravity = true; + Main.dust[d].position = projectile.Center; + } + return false; } } } diff --git a/Projectiles/Typeless/SandCloakVeil.cs b/Projectiles/Typeless/SandCloakVeil.cs index 683ac2ef27..907e1849a4 100644 --- a/Projectiles/Typeless/SandCloakVeil.cs +++ b/Projectiles/Typeless/SandCloakVeil.cs @@ -6,7 +6,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class SandCloakVeil : ModProjectile + public class SandCloakVeil : ModProjectile { private const float radius = 225f; private const int duration = 900; @@ -91,8 +91,8 @@ namespace CalamityMod.Projectiles.Typeless { // Knockback has to be done manually to ensure the enemies are repelled from the aura as opposed to thrown to one side of it - if (target.knockBackResist <= 0f) - return; + if (target.knockBackResist <= 0f) + return; if (CalamityGlobalNPC.ShouldAffectNPC(target)) { diff --git a/Projectiles/Typeless/SandExplosion.cs b/Projectiles/Typeless/SandExplosion.cs index 9a78d71c7c..22a4ec6ac4 100644 --- a/Projectiles/Typeless/SandExplosion.cs +++ b/Projectiles/Typeless/SandExplosion.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class SandExplosion : ModProjectile + public class SandExplosion : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Typeless/SepulcherSoul.cs b/Projectiles/Typeless/SepulcherSoul.cs index 38e6ccace4..507140ddae 100644 --- a/Projectiles/Typeless/SepulcherSoul.cs +++ b/Projectiles/Typeless/SepulcherSoul.cs @@ -5,38 +5,38 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class SepulcherSoul : ModProjectile - { - public ref float Time => ref projectile.ai[0]; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tormented Soul"); - Main.projFrames[projectile.type] = 3; - } + public class SepulcherSoul : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tormented Soul"); + Main.projFrames[projectile.type] = 3; + } - public override void SetDefaults() - { - projectile.width = projectile.height = 16; - projectile.Opacity = 0f; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 120; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 16; + projectile.Opacity = 0f; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 120; + } - public override void AI() - { - if (projectile.localAI[0] == 0f) + public override void AI() + { + if (projectile.localAI[0] == 0f) { - projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); - projectile.localAI[0] = 1f; + projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); + projectile.localAI[0] = 1f; } - Vector2 idealVelocity = Vector2.Zero; - idealVelocity.X = (float)(Math.Sin(Time / 27f + projectile.identity * 1.1f) + (float)Math.Cos(Math.E * (Time / 27f + projectile.identity * 1.1f))) * 4f; - idealVelocity.Y = MathHelper.SmoothStep(-3f, -9f, (float)Math.Sin(Time / 23f + projectile.identity * 1.1f) * 0.5f + 0.5f); - projectile.velocity = Vector2.Lerp(projectile.velocity, idealVelocity, 0.075f); - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - projectile.Opacity = Utils.InverseLerp(0f, 15f, Time, true) * Utils.InverseLerp(0f, 25f, projectile.timeLeft, true); - Time++; - } - } + Vector2 idealVelocity = Vector2.Zero; + idealVelocity.X = (float)(Math.Sin(Time / 27f + projectile.identity * 1.1f) + (float)Math.Cos(Math.E * (Time / 27f + projectile.identity * 1.1f))) * 4f; + idealVelocity.Y = MathHelper.SmoothStep(-3f, -9f, (float)Math.Sin(Time / 23f + projectile.identity * 1.1f) * 0.5f + 0.5f); + projectile.velocity = Vector2.Lerp(projectile.velocity, idealVelocity, 0.075f); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.Opacity = Utils.InverseLerp(0f, 15f, Time, true) * Utils.InverseLerp(0f, 25f, projectile.timeLeft, true); + Time++; + } + } } diff --git a/Projectiles/Typeless/SerpentsBiteHook.cs b/Projectiles/Typeless/SerpentsBiteHook.cs index e4b3c0cc3f..e27201f2a5 100644 --- a/Projectiles/Typeless/SerpentsBiteHook.cs +++ b/Projectiles/Typeless/SerpentsBiteHook.cs @@ -7,64 +7,64 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Typeless { - public class SerpentsBiteHook : ModProjectile - { - public const float PullSpeed = 12f; - public const float ReelbackSpeed = 14f; - public const float LaunchSpeed = 18f; - public const float GrappleRangInTiles = 28.125f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Serpent's Bite"); - } + public class SerpentsBiteHook : ModProjectile + { + public const float PullSpeed = 12f; + public const float ReelbackSpeed = 14f; + public const float LaunchSpeed = 18f; + public const float GrappleRangInTiles = 28.125f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Serpent's Bite"); + } - public override void SetDefaults() - { - projectile.CloneDefaults(ProjectileID.GemHookAmethyst); - } + public override void SetDefaults() + { + projectile.CloneDefaults(ProjectileID.GemHookAmethyst); + } - // Use this hook for hooks that can have multiple hooks mid-flight: Dual Hook, Web Slinger, Fish Hook, Static Hook, Lunar Hook - public override bool? CanUseGrapple(Player player) - { - int hooksOut = 0; - for (int l = 0; l < Main.maxProjectiles; l++) - { - if (Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == projectile.type) - { - hooksOut++; - } - } - if (hooksOut > 2) // This hook can have 3 hooks out. - { - return false; - } - return true; - } + // Use this hook for hooks that can have multiple hooks mid-flight: Dual Hook, Web Slinger, Fish Hook, Static Hook, Lunar Hook + public override bool? CanUseGrapple(Player player) + { + int hooksOut = 0; + for (int l = 0; l < Main.maxProjectiles; l++) + { + if (Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == projectile.type) + { + hooksOut++; + } + } + if (hooksOut > 2) // This hook can have 3 hooks out. + { + return false; + } + return true; + } - // Amethyst Hook is 300, Static Hook is 600, 16f = 1 tile - public override float GrappleRange() => GrappleRangInTiles * 16f; + // Amethyst Hook is 300, Static Hook is 600, 16f = 1 tile + public override float GrappleRange() => GrappleRangInTiles * 16f; - public override void NumGrappleHooks(Player player, ref int numHooks) - { - numHooks = 2; - } + public override void NumGrappleHooks(Player player, ref int numHooks) + { + numHooks = 2; + } - // default is 11, Lunar is 24 - public override void GrappleRetreatSpeed(Player player, ref float speed) - { - speed = ReelbackSpeed; - } + // default is 11, Lunar is 24 + public override void GrappleRetreatSpeed(Player player, ref float speed) + { + speed = ReelbackSpeed; + } - public override void GrapplePullSpeed(Player player, ref float speed) - { - speed = PullSpeed; - } + public override void GrapplePullSpeed(Player player, ref float speed) + { + speed = PullSpeed; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityUtils.DrawHook(projectile, GetTexture("CalamityMod/ExtraTextures/Chains/SerpentsBiteChain")); - return true; - } + return true; + } public override void AI() { diff --git a/Projectiles/Typeless/SkyFlareFriendly.cs b/Projectiles/Typeless/SkyFlareFriendly.cs index 88de19c668..86062b7014 100644 --- a/Projectiles/Typeless/SkyFlareFriendly.cs +++ b/Projectiles/Typeless/SkyFlareFriendly.cs @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Typeless num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - CalamityUtils.ExplosionGores(projectile.Center, 3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Typeless/SlurperBobber.cs b/Projectiles/Typeless/SlurperBobber.cs index af21fba268..d79ec02103 100644 --- a/Projectiles/Typeless/SlurperBobber.cs +++ b/Projectiles/Typeless/SlurperBobber.cs @@ -5,26 +5,26 @@ using Terraria.ModLoader; using CalamityMod.Items.Fishing.FishingRods; namespace CalamityMod.Projectiles.Typeless { - public class SlurperBobber : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Slurper Bobber"); - } + public class SlurperBobber : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Slurper Bobber"); + } - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 61; - projectile.bobber = true; - projectile.penetrate = -1; - } + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 61; + projectile.bobber = true; + projectile.penetrate = -1; + } - public override bool PreDrawExtras(SpriteBatch spriteBatch) - { - Lighting.AddLight(projectile.Center, 0.25f, 0f, 0f); - return projectile.DrawFishingLine(ModContent.ItemType(), new Color(227, 79, 79, 100)); - } - } + public override bool PreDrawExtras(SpriteBatch spriteBatch) + { + Lighting.AddLight(projectile.Center, 0.25f, 0f, 0f); + return projectile.DrawFishingLine(ModContent.ItemType(), new Color(227, 79, 79, 100)); + } + } } diff --git a/Projectiles/Typeless/SpiritOriginBullseye.cs b/Projectiles/Typeless/SpiritOriginBullseye.cs index a2223fa435..440c38e4e6 100644 --- a/Projectiles/Typeless/SpiritOriginBullseye.cs +++ b/Projectiles/Typeless/SpiritOriginBullseye.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class SpiritOriginBullseye : ModProjectile + public class SpiritOriginBullseye : ModProjectile { public Player Owner => Main.player[projectile.owner]; public NPC Target => Main.npc[(int)projectile.ai[0]]; diff --git a/Projectiles/Typeless/StandingFire.cs b/Projectiles/Typeless/StandingFire.cs index 506625c457..4c53894270 100644 --- a/Projectiles/Typeless/StandingFire.cs +++ b/Projectiles/Typeless/StandingFire.cs @@ -89,9 +89,9 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Typeless/StarStruckWaterBottle.cs b/Projectiles/Typeless/StarStruckWaterBottle.cs index a30e7286a9..3ab2600d04 100644 --- a/Projectiles/Typeless/StarStruckWaterBottle.cs +++ b/Projectiles/Typeless/StarStruckWaterBottle.cs @@ -17,38 +17,38 @@ namespace CalamityMod.Projectiles.Typeless public override void SetDefaults() { - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 2; - projectile.friendly = true; - projectile.penetrate = 1; + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 2; + projectile.friendly = true; + projectile.penetrate = 1; } public override void AI() { - projectile.ai[0] += 1f; - if (projectile.ai[0] >= 10f) - { - projectile.velocity.Y += 0.1f; - projectile.velocity.X *= 0.998f; - } + projectile.ai[0] += 1f; + if (projectile.ai[0] >= 10f) + { + projectile.velocity.Y += 0.1f; + projectile.velocity.X *= 0.998f; + } } public override void Kill(int timeLeft) { if (projectile.owner == Main.myPlayer) { - Main.PlaySound(SoundID.Shatter, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f); - for (int index = 0; index < 5; ++index) - Dust.NewDust(projectile.position, projectile.width, projectile.height, 13, 0f, 0f, 0, new Color(), 1f); - for (int index1 = 0; index1 < 30; ++index1) - { - int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType(), 0f, -2f, 0, new Color(), 1.1f); - Dust dust = Main.dust[index2]; - dust.alpha = 100; - dust.velocity.X *= 1.5f; - dust.velocity *= 3f; - } + Main.PlaySound(SoundID.Shatter, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f); + for (int index = 0; index < 5; ++index) + Dust.NewDust(projectile.position, projectile.width, projectile.height, 13, 0f, 0f, 0, new Color(), 1f); + for (int index1 = 0; index1 < 30; ++index1) + { + int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType(), 0f, -2f, 0, new Color(), 1.1f); + Dust dust = Main.dust[index2]; + dust.alpha = 100; + dust.velocity.X *= 1.5f; + dust.velocity *= 3f; + } Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, projectile.owner, 4f); } } diff --git a/Projectiles/Typeless/StickyFeatherAero.cs b/Projectiles/Typeless/StickyFeatherAero.cs index fd5257041d..9b055b38c1 100644 --- a/Projectiles/Typeless/StickyFeatherAero.cs +++ b/Projectiles/Typeless/StickyFeatherAero.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class StickyFeatherAero : ModProjectile + public class StickyFeatherAero : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Magic/StickyFeather"; diff --git a/Projectiles/Typeless/SuicideBomberDemon.cs b/Projectiles/Typeless/SuicideBomberDemon.cs index 74da20096f..f03ad218a4 100644 --- a/Projectiles/Typeless/SuicideBomberDemon.cs +++ b/Projectiles/Typeless/SuicideBomberDemon.cs @@ -252,7 +252,7 @@ namespace CalamityMod.Projectiles.Typeless { float flameOrbGlowIntensity = Utils.InverseLerp(90f, 98f, Time, true); for (int i = 0; i < 12; i++) - { + { Color flameOrbColor = Color.LightCyan * flameOrbGlowIntensity * 0.125f; flameOrbColor.A = 0; Vector2 flameOrbDrawOffset = (MathHelper.TwoPi * i / 12f + Main.GlobalTime * 2f).ToRotationVector2(); diff --git a/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs b/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs index 4f3476719e..c79932043f 100644 --- a/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs +++ b/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Typeless } target.AddBuff(BuffID.Venom, fromArmour ? 150 : 120); projectile.Kill(); - } + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Typeless/TarraEnergy.cs b/Projectiles/Typeless/TarraEnergy.cs index 91a226f9d8..560931e917 100644 --- a/Projectiles/Typeless/TarraEnergy.cs +++ b/Projectiles/Typeless/TarraEnergy.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class TarraEnergy : ModProjectile + public class TarraEnergy : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -23,40 +23,40 @@ namespace CalamityMod.Projectiles.Typeless projectile.extraUpdates = 1; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 170 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 170 && target.CanBeChasedBy(projectile); - // Reduce damage of projectiles if more than the cap are active - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; - int cap = 2; - int oldDamage = damage; - if (projectileCount > cap) - { - damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); - if (damage < 1) - damage = 1; - } - } + // Reduce damage of projectiles if more than the cap are active + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; + int cap = 2; + int oldDamage = damage; + if (projectileCount > cap) + { + damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); + if (damage < 1) + damage = 1; + } + } - public override void AI() - { - for (int num136 = 0; num136 < 2; num136++) - { - float x2 = projectile.position.X - projectile.velocity.X / 10f * (float)num136; - float y2 = projectile.position.Y - projectile.velocity.Y / 10f * (float)num136; - Vector2 dspeed = projectile.velocity * Main.rand.NextFloat(0.7f, 0.4f); - int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 107, 0f, 0f, 0, default, 1f); - Main.dust[num137].alpha = projectile.alpha; - Main.dust[num137].position.X = x2; - Main.dust[num137].position.Y = y2; - Main.dust[num137].velocity = dspeed; - Main.dust[num137].noGravity = true; - Main.dust[num137].noLight = true; - } + public override void AI() + { + for (int num136 = 0; num136 < 2; num136++) + { + float x2 = projectile.position.X - projectile.velocity.X / 10f * (float)num136; + float y2 = projectile.position.Y - projectile.velocity.Y / 10f * (float)num136; + Vector2 dspeed = projectile.velocity * Main.rand.NextFloat(0.7f, 0.4f); + int num137 = Dust.NewDust(new Vector2(x2, y2), 1, 1, 107, 0f, 0f, 0, default, 1f); + Main.dust[num137].alpha = projectile.alpha; + Main.dust[num137].position.X = x2; + Main.dust[num137].position.Y = y2; + Main.dust[num137].velocity = dspeed; + Main.dust[num137].noGravity = true; + Main.dust[num137].noLight = true; + } - if (projectile.timeLeft < 170) - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 9f, 20f); - } + if (projectile.timeLeft < 170) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 9f, 20f); + } } } diff --git a/Projectiles/Typeless/TerminusHoldout.cs b/Projectiles/Typeless/TerminusHoldout.cs index 70ed3804a0..6f591ee242 100644 --- a/Projectiles/Typeless/TerminusHoldout.cs +++ b/Projectiles/Typeless/TerminusHoldout.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.penetrate = -1; } - public override void AI() + public override void AI() { Time++; if (!Owner.channel || Owner.noItems || Owner.CCed) @@ -62,20 +62,20 @@ namespace CalamityMod.Projectiles.Typeless } if (projectile.timeLeft == 1) - { - projectile.Kill(); + { + projectile.Kill(); CreateEffectsHandler(); return; - } + } CreateIdleMagicDust(); float currentShakePower = MathHelper.Lerp(0.2f, 8f, Utils.InverseLerp(Lifetime * 0.725f, Lifetime, Time, true)); currentShakePower *= 1f - Utils.InverseLerp(1000f, 3100f, Main.LocalPlayer.Distance(projectile.Center), true); Main.LocalPlayer.Calamity().GeneralScreenShakePower = currentShakePower; - } + } public void CreateEffectsHandler() - { + { Main.PlaySound(SoundID.DD2_EtherianPortalDryadTouch, Main.LocalPlayer.Center); Main.LocalPlayer.Calamity().GeneralScreenShakePower = 16f; if (Main.myPlayer == projectile.owner) @@ -83,23 +83,23 @@ namespace CalamityMod.Projectiles.Typeless } public void CreateMysticDeathDust() - { + { if (Main.dedServ) return; for (int i = 0; i < 20; i++) - { + { Dust paleMagic = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(22f, 28f), 261); paleMagic.velocity = -Vector2.UnitY * Main.rand.NextFloat(1.8f, 3.2f); paleMagic.color = Color.White; paleMagic.scale = Main.rand.NextFloat(1.1f, 1.35f); paleMagic.fadeIn = 1.5f; paleMagic.noGravity = true; - } - } + } + } public void CreateIdleMagicDust() - { + { if (Main.dedServ) return; @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Typeless float outwardness = MathHelper.SmoothStep(40f, 150f, Time / Lifetime); float dustScale = MathHelper.Lerp(1.15f, 1.725f, Time / Lifetime); for (int i = 0; i < dustCount; i++) - { + { Vector2 spawnPosition = projectile.Center + Main.rand.NextVector2Unit() * outwardness * Main.rand.NextFloat(0.75f, 1.1f); Vector2 dustVelocity = (projectile.Center - spawnPosition) * 0.085f + Owner.velocity; @@ -118,15 +118,15 @@ namespace CalamityMod.Projectiles.Typeless paleMagic.noGravity = true; paleMagic.noLight = true; } - } + } public void UpdatePlayerFields() - { + { if (projectile.localAI[0] == 0f) - { + { projectile.spriteDirection = Owner.direction; projectile.localAI[0] = 1f; - } + } Owner.itemRotation = 0f; Owner.heldProj = projectile.whoAmI; Owner.itemTime = 2; @@ -136,15 +136,15 @@ namespace CalamityMod.Projectiles.Typeless projectile.Center = Owner.RotatedRelativePoint(Owner.MountedCenter, true) + Vector2.UnitX * projectile.spriteDirection * 26f; } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { Texture2D texture = Main.projectileTexture[projectile.type]; Vector2 baseDrawPosition = projectile.Center - Main.screenPosition; Vector2 origin = texture.Size() * 0.5f; Color baseColor = Color.Lerp(projectile.GetAlpha(lightColor), Color.White, Utils.InverseLerp(40f, 120f, Time, true)); SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; if (Time >= 150f) - { + { float outwardness = MathHelper.SmoothStep(1f, 15f, Utils.InverseLerp(150f, Lifetime - 30f, Time, true)); Color afterimageColor = Color.Lerp(baseColor, Color.LightCoral, Utils.InverseLerp(150f, 195f, Time, true)) * 0.225f; afterimageColor.A = 0; @@ -158,6 +158,6 @@ namespace CalamityMod.Projectiles.Typeless spriteBatch.Draw(texture, baseDrawPosition, null, baseColor, 0f, origin, projectile.scale, direction, 0f); return false; - } - } + } + } } diff --git a/Projectiles/Typeless/TeslaAura.cs b/Projectiles/Typeless/TeslaAura.cs index 665dd2b457..ec6dac1637 100644 --- a/Projectiles/Typeless/TeslaAura.cs +++ b/Projectiles/Typeless/TeslaAura.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class TeslaAura : ModProjectile + public class TeslaAura : ModProjectile { private const float radius = 98f; private const int framesX = 3; @@ -39,9 +39,9 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - //Protect against other mod projectile reflection like emode Granite Golems - projectile.friendly = true; - projectile.hostile = false; + //Protect against other mod projectile reflection like emode Granite Golems + projectile.friendly = true; + projectile.hostile = false; projectile.frameCounter++; if (projectile.frameCounter > 3) @@ -61,12 +61,12 @@ namespace CalamityMod.Projectiles.Typeless Player player = Main.player[projectile.owner]; Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.15f / 255f, (255 - projectile.alpha) * 0.15f / 255f, (255 - projectile.alpha) * 0.01f / 255f); projectile.Center = player.Center; - if (player is null || player.dead) - { + if (player is null || player.dead) + { player.ClearBuff(ModContent.BuffType()); - player.Calamity().tesla = false; - projectile.Kill(); - } + player.Calamity().tesla = false; + projectile.Kill(); + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -74,8 +74,8 @@ namespace CalamityMod.Projectiles.Typeless target.AddBuff(BuffID.Electrified, 180); target.AddBuff(ModContent.BuffType(), 30); - if (target.knockBackResist <= 0f) - return; + if (target.knockBackResist <= 0f) + return; if (CalamityGlobalNPC.ShouldAffectNPC(target)) { @@ -94,7 +94,7 @@ namespace CalamityMod.Projectiles.Typeless { target.AddBuff(BuffID.Electrified, 180); target.AddBuff(ModContent.BuffType(), 30); - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -138,12 +138,12 @@ namespace CalamityMod.Projectiles.Typeless public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, radius, targetHitbox); public override bool? CanHitNPC(NPC target) - { - if (target.catchItem != 0 && target.type != ModContent.NPCType()) - { - return false; - } - return null; - } + { + if (target.catchItem != 0 && target.type != ModContent.NPCType()) + { + return false; + } + return null; + } } } diff --git a/Projectiles/Typeless/UnstableSpark.cs b/Projectiles/Typeless/UnstableSpark.cs index 6d9cb7bbc9..3cae7f859e 100644 --- a/Projectiles/Typeless/UnstableSpark.cs +++ b/Projectiles/Typeless/UnstableSpark.cs @@ -23,21 +23,21 @@ namespace CalamityMod.Projectiles.Typeless projectile.localNPCHitCooldown = 10; } - // Reduce damage of projectiles if more than the cap are active - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; - int cap = 5; - int oldDamage = damage; - if (projectileCount > cap) - { - damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); - if (damage < 1) - damage = 1; - } - } + // Reduce damage of projectiles if more than the cap are active + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + int projectileCount = Main.player[projectile.owner].ownedProjectileCounts[projectile.type]; + int cap = 5; + int oldDamage = damage; + if (projectileCount > cap) + { + damage -= (int)(oldDamage * ((projectileCount - cap) * 0.05)); + if (damage < 1) + damage = 1; + } + } - public override void AI() + public override void AI() { if (projectile.velocity.X != projectile.velocity.X) { @@ -95,6 +95,6 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) => false; } } diff --git a/Projectiles/Typeless/VanquisherArrowSplit.cs b/Projectiles/Typeless/VanquisherArrowSplit.cs index 80966f261b..d594499d55 100644 --- a/Projectiles/Typeless/VanquisherArrowSplit.cs +++ b/Projectiles/Typeless/VanquisherArrowSplit.cs @@ -5,7 +5,7 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class VanquisherArrowSplit : ModProjectile + public class VanquisherArrowSplit : ModProjectile { public override string Texture => "CalamityMod/Items/Ammo/VanquisherArrow"; @@ -28,24 +28,24 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; - CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 200f, 12f, 20f); } public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) { - if (projectile.timeLeft < 90) - { - Vector2 origin = new Vector2(0f, 0f); - Color color = Color.White; - if (projectile.timeLeft < 85) - { - byte b2 = (byte)(projectile.timeLeft * 3); - byte a2 = (byte)(100f * (b2 / 255f)); - color = new Color(b2, b2, b2, a2); - } - Rectangle frame = new Rectangle(0, 0, Main.projectileTexture[projectile.type].Width, Main.projectileTexture[projectile.type].Height); - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Items/Ammo/VanquisherArrowGlow"), projectile.Center - Main.screenPosition, frame, color, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); - } + if (projectile.timeLeft < 90) + { + Vector2 origin = new Vector2(0f, 0f); + Color color = Color.White; + if (projectile.timeLeft < 85) + { + byte b2 = (byte)(projectile.timeLeft * 3); + byte a2 = (byte)(100f * (b2 / 255f)); + color = new Color(b2, b2, b2, a2); + } + Rectangle frame = new Rectangle(0, 0, Main.projectileTexture[projectile.type].Width, Main.projectileTexture[projectile.type].Height); + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Items/Ammo/VanquisherArrowGlow"), projectile.Center - Main.screenPosition, frame, color, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); + } } public override Color? GetAlpha(Color lightColor) @@ -67,6 +67,6 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - } + } } } diff --git a/Projectiles/Typeless/VerstaltiteBobber.cs b/Projectiles/Typeless/VerstaltiteBobber.cs index 6343baff03..c2f070140a 100644 --- a/Projectiles/Typeless/VerstaltiteBobber.cs +++ b/Projectiles/Typeless/VerstaltiteBobber.cs @@ -5,19 +5,19 @@ using Terraria.ModLoader; using CalamityMod.Items.Fishing.FishingRods; namespace CalamityMod.Projectiles.Typeless { - public class VerstaltiteBobber : ModProjectile + public class VerstaltiteBobber : ModProjectile { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Verstaltite Bobber"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Verstaltite Bobber"); + } public override void SetDefaults() { - //projectile.CloneDefaults(360); //Wooden Bobber - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 61; + //projectile.CloneDefaults(360); //Wooden Bobber + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 61; projectile.bobber = true; projectile.penetrate = -1; } @@ -27,6 +27,6 @@ namespace CalamityMod.Projectiles.Typeless Lighting.AddLight(projectile.Center, 0.4f, 0f, 0.4f); CalamityUtils.DrawFishingLine(projectile, ModContent.ItemType(), new Color(95, 158, 160, 100)); return false; - } + } } } diff --git a/Projectiles/Typeless/WaterConvertor.cs b/Projectiles/Typeless/WaterConvertor.cs index 0072558c70..c0781ba45a 100644 --- a/Projectiles/Typeless/WaterConvertor.cs +++ b/Projectiles/Typeless/WaterConvertor.cs @@ -15,54 +15,54 @@ namespace CalamityMod.Projectiles.Typeless projectile.height = 160; projectile.friendly = true; projectile.tileCollide = false; - projectile.ignoreWater = true; + projectile.ignoreWater = true; projectile.timeLeft = 10; } public override void AI() { - ConvertShit(projectile); - } + ConvertShit(projectile); + } public override void PostAI() { - ConvertShit(projectile); - } + ConvertShit(projectile); + } public void ConvertShit(Projectile projectile) { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int x = (int)(projectile.Center.X / 16f); - int y = (int)(projectile.Center.Y / 16f); - for (int i = x - 5; i <= x + 5; i++) - { - for (int j = y - 5; j <= y + 5; j++) - { - if (projectile.ai[0] == 0f) - { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Pure); - } - if (projectile.ai[0] == 1f) - { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Corrupt); - } - if (projectile.ai[0] == 2f) - { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Crimson); - } - if (projectile.ai[0] == 3f) - { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Hallow); - } - if (projectile.ai[0] == 4f) - { - AstralBiome.ConvertToAstral(i, j); - NetMessage.SendTileRange(-1, i, j, 1, 1); - } - } - } - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int x = (int)(projectile.Center.X / 16f); + int y = (int)(projectile.Center.Y / 16f); + for (int i = x - 5; i <= x + 5; i++) + { + for (int j = y - 5; j <= y + 5; j++) + { + if (projectile.ai[0] == 0f) + { + AstralBiome.ConvertFromAstral(i, j, ConvertType.Pure); + } + if (projectile.ai[0] == 1f) + { + AstralBiome.ConvertFromAstral(i, j, ConvertType.Corrupt); + } + if (projectile.ai[0] == 2f) + { + AstralBiome.ConvertFromAstral(i, j, ConvertType.Crimson); + } + if (projectile.ai[0] == 3f) + { + AstralBiome.ConvertFromAstral(i, j, ConvertType.Hallow); + } + if (projectile.ai[0] == 4f) + { + AstralBiome.ConvertToAstral(i, j); + NetMessage.SendTileRange(-1, i, j, 1, 1); + } + } + } + } } public override bool CanDamage() diff --git a/Projectiles/Typeless/WulfrumBobber.cs b/Projectiles/Typeless/WulfrumBobber.cs index c5984b55fb..d90a056c1a 100644 --- a/Projectiles/Typeless/WulfrumBobber.cs +++ b/Projectiles/Typeless/WulfrumBobber.cs @@ -4,25 +4,25 @@ using Terraria.ModLoader; using CalamityMod.Items.Fishing.FishingRods; namespace CalamityMod.Projectiles.Typeless { - public class WulfrumBobber : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Wulfrum Bobber"); - } + public class WulfrumBobber : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wulfrum Bobber"); + } - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.aiStyle = 61; - projectile.bobber = true; - projectile.penetrate = -1; - } + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.aiStyle = 61; + projectile.bobber = true; + projectile.penetrate = -1; + } - public override bool PreDrawExtras(SpriteBatch spriteBatch) - { - return projectile.DrawFishingLine(ModContent.ItemType(), new Color(200, 200, 200, 100), 38, 28f); - } - } + public override bool PreDrawExtras(SpriteBatch spriteBatch) + { + return projectile.DrawFishingLine(ModContent.ItemType(), new Color(200, 200, 200, 100), 38, 28f); + } + } } diff --git a/Projectiles/Typeless/XerocBlast.cs b/Projectiles/Typeless/XerocBlast.cs index f8c8a27929..a54813179f 100644 --- a/Projectiles/Typeless/XerocBlast.cs +++ b/Projectiles/Typeless/XerocBlast.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class XerocBlast : ModProjectile + public class XerocBlast : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; diff --git a/Projectiles/Typeless/XerocBubble.cs b/Projectiles/Typeless/XerocBubble.cs index 597ef3a37e..1dd98f344d 100644 --- a/Projectiles/Typeless/XerocBubble.cs +++ b/Projectiles/Typeless/XerocBubble.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class XerocBubble : ModProjectile + public class XerocBubble : ModProjectile { public override void SetStaticDefaults() { @@ -25,13 +25,13 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 62, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; - } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 8f, 20f); + if (projectile.localAI[0] > 4f) + { + int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 62, 0f, 0f, 100, default, 1f); + Main.dust[num469].noGravity = true; + Main.dust[num469].velocity *= 0f; + } + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 8f, 20f); } } } diff --git a/Projectiles/Typeless/XerocFire.cs b/Projectiles/Typeless/XerocFire.cs index ae5155b56d..4f6f55447a 100644 --- a/Projectiles/Typeless/XerocFire.cs +++ b/Projectiles/Typeless/XerocFire.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class XerocFire : ModProjectile + public class XerocFire : ModProjectile { public override void SetStaticDefaults() { @@ -60,16 +60,16 @@ namespace CalamityMod.Projectiles.Typeless dust2.noGravity = true; dust2.velocity *= 0.1f; } - else - { - int num199 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 62, 0f, 0f, 100, default, 0.75f); - 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 -= 2f; - } + else + { + int num199 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 62, 0f, 0f, 100, default, 0.75f); + 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 -= 2f; + } if (projectile.velocity.Y < 0.25f && projectile.velocity.Y > 0.15f) { projectile.velocity.X *= 0.8f; @@ -81,6 +81,6 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Typeless/XerocOrb.cs b/Projectiles/Typeless/XerocOrb.cs index dd18458f03..0c2bd037d4 100644 --- a/Projectiles/Typeless/XerocOrb.cs +++ b/Projectiles/Typeless/XerocOrb.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class XerocOrb : ModProjectile + public class XerocOrb : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Healing/XerocHealOrb"; @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Typeless int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 62, 0f, 0f, 100, default, 2f); Main.dust[num469].noGravity = true; Main.dust[num469].velocity *= 0f; - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 7f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 7f, 20f); } } } diff --git a/Projectiles/Typeless/XerocStar.cs b/Projectiles/Typeless/XerocStar.cs index 477ed1393f..dddcc953a2 100644 --- a/Projectiles/Typeless/XerocStar.cs +++ b/Projectiles/Typeless/XerocStar.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class XerocStar : ModProjectile + public class XerocStar : ModProjectile { public override void SetStaticDefaults() { @@ -20,21 +20,21 @@ namespace CalamityMod.Projectiles.Typeless projectile.friendly = true; projectile.penetrate = 1; projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 300; + projectile.ignoreWater = true; + projectile.timeLeft = 300; } public override void AI() { projectile.rotation += 0.25f; projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 62, 0f, 0f, 100, default, 2f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; - } - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 10f, 20f); + if (projectile.localAI[0] > 4f) + { + int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 62, 0f, 0f, 100, default, 2f); + Main.dust[num469].noGravity = true; + Main.dust[num469].velocity *= 0f; + } + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 10f, 20f); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Typeless/YanmeisKnifeSlash.cs b/Projectiles/Typeless/YanmeisKnifeSlash.cs index c1e1c1ee6e..ab9cc76114 100644 --- a/Projectiles/Typeless/YanmeisKnifeSlash.cs +++ b/Projectiles/Typeless/YanmeisKnifeSlash.cs @@ -12,126 +12,126 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class YanmeisKnifeSlash : ModProjectile - { - // This is a rather weird thing, but it's what the patron asked for. - public static readonly Func CanRecieveCoolEffectsFrom = (npc) => - { - bool validBoss = npc.boss && 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 (validBoss) - return true; - bool bossMinion = CalamityLists.bossMinionList.Contains(npc.type); - if (bossMinion) - return true; - bool miniboss = CalamityLists.minibossList.Contains(npc.type) || AcidRainEvent.AllMinibosses.Contains(npc.type); - return miniboss; - }; + public class YanmeisKnifeSlash : ModProjectile + { + // This is a rather weird thing, but it's what the patron asked for. + public static readonly Func CanRecieveCoolEffectsFrom = (npc) => + { + bool validBoss = npc.boss && 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 (validBoss) + return true; + bool bossMinion = CalamityLists.bossMinionList.Contains(npc.type); + if (bossMinion) + return true; + bool miniboss = CalamityLists.minibossList.Contains(npc.type) || AcidRainEvent.AllMinibosses.Contains(npc.type); + return miniboss; + }; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Yanmei's Knife"); - Main.projFrames[projectile.type] = 5; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Yanmei's Knife"); + Main.projFrames[projectile.type] = 5; + } - public override void SetDefaults() - { - projectile.width = 180; - projectile.height = 96; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.ownerHitCheck = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; - } + public override void SetDefaults() + { + projectile.width = 180; + projectile.height = 96; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ownerHitCheck = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; + public override void AI() + { + Player player = Main.player[projectile.owner]; - // Frames and crap - projectile.frameCounter++; - if (projectile.frameCounter % 7 == 0) - { - projectile.frame++; - if (projectile.frame >= Main.projFrames[projectile.type]) - projectile.Kill(); - } + // Frames and crap + projectile.frameCounter++; + if (projectile.frameCounter % 7 == 0) + { + projectile.frame++; + if (projectile.frame >= Main.projFrames[projectile.type]) + projectile.Kill(); + } - // Create idle light and dust. - Vector2 origin = projectile.Center + projectile.velocity * 3f; - Lighting.AddLight(origin, 0f, 1.5f, 0.1f); + // Create idle light and dust. + Vector2 origin = projectile.Center + projectile.velocity * 3f; + Lighting.AddLight(origin, 0f, 1.5f, 0.1f); - Vector2 playerRotatedPoint = player.RotatedRelativePoint(player.MountedCenter, true); + Vector2 playerRotatedPoint = player.RotatedRelativePoint(player.MountedCenter, true); - // Rotation and directioning. - float velocityAngle = projectile.velocity.ToRotation(); - projectile.rotation = velocityAngle + (projectile.spriteDirection == -1).ToInt() * MathHelper.Pi; - projectile.direction = (Math.Cos(velocityAngle) > 0).ToDirectionInt(); + // Rotation and directioning. + float velocityAngle = projectile.velocity.ToRotation(); + projectile.rotation = velocityAngle + (projectile.spriteDirection == -1).ToInt() * MathHelper.Pi; + projectile.direction = (Math.Cos(velocityAngle) > 0).ToDirectionInt(); - // Positioning close to the end of the player's arm. - projectile.position = playerRotatedPoint - projectile.Size * 0.5f + velocityAngle.ToRotationVector2() * 80f; + // Positioning close to the end of the player's arm. + projectile.position = playerRotatedPoint - projectile.Size * 0.5f + velocityAngle.ToRotationVector2() * 80f; - // Sprite and player directioning. - projectile.spriteDirection = projectile.direction; - player.ChangeDir(projectile.direction); + // Sprite and player directioning. + projectile.spriteDirection = projectile.direction; + player.ChangeDir(projectile.direction); - // Prevents the projectile from dying - projectile.timeLeft = 2; + // Prevents the projectile from dying + projectile.timeLeft = 2; - // Player item-based field manipulation. - player.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); - player.heldProj = projectile.whoAmI; - player.itemTime = 2; - player.itemAnimation = 2; - } + // Player item-based field manipulation. + player.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); + player.heldProj = projectile.whoAmI; + player.itemTime = 2; + player.itemAnimation = 2; + } - public void HandleAttachmentMovement(Player player, Vector2 playerRotatedPoint) - { - float speed = 1f; - if (player.ActiveItem().shoot == projectile.type) - { - speed = player.ActiveItem().shootSpeed * projectile.scale; - } - Vector2 newVelocity = (Main.MouseWorld - playerRotatedPoint).SafeNormalize(Vector2.UnitX * player.direction) * speed; + public void HandleAttachmentMovement(Player player, Vector2 playerRotatedPoint) + { + float speed = 1f; + if (player.ActiveItem().shoot == projectile.type) + { + speed = player.ActiveItem().shootSpeed * projectile.scale; + } + Vector2 newVelocity = (Main.MouseWorld - playerRotatedPoint).SafeNormalize(Vector2.UnitX * player.direction) * speed; - // Sync if a velocity component changes. - if (projectile.velocity.X != newVelocity.X || projectile.velocity.Y != newVelocity.Y) - { - projectile.netUpdate = true; - } - projectile.velocity = newVelocity; - } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (!CanRecieveCoolEffectsFrom(target)) - return; - target.AddBuff(ModContent.BuffType(), 600); - if (!Main.dedServ) - { - for (int i = 0; i < 60; i++) - { - Dust dust = Dust.NewDustDirect(Main.player[projectile.owner].position, Main.player[projectile.owner].width, Main.player[projectile.owner].height, 267); - dust.position.X += Main.rand.NextFloat(-16f, 16f); - dust.color = Main.hslToRgb(Main.rand.NextFloat(0.26f, 0.37f), 1f, 0.75f); - dust.velocity = Main.rand.NextVector2Circular(24f, 24f); - dust.scale = Main.rand.NextFloat(1.4f, 1.8f); - dust.noGravity = true; - } - } - if (projectile.ai[0] == 0f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/YanmeiKnifeHit"), (int)projectile.position.X, (int)projectile.position.Y); - projectile.ai[0] = 1f; - } - Main.player[projectile.owner].AddBuff(ModContent.BuffType(), 600); - } - public override Color? GetAlpha(Color lightColor) => new Color(0, 215, 0, 0); - } + // Sync if a velocity component changes. + if (projectile.velocity.X != newVelocity.X || projectile.velocity.Y != newVelocity.Y) + { + projectile.netUpdate = true; + } + projectile.velocity = newVelocity; + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (!CanRecieveCoolEffectsFrom(target)) + return; + target.AddBuff(ModContent.BuffType(), 600); + if (!Main.dedServ) + { + for (int i = 0; i < 60; i++) + { + Dust dust = Dust.NewDustDirect(Main.player[projectile.owner].position, Main.player[projectile.owner].width, Main.player[projectile.owner].height, 267); + dust.position.X += Main.rand.NextFloat(-16f, 16f); + dust.color = Main.hslToRgb(Main.rand.NextFloat(0.26f, 0.37f), 1f, 0.75f); + dust.velocity = Main.rand.NextVector2Circular(24f, 24f); + dust.scale = Main.rand.NextFloat(1.4f, 1.8f); + dust.noGravity = true; + } + } + if (projectile.ai[0] == 0f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/YanmeiKnifeHit"), (int)projectile.position.X, (int)projectile.position.Y); + projectile.ai[0] = 1f; + } + Main.player[projectile.owner].AddBuff(ModContent.BuffType(), 600); + } + public override Color? GetAlpha(Color lightColor) => new Color(0, 215, 0, 0); + } } diff --git a/Schematics/CalamitySchematicIO.cs b/Schematics/CalamitySchematicIO.cs index ee4b26f00f..01a6ef935f 100644 --- a/Schematics/CalamitySchematicIO.cs +++ b/Schematics/CalamitySchematicIO.cs @@ -11,556 +11,556 @@ using Terraria.ModLoader.IO; namespace CalamityMod.Schematics { - #region Structs - // A struct parallel to Tile which, for modded tiles, stores offset tile and wall type IDs based on the schematic's mod name arrays. - public struct SchematicMetaTile - { - public byte bTileHeader, bTileHeader2, bTileHeader3; - public ushort sTileHeader; - public ushort type; // If >= TileID.Count, is a modded tile type; consult mod tile name array - public ushort wall; // If >= WallID.Count, is a modded wall type; consule mod wall name array - internal readonly ushort originalType; - internal readonly ushort originalWall; - public byte liquid; - public short frameX, frameY; - public bool keepTile; - public bool keepWall; + #region Structs + // A struct parallel to Tile which, for modded tiles, stores offset tile and wall type IDs based on the schematic's mod name arrays. + public struct SchematicMetaTile + { + public byte bTileHeader, bTileHeader2, bTileHeader3; + public ushort sTileHeader; + public ushort type; // If >= TileID.Count, is a modded tile type; consult mod tile name array + public ushort wall; // If >= WallID.Count, is a modded wall type; consule mod wall name array + internal readonly ushort originalType; + internal readonly ushort originalWall; + public byte liquid; + public short frameX, frameY; + public bool keepTile; + public bool keepWall; - public SchematicMetaTile(Tile t) - { - bTileHeader = t.bTileHeader; - bTileHeader2 = t.bTileHeader2; - bTileHeader3 = t.bTileHeader3; - sTileHeader = t.sTileHeader; - type = t.type; // This is changed later if it's modded - wall = t.wall; // This is changed later if it's modded - originalType = type; // This is never changed - originalWall = wall; // This is never changed - liquid = t.liquid; - frameX = t.frameX; - frameY = t.frameY; - keepTile = false; - keepWall = false; - } + public SchematicMetaTile(Tile t) + { + bTileHeader = t.bTileHeader; + bTileHeader2 = t.bTileHeader2; + bTileHeader3 = t.bTileHeader3; + sTileHeader = t.sTileHeader; + type = t.type; // This is changed later if it's modded + wall = t.wall; // This is changed later if it's modded + originalType = type; // This is never changed + originalWall = wall; // This is never changed + liquid = t.liquid; + frameX = t.frameX; + frameY = t.frameY; + keepTile = false; + keepWall = false; + } - // This function is used by the schematic placer to respect the keepTile and keepWall booleans. - public void ApplyTo(ref Tile target, Tile original) - { - // This full-overwrite hypothetical tile is used to partially copy over various forms of data. - // A lot of tile data is nefariously binary encoded into the tile header bytes. - Tile replacement = new Tile - { - bTileHeader = bTileHeader, - bTileHeader2 = bTileHeader2, - bTileHeader3 = bTileHeader3, - sTileHeader = sTileHeader, - type = type, - frameX = frameX, - frameY = frameY, - wall = wall, - liquid = liquid - }; + // This function is used by the schematic placer to respect the keepTile and keepWall booleans. + public void ApplyTo(ref Tile target, Tile original) + { + // This full-overwrite hypothetical tile is used to partially copy over various forms of data. + // A lot of tile data is nefariously binary encoded into the tile header bytes. + Tile replacement = new Tile + { + bTileHeader = bTileHeader, + bTileHeader2 = bTileHeader2, + bTileHeader3 = bTileHeader3, + sTileHeader = sTileHeader, + type = type, + frameX = frameX, + frameY = frameY, + wall = wall, + liquid = liquid + }; - if (!keepTile && !keepWall) // full overwrite - target.CopyFrom(replacement); - else if (keepTile && keepWall) // full preservation - target.CopyFrom(original); - else if (keepWall) // wall from original, tile from replacement - { - target.CopyFrom(replacement); - target.wall = original.wall; - target.wallFrameX(original.wallFrameX()); - target.wallFrameY(original.wallFrameY()); - target.wallColor(original.wallColor()); - } - else if (keepTile) // tile from original, wall from replacement - { - target.CopyFrom(original); - target.wall = replacement.wall; - target.wallFrameX(replacement.wallFrameX()); - target.wallFrameY(replacement.wallFrameY()); - target.wallColor(replacement.wallColor()); - } - } - } + if (!keepTile && !keepWall) // full overwrite + target.CopyFrom(replacement); + else if (keepTile && keepWall) // full preservation + target.CopyFrom(original); + else if (keepWall) // wall from original, tile from replacement + { + target.CopyFrom(replacement); + target.wall = original.wall; + target.wallFrameX(original.wallFrameX()); + target.wallFrameY(original.wallFrameY()); + target.wallColor(original.wallColor()); + } + else if (keepTile) // tile from original, wall from replacement + { + target.CopyFrom(original); + target.wall = replacement.wall; + target.wallFrameX(replacement.wallFrameX()); + target.wallFrameY(replacement.wallFrameY()); + target.wallColor(replacement.wallColor()); + } + } + } - // A container struct for a List of unique tile definitions and an array of indices to those tile definitions. - public struct SchematicData - { - // Schematics assume 1024 or less unique tile definitions for their internal buffer. - // In real schematics, this number usually doesn't go above about 800. - // The buffer can be expanded up to 65536, as the indices used for it are 2 bytes. - // Note this would by definition require a schematic of size at least 256x256, so you should never really get to this point. - private const int DefaultUniqueTileCount = 1024; - public const int MaxUniqueTileCount = ushort.MaxValue + 1; - private const int DefaultModTileCount = 256; - private const int DefaultModWallCount = 32; + // A container struct for a List of unique tile definitions and an array of indices to those tile definitions. + public struct SchematicData + { + // Schematics assume 1024 or less unique tile definitions for their internal buffer. + // In real schematics, this number usually doesn't go above about 800. + // The buffer can be expanded up to 65536, as the indices used for it are 2 bytes. + // Note this would by definition require a schematic of size at least 256x256, so you should never really get to this point. + private const int DefaultUniqueTileCount = 1024; + public const int MaxUniqueTileCount = ushort.MaxValue + 1; + private const int DefaultModTileCount = 256; + private const int DefaultModWallCount = 32; - public readonly IList uniqueTiles; - public readonly IList modTileNames; - public readonly IList modWallNames; - public readonly ushort[,] areaIndices; + public readonly IList uniqueTiles; + public readonly IList modTileNames; + public readonly IList modWallNames; + public readonly ushort[,] areaIndices; - public SchematicData(int width, int height) - { - // Schematics by default have one "unique tile", which is air -- equivalent to new Tile(). - // This tile is always provided in schematics, even if it isn't used (e.g. your schematic is a solid block of stone). - // This allows for index zero to always refer to a fully blank tile. - uniqueTiles = new List(DefaultUniqueTileCount) - { - new SchematicMetaTile() - }; - modTileNames = new List(DefaultModTileCount); - modWallNames = new List(DefaultModWallCount); - areaIndices = new ushort[width, height]; - } - } + public SchematicData(int width, int height) + { + // Schematics by default have one "unique tile", which is air -- equivalent to new Tile(). + // This tile is always provided in schematics, even if it isn't used (e.g. your schematic is a solid block of stone). + // This allows for index zero to always refer to a fully blank tile. + uniqueTiles = new List(DefaultUniqueTileCount) + { + new SchematicMetaTile() + }; + modTileNames = new List(DefaultModTileCount); + modWallNames = new List(DefaultModWallCount); + areaIndices = new ushort[width, height]; + } + } - public enum ExportResult - { - Success, - CornerOutOfWorld, - ZeroArea, - TooManyUniqueTiles, - }; - #endregion + public enum ExportResult + { + Success, + CornerOutOfWorld, + ZeroArea, + TooManyUniqueTiles, + }; + #endregion - public static class CalamitySchematicIO - { - // A generous buffer of 1 megabyte is the default for schematics. If this somehow isn't big enough, they can get bigger. - private const int SchematicBufferStartingSize = 1048576; + public static class CalamitySchematicIO + { + // A generous buffer of 1 megabyte is the default for schematics. If this somehow isn't big enough, they can get bigger. + private const int SchematicBufferStartingSize = 1048576; - // If true, written schematics will have all data GZip compressed except for the magic number header. - public static bool UseCompression = true; + // If true, written schematics will have all data GZip compressed except for the magic number header. + public static bool UseCompression = true; - // This is a 3-byte magic number header for Calamity Schematic Files. CA1A5C = "CalaSC" - private static readonly byte[] SchematicMagicNumberHeader = new byte[] - { - 0xCA, - 0x1A, - 0x5C - }; - private const byte UncompressedMagicNumber = 0x00; - private const byte CompressedMagicNumber = 0xC0; - private const string PreserveTileName = "_"; + // This is a 3-byte magic number header for Calamity Schematic Files. CA1A5C = "CalaSC" + private static readonly byte[] SchematicMagicNumberHeader = new byte[] + { + 0xCA, + 0x1A, + 0x5C + }; + private const byte UncompressedMagicNumber = 0x00; + private const byte CompressedMagicNumber = 0xC0; + private const string PreserveTileName = "_"; - // These two fields are set to a non-zero value when the CalamitySchematicExporter mod loads. - public static ushort PreserveTileID = 0; - public static ushort PreserveWallID = 0; + // These two fields are set to a non-zero value when the CalamitySchematicExporter mod loads. + public static ushort PreserveTileID = 0; + public static ushort PreserveWallID = 0; - #region Export Helper Methods - private static Tile[,] GetTilesInRectangle(Rectangle area) - { - Tile[,] tiles = new Tile[area.Width, area.Height]; - for (int i = area.Left; i < area.Right; i++) - for (int j = area.Top; j < area.Bottom; j++) - { - Tile t = Main.tile[i, j]; - if (t is null) // Vanilla does this itself all the time. I wish it weren't necessary. - t = new Tile(); - tiles[i - area.Left, j - area.Top] = t; - } - return tiles; - } + #region Export Helper Methods + private static Tile[,] GetTilesInRectangle(Rectangle area) + { + Tile[,] tiles = new Tile[area.Width, area.Height]; + for (int i = area.Left; i < area.Right; i++) + for (int j = area.Top; j < area.Bottom; j++) + { + Tile t = Main.tile[i, j]; + if (t is null) // Vanilla does this itself all the time. I wish it weren't necessary. + t = new Tile(); + tiles[i - area.Left, j - area.Top] = t; + } + return tiles; + } - // This equality is slightly more strict than Tile.isTheSameAs because it checks type, wall and frame on non-active tiles. - public static bool EqualToMetaTile(this Tile t, SchematicMetaTile smt) - { - bool tileHeadersMatch = (t.bTileHeader == smt.bTileHeader) & (t.bTileHeader2 == smt.bTileHeader2) & (t.bTileHeader3 == smt.bTileHeader3) & (t.sTileHeader == smt.sTileHeader); - if (!tileHeadersMatch) - return false; + // This equality is slightly more strict than Tile.isTheSameAs because it checks type, wall and frame on non-active tiles. + public static bool EqualToMetaTile(this Tile t, SchematicMetaTile smt) + { + bool tileHeadersMatch = (t.bTileHeader == smt.bTileHeader) & (t.bTileHeader2 == smt.bTileHeader2) & (t.bTileHeader3 == smt.bTileHeader3) & (t.sTileHeader == smt.sTileHeader); + if (!tileHeadersMatch) + return false; - bool typesMatch = t.type == smt.originalType; - if (!typesMatch) - return false; + bool typesMatch = t.type == smt.originalType; + if (!typesMatch) + return false; - bool wallsMatch = t.wall == smt.originalWall; - if (!wallsMatch) - return false; + bool wallsMatch = t.wall == smt.originalWall; + if (!wallsMatch) + return false; - bool framesMatch = t.frameX == smt.frameX; - framesMatch &= t.frameY == smt.frameY; - // Wall frames are not checked separately because these are computed from binary headers. - // wallFrameX() => (bTileHeader2 & 0xF) * 36; - // wallFrameY() => (bTileHeader3 & 7) * 36; - if (!framesMatch) - return false; + bool framesMatch = t.frameX == smt.frameX; + framesMatch &= t.frameY == smt.frameY; + // Wall frames are not checked separately because these are computed from binary headers. + // wallFrameX() => (bTileHeader2 & 0xF) * 36; + // wallFrameY() => (bTileHeader3 & 7) * 36; + if (!framesMatch) + return false; - // Lava and honey state are not checked separately because these are computed from binary headers. - // lava() => (bTileHeader & 0x20) == 32; - // honey() => (bTileHeader & 0x40) == 64; - return t.liquid == smt.liquid; - } + // Lava and honey state are not checked separately because these are computed from binary headers. + // lava() => (bTileHeader & 0x20) == 32; + // honey() => (bTileHeader & 0x40) == 64; + return t.liquid == smt.liquid; + } - private static int GetMetaTileIndex(IList metaTiles, Tile toSearch) - { - int numTiles = metaTiles.Count; - for (int i = 0; i < numTiles; ++i) - if (toSearch.EqualToMetaTile(metaTiles[i])) - return i; - return -1; - } + private static int GetMetaTileIndex(IList metaTiles, Tile toSearch) + { + int numTiles = metaTiles.Count; + for (int i = 0; i < numTiles; ++i) + if (toSearch.EqualToMetaTile(metaTiles[i])) + return i; + return -1; + } - private static string GetFullName(this ModTile mt) => $"{mt.mod.Name}/{mt.Name}"; - private static string GetFullName(this ModWall mw) => $"{mw.mod.Name}/{mw.Name}"; + private static string GetFullName(this ModTile mt) => $"{mt.mod.Name}/{mt.Name}"; + private static string GetFullName(this ModWall mw) => $"{mw.mod.Name}/{mw.Name}"; - private static void ComputeMetaIndices(ref SchematicData schematic, ref SchematicMetaTile smt) - { - // Special case: this meta tile demands that the original tile in the destination be preserved. - // The meta index of this special mod tile name is always zero. - if (PreserveTileID > 0 && smt.type == PreserveTileID) - { - smt.type = TileID.Count; - smt.keepTile = true; - } - else if (smt.type >= TileID.Count) - { - ModTile mt = ModContent.GetModTile(smt.type); - if (mt != null) - { - // This tile has a valid modded tile. Check if that ModTile is already registered to find its index. - string tileFullName = mt.GetFullName(); - int tileNameIndex = schematic.modTileNames.IndexOf(tileFullName); - if (tileNameIndex == -1) - { - // This modded tile is not yet registered. Register it. The list's previous length is its index. - tileNameIndex = schematic.modTileNames.Count; - schematic.modTileNames.Add(tileFullName); - } + private static void ComputeMetaIndices(ref SchematicData schematic, ref SchematicMetaTile smt) + { + // Special case: this meta tile demands that the original tile in the destination be preserved. + // The meta index of this special mod tile name is always zero. + if (PreserveTileID > 0 && smt.type == PreserveTileID) + { + smt.type = TileID.Count; + smt.keepTile = true; + } + else if (smt.type >= TileID.Count) + { + ModTile mt = ModContent.GetModTile(smt.type); + if (mt != null) + { + // This tile has a valid modded tile. Check if that ModTile is already registered to find its index. + string tileFullName = mt.GetFullName(); + int tileNameIndex = schematic.modTileNames.IndexOf(tileFullName); + if (tileNameIndex == -1) + { + // This modded tile is not yet registered. Register it. The list's previous length is its index. + tileNameIndex = schematic.modTileNames.Count; + schematic.modTileNames.Add(tileFullName); + } - // Adjust the meta tile's type so that it points to the mod tile name array. - // typeOriginal is unaffected so that future searches will still function. - smt.type = (ushort)(TileID.Count + tileNameIndex); - } - } + // Adjust the meta tile's type so that it points to the mod tile name array. + // typeOriginal is unaffected so that future searches will still function. + smt.type = (ushort)(TileID.Count + tileNameIndex); + } + } - // Special case: this meta tile demands that the original wall in the destination be preserved. - // The meta index of this special mod wall name is always zero. - if (PreserveWallID > 0 && smt.wall == PreserveWallID) - { - smt.wall = WallID.Count; - smt.keepWall = true; - } - else if (smt.wall >= WallID.Count) - { - ModWall mw = ModContent.GetModWall(smt.wall); - if (mw != null) - { - // This tile has a valid modded wall. Check if that ModWall is already registered to find its index. - string wallFullName = mw.GetFullName(); - int wallNameIndex = schematic.modWallNames.IndexOf(wallFullName); - if (wallNameIndex == -1) - { - // This modded wall is not yet registered. Register it. The list's previous length is its index. - wallNameIndex = schematic.modWallNames.Count; - schematic.modWallNames.Add(wallFullName); - } + // Special case: this meta tile demands that the original wall in the destination be preserved. + // The meta index of this special mod wall name is always zero. + if (PreserveWallID > 0 && smt.wall == PreserveWallID) + { + smt.wall = WallID.Count; + smt.keepWall = true; + } + else if (smt.wall >= WallID.Count) + { + ModWall mw = ModContent.GetModWall(smt.wall); + if (mw != null) + { + // This tile has a valid modded wall. Check if that ModWall is already registered to find its index. + string wallFullName = mw.GetFullName(); + int wallNameIndex = schematic.modWallNames.IndexOf(wallFullName); + if (wallNameIndex == -1) + { + // This modded wall is not yet registered. Register it. The list's previous length is its index. + wallNameIndex = schematic.modWallNames.Count; + schematic.modWallNames.Add(wallFullName); + } - // Adjust the meta tile's wall so that it points to the mod wall name array. - // wallOriginal is unaffected so that future searches will still function. - smt.wall = (ushort)(WallID.Count + wallNameIndex); - } - } - } - - private static SchematicData ConstructSchematicData(Tile[,] tiles) - { - int width = tiles.GetLength(0); - int height = tiles.GetLength(1); - SchematicData schematic = new SchematicData(tiles.GetLength(0), tiles.GetLength(1)); + // Adjust the meta tile's wall so that it points to the mod wall name array. + // wallOriginal is unaffected so that future searches will still function. + smt.wall = (ushort)(WallID.Count + wallNameIndex); + } + } + } + + private static SchematicData ConstructSchematicData(Tile[,] tiles) + { + int width = tiles.GetLength(0); + int height = tiles.GetLength(1); + SchematicData schematic = new SchematicData(tiles.GetLength(0), tiles.GetLength(1)); - // Add the fixed mod tile and mod wall for index zero. These special tiles preserve the existing tile or wall at that location. - schematic.modTileNames.Add(PreserveTileName); - schematic.modWallNames.Add(PreserveTileName); + // Add the fixed mod tile and mod wall for index zero. These special tiles preserve the existing tile or wall at that location. + schematic.modTileNames.Add(PreserveTileName); + schematic.modWallNames.Add(PreserveTileName); - for (int y = 0; y < height; ++y) - for (int x = 0; x < width; ++x) - { - Tile t = tiles[x, y]; - int metaTileIndex = GetMetaTileIndex(schematic.uniqueTiles, t); + for (int y = 0; y < height; ++y) + for (int x = 0; x < width; ++x) + { + Tile t = tiles[x, y]; + int metaTileIndex = GetMetaTileIndex(schematic.uniqueTiles, t); - // If this is a new tile not already registered, it must be added to uniqueTiles. - if (metaTileIndex == -1) - { - metaTileIndex = schematic.uniqueTiles.Count; - SchematicMetaTile smt = new SchematicMetaTile(t); + // If this is a new tile not already registered, it must be added to uniqueTiles. + if (metaTileIndex == -1) + { + metaTileIndex = schematic.uniqueTiles.Count; + SchematicMetaTile smt = new SchematicMetaTile(t); - // If either the tile or the wall are modded, we may need to register that data. - // We will surely need to modify the meta tile's type and wall fields if it contains modded data. - // This function also handles the special case of preservation tiles/walls. - ComputeMetaIndices(ref schematic, ref smt); + // If either the tile or the wall are modded, we may need to register that data. + // We will surely need to modify the meta tile's type and wall fields if it contains modded data. + // This function also handles the special case of preservation tiles/walls. + ComputeMetaIndices(ref schematic, ref smt); - // With potentially modded data processed, add the meta tile to the list of registered meta tiles. - schematic.uniqueTiles.Add(smt); - } + // With potentially modded data processed, add the meta tile to the list of registered meta tiles. + schematic.uniqueTiles.Add(smt); + } - // There is no reason to continue processing a schematic if it is too complicated. - if (metaTileIndex >= SchematicData.MaxUniqueTileCount) - goto PostAreaIteration; + // There is no reason to continue processing a schematic if it is too complicated. + if (metaTileIndex >= SchematicData.MaxUniqueTileCount) + goto PostAreaIteration; - // Update the area indices so that the tile at this position is the correct reference. - schematic.areaIndices[x, y] = (ushort)metaTileIndex; - } + // Update the area indices so that the tile at this position is the correct reference. + schematic.areaIndices[x, y] = (ushort)metaTileIndex; + } - PostAreaIteration: + PostAreaIteration: - // If there are too many unique tiles, set the size to zero. This will cause the schematic to fail to export. - // Even in a schematic of nothing but air, there is one unique tile: air. - if (schematic.uniqueTiles.Count > SchematicData.MaxUniqueTileCount) - schematic.uniqueTiles.Clear(); + // If there are too many unique tiles, set the size to zero. This will cause the schematic to fail to export. + // Even in a schematic of nothing but air, there is one unique tile: air. + if (schematic.uniqueTiles.Count > SchematicData.MaxUniqueTileCount) + schematic.uniqueTiles.Clear(); - return schematic; - } + return schematic; + } - private static void WriteSchematicMetaTile(this BinaryWriter writer, SchematicMetaTile smt) - { - writer.Write(smt.bTileHeader); - writer.Write(smt.bTileHeader2); - writer.Write(smt.bTileHeader3); - writer.Write(smt.sTileHeader); - writer.Write(smt.type); - writer.Write(smt.wall); - writer.Write(smt.frameX); - writer.Write(smt.frameY); - writer.Write(smt.liquid); - } - #endregion + private static void WriteSchematicMetaTile(this BinaryWriter writer, SchematicMetaTile smt) + { + writer.Write(smt.bTileHeader); + writer.Write(smt.bTileHeader2); + writer.Write(smt.bTileHeader3); + writer.Write(smt.sTileHeader); + writer.Write(smt.type); + writer.Write(smt.wall); + writer.Write(smt.frameX); + writer.Write(smt.frameY); + writer.Write(smt.liquid); + } + #endregion - #region Export - public static ExportResult ExportSchematic(Rectangle area) - { - if (area.Top < 0 || area.Left < 0 || area.Right >= Main.maxTilesX || area.Bottom >= Main.maxTilesY) - return ExportResult.CornerOutOfWorld; - // IsEmpty does NOT return false for all rectangles with zero area. - if (area.Width <= 0 || area.Height <= 0) - return ExportResult.ZeroArea; - - Tile[,] tiles = GetTilesInRectangle(area); + #region Export + public static ExportResult ExportSchematic(Rectangle area) + { + if (area.Top < 0 || area.Left < 0 || area.Right >= Main.maxTilesX || area.Bottom >= Main.maxTilesY) + return ExportResult.CornerOutOfWorld; + // IsEmpty does NOT return false for all rectangles with zero area. + if (area.Width <= 0 || area.Height <= 0) + return ExportResult.ZeroArea; + + Tile[,] tiles = GetTilesInRectangle(area); - byte[] renderedStream; - using (MemoryStream stream = new MemoryStream(SchematicBufferStartingSize)) - using (BinaryWriter writer = new BinaryWriter(stream, Encoding.UTF8)) - { - // 1: 4-byte magic number header - // This is only included here if compression is turned off - if (!UseCompression) - { - writer.Write(SchematicMagicNumberHeader); - writer.Write(UncompressedMagicNumber); - } + byte[] renderedStream; + using (MemoryStream stream = new MemoryStream(SchematicBufferStartingSize)) + using (BinaryWriter writer = new BinaryWriter(stream, Encoding.UTF8)) + { + // 1: 4-byte magic number header + // This is only included here if compression is turned off + if (!UseCompression) + { + writer.Write(SchematicMagicNumberHeader); + writer.Write(UncompressedMagicNumber); + } - // Calculate the schematic's data. Fail immediately if the schematic has too many unique tiles. - SchematicData schematic = ConstructSchematicData(tiles); - if (schematic.uniqueTiles.Count <= 0) - { - writer.Close(); - return ExportResult.TooManyUniqueTiles; - } + // Calculate the schematic's data. Fail immediately if the schematic has too many unique tiles. + SchematicData schematic = ConstructSchematicData(tiles); + if (schematic.uniqueTiles.Count <= 0) + { + writer.Close(); + return ExportResult.TooManyUniqueTiles; + } - // 2: Length of list 3. - ushort numModTileNames = (ushort)schematic.modTileNames.Count; - writer.Write(numModTileNames); + // 2: Length of list 3. + ushort numModTileNames = (ushort)schematic.modTileNames.Count; + writer.Write(numModTileNames); - // 3: List of fully qualified modded tile names. - for (ushort i = 0; i < numModTileNames; ++i) - writer.Write(schematic.modTileNames[i]); + // 3: List of fully qualified modded tile names. + for (ushort i = 0; i < numModTileNames; ++i) + writer.Write(schematic.modTileNames[i]); - // 4: Length of list 5. - ushort numModWallNames = (ushort)schematic.modWallNames.Count; - writer.Write(numModWallNames); + // 4: Length of list 5. + ushort numModWallNames = (ushort)schematic.modWallNames.Count; + writer.Write(numModWallNames); - // 5: List of fully qualified modded wall names. - for (ushort i = 0; i < numModWallNames; ++i) - writer.Write(schematic.modWallNames[i]); + // 5: List of fully qualified modded wall names. + for (ushort i = 0; i < numModWallNames; ++i) + writer.Write(schematic.modWallNames[i]); - // 6: Length of list 7. - ushort numUniqueTiles = (ushort)schematic.uniqueTiles.Count; - writer.Write(numUniqueTiles); + // 6: Length of list 7. + ushort numUniqueTiles = (ushort)schematic.uniqueTiles.Count; + writer.Write(numUniqueTiles); - // 7: List of definitions of unique tiles. For modded tiles, their types are lookup indices to the mod tile and mod wall name arrays. - // Specific tiles and walls from the CalamitySchematicExporter mod have hardcoded behavior at this step. - // They will be replaced with preserve flags by overriding the tile and wall meta indices. - for (ushort i = 0; i < numUniqueTiles; ++i) - writer.WriteSchematicMetaTile(schematic.uniqueTiles[i]); + // 7: List of definitions of unique tiles. For modded tiles, their types are lookup indices to the mod tile and mod wall name arrays. + // Specific tiles and walls from the CalamitySchematicExporter mod have hardcoded behavior at this step. + // They will be replaced with preserve flags by overriding the tile and wall meta indices. + for (ushort i = 0; i < numUniqueTiles; ++i) + writer.WriteSchematicMetaTile(schematic.uniqueTiles[i]); - // 8: Width and height of array 9. - ushort tileWidth = (ushort)schematic.areaIndices.GetLength(0); - writer.Write(tileWidth); - ushort tileHeight = (ushort)schematic.areaIndices.GetLength(1); - writer.Write(tileHeight); + // 8: Width and height of array 9. + ushort tileWidth = (ushort)schematic.areaIndices.GetLength(0); + writer.Write(tileWidth); + ushort tileHeight = (ushort)schematic.areaIndices.GetLength(1); + writer.Write(tileHeight); - // 9: Array of indices to unique tile definitions. - for (ushort y = 0; y < tileHeight; ++y) - for (ushort x = 0; x < tileWidth; ++x) - writer.Write(schematic.areaIndices[x, y]); + // 9: Array of indices to unique tile definitions. + for (ushort y = 0; y < tileHeight; ++y) + for (ushort x = 0; x < tileWidth; ++x) + writer.Write(schematic.areaIndices[x, y]); - // Compile all serialized data into a byte array for writing. - renderedStream = stream.ToArray(); - } + // Compile all serialized data into a byte array for writing. + renderedStream = stream.ToArray(); + } - // If compression is enabled, replace the current rendered stream with a re-written compressed one. - if (UseCompression) - { - using (MemoryStream gzMem = new MemoryStream(renderedStream.Length)) - { - // Write the magic number outside the compressed region of data if compression is enabled. - // This is the only way for a reading algorithm to know this is a compressed schematic. - gzMem.Write(SchematicMagicNumberHeader, 0, SchematicMagicNumberHeader.Length); - gzMem.WriteByte(CompressedMagicNumber); + // If compression is enabled, replace the current rendered stream with a re-written compressed one. + if (UseCompression) + { + using (MemoryStream gzMem = new MemoryStream(renderedStream.Length)) + { + // Write the magic number outside the compressed region of data if compression is enabled. + // This is the only way for a reading algorithm to know this is a compressed schematic. + gzMem.Write(SchematicMagicNumberHeader, 0, SchematicMagicNumberHeader.Length); + gzMem.WriteByte(CompressedMagicNumber); - using (GZipStream gz = new GZipStream(gzMem, CompressionLevel.Optimal)) - { - gz.Write(renderedStream, 0, renderedStream.Length); - } - renderedStream = gzMem.ToArray(); - } - } + using (GZipStream gz = new GZipStream(gzMem, CompressionLevel.Optimal)) + { + gz.Write(renderedStream, 0, renderedStream.Length); + } + renderedStream = gzMem.ToArray(); + } + } - // To prevent overwrites, every schematic has an incredibly precise timestamp in its filename. - long fileTimestamp = System.DateTime.Now.ToFileTime(); - string filename = $"schematic_{fileTimestamp}.csch"; - string fullPath = Path.Combine(Main.SavePath, filename); - File.WriteAllBytes(fullPath, renderedStream); - return ExportResult.Success; - } - #endregion + // To prevent overwrites, every schematic has an incredibly precise timestamp in its filename. + long fileTimestamp = System.DateTime.Now.ToFileTime(); + string filename = $"schematic_{fileTimestamp}.csch"; + string fullPath = Path.Combine(Main.SavePath, filename); + File.WriteAllBytes(fullPath, renderedStream); + return ExportResult.Success; + } + #endregion - #region Import Helper Methods - private static SchematicMetaTile ReadSchematicMetaTile(this BinaryReader reader) - { - SchematicMetaTile smt = new SchematicMetaTile(); - smt.bTileHeader = reader.ReadByte(); - smt.bTileHeader2 = reader.ReadByte(); - smt.bTileHeader3 = reader.ReadByte(); - smt.sTileHeader = reader.ReadUInt16(); - smt.type = reader.ReadUInt16(); - smt.wall = reader.ReadUInt16(); - smt.frameX = reader.ReadInt16(); - smt.frameY = reader.ReadInt16(); - smt.liquid = reader.ReadByte(); - return smt; - } + #region Import Helper Methods + private static SchematicMetaTile ReadSchematicMetaTile(this BinaryReader reader) + { + SchematicMetaTile smt = new SchematicMetaTile(); + smt.bTileHeader = reader.ReadByte(); + smt.bTileHeader2 = reader.ReadByte(); + smt.bTileHeader3 = reader.ReadByte(); + smt.sTileHeader = reader.ReadUInt16(); + smt.type = reader.ReadUInt16(); + smt.wall = reader.ReadUInt16(); + smt.frameX = reader.ReadInt16(); + smt.frameY = reader.ReadInt16(); + smt.liquid = reader.ReadByte(); + return smt; + } - private static void ReplaceMetaIndicesWithLoadedIDs(ref SchematicMetaTile smt, string[] modTileNames, string[] modWallNames) - { - // If this schematic tile has a modded foreground tile, replace the meta index offset with that modded tile's ID. - if (smt.type >= TileID.Count) - { - // The first entry in modTileNames is always the special preserver name. If you hit this name, just set the keepTile flag. - string tileFullName = modTileNames[smt.type - TileID.Count]; - if (tileFullName == PreserveTileName) - smt.keepTile = true; - else - { - ModContent.SplitName(tileFullName, out string mod, out string tileName); - Mod theMod = ModLoader.GetMod(mod); - // If that mod isn't loaded, spawn in a MysteryTile instead. - smt.type = (ushort)(theMod is null ? ModContent.TileType() : theMod.TileType(tileName)); - } - } - // If this schematic tile has a modded wall, replace the meta index offset with that modded wall's ID. - if (smt.wall >= WallID.Count) - { - // The first entry in modWallNames is always the special preserver name. If you hit this name, just set the keepWall flag. - string wallFullName = modWallNames[smt.wall - WallID.Count]; - if (wallFullName == PreserveTileName) - smt.keepWall = true; - else - { - ModContent.SplitName(wallFullName, out string mod, out string wallName); - Mod theMod = ModLoader.GetMod(mod); - // tModLoader does not have a MysteryWall, so if that mod isn't loaded, this wall will disappear. - smt.wall = (ushort)(theMod is null ? 0 : theMod.WallType(wallName)); - } - } - } - #endregion + private static void ReplaceMetaIndicesWithLoadedIDs(ref SchematicMetaTile smt, string[] modTileNames, string[] modWallNames) + { + // If this schematic tile has a modded foreground tile, replace the meta index offset with that modded tile's ID. + if (smt.type >= TileID.Count) + { + // The first entry in modTileNames is always the special preserver name. If you hit this name, just set the keepTile flag. + string tileFullName = modTileNames[smt.type - TileID.Count]; + if (tileFullName == PreserveTileName) + smt.keepTile = true; + else + { + ModContent.SplitName(tileFullName, out string mod, out string tileName); + Mod theMod = ModLoader.GetMod(mod); + // If that mod isn't loaded, spawn in a MysteryTile instead. + smt.type = (ushort)(theMod is null ? ModContent.TileType() : theMod.TileType(tileName)); + } + } + // If this schematic tile has a modded wall, replace the meta index offset with that modded wall's ID. + if (smt.wall >= WallID.Count) + { + // The first entry in modWallNames is always the special preserver name. If you hit this name, just set the keepWall flag. + string wallFullName = modWallNames[smt.wall - WallID.Count]; + if (wallFullName == PreserveTileName) + smt.keepWall = true; + else + { + ModContent.SplitName(wallFullName, out string mod, out string wallName); + Mod theMod = ModLoader.GetMod(mod); + // tModLoader does not have a MysteryWall, so if that mod isn't loaded, this wall will disappear. + smt.wall = (ushort)(theMod is null ? 0 : theMod.WallType(wallName)); + } + } + } + #endregion - #region Import - public static SchematicMetaTile[,] LoadSchematic(string filename) - { - SchematicMetaTile[,] ret = null; - using (Stream st = CalamityMod.Instance.GetFileStream(filename, true)) - { - ret = ImportSchematic(st); - } - return ret; - } + #region Import + public static SchematicMetaTile[,] LoadSchematic(string filename) + { + SchematicMetaTile[,] ret = null; + using (Stream st = CalamityMod.Instance.GetFileStream(filename, true)) + { + ret = ImportSchematic(st); + } + return ret; + } - private const string InvalidFormatString = "Provided file is not a valid Calamity Schematic."; - private static SchematicMetaTile[,] ImportSchematic(Stream fileInputStream) - { - // 1: Header. First three bytes are a magic number. Fourth byte determines compression. - byte[] header = fileInputStream.ReadBytes(4); + private const string InvalidFormatString = "Provided file is not a valid Calamity Schematic."; + private static SchematicMetaTile[,] ImportSchematic(Stream fileInputStream) + { + // 1: Header. First three bytes are a magic number. Fourth byte determines compression. + byte[] header = fileInputStream.ReadBytes(4); - for (int i = 0; i < SchematicMagicNumberHeader.Length; ++i) - if (header[i] != SchematicMagicNumberHeader[i]) - throw new InvalidDataException($"{InvalidFormatString} The magic number signature is invalid."); + for (int i = 0; i < SchematicMagicNumberHeader.Length; ++i) + if (header[i] != SchematicMagicNumberHeader[i]) + throw new InvalidDataException($"{InvalidFormatString} The magic number signature is invalid."); - bool compression = false; - if (header[3] == CompressedMagicNumber) - compression = true; - else if (header[3] != UncompressedMagicNumber) - throw new InvalidDataException($"{InvalidFormatString} The file is not properly marked as compressed or uncompressed."); + bool compression = false; + if (header[3] == CompressedMagicNumber) + compression = true; + else if (header[3] != UncompressedMagicNumber) + throw new InvalidDataException($"{InvalidFormatString} The file is not properly marked as compressed or uncompressed."); - SchematicMetaTile[,] ret; - byte[] buffer; - using (MemoryStream stream = new MemoryStream(SchematicBufferStartingSize)) - { - if (compression) - using (GZipStream gz = new GZipStream(fileInputStream, CompressionMode.Decompress)) - gz.CopyTo(stream); - else - fileInputStream.CopyTo(stream); - buffer = stream.ToArray(); - } + SchematicMetaTile[,] ret; + byte[] buffer; + using (MemoryStream stream = new MemoryStream(SchematicBufferStartingSize)) + { + if (compression) + using (GZipStream gz = new GZipStream(fileInputStream, CompressionMode.Decompress)) + gz.CopyTo(stream); + else + fileInputStream.CopyTo(stream); + buffer = stream.ToArray(); + } - using (MemoryStream bufferStream = new MemoryStream(buffer, false)) - using (BinaryReader reader = new BinaryReader(bufferStream, Encoding.UTF8)) - { - // 2: Length of list 3. - ushort numModTileNames = reader.ReadUInt16(); + using (MemoryStream bufferStream = new MemoryStream(buffer, false)) + using (BinaryReader reader = new BinaryReader(bufferStream, Encoding.UTF8)) + { + // 2: Length of list 3. + ushort numModTileNames = reader.ReadUInt16(); - // 3: List of fully qualified modded tile names. - string[] modTileNames = new string[numModTileNames]; - for (int i = 0; i < numModTileNames; ++i) - modTileNames[i] = reader.ReadString(); + // 3: List of fully qualified modded tile names. + string[] modTileNames = new string[numModTileNames]; + for (int i = 0; i < numModTileNames; ++i) + modTileNames[i] = reader.ReadString(); - // 4: Length of list 5. - ushort numModWallNames = reader.ReadUInt16(); - string[] modWallNames = new string[numModWallNames]; + // 4: Length of list 5. + ushort numModWallNames = reader.ReadUInt16(); + string[] modWallNames = new string[numModWallNames]; - // 5: List of fully qualified modded wall names. - for (int i = 0; i < numModWallNames; ++i) - modWallNames[i] = reader.ReadString(); + // 5: List of fully qualified modded wall names. + for (int i = 0; i < numModWallNames; ++i) + modWallNames[i] = reader.ReadString(); - // 6: Length of list 7. - ushort numUniqueTiles = reader.ReadUInt16(); - SchematicMetaTile[] uniqueTiles = new SchematicMetaTile[numUniqueTiles]; + // 6: Length of list 7. + ushort numUniqueTiles = reader.ReadUInt16(); + SchematicMetaTile[] uniqueTiles = new SchematicMetaTile[numUniqueTiles]; - // 7: List of definitions of unique tiles. For modded tiles, their types are lookup indices to the mod tile and mod wall name arrays. - for (ushort i = 0; i < numUniqueTiles; ++i) - { - SchematicMetaTile smt = reader.ReadSchematicMetaTile(); - ReplaceMetaIndicesWithLoadedIDs(ref smt, modTileNames, modWallNames); - uniqueTiles[i] = smt; - } + // 7: List of definitions of unique tiles. For modded tiles, their types are lookup indices to the mod tile and mod wall name arrays. + for (ushort i = 0; i < numUniqueTiles; ++i) + { + SchematicMetaTile smt = reader.ReadSchematicMetaTile(); + ReplaceMetaIndicesWithLoadedIDs(ref smt, modTileNames, modWallNames); + uniqueTiles[i] = smt; + } - // 8: Width and height of array 9. - ushort tileWidth = reader.ReadUInt16(); - ushort tileHeight = reader.ReadUInt16(); - ret = new SchematicMetaTile[tileWidth, tileHeight]; + // 8: Width and height of array 9. + ushort tileWidth = reader.ReadUInt16(); + ushort tileHeight = reader.ReadUInt16(); + ret = new SchematicMetaTile[tileWidth, tileHeight]; - // 9: Array of indices to unique tile definitions. We immediately convert these to tiles. - for (ushort y = 0; y < tileHeight; ++y) - for (ushort x = 0; x < tileWidth; ++x) - { - ushort tileIndex = reader.ReadUInt16(); - ret[x, y] = uniqueTiles[tileIndex]; - } - } - return ret; - } - #endregion - } + // 9: Array of indices to unique tile definitions. We immediately convert these to tiles. + for (ushort y = 0; y < tileHeight; ++y) + for (ushort x = 0; x < tileWidth; ++x) + { + ushort tileIndex = reader.ReadUInt16(); + ret[x, y] = uniqueTiles[tileIndex]; + } + } + return ret; + } + #endregion + } } diff --git a/Schematics/SchematicManager.cs b/Schematics/SchematicManager.cs index 031a94261e..ea5b24af09 100644 --- a/Schematics/SchematicManager.cs +++ b/Schematics/SchematicManager.cs @@ -10,224 +10,224 @@ using Terraria.ModLoader; namespace CalamityMod.Schematics { - public static class SchematicManager - { - internal static Dictionary TileMaps; - internal static Dictionary PilePlacementMaps; - public delegate void PilePlacementFunction(int x, int y, Rectangle placeInArea); + public static class SchematicManager + { + internal static Dictionary TileMaps; + internal static Dictionary PilePlacementMaps; + public delegate void PilePlacementFunction(int x, int y, Rectangle placeInArea); - #region Load/Unload - internal static void Load() - { - PilePlacementMaps = new Dictionary(); - TileMaps = new Dictionary - { - // Draedon's Arsenal world gen structures - ["Workshop"] = CalamitySchematicIO.LoadSchematic("Schematics/Workshop.csch"), - ["Research Facility"] = CalamitySchematicIO.LoadSchematic("Schematics/ResearchFacility.csch"), - ["Hell Laboratory"] = CalamitySchematicIO.LoadSchematic("Schematics/HellLaboratory.csch"), - ["Sunken Sea Laboratory"] = CalamitySchematicIO.LoadSchematic("Schematics/SunkenSeaLaboratory.csch"), - ["Ice Laboratory"] = CalamitySchematicIO.LoadSchematic("Schematics/IceLaboratory.csch"), - ["Plague Laboratory"] = CalamitySchematicIO.LoadSchematic("Schematics/PlagueLaboratory.csch"), - ["Planetoid Laboratory"] = CalamitySchematicIO.LoadSchematic("Schematics/PlanetoidLaboratory.csch"), + #region Load/Unload + internal static void Load() + { + PilePlacementMaps = new Dictionary(); + TileMaps = new Dictionary + { + // Draedon's Arsenal world gen structures + ["Workshop"] = CalamitySchematicIO.LoadSchematic("Schematics/Workshop.csch"), + ["Research Facility"] = CalamitySchematicIO.LoadSchematic("Schematics/ResearchFacility.csch"), + ["Hell Laboratory"] = CalamitySchematicIO.LoadSchematic("Schematics/HellLaboratory.csch"), + ["Sunken Sea Laboratory"] = CalamitySchematicIO.LoadSchematic("Schematics/SunkenSeaLaboratory.csch"), + ["Ice Laboratory"] = CalamitySchematicIO.LoadSchematic("Schematics/IceLaboratory.csch"), + ["Plague Laboratory"] = CalamitySchematicIO.LoadSchematic("Schematics/PlagueLaboratory.csch"), + ["Planetoid Laboratory"] = CalamitySchematicIO.LoadSchematic("Schematics/PlanetoidLaboratory.csch"), - // Astral world gen structures - ["Astral Beacon"] = CalamitySchematicIO.LoadSchematic("Schematics/AstralBeacon.csch"), + // Astral world gen structures + ["Astral Beacon"] = CalamitySchematicIO.LoadSchematic("Schematics/AstralBeacon.csch"), - // Sulphurous Sea scrap world gen structures - ["Sulphurous Scrap 1"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile1.csch").ShaveOffEdge(), - ["Sulphurous Scrap 2"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile2.csch").ShaveOffEdge(), - ["Sulphurous Scrap 3"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile3.csch").ShaveOffEdge(), - ["Sulphurous Scrap 4"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile4.csch").ShaveOffEdge(), - ["Large Sulphurous Scrap 1"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile1.csch").ShaveOffEdge(), - ["Large Sulphurous Scrap 2"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile2.csch").ShaveOffEdge(), - ["Large Sulphurous Scrap 3"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile3.csch").ShaveOffEdge(), - ["Large Sulphurous Scrap 4"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile4.csch").ShaveOffEdge(), - }; - } - internal static void Unload() - { - TileMaps = null; - PilePlacementMaps = null; - } - #endregion - - #region Get Schematic Area - public static Vector2? GetSchematicArea(string name) - { - // If no schematic exists with this name, simply return null. - if (!TileMaps.TryGetValue(name, out SchematicMetaTile[,] schematic)) - return null; + // Sulphurous Sea scrap world gen structures + ["Sulphurous Scrap 1"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile1.csch").ShaveOffEdge(), + ["Sulphurous Scrap 2"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile2.csch").ShaveOffEdge(), + ["Sulphurous Scrap 3"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile3.csch").ShaveOffEdge(), + ["Sulphurous Scrap 4"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile4.csch").ShaveOffEdge(), + ["Large Sulphurous Scrap 1"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile1.csch").ShaveOffEdge(), + ["Large Sulphurous Scrap 2"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile2.csch").ShaveOffEdge(), + ["Large Sulphurous Scrap 3"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile3.csch").ShaveOffEdge(), + ["Large Sulphurous Scrap 4"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile4.csch").ShaveOffEdge(), + }; + } + internal static void Unload() + { + TileMaps = null; + PilePlacementMaps = null; + } + #endregion + + #region Get Schematic Area + public static Vector2? GetSchematicArea(string name) + { + // If no schematic exists with this name, simply return null. + if (!TileMaps.TryGetValue(name, out SchematicMetaTile[,] schematic)) + return null; - return new Vector2(schematic.GetLength(0), schematic.GetLength(1)); - } - #endregion Get Schematic Area - - #region Place Schematic - public static void PlaceSchematic(string name, Point pos, SchematicAnchor anchorType, ref bool specialCondition, T chestDelegate = null) where T : Delegate - { - // If no schematic exists with this name, cancel with a helpful log message. - if (!TileMaps.ContainsKey(name)) - { - CalamityMod.Instance.Logger.Warn($"Tried to place a schematic with name \"{name}\". No matching schematic file found."); - return; - } + return new Vector2(schematic.GetLength(0), schematic.GetLength(1)); + } + #endregion Get Schematic Area + + #region Place Schematic + public static void PlaceSchematic(string name, Point pos, SchematicAnchor anchorType, ref bool specialCondition, T chestDelegate = null) where T : Delegate + { + // If no schematic exists with this name, cancel with a helpful log message. + if (!TileMaps.ContainsKey(name)) + { + CalamityMod.Instance.Logger.Warn($"Tried to place a schematic with name \"{name}\". No matching schematic file found."); + return; + } - // Invalid chest interaction delegates need to throw an error. - if (chestDelegate != null && - !(chestDelegate is Action) && - !(chestDelegate is Action)) - { - throw new ArgumentException("The chest interaction function has invalid parameters.", nameof(chestDelegate)); - } - PilePlacementMaps.TryGetValue(name, out PilePlacementFunction pilePlacementFunction); + // Invalid chest interaction delegates need to throw an error. + if (chestDelegate != null && + !(chestDelegate is Action) && + !(chestDelegate is Action)) + { + throw new ArgumentException("The chest interaction function has invalid parameters.", nameof(chestDelegate)); + } + PilePlacementMaps.TryGetValue(name, out PilePlacementFunction pilePlacementFunction); - // Grab the schematic itself from the dictionary of loaded schematics. - SchematicMetaTile[,] schematic = TileMaps[name]; - int width = schematic.GetLength(0); - int height = schematic.GetLength(1); + // Grab the schematic itself from the dictionary of loaded schematics. + SchematicMetaTile[,] schematic = TileMaps[name]; + int width = schematic.GetLength(0); + int height = schematic.GetLength(1); - // Calculate the appropriate location to start laying down schematic tiles. - int cornerX = pos.X; - int cornerY = pos.Y; - switch (anchorType) - { - case SchematicAnchor.TopLeft: // Provided point is top-left corner = No change - case SchematicAnchor.Default: // This is also default behavior - default: - break; - case SchematicAnchor.TopCenter: // Provided point is top center = Top-left corner is 1/2 width to the left - cornerX -= width / 2; - break; - case SchematicAnchor.TopRight: // Provided point is top-right corner = Top-left corner is 1 width to the left - cornerX -= width; - break; - case SchematicAnchor.CenterLeft: // Provided point is left center: Top-left corner is 1/2 height above - cornerY -= height / 2; - break; - case SchematicAnchor.Center: // Provided point is center = Top-left corner is 1/2 width and 1/2 height up-left - cornerX -= width / 2; - cornerY -= height / 2; - break; - case SchematicAnchor.CenterRight: // Provided point is right center: Top-left corner is 1 width and 1/2 height up-left - cornerX -= width; - cornerY -= height / 2; - break; - case SchematicAnchor.BottomLeft: // Provided point is bottom-left corner = Top-left corner is 1 height above - cornerY -= height; - break; - case SchematicAnchor.BottomCenter: // Provided point is bottom center: Top-left corner is 1/2 width and 1 height up-left - cornerX -= width / 2; - cornerY -= height; - break; - case SchematicAnchor.BottomRight: // Provided point is bottom-right corner = Top-left corner is 1 width to the left and 1 height above - cornerX -= width; - cornerY -= height; - break; - } + // Calculate the appropriate location to start laying down schematic tiles. + int cornerX = pos.X; + int cornerY = pos.Y; + switch (anchorType) + { + case SchematicAnchor.TopLeft: // Provided point is top-left corner = No change + case SchematicAnchor.Default: // This is also default behavior + default: + break; + case SchematicAnchor.TopCenter: // Provided point is top center = Top-left corner is 1/2 width to the left + cornerX -= width / 2; + break; + case SchematicAnchor.TopRight: // Provided point is top-right corner = Top-left corner is 1 width to the left + cornerX -= width; + break; + case SchematicAnchor.CenterLeft: // Provided point is left center: Top-left corner is 1/2 height above + cornerY -= height / 2; + break; + case SchematicAnchor.Center: // Provided point is center = Top-left corner is 1/2 width and 1/2 height up-left + cornerX -= width / 2; + cornerY -= height / 2; + break; + case SchematicAnchor.CenterRight: // Provided point is right center: Top-left corner is 1 width and 1/2 height up-left + cornerX -= width; + cornerY -= height / 2; + break; + case SchematicAnchor.BottomLeft: // Provided point is bottom-left corner = Top-left corner is 1 height above + cornerY -= height; + break; + case SchematicAnchor.BottomCenter: // Provided point is bottom center: Top-left corner is 1/2 width and 1 height up-left + cornerX -= width / 2; + cornerY -= height; + break; + case SchematicAnchor.BottomRight: // Provided point is bottom-right corner = Top-left corner is 1 width to the left and 1 height above + cornerX -= width; + cornerY -= height; + break; + } - // Make sure that all four corners of the target area are actually in the world. - if (!WorldGen.InWorld(cornerX, cornerY) || !WorldGen.InWorld(cornerX + width, cornerY + height)) - { - CalamityMod.Instance.Logger.Warn("Schematic failed to place: Part of the target location is outside the game world."); - return; - } + // Make sure that all four corners of the target area are actually in the world. + if (!WorldGen.InWorld(cornerX, cornerY) || !WorldGen.InWorld(cornerX + width, cornerY + height)) + { + CalamityMod.Instance.Logger.Warn("Schematic failed to place: Part of the target location is outside the game world."); + return; + } - // Make an array for the tiles that used to be where this schematic will be pasted. - Tile[,] originalTiles = new Tile[width, height]; + // Make an array for the tiles that used to be where this schematic will be pasted. + Tile[,] originalTiles = new Tile[width, height]; - // Schematic area pre-processing has three steps. - // Step 1: Kill all trees and cacti specifically. This prevents ugly tree/cactus pieces from being restored later. - // Step 2: Fill the original tiles array with everything that was originally in the target rectangle. - // Step 3: Destroy everything in the target rectangle (except chests -- that'll cause infinite recursion). - // The third step is necessary so that multi tiles on the edge of the region are properly destroyed (e.g. Life Crystals). + // Schematic area pre-processing has three steps. + // Step 1: Kill all trees and cacti specifically. This prevents ugly tree/cactus pieces from being restored later. + // Step 2: Fill the original tiles array with everything that was originally in the target rectangle. + // Step 3: Destroy everything in the target rectangle (except chests -- that'll cause infinite recursion). + // The third step is necessary so that multi tiles on the edge of the region are properly destroyed (e.g. Life Crystals). - for (int x = 0; x < width; ++x) - for (int y = 0; y < height; ++y) - { - Tile t = Main.tile[x + cornerX, y + cornerY]; - if (t.type == TileID.Trees || t.type == TileID.PineTree || t.type == TileID.Cactus) - WorldGen.KillTile(x + cornerX, y + cornerY); - } - for (int x = 0; x < width; ++x) - for (int y = 0; y < height; ++y) - originalTiles[x, y] = new Tile(Main.tile[x + cornerX, y + cornerY]); - for (int x = 0; x < width; ++x) - for (int y = 0; y < height; ++y) - if (originalTiles[x, y].type != TileID.Containers) - WorldGen.KillTile(x + cornerX, y + cornerY); - - // Lay down the schematic. If the schematic calls for it, bring back tiles that are stored in the old tiles array. - for (int x = 0; x < width; ++x) - for (int y = 0; y < height; ++y) - { - SchematicMetaTile smt = schematic[x, y]; - string modChestStr = TileLoader.GetTile(smt.type)?.chest ?? ""; - bool isChest = smt.type == TileID.Containers || modChestStr != ""; + for (int x = 0; x < width; ++x) + for (int y = 0; y < height; ++y) + { + Tile t = Main.tile[x + cornerX, y + cornerY]; + if (t.type == TileID.Trees || t.type == TileID.PineTree || t.type == TileID.Cactus) + WorldGen.KillTile(x + cornerX, y + cornerY); + } + for (int x = 0; x < width; ++x) + for (int y = 0; y < height; ++y) + originalTiles[x, y] = new Tile(Main.tile[x + cornerX, y + cornerY]); + for (int x = 0; x < width; ++x) + for (int y = 0; y < height; ++y) + if (originalTiles[x, y].type != TileID.Containers) + WorldGen.KillTile(x + cornerX, y + cornerY); + + // Lay down the schematic. If the schematic calls for it, bring back tiles that are stored in the old tiles array. + for (int x = 0; x < width; ++x) + for (int y = 0; y < height; ++y) + { + SchematicMetaTile smt = schematic[x, y]; + string modChestStr = TileLoader.GetTile(smt.type)?.chest ?? ""; + bool isChest = smt.type == TileID.Containers || modChestStr != ""; - // If the determined tile type is a chest and this is its top left corner, define it appropriately. - if (isChest && smt.frameX % 36 == 0 && smt.frameY == 0) - { - Chest chest = PlaceChest(x + cornerX, y + cornerY, smt.type); - // Use the appropriate chest delegate function to fill the chest. - if (chestDelegate is Action) - { - (chestDelegate as Action)?.Invoke(chest, smt.type, specialCondition); - specialCondition = true; - } - else if (chestDelegate is Action) - (chestDelegate as Action)?.Invoke(chest); - } + // If the determined tile type is a chest and this is its top left corner, define it appropriately. + if (isChest && smt.frameX % 36 == 0 && smt.frameY == 0) + { + Chest chest = PlaceChest(x + cornerX, y + cornerY, smt.type); + // Use the appropriate chest delegate function to fill the chest. + if (chestDelegate is Action) + { + (chestDelegate as Action)?.Invoke(chest, smt.type, specialCondition); + specialCondition = true; + } + else if (chestDelegate is Action) + (chestDelegate as Action)?.Invoke(chest); + } - // This is where the meta tile keep booleans are applied. - Tile t = Main.tile[x + cornerX, y + cornerY]; - smt.ApplyTo(ref t, originalTiles[x, y]); - TryToPlaceTileEntities(x + cornerX, y + cornerY, t); + // This is where the meta tile keep booleans are applied. + Tile t = Main.tile[x + cornerX, y + cornerY]; + smt.ApplyTo(ref t, originalTiles[x, y]); + TryToPlaceTileEntities(x + cornerX, y + cornerY, t); - // Activate the pile placement function if defined. - Rectangle placeInArea = new Rectangle(x, y, width, height); - pilePlacementFunction?.Invoke(x + cornerX, y + cornerY, placeInArea); - } - } - #endregion + // Activate the pile placement function if defined. + Rectangle placeInArea = new Rectangle(x, y, width, height); + pilePlacementFunction?.Invoke(x + cornerX, y + cornerY, placeInArea); + } + } + #endregion - #region Place Schematic Helper Methods - private static void TryToPlaceTileEntities(int x, int y, Tile t) - { - // A tile entity in an empty spot would make no sense. - if (!t.active()) - return; - // Ignore tiles that aren't at the top left of the tile. - // All of Calamity's worldgen-placed tile entities refuse to exist except at the top left corner of their host tile. - if (t.frameX != 0 || t.frameY != 0) - return; + #region Place Schematic Helper Methods + private static void TryToPlaceTileEntities(int x, int y, Tile t) + { + // A tile entity in an empty spot would make no sense. + if (!t.active()) + return; + // Ignore tiles that aren't at the top left of the tile. + // All of Calamity's worldgen-placed tile entities refuse to exist except at the top left corner of their host tile. + if (t.frameX != 0 || t.frameY != 0) + return; - // This cannot be a switch because switch cases must be compile time constants, which ModContent calls are not. - // Therefore the only option is an if-else ladder. - int tileType = t.type; - if (tileType == ModContent.TileType()) - TileEntity.PlaceEntityNet(x, y, ModContent.TileEntityType()); - else if (tileType == ModContent.TileType()) - TileEntity.PlaceEntityNet(x, y, ModContent.TileEntityType()); - else if (tileType == ModContent.TileType()) - TileEntity.PlaceEntityNet(x, y, ModContent.TileEntityType()); - } + // This cannot be a switch because switch cases must be compile time constants, which ModContent calls are not. + // Therefore the only option is an if-else ladder. + int tileType = t.type; + if (tileType == ModContent.TileType()) + TileEntity.PlaceEntityNet(x, y, ModContent.TileEntityType()); + else if (tileType == ModContent.TileType()) + TileEntity.PlaceEntityNet(x, y, ModContent.TileEntityType()); + else if (tileType == ModContent.TileType()) + TileEntity.PlaceEntityNet(x, y, ModContent.TileEntityType()); + } - private static Chest PlaceChest(int x, int y, int chestType) - { - int chestIndex = Chest.FindEmptyChest(x, y, chestType); - Main.chest[chestIndex] = new Chest() - { - x = x, - y = y - }; - Main.chest[chestIndex].item = new Item[Main.chest[chestIndex].item.Length]; - for (int i = 0; i < Main.chest[chestIndex].item.Length; i++) - { - Main.chest[chestIndex].item[i] = new Item(); - } - return Main.chest[chestIndex]; - } - #endregion - } + private static Chest PlaceChest(int x, int y, int chestType) + { + int chestIndex = Chest.FindEmptyChest(x, y, chestType); + Main.chest[chestIndex] = new Chest() + { + x = x, + y = y + }; + Main.chest[chestIndex].item = new Item[Main.chest[chestIndex].item.Length]; + for (int i = 0; i < Main.chest[chestIndex].item.Length; i++) + { + Main.chest[chestIndex].item[i] = new Item(); + } + return Main.chest[chestIndex]; + } + #endregion + } } diff --git a/Skies/AstralScreenShaderData.cs b/Skies/AstralScreenShaderData.cs index 68e5a7043a..e8527c6ecb 100644 --- a/Skies/AstralScreenShaderData.cs +++ b/Skies/AstralScreenShaderData.cs @@ -6,7 +6,7 @@ using Terraria.Graphics.Shaders; namespace CalamityMod.Skies { - public class AstralScreenShaderData : ScreenShaderData + public class AstralScreenShaderData : ScreenShaderData { public AstralScreenShaderData(Ref shader, string passName) : base(shader, passName) { } diff --git a/Sounds/Custom/AbilitySounds/AdrenalineActivate.cs b/Sounds/Custom/AbilitySounds/AdrenalineActivate.cs index 3036d021e8..f3c697656b 100644 --- a/Sounds/Custom/AbilitySounds/AdrenalineActivate.cs +++ b/Sounds/Custom/AbilitySounds/AdrenalineActivate.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom.AbilitySounds { - public class AdrenalineActivate : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class AdrenalineActivate : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/AbilitySounds/BrimflameAbility.cs b/Sounds/Custom/AbilitySounds/BrimflameAbility.cs index cfbef663c5..9b36b9e3b1 100644 --- a/Sounds/Custom/AbilitySounds/BrimflameAbility.cs +++ b/Sounds/Custom/AbilitySounds/BrimflameAbility.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom.AbilitySounds { - public class BrimflameAbility : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class BrimflameAbility : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/AbilitySounds/BrimflameRecharge.cs b/Sounds/Custom/AbilitySounds/BrimflameRecharge.cs index 39f805799a..e266c986ab 100644 --- a/Sounds/Custom/AbilitySounds/BrimflameRecharge.cs +++ b/Sounds/Custom/AbilitySounds/BrimflameRecharge.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom.AbilitySounds { - public class BrimflameRecharge : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class BrimflameRecharge : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/AbilitySounds/ChaosStateOver.cs b/Sounds/Custom/AbilitySounds/ChaosStateOver.cs index 41436a6f6e..b91d7e249a 100644 --- a/Sounds/Custom/AbilitySounds/ChaosStateOver.cs +++ b/Sounds/Custom/AbilitySounds/ChaosStateOver.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom.AbilitySounds { - public class ChaosStateOver : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class ChaosStateOver : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/AbilitySounds/DemonshadeEnrage.cs b/Sounds/Custom/AbilitySounds/DemonshadeEnrage.cs index 6b7dc3d5d0..81535a86c3 100644 --- a/Sounds/Custom/AbilitySounds/DemonshadeEnrage.cs +++ b/Sounds/Custom/AbilitySounds/DemonshadeEnrage.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom.AbilitySounds { - public class DemonshadeEnrage : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class DemonshadeEnrage : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/AbilitySounds/OmegaBlueAbility.cs b/Sounds/Custom/AbilitySounds/OmegaBlueAbility.cs index 77a13c5fa4..3209a926c6 100644 --- a/Sounds/Custom/AbilitySounds/OmegaBlueAbility.cs +++ b/Sounds/Custom/AbilitySounds/OmegaBlueAbility.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom.AbilitySounds { - public class OmegaBlueAbility : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class OmegaBlueAbility : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/AbilitySounds/OmegaBlueRecharge.cs b/Sounds/Custom/AbilitySounds/OmegaBlueRecharge.cs index e3c099f846..0d3f143a2e 100644 --- a/Sounds/Custom/AbilitySounds/OmegaBlueRecharge.cs +++ b/Sounds/Custom/AbilitySounds/OmegaBlueRecharge.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom.AbilitySounds { - public class OmegaBlueRecharge : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class OmegaBlueRecharge : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/AbilitySounds/PlagueReaperAbility.cs b/Sounds/Custom/AbilitySounds/PlagueReaperAbility.cs index 2be0a93a1c..93a32d4106 100644 --- a/Sounds/Custom/AbilitySounds/PlagueReaperAbility.cs +++ b/Sounds/Custom/AbilitySounds/PlagueReaperAbility.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom.AbilitySounds { - public class PlagueReaperAbility : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class PlagueReaperAbility : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/AbilitySounds/PlagueReaperRecharge.cs b/Sounds/Custom/AbilitySounds/PlagueReaperRecharge.cs index 9e2955e598..ddcb0befc2 100644 --- a/Sounds/Custom/AbilitySounds/PlagueReaperRecharge.cs +++ b/Sounds/Custom/AbilitySounds/PlagueReaperRecharge.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom.AbilitySounds { - public class PlagueReaperRecharge : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class PlagueReaperRecharge : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/AbilitySounds/PotionSicknessOver.cs b/Sounds/Custom/AbilitySounds/PotionSicknessOver.cs index a06c76405e..52acd02228 100644 --- a/Sounds/Custom/AbilitySounds/PotionSicknessOver.cs +++ b/Sounds/Custom/AbilitySounds/PotionSicknessOver.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom.AbilitySounds { - public class PotionSicknessOver : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class PotionSicknessOver : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/AbilitySounds/RageActivate.cs b/Sounds/Custom/AbilitySounds/RageActivate.cs index 58d4c84154..36cef88b55 100644 --- a/Sounds/Custom/AbilitySounds/RageActivate.cs +++ b/Sounds/Custom/AbilitySounds/RageActivate.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom.AbilitySounds { - public class RageActivate : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class RageActivate : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/BossRushEnd.cs b/Sounds/Custom/BossRushEnd.cs index 2a376e552c..f70c0a29d1 100644 --- a/Sounds/Custom/BossRushEnd.cs +++ b/Sounds/Custom/BossRushEnd.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom { - public class BossRushEnd : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class BossRushEnd : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/LeviathanRoarCharge.cs b/Sounds/Custom/LeviathanRoarCharge.cs index 5dcb68e760..b68ed132c5 100644 --- a/Sounds/Custom/LeviathanRoarCharge.cs +++ b/Sounds/Custom/LeviathanRoarCharge.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom { - public class LeviathanRoarCharge : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class LeviathanRoarCharge : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Custom/LeviathanRoarMeteor.cs b/Sounds/Custom/LeviathanRoarMeteor.cs index 263ef5ac63..31de1ce355 100644 --- a/Sounds/Custom/LeviathanRoarMeteor.cs +++ b/Sounds/Custom/LeviathanRoarMeteor.cs @@ -4,15 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Custom { - public class LeviathanRoarMeteor : ModSound - { - public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) - { - soundInstance = sound.CreateInstance(); - soundInstance.Volume = volume * 1f; - soundInstance.Pan = pan; - Main.PlaySoundInstance(soundInstance); - return soundInstance; - } - } + public class LeviathanRoarMeteor : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } } diff --git a/Sounds/Item/PlasmaBolt.cs b/Sounds/Item/PlasmaBolt.cs index edc0c184ca..10d19677a9 100644 --- a/Sounds/Item/PlasmaBolt.cs +++ b/Sounds/Item/PlasmaBolt.cs @@ -4,7 +4,7 @@ using Terraria.ModLoader; namespace CalamityMod.Sounds.Item { - public class PlasmaBolt : ModSound + public class PlasmaBolt : ModSound { public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) { diff --git a/TileEntities/TEBaseTurret.cs b/TileEntities/TEBaseTurret.cs index 41b0160005..f51a1c0dc8 100644 --- a/TileEntities/TEBaseTurret.cs +++ b/TileEntities/TEBaseTurret.cs @@ -8,238 +8,238 @@ using Terraria.ModLoader; namespace CalamityMod.TileEntities { - public abstract class TEBaseTurret : ModTileEntity - { - internal static readonly Vector2 InvalidTarget = new Vector2(float.NaN, float.NaN); + public abstract class TEBaseTurret : ModTileEntity + { + internal static readonly Vector2 InvalidTarget = new Vector2(float.NaN, float.NaN); - // Fields specific to this instance of the turret tile entity - public int FiringTime = 0; - public float Angle = 0f; - public Vector2 TargetPos = InvalidTarget; + // Fields specific to this instance of the turret tile entity + public int FiringTime = 0; + public float Angle = 0f; + public Vector2 TargetPos = InvalidTarget; - // Tile which hosts this tile entity, and variables relating to it - public abstract int TileType { get; } - public abstract int HostTileWidth { get; } - public abstract int HostTileHeight { get; } + // Tile which hosts this tile entity, and variables relating to it + public abstract int TileType { get; } + public abstract int HostTileWidth { get; } + public abstract int HostTileHeight { get; } - // Projectile variables - public abstract int ProjectileType { get; } - public abstract int ProjectileDamage { get; } - public abstract float ProjectileKnockback { get; } - public abstract float ShootSpeed { get; } - public abstract int FiringStartupDelay { get; } - public abstract int FiringUseTime { get; } + // Projectile variables + public abstract int ProjectileType { get; } + public abstract int ProjectileDamage { get; } + public abstract float ProjectileKnockback { get; } + public abstract float ShootSpeed { get; } + public abstract int FiringStartupDelay { get; } + public abstract int FiringUseTime { get; } - // Projectile spawn location variables - public abstract Vector2 TurretCenterOffset { get; } - protected virtual float ShootForwardsOffset => 0f; + // Projectile spawn location variables + public abstract Vector2 TurretCenterOffset { get; } + protected virtual float ShootForwardsOffset => 0f; - // Targeting variables + // Targeting variables - // If the target is more than this distance away, stop tracking them. - public abstract float MaxRange { get; } - // Subclasses MUST define their own targeting algorithm. - protected abstract Vector2 ChooseTarget(Vector2 targetingCenter); - // If the target is more than this angle away from the turret's current firing direction, don't fire. - protected virtual float MaxTargetAngleDeviance => MathHelper.ToRadians(16f); - // How far can the turret swivel every frame while trying to track a fast target? - protected virtual float MaxDeltaAnglePerFrame => MathHelper.ToRadians(4f); - // At what angle difference does the turret switch from fixed swiveling to lerp aiming? - protected virtual float CloseAimThreshold => MathHelper.ToRadians(8f); - // How effective is the turret's lerp aiming? 1f makes it an aimbot. - protected virtual float CloseAimLerpFactor => 1f; + // If the target is more than this distance away, stop tracking them. + public abstract float MaxRange { get; } + // Subclasses MUST define their own targeting algorithm. + protected abstract Vector2 ChooseTarget(Vector2 targetingCenter); + // If the target is more than this angle away from the turret's current firing direction, don't fire. + protected virtual float MaxTargetAngleDeviance => MathHelper.ToRadians(16f); + // How far can the turret swivel every frame while trying to track a fast target? + protected virtual float MaxDeltaAnglePerFrame => MathHelper.ToRadians(4f); + // At what angle difference does the turret switch from fixed swiveling to lerp aiming? + protected virtual float CloseAimThreshold => MathHelper.ToRadians(8f); + // How effective is the turret's lerp aiming? 1f makes it an aimbot. + protected virtual float CloseAimLerpFactor => 1f; - // "Calculator" properties which are calculated on the fly for the code. - // Some of these are quite recursive, so if you do call them, store them in locals. - public Vector2 TurretPosition => Position.ToWorldCoordinates(0f, 0f) + TurretCenterOffset; - protected bool TargetIsInvalid => TargetPos.HasNaNs(); - public int Direction => (Math.Cos(Angle) > 0D).ToDirectionInt(); - public virtual float RestingAngle => Direction == -1 ? MathHelper.Pi : 0f; - protected float TargetAngle => TargetIsInvalid ? RestingAngle : (TargetPos - TurretPosition).ToRotation(); + // "Calculator" properties which are calculated on the fly for the code. + // Some of these are quite recursive, so if you do call them, store them in locals. + public Vector2 TurretPosition => Position.ToWorldCoordinates(0f, 0f) + TurretCenterOffset; + protected bool TargetIsInvalid => TargetPos.HasNaNs(); + public int Direction => (Math.Cos(Angle) > 0D).ToDirectionInt(); + public virtual float RestingAngle => Direction == -1 ? MathHelper.Pi : 0f; + protected float TargetAngle => TargetIsInvalid ? RestingAngle : (TargetPos - TurretPosition).ToRotation(); - // This guarantees that Turret tile entities will not persist if not placed directly on some part of their host tile. - public override bool ValidTile(int i, int j) - { - Tile tile = Main.tile[i, j]; - return tile.active() && tile.type == TileType; - } + // This guarantees that Turret tile entities will not persist if not placed directly on some part of their host tile. + public override bool ValidTile(int i, int j) + { + Tile tile = Main.tile[i, j]; + return tile.active() && tile.type == TileType; + } - #region Update and Turret Behavior - public override void Update() - { - Vector2 turretPos = TurretPosition; + #region Update and Turret Behavior + public override void Update() + { + Vector2 turretPos = TurretPosition; - // ChooseTarget runs every single frame for flexibility. - // If you're storing a target e.g. a player or NPC, do that in your subclass implementation of ChooseTarget. - TargetPos = ChooseTarget(turretPos); - bool validTarget = !TargetIsInvalid; + // ChooseTarget runs every single frame for flexibility. + // If you're storing a target e.g. a player or NPC, do that in your subclass implementation of ChooseTarget. + TargetPos = ChooseTarget(turretPos); + bool validTarget = !TargetIsInvalid; - // If there is a defined target, then this frame is spent aiming, and maybe even firing! - if (validTarget) - { - ActiveBehavior(turretPos, TargetPos); - FiringTime++; - } - - // Otherwise, reset the running "firing timer" and exhibit passive behavior. - else - { - PassiveBehavior(turretPos); - FiringTime = 0; - } + // If there is a defined target, then this frame is spent aiming, and maybe even firing! + if (validTarget) + { + ActiveBehavior(turretPos, TargetPos); + FiringTime++; + } + + // Otherwise, reset the running "firing timer" and exhibit passive behavior. + else + { + PassiveBehavior(turretPos); + FiringTime = 0; + } - UpdateAngle(); - } + UpdateAngle(); + } - // This function does nothing by default, but turrets can use it if they need to update themselves manually on multiplayer clients. - // Calamity calls this function exactly once per frame. - public virtual void UpdateClient() { } + // This function does nothing by default, but turrets can use it if they need to update themselves manually on multiplayer clients. + // Calamity calls this function exactly once per frame. + public virtual void UpdateClient() { } - // This function runs on both client and server side. Clients run it manually using Tile Entity Time Handler. - // This ensures that turrets aim at players visually in multiplayer without causing a packet storm. - public virtual void UpdateAngle() - { - float targetAngle = TargetAngle; - - // WrapAngle clamps things from -pi to pi, not from 0 to 2pi. - float deltaAngle = MathHelper.WrapAngle(Angle - targetAngle); - bool usingCloseAiming = Math.Abs(deltaAngle) <= Math.Max(CloseAimThreshold, MaxDeltaAnglePerFrame); + // This function runs on both client and server side. Clients run it manually using Tile Entity Time Handler. + // This ensures that turrets aim at players visually in multiplayer without causing a packet storm. + public virtual void UpdateAngle() + { + float targetAngle = TargetAngle; + + // WrapAngle clamps things from -pi to pi, not from 0 to 2pi. + float deltaAngle = MathHelper.WrapAngle(Angle - targetAngle); + bool usingCloseAiming = Math.Abs(deltaAngle) <= Math.Max(CloseAimThreshold, MaxDeltaAnglePerFrame); - // When far away from its target angle, the turret swivels at a fixed speed towards its exact target angle. - // When close in, the turret switches to lerping. The lerp strength is configurable. Set to 1 for an aimbot. - // Setting the lerp coefficient to be intentionally low makes it easy to dodge shots (albeit narrowly!) without moving super quickly. - Angle = usingCloseAiming - ? Utils.AngleLerp(Angle, targetAngle, CloseAimLerpFactor) - : MathHelper.WrapAngle(Angle - MaxDeltaAnglePerFrame * Math.Sign(deltaAngle)); - } + // When far away from its target angle, the turret swivels at a fixed speed towards its exact target angle. + // When close in, the turret switches to lerping. The lerp strength is configurable. Set to 1 for an aimbot. + // Setting the lerp coefficient to be intentionally low makes it easy to dodge shots (albeit narrowly!) without moving super quickly. + Angle = usingCloseAiming + ? Utils.AngleLerp(Angle, targetAngle, CloseAimLerpFactor) + : MathHelper.WrapAngle(Angle - MaxDeltaAnglePerFrame * Math.Sign(deltaAngle)); + } - // This function does nothing by default, but turrets can use it for flavor behaviors e.g. emitting sparks or beeping. - protected virtual void PassiveBehavior(Vector2 turretPos) {} + // This function does nothing by default, but turrets can use it for flavor behaviors e.g. emitting sparks or beeping. + protected virtual void PassiveBehavior(Vector2 turretPos) {} - protected virtual void ActiveBehavior(Vector2 turretPos, Vector2 targetPos) - { - // This function won't run without a valid target, so this will always be an angle to a real target. - float targetAngle = TargetAngle; + protected virtual void ActiveBehavior(Vector2 turretPos, Vector2 targetPos) + { + // This function won't run without a valid target, so this will always be an angle to a real target. + float targetAngle = TargetAngle; - // If the turret is too far off its mark or hasn't been around for long enough, don't fire at all. - float deltaAngle = MathHelper.WrapAngle(Angle - targetAngle); - bool angleCloseEnough = Math.Abs(deltaAngle) <= MaxTargetAngleDeviance; - if (!angleCloseEnough || FiringTime < FiringStartupDelay) - return; + // If the turret is too far off its mark or hasn't been around for long enough, don't fire at all. + float deltaAngle = MathHelper.WrapAngle(Angle - targetAngle); + bool angleCloseEnough = Math.Abs(deltaAngle) <= MaxTargetAngleDeviance; + if (!angleCloseEnough || FiringTime < FiringStartupDelay) + return; - // Don't shoot every frame, but sync up the firing cadence to the startup delay. - if ((FiringTime - FiringStartupDelay) % FiringUseTime == 0) - Shoot(turretPos); - } + // Don't shoot every frame, but sync up the firing cadence to the startup delay. + if ((FiringTime - FiringStartupDelay) % FiringUseTime == 0) + Shoot(turretPos); + } - // Orders the turret to fire exactly one projectile at its current heading. - // This function also sends a sync packet. As such, it refuses to run on mutliplayer clients. - public Projectile Shoot(Vector2 turretMuzzlePos, float ai0 = 0f, float ai1 = 0f) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - return null; + // Orders the turret to fire exactly one projectile at its current heading. + // This function also sends a sync packet. As such, it refuses to run on mutliplayer clients. + public Projectile Shoot(Vector2 turretMuzzlePos, float ai0 = 0f, float ai1 = 0f) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + return null; - SendSyncPacket(); + SendSyncPacket(); - Vector2 angleVec = Angle.ToRotationVector2(); - Vector2 pos = turretMuzzlePos + angleVec * ShootForwardsOffset; - Vector2 velocity = angleVec * ShootSpeed; - return Projectile.NewProjectileDirect(pos, velocity, ProjectileType, ProjectileDamage, ProjectileKnockback, ai0: ai0, ai1: ai1); - } - #endregion + Vector2 angleVec = Angle.ToRotationVector2(); + Vector2 pos = turretMuzzlePos + angleVec * ShootForwardsOffset; + Vector2 velocity = angleVec * ShootSpeed; + return Projectile.NewProjectileDirect(pos, velocity, ProjectileType, ProjectileDamage, ProjectileKnockback, ai0: ai0, ai1: ai1); + } + #endregion - // This code is called as a hook when the player places the host tile so that the turret tile entity may be placed. - public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction) - { - // If in multiplayer, tell the server to place the tile entity and DO NOT place it yourself. That would mismatch IDs. - // Also tell the server that you placed tiles in whatever space the host tile occupies. - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendTileRange(Main.myPlayer, i, j, HostTileWidth, HostTileHeight); - NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type); - return -1; - } + // This code is called as a hook when the player places the host tile so that the turret tile entity may be placed. + public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction) + { + // If in multiplayer, tell the server to place the tile entity and DO NOT place it yourself. That would mismatch IDs. + // Also tell the server that you placed tiles in whatever space the host tile occupies. + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileRange(Main.myPlayer, i, j, HostTileWidth, HostTileHeight); + NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type); + return -1; + } - // If in single player, just place the tile entity, no problems. - int id = Place(i, j); - return id; - } + // If in single player, just place the tile entity, no problems. + int id = Place(i, j); + return id; + } - // This code is called on dedicated servers only. It is the server-side response to MessageID.TileEntityPlacement. - // When the server receives such a message from a client, it sends a MessageID.TileEntitySharing to all clients. - // This will cause them to Place the tile entity locally at that position, all with exactly the same ID. - public override void OnNetPlace() => NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, ID, Position.X, Position.Y); + // This code is called on dedicated servers only. It is the server-side response to MessageID.TileEntityPlacement. + // When the server receives such a message from a client, it sends a MessageID.TileEntitySharing to all clients. + // This will cause them to Place the tile entity locally at that position, all with exactly the same ID. + public override void OnNetPlace() => NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, ID, Position.X, Position.Y); - // Normally, a bunch of other TML hooks would go here, namely: - // - // void OnKill() - // TagCompound Save() - // void Load(TagCompound tag) - // - // Subclasses can override these TML hooks as they please. The base turret does not need to use them. + // Normally, a bunch of other TML hooks would go here, namely: + // + // void OnKill() + // TagCompound Save() + // void Load(TagCompound tag) + // + // Subclasses can override these TML hooks as they please. The base turret does not need to use them. - public override void NetSend(BinaryWriter writer, bool lightSend) - { - writer.Write(FiringTime); - writer.Write(Angle); - writer.WriteVector2(TargetPos); - } + public override void NetSend(BinaryWriter writer, bool lightSend) + { + writer.Write(FiringTime); + writer.Write(Angle); + writer.WriteVector2(TargetPos); + } - public override void NetReceive(BinaryReader reader, bool lightReceive) - { - FiringTime = reader.ReadInt32(); - Angle = reader.ReadSingle(); - TargetPos = reader.ReadVector2(); - } + public override void NetReceive(BinaryReader reader, bool lightReceive) + { + FiringTime = reader.ReadInt32(); + Angle = reader.ReadSingle(); + TargetPos = reader.ReadVector2(); + } - protected internal void SendSyncPacket() - { - if (Main.netMode == NetmodeID.SinglePlayer) - return; - ModPacket packet = mod.GetPacket(); - packet.Write((byte)CalamityModMessageType.Turret); - packet.Write(ID); - packet.Write(FiringTime); - packet.Write(Angle); - packet.WriteVector2(TargetPos); - WriteExtraData(packet); - packet.Send(-1, -1); - } + protected internal void SendSyncPacket() + { + if (Main.netMode == NetmodeID.SinglePlayer) + return; + ModPacket packet = mod.GetPacket(); + packet.Write((byte)CalamityModMessageType.Turret); + packet.Write(ID); + packet.Write(FiringTime); + packet.Write(Angle); + packet.WriteVector2(TargetPos); + WriteExtraData(packet); + packet.Send(-1, -1); + } - protected internal static bool ReadSyncPacket(Mod mod, BinaryReader reader) - { - int teID = reader.ReadInt32(); - bool exists = ByID.TryGetValue(teID, out TileEntity te); + protected internal static bool ReadSyncPacket(Mod mod, BinaryReader reader) + { + int teID = reader.ReadInt32(); + bool exists = ByID.TryGetValue(teID, out TileEntity te); - // The rest of the packet must be read even if it turns out the turret doesn't exist for whatever reason. - int firingTime = reader.ReadInt32(); - float angle = reader.ReadSingle(); - Vector2 targetVec = reader.ReadVector2(); + // The rest of the packet must be read even if it turns out the turret doesn't exist for whatever reason. + int firingTime = reader.ReadInt32(); + float angle = reader.ReadSingle(); + Vector2 targetVec = reader.ReadVector2(); - if (exists && te is TEBaseTurret turret) - { - turret.FiringTime = firingTime; - turret.Angle = angle; - turret.TargetPos = targetVec; - turret.ReadExtraData(mod, reader); - return true; - } - else - { - // Otherwise, discard the fixed extra bytes so the message stream doesn't go haywire. - _ = reader.ReadBytes(NumExtraBytes); - return false; - } - } + if (exists && te is TEBaseTurret turret) + { + turret.FiringTime = firingTime; + turret.Angle = angle; + turret.TargetPos = targetVec; + turret.ReadExtraData(mod, reader); + return true; + } + else + { + // Otherwise, discard the fixed extra bytes so the message stream doesn't go haywire. + _ = reader.ReadBytes(NumExtraBytes); + return false; + } + } - // Subclasses cannot override SendSyncPacket, but they can override these functions to sync their own extra data. - // Due to the limitations of TML packets, this data must be exactly 16 bytes in size. - // The default implementations here write 16 bytes of zeroes and dump all 16 bytes when read. - public const int NumExtraBytes = 16; - protected virtual void WriteExtraData(BinaryWriter writer) { - writer.Write(0Lu); - writer.Write(0Lu); - } - protected virtual void ReadExtraData(Mod mod, BinaryReader reader) => _ = reader.ReadBytes(NumExtraBytes); - } + // Subclasses cannot override SendSyncPacket, but they can override these functions to sync their own extra data. + // Due to the limitations of TML packets, this data must be exactly 16 bytes in size. + // The default implementations here write 16 bytes of zeroes and dump all 16 bytes when read. + public const int NumExtraBytes = 16; + protected virtual void WriteExtraData(BinaryWriter writer) { + writer.Write(0Lu); + writer.Write(0Lu); + } + protected virtual void ReadExtraData(Mod mod, BinaryReader reader) => _ = reader.ReadBytes(NumExtraBytes); + } } diff --git a/TileEntities/TEChargingStation.cs b/TileEntities/TEChargingStation.cs index 4749051a2d..042d4be0f6 100644 --- a/TileEntities/TEChargingStation.cs +++ b/TileEntities/TEChargingStation.cs @@ -13,293 +13,293 @@ using Terraria.ModLoader.IO; namespace CalamityMod.TileEntities { - public class TEChargingStation : ModTileEntity - { - public Vector2 Center => Position.ToWorldCoordinates(8f * ChargingStation.Width, 8f * ChargingStation.Height); - private short ChargingTimer = 0; - private short _stack = 0; - public short CellStack - { - get => _stack; - set - { - _stack = value; - SendSyncPacket(); - } - } - public Item PluggedItem = new Item(); - private bool syncItemCharge = false; - public bool ClientChargingDust = false; + public class TEChargingStation : ModTileEntity + { + public Vector2 Center => Position.ToWorldCoordinates(8f * ChargingStation.Width, 8f * ChargingStation.Height); + private short ChargingTimer = 0; + private short _stack = 0; + public short CellStack + { + get => _stack; + set + { + _stack = value; + SendSyncPacket(); + } + } + public Item PluggedItem = new Item(); + private bool syncItemCharge = false; + public bool ClientChargingDust = false; - // This returns whether the charging station's inserted ("plugged") item can actually be charged. - private bool PluggedItemCanCharge - { - get - { - if (PluggedItem is null || PluggedItem.IsAir) - return false; - CalamityGlobalItem modItem = PluggedItem.Calamity(); - return modItem.UsesCharge && modItem.Charge < modItem.MaxCharge; - } - } - public bool CanDoWork => _stack > 0 && PluggedItemCanCharge; + // This returns whether the charging station's inserted ("plugged") item can actually be charged. + private bool PluggedItemCanCharge + { + get + { + if (PluggedItem is null || PluggedItem.IsAir) + return false; + CalamityGlobalItem modItem = PluggedItem.Calamity(); + return modItem.UsesCharge && modItem.Charge < modItem.MaxCharge; + } + } + public bool CanDoWork => _stack > 0 && PluggedItemCanCharge; - // Red when not actively charging an item, green when charging - public Color LightColor => CanDoWork ? Color.MediumSpringGreen : Color.Red; + // Red when not actively charging an item, green when charging + public Color LightColor => CanDoWork ? Color.MediumSpringGreen : Color.Red; - // This guarantees that this tile entity will not persist if not placed directly on the top left corner of a Charging Station tile. - public override bool ValidTile(int i, int j) - { - Tile tile = Main.tile[i, j]; - return tile.active() && tile.type == ModContent.TileType() && tile.frameX == 0 && tile.frameY == 0; - } + // This guarantees that this tile entity will not persist if not placed directly on the top left corner of a Charging Station tile. + public override bool ValidTile(int i, int j) + { + Tile tile = Main.tile[i, j]; + return tile.active() && tile.type == ModContent.TileType() && tile.frameX == 0 && tile.frameY == 0; + } - public override void Update() - { - bool canWork = CanDoWork; - if (!canWork) - { - ChargingTimer = 0; - return; - } + public override void Update() + { + bool canWork = CanDoWork; + if (!canWork) + { + ChargingTimer = 0; + return; + } - ++ChargingTimer; + ++ChargingTimer; - if (ChargingTimer >= ChargingStation.FramesPerChargeAction) - { - // Apply charge to the plugged item first, as this doesn't send a sync packet. - CalamityGlobalItem modItem = PluggedItem.Calamity(); - modItem.Charge += PowerCell.ChargeValue; - if (modItem.Charge >= modItem.MaxCharge) - modItem.Charge = modItem.MaxCharge; + if (ChargingTimer >= ChargingStation.FramesPerChargeAction) + { + // Apply charge to the plugged item first, as this doesn't send a sync packet. + CalamityGlobalItem modItem = PluggedItem.Calamity(); + modItem.Charge += PowerCell.ChargeValue; + if (modItem.Charge >= modItem.MaxCharge) + modItem.Charge = modItem.MaxCharge; - SpawnChargingDust(); + SpawnChargingDust(); - // Set the flag for syncing the plugged item's charge as well. - syncItemCharge = true; + // Set the flag for syncing the plugged item's charge as well. + syncItemCharge = true; - // Then decrement the cell stack. With the sync flag set, this will sync both the cell stack and the plugged item. - CellStack--; - ChargingTimer = 0; - } - } + // Then decrement the cell stack. With the sync flag set, this will sync both the cell stack and the plugged item. + CellStack--; + ChargingTimer = 0; + } + } - public void SpawnChargingDust() - { - bool chargeComplete = false; - if (!PluggedItem.IsAir) - { - CalamityGlobalItem modItem = PluggedItem.Calamity(); - chargeComplete = modItem.Charge == modItem.MaxCharge; - } + public void SpawnChargingDust() + { + bool chargeComplete = false; + if (!PluggedItem.IsAir) + { + CalamityGlobalItem modItem = PluggedItem.Calamity(); + chargeComplete = modItem.Charge == modItem.MaxCharge; + } - int dustID = 182; // Mechanical Cart laser dust. Looks epic. - int numDust = 18; - if (chargeComplete) - numDust *= 3; - Vector2 dustPos = Position.ToWorldCoordinates(ChargingStation.Width * 8f - 4f, 1f); - for (int i = 0; i < numDust; i += 2) - { - float pairSpeed = Main.rand.NextFloat(0.5f, 7f); - float pairScale = chargeComplete ? 2.4f : 1f; + int dustID = 182; // Mechanical Cart laser dust. Looks epic. + int numDust = 18; + if (chargeComplete) + numDust *= 3; + Vector2 dustPos = Position.ToWorldCoordinates(ChargingStation.Width * 8f - 4f, 1f); + for (int i = 0; i < numDust; i += 2) + { + float pairSpeed = Main.rand.NextFloat(0.5f, 7f); + float pairScale = chargeComplete ? 2.4f : 1f; - Dust d = Dust.NewDustDirect(dustPos, 0, 0, dustID); - d.velocity = Vector2.UnitX * pairSpeed; - d.scale = pairScale; - d.noGravity = true; + Dust d = Dust.NewDustDirect(dustPos, 0, 0, dustID); + d.velocity = Vector2.UnitX * pairSpeed; + d.scale = pairScale; + d.noGravity = true; - d = Dust.NewDustDirect(dustPos, 0, 0, dustID); - d.velocity = Vector2.UnitX * -pairSpeed; - d.scale = pairScale; - d.noGravity = true; - } - } + d = Dust.NewDustDirect(dustPos, 0, 0, dustID); + d.velocity = Vector2.UnitX * -pairSpeed; + d.scale = pairScale; + d.noGravity = true; + } + } - // This code is called as a hook when the player places the Charging Station tile so that the tile entity may be placed. - public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction) - { - // If in multiplayer, tell the server to place the tile entity and DO NOT place it yourself. That would mismatch IDs. - // Also tell the server that you placed the 3x2 tiles that make up the Charging Station. - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendTileRange(Main.myPlayer, i, j, ChargingStation.Width, ChargingStation.Height); - NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type); - return -1; - } + // This code is called as a hook when the player places the Charging Station tile so that the tile entity may be placed. + public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction) + { + // If in multiplayer, tell the server to place the tile entity and DO NOT place it yourself. That would mismatch IDs. + // Also tell the server that you placed the 3x2 tiles that make up the Charging Station. + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileRange(Main.myPlayer, i, j, ChargingStation.Width, ChargingStation.Height); + NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type); + return -1; + } - // If in single player, just place the tile entity, no problems. - int id = Place(i, j); - return id; - } + // If in single player, just place the tile entity, no problems. + int id = Place(i, j); + return id; + } - // This code is called on dedicated servers only. It is the server-side response to MessageID.TileEntityPlacement. - // When the server receives such a message from a client, it sends a MessageID.TileEntitySharing to all clients. - // This will cause them to Place the tile entity locally at that position, all with exactly the same ID. - public override void OnNetPlace() => NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, ID, Position.X, Position.Y); + // This code is called on dedicated servers only. It is the server-side response to MessageID.TileEntityPlacement. + // When the server receives such a message from a client, it sends a MessageID.TileEntitySharing to all clients. + // This will cause them to Place the tile entity locally at that position, all with exactly the same ID. + public override void OnNetPlace() => NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, ID, Position.X, Position.Y); - // If this charging station breaks, anyone's who's viewing it is no longer viewing it. - public override void OnKill() - { - for (int i = 0; i < Main.maxPlayers; ++i) - { - Player p = Main.player[i]; - if (!p.active) - continue; + // If this charging station breaks, anyone's who's viewing it is no longer viewing it. + public override void OnKill() + { + for (int i = 0; i < Main.maxPlayers; ++i) + { + Player p = Main.player[i]; + if (!p.active) + continue; - // Use reflection to stop TML from spitting an error here. - // Try-catching will not stop this error, TML will print it to console anyway. The error is harmless. - ModPlayer[] mpStorageArray = (ModPlayer[])typeof(Player).GetField("modPlayers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(p); - if (mpStorageArray.Length == 0) - continue; + // Use reflection to stop TML from spitting an error here. + // Try-catching will not stop this error, TML will print it to console anyway. The error is harmless. + ModPlayer[] mpStorageArray = (ModPlayer[])typeof(Player).GetField("modPlayers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(p); + if (mpStorageArray.Length == 0) + continue; - CalamityPlayer mp = p.Calamity(); - if (mp.CurrentlyViewedChargerID == ID) - mp.CurrentlyViewedChargerID = -1; - } - } + CalamityPlayer mp = p.Calamity(); + if (mp.CurrentlyViewedChargerID == ID) + mp.CurrentlyViewedChargerID = -1; + } + } - public override TagCompound Save() - { - TagCompound ret = new TagCompound - { - { "time", ChargingTimer }, - { "cells", _stack } - }; - Item forSaving; - if (PluggedItem is null) - { - forSaving = new Item(); - forSaving.TurnToAir(); - } - else - forSaving = PluggedItem; - ret.Add("item", forSaving); - return ret; - } + public override TagCompound Save() + { + TagCompound ret = new TagCompound + { + { "time", ChargingTimer }, + { "cells", _stack } + }; + Item forSaving; + if (PluggedItem is null) + { + forSaving = new Item(); + forSaving.TurnToAir(); + } + else + forSaving = PluggedItem; + ret.Add("item", forSaving); + return ret; + } - public override void Load(TagCompound tag) - { - ChargingTimer = tag.GetShort("time"); - _stack = tag.GetShort("cells"); - PluggedItem = ItemIO.Load(tag.GetCompound("item")); - } + public override void Load(TagCompound tag) + { + ChargingTimer = tag.GetShort("time"); + _stack = tag.GetShort("cells"); + PluggedItem = ItemIO.Load(tag.GetCompound("item")); + } - public override void NetSend(BinaryWriter writer, bool lightSend) - { - writer.Write(ChargingTimer); - writer.Write(_stack); - writer.WriteItem(PluggedItem, true); - } + public override void NetSend(BinaryWriter writer, bool lightSend) + { + writer.Write(ChargingTimer); + writer.Write(_stack); + writer.WriteItem(PluggedItem, true); + } - public override void NetReceive(BinaryReader reader, bool lightReceive) - { - ChargingTimer = reader.ReadInt16(); - _stack = reader.ReadInt16(); - PluggedItem = reader.ReadItem(true); - } + public override void NetReceive(BinaryReader reader, bool lightReceive) + { + ChargingTimer = reader.ReadInt16(); + _stack = reader.ReadInt16(); + PluggedItem = reader.ReadItem(true); + } - // This packet may or may not contain the plugged item's charge value. If it doesn't, it contains a dummy value (NaN) instead. - // The plugged item's charge is synced when syncItemCharge is true. - private void SendSyncPacket() - { - if (Main.netMode == NetmodeID.SinglePlayer) - return; - ModPacket packet = mod.GetPacket(); - packet.Write((byte)CalamityModMessageType.ChargingStationStandard); - packet.Write(ID); - packet.Write(ChargingTimer); - packet.Write(_stack); + // This packet may or may not contain the plugged item's charge value. If it doesn't, it contains a dummy value (NaN) instead. + // The plugged item's charge is synced when syncItemCharge is true. + private void SendSyncPacket() + { + if (Main.netMode == NetmodeID.SinglePlayer) + return; + ModPacket packet = mod.GetPacket(); + packet.Write((byte)CalamityModMessageType.ChargingStationStandard); + packet.Write(ID); + packet.Write(ChargingTimer); + packet.Write(_stack); - // Either write the real charge or garbage data. If garbage data is written it will be ignored on the other end. - CalamityGlobalItem modItem = PluggedItem.IsAir ? null : PluggedItem.Calamity(); - packet.Write(syncItemCharge && modItem != null ? modItem.Charge : float.NaN); - packet.Send(-1, -1); + // Either write the real charge or garbage data. If garbage data is written it will be ignored on the other end. + CalamityGlobalItem modItem = PluggedItem.IsAir ? null : PluggedItem.Calamity(); + packet.Write(syncItemCharge && modItem != null ? modItem.Charge : float.NaN); + packet.Send(-1, -1); - // If this flag was set to true, set it to false for any further updates (until it gets set to true again). - syncItemCharge = false; - } + // If this flag was set to true, set it to false for any further updates (until it gets set to true again). + syncItemCharge = false; + } - internal static bool ReadSyncPacket(Mod mod, BinaryReader reader) - { - int teID = reader.ReadInt32(); - bool exists = ByID.TryGetValue(teID, out TileEntity te); + internal static bool ReadSyncPacket(Mod mod, BinaryReader reader) + { + int teID = reader.ReadInt32(); + bool exists = ByID.TryGetValue(teID, out TileEntity te); - // The rest of the packet must be read even if it turns out the charging station doesn't exist for whatever reason. - short timer = reader.ReadInt16(); - short cellStack = reader.ReadInt16(); - float chargeOrNaN = reader.ReadSingle(); + // The rest of the packet must be read even if it turns out the charging station doesn't exist for whatever reason. + short timer = reader.ReadInt16(); + short cellStack = reader.ReadInt16(); + float chargeOrNaN = reader.ReadSingle(); - // When a server gets this packet, it immediately sends an equivalent packet to all clients. - if (Main.netMode == NetmodeID.Server) - { - ModPacket packet = mod.GetPacket(); - packet.Write((byte)CalamityModMessageType.ChargingStationStandard); - packet.Write(teID); - packet.Write(timer); - packet.Write(cellStack); - packet.Write(chargeOrNaN); - packet.Send(-1, -1); - } + // When a server gets this packet, it immediately sends an equivalent packet to all clients. + if (Main.netMode == NetmodeID.Server) + { + ModPacket packet = mod.GetPacket(); + packet.Write((byte)CalamityModMessageType.ChargingStationStandard); + packet.Write(teID); + packet.Write(timer); + packet.Write(cellStack); + packet.Write(chargeOrNaN); + packet.Send(-1, -1); + } - if (exists && te is TEChargingStation charger) - { - // Only clients update their timer from this packet. When a server receives this packet it ignores the time variable. - if (Main.netMode == NetmodeID.MultiplayerClient) - charger.ChargingTimer = timer; - charger._stack = cellStack; + if (exists && te is TEChargingStation charger) + { + // Only clients update their timer from this packet. When a server receives this packet it ignores the time variable. + if (Main.netMode == NetmodeID.MultiplayerClient) + charger.ChargingTimer = timer; + charger._stack = cellStack; - // If the charge value sent is not garbage, then try to apply the new charge to the plugged item. - if (!float.IsNaN(chargeOrNaN)) - { - bool itemExists = charger.PluggedItem != null && !charger.PluggedItem.IsAir; - CalamityGlobalItem modItem = itemExists ? charger.PluggedItem.Calamity() : null; - if (modItem != null && modItem.UsesCharge) - { - if (modItem.Charge != chargeOrNaN && Main.netMode == NetmodeID.MultiplayerClient) - charger.ClientChargingDust = true; - modItem.Charge = chargeOrNaN; - } - } - return true; - } - return false; - } + // If the charge value sent is not garbage, then try to apply the new charge to the plugged item. + if (!float.IsNaN(chargeOrNaN)) + { + bool itemExists = charger.PluggedItem != null && !charger.PluggedItem.IsAir; + CalamityGlobalItem modItem = itemExists ? charger.PluggedItem.Calamity() : null; + if (modItem != null && modItem.UsesCharge) + { + if (modItem.Charge != chargeOrNaN && Main.netMode == NetmodeID.MultiplayerClient) + charger.ClientChargingDust = true; + modItem.Charge = chargeOrNaN; + } + } + return true; + } + return false; + } - internal void SendItemSyncPacket() - { - if (Main.netMode == NetmodeID.SinglePlayer) - return; - ModPacket packet = mod.GetPacket(1024); - packet.Write((byte)CalamityModMessageType.ChargingStationItemChange); - packet.Write(ID); - packet.WriteItem(PluggedItem, true); - packet.Send(-1, -1); - } + internal void SendItemSyncPacket() + { + if (Main.netMode == NetmodeID.SinglePlayer) + return; + ModPacket packet = mod.GetPacket(1024); + packet.Write((byte)CalamityModMessageType.ChargingStationItemChange); + packet.Write(ID); + packet.WriteItem(PluggedItem, true); + packet.Send(-1, -1); + } - internal static bool ReadItemSyncPacket(Mod mod, BinaryReader reader) - { - int teID = reader.ReadInt32(); - bool exists = ByID.TryGetValue(teID, out TileEntity te); + internal static bool ReadItemSyncPacket(Mod mod, BinaryReader reader) + { + int teID = reader.ReadInt32(); + bool exists = ByID.TryGetValue(teID, out TileEntity te); - // The rest of the packet must be read even if it turns out the charging station doesn't exist for whatever reason. - Item thePlug = reader.ReadItem(true); + // The rest of the packet must be read even if it turns out the charging station doesn't exist for whatever reason. + Item thePlug = reader.ReadItem(true); - // When a server gets this packet, it immediately sends an equivalent packet to all clients. - if (Main.netMode == NetmodeID.Server) - { - ModPacket packet = mod.GetPacket(); - packet.Write((byte)CalamityModMessageType.ChargingStationItemChange); - packet.Write(teID); - packet.WriteItem(thePlug, true); - packet.Send(-1, -1); - } + // When a server gets this packet, it immediately sends an equivalent packet to all clients. + if (Main.netMode == NetmodeID.Server) + { + ModPacket packet = mod.GetPacket(); + packet.Write((byte)CalamityModMessageType.ChargingStationItemChange); + packet.Write(teID); + packet.WriteItem(thePlug, true); + packet.Send(-1, -1); + } - if (exists && te is TEChargingStation charger) - { - charger.PluggedItem = thePlug; - return true; - } - return false; - } - } + if (exists && te is TEChargingStation charger) + { + charger.PluggedItem = thePlug; + return true; + } + return false; + } + } } diff --git a/TileEntities/TECodebreaker.cs b/TileEntities/TECodebreaker.cs index ac6e52032f..489cb55250 100644 --- a/TileEntities/TECodebreaker.cs +++ b/TileEntities/TECodebreaker.cs @@ -11,416 +11,416 @@ using Terraria.ModLoader.IO; namespace CalamityMod.TileEntities { - public class TECodebreaker : ModTileEntity - { - public int InputtedCellCount; - public int InitialCellCountBeforeDecrypting; - public int HeldSchematicID; + public class TECodebreaker : ModTileEntity + { + public int InputtedCellCount; + public int InitialCellCountBeforeDecrypting; + public int HeldSchematicID; - public int DecryptionCountdown; - public int DecryptionTotalTime - { - get - { - // Decryption takes 2 minutes typically. - int decryptTime = 7200; + public int DecryptionCountdown; + public int DecryptionTotalTime + { + get + { + // Decryption takes 2 minutes typically. + int decryptTime = 7200; - // However, if this codebreaker has a quantum cell, it only takes 15 seconds. - if (ContainsCoolingCell) - decryptTime = 900; - return decryptTime; - } - } + // However, if this codebreaker has a quantum cell, it only takes 15 seconds. + if (ContainsCoolingCell) + decryptTime = 900; + return decryptTime; + } + } - public int DecryptionCellCost - { - get - { - // You can't decrypt nothing. - if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) - return 0; + public int DecryptionCellCost + { + get + { + // You can't decrypt nothing. + if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) + return 0; - int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; - if (schematicType == ModContent.ItemType()) - return 500; - if (schematicType == ModContent.ItemType()) - return 950; - if (schematicType == ModContent.ItemType()) - return 1750; - if (schematicType == ModContent.ItemType()) - return 5000; + int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; + if (schematicType == ModContent.ItemType()) + return 500; + if (schematicType == ModContent.ItemType()) + return 950; + if (schematicType == ModContent.ItemType()) + return 1750; + if (schematicType == ModContent.ItemType()) + return 5000; - return 0; - } - } + return 0; + } + } - public float DecryptionCompletion => 1f - DecryptionCountdown / (float)DecryptionTotalTime; - public bool ReadyToSummonDraedon => ContainsCoolingCell && DecryptionCountdown <= 0; + public float DecryptionCompletion => 1f - DecryptionCountdown / (float)DecryptionTotalTime; + public bool ReadyToSummonDraedon => ContainsCoolingCell && DecryptionCountdown <= 0; - public bool ContainsDecryptionComputer; - public bool ContainsSensorArray; - public bool ContainsAdvancedDisplay; - public bool ContainsVoltageRegulationSystem; - public bool ContainsCoolingCell; + public bool ContainsDecryptionComputer; + public bool ContainsSensorArray; + public bool ContainsAdvancedDisplay; + public bool ContainsVoltageRegulationSystem; + public bool ContainsCoolingCell; - public bool CanDecryptHeldSchematic - { - get - { - // You can't decrypt nothing. - if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) - return false; + public bool CanDecryptHeldSchematic + { + get + { + // You can't decrypt nothing. + if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) + return false; - int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; - if (schematicType == ModContent.ItemType()) - return ContainsDecryptionComputer; - if (schematicType == ModContent.ItemType()) - return ContainsDecryptionComputer && ContainsSensorArray; - if (schematicType == ModContent.ItemType()) - return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay; - if (schematicType == ModContent.ItemType()) - return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay && ContainsVoltageRegulationSystem; + int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer && ContainsSensorArray; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay && ContainsVoltageRegulationSystem; - return false; - } - } + return false; + } + } - public string UnderlyingSchematicText - { - get - { - // You can't decrypt nothing. - if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) - return string.Empty; + public string UnderlyingSchematicText + { + get + { + // You can't decrypt nothing. + if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) + return string.Empty; - int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; - if (schematicType == ModContent.ItemType()) - return "Within an army, as weapons do, the soldiers serve different purposes. That distinction is crucial, as the wrong tool in the wrong hands—no matter how potent—may as well be a wooden club.\n" + - "Addendum: Seek out my base of operations closest to the Lihzahrd’s home. I wish you the best of luck with all sincerity, for it has been a long time since I have had a worthy test subject. "; - if (schematicType == ModContent.ItemType()) - return "As rank progresses, so often does the lethality of equipment. In the hands of competent soldiers, the weapons have the ability to make change. However, competent soldiers take no action but orders from above.\n" + - "Addendum: If you read this, you have come far. Do not disappoint. Go now to Hell, for the next component stored in what were once my forges."; - if (schematicType == ModContent.ItemType()) - return "Only the highest ranking in the battalions of Yharim’s army held these weapons. However these are still not my most potent tools. Those...characters could not be trusted with them.\n" + - "Addendum: The final piece remains. Travel now from the hottest fire this land has to offer, to the most frigid cold. I cannot deny having some sense of poetic symmetry."; - if (schematicType == ModContent.ItemType()) - return "I have since made progress to even greater weapons than these, but they remain creations to be proud of. No progress can be made without a desire that comes from dissatisfaction.\n" + - "Addendum: The time has come. You are ready."; + int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; + if (schematicType == ModContent.ItemType()) + return "Within an army, as weapons do, the soldiers serve different purposes. That distinction is crucial, as the wrong tool in the wrong hands—no matter how potent—may as well be a wooden club.\n" + + "Addendum: Seek out my base of operations closest to the Lihzahrd’s home. I wish you the best of luck with all sincerity, for it has been a long time since I have had a worthy test subject. "; + if (schematicType == ModContent.ItemType()) + return "As rank progresses, so often does the lethality of equipment. In the hands of competent soldiers, the weapons have the ability to make change. However, competent soldiers take no action but orders from above.\n" + + "Addendum: If you read this, you have come far. Do not disappoint. Go now to Hell, for the next component stored in what were once my forges."; + if (schematicType == ModContent.ItemType()) + return "Only the highest ranking in the battalions of Yharim’s army held these weapons. However these are still not my most potent tools. Those...characters could not be trusted with them.\n" + + "Addendum: The final piece remains. Travel now from the hottest fire this land has to offer, to the most frigid cold. I cannot deny having some sense of poetic symmetry."; + if (schematicType == ModContent.ItemType()) + return "I have since made progress to even greater weapons than these, but they remain creations to be proud of. No progress can be made without a desire that comes from dissatisfaction.\n" + + "Addendum: The time has come. You are ready."; - return string.Empty; - } - } + return string.Empty; + } + } - public Vector2 Center => Position.ToWorldCoordinates(8f * CodebreakerTile.Width, 8f * CodebreakerTile.Height); - public const int MaxCellCapacity = 9999; + public Vector2 Center => Position.ToWorldCoordinates(8f * CodebreakerTile.Width, 8f * CodebreakerTile.Height); + public const int MaxCellCapacity = 9999; - // This guarantees that this tile entity will not persist if not placed directly on the top left corner of a Codebreaker tile. - public override bool ValidTile(int i, int j) - { - Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j); - return tile.active() && tile.type == ModContent.TileType() && tile.frameX == 0 && tile.frameY == 0; - } + // This guarantees that this tile entity will not persist if not placed directly on the top left corner of a Codebreaker tile. + public override bool ValidTile(int i, int j) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j); + return tile.active() && tile.type == ModContent.TileType() && tile.frameX == 0 && tile.frameY == 0; + } - // This code is called as a hook when the player places the Codebreaker tile so that the tile entity may be placed. - public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction) - { - // If in multiplayer, tell the server to place the tile entity and DO NOT place it yourself. That would mismatch IDs. - // Also tell the server that you placed the 5x8 tiles that make up the Codebreaker. - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendTileRange(Main.myPlayer, i, j, CodebreakerTile.Width, CodebreakerTile.Height); - NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type); - return -1; - } + // This code is called as a hook when the player places the Codebreaker tile so that the tile entity may be placed. + public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction) + { + // If in multiplayer, tell the server to place the tile entity and DO NOT place it yourself. That would mismatch IDs. + // Also tell the server that you placed the 5x8 tiles that make up the Codebreaker. + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileRange(Main.myPlayer, i, j, CodebreakerTile.Width, CodebreakerTile.Height); + NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type); + return -1; + } - // If in single player, just place the tile entity, no problems. - return Place(i, j); - } + // If in single player, just place the tile entity, no problems. + return Place(i, j); + } - // This code is called on dedicated servers only. It is the server-side response to MessageID.TileEntityPlacement. - // When the server receives such a message from a client, it sends a MessageID.TileEntitySharing to all clients. - // This will cause them to Place the tile entity locally at that position, all with exactly the same ID. - public override void OnNetPlace() => NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, ID, Position.X, Position.Y); + // This code is called on dedicated servers only. It is the server-side response to MessageID.TileEntityPlacement. + // When the server receives such a message from a client, it sends a MessageID.TileEntitySharing to all clients. + // This will cause them to Place the tile entity locally at that position, all with exactly the same ID. + public override void OnNetPlace() => NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, ID, Position.X, Position.Y); - public override void Update() => UpdateTime(); + public override void Update() => UpdateTime(); - public void DropConstituents(int x, int y) - { - if (ContainsDecryptionComputer) - Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); - if (ContainsSensorArray) - Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); - if (ContainsAdvancedDisplay) - Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); - if (ContainsVoltageRegulationSystem) - Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); - if (ContainsCoolingCell) - Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); + public void DropConstituents(int x, int y) + { + if (ContainsDecryptionComputer) + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); + if (ContainsSensorArray) + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); + if (ContainsAdvancedDisplay) + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); + if (ContainsVoltageRegulationSystem) + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); + if (ContainsCoolingCell) + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); - if (CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) - Item.NewItem(x * 16, y * 16, 32, 32, CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]); + if (CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) + Item.NewItem(x * 16, y * 16, 32, 32, CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]); - while (InputtedCellCount > 0) - { - int totalCellsToDrop = InputtedCellCount; - if (totalCellsToDrop > 999) - totalCellsToDrop = 999; - InputtedCellCount -= totalCellsToDrop; - Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType(), totalCellsToDrop); - } - } + while (InputtedCellCount > 0) + { + int totalCellsToDrop = InputtedCellCount; + if (totalCellsToDrop > 999) + totalCellsToDrop = 999; + InputtedCellCount -= totalCellsToDrop; + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType(), totalCellsToDrop); + } + } - public void SyncConstituents(short sender) - { - // Don't bother sending packets in singleplayer. - if (Main.netMode == NetmodeID.SinglePlayer) - return; + public void SyncConstituents(short sender) + { + // Don't bother sending packets in singleplayer. + if (Main.netMode == NetmodeID.SinglePlayer) + return; - ModPacket packet = mod.GetPacket(); - BitsByte containmentFlagWrapper = new BitsByte(); - containmentFlagWrapper[0] = ContainsDecryptionComputer; - containmentFlagWrapper[1] = ContainsSensorArray; - containmentFlagWrapper[2] = ContainsAdvancedDisplay; - containmentFlagWrapper[3] = ContainsVoltageRegulationSystem; - containmentFlagWrapper[4] = ContainsCoolingCell; + ModPacket packet = mod.GetPacket(); + BitsByte containmentFlagWrapper = new BitsByte(); + containmentFlagWrapper[0] = ContainsDecryptionComputer; + containmentFlagWrapper[1] = ContainsSensorArray; + containmentFlagWrapper[2] = ContainsAdvancedDisplay; + containmentFlagWrapper[3] = ContainsVoltageRegulationSystem; + containmentFlagWrapper[4] = ContainsCoolingCell; - packet.Write((byte)CalamityModMessageType.UpdateCodebreakerConstituents); - packet.Write(ID); - packet.Write(sender); - packet.Write(containmentFlagWrapper); - packet.Send(-1, sender); - } + packet.Write((byte)CalamityModMessageType.UpdateCodebreakerConstituents); + packet.Write(ID); + packet.Write(sender); + packet.Write(containmentFlagWrapper); + packet.Send(-1, sender); + } - public static void ReadConstituentsUpdateSync(Mod mod, BinaryReader reader) - { - int id = reader.ReadInt32(); - short sender = reader.ReadInt16(); - bool exists = ByID.TryGetValue(id, out TileEntity tileEntity); + public static void ReadConstituentsUpdateSync(Mod mod, BinaryReader reader) + { + int id = reader.ReadInt32(); + short sender = reader.ReadInt16(); + bool exists = ByID.TryGetValue(id, out TileEntity tileEntity); - // Continue reading to the end even if a tile entity with the given ID does not exist. - // Not doing this will cause errors/bugs. - BitsByte containmentFlagWrapper = reader.ReadByte(); - bool containsDecryptionComputer = containmentFlagWrapper[0]; - bool containsSensorArray = containmentFlagWrapper[1]; - bool containsAdvancedDisplay = containmentFlagWrapper[2]; - bool containsVoltageRegulationSystem = containmentFlagWrapper[3]; - bool containsCoolingCell = containmentFlagWrapper[4]; + // Continue reading to the end even if a tile entity with the given ID does not exist. + // Not doing this will cause errors/bugs. + BitsByte containmentFlagWrapper = reader.ReadByte(); + bool containsDecryptionComputer = containmentFlagWrapper[0]; + bool containsSensorArray = containmentFlagWrapper[1]; + bool containsAdvancedDisplay = containmentFlagWrapper[2]; + bool containsVoltageRegulationSystem = containmentFlagWrapper[3]; + bool containsCoolingCell = containmentFlagWrapper[4]; - // After doing reading, check again to see if the tile entity is actually there. - // If it isn't don't bother doing anything else. - if (!exists) - return; + // After doing reading, check again to see if the tile entity is actually there. + // If it isn't don't bother doing anything else. + if (!exists) + return; - // Furthermore, verify to ensure that the tile entity is a valid one. - if (!(tileEntity is TECodebreaker codebreakerTileEntity)) - return; + // Furthermore, verify to ensure that the tile entity is a valid one. + if (!(tileEntity is TECodebreaker codebreakerTileEntity)) + return; - codebreakerTileEntity.ContainsDecryptionComputer = containsDecryptionComputer; - codebreakerTileEntity.ContainsSensorArray = containsSensorArray; - codebreakerTileEntity.ContainsAdvancedDisplay = containsAdvancedDisplay; - codebreakerTileEntity.ContainsVoltageRegulationSystem = containsVoltageRegulationSystem; - codebreakerTileEntity.ContainsCoolingCell = containsCoolingCell; + codebreakerTileEntity.ContainsDecryptionComputer = containsDecryptionComputer; + codebreakerTileEntity.ContainsSensorArray = containsSensorArray; + codebreakerTileEntity.ContainsAdvancedDisplay = containsAdvancedDisplay; + codebreakerTileEntity.ContainsVoltageRegulationSystem = containsVoltageRegulationSystem; + codebreakerTileEntity.ContainsCoolingCell = containsCoolingCell; - // Send the packet again to the other clients if this packet was received on the server. - // Since ModPackets go solely to the server when sent by a client this is necesssary - // to ensure that all clients are informed of what happened. - if (Main.netMode == NetmodeID.Server) - codebreakerTileEntity.SyncConstituents(sender); - } + // Send the packet again to the other clients if this packet was received on the server. + // Since ModPackets go solely to the server when sent by a client this is necesssary + // to ensure that all clients are informed of what happened. + if (Main.netMode == NetmodeID.Server) + codebreakerTileEntity.SyncConstituents(sender); + } - public void SyncContainedStuff() - { - // Don't bother sending packets in singleplayer. - if (Main.netMode == NetmodeID.SinglePlayer) - return; + public void SyncContainedStuff() + { + // Don't bother sending packets in singleplayer. + if (Main.netMode == NetmodeID.SinglePlayer) + return; - ModPacket packet = mod.GetPacket(); - packet.Write((byte)CalamityModMessageType.UpdateCodebreakerContainedStuff); - packet.Write(ID); - packet.Write(InputtedCellCount); - packet.Write(InitialCellCountBeforeDecrypting); - packet.Write(HeldSchematicID); - packet.Send(); - } + ModPacket packet = mod.GetPacket(); + packet.Write((byte)CalamityModMessageType.UpdateCodebreakerContainedStuff); + packet.Write(ID); + packet.Write(InputtedCellCount); + packet.Write(InitialCellCountBeforeDecrypting); + packet.Write(HeldSchematicID); + packet.Send(); + } - public static void ReadContainmentSync(Mod mod, BinaryReader reader) - { - int id = reader.ReadInt32(); - bool exists = ByID.TryGetValue(id, out TileEntity tileEntity); + public static void ReadContainmentSync(Mod mod, BinaryReader reader) + { + int id = reader.ReadInt32(); + bool exists = ByID.TryGetValue(id, out TileEntity tileEntity); - // Continue reading to the end even if a tile entity with the given ID does not exist. - // Not doing this will cause errors/bugs. - int cellCount = reader.ReadInt32(); - int cellCountBeforeDecrypting = reader.ReadInt32(); - int schematicID = reader.ReadInt32(); + // Continue reading to the end even if a tile entity with the given ID does not exist. + // Not doing this will cause errors/bugs. + int cellCount = reader.ReadInt32(); + int cellCountBeforeDecrypting = reader.ReadInt32(); + int schematicID = reader.ReadInt32(); - // After doing reading, check again to see if the tile entity is actually there. - // If it isn't don't bother doing anything else. - if (!exists) - return; + // After doing reading, check again to see if the tile entity is actually there. + // If it isn't don't bother doing anything else. + if (!exists) + return; - // Furthermore, verify to ensure that the tile entity is a valid one. - if (!(tileEntity is TECodebreaker codebreakerTileEntity)) - return; + // Furthermore, verify to ensure that the tile entity is a valid one. + if (!(tileEntity is TECodebreaker codebreakerTileEntity)) + return; - codebreakerTileEntity.InputtedCellCount = cellCount; - codebreakerTileEntity.InitialCellCountBeforeDecrypting = cellCountBeforeDecrypting; - codebreakerTileEntity.HeldSchematicID = schematicID; - } + codebreakerTileEntity.InputtedCellCount = cellCount; + codebreakerTileEntity.InitialCellCountBeforeDecrypting = cellCountBeforeDecrypting; + codebreakerTileEntity.HeldSchematicID = schematicID; + } - public void SyncDecryptCountdown() - { - // Don't bother sending packets in singleplayer. - if (Main.netMode == NetmodeID.SinglePlayer) - return; + public void SyncDecryptCountdown() + { + // Don't bother sending packets in singleplayer. + if (Main.netMode == NetmodeID.SinglePlayer) + return; - ModPacket packet = mod.GetPacket(); - packet.Write((byte)CalamityModMessageType.UpdateCodebreakerDecryptCountdown); - packet.Write(ID); - packet.Write(DecryptionCountdown); - packet.Send(); - } + ModPacket packet = mod.GetPacket(); + packet.Write((byte)CalamityModMessageType.UpdateCodebreakerDecryptCountdown); + packet.Write(ID); + packet.Write(DecryptionCountdown); + packet.Send(); + } - public static void ReadDecryptCountdownSync(Mod mod, BinaryReader reader) - { - int id = reader.ReadInt32(); - bool exists = ByID.TryGetValue(id, out TileEntity tileEntity); + public static void ReadDecryptCountdownSync(Mod mod, BinaryReader reader) + { + int id = reader.ReadInt32(); + bool exists = ByID.TryGetValue(id, out TileEntity tileEntity); - // Continue reading to the end even if a tile entity with the given ID does not exist. - // Not doing this will cause errors/bugs. - int countdown = reader.ReadInt32(); + // Continue reading to the end even if a tile entity with the given ID does not exist. + // Not doing this will cause errors/bugs. + int countdown = reader.ReadInt32(); - // After doing reading, check again to see if the tile entity is actually there. - // If it isn't don't bother doing anything else. - if (!exists) - return; + // After doing reading, check again to see if the tile entity is actually there. + // If it isn't don't bother doing anything else. + if (!exists) + return; - // Furthermore, verify to ensure that the tile entity is a valid one. - if (!(tileEntity is TECodebreaker codebreakerTileEntity)) - return; + // Furthermore, verify to ensure that the tile entity is a valid one. + if (!(tileEntity is TECodebreaker codebreakerTileEntity)) + return; - codebreakerTileEntity.DecryptionCountdown = countdown; - } + codebreakerTileEntity.DecryptionCountdown = countdown; + } - public void UpdateTime() - { - if (DecryptionCountdown > 0) - { - DecryptionCountdown--; + public void UpdateTime() + { + if (DecryptionCountdown > 0) + { + DecryptionCountdown--; - // Gradually consume cells. - if (DecryptionCountdown % 5 == 0) - { - InputtedCellCount = InitialCellCountBeforeDecrypting - (int)(DecryptionCellCost * DecryptionCompletion); - if (Main.netMode != NetmodeID.MultiplayerClient) - SyncContainedStuff(); - } + // Gradually consume cells. + if (DecryptionCountdown % 5 == 0) + { + InputtedCellCount = InitialCellCountBeforeDecrypting - (int)(DecryptionCellCost * DecryptionCompletion); + if (Main.netMode != NetmodeID.MultiplayerClient) + SyncContainedStuff(); + } - if (DecryptionCountdown == 0) - { - // Reset the cell count prior to decrypting. - InitialCellCountBeforeDecrypting = 0; + if (DecryptionCountdown == 0) + { + // Reset the cell count prior to decrypting. + InitialCellCountBeforeDecrypting = 0; - LearnFromHeldSchematic(out bool anythingChanged); - if (Main.netMode == NetmodeID.Server) - { - SyncDecryptCountdown(); - SyncContainedStuff(); - } - else if (anythingChanged) - CombatText.NewText(Main.LocalPlayer.Hitbox, Color.Cyan, "You learned how to create new things!", true); - } - } - } + LearnFromHeldSchematic(out bool anythingChanged); + if (Main.netMode == NetmodeID.Server) + { + SyncDecryptCountdown(); + SyncContainedStuff(); + } + else if (anythingChanged) + CombatText.NewText(Main.LocalPlayer.Hitbox, Color.Cyan, "You learned how to create new things!", true); + } + } + } - public void LearnFromHeldSchematic(out bool anythingChanged) - { - anythingChanged = false; + public void LearnFromHeldSchematic(out bool anythingChanged) + { + anythingChanged = false; - // Do nothing if no valid schematic is inputted at the moment. - if (!CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) - return; + // Do nothing if no valid schematic is inputted at the moment. + if (!CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) + return; - int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; + int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; - if (!RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes && schematicType == ModContent.ItemType()) - { - RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes = true; - anythingChanged = true; - } - if (!RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes && schematicType == ModContent.ItemType()) - { - RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes = true; - anythingChanged = true; - } - if (!RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes && schematicType == ModContent.ItemType()) - { - RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes = true; - anythingChanged = true; - } - if (!RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes && schematicType == ModContent.ItemType()) - { - RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes = true; - anythingChanged = true; - } + if (!RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes && schematicType == ModContent.ItemType()) + { + RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes = true; + anythingChanged = true; + } + if (!RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes && schematicType == ModContent.ItemType()) + { + RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes = true; + anythingChanged = true; + } + if (!RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes && schematicType == ModContent.ItemType()) + { + RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes = true; + anythingChanged = true; + } + if (!RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes && schematicType == ModContent.ItemType()) + { + RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes = true; + anythingChanged = true; + } - if (Main.netMode == NetmodeID.Server && anythingChanged) - CalamityNetcode.SyncWorld(); - } + if (Main.netMode == NetmodeID.Server && anythingChanged) + CalamityNetcode.SyncWorld(); + } - public override TagCompound Save() - { - return new TagCompound - { - ["ContainsDecryptionComputer"] = ContainsDecryptionComputer, - ["ContainsSensorArray"] = ContainsSensorArray, - ["ContainsAdvancedDisplay"] = ContainsAdvancedDisplay, - ["ContainsVoltageRegulationSystem"] = ContainsVoltageRegulationSystem, - ["ContainsCoolingCell"] = ContainsCoolingCell, - ["InputtedCellCount"] = InputtedCellCount, - ["HeldSchematicID"] = HeldSchematicID, - ["DecryptionCountdown"] = DecryptionCountdown, - ["InitialCellCountBeforeDecrypting"] = InitialCellCountBeforeDecrypting - }; - } + public override TagCompound Save() + { + return new TagCompound + { + ["ContainsDecryptionComputer"] = ContainsDecryptionComputer, + ["ContainsSensorArray"] = ContainsSensorArray, + ["ContainsAdvancedDisplay"] = ContainsAdvancedDisplay, + ["ContainsVoltageRegulationSystem"] = ContainsVoltageRegulationSystem, + ["ContainsCoolingCell"] = ContainsCoolingCell, + ["InputtedCellCount"] = InputtedCellCount, + ["HeldSchematicID"] = HeldSchematicID, + ["DecryptionCountdown"] = DecryptionCountdown, + ["InitialCellCountBeforeDecrypting"] = InitialCellCountBeforeDecrypting + }; + } - public override void Load(TagCompound tag) - { - ContainsDecryptionComputer = tag.GetBool("ContainsDecryptionComputer"); - ContainsSensorArray = tag.GetBool("ContainsSensorArray"); - ContainsAdvancedDisplay = tag.GetBool("ContainsAdvancedDisplay"); - ContainsVoltageRegulationSystem = tag.GetBool("ContainsVoltageRegulationSystem"); - ContainsCoolingCell = tag.GetBool("ContainsCoolingCell"); - InputtedCellCount = tag.GetInt("InputtedCellCount"); - HeldSchematicID = tag.GetInt("HeldSchematicID"); - DecryptionCountdown = tag.GetInt("DecryptionCountdown"); - InitialCellCountBeforeDecrypting = tag.GetInt("InitialCellCountBeforeDecrypting"); - } + public override void Load(TagCompound tag) + { + ContainsDecryptionComputer = tag.GetBool("ContainsDecryptionComputer"); + ContainsSensorArray = tag.GetBool("ContainsSensorArray"); + ContainsAdvancedDisplay = tag.GetBool("ContainsAdvancedDisplay"); + ContainsVoltageRegulationSystem = tag.GetBool("ContainsVoltageRegulationSystem"); + ContainsCoolingCell = tag.GetBool("ContainsCoolingCell"); + InputtedCellCount = tag.GetInt("InputtedCellCount"); + HeldSchematicID = tag.GetInt("HeldSchematicID"); + DecryptionCountdown = tag.GetInt("DecryptionCountdown"); + InitialCellCountBeforeDecrypting = tag.GetInt("InitialCellCountBeforeDecrypting"); + } - public override void NetSend(BinaryWriter writer, bool lightSend) - { - writer.Write(ContainsDecryptionComputer); - writer.Write(ContainsSensorArray); - writer.Write(ContainsAdvancedDisplay); - writer.Write(ContainsVoltageRegulationSystem); - writer.Write(ContainsCoolingCell); - writer.Write(InputtedCellCount); - writer.Write(HeldSchematicID); - writer.Write(DecryptionCountdown); - writer.Write(InitialCellCountBeforeDecrypting); - } + public override void NetSend(BinaryWriter writer, bool lightSend) + { + writer.Write(ContainsDecryptionComputer); + writer.Write(ContainsSensorArray); + writer.Write(ContainsAdvancedDisplay); + writer.Write(ContainsVoltageRegulationSystem); + writer.Write(ContainsCoolingCell); + writer.Write(InputtedCellCount); + writer.Write(HeldSchematicID); + writer.Write(DecryptionCountdown); + writer.Write(InitialCellCountBeforeDecrypting); + } - public override void NetReceive(BinaryReader reader, bool lightReceive) - { - ContainsDecryptionComputer = reader.ReadBoolean(); - ContainsSensorArray = reader.ReadBoolean(); - ContainsAdvancedDisplay = reader.ReadBoolean(); - ContainsVoltageRegulationSystem = reader.ReadBoolean(); - ContainsCoolingCell = reader.ReadBoolean(); - InputtedCellCount = reader.ReadInt32(); - HeldSchematicID = reader.ReadInt32(); - DecryptionCountdown = reader.ReadInt32(); - InitialCellCountBeforeDecrypting = reader.ReadInt32(); - } - } + public override void NetReceive(BinaryReader reader, bool lightReceive) + { + ContainsDecryptionComputer = reader.ReadBoolean(); + ContainsSensorArray = reader.ReadBoolean(); + ContainsAdvancedDisplay = reader.ReadBoolean(); + ContainsVoltageRegulationSystem = reader.ReadBoolean(); + ContainsCoolingCell = reader.ReadBoolean(); + InputtedCellCount = reader.ReadInt32(); + HeldSchematicID = reader.ReadInt32(); + DecryptionCountdown = reader.ReadInt32(); + InitialCellCountBeforeDecrypting = reader.ReadInt32(); + } + } } diff --git a/TileEntities/TEDraedonLabTurret.cs b/TileEntities/TEDraedonLabTurret.cs index abf7241696..937c459d73 100644 --- a/TileEntities/TEDraedonLabTurret.cs +++ b/TileEntities/TEDraedonLabTurret.cs @@ -7,131 +7,131 @@ using Terraria.ModLoader; namespace CalamityMod.TileEntities { - public class TEDraedonLabTurret : TEBaseTurret - { - // Tile which hosts this tile entity - public override int TileType => ModContent.TileType(); - public override int HostTileWidth => DraedonLabTurret.Width; - public override int HostTileHeight => DraedonLabTurret.Height; + public class TEDraedonLabTurret : TEBaseTurret + { + // Tile which hosts this tile entity + public override int TileType => ModContent.TileType(); + public override int HostTileWidth => DraedonLabTurret.Width; + public override int HostTileHeight => DraedonLabTurret.Height; - // Projectile variables - public override int ProjectileType => ModContent.ProjectileType(); - public override int ProjectileDamage => Main.expertMode ? 14 : 20; - public override float ProjectileKnockback => 6.5f; - public override float ShootSpeed => 5f; - public override int FiringStartupDelay => 10; - public override int FiringUseTime => 20; + // Projectile variables + public override int ProjectileType => ModContent.ProjectileType(); + public override int ProjectileDamage => Main.expertMode ? 14 : 20; + public override float ProjectileKnockback => 6.5f; + public override float ShootSpeed => 5f; + public override int FiringStartupDelay => 10; + public override int FiringUseTime => 20; - // Projectile spawn location variables - public override Vector2 TurretCenterOffset => new Vector2(22f + 4f * Direction, -2f); - protected override float ShootForwardsOffset => 6f; + // Projectile spawn location variables + public override Vector2 TurretCenterOffset => new Vector2(22f + 4f * Direction, -2f); + protected override float ShootForwardsOffset => 6f; - // Targeting variables - public override float MaxRange => 600f; - protected override float MaxTargetAngleDeviance => MathHelper.ToRadians(12f); - protected override float MaxDeltaAnglePerFrame => MathHelper.ToRadians(2f); - protected override float CloseAimThreshold => MathHelper.ToRadians(12f); - protected override float CloseAimLerpFactor => 0.08f; + // Targeting variables + public override float MaxRange => 600f; + protected override float MaxTargetAngleDeviance => MathHelper.ToRadians(12f); + protected override float MaxDeltaAnglePerFrame => MathHelper.ToRadians(2f); + protected override float CloseAimThreshold => MathHelper.ToRadians(12f); + protected override float CloseAimLerpFactor => 0.08f; - // Variables specific to this turret subclass - private int _playerTargetIndex = -1; - public int PlayerTargetIndex - { - get => _playerTargetIndex; - set - { - bool sync = _playerTargetIndex != value; - _playerTargetIndex = value; - if (sync) - SendSyncPacket(); - } - } + // Variables specific to this turret subclass + private int _playerTargetIndex = -1; + public int PlayerTargetIndex + { + get => _playerTargetIndex; + set + { + bool sync = _playerTargetIndex != value; + _playerTargetIndex = value; + if (sync) + SendSyncPacket(); + } + } - // Lab turrets specifically must be placed on the top left corner of their host tile. - // This restriction is not shared by general turrets for flexibility reasons. - public override bool ValidTile(int i, int j) - { - Tile tile = Main.tile[i, j]; - return tile.active() && tile.type == TileType && tile.frameX == 0 && tile.frameY == 0; - } + // Lab turrets specifically must be placed on the top left corner of their host tile. + // This restriction is not shared by general turrets for flexibility reasons. + public override bool ValidTile(int i, int j) + { + Tile tile = Main.tile[i, j]; + return tile.active() && tile.type == TileType && tile.frameX == 0 && tile.frameY == 0; + } - protected override Vector2 ChooseTarget(Vector2 targetingCenter) - { - // Store the value that will be set into PlayerTargetIndex here. - // This local is used because changing the actual field will trigger a netcode auto-sync. - int indexToSet = PlayerTargetIndex; - - // If a player is already targeted, make sure they still exist and aren't dead. - if (indexToSet != -1) - { - Player p = Main.player[PlayerTargetIndex]; + protected override Vector2 ChooseTarget(Vector2 targetingCenter) + { + // Store the value that will be set into PlayerTargetIndex here. + // This local is used because changing the actual field will trigger a netcode auto-sync. + int indexToSet = PlayerTargetIndex; + + // If a player is already targeted, make sure they still exist and aren't dead. + if (indexToSet != -1) + { + Player p = Main.player[PlayerTargetIndex]; - // If they don't exist, or are dead, then unmark them as a target and search for a new one. - if (!p.active || p.dead) - indexToSet = -1; - else - { - // If the existing target player is close enough, return their position. Otherwise unmark them as a target. - Vector2 playerPos = p.Center; - float distSQ = Vector2.DistanceSquared(targetingCenter, playerPos); - if (distSQ <= MaxRange * MaxRange) - return playerPos; - else - indexToSet = -1; - } - } + // If they don't exist, or are dead, then unmark them as a target and search for a new one. + if (!p.active || p.dead) + indexToSet = -1; + else + { + // If the existing target player is close enough, return their position. Otherwise unmark them as a target. + Vector2 playerPos = p.Center; + float distSQ = Vector2.DistanceSquared(targetingCenter, playerPos); + if (distSQ <= MaxRange * MaxRange) + return playerPos; + else + indexToSet = -1; + } + } - // No valid target currently exists. Loop through players (efficiently!) to look for the closest new target. - Vector2 ret = InvalidTarget; - float distSQToBeat = MaxRange * MaxRange; + // No valid target currently exists. Loop through players (efficiently!) to look for the closest new target. + Vector2 ret = InvalidTarget; + float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxPlayers; ++i) - { - Player p = Main.player[i]; - if (!p.active || p.dead) - continue; + for (int i = 0; i < Main.maxPlayers; ++i) + { + Player p = Main.player[i]; + if (!p.active || p.dead) + continue; - float distSQ = p.DistanceSQ(targetingCenter); - if (distSQ < distSQToBeat) - { - distSQToBeat = distSQ; - ret = p.Center; - indexToSet = i; - } - } + float distSQ = p.DistanceSQ(targetingCenter); + if (distSQ < distSQToBeat) + { + distSQToBeat = distSQ; + ret = p.Center; + indexToSet = i; + } + } - // Set PlayerTargetIndex now that we're sure what we're targeting. This triggers a netcode sync if the value is different. - PlayerTargetIndex = indexToSet; - return ret; - } + // Set PlayerTargetIndex now that we're sure what we're targeting. This triggers a netcode sync if the value is different. + PlayerTargetIndex = indexToSet; + return ret; + } - // Makes turrets track their targeted player correctly client side. - // This doesn't improve their actual accuracy, because they only fire server side. - // However, it makes them rotate much more smoothly. - // Any targeting and rotation data derived from this update will be overridden by the turret's next sync. - public override void UpdateClient() - { - if (PlayerTargetIndex != -1) - { - Player p = Main.player[PlayerTargetIndex]; - if (p.active && !p.dead) - TargetPos = p.Center; - } - } + // Makes turrets track their targeted player correctly client side. + // This doesn't improve their actual accuracy, because they only fire server side. + // However, it makes them rotate much more smoothly. + // Any targeting and rotation data derived from this update will be overridden by the turret's next sync. + public override void UpdateClient() + { + if (PlayerTargetIndex != -1) + { + Player p = Main.player[PlayerTargetIndex]; + if (p.active && !p.dead) + TargetPos = p.Center; + } + } - // This type of turret syncs extra data: its player target index. - // This only takes 2 bytes so a junk array is written for the remainder of the space. - private const int BytesUsed = 2; - private static readonly byte[] JunkData = new byte[] { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA }; - protected override void WriteExtraData(BinaryWriter writer) - { - writer.Write((short)_playerTargetIndex); - writer.Write(JunkData); - } - protected override void ReadExtraData(Mod mod, BinaryReader reader) - { - _playerTargetIndex = reader.ReadInt16(); - _ = reader.ReadBytes(NumExtraBytes - BytesUsed); - } - } + // This type of turret syncs extra data: its player target index. + // This only takes 2 bytes so a junk array is written for the remainder of the space. + private const int BytesUsed = 2; + private static readonly byte[] JunkData = new byte[] { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA }; + protected override void WriteExtraData(BinaryWriter writer) + { + writer.Write((short)_playerTargetIndex); + writer.Write(JunkData); + } + protected override void ReadExtraData(Mod mod, BinaryReader reader) + { + _playerTargetIndex = reader.ReadInt16(); + _ = reader.ReadBytes(NumExtraBytes - BytesUsed); + } + } } diff --git a/TileEntities/TEPowerCellFactory.cs b/TileEntities/TEPowerCellFactory.cs index 64517e90d9..535c42e84c 100644 --- a/TileEntities/TEPowerCellFactory.cs +++ b/TileEntities/TEPowerCellFactory.cs @@ -12,180 +12,180 @@ using CalamityMod.Items.DraedonMisc; namespace CalamityMod.TileEntities { - public class TEPowerCellFactory : ModTileEntity - { - public Vector2 Center => Position.ToWorldCoordinates(8f * PowerCellFactory.Width, 8f * PowerCellFactory.Height); - public long Time = 0; - private short _stack = 0; + public class TEPowerCellFactory : ModTileEntity + { + public Vector2 Center => Position.ToWorldCoordinates(8f * PowerCellFactory.Width, 8f * PowerCellFactory.Height); + public long Time = 0; + private short _stack = 0; - public short CellStack - { - get => _stack; - set - { - _stack = value; - SendSyncPacket(); - } - } + public short CellStack + { + get => _stack; + set + { + _stack = value; + SendSyncPacket(); + } + } - private long CycleFrameCounter - { - get - { - long totalCycleTime = PowerCellFactory.BetweenCellDowntime + PowerCellFactory.TotalFrames * PowerCellFactory.AnimationFramerate; - return Time % totalCycleTime; - } - } - - private bool IsCellFrame - { - get - { - long magicFrame = PowerCellFactory.BetweenCellDowntime + PowerCellFactory.CellCreateFrame * PowerCellFactory.AnimationFramerate + PowerCellFactory.MagicFrameDelay; - return CycleFrameCounter == magicFrame; - } - } + private long CycleFrameCounter + { + get + { + long totalCycleTime = PowerCellFactory.BetweenCellDowntime + PowerCellFactory.TotalFrames * PowerCellFactory.AnimationFramerate; + return Time % totalCycleTime; + } + } + + private bool IsCellFrame + { + get + { + long magicFrame = PowerCellFactory.BetweenCellDowntime + PowerCellFactory.CellCreateFrame * PowerCellFactory.AnimationFramerate + PowerCellFactory.MagicFrameDelay; + return CycleFrameCounter == magicFrame; + } + } - // Property which allows anyone to get the current animation frame of this specific factory. - public int AnimationFrame - { - get - { - int f = (int)CycleFrameCounter; + // Property which allows anyone to get the current animation frame of this specific factory. + public int AnimationFrame + { + get + { + int f = (int)CycleFrameCounter; - // The animation sticks on the last frame throughout the entire downtime period. - if (f < PowerCellFactory.BetweenCellDowntime) - return PowerCellFactory.TotalFrames - 1; + // The animation sticks on the last frame throughout the entire downtime period. + if (f < PowerCellFactory.BetweenCellDowntime) + return PowerCellFactory.TotalFrames - 1; - // Remove the starting downtime period for the framerate divisor calculation. - return (f - PowerCellFactory.BetweenCellDowntime) / PowerCellFactory.AnimationFramerate; - } - } + // Remove the starting downtime period for the framerate divisor calculation. + return (f - PowerCellFactory.BetweenCellDowntime) / PowerCellFactory.AnimationFramerate; + } + } - // This guarantees that this tile entity will not persist if not placed directly on the top left corner of a Power Cell Factory tile. - public override bool ValidTile(int i, int j) - { - Tile tile = Main.tile[i, j]; - return tile.active() && tile.type == ModContent.TileType() && tile.frameX == 0 && tile.frameY == 0; - } + // This guarantees that this tile entity will not persist if not placed directly on the top left corner of a Power Cell Factory tile. + public override bool ValidTile(int i, int j) + { + Tile tile = Main.tile[i, j]; + return tile.active() && tile.type == ModContent.TileType() && tile.frameX == 0 && tile.frameY == 0; + } - public override void Update() - { - ++Time; - int maxCellStack = ModContent.GetModItem(ModContent.ItemType()).item.maxStack; - if (IsCellFrame && CellStack < maxCellStack) - // The property setter will automatically send the necessary packet. - CellStack++; - } + public override void Update() + { + ++Time; + int maxCellStack = ModContent.GetModItem(ModContent.ItemType()).item.maxStack; + if (IsCellFrame && CellStack < maxCellStack) + // The property setter will automatically send the necessary packet. + CellStack++; + } - // This code is called as a hook when the player places the Power Cell Factory tile so that the tile entity may be placed. - public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction) - { - // If in multiplayer, tell the server to place the tile entity and DO NOT place it yourself. That would mismatch IDs. - // Also tell the server that you placed the 4x4 tiles that make up the Power Cell Factory. - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendTileRange(Main.myPlayer, i, j, PowerCellFactory.Width, PowerCellFactory.Height); - NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type); - return -1; - } + // This code is called as a hook when the player places the Power Cell Factory tile so that the tile entity may be placed. + public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction) + { + // If in multiplayer, tell the server to place the tile entity and DO NOT place it yourself. That would mismatch IDs. + // Also tell the server that you placed the 4x4 tiles that make up the Power Cell Factory. + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileRange(Main.myPlayer, i, j, PowerCellFactory.Width, PowerCellFactory.Height); + NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type); + return -1; + } - // If in single player, just place the tile entity, no problems. - int id = Place(i, j); - return id; - } + // If in single player, just place the tile entity, no problems. + int id = Place(i, j); + return id; + } - // This code is called on dedicated servers only. It is the server-side response to MessageID.TileEntityPlacement. - // When the server receives such a message from a client, it sends a MessageID.TileEntitySharing to all clients. - // This will cause them to Place the tile entity locally at that position, all with exactly the same ID. - public override void OnNetPlace() => NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, ID, Position.X, Position.Y); + // This code is called on dedicated servers only. It is the server-side response to MessageID.TileEntityPlacement. + // When the server receives such a message from a client, it sends a MessageID.TileEntitySharing to all clients. + // This will cause them to Place the tile entity locally at that position, all with exactly the same ID. + public override void OnNetPlace() => NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, ID, Position.X, Position.Y); - // If this factory breaks, anyone who's viewing it is no longer viewing it. - public override void OnKill() - { - for (int i = 0; i < Main.maxPlayers; ++i) - { - Player p = Main.player[i]; - if (!p.active) - continue; + // If this factory breaks, anyone who's viewing it is no longer viewing it. + public override void OnKill() + { + for (int i = 0; i < Main.maxPlayers; ++i) + { + Player p = Main.player[i]; + if (!p.active) + continue; - // Use reflection to stop TML from spitting an error here. - // Try-catching will not stop this error, TML will print it to console anyway. The error is harmless. - ModPlayer[] mpStorageArray = (ModPlayer[])typeof(Player).GetField("modPlayers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(p); - if (mpStorageArray.Length == 0) - continue; + // Use reflection to stop TML from spitting an error here. + // Try-catching will not stop this error, TML will print it to console anyway. The error is harmless. + ModPlayer[] mpStorageArray = (ModPlayer[])typeof(Player).GetField("modPlayers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(p); + if (mpStorageArray.Length == 0) + continue; - CalamityPlayer mp = p.Calamity(); - if (mp.CurrentlyViewedFactoryID == ID) - mp.CurrentlyViewedFactoryID = -1; - } - } + CalamityPlayer mp = p.Calamity(); + if (mp.CurrentlyViewedFactoryID == ID) + mp.CurrentlyViewedFactoryID = -1; + } + } - public override TagCompound Save() => new TagCompound - { - { "time", Time }, - { "cells", _stack } - }; + public override TagCompound Save() => new TagCompound + { + { "time", Time }, + { "cells", _stack } + }; - public override void Load(TagCompound tag) - { - Time = tag.GetLong("time"); - _stack = tag.GetShort("cells"); - } + public override void Load(TagCompound tag) + { + Time = tag.GetLong("time"); + _stack = tag.GetShort("cells"); + } - public override void NetSend(BinaryWriter writer, bool lightSend) - { - writer.Write(Time); - writer.Write(_stack); - } + public override void NetSend(BinaryWriter writer, bool lightSend) + { + writer.Write(Time); + writer.Write(_stack); + } - public override void NetReceive(BinaryReader reader, bool lightReceive) - { - Time = reader.ReadInt64(); - _stack = reader.ReadInt16(); - } + public override void NetReceive(BinaryReader reader, bool lightReceive) + { + Time = reader.ReadInt64(); + _stack = reader.ReadInt16(); + } - private void SendSyncPacket() - { - if (Main.netMode == NetmodeID.SinglePlayer) - return; - ModPacket packet = mod.GetPacket(); - packet.Write((byte)CalamityModMessageType.PowerCellFactory); - packet.Write(ID); - packet.Write(Time); - packet.Write(_stack); - packet.Send(-1, -1); - } + private void SendSyncPacket() + { + if (Main.netMode == NetmodeID.SinglePlayer) + return; + ModPacket packet = mod.GetPacket(); + packet.Write((byte)CalamityModMessageType.PowerCellFactory); + packet.Write(ID); + packet.Write(Time); + packet.Write(_stack); + packet.Send(-1, -1); + } - internal static bool ReadSyncPacket(Mod mod, BinaryReader reader) - { - int teID = reader.ReadInt32(); - bool exists = ByID.TryGetValue(teID, out TileEntity te); + internal static bool ReadSyncPacket(Mod mod, BinaryReader reader) + { + int teID = reader.ReadInt32(); + bool exists = ByID.TryGetValue(teID, out TileEntity te); - // The rest of the packet must be read even if it turns out the factory doesn't exist for whatever reason. - long time = reader.ReadInt64(); - short cellStack = reader.ReadInt16(); + // The rest of the packet must be read even if it turns out the factory doesn't exist for whatever reason. + long time = reader.ReadInt64(); + short cellStack = reader.ReadInt16(); - // When a server gets this packet, it immediately sends an equivalent packet to all clients. - if (Main.netMode == NetmodeID.Server) - { - ModPacket packet = mod.GetPacket(); - packet.Write((byte)CalamityModMessageType.PowerCellFactory); - packet.Write(teID); - packet.Write(time); - packet.Write(cellStack); - packet.Send(-1, -1); - } + // When a server gets this packet, it immediately sends an equivalent packet to all clients. + if (Main.netMode == NetmodeID.Server) + { + ModPacket packet = mod.GetPacket(); + packet.Write((byte)CalamityModMessageType.PowerCellFactory); + packet.Write(teID); + packet.Write(time); + packet.Write(cellStack); + packet.Send(-1, -1); + } - if (exists && te is TEPowerCellFactory factory) - { - // Only clients update their timer from this packet. When a server receives this packet it ignores the time variable. - if (Main.netMode == NetmodeID.MultiplayerClient) - factory.Time = time; - factory._stack = cellStack; - return true; - } - return false; - } - } + if (exists && te is TEPowerCellFactory factory) + { + // Only clients update their timer from this packet. When a server receives this packet it ignores the time variable. + if (Main.netMode == NetmodeID.MultiplayerClient) + factory.Time = time; + factory._stack = cellStack; + return true; + } + return false; + } + } } diff --git a/TileEntities/TileEntityTimeHandler.cs b/TileEntities/TileEntityTimeHandler.cs index ce1a3d33f5..255de4a5e8 100644 --- a/TileEntities/TileEntityTimeHandler.cs +++ b/TileEntities/TileEntityTimeHandler.cs @@ -5,65 +5,65 @@ using Terraria.ModLoader; namespace CalamityMod.TileEntities { - public static class TileEntityTimeHandler - { - public static void Update() - { - MultiplayerClientUpdateVisuals(); - } - private static void MultiplayerClientUpdateVisuals() - { - if (Main.netMode != NetmodeID.MultiplayerClient) - return; + public static class TileEntityTimeHandler + { + public static void Update() + { + MultiplayerClientUpdateVisuals(); + } + private static void MultiplayerClientUpdateVisuals() + { + if (Main.netMode != NetmodeID.MultiplayerClient) + return; - byte factoryType = ModContent.GetInstance().type; - byte chargerType = ModContent.GetInstance().type; - byte codebreakerType = ModContent.GetInstance().type; + byte factoryType = ModContent.GetInstance().type; + byte chargerType = ModContent.GetInstance().type; + byte codebreakerType = ModContent.GetInstance().type; - var enumerator = TileEntity.ByID.Values.GetEnumerator(); - do - { - TileEntity te = enumerator.Current; - if (te == null) - continue; + var enumerator = TileEntity.ByID.Values.GetEnumerator(); + do + { + TileEntity te = enumerator.Current; + if (te == null) + continue; - if (te.type == factoryType) - { - // Specifically on multiplayer clients, manually update the time variables of Power Cell Factories every frame. - // This makes sure they animate. It will NOT produce cells; that code can only run server side. - // Time is manually synced from the server every time a cell is created, so even under heavy lag they cannot stay desynced indefinitely. - TEPowerCellFactory factory = (TEPowerCellFactory)te; - ++factory.Time; - } - else if (te.type == chargerType) - { - // Specifically on multiplayer clients, produce charging dust when the "should dust" flag is set by the most recent sync packet. - // This makes sure they produce charging dust for all clients. It will NOT actually charge items; that code can only run server side. - TEChargingStation charger = (TEChargingStation)te; + if (te.type == factoryType) + { + // Specifically on multiplayer clients, manually update the time variables of Power Cell Factories every frame. + // This makes sure they animate. It will NOT produce cells; that code can only run server side. + // Time is manually synced from the server every time a cell is created, so even under heavy lag they cannot stay desynced indefinitely. + TEPowerCellFactory factory = (TEPowerCellFactory)te; + ++factory.Time; + } + else if (te.type == chargerType) + { + // Specifically on multiplayer clients, produce charging dust when the "should dust" flag is set by the most recent sync packet. + // This makes sure they produce charging dust for all clients. It will NOT actually charge items; that code can only run server side. + TEChargingStation charger = (TEChargingStation)te; - if (charger.ClientChargingDust && charger.CanDoWork) - { - charger.ClientChargingDust = false; - charger.SpawnChargingDust(); - } - } - else if (te is TEBaseTurret turret) - { - // Perform any client-specific update tasks for this turret. - turret.UpdateClient(); - - // Specifically on multiplayer clients, manually update the turret's rotation every frame. This is exactly the same code run server side. - // This makes sure they visually track targets in multiplayer. It will NOT fire projectiles; that code can only run server side. - turret.UpdateAngle(); - } - else if (te.type == codebreakerType) - { - // Specifically on multiplayer clients, manually update the time variables of the Codebreaker every frame. - // This is done so that clients can accurately gauge how complete decryptions are. - TECodebreaker codebreaker = (TECodebreaker)te; - codebreaker.UpdateTime(); - } - } while (enumerator.MoveNext()); - } - } + if (charger.ClientChargingDust && charger.CanDoWork) + { + charger.ClientChargingDust = false; + charger.SpawnChargingDust(); + } + } + else if (te is TEBaseTurret turret) + { + // Perform any client-specific update tasks for this turret. + turret.UpdateClient(); + + // Specifically on multiplayer clients, manually update the turret's rotation every frame. This is exactly the same code run server side. + // This makes sure they visually track targets in multiplayer. It will NOT fire projectiles; that code can only run server side. + turret.UpdateAngle(); + } + else if (te.type == codebreakerType) + { + // Specifically on multiplayer clients, manually update the time variables of the Codebreaker every frame. + // This is done so that clients can accurately gauge how complete decryptions are. + TECodebreaker codebreaker = (TECodebreaker)te; + codebreaker.UpdateTime(); + } + } while (enumerator.MoveNext()); + } + } } diff --git a/Tiles/Abyss/AbyssalCrateTile.cs b/Tiles/Abyss/AbyssalCrateTile.cs index 95f8ae7797..6f0cd81ce7 100644 --- a/Tiles/Abyss/AbyssalCrateTile.cs +++ b/Tiles/Abyss/AbyssalCrateTile.cs @@ -6,7 +6,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Abyss { - public class AbyssalCrateTile : ModTile + public class AbyssalCrateTile : ModTile { public override void SetDefaults() { diff --git a/Tiles/Abyss/AbyssalPots.cs b/Tiles/Abyss/AbyssalPots.cs index 20f6fcbcd1..343d020e19 100644 --- a/Tiles/Abyss/AbyssalPots.cs +++ b/Tiles/Abyss/AbyssalPots.cs @@ -6,42 +6,42 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Abyss { - public class AbyssalPots : ModTile - { - public override void SetDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = false; - Main.tileValue[Type] = (short)100; - Main.tileSpelunker[Type] = true; - Main.tileCut[Type] = true; + public class AbyssalPots : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + Main.tileValue[Type] = (short)100; + Main.tileSpelunker[Type] = true; + Main.tileCut[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.addTile(Type); - ModTranslation name = CreateMapEntryName(); - name.SetDefault("Pot"); - AddMapEntry(new Color(47, 79, 79), name); //dark slate gray - dustType = 29; - soundType = SoundID.Shatter; - } + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.addTile(Type); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Pot"); + AddMapEntry(new Color(47, 79, 79), name); //dark slate gray + dustType = 29; + soundType = SoundID.Shatter; + } - public override bool CreateDust(int i, int j, ref int type) - { - if (Main.rand.NextBool(2)) - { - type = 29; - } - else - { - type = 186; - } - return true; - } + public override bool CreateDust(int i, int j, ref int type) + { + if (Main.rand.NextBool(2)) + { + type = 29; + } + else + { + type = 186; + } + return true; + } - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } } diff --git a/Tiles/Abyss/AcidWoodTreeSapling.cs b/Tiles/Abyss/AcidWoodTreeSapling.cs index f3470f4e33..5b11e68f0b 100644 --- a/Tiles/Abyss/AcidWoodTreeSapling.cs +++ b/Tiles/Abyss/AcidWoodTreeSapling.cs @@ -53,69 +53,69 @@ namespace CalamityMod.Tiles.Abyss { if (WorldGen.genRand.Next(20) == 0) { - int trueStartingPositionY = j; - while (TileLoader.IsSapling((int)Main.tile[i, trueStartingPositionY].type)) - { - trueStartingPositionY++; - } - Tile tileAtPosition = Main.tile[i, trueStartingPositionY]; - Tile tileAbovePosition = Main.tile[i, trueStartingPositionY - 1]; - if (!tileAtPosition.active() || tileAtPosition.halfBrick() || tileAtPosition.slope() != 0) - { - return; - } - if (tileAbovePosition.wall != 0 || tileAbovePosition.liquid != 0) - { - return; - } - if (!WorldGen.EmptyTileCheck(i - 1, i + 1, trueStartingPositionY - 30, trueStartingPositionY - 1, 20)) - { - return; - } - int treeHeight = WorldGen.genRand.Next(10, 21); - int frameYIdeal = WorldGen.genRand.Next(-8, 9); - frameYIdeal *= 2; - short frameY = 0; - for (int k = 0; k < treeHeight; k++) - { - tileAtPosition = Main.tile[i, trueStartingPositionY - 1 - k]; - if (k == 0) - { - tileAtPosition.active(true); - tileAtPosition.type = TileID.PalmTree; - tileAtPosition.frameX = 66; - tileAtPosition.frameY = 0; - } - else if (k == treeHeight - 1) - { - tileAtPosition.active(true); - tileAtPosition.type = TileID.PalmTree; - tileAtPosition.frameX = (short)(22 * WorldGen.genRand.Next(4, 7)); - tileAtPosition.frameY = frameY; - } - else - { - if (frameY != frameYIdeal) - { - float heightRatio = k / (float)treeHeight; - bool increaseFrameY = heightRatio >= 0.25f && ((heightRatio < 0.5f && WorldGen.genRand.Next(13) == 0) || (heightRatio < 0.7f && WorldGen.genRand.Next(9) == 0) || heightRatio >= 0.95f || WorldGen.genRand.Next(5) != 0 || true); - if (increaseFrameY) - { - frameY += (short)(Math.Sign(frameYIdeal) * 2); - } - } - tileAtPosition.active(true); - tileAtPosition.type = TileID.PalmTree; - tileAtPosition.frameX = (short)(22 * WorldGen.genRand.Next(0, 3)); - tileAtPosition.frameY = frameY; - } - } - bool isPlayerNear = WorldGen.PlayerLOS(i, j); - WorldGen.RangeFrame(i - 2, trueStartingPositionY - treeHeight - 1, i + 2, trueStartingPositionY + 1); - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendTileSquare(-1, i, (int)((double)trueStartingPositionY - (double)treeHeight * 0.5), treeHeight + 1, TileChangeType.None); - } + int trueStartingPositionY = j; + while (TileLoader.IsSapling((int)Main.tile[i, trueStartingPositionY].type)) + { + trueStartingPositionY++; + } + Tile tileAtPosition = Main.tile[i, trueStartingPositionY]; + Tile tileAbovePosition = Main.tile[i, trueStartingPositionY - 1]; + if (!tileAtPosition.active() || tileAtPosition.halfBrick() || tileAtPosition.slope() != 0) + { + return; + } + if (tileAbovePosition.wall != 0 || tileAbovePosition.liquid != 0) + { + return; + } + if (!WorldGen.EmptyTileCheck(i - 1, i + 1, trueStartingPositionY - 30, trueStartingPositionY - 1, 20)) + { + return; + } + int treeHeight = WorldGen.genRand.Next(10, 21); + int frameYIdeal = WorldGen.genRand.Next(-8, 9); + frameYIdeal *= 2; + short frameY = 0; + for (int k = 0; k < treeHeight; k++) + { + tileAtPosition = Main.tile[i, trueStartingPositionY - 1 - k]; + if (k == 0) + { + tileAtPosition.active(true); + tileAtPosition.type = TileID.PalmTree; + tileAtPosition.frameX = 66; + tileAtPosition.frameY = 0; + } + else if (k == treeHeight - 1) + { + tileAtPosition.active(true); + tileAtPosition.type = TileID.PalmTree; + tileAtPosition.frameX = (short)(22 * WorldGen.genRand.Next(4, 7)); + tileAtPosition.frameY = frameY; + } + else + { + if (frameY != frameYIdeal) + { + float heightRatio = k / (float)treeHeight; + bool increaseFrameY = heightRatio >= 0.25f && ((heightRatio < 0.5f && WorldGen.genRand.Next(13) == 0) || (heightRatio < 0.7f && WorldGen.genRand.Next(9) == 0) || heightRatio >= 0.95f || WorldGen.genRand.Next(5) != 0 || true); + if (increaseFrameY) + { + frameY += (short)(Math.Sign(frameYIdeal) * 2); + } + } + tileAtPosition.active(true); + tileAtPosition.type = TileID.PalmTree; + tileAtPosition.frameX = (short)(22 * WorldGen.genRand.Next(0, 3)); + tileAtPosition.frameY = frameY; + } + } + bool isPlayerNear = WorldGen.PlayerLOS(i, j); + WorldGen.RangeFrame(i - 2, trueStartingPositionY - treeHeight - 1, i + 2, trueStartingPositionY + 1); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, i, (int)((double)trueStartingPositionY - (double)treeHeight * 0.5), treeHeight + 1, TileChangeType.None); + } if (isPlayerNear) { WorldGen.TreeGrowFXCheck(i, j); diff --git a/Tiles/Abyss/SteamGeyser.cs b/Tiles/Abyss/SteamGeyser.cs index 4076a5362a..5838c8ccb7 100644 --- a/Tiles/Abyss/SteamGeyser.cs +++ b/Tiles/Abyss/SteamGeyser.cs @@ -8,44 +8,44 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Abyss { - public class SteamGeyser : ModTile - { - public override void SetDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.DrawYOffset = 4; - TileObjectData.addTile(Type); - ModTranslation name = CreateMapEntryName(); - name.SetDefault("Geyser"); - AddMapEntry(new Color(150, 100, 50), name); - dustType = (int)CalamityDusts.SulfurousSeaAcid; + public class SteamGeyser : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 4; + TileObjectData.addTile(Type); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Geyser"); + AddMapEntry(new Color(150, 100, 50), name); + dustType = (int)CalamityDusts.SulfurousSeaAcid; - base.SetDefaults(); - } + base.SetDefaults(); + } - public override bool Dangersense(int i, int j, Player player) => true; + public override bool Dangersense(int i, int j, Player player) => true; - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 2; - } - public override void NearbyEffects(int i, int j, bool closer) - { - bool noTilesBetweenPlayer = Collision.CanHit(new Vector2(i, j) * 16, 1, 1, new Vector2(i * 16f, Main.LocalPlayer.Center.Y), 1, 1); + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 2; + } + public override void NearbyEffects(int i, int j, bool closer) + { + bool noTilesBetweenPlayer = Collision.CanHit(new Vector2(i, j) * 16, 1, 1, new Vector2(i * 16f, Main.LocalPlayer.Center.Y), 1, 1); - if (WorldGen.genRand.NextBool(60) && !Main.gamePaused && noTilesBetweenPlayer) - { - if (Math.Abs(Main.LocalPlayer.Center.X - i * 16) < 80 && - Main.LocalPlayer.Bottom.Y < j * 16 && - Main.LocalPlayer.Bottom.Y > j * 16 - 300) - { - float yeetSpeed = MathHelper.Clamp(10f - (10f * Math.Abs(Main.LocalPlayer.Bottom.Y - j * 16) / 300f), 0f, 10f); - Main.LocalPlayer.velocity.Y -= yeetSpeed; - Projectile.NewProjectile(i * 16 + 8, j * 16 - 20, 0f, -10f, ModContent.ProjectileType(), Main.expertMode ? 12 : 15, 0f); - } - } - } - } + if (WorldGen.genRand.NextBool(60) && !Main.gamePaused && noTilesBetweenPlayer) + { + if (Math.Abs(Main.LocalPlayer.Center.X - i * 16) < 80 && + Main.LocalPlayer.Bottom.Y < j * 16 && + Main.LocalPlayer.Bottom.Y > j * 16 - 300) + { + float yeetSpeed = MathHelper.Clamp(10f - (10f * Math.Abs(Main.LocalPlayer.Bottom.Y - j * 16) / 300f), 0f, 10f); + Main.LocalPlayer.velocity.Y -= yeetSpeed; + Projectile.NewProjectile(i * 16 + 8, j * 16 - 20, 0f, -10f, ModContent.ProjectileType(), Main.expertMode ? 12 : 15, 0f); + } + } + } + } } diff --git a/Tiles/Abyss/SulphurousPots.cs b/Tiles/Abyss/SulphurousPots.cs index 726d02d26f..e5cabdfa7b 100644 --- a/Tiles/Abyss/SulphurousPots.cs +++ b/Tiles/Abyss/SulphurousPots.cs @@ -7,32 +7,32 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Abyss { - public class SulphurousPots : ModTile - { - public override void SetDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = false; - Main.tileValue[Type] = (short)100; - Main.tileSpelunker[Type] = true; - Main.tileCut[Type] = true; + public class SulphurousPots : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + Main.tileValue[Type] = (short)100; + Main.tileSpelunker[Type] = true; + Main.tileCut[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.DrawYOffset = 4; - TileObjectData.addTile(Type); + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 4; + TileObjectData.addTile(Type); - ModTranslation name = CreateMapEntryName(); - name.SetDefault("Pot"); - AddMapEntry(new Color(226, 205, 101), name); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Pot"); + AddMapEntry(new Color(226, 205, 101), name); - dustType = (int)CalamityDusts.SulfurousSeaAcid; - soundType = SoundID.Shatter; - } + dustType = (int)CalamityDusts.SulfurousSeaAcid; + soundType = SoundID.Shatter; + } - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } } diff --git a/Tiles/Abyss/Tenebris.cs b/Tiles/Abyss/Tenebris.cs index f79e20827d..26a1c31a63 100644 --- a/Tiles/Abyss/Tenebris.cs +++ b/Tiles/Abyss/Tenebris.cs @@ -26,12 +26,12 @@ namespace CalamityMod.Tiles.Abyss soundType = SoundID.Tink; } - public override bool CanExplode(int i, int j) - { - return false; - } + public override bool CanExplode(int i, int j) + { + return false; + } - public override void NumDust(int i, int j, bool fail, ref int num) + public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 3; } diff --git a/Tiles/AerialiteBarTile.cs b/Tiles/AerialiteBarTile.cs index 1c01bd964c..222aa95d8a 100644 --- a/Tiles/AerialiteBarTile.cs +++ b/Tiles/AerialiteBarTile.cs @@ -9,14 +9,14 @@ namespace CalamityMod.Tiles { public override void SetDefaults() { - this.SetUpBar(new Color(141, 232, 246)); + this.SetUpBar(new Color(141, 232, 246)); dustType = 187; drop = ModContent.ItemType(); } public override bool CreateDust(int i, int j, ref int type) { - type = Main.rand.NextBool() ? 187 : 16; + type = Main.rand.NextBool() ? 187 : 16; return true; } } diff --git a/Tiles/Astral/AstralBeacon.cs b/Tiles/Astral/AstralBeacon.cs index 7ab2a88a2e..9a2a23148f 100644 --- a/Tiles/Astral/AstralBeacon.cs +++ b/Tiles/Astral/AstralBeacon.cs @@ -12,7 +12,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Astral { - public class AstralBeacon : ModTile + public class AstralBeacon : ModTile { public const int Width = 5; public const int Height = 4; diff --git a/Tiles/Astral/AstralGrass.cs b/Tiles/Astral/AstralGrass.cs index ef60b9f0bc..2e34f8987e 100644 --- a/Tiles/Astral/AstralGrass.cs +++ b/Tiles/Astral/AstralGrass.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralGrass : ModTile + public class AstralGrass : ModTile { public override void SetDefaults() { diff --git a/Tiles/AstralBar.cs b/Tiles/AstralBar.cs index e9ed4b007a..924c959f02 100644 --- a/Tiles/AstralBar.cs +++ b/Tiles/AstralBar.cs @@ -9,14 +9,14 @@ namespace CalamityMod.Tiles { public override void SetDefaults() { - this.SetUpBar(new Color(47, 66, 90)); + this.SetUpBar(new Color(47, 66, 90)); dustType = ModContent.DustType(); drop = ModContent.ItemType(); } public override bool CreateDust(int i, int j, ref int type) { - type = Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType(); + type = Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType(); return true; } } diff --git a/Tiles/AstralSnow/AstralIce.cs b/Tiles/AstralSnow/AstralIce.cs index 350b1120d3..e2916f8c6d 100644 --- a/Tiles/AstralSnow/AstralIce.cs +++ b/Tiles/AstralSnow/AstralIce.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralSnow { - public class AstralIce : ModTile + public class AstralIce : ModTile { public override void SetDefaults() { diff --git a/Tiles/AstralSnow/AstralSnow.cs b/Tiles/AstralSnow/AstralSnow.cs index c3a455775a..1a005c3c5f 100644 --- a/Tiles/AstralSnow/AstralSnow.cs +++ b/Tiles/AstralSnow/AstralSnow.cs @@ -7,10 +7,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralSnow { - public class AstralSnow : ModTile - { - public override void SetDefaults() - { + public class AstralSnow : ModTile + { + public override void SetDefaults() + { Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; Main.tileBrick[Type] = true; @@ -20,7 +20,7 @@ namespace CalamityMod.Tiles.AstralSnow CalamityUtils.MergeAstralTiles(Type); dustType = 173; - drop = ModContent.ItemType(); + drop = ModContent.ItemType(); soundType = SoundID.Item; soundStyle = 48; @@ -35,8 +35,8 @@ namespace CalamityMod.Tiles.AstralSnow } public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; + { + num = fail ? 1 : 3; } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) diff --git a/Tiles/AuricTeslaBar.cs b/Tiles/AuricTeslaBar.cs index 8b3c3e9f70..1c809997fd 100644 --- a/Tiles/AuricTeslaBar.cs +++ b/Tiles/AuricTeslaBar.cs @@ -5,11 +5,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class AuricTeslaBar : ModTile + public class AuricTeslaBar : ModTile { public override void SetDefaults() { - this.SetUpBar(new Color(255, 227, 81)); + this.SetUpBar(new Color(255, 227, 81)); dustType = ModContent.DustType(); drop = ModContent.ItemType(); } diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 79b11faf1a..117b91ca2a 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -22,539 +22,539 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class CalamityGlobalTile : GlobalTile - { - public static IList WaterStyles => (IList)typeof(WaterStyleLoader).GetField("waterStyles", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); + 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, - TileID.CorruptPlants, - TileID.JunglePlants, - TileID.MushroomPlants, - TileID.Plants2, - TileID.JunglePlants2, - TileID.HallowedPlants, - TileID.HallowedPlants2, - TileID.FleshWeeds, - (ushort)ModContent.TileType(), - (ushort)ModContent.TileType() - }; + public static ushort[] PlantTypes = new ushort[] + { + TileID.Plants, + TileID.CorruptPlants, + TileID.JunglePlants, + TileID.MushroomPlants, + TileID.Plants2, + TileID.JunglePlants2, + TileID.HallowedPlants, + TileID.HallowedPlants2, + TileID.FleshWeeds, + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType() + }; - public static List GrowthTiles = new List - { - (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), - (ushort)ModContent.TileType() - }; + public static List GrowthTiles = new List + { + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType() + }; - public override void SetDefaults() - { - Main.tileSpelunker[TileID.LunarOre] = true; - Main.tileValue[TileID.LunarOre] = 900; - } + public override void SetDefaults() + { + Main.tileSpelunker[TileID.LunarOre] = true; + Main.tileValue[TileID.LunarOre] = 900; + } - public override bool PreHitWire(int i, int j, int type) - { - return !BossRushEvent.BossRushActive; - } + public override bool PreHitWire(int i, int j, int type) + { + return !BossRushEvent.BossRushActive; + } - 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++) - if (type == PlantTypes[k]) - { - TileFraming.PlantFrame(i, j); - return false; - } + 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++) + if (type == PlantTypes[k]) + { + TileFraming.PlantFrame(i, j); + return false; + } - // Custom vine framing - if (type == TileID.Vines || type == TileID.CrimsonVines || type == TileID.HallowedVines || type == ModContent.TileType()) - { - TileFraming.VineFrame(i, j); - return false; - } - return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); - } + // Custom vine framing + if (type == TileID.Vines || type == TileID.CrimsonVines || type == TileID.HallowedVines || type == ModContent.TileType()) + { + TileFraming.VineFrame(i, j); + return false; + } + return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); + } - public override void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) - { - // Guaranteed not null at this point - Tile tile = Main.tile[i, j]; + public override void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) + { + // Guaranteed not null at this point + Tile tile = Main.tile[i, j]; - // This function is only for Astral Cactus. If the tile isn't even cactus, forget about it. - if (type != TileID.Cactus) - return; + // This function is only for Astral Cactus. If the tile isn't even cactus, forget about it. + if (type != TileID.Cactus) + return; - Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); - if (Main.drawToScreen) - zero = Vector2.Zero; - int frameX = tile.frameX; - int frameY = tile.frameY; + Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); + if (Main.drawToScreen) + zero = Vector2.Zero; + int frameX = tile.frameX; + int frameY = tile.frameY; - // Search down the cactus to find out whether the block it is planted in is Astral Sand. - bool astralCactus = false; - if (!Main.canDrawColorTile(i, j)) - { - int xTile = i; - if (frameX == 36) // Cactus segment which splits left - xTile--; - if (frameX == 54) // Cactus segment which splits right - xTile++; - if (frameX == 108) // Cactus segment which splits both directions - xTile += (frameY == 18) ? -1 : 1; + // Search down the cactus to find out whether the block it is planted in is Astral Sand. + bool astralCactus = false; + if (!Main.canDrawColorTile(i, j)) + { + int xTile = i; + if (frameX == 36) // Cactus segment which splits left + xTile--; + if (frameX == 54) // Cactus segment which splits right + xTile++; + if (frameX == 108) // Cactus segment which splits both directions + xTile += (frameY == 18) ? -1 : 1; - int yTile = j; - bool slidingDownCactus = Main.tile[xTile, yTile] != null && Main.tile[xTile, yTile].type == TileID.Cactus && Main.tile[xTile, yTile].active(); - while (!Main.tile[xTile, yTile].active() || !Main.tileSolid[Main.tile[xTile, yTile].type] || !slidingDownCactus) - { - if (Main.tile[xTile, yTile].type == TileID.Cactus && Main.tile[xTile, yTile].active()) - { - slidingDownCactus = true; - } - yTile++; - // Cacti are assumed to be no more than 20 blocks tall. - if (yTile > i + 20) - break; - } - astralCactus = Main.tile[xTile, yTile].type == (ushort)ModContent.TileType(); - } + int yTile = j; + bool slidingDownCactus = Main.tile[xTile, yTile] != null && Main.tile[xTile, yTile].type == TileID.Cactus && Main.tile[xTile, yTile].active(); + while (!Main.tile[xTile, yTile].active() || !Main.tileSolid[Main.tile[xTile, yTile].type] || !slidingDownCactus) + { + if (Main.tile[xTile, yTile].type == TileID.Cactus && Main.tile[xTile, yTile].active()) + { + slidingDownCactus = true; + } + yTile++; + // Cacti are assumed to be no more than 20 blocks tall. + if (yTile > i + 20) + break; + } + astralCactus = Main.tile[xTile, yTile].type == (ushort)ModContent.TileType(); + } - // If it is actually astral cactus, then draw its glowmask. - if (astralCactus) - { - spriteBatch.Draw(CalamityMod.AstralCactusGlowTexture, new Vector2((float)(i * 16 - (int)Main.screenPosition.X), (float)(j * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle((int)frameX, (int)frameY, 16, 18), Color.White * 0.75f, 0f, default, 1f, SpriteEffects.None, 0f); - } - } + // If it is actually astral cactus, then draw its glowmask. + if (astralCactus) + { + spriteBatch.Draw(CalamityMod.AstralCactusGlowTexture, new Vector2((float)(i * 16 - (int)Main.screenPosition.X), (float)(j * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle((int)frameX, (int)frameY, 16, 18), Color.White * 0.75f, 0f, default, 1f, SpriteEffects.None, 0f); + } + } - // This function has two purposes: - // 1 - Shatters adjacent Lumenyl or Sea Prism crystals when a neighboring solid tile is destroyed - // 2 - Gives the player breath back when breaking blocks with Reaver set bonus - public override void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem) - { - Tile tile = Main.tile[i, j]; - if (tile is null) - return; + // This function has two purposes: + // 1 - Shatters adjacent Lumenyl or Sea Prism crystals when a neighboring solid tile is destroyed + // 2 - Gives the player breath back when breaking blocks with Reaver set bonus + public override void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem) + { + Tile tile = Main.tile[i, j]; + if (tile is null) + return; - // Helper function to shatter crystals attached to neighboring solid tiles. - void CheckShatterCrystal(int xPos, int yPos) - { - if (xPos < 0 || xPos >= Main.maxTilesX || yPos < 0 || yPos >= Main.maxTilesY) - return; - Tile t = Main.tile[xPos, yPos]; - if (t != null && t.active() && (t.type == ModContent.TileType() || (t.type == ModContent.TileType() && CalamityWorld.downedDesertScourge))) - { - WorldGen.KillTile(xPos, yPos, false, false, false); - if (!Main.tile[xPos, yPos].active() && Main.netMode != NetmodeID.SinglePlayer) - NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, xPos, yPos, 0f, 0, 0, 0); - } - } + // Helper function to shatter crystals attached to neighboring solid tiles. + void CheckShatterCrystal(int xPos, int yPos) + { + if (xPos < 0 || xPos >= Main.maxTilesX || yPos < 0 || yPos >= Main.maxTilesY) + return; + Tile t = Main.tile[xPos, yPos]; + if (t != null && t.active() && (t.type == ModContent.TileType() || (t.type == ModContent.TileType() && CalamityWorld.downedDesertScourge))) + { + WorldGen.KillTile(xPos, yPos, false, false, false); + if (!Main.tile[xPos, yPos].active() && Main.netMode != NetmodeID.SinglePlayer) + NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, xPos, yPos, 0f, 0, 0, 0); + } + } - // CONSIDER -- Lumenyl Crystals and Sea Prism Crystals aren't solid. They shouldn't need to be checked here. - if (Main.tileSolid[tile.type] && tile.type != ModContent.TileType() && tile.type != ModContent.TileType()) - { - CheckShatterCrystal(i + 1, j); - CheckShatterCrystal(i - 1, j); - CheckShatterCrystal(i, j + 1); - CheckShatterCrystal(i, j - 1); - } + // CONSIDER -- Lumenyl Crystals and Sea Prism Crystals aren't solid. They shouldn't need to be checked here. + if (Main.tileSolid[tile.type] && tile.type != ModContent.TileType() && tile.type != ModContent.TileType()) + { + CheckShatterCrystal(i + 1, j); + CheckShatterCrystal(i - 1, j); + CheckShatterCrystal(i, j + 1); + CheckShatterCrystal(i, j - 1); + } - Player player = Main.LocalPlayer; - if (player is null || !player.active) - return; + Player player = Main.LocalPlayer; + if (player is null || !player.active) + return; - if (player.Calamity().reaverExplore && !fail) - { - player.breath += 20; - if (player.breath > player.breathMax) - player.breath = player.breathMax; - } - } + if (player.Calamity().reaverExplore && !fail) + { + player.breath += 20; + if (player.breath > player.breathMax) + player.breath = player.breathMax; + } + } - // LATER -- clean up copied decompiled pot code here - public override bool Drop(int i, int j, int type) - { - Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(i, j); - if (tileAtPosition.frameX % 36 == 0 && tileAtPosition.frameY % 36 == 0) - { - if (type == ModContent.TileType()) - { - Item.NewItem(i * 16, j * 16, 16, 16, ModContent.ItemType()); + // LATER -- clean up copied decompiled pot code here + public override bool Drop(int i, int j, int type) + { + Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(i, j); + if (tileAtPosition.frameX % 36 == 0 && tileAtPosition.frameY % 36 == 0) + { + if (type == ModContent.TileType()) + { + Item.NewItem(i * 16, j * 16, 16, 16, ModContent.ItemType()); - for (int k = 0; k < Main.rand.Next(1, 2 + 1); k++) - { - Gore.NewGore(new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), mod.GetGoreSlot("Gores/SulphSeaGen/AbyssPotGore1")); - Gore.NewGore(new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), mod.GetGoreSlot("Gores/SulphSeaGen/AbyssPotGore2")); - } - } - else if (type == ModContent.TileType()) - { - Item.NewItem(i * 16, j * 16, 16, 16, ModContent.ItemType()); + for (int k = 0; k < Main.rand.Next(1, 2 + 1); k++) + { + Gore.NewGore(new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), mod.GetGoreSlot("Gores/SulphSeaGen/AbyssPotGore1")); + Gore.NewGore(new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), mod.GetGoreSlot("Gores/SulphSeaGen/AbyssPotGore2")); + } + } + else if (type == ModContent.TileType()) + { + Item.NewItem(i * 16, j * 16, 16, 16, ModContent.ItemType()); - for (int k = 0; k < Main.rand.Next(1, 2 + 1); k++) - { - Gore.NewGore(new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), mod.GetGoreSlot("Gores/SulphSeaGen/SulphPotGore1")); - Gore.NewGore(new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), mod.GetGoreSlot("Gores/SulphSeaGen/SulphPotGore2")); - } - } - else if (type == TileID.DemonAltar && Main.hardMode) - { - Vector2 pos = new Vector2(i, j) * 16; - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) - { - WorldGen.altarCount++; - int quantity = 6; - for (int k = 0; k < quantity; k += 1) - { - pos.X += Main.rand.NextFloat(-32f, 32f); - pos.Y += Main.rand.NextFloat(-32f, 32f); - Item.NewItem(pos, ItemID.SoulofNight); - } - } - if (WorldGen.altarCount % 3 == 0 && WorldGen.altarCount > 1) - Item.NewItem(pos, ModContent.ItemType()); - } - } + for (int k = 0; k < Main.rand.Next(1, 2 + 1); k++) + { + Gore.NewGore(new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), mod.GetGoreSlot("Gores/SulphSeaGen/SulphPotGore1")); + Gore.NewGore(new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), mod.GetGoreSlot("Gores/SulphSeaGen/SulphPotGore2")); + } + } + else if (type == TileID.DemonAltar && Main.hardMode) + { + Vector2 pos = new Vector2(i, j) * 16; + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) + { + WorldGen.altarCount++; + int quantity = 6; + for (int k = 0; k < quantity; k += 1) + { + pos.X += Main.rand.NextFloat(-32f, 32f); + pos.Y += Main.rand.NextFloat(-32f, 32f); + Item.NewItem(pos, ItemID.SoulofNight); + } + } + if (WorldGen.altarCount % 3 == 0 && WorldGen.altarCount > 1) + Item.NewItem(pos, ModContent.ItemType()); + } + } - // This is old pot code, kept here for legacy reasons with old worlds. Should be removed in a future update after a sufficient amount of time. - if (type == TileID.Pots) - { - int x = Main.maxTilesX; - int y = Main.maxTilesY; - int genLimit = x / 2; - int abyssChasmSteps = y / 4; - int abyssChasmY = y - abyssChasmSteps + (int)(y * 0.055); //132 = 1932 large - if (y < 1500) - { - abyssChasmY = y - abyssChasmSteps + (int)(y * 0.095); //114 = 1014 small - } - else if (y < 2100) - { - abyssChasmY = y - abyssChasmSteps + (int)(y * 0.0735); //132 = 1482 medium - } - int abyssChasmX = CalamityWorld.abyssSide ? genLimit - (genLimit - 135) : genLimit + (genLimit - 135); + // This is old pot code, kept here for legacy reasons with old worlds. Should be removed in a future update after a sufficient amount of time. + if (type == TileID.Pots) + { + int x = Main.maxTilesX; + int y = Main.maxTilesY; + int genLimit = x / 2; + int abyssChasmSteps = y / 4; + int abyssChasmY = y - abyssChasmSteps + (int)(y * 0.055); //132 = 1932 large + if (y < 1500) + { + abyssChasmY = y - abyssChasmSteps + (int)(y * 0.095); //114 = 1014 small + } + else if (y < 2100) + { + abyssChasmY = y - abyssChasmSteps + (int)(y * 0.0735); //132 = 1482 medium + } + int abyssChasmX = CalamityWorld.abyssSide ? genLimit - (genLimit - 135) : genLimit + (genLimit - 135); - bool abyssPosX = false; - bool sulphurPosX = false; - bool abyssPosY = j <= abyssChasmY; - if (CalamityWorld.abyssSide) - { - if (i < 380) - { - sulphurPosX = true; - } - if (i < abyssChasmX + 80) - { - abyssPosX = true; - } - } - else - { - if (i > Main.maxTilesX - 380) - { - sulphurPosX = true; - } - if (i > abyssChasmX - 80) - { - abyssPosX = true; - } - } - if (abyssPosX && abyssPosY) - { - if (Main.rand.NextBool(10)) - { - int potionType = Utils.SelectRandom(WorldGen.genRand, new int[] - { - ItemID.SpelunkerPotion, - ItemID.MagicPowerPotion, - ItemID.ShinePotion, - ItemID.WaterWalkingPotion, - ItemID.ObsidianSkinPotion, - ItemID.WaterWalkingPotion, - ItemID.GravitationPotion, - ItemID.RegenerationPotion, - ModContent.ItemType(), - ModContent.ItemType(), - ItemID.GillsPotion, - ItemID.EndurancePotion, - ItemID.HeartreachPotion, - ItemID.FlipperPotion, - ItemID.LifeforcePotion, - ItemID.InfernoPotion - }); - Item.NewItem(i * 16, j * 16, 16, 16, potionType, 1, false, 0, false, false); - } - else - { - int lootType = Main.rand.Next(10); //0 to 9 - if (lootType == 0) //spelunker glowsticks - { - int sglowstickAmt = Main.rand.Next(2, 6); - if (Main.expertMode) - { - sglowstickAmt += Main.rand.Next(1, 7); - } - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.SpelunkerGlowstick, sglowstickAmt, false, 0, false, false); - } - else if (lootType == 1) //hellfire arrows - { - int arrowAmt = Main.rand.Next(10, 21); - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.HellfireArrow, arrowAmt, false, 0, false, false); - } - else if (lootType == 2) //stew - { - Item.NewItem(i * 16, j * 16, 16, 16, ModContent.ItemType(), 1, false, 0, false, false); - } - else if (lootType == 3) //sticky dynamite - { - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.StickyDynamite, 1, false, 0, false, false); - } - else //money - { - float num13 = (float)(5000 + WorldGen.genRand.Next(-100, 101)); - while ((int)num13 > 0) - { - if (num13 > 1000000f) - { - int ptCoinAmt = (int)(num13 / 1000000f); - if (ptCoinAmt > 50 && Main.rand.NextBool(2)) - { - ptCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - ptCoinAmt /= Main.rand.Next(3) + 1; - } - num13 -= (float)(1000000 * ptCoinAmt); - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.PlatinumCoin, ptCoinAmt, false, 0, false, false); - } - else if (num13 > 10000f) - { - int auCoinAmt = (int)(num13 / 10000f); - if (auCoinAmt > 50 && Main.rand.NextBool(2)) - { - auCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - auCoinAmt /= Main.rand.Next(3) + 1; - } - num13 -= (float)(10000 * auCoinAmt); - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.GoldCoin, auCoinAmt, false, 0, false, false); - } - else if (num13 > 100f) - { - int agCoinAmt = (int)(num13 / 100f); - if (agCoinAmt > 50 && Main.rand.NextBool(2)) - { - agCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - agCoinAmt /= Main.rand.Next(3) + 1; - } - num13 -= (float)(100 * agCoinAmt); - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.SilverCoin, agCoinAmt, false, 0, false, false); - } - else - { - int cuCoinAmt = (int)num13; - if (cuCoinAmt > 50 && Main.rand.NextBool(2)) - { - cuCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - cuCoinAmt /= Main.rand.Next(4) + 1; - } - if (cuCoinAmt < 1) - { - cuCoinAmt = 1; - } - num13 -= (float)cuCoinAmt; - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.CopperCoin, cuCoinAmt, false, 0, false, false); - } - } - } - } - } - else if (sulphurPosX) - { - if (Main.rand.NextBool(15)) - { - int potionType = Utils.SelectRandom(WorldGen.genRand, new int[] - { - ItemID.SpelunkerPotion, - ItemID.MagicPowerPotion, - ItemID.ShinePotion, - ItemID.WaterWalkingPotion, - ItemID.ObsidianSkinPotion, - ItemID.WaterWalkingPotion, - ItemID.GravitationPotion, - ItemID.RegenerationPotion, - ModContent.ItemType(), - ModContent.ItemType(), - ItemID.GillsPotion, - ItemID.EndurancePotion, - ItemID.HeartreachPotion, - ItemID.FlipperPotion, - ItemID.LifeforcePotion, - ItemID.InfernoPotion - }); - Item.NewItem(i * 16, j * 16, 16, 16, potionType, 1, false, 0, false, false); - } - else - { - int lootType = Main.rand.Next(10); //0 to 9 - if (lootType == 0) //glowsticks - { - int glowstickAmt = Main.rand.Next(2, 6); - if (Main.expertMode) - { - glowstickAmt += Main.rand.Next(1, 7); - } - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.Glowstick, glowstickAmt, false, 0, false, false); - } - else if (lootType == 1) //jesters arrows - { - int jArrowAmt = Main.rand.Next(10, 21); - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.JestersArrow, jArrowAmt, false, 0, false, false); - } - else if (lootType == 2) //potion - { - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.HealingPotion, 1, false, 0, false, false); - } - else if (lootType == 3) //bomb - { - int bombAmt = Main.rand.Next(5, 9); - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.Bomb, bombAmt, false, 0, false, false); - } - else //money - { - float num13 = (float)(5000 + WorldGen.genRand.Next(-100, 101)); - while ((int)num13 > 0) - { - if (num13 > 1000000f) - { - int ptCoinAmt = (int)(num13 / 1000000f); - if (ptCoinAmt > 50 && Main.rand.NextBool(2)) - { - ptCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - ptCoinAmt /= Main.rand.Next(3) + 1; - } - num13 -= (float)(1000000 * ptCoinAmt); - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.PlatinumCoin, ptCoinAmt, false, 0, false, false); - } - else if (num13 > 10000f) - { - int auCoinAmt = (int)(num13 / 10000f); - if (auCoinAmt > 50 && Main.rand.NextBool(2)) - { - auCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - auCoinAmt /= Main.rand.Next(3) + 1; - } - num13 -= (float)(10000 * auCoinAmt); - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.GoldCoin, auCoinAmt, false, 0, false, false); - } - else if (num13 > 100f) - { - int agCoinAmt = (int)(num13 / 100f); - if (agCoinAmt > 50 && Main.rand.NextBool(2)) - { - agCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - agCoinAmt /= Main.rand.Next(3) + 1; - } - num13 -= (float)(100 * agCoinAmt); - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.SilverCoin, agCoinAmt, false, 0, false, false); - } - else - { - int cuCoinAmt = (int)num13; - if (cuCoinAmt > 50 && Main.rand.NextBool(2)) - { - cuCoinAmt /= Main.rand.Next(3) + 1; - } - if (Main.rand.NextBool(2)) - { - cuCoinAmt /= Main.rand.Next(4) + 1; - } - if (cuCoinAmt < 1) - { - cuCoinAmt = 1; - } - num13 -= (float)cuCoinAmt; - Item.NewItem(i * 16, j * 16, 16, 16, ItemID.CopperCoin, cuCoinAmt, false, 0, false, false); - } - } - } - } - } - } - return true; - } + bool abyssPosX = false; + bool sulphurPosX = false; + bool abyssPosY = j <= abyssChasmY; + if (CalamityWorld.abyssSide) + { + if (i < 380) + { + sulphurPosX = true; + } + if (i < abyssChasmX + 80) + { + abyssPosX = true; + } + } + else + { + if (i > Main.maxTilesX - 380) + { + sulphurPosX = true; + } + if (i > abyssChasmX - 80) + { + abyssPosX = true; + } + } + if (abyssPosX && abyssPosY) + { + if (Main.rand.NextBool(10)) + { + int potionType = Utils.SelectRandom(WorldGen.genRand, new int[] + { + ItemID.SpelunkerPotion, + ItemID.MagicPowerPotion, + ItemID.ShinePotion, + ItemID.WaterWalkingPotion, + ItemID.ObsidianSkinPotion, + ItemID.WaterWalkingPotion, + ItemID.GravitationPotion, + ItemID.RegenerationPotion, + ModContent.ItemType(), + ModContent.ItemType(), + ItemID.GillsPotion, + ItemID.EndurancePotion, + ItemID.HeartreachPotion, + ItemID.FlipperPotion, + ItemID.LifeforcePotion, + ItemID.InfernoPotion + }); + Item.NewItem(i * 16, j * 16, 16, 16, potionType, 1, false, 0, false, false); + } + else + { + int lootType = Main.rand.Next(10); //0 to 9 + if (lootType == 0) //spelunker glowsticks + { + int sglowstickAmt = Main.rand.Next(2, 6); + if (Main.expertMode) + { + sglowstickAmt += Main.rand.Next(1, 7); + } + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.SpelunkerGlowstick, sglowstickAmt, false, 0, false, false); + } + else if (lootType == 1) //hellfire arrows + { + int arrowAmt = Main.rand.Next(10, 21); + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.HellfireArrow, arrowAmt, false, 0, false, false); + } + else if (lootType == 2) //stew + { + Item.NewItem(i * 16, j * 16, 16, 16, ModContent.ItemType(), 1, false, 0, false, false); + } + else if (lootType == 3) //sticky dynamite + { + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.StickyDynamite, 1, false, 0, false, false); + } + else //money + { + float num13 = (float)(5000 + WorldGen.genRand.Next(-100, 101)); + while ((int)num13 > 0) + { + if (num13 > 1000000f) + { + int ptCoinAmt = (int)(num13 / 1000000f); + if (ptCoinAmt > 50 && Main.rand.NextBool(2)) + { + ptCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + ptCoinAmt /= Main.rand.Next(3) + 1; + } + num13 -= (float)(1000000 * ptCoinAmt); + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.PlatinumCoin, ptCoinAmt, false, 0, false, false); + } + else if (num13 > 10000f) + { + int auCoinAmt = (int)(num13 / 10000f); + if (auCoinAmt > 50 && Main.rand.NextBool(2)) + { + auCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + auCoinAmt /= Main.rand.Next(3) + 1; + } + num13 -= (float)(10000 * auCoinAmt); + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.GoldCoin, auCoinAmt, false, 0, false, false); + } + else if (num13 > 100f) + { + int agCoinAmt = (int)(num13 / 100f); + if (agCoinAmt > 50 && Main.rand.NextBool(2)) + { + agCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + agCoinAmt /= Main.rand.Next(3) + 1; + } + num13 -= (float)(100 * agCoinAmt); + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.SilverCoin, agCoinAmt, false, 0, false, false); + } + else + { + int cuCoinAmt = (int)num13; + if (cuCoinAmt > 50 && Main.rand.NextBool(2)) + { + cuCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + cuCoinAmt /= Main.rand.Next(4) + 1; + } + if (cuCoinAmt < 1) + { + cuCoinAmt = 1; + } + num13 -= (float)cuCoinAmt; + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.CopperCoin, cuCoinAmt, false, 0, false, false); + } + } + } + } + } + else if (sulphurPosX) + { + if (Main.rand.NextBool(15)) + { + int potionType = Utils.SelectRandom(WorldGen.genRand, new int[] + { + ItemID.SpelunkerPotion, + ItemID.MagicPowerPotion, + ItemID.ShinePotion, + ItemID.WaterWalkingPotion, + ItemID.ObsidianSkinPotion, + ItemID.WaterWalkingPotion, + ItemID.GravitationPotion, + ItemID.RegenerationPotion, + ModContent.ItemType(), + ModContent.ItemType(), + ItemID.GillsPotion, + ItemID.EndurancePotion, + ItemID.HeartreachPotion, + ItemID.FlipperPotion, + ItemID.LifeforcePotion, + ItemID.InfernoPotion + }); + Item.NewItem(i * 16, j * 16, 16, 16, potionType, 1, false, 0, false, false); + } + else + { + int lootType = Main.rand.Next(10); //0 to 9 + if (lootType == 0) //glowsticks + { + int glowstickAmt = Main.rand.Next(2, 6); + if (Main.expertMode) + { + glowstickAmt += Main.rand.Next(1, 7); + } + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.Glowstick, glowstickAmt, false, 0, false, false); + } + else if (lootType == 1) //jesters arrows + { + int jArrowAmt = Main.rand.Next(10, 21); + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.JestersArrow, jArrowAmt, false, 0, false, false); + } + else if (lootType == 2) //potion + { + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.HealingPotion, 1, false, 0, false, false); + } + else if (lootType == 3) //bomb + { + int bombAmt = Main.rand.Next(5, 9); + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.Bomb, bombAmt, false, 0, false, false); + } + else //money + { + float num13 = (float)(5000 + WorldGen.genRand.Next(-100, 101)); + while ((int)num13 > 0) + { + if (num13 > 1000000f) + { + int ptCoinAmt = (int)(num13 / 1000000f); + if (ptCoinAmt > 50 && Main.rand.NextBool(2)) + { + ptCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + ptCoinAmt /= Main.rand.Next(3) + 1; + } + num13 -= (float)(1000000 * ptCoinAmt); + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.PlatinumCoin, ptCoinAmt, false, 0, false, false); + } + else if (num13 > 10000f) + { + int auCoinAmt = (int)(num13 / 10000f); + if (auCoinAmt > 50 && Main.rand.NextBool(2)) + { + auCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + auCoinAmt /= Main.rand.Next(3) + 1; + } + num13 -= (float)(10000 * auCoinAmt); + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.GoldCoin, auCoinAmt, false, 0, false, false); + } + else if (num13 > 100f) + { + int agCoinAmt = (int)(num13 / 100f); + if (agCoinAmt > 50 && Main.rand.NextBool(2)) + { + agCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + agCoinAmt /= Main.rand.Next(3) + 1; + } + num13 -= (float)(100 * agCoinAmt); + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.SilverCoin, agCoinAmt, false, 0, false, false); + } + else + { + int cuCoinAmt = (int)num13; + if (cuCoinAmt > 50 && Main.rand.NextBool(2)) + { + cuCoinAmt /= Main.rand.Next(3) + 1; + } + if (Main.rand.NextBool(2)) + { + cuCoinAmt /= Main.rand.Next(4) + 1; + } + if (cuCoinAmt < 1) + { + cuCoinAmt = 1; + } + num13 -= (float)cuCoinAmt; + Item.NewItem(i * 16, j * 16, 16, 16, ItemID.CopperCoin, cuCoinAmt, false, 0, false, false); + } + } + } + } + } + } + return true; + } - public override int[] AdjTiles (int type) - { - // Ashen, Ancient and Profaned Sinks all count as a lava source instead of a water source - // Exo Sinks count as a water, lava, and honey source - if (type == ModContent.TileType() || - type == ModContent.TileType() || - type == ModContent.TileType() || - type == ModContent.TileType()) - { - Main.LocalPlayer.adjLava = true; - } - // Botanic Sink counts as a honey source instead of a water source - if (type == ModContent.TileType() || - type == ModContent.TileType()) - { - Main.LocalPlayer.adjHoney = true; - } + public override int[] AdjTiles (int type) + { + // Ashen, Ancient and Profaned Sinks all count as a lava source instead of a water source + // Exo Sinks count as a water, lava, and honey source + if (type == ModContent.TileType() || + type == ModContent.TileType() || + type == ModContent.TileType() || + type == ModContent.TileType()) + { + Main.LocalPlayer.adjLava = true; + } + // Botanic Sink counts as a honey source instead of a water source + if (type == ModContent.TileType() || + type == ModContent.TileType()) + { + Main.LocalPlayer.adjHoney = true; + } - return new int[0]; - } + return new int[0]; + } - public static bool ShouldNotBreakDueToAboveTile(int x, int y) - { - int[] invincibleTiles = new int[] - { - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType() - }; + public static bool ShouldNotBreakDueToAboveTile(int x, int y) + { + int[] invincibleTiles = new int[] + { + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType() + }; - Tile checkTile = CalamityUtils.ParanoidTileRetrieval(x, y); - Tile aboveTile = CalamityUtils.ParanoidTileRetrieval(x, y - 1); + Tile checkTile = CalamityUtils.ParanoidTileRetrieval(x, y); + Tile aboveTile = CalamityUtils.ParanoidTileRetrieval(x, y - 1); - // Prevent tiles below invincible tiles from being destroyed. This is like chests in vanilla. - return aboveTile.active() && checkTile.type != aboveTile.type && invincibleTiles.Contains(aboveTile.type); - } + // Prevent tiles below invincible tiles from being destroyed. This is like chests in vanilla. + return aboveTile.active() && checkTile.type != aboveTile.type && invincibleTiles.Contains(aboveTile.type); + } - public override bool CanExplode(int i, int j, int type) - { - if (ShouldNotBreakDueToAboveTile(i, j)) - return false; + public override bool CanExplode(int i, int j, int type) + { + if (ShouldNotBreakDueToAboveTile(i, j)) + return false; - return base.CanExplode(i, j, type); - } + return base.CanExplode(i, j, type); + } - public override bool CanKillTile(int i, int j, int type, ref bool blockDamaged) - { - if (ShouldNotBreakDueToAboveTile(i, j)) - return false; + public override bool CanKillTile(int i, int j, int type, ref bool blockDamaged) + { + if (ShouldNotBreakDueToAboveTile(i, j)) + return false; - return base.CanKillTile(i, j, type, ref blockDamaged); - } - } + return base.CanKillTile(i, j, type, ref blockDamaged); + } + } } diff --git a/Tiles/ChaoticBarPlaced.cs b/Tiles/ChaoticBarPlaced.cs index 2c09e4c9f2..9232c7632d 100644 --- a/Tiles/ChaoticBarPlaced.cs +++ b/Tiles/ChaoticBarPlaced.cs @@ -9,15 +9,15 @@ namespace CalamityMod.Tiles { public override void SetDefaults() { - this.SetUpBar(new Color(255, 165, 0)); + this.SetUpBar(new Color(255, 165, 0)); dustType = 87; drop = ModContent.ItemType(); } public override bool CreateDust(int i, int j, ref int type) { - type = Main.rand.NextBool() ? 87 : 6; + type = Main.rand.NextBool() ? 87 : 6; return true; } - } + } } diff --git a/Tiles/CosmiliteBarTile.cs b/Tiles/CosmiliteBarTile.cs index 1de2c2cb52..230c1b3fbd 100644 --- a/Tiles/CosmiliteBarTile.cs +++ b/Tiles/CosmiliteBarTile.cs @@ -5,18 +5,18 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class CosmiliteBarTile : ModTile + public class CosmiliteBarTile : ModTile { public override void SetDefaults() { - this.SetUpBar(new Color(229, 141, 246)); + this.SetUpBar(new Color(229, 141, 246)); dustType = ModContent.DustType(); drop = ModContent.ItemType(); } public override bool CreateDust(int i, int j, ref int type) { - type = ModContent.DustType(); + type = ModContent.DustType(); return true; } } diff --git a/Tiles/Crags/BrimstoneCrateTile.cs b/Tiles/Crags/BrimstoneCrateTile.cs index 74958ff9ac..2a06ac0fdf 100644 --- a/Tiles/Crags/BrimstoneCrateTile.cs +++ b/Tiles/Crags/BrimstoneCrateTile.cs @@ -6,7 +6,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Crags { - public class BrimstoneCrateTile : ModTile + public class BrimstoneCrateTile : ModTile { public override void SetDefaults() { diff --git a/Tiles/Crags/BrimstoneSlag.cs b/Tiles/Crags/BrimstoneSlag.cs index 47d5df1d45..5a3cad964a 100644 --- a/Tiles/Crags/BrimstoneSlag.cs +++ b/Tiles/Crags/BrimstoneSlag.cs @@ -6,7 +6,7 @@ using Terraria.ID; namespace CalamityMod.Tiles.Crags { - public class BrimstoneSlag : ModTile + public class BrimstoneSlag : ModTile { private const short subsheetWidth = 450; private const short subsheetHeight = 198; diff --git a/Tiles/CryonicBar.cs b/Tiles/CryonicBar.cs index d10266876a..b2c697c6cd 100644 --- a/Tiles/CryonicBar.cs +++ b/Tiles/CryonicBar.cs @@ -9,14 +9,14 @@ namespace CalamityMod.Tiles { public override void SetDefaults() { - this.SetUpBar(new Color(138, 43, 226)); + this.SetUpBar(new Color(138, 43, 226)); dustType = 44; drop = ModContent.ItemType(); } public override bool CreateDust(int i, int j, ref int type) { - type = Main.rand.NextBool() ? 56 : 73; + type = Main.rand.NextBool() ? 56 : 73; return true; } } diff --git a/Tiles/DraedonStructures/AgedLaboratoryDoorClosed.cs b/Tiles/DraedonStructures/AgedLaboratoryDoorClosed.cs index 0ee7e4e818..88c6d4d7fe 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryDoorClosed.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryDoorClosed.cs @@ -9,7 +9,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.DraedonStructures { - public class AgedLaboratoryDoorClosed : ModTile + public class AgedLaboratoryDoorClosed : ModTile { public override void SetDefaults() { diff --git a/Tiles/DraedonStructures/AgedLaboratoryDoorOpen.cs b/Tiles/DraedonStructures/AgedLaboratoryDoorOpen.cs index 93d07776be..ed8985c7e6 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryDoorOpen.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryDoorOpen.cs @@ -9,7 +9,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.DraedonStructures { - public class AgedLaboratoryDoorOpen : ModTile + public class AgedLaboratoryDoorOpen : ModTile { public override void SetDefaults() { diff --git a/Tiles/DraedonStructures/HazardChevronPanels.cs b/Tiles/DraedonStructures/HazardChevronPanels.cs index 8cd1749159..89098588fc 100644 --- a/Tiles/DraedonStructures/HazardChevronPanels.cs +++ b/Tiles/DraedonStructures/HazardChevronPanels.cs @@ -13,10 +13,10 @@ namespace CalamityMod.Tiles.DraedonStructures Main.tileBlockLight[Type] = true; CalamityUtils.MergeWithGeneral(Type); - CalamityUtils.SetMerge(Type, ModContent.TileType()); - CalamityUtils.SetMerge(Type, ModContent.TileType()); - CalamityUtils.SetMerge(Type, ModContent.TileType()); - CalamityUtils.SetMerge(Type, ModContent.TileType()); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + CalamityUtils.SetMerge(Type, ModContent.TileType()); + CalamityUtils.SetMerge(Type, ModContent.TileType()); soundType = SoundID.Tink; dustType = 19; diff --git a/Tiles/DraedonStructures/LaboratoryDoorClosed.cs b/Tiles/DraedonStructures/LaboratoryDoorClosed.cs index 5e1d82ce22..170cac3fe9 100644 --- a/Tiles/DraedonStructures/LaboratoryDoorClosed.cs +++ b/Tiles/DraedonStructures/LaboratoryDoorClosed.cs @@ -9,7 +9,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryDoorClosed : ModTile + public class LaboratoryDoorClosed : ModTile { public override void SetDefaults() { diff --git a/Tiles/DraedonStructures/LaboratoryDoorOpen.cs b/Tiles/DraedonStructures/LaboratoryDoorOpen.cs index 95d1d5f22a..cffc7aa927 100644 --- a/Tiles/DraedonStructures/LaboratoryDoorOpen.cs +++ b/Tiles/DraedonStructures/LaboratoryDoorOpen.cs @@ -9,7 +9,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryDoorOpen : ModTile + public class LaboratoryDoorOpen : ModTile { public override void SetDefaults() { diff --git a/Tiles/DraedonStructures/LaboratoryScreen.cs b/Tiles/DraedonStructures/LaboratoryScreen.cs index 1d37f27bfd..ce260cbc03 100644 --- a/Tiles/DraedonStructures/LaboratoryScreen.cs +++ b/Tiles/DraedonStructures/LaboratoryScreen.cs @@ -7,7 +7,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryScreen : ModTile + public class LaboratoryScreen : ModTile { public override void SetDefaults() { diff --git a/Tiles/Furniture/BabyFlakHermitCageTile.cs b/Tiles/Furniture/BabyFlakHermitCageTile.cs index 062d5a9337..c008dedaae 100644 --- a/Tiles/Furniture/BabyFlakHermitCageTile.cs +++ b/Tiles/Furniture/BabyFlakHermitCageTile.cs @@ -6,7 +6,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Furniture { - public class BabyFlakHermitCageTile : ModTile + public class BabyFlakHermitCageTile : ModTile { public override void SetDefaults() { @@ -34,26 +34,26 @@ namespace CalamityMod.Tiles.Furniture public override void AnimateTile(ref int frame, ref int frameCounter) { - int frameAmt = 34; - int timeNeeded = 6; - if (frame == 0 || frame == 16) - { - timeNeeded = 90; - } - if (frame == 28) - { - timeNeeded = 60; - } - frameCounter++; - if (frameCounter >= timeNeeded) - { + int frameAmt = 34; + int timeNeeded = 6; + if (frame == 0 || frame == 16) + { + timeNeeded = 90; + } + if (frame == 28) + { + timeNeeded = 60; + } + frameCounter++; + if (frameCounter >= timeNeeded) + { frame++; frameCounter = 0; - } - if (frame >= frameAmt) - { - frame = 0; - } + } + if (frame >= frameAmt) + { + frame = 0; + } } public override void KillMultiTile(int i, int j, int frameX, int frameY) diff --git a/Tiles/Furniture/BabyGhostBellJarTile.cs b/Tiles/Furniture/BabyGhostBellJarTile.cs index ab98adf317..066ac7bb0a 100644 --- a/Tiles/Furniture/BabyGhostBellJarTile.cs +++ b/Tiles/Furniture/BabyGhostBellJarTile.cs @@ -36,24 +36,24 @@ namespace CalamityMod.Tiles.Furniture public override void AnimateTile(ref int frame, ref int frameCounter) { - int frameAmt = 8; - int timeNeeded = 10; - frameCounter++; - if (frameCounter >= timeNeeded) - { + int frameAmt = 8; + int timeNeeded = 10; + frameCounter++; + if (frameCounter >= timeNeeded) + { frame++; frameCounter = 0; - } - if (frame >= frameAmt) - { - frame = 0; - } + } + if (frame >= frameAmt) + { + frame = 0; + } } - public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) - { - frameYOffset = this.GetAnimationOffset(i, j, 8, 18, 18, 2, 2, animationFrameHeight); - } + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameYOffset = this.GetAnimationOffset(i, j, 8, 18, 18, 2, 2, animationFrameHeight); + } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { diff --git a/Tiles/Furniture/BossTrophy.cs b/Tiles/Furniture/BossTrophy.cs index a79035e324..4a9b94b1f3 100644 --- a/Tiles/Furniture/BossTrophy.cs +++ b/Tiles/Furniture/BossTrophy.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Tiles.Furniture ModTranslation name = CreateMapEntryName(); name.SetDefault("Trophy"); AddMapEntry(new Color(120, 85, 60), name); - TileID.Sets.FramesOnKillWall[Type] = true; + TileID.Sets.FramesOnKillWall[Type] = true; } public override void KillMultiTile(int i, int j, int frameX, int frameY) @@ -99,12 +99,12 @@ namespace CalamityMod.Tiles.Furniture case 22: item = ModContent.ItemType(); break; - case 23: - item = ModContent.ItemType(); - break; - case 24: - item = ModContent.ItemType(); - break; + case 23: + item = ModContent.ItemType(); + break; + case 24: + item = ModContent.ItemType(); + break; case 25: item = ModContent.ItemType(); break; diff --git a/Tiles/Furniture/ChaosCandle.cs b/Tiles/Furniture/ChaosCandle.cs index d69174ff22..f839e30c82 100644 --- a/Tiles/Furniture/ChaosCandle.cs +++ b/Tiles/Furniture/ChaosCandle.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture { - public class ChaosCandle : ModTile + public class ChaosCandle : ModTile { public override void SetDefaults() { @@ -60,7 +60,7 @@ namespace CalamityMod.Tiles.Furniture public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { if (Main.tile[i, j].frameX < 18) - CalamityUtils.DrawFlameSparks(235, 5, i, j); + CalamityUtils.DrawFlameSparks(235, 5, i, j); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) diff --git a/Tiles/Furniture/CraftingStations/AncientAltar.cs b/Tiles/Furniture/CraftingStations/AncientAltar.cs index c8e8fbb474..68cca97d29 100644 --- a/Tiles/Furniture/CraftingStations/AncientAltar.cs +++ b/Tiles/Furniture/CraftingStations/AncientAltar.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations name.SetDefault("Ancient Altar"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Furniture/CraftingStations/AshenAltar.cs b/Tiles/Furniture/CraftingStations/AshenAltar.cs index 62f23fa375..bec7c3eca3 100644 --- a/Tiles/Furniture/CraftingStations/AshenAltar.cs +++ b/Tiles/Furniture/CraftingStations/AshenAltar.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations name.SetDefault("Ashen Altar"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Furniture/CraftingStations/BotanicPlanter.cs b/Tiles/Furniture/CraftingStations/BotanicPlanter.cs index 42827f2518..a7328d4724 100644 --- a/Tiles/Furniture/CraftingStations/BotanicPlanter.cs +++ b/Tiles/Furniture/CraftingStations/BotanicPlanter.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations name.SetDefault("Botanic Planter"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Furniture/CraftingStations/CosmicAnvil.cs b/Tiles/Furniture/CraftingStations/CosmicAnvil.cs index c10221a170..06b79f13cb 100644 --- a/Tiles/Furniture/CraftingStations/CosmicAnvil.cs +++ b/Tiles/Furniture/CraftingStations/CosmicAnvil.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; Main.tileLavaDeath[Type] = false; - Main.tileSolidTop[Type] = true; - Main.tileTable[Type] = true; + Main.tileSolidTop[Type] = true; + Main.tileTable[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style4x2); TileObjectData.newTile.LavaDeath = false; TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; diff --git a/Tiles/Furniture/CraftingStations/EutrophicCrafting.cs b/Tiles/Furniture/CraftingStations/EutrophicCrafting.cs index 91a8230630..1c97fd7e83 100644 --- a/Tiles/Furniture/CraftingStations/EutrophicCrafting.cs +++ b/Tiles/Furniture/CraftingStations/EutrophicCrafting.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations name.SetDefault("Eutrophic Shelf"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) @@ -59,9 +59,9 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 0.5f; - g = 1f; - b = 1f; + r = 0.5f; + g = 1f; + b = 1f; } public override void KillMultiTile(int i, int j, int frameX, int frameY) diff --git a/Tiles/Furniture/CraftingStations/MonolithCrafting.cs b/Tiles/Furniture/CraftingStations/MonolithCrafting.cs index 4436dc9442..98b68a7a92 100644 --- a/Tiles/Furniture/CraftingStations/MonolithCrafting.cs +++ b/Tiles/Furniture/CraftingStations/MonolithCrafting.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.CraftingStations { - public class MonolithCrafting : ModTile + public class MonolithCrafting : ModTile { public override void SetDefaults() { diff --git a/Tiles/Furniture/CraftingStations/PlagueInfuser.cs b/Tiles/Furniture/CraftingStations/PlagueInfuser.cs index 69a5ca684d..f99ed62e10 100644 --- a/Tiles/Furniture/CraftingStations/PlagueInfuser.cs +++ b/Tiles/Furniture/CraftingStations/PlagueInfuser.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = false; - TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.LavaDeath = false; TileObjectData.newTile.Width = 2; TileObjectData.newTile.Height = 4; TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; diff --git a/Tiles/Furniture/CraftingStations/ProfanedBasin.cs b/Tiles/Furniture/CraftingStations/ProfanedBasin.cs index bfb9f3da33..d4135e227e 100644 --- a/Tiles/Furniture/CraftingStations/ProfanedBasin.cs +++ b/Tiles/Furniture/CraftingStations/ProfanedBasin.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations name.SetDefault("Profaned Crucible"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Furniture/CraftingStations/SilvaBasin.cs b/Tiles/Furniture/CraftingStations/SilvaBasin.cs index c57524f6d3..dc387471c5 100644 --- a/Tiles/Furniture/CraftingStations/SilvaBasin.cs +++ b/Tiles/Furniture/CraftingStations/SilvaBasin.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations name.SetDefault("Effulgent Manipulator"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Furniture/CraftingStations/StaticRefiner.cs b/Tiles/Furniture/CraftingStations/StaticRefiner.cs index 6f976e1670..a6c006b00f 100644 --- a/Tiles/Furniture/CraftingStations/StaticRefiner.cs +++ b/Tiles/Furniture/CraftingStations/StaticRefiner.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations name.SetDefault("Static Refiner"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; - //also counts as a Solidifier + //also counts as a Solidifier adjTiles = new int[] { TileID.Solidifier }; } diff --git a/Tiles/Furniture/CraftingStations/VoidCondenser.cs b/Tiles/Furniture/CraftingStations/VoidCondenser.cs index df35f5c7ce..7a86d30b82 100644 --- a/Tiles/Furniture/CraftingStations/VoidCondenser.cs +++ b/Tiles/Furniture/CraftingStations/VoidCondenser.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations Main.tileWaterDeath[Type] = false; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Condenser"); diff --git a/Tiles/Furniture/Fountains/AbyssFountainTile.cs b/Tiles/Furniture/Fountains/AbyssFountainTile.cs index 77b201bca5..0dddd5e61d 100644 --- a/Tiles/Furniture/Fountains/AbyssFountainTile.cs +++ b/Tiles/Furniture/Fountains/AbyssFountainTile.cs @@ -7,12 +7,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.Fountains { - public class AbyssFountainTile : ModTile - { - public override void SetDefaults() - { + public class AbyssFountainTile : ModTile + { + public override void SetDefaults() + { this.SetUpFountain(); - AddMapEntry(new Color(71, 93, 107), Language.GetText("MapObject.WaterFountain")); + AddMapEntry(new Color(71, 93, 107), Language.GetText("MapObject.WaterFountain")); animationFrameHeight = 72; } @@ -55,8 +55,8 @@ namespace CalamityMod.Tiles.Furniture.Fountains } public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); + { + Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); } public override void HitWire(int i, int j) diff --git a/Tiles/Furniture/Fountains/AstralFountainTile.cs b/Tiles/Furniture/Fountains/AstralFountainTile.cs index 860d957e8c..4b35dd698e 100644 --- a/Tiles/Furniture/Fountains/AstralFountainTile.cs +++ b/Tiles/Furniture/Fountains/AstralFountainTile.cs @@ -8,12 +8,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.Fountains { - public class AstralFountainTile : ModTile - { - public override void SetDefaults() - { + public class AstralFountainTile : ModTile + { + public override void SetDefaults() + { this.SetUpFountain(); - AddMapEntry(new Color(59, 50, 77), Language.GetText("MapObject.WaterFountain")); + AddMapEntry(new Color(59, 50, 77), Language.GetText("MapObject.WaterFountain")); animationFrameHeight = 72; } @@ -56,8 +56,8 @@ namespace CalamityMod.Tiles.Furniture.Fountains } public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); + { + Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); } public override void HitWire(int i, int j) diff --git a/Tiles/Furniture/Fountains/SulphurousFountainTile.cs b/Tiles/Furniture/Fountains/SulphurousFountainTile.cs index 751ff7f155..c03f39c0a9 100644 --- a/Tiles/Furniture/Fountains/SulphurousFountainTile.cs +++ b/Tiles/Furniture/Fountains/SulphurousFountainTile.cs @@ -7,12 +7,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.Fountains { - public class SulphurousFountainTile : ModTile - { - public override void SetDefaults() - { + public class SulphurousFountainTile : ModTile + { + public override void SetDefaults() + { this.SetUpFountain(); - AddMapEntry(new Color(104, 195, 255), Language.GetText("MapObject.WaterFountain")); + AddMapEntry(new Color(104, 195, 255), Language.GetText("MapObject.WaterFountain")); animationFrameHeight = 72; } @@ -55,8 +55,8 @@ namespace CalamityMod.Tiles.Furniture.Fountains } public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); + { + Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); } public override void HitWire(int i, int j) diff --git a/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs b/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs index 0c45c652a9..6ee80fb030 100644 --- a/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs +++ b/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs @@ -7,12 +7,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.Fountains { - public class SunkenSeaFountainTile : ModTile - { - public override void SetDefaults() - { + public class SunkenSeaFountainTile : ModTile + { + public override void SetDefaults() + { this.SetUpFountain(); - AddMapEntry(new Color(104, 195, 255), Language.GetText("MapObject.WaterFountain")); + AddMapEntry(new Color(104, 195, 255), Language.GetText("MapObject.WaterFountain")); animationFrameHeight = 72; } @@ -55,8 +55,8 @@ namespace CalamityMod.Tiles.Furniture.Fountains } public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); + { + Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); } public override void HitWire(int i, int j) diff --git a/Tiles/Furniture/PiggyCageTile.cs b/Tiles/Furniture/PiggyCageTile.cs index 900468a087..ed77a7df78 100644 --- a/Tiles/Furniture/PiggyCageTile.cs +++ b/Tiles/Furniture/PiggyCageTile.cs @@ -6,7 +6,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Furniture { - public class PiggyCageTile : ModTile + public class PiggyCageTile : ModTile { public override void SetDefaults() { @@ -34,26 +34,26 @@ namespace CalamityMod.Tiles.Furniture public override void AnimateTile(ref int frame, ref int frameCounter) { - int frameAmt = 34; - int timeNeeded = 6; - if (frame == 0) - { - timeNeeded = 90; - } - if (frame == 25) - { - timeNeeded = 30; - } - frameCounter++; - if (frameCounter >= timeNeeded) - { + int frameAmt = 34; + int timeNeeded = 6; + if (frame == 0) + { + timeNeeded = 90; + } + if (frame == 25) + { + timeNeeded = 30; + } + frameCounter++; + if (frameCounter >= timeNeeded) + { frame++; frameCounter = 0; - } - if (frame >= frameAmt) - { - frame = 0; - } + } + if (frame >= frameAmt) + { + frame = 0; + } } public override void KillMultiTile(int i, int j, int frameX, int frameY) diff --git a/Tiles/Furniture/SCalAltar.cs b/Tiles/Furniture/SCalAltar.cs index e6150ded58..d2ed63dc38 100644 --- a/Tiles/Furniture/SCalAltar.cs +++ b/Tiles/Furniture/SCalAltar.cs @@ -14,7 +14,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Furniture { - public class SCalAltar : ModTile + public class SCalAltar : ModTile { public const int Width = 4; public const int Height = 3; diff --git a/Tiles/Furniture/SeaMinnowJarTile.cs b/Tiles/Furniture/SeaMinnowJarTile.cs index 727fd2a192..718dc44431 100644 --- a/Tiles/Furniture/SeaMinnowJarTile.cs +++ b/Tiles/Furniture/SeaMinnowJarTile.cs @@ -6,7 +6,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Furniture { - public class SeaMinnowJarTile : ModTile + public class SeaMinnowJarTile : ModTile { public override void SetDefaults() { @@ -34,24 +34,24 @@ namespace CalamityMod.Tiles.Furniture public override void AnimateTile(ref int frame, ref int frameCounter) { - int frameAmt = 12; - int timeNeeded = 6; - frameCounter++; - if (frameCounter >= timeNeeded) - { + int frameAmt = 12; + int timeNeeded = 6; + frameCounter++; + if (frameCounter >= timeNeeded) + { frame++; frameCounter = 0; - } - if (frame >= frameAmt) - { - frame = 0; - } + } + if (frame >= frameAmt) + { + frame = 0; + } } - public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) - { - frameYOffset = this.GetAnimationOffset(i, j, 12, 18, 18, 2, 2, animationFrameHeight); - } + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameYOffset = this.GetAnimationOffset(i, j, 12, 18, 18, 2, 2, animationFrameHeight); + } public override void KillMultiTile(int i, int j, int frameX, int frameY) { diff --git a/Tiles/Furniture/TranquilityCandle.cs b/Tiles/Furniture/TranquilityCandle.cs index d13e359157..9b2a0e2f09 100644 --- a/Tiles/Furniture/TranquilityCandle.cs +++ b/Tiles/Furniture/TranquilityCandle.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture { - public class TranquilityCandle : ModTile + public class TranquilityCandle : ModTile { public override void SetDefaults() { @@ -60,7 +60,7 @@ namespace CalamityMod.Tiles.Furniture public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { if (Main.tile[i, j].frameX < 18) - CalamityUtils.DrawFlameSparks(62, 5, i, j); + CalamityUtils.DrawFlameSparks(62, 5, i, j); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) @@ -69,9 +69,9 @@ namespace CalamityMod.Tiles.Furniture } public override bool NewRightClick(int i, int j) - { + { CalamityUtils.RightClickBreak(i, j); - return true; - } + return true; + } } } diff --git a/Tiles/Furniture/TwinklerInABottleTile.cs b/Tiles/Furniture/TwinklerInABottleTile.cs index 901b8a7c59..a8a10c6ae7 100644 --- a/Tiles/Furniture/TwinklerInABottleTile.cs +++ b/Tiles/Furniture/TwinklerInABottleTile.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture { - public class TwinklerInABottleTile : ModTile + public class TwinklerInABottleTile : ModTile { public override void SetDefaults() { @@ -22,24 +22,24 @@ namespace CalamityMod.Tiles.Furniture public override void AnimateTile(ref int frame, ref int frameCounter) { - int frameAmt = 15; - int timeNeeded = 6; - frameCounter++; - if (frameCounter >= timeNeeded) - { + int frameAmt = 15; + int timeNeeded = 6; + frameCounter++; + if (frameCounter >= timeNeeded) + { frame++; frameCounter = 0; - } - if (frame >= frameAmt) - { - frame = 0; - } + } + if (frame >= frameAmt) + { + frame = 0; + } } - public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) - { - frameYOffset = this.GetAnimationOffset(i, j, 15, 16, 18, 1, 2, animationFrameHeight); - } + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameYOffset = this.GetAnimationOffset(i, j, 15, 16, 18, 1, 2, animationFrameHeight); + } public override bool CreateDust(int i, int j, ref int type) { @@ -59,9 +59,9 @@ namespace CalamityMod.Tiles.Furniture public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 1f; - g = 0.39f; - b = 0.28f; + r = 1f; + g = 0.39f; + b = 0.28f; } } } diff --git a/Tiles/FurnitureAbyss/AbyssCandle.cs b/Tiles/FurnitureAbyss/AbyssCandle.cs index 58a567093e..c752127c51 100644 --- a/Tiles/FurnitureAbyss/AbyssCandle.cs +++ b/Tiles/FurnitureAbyss/AbyssCandle.cs @@ -5,11 +5,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureAbyss { - public class AbyssCandle : ModTile + public class AbyssCandle : ModTile { public override void SetDefaults() { - this.SetUpCandle(true, 0); + this.SetUpCandle(true, 0); ModTranslation name = CreateMapEntryName(); name.SetDefault("Candle"); diff --git a/Tiles/FurnitureAbyss/AbyssTorch.cs b/Tiles/FurnitureAbyss/AbyssTorch.cs index ec827168f8..6a2bbe63e2 100644 --- a/Tiles/FurnitureAbyss/AbyssTorch.cs +++ b/Tiles/FurnitureAbyss/AbyssTorch.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss drop = ModContent.ItemType(); adjTiles = new int[] { TileID.Torches }; torch = true; - TileID.Sets.FramesOnKillWall[Type] = true; + TileID.Sets.FramesOnKillWall[Type] = true; } public override bool CreateDust(int i, int j, ref int type) @@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { if (Main.tile[i, j].frameX < 66) - CalamityUtils.DrawFlameSparks(187, 5, i, j); + CalamityUtils.DrawFlameSparks(187, 5, i, j); } public override bool NewRightClick(int i, int j) diff --git a/Tiles/FurnitureAncient/AncientBasin.cs b/Tiles/FurnitureAncient/AncientBasin.cs index d436cacd5b..61b9ed3bd6 100644 --- a/Tiles/FurnitureAncient/AncientBasin.cs +++ b/Tiles/FurnitureAncient/AncientBasin.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Tiles.FurnitureAncient name.SetDefault("Ancient Basin"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/FurnitureAncient/AncientSink.cs b/Tiles/FurnitureAncient/AncientSink.cs index 92c683a99a..bdf01869bb 100644 --- a/Tiles/FurnitureAncient/AncientSink.cs +++ b/Tiles/FurnitureAncient/AncientSink.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureAncient { - public class AncientSink : ModTile + public class AncientSink : ModTile { public override void SetDefaults() { diff --git a/Tiles/FurnitureAshen/AshenBasin.cs b/Tiles/FurnitureAshen/AshenBasin.cs index c51fa931f0..a195bf90f2 100644 --- a/Tiles/FurnitureAshen/AshenBasin.cs +++ b/Tiles/FurnitureAshen/AshenBasin.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Tiles.FurnitureAshen name.SetDefault("Ashen Basin"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/FurnitureAshen/AshenCandelabra.cs b/Tiles/FurnitureAshen/AshenCandelabra.cs index 878f8fea69..b65e888432 100644 --- a/Tiles/FurnitureAshen/AshenCandelabra.cs +++ b/Tiles/FurnitureAshen/AshenCandelabra.cs @@ -78,7 +78,7 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { if (Main.tile[i, j].frameX < 35) - CalamityUtils.DrawFlameSparks(60, 5, i, j); + CalamityUtils.DrawFlameSparks(60, 5, i, j); } } } diff --git a/Tiles/FurnitureAshen/AshenCandle.cs b/Tiles/FurnitureAshen/AshenCandle.cs index a9edd489a4..5155a4efd8 100644 --- a/Tiles/FurnitureAshen/AshenCandle.cs +++ b/Tiles/FurnitureAshen/AshenCandle.cs @@ -74,7 +74,7 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { if (Main.tile[i, j].frameX < 18) - CalamityUtils.DrawFlameSparks(60, 5, i, j); + CalamityUtils.DrawFlameSparks(60, 5, i, j); } } } diff --git a/Tiles/FurnitureAshen/AshenSink.cs b/Tiles/FurnitureAshen/AshenSink.cs index 947d17414e..b401fb07c0 100644 --- a/Tiles/FurnitureAshen/AshenSink.cs +++ b/Tiles/FurnitureAshen/AshenSink.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureAshen { - public class AshenSink : ModTile + public class AshenSink : ModTile { public override void SetDefaults() { diff --git a/Tiles/FurnitureAstral/MonolithPlatform.cs b/Tiles/FurnitureAstral/MonolithPlatform.cs index 643765a99e..d9b9d872f3 100644 --- a/Tiles/FurnitureAstral/MonolithPlatform.cs +++ b/Tiles/FurnitureAstral/MonolithPlatform.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureAstral { - public class MonolithPlatform : ModTile + public class MonolithPlatform : ModTile { public override void SetDefaults() { diff --git a/Tiles/FurnitureBotanic/BotanicSink.cs b/Tiles/FurnitureBotanic/BotanicSink.cs index 10889dd9f1..929d34a9d2 100644 --- a/Tiles/FurnitureBotanic/BotanicSink.cs +++ b/Tiles/FurnitureBotanic/BotanicSink.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureBotanic { - public class BotanicSink : ModTile + public class BotanicSink : ModTile { public override void SetDefaults() { diff --git a/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs b/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs index 71293ec32e..b47008c4d7 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs @@ -9,24 +9,24 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.FurnitureCosmilite { - public class CosmiliteBasinTile : ModTile - { + public class CosmiliteBasinTile : ModTile + { int animationFrame = 0; - public override void SetDefaults() - { - Main.tileLighted[Type] = true; - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = false; + public override void SetDefaults() + { + Main.tileLighted[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); TileObjectData.newTile.LavaDeath = false; - TileObjectData.addTile(Type); - ModTranslation name = CreateMapEntryName(); - name.SetDefault("Cosmilite Basin"); - AddMapEntry(new Color(238, 145, 105), name); + TileObjectData.addTile(Type); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Cosmilite Basin"); + AddMapEntry(new Color(238, 145, 105), name); animationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) @@ -65,8 +65,8 @@ namespace CalamityMod.Tiles.FurnitureCosmilite } public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); + { + Item.NewItem(i * 16, j * 16, 16, 32, ModContent.ItemType()); } public override void HitWire(int i, int j) diff --git a/Tiles/FurnitureCosmilite/CosmiliteSconce.cs b/Tiles/FurnitureCosmilite/CosmiliteSconce.cs index 00a4fd031a..0e3d6c437e 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteSconce.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteSconce.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = false; - TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.LavaDeath = false; TileObjectData.newTile.Height = 3; TileObjectData.newTile.Width = 1; TileObjectData.newTile.CoordinateWidth = 16; @@ -31,8 +31,8 @@ namespace CalamityMod.Tiles.FurnitureCosmilite AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; disableSmartCursor = true; - TileID.Sets.FramesOnKillWall[Type] = true; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + TileID.Sets.FramesOnKillWall[Type] = true; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/FurnitureExo/ExoChestTile.cs b/Tiles/FurnitureExo/ExoChestTile.cs index d89a111903..b634509291 100644 --- a/Tiles/FurnitureExo/ExoChestTile.cs +++ b/Tiles/FurnitureExo/ExoChestTile.cs @@ -53,13 +53,13 @@ namespace CalamityMod.Tiles.FurnitureExo public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - Tile tile = Main.tile[i, j]; - int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; + Tile tile = Main.tile[i, j]; + int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; Texture2D glowmask = ModContent.GetTexture("CalamityMod/Tiles/FurnitureExo/ExoChestGlow"); - Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); + Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - (int)Main.screenPosition.X / 2f, j * 16 - (int)Main.screenPosition.Y + yOffset) + drawOffset; Color drawColour = Color.White; - Main.spriteBatch.Draw(glowmask, drawPosition, new Rectangle(tile.frameX, tile.frameY, 16, 16), drawColour, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(glowmask, drawPosition, new Rectangle(tile.frameX, tile.frameY, 16, 16), drawColour, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } } } diff --git a/Tiles/FurnitureExo/ExoDoorClosed.cs b/Tiles/FurnitureExo/ExoDoorClosed.cs index c797b530e1..99891da5a3 100644 --- a/Tiles/FurnitureExo/ExoDoorClosed.cs +++ b/Tiles/FurnitureExo/ExoDoorClosed.cs @@ -9,7 +9,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.FurnitureExo { - public class ExoDoorClosed : ModTile + public class ExoDoorClosed : ModTile { public override void SetDefaults() { diff --git a/Tiles/FurnitureExo/ExoDoorOpen.cs b/Tiles/FurnitureExo/ExoDoorOpen.cs index 0cad73eaff..94e8cf5cd6 100644 --- a/Tiles/FurnitureExo/ExoDoorOpen.cs +++ b/Tiles/FurnitureExo/ExoDoorOpen.cs @@ -9,7 +9,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.FurnitureExo { - public class ExoDoorOpen : ModTile + public class ExoDoorOpen : ModTile { public override void SetDefaults() { diff --git a/Tiles/FurnitureExo/ExoPlatingTile.cs b/Tiles/FurnitureExo/ExoPlatingTile.cs index 1060043b12..01d5fd21cf 100644 --- a/Tiles/FurnitureExo/ExoPlatingTile.cs +++ b/Tiles/FurnitureExo/ExoPlatingTile.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureExo { - public class ExoPlatingTile : ModTile + public class ExoPlatingTile : ModTile { internal static Texture2D GlowTexture; @@ -53,7 +53,7 @@ namespace CalamityMod.Tiles.FurnitureExo Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j); int xPos = tile.frameX; - int frameOffset = j % 2 * animationFrameHeight; + int frameOffset = j % 2 * animationFrameHeight; int yPos = tile.frameY + frameOffset; Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset; @@ -67,5 +67,5 @@ namespace CalamityMod.Tiles.FurnitureExo spriteBatch.Draw(GlowTexture, drawPosition + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } } - } + } } diff --git a/Tiles/FurnitureExo/ExoPrismPanelTile.cs b/Tiles/FurnitureExo/ExoPrismPanelTile.cs index cea6d571e6..fdded0abc8 100644 --- a/Tiles/FurnitureExo/ExoPrismPanelTile.cs +++ b/Tiles/FurnitureExo/ExoPrismPanelTile.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureExo { - public class ExoPrismPanelTile : ModTile + public class ExoPrismPanelTile : ModTile { internal static Texture2D GlowTexture; @@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurnitureExo public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) { - int frameOffset = (i + j) % 6; + int frameOffset = (i + j) % 6; frameYOffset = frameOffset * animationFrameHeight; } @@ -53,7 +53,7 @@ namespace CalamityMod.Tiles.FurnitureExo Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j); int xPos = tile.frameX; - int frameOffset = (i + j) % 6 * animationFrameHeight; + int frameOffset = (i + j) % 6 * animationFrameHeight; int yPos = tile.frameY + frameOffset; Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset; diff --git a/Tiles/FurnitureExo/ExoPrismPlatformTile.cs b/Tiles/FurnitureExo/ExoPrismPlatformTile.cs index 5ae0896633..d11260e9b4 100644 --- a/Tiles/FurnitureExo/ExoPrismPlatformTile.cs +++ b/Tiles/FurnitureExo/ExoPrismPlatformTile.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureExo { - public class ExoPrismPlatformTile : ModTile + public class ExoPrismPlatformTile : ModTile { internal static Texture2D GlowTexture; @@ -46,7 +46,7 @@ namespace CalamityMod.Tiles.FurnitureExo public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) { - int frameOffset = (i + j) % 6; + int frameOffset = (i + j) % 6; frameYOffset = frameOffset * animationFrameHeight; } @@ -58,7 +58,7 @@ namespace CalamityMod.Tiles.FurnitureExo Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j); int xPos = tile.frameX; - int frameOffset = (i + j) % 6 * animationFrameHeight; + int frameOffset = (i + j) % 6 * animationFrameHeight; int yPos = tile.frameY + frameOffset; Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset; diff --git a/Tiles/FurnitureExo/ExoScreenTile.cs b/Tiles/FurnitureExo/ExoScreenTile.cs index 299e3c7761..e9e36a9c88 100644 --- a/Tiles/FurnitureExo/ExoScreenTile.cs +++ b/Tiles/FurnitureExo/ExoScreenTile.cs @@ -7,7 +7,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.FurnitureExo { - public class ExoScreenTile : ModTile + public class ExoScreenTile : ModTile { public override void SetDefaults() { @@ -28,21 +28,21 @@ namespace CalamityMod.Tiles.FurnitureExo public override void AnimateTile(ref int frame, ref int frameCounter) { - int frameAmt = 4; + int frameAmt = 4; frameCounter++; - // Switch screens every 3 seconds + // Switch screens every 3 seconds if (frameCounter >= 180) { - // Switches to a randomized screen + // Switches to a randomized screen frame = (frame + Main.rand.Next(1, frameAmt)) % frameAmt; frameCounter = 0; } } - public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) - { - frameYOffset = this.GetAnimationOffset(i, j, 4, 18, 18, 3, 2, animationFrameHeight); - } + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameYOffset = this.GetAnimationOffset(i, j, 4, 18, 18, 3, 2, animationFrameHeight); + } public override bool CanExplode(int i, int j) => false; @@ -58,13 +58,13 @@ namespace CalamityMod.Tiles.FurnitureExo public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - Tile tile = Main.tile[i, j]; - int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; + Tile tile = Main.tile[i, j]; + int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; Texture2D glowmask = ModContent.GetTexture("CalamityMod/Tiles/FurnitureExo/ExoScreenGlow"); - Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); + Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - (int)Main.screenPosition.X / 2f, j * 16 - (int)Main.screenPosition.Y + yOffset) + drawOffset; Color drawColour = Color.White; - Main.spriteBatch.Draw(glowmask, drawPosition, new Rectangle(tile.frameX, tile.frameY, 16, 16), drawColour, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(glowmask, drawPosition, new Rectangle(tile.frameX, tile.frameY, 16, 16), drawColour, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } } } diff --git a/Tiles/FurnitureExo/ExoToiletTile.cs b/Tiles/FurnitureExo/ExoToiletTile.cs index a828e8873a..eb6e7e0e50 100644 --- a/Tiles/FurnitureExo/ExoToiletTile.cs +++ b/Tiles/FurnitureExo/ExoToiletTile.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Tiles.FurnitureExo TileObjectData.addAlternate(1); TileObjectData.addTile(Type); - // Toilets count as Chairs + // Toilets count as Chairs AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); ModTranslation name = CreateMapEntryName(); diff --git a/Tiles/FurnitureOccult/OccultCandle.cs b/Tiles/FurnitureOccult/OccultCandle.cs index 2abc23bf00..b780778b29 100644 --- a/Tiles/FurnitureOccult/OccultCandle.cs +++ b/Tiles/FurnitureOccult/OccultCandle.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureOccult { - public class OccultCandle : ModTile + public class OccultCandle : ModTile { public override void SetDefaults() { diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs index e66266ed3b..af025ad57c 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs @@ -14,13 +14,13 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = false; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Broken Plagued 'Bed'"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs index 92a0c81865..ca6cffc7b2 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate Main.tileLavaDeath[Type] = false; TileID.Sets.HasOutlines[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); //This bed has different dimensions to conventional beds, using bookcase dimentions instead - TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.LavaDeath = false; TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); diff --git a/Tiles/FurnitureProfaned/ProfanedCandelabra.cs b/Tiles/FurnitureProfaned/ProfanedCandelabra.cs index fe284a0a65..6754512810 100644 --- a/Tiles/FurnitureProfaned/ProfanedCandelabra.cs +++ b/Tiles/FurnitureProfaned/ProfanedCandelabra.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { if (Main.tile[i, j].frameX < 35) - CalamityUtils.DrawFlameSparks(246, 5, i, j); + CalamityUtils.DrawFlameSparks(246, 5, i, j); } } } diff --git a/Tiles/FurnitureProfaned/ProfanedCandle.cs b/Tiles/FurnitureProfaned/ProfanedCandle.cs index e301cd61d7..d7e8cccfbc 100644 --- a/Tiles/FurnitureProfaned/ProfanedCandle.cs +++ b/Tiles/FurnitureProfaned/ProfanedCandle.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { if (Main.tile[i, j].frameX < 18) - CalamityUtils.DrawFlameSparks(246, 5, i, j); + CalamityUtils.DrawFlameSparks(246, 5, i, j); } } } diff --git a/Tiles/FurnitureProfaned/ProfanedLantern.cs b/Tiles/FurnitureProfaned/ProfanedLantern.cs index 90df9f4548..292c16686d 100644 --- a/Tiles/FurnitureProfaned/ProfanedLantern.cs +++ b/Tiles/FurnitureProfaned/ProfanedLantern.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) { if (Main.tile[i, j].frameX < 18) - CalamityUtils.DrawFlameSparks(246, 5, i, j); + CalamityUtils.DrawFlameSparks(246, 5, i, j); } } } diff --git a/Tiles/FurnitureProfaned/ProfanedPiano.cs b/Tiles/FurnitureProfaned/ProfanedPiano.cs index 33dedbf73a..146600ca0b 100644 --- a/Tiles/FurnitureProfaned/ProfanedPiano.cs +++ b/Tiles/FurnitureProfaned/ProfanedPiano.cs @@ -16,12 +16,12 @@ namespace CalamityMod.Tiles.FurnitureProfaned Main.tileLavaDeath[Type] = false; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Piano"); AddMapEntry(new Color(191, 142, 111), name); - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/FurnitureProfaned/ProfanedSink.cs b/Tiles/FurnitureProfaned/ProfanedSink.cs index 8847c27b14..4006478c3a 100644 --- a/Tiles/FurnitureProfaned/ProfanedSink.cs +++ b/Tiles/FurnitureProfaned/ProfanedSink.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureProfaned { - public class ProfanedSink : ModTile + public class ProfanedSink : ModTile { public override void SetDefaults() { diff --git a/Tiles/FurnitureStratus/StratusCandle.cs b/Tiles/FurnitureStratus/StratusCandle.cs index 131ed89993..a296c32845 100644 --- a/Tiles/FurnitureStratus/StratusCandle.cs +++ b/Tiles/FurnitureStratus/StratusCandle.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureStratus { - public class StratusCandle : ModTile + public class StratusCandle : ModTile { public override void SetDefaults() { diff --git a/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs b/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs index 289fc8ceac..ca29bfe6e4 100644 --- a/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs +++ b/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs @@ -9,88 +9,88 @@ using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.LivingFire { - public class LivingBrimstoneFireBlockTile : ModTile - { - //Thank you to Seraph for getting living fire blocks to work properly. - public override void SetDefaults() - { - Main.tileLighted[Type] = true; - soundType = SoundID.Dig; - drop = ModContent.ItemType(); - AddMapEntry(new Color(178, 34, 34)); - animationFrameHeight = 90; - Main.tileSolid[Type] = false; - Main.tileNoAttach[Type] = false; - Main.tileFrameImportant[Type] = false; - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 1; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.HookCheck = new PlacementHook(CanPlaceAlter, -1, 0, true ); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); + public class LivingBrimstoneFireBlockTile : ModTile + { + //Thank you to Seraph for getting living fire blocks to work properly. + public override void SetDefaults() + { + Main.tileLighted[Type] = true; + soundType = SoundID.Dig; + drop = ModContent.ItemType(); + AddMapEntry(new Color(178, 34, 34)); + animationFrameHeight = 90; + Main.tileSolid[Type] = false; + Main.tileNoAttach[Type] = false; + Main.tileFrameImportant[Type] = false; + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.HookCheck = new PlacementHook(CanPlaceAlter, -1, 0, true ); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); - TileObjectData.addTile(Type); - } + TileObjectData.addTile(Type); + } - public int CanPlaceAlter(int i, int j, int type, int style, int direction) => 1; + public int CanPlaceAlter(int i, int j, int type, int style, int direction) => 1; - public static int AfterPlacement(int i, int j, int type, int style, int direction) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendTileRange(Main.myPlayer, i, j, 1, 1); - } - return 1; - } + public static int AfterPlacement(int i, int j, int type, int style, int direction) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileRange(Main.myPlayer, i, j, 1, 1); + } + return 1; + } - public override bool CanPlace(int i, int j) - { - List> around = new List> - { - new List() {i, j-1 }, - new List() {i-1, j }, - new List() {i+1, j }, - new List() {i, j+1 } - }; - //if (Main.tile[i, j]) || tile.type == Type + public override bool CanPlace(int i, int j) + { + List> around = new List> + { + new List() {i, j-1 }, + new List() {i-1, j }, + new List() {i+1, j }, + new List() {i, j+1 } + }; + //if (Main.tile[i, j]) || tile.type == Type - //return true; //temporary for testing purposes + //return true; //temporary for testing purposes - if (Main.tile[i, j].wall != WallID.None) - { - return true; - } + if (Main.tile[i, j].wall != WallID.None) + { + return true; + } - for (int k = 0; k < around.Count; ++k) - { - Tile tile = Main.tile[around[k][0], around[k][1]]; - if (tile.active() && (Main.tileSolid[tile.type] || CalamityLists.livingFireBlockList.Contains(tile.type))) - { - return true; - } - } - return false; - } + for (int k = 0; k < around.Count; ++k) + { + Tile tile = Main.tile[around[k][0], around[k][1]]; + if (tile.active() && (Main.tileSolid[tile.type] || CalamityLists.livingFireBlockList.Contains(tile.type))) + { + return true; + } + } + return false; + } - public override void AnimateTile(ref int frame, ref int frameCounter) - { - frame = Main.tileFrame[TileID.LivingFire]; - } + public override void AnimateTile(ref int frame, ref int frameCounter) + { + frame = Main.tileFrame[TileID.LivingFire]; + } - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 1f; - g = 0f; - b = 0f; - } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 1f; + g = 0f; + b = 0f; + } - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.Brimstone, 0f, 0f, 1, default, 1f); - return false; - } - } + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.Brimstone, 0f, 0f, 1, default, 1f); + return false; + } + } } diff --git a/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs b/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs index f7f2b393ee..0d449a21f5 100644 --- a/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs +++ b/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs @@ -9,87 +9,87 @@ using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.LivingFire { - public class LivingGodSlayerFireBlockTile : ModTile - { - public override void SetDefaults() - { - Main.tileLighted[Type] = true; - soundType = SoundID.Dig; - drop = ModContent.ItemType(); - AddMapEntry(new Color(186, 85, 211)); - animationFrameHeight = 90; - Main.tileSolid[Type] = false; - Main.tileNoAttach[Type] = false; - Main.tileFrameImportant[Type] = false; - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 1; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.HookCheck = new PlacementHook(CanPlaceAlter, -1, 0, true ); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); + public class LivingGodSlayerFireBlockTile : ModTile + { + public override void SetDefaults() + { + Main.tileLighted[Type] = true; + soundType = SoundID.Dig; + drop = ModContent.ItemType(); + AddMapEntry(new Color(186, 85, 211)); + animationFrameHeight = 90; + Main.tileSolid[Type] = false; + Main.tileNoAttach[Type] = false; + Main.tileFrameImportant[Type] = false; + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.HookCheck = new PlacementHook(CanPlaceAlter, -1, 0, true ); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); - TileObjectData.addTile(Type); - } + TileObjectData.addTile(Type); + } - public int CanPlaceAlter(int i, int j, int type, int style, int direction) => 1; + public int CanPlaceAlter(int i, int j, int type, int style, int direction) => 1; - public static int AfterPlacement(int i, int j, int type, int style, int direction) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendTileRange(Main.myPlayer, i, j, 1, 1); - } - return 1; - } + public static int AfterPlacement(int i, int j, int type, int style, int direction) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileRange(Main.myPlayer, i, j, 1, 1); + } + return 1; + } - public override bool CanPlace(int i, int j) - { - List> around = new List> - { - new List() {i, j-1 }, - new List() {i-1, j }, - new List() {i+1, j }, - new List() {i, j+1 } - }; - //if (Main.tile[i, j]) || tile.type == Type + public override bool CanPlace(int i, int j) + { + List> around = new List> + { + new List() {i, j-1 }, + new List() {i-1, j }, + new List() {i+1, j }, + new List() {i, j+1 } + }; + //if (Main.tile[i, j]) || tile.type == Type - //return true; //temporary for testing purposes + //return true; //temporary for testing purposes - if (Main.tile[i, j].wall != WallID.None) - { - return true; - } + if (Main.tile[i, j].wall != WallID.None) + { + return true; + } - for (int k = 0; k < around.Count; ++k) - { - Tile tile = Main.tile[around[k][0], around[k][1]]; - if (tile.active() && (Main.tileSolid[tile.type] || CalamityLists.livingFireBlockList.Contains(tile.type))) - { - return true; - } - } - return false; - } + for (int k = 0; k < around.Count; ++k) + { + Tile tile = Main.tile[around[k][0], around[k][1]]; + if (tile.active() && (Main.tileSolid[tile.type] || CalamityLists.livingFireBlockList.Contains(tile.type))) + { + return true; + } + } + return false; + } - public override void AnimateTile(ref int frame, ref int frameCounter) - { - frame = Main.tileFrame[TileID.LivingFire]; - } + public override void AnimateTile(ref int frame, ref int frameCounter) + { + frame = Main.tileFrame[TileID.LivingFire]; + } - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 1f; - g = 0f; - b = 1f; - } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 1f; + g = 0f; + b = 1f; + } - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 1, default, 1f); - return false; - } - } + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 1, default, 1f); + return false; + } + } } diff --git a/Tiles/LivingFire/LivingHolyFireBlockTile.cs b/Tiles/LivingFire/LivingHolyFireBlockTile.cs index be221fddc6..b3aa279e35 100644 --- a/Tiles/LivingFire/LivingHolyFireBlockTile.cs +++ b/Tiles/LivingFire/LivingHolyFireBlockTile.cs @@ -9,87 +9,87 @@ using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.LivingFire { - public class LivingHolyFireBlockTile : ModTile - { - public override void SetDefaults() - { - Main.tileLighted[Type] = true; - soundType = SoundID.Dig; - drop = ModContent.ItemType(); - AddMapEntry(new Color(255, 215, 0)); - animationFrameHeight = 90; - Main.tileSolid[Type] = false; - Main.tileNoAttach[Type] = false; - Main.tileFrameImportant[Type] = false; - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 1; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.HookCheck = new PlacementHook(CanPlaceAlter, -1, 0, true ); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); + public class LivingHolyFireBlockTile : ModTile + { + public override void SetDefaults() + { + Main.tileLighted[Type] = true; + soundType = SoundID.Dig; + drop = ModContent.ItemType(); + AddMapEntry(new Color(255, 215, 0)); + animationFrameHeight = 90; + Main.tileSolid[Type] = false; + Main.tileNoAttach[Type] = false; + Main.tileFrameImportant[Type] = false; + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.HookCheck = new PlacementHook(CanPlaceAlter, -1, 0, true ); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); - TileObjectData.addTile(Type); - } + TileObjectData.addTile(Type); + } - public int CanPlaceAlter(int i, int j, int type, int style, int direction) => 1; + public int CanPlaceAlter(int i, int j, int type, int style, int direction) => 1; - public static int AfterPlacement(int i, int j, int type, int style, int direction) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendTileRange(Main.myPlayer, i, j, 1, 1); - } - return 1; - } + public static int AfterPlacement(int i, int j, int type, int style, int direction) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileRange(Main.myPlayer, i, j, 1, 1); + } + return 1; + } - public override bool CanPlace(int i, int j) - { - List> around = new List> - { - new List() {i, j-1 }, - new List() {i-1, j }, - new List() {i+1, j }, - new List() {i, j+1 } - }; - //if (Main.tile[i, j]) || tile.type == Type + public override bool CanPlace(int i, int j) + { + List> around = new List> + { + new List() {i, j-1 }, + new List() {i-1, j }, + new List() {i+1, j }, + new List() {i, j+1 } + }; + //if (Main.tile[i, j]) || tile.type == Type - //return true; //temporary for testing purposes + //return true; //temporary for testing purposes - if (Main.tile[i, j].wall != WallID.None) - { - return true; - } + if (Main.tile[i, j].wall != WallID.None) + { + return true; + } - for (int k = 0; k < around.Count; ++k) - { - Tile tile = Main.tile[around[k][0], around[k][1]]; - if (tile.active() && (Main.tileSolid[tile.type] || CalamityLists.livingFireBlockList.Contains(tile.type))) - { - return true; - } - } - return false; - } + for (int k = 0; k < around.Count; ++k) + { + Tile tile = Main.tile[around[k][0], around[k][1]]; + if (tile.active() && (Main.tileSolid[tile.type] || CalamityLists.livingFireBlockList.Contains(tile.type))) + { + return true; + } + } + return false; + } - public override void AnimateTile(ref int frame, ref int frameCounter) - { - frame = Main.tileFrame[TileID.LivingFire]; - } + public override void AnimateTile(ref int frame, ref int frameCounter) + { + frame = Main.tileFrame[TileID.LivingFire]; + } - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 1f; - g = 1f; - b = 0f; - } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 1f; + g = 1f; + b = 0f; + } - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.ProfanedFire, 0f, 0f, 1, default, 1f); - return false; - } - } + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.ProfanedFire, 0f, 0f, 1, default, 1f); + return false; + } + } } diff --git a/Tiles/MonsterBanner.cs b/Tiles/MonsterBanner.cs index 483bec02db..8877eed27a 100644 --- a/Tiles/MonsterBanner.cs +++ b/Tiles/MonsterBanner.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Tiles TileObjectData.newTile.Height = 3; TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.SolidBottom, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.SolidBottom, TileObjectData.newTile.Width, 0); TileObjectData.addTile(Type); dustType = -1; disableSmartCursor = true; @@ -31,9 +31,9 @@ namespace CalamityMod.Tiles public override void KillMultiTile(int i, int j, int frameX, int frameY) { int style = frameX / 18; - int banner = CalamityUtils.GetBannerItem(style); - if (banner != -1) - Item.NewItem(i * 16, j * 16, 16, 48, banner); + int banner = CalamityUtils.GetBannerItem(style); + if (banner != -1) + Item.NewItem(i * 16, j * 16, 16, 48, banner); } public override void NearbyEffects(int i, int j, bool closer) @@ -45,12 +45,12 @@ namespace CalamityMod.Tiles return; int style = Main.tile[i, j].frameX / 18; - int npc = CalamityUtils.GetBannerNPC(style); - if (npc != -1) - { - player.NPCBannerBuff[npc] = true; - player.hasBanner = true; - } + int npc = CalamityUtils.GetBannerNPC(style); + if (npc != -1) + { + player.NPCBannerBuff[npc] = true; + player.hasBanner = true; + } } public override void SetSpriteEffects(int i, int j, ref SpriteEffects spriteEffects) diff --git a/Tiles/Ores/AuricOre.cs b/Tiles/Ores/AuricOre.cs index 3e41aed103..9e80a75a8a 100644 --- a/Tiles/Ores/AuricOre.cs +++ b/Tiles/Ores/AuricOre.cs @@ -5,7 +5,7 @@ using Terraria.ID; namespace CalamityMod.Tiles.Ores { - public class AuricOre : ModTile + public class AuricOre : ModTile { public override void SetDefaults() { diff --git a/Tiles/Ores/CharredOre.cs b/Tiles/Ores/CharredOre.cs index 7d806012a3..56e3b4981f 100644 --- a/Tiles/Ores/CharredOre.cs +++ b/Tiles/Ores/CharredOre.cs @@ -6,7 +6,7 @@ using Terraria.ID; namespace CalamityMod.Tiles.Ores { - public class CharredOre : ModTile + public class CharredOre : ModTile { private int sheetWidth = 288; private int sheetHeight = 270; diff --git a/Tiles/Ores/HallowedOre.cs b/Tiles/Ores/HallowedOre.cs index 9d0161b1ff..8235c1f242 100644 --- a/Tiles/Ores/HallowedOre.cs +++ b/Tiles/Ores/HallowedOre.cs @@ -11,8 +11,8 @@ namespace CalamityMod.Tiles.Ores { Main.tileLighted[Type] = true; Main.tileSolid[Type] = true; - Main.tileMergeDirt[Type] = true; - Main.tileBlockLight[Type] = true; + Main.tileMergeDirt[Type] = true; + Main.tileBlockLight[Type] = true; Main.tileValue[Type] = 690; CalamityUtils.MergeWithGeneral(Type); diff --git a/Tiles/PerennialBar.cs b/Tiles/PerennialBar.cs index ed08414383..2ad2f1d48f 100644 --- a/Tiles/PerennialBar.cs +++ b/Tiles/PerennialBar.cs @@ -9,14 +9,14 @@ namespace CalamityMod.Tiles { public override void SetDefaults() { - this.SetUpBar(new Color(157, 255, 0)); + this.SetUpBar(new Color(157, 255, 0)); dustType = 44; drop = ModContent.ItemType(); } public override bool CreateDust(int i, int j, ref int type) { - type = Main.rand.NextBool() ? 44 : 157; + type = Main.rand.NextBool() ? 44 : 157; return true; } } diff --git a/Tiles/Plates/PlagueContainmentCells.cs b/Tiles/Plates/PlagueContainmentCells.cs index 448d6ecfa9..ea73b12a9e 100644 --- a/Tiles/Plates/PlagueContainmentCells.cs +++ b/Tiles/Plates/PlagueContainmentCells.cs @@ -6,7 +6,7 @@ using Terraria.ID; namespace CalamityMod.Tiles.Plates { - public class PlagueContainmentCells : ModTile + public class PlagueContainmentCells : ModTile { internal static Texture2D GlowTexture; internal static Texture2D PulseTexture; diff --git a/Tiles/ShadowspecBarTile.cs b/Tiles/ShadowspecBarTile.cs index b552474b0c..faea740711 100644 --- a/Tiles/ShadowspecBarTile.cs +++ b/Tiles/ShadowspecBarTile.cs @@ -5,11 +5,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class ShadowspecBarTile : ModTile + public class ShadowspecBarTile : ModTile { public override void SetDefaults() { - this.SetUpBar(new Color(128, 41, 149)); + this.SetUpBar(new Color(128, 41, 149)); dustType = ModContent.DustType(); drop = ModContent.ItemType(); } diff --git a/Tiles/SunkenSea/SunkenCrateTile.cs b/Tiles/SunkenSea/SunkenCrateTile.cs index 35b5edabd5..f3a9d887ea 100644 --- a/Tiles/SunkenSea/SunkenCrateTile.cs +++ b/Tiles/SunkenSea/SunkenCrateTile.cs @@ -6,7 +6,7 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.SunkenSea { - public class SunkenCrateTile : ModTile + public class SunkenCrateTile : ModTile { public override void SetDefaults() { diff --git a/Tiles/UelibloomBar.cs b/Tiles/UelibloomBar.cs index 1c43c0d34c..08d3d55059 100644 --- a/Tiles/UelibloomBar.cs +++ b/Tiles/UelibloomBar.cs @@ -10,14 +10,14 @@ namespace CalamityMod.Tiles { public override void SetDefaults() { - this.SetUpBar(new Color(134, 209, 102)); + this.SetUpBar(new Color(134, 209, 102)); dustType = ModContent.DustType(); drop = ModContent.ItemType(); } public override bool CreateDust(int i, int j, ref int type) { - type = Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType(); + type = Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType(); return true; } } diff --git a/UI/BossHealthBarManager.cs b/UI/BossHealthBarManager.cs index 1264a7f32b..ef78160bea 100644 --- a/UI/BossHealthBarManager.cs +++ b/UI/BossHealthBarManager.cs @@ -697,7 +697,7 @@ namespace CalamityMod.UI } } else if (NPCIsIncreasingDefenseOrDR) - { + { if (IncreasingDefenseOrDRTimer > 0) { float pulse = (float)Math.Sin(Main.GlobalTime * 4.5f) * 0.5f + 0.5f; diff --git a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs index b093479f02..87630a768f 100644 --- a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs +++ b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs @@ -10,400 +10,400 @@ using Terraria.UI.Chat; namespace CalamityMod.UI.CalamitasEnchants { - public class CalamitasEnchantUI - { - public static int NPCIndex = -1; - public static int EnchantIndex = 0; - public static Enchantment? SelectedEnchantment = null; - public static Item CurrentlyHeldItem = new Item(); - public static float TopButtonClickCountdown = 0f; - public static float BottomButtonClickCountdown = 0f; - public static float ReforgeButtonClickCountdown = 0f; + public class CalamitasEnchantUI + { + public static int NPCIndex = -1; + public static int EnchantIndex = 0; + public static Enchantment? SelectedEnchantment = null; + public static Item CurrentlyHeldItem = new Item(); + public static float TopButtonClickCountdown = 0f; + public static float BottomButtonClickCountdown = 0f; + public static float ReforgeButtonClickCountdown = 0f; - public static bool CurrentlyViewing = false; + public static bool CurrentlyViewing = false; - public static readonly Vector2 ReforgeUITopLeft = new Vector2(68f, 320f); - public static readonly float ResolutionRatio = Main.screenHeight / 1440f; + public static readonly Vector2 ReforgeUITopLeft = new Vector2(68f, 320f); + public static readonly float ResolutionRatio = Main.screenHeight / 1440f; - public static Rectangle MouseScreenArea => Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f); + public static Rectangle MouseScreenArea => Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f); - public static bool InRangeOfNPC() - { - // Don't bother trying if no valid NPC has been selected yet. - if (!Main.npc.IndexInRange(NPCIndex) || !Main.npc[NPCIndex].active) - return false; - - Rectangle validTalkArea = Utils.CenteredRectangle(Main.LocalPlayer.Center, new Vector2(Player.tileRangeX * 3f, Player.tileRangeY * 2f) * 16f); - return validTalkArea.Intersects(Main.npc[NPCIndex].Hitbox); - } - - public static void Draw(SpriteBatch spriteBatch) - { - // Decrement click cooldowns. - // This is done so that click textures do not instantly disappear. - if (TopButtonClickCountdown > 0f) - TopButtonClickCountdown--; - if (BottomButtonClickCountdown > 0f) - BottomButtonClickCountdown--; - if (ReforgeButtonClickCountdown > 0f) - ReforgeButtonClickCountdown--; - - // Don't bother doing anything except resetting if not looking at the UI. - if (!CurrentlyViewing) - { - // If an item was stored, release it back into the world. - if (!CurrentlyHeldItem.IsAir) - { - Main.LocalPlayer.QuickSpawnClonedItem(CurrentlyHeldItem, CurrentlyHeldItem.stack); - CurrentlyHeldItem.TurnToAir(); - } - - EnchantIndex = 0; - NPCIndex = -1; - return; - } - - // Check if the player can still be in the UI. - if (Main.LocalPlayer.chest != -1 || Main.LocalPlayer.sign != -1 || Main.LocalPlayer.talkNPC == -1 || !Main.playerInventory || !InRangeOfNPC() || Main.InGuideCraftMenu) - { - CurrentlyViewing = false; - - // Check if the player has any items being held. - // If they do, drop it onto the ground. - Main.LocalPlayer.dropItemCheck(); - - // Reload visible recipes in case the dropped item was an ingredient. - Recipe.FindRecipes(); - return; - } - - // Open the inventory and stop talking to any NPCs by default while the UI is open, similar to the goblin tinkerer. - Main.playerInventory = true; - Main.npcChatText = string.Empty; - - Texture2D backgroundTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseBackground"); - Vector2 backgroundScale = Vector2.One * Main.UIScale; - - // Draw the background. - spriteBatch.Draw(backgroundTexture, ReforgeUITopLeft, null, Color.White, 0f, Vector2.Zero, backgroundScale, SpriteEffects.None, 0f); - - // Prevent the player from say, firing a weapon while the mouse is hovering over the UI. - DisableMouseWhenOverUI(backgroundTexture, backgroundScale); - - // Select the enchantment to use. - IEnumerable possibleEnchantments = SelectEnchantment(); - - // Draw the cost and description. - int cost = 0; - if (SelectedEnchantment.HasValue) - { - Point costDrawPositionTopLeft = (ReforgeUITopLeft + new Vector2(50f, 78f) * backgroundScale).ToPoint(); - cost = DrawEnchantmentCost(spriteBatch, costDrawPositionTopLeft); - Point descriptionDrawPositionTopLeft = costDrawPositionTopLeft; - descriptionDrawPositionTopLeft.Y += (int)(Main.UIScale * 70f); - Vector2 iconDrawPositionTopLeft = costDrawPositionTopLeft.ToVector2() + new Vector2(270f, -24f) * Main.UIScale; - - DrawEnchantmentDescription(spriteBatch, descriptionDrawPositionTopLeft); - if (!string.IsNullOrEmpty(SelectedEnchantment.Value.IconTexturePath)) - { - Texture2D iconTexture = ModContent.GetTexture(SelectedEnchantment.Value.IconTexturePath); - DrawIcon(spriteBatch, iconDrawPositionTopLeft, iconTexture); - } - } - - // Draw the item icon. - Vector2 itemSlotDrawPosition = ReforgeUITopLeft + new Vector2(30f, 50f) * backgroundScale; - Vector2 reforgeIconDrawPosition = ReforgeUITopLeft + new Vector2(84f, 60f) * backgroundScale; - DrawItemIcon(spriteBatch, itemSlotDrawPosition, reforgeIconDrawPosition, backgroundScale, out bool isHoveringOverItemIcon, out bool isHoveringOverReforgeIcon); - if (isHoveringOverItemIcon) - InteractWithItemSlot(); - - // Draw the buttons. - DrawAndInteractWithButtons(spriteBatch, possibleEnchantments, ReforgeUITopLeft + new Vector2(210f, 50f) * backgroundScale, ReforgeUITopLeft + new Vector2(210f, 90f) * backgroundScale, backgroundScale); - - // Draw the enchantment name. - if (SelectedEnchantment.HasValue) - DrawEnchantmentName(spriteBatch, ReforgeUITopLeft + new Vector2(216f, 66f) * backgroundScale); - - // Handle spending logic. - if (isHoveringOverReforgeIcon) - { - if (Main.mouseLeft && Main.mouseLeftRelease) - { - InteractWithEnchantIcon(cost); - ReforgeButtonClickCountdown = 15f; - } - } - } - - public static void DisableMouseWhenOverUI(Texture2D backgroundTexture, Vector2 backgroundScale) - { - Rectangle backgroundArea = new Rectangle((int)ReforgeUITopLeft.X, (int)ReforgeUITopLeft.Y, (int)(backgroundTexture.Width * backgroundScale.X), (int)(backgroundTexture.Width * backgroundScale.Y)); - - if (MouseScreenArea.Intersects(backgroundArea)) - { - Main.LocalPlayer.mouseInterface = false; - Main.blockMouse = true; - } - } - - public static IEnumerable SelectEnchantment() - { - IEnumerable possibleEnchantments = EnchantmentManager.GetValidEnchantmentsForItem(CurrentlyHeldItem); - - // Select the enchantment based on an index in the possible enchantments. - // If no possible enchantments were found, default to null. - SelectedEnchantment = null; - - if (possibleEnchantments.Count() > 0) - SelectedEnchantment = possibleEnchantments.ElementAt(EnchantIndex); - - return possibleEnchantments; - } - - public static int DrawEnchantmentCost(SpriteBatch spriteBatch, Point costDrawPositionTopLeft) - { - if (CurrentlyHeldItem.IsAir) - return 0; - - int cost = CurrentlyHeldItem.value * 4; - - // Increase the cost of enchanting significantly if doing so would upgrade the item directly. - if (SelectedEnchantment.HasValue && SelectedEnchantment.Value.Name == EnchantmentManager.UpgradeEnchantName) - cost = (int)MathHelper.Min(cost, Item.buyPrice(5)) * 5; - - // Make it 20% cheaper if the player has the Discount Card or Greedy Ring - if (Main.LocalPlayer.discount) - cost = (int)(cost * 0.8); - - // Draw the coin costs. - string costText = "Cost: "; - Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, costText, costDrawPositionTopLeft.X, costDrawPositionTopLeft.Y + 45f * Main.UIScale, Color.White * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, Main.UIScale); - costDrawPositionTopLeft.X += (int)((Main.fontMouseText.MeasureString(costText).X * 0.5f + 12f) * Main.UIScale); - - int[] coinsArray = Utils.CoinsSplit(cost); - for (int i = 0; i < 4; i++) - { - Vector2 drawPosition = new Vector2(costDrawPositionTopLeft.X + (ChatManager.GetStringSize(Main.fontMouseText, costText, Vector2.One, -1f).X + ((24 * i) - 24f)) * Main.UIScale, costDrawPositionTopLeft.Y + 54f * Main.UIScale); - spriteBatch.Draw(Main.itemTexture[ItemID.PlatinumCoin - i], drawPosition, null, Color.White, 0f, Main.itemTexture[ItemID.PlatinumCoin - i].Size() * 0.5f, Main.UIScale, SpriteEffects.None, 0f); - Utils.DrawBorderStringFourWay(spriteBatch, Main.fontItemStack, coinsArray[3 - i].ToString(), drawPosition.X - 11f, drawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), 0.75f * Main.UIScale); - } - - return cost; - } - - public static void DrawEnchantmentDescription(SpriteBatch spriteBatch, Point descriptionDrawPositionTopLeft) - { - Vector2 vectorDrawPosition = descriptionDrawPositionTopLeft.ToVector2(); - Vector2 scale = new Vector2(0.8f, 0.825f) * MathHelper.Clamp(ResolutionRatio, 0.825f, 1f) * Main.UIScale; - - string unifiedDescription = SelectedEnchantment.Value.Description.Replace("\n", " "); - foreach (string line in Utils.WordwrapString(unifiedDescription, Main.fontMouseText, 400, 16, out _)) - { - if (string.IsNullOrEmpty(line)) - continue; - - ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, line, vectorDrawPosition, Color.Orange, 0f, Vector2.Zero, scale); - vectorDrawPosition.Y += Main.UIScale * 16f; - } - } - - public static void DrawIcon(SpriteBatch spriteBatch, Vector2 drawPositionTopLeft, Texture2D texture) + public static bool InRangeOfNPC() { - spriteBatch.Draw(texture, drawPositionTopLeft, null, Color.White, 0f, Vector2.Zero, Main.UIScale, SpriteEffects.None, 0f); - } + // Don't bother trying if no valid NPC has been selected yet. + if (!Main.npc.IndexInRange(NPCIndex) || !Main.npc[NPCIndex].active) + return false; - public static void DrawItemIcon(SpriteBatch spriteBatch, Vector2 itemSlotDrawPosition, Vector2 reforgeIconDrawPosition, Vector2 scale, out bool isHoveringOverItemIcon, out bool isHoveringOverReforgeIcon) - { - isHoveringOverReforgeIcon = false; - Texture2D itemSlotTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseItemSlot"); + Rectangle validTalkArea = Utils.CenteredRectangle(Main.LocalPlayer.Center, new Vector2(Player.tileRangeX * 3f, Player.tileRangeY * 2f) * 16f); + return validTalkArea.Intersects(Main.npc[NPCIndex].Hitbox); + } - Texture2D reforgeIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_Button"); - Rectangle reforgeIconArea = new Rectangle((int)reforgeIconDrawPosition.X, (int)reforgeIconDrawPosition.Y, (int)(reforgeIconTexture.Width * scale.X), (int)(reforgeIconTexture.Height * scale.Y)); + public static void Draw(SpriteBatch spriteBatch) + { + // Decrement click cooldowns. + // This is done so that click textures do not instantly disappear. + if (TopButtonClickCountdown > 0f) + TopButtonClickCountdown--; + if (BottomButtonClickCountdown > 0f) + BottomButtonClickCountdown--; + if (ReforgeButtonClickCountdown > 0f) + ReforgeButtonClickCountdown--; - // Have the reforge icon light up if the mouse is hovering over it. - if (MouseScreenArea.Intersects(reforgeIconArea)) - { - reforgeIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ButtonHovered"); - isHoveringOverReforgeIcon = true; - } + // Don't bother doing anything except resetting if not looking at the UI. + if (!CurrentlyViewing) + { + // If an item was stored, release it back into the world. + if (!CurrentlyHeldItem.IsAir) + { + Main.LocalPlayer.QuickSpawnClonedItem(CurrentlyHeldItem, CurrentlyHeldItem.stack); + CurrentlyHeldItem.TurnToAir(); + } - if (ReforgeButtonClickCountdown > 0f) - reforgeIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ButtonClicked"); + EnchantIndex = 0; + NPCIndex = -1; + return; + } - // This will be used for item deposit/withdrawal logic. - isHoveringOverItemIcon = MouseScreenArea.Intersects(new Rectangle((int)itemSlotDrawPosition.X, (int)itemSlotDrawPosition.Y, (int)(itemSlotTexture.Width * scale.X), (int)(itemSlotTexture.Height * scale.Y))); + // Check if the player can still be in the UI. + if (Main.LocalPlayer.chest != -1 || Main.LocalPlayer.sign != -1 || Main.LocalPlayer.talkNPC == -1 || !Main.playerInventory || !InRangeOfNPC() || Main.InGuideCraftMenu) + { + CurrentlyViewing = false; - spriteBatch.Draw(itemSlotTexture, itemSlotDrawPosition, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + // Check if the player has any items being held. + // If they do, drop it onto the ground. + Main.LocalPlayer.dropItemCheck(); - // Draw the draw the item within the slot, if it exists. - if (!CurrentlyHeldItem.IsAir) - AttemptToDrawItemInIcon(spriteBatch, itemSlotDrawPosition); + // Reload visible recipes in case the dropped item was an ingredient. + Recipe.FindRecipes(); + return; + } - spriteBatch.Draw(reforgeIconTexture, reforgeIconDrawPosition, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); - } + // Open the inventory and stop talking to any NPCs by default while the UI is open, similar to the goblin tinkerer. + Main.playerInventory = true; + Main.npcChatText = string.Empty; - public static void AttemptToDrawItemInIcon(SpriteBatch spriteBatch, Vector2 drawPosition) - { - float inventoryScale = Main.inventoryScale; - Texture2D itemTexture = Main.itemTexture[CurrentlyHeldItem.type]; - Rectangle itemFrame = itemTexture.Frame(1, 1, 0, 0); - bool hasMultipleFrames = Main.itemAnimations[CurrentlyHeldItem.type] != null; - if (hasMultipleFrames) - itemFrame = Main.itemAnimations[CurrentlyHeldItem.type].GetFrame(itemTexture); + Texture2D backgroundTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseBackground"); + Vector2 backgroundScale = Vector2.One * Main.UIScale; - float baseScale = Main.UIScale; - Color _ = Color.White; - ItemSlot.GetItemLight(ref _, ref baseScale, CurrentlyHeldItem, false); + // Draw the background. + spriteBatch.Draw(backgroundTexture, ReforgeUITopLeft, null, Color.White, 0f, Vector2.Zero, backgroundScale, SpriteEffects.None, 0f); - float itemScale = 1f; + // Prevent the player from say, firing a weapon while the mouse is hovering over the UI. + DisableMouseWhenOverUI(backgroundTexture, backgroundScale); - // Ensure that the item being drawn does not exceed a certain size. - // If it does, constrict its scale to prevent it from going beyond the maximum. - if (itemFrame.Width > 36 || itemFrame.Height > 36) - itemScale = 36f / MathHelper.Max(itemFrame.Width, itemFrame.Height); + // Select the enchantment to use. + IEnumerable possibleEnchantments = SelectEnchantment(); - itemScale *= inventoryScale * baseScale; - drawPosition += Vector2.One * 24f * baseScale; + // Draw the cost and description. + int cost = 0; + if (SelectedEnchantment.HasValue) + { + Point costDrawPositionTopLeft = (ReforgeUITopLeft + new Vector2(50f, 78f) * backgroundScale).ToPoint(); + cost = DrawEnchantmentCost(spriteBatch, costDrawPositionTopLeft); + Point descriptionDrawPositionTopLeft = costDrawPositionTopLeft; + descriptionDrawPositionTopLeft.Y += (int)(Main.UIScale * 70f); + Vector2 iconDrawPositionTopLeft = costDrawPositionTopLeft.ToVector2() + new Vector2(270f, -24f) * Main.UIScale; - // Draw the item. - spriteBatch.Draw(itemTexture, drawPosition, itemFrame, CurrentlyHeldItem.GetAlpha(Color.White), 0f, itemFrame.Size() * 0.5f, itemScale, SpriteEffects.None, 0f); - spriteBatch.Draw(itemTexture, drawPosition, itemFrame, CurrentlyHeldItem.GetColor(Color.White), 0f, itemFrame.Size() * 0.5f, itemScale, SpriteEffects.None, 0f); - } + DrawEnchantmentDescription(spriteBatch, descriptionDrawPositionTopLeft); + if (!string.IsNullOrEmpty(SelectedEnchantment.Value.IconTexturePath)) + { + Texture2D iconTexture = ModContent.GetTexture(SelectedEnchantment.Value.IconTexturePath); + DrawIcon(spriteBatch, iconDrawPositionTopLeft, iconTexture); + } + } - public static void InteractWithItemSlot() - { - if (!CurrentlyHeldItem.IsAir) - { - // Display item stats. - Main.HoverItem = CurrentlyHeldItem.Clone(); + // Draw the item icon. + Vector2 itemSlotDrawPosition = ReforgeUITopLeft + new Vector2(30f, 50f) * backgroundScale; + Vector2 reforgeIconDrawPosition = ReforgeUITopLeft + new Vector2(84f, 60f) * backgroundScale; + DrawItemIcon(spriteBatch, itemSlotDrawPosition, reforgeIconDrawPosition, backgroundScale, out bool isHoveringOverItemIcon, out bool isHoveringOverReforgeIcon); + if (isHoveringOverItemIcon) + InteractWithItemSlot(); - // Force the HoverItem to be displayed. - Main.instance.MouseTextHackZoom(string.Empty); - } + // Draw the buttons. + DrawAndInteractWithButtons(spriteBatch, possibleEnchantments, ReforgeUITopLeft + new Vector2(210f, 50f) * backgroundScale, ReforgeUITopLeft + new Vector2(210f, 90f) * backgroundScale, backgroundScale); - // Attempt to exchange if the slot is clicked. - if (Main.mouseLeftRelease && Main.mouseLeft && (Main.mouseItem.CanBeEnchantedBySomething() || Main.mouseItem.IsAir)) - { - EnchantIndex = 0; - Utils.Swap(ref Main.mouseItem, ref CurrentlyHeldItem); - Main.PlaySound(SoundID.Grab); - } - } + // Draw the enchantment name. + if (SelectedEnchantment.HasValue) + DrawEnchantmentName(spriteBatch, ReforgeUITopLeft + new Vector2(216f, 66f) * backgroundScale); - public static void DrawAndInteractWithButtons(SpriteBatch spriteBatch, IEnumerable possibleEnchantments, Vector2 topButtonTopLeft, Vector2 bottomButtonTopLeft, Vector2 scale) - { - // Leave the arrows blank if no possible enchants exist. - if (possibleEnchantments.Count() == 0) - return; + // Handle spending logic. + if (isHoveringOverReforgeIcon) + { + if (Main.mouseLeft && Main.mouseLeftRelease) + { + InteractWithEnchantIcon(cost); + ReforgeButtonClickCountdown = 15f; + } + } + } - // Decide textures. - Texture2D topArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUp"); - Texture2D bottomArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDown"); - if (TopButtonClickCountdown > 0f) - topArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUpClicked"); - if (BottomButtonClickCountdown > 0f) - bottomArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDownClicked"); + public static void DisableMouseWhenOverUI(Texture2D backgroundTexture, Vector2 backgroundScale) + { + Rectangle backgroundArea = new Rectangle((int)ReforgeUITopLeft.X, (int)ReforgeUITopLeft.Y, (int)(backgroundTexture.Width * backgroundScale.X), (int)(backgroundTexture.Width * backgroundScale.Y)); - Rectangle topButtonArea = new Rectangle((int)topButtonTopLeft.X, (int)topButtonTopLeft.Y, (int)(topArrowTexture.Width * scale.X), (int)(topArrowTexture.Height * scale.Y)); - Rectangle bottomButtonArea = new Rectangle((int)bottomButtonTopLeft.X, (int)bottomButtonTopLeft.Y, (int)(bottomArrowTexture.Width * scale.X), (int)(bottomArrowTexture.Height * scale.Y)); - bool hoveringOverTopArrow = MouseScreenArea.Intersects(topButtonArea); - bool hoveringOverBottomArrow = MouseScreenArea.Intersects(bottomButtonArea); - if (hoveringOverTopArrow) - topArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUpHovered"); + if (MouseScreenArea.Intersects(backgroundArea)) + { + Main.LocalPlayer.mouseInterface = false; + Main.blockMouse = true; + } + } - if (hoveringOverBottomArrow) - bottomArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDownHovered"); + public static IEnumerable SelectEnchantment() + { + IEnumerable possibleEnchantments = EnchantmentManager.GetValidEnchantmentsForItem(CurrentlyHeldItem); - // Draw the arrows. - if (EnchantIndex > 0) - spriteBatch.Draw(topArrowTexture, topButtonTopLeft, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); - if (EnchantIndex < possibleEnchantments.Count() - 1) - spriteBatch.Draw(bottomArrowTexture, bottomButtonTopLeft, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + // Select the enchantment based on an index in the possible enchantments. + // If no possible enchantments were found, default to null. + SelectedEnchantment = null; - if (Main.mouseLeft && Main.mouseLeftRelease) - { - // Decement the enchantment index if the top button is pressed. - if (hoveringOverTopArrow && EnchantIndex > 0) - { - EnchantIndex--; - TopButtonClickCountdown = 15f; - Main.PlaySound(SoundID.MenuTick); - } + if (possibleEnchantments.Count() > 0) + SelectedEnchantment = possibleEnchantments.ElementAt(EnchantIndex); - // Increment the enchantment index if the bottom button is pressed. - if (hoveringOverBottomArrow && EnchantIndex < possibleEnchantments.Count() - 1) - { - EnchantIndex++; - BottomButtonClickCountdown = 15f; - Main.PlaySound(SoundID.MenuTick); - } - } - } + return possibleEnchantments; + } - public static void DrawEnchantmentName(SpriteBatch spriteBatch, Vector2 nameDrawCenter) - { - Vector2 scale = new Vector2(0.8f, 0.745f) * Main.UIScale; - float textWidth = Main.fontMouseText.MeasureString(SelectedEnchantment.Value.Name).X * scale.X; - Color drawColor = SelectedEnchantment.Value.Equals(EnchantmentManager.ClearEnchantment) ? Color.White : Color.Orange; - nameDrawCenter.X -= textWidth * 0.5f; - ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, SelectedEnchantment.Value.Name, nameDrawCenter, drawColor, 0f, Vector2.Zero, scale); - } + public static int DrawEnchantmentCost(SpriteBatch spriteBatch, Point costDrawPositionTopLeft) + { + if (CurrentlyHeldItem.IsAir) + return 0; - public static void InteractWithEnchantIcon(int cost) - { - // If there's no valid item in the slot, do nothing. - if (CurrentlyHeldItem.IsAir) - return; + int cost = CurrentlyHeldItem.value * 4; - // If no enchantment has been selected, do nothing. - if (!SelectedEnchantment.HasValue) - return; + // Increase the cost of enchanting significantly if doing so would upgrade the item directly. + if (SelectedEnchantment.HasValue && SelectedEnchantment.Value.Name == EnchantmentManager.UpgradeEnchantName) + cost = (int)MathHelper.Min(cost, Item.buyPrice(5)) * 5; - // If there is no cost or the player cannot afford it, do nothing. - if (cost <= 0 || !Main.LocalPlayer.CanBuyItem(cost)) - return; + // Make it 20% cheaper if the player has the Discount Card or Greedy Ring + if (Main.LocalPlayer.discount) + cost = (int)(cost * 0.8); - Item originalItem = CurrentlyHeldItem.Clone(); - byte oldPrefix = CurrentlyHeldItem.prefix; - CurrentlyHeldItem.SetDefaults(CurrentlyHeldItem.type); - CurrentlyHeldItem.Prefix(oldPrefix); - CurrentlyHeldItem = CurrentlyHeldItem.CloneWithModdedDataFrom(originalItem); + // Draw the coin costs. + string costText = "Cost: "; + Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, costText, costDrawPositionTopLeft.X, costDrawPositionTopLeft.Y + 45f * Main.UIScale, Color.White * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, Main.UIScale); + costDrawPositionTopLeft.X += (int)((Main.fontMouseText.MeasureString(costText).X * 0.5f + 12f) * Main.UIScale); - if (SelectedEnchantment.Value.Name == EnchantmentManager.UpgradeEnchantName) - { - CurrentlyHeldItem.SetDefaults(EnchantmentManager.ItemUpgradeRelationship[CurrentlyHeldItem.type]); - CurrentlyHeldItem.Prefix(oldPrefix); - } - else - { - CurrentlyHeldItem.Calamity().AppliedEnchantment = SelectedEnchantment.Value; - SelectedEnchantment.Value.CreationEffect?.Invoke(CurrentlyHeldItem); - } + int[] coinsArray = Utils.CoinsSplit(cost); + for (int i = 0; i < 4; i++) + { + Vector2 drawPosition = new Vector2(costDrawPositionTopLeft.X + (ChatManager.GetStringSize(Main.fontMouseText, costText, Vector2.One, -1f).X + ((24 * i) - 24f)) * Main.UIScale, costDrawPositionTopLeft.Y + 54f * Main.UIScale); + spriteBatch.Draw(Main.itemTexture[ItemID.PlatinumCoin - i], drawPosition, null, Color.White, 0f, Main.itemTexture[ItemID.PlatinumCoin - i].Size() * 0.5f, Main.UIScale, SpriteEffects.None, 0f); + Utils.DrawBorderStringFourWay(spriteBatch, Main.fontItemStack, coinsArray[3 - i].ToString(), drawPosition.X - 11f, drawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), 0.75f * Main.UIScale); + } - // Update the compare item. This is used check comparisons when showing reforge tooltip bonuses. - // Updating it with the same bonuses as what was applied to the real item will negate the incorrect numbers, - // such as absurd damage boosts. - if (Main.cpItem is null) - Main.cpItem = new Item(); - Main.cpItem.SetDefaults(Main.cpItem.type); + return cost; + } - if (SelectedEnchantment.Value.Name != EnchantmentManager.UpgradeEnchantName) - { - Main.cpItem.Calamity().AppliedEnchantment = SelectedEnchantment.Value; - SelectedEnchantment.Value.CreationEffect?.Invoke(Main.cpItem); - } + public static void DrawEnchantmentDescription(SpriteBatch spriteBatch, Point descriptionDrawPositionTopLeft) + { + Vector2 vectorDrawPosition = descriptionDrawPositionTopLeft.ToVector2(); + Vector2 scale = new Vector2(0.8f, 0.825f) * MathHelper.Clamp(ResolutionRatio, 0.825f, 1f) * Main.UIScale; - // Take away the money for the cost. - Main.LocalPlayer.BuyItem(cost); + string unifiedDescription = SelectedEnchantment.Value.Description.Replace("\n", " "); + foreach (string line in Utils.WordwrapString(unifiedDescription, Main.fontMouseText, 400, 16, out _)) + { + if (string.IsNullOrEmpty(line)) + continue; - // Reset the enchantment index to prevent index problems on a different item. - EnchantIndex = 0; + ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, line, vectorDrawPosition, Color.Orange, 0f, Vector2.Zero, scale); + vectorDrawPosition.Y += Main.UIScale * 16f; + } + } - Main.PlaySound(SoundID.DD2_BetsyFlameBreath, Main.LocalPlayer.Center); + public static void DrawIcon(SpriteBatch spriteBatch, Vector2 drawPositionTopLeft, Texture2D texture) + { + spriteBatch.Draw(texture, drawPositionTopLeft, null, Color.White, 0f, Vector2.Zero, Main.UIScale, SpriteEffects.None, 0f); + } - if (SelectedEnchantment.Value.Name == EnchantmentManager.UpgradeEnchantName) - Main.PlaySound(SoundID.DD2_DarkMageHealImpact, Main.LocalPlayer.Center); - } - } + public static void DrawItemIcon(SpriteBatch spriteBatch, Vector2 itemSlotDrawPosition, Vector2 reforgeIconDrawPosition, Vector2 scale, out bool isHoveringOverItemIcon, out bool isHoveringOverReforgeIcon) + { + isHoveringOverReforgeIcon = false; + Texture2D itemSlotTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseItemSlot"); + + Texture2D reforgeIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_Button"); + Rectangle reforgeIconArea = new Rectangle((int)reforgeIconDrawPosition.X, (int)reforgeIconDrawPosition.Y, (int)(reforgeIconTexture.Width * scale.X), (int)(reforgeIconTexture.Height * scale.Y)); + + // Have the reforge icon light up if the mouse is hovering over it. + if (MouseScreenArea.Intersects(reforgeIconArea)) + { + reforgeIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ButtonHovered"); + isHoveringOverReforgeIcon = true; + } + + if (ReforgeButtonClickCountdown > 0f) + reforgeIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ButtonClicked"); + + // This will be used for item deposit/withdrawal logic. + isHoveringOverItemIcon = MouseScreenArea.Intersects(new Rectangle((int)itemSlotDrawPosition.X, (int)itemSlotDrawPosition.Y, (int)(itemSlotTexture.Width * scale.X), (int)(itemSlotTexture.Height * scale.Y))); + + spriteBatch.Draw(itemSlotTexture, itemSlotDrawPosition, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + + // Draw the draw the item within the slot, if it exists. + if (!CurrentlyHeldItem.IsAir) + AttemptToDrawItemInIcon(spriteBatch, itemSlotDrawPosition); + + spriteBatch.Draw(reforgeIconTexture, reforgeIconDrawPosition, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + } + + public static void AttemptToDrawItemInIcon(SpriteBatch spriteBatch, Vector2 drawPosition) + { + float inventoryScale = Main.inventoryScale; + Texture2D itemTexture = Main.itemTexture[CurrentlyHeldItem.type]; + Rectangle itemFrame = itemTexture.Frame(1, 1, 0, 0); + bool hasMultipleFrames = Main.itemAnimations[CurrentlyHeldItem.type] != null; + if (hasMultipleFrames) + itemFrame = Main.itemAnimations[CurrentlyHeldItem.type].GetFrame(itemTexture); + + float baseScale = Main.UIScale; + Color _ = Color.White; + ItemSlot.GetItemLight(ref _, ref baseScale, CurrentlyHeldItem, false); + + float itemScale = 1f; + + // Ensure that the item being drawn does not exceed a certain size. + // If it does, constrict its scale to prevent it from going beyond the maximum. + if (itemFrame.Width > 36 || itemFrame.Height > 36) + itemScale = 36f / MathHelper.Max(itemFrame.Width, itemFrame.Height); + + itemScale *= inventoryScale * baseScale; + drawPosition += Vector2.One * 24f * baseScale; + + // Draw the item. + spriteBatch.Draw(itemTexture, drawPosition, itemFrame, CurrentlyHeldItem.GetAlpha(Color.White), 0f, itemFrame.Size() * 0.5f, itemScale, SpriteEffects.None, 0f); + spriteBatch.Draw(itemTexture, drawPosition, itemFrame, CurrentlyHeldItem.GetColor(Color.White), 0f, itemFrame.Size() * 0.5f, itemScale, SpriteEffects.None, 0f); + } + + public static void InteractWithItemSlot() + { + if (!CurrentlyHeldItem.IsAir) + { + // Display item stats. + Main.HoverItem = CurrentlyHeldItem.Clone(); + + // Force the HoverItem to be displayed. + Main.instance.MouseTextHackZoom(string.Empty); + } + + // Attempt to exchange if the slot is clicked. + if (Main.mouseLeftRelease && Main.mouseLeft && (Main.mouseItem.CanBeEnchantedBySomething() || Main.mouseItem.IsAir)) + { + EnchantIndex = 0; + Utils.Swap(ref Main.mouseItem, ref CurrentlyHeldItem); + Main.PlaySound(SoundID.Grab); + } + } + + public static void DrawAndInteractWithButtons(SpriteBatch spriteBatch, IEnumerable possibleEnchantments, Vector2 topButtonTopLeft, Vector2 bottomButtonTopLeft, Vector2 scale) + { + // Leave the arrows blank if no possible enchants exist. + if (possibleEnchantments.Count() == 0) + return; + + // Decide textures. + Texture2D topArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUp"); + Texture2D bottomArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDown"); + if (TopButtonClickCountdown > 0f) + topArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUpClicked"); + if (BottomButtonClickCountdown > 0f) + bottomArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDownClicked"); + + Rectangle topButtonArea = new Rectangle((int)topButtonTopLeft.X, (int)topButtonTopLeft.Y, (int)(topArrowTexture.Width * scale.X), (int)(topArrowTexture.Height * scale.Y)); + Rectangle bottomButtonArea = new Rectangle((int)bottomButtonTopLeft.X, (int)bottomButtonTopLeft.Y, (int)(bottomArrowTexture.Width * scale.X), (int)(bottomArrowTexture.Height * scale.Y)); + bool hoveringOverTopArrow = MouseScreenArea.Intersects(topButtonArea); + bool hoveringOverBottomArrow = MouseScreenArea.Intersects(bottomButtonArea); + if (hoveringOverTopArrow) + topArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUpHovered"); + + if (hoveringOverBottomArrow) + bottomArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDownHovered"); + + // Draw the arrows. + if (EnchantIndex > 0) + spriteBatch.Draw(topArrowTexture, topButtonTopLeft, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + if (EnchantIndex < possibleEnchantments.Count() - 1) + spriteBatch.Draw(bottomArrowTexture, bottomButtonTopLeft, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + + if (Main.mouseLeft && Main.mouseLeftRelease) + { + // Decement the enchantment index if the top button is pressed. + if (hoveringOverTopArrow && EnchantIndex > 0) + { + EnchantIndex--; + TopButtonClickCountdown = 15f; + Main.PlaySound(SoundID.MenuTick); + } + + // Increment the enchantment index if the bottom button is pressed. + if (hoveringOverBottomArrow && EnchantIndex < possibleEnchantments.Count() - 1) + { + EnchantIndex++; + BottomButtonClickCountdown = 15f; + Main.PlaySound(SoundID.MenuTick); + } + } + } + + public static void DrawEnchantmentName(SpriteBatch spriteBatch, Vector2 nameDrawCenter) + { + Vector2 scale = new Vector2(0.8f, 0.745f) * Main.UIScale; + float textWidth = Main.fontMouseText.MeasureString(SelectedEnchantment.Value.Name).X * scale.X; + Color drawColor = SelectedEnchantment.Value.Equals(EnchantmentManager.ClearEnchantment) ? Color.White : Color.Orange; + nameDrawCenter.X -= textWidth * 0.5f; + ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, SelectedEnchantment.Value.Name, nameDrawCenter, drawColor, 0f, Vector2.Zero, scale); + } + + public static void InteractWithEnchantIcon(int cost) + { + // If there's no valid item in the slot, do nothing. + if (CurrentlyHeldItem.IsAir) + return; + + // If no enchantment has been selected, do nothing. + if (!SelectedEnchantment.HasValue) + return; + + // If there is no cost or the player cannot afford it, do nothing. + if (cost <= 0 || !Main.LocalPlayer.CanBuyItem(cost)) + return; + + Item originalItem = CurrentlyHeldItem.Clone(); + byte oldPrefix = CurrentlyHeldItem.prefix; + CurrentlyHeldItem.SetDefaults(CurrentlyHeldItem.type); + CurrentlyHeldItem.Prefix(oldPrefix); + CurrentlyHeldItem = CurrentlyHeldItem.CloneWithModdedDataFrom(originalItem); + + if (SelectedEnchantment.Value.Name == EnchantmentManager.UpgradeEnchantName) + { + CurrentlyHeldItem.SetDefaults(EnchantmentManager.ItemUpgradeRelationship[CurrentlyHeldItem.type]); + CurrentlyHeldItem.Prefix(oldPrefix); + } + else + { + CurrentlyHeldItem.Calamity().AppliedEnchantment = SelectedEnchantment.Value; + SelectedEnchantment.Value.CreationEffect?.Invoke(CurrentlyHeldItem); + } + + // Update the compare item. This is used check comparisons when showing reforge tooltip bonuses. + // Updating it with the same bonuses as what was applied to the real item will negate the incorrect numbers, + // such as absurd damage boosts. + if (Main.cpItem is null) + Main.cpItem = new Item(); + Main.cpItem.SetDefaults(Main.cpItem.type); + + if (SelectedEnchantment.Value.Name != EnchantmentManager.UpgradeEnchantName) + { + Main.cpItem.Calamity().AppliedEnchantment = SelectedEnchantment.Value; + SelectedEnchantment.Value.CreationEffect?.Invoke(Main.cpItem); + } + + // Take away the money for the cost. + Main.LocalPlayer.BuyItem(cost); + + // Reset the enchantment index to prevent index problems on a different item. + EnchantIndex = 0; + + Main.PlaySound(SoundID.DD2_BetsyFlameBreath, Main.LocalPlayer.Center); + + if (SelectedEnchantment.Value.Name == EnchantmentManager.UpgradeEnchantName) + Main.PlaySound(SoundID.DD2_DarkMageHealImpact, Main.LocalPlayer.Center); + } + } } diff --git a/UI/CalamitasEnchantments/Enchantment.cs b/UI/CalamitasEnchantments/Enchantment.cs index e24f411e0e..bdf32fb2a9 100644 --- a/UI/CalamitasEnchantments/Enchantment.cs +++ b/UI/CalamitasEnchantments/Enchantment.cs @@ -3,62 +3,62 @@ using Terraria; namespace CalamityMod.UI.CalamitasEnchants { - public struct Enchantment - { - public string Name; - public string Description; - public string IconTexturePath; - public Action CreationEffect; - public Action HoldEffect; + public struct Enchantment + { + public string Name; + public string Description; + public string IconTexturePath; + public Action CreationEffect; + public Action HoldEffect; - public int ID { get; internal set; } + public int ID { get; internal set; } - // This is internal because CanBeAppliedTo should be used over this field directly. - // Using that has the benefit of null checks and is objectively superior to using the raw delegate. - internal Predicate ApplyRequirement; - public Enchantment(string name, string description, int id, string iconTexturePath, Action creationEffect, Action holdEffect, Predicate requirement) - { - Name = name; - Description = description; - CreationEffect = creationEffect; - HoldEffect = holdEffect; - ApplyRequirement = requirement; - ID = id; - IconTexturePath = iconTexturePath; - } - public Enchantment(string name, string description, int id, string iconTexturePath, Action holdEffect, Predicate requirement) - { - Name = name; - Description = description; - CreationEffect = null; - HoldEffect = holdEffect; - ApplyRequirement = requirement; - ID = id; - IconTexturePath = iconTexturePath; - } - public Enchantment(string name, string description, int id, string iconTexturePath, Action creationEffect, Predicate requirement) - { - Name = name; - Description = description; - CreationEffect = creationEffect; - HoldEffect = null; - ApplyRequirement = requirement; - ID = id; - IconTexturePath = iconTexturePath; - } + // This is internal because CanBeAppliedTo should be used over this field directly. + // Using that has the benefit of null checks and is objectively superior to using the raw delegate. + internal Predicate ApplyRequirement; + public Enchantment(string name, string description, int id, string iconTexturePath, Action creationEffect, Action holdEffect, Predicate requirement) + { + Name = name; + Description = description; + CreationEffect = creationEffect; + HoldEffect = holdEffect; + ApplyRequirement = requirement; + ID = id; + IconTexturePath = iconTexturePath; + } + public Enchantment(string name, string description, int id, string iconTexturePath, Action holdEffect, Predicate requirement) + { + Name = name; + Description = description; + CreationEffect = null; + HoldEffect = holdEffect; + ApplyRequirement = requirement; + ID = id; + IconTexturePath = iconTexturePath; + } + public Enchantment(string name, string description, int id, string iconTexturePath, Action creationEffect, Predicate requirement) + { + Name = name; + Description = description; + CreationEffect = creationEffect; + HoldEffect = null; + ApplyRequirement = requirement; + ID = id; + IconTexturePath = iconTexturePath; + } - public bool CanBeAppliedTo(Item item) - { - // "Empty" items can never be enchanted. - if (item is null || item.IsAir) - return false; + public bool CanBeAppliedTo(Item item) + { + // "Empty" items can never be enchanted. + if (item is null || item.IsAir) + return false; - // If there is no requirement, always return true, bar the above requirement. - if (ApplyRequirement is null) - return true; + // If there is no requirement, always return true, bar the above requirement. + if (ApplyRequirement is null) + return true; - // Otherwise return what the defined requirement says is needed. - return ApplyRequirement(item); - } - } + // Otherwise return what the defined requirement says is needed. + return ApplyRequirement(item); + } + } } diff --git a/UI/CalamitasEnchantments/EnchantmentManager.cs b/UI/CalamitasEnchantments/EnchantmentManager.cs index cad57c64ee..b0b2b18e2c 100644 --- a/UI/CalamitasEnchantments/EnchantmentManager.cs +++ b/UI/CalamitasEnchantments/EnchantmentManager.cs @@ -13,312 +13,312 @@ using Terraria.ModLoader; namespace CalamityMod.UI.CalamitasEnchants { - public static class EnchantmentManager - { - internal const int ClearEnchantmentID = -18591774; - internal const string UpgradeEnchantName = "Exhume"; - public static List EnchantmentList { get; internal set; } = new List(); - public static Dictionary ItemUpgradeRelationship { get; internal set; } = new Dictionary(); - public static Enchantment ClearEnchantment { get; internal set; } - public static IEnumerable GetValidEnchantmentsForItem(Item item) - { - // Do nothing if the item cannot be enchanted. - if (item is null || item.IsAir || !item.CanBeEnchantedBySomething()) - yield break; + public static class EnchantmentManager + { + internal const int ClearEnchantmentID = -18591774; + internal const string UpgradeEnchantName = "Exhume"; + public static List EnchantmentList { get; internal set; } = new List(); + public static Dictionary ItemUpgradeRelationship { get; internal set; } = new Dictionary(); + public static Enchantment ClearEnchantment { get; internal set; } + public static IEnumerable GetValidEnchantmentsForItem(Item item) + { + // Do nothing if the item cannot be enchanted. + if (item is null || item.IsAir || !item.CanBeEnchantedBySomething()) + yield break; - // Don't allow any enchantments if the item is an upgrade item. - if (ItemUpgradeRelationship.ContainsValue(item.type)) - yield break; + // Don't allow any enchantments if the item is an upgrade item. + if (ItemUpgradeRelationship.ContainsValue(item.type)) + yield break; - // Only give the option to clear if the item already has an enchantment. - if (item.Calamity().AppliedEnchantment.HasValue) - { - yield return ClearEnchantment; - yield break; - } + // Only give the option to clear if the item already has an enchantment. + if (item.Calamity().AppliedEnchantment.HasValue) + { + yield return ClearEnchantment; + yield break; + } - // Check based on all the requirements for all enchantments. - foreach (Enchantment enchantment in EnchantmentList) - { - // Don't incorporate an enchantment in the list if the item already has it. - if (item.Calamity().AppliedEnchantment.HasValue && item.Calamity().AppliedEnchantment.Value.Equals(enchantment)) - continue; + // Check based on all the requirements for all enchantments. + foreach (Enchantment enchantment in EnchantmentList) + { + // Don't incorporate an enchantment in the list if the item already has it. + if (item.Calamity().AppliedEnchantment.HasValue && item.Calamity().AppliedEnchantment.Value.Equals(enchantment)) + continue; - if (enchantment.ApplyRequirement(item)) - yield return enchantment; - } - } + if (enchantment.ApplyRequirement(item)) + yield return enchantment; + } + } - public static Enchantment? FindByID(int id) - { - Enchantment? enchantment = EnchantmentList.FirstOrDefault(enchant => enchant.ID == id); - if (enchantment.HasValue && !enchantment.Value.Equals(default(Enchantment))) - return enchantment; - return null; - } + public static Enchantment? FindByID(int id) + { + Enchantment? enchantment = EnchantmentList.FirstOrDefault(enchant => enchant.ID == id); + if (enchantment.HasValue && !enchantment.Value.Equals(default(Enchantment))) + return enchantment; + return null; + } - public static void ConstructFromModcall(IEnumerable parameters) - { - int secondaryArgumentCount = parameters.Count(); - if (secondaryArgumentCount < 5) - throw new ArgumentNullException("ERROR: A minimum of 4 arguments must be supplied to this command; a name, a description, an id, and a requirement predicate."); - if (secondaryArgumentCount > 7) - throw new ArgumentNullException("ERROR: A maximum of 6 arguments can be supplied to this command."); + public static void ConstructFromModcall(IEnumerable parameters) + { + int secondaryArgumentCount = parameters.Count(); + if (secondaryArgumentCount < 5) + throw new ArgumentNullException("ERROR: A minimum of 4 arguments must be supplied to this command; a name, a description, an id, and a requirement predicate."); + if (secondaryArgumentCount > 7) + throw new ArgumentNullException("ERROR: A maximum of 6 arguments can be supplied to this command."); - string name = string.Empty; - string description = string.Empty; - int id = -1; - string iconTexturePath = null; - Predicate requirement = null; - Action creationEffect = null; - Action holdEffect = null; + string name = string.Empty; + string description = string.Empty; + int id = -1; + string iconTexturePath = null; + Predicate requirement = null; + Action creationEffect = null; + Action holdEffect = null; - // First element - the name. - if (parameters.ElementAt(0) is string nameElement) - name = nameElement; - else - throw new ArgumentException("The first argument to this command must be a string."); + // First element - the name. + if (parameters.ElementAt(0) is string nameElement) + name = nameElement; + else + throw new ArgumentException("The first argument to this command must be a string."); - // Second element - the description. - if (parameters.ElementAt(1) is string descriptionElement) - description = descriptionElement; - else - throw new ArgumentException("The second argument to this command must be a string."); + // Second element - the description. + if (parameters.ElementAt(1) is string descriptionElement) + description = descriptionElement; + else + throw new ArgumentException("The second argument to this command must be a string."); - // Third element - the ID. - if (parameters.ElementAt(2) is int idElement) - id = idElement; - else - throw new ArgumentException("The third argument to this command must be an int."); + // Third element - the ID. + if (parameters.ElementAt(2) is int idElement) + id = idElement; + else + throw new ArgumentException("The third argument to this command must be an int."); - // Fourth element - the requirement predicate. This determines if an item can be enchanted by said enchant or not. - if (parameters.ElementAt(3) is Predicate requirementElement) - requirement = requirementElement; - else - throw new ArgumentException("The fourth argument to this command must be an Item Predicate."); + // Fourth element - the requirement predicate. This determines if an item can be enchanted by said enchant or not. + if (parameters.ElementAt(3) is Predicate requirementElement) + requirement = requirementElement; + else + throw new ArgumentException("The fourth argument to this command must be an Item Predicate."); - // Fifth element - the texture path. This determines what icon is drawn on the UI when selected. It may be null to specify that none should be drawn. - if (parameters.ElementAt(4) is string iconTexturePathElement) - iconTexturePath = iconTexturePathElement; - else - throw new ArgumentException("The fifth argument to this command must be a string."); + // Fifth element - the texture path. This determines what icon is drawn on the UI when selected. It may be null to specify that none should be drawn. + if (parameters.ElementAt(4) is string iconTexturePathElement) + iconTexturePath = iconTexturePathElement; + else + throw new ArgumentException("The fifth argument to this command must be a string."); - // Optional elements - creation and hold effects. - switch (secondaryArgumentCount) - { - case 6: - object sixthElement = parameters.ElementAt(4); - if (sixthElement is Action creationElement) - creationEffect = creationElement; - else if (sixthElement is Action holdElement) - holdEffect = holdElement; - else - throw new ArgumentException("The sixth argument to this command must be an Item or Player Action."); - break; - case 7: - sixthElement = parameters.ElementAt(4); - object seventhElement = parameters.ElementAt(5); - if (sixthElement is Action creationElement2) - { - creationEffect = creationElement2; - holdEffect = seventhElement as Action; - } - else if (sixthElement is Action holdElement2) - { - creationEffect = seventhElement as Action; - holdEffect = holdElement2; - } - else - throw new ArgumentException("The sixth argument to this command must be an Item or Player Action and the sixth must be the other action type."); - break; - } + // Optional elements - creation and hold effects. + switch (secondaryArgumentCount) + { + case 6: + object sixthElement = parameters.ElementAt(4); + if (sixthElement is Action creationElement) + creationEffect = creationElement; + else if (sixthElement is Action holdElement) + holdEffect = holdElement; + else + throw new ArgumentException("The sixth argument to this command must be an Item or Player Action."); + break; + case 7: + sixthElement = parameters.ElementAt(4); + object seventhElement = parameters.ElementAt(5); + if (sixthElement is Action creationElement2) + { + creationEffect = creationElement2; + holdEffect = seventhElement as Action; + } + else if (sixthElement is Action holdElement2) + { + creationEffect = seventhElement as Action; + holdEffect = holdElement2; + } + else + throw new ArgumentException("The sixth argument to this command must be an Item or Player Action and the sixth must be the other action type."); + break; + } - // Ensure the enchantment's ID is not already claimed. - if (EnchantmentList.Any(enchant => enchant.ID == id) || id == ClearEnchantmentID) - throw new ArgumentException("An enchantment with this ID already exists. Another one must be specified."); + // Ensure the enchantment's ID is not already claimed. + if (EnchantmentList.Any(enchant => enchant.ID == id) || id == ClearEnchantmentID) + throw new ArgumentException("An enchantment with this ID already exists. Another one must be specified."); - EnchantmentList.Add(new Enchantment(name, description, id, iconTexturePathElement, creationEffect, holdEffect, requirement)); - } + EnchantmentList.Add(new Enchantment(name, description, id, iconTexturePathElement, creationEffect, holdEffect, requirement)); + } - internal static void LoadAllEnchantments() - { - EnchantmentList = new List - { - new Enchantment(UpgradeEnchantName, "Transforms this item into something significantly stronger.", - 1, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Exhumed", - null, - null, - item => ItemUpgradeRelationship.ContainsKey(item.type)), + internal static void LoadAllEnchantments() + { + EnchantmentList = new List + { + new Enchantment(UpgradeEnchantName, "Transforms this item into something significantly stronger.", + 1, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Exhumed", + null, + null, + item => ItemUpgradeRelationship.ContainsKey(item.type)), - new Enchantment("Indignant", "Summons demons that harm you but drop healing items on death on item usage.", - 100, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Indignant", - null, - player => player.Calamity().cursedSummonsEnchant = true, - item => item.IsEnchantable() && item.damage > 0 && item.summon), + new Enchantment("Indignant", "Summons demons that harm you but drop healing items on death on item usage.", + 100, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Indignant", + null, + player => player.Calamity().cursedSummonsEnchant = true, + item => item.IsEnchantable() && item.damage > 0 && item.summon), - new Enchantment("Aflame", "Lights enemies ablaze on hit but also causes the user to take damage over time when holding this item.", - 200, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Aflame", - null, - player => player.Calamity().flamingItemEnchant = true, - item => item.IsEnchantable() && item.damage > 0 && !item.summon), + new Enchantment("Aflame", "Lights enemies ablaze on hit but also causes the user to take damage over time when holding this item.", + 200, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Aflame", + null, + player => player.Calamity().flamingItemEnchant = true, + item => item.IsEnchantable() && item.damage > 0 && !item.summon), - new Enchantment("Oblatory", "Reduces mana cost and greatly increases damage but sometimes causes this item to use your life.", - 300, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Oblatory", - item => - { - item.damage = (int)(item.damage * 1.5); - item.mana = (int)Math.Ceiling(item.mana * 0.6); - }, - player => player.Calamity().lifeManaEnchant = true, - item => item.IsEnchantable() && item.damage > 0 && item.magic && item.mana > 0), + new Enchantment("Oblatory", "Reduces mana cost and greatly increases damage but sometimes causes this item to use your life.", + 300, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Oblatory", + item => + { + item.damage = (int)(item.damage * 1.5); + item.mana = (int)Math.Ceiling(item.mana * 0.6); + }, + player => player.Calamity().lifeManaEnchant = true, + item => item.IsEnchantable() && item.damage > 0 && item.magic && item.mana > 0), - new Enchantment("Resentful", "Makes the damage of projectiles vary based on how far the hit target is from you. The farther, the more damage, and vice versa.", - 400, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Resentful", - null, - player => player.Calamity().farProximityRewardEnchant = true, - item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None && !item.Calamity().trueMelee), + new Enchantment("Resentful", "Makes the damage of projectiles vary based on how far the hit target is from you. The farther, the more damage, and vice versa.", + 400, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Resentful", + null, + player => player.Calamity().farProximityRewardEnchant = true, + item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None && !item.Calamity().trueMelee), - new Enchantment("Bloodthirsty", "Makes the damage of projectiles vary based on how far the hit target is from you. The closer, the more damage, and vice versa.", - 500, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Bloodthirsty", - null, - player => player.Calamity().closeProximityRewardEnchant = true, - item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None && !item.Calamity().trueMelee), + new Enchantment("Bloodthirsty", "Makes the damage of projectiles vary based on how far the hit target is from you. The closer, the more damage, and vice versa.", + 500, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Bloodthirsty", + null, + player => player.Calamity().closeProximityRewardEnchant = true, + item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None && !item.Calamity().trueMelee), - new Enchantment("Ephemeral", "Causes the damage output of this item to discharge from exhaustive use.\nIts damage returns naturally when not being used. It starts off with more damage than it normally would have.", - 600, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Ephemeral", - null, - player => player.Calamity().dischargingItemEnchant = true, - item => item.IsEnchantable() && item.damage > 0 && !item.summon && !item.channel), + new Enchantment("Ephemeral", "Causes the damage output of this item to discharge from exhaustive use.\nIts damage returns naturally when not being used. It starts off with more damage than it normally would have.", + 600, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Ephemeral", + null, + player => player.Calamity().dischargingItemEnchant = true, + item => item.IsEnchantable() && item.damage > 0 && !item.summon && !item.channel), - new Enchantment("Hellbound", "Causes minions to be created with a 40 second timer.\nOnce it runs out, they explode violently. Minions do more damage the longer they live and idly explode as well.", - 700, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Hellbound", - null, - player => player.Calamity().explosiveMinionsEnchant = true, - item => item.IsEnchantable() && item.damage > 0 && item.summon), + new Enchantment("Hellbound", "Causes minions to be created with a 40 second timer.\nOnce it runs out, they explode violently. Minions do more damage the longer they live and idly explode as well.", + 700, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Hellbound", + null, + player => player.Calamity().explosiveMinionsEnchant = true, + item => item.IsEnchantable() && item.damage > 0 && item.summon), - new Enchantment("Tainted", "Removes projectile shooting capabilities of this item. In exchange, two skeletal arms are released on use that slice at the mouse position.", - 800, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Tainted", - item => item.useTime = item.useAnimation = 25, - player => - { - if (Main.gameMenu) - return; + new Enchantment("Tainted", "Removes projectile shooting capabilities of this item. In exchange, two skeletal arms are released on use that slice at the mouse position.", + 800, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Tainted", + item => item.useTime = item.useAnimation = 25, + player => + { + if (Main.gameMenu) + return; - player.Calamity().bladeArmEnchant = true; - bool armsArePresent = false; - int armType = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].type != armType || Main.projectile[i].owner != player.whoAmI || !Main.projectile[i].active) - continue; + player.Calamity().bladeArmEnchant = true; + bool armsArePresent = false; + int armType = ModContent.ProjectileType(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != armType || Main.projectile[i].owner != player.whoAmI || !Main.projectile[i].active) + continue; - armsArePresent = true; - break; - } + armsArePresent = true; + break; + } - if (Main.myPlayer == player.whoAmI && !armsArePresent) - { - // Yes, this is a LOT of damage but given the limited range of this thing it needs to be extremely powerful when it does actually hit. - int damage = (int)(player.ActiveItem().damage * player.MeleeDamage() * 5); - int blade = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, player.ActiveItem().type); - if (Main.projectile.IndexInRange(blade)) - Main.projectile[blade].localAI[0] = 0f; + if (Main.myPlayer == player.whoAmI && !armsArePresent) + { + // Yes, this is a LOT of damage but given the limited range of this thing it needs to be extremely powerful when it does actually hit. + int damage = (int)(player.ActiveItem().damage * player.MeleeDamage() * 5); + int blade = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, player.ActiveItem().type); + if (Main.projectile.IndexInRange(blade)) + Main.projectile[blade].localAI[0] = 0f; - blade = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 1f, player.ActiveItem().type); - if (Main.projectile.IndexInRange(blade)) - Main.projectile[blade].localAI[0] = -80f; - } - }, - item => item.IsEnchantable() && item.damage > 0 && item.melee && !item.noUseGraphic && item.shoot > ProjectileID.None), + blade = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 1f, player.ActiveItem().type); + if (Main.projectile.IndexInRange(blade)) + Main.projectile[blade].localAI[0] = -80f; + } + }, + item => item.IsEnchantable() && item.damage > 0 && item.melee && !item.noUseGraphic && item.shoot > ProjectileID.None), - new Enchantment("Traitorous", "Causes this item to sometimes release a monster that hurts both you and enemies when you have less than 50% mana.", - 900, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Traitorous", - null, - player => player.Calamity().manaMonsterEnchant = true, - item => item.IsEnchantable() && item.damage > 0 && item.magic && item.mana > 0), + new Enchantment("Traitorous", "Causes this item to sometimes release a monster that hurts both you and enemies when you have less than 50% mana.", + 900, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Traitorous", + null, + player => player.Calamity().manaMonsterEnchant = true, + item => item.IsEnchantable() && item.damage > 0 && item.magic && item.mana > 0), - new Enchantment("Withering", "When hurt, you heal a percentage of the damage taken based on how much accumulated damage you did overall beforehand, up to 100%.\n" + - "After this, you gain a damage boost while holding this item but also take exponential damage over time the longer you hold it.", - 1000, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Withered", - null, - player => player.Calamity().witheringWeaponEnchant = true, - item => item.IsEnchantable() && item.damage > 0 && !item.summon), + new Enchantment("Withering", "When hurt, you heal a percentage of the damage taken based on how much accumulated damage you did overall beforehand, up to 100%.\n" + + "After this, you gain a damage boost while holding this item but also take exponential damage over time the longer you hold it.", + 1000, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Withered", + null, + player => player.Calamity().witheringWeaponEnchant = true, + item => item.IsEnchantable() && item.damage > 0 && !item.summon), - new Enchantment("Persecuted", "When attacked, or over time, demon portals appear near you.\nIf sufficiently damaged they are friendly; otherwise they attack you. They become angered if a portal is damaged.", - 1100, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Persecuted", - null, - player => player.Calamity().persecutedEnchant = true, - item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None), + new Enchantment("Persecuted", "When attacked, or over time, demon portals appear near you.\nIf sufficiently damaged they are friendly; otherwise they attack you. They become angered if a portal is damaged.", + 1100, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Persecuted", + null, + player => player.Calamity().persecutedEnchant = true, + item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None), - new Enchantment("Lecherous", "Spawns a resilient brimstone monster that stays between you and your mouse that interferes with your homing weapons. It releases a bunch of hearts on death.", - 1200, - "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Lecherous", - null, - player => - { - if (Main.gameMenu) - return; + new Enchantment("Lecherous", "Spawns a resilient brimstone monster that stays between you and your mouse that interferes with your homing weapons. It releases a bunch of hearts on death.", + 1200, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Lecherous", + null, + player => + { + if (Main.gameMenu) + return; - player.Calamity().lecherousOrbEnchant = true; + player.Calamity().lecherousOrbEnchant = true; - bool orbIsPresent = false; - int orbType = ModContent.NPCType(); - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].type != orbType || Main.npc[i].target != player.whoAmI || !Main.npc[i].active) - continue; + bool orbIsPresent = false; + int orbType = ModContent.NPCType(); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].type != orbType || Main.npc[i].target != player.whoAmI || !Main.npc[i].active) + continue; - orbIsPresent = true; - break; - } + orbIsPresent = true; + break; + } - if (Main.myPlayer == player.whoAmI && !orbIsPresent && !player.Calamity().awaitingLecherousOrbSpawn) - { - player.Calamity().awaitingLecherousOrbSpawn = true; - CalamityNetcode.NewNPC_ClientSide(player.Center, orbType, player); - } - }, - item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None && !item.summon), - }; + if (Main.myPlayer == player.whoAmI && !orbIsPresent && !player.Calamity().awaitingLecherousOrbSpawn) + { + player.Calamity().awaitingLecherousOrbSpawn = true; + CalamityNetcode.NewNPC_ClientSide(player.Center, orbType, player); + } + }, + item => item.IsEnchantable() && item.damage > 0 && item.shoot > ProjectileID.None && !item.summon), + }; - // Special disenchantment thing. This is separated from the list on purpose. - ClearEnchantment = new Enchantment("Disenchant", - string.Empty, - ClearEnchantmentID, - null, - item => - { - item.Calamity().AppliedEnchantment = null; - item.Calamity().DischargeEnchantExhaustion = 0; - }, - item => item.IsEnchantable() && item.shoot >= ProjectileID.None); + // Special disenchantment thing. This is separated from the list on purpose. + ClearEnchantment = new Enchantment("Disenchant", + string.Empty, + ClearEnchantmentID, + null, + item => + { + item.Calamity().AppliedEnchantment = null; + item.Calamity().DischargeEnchantExhaustion = 0; + }, + item => item.IsEnchantable() && item.shoot >= ProjectileID.None); - ItemUpgradeRelationship = new Dictionary() - { - [ModContent.ItemType()] = ModContent.ItemType(), - [ModContent.ItemType()] = ModContent.ItemType(), - [ModContent.ItemType()] = ModContent.ItemType(), - [ModContent.ItemType()] = ModContent.ItemType(), - [ModContent.ItemType()] = ModContent.ItemType() - }; - } + ItemUpgradeRelationship = new Dictionary() + { + [ModContent.ItemType()] = ModContent.ItemType(), + [ModContent.ItemType()] = ModContent.ItemType(), + [ModContent.ItemType()] = ModContent.ItemType(), + [ModContent.ItemType()] = ModContent.ItemType(), + [ModContent.ItemType()] = ModContent.ItemType() + }; + } - internal static void UnloadAllEnchantments() - { - EnchantmentList = null; - ItemUpgradeRelationship = null; - } - } + internal static void UnloadAllEnchantments() + { + EnchantmentList = null; + ItemUpgradeRelationship = null; + } + } } diff --git a/UI/ChargeMeterUI.cs b/UI/ChargeMeterUI.cs index fbfd23c4e1..69757c0ea0 100644 --- a/UI/ChargeMeterUI.cs +++ b/UI/ChargeMeterUI.cs @@ -8,94 +8,94 @@ using Terraria.ModLoader; namespace CalamityMod.UI { - public class ChargeMeterUI - { - public static Vector2 DrawPosition = new Vector2(CalamityConfig.Instance.ChargeMeterPosX, CalamityConfig.Instance.ChargeMeterPosY); - public static Vector2 Offset = DrawPosition; - public static void Draw(SpriteBatch spriteBatch, Player player) - { - if (DrawPosition.X <= 60f && DrawPosition.Y <= 20f) - { - DrawPosition.X = Main.screenWidth / 2f; - DrawPosition.Y = Main.screenHeight / 2 + Main.LocalPlayer.height / 2f + 24f; - } - CalamityPlayer modPlayer = player.Calamity(); - Item heldItem = player.ActiveItem(); - if (!CalamityConfig.Instance.ChargeMeter || heldItem is null || heldItem.IsAir) - { - Reset(); - return; - } + public class ChargeMeterUI + { + public static Vector2 DrawPosition = new Vector2(CalamityConfig.Instance.ChargeMeterPosX, CalamityConfig.Instance.ChargeMeterPosY); + public static Vector2 Offset = DrawPosition; + public static void Draw(SpriteBatch spriteBatch, Player player) + { + if (DrawPosition.X <= 60f && DrawPosition.Y <= 20f) + { + DrawPosition.X = Main.screenWidth / 2f; + DrawPosition.Y = Main.screenHeight / 2 + Main.LocalPlayer.height / 2f + 24f; + } + CalamityPlayer modPlayer = player.Calamity(); + Item heldItem = player.ActiveItem(); + if (!CalamityConfig.Instance.ChargeMeter || heldItem is null || heldItem.IsAir) + { + Reset(); + return; + } CalamityGlobalItem modItem = heldItem.Calamity(); - if (!(modItem?.UsesCharge ?? false)) - { - Reset(); - return; - } - Texture2D edgeTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ChargeMeterBorder"); - Texture2D barTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ChargeMeter"); - float uiScale = Main.UIScale; - spriteBatch.Draw(edgeTexture, DrawPosition, null, Color.White, 0f, edgeTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); + if (!(modItem?.UsesCharge ?? false)) + { + Reset(); + return; + } + Texture2D edgeTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ChargeMeterBorder"); + Texture2D barTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ChargeMeter"); + float uiScale = Main.UIScale; + spriteBatch.Draw(edgeTexture, DrawPosition, null, Color.White, 0f, edgeTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); - Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * modItem.ChargeRatio), barTexture.Width); - spriteBatch.Draw(barTexture, DrawPosition, barRectangle, Color.White, 0f, edgeTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); + Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * modItem.ChargeRatio), barTexture.Width); + spriteBatch.Draw(barTexture, DrawPosition, barRectangle, Color.White, 0f, edgeTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); Rectangle mouse = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); - Rectangle chargeBar = Utils.CenteredRectangle(DrawPosition, barTexture.Size() * uiScale); + Rectangle chargeBar = Utils.CenteredRectangle(DrawPosition, barTexture.Size() * uiScale); - if (chargeBar.Intersects(mouse)) - { - if (modItem.UsesCharge) - { - Main.LocalPlayer.mouseInterface = true; - float displayedPercent = modItem.ChargeRatio * 100f; - string percentString = displayedPercent.ToString("n2"); - // Tooltip only goes to one decimal place, but the meter displays two. This doesn't help the player much at all but hey, it's a thing. - Main.instance.MouseText("Current Charge: " + percentString + "%", 0, 0, -1, -1, -1, -1); - } - } - if (!CalamityConfig.Instance.MeterPosLock) - { - if (chargeBar.Intersects(mouse)) - { - if (Mouse.GetState().LeftButton == ButtonState.Pressed) - { - Offset = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); - DrawPosition.X = Offset.X; - DrawPosition.Y = Offset.Y; - } - if (Mouse.GetState().LeftButton == ButtonState.Released) - { - DrawPosition.X = Offset.X; - DrawPosition.Y = Offset.Y; - } - } + if (chargeBar.Intersects(mouse)) + { + if (modItem.UsesCharge) + { + Main.LocalPlayer.mouseInterface = true; + float displayedPercent = modItem.ChargeRatio * 100f; + string percentString = displayedPercent.ToString("n2"); + // Tooltip only goes to one decimal place, but the meter displays two. This doesn't help the player much at all but hey, it's a thing. + Main.instance.MouseText("Current Charge: " + percentString + "%", 0, 0, -1, -1, -1, -1); + } + } + if (!CalamityConfig.Instance.MeterPosLock) + { + if (chargeBar.Intersects(mouse)) + { + if (Mouse.GetState().LeftButton == ButtonState.Pressed) + { + Offset = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); + DrawPosition.X = Offset.X; + DrawPosition.Y = Offset.Y; + } + if (Mouse.GetState().LeftButton == ButtonState.Released) + { + DrawPosition.X = Offset.X; + DrawPosition.Y = Offset.Y; + } + } - if (CalamityConfig.Instance.ChargeMeterPosX != DrawPosition.X) - { - CalamityConfig.Instance.ChargeMeterPosX = DrawPosition.X; - CalamityMod.SaveConfig(CalamityConfig.Instance); - } - if (CalamityConfig.Instance.ChargeMeterPosY != DrawPosition.Y) - { - CalamityConfig.Instance.ChargeMeterPosY = DrawPosition.Y; - CalamityMod.SaveConfig(CalamityConfig.Instance); - } - } - } + if (CalamityConfig.Instance.ChargeMeterPosX != DrawPosition.X) + { + CalamityConfig.Instance.ChargeMeterPosX = DrawPosition.X; + CalamityMod.SaveConfig(CalamityConfig.Instance); + } + if (CalamityConfig.Instance.ChargeMeterPosY != DrawPosition.Y) + { + CalamityConfig.Instance.ChargeMeterPosY = DrawPosition.Y; + CalamityMod.SaveConfig(CalamityConfig.Instance); + } + } + } - internal static void Reset() - { - if (CalamityConfig.Instance.ChargeMeterPosX != DrawPosition.X) - { - CalamityConfig.Instance.ChargeMeterPosX = DrawPosition.X; - CalamityMod.SaveConfig(CalamityConfig.Instance); - } - if (CalamityConfig.Instance.ChargeMeterPosY != DrawPosition.Y) - { - CalamityConfig.Instance.ChargeMeterPosY = DrawPosition.Y; - CalamityMod.SaveConfig(CalamityConfig.Instance); - } - } - } + internal static void Reset() + { + if (CalamityConfig.Instance.ChargeMeterPosX != DrawPosition.X) + { + CalamityConfig.Instance.ChargeMeterPosX = DrawPosition.X; + CalamityMod.SaveConfig(CalamityConfig.Instance); + } + if (CalamityConfig.Instance.ChargeMeterPosY != DrawPosition.Y) + { + CalamityConfig.Instance.ChargeMeterPosY = DrawPosition.Y; + CalamityMod.SaveConfig(CalamityConfig.Instance); + } + } + } } diff --git a/UI/CodebreakerUI.cs b/UI/CodebreakerUI.cs index 752343f64c..8506d1f916 100644 --- a/UI/CodebreakerUI.cs +++ b/UI/CodebreakerUI.cs @@ -14,7 +14,7 @@ using Terraria.UI.Chat; namespace CalamityMod.UI { - public static class CodebreakerUI + public static class CodebreakerUI { public static int ViewedTileEntityID = -1; public static bool AwaitingCloseConfirmation = false; @@ -372,7 +372,7 @@ namespace CalamityMod.UI } public static void HandleDecryptionStuff(TECodebreaker codebreakerTileEntity, Texture2D backgroundTexture, Vector2 backgroundTopLeft, Vector2 barCenter) - { + { Texture2D textPanelTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonDecrypterScreen"); Vector2 textPanelCenter = backgroundTopLeft + Vector2.UnitX * backgroundTexture.Width * GeneralScale + textPanelTexture.Size() * new Vector2(-0.5f, 0.5f) * GeneralScale; Main.spriteBatch.Draw(textPanelTexture, textPanelCenter, null, Color.White, 0f, textPanelTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f); diff --git a/UI/CooldownRackUI.cs b/UI/CooldownRackUI.cs index 7c6bb862cf..1b6409fbcf 100644 --- a/UI/CooldownRackUI.cs +++ b/UI/CooldownRackUI.cs @@ -7,83 +7,83 @@ using Terraria; namespace CalamityMod.UI { - public class CooldownRackUI - { - /// - /// The maximum number of cooldowns which can be drawn in expanded mode before the rack auto-switches to compact mode. - /// - public static int MaxLargeIcons = 10; + public class CooldownRackUI + { + /// + /// The maximum number of cooldowns which can be drawn in expanded mode before the rack auto-switches to compact mode. + /// + public static int MaxLargeIcons = 10; - public static bool CompactIcons - { - get - { - // Option 1: Always use compact icons if configured to do so. - if (CalamityConfig.Instance.CooldownDisplay == 1) - return true; + public static bool CompactIcons + { + get + { + // Option 1: Always use compact icons if configured to do so. + if (CalamityConfig.Instance.CooldownDisplay == 1) + return true; - // Option 2: If there are too many cooldowns, auto switch to compact mode. - return Main.LocalPlayer.GetDisplayedCooldowns().Count > MaxLargeIcons; - } - } + // Option 2: If there are too many cooldowns, auto switch to compact mode. + return Main.LocalPlayer.GetDisplayedCooldowns().Count > MaxLargeIcons; + } + } - // TODO -- more of these display positioning constants - public const float CompactXSpacing = 28f; - public const float ExpandedXScaling = 46f; - public static Vector2 Spacing => CompactIcons ? Vector2.UnitX * CompactXSpacing : Vector2.UnitX * ExpandedXScaling; + // TODO -- more of these display positioning constants + public const float CompactXSpacing = 28f; + public const float ExpandedXScaling = 46f; + public static Vector2 Spacing => CompactIcons ? Vector2.UnitX * CompactXSpacing : Vector2.UnitX * ExpandedXScaling; - public static Vector2 BaseDrawPosition => new Vector2(32, 100) + Spacing / 2f + (Main.LocalPlayer.CountBuffs() > 0 ? Vector2.UnitY * 50 : Vector2.Zero) + (Main.LocalPlayer.CountBuffs() > 11 ? Vector2.UnitY * 50 : Vector2.Zero); + public static Vector2 BaseDrawPosition => new Vector2(32, 100) + Spacing / 2f + (Main.LocalPlayer.CountBuffs() > 0 ? Vector2.UnitY * 50 : Vector2.Zero) + (Main.LocalPlayer.CountBuffs() > 11 ? Vector2.UnitY * 50 : Vector2.Zero); - public static void Draw(SpriteBatch spriteBatch) - { - // Don't draw cooldowns under the following conditions: - // 1 - The game isn't even on the game screen yet. - // 2 - The player's inventory is open. - // 3 - Cooldown display is completely disabled. - if (Main.gameMenu || Main.playerInventory || CalamityConfig.Instance.CooldownDisplay < 1) - return; + public static void Draw(SpriteBatch spriteBatch) + { + // Don't draw cooldowns under the following conditions: + // 1 - The game isn't even on the game screen yet. + // 2 - The player's inventory is open. + // 3 - Cooldown display is completely disabled. + if (Main.gameMenu || Main.playerInventory || CalamityConfig.Instance.CooldownDisplay < 1) + return; - IList cooldownsToDraw = Main.LocalPlayer.GetDisplayedCooldowns(); - if (cooldownsToDraw.Count == 0) - return; + IList cooldownsToDraw = Main.LocalPlayer.GetDisplayedCooldowns(); + if (cooldownsToDraw.Count == 0) + return; - float uiScale = 1f; //The actual UI scale is automatically applied. Using Main.UIScale here will make everyting way bigger due to the scale being applied twice over - Vector2 displayPosition = BaseDrawPosition; - int rectangleSide = (int)Math.Floor(CompactIcons ? 24 * uiScale : 52 * uiScale); - Rectangle iconRectangle = new Rectangle((int)displayPosition.X - rectangleSide / 2, (int)displayPosition.Y - rectangleSide / 2, rectangleSide, rectangleSide); - Rectangle mouse = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); + float uiScale = 1f; //The actual UI scale is automatically applied. Using Main.UIScale here will make everyting way bigger due to the scale being applied twice over + Vector2 displayPosition = BaseDrawPosition; + int rectangleSide = (int)Math.Floor(CompactIcons ? 24 * uiScale : 52 * uiScale); + Rectangle iconRectangle = new Rectangle((int)displayPosition.X - rectangleSide / 2, (int)displayPosition.Y - rectangleSide / 2, rectangleSide, rectangleSide); + Rectangle mouse = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); - string mouseHover = ""; + string mouseHover = ""; - foreach (CooldownInstance instance in cooldownsToDraw) - { - CooldownHandler handler = instance.handler; - float iconOpacity = (float)Math.Sin(Main.GlobalTime) * 0.1f + 0.6f; + foreach (CooldownInstance instance in cooldownsToDraw) + { + CooldownHandler handler = instance.handler; + float iconOpacity = (float)Math.Sin(Main.GlobalTime) * 0.1f + 0.6f; - // Icons get brighter if the mouse gets closer - iconOpacity += 0.3f * (1 - MathHelper.Clamp(Vector2.Distance(mouse.Center.ToVector2(), iconRectangle.Center.ToVector2()), 0f, 80f) / 80f); + // Icons get brighter if the mouse gets closer + iconOpacity += 0.3f * (1 - MathHelper.Clamp(Vector2.Distance(mouse.Center.ToVector2(), iconRectangle.Center.ToVector2()), 0f, 80f) / 80f); - if (iconRectangle.Intersects(mouse)) - { - mouseHover = handler.DisplayName; - iconOpacity = MathHelper.Clamp((float)Math.Sin(Main.GlobalTime % MathHelper.Pi) * 2f, 0, 1) * 0.1f + 0.9f; - } + if (iconRectangle.Intersects(mouse)) + { + mouseHover = handler.DisplayName; + iconOpacity = MathHelper.Clamp((float)Math.Sin(Main.GlobalTime % MathHelper.Pi) * 2f, 0, 1) * 0.1f + 0.9f; + } - if (CompactIcons) - handler.DrawCompact(spriteBatch, displayPosition, iconOpacity, uiScale); - else - handler.DrawExpanded(spriteBatch, displayPosition, iconOpacity, uiScale); + if (CompactIcons) + handler.DrawCompact(spriteBatch, displayPosition, iconOpacity, uiScale); + else + handler.DrawExpanded(spriteBatch, displayPosition, iconOpacity, uiScale); - displayPosition += Spacing; - iconRectangle.X += (int)Spacing.X; - } + displayPosition += Spacing; + iconRectangle.X += (int)Spacing.X; + } - if (mouseHover != "") - { - Main.LocalPlayer.mouseInterface = true; - Main.instance.MouseText(mouseHover); - } + if (mouseHover != "") + { + Main.LocalPlayer.mouseInterface = true; + Main.instance.MouseText(mouseHover); + } - } - } + } + } } diff --git a/UI/DefenseDamageDisplayUI.cs b/UI/DefenseDamageDisplayUI.cs index de7b103ad0..5c5597e5b0 100644 --- a/UI/DefenseDamageDisplayUI.cs +++ b/UI/DefenseDamageDisplayUI.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.UI { - public static class DefenseDamageDisplayUI + public static class DefenseDamageDisplayUI { public static void Draw(SpriteBatch spriteBatch) { diff --git a/UI/DraedonsLogGUI.cs b/UI/DraedonsLogGUI.cs index 0cfecf9d92..4ffc8ab1c4 100644 --- a/UI/DraedonsLogGUI.cs +++ b/UI/DraedonsLogGUI.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.UI { - public abstract class DraedonsLogGUI : PopupGUI + public abstract class DraedonsLogGUI : PopupGUI { public int Page = 0; public int ArrowClickCooldown; diff --git a/UI/EnchantmentMetersUI.cs b/UI/EnchantmentMetersUI.cs index 75cfdcad7b..1e9ef17ad0 100644 --- a/UI/EnchantmentMetersUI.cs +++ b/UI/EnchantmentMetersUI.cs @@ -5,32 +5,32 @@ using Terraria.ModLoader; namespace CalamityMod.UI { - public class EnchantmentMetersUI - { - public static Vector2 DrawPosition => Main.LocalPlayer.Center; - public static void Draw(SpriteBatch spriteBatch, Player player) - { - Item heldItem = player.ActiveItem(); + public class EnchantmentMetersUI + { + public static Vector2 DrawPosition => Main.LocalPlayer.Center; + public static void Draw(SpriteBatch spriteBatch, Player player) + { + Item heldItem = player.ActiveItem(); - // Do not draw if the player has an empty item. Precise item checks for modded content will fail. - if (heldItem is null || heldItem.IsAir) - return; + // Do not draw if the player has an empty item. Precise item checks for modded content will fail. + if (heldItem is null || heldItem.IsAir) + return; - // Draw a bar above the player that displays the discharge of an item if the enchant is used. - if (player.Calamity().dischargingItemEnchant) - { - float dischargeFactor = heldItem.Calamity().DischargeExhaustionRatio; - Texture2D barBorderTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/EphemeralBarBorder"); - Texture2D barTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/EphemeralBar"); + // Draw a bar above the player that displays the discharge of an item if the enchant is used. + if (player.Calamity().dischargingItemEnchant) + { + float dischargeFactor = heldItem.Calamity().DischargeExhaustionRatio; + Texture2D barBorderTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/EphemeralBarBorder"); + Texture2D barTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/EphemeralBar"); - int barCutoff = (int)(barTexture.Height * (1f - dischargeFactor)); - Rectangle barFrame = new Rectangle(0, barCutoff, barTexture.Width, barTexture.Height - barCutoff); - Vector2 barDrawPosition = player.Top - Vector2.UnitY * (barTexture.Height * 0.5f + 40f) + Vector2.UnitY * player.gfxOffY - Main.screenPosition; - Color barColor = Color.White * 0.6f; + int barCutoff = (int)(barTexture.Height * (1f - dischargeFactor)); + Rectangle barFrame = new Rectangle(0, barCutoff, barTexture.Width, barTexture.Height - barCutoff); + Vector2 barDrawPosition = player.Top - Vector2.UnitY * (barTexture.Height * 0.5f + 40f) + Vector2.UnitY * player.gfxOffY - Main.screenPosition; + Color barColor = Color.White * 0.6f; - spriteBatch.Draw(barBorderTexture, barDrawPosition, null, barColor, 0f, barBorderTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); - spriteBatch.Draw(barTexture, barDrawPosition, barFrame, barColor, 0f, barTexture.Size() * 0.5f, 1f, SpriteEffects.FlipVertically, 0f); - } - } - } + spriteBatch.Draw(barBorderTexture, barDrawPosition, null, barColor, 0f, barBorderTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); + spriteBatch.Draw(barTexture, barDrawPosition, barFrame, barColor, 0f, barTexture.Size() * 0.5f, 1f, SpriteEffects.FlipVertically, 0f); + } + } + } } diff --git a/UI/ExoMechSelectionUI.cs b/UI/ExoMechSelectionUI.cs index 17bf26d57c..cbaaddc449 100644 --- a/UI/ExoMechSelectionUI.cs +++ b/UI/ExoMechSelectionUI.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.UI { - public static class ExoMechSelectionUI + public static class ExoMechSelectionUI { public static float DestroyerIconScale = 1f; public static float PrimeIconScale = 1f; @@ -66,7 +66,7 @@ namespace CalamityMod.UI // Make the selection known if a click is done. if (Main.mouseLeft && Main.mouseLeftRelease) - { + { CalamityWorld.DraedonMechToSummon = exoMech; if (Main.netMode != NetmodeID.SinglePlayer) diff --git a/UI/InvasionProgressUIManager.cs b/UI/InvasionProgressUIManager.cs index 509ae14e1a..3081d57271 100644 --- a/UI/InvasionProgressUIManager.cs +++ b/UI/InvasionProgressUIManager.cs @@ -5,7 +5,7 @@ using System.Linq; namespace CalamityMod.UI { - public static class InvasionProgressUIManager + public static class InvasionProgressUIManager { private static readonly List gUIs = new List(); public static int TotalGUIsActive => gUIs.Count(gui => gui.IsActive); diff --git a/UI/LabHologramProjectorUI.cs b/UI/LabHologramProjectorUI.cs index 94b275495c..b3d0d77ec9 100644 --- a/UI/LabHologramProjectorUI.cs +++ b/UI/LabHologramProjectorUI.cs @@ -9,99 +9,99 @@ using Terraria.DataStructures; namespace CalamityMod.UI { - public class LabHologramProjectorUI - { - public const float MaxPlayerDistance = 120f; - public const float TextPadding = 170f; - public const float TextAreaWidth = 800f; - public const float YOffsetPerLine = 30f; - public static string ChooseDialogue() - { - List dialogueOptions = new List() - { - "To any personnel engaged in the laboratories. Please wear your steel engraved ID badge at all times. It is the easiest method to discern your body if any accidents do occur.", - "To experiment is to fail. To fail is to learn. To learn is to advance.", - "Apparent danger while researching serves only to enhance the research experience.", + public class LabHologramProjectorUI + { + public const float MaxPlayerDistance = 120f; + public const float TextPadding = 170f; + public const float TextAreaWidth = 800f; + public const float YOffsetPerLine = 30f; + public static string ChooseDialogue() + { + List dialogueOptions = new List() + { + "To any personnel engaged in the laboratories. Please wear your steel engraved ID badge at all times. It is the easiest method to discern your body if any accidents do occur.", + "To experiment is to fail. To fail is to learn. To learn is to advance.", + "Apparent danger while researching serves only to enhance the research experience.", - "Laser-type weapon prototypes are incredibly lethal and are not to be used within presentation halls.", - "High-energy plasma emissions have adverse effects on both flesh and metal. Do not attempt to handle vented plasma.", - "Electric shocks from military equipment are intended to be fatal. If you survive such a shock, that is a clear indicator that the device is not functioning properly. Please report any such cases.", - "All employees are hereby notified that they will be held accountable for any collateral damage caused by Gauss weapon fire, even during sanctioned testing exercises.", - "Security Field Emitters will vaporize all unauthorized equipment and personnel. Please leave personal effects in the designated lockers off-site. This also means: Do not bring any family members who are not enlisted as personnel.", + "Laser-type weapon prototypes are incredibly lethal and are not to be used within presentation halls.", + "High-energy plasma emissions have adverse effects on both flesh and metal. Do not attempt to handle vented plasma.", + "Electric shocks from military equipment are intended to be fatal. If you survive such a shock, that is a clear indicator that the device is not functioning properly. Please report any such cases.", + "All employees are hereby notified that they will be held accountable for any collateral damage caused by Gauss weapon fire, even during sanctioned testing exercises.", + "Security Field Emitters will vaporize all unauthorized equipment and personnel. Please leave personal effects in the designated lockers off-site. This also means: Do not bring any family members who are not enlisted as personnel.", - "If one does manage to breach restricted testing facilities, do at least record any unexpected burns, lacerations, bruising, fractur... ...trauma, shocks and otherwise. Thank you.", - "The power grid has been... ...eavily compromised. Abort research and proceed to the emergency exits located at... ...and egress with haste.", - "Notify the Security Department of any aggressive local fauna immediately." - }; - if (NPC.downedAncientCultist) - dialogueOptions.Add("Sensors have detected a significant breach in the spacetime continuum."); + "If one does manage to breach restricted testing facilities, do at least record any unexpected burns, lacerations, bruising, fractur... ...trauma, shocks and otherwise. Thank you.", + "The power grid has been... ...eavily compromised. Abort research and proceed to the emergency exits located at... ...and egress with haste.", + "Notify the Security Department of any aggressive local fauna immediately." + }; + if (NPC.downedAncientCultist) + dialogueOptions.Add("Sensors have detected a significant breach in the spacetime continuum."); - return Main.rand.NextBool(5000) ? "Please help. I'm stuck in this hologram machine." : Main.rand.Next(dialogueOptions.ToArray()); - } - public static void Draw(SpriteBatch spriteBatch) - { - Player p = Main.LocalPlayer; - CalamityPlayer mp = p.Calamity(); - int projectorID = mp.CurrentlyViewedHologramID; + return Main.rand.NextBool(5000) ? "Please help. I'm stuck in this hologram machine." : Main.rand.Next(dialogueOptions.ToArray()); + } + public static void Draw(SpriteBatch spriteBatch) + { + Player p = Main.LocalPlayer; + CalamityPlayer mp = p.Calamity(); + int projectorID = mp.CurrentlyViewedHologramID; - // The UI only draws if the player is viewing a projector. - if (projectorID == -1) - return; + // The UI only draws if the player is viewing a projector. + if (projectorID == -1) + return; - // The UI cannot draw if the player is already occupied with an NPC. - if (p.talkNPC > 0 || Main.npcShop > 0) - return; + // The UI cannot draw if the player is already occupied with an NPC. + if (p.talkNPC > 0 || Main.npcShop > 0) + return; - // Check if this tile entity ID is actually a projector. If it's not, immediately destroy this UI. - TELabHologramProjector projector; - bool projectorIsValid = TileEntity.ByID.TryGetValue(projectorID, out TileEntity te); - if (projectorIsValid && te is TELabHologramProjector cast) - projector = cast; - else - { - mp.CurrentlyViewedHologramID = -1; - mp.CurrentlyViewedHologramText = string.Empty; - return; - } + // Check if this tile entity ID is actually a projector. If it's not, immediately destroy this UI. + TELabHologramProjector projector; + bool projectorIsValid = TileEntity.ByID.TryGetValue(projectorID, out TileEntity te); + if (projectorIsValid && te is TELabHologramProjector cast) + projector = cast; + else + { + mp.CurrentlyViewedHologramID = -1; + mp.CurrentlyViewedHologramText = string.Empty; + return; + } - // If the player is too far away from their viewed projector, immediately destroy this UI and play the menu close sound. - Vector2 projectorWorldCenter = projector.Center; - if (p.DistanceSQ(projectorWorldCenter) > MaxPlayerDistance * MaxPlayerDistance) - { - Main.PlaySound(SoundID.MenuClose); - mp.CurrentlyViewedHologramID = -1; - mp.CurrentlyViewedHologramText = string.Empty; - return; - } + // If the player is too far away from their viewed projector, immediately destroy this UI and play the menu close sound. + Vector2 projectorWorldCenter = projector.Center; + if (p.DistanceSQ(projectorWorldCenter) > MaxPlayerDistance * MaxPlayerDistance) + { + Main.PlaySound(SoundID.MenuClose); + mp.CurrentlyViewedHologramID = -1; + mp.CurrentlyViewedHologramText = string.Empty; + return; + } - // Pick text to display, if it has not already been picked. - if (string.IsNullOrEmpty(mp.CurrentlyViewedHologramText)) - mp.CurrentlyViewedHologramText = ChooseDialogue(); + // Pick text to display, if it has not already been picked. + if (string.IsNullOrEmpty(mp.CurrentlyViewedHologramText)) + mp.CurrentlyViewedHologramText = ChooseDialogue(); - Color backgroundColor = new Color(200, 200, 200, 200); + Color backgroundColor = new Color(200, 200, 200, 200); - // Wrap the text so that it neatly fits in the dialogue box. - string[] dialogLines = Utils.WordwrapString(mp.CurrentlyViewedHologramText, Main.fontMouseText, (int)(TextAreaWidth - TextPadding * 2), 10, out int lineCount); + // Wrap the text so that it neatly fits in the dialogue box. + string[] dialogLines = Utils.WordwrapString(mp.CurrentlyViewedHologramText, Main.fontMouseText, (int)(TextAreaWidth - TextPadding * 2), 10, out int lineCount); - // Draw the background of the text box. - spriteBatch.Draw(Main.chatBackTexture, new Vector2(Main.screenWidth / 2 - Main.chatBackTexture.Width / 2, 100f), - new Rectangle(0, 0, Main.chatBackTexture.Width, (lineCount + 2) * 30), backgroundColor, 0f, Vector2.Zero, 1f, - SpriteEffects.None, 0f); - spriteBatch.Draw(Main.chatBackTexture, - new Vector2(Main.screenWidth / 2 - Main.chatBackTexture.Width / 2, 100 + (lineCount + 2) * 30), - new Rectangle(0, Main.chatBackTexture.Height - 30, Main.chatBackTexture.Width, 30), backgroundColor, 0f, - Vector2.Zero, 1f, SpriteEffects.None, 0f); + // Draw the background of the text box. + spriteBatch.Draw(Main.chatBackTexture, new Vector2(Main.screenWidth / 2 - Main.chatBackTexture.Width / 2, 100f), + new Rectangle(0, 0, Main.chatBackTexture.Width, (lineCount + 2) * 30), backgroundColor, 0f, Vector2.Zero, 1f, + SpriteEffects.None, 0f); + spriteBatch.Draw(Main.chatBackTexture, + new Vector2(Main.screenWidth / 2 - Main.chatBackTexture.Width / 2, 100 + (lineCount + 2) * 30), + new Rectangle(0, Main.chatBackTexture.Height - 30, Main.chatBackTexture.Width, 30), backgroundColor, 0f, + Vector2.Zero, 1f, SpriteEffects.None, 0f); - // Draw the dialogue itself. - for (int i = 0; i < lineCount + 1; i++) - { - string text = dialogLines[i]; - if (text is null) - continue; - Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, dialogLines[i], - (int)TextPadding + (int)(Main.screenWidth - TextAreaWidth) / 2, 120 + i * YOffsetPerLine, Color.Cyan, Color.Black, - Vector2.Zero); - } - } - } + // Draw the dialogue itself. + for (int i = 0; i < lineCount + 1; i++) + { + string text = dialogLines[i]; + if (text is null) + continue; + Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, dialogLines[i], + (int)TextPadding + (int)(Main.screenWidth - TextAreaWidth) / 2, 120 + i * YOffsetPerLine, Color.Cyan, Color.Black, + Vector2.Zero); + } + } + } } diff --git a/UI/RipperUI.cs b/UI/RipperUI.cs index 4990423d49..3753b2b8cf 100644 --- a/UI/RipperUI.cs +++ b/UI/RipperUI.cs @@ -208,9 +208,9 @@ namespace CalamityMod.UI // Draw the border of the Adrenaline Bar first spriteBatch.Draw(adrenBorderTex, adrenDrawPos + shakeOffset, null, Color.White, 0f, adrenBorderTex.Size() * 0.5f, uiScale, SpriteEffects.None, 0); - // Use a slightly different texture if Adrenaline is full or active - if (modPlayer.adrenaline >= modPlayer.adrenalineMax || modPlayer.adrenalineModeActive) - spriteBatch.Draw(adrenBorderTexFull, adrenDrawPos + shakeOffset, null, Color.White, 0f, adrenBorderTex.Size() * 0.5f, uiScale, SpriteEffects.None, 0); + // Use a slightly different texture if Adrenaline is full or active + if (modPlayer.adrenaline >= modPlayer.adrenalineMax || modPlayer.adrenalineModeActive) + spriteBatch.Draw(adrenBorderTexFull, adrenDrawPos + shakeOffset, null, Color.White, 0f, adrenBorderTex.Size() * 0.5f, uiScale, SpriteEffects.None, 0); // The amount of the bar to draw depends on the player's current Adrenaline level // 7 pixels of dead space, 90 pixels of bar, 7 pixels of dead space. @@ -236,7 +236,7 @@ namespace CalamityMod.UI // If the animation is active, draw the animation on top of both the border and the bar. if (animationActive) { - float animOffset = 5f; + float animOffset = 5f; float xOffset = (adrenBorderTex.Width - adrenAnimTex.Width) / 2f; int frameHeight = (adrenAnimTex.Height / AdrenAnimFrames) - 1; float yOffset = (adrenBorderTex.Height - frameHeight) / 2f + animOffset; diff --git a/UI/StealthUI.cs b/UI/StealthUI.cs index 79fedac613..7d7794cc3e 100644 --- a/UI/StealthUI.cs +++ b/UI/StealthUI.cs @@ -8,91 +8,91 @@ using Terraria.ModLoader; namespace CalamityMod.UI { - public class StealthUI - { - public static Vector2 DrawPosition = new Vector2(CalamityConfig.Instance.StealthMeterPosX, CalamityConfig.Instance.StealthMeterPosY); - public static Vector2 Offset = DrawPosition; - public static void Draw(SpriteBatch spriteBatch, Player player) - { - if (DrawPosition.X <= 60f && DrawPosition.Y <= 20f) - { - DrawPosition.X = Main.screenWidth / 2f; - DrawPosition.Y = Main.screenHeight / 2 + Main.LocalPlayer.height / 2f + 24f; - } - CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.stealthUIAlpha <= 0f || !CalamityConfig.Instance.StealthBar || modPlayer.rogueStealthMax <= 0f || !modPlayer.wearingRogueArmor) - { - if (CalamityConfig.Instance.StealthMeterPosX != DrawPosition.X) - { - CalamityConfig.Instance.StealthMeterPosX = DrawPosition.X; - CalamityMod.SaveConfig(CalamityConfig.Instance); - } - if (CalamityConfig.Instance.StealthMeterPosY != DrawPosition.Y) - { - CalamityConfig.Instance.StealthMeterPosY = DrawPosition.Y; - CalamityMod.SaveConfig(CalamityConfig.Instance); - } - return; - } - Texture2D edgeTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeter"); - Texture2D indicatorTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterStrikeIndicator"); - Texture2D barTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterBar"); - Texture2D fullBarTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterBarFull"); - float uiScale = Main.UIScale; - spriteBatch.Draw(edgeTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, edgeTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); - if (modPlayer.StealthStrikeAvailable()) - { - spriteBatch.Draw(indicatorTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); - } + public class StealthUI + { + public static Vector2 DrawPosition = new Vector2(CalamityConfig.Instance.StealthMeterPosX, CalamityConfig.Instance.StealthMeterPosY); + public static Vector2 Offset = DrawPosition; + public static void Draw(SpriteBatch spriteBatch, Player player) + { + if (DrawPosition.X <= 60f && DrawPosition.Y <= 20f) + { + DrawPosition.X = Main.screenWidth / 2f; + DrawPosition.Y = Main.screenHeight / 2 + Main.LocalPlayer.height / 2f + 24f; + } + CalamityPlayer modPlayer = player.Calamity(); + if (modPlayer.stealthUIAlpha <= 0f || !CalamityConfig.Instance.StealthBar || modPlayer.rogueStealthMax <= 0f || !modPlayer.wearingRogueArmor) + { + if (CalamityConfig.Instance.StealthMeterPosX != DrawPosition.X) + { + CalamityConfig.Instance.StealthMeterPosX = DrawPosition.X; + CalamityMod.SaveConfig(CalamityConfig.Instance); + } + if (CalamityConfig.Instance.StealthMeterPosY != DrawPosition.Y) + { + CalamityConfig.Instance.StealthMeterPosY = DrawPosition.Y; + CalamityMod.SaveConfig(CalamityConfig.Instance); + } + return; + } + Texture2D edgeTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeter"); + Texture2D indicatorTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterStrikeIndicator"); + Texture2D barTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterBar"); + Texture2D fullBarTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterBarFull"); + float uiScale = Main.UIScale; + spriteBatch.Draw(edgeTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, edgeTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); + if (modPlayer.StealthStrikeAvailable()) + { + spriteBatch.Draw(indicatorTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); + } - float completionRatio = modPlayer.rogueStealth / modPlayer.rogueStealthMax; - Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * completionRatio), barTexture.Width); - bool full = modPlayer.rogueStealth >= modPlayer.rogueStealthMax; - spriteBatch.Draw(full ? fullBarTexture : barTexture, DrawPosition, barRectangle, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); + float completionRatio = modPlayer.rogueStealth / modPlayer.rogueStealthMax; + Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * completionRatio), barTexture.Width); + bool full = modPlayer.rogueStealth >= modPlayer.rogueStealthMax; + spriteBatch.Draw(full ? fullBarTexture : barTexture, DrawPosition, barRectangle, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); Rectangle mouse = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); - Rectangle stealthBar = Utils.CenteredRectangle(DrawPosition, barTexture.Size() * uiScale); + Rectangle stealthBar = Utils.CenteredRectangle(DrawPosition, barTexture.Size() * uiScale); - if (stealthBar.Intersects(mouse)) - { - if (modPlayer.rogueStealthMax > 0f && modPlayer.stealthUIAlpha >= 0.5f) - { - Main.LocalPlayer.mouseInterface = true; - int stealthInt = (int)Math.Round(modPlayer.rogueStealth * 100f); - int maxStealthInt = (int)Math.Round(modPlayer.rogueStealthMax * 100f); - //only way I got this to show up consistently, otherwise it fucked up and showed up anywhere onscreen lol. - Main.instance.MouseText("Stealth: " + stealthInt + "/" + maxStealthInt + "", 0, 0, -1, -1, -1, -1); - modPlayer.stealthUIAlpha = MathHelper.Lerp(modPlayer.stealthUIAlpha, 0.25f, 0.035f); - } - } - if (!CalamityConfig.Instance.MeterPosLock) - { - if (stealthBar.Intersects(mouse)) - { - if (Mouse.GetState().LeftButton == ButtonState.Pressed) - { - Offset = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); - DrawPosition.X = Offset.X; - DrawPosition.Y = Offset.Y; - } - if (Mouse.GetState().LeftButton == ButtonState.Released) - { - DrawPosition.X = Offset.X; - DrawPosition.Y = Offset.Y; - } - } + if (stealthBar.Intersects(mouse)) + { + if (modPlayer.rogueStealthMax > 0f && modPlayer.stealthUIAlpha >= 0.5f) + { + Main.LocalPlayer.mouseInterface = true; + int stealthInt = (int)Math.Round(modPlayer.rogueStealth * 100f); + int maxStealthInt = (int)Math.Round(modPlayer.rogueStealthMax * 100f); + //only way I got this to show up consistently, otherwise it fucked up and showed up anywhere onscreen lol. + Main.instance.MouseText("Stealth: " + stealthInt + "/" + maxStealthInt + "", 0, 0, -1, -1, -1, -1); + modPlayer.stealthUIAlpha = MathHelper.Lerp(modPlayer.stealthUIAlpha, 0.25f, 0.035f); + } + } + if (!CalamityConfig.Instance.MeterPosLock) + { + if (stealthBar.Intersects(mouse)) + { + if (Mouse.GetState().LeftButton == ButtonState.Pressed) + { + Offset = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); + DrawPosition.X = Offset.X; + DrawPosition.Y = Offset.Y; + } + if (Mouse.GetState().LeftButton == ButtonState.Released) + { + DrawPosition.X = Offset.X; + DrawPosition.Y = Offset.Y; + } + } - if (CalamityConfig.Instance.StealthMeterPosX != DrawPosition.X) - { - CalamityConfig.Instance.StealthMeterPosX = DrawPosition.X; - CalamityMod.SaveConfig(CalamityConfig.Instance); - } - if (CalamityConfig.Instance.StealthMeterPosY != DrawPosition.Y) - { - CalamityConfig.Instance.StealthMeterPosY = DrawPosition.Y; - CalamityMod.SaveConfig(CalamityConfig.Instance); - } - } - } - } + if (CalamityConfig.Instance.StealthMeterPosX != DrawPosition.X) + { + CalamityConfig.Instance.StealthMeterPosX = DrawPosition.X; + CalamityMod.SaveConfig(CalamityConfig.Instance); + } + if (CalamityConfig.Instance.StealthMeterPosY != DrawPosition.Y) + { + CalamityConfig.Instance.StealthMeterPosY = DrawPosition.Y; + CalamityMod.SaveConfig(CalamityConfig.Instance); + } + } + } + } } diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index 285002d173..c89af4806d 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -1052,7 +1052,7 @@ namespace CalamityMod // Frog Leg r = GetNewRecipe(); r.AddIngredient(ItemID.Frog, 6); - r.AddTile(TileID.Anvils); + r.AddTile(TileID.Anvils); r.SetResult(ItemID.FrogLeg); r.AddRecipe(); diff --git a/Utilities/CollisionUtils.cs b/Utilities/CollisionUtils.cs index 193270aded..3d79b60d96 100644 --- a/Utilities/CollisionUtils.cs +++ b/Utilities/CollisionUtils.cs @@ -3,79 +3,79 @@ using Terraria; namespace CalamityMod { - public static partial class CalamityUtils - { - /// - /// Performs collision based a rotating hitbox for an entity by treating the hitbox as a line. By default uses the velocity of the entity as a direction. This can be overriden. - /// - /// The entity. - /// The top left coordinates of the target to check. - /// The hitbox size of the target to check. - /// An optional direction override - public static bool RotatingHitboxCollision(this Entity entity, Vector2 targetTopLeft, Vector2 targetHitboxDimensions, Vector2? directionOverride = null) - { - Vector2 lineDirection = directionOverride ?? entity.velocity; + public static partial class CalamityUtils + { + /// + /// Performs collision based a rotating hitbox for an entity by treating the hitbox as a line. By default uses the velocity of the entity as a direction. This can be overriden. + /// + /// The entity. + /// The top left coordinates of the target to check. + /// The hitbox size of the target to check. + /// An optional direction override + public static bool RotatingHitboxCollision(this Entity entity, Vector2 targetTopLeft, Vector2 targetHitboxDimensions, Vector2? directionOverride = null) + { + Vector2 lineDirection = directionOverride ?? entity.velocity; - // Ensure that the line direction is a unit vector. - lineDirection = lineDirection.SafeNormalize(Vector2.UnitY); - Vector2 start = entity.Center - lineDirection * entity.height * 0.5f; - Vector2 end = entity.Center + lineDirection * entity.height * 0.5f; + // Ensure that the line direction is a unit vector. + lineDirection = lineDirection.SafeNormalize(Vector2.UnitY); + Vector2 start = entity.Center - lineDirection * entity.height * 0.5f; + Vector2 end = entity.Center + lineDirection * entity.height * 0.5f; - float _ = 0f; - return Collision.CheckAABBvLineCollision(targetTopLeft, targetHitboxDimensions, start, end, entity.width, ref _); - } + float _ = 0f; + return Collision.CheckAABBvLineCollision(targetTopLeft, targetHitboxDimensions, start, end, entity.width, ref _); + } - /// - /// Determines if a typical hitbox rectangle is intersecting a circular hitbox. - /// - /// The center of the circular hitbox. - /// The radius of the circular hitbox. - /// The hitbox of the target to check. - public static bool CircularHitboxCollision(Vector2 centerCheckPosition, float radius, Rectangle targetHitbox) - { - float topLeftDistance = Vector2.Distance(centerCheckPosition, targetHitbox.TopLeft()); - float topRightDistance = Vector2.Distance(centerCheckPosition, targetHitbox.TopRight()); - float bottomLeftDistance = Vector2.Distance(centerCheckPosition, targetHitbox.BottomLeft()); - float bottomRightDistance = Vector2.Distance(centerCheckPosition, targetHitbox.BottomRight()); + /// + /// Determines if a typical hitbox rectangle is intersecting a circular hitbox. + /// + /// The center of the circular hitbox. + /// The radius of the circular hitbox. + /// The hitbox of the target to check. + public static bool CircularHitboxCollision(Vector2 centerCheckPosition, float radius, Rectangle targetHitbox) + { + float topLeftDistance = Vector2.Distance(centerCheckPosition, targetHitbox.TopLeft()); + float topRightDistance = Vector2.Distance(centerCheckPosition, targetHitbox.TopRight()); + float bottomLeftDistance = Vector2.Distance(centerCheckPosition, targetHitbox.BottomLeft()); + float bottomRightDistance = Vector2.Distance(centerCheckPosition, targetHitbox.BottomRight()); - float distanceToClosestPoint = topLeftDistance; - if (topRightDistance < distanceToClosestPoint) - distanceToClosestPoint = topRightDistance; - if (bottomLeftDistance < distanceToClosestPoint) - distanceToClosestPoint = bottomLeftDistance; - if (bottomRightDistance < distanceToClosestPoint) - distanceToClosestPoint = bottomRightDistance; + float distanceToClosestPoint = topLeftDistance; + if (topRightDistance < distanceToClosestPoint) + distanceToClosestPoint = topRightDistance; + if (bottomLeftDistance < distanceToClosestPoint) + distanceToClosestPoint = bottomLeftDistance; + if (bottomRightDistance < distanceToClosestPoint) + distanceToClosestPoint = bottomRightDistance; - return distanceToClosestPoint <= radius; - } + return distanceToClosestPoint <= radius; + } - /// Determines the distance required before a ray in a given direction from a given starting position hits solid tiles. Gives up after a certain quantity of tiles, or when a world border is reached. - /// - /// The point to check from. - /// The direction in which tiles are checked. Will always be a unit vector. - public static float? DistanceToTileCollisionHit(Vector2 startingPoint, Vector2 checkDirection, int giveUpLimit = 500) - { - // Ensure that the check direction is normalized. - checkDirection = checkDirection.SafeNormalize(Vector2.Zero); + /// Determines the distance required before a ray in a given direction from a given starting position hits solid tiles. Gives up after a certain quantity of tiles, or when a world border is reached. + /// + /// The point to check from. + /// The direction in which tiles are checked. Will always be a unit vector. + public static float? DistanceToTileCollisionHit(Vector2 startingPoint, Vector2 checkDirection, int giveUpLimit = 500) + { + // Ensure that the check direction is normalized. + checkDirection = checkDirection.SafeNormalize(Vector2.Zero); - for (int i = 1; i < giveUpLimit; i++) - { - Point checkPosition = startingPoint.ToTileCoordinates(); - checkPosition.X += (int)(checkDirection.X * i); - checkPosition.Y += (int)(checkDirection.Y * i); + for (int i = 1; i < giveUpLimit; i++) + { + Point checkPosition = startingPoint.ToTileCoordinates(); + checkPosition.X += (int)(checkDirection.X * i); + checkPosition.Y += (int)(checkDirection.Y * i); - // Don't bother checking any further if the check has left the world. - if (!WorldGen.InWorld(checkPosition.X, checkPosition.Y, 2)) - return null; + // Don't bother checking any further if the check has left the world. + if (!WorldGen.InWorld(checkPosition.X, checkPosition.Y, 2)) + return null; - // If a solid tile is hit, return the distance. - // Since Terraria's tile coordinate system is discrete and does not care for more advanced concepts, - // the amount of tiles searched such far is a sufficient answer. - Tile tile = ParanoidTileRetrieval(checkPosition.X, checkPosition.Y); - if (WorldGen.SolidTile(tile) || (checkDirection.Y >= 0f && tile.active() && Main.tileSolidTop[tile.type])) - return i; - } - return null; - } - } + // If a solid tile is hit, return the distance. + // Since Terraria's tile coordinate system is discrete and does not care for more advanced concepts, + // the amount of tiles searched such far is a sufficient answer. + Tile tile = ParanoidTileRetrieval(checkPosition.X, checkPosition.Y); + if (WorldGen.SolidTile(tile) || (checkDirection.Y >= 0f && tile.active() && Main.tileSolidTop[tile.type])) + return i; + } + return null; + } + } } diff --git a/Utilities/EntityUtils.cs b/Utilities/EntityUtils.cs index bcd867859c..f694567dfd 100644 --- a/Utilities/EntityUtils.cs +++ b/Utilities/EntityUtils.cs @@ -3,22 +3,22 @@ using Terraria; namespace CalamityMod { - public static partial class CalamityUtils - { - /// - /// Gets a unit direction towards an arbitrary destination for an entity based on its center. Has safety in the form of a fallback vector. - /// - /// The entity to check from. - /// The destination to get the direction to. - /// A fallback value to use in the event of an unsafe normalization. - public static Vector2 SafeDirectionTo(this Entity entity, Vector2 destination, Vector2? fallback = null) - { - // Fall back to zero by default. default(Vector2) could be used in the parameter definition, but - // this is more clear. - if (!fallback.HasValue) - fallback = Vector2.Zero; + public static partial class CalamityUtils + { + /// + /// Gets a unit direction towards an arbitrary destination for an entity based on its center. Has safety in the form of a fallback vector. + /// + /// The entity to check from. + /// The destination to get the direction to. + /// A fallback value to use in the event of an unsafe normalization. + public static Vector2 SafeDirectionTo(this Entity entity, Vector2 destination, Vector2? fallback = null) + { + // Fall back to zero by default. default(Vector2) could be used in the parameter definition, but + // this is more clear. + if (!fallback.HasValue) + fallback = Vector2.Zero; - return (destination - entity.Center).SafeNormalize(fallback.Value); - } - } + return (destination - entity.Center).SafeNormalize(fallback.Value); + } + } } diff --git a/Utilities/FurnitureSetupUtils.cs b/Utilities/FurnitureSetupUtils.cs index 4c376dfbef..0426924d45 100644 --- a/Utilities/FurnitureSetupUtils.cs +++ b/Utilities/FurnitureSetupUtils.cs @@ -11,1134 +11,1134 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { - public static partial class CalamityUtils - { - public static void RightClickBreak(int i, int j) - { - if (Main.tile[i, j] != null && Main.tile[i, j].active()) - { - WorldGen.KillTile(i, j, false, false, false); - if (!Main.tile[i, j].active() && Main.netMode != NetmodeID.SinglePlayer) - { - NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); - } - } - } - - public static bool BedRightClick(int i, int j) - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[i, j]; - int spawnX = i - tile.frameX / 18; - int spawnY = j + 2; - spawnX += tile.frameX >= 72 ? 5 : 2; - if (tile.frameY % 38 != 0) - { - spawnY--; - } - player.FindSpawn(); - if (player.SpawnX == spawnX && player.SpawnY == spawnY) - { - player.RemoveSpawn(); - Main.NewText("Spawn point removed!", 255, 240, 20, false); - } - else if (Player.CheckSpawn(spawnX, spawnY)) - { - player.ChangeSpawn(spawnX, spawnY); - Main.NewText("Spawn point set!", 255, 240, 20, false); - } - return true; - } - - public static bool ChestRightClick(int i, int j) - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[i, j]; - Main.mouseRightRelease = false; - int left = i; - int top = j; - if (tile.frameX % 36 != 0) - { - left--; - } - if (tile.frameY != 0) - { - top--; - } - if (player.sign >= 0) - { - Main.PlaySound(SoundID.MenuClose); - player.sign = -1; - Main.editSign = false; - Main.npcChatText = ""; - } - if (Main.editChest) - { - Main.PlaySound(SoundID.MenuTick); - Main.editChest = false; - Main.npcChatText = ""; - } - if (player.editedChestName) - { - NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); - player.editedChestName = false; - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - { - if (left == player.chestX && top == player.chestY && player.chest >= 0) - { - player.chest = -1; - Recipe.FindRecipes(); - Main.PlaySound(SoundID.MenuClose); - } - else - { - NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); - Main.stackSplit = 600; - } - } - else - { - int chest = Chest.FindChest(left, top); - if (chest >= 0) - { - Main.stackSplit = 600; - if (chest == player.chest) - { - player.chest = -1; - Main.PlaySound(SoundID.MenuClose); - } - else - { - player.chest = chest; - Main.playerInventory = true; - Main.recBigList = false; - player.chestX = left; - player.chestY = top; - Main.PlaySound(player.chest < 0 ? SoundID.MenuOpen : SoundID.MenuTick); - } - Recipe.FindRecipes(); - } - } - return true; - } - - public static void ChestMouseOver(string chestName, int i, int j) where T : ModItem - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[i, j]; - int left = i; - int top = j; - if (tile.frameX % 36 != 0) - { - left--; - } - if (tile.frameY != 0) - { - top--; - } - int chest = Chest.FindChest(left, top); - player.showItemIcon2 = -1; - if (chest < 0) - { - player.showItemIconText = Language.GetTextValue("LegacyChestType.0"); - } - else - { - player.showItemIconText = Main.chest[chest].name.Length > 0 ? Main.chest[chest].name : chestName; - if (player.showItemIconText == chestName) - { - player.showItemIcon2 = ItemType(); - player.showItemIconText = ""; - } - } - player.noThrow = 2; - player.showItemIcon = true; - } - - public static void ChestMouseFar(string name, int i, int j) where T : ModItem - { - ChestMouseOver(name, i, j); - Player player = Main.LocalPlayer; - if (player.showItemIconText == "") - { - player.showItemIcon = false; - player.showItemIcon2 = 0; - } - } - - public static bool ClockRightClick() - { - string text = "AM"; - - // 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, then change to PM if necessary - if (time < 0D) - time += 24D; - if (time >= 12D) - text = "PM"; - - // 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); - - string minuteText = deltaTime.ToString(); - - // Ensure minutes has a leading zero - if (deltaTime < 10D) - minuteText = "0" + minuteText; - - // Convert from 24 to 12 hour time (PM already handled earlier) - if (intTime > 12) - intTime -= 12; - // 12 AM is actually hour zero in 24 hour time - if (intTime == 0) - intTime = 12; - - // Create an overall time readout and send it to chat - var newText = string.Concat("Time: ", intTime, ":", minuteText, " ", text); - Main.NewText(newText, 255, 240, 20); - return true; - } - - public static bool DresserRightClick() - { - Player player = Main.LocalPlayer; - if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameY == 0) - { - Main.CancelClothesWindow(true); - - int left = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18); - left %= 3; - left = Player.tileTargetX - left; - int top = Player.tileTargetY - (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18); - if (player.sign > -1) - { - Main.PlaySound(SoundID.MenuClose); - player.sign = -1; - Main.editSign = false; - Main.npcChatText = string.Empty; - } - if (Main.editChest) - { - Main.PlaySound(SoundID.MenuTick); - Main.editChest = false; - Main.npcChatText = string.Empty; - } - if (player.editedChestName) - { - NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); - player.editedChestName = false; - } - if (Main.netMode == NetmodeID.MultiplayerClient) - { - if (left == player.chestX && top == player.chestY && player.chest != -1) - { - player.chest = -1; - Recipe.FindRecipes(); - Main.PlaySound(SoundID.MenuClose); - } - else - { - NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); - Main.stackSplit = 600; - } - return true; - } - else - { - player.flyingPigChest = -1; - int num213 = Chest.FindChest(left, top); - if (num213 != -1) - { - Main.stackSplit = 600; - if (num213 == player.chest) - { - player.chest = -1; - Recipe.FindRecipes(); - Main.PlaySound(SoundID.MenuClose); - } - else if (num213 != player.chest && player.chest == -1) - { - player.chest = num213; - Main.playerInventory = true; - Main.recBigList = false; - Main.PlaySound(SoundID.MenuOpen); - player.chestX = left; - player.chestY = top; - } - else - { - player.chest = num213; - Main.playerInventory = true; - Main.recBigList = false; - Main.PlaySound(SoundID.MenuTick); - player.chestX = left; - player.chestY = top; - } - Recipe.FindRecipes(); - return true; - } - } - } - else - { - Main.playerInventory = false; - player.chest = -1; - Recipe.FindRecipes(); - Main.dresserX = Player.tileTargetX; - Main.dresserY = Player.tileTargetY; - Main.OpenClothesWindow(); - return true; - } - - return false; - } - - public static void DresserMouseFar(string chestName) where T : ModItem - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; - int left = Player.tileTargetX; - int top = Player.tileTargetY; - left -= (int)(tile.frameX % 54 / 18); - if (tile.frameY % 36 != 0) - { - top--; - } - int chestIndex = Chest.FindChest(left, top); - player.showItemIcon2 = -1; - if (chestIndex < 0) - { - player.showItemIconText = Language.GetTextValue("LegacyDresserType.0"); - } - else - { - if (Main.chest[chestIndex].name != "") - { - player.showItemIconText = Main.chest[chestIndex].name; - } - else - { - player.showItemIconText = chestName; - } - if (player.showItemIconText == chestName) - { - player.showItemIcon2 = ItemType(); - player.showItemIconText = ""; - } - } - player.noThrow = 2; - player.showItemIcon = true; - if (player.showItemIconText == "") - { - player.showItemIcon = false; - player.showItemIcon2 = 0; - } - } - - public static void DresserMouseOver(string chestName) where T : ModItem - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; - int left = Player.tileTargetX; - int top = Player.tileTargetY; - left -= (int)(tile.frameX % 54 / 18); - if (tile.frameY % 36 != 0) - { - top--; - } - int chestIndex = Chest.FindChest(left, top); - player.showItemIcon2 = -1; - if (chestIndex < 0) - { - player.showItemIconText = Language.GetTextValue("LegacyDresserType.0"); - } - else - { - if (Main.chest[chestIndex].name != "") - { - player.showItemIconText = Main.chest[chestIndex].name; - } - else - { - player.showItemIconText = chestName; - } - if (player.showItemIconText == chestName) - { - player.showItemIcon2 = ItemType(); - player.showItemIconText = ""; - } - } - player.noThrow = 2; - player.showItemIcon = true; - if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameY > 0) - { - player.showItemIcon2 = ItemID.FamiliarShirt; - } - } - - public static bool LockedChestRightClick(bool isLocked, int left, int top, int i, int j) - { - Player player = Main.LocalPlayer; - - // If the player right clicked the chest while editing a sign, finish that up - if (player.sign >= 0) - { - Main.PlaySound(SoundID.MenuClose); - player.sign = -1; - Main.editSign = false; - Main.npcChatText = ""; - } - - // If the player right clicked the chest while editing a chest, finish that up - if (Main.editChest) - { - Main.PlaySound(SoundID.MenuTick); - Main.editChest = false; - Main.npcChatText = ""; - } - - // If the player right clicked the chest after changing another chest's name, finish that up - if (player.editedChestName) - { - NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); - player.editedChestName = false; - } - if (Main.netMode == NetmodeID.MultiplayerClient && !isLocked) - { - // Right clicking the chest you currently have open closes it. This counts as interaction. - if (left == player.chestX && top == player.chestY && player.chest >= 0) - { - player.chest = -1; - Recipe.FindRecipes(); - Main.PlaySound(SoundID.MenuClose); - } - - // Right clicking this chest opens it if it's not already open. This counts as interaction. - else - { - NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); - Main.stackSplit = 600; - } - return true; - } - - else - { - if (isLocked) - { - // If you right click the locked chest and you can unlock it, it unlocks itself but does not open. This counts as interaction. - if (Chest.Unlock(left, top)) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendData(MessageID.Unlock, -1, -1, null, player.whoAmI, 1f, (float)left, (float)top); - } - return true; - } - } - else - { - int chest = Chest.FindChest(left, top); - if (chest >= 0) - { - Main.stackSplit = 600; - - // If you right click the same chest you already have open, it closes. This counts as interaction. - if (chest == player.chest) - { - player.chest = -1; - Main.PlaySound(SoundID.MenuClose); - } - - // If you right click this chest when you have a different chest selected, that one closes and this one opens. This counts as interaction. - else - { - player.chest = chest; - Main.playerInventory = true; - Main.recBigList = false; - player.chestX = left; - player.chestY = top; - Main.PlaySound(player.chest < 0 ? SoundID.MenuOpen : SoundID.MenuTick); - } - - Recipe.FindRecipes(); - return true; - } - } - } - - // This only occurs when the chest is locked and cannot be unlocked. You did not interact with the chest. - return false; - } - - public static void LockedChestMouseOver(string chestName, int i, int j) - where K : ModItem where C : ModItem - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[i, j]; - int left = i; - int top = j; - if (tile.frameX % 36 != 0) - { - left--; - } - if (tile.frameY != 0) - { - top--; - } - int chest = Chest.FindChest(left, top); - player.showItemIcon2 = -1; - if (chest < 0) - { - player.showItemIconText = Language.GetTextValue("LegacyChestType.0"); - } - else - { - player.showItemIconText = Main.chest[chest].name.Length > 0 ? Main.chest[chest].name : chestName; - if (player.showItemIconText == chestName) - { - player.showItemIcon2 = ItemType(); - if (Main.tile[left, top].frameX / 36 == 1) - player.showItemIcon2 = ItemType(); - player.showItemIconText = ""; - } - } - player.noThrow = 2; - player.showItemIcon = true; - } - - public static void LockedChestMouseOverFar(string chestName, int i, int j) - where K : ModItem where C : ModItem - { - LockedChestMouseOver(chestName, i, j); - Player player = Main.LocalPlayer; - if (player.showItemIconText == "") - { - player.showItemIcon = false; - player.showItemIcon2 = 0; - } - } - - /// - /// Extension which initializes a ModTile to be a bathtub. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpBathtub(this ModTile mt, bool lavaImmune = false) - { - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.Width = 4; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 4, 0); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; - TileObjectData.addAlternate(1); - TileObjectData.addTile(mt.Type); - - // All bathtubs count as tables. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - } - - /// - /// Extension which initializes a ModTile to be a bed. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpBed(this ModTile mt, bool lavaImmune = false) - { - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.HasOutlines[mt.Type] = true; - TileObjectData.newTile.Width = 4; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 4, 0); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; - TileObjectData.addAlternate(1); - TileObjectData.addTile(mt.Type); - - // All beds count as chairs. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); - } - - /// - /// Extension which initializes a ModTile to be a bookcase. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - /// Whether this tile is supposed to have a solid top. Defaults to true. - /// Whether this tile counts as a table for housing. Defaults to true. - internal static void SetUpBookcase(this ModTile mt, bool lavaImmune = false, bool solidTop = true, bool table = true) - { - Main.tileSolidTop[mt.Type] = solidTop; - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileTable[mt.Type] = solidTop; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.addTile(mt.Type); - - // All bookcases count as tables. Monolith Amalgam does not count as a table. - if (table) - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - } - - /// - /// Extension which initializes a ModTile to be a candelabra. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpCandelabra(this ModTile mt, bool lavaImmune = false) - { - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = true; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.addTile(mt.Type); - - // All candelabras count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - } - - /// - /// Extension which initializes a ModTile to be a candle. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpCandle(this ModTile mt, bool lavaImmune = false, int offset = -4) - { - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.StyleOnTable1x1); - TileObjectData.newTile.CoordinateHeights = new int[] { 20 }; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.DrawYOffset = offset; - TileObjectData.addTile(mt.Type); - - // All candles count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - } - - /// - /// Extension which initializes a ModTile to be a chair. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpChair(this ModTile mt, bool lavaImmune = false) - { - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.newTile.StyleWrapLimit = 2; - TileObjectData.newTile.StyleMultiplier = 2; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; - TileObjectData.addAlternate(1); - TileObjectData.addTile(mt.Type); - - // As you could probably guess, all chairs count as chairs. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); - } - - /// - /// Extension which initializes a ModTile to be a chandelier. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpChandelier(this ModTile mt, bool lavaImmune = false) - { - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.Width = 3; - TileObjectData.newTile.Height = 3; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.Origin = new Point16(1, 0); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.addTile(mt.Type); - - // All chandeliers count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - } - - /// - /// Extension which initializes a ModTile to be a chest. - /// - /// The ModTile which is being initialized. - internal static void SetUpChest(this ModTile mt, bool offset = false) - { - Main.tileSpelunker[mt.Type] = true; - Main.tileContainer[mt.Type] = true; - Main.tileShine2[mt.Type] = true; - Main.tileShine[mt.Type] = 1200; - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileValue[mt.Type] = 500; - TileID.Sets.HasOutlines[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - if (offset) - TileObjectData.newTile.DrawYOffset = 4; - TileObjectData.newTile.Origin = new Point16(0, 1); - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; - TileObjectData.newTile.HookCheck = new PlacementHook(new Func(Chest.FindEmptyChest), -1, 0, true); - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(new Func(Chest.AfterPlacement_Hook), -1, 0, false); - TileObjectData.newTile.AnchorInvalidTiles = new int[] { 127 }; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.LavaDeath = false; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); - TileObjectData.addTile(mt.Type); - } - - /// - /// Extension which initializes a ModTile to be a clock. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpClock(this ModTile mt, bool lavaImmune = false) - { - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - TileID.Sets.HasOutlines[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX); - TileObjectData.newTile.Height = 5; - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16, - 16, - 16, - 16, - 16 - }; - TileObjectData.newTile.Origin = new Point16(0, 4); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.addTile(mt.Type); - } - - /// - /// Extension which initializes a ModTile to be a closed door. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpDoorClosed(this ModTile mt, bool lavaImmune = false) - { - Main.tileFrameImportant[mt.Type] = true; - Main.tileBlockLight[mt.Type] = true; - Main.tileSolid[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.NotReallySolid[mt.Type] = true; - TileID.Sets.DrawsWalls[mt.Type] = true; - TileID.Sets.HasOutlines[mt.Type] = true; - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 3; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.LavaDeath = true; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(0, 1); - TileObjectData.addAlternate(0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(0, 2); - TileObjectData.addAlternate(0); - TileObjectData.addTile(mt.Type); - - // As you could probably guess, all closed doors count as doors. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); - } - - /// - /// Extension which initializes a ModTile to be an open door. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpDoorOpen(this ModTile mt, bool lavaImmune = false) - { - Main.tileFrameImportant[mt.Type] = true; - Main.tileSolid[mt.Type] = false; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - Main.tileNoSunLight[mt.Type] = true; - TileObjectData.newTile.Width = 2; - TileObjectData.newTile.Height = 3; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 0); - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 0); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.LavaDeath = true; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.StyleMultiplier = 2; - TileObjectData.newTile.StyleWrapLimit = 2; - TileObjectData.newTile.Direction = TileObjectDirection.PlaceRight; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(0, 1); - TileObjectData.addAlternate(0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(0, 2); - TileObjectData.addAlternate(0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(1, 0); - TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.addAlternate(1); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(1, 1); - TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.addAlternate(1); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(1, 2); - TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.addAlternate(1); - TileObjectData.addTile(mt.Type); - TileID.Sets.HousingWalls[mt.Type] = true; - TileID.Sets.HasOutlines[mt.Type] = true; - - // As you could probably guess, all open doors count as doors. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); - } - - /// - /// Extension which initializes a ModTile to be a dresser. - /// - /// The ModTile which is being initialized. - internal static void SetUpDresser(this ModTile mt) - { - Main.tileSolidTop[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileTable[mt.Type] = true; - Main.tileContainer[mt.Type] = true; - Main.tileWaterDeath[mt.Type] = false; - Main.tileLavaDeath[mt.Type] = false; - TileID.Sets.HasOutlines[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16 }; - TileObjectData.newTile.HookCheck = new PlacementHook(new Func(Chest.FindEmptyChest), -1, 0, true); - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(new Func(Chest.AfterPlacement_Hook), -1, 0, false); - TileObjectData.newTile.AnchorInvalidTiles = new int[] { 127 }; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.LavaDeath = false; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); - TileObjectData.addTile(mt.Type); - - // All dressers count as tables. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - } - - /// - /// Extension which initializes a ModTile to be a floor lamp. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpLamp(this ModTile mt, bool lavaImmune = false) - { - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1xX); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.addTile(mt.Type); - - // All floor lamps count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - } - - /// - /// Extension which initializes a ModTile to be a hanging lantern. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpLantern(this ModTile mt, bool lavaImmune = false) - { - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2Top); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.addTile(mt.Type); - - // All hanging lanterns count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - } - - /// - /// Extension which initializes a ModTile to be a piano. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - /// Whether this tile is supposed to have a solid top. Defaults to true. - internal static void SetUpPiano(this ModTile mt, bool lavaImmune = false, bool solidTop = true) - { - Main.tileSolidTop[mt.Type] = solidTop; - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.addTile(mt.Type); - - // All pianos count as tables. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - } - - /// - /// Extension which initializes a ModTile to be a platform. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpPlatform(this ModTile mt, bool lavaImmune = false) - { - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileSolidTop[mt.Type] = true; - Main.tileSolid[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileTable[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - TileID.Sets.Platforms[mt.Type] = true; - TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.StyleMultiplier = 27; - TileObjectData.newTile.StyleWrapLimit = 27; - TileObjectData.newTile.UsesCustomCanPlace = false; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.addTile(mt.Type); - - // All platforms count as doors (so that you may have top-or-bottom entry/exit rooms) - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); - } - - /// - /// Extension which initializes a ModTile to be a sink. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpSink(this ModTile mt, bool lavaImmune = false) - { - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.addTile(mt.Type); - } - - /// - /// Extension which initializes a ModTile to be a sofa. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpSofa(this ModTile mt, bool lavaImmune = false) - { - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.addTile(mt.Type); - - // All sofas count as chairs. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); - } - - /// - /// Extension which initializes a ModTile to be a table. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpTable(this ModTile mt, bool lavaImmune = false) - { - Main.tileSolidTop[mt.Type] = true; - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileTable[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.addTile(mt.Type); - - // As you could probably guess, all tables count as tables. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - } - - /// - /// Extension which initializes a ModTile to be a torch. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpTorch(this ModTile mt, bool lavaImmune = false, bool waterImmune = false) - { - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileSolid[mt.Type] = false; - Main.tileNoAttach[mt.Type] = true; - Main.tileNoFail[mt.Type] = true; - Main.tileWaterDeath[mt.Type] = !waterImmune; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - TileObjectData.newTile.CopyFrom(TileObjectData.StyleTorch); - TileObjectData.newTile.WaterDeath = !waterImmune; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); - TileObjectData.newAlternate.WaterDeath = false; - TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.Tree | AnchorType.AlternateTile, TileObjectData.newTile.Height, 0); - TileObjectData.newAlternate.AnchorAlternateTiles = new int[] { 124 }; - TileObjectData.addAlternate(1); - TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); - TileObjectData.newAlternate.WaterDeath = false; - TileObjectData.newAlternate.AnchorRight = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.Tree | AnchorType.AlternateTile, TileObjectData.newTile.Height, 0); - TileObjectData.newAlternate.AnchorAlternateTiles = new int[] { 124 }; - TileObjectData.addAlternate(2); - TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); - TileObjectData.newAlternate.WaterDeath = false; - TileObjectData.newAlternate.AnchorWall = true; - TileObjectData.addAlternate(0); - TileObjectData.addTile(mt.Type); - - // All torches count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - } - - /// - /// Extension which initializes a ModTile to be a work bench. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpWorkBench(this ModTile mt, bool lavaImmune = false) - { - Main.tileSolidTop[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileTable[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.CoordinateHeights = new int[] { 18 }; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.addTile(mt.Type); - - // 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.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.UsesCustomCanPlace = true; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 2, 0); - TileObjectData.addTile(mt.Type); - } - - /// - /// Extension which initializes a ModTile to be a bed. - /// - /// The ModTile which is being initialized. - /// The color of the bar on the minimap. - /// Whether this tile is supposed to be immune to lava. Defaults to true like vanilla bars. - internal static void SetUpBar(this ModTile mt, Color mapColor, bool lavaImmune = true) - { + public static partial class CalamityUtils + { + public static void RightClickBreak(int i, int j) + { + if (Main.tile[i, j] != null && Main.tile[i, j].active()) + { + WorldGen.KillTile(i, j, false, false, false); + if (!Main.tile[i, j].active() && Main.netMode != NetmodeID.SinglePlayer) + { + NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); + } + } + } + + public static bool BedRightClick(int i, int j) + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[i, j]; + int spawnX = i - tile.frameX / 18; + int spawnY = j + 2; + spawnX += tile.frameX >= 72 ? 5 : 2; + if (tile.frameY % 38 != 0) + { + spawnY--; + } + player.FindSpawn(); + if (player.SpawnX == spawnX && player.SpawnY == spawnY) + { + player.RemoveSpawn(); + Main.NewText("Spawn point removed!", 255, 240, 20, false); + } + else if (Player.CheckSpawn(spawnX, spawnY)) + { + player.ChangeSpawn(spawnX, spawnY); + Main.NewText("Spawn point set!", 255, 240, 20, false); + } + return true; + } + + public static bool ChestRightClick(int i, int j) + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[i, j]; + Main.mouseRightRelease = false; + int left = i; + int top = j; + if (tile.frameX % 36 != 0) + { + left--; + } + if (tile.frameY != 0) + { + top--; + } + if (player.sign >= 0) + { + Main.PlaySound(SoundID.MenuClose); + player.sign = -1; + Main.editSign = false; + Main.npcChatText = ""; + } + if (Main.editChest) + { + Main.PlaySound(SoundID.MenuTick); + Main.editChest = false; + Main.npcChatText = ""; + } + if (player.editedChestName) + { + NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); + player.editedChestName = false; + } + + if (Main.netMode == NetmodeID.MultiplayerClient) + { + if (left == player.chestX && top == player.chestY && player.chest >= 0) + { + player.chest = -1; + Recipe.FindRecipes(); + Main.PlaySound(SoundID.MenuClose); + } + else + { + NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); + Main.stackSplit = 600; + } + } + else + { + int chest = Chest.FindChest(left, top); + if (chest >= 0) + { + Main.stackSplit = 600; + if (chest == player.chest) + { + player.chest = -1; + Main.PlaySound(SoundID.MenuClose); + } + else + { + player.chest = chest; + Main.playerInventory = true; + Main.recBigList = false; + player.chestX = left; + player.chestY = top; + Main.PlaySound(player.chest < 0 ? SoundID.MenuOpen : SoundID.MenuTick); + } + Recipe.FindRecipes(); + } + } + return true; + } + + public static void ChestMouseOver(string chestName, int i, int j) where T : ModItem + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[i, j]; + int left = i; + int top = j; + if (tile.frameX % 36 != 0) + { + left--; + } + if (tile.frameY != 0) + { + top--; + } + int chest = Chest.FindChest(left, top); + player.showItemIcon2 = -1; + if (chest < 0) + { + player.showItemIconText = Language.GetTextValue("LegacyChestType.0"); + } + else + { + player.showItemIconText = Main.chest[chest].name.Length > 0 ? Main.chest[chest].name : chestName; + if (player.showItemIconText == chestName) + { + player.showItemIcon2 = ItemType(); + player.showItemIconText = ""; + } + } + player.noThrow = 2; + player.showItemIcon = true; + } + + public static void ChestMouseFar(string name, int i, int j) where T : ModItem + { + ChestMouseOver(name, i, j); + Player player = Main.LocalPlayer; + if (player.showItemIconText == "") + { + player.showItemIcon = false; + player.showItemIcon2 = 0; + } + } + + public static bool ClockRightClick() + { + string text = "AM"; + + // 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, then change to PM if necessary + if (time < 0D) + time += 24D; + if (time >= 12D) + text = "PM"; + + // 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); + + string minuteText = deltaTime.ToString(); + + // Ensure minutes has a leading zero + if (deltaTime < 10D) + minuteText = "0" + minuteText; + + // Convert from 24 to 12 hour time (PM already handled earlier) + if (intTime > 12) + intTime -= 12; + // 12 AM is actually hour zero in 24 hour time + if (intTime == 0) + intTime = 12; + + // Create an overall time readout and send it to chat + var newText = string.Concat("Time: ", intTime, ":", minuteText, " ", text); + Main.NewText(newText, 255, 240, 20); + return true; + } + + public static bool DresserRightClick() + { + Player player = Main.LocalPlayer; + if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameY == 0) + { + Main.CancelClothesWindow(true); + + int left = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18); + left %= 3; + left = Player.tileTargetX - left; + int top = Player.tileTargetY - (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18); + if (player.sign > -1) + { + Main.PlaySound(SoundID.MenuClose); + player.sign = -1; + Main.editSign = false; + Main.npcChatText = string.Empty; + } + if (Main.editChest) + { + Main.PlaySound(SoundID.MenuTick); + Main.editChest = false; + Main.npcChatText = string.Empty; + } + if (player.editedChestName) + { + NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); + player.editedChestName = false; + } + if (Main.netMode == NetmodeID.MultiplayerClient) + { + if (left == player.chestX && top == player.chestY && player.chest != -1) + { + player.chest = -1; + Recipe.FindRecipes(); + Main.PlaySound(SoundID.MenuClose); + } + else + { + NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); + Main.stackSplit = 600; + } + return true; + } + else + { + player.flyingPigChest = -1; + int num213 = Chest.FindChest(left, top); + if (num213 != -1) + { + Main.stackSplit = 600; + if (num213 == player.chest) + { + player.chest = -1; + Recipe.FindRecipes(); + Main.PlaySound(SoundID.MenuClose); + } + else if (num213 != player.chest && player.chest == -1) + { + player.chest = num213; + Main.playerInventory = true; + Main.recBigList = false; + Main.PlaySound(SoundID.MenuOpen); + player.chestX = left; + player.chestY = top; + } + else + { + player.chest = num213; + Main.playerInventory = true; + Main.recBigList = false; + Main.PlaySound(SoundID.MenuTick); + player.chestX = left; + player.chestY = top; + } + Recipe.FindRecipes(); + return true; + } + } + } + else + { + Main.playerInventory = false; + player.chest = -1; + Recipe.FindRecipes(); + Main.dresserX = Player.tileTargetX; + Main.dresserY = Player.tileTargetY; + Main.OpenClothesWindow(); + return true; + } + + return false; + } + + public static void DresserMouseFar(string chestName) where T : ModItem + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; + int left = Player.tileTargetX; + int top = Player.tileTargetY; + left -= (int)(tile.frameX % 54 / 18); + if (tile.frameY % 36 != 0) + { + top--; + } + int chestIndex = Chest.FindChest(left, top); + player.showItemIcon2 = -1; + if (chestIndex < 0) + { + player.showItemIconText = Language.GetTextValue("LegacyDresserType.0"); + } + else + { + if (Main.chest[chestIndex].name != "") + { + player.showItemIconText = Main.chest[chestIndex].name; + } + else + { + player.showItemIconText = chestName; + } + if (player.showItemIconText == chestName) + { + player.showItemIcon2 = ItemType(); + player.showItemIconText = ""; + } + } + player.noThrow = 2; + player.showItemIcon = true; + if (player.showItemIconText == "") + { + player.showItemIcon = false; + player.showItemIcon2 = 0; + } + } + + public static void DresserMouseOver(string chestName) where T : ModItem + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; + int left = Player.tileTargetX; + int top = Player.tileTargetY; + left -= (int)(tile.frameX % 54 / 18); + if (tile.frameY % 36 != 0) + { + top--; + } + int chestIndex = Chest.FindChest(left, top); + player.showItemIcon2 = -1; + if (chestIndex < 0) + { + player.showItemIconText = Language.GetTextValue("LegacyDresserType.0"); + } + else + { + if (Main.chest[chestIndex].name != "") + { + player.showItemIconText = Main.chest[chestIndex].name; + } + else + { + player.showItemIconText = chestName; + } + if (player.showItemIconText == chestName) + { + player.showItemIcon2 = ItemType(); + player.showItemIconText = ""; + } + } + player.noThrow = 2; + player.showItemIcon = true; + if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameY > 0) + { + player.showItemIcon2 = ItemID.FamiliarShirt; + } + } + + public static bool LockedChestRightClick(bool isLocked, int left, int top, int i, int j) + { + Player player = Main.LocalPlayer; + + // If the player right clicked the chest while editing a sign, finish that up + if (player.sign >= 0) + { + Main.PlaySound(SoundID.MenuClose); + player.sign = -1; + Main.editSign = false; + Main.npcChatText = ""; + } + + // If the player right clicked the chest while editing a chest, finish that up + if (Main.editChest) + { + Main.PlaySound(SoundID.MenuTick); + Main.editChest = false; + Main.npcChatText = ""; + } + + // If the player right clicked the chest after changing another chest's name, finish that up + if (player.editedChestName) + { + NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); + player.editedChestName = false; + } + if (Main.netMode == NetmodeID.MultiplayerClient && !isLocked) + { + // Right clicking the chest you currently have open closes it. This counts as interaction. + if (left == player.chestX && top == player.chestY && player.chest >= 0) + { + player.chest = -1; + Recipe.FindRecipes(); + Main.PlaySound(SoundID.MenuClose); + } + + // Right clicking this chest opens it if it's not already open. This counts as interaction. + else + { + NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); + Main.stackSplit = 600; + } + return true; + } + + else + { + if (isLocked) + { + // If you right click the locked chest and you can unlock it, it unlocks itself but does not open. This counts as interaction. + if (Chest.Unlock(left, top)) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.Unlock, -1, -1, null, player.whoAmI, 1f, (float)left, (float)top); + } + return true; + } + } + else + { + int chest = Chest.FindChest(left, top); + if (chest >= 0) + { + Main.stackSplit = 600; + + // If you right click the same chest you already have open, it closes. This counts as interaction. + if (chest == player.chest) + { + player.chest = -1; + Main.PlaySound(SoundID.MenuClose); + } + + // If you right click this chest when you have a different chest selected, that one closes and this one opens. This counts as interaction. + else + { + player.chest = chest; + Main.playerInventory = true; + Main.recBigList = false; + player.chestX = left; + player.chestY = top; + Main.PlaySound(player.chest < 0 ? SoundID.MenuOpen : SoundID.MenuTick); + } + + Recipe.FindRecipes(); + return true; + } + } + } + + // This only occurs when the chest is locked and cannot be unlocked. You did not interact with the chest. + return false; + } + + public static void LockedChestMouseOver(string chestName, int i, int j) + where K : ModItem where C : ModItem + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[i, j]; + int left = i; + int top = j; + if (tile.frameX % 36 != 0) + { + left--; + } + if (tile.frameY != 0) + { + top--; + } + int chest = Chest.FindChest(left, top); + player.showItemIcon2 = -1; + if (chest < 0) + { + player.showItemIconText = Language.GetTextValue("LegacyChestType.0"); + } + else + { + player.showItemIconText = Main.chest[chest].name.Length > 0 ? Main.chest[chest].name : chestName; + if (player.showItemIconText == chestName) + { + player.showItemIcon2 = ItemType(); + if (Main.tile[left, top].frameX / 36 == 1) + player.showItemIcon2 = ItemType(); + player.showItemIconText = ""; + } + } + player.noThrow = 2; + player.showItemIcon = true; + } + + public static void LockedChestMouseOverFar(string chestName, int i, int j) + where K : ModItem where C : ModItem + { + LockedChestMouseOver(chestName, i, j); + Player player = Main.LocalPlayer; + if (player.showItemIconText == "") + { + player.showItemIcon = false; + player.showItemIcon2 = 0; + } + } + + /// + /// Extension which initializes a ModTile to be a bathtub. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpBathtub(this ModTile mt, bool lavaImmune = false) + { + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 4, 0); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; + TileObjectData.addAlternate(1); + TileObjectData.addTile(mt.Type); + + // All bathtubs count as tables. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + } + + /// + /// Extension which initializes a ModTile to be a bed. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpBed(this ModTile mt, bool lavaImmune = false) + { + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.HasOutlines[mt.Type] = true; + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 4, 0); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; + TileObjectData.addAlternate(1); + TileObjectData.addTile(mt.Type); + + // All beds count as chairs. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); + } + + /// + /// Extension which initializes a ModTile to be a bookcase. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + /// Whether this tile is supposed to have a solid top. Defaults to true. + /// Whether this tile counts as a table for housing. Defaults to true. + internal static void SetUpBookcase(this ModTile mt, bool lavaImmune = false, bool solidTop = true, bool table = true) + { + Main.tileSolidTop[mt.Type] = solidTop; + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileTable[mt.Type] = solidTop; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.addTile(mt.Type); + + // All bookcases count as tables. Monolith Amalgam does not count as a table. + if (table) + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + } + + /// + /// Extension which initializes a ModTile to be a candelabra. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpCandelabra(this ModTile mt, bool lavaImmune = false) + { + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = true; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.addTile(mt.Type); + + // All candelabras count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + } + + /// + /// Extension which initializes a ModTile to be a candle. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpCandle(this ModTile mt, bool lavaImmune = false, int offset = -4) + { + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.StyleOnTable1x1); + TileObjectData.newTile.CoordinateHeights = new int[] { 20 }; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.DrawYOffset = offset; + TileObjectData.addTile(mt.Type); + + // All candles count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + } + + /// + /// Extension which initializes a ModTile to be a chair. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpChair(this ModTile mt, bool lavaImmune = false) + { + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.newTile.StyleWrapLimit = 2; + TileObjectData.newTile.StyleMultiplier = 2; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; + TileObjectData.addAlternate(1); + TileObjectData.addTile(mt.Type); + + // As you could probably guess, all chairs count as chairs. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); + } + + /// + /// Extension which initializes a ModTile to be a chandelier. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpChandelier(this ModTile mt, bool lavaImmune = false) + { + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.Width = 3; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.Origin = new Point16(1, 0); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.addTile(mt.Type); + + // All chandeliers count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + } + + /// + /// Extension which initializes a ModTile to be a chest. + /// + /// The ModTile which is being initialized. + internal static void SetUpChest(this ModTile mt, bool offset = false) + { + Main.tileSpelunker[mt.Type] = true; + Main.tileContainer[mt.Type] = true; + Main.tileShine2[mt.Type] = true; + Main.tileShine[mt.Type] = 1200; + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileValue[mt.Type] = 500; + TileID.Sets.HasOutlines[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + if (offset) + TileObjectData.newTile.DrawYOffset = 4; + TileObjectData.newTile.Origin = new Point16(0, 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.HookCheck = new PlacementHook(new Func(Chest.FindEmptyChest), -1, 0, true); + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(new Func(Chest.AfterPlacement_Hook), -1, 0, false); + TileObjectData.newTile.AnchorInvalidTiles = new int[] { 127 }; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.addTile(mt.Type); + } + + /// + /// Extension which initializes a ModTile to be a clock. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpClock(this ModTile mt, bool lavaImmune = false) + { + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + TileID.Sets.HasOutlines[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX); + TileObjectData.newTile.Height = 5; + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16, + 16, + 16, + 16, + 16 + }; + TileObjectData.newTile.Origin = new Point16(0, 4); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.addTile(mt.Type); + } + + /// + /// Extension which initializes a ModTile to be a closed door. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpDoorClosed(this ModTile mt, bool lavaImmune = false) + { + Main.tileFrameImportant[mt.Type] = true; + Main.tileBlockLight[mt.Type] = true; + Main.tileSolid[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.NotReallySolid[mt.Type] = true; + TileID.Sets.DrawsWalls[mt.Type] = true; + TileID.Sets.HasOutlines[mt.Type] = true; + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.LavaDeath = true; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(0, 1); + TileObjectData.addAlternate(0); + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(0, 2); + TileObjectData.addAlternate(0); + TileObjectData.addTile(mt.Type); + + // As you could probably guess, all closed doors count as doors. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); + } + + /// + /// Extension which initializes a ModTile to be an open door. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpDoorOpen(this ModTile mt, bool lavaImmune = false) + { + Main.tileFrameImportant[mt.Type] = true; + Main.tileSolid[mt.Type] = false; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + Main.tileNoSunLight[mt.Type] = true; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 0); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 0); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.LavaDeath = true; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 2; + TileObjectData.newTile.StyleWrapLimit = 2; + TileObjectData.newTile.Direction = TileObjectDirection.PlaceRight; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(0, 1); + TileObjectData.addAlternate(0); + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(0, 2); + TileObjectData.addAlternate(0); + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(1, 0); + TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.addAlternate(1); + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(1, 1); + TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.addAlternate(1); + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(1, 2); + TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.addAlternate(1); + TileObjectData.addTile(mt.Type); + TileID.Sets.HousingWalls[mt.Type] = true; + TileID.Sets.HasOutlines[mt.Type] = true; + + // As you could probably guess, all open doors count as doors. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); + } + + /// + /// Extension which initializes a ModTile to be a dresser. + /// + /// The ModTile which is being initialized. + internal static void SetUpDresser(this ModTile mt) + { + Main.tileSolidTop[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileTable[mt.Type] = true; + Main.tileContainer[mt.Type] = true; + Main.tileWaterDeath[mt.Type] = false; + Main.tileLavaDeath[mt.Type] = false; + TileID.Sets.HasOutlines[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16 }; + TileObjectData.newTile.HookCheck = new PlacementHook(new Func(Chest.FindEmptyChest), -1, 0, true); + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(new Func(Chest.AfterPlacement_Hook), -1, 0, false); + TileObjectData.newTile.AnchorInvalidTiles = new int[] { 127 }; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.addTile(mt.Type); + + // All dressers count as tables. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + } + + /// + /// Extension which initializes a ModTile to be a floor lamp. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpLamp(this ModTile mt, bool lavaImmune = false) + { + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1xX); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.addTile(mt.Type); + + // All floor lamps count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + } + + /// + /// Extension which initializes a ModTile to be a hanging lantern. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpLantern(this ModTile mt, bool lavaImmune = false) + { + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2Top); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.addTile(mt.Type); + + // All hanging lanterns count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + } + + /// + /// Extension which initializes a ModTile to be a piano. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + /// Whether this tile is supposed to have a solid top. Defaults to true. + internal static void SetUpPiano(this ModTile mt, bool lavaImmune = false, bool solidTop = true) + { + Main.tileSolidTop[mt.Type] = solidTop; + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.addTile(mt.Type); + + // All pianos count as tables. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + } + + /// + /// Extension which initializes a ModTile to be a platform. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpPlatform(this ModTile mt, bool lavaImmune = false) + { + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileSolidTop[mt.Type] = true; + Main.tileSolid[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileTable[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + TileID.Sets.Platforms[mt.Type] = true; + TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 27; + TileObjectData.newTile.StyleWrapLimit = 27; + TileObjectData.newTile.UsesCustomCanPlace = false; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.addTile(mt.Type); + + // All platforms count as doors (so that you may have top-or-bottom entry/exit rooms) + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); + } + + /// + /// Extension which initializes a ModTile to be a sink. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpSink(this ModTile mt, bool lavaImmune = false) + { + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.addTile(mt.Type); + } + + /// + /// Extension which initializes a ModTile to be a sofa. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpSofa(this ModTile mt, bool lavaImmune = false) + { + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.addTile(mt.Type); + + // All sofas count as chairs. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); + } + + /// + /// Extension which initializes a ModTile to be a table. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpTable(this ModTile mt, bool lavaImmune = false) + { + Main.tileSolidTop[mt.Type] = true; + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileTable[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.addTile(mt.Type); + + // As you could probably guess, all tables count as tables. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + } + + /// + /// Extension which initializes a ModTile to be a torch. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpTorch(this ModTile mt, bool lavaImmune = false, bool waterImmune = false) + { + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileSolid[mt.Type] = false; + Main.tileNoAttach[mt.Type] = true; + Main.tileNoFail[mt.Type] = true; + Main.tileWaterDeath[mt.Type] = !waterImmune; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + TileObjectData.newTile.CopyFrom(TileObjectData.StyleTorch); + TileObjectData.newTile.WaterDeath = !waterImmune; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); + TileObjectData.newAlternate.WaterDeath = false; + TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.Tree | AnchorType.AlternateTile, TileObjectData.newTile.Height, 0); + TileObjectData.newAlternate.AnchorAlternateTiles = new int[] { 124 }; + TileObjectData.addAlternate(1); + TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); + TileObjectData.newAlternate.WaterDeath = false; + TileObjectData.newAlternate.AnchorRight = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.Tree | AnchorType.AlternateTile, TileObjectData.newTile.Height, 0); + TileObjectData.newAlternate.AnchorAlternateTiles = new int[] { 124 }; + TileObjectData.addAlternate(2); + TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); + TileObjectData.newAlternate.WaterDeath = false; + TileObjectData.newAlternate.AnchorWall = true; + TileObjectData.addAlternate(0); + TileObjectData.addTile(mt.Type); + + // All torches count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + } + + /// + /// Extension which initializes a ModTile to be a work bench. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpWorkBench(this ModTile mt, bool lavaImmune = false) + { + Main.tileSolidTop[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileTable[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.CoordinateHeights = new int[] { 18 }; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.addTile(mt.Type); + + // 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.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.UsesCustomCanPlace = true; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 2, 0); + TileObjectData.addTile(mt.Type); + } + + /// + /// Extension which initializes a ModTile to be a bed. + /// + /// The ModTile which is being initialized. + /// The color of the bar on the minimap. + /// Whether this tile is supposed to be immune to lava. Defaults to true like vanilla bars. + internal static void SetUpBar(this ModTile mt, Color mapColor, bool lavaImmune = true) + { Main.tileShine[mt.Type] = 1100; Main.tileSolid[mt.Type] = true; Main.tileSolidTop[mt.Type] = true; @@ -1149,8 +1149,8 @@ namespace CalamityMod TileObjectData.newTile.LavaDeath = !lavaImmune; TileObjectData.addTile(mt.Type); - // Vanilla bars are labeled as "Metal Bar" on the minimap + // Vanilla bars are labeled as "Metal Bar" on the minimap mt.AddMapEntry(mapColor, Language.GetText("MapObject.MetalBar")); - } - } + } + } } diff --git a/Utilities/GeneralExtensionUtils.cs b/Utilities/GeneralExtensionUtils.cs index 255c5e6bbc..a4b8db2b25 100644 --- a/Utilities/GeneralExtensionUtils.cs +++ b/Utilities/GeneralExtensionUtils.cs @@ -6,12 +6,12 @@ using Terraria; namespace CalamityMod { - public static partial class CalamityUtils - { - public static CalamityPlayer Calamity(this Player player) => player.GetModPlayer(); - 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; - } + public static partial class CalamityUtils + { + public static CalamityPlayer Calamity(this Player player) => player.GetModPlayer(); + 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; + } } diff --git a/Utilities/GenericAIUtils.cs b/Utilities/GenericAIUtils.cs index 75f51fedb2..3fd95161bd 100644 --- a/Utilities/GenericAIUtils.cs +++ b/Utilities/GenericAIUtils.cs @@ -8,599 +8,599 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { - // TODO -- This does not properly utilize OOP. Destroy this file and convert everything here into a base entity at some point. - public static partial class CalamityUtils - { - public static void ChargingMinionAI(this Projectile projectile, float range, float maxPlayerDist, float extraMaxPlayerDist, float safeDist, int initialUpdates, float chargeDelayTime, float goToSpeed, float goBackSpeed, Vector2 returnOffset, float chargeCounterMax, float chargeSpeed, bool tileVision, bool ignoreTilesWhenCharging, int updateDifference = 1) - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + // TODO -- This does not properly utilize OOP. Destroy this file and convert everything here into a base entity at some point. + public static partial class CalamityUtils + { + public static void ChargingMinionAI(this Projectile projectile, float range, float maxPlayerDist, float extraMaxPlayerDist, float safeDist, int initialUpdates, float chargeDelayTime, float goToSpeed, float goBackSpeed, Vector2 returnOffset, float chargeCounterMax, float chargeSpeed, bool tileVision, bool ignoreTilesWhenCharging, int updateDifference = 1) + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); - //Anti sticky movement to prevent stacking - projectile.MinionAntiClump(); + //Anti sticky movement to prevent stacking + projectile.MinionAntiClump(); - //Breather time between charges as like a reset - bool chargeDelay = false; - if (projectile.ai[0] == 2f) - { - projectile.ai[1] += 1f; - projectile.extraUpdates = initialUpdates + updateDifference; - if (projectile.ai[1] > chargeDelayTime) - { - projectile.ai[1] = 1f; - projectile.ai[0] = 0f; - projectile.extraUpdates = initialUpdates; - projectile.numUpdates = 0; - projectile.netUpdate = true; - } - else - { - chargeDelay = true; - } - } - if (chargeDelay) - { - return; - } + //Breather time between charges as like a reset + bool chargeDelay = false; + if (projectile.ai[0] == 2f) + { + projectile.ai[1] += 1f; + projectile.extraUpdates = initialUpdates + updateDifference; + if (projectile.ai[1] > chargeDelayTime) + { + projectile.ai[1] = 1f; + projectile.ai[0] = 0f; + projectile.extraUpdates = initialUpdates; + projectile.numUpdates = 0; + projectile.netUpdate = true; + } + else + { + chargeDelay = true; + } + } + if (chargeDelay) + { + return; + } - //Find a target - float maxDist = range; - Vector2 targetVec = projectile.position; - bool foundTarget = false; - bool isButterfly = projectile.type == ProjectileType(); - //Prioritize the targeted enemy if possible - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; - if (npc.CanBeChasedBy(projectile, false) || fishronCheck) - { - //Check the size of the target to make it easier to hit fat targets like Levi - float extraDist = (npc.width / 2) + (npc.height / 2); + //Find a target + float maxDist = range; + Vector2 targetVec = projectile.position; + bool foundTarget = false; + bool isButterfly = projectile.type == ProjectileType(); + //Prioritize the targeted enemy if possible + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; + if (npc.CanBeChasedBy(projectile, false) || fishronCheck) + { + //Check the size of the target to make it easier to hit fat targets like Levi + float extraDist = (npc.width / 2) + (npc.height / 2); - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - //Some minions will ignore tiles when choosing a target like Ice Claspers, others will not - bool canHit = true; - if (extraDist < maxDist && !tileVision) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (!foundTarget && targetDist < (maxDist + extraDist) && canHit) - { - maxDist = targetDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - //If no npc is specifically targetted or the selected enemy can't be found, check through the entire array - if (!foundTarget) - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; - if (npc.CanBeChasedBy(projectile, false) || fishronCheck) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - bool canHit = true; - if (extraDist < maxDist && !tileVision) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (!foundTarget && targetDist < (maxDist + extraDist) && canHit) - { - maxDist = targetDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - } + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + //Some minions will ignore tiles when choosing a target like Ice Claspers, others will not + bool canHit = true; + if (extraDist < maxDist && !tileVision) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + if (!foundTarget && targetDist < (maxDist + extraDist) && canHit) + { + maxDist = targetDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + //If no npc is specifically targetted or the selected enemy can't be found, check through the entire array + if (!foundTarget) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; + if (npc.CanBeChasedBy(projectile, false) || fishronCheck) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + bool canHit = true; + if (extraDist < maxDist && !tileVision) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + if (!foundTarget && targetDist < (maxDist + extraDist) && canHit) + { + maxDist = targetDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + } - //If the player is too far, return to the player. Range is increased while attacking something. - float distBeforeForcedReturn = maxPlayerDist; - if (foundTarget) - { - distBeforeForcedReturn = extraMaxPlayerDist; - } - if (Vector2.Distance(player.Center, projectile.Center) > distBeforeForcedReturn) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } + //If the player is too far, return to the player. Range is increased while attacking something. + float distBeforeForcedReturn = maxPlayerDist; + if (foundTarget) + { + distBeforeForcedReturn = extraMaxPlayerDist; + } + if (Vector2.Distance(player.Center, projectile.Center) > distBeforeForcedReturn) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } - //Go to the target if you found one - if (foundTarget && projectile.ai[0] == 0f) - { - //Some minions don't ignore tiles while charging like brittle stars - projectile.tileCollide = !ignoreTilesWhenCharging; - Vector2 targetSpot = targetVec - projectile.Center; - float targetDist = targetSpot.Length(); - targetSpot.Normalize(); - //Tries to get the minion in the sweet spot of 200 pixels away but the minion also charges so idk what good it does - if (targetDist > 200f) - { - float speed = goToSpeed; //8 - targetSpot *= speed; - projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; - } - else - { - float speed = -goBackSpeed; //-4 - targetSpot *= speed; - projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; //41 - } - } + //Go to the target if you found one + if (foundTarget && projectile.ai[0] == 0f) + { + //Some minions don't ignore tiles while charging like brittle stars + projectile.tileCollide = !ignoreTilesWhenCharging; + Vector2 targetSpot = targetVec - projectile.Center; + float targetDist = targetSpot.Length(); + targetSpot.Normalize(); + //Tries to get the minion in the sweet spot of 200 pixels away but the minion also charges so idk what good it does + if (targetDist > 200f) + { + float speed = goToSpeed; //8 + targetSpot *= speed; + projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; + } + else + { + float speed = -goBackSpeed; //-4 + targetSpot *= speed; + projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; //41 + } + } - //Movement for idle or returning to the player - else - { - //Ignore tiles so they don't get stuck everywhere like Optic Staff - projectile.tileCollide = false; + //Movement for idle or returning to the player + else + { + //Ignore tiles so they don't get stuck everywhere like Optic Staff + projectile.tileCollide = false; - bool returningToPlayer = false; - if (!returningToPlayer) - { - returningToPlayer = projectile.ai[0] == 1f; - } + bool returningToPlayer = false; + if (!returningToPlayer) + { + returningToPlayer = projectile.ai[0] == 1f; + } - //Player distance calculations - Vector2 playerVec = player.Center - projectile.Center + returnOffset; - float playerDist = playerVec.Length(); + //Player distance calculations + Vector2 playerVec = player.Center - projectile.Center + returnOffset; + float playerDist = playerVec.Length(); - //If the minion is actively returning, move faster - float playerHomeSpeed = 6f; - if (returningToPlayer) - { - playerHomeSpeed = 15f; - } - //Move somewhat faster if the player is kinda far~ish - if (playerDist > 200f && playerHomeSpeed < 8f) - { - playerHomeSpeed = 8f; - } - //Return to normal if close enough to the player - if (playerDist < safeDist && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - //Teleport to the player if abnormally 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.netUpdate = true; - } - //If more than 70 pixels away, move toward the player - if (playerDist > 70f) - { - playerVec.Normalize(); - playerVec *= playerHomeSpeed; - projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f; - } - //Minions never stay still - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - } + //If the minion is actively returning, move faster + float playerHomeSpeed = 6f; + if (returningToPlayer) + { + playerHomeSpeed = 15f; + } + //Move somewhat faster if the player is kinda far~ish + if (playerDist > 200f && playerHomeSpeed < 8f) + { + playerHomeSpeed = 8f; + } + //Return to normal if close enough to the player + if (playerDist < safeDist && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + //Teleport to the player if abnormally 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.netUpdate = true; + } + //If more than 70 pixels away, move toward the player + if (playerDist > 70f) + { + playerVec.Normalize(); + playerVec *= playerHomeSpeed; + projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f; + } + //Minions never stay still + else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.15f; + projectile.velocity.Y = -0.05f; + } + } - //Increment attack counter randomly - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += (float)Main.rand.Next(1, 4); - } - //If high enough, prepare to attack - if (projectile.ai[1] > chargeCounterMax) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } + //Increment attack counter randomly + if (projectile.ai[1] > 0f) + { + projectile.ai[1] += (float)Main.rand.Next(1, 4); + } + //If high enough, prepare to attack + if (projectile.ai[1] > chargeCounterMax) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } - //Charge at an enemy if not on cooldown - if (projectile.ai[0] == 0f) - { - if (projectile.ai[1] == 0f && foundTarget && maxDist < 500f) - { - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - projectile.ai[0] = 2f; - Vector2 targetPos = targetVec - projectile.Center; - targetPos.Normalize(); - projectile.velocity = targetPos * chargeSpeed; //8 - projectile.netUpdate = true; - } - } - } - } + //Charge at an enemy if not on cooldown + if (projectile.ai[0] == 0f) + { + if (projectile.ai[1] == 0f && foundTarget && maxDist < 500f) + { + projectile.ai[1] += 1f; + if (Main.myPlayer == projectile.owner) + { + projectile.ai[0] = 2f; + Vector2 targetPos = targetVec - projectile.Center; + targetPos.Normalize(); + projectile.velocity = targetPos * chargeSpeed; //8 + projectile.netUpdate = true; + } + } + } + } - public static void FloatingPetAI(this Projectile projectile, bool faceRight, float tiltFloat, bool lightPet = false) - { - Player player = Main.player[projectile.owner]; + public static void FloatingPetAI(this Projectile projectile, bool faceRight, float tiltFloat, bool lightPet = false) + { + Player player = Main.player[projectile.owner]; - //anti sticking movement as a failsafe - float SAImovement = 0.05f; - for (int k = 0; k < Main.maxProjectiles; k++) - { - Projectile otherProj = Main.projectile[k]; - // Short circuits to make the loop as fast as possible - if (!otherProj.active || otherProj.owner != projectile.owner || !Main.projPet[otherProj.type] || k == projectile.whoAmI) - continue; + //anti sticking movement as a failsafe + float SAImovement = 0.05f; + for (int k = 0; k < Main.maxProjectiles; k++) + { + Projectile otherProj = Main.projectile[k]; + // Short circuits to make the loop as fast as possible + if (!otherProj.active || otherProj.owner != projectile.owner || !Main.projPet[otherProj.type] || k == projectile.whoAmI) + continue; - // If the other projectile is indeed another pet owned by the same player and they're too close, nudge them away. - bool isPet = Main.projPet[otherProj.type]; - float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y); - if (isPet && taxicabDist < projectile.width) - { - if (projectile.position.X < otherProj.position.X) - projectile.velocity.X -= SAImovement; - else - projectile.velocity.X += SAImovement; + // If the other projectile is indeed another pet owned by the same player and they're too close, nudge them away. + bool isPet = Main.projPet[otherProj.type]; + float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y); + if (isPet && taxicabDist < projectile.width) + { + if (projectile.position.X < otherProj.position.X) + projectile.velocity.X -= SAImovement; + else + projectile.velocity.X += SAImovement; - if (projectile.position.Y < otherProj.position.Y) - projectile.velocity.Y -= SAImovement; - else - projectile.velocity.Y += SAImovement; - } - } + if (projectile.position.Y < otherProj.position.Y) + projectile.velocity.Y -= SAImovement; + else + projectile.velocity.Y += SAImovement; + } + } - float passiveMvtFloat = 0.5f; - projectile.tileCollide = false; - float range = 100f; - Vector2 projPos = projectile.Center; - 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; - Vector2 playerVector = new Vector2(xDist, yDist); - float playerDist = playerVector.Length(); - float returnSpeed = 18f; + float passiveMvtFloat = 0.5f; + projectile.tileCollide = false; + float range = 100f; + Vector2 projPos = projectile.Center; + 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; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + float returnSpeed = 18f; - //If player is close enough, resume normal - if (playerDist < range && player.velocity.Y == 0f && - projectile.Bottom.Y <= player.Bottom.Y && - !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - if (projectile.velocity.Y < -6f) - { - projectile.velocity.Y = -6f; - } - } + //If player is close enough, resume normal + if (playerDist < range && player.velocity.Y == 0f && + projectile.Bottom.Y <= player.Bottom.Y && + !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + if (projectile.velocity.Y < -6f) + { + projectile.velocity.Y = -6f; + } + } - //Teleport to player if too far - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - projectile.width / 2; - projectile.position.Y = player.Center.Y - projectile.height / 2; - projectile.netUpdate = true; - } + //Teleport to player if too far + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - projectile.width / 2; + projectile.position.Y = player.Center.Y - projectile.height / 2; + projectile.netUpdate = true; + } - if (playerDist < 50f) - { - if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) - { - projectile.velocity *= 0.99f; - } - passiveMvtFloat = 0.01f; - } - else - { - if (playerDist < 100f) - { - passiveMvtFloat = 0.1f; - } - if (playerDist > 300f) - { - passiveMvtFloat = 1f; - } - playerDist = returnSpeed / playerDist; - playerVector.X *= playerDist; - playerVector.Y *= playerDist; - } - if (projectile.velocity.X < playerVector.X) - { - projectile.velocity.X += passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.X < 0f) - { - projectile.velocity.X += passiveMvtFloat; - } - } - if (projectile.velocity.X > playerVector.X) - { - projectile.velocity.X -= passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.X > 0f) - { - projectile.velocity.X -= passiveMvtFloat; - } - } - if (projectile.velocity.Y < playerVector.Y) - { - projectile.velocity.Y += passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.Y < 0f) - { - projectile.velocity.Y += passiveMvtFloat * 2f; - } - } - if (projectile.velocity.Y > playerVector.Y) - { - projectile.velocity.Y -= passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.Y > 0f) - { - projectile.velocity.Y -= passiveMvtFloat * 2f; - } - } - if (projectile.velocity.X >= 0.25f) - { - projectile.direction = faceRight ? 1 : -1; - } - else if (projectile.velocity.X < -0.25f) - { - projectile.direction = faceRight ? -1 : 1; - } - //Tilting and change directions - projectile.spriteDirection = projectile.direction; - projectile.rotation = projectile.velocity.X * tiltFloat; - } + if (playerDist < 50f) + { + if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) + { + projectile.velocity *= 0.99f; + } + passiveMvtFloat = 0.01f; + } + else + { + if (playerDist < 100f) + { + passiveMvtFloat = 0.1f; + } + if (playerDist > 300f) + { + passiveMvtFloat = 1f; + } + playerDist = returnSpeed / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + } + if (projectile.velocity.X < playerVector.X) + { + projectile.velocity.X += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.X < 0f) + { + projectile.velocity.X += passiveMvtFloat; + } + } + if (projectile.velocity.X > playerVector.X) + { + projectile.velocity.X -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.X > 0f) + { + projectile.velocity.X -= passiveMvtFloat; + } + } + if (projectile.velocity.Y < playerVector.Y) + { + projectile.velocity.Y += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.Y < 0f) + { + projectile.velocity.Y += passiveMvtFloat * 2f; + } + } + if (projectile.velocity.Y > playerVector.Y) + { + projectile.velocity.Y -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.Y > 0f) + { + projectile.velocity.Y -= passiveMvtFloat * 2f; + } + } + if (projectile.velocity.X >= 0.25f) + { + projectile.direction = faceRight ? 1 : -1; + } + else if (projectile.velocity.X < -0.25f) + { + projectile.direction = faceRight ? -1 : 1; + } + //Tilting and change directions + projectile.spriteDirection = projectile.direction; + projectile.rotation = projectile.velocity.X * tiltFloat; + } - public static void HealingProjectile(this 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; + public static void HealingProjectile(this 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 playerVector = player.Center - projectile.Center; - 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(MessageID.SpiritHeal, -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); - } - } + Vector2 playerVector = player.Center - projectile.Center; + 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(MessageID.SpiritHeal, -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); + } + } - /// - /// Call this function in the ai of your projectile so it can stick to enemies, also requires ModifyHitNPCSticky to be called in ModifyHitNPC - /// - /// The projectile you're adding sticky behaviour to - /// Number of seconds you want a projectile to cling to an NPC - public static void StickyProjAI(this Projectile projectile, int timeLeft, bool findNewNPC = false) - { - if (projectile.ai[0] == 1f) - { - int seconds = timeLeft; - bool killProj = false; - bool spawnDust = false; + /// + /// Call this function in the ai of your projectile so it can stick to enemies, also requires ModifyHitNPCSticky to be called in ModifyHitNPC + /// + /// The projectile you're adding sticky behaviour to + /// Number of seconds you want a projectile to cling to an NPC + public static void StickyProjAI(this Projectile projectile, int timeLeft, bool findNewNPC = false) + { + if (projectile.ai[0] == 1f) + { + int seconds = timeLeft; + bool killProj = false; + bool spawnDust = false; - //the projectile follows the NPC, even if it goes into blocks - projectile.tileCollide = false; + //the projectile follows the NPC, even if it goes into blocks + projectile.tileCollide = false; - //timer for triggering hit effects - projectile.localAI[0]++; - if (projectile.localAI[0] % 30f == 0f) - { - spawnDust = true; - } + //timer for triggering hit effects + projectile.localAI[0]++; + if (projectile.localAI[0] % 30f == 0f) + { + spawnDust = true; + } - //So AI knows what NPC it is sticking to - int npcIndex = (int)projectile.ai[1]; - NPC npc = Main.npc[npcIndex]; + //So AI knows what NPC it is sticking to + int npcIndex = (int)projectile.ai[1]; + NPC npc = Main.npc[npcIndex]; - //Kill projectile after so many seconds or if the NPC it is stuck to no longer exists - if (projectile.localAI[0] >= (float)(60 * seconds)) - { - killProj = true; - } - else if (!npcIndex.WithinBounds(Main.maxNPCs)) - { - killProj = true; - } + //Kill projectile after so many seconds or if the NPC it is stuck to no longer exists + if (projectile.localAI[0] >= (float)(60 * seconds)) + { + killProj = true; + } + else if (!npcIndex.WithinBounds(Main.maxNPCs)) + { + killProj = true; + } - else if (npc.active && !npc.dontTakeDamage) - { - //follow the NPC - projectile.Center = npc.Center - projectile.velocity * 2f; - projectile.gfxOffY = npc.gfxOffY; + else if (npc.active && !npc.dontTakeDamage) + { + //follow the NPC + projectile.Center = npc.Center - projectile.velocity * 2f; + projectile.gfxOffY = npc.gfxOffY; - //if attached to npc, trigger npc hit effects every half a second - if (spawnDust) - { - npc.HitEffect(0, 1.0); - } - } - else - { - killProj = true; - } + //if attached to npc, trigger npc hit effects every half a second + if (spawnDust) + { + npc.HitEffect(0, 1.0); + } + } + else + { + killProj = true; + } - //Kill the projectile or reset stats if needed - if (killProj) - { - if (findNewNPC) - projectile.ai[0] = 0f; - else - projectile.Kill(); - } - } - } + //Kill the projectile or reset stats if needed + if (killProj) + { + if (findNewNPC) + projectile.ai[0] = 0f; + else + projectile.Kill(); + } + } + } - /// - /// Call this function in ModifyHitNPC to make your projectiles stick to enemies, needs StickyProjAI to be called in the AI of the projectile - /// - /// The projectile you're giving sticky behaviour to - /// How many projectiles of this type can stick to one enemy - /// Decides if you want the projectile to deal damage while its sticked to enemies or not - public static void ModifyHitNPCSticky(this Projectile projectile, int maxStick, bool constantDamage) - { - Player player = Main.player[projectile.owner]; - Rectangle myRect = projectile.Hitbox; + /// + /// Call this function in ModifyHitNPC to make your projectiles stick to enemies, needs StickyProjAI to be called in the AI of the projectile + /// + /// The projectile you're giving sticky behaviour to + /// How many projectiles of this type can stick to one enemy + /// Decides if you want the projectile to deal damage while its sticked to enemies or not + public static void ModifyHitNPCSticky(this Projectile projectile, int maxStick, bool constantDamage) + { + Player player = Main.player[projectile.owner]; + Rectangle myRect = projectile.Hitbox; - if (projectile.owner == Main.myPlayer) - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - //covers most edge cases like voodoo dolls - if (npc.active && !npc.dontTakeDamage && - ((projectile.friendly && (!npc.friendly || (npc.type == NPCID.Guide && projectile.owner < Main.maxPlayers && player.killGuide) || (npc.type == NPCID.Clothier && projectile.owner < Main.maxPlayers && player.killClothier))) || - (projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles)) && (projectile.owner < 0 || npc.immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) - { - if (npc.noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(npc)) - { - bool stickingToNPC; - //Solar Crawltipede tail has special collision - if (npc.type == NPCID.SolarCrawltipedeTail) - { - Rectangle rect = npc.Hitbox; - int num5 = 8; - rect.X -= num5; - rect.Y -= num5; - rect.Width += num5 * 2; - rect.Height += num5 * 2; - stickingToNPC = projectile.Colliding(myRect, rect); - } - else - { - stickingToNPC = projectile.Colliding(myRect, npc.Hitbox); - } - if (stickingToNPC) - { - //reflect projectile if the npc can reflect it (like Selenians) - if (npc.reflectingProjectiles && projectile.CanReflect()) - { - npc.ReflectProjectile(projectile.whoAmI); - return; - } + if (projectile.owner == Main.myPlayer) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + //covers most edge cases like voodoo dolls + if (npc.active && !npc.dontTakeDamage && + ((projectile.friendly && (!npc.friendly || (npc.type == NPCID.Guide && projectile.owner < Main.maxPlayers && player.killGuide) || (npc.type == NPCID.Clothier && projectile.owner < Main.maxPlayers && player.killClothier))) || + (projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles)) && (projectile.owner < 0 || npc.immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) + { + if (npc.noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(npc)) + { + bool stickingToNPC; + //Solar Crawltipede tail has special collision + if (npc.type == NPCID.SolarCrawltipedeTail) + { + Rectangle rect = npc.Hitbox; + int num5 = 8; + rect.X -= num5; + rect.Y -= num5; + rect.Width += num5 * 2; + rect.Height += num5 * 2; + stickingToNPC = projectile.Colliding(myRect, rect); + } + else + { + stickingToNPC = projectile.Colliding(myRect, npc.Hitbox); + } + if (stickingToNPC) + { + //reflect projectile if the npc can reflect it (like Selenians) + if (npc.reflectingProjectiles && projectile.CanReflect()) + { + npc.ReflectProjectile(projectile.whoAmI); + return; + } - //let the projectile know it is sticking and the npc it is sticking too - projectile.ai[0] = 1f; - projectile.ai[1] = (float)npcIndex; + //let the projectile know it is sticking and the npc it is sticking too + projectile.ai[0] = 1f; + projectile.ai[1] = (float)npcIndex; - //follow the NPC - projectile.velocity = (npc.Center - projectile.Center) * 0.75f; + //follow the NPC + projectile.velocity = (npc.Center - projectile.Center) * 0.75f; - projectile.netUpdate = true; + projectile.netUpdate = true; - //Set projectile damage to 0 if desired - if (!constantDamage) - projectile.damage = 0; + //Set projectile damage to 0 if desired + if (!constantDamage) + projectile.damage = 0; - //Count how many projectiles are attached, delete as necessary - Point[] array2 = new Point[maxStick]; - int projCount = 0; - for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) - { - Projectile proj = Main.projectile[projIndex]; - if (projIndex != projectile.whoAmI && proj.active && proj.owner == Main.myPlayer && proj.type == projectile.type && proj.ai[0] == 1f && proj.ai[1] == (float)npcIndex) - { - array2[projCount++] = new Point(projIndex, proj.timeLeft); - if (projCount >= array2.Length) - { - break; - } - } - } - if (projCount >= 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(); - } - } - } - } - } - } - } + //Count how many projectiles are attached, delete as necessary + Point[] array2 = new Point[maxStick]; + int projCount = 0; + for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) + { + Projectile proj = Main.projectile[projIndex]; + if (projIndex != projectile.whoAmI && proj.active && proj.owner == Main.myPlayer && proj.type == projectile.type && proj.ai[0] == 1f && proj.ai[1] == (float)npcIndex) + { + array2[projCount++] = new Point(projIndex, proj.timeLeft); + if (projCount >= array2.Length) + { + break; + } + } + } + if (projCount >= 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(); + } + } + } + } + } + } + } - public static void StickToTiles(this Projectile projectile, bool ignorePlatforms, bool stickToEverything) - { - try - { - int xLeft = (int)(projectile.position.X / 16f) - 1; - int xRight = (int)((projectile.position.X + (float)projectile.width) / 16f) + 2; - int yBottom = (int)(projectile.position.Y / 16f) - 1; - int yTop = (int)((projectile.position.Y + (float)projectile.height) / 16f) + 2; - if (xLeft < 0) - { - xLeft = 0; - } - if (xRight > Main.maxTilesX) - { - xRight = Main.maxTilesX; - } - if (yBottom < 0) - { - yBottom = 0; - } - if (yTop > Main.maxTilesY) - { - yTop = Main.maxTilesY; - } - for (int x = xLeft; x < xRight; x++) - { - for (int y = yBottom; y < yTop; y++) - { - Tile tile = Main.tile[x, y]; - bool platformCheck = true; - if (ignorePlatforms) - platformCheck = !TileID.Sets.Platforms[tile.type] && tile.type != TileID.PlanterBox; - bool tableCheck = false; - if (stickToEverything) - tableCheck = Main.tileSolidTop[tile.type] && tile.frameY == 0; - if (tile != null && tile.nactive() && platformCheck && (Main.tileSolid[tile.type] || tableCheck)) - { - Vector2 tileSize; - tileSize.X = (float)(x * 16); - tileSize.Y = (float)(y * 16); - if (projectile.position.X + (float)projectile.width - 4f > tileSize.X && projectile.position.X + 4f < tileSize.X + 16f && projectile.position.Y + (float)projectile.height - 4f > tileSize.Y && projectile.position.Y + 4f < tileSize.Y + 16f) - { - projectile.velocity.X = 0f; - projectile.velocity.Y = -0.2f; - } - } - } - } - } - catch - { - } - } - } + public static void StickToTiles(this Projectile projectile, bool ignorePlatforms, bool stickToEverything) + { + try + { + int xLeft = (int)(projectile.position.X / 16f) - 1; + int xRight = (int)((projectile.position.X + (float)projectile.width) / 16f) + 2; + int yBottom = (int)(projectile.position.Y / 16f) - 1; + int yTop = (int)((projectile.position.Y + (float)projectile.height) / 16f) + 2; + if (xLeft < 0) + { + xLeft = 0; + } + if (xRight > Main.maxTilesX) + { + xRight = Main.maxTilesX; + } + if (yBottom < 0) + { + yBottom = 0; + } + if (yTop > Main.maxTilesY) + { + yTop = Main.maxTilesY; + } + for (int x = xLeft; x < xRight; x++) + { + for (int y = yBottom; y < yTop; y++) + { + Tile tile = Main.tile[x, y]; + bool platformCheck = true; + if (ignorePlatforms) + platformCheck = !TileID.Sets.Platforms[tile.type] && tile.type != TileID.PlanterBox; + bool tableCheck = false; + if (stickToEverything) + tableCheck = Main.tileSolidTop[tile.type] && tile.frameY == 0; + if (tile != null && tile.nactive() && platformCheck && (Main.tileSolid[tile.type] || tableCheck)) + { + Vector2 tileSize; + tileSize.X = (float)(x * 16); + tileSize.Y = (float)(y * 16); + if (projectile.position.X + (float)projectile.width - 4f > tileSize.X && projectile.position.X + 4f < tileSize.X + 16f && projectile.position.Y + (float)projectile.height - 4f > tileSize.Y && projectile.position.Y + 4f < tileSize.Y + 16f) + { + projectile.velocity.X = 0f; + projectile.velocity.Y = -0.2f; + } + } + } + } + } + catch + { + } + } + } } diff --git a/Utilities/ILEditingUtils.cs b/Utilities/ILEditingUtils.cs index 3c4f225e2f..250ac2d8b9 100644 --- a/Utilities/ILEditingUtils.cs +++ b/Utilities/ILEditingUtils.cs @@ -2,16 +2,16 @@ using MonoMod.Cil; namespace CalamityMod { - public static partial class CalamityUtils - { - /// - /// Moves an to the final Ret call in the method the cursor is assocated with. - /// - /// The cursor. - public static ILCursor GotoFinalRet(this ILCursor cursor) - { - while (cursor.TryGotoNext(c => c.MatchRet())) { } - return cursor; - } - } + public static partial class CalamityUtils + { + /// + /// Moves an to the final Ret call in the method the cursor is assocated with. + /// + /// The cursor. + public static ILCursor GotoFinalRet(this ILCursor cursor) + { + while (cursor.TryGotoNext(c => c.MatchRet())) { } + return cursor; + } + } } diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index a42a886f67..7ce307cefd 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -10,479 +10,479 @@ using Terraria.ModLoader; namespace CalamityMod { - public static partial class CalamityUtils - { - #region Item Rarity Utilities - internal const int TurquoiseRarityValue = 12; - internal static readonly Color TurquoiseRarityColor = new Color(0, 255, 200); - internal const int PureGreenRarityValue = 13; - internal static readonly Color PureGreenRarityColor = new Color(0, 255, 0); - internal const int DarkBlueRarityValue = 14; - internal static readonly Color DarkBlueRarityColor = new Color(43, 96, 222); - internal const int VioletRarityValue = 15; - internal static readonly Color VioletRarityColor = new Color(108, 45, 199); - internal const int HotPinkRarityValue = 16; - internal static readonly Color HotPinkRarityColor = new Color(255, 0, 255); - internal const int RainbowRarityValue = 30; - // The rainbow rarity has an ever-shifting color, not a stored constant - internal const int DraedonRustRarityValue = 33; - internal static readonly Color DraedonRustRarityColor = new Color(204, 71, 35); - // The donator rarity isn't technically a rarity, but is a constant color used in tooltips - internal static readonly Color DonatorItemColor = new Color(139, 0, 0); + public static partial class CalamityUtils + { + #region Item Rarity Utilities + internal const int TurquoiseRarityValue = 12; + internal static readonly Color TurquoiseRarityColor = new Color(0, 255, 200); + internal const int PureGreenRarityValue = 13; + internal static readonly Color PureGreenRarityColor = new Color(0, 255, 0); + internal const int DarkBlueRarityValue = 14; + internal static readonly Color DarkBlueRarityColor = new Color(43, 96, 222); + internal const int VioletRarityValue = 15; + internal static readonly Color VioletRarityColor = new Color(108, 45, 199); + internal const int HotPinkRarityValue = 16; + internal static readonly Color HotPinkRarityColor = new Color(255, 0, 255); + internal const int RainbowRarityValue = 30; + // The rainbow rarity has an ever-shifting color, not a stored constant + internal const int DraedonRustRarityValue = 33; + internal static readonly Color DraedonRustRarityColor = new Color(204, 71, 35); + // The donator rarity isn't technically a rarity, but is a constant color used in tooltips + internal static readonly Color DonatorItemColor = new Color(139, 0, 0); - public static readonly CalamityRarity[] postMLRarities = - { - CalamityRarity.Turquoise, - CalamityRarity.PureGreen, - CalamityRarity.DarkBlue, - CalamityRarity.Violet, - CalamityRarity.HotPink - }; + public static readonly CalamityRarity[] postMLRarities = + { + CalamityRarity.Turquoise, + CalamityRarity.PureGreen, + CalamityRarity.DarkBlue, + CalamityRarity.Violet, + CalamityRarity.HotPink + }; - public static bool IsPostML(this CalamityRarity calrare) - { - for(int i = 0; i < postMLRarities.Length; ++i) - if (postMLRarities[i] == calrare) - return true; - return false; - } + public static bool IsPostML(this CalamityRarity calrare) + { + for(int i = 0; i < postMLRarities.Length; ++i) + if (postMLRarities[i] == calrare) + return true; + return false; + } - public static Color? GetRarityColor(CalamityRarity calrare) - { - switch (calrare) - { - default: - return null; - case CalamityRarity.Turquoise: - return TurquoiseRarityColor; - case CalamityRarity.PureGreen: - return PureGreenRarityColor; - case CalamityRarity.DarkBlue: - return DarkBlueRarityColor; - case CalamityRarity.Violet: - return VioletRarityColor; - case CalamityRarity.HotPink: - return HotPinkRarityColor; + public static Color? GetRarityColor(CalamityRarity calrare) + { + switch (calrare) + { + default: + return null; + case CalamityRarity.Turquoise: + return TurquoiseRarityColor; + case CalamityRarity.PureGreen: + return PureGreenRarityColor; + case CalamityRarity.DarkBlue: + return DarkBlueRarityColor; + case CalamityRarity.Violet: + return VioletRarityColor; + case CalamityRarity.HotPink: + return HotPinkRarityColor; - case CalamityRarity.Rainbow: - return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - case CalamityRarity.DraedonRust: - return DraedonRustRarityColor; - } - } - #endregion + case CalamityRarity.Rainbow: + return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); + case CalamityRarity.DraedonRust: + return DraedonRustRarityColor; + } + } + #endregion - // TODO -- This probably isn't the best place to put this but it needs to be somewhere easily accessible. - #region Accessory Prefix Stats - internal static int GetScalingDefense(int prefixID) - { - switch (prefixID) - { - default: - return 0; + // TODO -- This probably isn't the best place to put this but it needs to be somewhere easily accessible. + #region Accessory Prefix Stats + internal static int GetScalingDefense(int prefixID) + { + switch (prefixID) + { + default: + return 0; - case PrefixID.Hard: - if (CalamityWorld.downedYharon) - return 4; - else if (CalamityWorld.downedPolterghast || CalamityWorld.downedDoG) - return 3; - else if (Main.hardMode || NPC.downedGolemBoss || NPC.downedMoonlord || CalamityWorld.downedProvidence) - return 2; - return 1; + case PrefixID.Hard: + if (CalamityWorld.downedYharon) + return 4; + else if (CalamityWorld.downedPolterghast || CalamityWorld.downedDoG) + return 3; + else if (Main.hardMode || NPC.downedGolemBoss || NPC.downedMoonlord || CalamityWorld.downedProvidence) + return 2; + return 1; - case PrefixID.Guarding: - if (CalamityWorld.downedYharon) - return 8; - else if (CalamityWorld.downedDoG) - return 6; - else if (CalamityWorld.downedProvidence || CalamityWorld.downedPolterghast) - return 5; - else if (NPC.downedGolemBoss || NPC.downedMoonlord) - return 4; - else if (Main.hardMode) - return 3; - return 2; + case PrefixID.Guarding: + if (CalamityWorld.downedYharon) + return 8; + else if (CalamityWorld.downedDoG) + return 6; + else if (CalamityWorld.downedProvidence || CalamityWorld.downedPolterghast) + return 5; + else if (NPC.downedGolemBoss || NPC.downedMoonlord) + return 4; + else if (Main.hardMode) + return 3; + return 2; - case PrefixID.Armored: - if (CalamityWorld.downedYharon) - return 11; - else if (CalamityWorld.downedDoG) - return 9; - else if (CalamityWorld.downedPolterghast) - return 8; - else if (CalamityWorld.downedProvidence) - return 7; - else if (NPC.downedMoonlord) - return 6; - else if (Main.hardMode || NPC.downedGolemBoss) - return 5; - return 3; + case PrefixID.Armored: + if (CalamityWorld.downedYharon) + return 11; + else if (CalamityWorld.downedDoG) + return 9; + else if (CalamityWorld.downedPolterghast) + return 8; + else if (CalamityWorld.downedProvidence) + return 7; + else if (NPC.downedMoonlord) + return 6; + else if (Main.hardMode || NPC.downedGolemBoss) + return 5; + return 3; - case PrefixID.Warding: - if (CalamityWorld.downedYharon) - return 15; - else if (CalamityWorld.downedDoG) - return 12; - else if (CalamityWorld.downedPolterghast) - return 10; - else if (CalamityWorld.downedProvidence) - return 9; - else if (NPC.downedMoonlord) - return 8; - else if (NPC.downedGolemBoss) - return 7; - else if (Main.hardMode) - return 6; - return 4; - } - } - #endregion + case PrefixID.Warding: + if (CalamityWorld.downedYharon) + return 15; + else if (CalamityWorld.downedDoG) + return 12; + else if (CalamityWorld.downedPolterghast) + return 10; + else if (CalamityWorld.downedProvidence) + return 9; + else if (NPC.downedMoonlord) + return 8; + else if (NPC.downedGolemBoss) + return 7; + else if (Main.hardMode) + return 6; + return 4; + } + } + #endregion - /// - /// Converts the given ModHotKey into a string for insertion into item tooltips.

- /// This allows the user's actual keybind choices to be shown to them in tooltips. - ///
- /// The ModHotKey to convert to a string. - /// - public static string TooltipHotkeyString(this ModHotKey mhk) - { - if (Main.dedServ || mhk is null) - return ""; + /// + /// Converts the given ModHotKey into a string for insertion into item tooltips.

+ /// This allows the user's actual keybind choices to be shown to them in tooltips. + ///
+ /// The ModHotKey to convert to a string. + /// + public static string TooltipHotkeyString(this ModHotKey mhk) + { + if (Main.dedServ || mhk is null) + return ""; - List keys = mhk.GetAssignedKeys(); - if (keys.Count == 0) - return "[NONE]"; - else - { - StringBuilder sb = new StringBuilder(16); - sb.Append(keys[0]); + List keys = mhk.GetAssignedKeys(); + if (keys.Count == 0) + return "[NONE]"; + else + { + StringBuilder sb = new StringBuilder(16); + sb.Append(keys[0]); - // In almost all cases, this code won't run, because there won't be multiple bindings for the hotkey. But just in case... - for (int i = 1; i < keys.Count; ++i) - sb.Append(" / ").Append(keys[i]); - return sb.ToString(); - } - } + // In almost all cases, this code won't run, because there won't be multiple bindings for the hotkey. But just in case... + for (int i = 1; i < keys.Count; ++i) + sb.Append(" / ").Append(keys[i]); + return sb.ToString(); + } + } - private const float WorldInsertionOffset = 15f; - /// - /// If the given item is outside the world, force it to be within the world boundaries. - /// - /// The item to possibly relocate. - /// The minimum distance in pixels the item can be from the world boundary. - /// Whether the item was relocated. - public static bool ForceItemIntoWorld(Item item, float desiredDist = WorldInsertionOffset) - { - if (item is null || !item.active) - return false; + private const float WorldInsertionOffset = 15f; + /// + /// If the given item is outside the world, force it to be within the world boundaries. + /// + /// The item to possibly relocate. + /// The minimum distance in pixels the item can be from the world boundary. + /// Whether the item was relocated. + public static bool ForceItemIntoWorld(Item item, float desiredDist = WorldInsertionOffset) + { + if (item is null || !item.active) + return false; - // The world edge needs to be accounted for regardless of the distance chosen as an argument. - float worldEdge = Main.offLimitBorderTiles * 16f; - float dist = worldEdge + desiredDist; + // The world edge needs to be accounted for regardless of the distance chosen as an argument. + float worldEdge = Main.offLimitBorderTiles * 16f; + float dist = worldEdge + desiredDist; - float maxPosX = Main.maxTilesX * 16f; - float maxPosY = Main.maxTilesY * 16f; - bool moved = false; - if (item.position.X < worldEdge) - { - item.position.X = dist; - moved = true; - } - else if (item.position.X + item.width > maxPosX - worldEdge) - { - item.position.X = maxPosX - item.width - dist; - moved = true; - } - if (item.position.Y < worldEdge) - { - item.position.Y = dist; - moved = true; - } - else if (item.position.Y + item.height > maxPosY - worldEdge) - { - item.position.Y = maxPosY - item.height - dist; - moved = true; - } - return moved; - } + float maxPosX = Main.maxTilesX * 16f; + float maxPosY = Main.maxTilesY * 16f; + bool moved = false; + if (item.position.X < worldEdge) + { + item.position.X = dist; + moved = true; + } + else if (item.position.X + item.width > maxPosX - worldEdge) + { + item.position.X = maxPosX - item.width - dist; + moved = true; + } + if (item.position.Y < worldEdge) + { + item.position.Y = dist; + moved = true; + } + else if (item.position.Y + item.height > maxPosY - worldEdge) + { + item.position.Y = maxPosY - item.height - dist; + moved = true; + } + return moved; + } - public static bool IsEnchantable(this Item item) - { - // If the item is air just immediately return false. - // It will not have a CalamityGlobalItem instance to use and attempting to do anything with it - // would just result in errors. - if (item.IsAir) - return false; + public static bool IsEnchantable(this Item item) + { + // If the item is air just immediately return false. + // It will not have a CalamityGlobalItem instance to use and attempting to do anything with it + // would just result in errors. + if (item.IsAir) + return false; - // Items with a max stack greater than one cannot be enchanted, due to problems with data duplication. - if (item.maxStack > 1) - return false; + // Items with a max stack greater than one cannot be enchanted, due to problems with data duplication. + if (item.maxStack > 1) + return false; - // Ammo cannot be enchanted because it is practically useless when held directly. - if (item.ammo != AmmoID.None) - return false; + // Ammo cannot be enchanted because it is practically useless when held directly. + if (item.ammo != AmmoID.None) + return false; - // Ignore items that explicitly say to not be enchanted. - if (item.Calamity().CannotBeEnchanted) - return false; + // Ignore items that explicitly say to not be enchanted. + if (item.Calamity().CannotBeEnchanted) + return false; - return true; - } + return true; + } - /// - /// Determines if a given item is enchanted based on Calamitas' special system. - /// - /// The item to check. - public static bool IsEnchanted(this Item item) - { - // If the item is air just immediately return false. - // It will not have a CalamityGlobalItem instance to use and attempting to do anything with it - // would just result in errors. - if (item.IsAir) - return false; + /// + /// Determines if a given item is enchanted based on Calamitas' special system. + /// + /// The item to check. + public static bool IsEnchanted(this Item item) + { + // If the item is air just immediately return false. + // It will not have a CalamityGlobalItem instance to use and attempting to do anything with it + // would just result in errors. + if (item.IsAir) + return false; - // If the item is contained in the enchant upgrade result relationship, return true. - if (EnchantmentManager.ItemUpgradeRelationship.ContainsValue(item.type)) - return true; + // If the item is contained in the enchant upgrade result relationship, return true. + if (EnchantmentManager.ItemUpgradeRelationship.ContainsValue(item.type)) + return true; - return item.Calamity().AppliedEnchantment.HasValue; - } + return item.Calamity().AppliedEnchantment.HasValue; + } - public static Rectangle FixSwingHitbox(float hitboxWidth, float hitboxHeight) - { - Player player = Main.player[Main.myPlayer]; - Item item = player.ActiveItem(); - float hitbox_X, hitbox_Y; - float mountOffsetY = player.mount.PlayerOffsetHitbox; + public static Rectangle FixSwingHitbox(float hitboxWidth, float hitboxHeight) + { + Player player = Main.player[Main.myPlayer]; + Item item = player.ActiveItem(); + float hitbox_X, hitbox_Y; + float mountOffsetY = player.mount.PlayerOffsetHitbox; - // Third hitbox shifting values - if (player.itemAnimation < player.itemAnimationMax * 0.333) - { - float shiftX = 10f; - if (hitboxWidth >= 92) - shiftX = 38f; - else if (hitboxWidth >= 64) - shiftX = 28f; - else if (hitboxWidth >= 52) - shiftX = 24f; - else if (hitboxWidth > 32) - shiftX = 14f; - hitbox_X = player.position.X + player.width * 0.5f + (hitboxWidth * 0.5f - shiftX) * player.direction; - hitbox_Y = player.position.Y + 24f + mountOffsetY; - } + // Third hitbox shifting values + if (player.itemAnimation < player.itemAnimationMax * 0.333) + { + float shiftX = 10f; + if (hitboxWidth >= 92) + shiftX = 38f; + else if (hitboxWidth >= 64) + shiftX = 28f; + else if (hitboxWidth >= 52) + shiftX = 24f; + else if (hitboxWidth > 32) + shiftX = 14f; + hitbox_X = player.position.X + player.width * 0.5f + (hitboxWidth * 0.5f - shiftX) * player.direction; + hitbox_Y = player.position.Y + 24f + mountOffsetY; + } - // Second hitbox shifting values - else if (player.itemAnimation < player.itemAnimationMax * 0.666) - { - float shift = 10f; - if (hitboxWidth >= 92) - shift = 38f; - else if (hitboxWidth >= 64) - shift = 28f; - else if (hitboxWidth >= 52) - shift = 24f; - else if (hitboxWidth > 32) - shift = 18f; - hitbox_X = player.position.X + (player.width * 0.5f + (hitboxWidth * 0.5f - shift) * player.direction); + // Second hitbox shifting values + else if (player.itemAnimation < player.itemAnimationMax * 0.666) + { + float shift = 10f; + if (hitboxWidth >= 92) + shift = 38f; + else if (hitboxWidth >= 64) + shift = 28f; + else if (hitboxWidth >= 52) + shift = 24f; + else if (hitboxWidth > 32) + shift = 18f; + hitbox_X = player.position.X + (player.width * 0.5f + (hitboxWidth * 0.5f - shift) * player.direction); - shift = 10f; - if (hitboxHeight > 64) - shift = 14f; - else if (hitboxHeight > 52) - shift = 12f; - else if (hitboxHeight > 32) - shift = 8f; + shift = 10f; + if (hitboxHeight > 64) + shift = 14f; + else if (hitboxHeight > 52) + shift = 12f; + else if (hitboxHeight > 32) + shift = 8f; - hitbox_Y = player.position.Y + shift + mountOffsetY; - } + hitbox_Y = player.position.Y + shift + mountOffsetY; + } - // First hitbox shifting values - else - { - float shift = 6f; - if (hitboxWidth >= 92) - shift = 38f; - else if (hitboxWidth >= 64) - shift = 28f; - else if (hitboxWidth >= 52) - shift = 24f; - else if (hitboxWidth >= 48) - shift = 18f; - else if (hitboxWidth > 32) - shift = 14f; - hitbox_X = player.position.X + player.width * 0.5f - (hitboxWidth * 0.5f - shift) * player.direction; + // First hitbox shifting values + else + { + float shift = 6f; + if (hitboxWidth >= 92) + shift = 38f; + else if (hitboxWidth >= 64) + shift = 28f; + else if (hitboxWidth >= 52) + shift = 24f; + else if (hitboxWidth >= 48) + shift = 18f; + else if (hitboxWidth > 32) + shift = 14f; + hitbox_X = player.position.X + player.width * 0.5f - (hitboxWidth * 0.5f - shift) * player.direction; - shift = 10f; - if (hitboxHeight > 64) - shift = 14f; - else if (hitboxHeight > 52) - shift = 12f; - else if (hitboxHeight > 32) - shift = 10f; - hitbox_Y = player.position.Y + shift + mountOffsetY; - } + shift = 10f; + if (hitboxHeight > 64) + shift = 14f; + else if (hitboxHeight > 52) + shift = 12f; + else if (hitboxHeight > 32) + shift = 10f; + hitbox_Y = player.position.Y + shift + mountOffsetY; + } - // Inversion due to grav potion - if (player.gravDir == -1f) - { - hitbox_Y = player.position.Y + player.height + (player.position.Y - hitbox_Y); - } + // Inversion due to grav potion + if (player.gravDir == -1f) + { + hitbox_Y = player.position.Y + player.height + (player.position.Y - hitbox_Y); + } - // Hitbox size adjustments - Rectangle hitbox = new Rectangle((int)hitbox_X, (int)hitbox_Y, 32, 32); - if (item.damage >= 0 && item.type > ItemID.None && !item.noMelee && player.itemAnimation > 0) - { - if (!Main.dedServ) - { - hitbox = new Rectangle((int)hitbox_X, (int)hitbox_Y, (int)hitboxWidth, (int)hitboxHeight); - } - hitbox.Width = (int)(hitbox.Width * item.scale); - hitbox.Height = (int)(hitbox.Height * item.scale); - if (player.direction == -1) - { - hitbox.X -= hitbox.Width; - } - if (player.gravDir == 1f) - { - hitbox.Y -= hitbox.Height; - } + // Hitbox size adjustments + Rectangle hitbox = new Rectangle((int)hitbox_X, (int)hitbox_Y, 32, 32); + if (item.damage >= 0 && item.type > ItemID.None && !item.noMelee && player.itemAnimation > 0) + { + if (!Main.dedServ) + { + hitbox = new Rectangle((int)hitbox_X, (int)hitbox_Y, (int)hitboxWidth, (int)hitboxHeight); + } + hitbox.Width = (int)(hitbox.Width * item.scale); + hitbox.Height = (int)(hitbox.Height * item.scale); + if (player.direction == -1) + { + hitbox.X -= hitbox.Width; + } + if (player.gravDir == 1f) + { + hitbox.Y -= hitbox.Height; + } - // Broadsword use style - if (item.useStyle == ItemUseStyleID.SwingThrow) - { - // Third hitbox size adjustments - if (player.itemAnimation < player.itemAnimationMax * 0.333) - { - if (player.direction == -1) - { - hitbox.X -= (int)(hitbox.Width * 1.4 - hitbox.Width); - } - hitbox.Width = (int)(hitbox.Width * 1.4); - hitbox.Y += (int)(hitbox.Height * 0.5 * player.gravDir); - hitbox.Height = (int)(hitbox.Height * 1.1); - } + // Broadsword use style + if (item.useStyle == ItemUseStyleID.SwingThrow) + { + // Third hitbox size adjustments + if (player.itemAnimation < player.itemAnimationMax * 0.333) + { + if (player.direction == -1) + { + hitbox.X -= (int)(hitbox.Width * 1.4 - hitbox.Width); + } + hitbox.Width = (int)(hitbox.Width * 1.4); + hitbox.Y += (int)(hitbox.Height * 0.5 * player.gravDir); + hitbox.Height = (int)(hitbox.Height * 1.1); + } - // First hitbox size adjustments - else if (player.itemAnimation >= player.itemAnimationMax * 0.666) - { - if (player.direction == 1) - { - hitbox.X -= (int)(hitbox.Width * 1.2); - } - hitbox.Width *= 2; - hitbox.Y -= (int)((hitbox.Height * 1.4 - hitbox.Height) * player.gravDir); - hitbox.Height = (int)(hitbox.Height * 1.4); - } - } - } - return hitbox; - } + // First hitbox size adjustments + else if (player.itemAnimation >= player.itemAnimationMax * 0.666) + { + if (player.direction == 1) + { + hitbox.X -= (int)(hitbox.Width * 1.2); + } + hitbox.Width *= 2; + hitbox.Y -= (int)((hitbox.Height * 1.4 - hitbox.Height) * player.gravDir); + hitbox.Height = (int)(hitbox.Height * 1.4); + } + } + } + return hitbox; + } - // TODO -- this is not very well understood old boffin code. It should probably be inspected thoroughly and re-documented. - #region Melee Dust Helper - /// - /// Dust helper to spawn dust for an item. Allows you to specify where on the item to spawn the dust, essentially. (ONLY WORKS FOR SWINGING WEAPONS?) - /// - /// The player using the item. - /// The type of dust to use. - /// The chance per frame to spawn the dust (0f-1f) - /// The minimum distance between the player and the dust - /// The maximum distance between the player and the dust - /// The minimum random rotation offset for the dust - /// The maximum random rotation offset for the dust - /// The minimum speed that the dust should travel - /// The maximum speed that the dust should travel - public static Dust MeleeDustHelper(Player player, int dustType, float chancePerFrame, float minDistance, float maxDistance, float minRandRot = -0.2f, float maxRandRot = 0.2f, float minSpeed = 0.9f, float maxSpeed = 1.1f) - { - if (Main.rand.NextFloat(1f) < chancePerFrame) - { - //Calculate values - //distance from player, - //the vector offset from the player center - //the vector between the pos and the player - float distance = Main.rand.NextFloat(minDistance, maxDistance); - Vector2 offset = (player.itemRotation - (MathHelper.PiOver4 * player.direction) + Main.rand.NextFloat(minRandRot, maxRandRot)).ToRotationVector2() * distance * player.direction; - Vector2 pos = player.Center + offset; - Vector2 vec = pos - player.Center; - //spawn the dust - Dust d = Dust.NewDustPerfect(pos, dustType); - //normalise vector and multiply by velocity magnitude - vec.Normalize(); - d.velocity = vec * Main.rand.NextFloat(minSpeed, maxSpeed); - return d; - } - return null; - } - #endregion + // TODO -- this is not very well understood old boffin code. It should probably be inspected thoroughly and re-documented. + #region Melee Dust Helper + /// + /// Dust helper to spawn dust for an item. Allows you to specify where on the item to spawn the dust, essentially. (ONLY WORKS FOR SWINGING WEAPONS?) + /// + /// The player using the item. + /// The type of dust to use. + /// The chance per frame to spawn the dust (0f-1f) + /// The minimum distance between the player and the dust + /// The maximum distance between the player and the dust + /// The minimum random rotation offset for the dust + /// The maximum random rotation offset for the dust + /// The minimum speed that the dust should travel + /// The maximum speed that the dust should travel + public static Dust MeleeDustHelper(Player player, int dustType, float chancePerFrame, float minDistance, float maxDistance, float minRandRot = -0.2f, float maxRandRot = 0.2f, float minSpeed = 0.9f, float maxSpeed = 1.1f) + { + if (Main.rand.NextFloat(1f) < chancePerFrame) + { + //Calculate values + //distance from player, + //the vector offset from the player center + //the vector between the pos and the player + float distance = Main.rand.NextFloat(minDistance, maxDistance); + Vector2 offset = (player.itemRotation - (MathHelper.PiOver4 * player.direction) + Main.rand.NextFloat(minRandRot, maxRandRot)).ToRotationVector2() * distance * player.direction; + Vector2 pos = player.Center + offset; + Vector2 vec = pos - player.Center; + //spawn the dust + Dust d = Dust.NewDustPerfect(pos, dustType); + //normalise vector and multiply by velocity magnitude + vec.Normalize(); + d.velocity = vec * Main.rand.NextFloat(minSpeed, maxSpeed); + return d; + } + return null; + } + #endregion - /// - /// Determines if an item can be enchanted by any item at all via Calamitas' enchantment system. - /// - /// The item to check. - public static bool CanBeEnchantedBySomething(this Item item) => EnchantmentManager.EnchantmentList.Any(enchantment => enchantment.ApplyRequirement(item)); + /// + /// Determines if an item can be enchanted by any item at all via Calamitas' enchantment system. + /// + /// The item to check. + public static bool CanBeEnchantedBySomething(this Item item) => EnchantmentManager.EnchantmentList.Any(enchantment => enchantment.ApplyRequirement(item)); - public static void ConsumeItemViaQuickBuff(Player player, Item item, int buffType, int buffTime, bool reducedPotionSickness) - { - bool showsOver = false; - //Fail if you have the buff - for (int l = 0; l < Player.MaxBuffs; l++) - { - int hasBuff = player.buffType[l]; - if (player.buffTime[l] > 0 && hasBuff == buffType) - showsOver = true; - } - //Fail if you have potion sickness - if (player.potionDelay > 0 || player.Calamity().potionTimer > 0) - showsOver = true; + public static void ConsumeItemViaQuickBuff(Player player, Item item, int buffType, int buffTime, bool reducedPotionSickness) + { + bool showsOver = false; + //Fail if you have the buff + for (int l = 0; l < Player.MaxBuffs; l++) + { + int hasBuff = player.buffType[l]; + if (player.buffTime[l] > 0 && hasBuff == buffType) + showsOver = true; + } + //Fail if you have potion sickness + if (player.potionDelay > 0 || player.Calamity().potionTimer > 0) + showsOver = true; - if (!showsOver) - { - Main.PlaySound(item.UseSound, player.Center); + if (!showsOver) + { + Main.PlaySound(item.UseSound, player.Center); - double healMult = 1D + - (player.Calamity().coreOfTheBloodGod ? 0.15 : 0) + - (player.Calamity().bloodPactBoost ? 0.5 : 0); - int healAmt = (int)(item.healLife * healMult); - if (healAmt > 0 && player.QuickHeal_GetItemToUse() != null) - { - if (player.QuickHeal_GetItemToUse().type != item.type) - healAmt = 0; - } + double healMult = 1D + + (player.Calamity().coreOfTheBloodGod ? 0.15 : 0) + + (player.Calamity().bloodPactBoost ? 0.5 : 0); + int healAmt = (int)(item.healLife * healMult); + if (healAmt > 0 && player.QuickHeal_GetItemToUse() != null) + { + if (player.QuickHeal_GetItemToUse().type != item.type) + healAmt = 0; + } - player.statLife += healAmt; - player.statMana += item.healMana; - if (player.statMana > player.statManaMax2) - { - player.statMana = player.statManaMax2; - } - if (player.statLife > player.statLifeMax2) - { - player.statLife = player.statLifeMax2; - } - if (item.healMana > 0) - player.AddBuff(BuffID.ManaSickness, Player.manaSickTime, true); - if (Main.myPlayer == player.whoAmI) - { - if (healAmt > 0) - player.HealEffect(healAmt, true); - if (item.healMana > 0) - player.ManaEffect(item.healMana); - } - if (item.potion && healAmt > 0) //Don't inflict Potion Sickness if you don't actually heal - { - int duration = reducedPotionSickness ? 3000 : 3600; - if (player.pStone) - duration = (int)(duration * 0.75); - player.AddBuff(BuffID.PotionSickness, duration); - } + player.statLife += healAmt; + player.statMana += item.healMana; + if (player.statMana > player.statManaMax2) + { + player.statMana = player.statManaMax2; + } + if (player.statLife > player.statLifeMax2) + { + player.statLife = player.statLifeMax2; + } + if (item.healMana > 0) + player.AddBuff(BuffID.ManaSickness, Player.manaSickTime, true); + if (Main.myPlayer == player.whoAmI) + { + if (healAmt > 0) + player.HealEffect(healAmt, true); + if (item.healMana > 0) + player.ManaEffect(item.healMana); + } + if (item.potion && healAmt > 0) //Don't inflict Potion Sickness if you don't actually heal + { + int duration = reducedPotionSickness ? 3000 : 3600; + if (player.pStone) + duration = (int)(duration * 0.75); + player.AddBuff(BuffID.PotionSickness, duration); + } - player.AddBuff(buffType, buffTime); + player.AddBuff(buffType, buffTime); - --item.stack; - if (item.stack <= 0) - item.TurnToAir(); - Recipe.FindRecipes(); - } - } - } + --item.stack; + if (item.stack <= 0) + item.TurnToAir(); + Recipe.FindRecipes(); + } + } + } } diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index 21aedc4a7e..32db19384f 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -38,297 +38,297 @@ using Terraria.ModLoader; namespace CalamityMod { - public static partial class NPCStats - { - #region Boss Stats Container Struct - internal partial struct EnemyStats - { - public static SortedDictionary> DebuffImmunities; - }; - #endregion + public static partial class NPCStats + { + #region Boss Stats Container Struct + internal partial struct EnemyStats + { + public static SortedDictionary> DebuffImmunities; + }; + #endregion - #region Stat Retrieval Methods - public static void SetNPCDebuffImmunities(this NPC npc) - { - // Safety check: If for some reason the debuff array is not initialized yet, return and do nothing. - // If the npc is not in the dictionary, return and do nothing. - // Also, can I just say that I hate Sorted Dictionaries and Tuples and want to make something explode? -Ben - var stupidTupleThing = new Tuple(true, new int[] {}); - bool exists = EnemyStats.DebuffImmunities.TryGetValue(npc.type, out stupidTupleThing); - if (npc.modNPC is null || !exists) - return; + #region Stat Retrieval Methods + public static void SetNPCDebuffImmunities(this NPC npc) + { + // Safety check: If for some reason the debuff array is not initialized yet, return and do nothing. + // If the npc is not in the dictionary, return and do nothing. + // Also, can I just say that I hate Sorted Dictionaries and Tuples and want to make something explode? -Ben + var stupidTupleThing = new Tuple(true, new int[] {}); + bool exists = EnemyStats.DebuffImmunities.TryGetValue(npc.type, out stupidTupleThing); + if (npc.modNPC is null || !exists) + return; - // If the npc is immune to everything, make it immune to everything - if (stupidTupleThing.Item1) - { - for (int k = 0; k < npc.buffImmune.Length; k++) - npc.buffImmune[k] = true; - } + // If the npc is immune to everything, make it immune to everything + if (stupidTupleThing.Item1) + { + for (int k = 0; k < npc.buffImmune.Length; k++) + npc.buffImmune[k] = true; + } - // Then set debuff vulnerabilities, or immunities if not immune to everything - for (int i = 0; i < stupidTupleThing.Item2.Length; ++i) - npc.buffImmune[stupidTupleThing.Item2[i]] = !stupidTupleThing.Item1; - } - #endregion + // Then set debuff vulnerabilities, or immunities if not immune to everything + for (int i = 0; i < stupidTupleThing.Item2.Length; ++i) + npc.buffImmune[stupidTupleThing.Item2[i]] = !stupidTupleThing.Item1; + } + #endregion - #region Load/Unload - // A static function, called exactly once, which initializes the EnemyStats struct at a predictable time. - // This is necessary to ensure this dictionary is populated as early as possible. - // Any boss not listed in here is only immune to Confusion and Pearl Aura. - internal static void LoadDebuffs() - { - EnemyStats.DebuffImmunities = new SortedDictionary> - { - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + #region Load/Unload + // A static function, called exactly once, which initializes the EnemyStats struct at a predictable time. + // This is necessary to ensure this dictionary is populated as early as possible. + // Any boss not listed in here is only immune to Confusion and Pearl Aura. + internal static void LoadDebuffs() + { + EnemyStats.DebuffImmunities = new SortedDictionary> + { + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { NPCID.Plantera, new Tuple(false, new int[] { BuffID.Venom }) }, - { NPCID.PlanterasTentacle, new Tuple(false, new int[] { BuffID.Venom }) }, + { NPCID.Plantera, new Tuple(false, new int[] { BuffID.Venom }) }, + { NPCID.PlanterasTentacle, new Tuple(false, new int[] { BuffID.Venom }) }, - // She resists the cold because of her ice-related abilities. - { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, + // She resists the cold because of her ice-related abilities. + { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { NPCID.MoonLordCore, new Tuple(false, new int[] { ModContent.BuffType() }) }, - { NPCID.MoonLordHand, new Tuple(false, new int[] { ModContent.BuffType() }) }, - { NPCID.MoonLordHead, new Tuple(false, new int[] { ModContent.BuffType() }) }, - { NPCID.MoonLordLeechBlob, new Tuple(false, new int[] { ModContent.BuffType() }) }, + { NPCID.MoonLordCore, new Tuple(false, new int[] { ModContent.BuffType() }) }, + { NPCID.MoonLordHand, new Tuple(false, new int[] { ModContent.BuffType() }) }, + { NPCID.MoonLordHead, new Tuple(false, new int[] { ModContent.BuffType() }) }, + { NPCID.MoonLordLeechBlob, new Tuple(false, new int[] { ModContent.BuffType() }) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { ModContent.BuffType() }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { ModContent.BuffType() }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { ModContent.BuffType(), ModContent.BuffType() }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { ModContent.BuffType(), ModContent.BuffType() }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.OnFire }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.OnFire }) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Poisoned, BuffID.Venom }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Poisoned, BuffID.Venom }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Poisoned, BuffID.Venom }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Poisoned, BuffID.Venom }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) } - }; - } + { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) } + }; + } - // Destroys the EnemyStats struct to save memory because mod assemblies will not be fully unloaded until TML 1.4. - internal static void UnloadDebuffs() - { - EnemyStats.DebuffImmunities = null; - } - #endregion - } + // Destroys the EnemyStats struct to save memory because mod assemblies will not be fully unloaded until TML 1.4. + internal static void UnloadDebuffs() + { + EnemyStats.DebuffImmunities = null; + } + #endregion + } } diff --git a/Utilities/NPCStats.cs b/Utilities/NPCStats.cs index 4de8e8cbb4..0a233fd5b1 100644 --- a/Utilities/NPCStats.cs +++ b/Utilities/NPCStats.cs @@ -42,764 +42,764 @@ using CalamityMod.NPCs.AcidRain; namespace CalamityMod { - public static partial class NPCStats - { - private const double ExpertContactVanillaMultiplier = 2D; - private const double NormalProjectileVanillaMultiplier = 2D; - private const double ExpertProjectileVanillaMultiplier = 4D; - - #region Enemy Stats Container Struct - internal partial struct EnemyStats - { - public static SortedDictionary ExpertDamageMultiplier; - public static SortedDictionary ContactDamageValues; - public static SortedDictionary, int[]> ProjectileDamageValues; - }; - #endregion - - #region Stat Retrieval Methods - public static void GetNPCDamage(this NPC npc) - { - double damageAdjustment = GetExpertDamageMultiplier(npc) * ExpertContactVanillaMultiplier; - - // Safety check: If for some reason the contact damage array is not initialized yet, set the NPC's damage to 1. - bool exists = EnemyStats.ContactDamageValues.TryGetValue(npc.type, out int[] contactDamage); - if (!exists) - npc.damage = 1; - - int normalDamage = contactDamage[0]; - int expertDamage = contactDamage[1] == -1 ? -1 : (int)Math.Round(contactDamage[1] / damageAdjustment); - int revengeanceDamage = contactDamage[2] == -1 ? -1 : (int)Math.Round(contactDamage[2] / damageAdjustment); - int deathDamage = contactDamage[3] == -1 ? -1 : (int)Math.Round(contactDamage[3] / damageAdjustment); - int masterDamage = contactDamage[4] == -1 ? -1 : (int)Math.Round(contactDamage[4] / damageAdjustment); - - // If the assigned value would be -1, don't actually assign it. This allows for conditionally disabling the system. - int damageToUse = CalamityWorld.death ? deathDamage : CalamityWorld.revenge ? revengeanceDamage : Main.expertMode ? expertDamage : normalDamage; - if (CalamityWorld.malice && damageToUse != -1) - damageToUse = (int)Math.Round(damageToUse * CalamityGlobalNPC.MaliceModeDamageMultiplier); - if (damageToUse != -1) - npc.damage = damageToUse; - } - - // Gets the amount of damage a given projectile should do from this NPC. - // Automatically compensates for Terraria's internal spaghetti scaling. - public static int GetProjectileDamage(this NPC npc, int projType) - { - double damageAdjustment = Main.expertMode ? ExpertProjectileVanillaMultiplier : NormalProjectileVanillaMultiplier; - - // Safety check: If for some reason the projectile damage array is not initialized yet, return 1. - bool exists = EnemyStats.ProjectileDamageValues.TryGetValue(new Tuple(npc.type, projType), out int[] projectileDamage); - if (!exists) - return 1; - - int normalDamage = (int)Math.Round(projectileDamage[0] / damageAdjustment); - int expertDamage = (int)Math.Round(projectileDamage[1] / damageAdjustment); - int revengeanceDamage = (int)Math.Round(projectileDamage[2] / damageAdjustment); - int deathDamage = (int)Math.Round(projectileDamage[3] / damageAdjustment); - int masterDamage = (int)Math.Round(projectileDamage[4] / damageAdjustment); - - int damageToUse = CalamityWorld.death ? deathDamage : CalamityWorld.revenge ? revengeanceDamage : Main.expertMode ? expertDamage : normalDamage; - if (CalamityWorld.malice) - damageToUse = (int)Math.Round(damageToUse * CalamityGlobalNPC.MaliceModeDamageMultiplier); - - return damageToUse; - } - - // Gets the amount of damage this projectile should do from a given NPC. - // Automatically compensates for Terraria's internal spaghetti scaling. - public static int GetProjectileDamage(this Projectile projectile, int npcType) - { - double damageAdjustment = Main.expertMode ? ExpertProjectileVanillaMultiplier : NormalProjectileVanillaMultiplier; - - // Safety check: If for some reason the projectile damage array is not initialized yet, return 1. - bool exists = EnemyStats.ProjectileDamageValues.TryGetValue(new Tuple(npcType, projectile.type), out int[] projectileDamage); - if (!exists) - return 1; - - int normalDamage = (int)Math.Round(projectileDamage[0] / damageAdjustment); - int expertDamage = (int)Math.Round(projectileDamage[1] / damageAdjustment); - int revengeanceDamage = (int)Math.Round(projectileDamage[2] / damageAdjustment); - int deathDamage = (int)Math.Round(projectileDamage[3] / damageAdjustment); - int masterDamage = (int)Math.Round(projectileDamage[4] / damageAdjustment); - - int damageToUse = CalamityWorld.death ? deathDamage : CalamityWorld.revenge ? revengeanceDamage : Main.expertMode ? expertDamage : normalDamage; - if (CalamityWorld.malice) - damageToUse = (int)Math.Round(damageToUse * CalamityGlobalNPC.MaliceModeDamageMultiplier); - - return damageToUse; - } - - // Gets the raw amount of damage a projectile should do from this NPC. - // That is, this doesn't adjust the value to compensate for Terraria's internal spaghetti scaling. - public static int GetProjectileDamageNoScaling(this NPC npc, int projType) - { - bool exists = EnemyStats.ProjectileDamageValues.TryGetValue(new Tuple(npc.type, projType), out int[] projectileDamage); - return !exists ? 1 // Base case for safety, in case the array is not initialized yet. - : (CalamityWorld.death || CalamityWorld.malice) ? projectileDamage[3] - : CalamityWorld.revenge ? projectileDamage[2] - : Main.expertMode ? projectileDamage[1] - : projectileDamage[0]; - } - - /// - /// Gets the Expert/Master Mode damage multiplier for the specified boss NPC. - /// Useful for determining the base damage a boss NPC should have prior to being run through the Expert/Master scaling code. - /// - /// The NPC you want to get the damage multiplier for - /// Whether Master Mode is enabled or not - /// - public static double GetExpertDamageMultiplier(this NPC npc, bool? master = null) - { - bool exists = EnemyStats.ExpertDamageMultiplier.TryGetValue(npc.type, out double damageMult); - return exists ? damageMult : 1D; - } - #endregion - - #region Load/Unload - internal static void Load() - { - LoadEnemyStats(); - LoadDebuffs(); - } - internal static void Unload() - { - UnloadEnemyStats(); - UnloadDebuffs(); - } - - // A static function, called exactly once, which initializes the EnemyStats struct at a predictable time. - // This is necessary to ensure this dictionary is populated as early as possible. - internal static void LoadEnemyStats() - { - EnemyStats.ExpertDamageMultiplier = new SortedDictionary - { - { NPCID.KingSlime, 0.8 }, - - { ModContent.NPCType(), 1.1 }, - - { ModContent.NPCType(), 0.8 }, - - { NPCID.EaterofWorldsHead, 1.1 }, - { NPCID.EaterofWorldsBody, 0.8 }, - { NPCID.EaterofWorldsTail, 0.8 }, - - { NPCID.BrainofCthulhu, 0.9 }, - - { ModContent.NPCType(), 0.9 }, - - { ModContent.NPCType(), 0.9 }, - - { NPCID.QueenBee, 0.9 }, - { NPCID.Bee, 0.6 }, - { NPCID.BeeSmall, 0.6 }, - - { NPCID.SkeletronHead, 1.1 }, - { NPCID.SkeletronHand, 1.1 }, + public static partial class NPCStats + { + private const double ExpertContactVanillaMultiplier = 2D; + private const double NormalProjectileVanillaMultiplier = 2D; + private const double ExpertProjectileVanillaMultiplier = 4D; + + #region Enemy Stats Container Struct + internal partial struct EnemyStats + { + public static SortedDictionary ExpertDamageMultiplier; + public static SortedDictionary ContactDamageValues; + public static SortedDictionary, int[]> ProjectileDamageValues; + }; + #endregion + + #region Stat Retrieval Methods + public static void GetNPCDamage(this NPC npc) + { + double damageAdjustment = GetExpertDamageMultiplier(npc) * ExpertContactVanillaMultiplier; + + // Safety check: If for some reason the contact damage array is not initialized yet, set the NPC's damage to 1. + bool exists = EnemyStats.ContactDamageValues.TryGetValue(npc.type, out int[] contactDamage); + if (!exists) + npc.damage = 1; + + int normalDamage = contactDamage[0]; + int expertDamage = contactDamage[1] == -1 ? -1 : (int)Math.Round(contactDamage[1] / damageAdjustment); + int revengeanceDamage = contactDamage[2] == -1 ? -1 : (int)Math.Round(contactDamage[2] / damageAdjustment); + int deathDamage = contactDamage[3] == -1 ? -1 : (int)Math.Round(contactDamage[3] / damageAdjustment); + int masterDamage = contactDamage[4] == -1 ? -1 : (int)Math.Round(contactDamage[4] / damageAdjustment); + + // If the assigned value would be -1, don't actually assign it. This allows for conditionally disabling the system. + int damageToUse = CalamityWorld.death ? deathDamage : CalamityWorld.revenge ? revengeanceDamage : Main.expertMode ? expertDamage : normalDamage; + if (CalamityWorld.malice && damageToUse != -1) + damageToUse = (int)Math.Round(damageToUse * CalamityGlobalNPC.MaliceModeDamageMultiplier); + if (damageToUse != -1) + npc.damage = damageToUse; + } + + // Gets the amount of damage a given projectile should do from this NPC. + // Automatically compensates for Terraria's internal spaghetti scaling. + public static int GetProjectileDamage(this NPC npc, int projType) + { + double damageAdjustment = Main.expertMode ? ExpertProjectileVanillaMultiplier : NormalProjectileVanillaMultiplier; + + // Safety check: If for some reason the projectile damage array is not initialized yet, return 1. + bool exists = EnemyStats.ProjectileDamageValues.TryGetValue(new Tuple(npc.type, projType), out int[] projectileDamage); + if (!exists) + return 1; + + int normalDamage = (int)Math.Round(projectileDamage[0] / damageAdjustment); + int expertDamage = (int)Math.Round(projectileDamage[1] / damageAdjustment); + int revengeanceDamage = (int)Math.Round(projectileDamage[2] / damageAdjustment); + int deathDamage = (int)Math.Round(projectileDamage[3] / damageAdjustment); + int masterDamage = (int)Math.Round(projectileDamage[4] / damageAdjustment); + + int damageToUse = CalamityWorld.death ? deathDamage : CalamityWorld.revenge ? revengeanceDamage : Main.expertMode ? expertDamage : normalDamage; + if (CalamityWorld.malice) + damageToUse = (int)Math.Round(damageToUse * CalamityGlobalNPC.MaliceModeDamageMultiplier); + + return damageToUse; + } + + // Gets the amount of damage this projectile should do from a given NPC. + // Automatically compensates for Terraria's internal spaghetti scaling. + public static int GetProjectileDamage(this Projectile projectile, int npcType) + { + double damageAdjustment = Main.expertMode ? ExpertProjectileVanillaMultiplier : NormalProjectileVanillaMultiplier; + + // Safety check: If for some reason the projectile damage array is not initialized yet, return 1. + bool exists = EnemyStats.ProjectileDamageValues.TryGetValue(new Tuple(npcType, projectile.type), out int[] projectileDamage); + if (!exists) + return 1; + + int normalDamage = (int)Math.Round(projectileDamage[0] / damageAdjustment); + int expertDamage = (int)Math.Round(projectileDamage[1] / damageAdjustment); + int revengeanceDamage = (int)Math.Round(projectileDamage[2] / damageAdjustment); + int deathDamage = (int)Math.Round(projectileDamage[3] / damageAdjustment); + int masterDamage = (int)Math.Round(projectileDamage[4] / damageAdjustment); + + int damageToUse = CalamityWorld.death ? deathDamage : CalamityWorld.revenge ? revengeanceDamage : Main.expertMode ? expertDamage : normalDamage; + if (CalamityWorld.malice) + damageToUse = (int)Math.Round(damageToUse * CalamityGlobalNPC.MaliceModeDamageMultiplier); + + return damageToUse; + } + + // Gets the raw amount of damage a projectile should do from this NPC. + // That is, this doesn't adjust the value to compensate for Terraria's internal spaghetti scaling. + public static int GetProjectileDamageNoScaling(this NPC npc, int projType) + { + bool exists = EnemyStats.ProjectileDamageValues.TryGetValue(new Tuple(npc.type, projType), out int[] projectileDamage); + return !exists ? 1 // Base case for safety, in case the array is not initialized yet. + : (CalamityWorld.death || CalamityWorld.malice) ? projectileDamage[3] + : CalamityWorld.revenge ? projectileDamage[2] + : Main.expertMode ? projectileDamage[1] + : projectileDamage[0]; + } + + /// + /// Gets the Expert/Master Mode damage multiplier for the specified boss NPC. + /// Useful for determining the base damage a boss NPC should have prior to being run through the Expert/Master scaling code. + /// + /// The NPC you want to get the damage multiplier for + /// Whether Master Mode is enabled or not + /// + public static double GetExpertDamageMultiplier(this NPC npc, bool? master = null) + { + bool exists = EnemyStats.ExpertDamageMultiplier.TryGetValue(npc.type, out double damageMult); + return exists ? damageMult : 1D; + } + #endregion + + #region Load/Unload + internal static void Load() + { + LoadEnemyStats(); + LoadDebuffs(); + } + internal static void Unload() + { + UnloadEnemyStats(); + UnloadDebuffs(); + } + + // A static function, called exactly once, which initializes the EnemyStats struct at a predictable time. + // This is necessary to ensure this dictionary is populated as early as possible. + internal static void LoadEnemyStats() + { + EnemyStats.ExpertDamageMultiplier = new SortedDictionary + { + { NPCID.KingSlime, 0.8 }, + + { ModContent.NPCType(), 1.1 }, + + { ModContent.NPCType(), 0.8 }, + + { NPCID.EaterofWorldsHead, 1.1 }, + { NPCID.EaterofWorldsBody, 0.8 }, + { NPCID.EaterofWorldsTail, 0.8 }, + + { NPCID.BrainofCthulhu, 0.9 }, + + { ModContent.NPCType(), 0.9 }, + + { ModContent.NPCType(), 0.9 }, + + { NPCID.QueenBee, 0.9 }, + { NPCID.Bee, 0.6 }, + { NPCID.BeeSmall, 0.6 }, + + { NPCID.SkeletronHead, 1.1 }, + { NPCID.SkeletronHand, 1.1 }, - { NPCID.WallofFlesh, 1.5 }, - { NPCID.WallofFleshEye, 1.5 }, - - { ModContent.NPCType(), 1.15 }, - - { NPCID.Spazmatism, 0.85 }, - { NPCID.Retinazer, 0.85 }, - - { ModContent.NPCType(), 1.1 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { NPCID.TheDestroyer, 2 }, - { NPCID.TheDestroyerBody, 0.85 }, - { NPCID.TheDestroyerTail, 0.85 }, - - { ModContent.NPCType(), 0.8 }, - - { NPCID.SkeletronPrime, 0.85 }, - { NPCID.PrimeCannon, 0.85 }, - { NPCID.PrimeLaser, 0.85 }, - { NPCID.PrimeSaw, 0.85 }, - { NPCID.PrimeVice, 0.85 }, + { NPCID.WallofFlesh, 1.5 }, + { NPCID.WallofFleshEye, 1.5 }, + + { ModContent.NPCType(), 1.15 }, + + { NPCID.Spazmatism, 0.85 }, + { NPCID.Retinazer, 0.85 }, + + { ModContent.NPCType(), 1.1 }, + { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, + + { NPCID.TheDestroyer, 2 }, + { NPCID.TheDestroyerBody, 0.85 }, + { NPCID.TheDestroyerTail, 0.85 }, + + { ModContent.NPCType(), 0.8 }, + + { NPCID.SkeletronPrime, 0.85 }, + { NPCID.PrimeCannon, 0.85 }, + { NPCID.PrimeLaser, 0.85 }, + { NPCID.PrimeSaw, 0.85 }, + { NPCID.PrimeVice, 0.85 }, - { ModContent.NPCType(), 0.8 }, - - { NPCID.Plantera, 1.15 }, - { NPCID.PlanterasTentacle, 1.15 }, + { ModContent.NPCType(), 0.8 }, + + { NPCID.Plantera, 1.15 }, + { NPCID.PlanterasTentacle, 1.15 }, - { ModContent.NPCType(), 1.2 }, - { ModContent.NPCType(), 0.8 }, - { NPCID.DetonatingBubble, 0.75 }, - - { ModContent.NPCType(), 1.1 }, - - { NPCID.Golem, 0.8 }, - { NPCID.GolemHead, 0.8 }, - { NPCID.GolemFistLeft, 0.8 }, - { NPCID.GolemFistRight, 0.8 }, - - { ModContent.NPCType(), 0.9 }, + { ModContent.NPCType(), 1.2 }, + { ModContent.NPCType(), 0.8 }, + { NPCID.DetonatingBubble, 0.75 }, + + { ModContent.NPCType(), 1.1 }, + + { NPCID.Golem, 0.8 }, + { NPCID.GolemHead, 0.8 }, + { NPCID.GolemFistLeft, 0.8 }, + { NPCID.GolemFistRight, 0.8 }, + + { ModContent.NPCType(), 0.9 }, - { NPCID.DukeFishron, 0.7 }, - { NPCID.Sharkron, 0.75 }, - { NPCID.Sharkron2, 0.75 }, - - { ModContent.NPCType(), 0.8 }, - - { NPCID.CultistDragonHead, 0.75 }, - { NPCID.CultistDragonBody1, 0.75 }, - { NPCID.CultistDragonBody2, 0.75 }, - { NPCID.CultistDragonBody3, 0.75 }, - { NPCID.CultistDragonBody4, 0.75 }, - { NPCID.CultistDragonTail, 0.75 }, - { NPCID.AncientDoom, 0.75 }, - { NPCID.AncientLight, 0.75 }, + { NPCID.DukeFishron, 0.7 }, + { NPCID.Sharkron, 0.75 }, + { NPCID.Sharkron2, 0.75 }, + + { ModContent.NPCType(), 0.8 }, + + { NPCID.CultistDragonHead, 0.75 }, + { NPCID.CultistDragonBody1, 0.75 }, + { NPCID.CultistDragonBody2, 0.75 }, + { NPCID.CultistDragonBody3, 0.75 }, + { NPCID.CultistDragonBody4, 0.75 }, + { NPCID.CultistDragonTail, 0.75 }, + { NPCID.AncientDoom, 0.75 }, + { NPCID.AncientLight, 0.75 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, + + { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.9 }, + { ModContent.NPCType(), 0.9 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.9 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, + + { ModContent.NPCType(), 0.9 }, + { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.85 }, - { ModContent.NPCType(), 0.85 }, + { ModContent.NPCType(), 0.85 }, + { ModContent.NPCType(), 0.85 }, - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 } - }; - - EnemyStats.ContactDamageValues = new SortedDictionary - { - { NPCID.KingSlime, new int[] { 40, 64, 80, 88, 96 } }, - - { ModContent.NPCType(), new int[] { 30, 66, 88, 99, 132 } }, - { ModContent.NPCType(), new int[] { 16, 32, 40, 44, 60 } }, - { ModContent.NPCType(), new int[] { 12, 24, 30, 32, 42 } }, - { ModContent.NPCType(), new int[] { 20, 44, 60, 70, 90 } }, - { ModContent.NPCType(), new int[] { 14, 28, 32, 36, 45 } }, - { ModContent.NPCType(), new int[] { 8, 16, 20, 24, 30 } }, - - { NPCID.EyeofCthulhu, new int[] { - 15, // 23 in phase 2 - 30, // 36 in phase 2, 40 in phase 3 - 40, // 48 in phase 2, 56 in phase 3 - 60, // Same for all phases - 51 } }, // Vanilla: 54 in phase 2, 60 in phase 3; Rev: 61 in phase 2, 71 in phase 3; Death: 71 at all times - { NPCID.ServantofCthulhu, new int[] { 12, 24, 30, 34, 42 } }, - - { ModContent.NPCType(), new int[] { 40, 64, 80, 88, 120 } }, - { ModContent.NPCType(), new int[] { 25, 50, 62, 70, 75 } }, - - { NPCID.EaterofWorldsHead, new int[] { 25, 55, 77, 88, 132 } }, - { NPCID.EaterofWorldsBody, new int[] { 15, 24, 32, 40, 60 } }, - { NPCID.EaterofWorldsTail, new int[] { 10, 16, 24, 32, 42 } }, - { NPCID.VileSpit, new int[] { -1, 64, 64, 64, 96 } }, - - { NPCID.BrainofCthulhu, new int[] { 30, 54, 81, 99, 135 } }, - { NPCID.Creeper, new int[] { 20, 36, 54, 72, 90 } }, - - { ModContent.NPCType(), new int[] { 35, 63, 81, 90, 135 } }, - { ModContent.NPCType(), new int[] { 25, 50, 62, 68, 90 } }, - - { ModContent.NPCType(), new int[] { 30, 54, 63, 72, 108 } }, - { ModContent.NPCType(), new int[] { 45, 90, 108, 118, 150 } }, - { ModContent.NPCType(), new int[] { 24, 48, 56, 60, 75 } }, - { ModContent.NPCType(), new int[] { 18, 36, 42, 46, 60 } }, - { ModContent.NPCType(), new int[] { 35, 70, 84, 92, 126 } }, - { ModContent.NPCType(), new int[] { 21, 42, 50, 54, 69 } }, - { ModContent.NPCType(), new int[] { 14, 28, 34, 38, 54 } }, - { ModContent.NPCType(), new int[] { 30, 60, 72, 80, 102 } }, - { ModContent.NPCType(), new int[] { 18, 36, 42, 46, 60 } }, - { ModContent.NPCType(), new int[] { 10, 20, 26, 30, 45 } }, - - { NPCID.QueenBee, new int[] { 30, 54, 81, 99, 135 } }, - { NPCID.Bee, new int[] { 20, 24, 30, 36, 54 } }, - { NPCID.BeeSmall, new int[] { 15, 18, 24, 30, 45 } }, - - { NPCID.SkeletronHead, new int[] { - 35, // Same for all phases - 77, // 100 while spinning - 88, // 114 while spinning - 99, // 128 while spinning - 132 } }, // 171 while spinning - { NPCID.SkeletronHand, new int[] { 20, 44, 55, 66, 99 } }, - { NPCID.ChaosBall, new int[] { -1, -1, -1, 40, 60 } }, - - { ModContent.NPCType(), new int[] { 40, 80, 96, 104, 135 } }, - { ModContent.NPCType(), new int[] { 45, 90, 108, 118, 150 } }, - { ModContent.NPCType(), new int[] { 40, 80, 96, 104, 135 } }, - { ModContent.NPCType(), new int[] { 50, 100, 120, 130, 171 } }, - { ModContent.NPCType(), new int[] { 45, 90, 108, 118, 150 } }, - { ModContent.NPCType(), new int[] { 30, 60, 72, 78, 99 } }, - { ModContent.NPCType(), new int[] { 20, 40, 48, 52, 66 } }, - { ModContent.NPCType(), new int[] { 35, 70, 84, 92, 120 } }, - { ModContent.NPCType(), new int[] { 25, 50, 60, 66, 84 } }, - - { NPCID.WallofFlesh, new int[] { 50, 150, 180, 195, 225 } }, - { NPCID.WallofFleshEye, new int[] { 50, 150, 180, 195, 225 } }, - { NPCID.TheHungry, new int[] { - 30, // Ranges from 30 to 75 depending on WoF life - 60, // Ranges from 60 to 150 depending on WoF life - 60, // Ranges from 60 to 150 depending on WoF life - 60, // Ranges from 60 to 150 depending on WoF life - 90 } }, // Ranges from 90 to 225 depending on WoF life - { NPCID.TheHungryII, new int[] { 30, 60, 74, 80, 90 } }, - { NPCID.LeechHead, new int[] { 26, 52, 62, 68, 78 } }, - { NPCID.LeechBody, new int[] { 22, 44, 52, 56, 66 } }, - { NPCID.LeechTail, new int[] { 18, 36, 42, 44, 54 } }, - - { ModContent.NPCType(), new int[] { 60, 138, 161, 184, 276 } }, - { ModContent.NPCType(), new int[] { 60, 120, 138, 158, 216 } }, - - { NPCID.Spazmatism, new int[] { - 60, // 90 in phase 2 - 102, // 153 in phase 2 - 119, // 178 in phase 2 - 136, // 204 in phase 2 - 204 } }, // 306 in phase 2 - { NPCID.Retinazer, new int[] { - 50, // 75 in phase 2 - 85, // 127 in phase 2 - 102, // 153 in phase 2 - 119, // 178 in phase 2 - 153 } }, // 229 in phase 2 - - { ModContent.NPCType(), new int[] { 80, 176, 187, 198, 264 } }, - { ModContent.NPCType(), new int[] { 70, 112, 136, 144, 180 } }, - { ModContent.NPCType(), new int[] { 65, 104, 112, 136, 168 } }, - { ModContent.NPCType(), new int[] { 60, 96, 104, 112, 156 } }, - - { NPCID.TheDestroyer, new int[] { 70, 280, 320, 340, 420 } }, - { NPCID.TheDestroyerBody, new int[] { 60, 102, 136, 153, 204 } }, - { NPCID.TheDestroyerTail, new int[] { 40, 68, 102, 136, 153 } }, - - { ModContent.NPCType(), new int[] { 70, 112, 136, 144, 180 } }, - - { NPCID.SkeletronPrime, new int[] { - 50, // 100 while spinning - 85, // 170 while spinning - 102, // 204 while spinning - 119, // 238 while spinning - 153 } }, // 306 while spinning - { NPCID.PrimeVice, new int[] { 60, 102, 136, 153, 204 } }, - { NPCID.PrimeSaw, new int[] { 60, 102, 136, 153, 204 } }, - { NPCID.PrimeCannon, new int[] { 30, 51, 68, 85, 102 } }, - { NPCID.PrimeLaser, new int[] { 30, 51, 68, 85, 102 } }, - - { ModContent.NPCType(), new int[] { 90, 144, 168, 176, 240 } }, - { ModContent.NPCType(), new int[] { 60, 120, 138, 148, 198 } }, - { ModContent.NPCType(), new int[] { 65, 130, 150, 162, 216 } }, - - { NPCID.Plantera, new int[] { - 50, // 70 in phase 2, vanilla is retarded and doesn't use the expert multiplier for plantera's damage - 100, // 140 in phase 2, vanilla is retarded and doesn't use the expert multiplier for plantera's damage - 138, // 193 in phase 2 - 161, // 225 in phase 2 - 207 } }, // Vanilla: Is retarded, so plantera does 150 in phase 1 and 210 in phase 2; Rev and Death: 289 in phase 2 - { NPCID.PlanterasTentacle, new int[] { 60, 138, 161, 207, 276 } }, - { NPCID.Spore, new int[] { 70, 140, 160, 170, 210 } }, - - { ModContent.NPCType(), new int[] { 90, 216, 240, 252, 324 } }, - { ModContent.NPCType(), new int[] { - 70, // 105 during charge - 112, // 168 during charge - 136, // 204 during charge - 144, // 216 during charge - 192 } }, // 288 during charge - { ModContent.NPCType(), new int[] { 55, 110, 126, 136, 165 } }, - { NPCID.DetonatingBubble, new int[] { 100, 150, 180, 195, 225 } }, - { ModContent.NPCType(), new int[] { 70, 140, 160, 170, 210 } }, - - { ModContent.NPCType(), new int[] { 100, 220, 242, 253, 330 } }, - { ModContent.NPCType(), new int[] { 75, 150, 172, 184, 240 } }, - - { NPCID.Golem, new int[] { 90, 144, 176, 192, 240 } }, - { NPCID.GolemHead, new int[] { 80, 128, 144, 160, 192 } }, - { NPCID.GolemFistLeft, new int[] { 70, 112, 144, 160, 180 } }, - { NPCID.GolemFistRight, new int[] { 70, 112, 144, 160, 180 } }, - - { ModContent.NPCType(), new int[] { 100, 180, 216, 234, 297 } }, - { ModContent.NPCType(), new int[] { 90, 180, 210, 224, 270 } }, - { ModContent.NPCType(), new int[] { 100, 200, 240, 260, 330 } }, - - { NPCID.DukeFishron, new int[] { - 100, // 120 in phase 2 - 140, // 201 in phase 2, 184 in phase 3 - 168, // 241 in phase 2, 221 in phase 3 - 182, // 262 in phase 2, 240 in phase 3 - 210 } }, // 302 in phase 2, 277 in phase 3 - { NPCID.Sharkron, new int[] { 100, 150, 180, 195, 225 } }, - { NPCID.Sharkron2, new int[] { 120, 180, 210, 225, 270 } }, - - { ModContent.NPCType(), new int[] { 120, 192, 224, 232, 288 } }, - { ModContent.NPCType(), new int[] { 80, 160, 180, 200, 240 } }, - { ModContent.NPCType(), new int[] { 80, 160, 180, 200, 240 } }, - { ModContent.NPCType(), new int[] { 120, 192, 224, 232, 288 } }, - { ModContent.NPCType(), new int[] { 100, 160, 192, 200, 216 } }, - - { NPCID.CultistDragonHead, new int[] { 120, 180, 210, 225, 270 } }, - { NPCID.CultistDragonBody1, new int[] { 60, 90, 105, 120, 135 } }, - { NPCID.CultistDragonBody2, new int[] { 60, 90, 105, 120, 135 } }, - { NPCID.CultistDragonBody3, new int[] { 60, 90, 105, 120, 135 } }, - { NPCID.CultistDragonBody4, new int[] { 60, 90, 105, 120, 135 } }, - { NPCID.CultistDragonTail, new int[] { 60, 90, 105, 120, 135 } }, - { NPCID.AncientCultistSquidhead, new int[] { 90, 180, 210, 225, 270 } }, - { NPCID.AncientDoom, new int[] { 30, 45, 0, 0, 90 } }, // Vanilla: 90 in Master Mode; Rev and Death: 0 in Master Mode - { NPCID.AncientLight, new int[] { 120, 180, 210, 225, 270 } }, - - { ModContent.NPCType(), new int[] { 120, 240, 268, 280, 360 } }, - { ModContent.NPCType(), new int[] { 100, 160, 192, 200, 240 } }, - { ModContent.NPCType(), new int[] { 80, 128, 160, 168, 192 } }, - - { ModContent.NPCType(), new int[] { 140, 224, 256, 280, 336 } }, - { ModContent.NPCType(), new int[] { 120, 240, 264, 278, 336 } }, - { ModContent.NPCType(), new int[] { 100, 200, 220, 232, 270 } }, - - { ModContent.NPCType(), new int[] { 160, 256, 288, 304, 384 } }, - { ModContent.NPCType(), new int[] { 110, 220, 242, 256, 330 } }, - - { ModContent.NPCType(), new int[] { 120, 240, 264, 278, 336 } }, - { ModContent.NPCType(), new int[] { 100, 200, 220, 232, 270 } }, - - { ModContent.NPCType(), new int[] { 150, 300, 330, 348, 450 } }, - { ModContent.NPCType(), new int[] { 130, 260, 288, 304, 390 } }, - - { ModContent.NPCType(), new int[] { 180, 360, 396, 418, 540 } }, - { ModContent.NPCType(), new int[] { 120, 192, 224, 250, 330 } }, - { ModContent.NPCType(), new int[] { 100, 160, 192, 210, 270 } }, - - { ModContent.NPCType(), new int[] { 175, 315, 351, 369, 459 } }, - { ModContent.NPCType(), new int[] { 130, 260, 288, 304, 390 } }, - { ModContent.NPCType(), new int[] { 140, 280, 300, 320, 390 } }, - - { ModContent.NPCType(), new int[] { - 150, // 180 in phase 2, 210 in phase 3 - 240, // 288 in phase 2, 336 in phase 3 - 264, // 316 in phase 2, 369 in phase 3 - 280, // 336 in phase 2, 392 in phase 3 - 384 } }, // 460 in phase 2, 537 in phase 3 - { ModContent.NPCType(), new int[] { 210, 336, 360, 392, 528 } }, - - { ModContent.NPCType(), new int[] { - 160, // 176 in phase 2, 192 in phase 3 - 288, // 316 in phase 2, 345 in phase 3 - 324, // 356 in phase 2, 388 in phase 3 - 342, // 376 in phase 2, 410 in phase 3 - 432 } }, // 475 in phase 2, 518 in phase 3 - { ModContent.NPCType(), new int[] { 180, 288, 328, 344, 432 } }, - { ModContent.NPCType(), new int[] { 180, 288, 328, 344, 432 } }, - - { ModContent.NPCType(), new int[] { 350, 700, 750, 780, 880 } }, - { ModContent.NPCType(), new int[] { 220, 374, 425, 442, 561 } }, - { ModContent.NPCType(), new int[] { 180, 306, 340, 357, 459 } }, - { ModContent.NPCType(), new int[] { 180, 360, 396, 420, 510 } }, - { ModContent.NPCType(), new int[] { 130, 260, 290, 320, 420 } }, - { ModContent.NPCType(), new int[] { 100, 200, 230, 260, 330 } }, - - { ModContent.NPCType(), new int[] { 330, 528, 560, 576, 690 } }, - - { ModContent.NPCType(), new int[] { 350, 560, 592, 608, 768 } }, - - { ModContent.NPCType(), new int[] { 350, 560, 592, 608, 768 } }, - { ModContent.NPCType(), new int[] { 330, 528, 560, 576, 690 } }, - - { ModContent.NPCType(), new int[] { 400, 640, 680, 704, 864 } }, - { ModContent.NPCType(), new int[] { 330, 528, 560, 576, 690 } }, - { ModContent.NPCType(), new int[] { 330, 528, 560, 576, 690 } }, - { ModContent.NPCType(), new int[] { 260, 416, 446, 464, 570 } }, - - { ModContent.NPCType(), new int[] { 400, 800, 850, 880, 1000 } } - }; - - EnemyStats.ProjectileDamageValues = new SortedDictionary, int[]> - { - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 22, 36, 44, 48, 66 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 44, 60, 68, 90 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 32, 48, 60, 68, 90 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 32, 48, 60, 68, 90 } }, - - { new Tuple(NPCID.EaterofWorldsHead, ProjectileID.CursedFlameHostile), new int[] { 32, 48, 60, 68, 90 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 30, 48, 60, 68, 90 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 30, 48, 60, 68, 90 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, - - { new Tuple(NPCID.QueenBee, ProjectileID.Stinger), new int[] { 22, 44, 64, 72, 96 } }, // 66 damage in non-rev master mode - - { new Tuple(NPCID.SkeletronHead, ProjectileID.Skull), new int[] { 46, 68, 84, 92, 126 } }, // 102 damage in non-rev master mode - { new Tuple(NPCID.SkeletronHead, ProjectileID.Shadowflames), new int[] { 40, 60, 76, 84, 114 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 42, 68, 84, 92, 126 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 84, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 42, 68, 84, 92, 126 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 84, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 84, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 34, 52, 68, 74, 102 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 24, 48, 60, 68, 90 } }, - - { new Tuple(NPCID.WallofFleshEye, ProjectileID.EyeLaser), new int[] { - 22, // 22 to 30, depending on life - 44, // 44 to 60, depending on life - 68, - 76, - 102 } }, // 66 to 90, depending on life - { new Tuple(NPCID.WallofFleshEye, ProjectileID.DeathLaser), new int[] { 40, 72, 88, 96, 132 } }, - { new Tuple(NPCID.WallofFlesh, ProjectileID.DemonSickle), new int[] { 52, 92, 112, 124, 168 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 52, 92, 112, 124, 168 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 132, 180 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 52, 92, 112, 124, 168 } }, - - { new Tuple(NPCID.Retinazer, ProjectileID.EyeLaser), new int[] { 40, 76, 92, 100, 138 } }, // 114 damage in non-rev master mode - { new Tuple(NPCID.Retinazer, ProjectileID.DeathLaser), new int[] { - 50, // 36 in rapid fire - 92, // 68 in rapid fire - 112, // 84 in rapid fire - 124, // 92 in rapid fire - 168 } }, // 126 in rapid fire; 138 in non-rev master mode, 102 in rapid fire in non-rev master mode - { new Tuple(NPCID.Retinazer, ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, - { new Tuple(NPCID.Spazmatism, ProjectileID.CursedFlameHostile), new int[] { 50, 88, 108, 120, 162 } }, // 132 in non-rev master mode - { new Tuple(NPCID.Spazmatism, ProjectileID.EyeFire), new int[] { 60, 108, 0, 0, 162 } }, // Only used in non-rev modes - { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, - { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 60, 100, 120, 132, 180 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 132, 180 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 66, 112, 128, 140, 192 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 132, 180 } }, - - { new Tuple(NPCID.TheDestroyer, ProjectileID.DeathLaser), new int[] { 0, 0, 0, 152, 210 } }, - { new Tuple(NPCID.TheDestroyerBody, ProjectileID.DeathLaser), new int[] { 44, 72, 116, 128, 174 } }, // 108 in non-rev master mode - { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 46, 76, 128, 140, 186 } }, - { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 48, 80, 136, 152, 210 } }, - { new Tuple(NPCID.Probe, ProjectileID.PinkLaser), new int[] { 50, 88, 100, 112, 144 } }, // 132 in non-rev master mode - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 140, 192 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 200, 240, 252, 342 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, - - { new Tuple(NPCID.SkeletronPrime, ProjectileID.Skull), new int[] { 50, 100, 124, 136, 186 } }, - { new Tuple(NPCID.SkeletronPrime, ProjectileID.DeathLaser), new int[] { 50, 100, 124, 136, 186 } }, - { new Tuple(NPCID.SkeletronPrime, ProjectileID.RocketSkeleton), new int[] { 60, 120, 148, 160, 222 } }, - { new Tuple(NPCID.SkeletronPrime, ProjectileID.SaucerMissile), new int[] { 60, 120, 148, 160, 222 } }, - { new Tuple(NPCID.PrimeCannon, ProjectileID.RocketSkeleton), new int[] { 60, 120, 148, 160, 222 } }, - { new Tuple(NPCID.PrimeCannon, ProjectileID.BombSkeletronPrime), new int[] { 80, 160, 0, 0, 240 } }, - { new Tuple(NPCID.PrimeLaser, ProjectileID.DeathLaser), new int[] { 50, 100, 124, 136, 186 } }, // 150 in non-rev master mode - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 140, 192 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 140, 192 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 140, 192 } }, - - { new Tuple(NPCID.Plantera, ProjectileID.SeedPlantera), new int[] { 44, 76, 128, 140, 186 } }, // 114 in non-rev master mode - { new Tuple(NPCID.Plantera, ProjectileID.PoisonSeedPlantera), new int[] { 54, 96, 136, 152, 210 } }, // 144 in non-rev master mode - { new Tuple(NPCID.Plantera, ProjectileID.ThornBall), new int[] { 62, 108, 160, 176, 234 } }, // 162 in non-rev master mode - { new Tuple(NPCID.Plantera, ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 208, 228, 300 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 84, 148, 172, 188, 252 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 200, 270 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 200, 270 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 208, 228, 300 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 208, 228, 300 } }, - - { new Tuple(NPCID.Golem, ProjectileID.Fireball), new int[] { 58, 116, 160, 176, 234 } }, - { new Tuple(NPCID.Golem, ProjectileID.EyeBeam), new int[] { 56, 112, 172, 188, 252 } }, - { new Tuple(NPCID.GolemHead, ProjectileID.Fireball), new int[] { - 36, // 36 to 58 depending on life - 72, // 72 to 116 depending on life - 160, - 176, - 234 } }, // 108 to 174 depending on life in non-rev master mode - { new Tuple(NPCID.GolemHead, ProjectileID.EyeBeam), new int[] { 56, 112, 172, 188, 252 } }, // 168 in non-rev master mode - { new Tuple(NPCID.GolemHeadFree, ProjectileID.Fireball), new int[] { - 36, // 36 to 58 depending on life - 72, // 72 to 116 depending on life - 160, - 176, - 234 } }, // 108 to 174 depending on life in non-rev master mode - { new Tuple(NPCID.GolemHeadFree, ProjectileID.EyeBeam), new int[] { 56, 112, 172, 188, 252 } }, // 168 in non-rev master mode - { new Tuple(NPCID.GolemHeadFree, ProjectileID.InfernoHostileBolt), new int[] { 64, 128, 184, 200, 270 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 200, 270 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 200, 270 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 240, 330 } }, - - { new Tuple(NPCID.DukeFishron, ProjectileID.Sharknado), new int[] { 80, 100, 184, 200, 270 } }, // 150 in non-rev master mode - { new Tuple(NPCID.DukeFishron, ProjectileID.Cthulunado), new int[] { 160, 200, 232, 248, 348 } }, // 300 in non-rev master mode - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 224, 312 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 144, 172, 188, 258 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 224, 312 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 144, 172, 188, 258 } }, - - { new Tuple(NPCID.CultistBoss, ProjectileID.CultistBossFireBall), new int[] { 60, 80, 184, 200, 270 } }, // 80 in non-rev master mode - { new Tuple(NPCID.CultistBoss, ProjectileID.CultistBossIceMist), new int[] { 70, 100, 208, 224, 312 } }, // 100 in non-rev master mode - { new Tuple(NPCID.CultistBoss, ProjectileID.CultistBossLightningOrb), new int[] { 90, 120, 220, 240, 330 } }, // 120 in non-rev master mode - { new Tuple(NPCID.CultistBossClone, ProjectileID.CultistBossFireBallClone), new int[] { 36, 72, 172, 188, 258 } }, // 72 in non-rev master mode - { new Tuple(NPCID.AncientDoom, ProjectileID.AncientDoomProjectile), new int[] { 60, 180, 184, 200, 270 } }, // 402 in non-rev master mode - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 152, 176, 188, 264 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 224, 312 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 192, 204, 288 } }, - - { new Tuple(NPCID.MoonLordHead, ProjectileID.PhantasmalDeathray), new int[] { 150, 300, 380, 420, 570 } }, // 450 in non-rev master mode - { new Tuple(NPCID.MoonLordHead, ProjectileID.PhantasmalBolt), new int[] { 60, 120, 160, 176, 240 } }, // 180 in non-rev master mode - { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalEye), new int[] { 60, 120, 160, 176, 240 } }, // 180 in non-rev master mode - { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalSphere), new int[] { 100, 200, 260, 284, 390 } }, // 300 in non-rev master mode - { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalBolt), new int[] { 60, 120, 160, 176, 240 } }, // 180 in non-rev master mode - { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalBolt), new int[] { 70, 140, 180, 200, 270 } }, // 210 in non-rev master mode - { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalEye), new int[] { 70, 140, 180, 200, 270 } }, // 210 in non-rev master mode - { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalSphere), new int[] { 110, 220, 260, 284, 390 } }, // 330 in non-rev master mode - { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalDeathray), new int[] { 100, 200, 260, 284, 390 } }, // 300 in non-rev master mode - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 200, 300, 332, 356, 498 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 300, 432 } }, // Split holy fire does: 113, 198, 216, 225, 324 - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 236, 330 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 236, 330 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 35, 50, 50, 0, 0 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 264, 378 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 105, 171, 189, 198, 284 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 264, 378 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 105, 171, 189, 198, 284 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 264, 378 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 264, 378 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 200, 400, 440, 464, 660 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, - - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrb), new int[] { 150, 264, 288, 300, 432 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrbArc), new int[] { 150, 264, 288, 300, 432 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 300, 432 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 300, 432 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 160, 276, 304, 320, 456 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 340, 462 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 300, 432 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 220, 220, 220 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 220, 220, 220 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 340, 462 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 280, 400, 440, 464, 660 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 340, 462 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 180, 316, 348, 364, 492 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 340, 462 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 180, 316, 348, 364, 492 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 200, 340, 376, 396, 564 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 520, 548, 564, 822 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 444, 600 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 250, 440, 464, 476, 696 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 520, 548, 564, 822 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 520, 548, 564, 822 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 444, 600 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 444, 600 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 444, 600 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, // 25% increased damage in bullet hell 1 - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 608, 640, 658, 960 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 450, 676, 710, 728, 1062 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 320, 480, 504, 532, 774 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 320, 480, 504, 532, 774 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 320, 480, 504, 532, 774 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 320, 480, 504, 532, 774 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 320, 480, 504, 532, 774 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 450, 676, 710, 728, 1062 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 608, 640, 658, 960 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 450, 676, 710, 728, 1062 } }, - - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossIceMist), new int[] { 400, 600, 632, 648, 948 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrbArc), new int[] { 500, 752, 788, 808, 1182 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.AncientDoomProjectile), new int[] { 400, 600, 632, 648, 948 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossFireBallClone), new int[] { 400, 600, 632, 648, 948 } } - }; - } - - // Destroys the EnemyStats struct to save memory because mod assemblies will not be fully unloaded until TML 1.4. - internal static void UnloadEnemyStats() - { - EnemyStats.ExpertDamageMultiplier = null; - EnemyStats.ContactDamageValues = null; - EnemyStats.ProjectileDamageValues = null; - } - #endregion - } + { ModContent.NPCType(), 0.8 }, + + { ModContent.NPCType(), 0.8 }, + + { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, + + { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, + { ModContent.NPCType(), 0.8 }, + + { ModContent.NPCType(), 0.8 } + }; + + EnemyStats.ContactDamageValues = new SortedDictionary + { + { NPCID.KingSlime, new int[] { 40, 64, 80, 88, 96 } }, + + { ModContent.NPCType(), new int[] { 30, 66, 88, 99, 132 } }, + { ModContent.NPCType(), new int[] { 16, 32, 40, 44, 60 } }, + { ModContent.NPCType(), new int[] { 12, 24, 30, 32, 42 } }, + { ModContent.NPCType(), new int[] { 20, 44, 60, 70, 90 } }, + { ModContent.NPCType(), new int[] { 14, 28, 32, 36, 45 } }, + { ModContent.NPCType(), new int[] { 8, 16, 20, 24, 30 } }, + + { NPCID.EyeofCthulhu, new int[] { + 15, // 23 in phase 2 + 30, // 36 in phase 2, 40 in phase 3 + 40, // 48 in phase 2, 56 in phase 3 + 60, // Same for all phases + 51 } }, // Vanilla: 54 in phase 2, 60 in phase 3; Rev: 61 in phase 2, 71 in phase 3; Death: 71 at all times + { NPCID.ServantofCthulhu, new int[] { 12, 24, 30, 34, 42 } }, + + { ModContent.NPCType(), new int[] { 40, 64, 80, 88, 120 } }, + { ModContent.NPCType(), new int[] { 25, 50, 62, 70, 75 } }, + + { NPCID.EaterofWorldsHead, new int[] { 25, 55, 77, 88, 132 } }, + { NPCID.EaterofWorldsBody, new int[] { 15, 24, 32, 40, 60 } }, + { NPCID.EaterofWorldsTail, new int[] { 10, 16, 24, 32, 42 } }, + { NPCID.VileSpit, new int[] { -1, 64, 64, 64, 96 } }, + + { NPCID.BrainofCthulhu, new int[] { 30, 54, 81, 99, 135 } }, + { NPCID.Creeper, new int[] { 20, 36, 54, 72, 90 } }, + + { ModContent.NPCType(), new int[] { 35, 63, 81, 90, 135 } }, + { ModContent.NPCType(), new int[] { 25, 50, 62, 68, 90 } }, + + { ModContent.NPCType(), new int[] { 30, 54, 63, 72, 108 } }, + { ModContent.NPCType(), new int[] { 45, 90, 108, 118, 150 } }, + { ModContent.NPCType(), new int[] { 24, 48, 56, 60, 75 } }, + { ModContent.NPCType(), new int[] { 18, 36, 42, 46, 60 } }, + { ModContent.NPCType(), new int[] { 35, 70, 84, 92, 126 } }, + { ModContent.NPCType(), new int[] { 21, 42, 50, 54, 69 } }, + { ModContent.NPCType(), new int[] { 14, 28, 34, 38, 54 } }, + { ModContent.NPCType(), new int[] { 30, 60, 72, 80, 102 } }, + { ModContent.NPCType(), new int[] { 18, 36, 42, 46, 60 } }, + { ModContent.NPCType(), new int[] { 10, 20, 26, 30, 45 } }, + + { NPCID.QueenBee, new int[] { 30, 54, 81, 99, 135 } }, + { NPCID.Bee, new int[] { 20, 24, 30, 36, 54 } }, + { NPCID.BeeSmall, new int[] { 15, 18, 24, 30, 45 } }, + + { NPCID.SkeletronHead, new int[] { + 35, // Same for all phases + 77, // 100 while spinning + 88, // 114 while spinning + 99, // 128 while spinning + 132 } }, // 171 while spinning + { NPCID.SkeletronHand, new int[] { 20, 44, 55, 66, 99 } }, + { NPCID.ChaosBall, new int[] { -1, -1, -1, 40, 60 } }, + + { ModContent.NPCType(), new int[] { 40, 80, 96, 104, 135 } }, + { ModContent.NPCType(), new int[] { 45, 90, 108, 118, 150 } }, + { ModContent.NPCType(), new int[] { 40, 80, 96, 104, 135 } }, + { ModContent.NPCType(), new int[] { 50, 100, 120, 130, 171 } }, + { ModContent.NPCType(), new int[] { 45, 90, 108, 118, 150 } }, + { ModContent.NPCType(), new int[] { 30, 60, 72, 78, 99 } }, + { ModContent.NPCType(), new int[] { 20, 40, 48, 52, 66 } }, + { ModContent.NPCType(), new int[] { 35, 70, 84, 92, 120 } }, + { ModContent.NPCType(), new int[] { 25, 50, 60, 66, 84 } }, + + { NPCID.WallofFlesh, new int[] { 50, 150, 180, 195, 225 } }, + { NPCID.WallofFleshEye, new int[] { 50, 150, 180, 195, 225 } }, + { NPCID.TheHungry, new int[] { + 30, // Ranges from 30 to 75 depending on WoF life + 60, // Ranges from 60 to 150 depending on WoF life + 60, // Ranges from 60 to 150 depending on WoF life + 60, // Ranges from 60 to 150 depending on WoF life + 90 } }, // Ranges from 90 to 225 depending on WoF life + { NPCID.TheHungryII, new int[] { 30, 60, 74, 80, 90 } }, + { NPCID.LeechHead, new int[] { 26, 52, 62, 68, 78 } }, + { NPCID.LeechBody, new int[] { 22, 44, 52, 56, 66 } }, + { NPCID.LeechTail, new int[] { 18, 36, 42, 44, 54 } }, + + { ModContent.NPCType(), new int[] { 60, 138, 161, 184, 276 } }, + { ModContent.NPCType(), new int[] { 60, 120, 138, 158, 216 } }, + + { NPCID.Spazmatism, new int[] { + 60, // 90 in phase 2 + 102, // 153 in phase 2 + 119, // 178 in phase 2 + 136, // 204 in phase 2 + 204 } }, // 306 in phase 2 + { NPCID.Retinazer, new int[] { + 50, // 75 in phase 2 + 85, // 127 in phase 2 + 102, // 153 in phase 2 + 119, // 178 in phase 2 + 153 } }, // 229 in phase 2 + + { ModContent.NPCType(), new int[] { 80, 176, 187, 198, 264 } }, + { ModContent.NPCType(), new int[] { 70, 112, 136, 144, 180 } }, + { ModContent.NPCType(), new int[] { 65, 104, 112, 136, 168 } }, + { ModContent.NPCType(), new int[] { 60, 96, 104, 112, 156 } }, + + { NPCID.TheDestroyer, new int[] { 70, 280, 320, 340, 420 } }, + { NPCID.TheDestroyerBody, new int[] { 60, 102, 136, 153, 204 } }, + { NPCID.TheDestroyerTail, new int[] { 40, 68, 102, 136, 153 } }, + + { ModContent.NPCType(), new int[] { 70, 112, 136, 144, 180 } }, + + { NPCID.SkeletronPrime, new int[] { + 50, // 100 while spinning + 85, // 170 while spinning + 102, // 204 while spinning + 119, // 238 while spinning + 153 } }, // 306 while spinning + { NPCID.PrimeVice, new int[] { 60, 102, 136, 153, 204 } }, + { NPCID.PrimeSaw, new int[] { 60, 102, 136, 153, 204 } }, + { NPCID.PrimeCannon, new int[] { 30, 51, 68, 85, 102 } }, + { NPCID.PrimeLaser, new int[] { 30, 51, 68, 85, 102 } }, + + { ModContent.NPCType(), new int[] { 90, 144, 168, 176, 240 } }, + { ModContent.NPCType(), new int[] { 60, 120, 138, 148, 198 } }, + { ModContent.NPCType(), new int[] { 65, 130, 150, 162, 216 } }, + + { NPCID.Plantera, new int[] { + 50, // 70 in phase 2, vanilla is retarded and doesn't use the expert multiplier for plantera's damage + 100, // 140 in phase 2, vanilla is retarded and doesn't use the expert multiplier for plantera's damage + 138, // 193 in phase 2 + 161, // 225 in phase 2 + 207 } }, // Vanilla: Is retarded, so plantera does 150 in phase 1 and 210 in phase 2; Rev and Death: 289 in phase 2 + { NPCID.PlanterasTentacle, new int[] { 60, 138, 161, 207, 276 } }, + { NPCID.Spore, new int[] { 70, 140, 160, 170, 210 } }, + + { ModContent.NPCType(), new int[] { 90, 216, 240, 252, 324 } }, + { ModContent.NPCType(), new int[] { + 70, // 105 during charge + 112, // 168 during charge + 136, // 204 during charge + 144, // 216 during charge + 192 } }, // 288 during charge + { ModContent.NPCType(), new int[] { 55, 110, 126, 136, 165 } }, + { NPCID.DetonatingBubble, new int[] { 100, 150, 180, 195, 225 } }, + { ModContent.NPCType(), new int[] { 70, 140, 160, 170, 210 } }, + + { ModContent.NPCType(), new int[] { 100, 220, 242, 253, 330 } }, + { ModContent.NPCType(), new int[] { 75, 150, 172, 184, 240 } }, + + { NPCID.Golem, new int[] { 90, 144, 176, 192, 240 } }, + { NPCID.GolemHead, new int[] { 80, 128, 144, 160, 192 } }, + { NPCID.GolemFistLeft, new int[] { 70, 112, 144, 160, 180 } }, + { NPCID.GolemFistRight, new int[] { 70, 112, 144, 160, 180 } }, + + { ModContent.NPCType(), new int[] { 100, 180, 216, 234, 297 } }, + { ModContent.NPCType(), new int[] { 90, 180, 210, 224, 270 } }, + { ModContent.NPCType(), new int[] { 100, 200, 240, 260, 330 } }, + + { NPCID.DukeFishron, new int[] { + 100, // 120 in phase 2 + 140, // 201 in phase 2, 184 in phase 3 + 168, // 241 in phase 2, 221 in phase 3 + 182, // 262 in phase 2, 240 in phase 3 + 210 } }, // 302 in phase 2, 277 in phase 3 + { NPCID.Sharkron, new int[] { 100, 150, 180, 195, 225 } }, + { NPCID.Sharkron2, new int[] { 120, 180, 210, 225, 270 } }, + + { ModContent.NPCType(), new int[] { 120, 192, 224, 232, 288 } }, + { ModContent.NPCType(), new int[] { 80, 160, 180, 200, 240 } }, + { ModContent.NPCType(), new int[] { 80, 160, 180, 200, 240 } }, + { ModContent.NPCType(), new int[] { 120, 192, 224, 232, 288 } }, + { ModContent.NPCType(), new int[] { 100, 160, 192, 200, 216 } }, + + { NPCID.CultistDragonHead, new int[] { 120, 180, 210, 225, 270 } }, + { NPCID.CultistDragonBody1, new int[] { 60, 90, 105, 120, 135 } }, + { NPCID.CultistDragonBody2, new int[] { 60, 90, 105, 120, 135 } }, + { NPCID.CultistDragonBody3, new int[] { 60, 90, 105, 120, 135 } }, + { NPCID.CultistDragonBody4, new int[] { 60, 90, 105, 120, 135 } }, + { NPCID.CultistDragonTail, new int[] { 60, 90, 105, 120, 135 } }, + { NPCID.AncientCultistSquidhead, new int[] { 90, 180, 210, 225, 270 } }, + { NPCID.AncientDoom, new int[] { 30, 45, 0, 0, 90 } }, // Vanilla: 90 in Master Mode; Rev and Death: 0 in Master Mode + { NPCID.AncientLight, new int[] { 120, 180, 210, 225, 270 } }, + + { ModContent.NPCType(), new int[] { 120, 240, 268, 280, 360 } }, + { ModContent.NPCType(), new int[] { 100, 160, 192, 200, 240 } }, + { ModContent.NPCType(), new int[] { 80, 128, 160, 168, 192 } }, + + { ModContent.NPCType(), new int[] { 140, 224, 256, 280, 336 } }, + { ModContent.NPCType(), new int[] { 120, 240, 264, 278, 336 } }, + { ModContent.NPCType(), new int[] { 100, 200, 220, 232, 270 } }, + + { ModContent.NPCType(), new int[] { 160, 256, 288, 304, 384 } }, + { ModContent.NPCType(), new int[] { 110, 220, 242, 256, 330 } }, + + { ModContent.NPCType(), new int[] { 120, 240, 264, 278, 336 } }, + { ModContent.NPCType(), new int[] { 100, 200, 220, 232, 270 } }, + + { ModContent.NPCType(), new int[] { 150, 300, 330, 348, 450 } }, + { ModContent.NPCType(), new int[] { 130, 260, 288, 304, 390 } }, + + { ModContent.NPCType(), new int[] { 180, 360, 396, 418, 540 } }, + { ModContent.NPCType(), new int[] { 120, 192, 224, 250, 330 } }, + { ModContent.NPCType(), new int[] { 100, 160, 192, 210, 270 } }, + + { ModContent.NPCType(), new int[] { 175, 315, 351, 369, 459 } }, + { ModContent.NPCType(), new int[] { 130, 260, 288, 304, 390 } }, + { ModContent.NPCType(), new int[] { 140, 280, 300, 320, 390 } }, + + { ModContent.NPCType(), new int[] { + 150, // 180 in phase 2, 210 in phase 3 + 240, // 288 in phase 2, 336 in phase 3 + 264, // 316 in phase 2, 369 in phase 3 + 280, // 336 in phase 2, 392 in phase 3 + 384 } }, // 460 in phase 2, 537 in phase 3 + { ModContent.NPCType(), new int[] { 210, 336, 360, 392, 528 } }, + + { ModContent.NPCType(), new int[] { + 160, // 176 in phase 2, 192 in phase 3 + 288, // 316 in phase 2, 345 in phase 3 + 324, // 356 in phase 2, 388 in phase 3 + 342, // 376 in phase 2, 410 in phase 3 + 432 } }, // 475 in phase 2, 518 in phase 3 + { ModContent.NPCType(), new int[] { 180, 288, 328, 344, 432 } }, + { ModContent.NPCType(), new int[] { 180, 288, 328, 344, 432 } }, + + { ModContent.NPCType(), new int[] { 350, 700, 750, 780, 880 } }, + { ModContent.NPCType(), new int[] { 220, 374, 425, 442, 561 } }, + { ModContent.NPCType(), new int[] { 180, 306, 340, 357, 459 } }, + { ModContent.NPCType(), new int[] { 180, 360, 396, 420, 510 } }, + { ModContent.NPCType(), new int[] { 130, 260, 290, 320, 420 } }, + { ModContent.NPCType(), new int[] { 100, 200, 230, 260, 330 } }, + + { ModContent.NPCType(), new int[] { 330, 528, 560, 576, 690 } }, + + { ModContent.NPCType(), new int[] { 350, 560, 592, 608, 768 } }, + + { ModContent.NPCType(), new int[] { 350, 560, 592, 608, 768 } }, + { ModContent.NPCType(), new int[] { 330, 528, 560, 576, 690 } }, + + { ModContent.NPCType(), new int[] { 400, 640, 680, 704, 864 } }, + { ModContent.NPCType(), new int[] { 330, 528, 560, 576, 690 } }, + { ModContent.NPCType(), new int[] { 330, 528, 560, 576, 690 } }, + { ModContent.NPCType(), new int[] { 260, 416, 446, 464, 570 } }, + + { ModContent.NPCType(), new int[] { 400, 800, 850, 880, 1000 } } + }; + + EnemyStats.ProjectileDamageValues = new SortedDictionary, int[]> + { + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 22, 36, 44, 48, 66 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 44, 60, 68, 90 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 32, 48, 60, 68, 90 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 32, 48, 60, 68, 90 } }, + + { new Tuple(NPCID.EaterofWorldsHead, ProjectileID.CursedFlameHostile), new int[] { 32, 48, 60, 68, 90 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 30, 48, 60, 68, 90 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 30, 48, 60, 68, 90 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 76, 102 } }, + + { new Tuple(NPCID.QueenBee, ProjectileID.Stinger), new int[] { 22, 44, 64, 72, 96 } }, // 66 damage in non-rev master mode + + { new Tuple(NPCID.SkeletronHead, ProjectileID.Skull), new int[] { 46, 68, 84, 92, 126 } }, // 102 damage in non-rev master mode + { new Tuple(NPCID.SkeletronHead, ProjectileID.Shadowflames), new int[] { 40, 60, 76, 84, 114 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 42, 68, 84, 92, 126 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 84, 114 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 42, 68, 84, 92, 126 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 84, 114 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 84, 114 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 34, 52, 68, 74, 102 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 24, 48, 60, 68, 90 } }, + + { new Tuple(NPCID.WallofFleshEye, ProjectileID.EyeLaser), new int[] { + 22, // 22 to 30, depending on life + 44, // 44 to 60, depending on life + 68, + 76, + 102 } }, // 66 to 90, depending on life + { new Tuple(NPCID.WallofFleshEye, ProjectileID.DeathLaser), new int[] { 40, 72, 88, 96, 132 } }, + { new Tuple(NPCID.WallofFlesh, ProjectileID.DemonSickle), new int[] { 52, 92, 112, 124, 168 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 52, 92, 112, 124, 168 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 132, 180 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 52, 92, 112, 124, 168 } }, + + { new Tuple(NPCID.Retinazer, ProjectileID.EyeLaser), new int[] { 40, 76, 92, 100, 138 } }, // 114 damage in non-rev master mode + { new Tuple(NPCID.Retinazer, ProjectileID.DeathLaser), new int[] { + 50, // 36 in rapid fire + 92, // 68 in rapid fire + 112, // 84 in rapid fire + 124, // 92 in rapid fire + 168 } }, // 126 in rapid fire; 138 in non-rev master mode, 102 in rapid fire in non-rev master mode + { new Tuple(NPCID.Retinazer, ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, + { new Tuple(NPCID.Spazmatism, ProjectileID.CursedFlameHostile), new int[] { 50, 88, 108, 120, 162 } }, // 132 in non-rev master mode + { new Tuple(NPCID.Spazmatism, ProjectileID.EyeFire), new int[] { 60, 108, 0, 0, 162 } }, // Only used in non-rev modes + { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, + { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 60, 100, 120, 132, 180 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 132, 180 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 66, 112, 128, 140, 192 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 132, 180 } }, + + { new Tuple(NPCID.TheDestroyer, ProjectileID.DeathLaser), new int[] { 0, 0, 0, 152, 210 } }, + { new Tuple(NPCID.TheDestroyerBody, ProjectileID.DeathLaser), new int[] { 44, 72, 116, 128, 174 } }, // 108 in non-rev master mode + { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 46, 76, 128, 140, 186 } }, + { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 48, 80, 136, 152, 210 } }, + { new Tuple(NPCID.Probe, ProjectileID.PinkLaser), new int[] { 50, 88, 100, 112, 144 } }, // 132 in non-rev master mode + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 140, 192 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 200, 240, 252, 342 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, + + { new Tuple(NPCID.SkeletronPrime, ProjectileID.Skull), new int[] { 50, 100, 124, 136, 186 } }, + { new Tuple(NPCID.SkeletronPrime, ProjectileID.DeathLaser), new int[] { 50, 100, 124, 136, 186 } }, + { new Tuple(NPCID.SkeletronPrime, ProjectileID.RocketSkeleton), new int[] { 60, 120, 148, 160, 222 } }, + { new Tuple(NPCID.SkeletronPrime, ProjectileID.SaucerMissile), new int[] { 60, 120, 148, 160, 222 } }, + { new Tuple(NPCID.PrimeCannon, ProjectileID.RocketSkeleton), new int[] { 60, 120, 148, 160, 222 } }, + { new Tuple(NPCID.PrimeCannon, ProjectileID.BombSkeletronPrime), new int[] { 80, 160, 0, 0, 240 } }, + { new Tuple(NPCID.PrimeLaser, ProjectileID.DeathLaser), new int[] { 50, 100, 124, 136, 186 } }, // 150 in non-rev master mode + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 140, 192 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 140, 192 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 140, 192 } }, + + { new Tuple(NPCID.Plantera, ProjectileID.SeedPlantera), new int[] { 44, 76, 128, 140, 186 } }, // 114 in non-rev master mode + { new Tuple(NPCID.Plantera, ProjectileID.PoisonSeedPlantera), new int[] { 54, 96, 136, 152, 210 } }, // 144 in non-rev master mode + { new Tuple(NPCID.Plantera, ProjectileID.ThornBall), new int[] { 62, 108, 160, 176, 234 } }, // 162 in non-rev master mode + { new Tuple(NPCID.Plantera, ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 208, 228, 300 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 84, 148, 172, 188, 252 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 200, 270 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 200, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 208, 228, 300 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 208, 228, 300 } }, + + { new Tuple(NPCID.Golem, ProjectileID.Fireball), new int[] { 58, 116, 160, 176, 234 } }, + { new Tuple(NPCID.Golem, ProjectileID.EyeBeam), new int[] { 56, 112, 172, 188, 252 } }, + { new Tuple(NPCID.GolemHead, ProjectileID.Fireball), new int[] { + 36, // 36 to 58 depending on life + 72, // 72 to 116 depending on life + 160, + 176, + 234 } }, // 108 to 174 depending on life in non-rev master mode + { new Tuple(NPCID.GolemHead, ProjectileID.EyeBeam), new int[] { 56, 112, 172, 188, 252 } }, // 168 in non-rev master mode + { new Tuple(NPCID.GolemHeadFree, ProjectileID.Fireball), new int[] { + 36, // 36 to 58 depending on life + 72, // 72 to 116 depending on life + 160, + 176, + 234 } }, // 108 to 174 depending on life in non-rev master mode + { new Tuple(NPCID.GolemHeadFree, ProjectileID.EyeBeam), new int[] { 56, 112, 172, 188, 252 } }, // 168 in non-rev master mode + { new Tuple(NPCID.GolemHeadFree, ProjectileID.InfernoHostileBolt), new int[] { 64, 128, 184, 200, 270 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 200, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 200, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 240, 330 } }, + + { new Tuple(NPCID.DukeFishron, ProjectileID.Sharknado), new int[] { 80, 100, 184, 200, 270 } }, // 150 in non-rev master mode + { new Tuple(NPCID.DukeFishron, ProjectileID.Cthulunado), new int[] { 160, 200, 232, 248, 348 } }, // 300 in non-rev master mode + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 224, 312 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 144, 172, 188, 258 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 224, 312 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 144, 172, 188, 258 } }, + + { new Tuple(NPCID.CultistBoss, ProjectileID.CultistBossFireBall), new int[] { 60, 80, 184, 200, 270 } }, // 80 in non-rev master mode + { new Tuple(NPCID.CultistBoss, ProjectileID.CultistBossIceMist), new int[] { 70, 100, 208, 224, 312 } }, // 100 in non-rev master mode + { new Tuple(NPCID.CultistBoss, ProjectileID.CultistBossLightningOrb), new int[] { 90, 120, 220, 240, 330 } }, // 120 in non-rev master mode + { new Tuple(NPCID.CultistBossClone, ProjectileID.CultistBossFireBallClone), new int[] { 36, 72, 172, 188, 258 } }, // 72 in non-rev master mode + { new Tuple(NPCID.AncientDoom, ProjectileID.AncientDoomProjectile), new int[] { 60, 180, 184, 200, 270 } }, // 402 in non-rev master mode + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 152, 176, 188, 264 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 224, 312 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 192, 204, 288 } }, + + { new Tuple(NPCID.MoonLordHead, ProjectileID.PhantasmalDeathray), new int[] { 150, 300, 380, 420, 570 } }, // 450 in non-rev master mode + { new Tuple(NPCID.MoonLordHead, ProjectileID.PhantasmalBolt), new int[] { 60, 120, 160, 176, 240 } }, // 180 in non-rev master mode + { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalEye), new int[] { 60, 120, 160, 176, 240 } }, // 180 in non-rev master mode + { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalSphere), new int[] { 100, 200, 260, 284, 390 } }, // 300 in non-rev master mode + { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalBolt), new int[] { 60, 120, 160, 176, 240 } }, // 180 in non-rev master mode + { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalBolt), new int[] { 70, 140, 180, 200, 270 } }, // 210 in non-rev master mode + { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalEye), new int[] { 70, 140, 180, 200, 270 } }, // 210 in non-rev master mode + { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalSphere), new int[] { 110, 220, 260, 284, 390 } }, // 330 in non-rev master mode + { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalDeathray), new int[] { 100, 200, 260, 284, 390 } }, // 300 in non-rev master mode + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 200, 300, 332, 356, 498 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 300, 432 } }, // Split holy fire does: 113, 198, 216, 225, 324 + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 236, 330 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 236, 330 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 35, 50, 50, 0, 0 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 264, 378 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 105, 171, 189, 198, 284 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 264, 378 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 105, 171, 189, 198, 284 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 264, 378 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 264, 378 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 200, 400, 440, 464, 660 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, + + { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrb), new int[] { 150, 264, 288, 300, 432 } }, + { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrbArc), new int[] { 150, 264, 288, 300, 432 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 300, 432 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 300, 432 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 160, 276, 304, 320, 456 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 340, 462 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 300, 432 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 220, 220, 220 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 220, 220, 220 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 340, 462 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 280, 400, 440, 464, 660 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 340, 462 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 180, 316, 348, 364, 492 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 340, 462 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 180, 316, 348, 364, 492 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 200, 340, 376, 396, 564 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 520, 548, 564, 822 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 444, 600 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 250, 440, 464, 476, 696 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 520, 548, 564, 822 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 520, 548, 564, 822 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 444, 600 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 444, 600 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 444, 600 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, // 25% increased damage in bullet hell 1 + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 608, 640, 658, 960 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 450, 676, 710, 728, 1062 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 320, 480, 504, 532, 774 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 320, 480, 504, 532, 774 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 320, 480, 504, 532, 774 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 320, 480, 504, 532, 774 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 320, 480, 504, 532, 774 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 450, 676, 710, 728, 1062 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 608, 640, 658, 960 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 360, 540, 568, 584, 858 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 288, 432, 454, 478, 696 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 450, 676, 710, 728, 1062 } }, + + { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossIceMist), new int[] { 400, 600, 632, 648, 948 } }, + { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrbArc), new int[] { 500, 752, 788, 808, 1182 } }, + { new Tuple(ModContent.NPCType(), ProjectileID.AncientDoomProjectile), new int[] { 400, 600, 632, 648, 948 } }, + { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossFireBallClone), new int[] { 400, 600, 632, 648, 948 } } + }; + } + + // Destroys the EnemyStats struct to save memory because mod assemblies will not be fully unloaded until TML 1.4. + internal static void UnloadEnemyStats() + { + EnemyStats.ExpertDamageMultiplier = null; + EnemyStats.ContactDamageValues = null; + EnemyStats.ProjectileDamageValues = null; + } + #endregion + } } diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index e394dbbc46..7b415eb20d 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -23,385 +23,385 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { - public static partial class CalamityUtils - { - /// - /// Efficiently counts the amount of existing enemies. May be used for multiple enemies. - /// - /// - /// - public static int CountNPCsBetter(params int[] typesToCheck) - { - // Don't waste time if the type check list is empty for some reason. - if (typesToCheck.Length <= 0) - return 0; - - int count = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (!typesToCheck.Contains(Main.npc[i].type) || !Main.npc[i].active) - continue; - - count++; - } - - return count; - } - - private static readonly FieldInfo waterSpeedField = typeof(NPC).GetField("waterMovementSpeed", BindingFlags.NonPublic | BindingFlags.Instance); - public static void RemoveWaterSlowness(this NPC npc) - { - waterSpeedField.SetValue(npc, 1f); - } - - /// - /// Syncs position and velocity from a client to the server. This is to be used in contexts where these things are reliant on client-side information, such as . - /// - /// - public static void SyncMotionToServer(this NPC npc) + public static partial class CalamityUtils + { + /// + /// Efficiently counts the amount of existing enemies. May be used for multiple enemies. + /// + /// + /// + public static int CountNPCsBetter(params int[] typesToCheck) { - if (Main.netMode != NetmodeID.MultiplayerClient) - return; + // Don't waste time if the type check list is empty for some reason. + if (typesToCheck.Length <= 0) + return 0; - var netMessage = CalamityMod.Instance.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.SyncNPCMotionDataToServer); - netMessage.Write(npc.whoAmI); - netMessage.WriteVector2(npc.Center); - netMessage.WriteVector2(npc.velocity); - netMessage.Send(); - } + int count = 0; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (!typesToCheck.Contains(Main.npc[i].type) || !Main.npc[i].active) + continue; - /// - /// Allows you to set the lifeMax value of a NPC to different values based on the mode. Called instead of npc.lifeMax = X. - /// - /// The NPC whose lifeMax value you are trying to set. - /// The value lifeMax will be set to in normal mode, this value gets doubled automatically in Expert mode. - /// The value lifeMax will be set to in Revegeneance mode. - /// The value lifeMax will be set to during the Boss Rush. - public static void LifeMaxNERB(this NPC npc, int normal, int? revengeance = null, int? bossRush = null) - { - npc.lifeMax = normal; + count++; + } - if (bossRush.HasValue && BossRushEvent.BossRushActive) - { - npc.lifeMax = bossRush.Value; - } - else if (revengeance.HasValue && CalamityWorld.revenge) - { - npc.lifeMax = revengeance.Value; - } - } + return count; + } - /// - /// Allows you to set the DR value of a NPC to different values based on the mode. - /// - /// The NPC whose DR value you are trying to set. - /// The value DR will be set to in normal mode. - /// The value DR will be set to in Revegeneance mode. - /// The value DR will be set to during the Boss Rush. - public static void DR_NERD(this NPC npc, float normal, float? revengeance = null, float? death = null, float? bossRush = null, bool? customDR = null) - { - npc.Calamity().DR = normal; - - if (bossRush.HasValue && BossRushEvent.BossRushActive) - { - npc.Calamity().DR = bossRush.Value; - } - else if (revengeance.HasValue && CalamityWorld.revenge) - { - npc.Calamity().DR = CalamityWorld.death ? death.Value : revengeance.Value; - } - - if (customDR.HasValue) - npc.Calamity().customDR = true; - } - - public static bool IsAnEnemy(this NPC npc) - { - // Null, inactive, town NPCs, friendlies, statue spawns, "non-enemies" (e.g. butterflies or projectile enemies), - // or anything else with no contact damage (exception: Providence and Celestial Pillars) don't count for rage. - if (npc is null || !npc.active || npc.townNPC || npc.friendly || npc.SpawnedFromStatue || npc.lifeMax <= 5 || (npc.damage <= 5 && npc.lifeMax <= 2000)) - return false; - // Also explicitly exclude dummies and anything with a ridiculous health pool (dummies from Fargo's for example). - if (npc.type == NPCID.TargetDummy || npc.type == NPCType() || npc.lifeMax > 100000000) - return false; - // Finally, exclude boss spawners. - if (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType()) - return false; - - // Anything else is considered a valid enemy target. - return true; - } - - // This function follows the behavior of Adrenaline. - // Vanilla worm segments and Slime God slimes are specifically included. - // Martian Saucers are specifically excluded. - public static bool IsABoss(this NPC npc) - { - if (npc is null || !npc.active) - return false; - if (npc.boss && npc.type != NPCID.MartianSaucerCore) - return true; - if (npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsTail) - return true; - return npc.type == NPCType() || npc.type == NPCType() || - npc.type == NPCType() || npc.type == NPCType(); - } - - public static bool AnyBossNPCS(bool checkForMechs = false) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i] != null) - { - NPC npc = Main.npc[i]; - if (npc.IsABoss()) - { - // Added due to the new mech boss ore progression, return true if any mech is alive and checkForMechs is true, reduces mech boss projectile damage if true. - if (checkForMechs) - return npc.type == NPCID.TheDestroyer || npc.type == NPCID.SkeletronPrime || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer; - return true; - } - } - } - return FindFirstProjectile(ProjectileType()) != -1; - } - - /// - /// Syncs . This exists specifically for AIs manipulated in a global context, as has no netUpdate related hooks. - /// - /// - public static void SyncExtraAI(this NPC npc) + private static readonly FieldInfo waterSpeedField = typeof(NPC).GetField("waterMovementSpeed", BindingFlags.NonPublic | BindingFlags.Instance); + public static void RemoveWaterSlowness(this NPC npc) { - // Don't bother attempting to send packets in singleplayer. - if (Main.netMode == NetmodeID.SinglePlayer) - return; + waterSpeedField.SetValue(npc, 1f); + } - ModPacket packet = CalamityMod.Instance.GetPacket(); - packet.Write((byte)CalamityModMessageType.SyncCalamityNPCAIArray); - packet.Write((byte)npc.whoAmI); + /// + /// Syncs position and velocity from a client to the server. This is to be used in contexts where these things are reliant on client-side information, such as . + /// + /// + public static void SyncMotionToServer(this NPC npc) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + return; - for (int i = 0; i < npc.Calamity().newAI.Length; i++) - packet.Write(npc.Calamity().newAI[i]); + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.SyncNPCMotionDataToServer); + netMessage.Write(npc.whoAmI); + netMessage.WriteVector2(npc.Center); + netMessage.WriteVector2(npc.velocity); + netMessage.Send(); + } - packet.Send(); - } + /// + /// Allows you to set the lifeMax value of a NPC to different values based on the mode. Called instead of npc.lifeMax = X. + /// + /// The NPC whose lifeMax value you are trying to set. + /// The value lifeMax will be set to in normal mode, this value gets doubled automatically in Expert mode. + /// The value lifeMax will be set to in Revegeneance mode. + /// The value lifeMax will be set to during the Boss Rush. + public static void LifeMaxNERB(this NPC npc, int normal, int? revengeance = null, int? bossRush = null) + { + npc.lifeMax = normal; - /// - /// Detects nearby hostile NPCs from a given point - /// - /// The position where we wish to check for nearby NPCs - /// Maximum amount of pixels to check around the origin - /// Whether to ignore tiles when finding a target or not - /// Whether bosses should be prioritized in targetting or not - public static NPC ClosestNPCAt(this Vector2 origin, float maxDistanceToCheck, bool ignoreTiles = true, bool bossPriority = false) - { - NPC closestTarget = null; - float distance = maxDistanceToCheck; - if (bossPriority) - { - bool bossFound = false; - for (int index = 0; index < Main.npc.Length; index++) - { - // If we've found a valid boss target, ignore ALL targets which aren't bosses. - if (bossFound && !(Main.npc[index].boss || Main.npc[index].type == NPCID.WallofFleshEye)) - continue; - if (Main.npc[index].CanBeChasedBy(null, false)) - { - float extraDistance = (Main.npc[index].width / 2) + (Main.npc[index].height / 2); + if (bossRush.HasValue && BossRushEvent.BossRushActive) + { + npc.lifeMax = bossRush.Value; + } + else if (revengeance.HasValue && CalamityWorld.revenge) + { + npc.lifeMax = revengeance.Value; + } + } - bool canHit = true; - if (extraDistance < distance && !ignoreTiles) - canHit = Collision.CanHit(origin, 1, 1, Main.npc[index].Center, 1, 1); + /// + /// Allows you to set the DR value of a NPC to different values based on the mode. + /// + /// The NPC whose DR value you are trying to set. + /// The value DR will be set to in normal mode. + /// The value DR will be set to in Revegeneance mode. + /// The value DR will be set to during the Boss Rush. + public static void DR_NERD(this NPC npc, float normal, float? revengeance = null, float? death = null, float? bossRush = null, bool? customDR = null) + { + npc.Calamity().DR = normal; - if (Vector2.Distance(origin, Main.npc[index].Center) < (distance + extraDistance) && canHit) - { - if (Main.npc[index].boss || Main.npc[index].type == NPCID.WallofFleshEye) - bossFound = true; - distance = Vector2.Distance(origin, Main.npc[index].Center); - closestTarget = Main.npc[index]; - } - } - } - } - else - { - for (int index = 0; index < Main.npc.Length; index++) - { - if (Main.npc[index].CanBeChasedBy(null, false)) - { - float extraDistance = (Main.npc[index].width / 2) + (Main.npc[index].height / 2); + if (bossRush.HasValue && BossRushEvent.BossRushActive) + { + npc.Calamity().DR = bossRush.Value; + } + else if (revengeance.HasValue && CalamityWorld.revenge) + { + npc.Calamity().DR = CalamityWorld.death ? death.Value : revengeance.Value; + } - bool canHit = true; - if (extraDistance < distance && !ignoreTiles) - canHit = Collision.CanHit(origin, 1, 1, Main.npc[index].Center, 1, 1); + if (customDR.HasValue) + npc.Calamity().customDR = true; + } - if (Vector2.Distance(origin, Main.npc[index].Center) < (distance + extraDistance) && canHit) - { - distance = Vector2.Distance(origin, Main.npc[index].Center); - closestTarget = Main.npc[index]; - } - } - } - } - return closestTarget; - } + public static bool IsAnEnemy(this NPC npc) + { + // Null, inactive, town NPCs, friendlies, statue spawns, "non-enemies" (e.g. butterflies or projectile enemies), + // or anything else with no contact damage (exception: Providence and Celestial Pillars) don't count for rage. + if (npc is null || !npc.active || npc.townNPC || npc.friendly || npc.SpawnedFromStatue || npc.lifeMax <= 5 || (npc.damage <= 5 && npc.lifeMax <= 2000)) + return false; + // Also explicitly exclude dummies and anything with a ridiculous health pool (dummies from Fargo's for example). + if (npc.type == NPCID.TargetDummy || npc.type == NPCType() || npc.lifeMax > 100000000) + return false; + // Finally, exclude boss spawners. + if (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType()) + return false; - /// - /// Detects nearby hostile NPCs from a given point with minion support - /// - /// The position where we wish to check for nearby NPCs - /// Maximum amount of pixels to check around the origin - /// Owner of the minion - /// Whether to ignore tiles when finding a target or not - public static NPC MinionHoming(this Vector2 origin, float maxDistanceToCheck, Player owner, bool ignoreTiles = true, bool checksRange = false) - { - if (owner is null || !owner.whoAmI.WithinBounds(Main.maxPlayers) || !owner.MinionAttackTargetNPC.WithinBounds(Main.maxNPCs)) - return ClosestNPCAt(origin, maxDistanceToCheck, ignoreTiles); - NPC npc = Main.npc[owner.MinionAttackTargetNPC]; - bool canHit = true; - if (!ignoreTiles) - canHit = Collision.CanHit(origin, 1, 1, npc.Center, 1, 1); - float extraDistance = (npc.width / 2) + (npc.height / 2); - bool distCheck = Vector2.Distance(origin, npc.Center) < (maxDistanceToCheck + extraDistance) || !checksRange; - if (owner.HasMinionAttackTargetNPC && canHit && distCheck) - { - return npc; - } - return ClosestNPCAt(origin, maxDistanceToCheck, ignoreTiles); - } + // Anything else is considered a valid enemy target. + return true; + } - /// - /// Check if an NPC is organic - /// - /// The NPC attacked. - /// Whether or not the NPC is organic. - public static bool Organic(this NPC target) - { - if ((target.HitSound != SoundID.NPCHit4 && target.HitSound != SoundID.NPCHit41 && target.HitSound != SoundID.NPCHit2 && - target.HitSound != SoundID.NPCHit5 && target.HitSound != SoundID.NPCHit11 && target.HitSound != SoundID.NPCHit30 && - target.HitSound != SoundID.NPCHit34 && target.HitSound != SoundID.NPCHit36 && target.HitSound != SoundID.NPCHit42 && - target.HitSound != SoundID.NPCHit49 && target.HitSound != SoundID.NPCHit52 && target.HitSound != SoundID.NPCHit53 && - target.HitSound != SoundID.NPCHit54 && target.HitSound != null) || target.type == NPCType() || - target.type == NPCType()) - { - return true; - } - return false; - } + // This function follows the behavior of Adrenaline. + // Vanilla worm segments and Slime God slimes are specifically included. + // Martian Saucers are specifically excluded. + public static bool IsABoss(this NPC npc) + { + if (npc is null || !npc.active) + return false; + if (npc.boss && npc.type != NPCID.MartianSaucerCore) + return true; + if (npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsTail) + return true; + return npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCType(); + } - /// - /// Shortcut for the generic boss summon message. - /// - /// The whoAmI index of the summoned npc. - public static void BossAwakenMessage(int npcIndex) - { - // TODO -- this should use MiscUtils DisplayLocalizedText. - string typeName = Main.npc[npcIndex].TypeName; - if (Main.netMode == NetmodeID.SinglePlayer) - { - Main.NewText(Language.GetTextValue("Announcement.HasAwoken", typeName), new Color(175, 75, 255)); - } - else if (Main.netMode == NetmodeID.Server) - { - NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] { Main.npc[npcIndex].GetTypeNetName() }), new Color(175, 75, 255)); - } - } + public static bool AnyBossNPCS(bool checkForMechs = false) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i] != null) + { + NPC npc = Main.npc[i]; + if (npc.IsABoss()) + { + // Added due to the new mech boss ore progression, return true if any mech is alive and checkForMechs is true, reduces mech boss projectile damage if true. + if (checkForMechs) + return npc.type == NPCID.TheDestroyer || npc.type == NPCID.SkeletronPrime || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer; + return true; + } + } + } + return FindFirstProjectile(ProjectileType()) != -1; + } - public static void Inflict246DebuffsNPC(NPC target, int buff, float timeBase = 2f) - { - if (Main.rand.NextBool(4)) - { - target.AddBuff(buff, SecondsToFrames(timeBase * 3f), false); - } - else if (Main.rand.NextBool(2)) - { - target.AddBuff(buff, SecondsToFrames(timeBase * 2f), false); - } - else - { - target.AddBuff(buff, SecondsToFrames(timeBase), false); - } - } + /// + /// Syncs . This exists specifically for AIs manipulated in a global context, as has no netUpdate related hooks. + /// + /// + public static void SyncExtraAI(this NPC npc) + { + // Don't bother attempting to send packets in singleplayer. + if (Main.netMode == NetmodeID.SinglePlayer) + return; - /// Inflict typical exo weapon debuffs. Duration multiplier optional. - /// - /// The NPC attacked. - /// Debuff time multiplier if needed. - /// Inflicts debuffs if they can. - public static void ExoDebuffs(this NPC target, float multiplier = 1f) - { - target.AddBuff(BuffType(), (int)(30 * multiplier)); - target.AddBuff(BuffType(), (int)(120 * multiplier)); - target.AddBuff(BuffID.Frostburn, (int)(150 * multiplier)); - target.AddBuff(BuffID.OnFire, (int)(180 * multiplier)); - } + ModPacket packet = CalamityMod.Instance.GetPacket(); + packet.Write((byte)CalamityModMessageType.SyncCalamityNPCAIArray); + packet.Write((byte)npc.whoAmI); - public static T ModNPC(this NPC npc) where T : ModNPC => npc.modNPC as T; + for (int i = 0; i < npc.Calamity().newAI.Length; i++) + packet.Write(npc.Calamity().newAI[i]); - /// - /// Summons a boss near a particular area depending on a specific spawn context. - /// - /// The relative spawn position. - /// The NPC type ID of the boss to spawn. - /// The context in which the direct spawn position is decided. - /// The optional 1st ai parameter for the boss. - /// The optional 2nd ai parameter for the boss. - /// The optional 3rd ai parameter for the boss. - /// The optional 4th ai parameter for the boss. - public static NPC SpawnBossBetter(Vector2 relativeSpawnPosition, int bossType, BaseBossSpawnContext spawnContext = null, float ai0 = 0f, float ai1 = 0f, float ai2 = 0f, float ai3 = 0f) - { - // Don't spawn entities client-side. - if (Main.netMode == NetmodeID.MultiplayerClient) - return null; + packet.Send(); + } - // Fall back to an exact spawn position if nothing else is inputted. - if (spawnContext is null) - spawnContext = new ExactPositionBossSpawnContext(); + /// + /// Detects nearby hostile NPCs from a given point + /// + /// The position where we wish to check for nearby NPCs + /// Maximum amount of pixels to check around the origin + /// Whether to ignore tiles when finding a target or not + /// Whether bosses should be prioritized in targetting or not + public static NPC ClosestNPCAt(this Vector2 origin, float maxDistanceToCheck, bool ignoreTiles = true, bool bossPriority = false) + { + NPC closestTarget = null; + float distance = maxDistanceToCheck; + if (bossPriority) + { + bool bossFound = false; + for (int index = 0; index < Main.npc.Length; index++) + { + // If we've found a valid boss target, ignore ALL targets which aren't bosses. + if (bossFound && !(Main.npc[index].boss || Main.npc[index].type == NPCID.WallofFleshEye)) + continue; + if (Main.npc[index].CanBeChasedBy(null, false)) + { + float extraDistance = (Main.npc[index].width / 2) + (Main.npc[index].height / 2); - Vector2 spawnPosition = spawnContext.DetermineSpawnPosition(relativeSpawnPosition); - int bossIndex = NPC.NewNPC((int)spawnPosition.X, (int)spawnPosition.Y, bossType, 0, ai0, ai1, ai2, ai3); + bool canHit = true; + if (extraDistance < distance && !ignoreTiles) + canHit = Collision.CanHit(origin, 1, 1, Main.npc[index].Center, 1, 1); - // Broadcast a spawn message to indicate the summoning of the boss if it was successfully spawned. - if (Main.npc.IndexInRange(bossIndex)) - { - BossAwakenMessage(bossIndex); - return Main.npc[bossIndex]; - } - else - return null; - } + if (Vector2.Distance(origin, Main.npc[index].Center) < (distance + extraDistance) && canHit) + { + if (Main.npc[index].boss || Main.npc[index].type == NPCID.WallofFleshEye) + bossFound = true; + distance = Vector2.Distance(origin, Main.npc[index].Center); + closestTarget = Main.npc[index]; + } + } + } + } + else + { + for (int index = 0; index < Main.npc.Length; index++) + { + if (Main.npc[index].CanBeChasedBy(null, false)) + { + float extraDistance = (Main.npc[index].width / 2) + (Main.npc[index].height / 2); - /// - /// Spawns Old Duke on a player. Only works server side, and only works if the player owns a fishing bobber.
- /// Old Duke will spawn above the fishing bobber if one is found. - ///
- /// The index of the player who will spawn Old Duke. - internal static void SpawnOldDuke(int playerIndex) - { - if (Main.netMode != NetmodeID.Server) - return; + bool canHit = true; + if (extraDistance < distance && !ignoreTiles) + canHit = Collision.CanHit(origin, 1, 1, Main.npc[index].Center, 1, 1); - Player player = Main.player[playerIndex]; - if (!player.active || player.dead) - return; + if (Vector2.Distance(origin, Main.npc[index].Center) < (distance + extraDistance) && canHit) + { + distance = Vector2.Distance(origin, Main.npc[index].Center); + closestTarget = Main.npc[index]; + } + } + } + } + return closestTarget; + } - Projectile projectile = null; - for (int i = 0; i < Main.maxProjectiles; i++) - { - projectile = Main.projectile[i]; - if (Main.projectile[i].active && Main.projectile[i].bobber && Main.projectile[i].owner == playerIndex) - { - projectile = Main.projectile[i]; - break; - } - } + /// + /// Detects nearby hostile NPCs from a given point with minion support + /// + /// The position where we wish to check for nearby NPCs + /// Maximum amount of pixels to check around the origin + /// Owner of the minion + /// Whether to ignore tiles when finding a target or not + public static NPC MinionHoming(this Vector2 origin, float maxDistanceToCheck, Player owner, bool ignoreTiles = true, bool checksRange = false) + { + if (owner is null || !owner.whoAmI.WithinBounds(Main.maxPlayers) || !owner.MinionAttackTargetNPC.WithinBounds(Main.maxNPCs)) + return ClosestNPCAt(origin, maxDistanceToCheck, ignoreTiles); + NPC npc = Main.npc[owner.MinionAttackTargetNPC]; + bool canHit = true; + if (!ignoreTiles) + canHit = Collision.CanHit(origin, 1, 1, npc.Center, 1, 1); + float extraDistance = (npc.width / 2) + (npc.height / 2); + bool distCheck = Vector2.Distance(origin, npc.Center) < (maxDistanceToCheck + extraDistance) || !checksRange; + if (owner.HasMinionAttackTargetNPC && canHit && distCheck) + { + return npc; + } + return ClosestNPCAt(origin, maxDistanceToCheck, ignoreTiles); + } - if (projectile is null) - return; + /// + /// Check if an NPC is organic + /// + /// The NPC attacked. + /// Whether or not the NPC is organic. + public static bool Organic(this NPC target) + { + if ((target.HitSound != SoundID.NPCHit4 && target.HitSound != SoundID.NPCHit41 && target.HitSound != SoundID.NPCHit2 && + target.HitSound != SoundID.NPCHit5 && target.HitSound != SoundID.NPCHit11 && target.HitSound != SoundID.NPCHit30 && + target.HitSound != SoundID.NPCHit34 && target.HitSound != SoundID.NPCHit36 && target.HitSound != SoundID.NPCHit42 && + target.HitSound != SoundID.NPCHit49 && target.HitSound != SoundID.NPCHit52 && target.HitSound != SoundID.NPCHit53 && + target.HitSound != SoundID.NPCHit54 && target.HitSound != null) || target.type == NPCType() || + target.type == NPCType()) + { + return true; + } + return false; + } - int oldDuke = NPC.NewNPC((int)projectile.Center.X, (int)projectile.Center.Y + 100, NPCType()); - BossAwakenMessage(oldDuke); - } - } + /// + /// Shortcut for the generic boss summon message. + /// + /// The whoAmI index of the summoned npc. + public static void BossAwakenMessage(int npcIndex) + { + // TODO -- this should use MiscUtils DisplayLocalizedText. + string typeName = Main.npc[npcIndex].TypeName; + if (Main.netMode == NetmodeID.SinglePlayer) + { + Main.NewText(Language.GetTextValue("Announcement.HasAwoken", typeName), new Color(175, 75, 255)); + } + else if (Main.netMode == NetmodeID.Server) + { + NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] { Main.npc[npcIndex].GetTypeNetName() }), new Color(175, 75, 255)); + } + } + + public static void Inflict246DebuffsNPC(NPC target, int buff, float timeBase = 2f) + { + if (Main.rand.NextBool(4)) + { + target.AddBuff(buff, SecondsToFrames(timeBase * 3f), false); + } + else if (Main.rand.NextBool(2)) + { + target.AddBuff(buff, SecondsToFrames(timeBase * 2f), false); + } + else + { + target.AddBuff(buff, SecondsToFrames(timeBase), false); + } + } + + /// Inflict typical exo weapon debuffs. Duration multiplier optional. + /// + /// The NPC attacked. + /// Debuff time multiplier if needed. + /// Inflicts debuffs if they can. + public static void ExoDebuffs(this NPC target, float multiplier = 1f) + { + target.AddBuff(BuffType(), (int)(30 * multiplier)); + target.AddBuff(BuffType(), (int)(120 * multiplier)); + target.AddBuff(BuffID.Frostburn, (int)(150 * multiplier)); + target.AddBuff(BuffID.OnFire, (int)(180 * multiplier)); + } + + public static T ModNPC(this NPC npc) where T : ModNPC => npc.modNPC as T; + + /// + /// Summons a boss near a particular area depending on a specific spawn context. + /// + /// The relative spawn position. + /// The NPC type ID of the boss to spawn. + /// The context in which the direct spawn position is decided. + /// The optional 1st ai parameter for the boss. + /// The optional 2nd ai parameter for the boss. + /// The optional 3rd ai parameter for the boss. + /// The optional 4th ai parameter for the boss. + public static NPC SpawnBossBetter(Vector2 relativeSpawnPosition, int bossType, BaseBossSpawnContext spawnContext = null, float ai0 = 0f, float ai1 = 0f, float ai2 = 0f, float ai3 = 0f) + { + // Don't spawn entities client-side. + if (Main.netMode == NetmodeID.MultiplayerClient) + return null; + + // Fall back to an exact spawn position if nothing else is inputted. + if (spawnContext is null) + spawnContext = new ExactPositionBossSpawnContext(); + + Vector2 spawnPosition = spawnContext.DetermineSpawnPosition(relativeSpawnPosition); + int bossIndex = NPC.NewNPC((int)spawnPosition.X, (int)spawnPosition.Y, bossType, 0, ai0, ai1, ai2, ai3); + + // Broadcast a spawn message to indicate the summoning of the boss if it was successfully spawned. + if (Main.npc.IndexInRange(bossIndex)) + { + BossAwakenMessage(bossIndex); + return Main.npc[bossIndex]; + } + else + return null; + } + + /// + /// Spawns Old Duke on a player. Only works server side, and only works if the player owns a fishing bobber.
+ /// Old Duke will spawn above the fishing bobber if one is found. + ///
+ /// The index of the player who will spawn Old Duke. + internal static void SpawnOldDuke(int playerIndex) + { + if (Main.netMode != NetmodeID.Server) + return; + + Player player = Main.player[playerIndex]; + if (!player.active || player.dead) + return; + + Projectile projectile = null; + for (int i = 0; i < Main.maxProjectiles; i++) + { + projectile = Main.projectile[i]; + if (Main.projectile[i].active && Main.projectile[i].bobber && Main.projectile[i].owner == playerIndex) + { + projectile = Main.projectile[i]; + break; + } + } + + if (projectile is null) + return; + + int oldDuke = NPC.NewNPC((int)projectile.Center.X, (int)projectile.Center.Y + 100, NPCType()); + BossAwakenMessage(oldDuke); + } + } } diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index fb0b29a38a..179882f732 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -11,320 +11,320 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { - public static partial class CalamityUtils - { - #region Damage - // These functions factor in TML 0.11 allDamage to get the player's total damage boost which affects the specified class. - public static float MeleeDamage(this Player player) => player.allDamage + player.meleeDamage - 1f; - public static float RangedDamage(this Player player) => player.allDamage + player.rangedDamage - 1f; - public static float MagicDamage(this Player player) => player.allDamage + player.magicDamage - 1f; - public static float MinionDamage(this Player player) => player.allDamage + player.minionDamage - 1f; - public static float ThrownDamage(this Player player) => player.allDamage + player.thrownDamage - 1f; - public static float RogueDamage(this Player player) => player.allDamage + player.thrownDamage + player.Calamity().throwingDamage - 2f; - public static float AverageDamage(this Player player) => player.allDamage + (player.meleeDamage + player.rangedDamage + player.magicDamage + player.minionDamage + player.Calamity().throwingDamage - 5f) / 5f; - #endregion + public static partial class CalamityUtils + { + #region Damage + // These functions factor in TML 0.11 allDamage to get the player's total damage boost which affects the specified class. + public static float MeleeDamage(this Player player) => player.allDamage + player.meleeDamage - 1f; + public static float RangedDamage(this Player player) => player.allDamage + player.rangedDamage - 1f; + public static float MagicDamage(this Player player) => player.allDamage + player.magicDamage - 1f; + public static float MinionDamage(this Player player) => player.allDamage + player.minionDamage - 1f; + public static float ThrownDamage(this Player player) => player.allDamage + player.thrownDamage - 1f; + public static float RogueDamage(this Player player) => player.allDamage + player.thrownDamage + player.Calamity().throwingDamage - 2f; + public static float AverageDamage(this Player player) => player.allDamage + (player.meleeDamage + player.rangedDamage + player.magicDamage + player.minionDamage + player.Calamity().throwingDamage - 5f) / 5f; + #endregion - public static bool StandingStill(this Player player, float velocity = 0.05f) => player.velocity.Length() < velocity; + public static bool StandingStill(this Player player, float velocity = 0.05f) => player.velocity.Length() < velocity; - #region Location & Biomes - public static bool IsUnderwater(this Player player) => Collision.DrownCollision(player.position, player.width, player.height, player.gravDir); - public static bool InSpace(this Player player) - { - float x = Main.maxTilesX / 4200f; - x *= x; - float spaceGravityMult = (float)((player.position.Y / 16f - (60f + 10f * x)) / (Main.worldSurface / 6.0)); - return spaceGravityMult < 1f; - } - public static bool PillarZone(this Player player) => player.ZoneTowerStardust || player.ZoneTowerSolar || player.ZoneTowerVortex || player.ZoneTowerNebula; - public static bool InCalamity(this Player player) => player.Calamity().ZoneCalamity; - public static bool InSunkenSea(this Player player) => player.Calamity().ZoneSunkenSea; - public static bool InSulphur(this Player player) => player.Calamity().ZoneSulphur; - public static bool InAstral(this Player player, int biome = 0) //1 is above ground, 2 is underground, 3 is desert - { - switch (biome) - { - case 1: - return player.Calamity().ZoneAstral && (player.ZoneOverworldHeight || player.ZoneSkyHeight); + #region Location & Biomes + public static bool IsUnderwater(this Player player) => Collision.DrownCollision(player.position, player.width, player.height, player.gravDir); + public static bool InSpace(this Player player) + { + float x = Main.maxTilesX / 4200f; + x *= x; + float spaceGravityMult = (float)((player.position.Y / 16f - (60f + 10f * x)) / (Main.worldSurface / 6.0)); + return spaceGravityMult < 1f; + } + public static bool PillarZone(this Player player) => player.ZoneTowerStardust || player.ZoneTowerSolar || player.ZoneTowerVortex || player.ZoneTowerNebula; + public static bool InCalamity(this Player player) => player.Calamity().ZoneCalamity; + public static bool InSunkenSea(this Player player) => player.Calamity().ZoneSunkenSea; + public static bool InSulphur(this Player player) => player.Calamity().ZoneSulphur; + public static bool InAstral(this Player player, int biome = 0) //1 is above ground, 2 is underground, 3 is desert + { + switch (biome) + { + case 1: + return player.Calamity().ZoneAstral && (player.ZoneOverworldHeight || player.ZoneSkyHeight); - case 2: - return player.Calamity().ZoneAstral && (player.ZoneDirtLayerHeight || player.ZoneRockLayerHeight || player.ZoneUnderworldHeight); + case 2: + return player.Calamity().ZoneAstral && (player.ZoneDirtLayerHeight || player.ZoneRockLayerHeight || player.ZoneUnderworldHeight); - case 3: - return player.Calamity().ZoneAstral && player.ZoneDesert; + case 3: + return player.Calamity().ZoneAstral && player.ZoneDesert; - default: - return player.Calamity().ZoneAstral; - } - } - public static bool InAbyss(this Player player, int layer = 0) - { - switch (layer) - { - case 1: - return player.Calamity().ZoneAbyssLayer1; + default: + return player.Calamity().ZoneAstral; + } + } + public static bool InAbyss(this Player player, int layer = 0) + { + switch (layer) + { + case 1: + return player.Calamity().ZoneAbyssLayer1; - case 2: - return player.Calamity().ZoneAbyssLayer2; + case 2: + return player.Calamity().ZoneAbyssLayer2; - case 3: - return player.Calamity().ZoneAbyssLayer3; + case 3: + return player.Calamity().ZoneAbyssLayer3; - case 4: - return player.Calamity().ZoneAbyssLayer4; + case 4: + return player.Calamity().ZoneAbyssLayer4; - default: - return player.Calamity().ZoneAbyss; - } - } - #endregion + default: + return player.Calamity().ZoneAbyss; + } + } + #endregion - public static bool InventoryHas(this Player player, params int[] items) - { - return player.inventory.Any(item => items.Contains(item.type)); - } - public static bool PortableStorageHas(this Player player, params int[] items) - { - bool hasItem = false; - if (player.bank.item.Any(item => items.Contains(item.type))) - hasItem = true; - if (player.bank2.item.Any(item => items.Contains(item.type))) - hasItem = true; - if (player.bank3.item.Any(item => items.Contains(item.type))) - hasItem = true; - return hasItem; - } + public static bool InventoryHas(this Player player, params int[] items) + { + return player.inventory.Any(item => items.Contains(item.type)); + } + public static bool PortableStorageHas(this Player player, params int[] items) + { + bool hasItem = false; + if (player.bank.item.Any(item => items.Contains(item.type))) + hasItem = true; + if (player.bank2.item.Any(item => items.Contains(item.type))) + hasItem = true; + if (player.bank3.item.Any(item => items.Contains(item.type))) + hasItem = true; + return hasItem; + } - #region Immunity Frames - /// - /// Gives the player the specified number of immunity frames (or "iframes" for short).
If the player already has more iframes than you want to give them, this function does nothing. - ///
- /// The player who should be given immunity frames. - /// The number of immunity frames to give. - /// Whether or not the player should be blinking during this time. - /// Whether or not any immunity frames were given. - public static bool GiveIFrames(this Player player, int frames, bool blink = false) - { - // Check to see if there is any way for the player to get iframes from this operation. - bool anyIFramesWouldBeGiven = false; - for (int i = 0; i < player.hurtCooldowns.Length; ++i) - if (player.hurtCooldowns[i] < frames) - anyIFramesWouldBeGiven = true; + #region Immunity Frames + /// + /// Gives the player the specified number of immunity frames (or "iframes" for short).
If the player already has more iframes than you want to give them, this function does nothing. + ///
+ /// The player who should be given immunity frames. + /// The number of immunity frames to give. + /// Whether or not the player should be blinking during this time. + /// Whether or not any immunity frames were given. + public static bool GiveIFrames(this Player player, int frames, bool blink = false) + { + // Check to see if there is any way for the player to get iframes from this operation. + bool anyIFramesWouldBeGiven = false; + for (int i = 0; i < player.hurtCooldowns.Length; ++i) + if (player.hurtCooldowns[i] < frames) + anyIFramesWouldBeGiven = true; - // If they would get nothing, don't do it. - if (!anyIFramesWouldBeGiven) - return false; + // If they would get nothing, don't do it. + if (!anyIFramesWouldBeGiven) + return false; - // Apply iframes thoroughly. - player.immune = true; - player.immuneNoBlink = !blink; - player.immuneTime = frames; - for (int i = 0; i < player.hurtCooldowns.Length; ++i) - if (player.hurtCooldowns[i] < frames) - player.hurtCooldowns[i] = frames; - return true; - } + // Apply iframes thoroughly. + player.immune = true; + player.immuneNoBlink = !blink; + player.immuneTime = frames; + for (int i = 0; i < player.hurtCooldowns.Length; ++i) + if (player.hurtCooldowns[i] < frames) + player.hurtCooldowns[i] = frames; + return true; + } - /// - /// Removes all immunity frames (or "iframes" for short) from the specified player immediately. - /// - /// The player whose iframes should be removed. - public static void RemoveAllIFrames(this Player player) - { - player.immune = false; - player.immuneNoBlink = false; - player.immuneTime = 0; - for (int i = 0; i < player.hurtCooldowns.Length; ++i) - player.hurtCooldowns[i] = 0; - } - #endregion + /// + /// Removes all immunity frames (or "iframes" for short) from the specified player immediately. + /// + /// The player whose iframes should be removed. + public static void RemoveAllIFrames(this Player player) + { + player.immune = false; + player.immuneNoBlink = false; + player.immuneTime = 0; + for (int i = 0; i < player.hurtCooldowns.Length; ++i) + player.hurtCooldowns[i] = 0; + } + #endregion - #region Rage and Adrenaline - /// - /// Returns the damage multiplier Adrenaline Mode provides for the given player. - /// - /// The player whose Adrenaline damage should be calculated. - /// Adrenaline damage multiplier. 1.0 would be no change. - public static double GetAdrenalineDamage(this CalamityPlayer mp) - { - double adrenalineBoost = CalamityPlayer.AdrenalineDamageBoost; - if (mp.adrenalineBoostOne) - adrenalineBoost += CalamityPlayer.AdrenalineDamagePerBooster; - if (mp.adrenalineBoostTwo) - adrenalineBoost += CalamityPlayer.AdrenalineDamagePerBooster; - if (mp.adrenalineBoostThree) - adrenalineBoost += CalamityPlayer.AdrenalineDamagePerBooster; + #region Rage and Adrenaline + /// + /// Returns the damage multiplier Adrenaline Mode provides for the given player. + /// + /// The player whose Adrenaline damage should be calculated. + /// Adrenaline damage multiplier. 1.0 would be no change. + public static double GetAdrenalineDamage(this CalamityPlayer mp) + { + double adrenalineBoost = CalamityPlayer.AdrenalineDamageBoost; + if (mp.adrenalineBoostOne) + adrenalineBoost += CalamityPlayer.AdrenalineDamagePerBooster; + if (mp.adrenalineBoostTwo) + adrenalineBoost += CalamityPlayer.AdrenalineDamagePerBooster; + if (mp.adrenalineBoostThree) + adrenalineBoost += CalamityPlayer.AdrenalineDamagePerBooster; - return adrenalineBoost; - } + return adrenalineBoost; + } - /// - /// Applies Rage and Adrenaline to the given damage multiplier. The values controlling the so-called "Rippers" can be found in CalamityPlayer. - /// - /// The CalamityPlayer who may or may not be using Rage or Adrenaline. - /// A reference to the current in-use damage multiplier. This will be increased in-place. - public static void ApplyRippersToDamage(CalamityPlayer mp, bool trueMelee, ref double damageMult) - { - // Reduce how much true melee benefits from Rage and Adrenaline. - double rageAndAdrenalineTrueMeleeDamageMult = 0.5; + /// + /// Applies Rage and Adrenaline to the given damage multiplier. The values controlling the so-called "Rippers" can be found in CalamityPlayer. + /// + /// The CalamityPlayer who may or may not be using Rage or Adrenaline. + /// A reference to the current in-use damage multiplier. This will be increased in-place. + public static void ApplyRippersToDamage(CalamityPlayer mp, bool trueMelee, ref double damageMult) + { + // Reduce how much true melee benefits from Rage and Adrenaline. + double rageAndAdrenalineTrueMeleeDamageMult = 0.5; - // Rage and Adrenaline now stack additively with no special cases. - if (mp.rageModeActive) - damageMult += trueMelee ? mp.RageDamageBoost * rageAndAdrenalineTrueMeleeDamageMult : mp.RageDamageBoost; - if (mp.adrenalineModeActive) - damageMult += trueMelee ? mp.GetAdrenalineDamage() * rageAndAdrenalineTrueMeleeDamageMult : mp.GetAdrenalineDamage(); - } - #endregion + // Rage and Adrenaline now stack additively with no special cases. + if (mp.rageModeActive) + damageMult += trueMelee ? mp.RageDamageBoost * rageAndAdrenalineTrueMeleeDamageMult : mp.RageDamageBoost; + if (mp.adrenalineModeActive) + damageMult += trueMelee ? mp.GetAdrenalineDamage() * rageAndAdrenalineTrueMeleeDamageMult : mp.GetAdrenalineDamage(); + } + #endregion - #region Cooldowns - public static bool HasCooldown(this Player p, string id) - { - if (p is null) - return false; - CalamityPlayer modPlayer = p.Calamity(); - return !(modPlayer is null) && modPlayer.cooldowns.ContainsKey(id); - } + #region Cooldowns + public static bool HasCooldown(this Player p, string id) + { + if (p is null) + return false; + CalamityPlayer modPlayer = p.Calamity(); + return !(modPlayer is null) && modPlayer.cooldowns.ContainsKey(id); + } - /// - /// Applies the specified cooldown to the player, creating a new instance automatically.
- /// By default, overwrites existing instances of this cooldown, but this behavior can be disabled. - ///
- /// The player to whom the cooldown should be applied. - /// The string ID of the cooldown to apply. This is referenced against the Cooldown Registry. - /// The duration, in frames, of this instance of the cooldown. - /// Whether or not to overwrite any existing instances of this cooldown. Defaults to true. - /// The cooldown instance which was created. Note the cooldown is always created, but may not be necessarily applied to the player. - public static CooldownInstance AddCooldown(this Player p, string id, int duration, bool overwrite = true) - { - var cd = CooldownRegistry.Get(id); - CooldownInstance instance = new CooldownInstance(p, cd, duration); + /// + /// Applies the specified cooldown to the player, creating a new instance automatically.
+ /// By default, overwrites existing instances of this cooldown, but this behavior can be disabled. + ///
+ /// The player to whom the cooldown should be applied. + /// The string ID of the cooldown to apply. This is referenced against the Cooldown Registry. + /// The duration, in frames, of this instance of the cooldown. + /// Whether or not to overwrite any existing instances of this cooldown. Defaults to true. + /// The cooldown instance which was created. Note the cooldown is always created, but may not be necessarily applied to the player. + public static CooldownInstance AddCooldown(this Player p, string id, int duration, bool overwrite = true) + { + var cd = CooldownRegistry.Get(id); + CooldownInstance instance = new CooldownInstance(p, cd, duration); - bool alreadyHasCooldown = p.HasCooldown(id); - if (!alreadyHasCooldown || overwrite) - { - CalamityPlayer mp = p.Calamity(); - mp.cooldowns[id] = instance; - mp.SyncCooldownAddition(Main.netMode == NetmodeID.Server, instance); - } + bool alreadyHasCooldown = p.HasCooldown(id); + if (!alreadyHasCooldown || overwrite) + { + CalamityPlayer mp = p.Calamity(); + mp.cooldowns[id] = instance; + mp.SyncCooldownAddition(Main.netMode == NetmodeID.Server, instance); + } - return instance; - } + return instance; + } - /// - /// Applies the specified cooldown to the player, creating a new instance automatically.
- /// By default, overwrites existing instances of this cooldown, but this behavior can be disabled. - ///
- /// The player to whom the cooldown should be applied. - /// The string ID of the cooldown to apply. This is referenced against the Cooldown Registry. - /// The duration, in frames, of this instance of the cooldown. - /// Whether or not to overwrite any existing instances of this cooldown. Defaults to true. - /// Arbitrary extra arguments to pass to the CooldownHandler constructor via reflection. - /// The cooldown instance which was created. Note the cooldown is always created, but may not be necessarily applied to the player. - public static CooldownInstance AddCooldown(this Player p, string id, int duration, bool overwrite = true, params object[] handlerArgs) - { - var cd = CooldownRegistry.Get(id); - CooldownInstance instance = new CooldownInstance(p, cd, duration, handlerArgs); + /// + /// Applies the specified cooldown to the player, creating a new instance automatically.
+ /// By default, overwrites existing instances of this cooldown, but this behavior can be disabled. + ///
+ /// The player to whom the cooldown should be applied. + /// The string ID of the cooldown to apply. This is referenced against the Cooldown Registry. + /// The duration, in frames, of this instance of the cooldown. + /// Whether or not to overwrite any existing instances of this cooldown. Defaults to true. + /// Arbitrary extra arguments to pass to the CooldownHandler constructor via reflection. + /// The cooldown instance which was created. Note the cooldown is always created, but may not be necessarily applied to the player. + public static CooldownInstance AddCooldown(this Player p, string id, int duration, bool overwrite = true, params object[] handlerArgs) + { + var cd = CooldownRegistry.Get(id); + CooldownInstance instance = new CooldownInstance(p, cd, duration, handlerArgs); - bool alreadyHasCooldown = p.HasCooldown(id); - if (!alreadyHasCooldown || overwrite) - p.Calamity().cooldowns[id] = instance; + bool alreadyHasCooldown = p.HasCooldown(id); + if (!alreadyHasCooldown || overwrite) + p.Calamity().cooldowns[id] = instance; - return instance; - } + return instance; + } - public static IList GetDisplayedCooldowns(this Player p) - { - List ret = new List(16); - if (p is null || p.Calamity() is null) - return ret; + public static IList GetDisplayedCooldowns(this Player p) + { + List ret = new List(16); + if (p is null || p.Calamity() is null) + return ret; - foreach (CooldownInstance instance in p.Calamity().cooldowns.Values) - if (instance.handler.ShouldDisplay) - ret.Add(instance); - return ret; - } - #endregion + foreach (CooldownInstance instance in p.Calamity().cooldowns.Values) + if (instance.handler.ShouldDisplay) + ret.Add(instance); + return ret; + } + #endregion - #region Debuffs - public static void Inflict246DebuffsPvp(Player target, int buff, float timeBase = 2f) - { - if (Main.rand.NextBool(4)) - { - target.AddBuff(buff, SecondsToFrames(timeBase * 3f), false); - } - else if (Main.rand.NextBool(2)) - { - target.AddBuff(buff, SecondsToFrames(timeBase * 2f), false); - } - else - { - target.AddBuff(buff, SecondsToFrames(timeBase), false); - } - } + #region Debuffs + public static void Inflict246DebuffsPvp(Player target, int buff, float timeBase = 2f) + { + if (Main.rand.NextBool(4)) + { + target.AddBuff(buff, SecondsToFrames(timeBase * 3f), false); + } + else if (Main.rand.NextBool(2)) + { + target.AddBuff(buff, SecondsToFrames(timeBase * 2f), false); + } + else + { + target.AddBuff(buff, SecondsToFrames(timeBase), false); + } + } - /// - /// Inflict typical exo weapon debuffs in pvp. - /// - /// The Player attacked. - /// Debuff time multiplier if needed. - /// Inflicts debuffs if the target isn't immune. - public static void ExoDebuffs(this Player target, float multiplier = 1f) - { - target.AddBuff(BuffType(), (int)(30 * multiplier)); - target.AddBuff(BuffType(), (int)(120 * multiplier)); - target.AddBuff(BuffID.Frostburn, (int)(150 * multiplier)); - target.AddBuff(BuffID.OnFire, (int)(180 * multiplier)); - } - #endregion + /// + /// Inflict typical exo weapon debuffs in pvp. + /// + /// The Player attacked. + /// Debuff time multiplier if needed. + /// Inflicts debuffs if the target isn't immune. + public static void ExoDebuffs(this Player target, float multiplier = 1f) + { + target.AddBuff(BuffType(), (int)(30 * multiplier)); + target.AddBuff(BuffType(), (int)(120 * multiplier)); + target.AddBuff(BuffID.Frostburn, (int)(150 * multiplier)); + target.AddBuff(BuffID.OnFire, (int)(180 * multiplier)); + } + #endregion - /// - /// Checks if the player is ontop of solid ground. May also check for solid ground for X tiles in front of them - /// - /// The Player whose position is being checked - /// How many tiles in front of the player to check - /// How many tiles above every checked tile are checked for non-solid ground - public static bool CheckSolidGround(this Player player, int solidGroundAhead = 0, int airExposureNeeded = 0) - { - if (player.velocity.Y != 0) //Player gotta be standing still in any case - return false; + /// + /// Checks if the player is ontop of solid ground. May also check for solid ground for X tiles in front of them + /// + /// The Player whose position is being checked + /// How many tiles in front of the player to check + /// How many tiles above every checked tile are checked for non-solid ground + public static bool CheckSolidGround(this Player player, int solidGroundAhead = 0, int airExposureNeeded = 0) + { + if (player.velocity.Y != 0) //Player gotta be standing still in any case + return false; - Tile checkedTile; - bool ConditionMet = true; + Tile checkedTile; + bool ConditionMet = true; - for (int i = 0; i <= solidGroundAhead; i++) //Check i tiles in front of the player - { - ConditionMet = Main.tile[(int)player.Center.X / 16 + player.direction * i, (int)(player.position.Y + (float)player.height - 1f) / 16 + 1].IsTileSolidGround(); - if (!ConditionMet) - return ConditionMet; + for (int i = 0; i <= solidGroundAhead; i++) //Check i tiles in front of the player + { + ConditionMet = Main.tile[(int)player.Center.X / 16 + player.direction * i, (int)(player.position.Y + (float)player.height - 1f) / 16 + 1].IsTileSolidGround(); + if (!ConditionMet) + return ConditionMet; - for (int j = 1; j <= airExposureNeeded; j++) //Check j tiles ontop of each checked tiles for non-solid ground - { - checkedTile = Main.tile[(int)player.Center.X / 16 + player.direction * i, (int)(player.position.Y + (float)player.height - 1f) / 16 + 1 - j]; + for (int j = 1; j <= airExposureNeeded; j++) //Check j tiles ontop of each checked tiles for non-solid ground + { + checkedTile = Main.tile[(int)player.Center.X / 16 + player.direction * i, (int)(player.position.Y + (float)player.height - 1f) / 16 + 1 - j]; - ConditionMet = !(checkedTile != null && checkedTile.nactive() && Main.tileSolid[checkedTile.type]); //IsTileSolidGround minus the ground part, to avoid platforms and other half solid tiles messing it up - if (!ConditionMet) - return ConditionMet; - } - } - return ConditionMet; - } + ConditionMet = !(checkedTile != null && checkedTile.nactive() && Main.tileSolid[checkedTile.type]); //IsTileSolidGround minus the ground part, to avoid platforms and other half solid tiles messing it up + if (!ConditionMet) + return ConditionMet; + } + } + return ConditionMet; + } - /// - /// Makes the given player send the given packet to all appropriate receivers.
- /// If server is false, the packet is sent only to the multiplayer host.
- /// If server is true, the packet is sent to all clients except the player it pertains to. - ///
- /// The player to whom the packet's data pertains. - /// The packet to send with certain parameters. - /// True if a dedicated server is broadcasting information to all players. - public static void SendPacket(this Player player, ModPacket packet, bool server) - { - // Client: Send the packet only to the host. - if (!server) - packet.Send(); + /// + /// Makes the given player send the given packet to all appropriate receivers.
+ /// If server is false, the packet is sent only to the multiplayer host.
+ /// If server is true, the packet is sent to all clients except the player it pertains to. + ///
+ /// The player to whom the packet's data pertains. + /// The packet to send with certain parameters. + /// True if a dedicated server is broadcasting information to all players. + public static void SendPacket(this Player player, ModPacket packet, bool server) + { + // Client: Send the packet only to the host. + if (!server) + packet.Send(); - // Server: Send the packet to every OTHER client. - else - packet.Send(-1, player.whoAmI); - } - } + // Server: Send the packet to every OTHER client. + else + packet.Send(-1, player.whoAmI); + } + } } diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index b84b6418ee..350bd7dcd3 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -11,463 +11,463 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { - public static partial class CalamityUtils - { - public static int CountProjectiles(int Type) => Main.projectile.Count(proj => proj.type == Type && proj.active); + public static partial class CalamityUtils + { + public static int CountProjectiles(int Type) => Main.projectile.Count(proj => proj.type == Type && proj.active); - public static int CountHookProj() => Main.projectile.Count(proj => Main.projHook[proj.type] && proj.ai[0] == 2f && proj.active && proj.owner == Main.myPlayer); + public static int CountHookProj() => Main.projectile.Count(proj => Main.projHook[proj.type] && proj.ai[0] == 2f && proj.active && proj.owner == Main.myPlayer); - public static bool FinalExtraUpdate(this Projectile proj) => proj.numUpdates == -1; + public static bool FinalExtraUpdate(this Projectile proj) => proj.numUpdates == -1; - public static bool IsSummon(this Projectile proj) => proj.minion || proj.sentry || CalamityLists.projectileMinionList.Contains(proj.type) || ProjectileID.Sets.MinionShot[proj.type] || ProjectileID.Sets.SentryShot[proj.type]; + public static bool IsSummon(this Projectile proj) => proj.minion || proj.sentry || CalamityLists.projectileMinionList.Contains(proj.type) || ProjectileID.Sets.MinionShot[proj.type] || ProjectileID.Sets.SentryShot[proj.type]; - public static T ModProjectile(this Projectile projectile) where T : ModProjectile - { - return projectile.modProjectile as T; - } + public static T ModProjectile(this Projectile projectile) where T : ModProjectile + { + return projectile.modProjectile as T; + } - public static Projectile FindProjectileByIdentity(int identity, int ownerIndex) - { - // If in singleplayer, simply return the projectile at the designated index, as singleplayer will never have mismatching indices. - if (Main.netMode == NetmodeID.SinglePlayer) - return Main.projectile[identity]; + public static Projectile FindProjectileByIdentity(int identity, int ownerIndex) + { + // If in singleplayer, simply return the projectile at the designated index, as singleplayer will never have mismatching indices. + if (Main.netMode == NetmodeID.SinglePlayer) + return Main.projectile[identity]; - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].identity != identity || Main.projectile[i].owner != ownerIndex || !Main.projectile[i].active) - continue; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].identity != identity || Main.projectile[i].owner != ownerIndex || !Main.projectile[i].active) + continue; - return Main.projectile[i]; - } - return null; - } + return Main.projectile[i]; + } + return null; + } - // NOTE - Do not under any circumstance use these predictive methods for enemies or bosses. It is intended for minions and player-created projectiles. - // Due to its extremely precise nature, it will have little openings that allow players to react without dashing through the enemy. - // The results will be neither fun nor fair. + // NOTE - Do not under any circumstance use these predictive methods for enemies or bosses. It is intended for minions and player-created projectiles. + // Due to its extremely precise nature, it will have little openings that allow players to react without dashing through the enemy. + // The results will be neither fun nor fair. - /// - /// Calculates a velocity that approximately predicts where some target will be in the future based on Euler's Method. - /// - /// The starting position from where the movement is calculated. - /// The position of the target to hit. - /// The velocity of the target to hit. - /// The speed of the predictive velocity. - /// The number of iterations to perform. The more iterations, the more precise the results are. - public static Vector2 CalculatePredictiveAimToTarget(Vector2 startingPosition, Vector2 targetPosition, Vector2 targetVelocity, float shootSpeed, int iterations = 4) - { - float previousTimeToReachDestination = 0f; - Vector2 currentTargetPosition = targetPosition; - for (int i = 0; i < iterations; i++) - { - float timeToReachDestination = Vector2.Distance(startingPosition, currentTargetPosition) / shootSpeed; - currentTargetPosition += targetVelocity * (timeToReachDestination - previousTimeToReachDestination); - previousTimeToReachDestination = timeToReachDestination; - } - return (currentTargetPosition - startingPosition).SafeNormalize(Vector2.UnitY) * shootSpeed; - } + /// + /// Calculates a velocity that approximately predicts where some target will be in the future based on Euler's Method. + /// + /// The starting position from where the movement is calculated. + /// The position of the target to hit. + /// The velocity of the target to hit. + /// The speed of the predictive velocity. + /// The number of iterations to perform. The more iterations, the more precise the results are. + public static Vector2 CalculatePredictiveAimToTarget(Vector2 startingPosition, Vector2 targetPosition, Vector2 targetVelocity, float shootSpeed, int iterations = 4) + { + float previousTimeToReachDestination = 0f; + Vector2 currentTargetPosition = targetPosition; + for (int i = 0; i < iterations; i++) + { + float timeToReachDestination = Vector2.Distance(startingPosition, currentTargetPosition) / shootSpeed; + currentTargetPosition += targetVelocity * (timeToReachDestination - previousTimeToReachDestination); + previousTimeToReachDestination = timeToReachDestination; + } + return (currentTargetPosition - startingPosition).SafeNormalize(Vector2.UnitY) * shootSpeed; + } - /// - /// Calculates a velocity that approximately predicts where some target will be in the future based on Euler's Method. - /// - /// The starting position from where the movement is calculated. - /// The target to hit. - /// The speed of the predictive velocity. - /// The number of iterations to perform. The more iterations, the more precise the results are. - public static Vector2 CalculatePredictiveAimToTarget(Vector2 startingPosition, Entity target, float shootSpeed, int iterations = 4) - { - return CalculatePredictiveAimToTarget(startingPosition, target.Center, target.velocity, shootSpeed, iterations); - } + /// + /// Calculates a velocity that approximately predicts where some target will be in the future based on Euler's Method. + /// + /// The starting position from where the movement is calculated. + /// The target to hit. + /// The speed of the predictive velocity. + /// The number of iterations to perform. The more iterations, the more precise the results are. + public static Vector2 CalculatePredictiveAimToTarget(Vector2 startingPosition, Entity target, float shootSpeed, int iterations = 4) + { + return CalculatePredictiveAimToTarget(startingPosition, target.Center, target.velocity, shootSpeed, iterations); + } - /// - /// Makes a projectile home in such a way that it attempts to fractionally move towards a target's expected future position. - /// This is based on the results of the method. - /// - /// The projectile that should home. - /// The target. - /// The inertia of the movement change. - public static Vector2 SuperhomeTowardsTarget(this Projectile projectile, NPC target, float homingSpeed, float inertia) - { - Vector2 idealVelocity = CalculatePredictiveAimToTarget(projectile.Center, target, homingSpeed); - return (projectile.velocity * (inertia - 1f) + idealVelocity) / inertia; - } + /// + /// Makes a projectile home in such a way that it attempts to fractionally move towards a target's expected future position. + /// This is based on the results of the method. + /// + /// The projectile that should home. + /// The target. + /// The inertia of the movement change. + public static Vector2 SuperhomeTowardsTarget(this Projectile projectile, NPC target, float homingSpeed, float inertia) + { + Vector2 idealVelocity = CalculatePredictiveAimToTarget(projectile.Center, target, homingSpeed); + return (projectile.velocity * (inertia - 1f) + idealVelocity) / inertia; + } - public static void KillAllHostileProjectiles() - { - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active && projectile.hostile && !projectile.friendly && projectile.damage > 0) - { - projectile.Kill(); - } - } - } + public static void KillAllHostileProjectiles() + { + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active && projectile.hostile && !projectile.friendly && projectile.damage > 0) + { + projectile.Kill(); + } + } + } - public static void KillShootProjectiles(bool shouldBreak, int projType, Player player) - { - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile proj = Main.projectile[x]; - if (proj.active && proj.owner == player.whoAmI && proj.type == projType) - { - proj.Kill(); - if (shouldBreak) - break; - } - } - } + public static void KillShootProjectiles(bool shouldBreak, int projType, Player player) + { + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile proj = Main.projectile[x]; + if (proj.active && proj.owner == player.whoAmI && proj.type == projType) + { + proj.Kill(); + if (shouldBreak) + break; + } + } + } - public static void KillShootProjectileMany(Player player, params int[] projTypes) - { - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile proj = Main.projectile[x]; - if (proj.active && proj.owner == player.whoAmI && projTypes.Contains(proj.type)) - { - proj.Kill(); - } - } - } + public static void KillShootProjectileMany(Player player, params int[] projTypes) + { + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile proj = Main.projectile[x]; + if (proj.active && proj.owner == player.whoAmI && projTypes.Contains(proj.type)) + { + proj.Kill(); + } + } + } - public static int FindFirstProjectile(int Type) - { - int index = -1; - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile proj = Main.projectile[x]; - if (proj.active && proj.type == Type) - { - index = x; - break; - } - } - return index; - } + public static int FindFirstProjectile(int Type) + { + int index = -1; + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile proj = Main.projectile[x]; + if (proj.active && proj.type == Type) + { + index = x; + break; + } + } + return index; + } - public static void OnlyOneSentry(Player player, int Type) - { - int existingTurrets = player.ownedProjectileCounts[Type]; - if (existingTurrets > 0) - { - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].type == Type && - Main.projectile[i].owner == player.whoAmI && - Main.projectile[i].active) - { - Main.projectile[i].Kill(); - existingTurrets--; - if (existingTurrets <= 0) - break; - } - } - } - } + public static void OnlyOneSentry(Player player, int Type) + { + int existingTurrets = player.ownedProjectileCounts[Type]; + if (existingTurrets > 0) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type == Type && + Main.projectile[i].owner == player.whoAmI && + Main.projectile[i].active) + { + Main.projectile[i].Kill(); + existingTurrets--; + if (existingTurrets <= 0) + break; + } + } + } + } - public static Projectile ProjectileRain(Vector2 targetPos, float xLimit, float xVariance, float yLimitLower, float yLimitUpper, float projSpeed, int projType, int damage, float knockback, int owner) - { - float x = targetPos.X + Main.rand.NextFloat(-xLimit, xLimit); - if (projType == ProjectileType()) - x = targetPos.X + xLimit; - float y = targetPos.Y - Main.rand.NextFloat(yLimitLower, yLimitUpper); - Vector2 source = new Vector2(x, y); - Vector2 velocity = targetPos - source; - velocity.X += Main.rand.NextFloat(-xVariance, xVariance); - float speed = projSpeed; - float targetDist = velocity.Length(); - targetDist = speed / targetDist; - velocity.X *= targetDist; - velocity.Y *= targetDist; - return Projectile.NewProjectileDirect(source, velocity, projType, damage, knockback, owner); - } + public static Projectile ProjectileRain(Vector2 targetPos, float xLimit, float xVariance, float yLimitLower, float yLimitUpper, float projSpeed, int projType, int damage, float knockback, int owner) + { + float x = targetPos.X + Main.rand.NextFloat(-xLimit, xLimit); + if (projType == ProjectileType()) + x = targetPos.X + xLimit; + float y = targetPos.Y - Main.rand.NextFloat(yLimitLower, yLimitUpper); + Vector2 source = new Vector2(x, y); + Vector2 velocity = targetPos - source; + velocity.X += Main.rand.NextFloat(-xVariance, xVariance); + float speed = projSpeed; + float targetDist = velocity.Length(); + targetDist = speed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; + return Projectile.NewProjectileDirect(source, velocity, projType, damage, knockback, owner); + } - public static Projectile ProjectileBarrage(Vector2 originVec, Vector2 targetPos, bool fromRight, float xOffsetMin, float xOffsetMax, float yOffsetMin, float yOffsetMax, float projSpeed, int projType, int damage, float knockback, int owner, bool clamped = false, float inaccuracyOffset = 5f) - { - float xPos = originVec.X + Main.rand.NextFloat(xOffsetMin, xOffsetMax) * fromRight.ToDirectionInt(); - float yPos = originVec.Y + Main.rand.NextFloat(yOffsetMin, yOffsetMax) * Main.rand.NextBool().ToDirectionInt(); - Vector2 spawnPosition = new Vector2(xPos, yPos); - Vector2 velocity = targetPos - spawnPosition; - velocity.X += Main.rand.NextFloat(-inaccuracyOffset, inaccuracyOffset); - velocity.Y += Main.rand.NextFloat(-inaccuracyOffset, inaccuracyOffset); - velocity.Normalize(); - velocity *= projSpeed * (clamped ? 150f : 1f); - //This clamp means the spawned projectiles only go at diagnals and are not accurate - if (clamped) - { - velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f); - velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f); - } - return Projectile.NewProjectileDirect(spawnPosition, velocity, projType, damage, knockback, owner); - } + public static Projectile ProjectileBarrage(Vector2 originVec, Vector2 targetPos, bool fromRight, float xOffsetMin, float xOffsetMax, float yOffsetMin, float yOffsetMax, float projSpeed, int projType, int damage, float knockback, int owner, bool clamped = false, float inaccuracyOffset = 5f) + { + float xPos = originVec.X + Main.rand.NextFloat(xOffsetMin, xOffsetMax) * fromRight.ToDirectionInt(); + float yPos = originVec.Y + Main.rand.NextFloat(yOffsetMin, yOffsetMax) * Main.rand.NextBool().ToDirectionInt(); + Vector2 spawnPosition = new Vector2(xPos, yPos); + Vector2 velocity = targetPos - spawnPosition; + velocity.X += Main.rand.NextFloat(-inaccuracyOffset, inaccuracyOffset); + velocity.Y += Main.rand.NextFloat(-inaccuracyOffset, inaccuracyOffset); + velocity.Normalize(); + velocity *= projSpeed * (clamped ? 150f : 1f); + //This clamp means the spawned projectiles only go at diagnals and are not accurate + if (clamped) + { + velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f); + velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f); + } + return Projectile.NewProjectileDirect(spawnPosition, velocity, projType, damage, knockback, owner); + } - public static int DamageSoftCap(double dmgInput, int cap) - { - // If the incoming damage is less than the cap, don't do anything. - if (dmgInput < cap) - return (int)dmgInput; + public static int DamageSoftCap(double dmgInput, int cap) + { + // If the incoming damage is less than the cap, don't do anything. + if (dmgInput < cap) + return (int)dmgInput; - // Ratio of how far over the cap you are. - // This is a value from 1.0 upwards to theoretically infinity. - double overpoweredRatio = dmgInput / cap; + // Ratio of how far over the cap you are. + // This is a value from 1.0 upwards to theoretically infinity. + double overpoweredRatio = dmgInput / cap; - // Formula which reduces how "overpowered" you are to a reasonable level. - double cappedRatio = Math.Pow(overpoweredRatio, 0.5) / 1.25 + 0.2; + // Formula which reduces how "overpowered" you are to a reasonable level. + double cappedRatio = Math.Pow(overpoweredRatio, 0.5) / 1.25 + 0.2; - // Take the reduced ratio and multiply the cap by it to get the final capped damage. - return (int)(cap * cappedRatio); - } + // Take the reduced ratio and multiply the cap by it to get the final capped damage. + return (int)(cap * cappedRatio); + } - public static Vector2 RandomVelocity(float directionMult, float speedLowerLimit, float speedCap, float speedMult = 0.1f) - { - Vector2 velocity = new Vector2(Main.rand.NextFloat(-directionMult, directionMult), Main.rand.NextFloat(-directionMult, directionMult)); - //Rerolling to avoid dividing by zero - while (velocity.X == 0f && velocity.Y == 0f) - { - velocity = new Vector2(Main.rand.NextFloat(-directionMult, directionMult), Main.rand.NextFloat(-directionMult, directionMult)); - } - velocity.Normalize(); - velocity *= Main.rand.NextFloat(speedLowerLimit, speedCap) * speedMult; - return velocity; - } + public static Vector2 RandomVelocity(float directionMult, float speedLowerLimit, float speedCap, float speedMult = 0.1f) + { + Vector2 velocity = new Vector2(Main.rand.NextFloat(-directionMult, directionMult), Main.rand.NextFloat(-directionMult, directionMult)); + //Rerolling to avoid dividing by zero + while (velocity.X == 0f && velocity.Y == 0f) + { + velocity = new Vector2(Main.rand.NextFloat(-directionMult, directionMult), Main.rand.NextFloat(-directionMult, directionMult)); + } + velocity.Normalize(); + velocity *= Main.rand.NextFloat(speedLowerLimit, speedCap) * speedMult; + return velocity; + } - public static void MinionAntiClump(this Projectile projectile, float pushForce = 0.05f) - { - for (int k = 0; k < Main.maxProjectiles; k++) - { - Projectile otherProj = Main.projectile[k]; - // Short circuits to make the loop as fast as possible - if (!otherProj.active || otherProj.owner != projectile.owner || !otherProj.minion || k == projectile.whoAmI) - continue; + public static void MinionAntiClump(this Projectile projectile, float pushForce = 0.05f) + { + for (int k = 0; k < Main.maxProjectiles; k++) + { + Projectile otherProj = Main.projectile[k]; + // Short circuits to make the loop as fast as possible + if (!otherProj.active || otherProj.owner != projectile.owner || !otherProj.minion || k == projectile.whoAmI) + continue; - // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. - bool sameProjType = otherProj.type == projectile.type; - float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y); - if (sameProjType && taxicabDist < projectile.width) - { - if (projectile.position.X < otherProj.position.X) - projectile.velocity.X -= pushForce; - else - projectile.velocity.X += pushForce; + // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. + bool sameProjType = otherProj.type == projectile.type; + float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y); + if (sameProjType && taxicabDist < projectile.width) + { + if (projectile.position.X < otherProj.position.X) + projectile.velocity.X -= pushForce; + else + projectile.velocity.X += pushForce; - if (projectile.position.Y < otherProj.position.Y) - projectile.velocity.Y -= pushForce; - else - projectile.velocity.Y += pushForce; - } - } - } + if (projectile.position.Y < otherProj.position.Y) + projectile.velocity.Y -= pushForce; + else + projectile.velocity.Y += pushForce; + } + } + } - public static bool DrawBeam(this Projectile projectile, float length, float spacer, Color lightColor, Texture2D texture = null, bool curve = false) - { - if (texture is null) - texture = Main.projectileTexture[projectile.type]; + public static bool DrawBeam(this Projectile projectile, float length, float spacer, Color lightColor, Texture2D texture = null, bool curve = false) + { + if (texture is null) + texture = Main.projectileTexture[projectile.type]; - float widthOffset = (float)(texture.Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - float heightOffset = (float)(projectile.height / 2); - Vector2 origin = new Vector2(widthOffset, heightOffset); - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle roughScreenBounds = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(roughScreenBounds)) - { - Vector2 drawPos = projectile.position - Main.screenPosition + origin; - drawPos.Y += projectile.gfxOffY; - float maxTrailPoints = length; + float widthOffset = (float)(texture.Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; + float heightOffset = (float)(projectile.height / 2); + Vector2 origin = new Vector2(widthOffset, heightOffset); + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + { + spriteEffects = SpriteEffects.FlipHorizontally; + } + Rectangle roughScreenBounds = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); + if (projectile.getRect().Intersects(roughScreenBounds)) + { + Vector2 drawPos = projectile.position - Main.screenPosition + origin; + drawPos.Y += projectile.gfxOffY; + float maxTrailPoints = length; - if (projectile.ai[1] == 1f) - maxTrailPoints = (int)projectile.localAI[0]; + if (projectile.ai[1] == 1f) + maxTrailPoints = (int)projectile.localAI[0]; - Vector2 cumulativeOffset = Vector2.Zero; - for (int i = 1; i <= (int)projectile.localAI[0]; i++) - { - Vector2 velToUseThisIter = projectile.velocity; - if (curve) - { - float oldVelRatio = i / projectile.localAI[0]; - int oldVelIndex = (int)(oldVelRatio * projectile.oldRot.Length); - if (oldVelIndex > 0) - { - float angleChange = projectile.oldRot[oldVelIndex - 1] - projectile.rotation; - velToUseThisIter = projectile.velocity.RotatedBy(angleChange); - } - } - cumulativeOffset += Vector2.Normalize(velToUseThisIter) * spacer; - Color color = projectile.GetAlpha(lightColor); - color *= (maxTrailPoints - (float)i) / maxTrailPoints; - color.A = 0; - float fixedRotation = projectile.rotation + MathHelper.PiOver2; - Main.spriteBatch.Draw(texture, drawPos - cumulativeOffset, null, color, fixedRotation, origin, projectile.scale, spriteEffects, 0f); - } - } - return false; - } + Vector2 cumulativeOffset = Vector2.Zero; + for (int i = 1; i <= (int)projectile.localAI[0]; i++) + { + Vector2 velToUseThisIter = projectile.velocity; + if (curve) + { + float oldVelRatio = i / projectile.localAI[0]; + int oldVelIndex = (int)(oldVelRatio * projectile.oldRot.Length); + if (oldVelIndex > 0) + { + float angleChange = projectile.oldRot[oldVelIndex - 1] - projectile.rotation; + velToUseThisIter = projectile.velocity.RotatedBy(angleChange); + } + } + cumulativeOffset += Vector2.Normalize(velToUseThisIter) * spacer; + Color color = projectile.GetAlpha(lightColor); + color *= (maxTrailPoints - (float)i) / maxTrailPoints; + color.A = 0; + float fixedRotation = projectile.rotation + MathHelper.PiOver2; + Main.spriteBatch.Draw(texture, drawPos - cumulativeOffset, null, color, fixedRotation, origin, projectile.scale, spriteEffects, 0f); + } + } + return false; + } - public static void ExplodeandDestroyTiles(Projectile projectile, int explosionRadius, bool checkExplosions, List tilesToCheck, List wallsToCheck) - { - int minTileX = (int)projectile.position.X / 16 - explosionRadius; - int maxTileX = (int)projectile.position.X / 16 + explosionRadius; - int minTileY = (int)projectile.position.Y / 16 - explosionRadius; - int maxTileY = (int)projectile.position.Y / 16 + explosionRadius; - if (minTileX < 0) - { - minTileX = 0; - } - if (maxTileX > Main.maxTilesX) - { - maxTileX = Main.maxTilesX; - } - if (minTileY < 0) - { - minTileY = 0; - } - if (maxTileY > Main.maxTilesY) - { - maxTileY = Main.maxTilesY; - } + public static void ExplodeandDestroyTiles(Projectile projectile, int explosionRadius, bool checkExplosions, List tilesToCheck, List wallsToCheck) + { + int minTileX = (int)projectile.position.X / 16 - explosionRadius; + int maxTileX = (int)projectile.position.X / 16 + explosionRadius; + int minTileY = (int)projectile.position.Y / 16 - explosionRadius; + int maxTileY = (int)projectile.position.Y / 16 + explosionRadius; + if (minTileX < 0) + { + minTileX = 0; + } + if (maxTileX > Main.maxTilesX) + { + maxTileX = Main.maxTilesX; + } + if (minTileY < 0) + { + minTileY = 0; + } + if (maxTileY > Main.maxTilesY) + { + maxTileY = Main.maxTilesY; + } - bool canKillWalls = false; - for (int x = minTileX; x <= maxTileX; x++) - { - for (int y = minTileY; y <= maxTileY; y++) - { - Vector2 explodeArea = new Vector2(Math.Abs(x - projectile.position.X / 16f), Math.Abs(y - projectile.position.Y / 16f)); - float distance = explodeArea.Length(); - if (distance < explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == WallID.None) - { - canKillWalls = true; - break; - } - } - } + bool canKillWalls = false; + for (int x = minTileX; x <= maxTileX; x++) + { + for (int y = minTileY; y <= maxTileY; y++) + { + Vector2 explodeArea = new Vector2(Math.Abs(x - projectile.position.X / 16f), Math.Abs(y - projectile.position.Y / 16f)); + float distance = explodeArea.Length(); + if (distance < explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == WallID.None) + { + canKillWalls = true; + break; + } + } + } - List tileExcludeList = new List() - { - TileID.DemonAltar, - TileID.ElderCrystalStand - }; - for (int i = 0; i < tilesToCheck.Count; ++i) - tileExcludeList.Add(tilesToCheck[i]); - List wallExcludeList = new List(); - for (int i = 0; i < wallsToCheck.Count; ++i) - wallExcludeList.Add(wallsToCheck[i]); + List tileExcludeList = new List() + { + TileID.DemonAltar, + TileID.ElderCrystalStand + }; + for (int i = 0; i < tilesToCheck.Count; ++i) + tileExcludeList.Add(tilesToCheck[i]); + List wallExcludeList = new List(); + for (int i = 0; i < wallsToCheck.Count; ++i) + wallExcludeList.Add(wallsToCheck[i]); - List explosionCheckList = new List() - { - TileID.DemonAltar, - TileID.Cobalt, - TileID.Mythril, - TileID.Adamantite, - TileID.Palladium, - TileID.Orichalcum, - TileID.Titanium, - TileID.Chlorophyte, - TileID.LihzahrdBrick, - TileID.LihzahrdAltar, - TileID.DesertFossil - }; - AddWithCondition(explosionCheckList, TileID.Hellstone, !Main.hardMode); + List explosionCheckList = new List() + { + TileID.DemonAltar, + TileID.Cobalt, + TileID.Mythril, + TileID.Adamantite, + TileID.Palladium, + TileID.Orichalcum, + TileID.Titanium, + TileID.Chlorophyte, + TileID.LihzahrdBrick, + TileID.LihzahrdAltar, + TileID.DesertFossil + }; + AddWithCondition(explosionCheckList, TileID.Hellstone, !Main.hardMode); - for (int i = minTileX; i <= maxTileX; i++) - { - for (int j = minTileY; j <= maxTileY; j++) - { - Tile tile = Main.tile[i, j]; - bool t = 1 == 1; bool f = 1 == 2; + for (int i = minTileX; i <= maxTileX; i++) + { + for (int j = minTileY; j <= maxTileY; j++) + { + Tile tile = Main.tile[i, j]; + bool t = 1 == 1; bool f = 1 == 2; - Vector2 explodeArea = new Vector2(Math.Abs(i - projectile.position.X / 16f), Math.Abs(j - projectile.position.Y / 16f)); - float distance = explodeArea.Length(); - if (distance < explosionRadius) - { - bool canKillTile = true; - if (tile != null && tile.active()) - { - if (checkExplosions) - { - if (Main.tileDungeon[tile.type] || explosionCheckList.Contains(tile.type)) - { - canKillTile = false; - } - if (!TileLoader.CanExplode(i, j)) - { - canKillTile = false; - } - } - if (Main.tileContainer[tile.type]) - canKillTile = false; - if (!TileLoader.CanKillTile(i, j, tile.type, ref t) || !TileLoader.CanKillTile(i, j, tile.type, ref f)) - canKillTile = false; - if (tileExcludeList.Contains(tile.type)) - canKillTile = false; + Vector2 explodeArea = new Vector2(Math.Abs(i - projectile.position.X / 16f), Math.Abs(j - projectile.position.Y / 16f)); + float distance = explodeArea.Length(); + if (distance < explosionRadius) + { + bool canKillTile = true; + if (tile != null && tile.active()) + { + if (checkExplosions) + { + if (Main.tileDungeon[tile.type] || explosionCheckList.Contains(tile.type)) + { + canKillTile = false; + } + if (!TileLoader.CanExplode(i, j)) + { + canKillTile = false; + } + } + if (Main.tileContainer[tile.type]) + canKillTile = false; + if (!TileLoader.CanKillTile(i, j, tile.type, ref t) || !TileLoader.CanKillTile(i, j, tile.type, ref f)) + canKillTile = false; + if (tileExcludeList.Contains(tile.type)) + canKillTile = false; - if (canKillTile) - { - WorldGen.KillTile(i, j, false, false, false); - if (!tile.active() && Main.netMode != NetmodeID.SinglePlayer) - { - NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, i, j, 0f, 0, 0, 0); - } - } - } - if (canKillTile) - { - for (int x = i - 1; x <= i + 1; x++) - { - for (int y = j - 1; y <= j + 1; y++) - { - bool canExplode = true; - if (checkExplosions) - canExplode = WallLoader.CanExplode(x, y, Main.tile[x, y].wall); - if (wallExcludeList.Any() && wallExcludeList.Contains(Main.tile[x, y].wall)) - canKillWalls = false; - if (Main.tile[x, y] != null && Main.tile[x, y].wall > WallID.None && canKillWalls && canExplode) - { - WorldGen.KillWall(x, y, false); - if (Main.tile[x, y].wall == WallID.None && Main.netMode != NetmodeID.SinglePlayer) - { - NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, x, y, 0f, 0, 0, 0); - } - } - } - } - } - } - } - } - } + if (canKillTile) + { + WorldGen.KillTile(i, j, false, false, false); + if (!tile.active() && Main.netMode != NetmodeID.SinglePlayer) + { + NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, i, j, 0f, 0, 0, 0); + } + } + } + if (canKillTile) + { + for (int x = i - 1; x <= i + 1; x++) + { + for (int y = j - 1; y <= j + 1; y++) + { + bool canExplode = true; + if (checkExplosions) + canExplode = WallLoader.CanExplode(x, y, Main.tile[x, y].wall); + if (wallExcludeList.Any() && wallExcludeList.Contains(Main.tile[x, y].wall)) + canKillWalls = false; + if (Main.tile[x, y] != null && Main.tile[x, y].wall > WallID.None && canKillWalls && canExplode) + { + WorldGen.KillWall(x, y, false); + if (Main.tile[x, y].wall == WallID.None && Main.netMode != NetmodeID.SinglePlayer) + { + NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, x, y, 0f, 0, 0, 0); + } + } + } + } + } + } + } + } + } - /// - /// Creates an explosion which is visually identical to vanilla's Rocket III and Rocket IV on-hit explosions. - /// - /// The projectile which is exploding. - public static void LargeFieryExplosion(this Projectile projectile) - { - // Sparks and such - Vector2 corner = projectile.position; - for (int i = 0; i < 40; i++) - { - int idx = Dust.NewDust(corner, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[idx].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[idx].scale = 0.5f; - Main.dust[idx].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int i = 0; i < 70; i++) - { - int idx = Dust.NewDust(corner, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 5f; - idx = Dust.NewDust(corner, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[idx].velocity *= 2f; - } + /// + /// Creates an explosion which is visually identical to vanilla's Rocket III and Rocket IV on-hit explosions. + /// + /// The projectile which is exploding. + public static void LargeFieryExplosion(this Projectile projectile) + { + // Sparks and such + Vector2 corner = projectile.position; + for (int i = 0; i < 40; i++) + { + int idx = Dust.NewDust(corner, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[idx].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[idx].scale = 0.5f; + Main.dust[idx].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int i = 0; i < 70; i++) + { + int idx = Dust.NewDust(corner, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 5f; + idx = Dust.NewDust(corner, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); + Main.dust[idx].velocity *= 2f; + } - // Smoke, which counts as a Gore - ExplosionGores(projectile.Center, 3); - } - } + // Smoke, which counts as a Gore + ExplosionGores(projectile.Center, 3); + } + } } diff --git a/Utilities/StringUtils.cs b/Utilities/StringUtils.cs index 1c08f38964..5bb96f2528 100644 --- a/Utilities/StringUtils.cs +++ b/Utilities/StringUtils.cs @@ -3,7 +3,7 @@ using Terraria; namespace CalamityMod { - public static partial class CalamityUtils + public static partial class CalamityUtils { internal static readonly string AlphanumericCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; public static string GenerateRandomAlphanumericString(int length) => new string(Enumerable.Repeat(AlphanumericCharacters, length).Select(s => s[Main.rand.Next(s.Length)]).ToArray()); diff --git a/Utilities/TileEntityUtils.cs b/Utilities/TileEntityUtils.cs index c3535b2d59..b664f635f5 100644 --- a/Utilities/TileEntityUtils.cs +++ b/Utilities/TileEntityUtils.cs @@ -9,88 +9,88 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { - public static partial class CalamityUtils - { - /// - /// A hitbox that should approximately represent the tip of the mouse cursor. Used for UI stuff. - /// - public static Rectangle MouseHitbox => new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 2, 2); + public static partial class CalamityUtils + { + /// + /// A hitbox that should approximately represent the tip of the mouse cursor. Used for UI stuff. + /// + public static Rectangle MouseHitbox => new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 2, 2); - /// - /// Finds the Calamity tile entity that is associated with the tile at the given world coordinates (i, j).

- /// Can return null if nothing is found. - ///
- /// The Type of Tile Entity to look for. Must be a modded tile entity. - /// The X coordinate of the tile in the world. - /// The Y coordinate of the tile in the world. - /// The width of the FrameImportant Tile that hosts the tile entity. - /// The height of the FrameImportant Tile that hosts the tile entity. - /// The width in pixels of each tile-square on the Tile's sprite sheet. Usually 16. Can be 18 if the sprite sheet has pink lines. - /// A ModTileEntity of the proper type, or null. - public static T FindTileEntity(int i, int j, int width, int height, int sheetSquare = 16) where T : ModTileEntity - { - // Find the top left corner of the FrameImportant tile that the player clicked on in the world. - Tile t = Main.tile[i, j]; - int left = i - t.frameX % (width * sheetSquare) / sheetSquare; - int top = j - t.frameY % (height * sheetSquare) / sheetSquare; + /// + /// Finds the Calamity tile entity that is associated with the tile at the given world coordinates (i, j).

+ /// Can return null if nothing is found. + ///
+ /// The Type of Tile Entity to look for. Must be a modded tile entity. + /// The X coordinate of the tile in the world. + /// The Y coordinate of the tile in the world. + /// The width of the FrameImportant Tile that hosts the tile entity. + /// The height of the FrameImportant Tile that hosts the tile entity. + /// The width in pixels of each tile-square on the Tile's sprite sheet. Usually 16. Can be 18 if the sprite sheet has pink lines. + /// A ModTileEntity of the proper type, or null. + public static T FindTileEntity(int i, int j, int width, int height, int sheetSquare = 16) where T : ModTileEntity + { + // Find the top left corner of the FrameImportant tile that the player clicked on in the world. + Tile t = Main.tile[i, j]; + int left = i - t.frameX % (width * sheetSquare) / sheetSquare; + int top = j - t.frameY % (height * sheetSquare) / sheetSquare; - byte chargerType = GetInstance().type; - bool exists = TileEntity.ByPosition.TryGetValue(new Point16(left, top), out TileEntity te); - return exists && te.type == chargerType ? (T)te : null; - } + byte chargerType = GetInstance().type; + bool exists = TileEntity.ByPosition.TryGetValue(new Point16(left, top), out TileEntity te); + return exists && te.type == chargerType ? (T)te : null; + } - /// - /// Cancels any currently active sign or chest name edits, and closes any chest the player may have open. - /// - /// The player to act upon. Should basically always be Main.LocalPlayer. - public static void CancelSignsAndChests(this Player player) - { - Main.mouseRightRelease = false; + /// + /// Cancels any currently active sign or chest name edits, and closes any chest the player may have open. + /// + /// The player to act upon. Should basically always be Main.LocalPlayer. + public static void CancelSignsAndChests(this Player player) + { + Main.mouseRightRelease = false; - // If a sign or chest was in use previously, close those GUIs. - if (player.sign >= 0) - { - Main.PlaySound(SoundID.MenuClose); - player.sign = -1; - Main.editSign = false; - Main.npcChatText = ""; - } - if (Main.editChest) - { - Main.PlaySound(SoundID.MenuTick); - Main.editChest = false; - Main.npcChatText = ""; - } - if (player.chest >= 0) - player.chest = -1; - } + // If a sign or chest was in use previously, close those GUIs. + if (player.sign >= 0) + { + Main.PlaySound(SoundID.MenuClose); + player.sign = -1; + Main.editSign = false; + Main.npcChatText = ""; + } + if (Main.editChest) + { + Main.PlaySound(SoundID.MenuTick); + Main.editChest = false; + Main.npcChatText = ""; + } + if (player.chest >= 0) + player.chest = -1; + } - // Draws the Power Cell item slot in a UI. Used by both the Power Cell Factory and Charging Station. - internal static void DrawPowercellSlot(SpriteBatch spriteBatch, Item item, Vector2 drawPosition, float iconScale = 0.7f) - { - Texture2D slotBackgroundTex = GetTexture("CalamityMod/ExtraTextures/UI/PowerCellSlot_Empty"); + // Draws the Power Cell item slot in a UI. Used by both the Power Cell Factory and Charging Station. + internal static void DrawPowercellSlot(SpriteBatch spriteBatch, Item item, Vector2 drawPosition, float iconScale = 0.7f) + { + Texture2D slotBackgroundTex = GetTexture("CalamityMod/ExtraTextures/UI/PowerCellSlot_Empty"); - // This check is done twice because the draw order matters. We want to draw the background icon before any text. - if (item.stack > 0) - slotBackgroundTex = GetTexture("CalamityMod/ExtraTextures/UI/PowerCellSlot_Filled"); + // This check is done twice because the draw order matters. We want to draw the background icon before any text. + if (item.stack > 0) + slotBackgroundTex = GetTexture("CalamityMod/ExtraTextures/UI/PowerCellSlot_Filled"); - spriteBatch.Draw(slotBackgroundTex, drawPosition, null, Color.White, 0f, slotBackgroundTex.Size() * 0.5f, iconScale, SpriteEffects.None, 0f); - if (item.stack > 0) - { - float inventoryScale = Main.inventoryScale; - Vector2 numberOffset = slotBackgroundTex.Size() * 0.2f; - numberOffset.X -= 17f; - ChatManager.DrawColorCodedStringWithShadow(spriteBatch, - Main.fontItemStack, - item.stack.ToString(), - drawPosition + numberOffset * inventoryScale, - Color.White, - 0f, - Vector2.Zero, - new Vector2(inventoryScale), - -1f, - inventoryScale); - } - } - } + spriteBatch.Draw(slotBackgroundTex, drawPosition, null, Color.White, 0f, slotBackgroundTex.Size() * 0.5f, iconScale, SpriteEffects.None, 0f); + if (item.stack > 0) + { + float inventoryScale = Main.inventoryScale; + Vector2 numberOffset = slotBackgroundTex.Size() * 0.2f; + numberOffset.X -= 17f; + ChatManager.DrawColorCodedStringWithShadow(spriteBatch, + Main.fontItemStack, + item.stack.ToString(), + drawPosition + numberOffset * inventoryScale, + Color.White, + 0f, + Vector2.Zero, + new Vector2(inventoryScale), + -1f, + inventoryScale); + } + } + } } diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index 0fd7914474..737029dd06 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -23,502 +23,502 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { - public static partial class CalamityUtils - { - public static string GetMapChestName(string baseName, int x, int y) - { - // Bounds check. - if (!WorldGen.InWorld(x, y, 2)) - return baseName; + public static partial class CalamityUtils + { + public static string GetMapChestName(string baseName, int x, int y) + { + // Bounds check. + if (!WorldGen.InWorld(x, y, 2)) + return baseName; - // Tile null check. - Tile tile = Main.tile[x, y]; - if (tile is null) - return baseName; + // Tile null check. + Tile tile = Main.tile[x, y]; + if (tile is null) + return baseName; - int left = x; - int top = y; - if (tile.frameX % 36 != 0) - left--; - if (tile.frameY != 0) - top--; + int left = x; + int top = y; + if (tile.frameX % 36 != 0) + left--; + if (tile.frameY != 0) + top--; - int chest = Chest.FindChest(left, top); + int chest = Chest.FindChest(left, top); - // Valid chest index check. - if (chest < 0) - return baseName; + // Valid chest index check. + if (chest < 0) + return baseName; - string name = baseName; + string name = baseName; - // Concatenate the chest's custom name if it has one. - if (!string.IsNullOrEmpty(Main.chest[chest].name)) - name += $": {Main.chest[chest].name}"; + // Concatenate the chest's custom name if it has one. + if (!string.IsNullOrEmpty(Main.chest[chest].name)) + name += $": {Main.chest[chest].name}"; - return name; - } + return name; + } - public static void SafeSquareTileFrame(int x, int y, bool resetFrame = true) - { - if (Main.tile[x, y] is null) - return; + public static void SafeSquareTileFrame(int x, int y, bool resetFrame = true) + { + if (Main.tile[x, y] is null) + return; - for (int xIter = x - 1; xIter <= x + 1; ++xIter) - { - if (xIter < 0 || xIter >= Main.maxTilesX) - continue; - for (int yIter = y - 1; yIter <= y + 1; yIter++) - { - if (yIter < 0 || yIter >= Main.maxTilesY) - continue; - if (xIter == x && yIter == y) - { - WorldGen.TileFrame(x, y, resetFrame, false); - } - else - { - WorldGen.TileFrame(xIter, yIter, false, false); - } - } - } - } + for (int xIter = x - 1; xIter <= x + 1; ++xIter) + { + if (xIter < 0 || xIter >= Main.maxTilesX) + continue; + for (int yIter = y - 1; yIter <= y + 1; yIter++) + { + if (yIter < 0 || yIter >= Main.maxTilesY) + continue; + if (xIter == x && yIter == y) + { + WorldGen.TileFrame(x, y, resetFrame, false); + } + else + { + WorldGen.TileFrame(xIter, yIter, false, false); + } + } + } + } - public static void LightHitWire(int type, int i, int j, int tileX, int tileY) - { - int x = i - Main.tile[i, j].frameX / 18 % tileX; - int y = j - Main.tile[i, j].frameY / 18 % tileY; - for (int l = x; l < x + tileX; l++) - { - for (int m = y; m < y + tileY; m++) - { - if (Main.tile[l, m] == null) - { - Main.tile[l, m] = new Tile(); - } - if (Main.tile[l, m].active() && Main.tile[l, m].type == type) - { - if (Main.tile[l, m].frameX < (18 * tileX)) - { - Main.tile[l, m].frameX += (short)(18 * tileX); - } - else - { - Main.tile[l, m].frameX -= (short)(18 * tileX); - } - } - } - } - if (Wiring.running) - { - for (int k = 0; k < tileX; k++) - { - for (int l = 0; l < tileY; l++) - { - Wiring.SkipWire(x + k, y + l); - } - } - } - } + public static void LightHitWire(int type, int i, int j, int tileX, int tileY) + { + int x = i - Main.tile[i, j].frameX / 18 % tileX; + int y = j - Main.tile[i, j].frameY / 18 % tileY; + for (int l = x; l < x + tileX; l++) + { + for (int m = y; m < y + tileY; m++) + { + if (Main.tile[l, m] == null) + { + Main.tile[l, m] = new Tile(); + } + if (Main.tile[l, m].active() && Main.tile[l, m].type == type) + { + if (Main.tile[l, m].frameX < (18 * tileX)) + { + Main.tile[l, m].frameX += (short)(18 * tileX); + } + else + { + Main.tile[l, m].frameX -= (short)(18 * tileX); + } + } + } + } + if (Wiring.running) + { + for (int k = 0; k < tileX; k++) + { + for (int l = 0; l < tileY; l++) + { + Wiring.SkipWire(x + k, y + l); + } + } + } + } - public static void DrawFlameEffect(Texture2D flameTexture, int i, int j, int offsetX = 0, int offsetY = 0) - { - Tile tile = Main.tile[i, j]; - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); + public static void DrawFlameEffect(Texture2D flameTexture, int i, int j, int offsetX = 0, int offsetY = 0) + { + Tile tile = Main.tile[i, j]; + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - int width = 16; - int height = 16; - int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; + int width = 16; + int height = 16; + int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; - ulong num190 = Main.TileFrameSeed ^ (ulong)((long)j << 32 | (long)(uint)i); + ulong num190 = Main.TileFrameSeed ^ (ulong)((long)j << 32 | (long)(uint)i); - for (int c = 0; c < 7; c++) - { - float shakeX = Utils.RandomInt(ref num190, -10, 11) * 0.15f; - float shakeY = Utils.RandomInt(ref num190, -10, 1) * 0.35f; - Main.spriteBatch.Draw(flameTexture, new Vector2(i * 16 - (int)Main.screenPosition.X - (width - 16f) / 2f + shakeX, j * 16 - (int)Main.screenPosition.Y + shakeY + yOffset) + zero, new Rectangle(tile.frameX + offsetX, tile.frameY + offsetY, width, height), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); - } - } + for (int c = 0; c < 7; c++) + { + float shakeX = Utils.RandomInt(ref num190, -10, 11) * 0.15f; + float shakeY = Utils.RandomInt(ref num190, -10, 1) * 0.35f; + Main.spriteBatch.Draw(flameTexture, new Vector2(i * 16 - (int)Main.screenPosition.X - (width - 16f) / 2f + shakeX, j * 16 - (int)Main.screenPosition.Y + shakeY + yOffset) + zero, new Rectangle(tile.frameX + offsetX, tile.frameY + offsetY, width, height), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + } + } - public static void DrawStaticFlameEffect(Texture2D flameTexture, int i, int j, int offsetX = 0, int offsetY = 0) - { - int xPos = Main.tile[i, j].frameX; - int yPos = Main.tile[i, j].frameY; - Color drawColour = new Color(100, 100, 100, 0); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - for (int x = -1; x < 2; x++) - { - for (int y = -1; y < 2; y++) - { - Vector2 flameOffset = new Vector2(x, y).SafeNormalize(Vector2.Zero); - flameOffset *= 1.5f; - Main.spriteBatch.Draw(flameTexture, drawOffset + flameOffset, new Rectangle?(new Rectangle(xPos + offsetX, yPos + offsetY, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); - } - } - } + public static void DrawStaticFlameEffect(Texture2D flameTexture, int i, int j, int offsetX = 0, int offsetY = 0) + { + int xPos = Main.tile[i, j].frameX; + int yPos = Main.tile[i, j].frameY; + Color drawColour = new Color(100, 100, 100, 0); + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; + for (int x = -1; x < 2; x++) + { + for (int y = -1; y < 2; y++) + { + Vector2 flameOffset = new Vector2(x, y).SafeNormalize(Vector2.Zero); + flameOffset *= 1.5f; + Main.spriteBatch.Draw(flameTexture, drawOffset + flameOffset, new Rectangle?(new Rectangle(xPos + offsetX, yPos + offsetY, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } + } - public static void DrawFlameSparks(int dustType, int rarity, int i, int j) - { - if (!Main.gamePaused && Main.instance.IsActive && (!Lighting.UpdateEveryFrame || Main.rand.NextBool(4))) - { - if (Main.rand.NextBool(rarity)) - { - int dust = Dust.NewDust(new Vector2(i * 16 + 4, j * 16 + 2), 4, 4, dustType, 0f, 0f, 100, default, 1f); - if (Main.rand.Next(3) != 0) - { - Main.dust[dust].noGravity = true; - } - Main.dust[dust].velocity *= 0.3f; - Main.dust[dust].velocity.Y = Main.dust[dust].velocity.Y - 1.5f; - } - } - } + public static void DrawFlameSparks(int dustType, int rarity, int i, int j) + { + if (!Main.gamePaused && Main.instance.IsActive && (!Lighting.UpdateEveryFrame || Main.rand.NextBool(4))) + { + if (Main.rand.NextBool(rarity)) + { + int dust = Dust.NewDust(new Vector2(i * 16 + 4, j * 16 + 2), 4, 4, dustType, 0f, 0f, 100, default, 1f); + if (Main.rand.Next(3) != 0) + { + Main.dust[dust].noGravity = true; + } + Main.dust[dust].velocity *= 0.3f; + Main.dust[dust].velocity.Y = Main.dust[dust].velocity.Y - 1.5f; + } + } + } - public static void DrawItemFlame(Texture2D flameTexture, Item item) - { - int width = flameTexture.Width; - int height = flameTexture.Height; - for (int c = 0; c < 7; c++) - { - float shakeX = Main.rand.Next(-10, 11) * 0.15f; - float shakeY = Main.rand.Next(-10, 1) * 0.35f; - Main.spriteBatch.Draw(flameTexture, new Vector2(item.position.X - Main.screenPosition.X + item.width * 0.5f + shakeX, item.position.Y - Main.screenPosition.Y + item.height - flameTexture.Height * 0.5f + 2f + shakeY), new Rectangle(0, 0, width, height), new Color(100, 100, 100, 0), 0f, default, 1f, SpriteEffects.None, 0f); - } - } + public static void DrawItemFlame(Texture2D flameTexture, Item item) + { + int width = flameTexture.Width; + int height = flameTexture.Height; + for (int c = 0; c < 7; c++) + { + float shakeX = Main.rand.Next(-10, 11) * 0.15f; + float shakeY = Main.rand.Next(-10, 1) * 0.35f; + Main.spriteBatch.Draw(flameTexture, new Vector2(item.position.X - Main.screenPosition.X + item.width * 0.5f + shakeX, item.position.Y - Main.screenPosition.Y + item.height - flameTexture.Height * 0.5f + 2f + shakeY), new Rectangle(0, 0, width, height), new Color(100, 100, 100, 0), 0f, default, 1f, SpriteEffects.None, 0f); + } + } - /// - /// Generates an framing offset for individual tiles to be animated off-sync. DOES NOT WORK WITHOUT EVEN ANIMATIONS!!! (e.g. Flak Hermit Cages don't work with this.) - /// - /// The ModTile which is being initialized. - /// X position of the tile. - /// Y position of the tile. - /// The number of frames the tile has. - /// The number of pixels of one tile of the furniture in the X direction (ImageHeight / frameAmt / xTiles). - /// The number of pixels of one tile of the furniture in the Y direction (ImageWidth / frameAmt / yTiles). - /// The number of tiles wide the furniture is. - /// The number of tiles tall the furniture is. - /// This is animationFrameHeight in vertical animated tiles and animationFrameWidth in horizontal animated tiles. - /// The offset for the animation. This is set to frameXOffset in horizontal animations and frameYOffset in vertical animations in the AnimateIndividualTile() function. - internal static int GetAnimationOffset(this ModTile mt, int i, int j, int frameAmt, int xLength, int yLength, int xTiles, int yTiles, int animationFrameLength) - { - int frameX = Main.tile[i, j].frameX; - int frameY = Main.tile[i, j].frameY; + /// + /// Generates an framing offset for individual tiles to be animated off-sync. DOES NOT WORK WITHOUT EVEN ANIMATIONS!!! (e.g. Flak Hermit Cages don't work with this.) + /// + /// The ModTile which is being initialized. + /// X position of the tile. + /// Y position of the tile. + /// The number of frames the tile has. + /// The number of pixels of one tile of the furniture in the X direction (ImageHeight / frameAmt / xTiles). + /// The number of pixels of one tile of the furniture in the Y direction (ImageWidth / frameAmt / yTiles). + /// The number of tiles wide the furniture is. + /// The number of tiles tall the furniture is. + /// This is animationFrameHeight in vertical animated tiles and animationFrameWidth in horizontal animated tiles. + /// The offset for the animation. This is set to frameXOffset in horizontal animations and frameYOffset in vertical animations in the AnimateIndividualTile() function. + internal static int GetAnimationOffset(this ModTile mt, int i, int j, int frameAmt, int xLength, int yLength, int xTiles, int yTiles, int animationFrameLength) + { + int frameX = Main.tile[i, j].frameX; + int frameY = Main.tile[i, j].frameY; - // Tweak the frame drawn so tiles next to each other are off-sync and look much more interesting. - frameX %= (xLength * xTiles); + // Tweak the frame drawn so tiles next to each other are off-sync and look much more interesting. + frameX %= (xLength * xTiles); i -= frameX / xLength; - frameY %= (yLength * yTiles); - j -= frameY / yLength; + frameY %= (yLength * yTiles); + j -= frameY / yLength; - int uniqueAnimationFrame = Main.tileFrame[mt.Type] + j; - if (i % 2 == 0) - uniqueAnimationFrame += 3; - if (i % 3 == 0) - uniqueAnimationFrame += 3; - if (i % 4 == 0) - uniqueAnimationFrame += 3; - if (j % 2 == 0) - uniqueAnimationFrame += 3; - if (j % 3 == 0) - uniqueAnimationFrame += 3; - if (j % 4 == 0) - uniqueAnimationFrame += 3; + int uniqueAnimationFrame = Main.tileFrame[mt.Type] + j; + if (i % 2 == 0) + uniqueAnimationFrame += 3; + if (i % 3 == 0) + uniqueAnimationFrame += 3; + if (i % 4 == 0) + uniqueAnimationFrame += 3; + if (j % 2 == 0) + uniqueAnimationFrame += 3; + if (j % 3 == 0) + uniqueAnimationFrame += 3; + if (j % 4 == 0) + uniqueAnimationFrame += 3; - uniqueAnimationFrame %= frameAmt; + uniqueAnimationFrame %= frameAmt; - return uniqueAnimationFrame * animationFrameLength; - } + return uniqueAnimationFrame * animationFrameLength; + } - public static Tile ParanoidTileRetrieval(int x, int y) - { - if (!WorldGen.InWorld(x, y)) - return new Tile(); - Tile tile = Main.tile[x, y]; - if (tile is null) - { - tile = new Tile(); - Main.tile[x, y] = tile; - } - return tile; - } + public static Tile ParanoidTileRetrieval(int x, int y) + { + if (!WorldGen.InWorld(x, y)) + return new Tile(); + Tile tile = Main.tile[x, y]; + if (tile is null) + { + tile = new Tile(); + Main.tile[x, y] = tile; + } + return tile; + } - public static bool TileSelectionSolid(int x, int y, int width, int height) - { - for (int i = x; i != x + width; i += Math.Sign(width)) - { - for (int j = y; y != y + height; j += Math.Sign(height)) - { - if (!WorldGen.InWorld(i, j)) - return false; - if (!WorldGen.SolidTile(Framing.GetTileSafely(i, j))) - return false; - } - } - return true; - } + public static bool TileSelectionSolid(int x, int y, int width, int height) + { + for (int i = x; i != x + width; i += Math.Sign(width)) + { + for (int j = y; y != y + height; j += Math.Sign(height)) + { + if (!WorldGen.InWorld(i, j)) + return false; + if (!WorldGen.SolidTile(Framing.GetTileSafely(i, j))) + return false; + } + } + return true; + } - public static bool TileSelectionSolidSquare(int x, int y, int width, int height) - { - for (int i = x - width; i != x + width; i += Math.Sign(width)) - { - for (int j = y - height; y != y + height; j += Math.Sign(height)) - { - if (!WorldGen.InWorld(i, j)) - return false; - if (!WorldGen.SolidTile(Framing.GetTileSafely(i, j))) - return false; - } - } - return true; - } + public static bool TileSelectionSolidSquare(int x, int y, int width, int height) + { + for (int i = x - width; i != x + width; i += Math.Sign(width)) + { + for (int j = y - height; y != y + height; j += Math.Sign(height)) + { + if (!WorldGen.InWorld(i, j)) + return false; + if (!WorldGen.SolidTile(Framing.GetTileSafely(i, j))) + return false; + } + } + return true; + } - public static bool TileActiveAndOfType(int x, int y, int type) - { - return ParanoidTileRetrieval(x, y).active() && ParanoidTileRetrieval(x, y).type == type; - } + public static bool TileActiveAndOfType(int x, int y, int type) + { + return ParanoidTileRetrieval(x, y).active() && ParanoidTileRetrieval(x, y).type == type; + } - /// - /// Sets the mergeability state of two tiles. By default, enables tile merging. - /// - /// The first tile type which should merge (or not). - /// The second tile type which should merge (or not). - /// The mergeability state of the tiles. Defaults to true if omitted. - public static void SetMerge(int type1, int type2, bool merge = true) - { - if (type1 != type2) - { - Main.tileMerge[type1][type2] = merge; - Main.tileMerge[type2][type1] = merge; - } - } + /// + /// Sets the mergeability state of two tiles. By default, enables tile merging. + /// + /// The first tile type which should merge (or not). + /// The second tile type which should merge (or not). + /// The mergeability state of the tiles. Defaults to true if omitted. + public static void SetMerge(int type1, int type2, bool merge = true) + { + if (type1 != type2) + { + Main.tileMerge[type1][type2] = merge; + Main.tileMerge[type2][type1] = merge; + } + } - /// - /// Makes the first tile type argument merge with all the other tile type arguments. Also accepts arrays. - /// - /// The tile whose merging properties will be set. - /// Every tile that should be merged with. - public static void MergeWithSet(int myType, params int[] otherTypes) - { - for (int i = 0; i < otherTypes.Length; ++i) - SetMerge(myType, otherTypes[i]); - } + /// + /// Makes the first tile type argument merge with all the other tile type arguments. Also accepts arrays. + /// + /// The tile whose merging properties will be set. + /// Every tile that should be merged with. + public static void MergeWithSet(int myType, params int[] otherTypes) + { + for (int i = 0; i < otherTypes.Length; ++i) + SetMerge(myType, otherTypes[i]); + } - /// - /// Makes the specified tile merge with the most common types of tiles found in world generation.

- /// Notably excludes Ice. - ///
- /// The tile whose merging properties will be set. - public static void MergeWithGeneral(int type) => MergeWithSet(type, new int[] { - // Soils - TileID.Dirt, - TileID.Mud, - TileID.ClayBlock, - // Stones - TileID.Stone, - TileID.Ebonstone, - TileID.Crimstone, - TileID.Pearlstone, - // Sands - TileID.Sand, - TileID.Ebonsand, - TileID.Crimsand, - TileID.Pearlsand, - // Snows - TileID.SnowBlock, - // Calamity Tiles - TileType(), - TileType(), - TileType(), - TileType(), - TileType(), - TileType(), - TileType(), - TileType(), - TileType(), - }); + /// + /// Makes the specified tile merge with the most common types of tiles found in world generation.

+ /// Notably excludes Ice. + ///
+ /// The tile whose merging properties will be set. + public static void MergeWithGeneral(int type) => MergeWithSet(type, new int[] { + // Soils + TileID.Dirt, + TileID.Mud, + TileID.ClayBlock, + // Stones + TileID.Stone, + TileID.Ebonstone, + TileID.Crimstone, + TileID.Pearlstone, + // Sands + TileID.Sand, + TileID.Ebonsand, + TileID.Crimsand, + TileID.Pearlsand, + // Snows + TileID.SnowBlock, + // Calamity Tiles + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + }); - /// - /// Makes the specified tile merge with all ores, vanilla and Calamity. Particularly useful for stone blocks. - /// - /// The tile whose merging properties will be set. - public static void MergeWithOres(int type) => MergeWithSet(type, new int[] { - // Vanilla Ores - TileID.Copper, - TileID.Tin, - TileID.Iron, - TileID.Lead, - TileID.Silver, - TileID.Tungsten, - TileID.Gold, - TileID.Platinum, - TileID.Demonite, - TileID.Crimtane, - TileID.Cobalt, - TileID.Palladium, - TileID.Mythril, - TileID.Orichalcum, - TileID.Adamantite, - TileID.Titanium, - TileID.LunarOre, - // Calamity Ores - TileType(), - TileType(), - TileType(), - TileType(), - TileType(), - TileType(), - TileType(), - TileType(), - }); + /// + /// Makes the specified tile merge with all ores, vanilla and Calamity. Particularly useful for stone blocks. + /// + /// The tile whose merging properties will be set. + public static void MergeWithOres(int type) => MergeWithSet(type, new int[] { + // Vanilla Ores + TileID.Copper, + TileID.Tin, + TileID.Iron, + TileID.Lead, + TileID.Silver, + TileID.Tungsten, + TileID.Gold, + TileID.Platinum, + TileID.Demonite, + TileID.Crimtane, + TileID.Cobalt, + TileID.Palladium, + TileID.Mythril, + TileID.Orichalcum, + TileID.Adamantite, + TileID.Titanium, + TileID.LunarOre, + // Calamity Ores + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + }); - /// - /// Makes the specified tile merge with all types of desert tiles, including the Calamity Sunken Sea. - /// - /// The tile whose merging properties will be set. - public static void MergeWithDesert(int type) => MergeWithSet(type, new int[] { - // Sands - TileID.Sand, - TileID.Ebonsand, - TileID.Crimsand, - TileID.Pearlsand, - // Hardened Sands - TileID.HardenedSand, - TileID.CorruptHardenedSand, - TileID.CrimsonHardenedSand, - TileID.HallowHardenedSand, - // Sandstones - TileID.Sandstone, - TileID.CorruptSandstone, - TileID.CrimsonSandstone, - TileID.HallowSandstone, - // Miscellaneous Desert Tiles - TileID.FossilOre, - TileID.DesertFossil, - // Astral Desert - TileType(), - TileType(), - TileType(), - TileType(), - // Sunken Sea - TileType(), - TileType(), - TileType(), - }); + /// + /// Makes the specified tile merge with all types of desert tiles, including the Calamity Sunken Sea. + /// + /// The tile whose merging properties will be set. + public static void MergeWithDesert(int type) => MergeWithSet(type, new int[] { + // Sands + TileID.Sand, + TileID.Ebonsand, + TileID.Crimsand, + TileID.Pearlsand, + // Hardened Sands + TileID.HardenedSand, + TileID.CorruptHardenedSand, + TileID.CrimsonHardenedSand, + TileID.HallowHardenedSand, + // Sandstones + TileID.Sandstone, + TileID.CorruptSandstone, + TileID.CrimsonSandstone, + TileID.HallowSandstone, + // Miscellaneous Desert Tiles + TileID.FossilOre, + TileID.DesertFossil, + // Astral Desert + TileType(), + TileType(), + TileType(), + TileType(), + // Sunken Sea + TileType(), + TileType(), + TileType(), + }); - /// - /// Makes the specified tile merge with all types of snow and ice tiles. - /// - /// The tile whose merging properties will be set. - public static void MergeWithSnow(int type) => MergeWithSet(type, new int[] { - // Snows - TileID.SnowBlock, - // Ices - TileID.IceBlock, - TileID.CorruptIce, - TileID.FleshIce, - TileID.HallowedIce, - // Astral Snow - TileType(), - TileType(), - TileType(), - }); + /// + /// Makes the specified tile merge with all types of snow and ice tiles. + /// + /// The tile whose merging properties will be set. + public static void MergeWithSnow(int type) => MergeWithSet(type, new int[] { + // Snows + TileID.SnowBlock, + // Ices + TileID.IceBlock, + TileID.CorruptIce, + TileID.FleshIce, + TileID.HallowedIce, + // Astral Snow + TileType(), + TileType(), + TileType(), + }); - /// - /// Makes the specified tile merge with all tiles which generate in hell. Does not include Charred Ore. - /// - /// The tile whose merging properties will be set. - public static void MergeWithHell(int type) => MergeWithSet(type, new int[] { - TileID.Ash, - TileID.Hellstone, - TileID.ObsidianBrick, - TileID.HellstoneBrick, - TileType(), - }); + /// + /// Makes the specified tile merge with all tiles which generate in hell. Does not include Charred Ore. + /// + /// The tile whose merging properties will be set. + public static void MergeWithHell(int type) => MergeWithSet(type, new int[] { + TileID.Ash, + TileID.Hellstone, + TileID.ObsidianBrick, + TileID.HellstoneBrick, + TileType(), + }); - /// - /// Makes the specified tile merge with all tiles which generate in the Abyss or the Sulphurous Sea. Includes Chaotic Ore. - /// - /// The tile whose merging properties will be set. - public static void MergeWithAbyss(int type) => MergeWithSet(type, new int[] { - // Sulphurous Sea - TileType(), - TileType(), - // Abyss - TileType(), - TileType(), - TileType(), - TileType(), - TileType(), - }); + /// + /// Makes the specified tile merge with all tiles which generate in the Abyss or the Sulphurous Sea. Includes Chaotic Ore. + /// + /// The tile whose merging properties will be set. + public static void MergeWithAbyss(int type) => MergeWithSet(type, new int[] { + // Sulphurous Sea + TileType(), + TileType(), + // Abyss + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + }); - /// - /// Makes the tile merge with all the tile types that generate within various types of astral tiles - /// - /// - public static void MergeAstralTiles(int type) - { - //Astral - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - //Astral Desert - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - //Astral Snow - SetMerge(type, TileType()); - SetMerge(type, TileType()); - } + /// + /// Makes the tile merge with all the tile types that generate within various types of astral tiles + /// + /// + public static void MergeAstralTiles(int type) + { + //Astral + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + //Astral Desert + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + //Astral Snow + SetMerge(type, TileType()); + SetMerge(type, TileType()); + } - /// - /// Makes the tile merge with all the decorative 'smooth' tiles - /// - /// - public static void MergeSmoothTiles(int type) - { - //Vanilla - SetMerge(type, TileID.MarbleBlock); - SetMerge(type, TileID.GraniteBlock); - //Calam - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - } + /// + /// Makes the tile merge with all the decorative 'smooth' tiles + /// + /// + public static void MergeSmoothTiles(int type) + { + //Vanilla + SetMerge(type, TileID.MarbleBlock); + SetMerge(type, TileID.GraniteBlock); + //Calam + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + } - /// - /// Makes the tile merge with other mergable decorative tiles - /// - /// - public static void MergeDecorativeTiles(int type) - { - //Vanilla decor - Main.tileBrick[type] = true; - //Calam - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - SetMerge(type, TileType()); - } + /// + /// Makes the tile merge with other mergable decorative tiles + /// + /// + public static void MergeDecorativeTiles(int type) + { + //Vanilla decor + Main.tileBrick[type] = true; + //Calam + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + } - /// - /// Determines if a tile is solid ground based on whether it's active and not actuated or if the tile is solid in any way, including just the top. - /// - /// The tile to check. - public static bool IsTileSolidGround(this Tile tile) => tile != null && tile.nactive() && (Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]); - + /// + /// Determines if a tile is solid ground based on whether it's active and not actuated or if the tile is solid in any way, including just the top. + /// + /// The tile to check. + public static bool IsTileSolidGround(this Tile tile) => tile != null && tile.nactive() && (Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]); + - /// - /// Determines if a tile is solid based on whether it's active and not actuated or if the tile is solid. This will not count platforms and other non-solid ground tiles - /// - /// The tile to check. - public static bool IsTileSolid(this Tile tile) => tile != null && tile.nactive() && Main.tileSolid[tile.type]; - } + /// + /// Determines if a tile is solid based on whether it's active and not actuated or if the tile is solid. This will not count platforms and other non-solid ground tiles + /// + /// The tile to check. + public static bool IsTileSolid(this Tile tile) => tile != null && tile.nactive() && Main.tileSolid[tile.type]; + } } diff --git a/Utilities/WorldgenUtils.cs b/Utilities/WorldgenUtils.cs index 7552177cc3..0713adb895 100644 --- a/Utilities/WorldgenUtils.cs +++ b/Utilities/WorldgenUtils.cs @@ -4,7 +4,7 @@ using Terraria.ID; namespace CalamityMod { - public static partial class CalamityUtils + public static partial class CalamityUtils { /// /// Generates clusters of ore across the world based on various requirements and with various strengths/frequencies. diff --git a/Walls/AstralFossilWall.cs b/Walls/AstralFossilWall.cs index 39c3575dc4..bca198d6bf 100644 --- a/Walls/AstralFossilWall.cs +++ b/Walls/AstralFossilWall.cs @@ -3,7 +3,7 @@ using Microsoft.Xna.Framework; using Terraria.ModLoader; namespace CalamityMod.Walls { - public class AstralFossilWall : ModWall + public class AstralFossilWall : ModWall { public override void SetDefaults() diff --git a/Walls/AstralSnowWall.cs b/Walls/AstralSnowWall.cs index eb6880ff73..9ad6d3d0e9 100644 --- a/Walls/AstralSnowWall.cs +++ b/Walls/AstralSnowWall.cs @@ -3,7 +3,7 @@ using Microsoft.Xna.Framework; using Terraria.ModLoader; namespace CalamityMod.Walls { - public class AstralSnowWall : ModWall + public class AstralSnowWall : ModWall { public override void SetDefaults() { diff --git a/Walls/AstralSnowWallSafe.cs b/Walls/AstralSnowWallSafe.cs index 09dd191381..4dff8f6ee1 100644 --- a/Walls/AstralSnowWallSafe.cs +++ b/Walls/AstralSnowWallSafe.cs @@ -3,7 +3,7 @@ using Microsoft.Xna.Framework; using Terraria.ModLoader; namespace CalamityMod.Walls { - public class AstralSnowWallSafe : ModWall + public class AstralSnowWallSafe : ModWall { public override void SetDefaults() diff --git a/Walls/DraedonStructures/HazardChevronWall.cs b/Walls/DraedonStructures/HazardChevronWall.cs index afd8eafff7..d1e1709177 100644 --- a/Walls/DraedonStructures/HazardChevronWall.cs +++ b/Walls/DraedonStructures/HazardChevronWall.cs @@ -3,7 +3,7 @@ using Microsoft.Xna.Framework; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { - public class HazardChevronWall : ModWall + public class HazardChevronWall : ModWall { public override void SetDefaults() diff --git a/Walls/DraedonStructures/LaboratoryPanelWall.cs b/Walls/DraedonStructures/LaboratoryPanelWall.cs index 1d2515615e..8987f9a605 100644 --- a/Walls/DraedonStructures/LaboratoryPanelWall.cs +++ b/Walls/DraedonStructures/LaboratoryPanelWall.cs @@ -3,7 +3,7 @@ using Microsoft.Xna.Framework; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { - public class LaboratoryPanelWall : ModWall + public class LaboratoryPanelWall : ModWall { public override void SetDefaults() diff --git a/Walls/DraedonStructures/LaboratoryPlateBeam.cs b/Walls/DraedonStructures/LaboratoryPlateBeam.cs index 01b790cf9b..3268b47970 100644 --- a/Walls/DraedonStructures/LaboratoryPlateBeam.cs +++ b/Walls/DraedonStructures/LaboratoryPlateBeam.cs @@ -3,7 +3,7 @@ using Microsoft.Xna.Framework; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { - public class LaboratoryPlateBeam : ModWall + public class LaboratoryPlateBeam : ModWall { public override void SetDefaults() diff --git a/Walls/DraedonStructures/LaboratoryPlatePillar.cs b/Walls/DraedonStructures/LaboratoryPlatePillar.cs index f01eb32a01..4ab0ab8736 100644 --- a/Walls/DraedonStructures/LaboratoryPlatePillar.cs +++ b/Walls/DraedonStructures/LaboratoryPlatePillar.cs @@ -3,7 +3,7 @@ using Microsoft.Xna.Framework; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { - public class LaboratoryPlatePillar : ModWall + public class LaboratoryPlatePillar : ModWall { public override void SetDefaults() diff --git a/Walls/DraedonStructures/LaboratoryPlatingWall.cs b/Walls/DraedonStructures/LaboratoryPlatingWall.cs index e8d27f6a8f..701c3af2dc 100644 --- a/Walls/DraedonStructures/LaboratoryPlatingWall.cs +++ b/Walls/DraedonStructures/LaboratoryPlatingWall.cs @@ -3,7 +3,7 @@ using Microsoft.Xna.Framework; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { - public class LaboratoryPlatingWall : ModWall + public class LaboratoryPlatingWall : ModWall { public override void SetDefaults() diff --git a/Walls/DraedonStructures/RustedPlatingWall.cs b/Walls/DraedonStructures/RustedPlatingWall.cs index 8950c4c2e2..90ba394c24 100644 --- a/Walls/DraedonStructures/RustedPlatingWall.cs +++ b/Walls/DraedonStructures/RustedPlatingWall.cs @@ -3,7 +3,7 @@ using Microsoft.Xna.Framework; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { - public class RustedPlatingWall : ModWall + public class RustedPlatingWall : ModWall { public override void SetDefaults() diff --git a/Waters/AbyssWater.cs b/Waters/AbyssWater.cs index 76bc725e05..e611aba111 100644 --- a/Waters/AbyssWater.cs +++ b/Waters/AbyssWater.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Waters { public override bool ChooseWaterStyle() { - CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); + CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); return modPlayer.ZoneAbyss; } diff --git a/Waters/AstralWater.cs b/Waters/AstralWater.cs index 82d110d09d..cfa10fc018 100644 --- a/Waters/AstralWater.cs +++ b/Waters/AstralWater.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Waters { public override bool ChooseWaterStyle() { - CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); + CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); return modPlayer.ZoneAstral; } diff --git a/Waters/CragsLavaStyle.cs b/Waters/CragsLavaStyle.cs index cb0fd9824d..971ac0d8e7 100644 --- a/Waters/CragsLavaStyle.cs +++ b/Waters/CragsLavaStyle.cs @@ -4,27 +4,27 @@ using Terraria.ModLoader; namespace CalamityMod.Waters { - public class CragsLavaflow : ModWaterfallStyle { } + public class CragsLavaflow : ModWaterfallStyle { } - public class CragsLavaStyle : CustomLavaStyle - { - public override string LavaTexturePath => "CalamityMod/Waters/CragsLava"; + public class CragsLavaStyle : CustomLavaStyle + { + public override string LavaTexturePath => "CalamityMod/Waters/CragsLava"; - public override string BlockTexturePath => LavaTexturePath + "_Block"; + public override string BlockTexturePath => LavaTexturePath + "_Block"; - public override bool ChooseLavaStyle() => Main.LocalPlayer.Calamity().ZoneCalamity; + public override bool ChooseLavaStyle() => Main.LocalPlayer.Calamity().ZoneCalamity; - public override int ChooseWaterfallStyle() => CalamityMod.Instance.GetWaterfallStyleSlot("CragsLavaflow"); + public override int ChooseWaterfallStyle() => CalamityMod.Instance.GetWaterfallStyleSlot("CragsLavaflow"); - public override int GetSplashDust() => 0; + public override int GetSplashDust() => 0; - public override int GetDropletGore() => 0; + public override int GetDropletGore() => 0; - public override void SelectLightColor(ref Color initialLightColor) - { - initialLightColor = Color.Lerp(initialLightColor, Color.White, 0.5f); - initialLightColor = Color.Lerp(initialLightColor, Color.DarkRed, 0.45f); - initialLightColor.A = 255; - } - } + public override void SelectLightColor(ref Color initialLightColor) + { + initialLightColor = Color.Lerp(initialLightColor, Color.White, 0.5f); + initialLightColor = Color.Lerp(initialLightColor, Color.DarkRed, 0.45f); + initialLightColor.A = 255; + } + } } diff --git a/Waters/CustomLavaStyle.cs b/Waters/CustomLavaStyle.cs index ef83e7c100..15ad98ccaf 100644 --- a/Waters/CustomLavaStyle.cs +++ b/Waters/CustomLavaStyle.cs @@ -6,41 +6,41 @@ using Terraria.ModLoader; namespace CalamityMod.Waters { - public abstract class CustomLavaStyle - { - internal Texture2D LavaTexture; - internal Texture2D BlockTexture; + public abstract class CustomLavaStyle + { + internal Texture2D LavaTexture; + internal Texture2D BlockTexture; - internal void Load() + internal void Load() { - // Don't load textures serverside. - if (Main.netMode == NetmodeID.Server) - return; + // Don't load textures serverside. + if (Main.netMode == NetmodeID.Server) + return; - LavaTexture = ModContent.GetTexture(LavaTexturePath); - BlockTexture = ModContent.GetTexture(BlockTexturePath); - } + LavaTexture = ModContent.GetTexture(LavaTexturePath); + BlockTexture = ModContent.GetTexture(BlockTexturePath); + } - internal void Unload() + internal void Unload() { - LavaTexture = null; - BlockTexture = null; - } + LavaTexture = null; + BlockTexture = null; + } - public abstract string LavaTexturePath { get; } + public abstract string LavaTexturePath { get; } - public abstract string BlockTexturePath { get; } + public abstract string BlockTexturePath { get; } - public virtual bool ChooseLavaStyle() => false; + public virtual bool ChooseLavaStyle() => false; - public abstract int ChooseWaterfallStyle(); + public abstract int ChooseWaterfallStyle(); - public abstract int GetSplashDust(); + public abstract int GetSplashDust(); - public abstract int GetDropletGore(); + public abstract int GetDropletGore(); - public virtual void SelectLightColor(ref Color initialLightColor) - { - } - } + public virtual void SelectLightColor(ref Color initialLightColor) + { + } + } } diff --git a/Waters/SulphuricWater.cs b/Waters/SulphuricWater.cs index 61d90d8335..13d93e5794 100644 --- a/Waters/SulphuricWater.cs +++ b/Waters/SulphuricWater.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Waters bool inYZone = Main.LocalPlayer.Center.Y < Main.rockLayer * 16f - 320 && Main.LocalPlayer.Center.Y >= 5800f; - CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); - bool greenWater = (inXZone && inYZone) || modPlayer.ZoneSulphur; + CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); + bool greenWater = (inXZone && inYZone) || modPlayer.ZoneSulphur; return greenWater; } diff --git a/Waters/SunkenSeaWater.cs b/Waters/SunkenSeaWater.cs index e8cb9e7ff5..8dc8eac1eb 100644 --- a/Waters/SunkenSeaWater.cs +++ b/Waters/SunkenSeaWater.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Waters { public override bool ChooseWaterStyle() { - CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); + CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); return modPlayer.ZoneSunkenSea; } diff --git a/World/Abyss.cs b/World/Abyss.cs index 3bb51503c8..c8e1c54000 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -18,350 +18,350 @@ using Terraria.ModLoader; namespace CalamityMod.World { - public class Abyss - { - public static void PlaceAbyss() - { - int x = Main.maxTilesX; - int y = Main.maxTilesY; - int genLimit = x / 2; - int rockLayer = (int)Main.rockLayer; + public class Abyss + { + public static void PlaceAbyss() + { + int x = Main.maxTilesX; + int y = Main.maxTilesY; + int genLimit = x / 2; + int rockLayer = (int)Main.rockLayer; - int abyssChasmY = y - 250; //Underworld = y - 200 - CalamityWorld.abyssChasmBottom = abyssChasmY - 100; //850 small 1450 medium 2050 large - int abyssChasmX = CalamityWorld.abyssSide ? genLimit - (genLimit - 135) : genLimit + (genLimit - 135); //2100 - 1965 = 135 : 2100 + 1965 = 4065 + int abyssChasmY = y - 250; //Underworld = y - 200 + CalamityWorld.abyssChasmBottom = abyssChasmY - 100; //850 small 1450 medium 2050 large + int abyssChasmX = CalamityWorld.abyssSide ? genLimit - (genLimit - 135) : genLimit + (genLimit - 135); //2100 - 1965 = 135 : 2100 + 1965 = 4065 - bool tenebrisSide = true; - if (abyssChasmX < genLimit) - tenebrisSide = false; + bool tenebrisSide = true; + if (abyssChasmX < genLimit) + tenebrisSide = false; - if (CalamityWorld.abyssSide) - { - for (int abyssIndex = 0; abyssIndex < abyssChasmX + 80; abyssIndex++) //235 - { - for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) - { - Tile tile = Framing.GetTileSafely(abyssIndex, abyssIndex2); - bool canConvert = tile.active() && - tile.type < TileID.Count && - tile.type != TileID.DyePlants && - tile.type != TileID.Trees && - tile.type != TileID.PalmTree && - tile.type != TileID.Sand && - tile.type != TileID.Containers && - tile.type != TileID.Coral && - tile.type != TileID.BeachPiles && - tile.type != ModContent.TileType() && - tile.type != ModContent.TileType(); - if (abyssIndex2 > rockLayer - WorldGen.genRand.Next(30)) - { - if (abyssIndex > abyssChasmX + 75 - WorldGen.genRand.Next(30)) - { - if (WorldGen.genRand.Next(4) == 0) - { - if (canConvert) - { - tile.wall = (ushort)ModContent.WallType(); - tile.type = (ushort)ModContent.TileType(); - } - else if (!tile.active()) - { - tile.active(true); - tile.wall = (ushort)ModContent.WallType(); - tile.type = (ushort)ModContent.TileType(); - } - } - } - else if (abyssIndex > abyssChasmX + 70) - { - if (WorldGen.genRand.Next(2) == 0) - { - if (canConvert) - { - tile.wall = (ushort)ModContent.WallType(); - tile.type = (ushort)ModContent.TileType(); - } - else if (!tile.active()) - { - tile.active(true); - tile.wall = (ushort)ModContent.WallType(); - tile.type = (ushort)ModContent.TileType(); - } - } - } - else - { - if (canConvert) - { - if (abyssIndex2 > (rockLayer + y * 0.262)) - { - tile.type = (ushort)ModContent.TileType(); - tile.wall = (ushort)ModContent.WallType(); - } - else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.Next(3) == 0) - { - tile.type = (ushort)ModContent.TileType(); - tile.wall = (ushort)ModContent.WallType(); - } - else - { - tile.type = (ushort)ModContent.TileType(); - tile.wall = (ushort)ModContent.WallType(); - } - } - else if (!tile.active()) - { - tile.active(true); - if (abyssIndex2 > (rockLayer + y * 0.262)) - { - tile.type = (ushort)ModContent.TileType(); - tile.wall = (ushort)ModContent.WallType(); - } - else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.Next(3) == 0) - { - tile.type = (ushort)ModContent.TileType(); - tile.wall = (ushort)ModContent.WallType(); - } - else - { - tile.wall = (ushort)ModContent.WallType(); - tile.type = (ushort)ModContent.TileType(); - } - } - } - } - } - } - } - else - { - for (int abyssIndex = abyssChasmX - 80; abyssIndex < x; abyssIndex++) //3965 - { - for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) - { - Tile tile = Framing.GetTileSafely(abyssIndex, abyssIndex2); - bool canConvert = tile.active() && - tile.type < TileID.Count && - tile.type != TileID.DyePlants && - tile.type != TileID.Trees && - tile.type != TileID.PalmTree && - tile.type != TileID.Sand && - tile.type != TileID.Containers && - tile.type != TileID.Coral && - tile.type != TileID.BeachPiles; - if (abyssIndex2 > rockLayer - WorldGen.genRand.Next(30)) - { - if (abyssIndex < abyssChasmX - 75) - { - if (WorldGen.genRand.Next(4) == 0) - { - if (canConvert) - { - tile.wall = (ushort)ModContent.WallType(); - tile.type = (ushort)ModContent.TileType(); - } - else if (!tile.active()) - { - tile.active(true); - tile.wall = (ushort)ModContent.WallType(); - tile.type = (ushort)ModContent.TileType(); - } - } - } - else if (abyssIndex < abyssChasmX - 70) - { - if (WorldGen.genRand.Next(2) == 0) - { - if (canConvert) - { - tile.wall = (ushort)ModContent.WallType(); - tile.type = (ushort)ModContent.TileType(); - } - else if (!tile.active()) - { - tile.active(true); - tile.wall = (ushort)ModContent.WallType(); - tile.type = (ushort)ModContent.TileType(); - } - } - } - else - { - if (canConvert) - { - if (abyssIndex2 > (rockLayer + y * 0.262)) - { - tile.type = (ushort)ModContent.TileType(); - tile.wall = (ushort)ModContent.WallType(); - } - else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.Next(3) == 0) - { - tile.type = (ushort)ModContent.TileType(); - tile.wall = (ushort)ModContent.WallType(); - } - else - { - tile.type = (ushort)ModContent.TileType(); - tile.wall = (ushort)ModContent.WallType(); - } - } - else if (!tile.active()) - { - tile.active(true); - if (abyssIndex2 > (rockLayer + y * 0.262)) - { - tile.type = (ushort)ModContent.TileType(); - tile.wall = (ushort)ModContent.WallType(); - } - else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.Next(3) == 0) - { - tile.type = (ushort)ModContent.TileType(); - tile.wall = (ushort)ModContent.WallType(); - } - else - { - tile.wall = (ushort)ModContent.WallType(); - tile.type = (ushort)ModContent.TileType(); - } - } - } - } - } - } - } + if (CalamityWorld.abyssSide) + { + for (int abyssIndex = 0; abyssIndex < abyssChasmX + 80; abyssIndex++) //235 + { + for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) + { + Tile tile = Framing.GetTileSafely(abyssIndex, abyssIndex2); + bool canConvert = tile.active() && + tile.type < TileID.Count && + tile.type != TileID.DyePlants && + tile.type != TileID.Trees && + tile.type != TileID.PalmTree && + tile.type != TileID.Sand && + tile.type != TileID.Containers && + tile.type != TileID.Coral && + tile.type != TileID.BeachPiles && + tile.type != ModContent.TileType() && + tile.type != ModContent.TileType(); + if (abyssIndex2 > rockLayer - WorldGen.genRand.Next(30)) + { + if (abyssIndex > abyssChasmX + 75 - WorldGen.genRand.Next(30)) + { + if (WorldGen.genRand.Next(4) == 0) + { + if (canConvert) + { + tile.wall = (ushort)ModContent.WallType(); + tile.type = (ushort)ModContent.TileType(); + } + else if (!tile.active()) + { + tile.active(true); + tile.wall = (ushort)ModContent.WallType(); + tile.type = (ushort)ModContent.TileType(); + } + } + } + else if (abyssIndex > abyssChasmX + 70) + { + if (WorldGen.genRand.Next(2) == 0) + { + if (canConvert) + { + tile.wall = (ushort)ModContent.WallType(); + tile.type = (ushort)ModContent.TileType(); + } + else if (!tile.active()) + { + tile.active(true); + tile.wall = (ushort)ModContent.WallType(); + tile.type = (ushort)ModContent.TileType(); + } + } + } + else + { + if (canConvert) + { + if (abyssIndex2 > (rockLayer + y * 0.262)) + { + tile.type = (ushort)ModContent.TileType(); + tile.wall = (ushort)ModContent.WallType(); + } + else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.Next(3) == 0) + { + tile.type = (ushort)ModContent.TileType(); + tile.wall = (ushort)ModContent.WallType(); + } + else + { + tile.type = (ushort)ModContent.TileType(); + tile.wall = (ushort)ModContent.WallType(); + } + } + else if (!tile.active()) + { + tile.active(true); + if (abyssIndex2 > (rockLayer + y * 0.262)) + { + tile.type = (ushort)ModContent.TileType(); + tile.wall = (ushort)ModContent.WallType(); + } + else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.Next(3) == 0) + { + tile.type = (ushort)ModContent.TileType(); + tile.wall = (ushort)ModContent.WallType(); + } + else + { + tile.wall = (ushort)ModContent.WallType(); + tile.type = (ushort)ModContent.TileType(); + } + } + } + } + } + } + } + else + { + for (int abyssIndex = abyssChasmX - 80; abyssIndex < x; abyssIndex++) //3965 + { + for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) + { + Tile tile = Framing.GetTileSafely(abyssIndex, abyssIndex2); + bool canConvert = tile.active() && + tile.type < TileID.Count && + tile.type != TileID.DyePlants && + tile.type != TileID.Trees && + tile.type != TileID.PalmTree && + tile.type != TileID.Sand && + tile.type != TileID.Containers && + tile.type != TileID.Coral && + tile.type != TileID.BeachPiles; + if (abyssIndex2 > rockLayer - WorldGen.genRand.Next(30)) + { + if (abyssIndex < abyssChasmX - 75) + { + if (WorldGen.genRand.Next(4) == 0) + { + if (canConvert) + { + tile.wall = (ushort)ModContent.WallType(); + tile.type = (ushort)ModContent.TileType(); + } + else if (!tile.active()) + { + tile.active(true); + tile.wall = (ushort)ModContent.WallType(); + tile.type = (ushort)ModContent.TileType(); + } + } + } + else if (abyssIndex < abyssChasmX - 70) + { + if (WorldGen.genRand.Next(2) == 0) + { + if (canConvert) + { + tile.wall = (ushort)ModContent.WallType(); + tile.type = (ushort)ModContent.TileType(); + } + else if (!tile.active()) + { + tile.active(true); + tile.wall = (ushort)ModContent.WallType(); + tile.type = (ushort)ModContent.TileType(); + } + } + } + else + { + if (canConvert) + { + if (abyssIndex2 > (rockLayer + y * 0.262)) + { + tile.type = (ushort)ModContent.TileType(); + tile.wall = (ushort)ModContent.WallType(); + } + else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.Next(3) == 0) + { + tile.type = (ushort)ModContent.TileType(); + tile.wall = (ushort)ModContent.WallType(); + } + else + { + tile.type = (ushort)ModContent.TileType(); + tile.wall = (ushort)ModContent.WallType(); + } + } + else if (!tile.active()) + { + tile.active(true); + if (abyssIndex2 > (rockLayer + y * 0.262)) + { + tile.type = (ushort)ModContent.TileType(); + tile.wall = (ushort)ModContent.WallType(); + } + else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.Next(3) == 0) + { + tile.type = (ushort)ModContent.TileType(); + tile.wall = (ushort)ModContent.WallType(); + } + else + { + tile.wall = (ushort)ModContent.WallType(); + tile.type = (ushort)ModContent.TileType(); + } + } + } + } + } + } + } - MiscWorldgenRoutines.ChasmGenerator(abyssChasmX, (int)WorldGen.worldSurfaceLow, CalamityWorld.abyssChasmBottom, true); + MiscWorldgenRoutines.ChasmGenerator(abyssChasmX, (int)WorldGen.worldSurfaceLow, CalamityWorld.abyssChasmBottom, true); - int maxAbyssIslands = 11; //Small World - if (y > 2100) - maxAbyssIslands = 20; //Large World - else if (y > 1500) - maxAbyssIslands = 16; //Medium World + int maxAbyssIslands = 11; //Small World + if (y > 2100) + maxAbyssIslands = 20; //Large World + else if (y > 1500) + maxAbyssIslands = 16; //Medium World - // Place the Terminus shrine. - UndergroundShrines.SpecialHut((ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.WallType(), UndergroundShrines.UndergroundShrineType.Abyss, abyssChasmX, CalamityWorld.abyssChasmBottom); + // Place the Terminus shrine. + UndergroundShrines.SpecialHut((ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.WallType(), UndergroundShrines.UndergroundShrineType.Abyss, abyssChasmX, CalamityWorld.abyssChasmBottom); - int islandLocationOffset = 30; - int islandLocationY = rockLayer; - for (int islands = 0; islands < maxAbyssIslands; islands++) - { - int islandLocationX = abyssChasmX; - int randomIsland = WorldGen.genRand.Next(5); //0 1 2 3 4 - bool hasVoidstone = islandLocationY > (rockLayer + y * 0.143); - CalamityWorld.AbyssIslandY[CalamityWorld.numAbyssIslands] = islandLocationY; - switch (randomIsland) - { - case 0: - AbyssIsland(islandLocationX, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); - AbyssIsland(islandLocationX + 40, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); - AbyssIsland(islandLocationX - 40, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); - break; - case 1: - AbyssIsland(islandLocationX + 30, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); - AbyssIsland(islandLocationX, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); - AbyssIsland(islandLocationX - 40, islandLocationY + 10, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); - islandLocationX += 30; - break; - case 2: - AbyssIsland(islandLocationX - 30, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); - AbyssIsland(islandLocationX + 30, islandLocationY + 10, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); - AbyssIsland(islandLocationX, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); - islandLocationX -= 30; - break; - case 3: - AbyssIsland(islandLocationX + 25, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); - AbyssIsland(islandLocationX - 5, islandLocationY + 5, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); - AbyssIsland(islandLocationX - 35, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); - islandLocationX += 25; - break; - case 4: - AbyssIsland(islandLocationX - 25, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); - AbyssIsland(islandLocationX + 5, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); - AbyssIsland(islandLocationX + 35, islandLocationY + 5, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); - islandLocationX -= 25; - break; - } + int islandLocationOffset = 30; + int islandLocationY = rockLayer; + for (int islands = 0; islands < maxAbyssIslands; islands++) + { + int islandLocationX = abyssChasmX; + int randomIsland = WorldGen.genRand.Next(5); //0 1 2 3 4 + bool hasVoidstone = islandLocationY > (rockLayer + y * 0.143); + CalamityWorld.AbyssIslandY[CalamityWorld.numAbyssIslands] = islandLocationY; + switch (randomIsland) + { + case 0: + AbyssIsland(islandLocationX, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); + AbyssIsland(islandLocationX + 40, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX - 40, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); + break; + case 1: + AbyssIsland(islandLocationX + 30, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); + AbyssIsland(islandLocationX, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX - 40, islandLocationY + 10, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); + islandLocationX += 30; + break; + case 2: + AbyssIsland(islandLocationX - 30, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); + AbyssIsland(islandLocationX + 30, islandLocationY + 10, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); + islandLocationX -= 30; + break; + case 3: + AbyssIsland(islandLocationX + 25, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); + AbyssIsland(islandLocationX - 5, islandLocationY + 5, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX - 35, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); + islandLocationX += 25; + break; + case 4: + AbyssIsland(islandLocationX - 25, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); + AbyssIsland(islandLocationX + 5, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX + 35, islandLocationY + 5, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); + islandLocationX -= 25; + break; + } - CalamityWorld.AbyssIslandX[CalamityWorld.numAbyssIslands] = islandLocationX; - CalamityWorld.numAbyssIslands++; + CalamityWorld.AbyssIslandX[CalamityWorld.numAbyssIslands] = islandLocationX; + CalamityWorld.numAbyssIslands++; - islandLocationY += islandLocationOffset; - if (islandLocationY >= CalamityWorld.abyssChasmBottom - 50) - break; - } + islandLocationY += islandLocationOffset; + if (islandLocationY >= CalamityWorld.abyssChasmBottom - 50) + break; + } - CalamityWorld.AbyssItemArray = CalamityUtils.ShuffleArray(CalamityWorld.AbyssItemArray); - for (int abyssHouse = 0; abyssHouse < CalamityWorld.numAbyssIslands; abyssHouse++) //11 15 19 - { - if (abyssHouse != 20) - AbyssIslandHouse(CalamityWorld.AbyssIslandX[abyssHouse], - CalamityWorld.AbyssIslandY[abyssHouse], - CalamityWorld.AbyssItemArray[abyssHouse > 9 ? (abyssHouse - 10) : abyssHouse], //10 choices 0 to 9 - CalamityWorld.AbyssIslandY[abyssHouse] > (rockLayer + y * 0.143)); - } + CalamityWorld.AbyssItemArray = CalamityUtils.ShuffleArray(CalamityWorld.AbyssItemArray); + for (int abyssHouse = 0; abyssHouse < CalamityWorld.numAbyssIslands; abyssHouse++) //11 15 19 + { + if (abyssHouse != 20) + AbyssIslandHouse(CalamityWorld.AbyssIslandX[abyssHouse], + CalamityWorld.AbyssIslandY[abyssHouse], + CalamityWorld.AbyssItemArray[abyssHouse > 9 ? (abyssHouse - 10) : abyssHouse], //10 choices 0 to 9 + CalamityWorld.AbyssIslandY[abyssHouse] > (rockLayer + y * 0.143)); + } - if (CalamityWorld.abyssSide) - { - for (int abyssIndex = 0; abyssIndex < abyssChasmX + 80; abyssIndex++) //235 - { - for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) - { - if (!Main.tile[abyssIndex, abyssIndex2].active()) - { - if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && - abyssIndex2 > rockLayer) - { - if (WorldGen.genRand.Next(5) == 0) - { - WorldGen.PlacePot(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); - CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true); - } - } - else if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && - abyssIndex2 < (int)Main.worldSurface) - { - if (WorldGen.genRand.Next(3) == 0) - { - WorldGen.PlacePot(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); - CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true); - } - } - } - } - } - } - else - { - for (int abyssIndex = abyssChasmX - 80; abyssIndex < x; abyssIndex++) //3965 - { - for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) - { - if (!Main.tile[abyssIndex, abyssIndex2].active()) - { - if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && - abyssIndex2 > rockLayer) - { - if (WorldGen.genRand.Next(5) == 0) - { - WorldGen.PlacePot(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); - CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true); - } - } - else if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && - abyssIndex2 < (int)Main.worldSurface) - { - if (WorldGen.genRand.Next(3) == 0) - { - WorldGen.PlacePot(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); - CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true); - } - } - } - } - } - } - } + if (CalamityWorld.abyssSide) + { + for (int abyssIndex = 0; abyssIndex < abyssChasmX + 80; abyssIndex++) //235 + { + for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) + { + if (!Main.tile[abyssIndex, abyssIndex2].active()) + { + if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && + abyssIndex2 > rockLayer) + { + if (WorldGen.genRand.Next(5) == 0) + { + WorldGen.PlacePot(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); + CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true); + } + } + else if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && + abyssIndex2 < (int)Main.worldSurface) + { + if (WorldGen.genRand.Next(3) == 0) + { + WorldGen.PlacePot(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); + CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true); + } + } + } + } + } + } + else + { + for (int abyssIndex = abyssChasmX - 80; abyssIndex < x; abyssIndex++) //3965 + { + for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY; abyssIndex2++) + { + if (!Main.tile[abyssIndex, abyssIndex2].active()) + { + if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && + abyssIndex2 > rockLayer) + { + if (WorldGen.genRand.Next(5) == 0) + { + WorldGen.PlacePot(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); + CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true); + } + } + else if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && + abyssIndex2 < (int)Main.worldSurface) + { + if (WorldGen.genRand.Next(3) == 0) + { + WorldGen.PlacePot(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); + CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true); + } + } + } + } + } + } + } #region Houses public static void AbyssIsland(int i, int j, int sizeMin, int sizeMax, int sizeMin2, int sizeMax2, bool hasChest, bool hasTenebris, bool isVoid) diff --git a/World/AstralBiome.cs b/World/AstralBiome.cs index 66622f896b..ceb49bda5c 100644 --- a/World/AstralBiome.cs +++ b/World/AstralBiome.cs @@ -17,7 +17,7 @@ using Terraria.World.Generation; namespace CalamityMod.World { - public class AstralBiome + public class AstralBiome { public static bool CanAstralMeteorSpawn() { diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index f2c6629077..1293e15b4d 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -26,7 +26,7 @@ using Terraria.World.Generation; namespace CalamityMod.World { - public partial class CalamityWorld : ModWorld + public partial class CalamityWorld : ModWorld { #region Vars public static int DoGSecondStageCountdown = 0; @@ -50,7 +50,7 @@ namespace CalamityMod.World // New Temple Altar public static int newAltarX = 0; public static int newAltarY = 0; - + // Evil Islands public static int fehX = 0; public static int fehY = 0; @@ -238,8 +238,8 @@ namespace CalamityMod.World CalamityGlobalNPC.fireEye = -1; CalamityGlobalNPC.brimstoneElemental = -1; CalamityGlobalNPC.signus = -1; - CalamityGlobalNPC.draedonExoMechPrimePlasmaCannon = -1; - CalamityGlobalNPC.draedonExoMechPrime = -1; + CalamityGlobalNPC.draedonExoMechPrimePlasmaCannon = -1; + CalamityGlobalNPC.draedonExoMechPrime = -1; CalamityGlobalNPC.draedonExoMechTwinGreen = -1; CalamityGlobalNPC.draedonExoMechTwinRed = -1; CalamityGlobalNPC.draedonExoMechWorm = -1; @@ -751,7 +751,7 @@ namespace CalamityMod.World downedAres = flags11[4]; downedThanatos = flags11[5]; downedArtemisAndApollo = flags11[6]; - TalkedToDraedon = flags11[7]; + TalkedToDraedon = flags11[7]; } else { @@ -1017,9 +1017,9 @@ namespace CalamityMod.World downedArtemisAndApollo = flags11[6]; TalkedToDraedon = flags11[7]; - RecipeUnlockHandler.ReceiveData(reader); + RecipeUnlockHandler.ReceiveData(reader); - abyssChasmBottom = reader.ReadInt32(); + abyssChasmBottom = reader.ReadInt32(); acidRainPoints = reader.ReadInt32(); Reforges = reader.ReadInt32(); MoneyStolenByBandit = reader.ReadInt32(); diff --git a/World/CustomTemple.cs b/World/CustomTemple.cs index 8edbdb85c7..3f044935f2 100644 --- a/World/CustomTemple.cs +++ b/World/CustomTemple.cs @@ -5,917 +5,917 @@ using Terraria.ID; namespace CalamityMod.World { - public class CustomTemple + public class CustomTemple { - public static void NewJungleTemple() - { - bool success = false; - while (!success) - { - int x; - if (WorldGen.dungeonX < Main.maxTilesX / 2) - x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.6), (int)(Main.maxTilesX * 0.85)); - else - x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.15), (int)(Main.maxTilesX * 0.4)); - - int y = WorldGen.genRand.Next((int)Main.rockLayer, Main.maxTilesY - 500); - - if (Main.tile[x, y].active() && Main.tile[x, y].type == 60) - { - success = true; - GenNewTemple(x, y); - } - } - } - - public static void GenNewTemple(int x, int y) - { - Rectangle[] roomBounds = new Rectangle[200]; - float worldScale = Main.maxTilesX / 4200f; - int totalRooms = (int)(worldScale * WorldGen.genRand.Next(12, 16)); - int xDirection = WorldGen.genRand.NextBool(2).ToDirectionInt(); - int initalDirection = xDirection; - int pathPositionX = x; - int pathPositionY = y; - int currentRoomPositionX = x; - int currentRoomPositionY = y; - int xDirectionChangePromptThreshold = WorldGen.genRand.Next(1, 3); - int totalAttempts = 0; - - // Temple room sizes. - for (int i = 0; i < totalRooms; i++) - { - totalAttempts++; - int currentXDirection = xDirection; - int roomPositionX = currentRoomPositionX; - int roomPositionY = currentRoomPositionY; - bool isValidRoom = false; - int width = 0; - int height = 0; - int xOffset = -10; - Rectangle rectangle = new Rectangle(roomPositionX - width / 2, roomPositionY - height / 2, width, height); - while (!isValidRoom) - { - roomPositionX = currentRoomPositionX; - roomPositionY = currentRoomPositionY; - - // Typical temple room size. - width = WorldGen.genRand.Next(30, 46); - height = WorldGen.genRand.Next(25, 31); - - // Final temple room size. - if (i == totalRooms - 1) - { - width = WorldGen.genRand.Next(105, 116); - height = WorldGen.genRand.Next(90, 106); - roomPositionY += WorldGen.genRand.Next(6, 9); - } - - if (totalAttempts > xDirectionChangePromptThreshold) - { - roomPositionY += WorldGen.genRand.Next(height + 1, height + 3) + xOffset; - roomPositionX += WorldGen.genRand.Next(-2, 3); - currentXDirection = xDirection * -1; - } - else - { - roomPositionX += (WorldGen.genRand.Next(width + 1, width + 3) + xOffset) * currentXDirection; - roomPositionY += WorldGen.genRand.Next(-2, 3); - } - - // Ensure that the new room doesn't intersect any other existing rooms. - isValidRoom = true; - rectangle = new Rectangle(roomPositionX - width / 2, roomPositionY - height / 2, width, height); - for (int j = 0; j < i; j++) - { - if (rectangle.Intersects(roomBounds[j])) - isValidRoom = false; - if (WorldGen.genRand.Next(100) == 0) - { - xOffset++; - } - } - } - if (totalAttempts > xDirectionChangePromptThreshold) - { - xDirectionChangePromptThreshold++; - totalAttempts = 1; - } - - // Update the old values after valid room bounds have been determined. - roomBounds[i] = rectangle; - xDirection = currentXDirection; - currentRoomPositionX = roomPositionX; - currentRoomPositionY = roomPositionY; - } - - for (int i = 0; i < totalRooms; i++) - { - for (int j = 0; j < 2; j++) - { - for (int k = 0; k < totalRooms; k++) - { - for (int l = 0; l < 2; l++) - { - int roomPositionX = roomBounds[i].X; - if (j == 1) - roomPositionX += roomBounds[i].Width - 1; - - int roomTop = roomBounds[i].Y; - int roomBottom = roomTop + roomBounds[i].Height; - int checkRoomPositionX = roomBounds[k].X; - - if (l == 1) - checkRoomPositionX += roomBounds[k].Width - 1; - - int checkRoomTop = roomBounds[k].Y; - int checkRoomBottom = checkRoomTop + roomBounds[k].Height; - while (roomPositionX != checkRoomPositionX || roomTop != checkRoomTop || roomBottom != checkRoomBottom) - { - if (roomPositionX < checkRoomPositionX) - { - roomPositionX++; - } - if (roomPositionX > checkRoomPositionX) - { - roomPositionX--; - } - if (roomTop < checkRoomTop) - { - roomTop++; - } - if (roomTop > checkRoomTop) - { - roomTop--; - } - if (roomBottom < checkRoomBottom) - { - roomBottom++; - } - if (roomBottom > checkRoomBottom) - { - roomBottom--; - } - for (int roomPositionY = roomTop; roomPositionY < roomBottom; roomPositionY++) - { - Main.tile[roomPositionX, roomPositionY].active(true); - Main.tile[roomPositionX, roomPositionY].type = TileID.LihzahrdBrick; - Main.tile[roomPositionX, roomPositionY].liquid = 0; - Main.tile[roomPositionX, roomPositionY].slope(0); - Main.tile[roomPositionX, roomPositionY].halfBrick(false); - } - } - } - } - } - } - - // Cut out rooms and replace the empty space with walls. - for (int i = 0; i < totalRooms; i++) - { - bool isLastRoom = i == totalRooms - 1; - for (int roomPositionX = roomBounds[i].X; roomPositionX < roomBounds[i].X + roomBounds[i].Width; roomPositionX++) - { - for (int roomPositionY = roomBounds[i].Y; roomPositionY < roomBounds[i].Y + roomBounds[i].Height; roomPositionY++) - { - Main.tile[roomPositionX, roomPositionY].active(true); - Main.tile[roomPositionX, roomPositionY].type = TileID.LihzahrdBrick; - Main.tile[roomPositionX, roomPositionY].liquid = 0; - Main.tile[roomPositionX, roomPositionY].slope(0); - Main.tile[roomPositionX, roomPositionY].halfBrick(false); - } - } - - if (!isLastRoom) - GenerateGenericRoom(roomBounds[i]); - else - GenerateShrineRoom(roomBounds[i]); - } - - Vector2 pathPosition = new Vector2(pathPositionX, pathPositionY); - - // Cut out areas between rooms, creating corridors. - for (int i = 0; i < totalRooms; i++) - { - Rectangle destinationArea = roomBounds[i]; - destinationArea.X += 8; - destinationArea.Y += 8; - destinationArea.Width -= 16; - destinationArea.Height -= 16; - - // Recursively attempt to reach the next room and empty anything in said path. - bool reachedDestination = false; - while (!reachedDestination) - { - int destinationX = WorldGen.genRand.Next(destinationArea.X, destinationArea.X + destinationArea.Width); - int destinationY = WorldGen.genRand.Next(destinationArea.Y, destinationArea.Y + destinationArea.Height); - pathPosition = WorldGen.templePather(pathPosition, destinationX, destinationY); - - if (pathPosition.X == destinationX && pathPosition.Y == destinationY) - reachedDestination = true; - } - if (i < totalRooms - 1) - { - reachedDestination = false; - if (WorldGen.genRand.Next(3) != 0) - { - Rectangle nextRoom = roomBounds[i + 1]; - if (nextRoom.Y >= roomBounds[i].Y + roomBounds[i].Height) - { - destinationArea.X = nextRoom.X; - - if (nextRoom.X < roomBounds[i].X) - destinationArea.X += (int)(nextRoom.Width * 0.2); - else destinationArea.X += (int)(nextRoom.Width * 0.8f); - - destinationArea.Y = nextRoom.Y; - } - else - { - destinationArea.X = (roomBounds[i].X + roomBounds[i].Width / 2 + nextRoom.X + nextRoom.Width / 2) / 2; - destinationArea.Y = (int)(nextRoom.Y + nextRoom.Height * 0.8); - } - while (!reachedDestination) - { - int destinationX = WorldGen.genRand.Next(destinationArea.X - 4, destinationArea.X + 5); - int destinationY = WorldGen.genRand.Next(destinationArea.Y - 4, destinationArea.Y + 5); - pathPosition = WorldGen.templePather(pathPosition, destinationX, destinationY); - if (pathPosition.X == destinationX && pathPosition.Y == destinationY) - reachedDestination = true; - } - } - else - { - Rectangle nextRoom = roomBounds[i + 1]; - int roomCenterMidpointX = (roomBounds[i].X + roomBounds[i].Width / 2 + nextRoom.X + nextRoom.Width / 2) / 2; - int roomCenterMidpointY = (roomBounds[i].Y + roomBounds[i].Height / 2 + nextRoom.Y + nextRoom.Height / 2) / 2; - while (!reachedDestination) - { - int destinationX = WorldGen.genRand.Next(roomCenterMidpointX - 4, roomCenterMidpointX + 5); - int destinationY = WorldGen.genRand.Next(roomCenterMidpointY - 4, roomCenterMidpointY + 5); - pathPosition = WorldGen.templePather(pathPosition, destinationX, destinationY); - if (pathPosition.X == destinationX && pathPosition.Y == destinationY) - reachedDestination = true; - } - } - } - } - - int farthestRoomLeft = Main.maxTilesX - 20; - int farthestRoomRight = 20; - int farthestRoomTop = Main.maxTilesY - 20; - int farthestRoomBottom = 20; - for (int i = 0; i < totalRooms; i++) - { - if (roomBounds[i].X < farthestRoomLeft) - { - farthestRoomLeft = roomBounds[i].X; - } - if (roomBounds[i].X + roomBounds[i].Width > farthestRoomRight) - { - farthestRoomRight = roomBounds[i].X + roomBounds[i].Width; - } - if (roomBounds[i].Y < farthestRoomTop) - { - farthestRoomTop = roomBounds[i].Y; - } - if (roomBounds[i].Y + roomBounds[i].Height > farthestRoomBottom) - { - farthestRoomBottom = roomBounds[i].Y + roomBounds[i].Height; - } - } - - // Create outer temple shape. - farthestRoomLeft -= 10; - farthestRoomRight += 10; - farthestRoomTop -= 10; - farthestRoomBottom += 10; - - for (int xRoomPosition = farthestRoomLeft; xRoomPosition < farthestRoomRight; xRoomPosition++) - { - for (int roomPositionY = farthestRoomTop; roomPositionY < farthestRoomBottom; roomPositionY++) - { - WorldGen.outerTempled(xRoomPosition, roomPositionY); - } - } - for (int xRoomPosition = farthestRoomRight; xRoomPosition >= farthestRoomLeft; xRoomPosition--) - { - for (int yRoomPosition = farthestRoomTop; yRoomPosition < farthestRoomBottom / 2; yRoomPosition++) - { - WorldGen.outerTempled(xRoomPosition, yRoomPosition); - } - } - for (int yRoomPosition = farthestRoomTop; yRoomPosition < farthestRoomBottom; yRoomPosition++) - { - for (int xRoomPosition = farthestRoomLeft; xRoomPosition < farthestRoomRight; xRoomPosition++) - { - WorldGen.outerTempled(xRoomPosition, yRoomPosition); - } - } - for (int yRoomPosition = farthestRoomBottom; yRoomPosition >= farthestRoomTop; yRoomPosition--) - { - for (int xRoomPosition = farthestRoomLeft; xRoomPosition < farthestRoomRight; xRoomPosition++) - { - WorldGen.outerTempled(xRoomPosition, yRoomPosition); - } - } - - // Move downward and prepare to have the tunnel go in the opposite direction(?) - xDirection = -initalDirection; - Vector2 endPathPosition = new Vector2(pathPositionX, pathPositionY); - int yArea = 4; - bool success = false; - int totralDescentTries = 0; - int endPathRisePrompt = WorldGen.genRand.Next(12, 14); - while (!success) - { - totralDescentTries++; - if (totralDescentTries >= endPathRisePrompt) - { - totralDescentTries = 0; - endPathPosition.Y--; - } - endPathPosition.X += xDirection; - success = true; - int dy = (int)endPathPosition.Y - yArea; - while (dy < endPathPosition.Y + yArea) - { - if (Main.tile[(int)endPathPosition.X, dy].wall == WallID.LihzahrdBrickUnsafe || (Main.tile[(int)endPathPosition.X, dy].active() && Main.tile[(int)endPathPosition.X, dy].type == TileID.LihzahrdBrick)) - { - success = false; - } - if (Main.tile[(int)endPathPosition.X, dy].active() && Main.tile[(int)endPathPosition.X, dy].type == TileID.LihzahrdBrick) - { - Main.tile[(int)endPathPosition.X, dy].active(false); - Main.tile[(int)endPathPosition.X, dy].wall = WallID.LihzahrdBrickUnsafe; - } - dy++; - } - } - - // Place bricks and walls around temple door. - int doorPositionX = pathPositionX; - int doorPositionY = pathPositionY; - while (!Main.tile[doorPositionX, doorPositionY].active()) - { - doorPositionY++; - } - doorPositionY -= 4; - int doorTop = doorPositionY; - while ((Main.tile[doorPositionX, doorTop].active() && Main.tile[doorPositionX, doorTop].type == TileID.LihzahrdBrick) || Main.tile[doorPositionX, doorTop].wall == WallID.LihzahrdBrickUnsafe) - { - doorTop--; - } - doorTop += 2; - for (int dx = doorPositionX - 1; dx <= doorPositionX + 1; dx++) - { - for (int dy = doorTop; dy <= doorPositionY; dy++) - { - Main.tile[dx, dy].active(true); - Main.tile[dx, dy].type = TileID.LihzahrdBrick; - Main.tile[dx, dy].liquid = 0; - Main.tile[dx, dy].slope(0); - Main.tile[dx, dy].halfBrick(false); - } - } - for (int dx = doorPositionX - 4; dx <= doorPositionX + 4; dx++) - { - for (int dy = doorPositionY - 1; dy < doorPositionY + 3; dy++) - { - Main.tile[dx, dy].active(false); - Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; - } - } - for (int dx = doorPositionX - 1; dx <= doorPositionX + 1; dx++) - { - for (int dy = doorPositionY - 5; dy <= doorPositionY + 8; dy++) - { - Main.tile[dx, dy].active(true); - Main.tile[dx, dy].type = TileID.LihzahrdBrick; - Main.tile[dx, dy].liquid = 0; - Main.tile[dx, dy].slope(0); - Main.tile[dx, dy].halfBrick(false); - } - } - for (int dx = doorPositionX - 1; dx <= doorPositionX + 1; dx++) - { - for (int dy = doorPositionY; dy < doorPositionY + 3; dy++) - { - Main.tile[dx, dy].active(false); - Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; - } - } - - // Temple Door - WorldGen.PlaceTile(doorPositionX, doorPositionY, 10, true, false, -1, 11); - - // Clear space in temple - for (int dx = farthestRoomLeft; dx < farthestRoomRight; dx++) - { - for (int dy = farthestRoomTop; dy < farthestRoomBottom; dy++) - { - WorldGen.templeCleaner(dx, dy); - } - } - for (int dx = farthestRoomBottom; dx >= farthestRoomTop; dx--) - { - for (int dy = farthestRoomRight; dy >= farthestRoomLeft; dy--) - { - WorldGen.templeCleaner(dy, dx); - } - } - - // Place walls - for (int dx = farthestRoomLeft; dx < farthestRoomRight; dx++) - { - for (int dy = farthestRoomTop; dy < farthestRoomBottom; dy++) - { - bool shouldPlaceWalls = true; - for (int dx2 = dx - 1; dx2 <= dx + 1; dx2++) - { - for (int dy2 = dy - 1; dy2 <= dy + 1; dy2++) - { - if ((!Main.tile[dx2, dy2].active() || Main.tile[dx2, dy2].type != TileID.LihzahrdBrick) && Main.tile[dx2, dy2].wall != WallID.LihzahrdBrickUnsafe) - { - shouldPlaceWalls = false; - break; - } - } - } - if (shouldPlaceWalls) - { - Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; - } - } - } - - // Create temple spikes - float totalSpikeAreasToSawpn = totalRooms * 1.3f; - int spikeAreaSpawnAttempts = 0; - while (totalSpikeAreasToSawpn > 0f) - { - spikeAreaSpawnAttempts++; - int roomToFillIndex = WorldGen.genRand.Next(totalRooms); - int randomPointInRoomX = WorldGen.genRand.Next(roomBounds[roomToFillIndex].X, roomBounds[roomToFillIndex].X + roomBounds[roomToFillIndex].Width); - int randomPointInRoomY = WorldGen.genRand.Next(roomBounds[roomToFillIndex].Y, roomBounds[roomToFillIndex].Y + roomBounds[roomToFillIndex].Height); - if (Main.tile[randomPointInRoomX, randomPointInRoomY].wall == 87 && !Main.tile[randomPointInRoomX, randomPointInRoomY].active()) - { - bool successPlacingSpikes = false; - if (WorldGen.genRand.Next(2) == 0) - { - int xMoveDirection = WorldGen.genRand.NextBool(2).ToDirectionInt(); - while (!Main.tile[randomPointInRoomX, randomPointInRoomY].active()) - { - randomPointInRoomY += xMoveDirection; - } - randomPointInRoomY -= xMoveDirection; - int yMoveDirection = WorldGen.genRand.Next(2); - int areaToCheck = WorldGen.genRand.Next(8, 10); - bool noDoorInWay = true; - for (int dx = randomPointInRoomX - areaToCheck; dx < randomPointInRoomX + areaToCheck; dx++) - { - for (int dy = randomPointInRoomY - areaToCheck; dy < randomPointInRoomY + areaToCheck; dy++) - { - if (Main.tile[dx, dy].active() && Main.tile[dx, dy].type == 10) - { - noDoorInWay = false; - break; - } - } - } - if (noDoorInWay) - { - for (int dx = randomPointInRoomX - areaToCheck; dx < randomPointInRoomX + areaToCheck; dx++) - { - for (int dy = randomPointInRoomY - areaToCheck; dy < randomPointInRoomY + areaToCheck; dy++) - { - if (WorldGen.SolidTile(dx, dy) && Main.tile[dx, dy].type != TileID.WoodenSpikes && !WorldGen.SolidTile(dx, dy - xMoveDirection)) - { - Main.tile[dx, dy].type = TileID.WoodenSpikes; - successPlacingSpikes = true; - if (yMoveDirection == 0) - { - Main.tile[dx, dy - 1].type = TileID.WoodenSpikes; - Main.tile[dx, dy - 1].active(true); - } - else - { - Main.tile[dx, dy + 1].type = TileID.WoodenSpikes; - Main.tile[dx, dy + 1].active(true); - } - yMoveDirection++; - if (yMoveDirection > 1) - { - yMoveDirection = 0; - } - } - } - } - } - if (successPlacingSpikes) - { - spikeAreaSpawnAttempts = 0; - totalSpikeAreasToSawpn--; - } - } - else - { - int xMoveDirection = WorldGen.genRand.NextBool(2).ToDirectionInt(); - while (!Main.tile[randomPointInRoomX, randomPointInRoomY].active()) - { - randomPointInRoomX += xMoveDirection; - } - randomPointInRoomX -= xMoveDirection; - int yMoveDirection = WorldGen.genRand.Next(2); - int areaToCheck = WorldGen.genRand.Next(8, 10); - bool noDoorInWay = true; - for (int dx = randomPointInRoomX - areaToCheck; dx < randomPointInRoomX + areaToCheck; dx++) - { - for (int dy = randomPointInRoomY - areaToCheck; dy < randomPointInRoomY + areaToCheck; dy++) - { - if (Main.tile[dx, dy].active() && Main.tile[dx, dy].type == 10) - { - noDoorInWay = false; - break; - } - } - } - if (noDoorInWay) - { - for (int dx = randomPointInRoomX - areaToCheck; dx < randomPointInRoomX + areaToCheck; dx++) - { - for (int dy = randomPointInRoomY - areaToCheck; dy < randomPointInRoomY + areaToCheck; dy++) - { - if (WorldGen.SolidTile(dx, dy) && Main.tile[dx, dy].type != TileID.WoodenSpikes && !WorldGen.SolidTile(dx - xMoveDirection, dy)) - { - Main.tile[dx, dy].type = TileID.WoodenSpikes; - successPlacingSpikes = true; - if (yMoveDirection == 0) - { - Main.tile[dx - 1, dy].type = TileID.WoodenSpikes; - Main.tile[dx - 1, dy].active(true); - } - else - { - Main.tile[dx + 1, dy].type = TileID.WoodenSpikes; - Main.tile[dx + 1, dy].active(true); - } - yMoveDirection++; - if (yMoveDirection > 1) - { - yMoveDirection = 0; - } - } - } - } - } - if (successPlacingSpikes) - { - spikeAreaSpawnAttempts = 0; - totalSpikeAreasToSawpn--; - } - } - } - if (spikeAreaSpawnAttempts > 1000) - { - spikeAreaSpawnAttempts = 0; - totalSpikeAreasToSawpn--; - } - } - - // Set variables for the bounds and room count of the temple. - WorldGen.tLeft = farthestRoomLeft; - WorldGen.tRight = farthestRoomRight; - WorldGen.tTop = farthestRoomTop; - WorldGen.tBottom = farthestRoomBottom; - WorldGen.tRooms = totalRooms; - } - - public static void GenerateGenericRoom(Rectangle roomBounds) - { - int roomLeft = roomBounds.X; - int roomRight = roomLeft + roomBounds.Width; - int roomTop = roomBounds.Y; - int roomBottom = roomTop + roomBounds.Height; - - roomLeft += WorldGen.genRand.Next(4, 7); - roomRight -= WorldGen.genRand.Next(4, 7); - roomTop += WorldGen.genRand.Next(4, 7); - roomBottom -= WorldGen.genRand.Next(4, 7); - - int offsettedRoomLeft = roomLeft; - int offsettedRoomRight = roomRight; - int offsettedRoomTop = roomTop; - int offsettedRoomBottom = roomBottom; - - int roomCenterX = (roomLeft + roomRight) / 2; - int roomCenterY = (roomTop + roomBottom) / 2; - - // Cut out the rooms with a bit of randomness incorporated, so that the room is not entirely square. - for (int dx = roomLeft; dx < roomRight; dx++) - { - for (int dy = roomTop; dy < roomBottom; dy++) - { - if (WorldGen.genRand.NextBool(20)) - offsettedRoomTop += WorldGen.genRand.NextBool(2).ToDirectionInt(); - - if (WorldGen.genRand.NextBool(20)) - offsettedRoomBottom += WorldGen.genRand.NextBool(2).ToDirectionInt(); - - if (WorldGen.genRand.NextBool(20)) - offsettedRoomLeft += WorldGen.genRand.NextBool(2).ToDirectionInt(); - - if (WorldGen.genRand.NextBool(20)) - offsettedRoomRight += WorldGen.genRand.NextBool(2).ToDirectionInt(); - - offsettedRoomLeft = Utils.Clamp(offsettedRoomLeft, roomLeft, roomCenterX); - offsettedRoomRight = Utils.Clamp(offsettedRoomRight, roomCenterX, roomRight); - offsettedRoomTop = Utils.Clamp(offsettedRoomTop, roomTop, roomCenterY); - offsettedRoomBottom = Utils.Clamp(offsettedRoomBottom, roomCenterY, roomBottom); - - if (dx >= offsettedRoomLeft && (dx < offsettedRoomRight & dy >= offsettedRoomTop) && dy <= offsettedRoomBottom) - { - Main.tile[dx, dy].active(false); - Main.tile[dx, dy].liquid = 0; // Apparently this can indeed happen, and it can interfere with furniture placement. - Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; - } - } - } - for (int dy = roomBottom; dy > roomTop; dy--) - { - for (int dx = roomRight; dx > roomLeft; dx--) - { - if (WorldGen.genRand.NextBool(20)) - offsettedRoomTop += WorldGen.genRand.NextBool(2).ToDirectionInt(); - - if (WorldGen.genRand.NextBool(20)) - offsettedRoomBottom += WorldGen.genRand.NextBool(2).ToDirectionInt(); - - if (WorldGen.genRand.NextBool(20)) - offsettedRoomLeft += WorldGen.genRand.NextBool(2).ToDirectionInt(); - - if (WorldGen.genRand.NextBool(20)) - offsettedRoomRight += WorldGen.genRand.NextBool(2).ToDirectionInt(); - - offsettedRoomLeft = Utils.Clamp(offsettedRoomLeft, roomLeft, roomCenterX); - offsettedRoomRight = Utils.Clamp(offsettedRoomRight, roomCenterX, roomRight); - offsettedRoomTop = Utils.Clamp(offsettedRoomTop, roomTop, roomCenterY); - offsettedRoomBottom = Utils.Clamp(offsettedRoomBottom, roomCenterY, roomBottom); - - if (dx >= offsettedRoomLeft && (dx < offsettedRoomRight & dy >= offsettedRoomTop) && dy <= offsettedRoomBottom) - { - Main.tile[dx, dy].active(false); - Main.tile[dx, dy].liquid = 0; // Apparently this can indeed happen, and it can interfere with furniture placement. - Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; - } - } - } - } - - public static void GenerateShrineRoom(Rectangle roomBounds) - { - // Cut out the room. - for (int dx = roomBounds.Left; dx < roomBounds.Right; dx++) - { - for (int dy = roomBounds.Top; dy < roomBounds.Bottom; dy++) - { - Main.tile[dx, dy].active(false); - Main.tile[dx, dy].liquid = 0; // Apparently this can indeed happen, and it can interfere with furniture placement. - Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; - } - } - - // Place the shrine atop a pedestal. - int roomCenterX = roomBounds.Center.X; - int roomTop = roomBounds.Top; - int roomBottom = roomBounds.Bottom; - int shrinePedestalWidth = roomBounds.Width / 6 + WorldGen.genRand.Next(6); - - // Ensure that the pedestal is always an even number, so that the shrine can be placed atop symmetrically. - if (shrinePedestalWidth % 2 != 0) - shrinePedestalWidth++; - - int calculateHeightFromOutwardness(int outwardness) - { - int height = Math.Max(outwardness, 4); // 8 tile wide area on top. - - return (shrinePedestalWidth / 2) - height; // Invert height so that it ascends instead of descends. - } - - // Place the pedestal. - for (int dx = 0; dx < shrinePedestalWidth / 2; dx++) - { - int height = calculateHeightFromOutwardness(dx); - - for (int y = roomBottom - height; y <= roomBottom; y++) - { - Main.tile[roomCenterX - dx, y].active(true); - Main.tile[roomCenterX - dx, y].type = TileID.LihzahrdBrick; - - Main.tile[roomCenterX + dx, y].active(true); - Main.tile[roomCenterX + dx, y].type = TileID.LihzahrdBrick; - } - } - - // And place the shrine. - CalamityWorld.newAltarX = roomCenterX - 1; - CalamityWorld.newAltarY = roomBottom - calculateHeightFromOutwardness(0) - 2; - - // Place some lanterns on the top of the room. - for (int dx = 6; dx < roomBounds.Width - 6; dx += 10) - { - WorldGen.PlaceTile(roomBounds.Left + dx, roomTop + 1, TileID.HangingLanterns, style: 20); - } - - int totalTables = roomBounds.Width / 8; - int tries = 0; - for (int i = 0; i < totalTables; i++) - { - tries++; - if (tries >= 1600) - break; - int x = WorldGen.genRand.Next(5, roomBounds.Width - 5) + roomBounds.Left; - WorldGen.PlaceTile(x, roomBottom - 1, TileID.Tables, style: 9); - - // Try again if the table failed to place. - if (Main.tile[x, roomBottom - 1].type != TileID.Tables) - { - i--; - continue; - } - WorldGen.PlaceTile(x, roomBottom - 3, TileID.Candles, style: 11); - } - } - - public static void NewJungleTemplePart2() - { - int templeLeft = WorldGen.tLeft; - int templeRight = WorldGen.tRight; - int templeTop = WorldGen.tTop; - int templeBottom = WorldGen.tBottom; - int totalRooms = WorldGen.tRooms; - float totalTrapsToPlace = totalRooms * 2.1f; - float totalStatuesToPlace = totalRooms * 1.6f; - float totalChestsToPlace = totalRooms * 0.4f; - - int placementAttempts = 0; - while (totalTrapsToPlace > 0f) - { - int randomPointInRoomX = WorldGen.genRand.Next(templeLeft, templeRight); - int randomPointInRoomY = WorldGen.genRand.Next(templeTop, templeBottom); - if (Main.tile[randomPointInRoomX, randomPointInRoomY].wall == WallID.LihzahrdBrickUnsafe && !Main.tile[randomPointInRoomX, randomPointInRoomY].active()) - { - if (WorldGen.mayanTrap(randomPointInRoomX, randomPointInRoomY)) - { - totalTrapsToPlace--; - placementAttempts = 0; - } - else - { - placementAttempts++; - } - } - else - { - placementAttempts++; - } - if (placementAttempts > 100) - { - placementAttempts = 0; - totalTrapsToPlace--; - } - } - - // Bit of a weird solution that makes wooden spikes non-solid so that nothing is placed on top of them. - Main.tileSolid[TileID.WoodenSpikes] = false; - - placementAttempts = 0; - while (totalChestsToPlace > 0f) - { - int randomPointInTempleX = WorldGen.genRand.Next(templeLeft, templeRight); - int randomPointInTempleY = WorldGen.genRand.Next(templeTop, templeBottom); - if (Main.tile[randomPointInTempleX, randomPointInTempleY].wall == WallID.LihzahrdBrickUnsafe && - !Main.tile[randomPointInTempleX, randomPointInTempleY].active() && - WorldGen.AddBuriedChest(randomPointInTempleX, randomPointInTempleY, ItemID.LihzahrdPowerCell, true, 16)) - { - totalChestsToPlace--; - placementAttempts = 0; - } - placementAttempts++; - if (placementAttempts > 10000) - { - break; - } - } - placementAttempts = 0; - while (totalStatuesToPlace > 0f) - { - placementAttempts++; - int randomPointInTempleX = WorldGen.genRand.Next(templeLeft, templeRight); - int randomPointInTempleY = WorldGen.genRand.Next(templeTop, templeBottom); - if (Main.tile[randomPointInTempleX, randomPointInTempleY].wall == WallID.LihzahrdBrickUnsafe && !Main.tile[randomPointInTempleX, randomPointInTempleY].active()) - { - int statuePlacementPositionY = randomPointInTempleY; - while (!Main.tile[randomPointInTempleX, statuePlacementPositionY].active()) - { - statuePlacementPositionY++; - if (statuePlacementPositionY > templeBottom) - { - break; - } - } - statuePlacementPositionY--; - if (statuePlacementPositionY <= templeBottom) - { - WorldGen.PlaceTile(randomPointInTempleX, statuePlacementPositionY, TileID.Statues, true, false, -1, WorldGen.genRand.Next(43, 46)); - if (Main.tile[randomPointInTempleX, statuePlacementPositionY].type == TileID.Statues) - { - totalStatuesToPlace--; - } - } - } - } - - float totalFurnitureElementsToPlace = totalRooms * 1.1f; - - placementAttempts = 0; - while (totalFurnitureElementsToPlace > 0f) - { - placementAttempts++; - int randomPointInTempleX = WorldGen.genRand.Next(templeLeft, templeRight); - int randomPointInTempleY = WorldGen.genRand.Next(templeTop, templeBottom); - if (Main.tile[randomPointInTempleX, randomPointInTempleY].wall == WallID.LihzahrdBrickUnsafe && !Main.tile[randomPointInTempleX, randomPointInTempleY].active()) - { - int furniturePlacementPositionY = randomPointInTempleY; - while (!Main.tile[randomPointInTempleX, furniturePlacementPositionY].active()) - { - furniturePlacementPositionY++; - if (furniturePlacementPositionY > templeBottom) - { - break; - } - } - furniturePlacementPositionY--; - if (furniturePlacementPositionY <= templeBottom) - { - switch (WorldGen.genRand.Next(3)) - { - case 0: - WorldGen.PlaceTile(randomPointInTempleX, furniturePlacementPositionY, TileID.WorkBenches, true, false, -1, 10); - if (Main.tile[randomPointInTempleX, furniturePlacementPositionY].type == TileID.WorkBenches) - { - totalFurnitureElementsToPlace--; - } - break; - case 1: - WorldGen.PlaceTile(randomPointInTempleX, furniturePlacementPositionY, TileID.Tables, true, false, -1, 9); - if (Main.tile[randomPointInTempleX, furniturePlacementPositionY].type == TileID.Tables) - { - totalFurnitureElementsToPlace--; - } - break; - case 2: - WorldGen.PlaceTile(randomPointInTempleX, furniturePlacementPositionY, TileID.Chairs, true, false, -1, 12); - if (Main.tile[randomPointInTempleX, furniturePlacementPositionY].type == TileID.Chairs) - { - totalFurnitureElementsToPlace--; - } - break; - } - } - } - if (placementAttempts > 10000) - { - break; - } - } - - // Return wood spikes back to normal after the above placements are done. - Main.tileSolid[TileID.WoodenSpikes] = true; - } - - public static void NewJungleTempleLihzahrdAltar() - { - int alterPositionX = CalamityWorld.newAltarX; - int alterPositionY = CalamityWorld.newAltarY; - for (int i = 0; i <= 2; i++) - { - for (int j = 0; j < 2; j++) - { - int framedAlterPositionX = alterPositionX + i; - int framedAlterPositionY = alterPositionY + j; - Main.tile[framedAlterPositionX, framedAlterPositionY].active(true); - Main.tile[framedAlterPositionX, framedAlterPositionY].type = TileID.LihzahrdAltar; - Main.tile[framedAlterPositionX, framedAlterPositionY].frameX = (short)(i * 18); - Main.tile[framedAlterPositionX, framedAlterPositionY].frameY = (short)(j * 18); - } - - // Ensure that the tiles below the altar are active and valid. - Main.tile[i, alterPositionY + 2].active(true); - Main.tile[i, alterPositionY + 2].slope(0); - Main.tile[i, alterPositionY + 2].halfBrick(false); - Main.tile[i, alterPositionY + 2].type = TileID.LihzahrdBrick; - } - } - } + public static void NewJungleTemple() + { + bool success = false; + while (!success) + { + int x; + if (WorldGen.dungeonX < Main.maxTilesX / 2) + x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.6), (int)(Main.maxTilesX * 0.85)); + else + x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.15), (int)(Main.maxTilesX * 0.4)); + + int y = WorldGen.genRand.Next((int)Main.rockLayer, Main.maxTilesY - 500); + + if (Main.tile[x, y].active() && Main.tile[x, y].type == 60) + { + success = true; + GenNewTemple(x, y); + } + } + } + + public static void GenNewTemple(int x, int y) + { + Rectangle[] roomBounds = new Rectangle[200]; + float worldScale = Main.maxTilesX / 4200f; + int totalRooms = (int)(worldScale * WorldGen.genRand.Next(12, 16)); + int xDirection = WorldGen.genRand.NextBool(2).ToDirectionInt(); + int initalDirection = xDirection; + int pathPositionX = x; + int pathPositionY = y; + int currentRoomPositionX = x; + int currentRoomPositionY = y; + int xDirectionChangePromptThreshold = WorldGen.genRand.Next(1, 3); + int totalAttempts = 0; + + // Temple room sizes. + for (int i = 0; i < totalRooms; i++) + { + totalAttempts++; + int currentXDirection = xDirection; + int roomPositionX = currentRoomPositionX; + int roomPositionY = currentRoomPositionY; + bool isValidRoom = false; + int width = 0; + int height = 0; + int xOffset = -10; + Rectangle rectangle = new Rectangle(roomPositionX - width / 2, roomPositionY - height / 2, width, height); + while (!isValidRoom) + { + roomPositionX = currentRoomPositionX; + roomPositionY = currentRoomPositionY; + + // Typical temple room size. + width = WorldGen.genRand.Next(30, 46); + height = WorldGen.genRand.Next(25, 31); + + // Final temple room size. + if (i == totalRooms - 1) + { + width = WorldGen.genRand.Next(105, 116); + height = WorldGen.genRand.Next(90, 106); + roomPositionY += WorldGen.genRand.Next(6, 9); + } + + if (totalAttempts > xDirectionChangePromptThreshold) + { + roomPositionY += WorldGen.genRand.Next(height + 1, height + 3) + xOffset; + roomPositionX += WorldGen.genRand.Next(-2, 3); + currentXDirection = xDirection * -1; + } + else + { + roomPositionX += (WorldGen.genRand.Next(width + 1, width + 3) + xOffset) * currentXDirection; + roomPositionY += WorldGen.genRand.Next(-2, 3); + } + + // Ensure that the new room doesn't intersect any other existing rooms. + isValidRoom = true; + rectangle = new Rectangle(roomPositionX - width / 2, roomPositionY - height / 2, width, height); + for (int j = 0; j < i; j++) + { + if (rectangle.Intersects(roomBounds[j])) + isValidRoom = false; + if (WorldGen.genRand.Next(100) == 0) + { + xOffset++; + } + } + } + if (totalAttempts > xDirectionChangePromptThreshold) + { + xDirectionChangePromptThreshold++; + totalAttempts = 1; + } + + // Update the old values after valid room bounds have been determined. + roomBounds[i] = rectangle; + xDirection = currentXDirection; + currentRoomPositionX = roomPositionX; + currentRoomPositionY = roomPositionY; + } + + for (int i = 0; i < totalRooms; i++) + { + for (int j = 0; j < 2; j++) + { + for (int k = 0; k < totalRooms; k++) + { + for (int l = 0; l < 2; l++) + { + int roomPositionX = roomBounds[i].X; + if (j == 1) + roomPositionX += roomBounds[i].Width - 1; + + int roomTop = roomBounds[i].Y; + int roomBottom = roomTop + roomBounds[i].Height; + int checkRoomPositionX = roomBounds[k].X; + + if (l == 1) + checkRoomPositionX += roomBounds[k].Width - 1; + + int checkRoomTop = roomBounds[k].Y; + int checkRoomBottom = checkRoomTop + roomBounds[k].Height; + while (roomPositionX != checkRoomPositionX || roomTop != checkRoomTop || roomBottom != checkRoomBottom) + { + if (roomPositionX < checkRoomPositionX) + { + roomPositionX++; + } + if (roomPositionX > checkRoomPositionX) + { + roomPositionX--; + } + if (roomTop < checkRoomTop) + { + roomTop++; + } + if (roomTop > checkRoomTop) + { + roomTop--; + } + if (roomBottom < checkRoomBottom) + { + roomBottom++; + } + if (roomBottom > checkRoomBottom) + { + roomBottom--; + } + for (int roomPositionY = roomTop; roomPositionY < roomBottom; roomPositionY++) + { + Main.tile[roomPositionX, roomPositionY].active(true); + Main.tile[roomPositionX, roomPositionY].type = TileID.LihzahrdBrick; + Main.tile[roomPositionX, roomPositionY].liquid = 0; + Main.tile[roomPositionX, roomPositionY].slope(0); + Main.tile[roomPositionX, roomPositionY].halfBrick(false); + } + } + } + } + } + } + + // Cut out rooms and replace the empty space with walls. + for (int i = 0; i < totalRooms; i++) + { + bool isLastRoom = i == totalRooms - 1; + for (int roomPositionX = roomBounds[i].X; roomPositionX < roomBounds[i].X + roomBounds[i].Width; roomPositionX++) + { + for (int roomPositionY = roomBounds[i].Y; roomPositionY < roomBounds[i].Y + roomBounds[i].Height; roomPositionY++) + { + Main.tile[roomPositionX, roomPositionY].active(true); + Main.tile[roomPositionX, roomPositionY].type = TileID.LihzahrdBrick; + Main.tile[roomPositionX, roomPositionY].liquid = 0; + Main.tile[roomPositionX, roomPositionY].slope(0); + Main.tile[roomPositionX, roomPositionY].halfBrick(false); + } + } + + if (!isLastRoom) + GenerateGenericRoom(roomBounds[i]); + else + GenerateShrineRoom(roomBounds[i]); + } + + Vector2 pathPosition = new Vector2(pathPositionX, pathPositionY); + + // Cut out areas between rooms, creating corridors. + for (int i = 0; i < totalRooms; i++) + { + Rectangle destinationArea = roomBounds[i]; + destinationArea.X += 8; + destinationArea.Y += 8; + destinationArea.Width -= 16; + destinationArea.Height -= 16; + + // Recursively attempt to reach the next room and empty anything in said path. + bool reachedDestination = false; + while (!reachedDestination) + { + int destinationX = WorldGen.genRand.Next(destinationArea.X, destinationArea.X + destinationArea.Width); + int destinationY = WorldGen.genRand.Next(destinationArea.Y, destinationArea.Y + destinationArea.Height); + pathPosition = WorldGen.templePather(pathPosition, destinationX, destinationY); + + if (pathPosition.X == destinationX && pathPosition.Y == destinationY) + reachedDestination = true; + } + if (i < totalRooms - 1) + { + reachedDestination = false; + if (WorldGen.genRand.Next(3) != 0) + { + Rectangle nextRoom = roomBounds[i + 1]; + if (nextRoom.Y >= roomBounds[i].Y + roomBounds[i].Height) + { + destinationArea.X = nextRoom.X; + + if (nextRoom.X < roomBounds[i].X) + destinationArea.X += (int)(nextRoom.Width * 0.2); + else destinationArea.X += (int)(nextRoom.Width * 0.8f); + + destinationArea.Y = nextRoom.Y; + } + else + { + destinationArea.X = (roomBounds[i].X + roomBounds[i].Width / 2 + nextRoom.X + nextRoom.Width / 2) / 2; + destinationArea.Y = (int)(nextRoom.Y + nextRoom.Height * 0.8); + } + while (!reachedDestination) + { + int destinationX = WorldGen.genRand.Next(destinationArea.X - 4, destinationArea.X + 5); + int destinationY = WorldGen.genRand.Next(destinationArea.Y - 4, destinationArea.Y + 5); + pathPosition = WorldGen.templePather(pathPosition, destinationX, destinationY); + if (pathPosition.X == destinationX && pathPosition.Y == destinationY) + reachedDestination = true; + } + } + else + { + Rectangle nextRoom = roomBounds[i + 1]; + int roomCenterMidpointX = (roomBounds[i].X + roomBounds[i].Width / 2 + nextRoom.X + nextRoom.Width / 2) / 2; + int roomCenterMidpointY = (roomBounds[i].Y + roomBounds[i].Height / 2 + nextRoom.Y + nextRoom.Height / 2) / 2; + while (!reachedDestination) + { + int destinationX = WorldGen.genRand.Next(roomCenterMidpointX - 4, roomCenterMidpointX + 5); + int destinationY = WorldGen.genRand.Next(roomCenterMidpointY - 4, roomCenterMidpointY + 5); + pathPosition = WorldGen.templePather(pathPosition, destinationX, destinationY); + if (pathPosition.X == destinationX && pathPosition.Y == destinationY) + reachedDestination = true; + } + } + } + } + + int farthestRoomLeft = Main.maxTilesX - 20; + int farthestRoomRight = 20; + int farthestRoomTop = Main.maxTilesY - 20; + int farthestRoomBottom = 20; + for (int i = 0; i < totalRooms; i++) + { + if (roomBounds[i].X < farthestRoomLeft) + { + farthestRoomLeft = roomBounds[i].X; + } + if (roomBounds[i].X + roomBounds[i].Width > farthestRoomRight) + { + farthestRoomRight = roomBounds[i].X + roomBounds[i].Width; + } + if (roomBounds[i].Y < farthestRoomTop) + { + farthestRoomTop = roomBounds[i].Y; + } + if (roomBounds[i].Y + roomBounds[i].Height > farthestRoomBottom) + { + farthestRoomBottom = roomBounds[i].Y + roomBounds[i].Height; + } + } + + // Create outer temple shape. + farthestRoomLeft -= 10; + farthestRoomRight += 10; + farthestRoomTop -= 10; + farthestRoomBottom += 10; + + for (int xRoomPosition = farthestRoomLeft; xRoomPosition < farthestRoomRight; xRoomPosition++) + { + for (int roomPositionY = farthestRoomTop; roomPositionY < farthestRoomBottom; roomPositionY++) + { + WorldGen.outerTempled(xRoomPosition, roomPositionY); + } + } + for (int xRoomPosition = farthestRoomRight; xRoomPosition >= farthestRoomLeft; xRoomPosition--) + { + for (int yRoomPosition = farthestRoomTop; yRoomPosition < farthestRoomBottom / 2; yRoomPosition++) + { + WorldGen.outerTempled(xRoomPosition, yRoomPosition); + } + } + for (int yRoomPosition = farthestRoomTop; yRoomPosition < farthestRoomBottom; yRoomPosition++) + { + for (int xRoomPosition = farthestRoomLeft; xRoomPosition < farthestRoomRight; xRoomPosition++) + { + WorldGen.outerTempled(xRoomPosition, yRoomPosition); + } + } + for (int yRoomPosition = farthestRoomBottom; yRoomPosition >= farthestRoomTop; yRoomPosition--) + { + for (int xRoomPosition = farthestRoomLeft; xRoomPosition < farthestRoomRight; xRoomPosition++) + { + WorldGen.outerTempled(xRoomPosition, yRoomPosition); + } + } + + // Move downward and prepare to have the tunnel go in the opposite direction(?) + xDirection = -initalDirection; + Vector2 endPathPosition = new Vector2(pathPositionX, pathPositionY); + int yArea = 4; + bool success = false; + int totralDescentTries = 0; + int endPathRisePrompt = WorldGen.genRand.Next(12, 14); + while (!success) + { + totralDescentTries++; + if (totralDescentTries >= endPathRisePrompt) + { + totralDescentTries = 0; + endPathPosition.Y--; + } + endPathPosition.X += xDirection; + success = true; + int dy = (int)endPathPosition.Y - yArea; + while (dy < endPathPosition.Y + yArea) + { + if (Main.tile[(int)endPathPosition.X, dy].wall == WallID.LihzahrdBrickUnsafe || (Main.tile[(int)endPathPosition.X, dy].active() && Main.tile[(int)endPathPosition.X, dy].type == TileID.LihzahrdBrick)) + { + success = false; + } + if (Main.tile[(int)endPathPosition.X, dy].active() && Main.tile[(int)endPathPosition.X, dy].type == TileID.LihzahrdBrick) + { + Main.tile[(int)endPathPosition.X, dy].active(false); + Main.tile[(int)endPathPosition.X, dy].wall = WallID.LihzahrdBrickUnsafe; + } + dy++; + } + } + + // Place bricks and walls around temple door. + int doorPositionX = pathPositionX; + int doorPositionY = pathPositionY; + while (!Main.tile[doorPositionX, doorPositionY].active()) + { + doorPositionY++; + } + doorPositionY -= 4; + int doorTop = doorPositionY; + while ((Main.tile[doorPositionX, doorTop].active() && Main.tile[doorPositionX, doorTop].type == TileID.LihzahrdBrick) || Main.tile[doorPositionX, doorTop].wall == WallID.LihzahrdBrickUnsafe) + { + doorTop--; + } + doorTop += 2; + for (int dx = doorPositionX - 1; dx <= doorPositionX + 1; dx++) + { + for (int dy = doorTop; dy <= doorPositionY; dy++) + { + Main.tile[dx, dy].active(true); + Main.tile[dx, dy].type = TileID.LihzahrdBrick; + Main.tile[dx, dy].liquid = 0; + Main.tile[dx, dy].slope(0); + Main.tile[dx, dy].halfBrick(false); + } + } + for (int dx = doorPositionX - 4; dx <= doorPositionX + 4; dx++) + { + for (int dy = doorPositionY - 1; dy < doorPositionY + 3; dy++) + { + Main.tile[dx, dy].active(false); + Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; + } + } + for (int dx = doorPositionX - 1; dx <= doorPositionX + 1; dx++) + { + for (int dy = doorPositionY - 5; dy <= doorPositionY + 8; dy++) + { + Main.tile[dx, dy].active(true); + Main.tile[dx, dy].type = TileID.LihzahrdBrick; + Main.tile[dx, dy].liquid = 0; + Main.tile[dx, dy].slope(0); + Main.tile[dx, dy].halfBrick(false); + } + } + for (int dx = doorPositionX - 1; dx <= doorPositionX + 1; dx++) + { + for (int dy = doorPositionY; dy < doorPositionY + 3; dy++) + { + Main.tile[dx, dy].active(false); + Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; + } + } + + // Temple Door + WorldGen.PlaceTile(doorPositionX, doorPositionY, 10, true, false, -1, 11); + + // Clear space in temple + for (int dx = farthestRoomLeft; dx < farthestRoomRight; dx++) + { + for (int dy = farthestRoomTop; dy < farthestRoomBottom; dy++) + { + WorldGen.templeCleaner(dx, dy); + } + } + for (int dx = farthestRoomBottom; dx >= farthestRoomTop; dx--) + { + for (int dy = farthestRoomRight; dy >= farthestRoomLeft; dy--) + { + WorldGen.templeCleaner(dy, dx); + } + } + + // Place walls + for (int dx = farthestRoomLeft; dx < farthestRoomRight; dx++) + { + for (int dy = farthestRoomTop; dy < farthestRoomBottom; dy++) + { + bool shouldPlaceWalls = true; + for (int dx2 = dx - 1; dx2 <= dx + 1; dx2++) + { + for (int dy2 = dy - 1; dy2 <= dy + 1; dy2++) + { + if ((!Main.tile[dx2, dy2].active() || Main.tile[dx2, dy2].type != TileID.LihzahrdBrick) && Main.tile[dx2, dy2].wall != WallID.LihzahrdBrickUnsafe) + { + shouldPlaceWalls = false; + break; + } + } + } + if (shouldPlaceWalls) + { + Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; + } + } + } + + // Create temple spikes + float totalSpikeAreasToSawpn = totalRooms * 1.3f; + int spikeAreaSpawnAttempts = 0; + while (totalSpikeAreasToSawpn > 0f) + { + spikeAreaSpawnAttempts++; + int roomToFillIndex = WorldGen.genRand.Next(totalRooms); + int randomPointInRoomX = WorldGen.genRand.Next(roomBounds[roomToFillIndex].X, roomBounds[roomToFillIndex].X + roomBounds[roomToFillIndex].Width); + int randomPointInRoomY = WorldGen.genRand.Next(roomBounds[roomToFillIndex].Y, roomBounds[roomToFillIndex].Y + roomBounds[roomToFillIndex].Height); + if (Main.tile[randomPointInRoomX, randomPointInRoomY].wall == 87 && !Main.tile[randomPointInRoomX, randomPointInRoomY].active()) + { + bool successPlacingSpikes = false; + if (WorldGen.genRand.Next(2) == 0) + { + int xMoveDirection = WorldGen.genRand.NextBool(2).ToDirectionInt(); + while (!Main.tile[randomPointInRoomX, randomPointInRoomY].active()) + { + randomPointInRoomY += xMoveDirection; + } + randomPointInRoomY -= xMoveDirection; + int yMoveDirection = WorldGen.genRand.Next(2); + int areaToCheck = WorldGen.genRand.Next(8, 10); + bool noDoorInWay = true; + for (int dx = randomPointInRoomX - areaToCheck; dx < randomPointInRoomX + areaToCheck; dx++) + { + for (int dy = randomPointInRoomY - areaToCheck; dy < randomPointInRoomY + areaToCheck; dy++) + { + if (Main.tile[dx, dy].active() && Main.tile[dx, dy].type == 10) + { + noDoorInWay = false; + break; + } + } + } + if (noDoorInWay) + { + for (int dx = randomPointInRoomX - areaToCheck; dx < randomPointInRoomX + areaToCheck; dx++) + { + for (int dy = randomPointInRoomY - areaToCheck; dy < randomPointInRoomY + areaToCheck; dy++) + { + if (WorldGen.SolidTile(dx, dy) && Main.tile[dx, dy].type != TileID.WoodenSpikes && !WorldGen.SolidTile(dx, dy - xMoveDirection)) + { + Main.tile[dx, dy].type = TileID.WoodenSpikes; + successPlacingSpikes = true; + if (yMoveDirection == 0) + { + Main.tile[dx, dy - 1].type = TileID.WoodenSpikes; + Main.tile[dx, dy - 1].active(true); + } + else + { + Main.tile[dx, dy + 1].type = TileID.WoodenSpikes; + Main.tile[dx, dy + 1].active(true); + } + yMoveDirection++; + if (yMoveDirection > 1) + { + yMoveDirection = 0; + } + } + } + } + } + if (successPlacingSpikes) + { + spikeAreaSpawnAttempts = 0; + totalSpikeAreasToSawpn--; + } + } + else + { + int xMoveDirection = WorldGen.genRand.NextBool(2).ToDirectionInt(); + while (!Main.tile[randomPointInRoomX, randomPointInRoomY].active()) + { + randomPointInRoomX += xMoveDirection; + } + randomPointInRoomX -= xMoveDirection; + int yMoveDirection = WorldGen.genRand.Next(2); + int areaToCheck = WorldGen.genRand.Next(8, 10); + bool noDoorInWay = true; + for (int dx = randomPointInRoomX - areaToCheck; dx < randomPointInRoomX + areaToCheck; dx++) + { + for (int dy = randomPointInRoomY - areaToCheck; dy < randomPointInRoomY + areaToCheck; dy++) + { + if (Main.tile[dx, dy].active() && Main.tile[dx, dy].type == 10) + { + noDoorInWay = false; + break; + } + } + } + if (noDoorInWay) + { + for (int dx = randomPointInRoomX - areaToCheck; dx < randomPointInRoomX + areaToCheck; dx++) + { + for (int dy = randomPointInRoomY - areaToCheck; dy < randomPointInRoomY + areaToCheck; dy++) + { + if (WorldGen.SolidTile(dx, dy) && Main.tile[dx, dy].type != TileID.WoodenSpikes && !WorldGen.SolidTile(dx - xMoveDirection, dy)) + { + Main.tile[dx, dy].type = TileID.WoodenSpikes; + successPlacingSpikes = true; + if (yMoveDirection == 0) + { + Main.tile[dx - 1, dy].type = TileID.WoodenSpikes; + Main.tile[dx - 1, dy].active(true); + } + else + { + Main.tile[dx + 1, dy].type = TileID.WoodenSpikes; + Main.tile[dx + 1, dy].active(true); + } + yMoveDirection++; + if (yMoveDirection > 1) + { + yMoveDirection = 0; + } + } + } + } + } + if (successPlacingSpikes) + { + spikeAreaSpawnAttempts = 0; + totalSpikeAreasToSawpn--; + } + } + } + if (spikeAreaSpawnAttempts > 1000) + { + spikeAreaSpawnAttempts = 0; + totalSpikeAreasToSawpn--; + } + } + + // Set variables for the bounds and room count of the temple. + WorldGen.tLeft = farthestRoomLeft; + WorldGen.tRight = farthestRoomRight; + WorldGen.tTop = farthestRoomTop; + WorldGen.tBottom = farthestRoomBottom; + WorldGen.tRooms = totalRooms; + } + + public static void GenerateGenericRoom(Rectangle roomBounds) + { + int roomLeft = roomBounds.X; + int roomRight = roomLeft + roomBounds.Width; + int roomTop = roomBounds.Y; + int roomBottom = roomTop + roomBounds.Height; + + roomLeft += WorldGen.genRand.Next(4, 7); + roomRight -= WorldGen.genRand.Next(4, 7); + roomTop += WorldGen.genRand.Next(4, 7); + roomBottom -= WorldGen.genRand.Next(4, 7); + + int offsettedRoomLeft = roomLeft; + int offsettedRoomRight = roomRight; + int offsettedRoomTop = roomTop; + int offsettedRoomBottom = roomBottom; + + int roomCenterX = (roomLeft + roomRight) / 2; + int roomCenterY = (roomTop + roomBottom) / 2; + + // Cut out the rooms with a bit of randomness incorporated, so that the room is not entirely square. + for (int dx = roomLeft; dx < roomRight; dx++) + { + for (int dy = roomTop; dy < roomBottom; dy++) + { + if (WorldGen.genRand.NextBool(20)) + offsettedRoomTop += WorldGen.genRand.NextBool(2).ToDirectionInt(); + + if (WorldGen.genRand.NextBool(20)) + offsettedRoomBottom += WorldGen.genRand.NextBool(2).ToDirectionInt(); + + if (WorldGen.genRand.NextBool(20)) + offsettedRoomLeft += WorldGen.genRand.NextBool(2).ToDirectionInt(); + + if (WorldGen.genRand.NextBool(20)) + offsettedRoomRight += WorldGen.genRand.NextBool(2).ToDirectionInt(); + + offsettedRoomLeft = Utils.Clamp(offsettedRoomLeft, roomLeft, roomCenterX); + offsettedRoomRight = Utils.Clamp(offsettedRoomRight, roomCenterX, roomRight); + offsettedRoomTop = Utils.Clamp(offsettedRoomTop, roomTop, roomCenterY); + offsettedRoomBottom = Utils.Clamp(offsettedRoomBottom, roomCenterY, roomBottom); + + if (dx >= offsettedRoomLeft && (dx < offsettedRoomRight & dy >= offsettedRoomTop) && dy <= offsettedRoomBottom) + { + Main.tile[dx, dy].active(false); + Main.tile[dx, dy].liquid = 0; // Apparently this can indeed happen, and it can interfere with furniture placement. + Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; + } + } + } + for (int dy = roomBottom; dy > roomTop; dy--) + { + for (int dx = roomRight; dx > roomLeft; dx--) + { + if (WorldGen.genRand.NextBool(20)) + offsettedRoomTop += WorldGen.genRand.NextBool(2).ToDirectionInt(); + + if (WorldGen.genRand.NextBool(20)) + offsettedRoomBottom += WorldGen.genRand.NextBool(2).ToDirectionInt(); + + if (WorldGen.genRand.NextBool(20)) + offsettedRoomLeft += WorldGen.genRand.NextBool(2).ToDirectionInt(); + + if (WorldGen.genRand.NextBool(20)) + offsettedRoomRight += WorldGen.genRand.NextBool(2).ToDirectionInt(); + + offsettedRoomLeft = Utils.Clamp(offsettedRoomLeft, roomLeft, roomCenterX); + offsettedRoomRight = Utils.Clamp(offsettedRoomRight, roomCenterX, roomRight); + offsettedRoomTop = Utils.Clamp(offsettedRoomTop, roomTop, roomCenterY); + offsettedRoomBottom = Utils.Clamp(offsettedRoomBottom, roomCenterY, roomBottom); + + if (dx >= offsettedRoomLeft && (dx < offsettedRoomRight & dy >= offsettedRoomTop) && dy <= offsettedRoomBottom) + { + Main.tile[dx, dy].active(false); + Main.tile[dx, dy].liquid = 0; // Apparently this can indeed happen, and it can interfere with furniture placement. + Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; + } + } + } + } + + public static void GenerateShrineRoom(Rectangle roomBounds) + { + // Cut out the room. + for (int dx = roomBounds.Left; dx < roomBounds.Right; dx++) + { + for (int dy = roomBounds.Top; dy < roomBounds.Bottom; dy++) + { + Main.tile[dx, dy].active(false); + Main.tile[dx, dy].liquid = 0; // Apparently this can indeed happen, and it can interfere with furniture placement. + Main.tile[dx, dy].wall = WallID.LihzahrdBrickUnsafe; + } + } + + // Place the shrine atop a pedestal. + int roomCenterX = roomBounds.Center.X; + int roomTop = roomBounds.Top; + int roomBottom = roomBounds.Bottom; + int shrinePedestalWidth = roomBounds.Width / 6 + WorldGen.genRand.Next(6); + + // Ensure that the pedestal is always an even number, so that the shrine can be placed atop symmetrically. + if (shrinePedestalWidth % 2 != 0) + shrinePedestalWidth++; + + int calculateHeightFromOutwardness(int outwardness) + { + int height = Math.Max(outwardness, 4); // 8 tile wide area on top. + + return (shrinePedestalWidth / 2) - height; // Invert height so that it ascends instead of descends. + } + + // Place the pedestal. + for (int dx = 0; dx < shrinePedestalWidth / 2; dx++) + { + int height = calculateHeightFromOutwardness(dx); + + for (int y = roomBottom - height; y <= roomBottom; y++) + { + Main.tile[roomCenterX - dx, y].active(true); + Main.tile[roomCenterX - dx, y].type = TileID.LihzahrdBrick; + + Main.tile[roomCenterX + dx, y].active(true); + Main.tile[roomCenterX + dx, y].type = TileID.LihzahrdBrick; + } + } + + // And place the shrine. + CalamityWorld.newAltarX = roomCenterX - 1; + CalamityWorld.newAltarY = roomBottom - calculateHeightFromOutwardness(0) - 2; + + // Place some lanterns on the top of the room. + for (int dx = 6; dx < roomBounds.Width - 6; dx += 10) + { + WorldGen.PlaceTile(roomBounds.Left + dx, roomTop + 1, TileID.HangingLanterns, style: 20); + } + + int totalTables = roomBounds.Width / 8; + int tries = 0; + for (int i = 0; i < totalTables; i++) + { + tries++; + if (tries >= 1600) + break; + int x = WorldGen.genRand.Next(5, roomBounds.Width - 5) + roomBounds.Left; + WorldGen.PlaceTile(x, roomBottom - 1, TileID.Tables, style: 9); + + // Try again if the table failed to place. + if (Main.tile[x, roomBottom - 1].type != TileID.Tables) + { + i--; + continue; + } + WorldGen.PlaceTile(x, roomBottom - 3, TileID.Candles, style: 11); + } + } + + public static void NewJungleTemplePart2() + { + int templeLeft = WorldGen.tLeft; + int templeRight = WorldGen.tRight; + int templeTop = WorldGen.tTop; + int templeBottom = WorldGen.tBottom; + int totalRooms = WorldGen.tRooms; + float totalTrapsToPlace = totalRooms * 2.1f; + float totalStatuesToPlace = totalRooms * 1.6f; + float totalChestsToPlace = totalRooms * 0.4f; + + int placementAttempts = 0; + while (totalTrapsToPlace > 0f) + { + int randomPointInRoomX = WorldGen.genRand.Next(templeLeft, templeRight); + int randomPointInRoomY = WorldGen.genRand.Next(templeTop, templeBottom); + if (Main.tile[randomPointInRoomX, randomPointInRoomY].wall == WallID.LihzahrdBrickUnsafe && !Main.tile[randomPointInRoomX, randomPointInRoomY].active()) + { + if (WorldGen.mayanTrap(randomPointInRoomX, randomPointInRoomY)) + { + totalTrapsToPlace--; + placementAttempts = 0; + } + else + { + placementAttempts++; + } + } + else + { + placementAttempts++; + } + if (placementAttempts > 100) + { + placementAttempts = 0; + totalTrapsToPlace--; + } + } + + // Bit of a weird solution that makes wooden spikes non-solid so that nothing is placed on top of them. + Main.tileSolid[TileID.WoodenSpikes] = false; + + placementAttempts = 0; + while (totalChestsToPlace > 0f) + { + int randomPointInTempleX = WorldGen.genRand.Next(templeLeft, templeRight); + int randomPointInTempleY = WorldGen.genRand.Next(templeTop, templeBottom); + if (Main.tile[randomPointInTempleX, randomPointInTempleY].wall == WallID.LihzahrdBrickUnsafe && + !Main.tile[randomPointInTempleX, randomPointInTempleY].active() && + WorldGen.AddBuriedChest(randomPointInTempleX, randomPointInTempleY, ItemID.LihzahrdPowerCell, true, 16)) + { + totalChestsToPlace--; + placementAttempts = 0; + } + placementAttempts++; + if (placementAttempts > 10000) + { + break; + } + } + placementAttempts = 0; + while (totalStatuesToPlace > 0f) + { + placementAttempts++; + int randomPointInTempleX = WorldGen.genRand.Next(templeLeft, templeRight); + int randomPointInTempleY = WorldGen.genRand.Next(templeTop, templeBottom); + if (Main.tile[randomPointInTempleX, randomPointInTempleY].wall == WallID.LihzahrdBrickUnsafe && !Main.tile[randomPointInTempleX, randomPointInTempleY].active()) + { + int statuePlacementPositionY = randomPointInTempleY; + while (!Main.tile[randomPointInTempleX, statuePlacementPositionY].active()) + { + statuePlacementPositionY++; + if (statuePlacementPositionY > templeBottom) + { + break; + } + } + statuePlacementPositionY--; + if (statuePlacementPositionY <= templeBottom) + { + WorldGen.PlaceTile(randomPointInTempleX, statuePlacementPositionY, TileID.Statues, true, false, -1, WorldGen.genRand.Next(43, 46)); + if (Main.tile[randomPointInTempleX, statuePlacementPositionY].type == TileID.Statues) + { + totalStatuesToPlace--; + } + } + } + } + + float totalFurnitureElementsToPlace = totalRooms * 1.1f; + + placementAttempts = 0; + while (totalFurnitureElementsToPlace > 0f) + { + placementAttempts++; + int randomPointInTempleX = WorldGen.genRand.Next(templeLeft, templeRight); + int randomPointInTempleY = WorldGen.genRand.Next(templeTop, templeBottom); + if (Main.tile[randomPointInTempleX, randomPointInTempleY].wall == WallID.LihzahrdBrickUnsafe && !Main.tile[randomPointInTempleX, randomPointInTempleY].active()) + { + int furniturePlacementPositionY = randomPointInTempleY; + while (!Main.tile[randomPointInTempleX, furniturePlacementPositionY].active()) + { + furniturePlacementPositionY++; + if (furniturePlacementPositionY > templeBottom) + { + break; + } + } + furniturePlacementPositionY--; + if (furniturePlacementPositionY <= templeBottom) + { + switch (WorldGen.genRand.Next(3)) + { + case 0: + WorldGen.PlaceTile(randomPointInTempleX, furniturePlacementPositionY, TileID.WorkBenches, true, false, -1, 10); + if (Main.tile[randomPointInTempleX, furniturePlacementPositionY].type == TileID.WorkBenches) + { + totalFurnitureElementsToPlace--; + } + break; + case 1: + WorldGen.PlaceTile(randomPointInTempleX, furniturePlacementPositionY, TileID.Tables, true, false, -1, 9); + if (Main.tile[randomPointInTempleX, furniturePlacementPositionY].type == TileID.Tables) + { + totalFurnitureElementsToPlace--; + } + break; + case 2: + WorldGen.PlaceTile(randomPointInTempleX, furniturePlacementPositionY, TileID.Chairs, true, false, -1, 12); + if (Main.tile[randomPointInTempleX, furniturePlacementPositionY].type == TileID.Chairs) + { + totalFurnitureElementsToPlace--; + } + break; + } + } + } + if (placementAttempts > 10000) + { + break; + } + } + + // Return wood spikes back to normal after the above placements are done. + Main.tileSolid[TileID.WoodenSpikes] = true; + } + + public static void NewJungleTempleLihzahrdAltar() + { + int alterPositionX = CalamityWorld.newAltarX; + int alterPositionY = CalamityWorld.newAltarY; + for (int i = 0; i <= 2; i++) + { + for (int j = 0; j < 2; j++) + { + int framedAlterPositionX = alterPositionX + i; + int framedAlterPositionY = alterPositionY + j; + Main.tile[framedAlterPositionX, framedAlterPositionY].active(true); + Main.tile[framedAlterPositionX, framedAlterPositionY].type = TileID.LihzahrdAltar; + Main.tile[framedAlterPositionX, framedAlterPositionY].frameX = (short)(i * 18); + Main.tile[framedAlterPositionX, framedAlterPositionY].frameY = (short)(j * 18); + } + + // Ensure that the tiles below the altar are active and valid. + Main.tile[i, alterPositionY + 2].active(true); + Main.tile[i, alterPositionY + 2].slope(0); + Main.tile[i, alterPositionY + 2].halfBrick(false); + Main.tile[i, alterPositionY + 2].type = TileID.LihzahrdBrick; + } + } + } } diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index ec1ca37e0e..922a761182 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -546,9 +546,9 @@ namespace CalamityMod.World new ChestItem(ItemID.Bomb, WorldGen.genRand.Next(6, 7 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(3, 5 + 1)), }; - if (!WorldGen.crimson) + if (!WorldGen.crimson) contents.Insert(8, new ChestItem(ItemID.CorruptPlanterBox, WorldGen.genRand.Next(5, 9 + 1))); - else + else contents.Insert(8, new ChestItem(ItemID.CrimsonPlanterBox, WorldGen.genRand.Next(5, 9 + 1))); Mod thorium = CalamityMod.Instance.thorium; diff --git a/World/MiscWorldgenRoutines.cs b/World/MiscWorldgenRoutines.cs index 1aab3675f9..9aa3287df5 100644 --- a/World/MiscWorldgenRoutines.cs +++ b/World/MiscWorldgenRoutines.cs @@ -828,52 +828,52 @@ namespace CalamityMod.World } } } - #endregion + #endregion - #region Smart Gem Gen - public static void SmartGemGen() - { - double oneThirdOfUnderground = (Main.maxTilesY - 200 - Main.worldSurface) / 3D; - double verticalStartFactor_Layer1 = Main.worldSurface; - double verticalStartFactor_Layer2 = verticalStartFactor_Layer1 + oneThirdOfUnderground; - double verticalStartFactor_Layer3 = verticalStartFactor_Layer1 + oneThirdOfUnderground * 2D; - for (int x = 0; x < Main.maxTilesX; x++) - { - for (int y = 0; y < Main.maxTilesY; y++) - { - if (y > verticalStartFactor_Layer3) - { - if (Main.tile[x, y] != null) - { - if (Main.tile[x, y].type == TileID.Emerald || Main.tile[x, y].type == TileID.Sapphire) - Main.tile[x, y].type = TileID.Diamond; - else if (Main.tile[x, y].type == TileID.Topaz || Main.tile[x, y].type == TileID.Amethyst) - Main.tile[x, y].type = TileID.Ruby; - } - } - else if (y > verticalStartFactor_Layer2) - { - if (Main.tile[x, y] != null) - { - if (Main.tile[x, y].type == TileID.Diamond || Main.tile[x, y].type == TileID.Ruby) - Main.tile[x, y].type = TileID.Emerald; - else if (Main.tile[x, y].type == TileID.Topaz || Main.tile[x, y].type == TileID.Amethyst) - Main.tile[x, y].type = TileID.Sapphire; - } - } - else if (y > verticalStartFactor_Layer1) - { - if (Main.tile[x, y] != null) - { - if (Main.tile[x, y].type == TileID.Diamond || Main.tile[x, y].type == TileID.Ruby) - Main.tile[x, y].type = TileID.Topaz; - else if (Main.tile[x, y].type == TileID.Emerald || Main.tile[x, y].type == TileID.Sapphire) - Main.tile[x, y].type = TileID.Amethyst; - } - } - } - } - } - #endregion - } + #region Smart Gem Gen + public static void SmartGemGen() + { + double oneThirdOfUnderground = (Main.maxTilesY - 200 - Main.worldSurface) / 3D; + double verticalStartFactor_Layer1 = Main.worldSurface; + double verticalStartFactor_Layer2 = verticalStartFactor_Layer1 + oneThirdOfUnderground; + double verticalStartFactor_Layer3 = verticalStartFactor_Layer1 + oneThirdOfUnderground * 2D; + for (int x = 0; x < Main.maxTilesX; x++) + { + for (int y = 0; y < Main.maxTilesY; y++) + { + if (y > verticalStartFactor_Layer3) + { + if (Main.tile[x, y] != null) + { + if (Main.tile[x, y].type == TileID.Emerald || Main.tile[x, y].type == TileID.Sapphire) + Main.tile[x, y].type = TileID.Diamond; + else if (Main.tile[x, y].type == TileID.Topaz || Main.tile[x, y].type == TileID.Amethyst) + Main.tile[x, y].type = TileID.Ruby; + } + } + else if (y > verticalStartFactor_Layer2) + { + if (Main.tile[x, y] != null) + { + if (Main.tile[x, y].type == TileID.Diamond || Main.tile[x, y].type == TileID.Ruby) + Main.tile[x, y].type = TileID.Emerald; + else if (Main.tile[x, y].type == TileID.Topaz || Main.tile[x, y].type == TileID.Amethyst) + Main.tile[x, y].type = TileID.Sapphire; + } + } + else if (y > verticalStartFactor_Layer1) + { + if (Main.tile[x, y] != null) + { + if (Main.tile[x, y].type == TileID.Diamond || Main.tile[x, y].type == TileID.Ruby) + Main.tile[x, y].type = TileID.Topaz; + else if (Main.tile[x, y].type == TileID.Emerald || Main.tile[x, y].type == TileID.Sapphire) + Main.tile[x, y].type = TileID.Amethyst; + } + } + } + } + } + #endregion + } } diff --git a/World/Planets/LuminitePlanet.cs b/World/Planets/LuminitePlanet.cs index 7886b6dc64..8993b6589a 100644 --- a/World/Planets/LuminitePlanet.cs +++ b/World/Planets/LuminitePlanet.cs @@ -90,5 +90,5 @@ namespace CalamityMod.World.Planets if (Main.netMode == NetmodeID.Server) NetMessage.SendTileRange(-1, origin.X - radius - 16, origin.Y - radius - 16, radius * 2 + 16, radius * 2 + 16); } - } + } } diff --git a/World/Planets/LuminitePlanet2.cs b/World/Planets/LuminitePlanet2.cs index d54e4e765a..6ef92addaf 100644 --- a/World/Planets/LuminitePlanet2.cs +++ b/World/Planets/LuminitePlanet2.cs @@ -55,7 +55,7 @@ namespace CalamityMod.World.Planets float initialRotationalOffset = WorldGen.genRand.NextFloat(MathHelper.TwoPi); Vector2[] initialTendrilDirections = new Vector2[5]; for (int i = 0; i < initialTendrilDirections.Length; i++) - { + { // Determine the base control points for the tendril. // They are all determined relative to the previous point. Vector2[] veinDirections = new Vector2[4]; @@ -69,7 +69,7 @@ namespace CalamityMod.World.Planets veinDirections[j] = veinDirections[j - 1].RotatedBy(WorldGen.genRand.NextFloat(-0.87f, 0.87f)); for (int j = 0; j <= 18; j++) - { + { float completionRatio = j / 18f; // Smoothen the control points based on a catmull-rom spline. @@ -97,5 +97,5 @@ namespace CalamityMod.World.Planets if (Main.netMode == NetmodeID.Server) NetMessage.SendTileRange(-1, origin.X - radius - 36, origin.Y - radius - 36, radius * 2 + 36, radius * 2 + 36); } - } + } } diff --git a/World/Planets/MainPlanet.cs b/World/Planets/MainPlanet.cs index e5a02bba6a..dc3332ea30 100644 --- a/World/Planets/MainPlanet.cs +++ b/World/Planets/MainPlanet.cs @@ -11,7 +11,7 @@ using Terraria.World.Generation; namespace CalamityMod.World.Planets { - public class MainPlanet : Planetoid + public class MainPlanet : Planetoid { public override bool Place(Point origin, StructureMap structures) { diff --git a/World/Planets/MudPlanet.cs b/World/Planets/MudPlanet.cs index b065338a43..4cfcb6194f 100644 --- a/World/Planets/MudPlanet.cs +++ b/World/Planets/MudPlanet.cs @@ -117,9 +117,9 @@ namespace CalamityMod.World.Planets _tiles[floorX, testY + 2].type = TileID.Hive; WorldGen.SquareTileFrame(floorX, testY + 2); } - //Place chest - int chestID = WorldGen.PlaceChest(testX, testY + 1, 21, false, 29); - FillHoneyChest(chestID); + //Place chest + int chestID = WorldGen.PlaceChest(testX, testY + 1, 21, false, 29); + FillHoneyChest(chestID); placedChest = true; } } @@ -274,89 +274,89 @@ namespace CalamityMod.World.Planets } - //--------------------- - //HONEY CHEST STUFF - //--------------------- + //--------------------- + //HONEY CHEST STUFF + //--------------------- - private int[] FocusLootHoney = new int[] - { - ItemID.NaturesGift, - ItemID.Bezoar, - ItemID.SharpeningStation - }; + private int[] FocusLootHoney = new int[] + { + ItemID.NaturesGift, + ItemID.Bezoar, + ItemID.SharpeningStation + }; - private int[] PotionLootHoney = new int[] - { - ItemID.LifeforcePotion, - ItemID.RegenerationPotion, - ItemID.ManaRegenerationPotion, - ItemID.HeartreachPotion, - ModContent.ItemType(), - ModContent.ItemType() - }; + private int[] PotionLootHoney = new int[] + { + ItemID.LifeforcePotion, + ItemID.RegenerationPotion, + ItemID.ManaRegenerationPotion, + ItemID.HeartreachPotion, + ModContent.ItemType(), + ModContent.ItemType() + }; - private int[] BarLootHoney = new int[] - { - WorldGen.SilverTierOre == TileID.Silver ? ItemID.SilverBar : ItemID.TungstenBar, - WorldGen.GoldTierOre == TileID.Gold ? ItemID.GoldBar : ItemID.PlatinumBar - }; + private int[] BarLootHoney = new int[] + { + WorldGen.SilverTierOre == TileID.Silver ? ItemID.SilverBar : ItemID.TungstenBar, + WorldGen.GoldTierOre == TileID.Gold ? ItemID.GoldBar : ItemID.PlatinumBar + }; - private void FillHoneyChest(int id) - { - Chest chest = Main.chest[id]; - int index = 0; + private void FillHoneyChest(int id) + { + Chest chest = Main.chest[id]; + int index = 0; - //Focus loot - chest.item[index++].SetDefaults(_random.Next(FocusLootHoney)); + //Focus loot + chest.item[index++].SetDefaults(_random.Next(FocusLootHoney)); - //Bars - if (_random.Next(3) <= 1) - { - chest.item[index].SetDefaults(_random.Next(BarLootHoney)); - chest.item[index].SetDefaults(_random.Next(7, 15)); - } - else - { - chest.item[index].SetDefaults(ItemID.GoldCoin); - chest.item[index++].stack = _random.Next(3, 5); // 3 or 4 gold coins - } + //Bars + if (_random.Next(3) <= 1) + { + chest.item[index].SetDefaults(_random.Next(BarLootHoney)); + chest.item[index].SetDefaults(_random.Next(7, 15)); + } + else + { + chest.item[index].SetDefaults(ItemID.GoldCoin); + chest.item[index++].stack = _random.Next(3, 5); // 3 or 4 gold coins + } - //Potion loot - if (_random.Next(2) == 0) - { - chest.item[index].SetDefaults(_random.Next(PotionLootHoney)); - chest.item[index++].stack = _random.Next(1, 4); - } - else //Healing potion - { - chest.item[index].SetDefaults(ItemID.BottledHoney); - chest.item[index++].stack = _random.Next(3, 7); - } + //Potion loot + if (_random.Next(2) == 0) + { + chest.item[index].SetDefaults(_random.Next(PotionLootHoney)); + chest.item[index++].stack = _random.Next(1, 4); + } + else //Healing potion + { + chest.item[index].SetDefaults(ItemID.BottledHoney); + chest.item[index++].stack = _random.Next(3, 7); + } - //Weaponry - if (_random.Next(2) == 0) - { - chest.item[index].SetDefaults(ItemID.Stinger); - chest.item[index++].stack = _random.Next(4, 6); - } - else - { - chest.item[index].SetDefaults(ItemID.JungleSpores); - chest.item[index++].stack = _random.Next(3, 5); - } + //Weaponry + if (_random.Next(2) == 0) + { + chest.item[index].SetDefaults(ItemID.Stinger); + chest.item[index++].stack = _random.Next(4, 6); + } + else + { + chest.item[index].SetDefaults(ItemID.JungleSpores); + chest.item[index++].stack = _random.Next(3, 5); + } - //Recall potion - if (_random.Next(2) == 0) - { - chest.item[index].SetDefaults(ItemID.RecallPotion); - chest.item[index++].stack = _random.Next(1, 4); - } - else //glowsticks - { - chest.item[index].SetDefaults(ItemID.YellowTorch); - chest.item[index++].stack = _random.Next(18, 36); - } + //Recall potion + if (_random.Next(2) == 0) + { + chest.item[index].SetDefaults(ItemID.RecallPotion); + chest.item[index++].stack = _random.Next(1, 4); + } + else //glowsticks + { + chest.item[index].SetDefaults(ItemID.YellowTorch); + chest.item[index++].stack = _random.Next(18, 36); + } - } - } + } + } } diff --git a/World/Planets/Planetoid.cs b/World/Planets/Planetoid.cs index c92510ff74..d0a1ac8823 100644 --- a/World/Planets/Planetoid.cs +++ b/World/Planets/Planetoid.cs @@ -75,7 +75,7 @@ namespace CalamityMod.World.Planets } public static bool InvalidSkyPlacementArea(Rectangle area) - { + { Mod varia = CalamityMod.Instance.varia; for (int i = area.Left; i < area.Right; i++) { diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index 271e4536ee..388ae8fe23 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -196,11 +196,11 @@ namespace CalamityMod.World private static void PlaceClusters(ClusterGroup clusters, Point start, Vector2 scale) //Places tile/wall clusters in Sunken Sea area { - int num = (int)(scale.X * (float)clusters.Width); - int num2 = (int)(scale.Y * (float)clusters.Height); - Vector2 value = new Vector2((float)num, (float)num2); - Vector2 value2 = new Vector2((float)clusters.Width, (float)clusters.Height); - for (int i = -20; i < num + 20; i++) + int num = (int)(scale.X * (float)clusters.Width); + int num2 = (int)(scale.Y * (float)clusters.Height); + Vector2 value = new Vector2((float)num, (float)num2); + Vector2 value2 = new Vector2((float)clusters.Width, (float)clusters.Height); + for (int i = -20; i < num + 20; i++) { for (int j = -20; j < num2 + 20; j++) { @@ -209,9 +209,9 @@ namespace CalamityMod.World float num5 = 0f; int num6 = i + start.X; int num7 = j + start.Y; - Vector2 vector = new Vector2((float)i, (float)j) / value * value2; - float num8 = (new Vector2((float)i, (float)j) / value * 2f - Vector2.One).Length(); - for (int k = 0; k < clusters.Count; k++) + Vector2 vector = new Vector2((float)i, (float)j) / value * value2; + float num8 = (new Vector2((float)i, (float)j) / value * 2f - Vector2.One).Length(); + for (int k = 0; k < clusters.Count; k++) { Cluster cluster = clusters[k]; if (Math.Abs(cluster[0].Position.X - vector.X) <= 10f && Math.Abs(cluster[0].Position.Y - vector.Y) <= 10f) @@ -303,18 +303,18 @@ namespace CalamityMod.World private static void AddTileVariance(ClusterGroup clusters, Point start, Vector2 scale, float size) /*Adds tile variation to the generated tile clusters and generates open areas with sea prism ore; Generates sea prism crystals on prism ore and occasionally on navystone*/ { - int num = (int)(scale.X * (float)clusters.Width); - int num2 = (int)(scale.Y * (float)clusters.Height); - bool genCentalHole = true; + int num = (int)(scale.X * (float)clusters.Width); + int num2 = (int)(scale.Y * (float)clusters.Height); + bool genCentalHole = true; Rectangle rectangle = default; - int radius = (int)(((float)WorldGen.genRand.Next(24, 28)) * size); //Radius of the generated hole - int diameter = radius * 2; + int radius = (int)(((float)WorldGen.genRand.Next(24, 28)) * size); //Radius of the generated hole + int diameter = radius * 2; Point point = new Point(WorldGen.UndergroundDesertLocation.Left + (WorldGen.UndergroundDesertLocation.Width / 2), WorldGen.UndergroundDesertLocation.Bottom + (WorldGen.UndergroundDesertLocation.Height / 3)); //Around the center of the Sunken Sea area ShapeData holeShape = new ShapeData(); - float outerRadiusPercentage = (float)((double)WorldGen.genRand.Next(40, 56) * 0.01); //Small radius for ore patch to fit inside holes - int sunkenSeaBottom = WorldGen.UndergroundDesertLocation.Bottom + (int)((double)WorldGen.UndergroundDesertLocation.Height * 0.7); - int smallHoles = 0; + float outerRadiusPercentage = (float)((double)WorldGen.genRand.Next(40, 56) * 0.01); //Small radius for ore patch to fit inside holes + int sunkenSeaBottom = WorldGen.UndergroundDesertLocation.Bottom + (int)((double)WorldGen.UndergroundDesertLocation.Height * 0.7); + int smallHoles = 0; int amt = (int)(4f * size); //Scale amount of holes with world size for (int i = -20; i < num + 20; i++) { @@ -381,8 +381,8 @@ namespace CalamityMod.World if (smallHoles < amt && WorldGen.genRand.Next(3) == 0 && !rectangle.Contains(point)) { smallHoles++; - int radiusSmall = (int)(((float)WorldGen.genRand.Next(8, 11)) * size); - WorldUtils.Gen(point, new Shapes.Circle(radiusSmall), Actions.Chain(new GenAction[] + int radiusSmall = (int)(((float)WorldGen.genRand.Next(8, 11)) * size); + WorldUtils.Gen(point, new Shapes.Circle(radiusSmall), Actions.Chain(new GenAction[] { new Modifiers.Blotches(2, 0.45).Output(holeShape), new Actions.ClearTile(true), @@ -397,8 +397,8 @@ namespace CalamityMod.World new Actions.SetFrames(true) })); - outerRadiusPercentage = (float)((double)WorldGen.genRand.Next(65, 81) * 0.01); - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radiusSmall * outerRadiusPercentage)), Actions.Chain(new GenAction[] //Smallest is 4 + outerRadiusPercentage = (float)((double)WorldGen.genRand.Next(65, 81) * 0.01); + WorldUtils.Gen(point, new Shapes.Circle((int)((float)radiusSmall * outerRadiusPercentage)), Actions.Chain(new GenAction[] //Smallest is 4 { new Modifiers.Blotches(2, 0.3).Output(holeShape), new Actions.SetTile((ushort)ModContent.TileType(), true) //Place outer shell @@ -501,12 +501,12 @@ namespace CalamityMod.World tile3.type = (ushort)ModContent.TileType(); if (Main.tile[num5 - 1, num6].type == ModContent.TileType()) { - Main.tile[num5 - 1, num6].frameY = (short)(2 * 18); - } + Main.tile[num5 - 1, num6].frameY = (short)(2 * 18); + } else if (Main.tile[num5 + 1, num6].type == ModContent.TileType()) { - Main.tile[num5 + 1, num6].frameY = (short)(3 * 18); - } + Main.tile[num5 + 1, num6].frameY = (short)(3 * 18); + } tile3.frameX = (short)(WorldGen.genRand.Next(18) * 18); tile3.active(true); } @@ -519,12 +519,12 @@ namespace CalamityMod.World tile3.type = (ushort)ModContent.TileType(); if (Main.tile[num5, num6 - 1].type == ModContent.TileType()) { - Main.tile[num5, num6 - 1].frameY = (short)(0 * 18); - } + Main.tile[num5, num6 - 1].frameY = (short)(0 * 18); + } else if (Main.tile[num5, num6 + 1].type == ModContent.TileType()) { - Main.tile[num5, num6 + 1].frameY = (short)(1 * 18); - } + Main.tile[num5, num6 + 1].frameY = (short)(1 * 18); + } tile3.frameX = (short)(WorldGen.genRand.Next(18) * 18); tile3.active(true); } diff --git a/World/UndergroundShrines.cs b/World/UndergroundShrines.cs index 933ae2dbaa..992bdefc14 100644 --- a/World/UndergroundShrines.cs +++ b/World/UndergroundShrines.cs @@ -184,9 +184,9 @@ namespace CalamityMod.World int genLimit = x / 2; int generateBack = genLimit - 80; //Small = 2020 int generateForward = genLimit + 80; //Small = 2180 - double shrineChance = 100E-05; + double shrineChance = 100E-05; - for (int k = 0; k < (int)(x * y * shrineChance); k++) //Surface Shrine + for (int k = 0; k < (int)(x * y * shrineChance); k++) //Surface Shrine { int tilesX = WorldGen.genRand.Next((int)(x * 0.35), generateBack); int tilesX2 = WorldGen.genRand.Next(generateForward, (int)(x * 0.65)); diff --git a/World/WorldEvilIsland.cs b/World/WorldEvilIsland.cs index be6644f3f5..e9f8ff73d3 100644 --- a/World/WorldEvilIsland.cs +++ b/World/WorldEvilIsland.cs @@ -9,7 +9,7 @@ using Terraria.World.Generation; namespace CalamityMod.World { - public class WorldEvilIsland + public class WorldEvilIsland { public static void PlaceEvilIsland() { diff --git a/World/WorldUpdateMiscEffects.cs b/World/WorldUpdateMiscEffects.cs index 5d000c3b1e..343aee649b 100644 --- a/World/WorldUpdateMiscEffects.cs +++ b/World/WorldUpdateMiscEffects.cs @@ -22,12 +22,12 @@ using Terraria.ModLoader; namespace CalamityMod.World { - public partial class CalamityWorld : ModWorld + public partial class CalamityWorld : ModWorld { public override void PostUpdate() { - // Reset this int because it causes bugs with other mods if you delete Dr. Draedon through abnormal means - if (!NPC.AnyNPCs(ModContent.NPCType())) + // Reset this int because it causes bugs with other mods if you delete Dr. Draedon through abnormal means + if (!NPC.AnyNPCs(ModContent.NPCType())) CalamityGlobalNPC.draedon = -1; // Reset the exo mech to summon if Draedon is absent. @@ -400,8 +400,8 @@ namespace CalamityMod.World spawnRate *= 1.43D; if (Main.peaceCandles > 0) spawnRate *= 1.25D; - if (player.HasItem(ModContent.ItemType())) - spawnRate *= 5D; + if (player.HasItem(ModContent.ItemType())) + spawnRate *= 5D; int chance = (int)spawnRate; if (Main.rand.NextBool(chance))